2023-11-30 02:11:21 +08:00
|
|
|
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,
|
2023-11-30 02:11:21 +08:00
|
|
|
): 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,
|
2023-11-30 02:11:21 +08:00
|
|
|
// TODO: registory of provides, appContext, lifecycles, ...
|
|
|
|
}
|
|
|
|
return instance
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: duplicated with runtime-core
|
|
|
|
export type Data = Record<string, unknown>
|