vue3-core/packages/runtime-vapor/src/component.ts

36 lines
812 B
TypeScript
Raw Normal View History

import { EffectScope } from '@vue/reactivity'
import { Block, BlockFn } from './render'
export interface ComponentInternalInstance {
uid: number
container: ParentNode
block: Block | null
scope: EffectScope
component: BlockFn
isMounted: boolean
// TODO: registory of provides, appContext, lifecycles, ...
}
let uid = 0
export const createComponentInstance = (
2023-12-01 01:28:16 +08:00
component: BlockFn,
): ComponentInternalInstance => {
const instance: ComponentInternalInstance = {
uid: uid++,
block: null,
container: null!, // set on mount
scope: new EffectScope(true /* detached */)!,
component,
2023-12-01 01:28:16 +08:00
isMounted: false,
// TODO: registory of provides, appContext, lifecycles, ...
}
return instance
}
// FIXME: duplicated with runtime-core
export type Data = Record<string, unknown>