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
|
@@ -31,10 +31,12 @@ export { createRouter, type RouteDef } from './router.ts';
|
|
|
31
31
|
export { renderToEvents, renderToEventStream, serializeEvents, deserializeEvents, eventsToHtml } from './ssr.ts';
|
|
32
32
|
export { recordToTest, summarizeEvents } from './record.ts';
|
|
33
33
|
export { createPortal } from './jsx.ts';
|
|
34
|
-
export { Portal } from './types.ts';
|
|
34
|
+
export { Portal, App } from './types.ts';
|
|
35
35
|
export { ensurePortalContainer } from './registry.ts';
|
|
36
36
|
export { createV3Ui } from './ui.ts';
|
|
37
37
|
export { createSync, autoSync } from './sync.ts';
|
|
38
|
-
export {
|
|
39
|
-
export { createEventStream, stream, nextNodeId } from './events.ts';
|
|
38
|
+
export { v3Confirm, v3Toast, type V3CommandInjected } from './commands.ts';
|
|
39
|
+
export { createEventStream, stream, nextNodeId, ev, evKey } from './events.ts';
|
|
40
|
+
export { registerApp, getAppFactory, resetAppRegistry } from './app.ts';
|
|
41
|
+
export { addGlobalListener, bindElementListener, bindDelegated, unbindEvent, unbindAll, ensureDelegationRoot, removeDelegationRoot, resetDelegation, } from './delegate.ts';
|
|
40
42
|
export type { VNode, VNodeChild, V3Event, EventStream, Renderer } from './types.ts';
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vdom3 jsx — vnode
|
|
2
|
+
* vdom3 jsx — vnode 创建(声明式——vdom2 同模型:renderFn 输出完整树)
|
|
3
|
+
*
|
|
4
|
+
* 统一 JSX 入口:h/jsx/jsxs/jsxDEV + createPortal + Fragment/Portal——
|
|
5
|
+
* vdom2 时代 vnode.ts 的工厂全部收敛到此处(组件库 249 处 import 经转发层零改动)。
|
|
3
6
|
*/
|
|
4
7
|
import type { VNode, VNodeChild } from './types.ts';
|
|
5
|
-
import { Fragment, Portal } from './types.ts';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
import { Fragment, Portal, App } from './types.ts';
|
|
9
|
+
import type { Component } from './types.ts';
|
|
10
|
+
type HType = string | symbol | Component<any, any>;
|
|
11
|
+
export declare function h(type: HType, props?: Record<string, unknown> | null, ...children: VNodeChild[]): VNode;
|
|
12
|
+
/** JSX 编译产物入口(jsxImportSource: weifuwu/ui-dom——jsx-runtime 转发) */
|
|
13
|
+
export declare function jsx(type: HType, props: Record<string, unknown> | null, key?: string | null): VNode;
|
|
14
|
+
/** jsxs = jsx(children 数组已在 props.children——h 语义同构) */
|
|
15
|
+
export declare const jsxs: typeof jsx;
|
|
16
|
+
export declare function jsxDEV(type: HType, props: Record<string, unknown> | null, key?: string | null): VNode;
|
|
8
17
|
/** Portal:children 渲染到远程容器(#__wf_portal > [data-wf-portal-key=key]) */
|
|
9
18
|
export declare function createPortal(children: VNodeChild, portalKey?: string): VNode;
|
|
10
19
|
export { Fragment, Portal };
|
|
20
|
+
/** JSX 类型声明(jsxImportSource: weifuwu/ui-dom——组件/用户 JSX 编译产物类型) */
|
|
21
|
+
declare global {
|
|
22
|
+
namespace JSX {
|
|
23
|
+
type Element = import('./types.ts').VNode | null;
|
|
24
|
+
type ElementType = string | ((props: any, ctx: any) => any) | typeof Fragment | typeof Portal | typeof App;
|
|
25
|
+
interface IntrinsicElements {
|
|
26
|
+
[tag: string]: any;
|
|
27
|
+
}
|
|
28
|
+
interface IntrinsicAttributes {
|
|
29
|
+
key?: string | number | null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* → 回放 + 事件序列断言(DOM = fold 验证 + 精确渲染描述)。
|
|
6
6
|
*
|
|
7
7
|
* 事故转测试:任意渲染异常 → 录制事件流 → 生成回归测试(无需手动复现)。
|
|
8
|
+
*
|
|
9
|
+
* 事件统一命名:对象 + 动作 + 参数(entity + action + target + payload)——
|
|
10
|
+
* 键格式 `entity:action`(如 'node:create' / 'comp:render')。
|
|
8
11
|
*/
|
|
9
12
|
import type { V3Event } from './types.ts';
|
|
10
13
|
/** 事件流 → jsdom 测试代码(可写盘/执行) */
|
|
@@ -7,20 +7,33 @@
|
|
|
7
7
|
* 组件 vnode(已 build):输出 _child(渲染组件输出——无重复构建);
|
|
8
8
|
* 卸载:COMP_UNMOUNT 事件(类型/位置变化时——由 patch 顶层判定)。
|
|
9
9
|
*/
|
|
10
|
-
import type { VNode,
|
|
10
|
+
import type { VNode, PortalVNode } from './types.ts';
|
|
11
11
|
import { Fragment } from './types.ts';
|
|
12
12
|
/** Portal 判定(symbol 恒等 + props.portalKey——兼容 vdom2 组件产出的 Portal vnode) */
|
|
13
13
|
export declare function isPortalNode(v: unknown): v is PortalVNode;
|
|
14
14
|
/** Fragment 判定(symbol 且非 Portal——vdom2/vdom3 Fragment 都认) */
|
|
15
15
|
export declare function isFragmentNode(v: unknown): boolean;
|
|
16
16
|
import { NodeRegistry } from './registry.ts';
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
17
|
+
/** 节点注册表(id ↔ Node——事件流指令定位)——模块级可变(mount/patch 支持
|
|
18
|
+
* per-call 注入(测试隔离)——同步段切换安全(并发交错在 await 点) */
|
|
19
|
+
declare let registry: NodeRegistry;
|
|
20
|
+
export { registry };
|
|
21
|
+
/** 挂载:纯树 → 事件流 → DOM(reg 可选——per-call 隔离;默认全局)
|
|
22
|
+
* 挂载前清空容器(首次挂载语义——清除 HTML 预置的 boot-loading 等占位——
|
|
23
|
+
* 不残留「加载中...」) */
|
|
24
|
+
export declare function mount(vnode: VNode, root: HTMLElement, reg?: NodeRegistry): void;
|
|
21
25
|
/**
|
|
22
26
|
* patch:旧树(纯)vs 新树(纯)→ 事件流 → DOM。
|
|
23
27
|
* 同位置同类型(含 key)复用——仅变化发事件;异类型 → REMOVE+CREATE+INSERT(重建事件)。
|
|
24
28
|
*/
|
|
25
|
-
export declare function patch(oldV: VNode | null, newV:
|
|
29
|
+
export declare function patch(oldV: VNode | null, newV: VNode | string | number | null | undefined | boolean, parent: Node, anchor?: Node | null, reg?: NodeRegistry): Node | null;
|
|
30
|
+
/** 递归调 ref(null)(移除树——ref 纪律:卸载清理(lockScroll/focus)依赖
|
|
31
|
+
* ——portal/组件输出等嵌套结构的 ref 全部清理——REF_CLEANUP 事件(生命周期可观测))
|
|
32
|
+
* 导出(组件级 update 用) */
|
|
33
|
+
export declare function callRefCleanup(v: VNode | null | undefined): void;
|
|
34
|
+
/** 节点移除的完整清理(REMOVE 事件 + EVENT_UNBIND(绑定生命周期)+ ref(null) + registry) */
|
|
35
|
+
export declare function removeNodeWithLifecycle(node: Node, parent: Node, vnodeRef?: VNode | null): void;
|
|
36
|
+
/** 移除 portal 内容(远程容器清空——子树 REMOVE 事件 + ref(null)——ref 纪律:
|
|
37
|
+
* 卸载必须调 ref(null)(usePopup 的 portalPanelRef 清理——lockScroll/focus 恢复)) */
|
|
38
|
+
export declare function removePortalContent(pv: PortalVNode): void;
|
|
26
39
|
export { Fragment };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* vdom3 replay — 事件流回放 / 取消 / 断言(DOM = fold(事件流))
|
|
3
3
|
*
|
|
4
|
-
* 回放(replay):从目标容器重放事件流——
|
|
5
|
-
*
|
|
4
|
+
* 回放(replay):从目标容器重放事件流——node:create 建节点(id→节点映射)、
|
|
5
|
+
* node:insert 挂载、prop:text update 应用——结果 = 原渲染的 DOM(fold 不变量)。
|
|
6
6
|
*
|
|
7
|
-
* 取消(undo):从事件流末尾取 N 个事件 → 应用逆操作——
|
|
8
|
-
*
|
|
7
|
+
* 取消(undo):从事件流末尾取 N 个事件 → 应用逆操作——insert→remove、
|
|
8
|
+
* remove→恢复(registry 保存的节点)、update→恢复 prev。
|
|
9
9
|
*
|
|
10
10
|
* 断言(eventsOf/hasEvent):渲染 = 事件序列断言(测试/调试)。
|
|
11
|
+
*
|
|
12
|
+
* 事件统一命名:对象 + 动作 + 参数(entity + action + target + payload)——
|
|
13
|
+
* 键格式 `entity:action`(如 'node:create')。
|
|
11
14
|
*/
|
|
12
15
|
import type { V3Event } from './types.ts';
|
|
13
16
|
import { NodeRegistry } from './registry.ts';
|
|
@@ -17,9 +20,9 @@ export declare function applyEvent(ev: V3Event, target: HTMLElement, reg: NodeRe
|
|
|
17
20
|
export declare function replay(events: V3Event[], target: HTMLElement, reg?: NodeRegistry): void;
|
|
18
21
|
/** 取消:从事件流末尾取 n 个 DOM 指令 → 应用逆操作(撤销渲染变化) */
|
|
19
22
|
export declare function undo(events: V3Event[], n: number, reg?: NodeRegistry): void;
|
|
20
|
-
/**
|
|
21
|
-
export declare function eventsOf(events: V3Event[], type:
|
|
23
|
+
/** 断言工具:过滤事件(按 entity:action 键——如 'node:create') */
|
|
24
|
+
export declare function eventsOf(events: V3Event[], type: string): V3Event[];
|
|
22
25
|
/** 断言工具:是否存在匹配事件 */
|
|
23
26
|
export declare function hasEvent(events: V3Event[], predicate: (e: V3Event) => boolean): boolean;
|
|
24
|
-
/** 断言:渲染 =
|
|
25
|
-
export declare function expectEventSequence(events: V3Event[], expected:
|
|
27
|
+
/** 断言:渲染 = 事件序列(测试——精确描述渲染做了什么;键格式 entity:action) */
|
|
28
|
+
export declare function expectEventSequence(events: V3Event[], expected: string[]): void;
|
|
@@ -4,13 +4,7 @@
|
|
|
4
4
|
* 组件 ctx.render():调度自身重渲染(同 tick 合并——一次 patch)。
|
|
5
5
|
* 渲染流程:renderFn 重跑 → buildVNode(oldV 对照复用)→ patch(事件流 → DOM)。
|
|
6
6
|
*/
|
|
7
|
-
import type { VNode } from './types.ts';
|
|
8
|
-
export interface V3Ctx {
|
|
9
|
-
render: () => void;
|
|
10
|
-
/** 组件自身输出(渲染定位) */
|
|
11
|
-
_vnode: VNode;
|
|
12
|
-
_parent: Node | null;
|
|
13
|
-
}
|
|
7
|
+
import type { VNode, V3Ctx } from './types.ts';
|
|
14
8
|
export interface RootHandle {
|
|
15
9
|
ctx: V3Ctx;
|
|
16
10
|
/** 组件重渲染(ctx.render 内部路径——同 tick 合并) */
|
|
@@ -21,6 +15,8 @@ export interface RootHandle {
|
|
|
21
15
|
/** 首帧完成 Promise(初始挂载——工厂 await + 渲染落地) */
|
|
22
16
|
ready: Promise<void>;
|
|
23
17
|
}
|
|
18
|
+
/** 树中按组件 _id 定位(组件级更新的定位——DFS——含组件输出 _child) */
|
|
19
|
+
export declare function findComponent(v: VNode | null | undefined, compId: string): VNode | null;
|
|
24
20
|
/** 创建应用根(挂载组件树——组件获得 ctx.render 调度能力;options.ctx 注入扩展字段
|
|
25
21
|
* ——中间件面(app/i18n/auth/data 等——组件 ctx 可选链消费)) */
|
|
26
22
|
export declare function createRoot(vnode: VNode, root: HTMLElement, options?: {
|
|
@@ -9,26 +9,71 @@
|
|
|
9
9
|
* 事件流是引擎本体:从 location 到 DOM 的每一步都是事件——可记录/回放/取消/断言。
|
|
10
10
|
* 不变量:DOM = fold(事件流)——给定初始 DOM + 事件流 = 任意时刻 DOM。
|
|
11
11
|
*/
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/** WfuiContext(组件 ctx 类型源——192 处组件消费)——V3Ctx extends 统一 */
|
|
13
|
+
import type { WfuiContext } from '../types.ts';
|
|
14
|
+
/** vdom3 组件 ctx(正式契约——组件可见最小面 + 中间件扩展(index 签名))
|
|
15
|
+
* render:调度自身重渲染(同 tick 合并)——render-only 唯一触发
|
|
16
|
+
* onUnmount:卸载清理注册(COMP_UNMOUNT 时执行)
|
|
17
|
+
* ui:vdom2 兼容面(hooks shim——组件库零改动运行)
|
|
18
|
+
* 扩展字段(ctx.app/i18n/data/auth...)经 index 签名消费(可选链——中间件注入) */
|
|
19
|
+
/** vdom3 组件 ctx(正式契约——与 WfuiContext 类型唯一化:
|
|
20
|
+
* V3Ctx extends WfuiContext——vdom2 时代内联标注 ctx: WfuiContext 的组件
|
|
21
|
+
* 类型兼容(逆变:接受 WfuiContext 的函数可接收 V3Ctx);组件库 192 处
|
|
22
|
+
* WfuiContext 消费零改动——严格类型,无 any 绕开) */
|
|
23
|
+
export interface V3Ctx extends WfuiContext {
|
|
24
|
+
/** 调度自身重渲染(同 tick 合并)——render-only 唯一触发 */
|
|
25
|
+
render(): void;
|
|
26
|
+
/** 卸载清理注册(COMP_UNMOUNT 时执行) */
|
|
27
|
+
onUnmount(fn: () => void): void;
|
|
28
|
+
/** vdom2 兼容面(hooks shim——组件库零改动运行——V3Ui 满足放宽后的
|
|
29
|
+
* WfuiContext['ui'](render: void ⊂ void | Promise<void>)) */
|
|
30
|
+
ui: V3Ui;
|
|
31
|
+
}
|
|
32
|
+
/** ctx.ui 兼容面(vdom2 hooks 契约——组件库零改动运行)
|
|
33
|
+
* 方法签名继承 vdom2 ui(hooks 类型源——vdom2 删除后 hooks 保留为共享层);
|
|
34
|
+
* render/onUnmount 覆盖为 vdom3 语义(同步 render)。 */
|
|
35
|
+
export interface V3Ui extends Omit<WfuiContext['ui'], 'render' | 'onUnmount'> {
|
|
36
|
+
render(ids?: string[]): void;
|
|
37
|
+
onUnmount(fn: () => void): (() => void) | undefined;
|
|
38
|
+
/** 实例标记(debug:ctx.ui 来源审计——双实例定位) */
|
|
39
|
+
__v3ui?: boolean;
|
|
40
|
+
/** 实例绑定的组件 id(debug:compId 错位定位) */
|
|
41
|
+
__compId?: string;
|
|
42
|
+
}
|
|
43
|
+
/** 两阶段组件契约(正式签名——无 any)
|
|
44
|
+
* P:props(JSX 自动推断);C:ctx 注入依赖——**自动 & WfuiContext**(vdom2 语义:
|
|
45
|
+
* 组件声明 C 只写注入面(ToastInjected 等)——ctx.ui/browser 等基础面自动可用)
|
|
46
|
+
* ——严格交叉(无 any)——默认 C = V3Ctx(V3Ctx extends WfuiContext——交叉 = V3Ctx) */
|
|
47
|
+
export type Component<P = Record<string, unknown>, C = V3Ctx> = (initProps: P, ctx: C & WfuiContext) => Promise<(props: P) => Promise<VNode | null>>;
|
|
16
48
|
export interface VNode {
|
|
17
|
-
/** native 标签名 / 组件函数 / Fragment 符号 */
|
|
49
|
+
/** native 标签名 / 组件函数 / Fragment/Portal 符号 */
|
|
18
50
|
type: string | symbol | Component;
|
|
19
51
|
props: Record<string, unknown>;
|
|
20
52
|
key?: string | null;
|
|
21
53
|
/** 渲染后回填:DOM 元素(native)/ 组件实例输出(comp) */
|
|
22
54
|
el?: Node | null;
|
|
23
55
|
children?: VNodeChild[];
|
|
24
|
-
/** 组件实例状态(comp:工厂返回的 renderFn + 实例 id
|
|
25
|
-
|
|
56
|
+
/** 组件实例状态(comp:工厂返回的 renderFn + 实例 id)——内部字段
|
|
57
|
+
* (props 参数放宽为 Record——组件 renderFn 的 P 泛型在 buildVNode 赋值处断言一次) */
|
|
58
|
+
_render?: (props: Record<string, unknown>) => Promise<VNode | null>;
|
|
26
59
|
_id?: string;
|
|
27
60
|
/** 组件输出(build 写——独立于 children(props.children 是入参);避免覆盖污染对照树) */
|
|
28
61
|
_child?: VNode | null;
|
|
62
|
+
/** 多节点输出范围(阶段 2——渲染后回填:首/尾 DOM 节点——组件/Fragment 输出
|
|
63
|
+
* 多节点时移除/推进用范围(vdom2 getOutputRange 语义——事件流引用替代 DOM 标记) */
|
|
64
|
+
_outFirst?: Node | null;
|
|
65
|
+
_outLast?: Node | null;
|
|
66
|
+
/** props 内容快照(透明度 round2 阶段 1——dev only——检测原地改对象) */
|
|
67
|
+
_propsSnap?: string | null;
|
|
29
68
|
}
|
|
30
|
-
export type VNodeChild = VNode | string | number | null | undefined | boolean;
|
|
31
|
-
|
|
69
|
+
export type VNodeChild = VNode | string | number | null | undefined | boolean | VNodeChild[];
|
|
70
|
+
/** vnode kind 分类(全链路事件流的决策基础——单一规则源)
|
|
71
|
+
* renderVNode / patchInner / patchChildren / 事件流 全部消费——新增类型只改此处 */
|
|
72
|
+
export type VKind = 'native' | 'comp' | 'frag' | 'portal' | 'text' | 'null' | 'app';
|
|
73
|
+
export declare function classifyKind(v: VNodeChild | undefined | null): VKind;
|
|
74
|
+
/** 拍平后元素(flatten 展开嵌套数组——类型层面排除数组——逻辑保证) */
|
|
75
|
+
export type FlatChild = VNode | string | number | null | undefined | boolean;
|
|
76
|
+
export declare function childrenOf(v: VNode): FlatChild[];
|
|
32
77
|
export declare const Fragment: unique symbol;
|
|
33
78
|
/** Portal(浮层渲染到远程容器——#__wf_portal 下按 key 的容器——脱离父节点位置) */
|
|
34
79
|
export declare const Portal: unique symbol;
|
|
@@ -36,73 +81,86 @@ export type PortalVNode = VNode & {
|
|
|
36
81
|
type: typeof Portal;
|
|
37
82
|
portalKey?: string | null;
|
|
38
83
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
type:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
ts: number;
|
|
94
|
-
} | {
|
|
95
|
-
type: 'MOVE';
|
|
96
|
-
node: string;
|
|
97
|
-
parent: string;
|
|
98
|
-
ref: string | null;
|
|
99
|
-
prev?: string | null;
|
|
84
|
+
/** App(多应用加载——type: App 的节点 = 子应用挂载点——应用编排) */
|
|
85
|
+
export declare const App: unique symbol;
|
|
86
|
+
export type AppVNode = VNode & {
|
|
87
|
+
type: typeof App;
|
|
88
|
+
appId?: string;
|
|
89
|
+
_appOutput?: VNode | null;
|
|
90
|
+
};
|
|
91
|
+
export type Entity = 'route' | 'comp' | 'props' | 'vnode' | 'node' | 'text' | 'prop' | 'event' | 'ref' | 'error' | 'internal' | 'stream' | 'effect' | 'app' | 'diff' | 'render' | 'portal';
|
|
92
|
+
export type Action =
|
|
93
|
+
/** location 层 */
|
|
94
|
+
'change'
|
|
95
|
+
/** jsx 层 */
|
|
96
|
+
| 'render' | 'build' | 'mount' | 'unmount' | 'update'
|
|
97
|
+
/** vdom 层 */
|
|
98
|
+
| 'patch'
|
|
99
|
+
/** dom 层 */
|
|
100
|
+
| 'create' | 'insert' | 'remove' | 'move' | 'bind' | 'unbind' | 'cleanup'
|
|
101
|
+
/** 错误层(任意环节失败——事件流完整覆盖:throw=未捕获传播 / caught=隔离降级) */
|
|
102
|
+
| 'throw' | 'caught'
|
|
103
|
+
/** 内部决策层(渲染管线内部状态——busy 排队/组件未定位/跳过——非正常路径可观测) */
|
|
104
|
+
| 'queue' | 'notfound' | 'skip'
|
|
105
|
+
/** 事件流自身层(buffer 状态——溢出覆盖/水位预警可观测) */
|
|
106
|
+
| 'overflow' | 'watermark'
|
|
107
|
+
/** diff 决策层(阶段 0——vdom2 机制事件化):
|
|
108
|
+
* transition = 类型转换决策(from 旧 kind → to 新 kind——patch 查表分派观测)
|
|
109
|
+
* mode = key 模式选择(unkeyed/keyed/mixed——业务身份声明协议观测)
|
|
110
|
+
* summary = children 摘要(old/new/dom 三序列——顺序错乱快速定位) */
|
|
111
|
+
| 'transition' | 'mode' | 'summary'
|
|
112
|
+
/** 渲染性能层(round2 阶段 2——每次渲染耗时可观测) */
|
|
113
|
+
| 'duration'
|
|
114
|
+
/** 调度时间线层(round3 阶段 2——渲染排队/合并可观测) */
|
|
115
|
+
| 'queued' | 'flushed'
|
|
116
|
+
/** portal 生命周期层(round3 阶段 3——弹层开合可观测) */
|
|
117
|
+
| 'open' | 'close'
|
|
118
|
+
/** 组件副作用层(ref 挂载/动画/滚动锁/焦点 trap/滚动——非渲染的 DOM 行为可观测) */
|
|
119
|
+
| 'mount' | 'animate' | 'lock' | 'unlock' | 'focus' | 'scroll'
|
|
120
|
+
/** 用户文本操作层(输入/选区/剪贴板——用户对文本的交互可观测) */
|
|
121
|
+
| 'input' | 'select' | 'copy' | 'cut' | 'paste'
|
|
122
|
+
/** 应用编排层(app 节点——子应用挂载/更新/卸载/错误——payload.appId 可区分) */
|
|
123
|
+
| 'mount' | 'unmount' | 'error'
|
|
124
|
+
/** 应用编排层(app 节点——子应用挂载/更新/卸载/错误——payload.appId 可区分) */
|
|
125
|
+
| 'mount' | 'unmount' | 'error';
|
|
126
|
+
export type V3Event = {
|
|
127
|
+
/** 对象(什么) */
|
|
128
|
+
entity: Entity;
|
|
129
|
+
/** 动作(怎么了) */
|
|
130
|
+
action: Action;
|
|
131
|
+
/** 对象 id(目标定位——node id / comp id) */
|
|
132
|
+
target?: string;
|
|
133
|
+
/** 参数(对象相关数据——旧值/新值/父节点/属性 key 等) */
|
|
134
|
+
payload?: Record<string, unknown>;
|
|
135
|
+
/** 渲染会话 id(一次渲染(renderByIds/首帧/导航)内的事件共享同一 session——
|
|
136
|
+
* 按会话过滤/回放——vdom2 traceId 事件流化)——emit 时注入(stream 持有当前会话) */
|
|
137
|
+
session?: string;
|
|
100
138
|
ts: number;
|
|
101
139
|
};
|
|
140
|
+
/** patch 决策策略(vnode:patch 的 payload.strategy) */
|
|
141
|
+
export type PatchStrategy = 'reuse' | 'rebuild' | 'move' | 'remove' | 'unhandled';
|
|
142
|
+
/** 错误发生的环节(error:throw/caught 的 payload.phase——全链路可定位) */
|
|
143
|
+
export type ErrorPhase = 'factory' | 'renderFn' | 'build' | 'patch' | 'mount' | 'update' | 'hook' | 'schedule' | 'event';
|
|
102
144
|
/** 事件流(记录/回放/断言——DOM = fold(events)) */
|
|
103
145
|
export interface EventStream {
|
|
104
146
|
emit(ev: V3Event): void;
|
|
147
|
+
/** 新渲染会话开始(每次渲染入口调用——同一次渲染的事件共享 session) */
|
|
148
|
+
setSession(): string;
|
|
149
|
+
/** 当前会话 id(无渲染进行时 null) */
|
|
150
|
+
currentSession(): string | null;
|
|
151
|
+
/** 实时订阅(emit 同步回调——缓冲溢出也不丢事件——返回退订)
|
|
152
|
+
* 重载:subscribe(fn) 全部事件;subscribe(filter, fn) 按层过滤(entity) */
|
|
153
|
+
subscribe(fn: (ev: V3Event) => void): () => void;
|
|
154
|
+
subscribe(filter: Entity[] | Entity, fn: (ev: V3Event) => void): () => void;
|
|
105
155
|
events(): V3Event[];
|
|
156
|
+
/** 按渲染会话过滤(一次渲染的事件全量——调试/回放按会话) */
|
|
157
|
+
eventsBySession(sessionId: string): V3Event[];
|
|
158
|
+
/** 当前有效条数(缓冲占用——事件流自身状态可观测) */
|
|
159
|
+
size(): number;
|
|
160
|
+
/** 缓冲容量 */
|
|
161
|
+
capacity(): number;
|
|
162
|
+
/** 溢出次数(最旧事件被覆盖的次数——事件丢失可审计) */
|
|
163
|
+
overflowCount(): number;
|
|
106
164
|
/** 逆操作(取消——INSERT↔REMOVE / UPDATE 恢复旧值) */
|
|
107
165
|
inverse(ev: V3Event): V3Event | null;
|
|
108
166
|
reset(): void;
|
|
@@ -9,35 +9,8 @@
|
|
|
9
9
|
* render(ids) 语义:含自身 id → vdom3 ctx.render()(组件自身重渲染);
|
|
10
10
|
* 其他 id → vdom3 无跨组件 render(诚实 warn——后续补 registry 级 render)。
|
|
11
11
|
*/
|
|
12
|
-
/** 组件 ctx.ui(vdom2
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onUnmount(fn: () => void): (() => void) | undefined;
|
|
16
|
-
selfId(name: string): void;
|
|
17
|
-
useExternal(store: any): any;
|
|
18
|
-
useControlled(options: any): any;
|
|
19
|
-
useControlledInput(options: any): any;
|
|
20
|
-
useOpen(options: any): any;
|
|
21
|
-
usePopup(options: any): any;
|
|
22
|
-
usePopupPosition(options: any): any;
|
|
23
|
-
useTween(target: number, opts?: any): any;
|
|
24
|
-
useInView(options?: any): any;
|
|
25
|
-
useScrollPosition(options?: any): any;
|
|
26
|
-
useGlobalKey(handler: (e: KeyboardEvent) => void): () => void;
|
|
27
|
-
useDrag(options?: any): any;
|
|
28
|
-
useDragDrop(options?: any): any;
|
|
29
|
-
useMedia(query: string, callback: (matches: boolean) => void): void;
|
|
30
|
-
useBreakpoint(bps: any, callback?: any): void;
|
|
31
|
-
useReducedMotion(): boolean;
|
|
32
|
-
useStableRef(init: any, cleanup?: any): any;
|
|
33
|
-
useAnimationEnd(cb: any, opts?: any): any;
|
|
34
|
-
usePresence(options?: any): any;
|
|
35
|
-
useLongPress(options?: any): any;
|
|
36
|
-
useHoverCapable(): boolean;
|
|
37
|
-
useVisualViewport(): any;
|
|
38
|
-
useAsync(fetcher: any): any;
|
|
39
|
-
useChat(options: any): any;
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
}
|
|
12
|
+
/** 组件 ctx.ui(vdom2 兼容面——V3Ui 类型定义在 types.ts(hooks 契约继承)) */
|
|
13
|
+
import type { V3Ui } from './types.ts';
|
|
14
|
+
export type { V3Ui } from './types.ts';
|
|
42
15
|
/** 组装 HookEnv + ctx.ui(组件实例级——id 绑定;共享态模块级) */
|
|
43
16
|
export declare function createV3Ui(compId: string, render: () => void, onUnmountCb: (fn: () => void) => void): V3Ui;
|