Skip to content

Commit

Permalink
further progress
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusBorg committed Nov 1, 2022
1 parent eeae6ef commit 91d6b03
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ coverage
*.njsproj
*.sln
*.sw?

tsconfig.app.tsbuildinfo
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vue-comixable",
"description": "",
"keywords": ["Vue", "composables", "mixins", "Vue plugin", "migration"],
"version": "0.0.0",
"version": "0.1.0",
"author": {
"name": "Thorsten Lünborg",
"url": "https://github.com/linusborg"
Expand All @@ -23,11 +23,9 @@
},
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
"preview": "vite preview",
"test:unit": "vitest --environment jsdom --root src/",
"build-only": "vite build",
"build": "vite build && tsc --declaration --emitDeclarationOnly -p tsconfig.app.json --outDir dist",
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
"test:unit": "vitest --environment jsdom --root src/",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
10 changes: 7 additions & 3 deletions src/createComposable.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* Code in this file is based on the Options API implementation in Vue 3's codebase:
* https://github.com/vuejs/core/blob/f67bb500b6071bc0e55a89709a495a27da73badd/packages/runtime-core/src/componentOptions.ts
*/
import {
onBeforeMount,
onMounted,
Expand Down Expand Up @@ -45,17 +49,15 @@ export function createComposableFromMixin<
props,
emits,

// mixins,

data: dataFn,
computed: computedOptions,
methods,

watch,

provide: provideOptions,
inject: injectOptions,

// Lifecylce Hooks
created,
beforeCreate,
beforeMount,
Expand All @@ -69,6 +71,8 @@ export function createComposableFromMixin<
renderTracked,
renderTriggered,
errorCaptured,

// mixins,
} = mixin

const composable = () => {
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/inject.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* @legal
* This code is largely based on code from the Vue 3 codebase:
* https://github.com/vuejs/core/blob/f67bb500b6071bc0e55a89709a495a27da73badd/packages/runtime-core/src/componentOptions.ts#L823-L876
* https://github.com/vuejs/core/blob/f67bb500b6071bc0e55a89709a495a27da73badd/packages/runtime-core/src/componentOptions.ts#L1073-L1084
*/

import { inject, isRef, type Ref } from 'vue'
import type { ComponentInjectOptions, ObjectInjectOptions } from './types'
import { isArray, isObject } from './utils'
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* @legal
* Various types in this file are based on code from the Vue 3 codebase:
* https://github.com/vuejs/core/blob/f67bb500b6071bc0e55a89709a495a27da73badd/packages/runtime-core/src/componentOptions.ts
*/

// TODO: replace with ComponentOptions or something
import type {
ComponentProvideOptions,
Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export const isArray = Array.isArray
export const isObject = (val: unknown): val is Record<any, any> =>
val !== null && typeof val === 'object'

/**
* @legal
* taken from the Vue 3 Codebase, slightly adjusted:
* https://github.com/vuejs/core/blob/f67bb500b6071bc0e55a89709a495a27da73badd/packages/runtime-core/src/componentOptions.ts#L878-L890
*/
export function callHook(
hook: Function,
instance: ComponentInternalInstance,
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"include": ["src/env.d.tsd.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"outDir": "dist",
"allowJs": true,
"baseUrl": ".",
"rootDir": "src",
"paths": {
"@/*": ["./src/*"]
}
Expand Down

0 comments on commit 91d6b03

Please sign in to comment.