weifuwu 0.83.0 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -51
- package/dist/components/ChatInput/ChatInput.d.ts +2 -2
- package/dist/components/Confirm/Confirm.d.ts +2 -2
- package/dist/components/Notification/Notification.d.ts +0 -2
- package/dist/components/Toast/Toast.d.ts +0 -2
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +12 -12
- package/dist/components/style.css +17 -0
- package/dist/index.js +2408 -341
- package/dist/ui-dom/Confirm.d.ts +1 -1
- package/dist/ui-dom/Notification.d.ts +1 -1
- package/dist/ui-dom/Toast.d.ts +1 -1
- package/dist/ui-dom/hooks/index.d.ts +0 -1
- package/dist/ui-dom/hooks/popup.d.ts +2 -0
- package/dist/ui-dom/hooks/stable.d.ts +2 -6
- package/dist/ui-dom/index.d.ts +24 -19
- package/dist/ui-dom/index.js +40 -22
- package/dist/ui-dom/jsx-runtime.js +1 -1
- package/dist/ui-dom/middleware/ws.d.ts +8 -0
- package/dist/ui-dom/popup-tracker.d.ts +1 -1
- package/dist/ui-dom/testing.d.ts +3 -9
- package/dist/ui-dom/testing.js +7 -1
- package/dist/ui-dom/types.d.ts +7 -37
- package/dist/ui-dom/vdom3/README.d.ts +6 -3
- package/dist/ui-dom/vdom3/app.d.ts +20 -0
- package/dist/ui-dom/vdom3/audit.d.ts +13 -0
- package/dist/ui-dom/vdom3/build.d.ts +7 -3
- package/dist/ui-dom/vdom3/commands.d.ts +13 -3
- package/dist/ui-dom/vdom3/comp-index.d.ts +18 -0
- package/dist/ui-dom/vdom3/delegate.d.ts +48 -0
- package/dist/ui-dom/vdom3/events.d.ts +8 -2
- package/dist/ui-dom/vdom3/index.d.ts +5 -3
- package/dist/ui-dom/vdom3/jsx.d.ts +26 -4
- package/dist/ui-dom/vdom3/record.d.ts +3 -0
- package/dist/ui-dom/vdom3/render.d.ts +19 -6
- package/dist/ui-dom/vdom3/replay.d.ts +11 -8
- package/dist/ui-dom/vdom3/root.d.ts +3 -7
- package/dist/ui-dom/vdom3/types.d.ts +128 -70
- package/dist/ui-dom/vdom3/ui.d.ts +3 -30
- package/dist/ui-dom/vdom3.js +12 -10
- package/dist/ui-dom/vnode.d.ts +9 -89
- package/docs/compat-three-library.md +1 -1
- package/docs/components-map.md +1 -1
- package/docs/frontend-middleware.md +59 -53
- package/docs/frontend-ui-dom.md +115 -132
- package/docs/frontend.md +28 -24
- package/docs/realtime.md +21 -21
- package/package.json +1 -1
- package/dist/test/client/setup.d.ts +0 -12
- package/dist/ui-dom/context.d.ts +0 -32
- package/dist/ui-dom/hooks/test/hooks.test.d.ts +0 -1
- package/dist/ui-dom/middleware/serve.d.ts +0 -27
- package/dist/ui-dom/router.d.ts +0 -73
- package/dist/ui-dom/vdom2/audit.d.ts +0 -28
- package/dist/ui-dom/vdom2/build.d.ts +0 -53
- package/dist/ui-dom/vdom2/ctx.d.ts +0 -32
- package/dist/ui-dom/vdom2/dom-trace.d.ts +0 -4
- package/dist/ui-dom/vdom2/events.d.ts +0 -65
- package/dist/ui-dom/vdom2/hydrate.d.ts +0 -21
- package/dist/ui-dom/vdom2/index.d.ts +0 -13
- package/dist/ui-dom/vdom2/kind.d.ts +0 -44
- package/dist/ui-dom/vdom2/lifecycle.d.ts +0 -54
- package/dist/ui-dom/vdom2/mount.d.ts +0 -77
- package/dist/ui-dom/vdom2/patch.d.ts +0 -116
- package/dist/ui-dom/vdom2/registry.d.ts +0 -27
- package/dist/ui-dom/vdom2/render.d.ts +0 -21
- package/dist/ui-dom/vdom2/route.d.ts +0 -29
- package/dist/ui-dom/vdom2/ssr.d.ts +0 -32
- package/dist/ui-dom/vdom2/trace.d.ts +0 -62
- package/dist/ui-dom/vdom2/transform.d.ts +0 -76
- package/dist/ui-dom/vdom2/transitions.d.ts +0 -24
- package/dist/ui-dom/vdom2/x2html.d.ts +0 -26
- package/dist/ui-dom/vdom3/compat.d.ts +0 -20
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom/diff — 同步 patch(阶段 2)
|
|
3
|
-
*
|
|
4
|
-
* **不变量:diff 只处理已构建树**——组件 vnode 必已 `_render`/`_child`(buildVNode 预构建)。
|
|
5
|
-
* 遇未构建组件 → throw(开发期暴露;生产路径 renderByIds/导航都先 buildVNode await)。
|
|
6
|
-
* 这是第 1 代死循环的根治:diff 永不调用组件工厂、无 resolve 回调、无补全循环。
|
|
7
|
-
*
|
|
8
|
-
* 三态 skip:props 同 + 无 dirty + ctx 版本同 → 复用旧 _child(renderFn 不重跑)。
|
|
9
|
-
*/
|
|
10
|
-
import type { VNode, VNodeChild } from '../vnode.ts';
|
|
11
|
-
import { arrayChildren } from '../vnode.ts';
|
|
12
|
-
export { arrayChildren };
|
|
13
|
-
import { type Registry } from './registry.ts';
|
|
14
|
-
/** 组件 vnode 从树中移除:ref(null) 递归 + 卸载钩子(cleanupComponent) */
|
|
15
|
-
export declare function disposeComponent(vnode: VNode, registry?: Registry): void;
|
|
16
|
-
import { type PropChannel } from './transform.ts';
|
|
17
|
-
import { type KeyMode, type VKind } from './kind.ts';
|
|
18
|
-
/** 重置 audit 告警去重(测试隔离——node --test 同进程共享 module 状态) */
|
|
19
|
-
export declare function __resetAuditWarnings(): void;
|
|
20
|
-
/**
|
|
21
|
-
* 移除旧输出的全部 DOM(Fragment 展开多节点 + Portal 容器)并做组件/ref 清理。
|
|
22
|
-
* @returns 移除后应插入新节点的位置(范围后兄弟;null = append 末尾)
|
|
23
|
-
* 真实 bug:Frag→div 类型切换只 replaceChild 锚点 → Fragment 其余节点(holes/标记/数组项)残留
|
|
24
|
-
* (frag-native-switch trace 定位 2026-12;同逻辑覆盖 Frag→null/Portal→null)
|
|
25
|
-
*
|
|
26
|
-
* 分派:REMOVERS[classifyKind(oldInput)] 查表(kind → 移除行为——无 if/else 类型链)
|
|
27
|
-
*/
|
|
28
|
-
export declare function removeOldOutput(oldInput: VNodeChild, oldNode: Node | null, parent: Node, ctx: PatchCtx): Node | null;
|
|
29
|
-
/** 移除状态机表(kind → 移除行为——单节点/范围/远程容器三类输出范围) */
|
|
30
|
-
export declare const REMOVERS: Record<VKind, (oldInput: VNodeChild, oldNode: Node | null, parent: Node, ctx: PatchCtx) => Node | null>;
|
|
31
|
-
export interface PatchCtx {
|
|
32
|
-
browser: any;
|
|
33
|
-
registry: import('./registry.ts').Registry;
|
|
34
|
-
/** 当前 ctx 版本号(三态 skip 版本比较:组件 _ctxVersion !== 当前版本 → 不 skip,
|
|
35
|
-
* 强制重渲染——bumpCtxVersion 递增后所有组件重跑 renderFn,如 i18n 切换语言) */
|
|
36
|
-
ctxVersion?: number;
|
|
37
|
-
/** force:跳过三态 skip(mountRoot.rerender 全量重跑用) */
|
|
38
|
-
force?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* patchValue — 同步 diff 单一节点。
|
|
42
|
-
* @returns newInput 的实际 DOM(null = 无 DOM)
|
|
43
|
-
*/
|
|
44
|
-
export declare function patchValue(parent: Node, oldNode: Node | null, oldInput: VNodeChild, newInput: VNodeChild, ctx: PatchCtx): Node | null;
|
|
45
|
-
/** 属性 diff 状态机表(通道 → 更新/移除行为——patchProps 查表分派):
|
|
46
|
-
* 每个处理器自含「移除」(nv==null/false)与「更新」两态——值判断保留在处理器内。
|
|
47
|
-
* 通道分类单一源 = propChannelOf(transform.ts——与 setProp 共用,禁止各路径各自判定) */
|
|
48
|
-
export declare const PROP_PATCHERS: Record<PropChannel, (el: Element, key: string, ov: any, nv: any) => void>;
|
|
49
|
-
export declare function patchProps(el: Element, oldProps: Record<string, any>, newProps: Record<string, any>): void;
|
|
50
|
-
/**
|
|
51
|
-
* patchChildren — 数组 diff。
|
|
52
|
-
* @returns 每个新子项的 DOM 范围(Fragment 展开对齐)
|
|
53
|
-
*/
|
|
54
|
-
/** 多节点配对 diff(Fragment/数组项统一——2026-12 array2array):
|
|
55
|
-
* 展开 children(Fragment 项取 props.children;数组项传自身)→ patchChildren 递归。
|
|
56
|
-
* 位置循环多节点分支与 fragToFrag(keyed/顶层入口)共用——多节点 diff 实现单点。
|
|
57
|
-
* oldRange = 标记范围(getOutputRange——start/end + fid 配对) */
|
|
58
|
-
export declare function arrayToArray(parent: Node, oldInput: VNodeChild | null, newInput: VNodeChild | null, ctx: PatchCtx, oldRange: Node[] | null): (Node | null)[];
|
|
59
|
-
export declare function patchChildren(parent: Node, oldInput: VNodeChild | null, newInput: VNodeChild | null, ctx: PatchCtx, oldRange?: Node[] | null, anchorOut?: (Node | null)[]): (Node | null)[];
|
|
60
|
-
/** 位置级 kind 分类(数组上下文——POS 位置转换表分派用):
|
|
61
|
-
* - hole :无渲染值(null/false/undefined/true——占位)
|
|
62
|
-
* - real :单节点值(text/native/comp/portal)
|
|
63
|
-
* - multi:多节点输出(数组项 = 隐式 Fragment / 显式 Fragment) */
|
|
64
|
-
type PosKind = 'hole' | 'real' | 'multi';
|
|
65
|
-
/** 位置转换上下文(数组 diff 每位置——POS 表分派参数) */
|
|
66
|
-
interface PosState {
|
|
67
|
-
parent: Node;
|
|
68
|
-
oldC: VNodeChild | null;
|
|
69
|
-
newC: VNodeChild;
|
|
70
|
-
oldNode: Node | null;
|
|
71
|
-
i: number;
|
|
72
|
-
oldNodes: (Node | null)[];
|
|
73
|
-
newChildren: VNodeChild[];
|
|
74
|
-
out: (Node | null)[];
|
|
75
|
-
pushA: (n: Node | null) => void;
|
|
76
|
-
ctx: PatchCtx;
|
|
77
|
-
}
|
|
78
|
-
/** 位置级 (oldKind, newKind) 转换状态机表(数组上下文——与 x2y 同构的矩阵分派) */
|
|
79
|
-
export declare const POS: Record<PosKind, Record<PosKind, (s: PosState) => void>>;
|
|
80
|
-
/** keyed 新增项 kind 分类(无 key 匹配的占位/portal/普通项——KEYED_NEW 分派用) */
|
|
81
|
-
type KeyedNewKind = 'hole' | 'portal' | 'real';
|
|
82
|
-
/** keyed 新增上下文(KEYED_NEW 分派参数) */
|
|
83
|
-
interface KeyedNewState {
|
|
84
|
-
parent: Node;
|
|
85
|
-
oldChildren: VNodeChild[];
|
|
86
|
-
newChildren: VNodeChild[];
|
|
87
|
-
oldNodes: (Node | null)[];
|
|
88
|
-
ctx: PatchCtx;
|
|
89
|
-
out: (Node | null)[];
|
|
90
|
-
pushA: (n: Node | null) => void;
|
|
91
|
-
arrEnd: Node | null;
|
|
92
|
-
c: VNodeChild;
|
|
93
|
-
i: number;
|
|
94
|
-
}
|
|
95
|
-
/** keyed 新增分派状态机表(kind → 处理——无 if/else 类型链) */
|
|
96
|
-
export declare const KEYED_NEW: Record<KeyedNewKind, (s: KeyedNewState, lastRef: {
|
|
97
|
-
current: Node | null;
|
|
98
|
-
}) => void>;
|
|
99
|
-
/** 数组 diff 上下文(unkeyed/keyed 共享——状态机分派参数) */
|
|
100
|
-
export interface KeyDiffState {
|
|
101
|
-
parent: Node;
|
|
102
|
-
oldChildren: VNodeChild[];
|
|
103
|
-
newChildren: VNodeChild[];
|
|
104
|
-
oldNodes: (Node | null)[];
|
|
105
|
-
ctx: PatchCtx;
|
|
106
|
-
arrEnd: Node | null;
|
|
107
|
-
anchorOut?: (Node | null)[];
|
|
108
|
-
}
|
|
109
|
-
/** mixed → keyed 状态转换:无 key 项分配 pos:{i}(位置身份显式化——防 keyed 分支
|
|
110
|
-
* 「移除旧+新建」重建固定结构;portal 的 portalKey 不算用户 keyed(C1)——不分配) */
|
|
111
|
-
export declare function prepPos(children: VNodeChild[]): void;
|
|
112
|
-
/** key diff 策略状态机:KeyMode → 实现(查表分派——与 x2y 转换状态机同构)
|
|
113
|
-
* - unkeyed:位置身份——按位置 patch(不移动 DOM)
|
|
114
|
-
* - keyed :内容身份——按 key 匹配(keyMap + 位置校正)
|
|
115
|
-
* - mixed :状态转换 prepPos(无 key 项 → pos:{i})→ 降级 keyed */
|
|
116
|
-
export declare const KEY_DIFFERS: Record<KeyMode, (s: KeyDiffState) => (Node | null)[]>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom/registry — 组件实例注册表(id → vnode)+ 卸载钩子
|
|
3
|
-
*
|
|
4
|
-
* 组件 id:`_wf_0` 自动分配(精准刷新锚点)+ `_customId`(ctx.ui.selfId 注册)。
|
|
5
|
-
* 卸载钩子:hooks(usePopup/useMedia 等)注册清理回调,组件卸载时执行。
|
|
6
|
-
*/
|
|
7
|
-
import type { VNode } from '../vnode.ts';
|
|
8
|
-
export interface Registry {
|
|
9
|
-
idRegistry: Map<string, VNode>;
|
|
10
|
-
/** 卸载钩子(按组件 id 匹配——组件卸载时执行对应清理) */
|
|
11
|
-
unmountHooks: Array<(id: string) => void>;
|
|
12
|
-
nextId(): string;
|
|
13
|
-
}
|
|
14
|
-
export declare function createRegistry(): Registry;
|
|
15
|
-
/** 给组件 vnode 分配 id(注册表写入) */
|
|
16
|
-
export declare function ensureId(reg: Registry, vnode: VNode): string;
|
|
17
|
-
/** 组件卸载回调注册(hooks 清理)——返回退订函数 */
|
|
18
|
-
export declare function onComponentUnmountFor(reg: Registry, hook: (id: string) => void): () => void;
|
|
19
|
-
/** 组件卸载:执行匹配的清理钩子 + 移除注册(vdom 渲染器卸载组件时调用) */
|
|
20
|
-
export declare function cleanupComponent(reg: Registry, id: string): void;
|
|
21
|
-
/** ref 调用错误隔离(用户 ref 抛错不中断渲染/清理管线) */
|
|
22
|
-
export declare function safeCallRef(ref: Function, arg: any, phase: 'mount' | 'cleanup', name?: string): void;
|
|
23
|
-
/**
|
|
24
|
-
* 递归 ref 清理 + 组件卸载(组件 vnode 从树中移除时调用):
|
|
25
|
-
* idRegistry 注销 + 卸载钩子 + _child/props.children 递归 + ref(null) + Portal 容器移除
|
|
26
|
-
*/
|
|
27
|
-
export declare function callRefCleanupFor(input: any, reg: Registry): void;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom2 render — vnode → DOM(客户端渲染)
|
|
3
|
-
*
|
|
4
|
-
* 与 vdom1 同构的渲染语义,但组织方式为**类型分派表**(vdom2 方案):
|
|
5
|
-
* RENDERERS[classifyKind(v)] 查表调用——每类一个渲染函数,无 if-else 类型链。
|
|
6
|
-
* 渲染是「创建目标」——按目标类型分派(与 patch 的「源类型驱动 x2y」互补)。
|
|
7
|
-
*
|
|
8
|
-
* 输出范围协议(与 kind.ts getOutputRange 一致):
|
|
9
|
-
* - Fragment:_childNodes(输出节点数组)
|
|
10
|
-
* - 组件:_refNode = 输出范围首节点(非 DocumentFragment——展开后失效)
|
|
11
|
-
* - 数组项:fragment-start/end 标记(DOM 持久化)
|
|
12
|
-
*/
|
|
13
|
-
import type { VNodeChild } from '../vnode.ts';
|
|
14
|
-
import type { BrowserEnv } from '../types.ts';
|
|
15
|
-
/** 创建占位节点(数组上下文的无渲染值 → 注释节点,childNodes 与数组同构——规则表 §1) */
|
|
16
|
-
export declare function createHole(browser: BrowserEnv, v: unknown): Node | null;
|
|
17
|
-
/** 递归渲染(同步——组件必须已构建;首帧/新增路径) */
|
|
18
|
-
export declare function renderValue(v: VNodeChild, ctx: any, browser?: BrowserEnv, key?: string | null, id?: string | null, fid?: string | null): Node | null;
|
|
19
|
-
/** 渲染函数表(按 classifyKind 分派——每类一个实现,无 if-else 类型链) */
|
|
20
|
-
export declare const RENDERERS: Record<string, (v: VNodeChild, ctx: any, b: BrowserEnv, key?: string | null, id?: string | null, fid?: string | null) => Node | null>;
|
|
21
|
-
export declare function renderTree(v: VNodeChild, ctx: any, browser?: BrowserEnv): Node | null;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom2 route — 路由生命周期状态机(2026-12,design/vdom-lifecycle-state-machines.md Phase 1)
|
|
3
|
-
*
|
|
4
|
-
* 四状态机架构的第一层(页面级·宏观):导航状态统一管理——
|
|
5
|
-
* idle → navigating(旧树卸载/新树构建中)→ settled(新树就绪)。
|
|
6
|
-
*
|
|
7
|
-
* 与节点状态机(lifecycle.ts)的协同:NAVIGATE_START 触发旧树 DISPOSE + 新树 BUILD;
|
|
8
|
-
* NAVIGATE_DONE 表示整条链路(build → diff → render)完成。
|
|
9
|
-
*
|
|
10
|
-
* 统一架构模式:状态 + 事件 + 转换表 + 查表分派(无 if/else 分派链)。
|
|
11
|
-
*/
|
|
12
|
-
/** 路由生命周期状态 */
|
|
13
|
-
export type RouteLifecycle = 'idle' | 'navigating' | 'settled';
|
|
14
|
-
/** 路由事件(导航触发点) */
|
|
15
|
-
export type RouteEvent = 'NAVIGATE_START' | 'NAVIGATE_DONE' | 'NAVIGATE_ERROR';
|
|
16
|
-
/** 路由生命周期协调器(每 app 实例一个——serve.ts 接入) */
|
|
17
|
-
export interface RouteController {
|
|
18
|
-
state: RouteLifecycle;
|
|
19
|
-
/** 导航开始(renderPath 入口):旧树卸载 + 新树构建起点 */
|
|
20
|
-
navigateStart(path: string): void;
|
|
21
|
-
/** 导航完成(build + diff + render 全部落地) */
|
|
22
|
-
navigateDone(path: string): void;
|
|
23
|
-
/** 导航失败(router.execute 抛错——回退 idle) */
|
|
24
|
-
navigateError(path: string, err: unknown): void;
|
|
25
|
-
}
|
|
26
|
-
/** 创建路由生命周期协调器(查表分派——非法转换 emit/trace warn 不静默) */
|
|
27
|
-
export declare function createRouteController(): RouteController;
|
|
28
|
-
/** 重置(测试/清理用) */
|
|
29
|
-
export declare function __resetRouteState(): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom2/ssr — 服务端渲染(基于 x2html——与客户端 renderValue 同一类型遍历)
|
|
3
|
-
*
|
|
4
|
-
* ssrToString:组件 → HTML 片段(工厂 + renderFn 现场执行——SSR 无预构建)
|
|
5
|
-
* serializeData:__DATA__ 种子(hydration 同步命中)
|
|
6
|
-
* ssrPage:完整页面(路由 + 数据 + HTML + 种子)
|
|
7
|
-
*/
|
|
8
|
-
import type { Component } from '../vnode.ts';
|
|
9
|
-
import { type VdomCtx } from './ctx.ts';
|
|
10
|
-
/** __DATA__ 序列化(hydration 种子——< 转义防注入) */
|
|
11
|
-
export declare function serializeData(data: Map<string, unknown>): string;
|
|
12
|
-
/** SSR ctx:ui shim(hooks no-op)+ ctx.data(预取写入 dataStore) */
|
|
13
|
-
export declare function createSsrContext(serverCtx: Record<string, unknown>, dataStore: Map<string, unknown>): VdomCtx;
|
|
14
|
-
/** SSR 渲染组件 → HTML 片段(组件现场执行工厂 + renderFn) */
|
|
15
|
-
export declare function ssrToString(Comp: Component, props: Record<string, any>, serverCtx: any, opts?: {
|
|
16
|
-
data?: Map<string, unknown>;
|
|
17
|
-
}): Promise<string>;
|
|
18
|
-
export interface SsrPageResult {
|
|
19
|
-
html: string;
|
|
20
|
-
/** __DATA__ 脚本(hydration 种子) */
|
|
21
|
-
dataScript: string;
|
|
22
|
-
/** 完整 HTML 页面 */
|
|
23
|
-
page: string;
|
|
24
|
-
}
|
|
25
|
-
/** SSR 完整页面(路由 + 数据 + HTML + 种子) */
|
|
26
|
-
export declare function ssrPage(router: any, opts: {
|
|
27
|
-
url: string;
|
|
28
|
-
title?: string;
|
|
29
|
-
lang?: string;
|
|
30
|
-
rootId?: string;
|
|
31
|
-
styles?: string[];
|
|
32
|
-
}): Promise<SsrPageResult>;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom/trace — 结构化调试 trace(阶段级开关 + 渲染会话 traceId)
|
|
3
|
-
*
|
|
4
|
-
* 目的(design 归档):
|
|
5
|
-
* - 一次建立全面 vdom 调试能力:build/render/diff/mount/audit 各阶段独立开关
|
|
6
|
-
* - traceId 关联同一渲染会话(renderByIds/首帧/导航)的全部日志——事故可回放
|
|
7
|
-
* - children 顺序可视化(kidsSeq)——快速定位顺序错乱类 bug(Fragment/数组项)
|
|
8
|
-
*
|
|
9
|
-
* 开启方式(三路,幂等解析):
|
|
10
|
-
* 1. URL query:?vdom_trace=build,render,diff(阶段子集);?vdom_trace=render:trace(阶段+级别);
|
|
11
|
-
* ?vdom_debug=1(兼容旧开关——全开 debug + audit)
|
|
12
|
-
* 2. 全局变量(页面加载前注入):window.__vdom_trace__ = { stages, level }
|
|
13
|
-
* 3. localStorage:localStorage.vdom_trace = 'render:debug'(运行时设置 + reload)
|
|
14
|
-
*
|
|
15
|
-
* 性能:关闭时零开销——trace() 首行 flag 检查;插桩点用 traceEnabled() 前置检查
|
|
16
|
-
* (关闭时连参数求值都跳过)。开启时高频路径(diff 逐位置)默认 trace 级(低于默认 debug)。
|
|
17
|
-
*
|
|
18
|
-
* 与 ../debug.ts(uiLog——递归深度/死循环定位)互补:trace 是阶段结构化日志,
|
|
19
|
-
* uiLog 是深度跟踪——两者独立开关、不冲突。
|
|
20
|
-
*/
|
|
21
|
-
import type { VNodeChild } from '../vnode.ts';
|
|
22
|
-
export type VdomStage = 'mount' | 'build' | 'render' | 'diff' | 'lifecycle' | 'route' | 'audit';
|
|
23
|
-
export type VdomLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
24
|
-
export interface VdomTraceConfig {
|
|
25
|
-
enabled: boolean;
|
|
26
|
-
/** 空 Set = 全阶段开启 */
|
|
27
|
-
stages: Set<VdomStage>;
|
|
28
|
-
/** 最低级别(info 起;debug/trace 明细) */
|
|
29
|
-
level: VdomLevel;
|
|
30
|
-
/** 组件名过滤(只输出含该名称的组件相关日志;null = 不过滤) */
|
|
31
|
-
filter: string | null;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 解析开启配置(幂等——首次调用后缓存)。
|
|
35
|
-
* uiServe 在首帧渲染前调用一次;测试/Node 环境也可手动调用。
|
|
36
|
-
*/
|
|
37
|
-
export declare function initVdomTrace(): VdomTraceConfig;
|
|
38
|
-
/** 插桩点前置检查:阶段开启 + 级别满足(关闭时连参数求值都跳过) */
|
|
39
|
-
export declare function traceEnabled(stage: VdomStage, level?: VdomLevel): boolean;
|
|
40
|
-
/** 输出 trace 日志([vdom:{stage}] {traceId} {msg})
|
|
41
|
-
* 统一事件流:trace = 执行细节摘要通道——内部发射 TRACE 事件(console sink 输出原格式;
|
|
42
|
-
* ring/collect sink 记录——执行细节可追溯/可断言)。
|
|
43
|
-
* gate:trace 开启 或 存在观测 sink(collect/ring)——否则零成本(调用点已有 traceEnabled 前置守卫保证 msg 惰性) */
|
|
44
|
-
export declare function trace(stage: VdomStage, level: VdomLevel, msg: string, ...args: unknown[]): void;
|
|
45
|
-
/** 手动配置(测试/调试用——不受 init 时序/缓存影响) */
|
|
46
|
-
export declare function configureVdomTrace(c: Partial<Omit<VdomTraceConfig, 'enabled'>>): void;
|
|
47
|
-
export declare function nextTraceId(tag?: string): string;
|
|
48
|
-
/** children 顺序摘要:["div#list-simple | false | ARR(2) | str"] */
|
|
49
|
-
export declare function kidsSeq(kids: VNodeChild[] | null, max?: number): string;
|
|
50
|
-
/** 单值摘要(children 项) */
|
|
51
|
-
export declare function vnDesc(v: VNodeChild): string;
|
|
52
|
-
/** DOM 节点摘要 */
|
|
53
|
-
export declare function nodeDesc(n: Node | null): string;
|
|
54
|
-
/** DOM 子节点序列摘要(childNodes 顺序——与 kidsSeq 对照验证顺序一致性) */
|
|
55
|
-
export declare function childNodesSeq(parent: Node | null, max?: number): string;
|
|
56
|
-
/** 递归打印 vnode 树快照:type + id + lifecycle + 深度缩进(组件视角——整页可观测) */
|
|
57
|
-
export declare function dumpTree(vnode: VNodeChild, depth?: number): string[];
|
|
58
|
-
/** 安装全局调试 API(dev/调试——页面加载后可用):
|
|
59
|
-
* __vdom_dump() 全树生命周期快照(root 由调用方注入)
|
|
60
|
-
* __vdom_lc(id?) 生命周期时间线(全组件或单组件)
|
|
61
|
-
* __vdom_events(n?) 统一状态机事件流(最近 N 条——跨状态机关联/追溯) */
|
|
62
|
-
export declare function installVdomInspect(rootGetter: () => VNodeChild | null | undefined): void;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* transform — children/属性转化规则单一源(design 归档 阶段 0)
|
|
3
|
-
*
|
|
4
|
-
* 可推导性 by construction(design/vdom-transform-rules.md):所有 children 形态判定与
|
|
5
|
-
* 属性通道判定收敛到此单一模块——buildVNode / renderValue / patchChildren / renderSsr /
|
|
6
|
-
* hydrateVNode 全部调用,禁止各路径各自实现形态判定(同一语义多套实现 = 漂移 = 转化分叉)。
|
|
7
|
-
*/
|
|
8
|
-
import type { VNodeChild } from '../vnode.ts';
|
|
9
|
-
import type { BrowserEnv } from '../types.ts';
|
|
10
|
-
/** wf-hole 值摘要(占位内容可见可审计:false/null/undefined/true/对象摘要/bad-vnode) */
|
|
11
|
-
export declare function holeDetail(v: unknown): string;
|
|
12
|
-
/** 统一 wf-hole 标记(规则表 §1——全部 wf-hole 同一格式,用户直接读 DOM 注释可懂):
|
|
13
|
-
* - 占位 `wf-hole: type=hole value=false key=0 id=_wf_5`
|
|
14
|
-
* - 边界 `wf-hole: type=fragment-start key="0" id="_wf_5"` / `wf-hole: type=fragment-end key="0"`
|
|
15
|
-
* - 诊断 `wf-hole: type=hole value="object {...}"`(value 承载内容)
|
|
16
|
-
* 字段:type 必写(hole/fragment-start/fragment-end);value/key/id 有则写。
|
|
17
|
-
* 前缀恒为 `wf-hole:`——diff/audit/hydrate 的占位判断(startsWith)不随格式演进变化 */
|
|
18
|
-
export declare function holeMarkup(opts: {
|
|
19
|
-
type: string;
|
|
20
|
-
value?: unknown;
|
|
21
|
-
key: string | null;
|
|
22
|
-
id: string | null;
|
|
23
|
-
fid: string | null;
|
|
24
|
-
}): string;
|
|
25
|
-
/** 解析 wf-hole 注释字段(type/key/depth/id/value——统一格式,单一解析点) */
|
|
26
|
-
export declare function parseHoleMarkup(nodeValue: string): Record<string, string>;
|
|
27
|
-
/** children 项分类(规则表 §1)——唯一判定,消费方只调函数不写判定 */
|
|
28
|
-
export type ChildKind = 'text' | 'hole' | 'native' | 'component' | 'fragment' | 'portal' | 'array' | 'invalid';
|
|
29
|
-
export declare function classifyChild(c: VNodeChild): ChildKind;
|
|
30
|
-
/** 非法 type 判定(组件/原生/Fragment/Portal 之外——数字/未知 Symbol/缺失 → 诊断占位) */
|
|
31
|
-
export declare function isInvalidVNodeType(t: unknown): boolean;
|
|
32
|
-
/** 数组上下文:无渲染值(false/null/true)→ 占位(规则表 §1——childNodes 与数组同构) */
|
|
33
|
-
export declare function isHoleChild(c: VNodeChild): boolean;
|
|
34
|
-
/** 数组项 key 规范化(key 业务身份声明协议——design 归档):显式 key 仅字符串化(统一字符串);
|
|
35
|
-
* 无 key 项保持 null(框架不生成身份 key——位置身份由 patch 的 prepPos 显式接管混合数组)。
|
|
36
|
-
* 文本/占位值豁免。原地写入 vnode.key(声明规则,非隐藏 magic) */
|
|
37
|
-
export declare function ensureArrayKeys(children: VNodeChild[]): void;
|
|
38
|
-
/** 事件 prop 判定:on + 大写字母(React 约定)——排除 once/only 等 on 开头非事件属性 */
|
|
39
|
-
export declare const EVENT_RE: RegExp;
|
|
40
|
-
/** 事件类型 + 捕获标志(onClick → click;onClickCapture → click + capture)——单一实现 */
|
|
41
|
-
export declare function eventTarget(key: string): {
|
|
42
|
-
type: string;
|
|
43
|
-
capture: boolean;
|
|
44
|
-
};
|
|
45
|
-
/** enumerated value-based 白名单(规则表 §2):空字符串解析为 false——必须显式 'true'/'false'。
|
|
46
|
-
* 对照 HTML 规范 enumerated 属性表:value-based 类(draggable/contenteditable/spellcheck/translate) */
|
|
47
|
-
export declare const ENUMERATED_VALUE_BASED: Set<string>;
|
|
48
|
-
/** CSS 无单位属性(数字不加 px)——其余数字样式属性必须加 px(规则表 §2 UNITLESS 白名单) */
|
|
49
|
-
export declare const UNITLESS_PROPS: Set<string>;
|
|
50
|
-
/** 属性通道分类(单一判定源——setProp/patchProps/x2html 共用;规则表 §2 属性三通道):
|
|
51
|
-
* - enumerated :value-based 枚举属性(draggable 等——空字符串解析为 false,必须显式 'true'/'false')
|
|
52
|
-
* - class :class/className(字符串/对象形态)
|
|
53
|
-
* - style :style(字符串/对象形态)
|
|
54
|
-
* - ref :ref 回调(挂载调用 el / 卸载调用 null)
|
|
55
|
-
* - event :on + 大写(onClick/onClickCapture——事件通道)
|
|
56
|
-
* - value :input/select value(property)
|
|
57
|
-
* - indeterminate:checkbox 半选态(property——attribute 解析为 false)
|
|
58
|
-
* - innerHTML :innerHTML 内容(存在则 children 不渲染)
|
|
59
|
-
* - aria :aria-* 语义属性(boolean 必须显式 'true'/'false')
|
|
60
|
-
* - default :其余——property + attribute 双写 */
|
|
61
|
-
export type PropChannel = 'enumerated' | 'class' | 'style' | 'ref' | 'event' | 'value' | 'indeterminate' | 'innerHTML' | 'aria' | 'default';
|
|
62
|
-
/** 属性通道判定(key 分类——值判断留在各通道处理函数内,规则表 §2)
|
|
63
|
-
* enumerated 白名单小写匹配:JSX camelCase(contentEditable)与规范小写(contenteditable)
|
|
64
|
-
* 统一走显式 'true'/'false'——否则 camelCase 落入 boolean 通道输出空字符串(解析仍 true,
|
|
65
|
-
* 但违反 §6.2 显式协议且属性值不可预期) */
|
|
66
|
-
export declare function propChannelOf(key: string): PropChannel;
|
|
67
|
-
type SetPropFn = (el: Element, key: string, value: any) => void;
|
|
68
|
-
/** 属性设置状态机表(通道 → 设置行为——setProp 查表分派,无 if/else 通道链) */
|
|
69
|
-
export declare const PROP_SETTERS: Record<PropChannel, SetPropFn>;
|
|
70
|
-
/** 属性设置(查表分派——PROP_SETTERS[propChannelOf(key)]) */
|
|
71
|
-
export declare function setProp(el: Element, key: string, value: any): void;
|
|
72
|
-
/** 占位内容(规则表 §1——wf-hole 内容可见可审计:false/null/undefined/true/对象摘要/bad-vnode) */
|
|
73
|
-
/** 创建占位节点(数组上下文的无渲染值 → 注释节点,childNodes 与数组同构——规则表 §1) */
|
|
74
|
-
export declare function createHole(browser: BrowserEnv, v: unknown): Node | null;
|
|
75
|
-
export {};
|
|
76
|
-
/** 递归渲染(同步——组件必须已构建) */
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom2 x2y 转换状态机——**源类型驱动**:每个 (源, 目标) 组合一个转换函数,
|
|
3
|
-
* TRANSITIONS[oldKind][newKind] 查表分派(patchValue 用)。
|
|
4
|
-
*
|
|
5
|
-
* 转换动作由**源类型**决定(源最清楚自己的 DOM 形态如何移除/递归/复用):
|
|
6
|
-
* - 同类型:递归 patch(frag→frag children diff / comp→comp 输出递归 / native→native
|
|
7
|
-
* 同 tag in-place / arr→arr 数组递归 / text→text nodeValue 直改 / hole→hole 占位保持 /
|
|
8
|
-
* portal→portal 远程 patch)
|
|
9
|
-
* - 异类型:toOther 通用——renderValue 渲染目标 + removeOldOutput 移除旧输出
|
|
10
|
-
* (removeOldOutput 内部 getOutputRange 多态——每类输出范围:Fragment._childNodes /
|
|
11
|
-
* 组件 _outputChild 递归 / 数组 fragment-start..end 标记)
|
|
12
|
-
*
|
|
13
|
-
* 全量组合表显式列出——vdom2-matrix.test.ts 9×9 矩阵验证无遗漏。
|
|
14
|
-
*/
|
|
15
|
-
import { Fragment, Portal } from '../vnode.ts';
|
|
16
|
-
import { type PatchState, type VKind } from './kind.ts';
|
|
17
|
-
import { type PatchCtx } from './patch.ts';
|
|
18
|
-
type TransitionFn = (s: PatchState) => Node | null;
|
|
19
|
-
export declare const TRANSITIONS: Record<VKind, Record<VKind, TransitionFn>>;
|
|
20
|
-
/** x2y 状态机分派:由源类型(oldInput)与目标类型(newInput)查表调用转换函数
|
|
21
|
-
* 转换事件:machine=x2y(from=旧 kind,to=新 kind)——过程级可观测 */
|
|
22
|
-
export declare function x2y(s: PatchState): Node | null;
|
|
23
|
-
export type { PatchCtx };
|
|
24
|
-
export { Fragment, Portal };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom2 x2html — vnode → HTML 字符串(SSR)
|
|
3
|
-
*
|
|
4
|
-
* 与 renderValue(客户端 DOM)同一**类型遍历**——TO_HTML[classifyKind(v)] 分派:
|
|
5
|
-
* 每个类型一个渲染实现,SSR/客户端结构同构(数组边界标记/占位注释/属性规则同一单一规则源
|
|
6
|
-
* transform.ts),hydration 不 mismatch。
|
|
7
|
-
*
|
|
8
|
-
* 与客户端的差异(SSR 语义):
|
|
9
|
-
* - 组件:现场执行工厂 + renderFn(无预构建——SSR 服务端每次渲染)
|
|
10
|
-
* - Portal:就地内联子节点(客户端 portal 渲染到 #__wf_portal——SSR 内联保留内容/SEO)
|
|
11
|
-
* - 事件 props 剥离(hydration 接线);ref 剥离
|
|
12
|
-
*/
|
|
13
|
-
import type { VNodeChild } from '../vnode.ts';
|
|
14
|
-
import { isFrag, isComp, isPortal, isNative, Fragment, Portal } from '../vnode.ts';
|
|
15
|
-
import { type VKind } from './kind.ts';
|
|
16
|
-
export declare function escape(s: string): string;
|
|
17
|
-
type HtmlCtx = {
|
|
18
|
-
_fidPath?: string;
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
21
|
-
/** vnode → HTML(SSR)——类型分派主入口 */
|
|
22
|
-
export declare function x2html(input: VNodeChild, ctx: HtmlCtx): Promise<string>;
|
|
23
|
-
/** 类型分派表(与客户端 renderValue 同一 classifyKind——SSR/客户端结构同构) */
|
|
24
|
-
export declare const TO_HTML: Record<VKind, (v: VNodeChild, ctx: HtmlCtx) => Promise<string>>;
|
|
25
|
-
export { Fragment, Portal };
|
|
26
|
-
export { isFrag, isComp, isPortal, isNative };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vdom3 compat — vdom2 ↔ vdom3 组件兼容层(迁移路径)
|
|
3
|
-
*
|
|
4
|
-
* vdom2 两阶段组件 `(initProps, ctx) => async (props) => VNode` 与 vdom3 同模型——
|
|
5
|
-
* 唯一差异是 ctx 接口:vdom2 用 `ctx.ui.render()`(vdom2 的 ui 上下文)。
|
|
6
|
-
*
|
|
7
|
-
* compat():包一层——ctx.ui.render → v3 ctx.render(调度自身重渲染——同 tick 合并)。
|
|
8
|
-
* 迁移:vdom2 组件 `h(compat(V2Comp), props)` 即可在 vdom3 树运行(无需改组件代码)。
|
|
9
|
-
*
|
|
10
|
-
* 裁剪(诚实):只适配 render/onUnmount/基础 ctx——vdom2 的 hooks
|
|
11
|
-
* (useExternal/useMedia/usePopup 等 ctx.ui.* 依赖)不在兼容范围
|
|
12
|
-
* (迁移时由调用方注入或重构)。
|
|
13
|
-
*/
|
|
14
|
-
import type { Component } from './types.ts';
|
|
15
|
-
type V2Component = (initProps: any, ctx: any) => Promise<(props: any) => Promise<any>>;
|
|
16
|
-
/** vdom2 组件 → vdom3 组件(ctx.ui.render 适配) */
|
|
17
|
-
export declare function compat(comp: V2Component): Component;
|
|
18
|
-
/** vdom3 组件 → vdom2 组件(反向互操作——ctx.render 从 ui.render 取) */
|
|
19
|
-
export declare function toV2(comp: Component): V2Component;
|
|
20
|
-
export {};
|