@small-vue/runtime-core
Version:
简版vue3 runtime-core
67 lines (56 loc) • 2.08 kB
TypeScript
export { toDisplayString } from '@small-vue/shared';
export * from '@small-vue/reactivity';
interface App {
mount(rootContainer: any): void;
}
type CreateAppFunction = (rootComponent: any) => App;
interface ComponentInstance {
vnode: VNode;
setupStatus: any;
proxy: {
[key: string]: any;
};
emit: (event: string, ...params: any[]) => void;
provides: {
[key: string]: any;
};
parent: ComponentInstance;
subTree: any;
update: any;
}
declare function getCurrentInstance(): ComponentInstance;
declare function registerRuntimeCompiler(_compiler: any): void;
interface VNode {
type: any;
props?: {
[key: string]: any;
};
children?: VNode[] | string | Slots;
el?: any;
component?: ComponentInstance;
}
interface Slots {
[key: string]: {
(props: any): VNode[];
};
}
declare function createVNode(type: VNode["type"], props?: VNode["props"], children?: VNode["children"]): VNode;
declare function createTextVNode(text: string): VNode;
declare function createFragmentVNode(children: VNode[]): VNode;
declare function renderSlot(slots: Slots, name: string, props: any): VNode;
declare function withCtx(fn: any, _ctx: any): (props: any) => any;
declare function provide(key: any, value: any): void;
declare function inject(key: string, defaultValue?: any): any;
interface RendererOptions {
createElement(type: string): any;
patchProp(el: any, key: any, prevVal: any, nextVal: any): void;
insert(el: any, parent: any, anchor?: any): void;
remove(el: any): void;
setElementText(el: any, text: string): void;
}
declare function createRenderer(options: RendererOptions): {
createApp: CreateAppFunction;
};
declare function getSequence(arr: number[]): number[];
declare function nextTick(fn?: any): Promise<void>;
export { type CreateAppFunction, createVNode as createElementVNode, createFragmentVNode, createRenderer, createTextVNode, createVNode, getCurrentInstance, getSequence, inject, nextTick, provide, registerRuntimeCompiler, renderSlot, withCtx };