@lytjs/renderer 5.0.1 → 6.0.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 +371 -204
- package/dist/dom.cjs +12 -1
- package/dist/dom.cjs.map +1 -0
- package/dist/dom.d.cts +1 -0
- package/dist/dom.d.ts +1 -0
- package/dist/dom.mjs +3 -1
- package/dist/dom.mjs.map +1 -0
- package/dist/index.cjs +3312 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1004 -0
- package/dist/index.d.ts +1004 -0
- package/dist/index.mjs +3190 -1
- package/dist/index.mjs.map +1 -0
- package/dist/ssr.cjs +310 -1
- package/dist/ssr.cjs.map +1 -0
- package/dist/ssr.d.cts +21 -0
- package/dist/ssr.d.ts +21 -0
- package/dist/ssr.mjs +308 -1
- package/dist/ssr.mjs.map +1 -0
- package/package.json +35 -58
- package/dist/miniapp.cjs +0 -27
- package/dist/miniapp.mjs +0 -27
- package/dist/native.cjs +0 -1
- package/dist/native.mjs +0 -1
- package/dist/types/create-renderer.d.ts +0 -20
- package/dist/types/create-renderer.d.ts.map +0 -1
- package/dist/types/dom/dom-ops.d.ts +0 -74
- package/dist/types/dom/dom-ops.d.ts.map +0 -1
- package/dist/types/dom/dom-renderer.d.ts +0 -243
- package/dist/types/dom/dom-renderer.d.ts.map +0 -1
- package/dist/types/dom/index.d.ts +0 -17
- package/dist/types/dom/index.d.ts.map +0 -1
- package/dist/types/dom/patch-events.d.ts +0 -123
- package/dist/types/dom/patch-events.d.ts.map +0 -1
- package/dist/types/dom/patch-props.d.ts +0 -118
- package/dist/types/dom/patch-props.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -36
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/miniapp/api-adapter.d.ts +0 -514
- package/dist/types/miniapp/api-adapter.d.ts.map +0 -1
- package/dist/types/miniapp/index.d.ts +0 -34
- package/dist/types/miniapp/index.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-compiler.d.ts +0 -269
- package/dist/types/miniapp/miniapp-compiler.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-event-bridge.d.ts +0 -255
- package/dist/types/miniapp/miniapp-event-bridge.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-lifecycle.d.ts +0 -224
- package/dist/types/miniapp/miniapp-lifecycle.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-renderer.d.ts +0 -269
- package/dist/types/miniapp/miniapp-renderer.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-utils.d.ts +0 -168
- package/dist/types/miniapp/miniapp-utils.d.ts.map +0 -1
- package/dist/types/miniapp/shared-constants.d.ts +0 -28
- package/dist/types/miniapp/shared-constants.d.ts.map +0 -1
- package/dist/types/miniapp/style-compiler.d.ts +0 -193
- package/dist/types/miniapp/style-compiler.d.ts.map +0 -1
- package/dist/types/mount.d.ts +0 -32
- package/dist/types/mount.d.ts.map +0 -1
- package/dist/types/native/index.d.ts +0 -13
- package/dist/types/native/index.d.ts.map +0 -1
- package/dist/types/native/native-renderer.d.ts +0 -249
- package/dist/types/native/native-renderer.d.ts.map +0 -1
- package/dist/types/patch.d.ts +0 -23
- package/dist/types/patch.d.ts.map +0 -1
- package/dist/types/props.d.ts +0 -19
- package/dist/types/props.d.ts.map +0 -1
- package/dist/types/renderer-interfaces.d.ts +0 -157
- package/dist/types/renderer-interfaces.d.ts.map +0 -1
- package/dist/types/shared/abstract-renderer.d.ts +0 -74
- package/dist/types/shared/abstract-renderer.d.ts.map +0 -1
- package/dist/types/ssr/hydration.d.ts +0 -267
- package/dist/types/ssr/hydration.d.ts.map +0 -1
- package/dist/types/ssr/index.d.ts +0 -15
- package/dist/types/ssr/index.d.ts.map +0 -1
- package/dist/types/ssr/ssr-renderer.d.ts +0 -277
- package/dist/types/ssr/ssr-renderer.d.ts.map +0 -1
- package/dist/types/unmount.d.ts +0 -16
- package/dist/types/unmount.d.ts.map +0 -1
- package/dist/types/vapor/index.d.ts +0 -18
- package/dist/types/vapor/index.d.ts.map +0 -1
- package/dist/types/vapor/vapor-compiler.d.ts +0 -76
- package/dist/types/vapor/vapor-compiler.d.ts.map +0 -1
- package/dist/types/vapor/vapor-component.d.ts +0 -55
- package/dist/types/vapor/vapor-component.d.ts.map +0 -1
- package/dist/types/vapor/vapor-reactive.d.ts +0 -133
- package/dist/types/vapor/vapor-reactive.d.ts.map +0 -1
- package/dist/types/vapor/vapor-renderer.d.ts +0 -135
- package/dist/types/vapor/vapor-renderer.d.ts.map +0 -1
- package/dist/types/vnode.d.ts +0 -203
- package/dist/types/vnode.d.ts.map +0 -1
- package/dist/vapor.cjs +0 -1
- package/dist/vapor.mjs +0 -1
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lyt.js Vapor Mode - 渲染器
|
|
3
|
-
*
|
|
4
|
-
* Vapor Mode 绕过虚拟 DOM,直接操作真实 DOM。
|
|
5
|
-
* 每个 VaporNode 代表一个直接的 DOM 绑定关系,
|
|
6
|
-
* 当响应式信号变化时,只更新受影响的 DOM 节点。
|
|
7
|
-
*
|
|
8
|
-
* 核心思想:
|
|
9
|
-
* - 无 VNode 中间层,直接创建 DOM 元素
|
|
10
|
-
* - 无 diff 算法,每个绑定精确知道要更新哪个 DOM 节点
|
|
11
|
-
* - 信号变化时,直接操作对应的 DOM 属性
|
|
12
|
-
*/
|
|
13
|
-
import type { Signal } from '@lytjs/reactivity/signal';
|
|
14
|
-
import type { VaporElement, BindingCleanup } from './vapor-reactive';
|
|
15
|
-
import { bindText, bindProp, bindAttr, bindClass, bindEvent, bindIf, bindEach, bindStyle, bindHTML } from './vapor-reactive';
|
|
16
|
-
/** Vapor 绑定类型 */
|
|
17
|
-
export type VaporBindingType = 'text' | 'prop' | 'attr' | 'class' | 'style' | 'event';
|
|
18
|
-
/** Vapor 绑定描述 */
|
|
19
|
-
export interface VaporBinding<T = unknown> {
|
|
20
|
-
/** 绑定类型 */
|
|
21
|
-
type: VaporBindingType;
|
|
22
|
-
/** 目标属性名或事件名 */
|
|
23
|
-
target: string;
|
|
24
|
-
/** 绑定的响应式信号 */
|
|
25
|
-
signal?: Signal<T>;
|
|
26
|
-
/** 计算值表达式 */
|
|
27
|
-
expression?: () => T;
|
|
28
|
-
}
|
|
29
|
-
/** Vapor 节点 — 代表一个直接 DOM 绑定 */
|
|
30
|
-
export interface VaporNode {
|
|
31
|
-
/** HTML 标签名 */
|
|
32
|
-
tag: string;
|
|
33
|
-
/** 关联的真实 DOM 元素 */
|
|
34
|
-
el?: VaporElement;
|
|
35
|
-
/** 子节点 */
|
|
36
|
-
children: VaporNode[];
|
|
37
|
-
/** 静态属性 */
|
|
38
|
-
props: Record<string, unknown>;
|
|
39
|
-
/** 事件处理器 */
|
|
40
|
-
events: Record<string, Function>;
|
|
41
|
-
/** 响应式绑定列表 */
|
|
42
|
-
bindings: VaporBinding<unknown>[];
|
|
43
|
-
/** 文本内容(静态) */
|
|
44
|
-
text?: string;
|
|
45
|
-
/** 节点 key(用于列表渲染) */
|
|
46
|
-
key?: string | number;
|
|
47
|
-
/** 内部:绑定清理函数列表(用于 patch 时清理旧绑定) */
|
|
48
|
-
_bindingCleanups?: BindingCleanup[];
|
|
49
|
-
}
|
|
50
|
-
/** Vapor 挂载容器接口 */
|
|
51
|
-
export interface VaporContainer {
|
|
52
|
-
appendChild(child: VaporElement): void;
|
|
53
|
-
removeChild(child: VaporElement): void;
|
|
54
|
-
childNodes: VaporElement[];
|
|
55
|
-
firstChild: VaporElement | null;
|
|
56
|
-
}
|
|
57
|
-
/** Vapor 组件选项 */
|
|
58
|
-
export interface VaporComponentOptions {
|
|
59
|
-
/** 组件名称 */
|
|
60
|
-
name?: string;
|
|
61
|
-
/** 初始化函数,返回组件上下文 */
|
|
62
|
-
setup?: () => Record<string, unknown>;
|
|
63
|
-
/** 渲染函数,接收上下文和 createElement 函数 */
|
|
64
|
-
render?: (ctx: Record<string, unknown>, h: typeof createVaporElement) => VaporNode | VaporNode[];
|
|
65
|
-
/** 模板字符串(需要编译器) */
|
|
66
|
-
template?: string;
|
|
67
|
-
/** 子组件 */
|
|
68
|
-
components?: Record<string, VaporComponentOptions>;
|
|
69
|
-
/** 挂载前 */
|
|
70
|
-
beforeMount?: () => void;
|
|
71
|
-
/** 挂载后 */
|
|
72
|
-
mounted?: () => void;
|
|
73
|
-
/** 卸载前 */
|
|
74
|
-
beforeUnmount?: () => void;
|
|
75
|
-
/** 卸载后 */
|
|
76
|
-
unmounted?: () => void;
|
|
77
|
-
}
|
|
78
|
-
/** Vapor App 实例 */
|
|
79
|
-
export interface VaporApp {
|
|
80
|
-
/** 挂载到容器 */
|
|
81
|
-
mount(container: VaporContainer | string): void;
|
|
82
|
-
/** 卸载 */
|
|
83
|
-
unmount(): void;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* 设置自定义 DOM 工厂函数(用于测试环境)
|
|
87
|
-
*/
|
|
88
|
-
export declare function setVaporDOMFactory(factory: (tag: string) => VaporElement): void;
|
|
89
|
-
/**
|
|
90
|
-
* 获取当前 DOM 工厂函数
|
|
91
|
-
*/
|
|
92
|
-
export declare function getVaporDOMFactory(): (tag: string) => VaporElement;
|
|
93
|
-
/**
|
|
94
|
-
* 创建 Vapor 元素
|
|
95
|
-
*
|
|
96
|
-
* 直接创建 DOM 元素并应用静态属性,不涉及 VNode。
|
|
97
|
-
*
|
|
98
|
-
* @param tag HTML 标签名
|
|
99
|
-
* @param props 属性对象(可包含信号绑定)
|
|
100
|
-
* @param children 子节点
|
|
101
|
-
* @returns VaporNode
|
|
102
|
-
*/
|
|
103
|
-
export declare function createVaporElement(tag: string, props?: Record<string, unknown>, ...children: (VaporNode | string)[]): VaporNode;
|
|
104
|
-
/**
|
|
105
|
-
* 将 VaporNode 渲染为真实 DOM 元素
|
|
106
|
-
*
|
|
107
|
-
* 直接创建 DOM 元素树,并建立信号绑定。
|
|
108
|
-
*
|
|
109
|
-
* @param node VaporNode
|
|
110
|
-
* @returns 渲染后的 DOM 元素
|
|
111
|
-
*/
|
|
112
|
-
export declare function renderVaporNode(node: VaporNode): VaporElement;
|
|
113
|
-
/**
|
|
114
|
-
* Vapor Patch — 直接 DOM 更新,无 VDOM diff
|
|
115
|
-
*
|
|
116
|
-
* 与传统 VDOM patch 不同,Vapor patch 直接操作 DOM:
|
|
117
|
-
* - 如果 tag 相同,更新属性和绑定
|
|
118
|
-
* - 如果 tag 不同,替换整个 DOM 元素
|
|
119
|
-
*
|
|
120
|
-
* @param oldNode 旧的 VaporNode
|
|
121
|
-
* @param newNode 新的 VaporNode
|
|
122
|
-
* @param parentEl 父 DOM 元素
|
|
123
|
-
*/
|
|
124
|
-
export declare function vaporPatch(oldNode: VaporNode, newNode: VaporNode, parentEl: VaporElement): void;
|
|
125
|
-
/**
|
|
126
|
-
* 使用 Vapor Mode 挂载组件到容器
|
|
127
|
-
*
|
|
128
|
-
* @param container 挂载容器
|
|
129
|
-
* @param component 组件选项
|
|
130
|
-
* @returns 卸载函数
|
|
131
|
-
*/
|
|
132
|
-
export declare function vaporMount(container: VaporContainer, component: VaporComponentOptions): () => void;
|
|
133
|
-
export { bindText, bindProp, bindAttr, bindClass, bindEvent, bindIf, bindEach, bindStyle, bindHTML, };
|
|
134
|
-
export type { VaporElement, BindingCleanup, };
|
|
135
|
-
//# sourceMappingURL=vapor-renderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vapor-renderer.d.ts","sourceRoot":"","sources":["../../../src/vapor/vapor-renderer.ts"],"names":[],"mappings":"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"}
|
package/dist/types/vnode.d.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lyt.js 渲染器 — VNode 最小接口定义与辅助类型
|
|
3
|
-
*
|
|
4
|
-
* 本模块定义了渲染器所需的 VNode 接口、形状标记、补丁标记,
|
|
5
|
-
* 以及 Fragment/Text/Comment 类型标识符和辅助判断函数。
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* VNode 最小接口
|
|
9
|
-
*
|
|
10
|
-
* 本地定义渲染器所需的 VNode 字段,不依赖 @lytjs/vdom 包。
|
|
11
|
-
* 完整的 VNode 类型由 @lytjs/vdom 提供,此处仅声明渲染器使用到的字段。
|
|
12
|
-
*
|
|
13
|
-
* 在 monorepo 中,可以使用 import type 从 @lytjs/vdom 导入完整类型,
|
|
14
|
-
* 但为了保持渲染器包的独立性,此处定义最小接口。
|
|
15
|
-
*/
|
|
16
|
-
export interface VNode {
|
|
17
|
-
/** 节点类型:HTML 标签字符串 | 组件对象 | Symbol(Fragment/Text/Comment) */
|
|
18
|
-
type: string | object | symbol;
|
|
19
|
-
/** 节点属性 */
|
|
20
|
-
props: Record<string, unknown> | null;
|
|
21
|
-
/** 子节点:文本字符串 | VNode 数组 | 插槽对象 */
|
|
22
|
-
children: string | VNode[] | Record<string, unknown> | null;
|
|
23
|
-
/** 节点的唯一标识,用于列表 diff */
|
|
24
|
-
key: string | number | null;
|
|
25
|
-
/** ref 回调或 ref 对象 */
|
|
26
|
-
ref: ((el: unknown) => void) | {
|
|
27
|
-
current: unknown;
|
|
28
|
-
} | null;
|
|
29
|
-
/** 形状标记,描述节点类型和子节点形态 */
|
|
30
|
-
shapeFlag: number;
|
|
31
|
-
/** PatchFlag,标记哪些 props 是动态的 */
|
|
32
|
-
patchFlag: number;
|
|
33
|
-
/** 动态子节点列表(Block Tree 优化) */
|
|
34
|
-
dynamicChildren: VNode[] | null;
|
|
35
|
-
/** 动态 props 的键名列表 */
|
|
36
|
-
dynamicProps: string[] | null;
|
|
37
|
-
/** 关联的组件实例 */
|
|
38
|
-
component: {
|
|
39
|
-
update?: () => void;
|
|
40
|
-
subTree?: VNode;
|
|
41
|
-
[key: string]: unknown;
|
|
42
|
-
} | null;
|
|
43
|
-
/** 应用上下文(用于 provide/inject 等跨层级通信) */
|
|
44
|
-
appContext: Record<string, unknown> | null;
|
|
45
|
-
/** 对应的真实 DOM 元素引用 */
|
|
46
|
-
el: Element | Text | null;
|
|
47
|
-
/** Fragment 锚点 */
|
|
48
|
-
anchor: Element | Text | null;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* VNode 形状标记
|
|
52
|
-
*
|
|
53
|
-
* 使用位标记描述 VNode 的类型和子节点形态。
|
|
54
|
-
* 与 @lytjs/vdom 的 ShapeFlags 保持一致。
|
|
55
|
-
*/
|
|
56
|
-
export declare const enum ShapeFlags {
|
|
57
|
-
/** 普通 HTML/SVG 元素 */
|
|
58
|
-
ELEMENT = 1,
|
|
59
|
-
/** 函数式组件 */
|
|
60
|
-
FUNCTIONAL_COMPONENT = 2,
|
|
61
|
-
/** 有状态组件 */
|
|
62
|
-
STATEFUL_COMPONENT = 4,
|
|
63
|
-
/** 子节点是纯文本 */
|
|
64
|
-
TEXT_CHILDREN = 8,
|
|
65
|
-
/** 子节点是数组 */
|
|
66
|
-
ARRAY_CHILDREN = 16,
|
|
67
|
-
/** 子节点是插槽 */
|
|
68
|
-
SLOTS_CHILDREN = 32
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* PatchFlag 位标记
|
|
72
|
-
*
|
|
73
|
-
* 与 @lytjs/vdom 的 PatchFlags 保持一致。
|
|
74
|
-
*/
|
|
75
|
-
export declare const enum PatchFlags {
|
|
76
|
-
/** 动态文本 */
|
|
77
|
-
TEXT = 1,
|
|
78
|
-
/** 动态 class */
|
|
79
|
-
CLASS = 2,
|
|
80
|
-
/** 动态 style */
|
|
81
|
-
STYLE = 4,
|
|
82
|
-
/** 动态 props */
|
|
83
|
-
PROPS = 8,
|
|
84
|
-
/** 动态 props,键名可能变化 */
|
|
85
|
-
FULL_PROPS = 16,
|
|
86
|
-
/** 稳定的 Fragment */
|
|
87
|
-
STABLE_FRAGMENT = 32,
|
|
88
|
-
/** 带 key 的 Fragment */
|
|
89
|
-
KEYED_FRAGMENT = 64,
|
|
90
|
-
/** 不带 key 的 Fragment */
|
|
91
|
-
UNKEYED_FRAGMENT = 128,
|
|
92
|
-
/** 需要 patch */
|
|
93
|
-
NEED_PATCH = 256,
|
|
94
|
-
/** 动态插槽 */
|
|
95
|
-
DYNAMIC_SLOTS = 512,
|
|
96
|
-
/** 静态提升 */
|
|
97
|
-
HOISTED = -1,
|
|
98
|
-
/** 退出优化 */
|
|
99
|
-
BAIL = -2
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Fragment 类型标识符
|
|
103
|
-
*
|
|
104
|
-
* Fragment 用于表示一组没有父容器的子节点。
|
|
105
|
-
* 本地定义以避免依赖 @lytjs/vdom 包。
|
|
106
|
-
*/
|
|
107
|
-
export declare const Fragment: unique symbol;
|
|
108
|
-
/**
|
|
109
|
-
* Text 类型标识符
|
|
110
|
-
*/
|
|
111
|
-
export declare const Text: unique symbol;
|
|
112
|
-
/**
|
|
113
|
-
* Comment 类型标识符
|
|
114
|
-
*/
|
|
115
|
-
export declare const Comment: unique symbol;
|
|
116
|
-
/**
|
|
117
|
-
* 判断 VNode 是否为 Fragment 类型
|
|
118
|
-
*
|
|
119
|
-
* @param vnode - 待检测的虚拟节点
|
|
120
|
-
* @returns 如果节点类型为 Fragment 则返回 true
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```ts
|
|
124
|
-
* import { isFragment, Fragment, h } from '@lytjs/renderer'
|
|
125
|
-
*
|
|
126
|
-
* const vnode = h(Fragment, null, [h('div', null, 'A'), h('div', null, 'B')])
|
|
127
|
-
* console.log(isFragment(vnode)) // true
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
export declare function isFragment(vnode: VNode): boolean;
|
|
131
|
-
/**
|
|
132
|
-
* 判断 VNode 是否为文本类型
|
|
133
|
-
*
|
|
134
|
-
* @param vnode - 待检测的虚拟节点
|
|
135
|
-
* @returns 如果节点类型为 Text 则返回 true
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```ts
|
|
139
|
-
* import { isTextVNode, Text, h } from '@lytjs/renderer'
|
|
140
|
-
*
|
|
141
|
-
* const vnode = h(Text, null, 'hello')
|
|
142
|
-
* console.log(isTextVNode(vnode)) // true
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
export declare function isTextVNode(vnode: VNode): boolean;
|
|
146
|
-
/**
|
|
147
|
-
* 判断 VNode 是否为注释类型
|
|
148
|
-
*
|
|
149
|
-
* @param vnode - 待检测的虚拟节点
|
|
150
|
-
* @returns 如果节点类型为 Comment 则返回 true
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts
|
|
154
|
-
* import { isCommentVNode, Comment, h } from '@lytjs/renderer'
|
|
155
|
-
*
|
|
156
|
-
* const vnode = h(Comment, null, 'conditional comment')
|
|
157
|
-
* console.log(isCommentVNode(vnode)) // true
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
export declare function isCommentVNode(vnode: VNode): boolean;
|
|
161
|
-
/**
|
|
162
|
-
* 判断两个 VNode 是否为相同类型
|
|
163
|
-
*
|
|
164
|
-
* 相同类型的定义:type 相同且 key 相同。
|
|
165
|
-
* 在 diff 算法中,只有相同类型的 VNode 才会进行 patch 复用。
|
|
166
|
-
*
|
|
167
|
-
* @param n1 - 第一个虚拟节点
|
|
168
|
-
* @param n2 - 第二个虚拟节点
|
|
169
|
-
* @returns 如果两个节点的 type 和 key 均相同则返回 true
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```ts
|
|
173
|
-
* import { isSameVNodeType, h } from '@lytjs/renderer'
|
|
174
|
-
*
|
|
175
|
-
* const a = h('div', { key: 'x' }, 'hello')
|
|
176
|
-
* const b = h('div', { key: 'x' }, 'world')
|
|
177
|
-
* const c = h('span', { key: 'x' }, 'hello')
|
|
178
|
-
*
|
|
179
|
-
* console.log(isSameVNodeType(a, b)) // true(type 和 key 相同)
|
|
180
|
-
* console.log(isSameVNodeType(a, c)) // false(type 不同)
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
export declare function isSameVNodeType(n1: VNode, n2: VNode): boolean;
|
|
184
|
-
/**
|
|
185
|
-
* 判断 VNode 是否为 Block
|
|
186
|
-
*
|
|
187
|
-
* Block 的 dynamicChildren 是非 null 的数组。
|
|
188
|
-
* Block Tree 优化允许跳过静态子树的 diff,仅更新 dynamicChildren 列表中的节点。
|
|
189
|
-
*
|
|
190
|
-
* @param vnode - 待检测的虚拟节点
|
|
191
|
-
* @returns 如果节点是 Block 则返回 true
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* import { isBlock, h, openBlock } from '@lytjs/renderer'
|
|
196
|
-
*
|
|
197
|
-
* // Block 节点在编译时通过 openBlock() 创建
|
|
198
|
-
* const vnode = openBlock(() => h('div', null, h('span', null, 'dynamic')))
|
|
199
|
-
* console.log(isBlock(vnode)) // true
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
export declare function isBlock(vnode: VNode): boolean;
|
|
203
|
-
//# sourceMappingURL=vnode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vnode.d.ts","sourceRoot":"","sources":["../../src/vnode.ts"],"names":[],"mappings":"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"}
|
package/dist/vapor.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var G=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var Re=(e,o)=>{for(var t in o)G(e,t,{get:o[t],enumerable:!0})},be=(e,o,t,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of ve(o))!xe.call(e,n)&&n!==t&&G(e,n,{get:()=>o[n],enumerable:!(r=Ne(o,n))||r.enumerable});return e};var Te=e=>be(G({},"__esModule",{value:!0}),e);var He={};Re(He,{Comment:()=>Q,Fragment:()=>q,PatchFlags:()=>B,ShapeFlags:()=>v,Text:()=>J,bindAttr:()=>k,bindClass:()=>A,bindEach:()=>O,bindEvent:()=>U,bindHTML:()=>ie,bindIf:()=>L,bindProp:()=>w,bindStyle:()=>S,bindText:()=>T,compileToVapor:()=>Z,createRenderer:()=>fe,createVaporApp:()=>Ce,createVaporElement:()=>_,defineVaporComponent:()=>Ve,getVaporDOMFactory:()=>R,parseTemplate:()=>X,renderVaporComponent:()=>Ee,renderVaporNode:()=>h,setVaporDOMFactory:()=>ge,vaporMount:()=>Y,vaporPatch:()=>se});module.exports=Te(He);var ue=require("@lytjs/vdom");var v=(l=>(l[l.ELEMENT=1]="ELEMENT",l[l.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",l[l.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",l[l.TEXT_CHILDREN=8]="TEXT_CHILDREN",l[l.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",l[l.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",l))(v||{}),B=(c=>(c[c.TEXT=1]="TEXT",c[c.CLASS=2]="CLASS",c[c.STYLE=4]="STYLE",c[c.PROPS=8]="PROPS",c[c.FULL_PROPS=16]="FULL_PROPS",c[c.STABLE_FRAGMENT=32]="STABLE_FRAGMENT",c[c.KEYED_FRAGMENT=64]="KEYED_FRAGMENT",c[c.UNKEYED_FRAGMENT=128]="UNKEYED_FRAGMENT",c[c.NEED_PATCH=256]="NEED_PATCH",c[c.DYNAMIC_SLOTS=512]="DYNAMIC_SLOTS",c[c.HOISTED=-1]="HOISTED",c[c.BAIL=-2]="BAIL",c))(B||{}),q=Symbol("Fragment"),J=Symbol("Text"),Q=Symbol("Comment");function x(e){return e.type===q}function I(e){return e.type===J}function D(e){return e.type===Q}function ae(e,o){return e.type===o.type&&e.key===o.key}function ee(e){return Array.isArray(e.dynamicChildren)}function pe(e,o,t,r){if(t==="class")e.setClass(o,r);else if(t==="style")e.setStyle(o,r);else if(t.startsWith("on")||t.startsWith("@")){let n=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();e.addEventListener(o,n,r)}else t==="key"||t==="ref"||e.setAttribute(o,t,r)}function ne(e,o,t,r,n){if(t==="class")e.setClass(o,r);else if(t==="style")e.setStyle(o,r||{});else if(t.startsWith("on")||t.startsWith("@")){let i=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();n&&e.removeEventListener(o,i,n),r&&e.addEventListener(o,i,r)}else e.setAttribute(o,t,r)}function te(e,o,t,r){for(let n in r){if(n==="key"||n==="ref")continue;let i=t[n],l=r[n];l!==i&&ne(e,o,n,l,i)}for(let n in t)if(!(n==="key"||n==="ref")&&!(n in r))if(n==="class")e.setClass(o,"");else if(n==="style")e.setStyle(o,{});else if(n.startsWith("on")||n.startsWith("@")){let i=n.startsWith("@")?n.slice(1).toLowerCase():n.slice(2).toLowerCase();e.removeEventListener(o,i,t[n])}else e.removeAttribute(o,n)}function oe(e,o,t,r,n,i){let{shapeFlag:l}=t;if(x(t)){ke(e,o,t,r,n,i);return}if(I(t)){let s=e.createText(t.children);t.el=s,e.insert(r,s,n);return}if(D(t)){let s=e.createComment(t.children);t.el=s,e.insert(r,s,n);return}if(l&1){we(e,o,t,r,n,i);return}if(l&6){Ae(o,t,r,n,i);return}}function we(e,o,t,r,n,i){let l=t.type,s=e.createElement(l);if(t.el=s,t.props)for(let d in t.props){let g=t.props[d];pe(e,s,d,g)}let{shapeFlag:a,children:p}=t;a&8?s.textContent=p:a&16&&j(o,p,s,null,i),e.insert(r,s,n)}function j(e,o,t,r,n){for(let i=0;i<o.length;i++)e(null,o[i],t,r,n)}function ke(e,o,t,r,n,i){let{children:l}=t,s=e.createComment("");e.insert(r,s,n),Array.isArray(l)&&l.length>0&&j(o,l,r,s,i),t.el=s,t.anchor=s}function Ae(e,o,t,r,n){let i=o.component;i&&i.update&&i.update(),i&&i.subTree&&(e(null,i.subTree,t,r,i),o.el=i.subTree.el)}function ce(e,o,t,r){let{shapeFlag:n,children:i}=t;if(x(t)){if(Array.isArray(i))for(let l=0;l<i.length;l++)o(i[l],r);t.anchor&&t.anchor.parentNode&&e.remove(t.anchor);return}if(n&6){t.component&&t.component.subTree&&o(t.component.subTree,r);return}t.el&&e.remove(t.el)}function H(e,o){for(let t=0;t<o.length;t++)e(o[t])}var P=require("@lytjs/vdom");function F(e,o,t,r,n,i=null,l=null){if(r==null){t&&o(t,n);return}if(t===null){oe(e,re(e,o),r,n,i,l);return}if(ee(r)&&ee(t)){_e(e,o,t,r,n,l);return}if(!ae(t,r)){o(t,n),oe(e,re(e,o),r,n,i,l);return}r.el=t.el,r.anchor=t.anchor;let{shapeFlag:s}=r;if(x(r)){Oe(e,o,t,r,n,i,l);return}if(I(r)){r.children!==t.children&&(r.el.nodeValue=r.children);return}if(D(r)){r.children!==t.children&&(r.el.nodeValue=r.children);return}if(s&1){Se(e,o,t,r,l);return}if(s&6){Me(t,r,l);return}}function re(e,o){return(t,r,n,i,l)=>{F(e,o,t,r,n,i,l)}}function Se(e,o,t,r,n=null){let i=r.el=t.el,l=t.props||{},s=r.props||{},{patchFlag:a,dynamicProps:p}=r;if(a&&a>0){if(a&1&&t.children!==r.children&&(i.textContent=r.children),a&2&&l.class!==s.class&&e.setClass(i,s.class),a&4&&l.style!==s.style&&e.setStyle(i,s.style||{}),a&8&&p)for(let d=0;d<p.length;d++){let g=p[d],c=l[g],f=s[g];f!==c&&ne(e,i,g,f,c)}a&16&&te(e,i,l,s)}else te(e,i,l,s);(!a||!(a&1))&&de(e,o,t,r,i,null,n)}function de(e,o,t,r,n,i,l){let s=t.shapeFlag,a=r.shapeFlag,p=t.children,d=r.children;if(a&8){s&16&&H(o,p),p!==d&&(n.textContent=d);return}if(a&16){s&16?Le(e,o,p,d,n,i,l):(s&8&&(n.textContent=""),j(re(e,o),d,n,i,l));return}d==null&&(s&8?n.textContent="":s&16&&H(o,p))}function Le(e,o,t,r,n,i,l){r.every(a=>a.key!==null&&a.key!==void 0)&&t.every(a=>a.key!==null&&a.key!==void 0)?(0,P.patchKeyedChildren)(t,r,n,i,l,null,!1):(0,P.patchUnkeyedChildren)(t,r,n,i,l,null,!1)}function Oe(e,o,t,r,n,i,l){let s=t.children,a=r.children;Array.isArray(a)&&a.length>0?(de(e,o,t,r,n,i,l),r.el=a[0].el,r.anchor=a[a.length-1].el?e.nextSibling(a[a.length-1].el):i):Array.isArray(s)&&s.length>0&&a===null?(H(o,s),r.el=t.el,r.anchor=t.anchor):(r.el=t.el,r.anchor=t.anchor)}function _e(e,o,t,r,n,i){let l=t.dynamicChildren,s=r.dynamicChildren;for(let a=0;a<s.length;a++)F(e,o,l[a],s[a],n,null,i)}function Me(e,o,t){o.component=e.component,o.el=e.el,o.component&&o.component.update&&o.component.update()}function fe(e){function o(n,i){ce(e,o,n,i)}(0,ue.registerDOMOperations)({insert(n,i,l){e.insert(i,n,l)},createElement(n){return e.createElement(n)},createText(n){return e.createText(n)},setText(n,i){n.nodeValue=i},setElementText(n,i){n.textContent=i},remove(n){e.remove(n)},createComment(n){return e.createComment(n)},mount(n,i,l,s,a,p,d){r(null,n,i,l,s)},patch(n,i,l,s,a,p,d,g){r(n,i,l,s,a)},unmount(n,i,l,s){o(n)},move(n,i,l){e.insert(i,n.el,l)}});function r(n,i,l,s,a){F(e,o,n,i,l,s,a)}return{mount(n,i){i.nodeType===1&&(i.textContent=""),r(null,n,i,null,null)},patch(n,i,l){var s;r(n,i,l||((s=n.el)==null?void 0:s.parentNode),null,null)},unmount(n,i){o(n,i)}}}var V=require("@lytjs/reactivity/signal");function T(e,o){return(0,V.effect)(()=>{let r=o();e.textContent=r==null?"":String(r)})}function w(e,o,t){return(0,V.effect)(()=>{let n=t();e[o]=n})}function k(e,o,t){return(0,V.effect)(()=>{let n=t();n==null||n===!1?e.removeAttribute(o):e.setAttribute(o,n===!0?"":String(n))})}function A(e,o){return(0,V.effect)(()=>{let r=o();if(typeof r=="string")e.className=r;else if(Array.isArray(r))e.className=r.filter(Boolean).join(" ");else if(typeof r=="object"&&r!==null){let n=[],i=r;for(let l of Object.keys(i))i[l]&&n.push(l);e.className=n.join(" ")}else e.className=""})}function U(e,o,t){return e.addEventListener(o,t),()=>{e.removeEventListener(o,t)}}function S(e,o){return(0,V.effect)(()=>{let r=o();if(typeof r=="string")e.style=r;else if(typeof r=="object"&&r!==null){let n=e.style;for(let i of Object.keys(n))n[i]="";for(let[i,l]of Object.entries(r))n[i]=l}else e.style=""})}function ie(e,o){return(0,V.effect)(()=>{let r=o(),n=r==null?"":String(r);e.innerHTML!==n&&(e.innerHTML=n)})}function L(e,o,t){let r=e.parentNode!==null,n=t||null;!n&&e.parentNode&&(n=e.parentNode);let i=(0,V.effect)(()=>{o()?r||(n&&n.parentNode?n.parentNode.insertBefore(e,n.nextSibling):n&&n.appendChild(e),r=!0):r&&e.parentNode&&(e.parentNode.removeChild(e),r=!1)});return()=>{i(),r&&e.parentNode&&e.parentNode.removeChild(e)}}function O(e,o,t,r){let n=[],i=[],l=new Map,s=(0,V.effect)(()=>{let a=o();if(!Array.isArray(a))return;let p=a.map((f,u)=>r?r(f,u):u);if(p.length===i.length){let f=!0;for(let u=0;u<p.length;u++)if(p[u]!==i[u]){f=!1;break}if(f){for(let u=0;u<a.length;u++){let m=t(a[u],u),y=n[u];y&&y.parentNode===e&&e.replaceChild(m,y),n[u]=m,l.set(p[u],m)}return}}let d=new Set(i),g=new Set(p),c=new Map;for(let f=0;f<a.length;f++){let u=p[f];if(d.has(u)&&l.has(u)){let m=l.get(u);c.set(u,m),l.delete(u)}else{let m=t(a[f],f);c.set(u,m)}}for(let[f,u]of l)!g.has(f)&&u.parentNode===e&&e.removeChild(u);for(let f of n)f.parentNode===e&&e.removeChild(f);n=[],i=[];for(let f=0;f<a.length;f++){let u=p[f],m=c.get(u);e.appendChild(m),n.push(m),i.push(u)}l.clear();for(let[f,u]of c)l.set(f,u)});return()=>{s();for(let a of n)a.parentNode===e&&e.removeChild(a);n=[],i=[],l.clear()}}var W=require("@lytjs/common"),K=e=>{if(typeof document!="undefined")return document.createElement(e);throw new W.LytError(W.LytErrorCodes.LYT_RENDERER_VAPOR_ERROR,"\u672A\u8BBE\u7F6E DOM \u5DE5\u5382\u51FD\u6570\u3002\u5728\u975E\u6D4F\u89C8\u5668\u73AF\u5883\u4E2D\u8BF7\u8C03\u7528 setVaporDOMFactory()")};function ge(e){K=e}function R(){return K}function _(e,o,...t){let r={tag:e,children:[],props:{},events:{},bindings:[]};if(o)for(let[n,i]of Object.entries(o))if(n.startsWith("on")&&typeof i=="function"&&!me(i)){let l=n.slice(2).toLowerCase();r.events[l]=i}else me(i)?n==="textContent"||n==="text"?r.bindings.push({type:"text",target:"textContent",signal:i}):n==="className"||n==="class"?r.bindings.push({type:"class",target:"className",signal:i}):n==="style"?r.bindings.push({type:"style",target:"style",signal:i}):r.bindings.push({type:"prop",target:n,signal:i}):r.props[n]=i;for(let n of t)typeof n=="string"?r.children.push({tag:"#text",children:[],props:{},events:{},bindings:[],text:n}):r.children.push(n);return r}function me(e){if(typeof e!="function")return!1;let o=e;return!!o._subscribe||!!(o.set&&o._subscribe)}function h(e){if(e.tag==="#text"){let n=K("#text");return n.textContent=e.text||"",n.nodeType=3,n}let o=K(e.tag);e.el=o;let t=o;for(let[n,i]of Object.entries(e.props))if(n==="style"&&typeof i=="object"&&i!==null)for(let[l,s]of Object.entries(i))t.style[l]=s;else n==="className"||n==="class"?o.className=String(i):t[n]=i;let r=[];for(let n of e.bindings){if(!n.signal)continue;let i;if(n.type==="text")i=T(o,n.signal);else if(n.type==="prop")i=w(o,n.target,n.signal);else if(n.type==="attr")i=k(o,n.target,n.signal);else if(n.type==="class")i=A(o,n.signal);else if(n.type==="style")i=S(o,n.signal);else continue;r.push(i)}e._bindingCleanups=r;for(let[n,i]of Object.entries(e.events))U(o,n,i);for(let n of e.children){let i=h(n);o.appendChild(i)}return o}function se(e,o,t){if(e.tag!==o.tag){let s=h(o);e.el&&e.el.parentNode===t&&t.removeChild(e.el),t.appendChild(s);return}let r=e.el||h(e);o.el=r;let n=r;if(e._bindingCleanups)for(let s of e._bindingCleanups)s();let i=[];for(let s of o.bindings){if(!s.signal)continue;let a;if(s.type==="text")a=T(r,s.signal);else if(s.type==="prop")a=w(r,s.target,s.signal);else if(s.type==="attr")a=k(r,s.target,s.signal);else if(s.type==="class")a=A(r,s.signal);else if(s.type==="style")a=S(r,s.signal);else continue;i.push(a)}o._bindingCleanups=i;for(let[s,a]of Object.entries(o.props))if(s==="style"&&typeof a=="object"&&a!==null)for(let[p,d]of Object.entries(a))n.style[p]=d;else s==="className"||s==="class"?r.className=String(a):n[s]=a;o.text!==void 0&&(r.textContent=o.text);for(let[s,a]of Object.entries(e.events))o.events[s]||r.removeEventListener(s,a);for(let[s,a]of Object.entries(o.events))e.events[s]!==a&&(e.events[s]&&r.removeEventListener(s,e.events[s]),r.addEventListener(s,a));let l=Math.max(e.children.length,o.children.length);for(let s=0;s<l;s++){let a=e.children[s],p=o.children[s];if(!a&&p){let d=h(p);r.appendChild(d)}else a&&!p?a.el&&a.el.parentNode===r&&r.removeChild(a.el):a&&p&&se(a,p,r)}}function Y(e,o){let t=o.setup?o.setup():{};o.beforeMount&&o.beforeMount();let r;if(o.render){let l=o.render(t,_);r=Array.isArray(l)?l:[l]}else r=[];let n=[],i=[];for(let l of r){let s=h(l);e.appendChild(s),n.push(s),ye(l,i)}return o.mounted&&o.mounted(),()=>{o.beforeUnmount&&o.beforeUnmount();for(let l of i)l();for(let l of n)(l.parentNode===e||e===l.parentNode)&&e.removeChild(l);o.unmounted&&o.unmounted()}}function ye(e,o){e._bindingCleanups&&o.push(...e._bindingCleanups);for(let t of e.children)ye(t,o)}var le=require("@lytjs/reactivity/signal");var z=require("@lytjs/common");function X(e){var r,n,i,l,s;let o={type:"fragment",children:[]},t=e.trim();for(;t.length>0;){let a=t.match(/^<([a-zA-Z][a-zA-Z0-9-]*)([\s\S]*?)(\/?)>/);if(a){let p=a[1],d=a[2],g=a[3]==="/",{props:c,events:f,directives:u}=Ie(d),m={type:"element",tag:p,props:c,events:f,directives:u,children:[]};if(t=t.slice(a[0].length),g){((r=o.children)!=null?r:[]).push(m);continue}let y=`</${p}>`,C=Be(t,p);if(C===-1)throw new z.LytError(z.LytErrorCodes.LYT_RENDERER_VAPOR_COMPILER_ERROR,`\u672A\u627E\u5230\u95ED\u5408\u6807\u7B7E: </${p}>`);let E=t.slice(0,C);t=t.slice(C+y.length);let N=X(E);m.children=N.children||[],((n=o.children)!=null?n:[]).push(m)}else{let p=t.indexOf("<"),d;if(p===-1?(d=t,t=""):(d=t.slice(0,p),t=t.slice(p)),d.trim())if(d.includes("{{")){let g=De(d);for(let c of g)c.type==="text"?((i=o.children)!=null?i:[]).push({type:"text",text:c.value}):((l=o.children)!=null?l:[]).push({type:"interpolation",expression:c.value})}else((s=o.children)!=null?s:[]).push({type:"text",text:d})}}return o}function Be(e,o){let t=1,r=0,n=`<${o}`,i=`</${o}>`;for(;r<e.length&&t>0;){let l=e.indexOf(n,r),s=e.indexOf(i,r);if(s===-1)return-1;if(l!==-1&&l<s){let a=e[l+n.length];a===">"||a===" "||a==="/"?(t++,r=l+n.length):(r=s+i.length,t--)}else r=s+i.length,t--}return t===0?r-i.length:-1}function Ie(e){let o={},t={},r={},n=/([a-zA-Z@:][a-zA-Z0-9@:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,i;for(;(i=n.exec(e))!==null;){let l=i[1],s=i[2]||i[3];if(l.startsWith("on:")){let a=l.slice(3);t[a]=s}else if(l.startsWith(":")){let a=l.slice(1);o[a]=s}else if(l==="v-if")r.if=s;else if(l==="v-each"){let a=s.match(/^\s*(\w+)\s+in\s+(.+)\s*$/);a&&(r.each={item:a[1],expression:a[2]})}else o[l]=s}return{props:o,events:t,directives:r}}function De(e){let o=[],t=/\{\{([\s\S]*?)\}\}/g,r=0,n;for(;(n=t.exec(e))!==null;)n.index>r&&o.push({type:"text",value:e.slice(r,n.index)}),o.push({type:"interpolation",value:n[1].trim()}),r=n.index+n[0].length;return r<e.length&&o.push({type:"text",value:e.slice(r)}),o}function Z(e){let o=X(e);return{render:je(o),ast:o}}function je(e){return function(t){let r=R();return b(e,t,r)}}function b(e,o,t){var r,n;if(e.type==="fragment"){if(e.children&&e.children.length===1)return b(e.children[0],o,t);let i=t("div");if(i.nodeType=11,i.childNodes=i.childNodes||[],e.children)for(let l of e.children){let s=b(l,o,t);i.appendChild?i.appendChild(s):i.childNodes.push(s)}return i}if(e.type==="text"){let i=t("#text");return i.textContent=e.text||"",i.nodeType=3,i}if(e.type==="interpolation"){let i=t("span"),l=e.expression||"",s=M(o,l);if($(s)){let a=s,p=t("#text");p.nodeType=3,p.textContent=String(a());let d=(0,le.effect)(()=>{p.textContent=a()===null||a()===void 0?"":String(a())});i.appendChild(p),i._bindingCleanup=d,he(i,d)}else i.textContent=s!=null?String(s):"";return i}if(e.type==="element"){if((r=e.directives)!=null&&r.each){let{item:s,expression:a}=e.directives.each,p=M(o,a);if($(p)){let c=t("#fragment");c.childNodes=[],c.nodeType=11;let f=c;return O(f,p,(u,m)=>{let y={...o,[s]:u,index:m},C=t(e.tag||"div");if(e.props)for(let[E,N]of Object.entries(e.props))E==="class"||E==="className"?C.className=N:C[E]=N;if(e.children)for(let E of e.children){let N=b(E,y,t);C.appendChild(N)}return C}),f}let d=Array.isArray(p)?p:[],g=t("#fragment");if(g.childNodes=[],g.nodeType=11,d.length>0)for(let c=0;c<d.length;c++){let f={...o,[s]:d[c],index:c},u=t(e.tag||"div");if(e.props)for(let[m,y]of Object.entries(e.props))m==="class"||m==="className"?u.className=y:u[m]=y;if(e.children)for(let m of e.children){let y=b(m,f,t);u.appendChild(y)}g.appendChild(u)}return g}let i=t(e.tag||"div"),l=i;if((n=e.directives)!=null&&n.if){let s=M(o,e.directives.if);$(s)?L(i,s):s||(l.style=l.style||{},l.style.display="none",l.hidden=!0)}if(e.props)for(let[s,a]of Object.entries(e.props))if(s.startsWith(":")){let p=s.slice(1),d=M(o,a);if($(d)){let g=d,c=(0,le.effect)(()=>{l[p]=g()});i._propBindingCleanup=c,he(i,c)}else l[p]=d}else s==="class"||s==="className"?i.className=a:l[s]=a;if(e.events)for(let[s,a]of Object.entries(e.events)){let p=M(o,a);typeof p=="function"&&i.addEventListener(s,p)}if(e.children)for(let s of e.children){let a=b(s,o,t);if(a.nodeType===11&&a.childNodes)for(let p of a.childNodes)i.appendChild(p);else i.appendChild(a)}return i}return t("div")}function M(e,o){let t=o.trim();if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))return e[t];let r=t.split("."),n=e;for(let i of r){if(n==null)return;n=n[i]}return n}function $(e){return typeof e!="function"?!1:!!e._subscribe}function he(e,o){let t=e;t._cleanupEffects||(t._cleanupEffects=[]),t._cleanupEffects.push(o)}function Ve(e){return e.__vapor__=!0,e}function Ce(e){let o=!1,t=null,r=null;return{mount(n){if(!o){if(typeof n=="string")if(typeof document!="undefined"){let i=document.querySelector(n);if(!i)throw new Error(`[lyt:vapor] \u672A\u627E\u5230\u6302\u8F7D\u76EE\u6807: ${n}`);r=i}else throw new Error("[lyt:vapor] \u5728\u975E\u6D4F\u89C8\u5668\u73AF\u5883\u4E2D\uFF0C\u8BF7\u76F4\u63A5\u4F20\u5165\u5BB9\u5668\u5143\u7D20");else r=n;t=Y(r,e),o=!0}},unmount(){o&&(t&&(t(),t=null),o=!1,r=null)}}}function Ee(e,o){let t=e.setup?{...e.setup(),...o}:{...o};e.beforeMount&&e.beforeMount();let r;if(e.template){let{render:n}=Z(e.template);r=n(t)}else if(e.render){let n=e.render(t,_),i=Array.isArray(n)?n:[n];if(i.length===1)r=h(i[0]);else{r=R()("div");for(let s of i)r.appendChild(h(s))}}else throw new Error("[lyt:vapor] \u7EC4\u4EF6\u5FC5\u987B\u63D0\u4F9B template \u6216 render \u51FD\u6570");return e.mounted&&e.mounted(),r}
|
package/dist/vapor.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{registerDOMOperations as Ne}from"@lytjs/vdom";var R=(l=>(l[l.ELEMENT=1]="ELEMENT",l[l.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",l[l.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",l[l.TEXT_CHILDREN=8]="TEXT_CHILDREN",l[l.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",l[l.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",l))(R||{}),U=(c=>(c[c.TEXT=1]="TEXT",c[c.CLASS=2]="CLASS",c[c.STYLE=4]="STYLE",c[c.PROPS=8]="PROPS",c[c.FULL_PROPS=16]="FULL_PROPS",c[c.STABLE_FRAGMENT=32]="STABLE_FRAGMENT",c[c.KEYED_FRAGMENT=64]="KEYED_FRAGMENT",c[c.UNKEYED_FRAGMENT=128]="UNKEYED_FRAGMENT",c[c.NEED_PATCH=256]="NEED_PATCH",c[c.DYNAMIC_SLOTS=512]="DYNAMIC_SLOTS",c[c.HOISTED=-1]="HOISTED",c[c.BAIL=-2]="BAIL",c))(U||{}),J=Symbol("Fragment"),Q=Symbol("Text"),ee=Symbol("Comment");function v(e){return e.type===J}function w(e){return e.type===Q}function k(e){return e.type===ee}function ne(e,r){return e.type===r.type&&e.key===r.key}function K(e){return Array.isArray(e.dynamicChildren)}function te(e,r,t,o){if(t==="class")e.setClass(r,o);else if(t==="style")e.setStyle(r,o);else if(t.startsWith("on")||t.startsWith("@")){let n=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();e.addEventListener(r,n,o)}else t==="key"||t==="ref"||e.setAttribute(r,t,o)}function W(e,r,t,o,n){if(t==="class")e.setClass(r,o);else if(t==="style")e.setStyle(r,o||{});else if(t.startsWith("on")||t.startsWith("@")){let i=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();n&&e.removeEventListener(r,i,n),o&&e.addEventListener(r,i,o)}else e.setAttribute(r,t,o)}function Y(e,r,t,o){for(let n in o){if(n==="key"||n==="ref")continue;let i=t[n],l=o[n];l!==i&&W(e,r,n,l,i)}for(let n in t)if(!(n==="key"||n==="ref")&&!(n in o))if(n==="class")e.setClass(r,"");else if(n==="style")e.setStyle(r,{});else if(n.startsWith("on")||n.startsWith("@")){let i=n.startsWith("@")?n.slice(1).toLowerCase():n.slice(2).toLowerCase();e.removeEventListener(r,i,t[n])}else e.removeAttribute(r,n)}function $(e,r,t,o,n,i){let{shapeFlag:l}=t;if(v(t)){ue(e,r,t,o,n,i);return}if(w(t)){let s=e.createText(t.children);t.el=s,e.insert(o,s,n);return}if(k(t)){let s=e.createComment(t.children);t.el=s,e.insert(o,s,n);return}if(l&1){de(e,r,t,o,n,i);return}if(l&6){fe(r,t,o,n,i);return}}function de(e,r,t,o,n,i){let l=t.type,s=e.createElement(l);if(t.el=s,t.props)for(let d in t.props){let g=t.props[d];te(e,s,d,g)}let{shapeFlag:a,children:p}=t;a&8?s.textContent=p:a&16&&A(r,p,s,null,i),e.insert(o,s,n)}function A(e,r,t,o,n){for(let i=0;i<r.length;i++)e(null,r[i],t,o,n)}function ue(e,r,t,o,n,i){let{children:l}=t,s=e.createComment("");e.insert(o,s,n),Array.isArray(l)&&l.length>0&&A(r,l,o,s,i),t.el=s,t.anchor=s}function fe(e,r,t,o,n){let i=r.component;i&&i.update&&i.update(),i&&i.subTree&&(e(null,i.subTree,t,o,i),r.el=i.subTree.el)}function oe(e,r,t,o){let{shapeFlag:n,children:i}=t;if(v(t)){if(Array.isArray(i))for(let l=0;l<i.length;l++)r(i[l],o);t.anchor&&t.anchor.parentNode&&e.remove(t.anchor);return}if(n&6){t.component&&t.component.subTree&&r(t.component.subTree,o);return}t.el&&e.remove(t.el)}function S(e,r){for(let t=0;t<r.length;t++)e(r[t])}import{patchKeyedChildren as me,patchUnkeyedChildren as ge}from"@lytjs/vdom";function L(e,r,t,o,n,i=null,l=null){if(o==null){t&&r(t,n);return}if(t===null){$(e,z(e,r),o,n,i,l);return}if(K(o)&&K(t)){Ce(e,r,t,o,n,l);return}if(!ne(t,o)){r(t,n),$(e,z(e,r),o,n,i,l);return}o.el=t.el,o.anchor=t.anchor;let{shapeFlag:s}=o;if(v(o)){Ve(e,r,t,o,n,i,l);return}if(w(o)){o.children!==t.children&&(o.el.nodeValue=o.children);return}if(k(o)){o.children!==t.children&&(o.el.nodeValue=o.children);return}if(s&1){ye(e,r,t,o,l);return}if(s&6){Ee(t,o,l);return}}function z(e,r){return(t,o,n,i,l)=>{L(e,r,t,o,n,i,l)}}function ye(e,r,t,o,n=null){let i=o.el=t.el,l=t.props||{},s=o.props||{},{patchFlag:a,dynamicProps:p}=o;if(a&&a>0){if(a&1&&t.children!==o.children&&(i.textContent=o.children),a&2&&l.class!==s.class&&e.setClass(i,s.class),a&4&&l.style!==s.style&&e.setStyle(i,s.style||{}),a&8&&p)for(let d=0;d<p.length;d++){let g=p[d],c=l[g],f=s[g];f!==c&&W(e,i,g,f,c)}a&16&&Y(e,i,l,s)}else Y(e,i,l,s);(!a||!(a&1))&&re(e,r,t,o,i,null,n)}function re(e,r,t,o,n,i,l){let s=t.shapeFlag,a=o.shapeFlag,p=t.children,d=o.children;if(a&8){s&16&&S(r,p),p!==d&&(n.textContent=d);return}if(a&16){s&16?he(e,r,p,d,n,i,l):(s&8&&(n.textContent=""),A(z(e,r),d,n,i,l));return}d==null&&(s&8?n.textContent="":s&16&&S(r,p))}function he(e,r,t,o,n,i,l){o.every(a=>a.key!==null&&a.key!==void 0)&&t.every(a=>a.key!==null&&a.key!==void 0)?me(t,o,n,i,l,null,!1):ge(t,o,n,i,l,null,!1)}function Ve(e,r,t,o,n,i,l){let s=t.children,a=o.children;Array.isArray(a)&&a.length>0?(re(e,r,t,o,n,i,l),o.el=a[0].el,o.anchor=a[a.length-1].el?e.nextSibling(a[a.length-1].el):i):Array.isArray(s)&&s.length>0&&a===null?(S(r,s),o.el=t.el,o.anchor=t.anchor):(o.el=t.el,o.anchor=t.anchor)}function Ce(e,r,t,o,n,i){let l=t.dynamicChildren,s=o.dynamicChildren;for(let a=0;a<s.length;a++)L(e,r,l[a],s[a],n,null,i)}function Ee(e,r,t){r.component=e.component,r.el=e.el,r.component&&r.component.update&&r.component.update()}function ve(e){function r(n,i){oe(e,r,n,i)}Ne({insert(n,i,l){e.insert(i,n,l)},createElement(n){return e.createElement(n)},createText(n){return e.createText(n)},setText(n,i){n.nodeValue=i},setElementText(n,i){n.textContent=i},remove(n){e.remove(n)},createComment(n){return e.createComment(n)},mount(n,i,l,s,a,p,d){o(null,n,i,l,s)},patch(n,i,l,s,a,p,d,g){o(n,i,l,s,a)},unmount(n,i,l,s){r(n)},move(n,i,l){e.insert(i,n.el,l)}});function o(n,i,l,s,a){L(e,r,n,i,l,s,a)}return{mount(n,i){i.nodeType===1&&(i.textContent=""),o(null,n,i,null,null)},patch(n,i,l){var s;o(n,i,l||((s=n.el)==null?void 0:s.parentNode),null,null)},unmount(n,i){r(n,i)}}}import{effect as C}from"@lytjs/reactivity/signal";function O(e,r){return C(()=>{let o=r();e.textContent=o==null?"":String(o)})}function _(e,r,t){return C(()=>{let n=t();e[r]=n})}function M(e,r,t){return C(()=>{let n=t();n==null||n===!1?e.removeAttribute(r):e.setAttribute(r,n===!0?"":String(n))})}function B(e,r){return C(()=>{let o=r();if(typeof o=="string")e.className=o;else if(Array.isArray(o))e.className=o.filter(Boolean).join(" ");else if(typeof o=="object"&&o!==null){let n=[],i=o;for(let l of Object.keys(i))i[l]&&n.push(l);e.className=n.join(" ")}else e.className=""})}function X(e,r,t){return e.addEventListener(r,t),()=>{e.removeEventListener(r,t)}}function I(e,r){return C(()=>{let o=r();if(typeof o=="string")e.style=o;else if(typeof o=="object"&&o!==null){let n=e.style;for(let i of Object.keys(n))n[i]="";for(let[i,l]of Object.entries(o))n[i]=l}else e.style=""})}function ie(e,r){return C(()=>{let o=r(),n=o==null?"":String(o);e.innerHTML!==n&&(e.innerHTML=n)})}function D(e,r,t){let o=e.parentNode!==null,n=t||null;!n&&e.parentNode&&(n=e.parentNode);let i=C(()=>{r()?o||(n&&n.parentNode?n.parentNode.insertBefore(e,n.nextSibling):n&&n.appendChild(e),o=!0):o&&e.parentNode&&(e.parentNode.removeChild(e),o=!1)});return()=>{i(),o&&e.parentNode&&e.parentNode.removeChild(e)}}function j(e,r,t,o){let n=[],i=[],l=new Map,s=C(()=>{let a=r();if(!Array.isArray(a))return;let p=a.map((f,u)=>o?o(f,u):u);if(p.length===i.length){let f=!0;for(let u=0;u<p.length;u++)if(p[u]!==i[u]){f=!1;break}if(f){for(let u=0;u<a.length;u++){let m=t(a[u],u),y=n[u];y&&y.parentNode===e&&e.replaceChild(m,y),n[u]=m,l.set(p[u],m)}return}}let d=new Set(i),g=new Set(p),c=new Map;for(let f=0;f<a.length;f++){let u=p[f];if(d.has(u)&&l.has(u)){let m=l.get(u);c.set(u,m),l.delete(u)}else{let m=t(a[f],f);c.set(u,m)}}for(let[f,u]of l)!g.has(f)&&u.parentNode===e&&e.removeChild(u);for(let f of n)f.parentNode===e&&e.removeChild(f);n=[],i=[];for(let f=0;f<a.length;f++){let u=p[f],m=c.get(u);e.appendChild(m),n.push(m),i.push(u)}l.clear();for(let[f,u]of c)l.set(f,u)});return()=>{s();for(let a of n)a.parentNode===e&&e.removeChild(a);n=[],i=[],l.clear()}}import{LytError as xe,LytErrorCodes as Re}from"@lytjs/common";var H=e=>{if(typeof document!="undefined")return document.createElement(e);throw new xe(Re.LYT_RENDERER_VAPOR_ERROR,"\u672A\u8BBE\u7F6E DOM \u5DE5\u5382\u51FD\u6570\u3002\u5728\u975E\u6D4F\u89C8\u5668\u73AF\u5883\u4E2D\u8BF7\u8C03\u7528 setVaporDOMFactory()")};function be(e){H=e}function b(){return H}function P(e,r,...t){let o={tag:e,children:[],props:{},events:{},bindings:[]};if(r)for(let[n,i]of Object.entries(r))if(n.startsWith("on")&&typeof i=="function"&&!se(i)){let l=n.slice(2).toLowerCase();o.events[l]=i}else se(i)?n==="textContent"||n==="text"?o.bindings.push({type:"text",target:"textContent",signal:i}):n==="className"||n==="class"?o.bindings.push({type:"class",target:"className",signal:i}):n==="style"?o.bindings.push({type:"style",target:"style",signal:i}):o.bindings.push({type:"prop",target:n,signal:i}):o.props[n]=i;for(let n of t)typeof n=="string"?o.children.push({tag:"#text",children:[],props:{},events:{},bindings:[],text:n}):o.children.push(n);return o}function se(e){if(typeof e!="function")return!1;let r=e;return!!r._subscribe||!!(r.set&&r._subscribe)}function h(e){if(e.tag==="#text"){let n=H("#text");return n.textContent=e.text||"",n.nodeType=3,n}let r=H(e.tag);e.el=r;let t=r;for(let[n,i]of Object.entries(e.props))if(n==="style"&&typeof i=="object"&&i!==null)for(let[l,s]of Object.entries(i))t.style[l]=s;else n==="className"||n==="class"?r.className=String(i):t[n]=i;let o=[];for(let n of e.bindings){if(!n.signal)continue;let i;if(n.type==="text")i=O(r,n.signal);else if(n.type==="prop")i=_(r,n.target,n.signal);else if(n.type==="attr")i=M(r,n.target,n.signal);else if(n.type==="class")i=B(r,n.signal);else if(n.type==="style")i=I(r,n.signal);else continue;o.push(i)}e._bindingCleanups=o;for(let[n,i]of Object.entries(e.events))X(r,n,i);for(let n of e.children){let i=h(n);r.appendChild(i)}return r}function le(e,r,t){if(e.tag!==r.tag){let s=h(r);e.el&&e.el.parentNode===t&&t.removeChild(e.el),t.appendChild(s);return}let o=e.el||h(e);r.el=o;let n=o;if(e._bindingCleanups)for(let s of e._bindingCleanups)s();let i=[];for(let s of r.bindings){if(!s.signal)continue;let a;if(s.type==="text")a=O(o,s.signal);else if(s.type==="prop")a=_(o,s.target,s.signal);else if(s.type==="attr")a=M(o,s.target,s.signal);else if(s.type==="class")a=B(o,s.signal);else if(s.type==="style")a=I(o,s.signal);else continue;i.push(a)}r._bindingCleanups=i;for(let[s,a]of Object.entries(r.props))if(s==="style"&&typeof a=="object"&&a!==null)for(let[p,d]of Object.entries(a))n.style[p]=d;else s==="className"||s==="class"?o.className=String(a):n[s]=a;r.text!==void 0&&(o.textContent=r.text);for(let[s,a]of Object.entries(e.events))r.events[s]||o.removeEventListener(s,a);for(let[s,a]of Object.entries(r.events))e.events[s]!==a&&(e.events[s]&&o.removeEventListener(s,e.events[s]),o.addEventListener(s,a));let l=Math.max(e.children.length,r.children.length);for(let s=0;s<l;s++){let a=e.children[s],p=r.children[s];if(!a&&p){let d=h(p);o.appendChild(d)}else a&&!p?a.el&&a.el.parentNode===o&&o.removeChild(a.el):a&&p&&le(a,p,o)}}function Z(e,r){let t=r.setup?r.setup():{};r.beforeMount&&r.beforeMount();let o;if(r.render){let l=r.render(t,P);o=Array.isArray(l)?l:[l]}else o=[];let n=[],i=[];for(let l of o){let s=h(l);e.appendChild(s),n.push(s),ae(l,i)}return r.mounted&&r.mounted(),()=>{r.beforeUnmount&&r.beforeUnmount();for(let l of i)l();for(let l of n)(l.parentNode===e||e===l.parentNode)&&e.removeChild(l);r.unmounted&&r.unmounted()}}function ae(e,r){e._bindingCleanups&&r.push(...e._bindingCleanups);for(let t of e.children)ae(t,r)}import{effect as pe}from"@lytjs/reactivity/signal";import{LytError as Te,LytErrorCodes as we}from"@lytjs/common";function G(e){var o,n,i,l,s;let r={type:"fragment",children:[]},t=e.trim();for(;t.length>0;){let a=t.match(/^<([a-zA-Z][a-zA-Z0-9-]*)([\s\S]*?)(\/?)>/);if(a){let p=a[1],d=a[2],g=a[3]==="/",{props:c,events:f,directives:u}=Ae(d),m={type:"element",tag:p,props:c,events:f,directives:u,children:[]};if(t=t.slice(a[0].length),g){((o=r.children)!=null?o:[]).push(m);continue}let y=`</${p}>`,V=ke(t,p);if(V===-1)throw new Te(we.LYT_RENDERER_VAPOR_COMPILER_ERROR,`\u672A\u627E\u5230\u95ED\u5408\u6807\u7B7E: </${p}>`);let E=t.slice(0,V);t=t.slice(V+y.length);let N=G(E);m.children=N.children||[],((n=r.children)!=null?n:[]).push(m)}else{let p=t.indexOf("<"),d;if(p===-1?(d=t,t=""):(d=t.slice(0,p),t=t.slice(p)),d.trim())if(d.includes("{{")){let g=Se(d);for(let c of g)c.type==="text"?((i=r.children)!=null?i:[]).push({type:"text",text:c.value}):((l=r.children)!=null?l:[]).push({type:"interpolation",expression:c.value})}else((s=r.children)!=null?s:[]).push({type:"text",text:d})}}return r}function ke(e,r){let t=1,o=0,n=`<${r}`,i=`</${r}>`;for(;o<e.length&&t>0;){let l=e.indexOf(n,o),s=e.indexOf(i,o);if(s===-1)return-1;if(l!==-1&&l<s){let a=e[l+n.length];a===">"||a===" "||a==="/"?(t++,o=l+n.length):(o=s+i.length,t--)}else o=s+i.length,t--}return t===0?o-i.length:-1}function Ae(e){let r={},t={},o={},n=/([a-zA-Z@:][a-zA-Z0-9@:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,i;for(;(i=n.exec(e))!==null;){let l=i[1],s=i[2]||i[3];if(l.startsWith("on:")){let a=l.slice(3);t[a]=s}else if(l.startsWith(":")){let a=l.slice(1);r[a]=s}else if(l==="v-if")o.if=s;else if(l==="v-each"){let a=s.match(/^\s*(\w+)\s+in\s+(.+)\s*$/);a&&(o.each={item:a[1],expression:a[2]})}else r[l]=s}return{props:r,events:t,directives:o}}function Se(e){let r=[],t=/\{\{([\s\S]*?)\}\}/g,o=0,n;for(;(n=t.exec(e))!==null;)n.index>o&&r.push({type:"text",value:e.slice(o,n.index)}),r.push({type:"interpolation",value:n[1].trim()}),o=n.index+n[0].length;return o<e.length&&r.push({type:"text",value:e.slice(o)}),r}function q(e){let r=G(e);return{render:Le(r),ast:r}}function Le(e){return function(t){let o=b();return x(e,t,o)}}function x(e,r,t){var o,n;if(e.type==="fragment"){if(e.children&&e.children.length===1)return x(e.children[0],r,t);let i=t("div");if(i.nodeType=11,i.childNodes=i.childNodes||[],e.children)for(let l of e.children){let s=x(l,r,t);i.appendChild?i.appendChild(s):i.childNodes.push(s)}return i}if(e.type==="text"){let i=t("#text");return i.textContent=e.text||"",i.nodeType=3,i}if(e.type==="interpolation"){let i=t("span"),l=e.expression||"",s=T(r,l);if(F(s)){let a=s,p=t("#text");p.nodeType=3,p.textContent=String(a());let d=pe(()=>{p.textContent=a()===null||a()===void 0?"":String(a())});i.appendChild(p),i._bindingCleanup=d,ce(i,d)}else i.textContent=s!=null?String(s):"";return i}if(e.type==="element"){if((o=e.directives)!=null&&o.each){let{item:s,expression:a}=e.directives.each,p=T(r,a);if(F(p)){let c=t("#fragment");c.childNodes=[],c.nodeType=11;let f=c;return j(f,p,(u,m)=>{let y={...r,[s]:u,index:m},V=t(e.tag||"div");if(e.props)for(let[E,N]of Object.entries(e.props))E==="class"||E==="className"?V.className=N:V[E]=N;if(e.children)for(let E of e.children){let N=x(E,y,t);V.appendChild(N)}return V}),f}let d=Array.isArray(p)?p:[],g=t("#fragment");if(g.childNodes=[],g.nodeType=11,d.length>0)for(let c=0;c<d.length;c++){let f={...r,[s]:d[c],index:c},u=t(e.tag||"div");if(e.props)for(let[m,y]of Object.entries(e.props))m==="class"||m==="className"?u.className=y:u[m]=y;if(e.children)for(let m of e.children){let y=x(m,f,t);u.appendChild(y)}g.appendChild(u)}return g}let i=t(e.tag||"div"),l=i;if((n=e.directives)!=null&&n.if){let s=T(r,e.directives.if);F(s)?D(i,s):s||(l.style=l.style||{},l.style.display="none",l.hidden=!0)}if(e.props)for(let[s,a]of Object.entries(e.props))if(s.startsWith(":")){let p=s.slice(1),d=T(r,a);if(F(d)){let g=d,c=pe(()=>{l[p]=g()});i._propBindingCleanup=c,ce(i,c)}else l[p]=d}else s==="class"||s==="className"?i.className=a:l[s]=a;if(e.events)for(let[s,a]of Object.entries(e.events)){let p=T(r,a);typeof p=="function"&&i.addEventListener(s,p)}if(e.children)for(let s of e.children){let a=x(s,r,t);if(a.nodeType===11&&a.childNodes)for(let p of a.childNodes)i.appendChild(p);else i.appendChild(a)}return i}return t("div")}function T(e,r){let t=r.trim();if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))return e[t];let o=t.split("."),n=e;for(let i of o){if(n==null)return;n=n[i]}return n}function F(e){return typeof e!="function"?!1:!!e._subscribe}function ce(e,r){let t=e;t._cleanupEffects||(t._cleanupEffects=[]),t._cleanupEffects.push(r)}function Oe(e){return e.__vapor__=!0,e}function _e(e){let r=!1,t=null,o=null;return{mount(n){if(!r){if(typeof n=="string")if(typeof document!="undefined"){let i=document.querySelector(n);if(!i)throw new Error(`[lyt:vapor] \u672A\u627E\u5230\u6302\u8F7D\u76EE\u6807: ${n}`);o=i}else throw new Error("[lyt:vapor] \u5728\u975E\u6D4F\u89C8\u5668\u73AF\u5883\u4E2D\uFF0C\u8BF7\u76F4\u63A5\u4F20\u5165\u5BB9\u5668\u5143\u7D20");else o=n;t=Z(o,e),r=!0}},unmount(){r&&(t&&(t(),t=null),r=!1,o=null)}}}function Me(e,r){let t=e.setup?{...e.setup(),...r}:{...r};e.beforeMount&&e.beforeMount();let o;if(e.template){let{render:n}=q(e.template);o=n(t)}else if(e.render){let n=e.render(t,P),i=Array.isArray(n)?n:[n];if(i.length===1)o=h(i[0]);else{o=b()("div");for(let s of i)o.appendChild(h(s))}}else throw new Error("[lyt:vapor] \u7EC4\u4EF6\u5FC5\u987B\u63D0\u4F9B template \u6216 render \u51FD\u6570");return e.mounted&&e.mounted(),o}export{ee as Comment,J as Fragment,U as PatchFlags,R as ShapeFlags,Q as Text,M as bindAttr,B as bindClass,j as bindEach,X as bindEvent,ie as bindHTML,D as bindIf,_ as bindProp,I as bindStyle,O as bindText,q as compileToVapor,ve as createRenderer,_e as createVaporApp,P as createVaporElement,Oe as defineVaporComponent,b as getVaporDOMFactory,G as parseTemplate,Me as renderVaporComponent,h as renderVaporNode,be as setVaporDOMFactory,Z as vaporMount,le as vaporPatch};
|