elit 3.6.5 → 3.6.7
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +6 -0
- package/dist/build.cjs +421 -331
- package/dist/build.d.ts +1 -16
- package/dist/build.js +420 -330
- package/dist/build.mjs +420 -330
- package/dist/chokidar.cjs +219 -182
- package/dist/chokidar.d.ts +25 -10
- package/dist/chokidar.js +217 -182
- package/dist/chokidar.mjs +218 -183
- package/dist/cli.cjs +21608 -20241
- package/dist/cli.d.ts +19 -37
- package/dist/cli.mjs +21262 -19910
- package/dist/config.cjs +357 -350
- package/dist/config.d.ts +19 -240
- package/dist/config.js +520 -515
- package/dist/config.mjs +346 -341
- package/dist/contracts-BeW9k0yZ.d.ts +54 -0
- package/dist/contracts-D7KIS-TK.d.ts +36 -0
- package/dist/coverage.cjs +448 -485
- package/dist/coverage.d.ts +13 -59
- package/dist/coverage.js +447 -484
- package/dist/coverage.mjs +447 -484
- package/dist/database.cjs +819 -828
- package/dist/database.d.ts +8 -24
- package/dist/database.js +818 -829
- package/dist/database.mjs +818 -829
- package/dist/desktop-auto-render.cjs +1700 -1522
- package/dist/desktop-auto-render.d.ts +4 -9
- package/dist/desktop-auto-render.js +1695 -1517
- package/dist/desktop-auto-render.mjs +1696 -1518
- package/dist/desktop.cjs +3 -1
- package/dist/desktop.d.ts +4 -1
- package/dist/desktop.js +1 -1
- package/dist/desktop.mjs +1 -1
- package/dist/dev-build.cjs +830 -0
- package/dist/dev-build.d.ts +53 -0
- package/dist/dev-build.js +3318 -0
- package/dist/dev-build.mjs +797 -0
- package/dist/dom.cjs +717 -590
- package/dist/dom.d.ts +2 -15
- package/dist/dom.js +714 -587
- package/dist/dom.mjs +716 -589
- package/dist/el.cjs +62 -52
- package/dist/el.d.ts +5 -10
- package/dist/el.js +60 -52
- package/dist/el.mjs +60 -52
- package/dist/fs.cjs +72 -63
- package/dist/fs.d.ts +22 -19
- package/dist/fs.js +71 -62
- package/dist/fs.mjs +71 -62
- package/dist/hmr.cjs +40 -14
- package/dist/hmr.d.ts +11 -23
- package/dist/hmr.js +38 -14
- package/dist/hmr.mjs +38 -14
- package/dist/http.cjs +251 -99
- package/dist/http.d.ts +38 -104
- package/dist/http.js +249 -99
- package/dist/http.mjs +249 -99
- package/dist/https.cjs +524 -228
- package/dist/https.d.ts +44 -36
- package/dist/https.js +520 -226
- package/dist/https.mjs +522 -228
- package/dist/index.cjs +7502 -7690
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7486 -7676
- package/dist/index.mjs +7497 -7686
- package/dist/mime-types.cjs +10 -4
- package/dist/mime-types.d.ts +8 -11
- package/dist/mime-types.js +9 -3
- package/dist/mime-types.mjs +9 -3
- package/dist/native.cjs +8616 -8869
- package/dist/native.d.ts +7 -8
- package/dist/native.js +8682 -8935
- package/dist/native.mjs +8615 -8868
- package/dist/path.cjs +83 -77
- package/dist/path.d.ts +29 -29
- package/dist/path.js +82 -76
- package/dist/path.mjs +82 -76
- package/dist/pm.cjs +3300 -0
- package/dist/pm.d.ts +256 -0
- package/dist/pm.js +5638 -0
- package/dist/pm.mjs +3196 -0
- package/dist/preview-build.cjs +712 -0
- package/dist/preview-build.d.ts +59 -0
- package/dist/preview-build.js +3194 -0
- package/dist/preview-build.mjs +676 -0
- package/dist/render-context.cjs +13 -2
- package/dist/render-context.d.ts +9 -31
- package/dist/render-context.js +11 -2
- package/dist/render-context.mjs +11 -2
- package/dist/router.cjs +787 -645
- package/dist/router.d.ts +8 -12
- package/dist/router.js +786 -644
- package/dist/router.mjs +786 -644
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/server.cjs +3315 -2603
- package/dist/server.d.ts +49 -4
- package/dist/server.js +7611 -2834
- package/dist/server.mjs +3317 -2607
- package/dist/smtp-server.cjs +128 -0
- package/dist/smtp-server.d.ts +27 -0
- package/dist/smtp-server.js +4199 -0
- package/dist/smtp-server.mjs +100 -0
- package/dist/state-DvEkDehk.d.ts +195 -0
- package/dist/state.cjs +768 -658
- package/dist/state.d.ts +11 -69
- package/dist/state.js +760 -650
- package/dist/state.mjs +767 -657
- package/dist/style.cjs +1011 -968
- package/dist/style.d.ts +13 -127
- package/dist/style.js +1009 -970
- package/dist/style.mjs +1011 -971
- package/dist/test-reporter.cjs +332 -316
- package/dist/test-reporter.d.ts +28 -33
- package/dist/test-reporter.js +328 -312
- package/dist/test-reporter.mjs +328 -312
- package/dist/test-runtime.cjs +927 -968
- package/dist/test-runtime.d.ts +24 -99
- package/dist/test-runtime.js +922 -965
- package/dist/test-runtime.mjs +922 -965
- package/dist/test.cjs +4428 -4273
- package/dist/test.d.ts +2 -8
- package/dist/test.js +4307 -4154
- package/dist/test.mjs +4419 -4267
- package/dist/types-BONVzPtp.d.ts +59 -0
- package/dist/types-BR4wMiVx.d.ts +32 -0
- package/dist/types-C4gKykuG.d.ts +23 -0
- package/dist/types-CIhpN1-K.d.ts +64 -0
- package/dist/types-Ckj8md_j.d.ts +84 -0
- package/dist/types-CpjQTAkX.d.ts +24 -0
- package/dist/types-D0LjrYjS.d.ts +14 -0
- package/dist/types-DAisuVr5.d.ts +75 -0
- package/dist/types-tJn88E1N.d.ts +242 -0
- package/dist/types.d.ts +71 -226
- package/dist/universal.cjs +1 -1
- package/dist/universal.d.ts +1 -5
- package/dist/universal.js +1 -1
- package/dist/universal.mjs +1 -1
- package/dist/websocket-XfyK23zD.d.ts +119 -0
- package/dist/ws.cjs +129 -108
- package/dist/ws.d.ts +21 -131
- package/dist/ws.js +128 -109
- package/dist/ws.mjs +128 -109
- package/dist/wss.cjs +757 -479
- package/dist/wss.d.ts +31 -28
- package/dist/wss.js +755 -479
- package/dist/wss.mjs +758 -482
- package/package.json +16 -1
- package/vendor/epaint-0.31.1/src/image.rs +418 -0
- package/dist/server-CcBFc2F5.d.ts +0 -449
package/dist/dom.cjs
CHANGED
|
@@ -17,24 +17,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/dom.ts
|
|
20
|
+
// src/client/dom/index.ts
|
|
21
21
|
var dom_exports = {};
|
|
22
22
|
__export(dom_exports, {
|
|
23
23
|
DomNode: () => DomNode,
|
|
24
24
|
dom: () => dom,
|
|
25
25
|
mount: () => mount,
|
|
26
|
-
render: () =>
|
|
27
|
-
renderToString: () =>
|
|
26
|
+
render: () => render2,
|
|
27
|
+
renderToString: () => renderToString2
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(dom_exports);
|
|
30
30
|
|
|
31
|
-
// src/render-context.ts
|
|
31
|
+
// src/desktop/render-context/constants.ts
|
|
32
32
|
var RUNTIME_TARGET_KEY = "__ELIT_RUNTIME_TARGET__";
|
|
33
33
|
var CAPTURED_RENDER_KEY = "__ELIT_CAPTURED_RENDER__";
|
|
34
34
|
var RUNTIME_TARGET_ENV = "ELIT_RUNTIME_TARGET";
|
|
35
|
+
|
|
36
|
+
// src/desktop/render-context/globals.ts
|
|
35
37
|
function getGlobalRenderScope() {
|
|
36
38
|
return globalThis;
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
// src/desktop/render-context/runtime-target.ts
|
|
38
42
|
function isRenderRuntimeTarget(value) {
|
|
39
43
|
return value === "web" || value === "desktop" || value === "mobile" || value === "unknown";
|
|
40
44
|
}
|
|
@@ -50,7 +54,8 @@ function detectRenderRuntimeTarget() {
|
|
|
50
54
|
if (typeof globalScope.createWindow === "function") {
|
|
51
55
|
return "desktop";
|
|
52
56
|
}
|
|
53
|
-
const
|
|
57
|
+
const argvValues = globalScope.process?.argv;
|
|
58
|
+
const argv = Array.isArray(argvValues) ? argvValues.join(" ") : "";
|
|
54
59
|
if (/\bdesktop\b/i.test(argv)) {
|
|
55
60
|
return "desktop";
|
|
56
61
|
}
|
|
@@ -59,6 +64,8 @@ function detectRenderRuntimeTarget() {
|
|
|
59
64
|
}
|
|
60
65
|
return "unknown";
|
|
61
66
|
}
|
|
67
|
+
|
|
68
|
+
// src/desktop/render-context/captured-render.ts
|
|
62
69
|
function captureRenderedVNode(rootElement, vNode, target = detectRenderRuntimeTarget()) {
|
|
63
70
|
const globalScope = getGlobalRenderScope();
|
|
64
71
|
globalScope[RUNTIME_TARGET_KEY] = target;
|
|
@@ -69,7 +76,7 @@ function captureRenderedVNode(rootElement, vNode, target = detectRenderRuntimeTa
|
|
|
69
76
|
};
|
|
70
77
|
}
|
|
71
78
|
|
|
72
|
-
// src/dom.ts
|
|
79
|
+
// src/client/dom/helpers.ts
|
|
73
80
|
function resolveElement(rootElement) {
|
|
74
81
|
return typeof rootElement === "string" ? document.getElementById(rootElement.replace("#", "")) : rootElement;
|
|
75
82
|
}
|
|
@@ -97,668 +104,788 @@ function resolveTextareaValue(tagName, props) {
|
|
|
97
104
|
function hasDocumentApi() {
|
|
98
105
|
return typeof document !== "undefined";
|
|
99
106
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (Array.isArray(vNode)) {
|
|
123
|
-
for (const child of vNode) {
|
|
124
|
-
this.renderToDOM(child, parent);
|
|
107
|
+
function isState(value) {
|
|
108
|
+
return value && typeof value === "object" && "value" in value && "subscribe" in value && typeof value.subscribe === "function";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/client/dom/dom-render.ts
|
|
112
|
+
function isSvgElement(tagName, parent) {
|
|
113
|
+
return tagName === "svg" || tagName[0] === "s" && tagName[1] === "v" && tagName[2] === "g" || parent.namespaceURI === "http://www.w3.org/2000/svg";
|
|
114
|
+
}
|
|
115
|
+
function applyProps(el, props, textareaValue) {
|
|
116
|
+
for (const key in props) {
|
|
117
|
+
const value = props[key];
|
|
118
|
+
if (value == null || value === false) continue;
|
|
119
|
+
const c = key.charCodeAt(0);
|
|
120
|
+
if (c === 99 && (key.length < 6 || key[5] === "N")) {
|
|
121
|
+
const classValue = Array.isArray(value) ? value.join(" ") : String(value);
|
|
122
|
+
if (el instanceof SVGElement) {
|
|
123
|
+
el.setAttribute("class", classValue);
|
|
124
|
+
} else {
|
|
125
|
+
el.className = classValue;
|
|
125
126
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (Array.isArray(child)) {
|
|
134
|
-
for (const c of child) {
|
|
135
|
-
!shouldSkipChild(c) && this.renderToDOM(c, parent);
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
this.renderToDOM(child, parent);
|
|
127
|
+
} else if (c === 115 && key.length === 5) {
|
|
128
|
+
if (typeof value === "string") {
|
|
129
|
+
el.style.cssText = value;
|
|
130
|
+
} else {
|
|
131
|
+
const style = el.style;
|
|
132
|
+
for (const styleKey in value) {
|
|
133
|
+
style[styleKey] = value[styleKey];
|
|
139
134
|
}
|
|
140
135
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (c === 99 && (key.length < 6 || key[5] === "N")) {
|
|
150
|
-
const classValue = Array.isArray(value) ? value.join(" ") : value;
|
|
151
|
-
isSVG ? el.setAttribute("class", classValue) : el.className = classValue;
|
|
152
|
-
} else if (c === 115 && key.length === 5) {
|
|
153
|
-
if (typeof value === "string") {
|
|
154
|
-
el.style.cssText = value;
|
|
136
|
+
} else if (c === 111 && key.charCodeAt(1) === 110) {
|
|
137
|
+
el[key.toLowerCase()] = value;
|
|
138
|
+
} else if (c === 100 && key.length > 20) {
|
|
139
|
+
el.innerHTML = value.__html;
|
|
140
|
+
} else if (c === 114 && key === "ref") {
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
if (typeof value === "function") {
|
|
143
|
+
value(el);
|
|
155
144
|
} else {
|
|
156
|
-
|
|
157
|
-
for (const k in value) s[k] = value[k];
|
|
145
|
+
value.current = el;
|
|
158
146
|
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
setTimeout(() => {
|
|
165
|
-
typeof value === "function" ? value(el) : value.current = el;
|
|
166
|
-
}, 0);
|
|
167
|
-
} else if (textareaValue !== void 0 && key === "value") {
|
|
168
|
-
continue;
|
|
169
|
-
} else {
|
|
170
|
-
el.setAttribute(key, value === true ? "" : String(value));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
const renderableChildren = textareaValue === void 0 ? children : [];
|
|
174
|
-
const len = renderableChildren.length;
|
|
175
|
-
if (!len) {
|
|
176
|
-
if (textareaValue !== void 0) {
|
|
177
|
-
el.value = textareaValue;
|
|
178
|
-
}
|
|
179
|
-
parent.appendChild(el);
|
|
180
|
-
return;
|
|
147
|
+
}, 0);
|
|
148
|
+
} else if (textareaValue !== void 0 && key === "value") {
|
|
149
|
+
continue;
|
|
150
|
+
} else {
|
|
151
|
+
el.setAttribute(key, value === true ? "" : String(value));
|
|
181
152
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function renderChildren(children, target) {
|
|
156
|
+
const len = children.length;
|
|
157
|
+
for (let i = 0; i < len; i++) {
|
|
158
|
+
const child = children[i];
|
|
159
|
+
if (shouldSkipChild(child)) continue;
|
|
160
|
+
if (Array.isArray(child)) {
|
|
161
|
+
for (let j = 0, childLen = child.length; j < childLen; j++) {
|
|
162
|
+
const nestedChild = child[j];
|
|
163
|
+
if (!shouldSkipChild(nestedChild)) {
|
|
164
|
+
renderToDOM(nestedChild, target);
|
|
193
165
|
}
|
|
194
166
|
}
|
|
195
|
-
};
|
|
196
|
-
if (len > 30) {
|
|
197
|
-
const fragment = document.createDocumentFragment();
|
|
198
|
-
renderChildren(fragment);
|
|
199
|
-
el.appendChild(fragment);
|
|
200
167
|
} else {
|
|
201
|
-
|
|
168
|
+
renderToDOM(child, target);
|
|
202
169
|
}
|
|
203
|
-
parent.appendChild(el);
|
|
204
170
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
171
|
+
}
|
|
172
|
+
function renderToDOM(vNode, parent) {
|
|
173
|
+
if (vNode == null || vNode === false) return;
|
|
174
|
+
if (typeof vNode !== "object") {
|
|
175
|
+
parent.appendChild(document.createTextNode(String(vNode)));
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (isState(vNode)) {
|
|
179
|
+
const textNode = document.createTextNode(String(vNode.value ?? ""));
|
|
180
|
+
parent.appendChild(textNode);
|
|
181
|
+
vNode.subscribe((newValue) => {
|
|
182
|
+
textNode.textContent = String(newValue ?? "");
|
|
183
|
+
});
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (Array.isArray(vNode)) {
|
|
187
|
+
for (const child of vNode) {
|
|
188
|
+
renderToDOM(child, parent);
|
|
222
189
|
}
|
|
223
|
-
return
|
|
190
|
+
return;
|
|
224
191
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
processed = end;
|
|
238
|
-
if (processed >= len) {
|
|
239
|
-
el.appendChild(fragment);
|
|
240
|
-
} else {
|
|
241
|
-
requestAnimationFrame(processChunk);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
processChunk();
|
|
245
|
-
} else {
|
|
246
|
-
const fragment = document.createDocumentFragment();
|
|
247
|
-
for (let i = 0; i < len; i++) {
|
|
248
|
-
this.renderToDOM(vNodes[i], fragment);
|
|
249
|
-
}
|
|
250
|
-
el.appendChild(fragment);
|
|
192
|
+
const { tagName, props, children } = vNode;
|
|
193
|
+
const textareaValue = resolveTextareaValue(tagName, props);
|
|
194
|
+
if (!tagName) {
|
|
195
|
+
renderChildren(children, parent);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const el = isSvgElement(tagName, parent) ? document.createElementNS("http://www.w3.org/2000/svg", tagName.replace("svg", "").toLowerCase() || tagName) : document.createElement(tagName);
|
|
199
|
+
applyProps(el, props, textareaValue);
|
|
200
|
+
const renderableChildren = textareaValue === void 0 ? children : [];
|
|
201
|
+
if (!renderableChildren.length) {
|
|
202
|
+
if (textareaValue !== void 0) {
|
|
203
|
+
el.value = textareaValue;
|
|
251
204
|
}
|
|
252
|
-
|
|
205
|
+
parent.appendChild(el);
|
|
206
|
+
return;
|
|
253
207
|
}
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
208
|
+
if (renderableChildren.length > 30) {
|
|
209
|
+
const fragment = document.createDocumentFragment();
|
|
210
|
+
renderChildren(renderableChildren, fragment);
|
|
211
|
+
el.appendChild(fragment);
|
|
212
|
+
} else {
|
|
213
|
+
renderChildren(renderableChildren, el);
|
|
214
|
+
}
|
|
215
|
+
parent.appendChild(el);
|
|
216
|
+
}
|
|
217
|
+
function render(rootElement, vNode) {
|
|
218
|
+
if (!hasDocumentApi()) {
|
|
219
|
+
const runtimeTarget = detectRenderRuntimeTarget();
|
|
220
|
+
if (runtimeTarget === "desktop" || runtimeTarget === "mobile") {
|
|
221
|
+
captureRenderedVNode(rootElement, vNode, runtimeTarget);
|
|
222
|
+
return {};
|
|
223
|
+
}
|
|
224
|
+
throw new Error("render() requires a DOM or an Elit desktop/mobile runtime target.");
|
|
225
|
+
}
|
|
226
|
+
const el = ensureElement(resolveElement(rootElement), rootElement);
|
|
227
|
+
el.innerHTML = "";
|
|
228
|
+
if (vNode.children && vNode.children.length > 500) {
|
|
229
|
+
const fragment = document.createDocumentFragment();
|
|
230
|
+
renderToDOM(vNode, fragment);
|
|
231
|
+
el.appendChild(fragment);
|
|
232
|
+
} else {
|
|
233
|
+
renderToDOM(vNode, el);
|
|
234
|
+
}
|
|
235
|
+
return el;
|
|
236
|
+
}
|
|
237
|
+
function batchRender(rootElement, vNodes) {
|
|
238
|
+
const el = ensureElement(resolveElement(rootElement), rootElement);
|
|
239
|
+
const len = vNodes.length;
|
|
240
|
+
if (len > 3e3) {
|
|
241
|
+
const fragment = document.createDocumentFragment();
|
|
242
|
+
let processed = 0;
|
|
243
|
+
const chunkSize = 1500;
|
|
244
|
+
const processChunk = () => {
|
|
245
|
+
const end = Math.min(processed + chunkSize, len);
|
|
246
|
+
for (let i = processed; i < end; i++) {
|
|
247
|
+
renderToDOM(vNodes[i], fragment);
|
|
263
248
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
requestAnimationFrame(
|
|
249
|
+
processed = end;
|
|
250
|
+
if (processed >= len) {
|
|
251
|
+
el.appendChild(fragment);
|
|
252
|
+
} else {
|
|
253
|
+
requestAnimationFrame(processChunk);
|
|
269
254
|
}
|
|
270
255
|
};
|
|
271
|
-
|
|
272
|
-
|
|
256
|
+
processChunk();
|
|
257
|
+
} else {
|
|
258
|
+
const fragment = document.createDocumentFragment();
|
|
259
|
+
for (let i = 0; i < len; i++) {
|
|
260
|
+
renderToDOM(vNodes[i], fragment);
|
|
261
|
+
}
|
|
262
|
+
el.appendChild(fragment);
|
|
273
263
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
264
|
+
return el;
|
|
265
|
+
}
|
|
266
|
+
function renderChunked(rootElement, vNodes, chunkSize = 5e3, onProgress) {
|
|
267
|
+
const el = ensureElement(resolveElement(rootElement), rootElement);
|
|
268
|
+
const len = vNodes.length;
|
|
269
|
+
let index = 0;
|
|
270
|
+
const renderChunkFrame = () => {
|
|
271
|
+
const end = Math.min(index + chunkSize, len);
|
|
272
|
+
const fragment = document.createDocumentFragment();
|
|
273
|
+
for (let i = index; i < end; i++) {
|
|
274
|
+
renderToDOM(vNodes[i], fragment);
|
|
275
|
+
}
|
|
276
|
+
el.appendChild(fragment);
|
|
277
|
+
index = end;
|
|
278
|
+
if (onProgress) {
|
|
279
|
+
onProgress(index, len);
|
|
280
|
+
}
|
|
281
|
+
if (index < len) {
|
|
282
|
+
requestAnimationFrame(renderChunkFrame);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
requestAnimationFrame(renderChunkFrame);
|
|
286
|
+
return el;
|
|
287
|
+
}
|
|
288
|
+
function renderToHead(...vNodes) {
|
|
289
|
+
const head = document.head;
|
|
290
|
+
if (head) {
|
|
291
|
+
for (const vNode of vNodes.flat()) {
|
|
292
|
+
if (vNode) {
|
|
293
|
+
renderToDOM(vNode, head);
|
|
279
294
|
}
|
|
280
295
|
}
|
|
281
|
-
return head;
|
|
282
|
-
}
|
|
283
|
-
addStyle(cssText) {
|
|
284
|
-
const el = document.createElement("style");
|
|
285
|
-
el.textContent = cssText;
|
|
286
|
-
return document.head.appendChild(el);
|
|
287
296
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
297
|
+
return head;
|
|
298
|
+
}
|
|
299
|
+
function addStyle(cssText) {
|
|
300
|
+
const el = document.createElement("style");
|
|
301
|
+
el.textContent = cssText;
|
|
302
|
+
return document.head.appendChild(el);
|
|
303
|
+
}
|
|
304
|
+
function addMeta(attrs) {
|
|
305
|
+
const el = document.createElement("meta");
|
|
306
|
+
for (const key in attrs) {
|
|
307
|
+
el.setAttribute(key, attrs[key]);
|
|
292
308
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
309
|
+
return document.head.appendChild(el);
|
|
310
|
+
}
|
|
311
|
+
function addLink(attrs) {
|
|
312
|
+
const el = document.createElement("link");
|
|
313
|
+
for (const key in attrs) {
|
|
314
|
+
el.setAttribute(key, attrs[key]);
|
|
297
315
|
}
|
|
298
|
-
|
|
299
|
-
|
|
316
|
+
return document.head.appendChild(el);
|
|
317
|
+
}
|
|
318
|
+
function setTitle(text) {
|
|
319
|
+
return document.title = text;
|
|
320
|
+
}
|
|
321
|
+
function cleanupUnusedElements(root, elementCache) {
|
|
322
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
323
|
+
const toRemove = [];
|
|
324
|
+
while (walker.nextNode()) {
|
|
325
|
+
const node = walker.currentNode;
|
|
326
|
+
if (node.id && node.id.startsWith("r") && !elementCache.has(node)) {
|
|
327
|
+
toRemove.push(node);
|
|
328
|
+
}
|
|
300
329
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
} else {
|
|
317
|
-
notify();
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
return {
|
|
321
|
-
get value() {
|
|
322
|
-
return value;
|
|
323
|
-
},
|
|
324
|
-
set value(newValue) {
|
|
325
|
-
const changed = deep ? JSON.stringify(value) !== JSON.stringify(newValue) : value !== newValue;
|
|
326
|
-
if (changed) {
|
|
327
|
-
value = newValue;
|
|
328
|
-
scheduleUpdate();
|
|
329
|
-
}
|
|
330
|
-
},
|
|
331
|
-
subscribe(fn) {
|
|
332
|
-
listeners.add(fn);
|
|
333
|
-
return () => listeners.delete(fn);
|
|
334
|
-
},
|
|
335
|
-
destroy() {
|
|
336
|
-
listeners.clear();
|
|
337
|
-
updateTimer && clearTimeout(updateTimer);
|
|
330
|
+
toRemove.forEach((el) => el.remove());
|
|
331
|
+
return toRemove.length;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/client/dom/reactive.ts
|
|
335
|
+
function createReactiveChild(state, reactiveNodes, renderFn) {
|
|
336
|
+
const currentValue = renderFn(state.value);
|
|
337
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
338
|
+
const entry = { node: null, renderFn };
|
|
339
|
+
reactiveNodes.set(state, entry);
|
|
340
|
+
state.subscribe(() => {
|
|
341
|
+
if (entry.node && entry.node.parentNode) {
|
|
342
|
+
const newValue = renderFn(state.value);
|
|
343
|
+
entry.node.textContent = String(newValue ?? "");
|
|
338
344
|
}
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
computed(states, computeFn) {
|
|
342
|
-
const values = states.map((s) => s.value);
|
|
343
|
-
const result = this.createState(computeFn(...values));
|
|
344
|
-
states.forEach((state, index) => {
|
|
345
|
-
state.subscribe((newValue) => {
|
|
346
|
-
values[index] = newValue;
|
|
347
|
-
result.value = computeFn(...values);
|
|
348
|
-
});
|
|
349
345
|
});
|
|
350
|
-
return result;
|
|
351
346
|
}
|
|
352
|
-
|
|
353
|
-
|
|
347
|
+
return currentValue;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// src/client/dom/string-render.ts
|
|
351
|
+
var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
|
|
352
|
+
"area",
|
|
353
|
+
"base",
|
|
354
|
+
"br",
|
|
355
|
+
"col",
|
|
356
|
+
"embed",
|
|
357
|
+
"hr",
|
|
358
|
+
"img",
|
|
359
|
+
"input",
|
|
360
|
+
"link",
|
|
361
|
+
"meta",
|
|
362
|
+
"param",
|
|
363
|
+
"source",
|
|
364
|
+
"track",
|
|
365
|
+
"wbr"
|
|
366
|
+
]);
|
|
367
|
+
function resolveStateValue(value) {
|
|
368
|
+
return isState(value) ? value.value : value;
|
|
369
|
+
}
|
|
370
|
+
function isReactiveWrapper(vNode) {
|
|
371
|
+
if (!vNode || typeof vNode !== "object" || !vNode.tagName) {
|
|
372
|
+
return false;
|
|
354
373
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const getVisibleRange = () => {
|
|
361
|
-
const start = Math.max(0, Math.floor(scrollTop / itemHeight) - bufferSize);
|
|
362
|
-
const end = Math.min(items.length, Math.ceil((scrollTop + viewportHeight) / itemHeight) + bufferSize);
|
|
363
|
-
return { start, end };
|
|
364
|
-
};
|
|
365
|
-
const render2 = () => {
|
|
366
|
-
const { start, end } = getVisibleRange();
|
|
367
|
-
const wrapper = document.createElement("div");
|
|
368
|
-
wrapper.style.cssText = `height:${totalHeight}px;position:relative`;
|
|
369
|
-
for (let i = start; i < end; i++) {
|
|
370
|
-
const itemEl = document.createElement("div");
|
|
371
|
-
itemEl.style.cssText = `position:absolute;top:${i * itemHeight}px;height:${itemHeight}px;width:100%`;
|
|
372
|
-
this.renderToDOM(renderItem(items[i], i), itemEl);
|
|
373
|
-
wrapper.appendChild(itemEl);
|
|
374
|
-
}
|
|
375
|
-
container.innerHTML = "";
|
|
376
|
-
container.appendChild(wrapper);
|
|
377
|
-
};
|
|
378
|
-
const scrollHandler = () => {
|
|
379
|
-
scrollTop = container.scrollTop;
|
|
380
|
-
requestAnimationFrame(render2);
|
|
381
|
-
};
|
|
382
|
-
container.addEventListener("scroll", scrollHandler);
|
|
383
|
-
render2();
|
|
384
|
-
return {
|
|
385
|
-
render: render2,
|
|
386
|
-
destroy: () => {
|
|
387
|
-
container.removeEventListener("scroll", scrollHandler);
|
|
388
|
-
container.innerHTML = "";
|
|
389
|
-
}
|
|
390
|
-
};
|
|
374
|
+
return vNode.tagName === "span" && vNode.props?.id && typeof vNode.props.id === "string" && /^r[a-z0-9]{9}$/.test(vNode.props.id);
|
|
375
|
+
}
|
|
376
|
+
function unwrapReactive(vNode) {
|
|
377
|
+
if (!isReactiveWrapper(vNode)) {
|
|
378
|
+
return vNode;
|
|
391
379
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
let loading = false;
|
|
396
|
-
return async (...args) => {
|
|
397
|
-
if (!component && !loading) {
|
|
398
|
-
loading = true;
|
|
399
|
-
component = await loadFn();
|
|
400
|
-
loading = false;
|
|
401
|
-
}
|
|
402
|
-
return component ? component(...args) : { tagName: "div", props: { class: "loading" }, children: ["Loading..."] };
|
|
403
|
-
};
|
|
380
|
+
const children = vNode.children;
|
|
381
|
+
if (!children || children.length === 0) {
|
|
382
|
+
return "";
|
|
404
383
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
if (
|
|
412
|
-
|
|
384
|
+
if (children.length === 1) {
|
|
385
|
+
const child = children[0];
|
|
386
|
+
if (child && typeof child === "object" && child.tagName === "span") {
|
|
387
|
+
const props = child.props;
|
|
388
|
+
const hasNoProps = !props || Object.keys(props).length === 0;
|
|
389
|
+
const hasSingleStringChild = child.children && child.children.length === 1 && typeof child.children[0] === "string";
|
|
390
|
+
if (hasNoProps && hasSingleStringChild) {
|
|
391
|
+
return child.children[0];
|
|
413
392
|
}
|
|
414
393
|
}
|
|
415
|
-
|
|
416
|
-
return toRemove.length;
|
|
394
|
+
return unwrapReactive(child);
|
|
417
395
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
396
|
+
return children.map((child) => unwrapReactive(child));
|
|
397
|
+
}
|
|
398
|
+
function escapeHtml(text) {
|
|
399
|
+
const htmlEscapes = {
|
|
400
|
+
"&": "&",
|
|
401
|
+
"<": "<",
|
|
402
|
+
">": ">",
|
|
403
|
+
'"': """,
|
|
404
|
+
"'": "'"
|
|
405
|
+
};
|
|
406
|
+
return text.replace(/[&<>"']/g, (char) => htmlEscapes[char]);
|
|
407
|
+
}
|
|
408
|
+
function isSelfClosingTag(tagName) {
|
|
409
|
+
return SELF_CLOSING_TAGS.has(tagName.toLowerCase());
|
|
410
|
+
}
|
|
411
|
+
function styleToString(style) {
|
|
412
|
+
if (typeof style === "string") {
|
|
413
|
+
return style;
|
|
414
|
+
}
|
|
415
|
+
if (typeof style === "object" && style !== null) {
|
|
416
|
+
const styles = [];
|
|
417
|
+
for (const key in style) {
|
|
418
|
+
const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
419
|
+
styles.push(`${cssKey}:${style[key]}`);
|
|
420
|
+
}
|
|
421
|
+
return styles.join(";");
|
|
422
|
+
}
|
|
423
|
+
return "";
|
|
424
|
+
}
|
|
425
|
+
function propsToAttributes(props, tagName) {
|
|
426
|
+
const attrs = [];
|
|
427
|
+
for (const key in props) {
|
|
428
|
+
if (key === "children" || key === "dangerouslySetInnerHTML" || key === "ref" || tagName === "textarea" && key === "value") {
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
let value = props[key];
|
|
432
|
+
value = resolveStateValue(value);
|
|
433
|
+
if (value == null || value === false) continue;
|
|
434
|
+
if (key.startsWith("on") && typeof value === "function") {
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
if (key === "className" || key === "class") {
|
|
438
|
+
const className = Array.isArray(value) ? value.join(" ") : value;
|
|
439
|
+
if (className) {
|
|
440
|
+
attrs.push(`class="${escapeHtml(String(className))}"`);
|
|
431
441
|
}
|
|
432
|
-
|
|
442
|
+
continue;
|
|
433
443
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
html += ` ${attrs}`;
|
|
444
|
+
if (key === "style") {
|
|
445
|
+
const styleStr = styleToString(value);
|
|
446
|
+
if (styleStr) {
|
|
447
|
+
attrs.push(`style="${escapeHtml(styleStr)}"`);
|
|
448
|
+
}
|
|
449
|
+
continue;
|
|
441
450
|
}
|
|
442
|
-
if (
|
|
443
|
-
|
|
444
|
-
|
|
451
|
+
if (value === true) {
|
|
452
|
+
attrs.push(key);
|
|
453
|
+
continue;
|
|
445
454
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
455
|
+
attrs.push(`${key}="${escapeHtml(String(value))}"`);
|
|
456
|
+
}
|
|
457
|
+
return attrs.join(" ");
|
|
458
|
+
}
|
|
459
|
+
function renderToString(vNode, options = {}) {
|
|
460
|
+
const { pretty = false, indent = 0 } = options;
|
|
461
|
+
const indentStr = pretty ? " ".repeat(indent) : "";
|
|
462
|
+
const newLine = pretty ? "\n" : "";
|
|
463
|
+
let resolvedVNode = resolveStateValue(vNode);
|
|
464
|
+
resolvedVNode = unwrapReactive(resolvedVNode);
|
|
465
|
+
if (Array.isArray(resolvedVNode)) {
|
|
466
|
+
return resolvedVNode.map((child) => renderToString(child, options)).join("");
|
|
467
|
+
}
|
|
468
|
+
if (typeof resolvedVNode !== "object" || resolvedVNode === null) {
|
|
469
|
+
if (resolvedVNode === null || resolvedVNode === void 0 || resolvedVNode === false) {
|
|
470
|
+
return "";
|
|
471
|
+
}
|
|
472
|
+
return escapeHtml(String(resolvedVNode));
|
|
473
|
+
}
|
|
474
|
+
const { tagName, props, children } = resolvedVNode;
|
|
475
|
+
const textareaValue = resolveTextareaValue(tagName, props);
|
|
476
|
+
const selfClosing = isSelfClosingTag(tagName);
|
|
477
|
+
let html = `${indentStr}<${tagName}`;
|
|
478
|
+
const attrs = propsToAttributes(props, tagName);
|
|
479
|
+
if (attrs) {
|
|
480
|
+
html += ` ${attrs}`;
|
|
481
|
+
}
|
|
482
|
+
if (selfClosing) {
|
|
483
|
+
html += ` />${newLine}`;
|
|
484
|
+
return html;
|
|
485
|
+
}
|
|
486
|
+
html += ">";
|
|
487
|
+
if (textareaValue !== void 0) {
|
|
488
|
+
html += escapeHtml(textareaValue);
|
|
489
|
+
html += `</${tagName}>${newLine}`;
|
|
490
|
+
return html;
|
|
491
|
+
}
|
|
492
|
+
if (props.dangerouslySetInnerHTML) {
|
|
493
|
+
html += props.dangerouslySetInnerHTML.__html;
|
|
494
|
+
html += `</${tagName}>${newLine}`;
|
|
495
|
+
return html;
|
|
496
|
+
}
|
|
497
|
+
const isRawText = tagName === "script" || tagName === "style";
|
|
498
|
+
if (children && children.length > 0) {
|
|
499
|
+
const resolvedChildren = children.map((child) => unwrapReactive(resolveStateValue(child)));
|
|
500
|
+
const hasComplexChildren = resolvedChildren.some(
|
|
501
|
+
(child) => typeof child === "object" && child !== null && !Array.isArray(child) && "tagName" in child
|
|
502
|
+
);
|
|
503
|
+
if (pretty && hasComplexChildren) {
|
|
504
|
+
html += newLine;
|
|
505
|
+
for (const child of resolvedChildren) {
|
|
506
|
+
if (shouldSkipChild(child)) continue;
|
|
507
|
+
if (Array.isArray(child)) {
|
|
508
|
+
for (const nestedChild of child) {
|
|
509
|
+
if (!shouldSkipChild(nestedChild)) {
|
|
510
|
+
html += isRawText && typeof nestedChild === "string" ? nestedChild : renderToString(nestedChild, { pretty, indent: indent + 1 });
|
|
474
511
|
}
|
|
475
|
-
} else {
|
|
476
|
-
html += this.renderToString(child, { pretty, indent: indent + 1 });
|
|
477
512
|
}
|
|
513
|
+
} else {
|
|
514
|
+
html += isRawText && typeof child === "string" ? child : renderToString(child, { pretty, indent: indent + 1 });
|
|
478
515
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
516
|
+
}
|
|
517
|
+
html += indentStr;
|
|
518
|
+
} else {
|
|
519
|
+
for (const child of resolvedChildren) {
|
|
520
|
+
if (shouldSkipChild(child)) continue;
|
|
521
|
+
if (Array.isArray(child)) {
|
|
522
|
+
for (const nestedChild of child) {
|
|
523
|
+
if (!shouldSkipChild(nestedChild)) {
|
|
524
|
+
html += isRawText && typeof nestedChild === "string" ? nestedChild : renderToString(nestedChild, { pretty: false, indent: 0 });
|
|
488
525
|
}
|
|
489
|
-
} else {
|
|
490
|
-
html += this.renderToString(child, { pretty: false, indent: 0 });
|
|
491
526
|
}
|
|
527
|
+
} else {
|
|
528
|
+
html += isRawText && typeof child === "string" ? child : renderToString(child, { pretty: false, indent: 0 });
|
|
492
529
|
}
|
|
493
530
|
}
|
|
494
531
|
}
|
|
495
|
-
html += `</${tagName}>${newLine}`;
|
|
496
|
-
return html;
|
|
497
532
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
533
|
+
html += `</${tagName}>${newLine}`;
|
|
534
|
+
return html;
|
|
535
|
+
}
|
|
536
|
+
function renderToHTMLDocument(vNode, options = {}) {
|
|
537
|
+
const {
|
|
538
|
+
title = "",
|
|
539
|
+
meta = [],
|
|
540
|
+
links = [],
|
|
541
|
+
scripts = [],
|
|
542
|
+
styles = [],
|
|
543
|
+
lang = "en",
|
|
544
|
+
head = "",
|
|
545
|
+
bodyAttrs = {},
|
|
546
|
+
pretty = false
|
|
547
|
+
} = options;
|
|
548
|
+
const nl = pretty ? "\n" : "";
|
|
549
|
+
const indent = pretty ? " " : "";
|
|
550
|
+
const indent2 = pretty ? " " : "";
|
|
551
|
+
let html = `<!DOCTYPE html>${nl}<html lang="${lang}">${nl}${indent}<head>${nl}${indent2}<meta charset="UTF-8">${nl}${indent2}<meta name="viewport" content="width=device-width, initial-scale=1.0">${nl}`;
|
|
552
|
+
if (title) {
|
|
553
|
+
html += `${indent2}<title>${escapeHtml(title)}</title>${nl}`;
|
|
554
|
+
}
|
|
555
|
+
for (const metaAttrs of meta) {
|
|
556
|
+
html += `${indent2}<meta`;
|
|
557
|
+
for (const key in metaAttrs) {
|
|
558
|
+
html += ` ${key}="${escapeHtml(metaAttrs[key])}"`;
|
|
501
559
|
}
|
|
502
|
-
|
|
560
|
+
html += `>${nl}`;
|
|
503
561
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
562
|
+
for (const linkAttrs of links) {
|
|
563
|
+
html += `${indent2}<link`;
|
|
564
|
+
for (const key in linkAttrs) {
|
|
565
|
+
html += ` ${key}="${escapeHtml(linkAttrs[key])}"`;
|
|
507
566
|
}
|
|
508
|
-
|
|
567
|
+
html += `>${nl}`;
|
|
509
568
|
}
|
|
510
|
-
|
|
511
|
-
if (
|
|
512
|
-
|
|
569
|
+
for (const style of styles) {
|
|
570
|
+
if (style.href) {
|
|
571
|
+
html += `${indent2}<link rel="stylesheet" href="${escapeHtml(style.href)}">${nl}`;
|
|
572
|
+
} else if (style.content) {
|
|
573
|
+
html += `${indent2}<style>${style.content}</style>${nl}`;
|
|
513
574
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
575
|
+
}
|
|
576
|
+
if (head) {
|
|
577
|
+
html += head + nl;
|
|
578
|
+
}
|
|
579
|
+
html += `${indent}</head>${nl}${indent}<body`;
|
|
580
|
+
for (const key in bodyAttrs) {
|
|
581
|
+
html += ` ${key}="${escapeHtml(bodyAttrs[key])}"`;
|
|
582
|
+
}
|
|
583
|
+
html += `>${nl}`;
|
|
584
|
+
html += renderToString(vNode, { pretty, indent: 2 });
|
|
585
|
+
for (const script of scripts) {
|
|
586
|
+
html += `${indent2}<script`;
|
|
587
|
+
if (script.type) {
|
|
588
|
+
html += ` type="${escapeHtml(script.type)}"`;
|
|
517
589
|
}
|
|
518
|
-
if (
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
|
|
590
|
+
if (script.async) {
|
|
591
|
+
html += " async";
|
|
592
|
+
}
|
|
593
|
+
if (script.defer) {
|
|
594
|
+
html += " defer";
|
|
595
|
+
}
|
|
596
|
+
if (script.src) {
|
|
597
|
+
html += ` src="${escapeHtml(script.src)}"></script>${nl}`;
|
|
598
|
+
} else if (script.content) {
|
|
599
|
+
html += `>${script.content}</script>${nl}`;
|
|
600
|
+
} else {
|
|
601
|
+
html += `></script>${nl}`;
|
|
529
602
|
}
|
|
530
|
-
return children.map((c) => this.unwrapReactive(c));
|
|
531
603
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
continue;
|
|
566
|
-
}
|
|
567
|
-
let value = props[key];
|
|
568
|
-
value = this.resolveStateValue(value);
|
|
569
|
-
if (value == null || value === false) continue;
|
|
570
|
-
if (key.startsWith("on") && typeof value === "function") {
|
|
571
|
-
continue;
|
|
572
|
-
}
|
|
573
|
-
if (key === "className" || key === "class") {
|
|
574
|
-
const className = Array.isArray(value) ? value.join(" ") : value;
|
|
575
|
-
if (className) {
|
|
576
|
-
attrs.push(`class="${this.escapeHtml(String(className))}"`);
|
|
577
|
-
}
|
|
578
|
-
continue;
|
|
579
|
-
}
|
|
580
|
-
if (key === "style") {
|
|
581
|
-
const styleStr = this.styleToString(value);
|
|
582
|
-
if (styleStr) {
|
|
583
|
-
attrs.push(`style="${this.escapeHtml(styleStr)}"`);
|
|
604
|
+
html += `${indent}</body>${nl}</html>`;
|
|
605
|
+
return html;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// src/client/dom/json.ts
|
|
609
|
+
function jsonToVNode(json, reactiveNodes) {
|
|
610
|
+
if (isState(json)) {
|
|
611
|
+
return createReactiveChild(json, reactiveNodes, (value) => value);
|
|
612
|
+
}
|
|
613
|
+
if (isPrimitiveJson(json)) {
|
|
614
|
+
return json;
|
|
615
|
+
}
|
|
616
|
+
const { tag, attributes = {}, children } = json;
|
|
617
|
+
const props = {};
|
|
618
|
+
for (const key in attributes) {
|
|
619
|
+
const value = attributes[key];
|
|
620
|
+
if (key === "class") {
|
|
621
|
+
props.className = isState(value) ? value.value : value;
|
|
622
|
+
} else {
|
|
623
|
+
props[key] = isState(value) ? value.value : value;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
const childrenArray = [];
|
|
627
|
+
if (children != null) {
|
|
628
|
+
if (Array.isArray(children)) {
|
|
629
|
+
for (const child of children) {
|
|
630
|
+
if (isState(child)) {
|
|
631
|
+
childrenArray.push(createReactiveChild(child, reactiveNodes, (value) => value));
|
|
632
|
+
} else {
|
|
633
|
+
const converted = jsonToVNode(child, reactiveNodes);
|
|
634
|
+
if (converted != null && converted !== false) {
|
|
635
|
+
childrenArray.push(converted);
|
|
636
|
+
}
|
|
584
637
|
}
|
|
585
|
-
continue;
|
|
586
638
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
639
|
+
} else if (isState(children)) {
|
|
640
|
+
childrenArray.push(createReactiveChild(children, reactiveNodes, (value) => value));
|
|
641
|
+
} else if (typeof children === "object" && children !== null && "tag" in children) {
|
|
642
|
+
const converted = jsonToVNode(children, reactiveNodes);
|
|
643
|
+
if (converted != null && converted !== false) {
|
|
644
|
+
childrenArray.push(converted);
|
|
590
645
|
}
|
|
591
|
-
|
|
646
|
+
} else {
|
|
647
|
+
childrenArray.push(children);
|
|
592
648
|
}
|
|
593
|
-
return attrs.join(" ");
|
|
594
649
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
650
|
+
return { tagName: tag, props, children: childrenArray };
|
|
651
|
+
}
|
|
652
|
+
function vNodeJsonToVNode(json, reactiveNodes) {
|
|
653
|
+
if (isState(json)) {
|
|
654
|
+
return createReactiveChild(json, reactiveNodes, (value) => value);
|
|
655
|
+
}
|
|
656
|
+
if (isPrimitiveJson(json)) {
|
|
657
|
+
return json;
|
|
658
|
+
}
|
|
659
|
+
const { tagName, props = {}, children = [] } = json;
|
|
660
|
+
const resolvedProps = {};
|
|
661
|
+
for (const key in props) {
|
|
662
|
+
const value = props[key];
|
|
663
|
+
resolvedProps[key] = isState(value) ? value.value : value;
|
|
664
|
+
}
|
|
665
|
+
const childrenArray = [];
|
|
666
|
+
for (const child of children) {
|
|
667
|
+
if (isState(child)) {
|
|
668
|
+
childrenArray.push(createReactiveChild(child, reactiveNodes, (value) => value));
|
|
669
|
+
} else {
|
|
670
|
+
const converted = vNodeJsonToVNode(child, reactiveNodes);
|
|
671
|
+
if (converted != null && converted !== false) {
|
|
672
|
+
childrenArray.push(converted);
|
|
604
673
|
}
|
|
605
|
-
return styles.join(";");
|
|
606
674
|
}
|
|
607
|
-
return "";
|
|
608
675
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const entry = { node: null, renderFn };
|
|
616
|
-
this.reactiveNodes.set(state, entry);
|
|
617
|
-
state.subscribe(() => {
|
|
618
|
-
if (entry.node && entry.node.parentNode) {
|
|
619
|
-
const newValue = renderFn(state.value);
|
|
620
|
-
entry.node.textContent = String(newValue ?? "");
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
return currentValue;
|
|
676
|
+
return { tagName, props: resolvedProps, children: childrenArray };
|
|
677
|
+
}
|
|
678
|
+
function renderJson(rootElement, json, reactiveNodes) {
|
|
679
|
+
const vNode = jsonToVNode(json, reactiveNodes);
|
|
680
|
+
if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
|
|
681
|
+
throw new Error("Invalid JSON structure");
|
|
625
682
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
683
|
+
return render(rootElement, vNode);
|
|
684
|
+
}
|
|
685
|
+
function renderVNode(rootElement, json, reactiveNodes) {
|
|
686
|
+
const vNode = vNodeJsonToVNode(json, reactiveNodes);
|
|
687
|
+
if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
|
|
688
|
+
throw new Error("Invalid VNode JSON structure");
|
|
689
|
+
}
|
|
690
|
+
return render(rootElement, vNode);
|
|
691
|
+
}
|
|
692
|
+
function renderJsonToString(json, reactiveNodes, options = {}) {
|
|
693
|
+
const vNode = jsonToVNode(json, reactiveNodes);
|
|
694
|
+
return renderToString(vNode, options);
|
|
695
|
+
}
|
|
696
|
+
function renderVNodeToString(json, reactiveNodes, options = {}) {
|
|
697
|
+
const vNode = vNodeJsonToVNode(json, reactiveNodes);
|
|
698
|
+
return renderToString(vNode, options);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/client/dom/state-utils.ts
|
|
702
|
+
function createState(initialValue, options = {}) {
|
|
703
|
+
let value = initialValue;
|
|
704
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
705
|
+
let updateTimer = null;
|
|
706
|
+
const { throttle = 0, deep = false } = options;
|
|
707
|
+
const notify = () => listeners.forEach((listener) => listener(value));
|
|
708
|
+
const scheduleUpdate = () => {
|
|
709
|
+
if (throttle > 0) {
|
|
710
|
+
if (!updateTimer) {
|
|
711
|
+
updateTimer = setTimeout(() => {
|
|
712
|
+
updateTimer = null;
|
|
713
|
+
notify();
|
|
714
|
+
}, throttle);
|
|
641
715
|
}
|
|
716
|
+
} else {
|
|
717
|
+
notify();
|
|
642
718
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
} else {
|
|
664
|
-
childrenArray.push(children);
|
|
719
|
+
};
|
|
720
|
+
return {
|
|
721
|
+
get value() {
|
|
722
|
+
return value;
|
|
723
|
+
},
|
|
724
|
+
set value(newValue) {
|
|
725
|
+
const changed = deep ? JSON.stringify(value) !== JSON.stringify(newValue) : value !== newValue;
|
|
726
|
+
if (changed) {
|
|
727
|
+
value = newValue;
|
|
728
|
+
scheduleUpdate();
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
subscribe(fn) {
|
|
732
|
+
listeners.add(fn);
|
|
733
|
+
return () => listeners.delete(fn);
|
|
734
|
+
},
|
|
735
|
+
destroy() {
|
|
736
|
+
listeners.clear();
|
|
737
|
+
if (updateTimer) {
|
|
738
|
+
clearTimeout(updateTimer);
|
|
665
739
|
}
|
|
666
740
|
}
|
|
667
|
-
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
function computed(states, computeFn) {
|
|
744
|
+
const values = states.map((state) => state.value);
|
|
745
|
+
const result = createState(computeFn(...values));
|
|
746
|
+
states.forEach((state, index) => {
|
|
747
|
+
state.subscribe((newValue) => {
|
|
748
|
+
values[index] = newValue;
|
|
749
|
+
result.value = computeFn(...values);
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
function effect(stateFn) {
|
|
755
|
+
stateFn();
|
|
756
|
+
}
|
|
757
|
+
function createVirtualList(container, items, renderItem, itemHeight = 50, bufferSize = 5) {
|
|
758
|
+
const viewportHeight = container.clientHeight;
|
|
759
|
+
const totalHeight = items.length * itemHeight;
|
|
760
|
+
let scrollTop = 0;
|
|
761
|
+
const getVisibleRange = () => {
|
|
762
|
+
const start = Math.max(0, Math.floor(scrollTop / itemHeight) - bufferSize);
|
|
763
|
+
const end = Math.min(items.length, Math.ceil((scrollTop + viewportHeight) / itemHeight) + bufferSize);
|
|
764
|
+
return { start, end };
|
|
765
|
+
};
|
|
766
|
+
const render3 = () => {
|
|
767
|
+
const { start, end } = getVisibleRange();
|
|
768
|
+
const wrapper = document.createElement("div");
|
|
769
|
+
wrapper.style.cssText = `height:${totalHeight}px;position:relative`;
|
|
770
|
+
for (let i = start; i < end; i++) {
|
|
771
|
+
const itemEl = document.createElement("div");
|
|
772
|
+
itemEl.style.cssText = `position:absolute;top:${i * itemHeight}px;height:${itemHeight}px;width:100%`;
|
|
773
|
+
renderToDOM(renderItem(items[i], i), itemEl);
|
|
774
|
+
wrapper.appendChild(itemEl);
|
|
775
|
+
}
|
|
776
|
+
container.innerHTML = "";
|
|
777
|
+
container.appendChild(wrapper);
|
|
778
|
+
};
|
|
779
|
+
const scrollHandler = () => {
|
|
780
|
+
scrollTop = container.scrollTop;
|
|
781
|
+
requestAnimationFrame(render3);
|
|
782
|
+
};
|
|
783
|
+
container.addEventListener("scroll", scrollHandler);
|
|
784
|
+
render3();
|
|
785
|
+
return {
|
|
786
|
+
render: render3,
|
|
787
|
+
destroy: () => {
|
|
788
|
+
container.removeEventListener("scroll", scrollHandler);
|
|
789
|
+
container.innerHTML = "";
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function lazy(loadFn) {
|
|
794
|
+
let component = null;
|
|
795
|
+
let loading = false;
|
|
796
|
+
return async (...args) => {
|
|
797
|
+
if (!component && !loading) {
|
|
798
|
+
loading = true;
|
|
799
|
+
component = await loadFn();
|
|
800
|
+
loading = false;
|
|
801
|
+
}
|
|
802
|
+
return component ? component(...args) : { tagName: "div", props: { class: "loading" }, children: ["Loading..."] };
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// src/client/dom/index.ts
|
|
807
|
+
var DomNode = class {
|
|
808
|
+
constructor() {
|
|
809
|
+
this.elementCache = /* @__PURE__ */ new WeakMap();
|
|
810
|
+
this.reactiveNodes = /* @__PURE__ */ new Map();
|
|
811
|
+
}
|
|
812
|
+
createElement(tagName, props = {}, children = []) {
|
|
813
|
+
return { tagName, props, children };
|
|
814
|
+
}
|
|
815
|
+
renderToDOM(vNode, parent) {
|
|
816
|
+
return renderToDOM(vNode, parent);
|
|
817
|
+
}
|
|
818
|
+
render(rootElement, vNode) {
|
|
819
|
+
return render(rootElement, vNode);
|
|
820
|
+
}
|
|
821
|
+
batchRender(rootElement, vNodes) {
|
|
822
|
+
return batchRender(rootElement, vNodes);
|
|
823
|
+
}
|
|
824
|
+
renderChunked(rootElement, vNodes, chunkSize = 5e3, onProgress) {
|
|
825
|
+
return renderChunked(rootElement, vNodes, chunkSize, onProgress);
|
|
826
|
+
}
|
|
827
|
+
renderToHead(...vNodes) {
|
|
828
|
+
return renderToHead(...vNodes);
|
|
829
|
+
}
|
|
830
|
+
addStyle(cssText) {
|
|
831
|
+
return addStyle(cssText);
|
|
832
|
+
}
|
|
833
|
+
addMeta(attrs) {
|
|
834
|
+
return addMeta(attrs);
|
|
835
|
+
}
|
|
836
|
+
addLink(attrs) {
|
|
837
|
+
return addLink(attrs);
|
|
838
|
+
}
|
|
839
|
+
setTitle(text) {
|
|
840
|
+
return setTitle(text);
|
|
841
|
+
}
|
|
842
|
+
// Reactive State Management
|
|
843
|
+
createState(initialValue, options = {}) {
|
|
844
|
+
return createState(initialValue, options);
|
|
845
|
+
}
|
|
846
|
+
computed(states, computeFn) {
|
|
847
|
+
return computed(states, computeFn);
|
|
848
|
+
}
|
|
849
|
+
effect(stateFn) {
|
|
850
|
+
effect(stateFn);
|
|
851
|
+
}
|
|
852
|
+
// Virtual scrolling helper for large lists
|
|
853
|
+
createVirtualList(container, items, renderItem, itemHeight = 50, bufferSize = 5) {
|
|
854
|
+
return createVirtualList(container, items, renderItem, itemHeight, bufferSize);
|
|
855
|
+
}
|
|
856
|
+
// Lazy load components
|
|
857
|
+
lazy(loadFn) {
|
|
858
|
+
return lazy(loadFn);
|
|
859
|
+
}
|
|
860
|
+
// Memory management - cleanup unused elements
|
|
861
|
+
cleanupUnusedElements(root) {
|
|
862
|
+
return cleanupUnusedElements(root, this.elementCache);
|
|
863
|
+
}
|
|
864
|
+
// Server-Side Rendering - convert VNode to HTML string
|
|
865
|
+
renderToString(vNode, options = {}) {
|
|
866
|
+
return renderToString(vNode, options);
|
|
867
|
+
}
|
|
868
|
+
jsonToVNode(json) {
|
|
869
|
+
return jsonToVNode(json, this.reactiveNodes);
|
|
668
870
|
}
|
|
669
871
|
vNodeJsonToVNode(json) {
|
|
670
|
-
|
|
671
|
-
return this.createReactiveChild(json, (v) => v);
|
|
672
|
-
}
|
|
673
|
-
if (isPrimitiveJson(json)) {
|
|
674
|
-
return json;
|
|
675
|
-
}
|
|
676
|
-
const { tagName, props = {}, children = [] } = json;
|
|
677
|
-
const resolvedProps = {};
|
|
678
|
-
for (const key in props) {
|
|
679
|
-
const value = props[key];
|
|
680
|
-
resolvedProps[key] = this.isState(value) ? value.value : value;
|
|
681
|
-
}
|
|
682
|
-
const childrenArray = [];
|
|
683
|
-
for (const child of children) {
|
|
684
|
-
if (this.isState(child)) {
|
|
685
|
-
childrenArray.push(this.createReactiveChild(child, (v) => v));
|
|
686
|
-
} else {
|
|
687
|
-
const converted = this.vNodeJsonToVNode(child);
|
|
688
|
-
if (converted != null && converted !== false) {
|
|
689
|
-
childrenArray.push(converted);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
return { tagName, props: resolvedProps, children: childrenArray };
|
|
872
|
+
return vNodeJsonToVNode(json, this.reactiveNodes);
|
|
694
873
|
}
|
|
695
874
|
renderJson(rootElement, json) {
|
|
696
|
-
|
|
697
|
-
if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
|
|
698
|
-
throw new Error("Invalid JSON structure");
|
|
699
|
-
}
|
|
700
|
-
return this.render(rootElement, vNode);
|
|
875
|
+
return renderJson(rootElement, json, this.reactiveNodes);
|
|
701
876
|
}
|
|
702
877
|
renderVNode(rootElement, json) {
|
|
703
|
-
|
|
704
|
-
if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
|
|
705
|
-
throw new Error("Invalid VNode JSON structure");
|
|
706
|
-
}
|
|
707
|
-
return this.render(rootElement, vNode);
|
|
878
|
+
return renderVNode(rootElement, json, this.reactiveNodes);
|
|
708
879
|
}
|
|
709
880
|
renderJsonToString(json, options = {}) {
|
|
710
|
-
|
|
711
|
-
return this.renderToString(vNode, options);
|
|
881
|
+
return renderJsonToString(json, this.reactiveNodes, options);
|
|
712
882
|
}
|
|
713
883
|
renderVNodeToString(json, options = {}) {
|
|
714
|
-
|
|
715
|
-
return this.renderToString(vNode, options);
|
|
884
|
+
return renderVNodeToString(json, this.reactiveNodes, options);
|
|
716
885
|
}
|
|
717
886
|
// Generate complete HTML document as string (for SSR)
|
|
718
887
|
renderToHTMLDocument(vNode, options = {}) {
|
|
719
|
-
|
|
720
|
-
const nl = pretty ? "\n" : "";
|
|
721
|
-
const indent = pretty ? " " : "";
|
|
722
|
-
const indent2 = pretty ? " " : "";
|
|
723
|
-
let html = `<!DOCTYPE html>${nl}<html lang="${lang}">${nl}${indent}<head>${nl}${indent2}<meta charset="UTF-8">${nl}${indent2}<meta name="viewport" content="width=device-width, initial-scale=1.0">${nl}`;
|
|
724
|
-
if (title) html += `${indent2}<title>${this.escapeHtml(title)}</title>${nl}`;
|
|
725
|
-
for (const m of meta) {
|
|
726
|
-
html += `${indent2}<meta`;
|
|
727
|
-
for (const k in m) html += ` ${k}="${this.escapeHtml(m[k])}"`;
|
|
728
|
-
html += `>${nl}`;
|
|
729
|
-
}
|
|
730
|
-
for (const l of links) {
|
|
731
|
-
html += `${indent2}<link`;
|
|
732
|
-
for (const k in l) html += ` ${k}="${this.escapeHtml(l[k])}"`;
|
|
733
|
-
html += `>${nl}`;
|
|
734
|
-
}
|
|
735
|
-
for (const s of styles) {
|
|
736
|
-
if (s.href) {
|
|
737
|
-
html += `${indent2}<link rel="stylesheet" href="${this.escapeHtml(s.href)}">${nl}`;
|
|
738
|
-
} else if (s.content) {
|
|
739
|
-
html += `${indent2}<style>${s.content}</style>${nl}`;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
if (head) html += head + nl;
|
|
743
|
-
html += `${indent}</head>${nl}${indent}<body`;
|
|
744
|
-
for (const k in bodyAttrs) html += ` ${k}="${this.escapeHtml(bodyAttrs[k])}"`;
|
|
745
|
-
html += `>${nl}`;
|
|
746
|
-
html += this.renderToString(vNode, { pretty, indent: 2 });
|
|
747
|
-
for (const script of scripts) {
|
|
748
|
-
html += `${indent2}<script`;
|
|
749
|
-
if (script.type) html += ` type="${this.escapeHtml(script.type)}"`;
|
|
750
|
-
if (script.async) html += ` async`;
|
|
751
|
-
if (script.defer) html += ` defer`;
|
|
752
|
-
if (script.src) {
|
|
753
|
-
html += ` src="${this.escapeHtml(script.src)}"></script>${nl}`;
|
|
754
|
-
} else if (script.content) {
|
|
755
|
-
html += `>${script.content}</script>${nl}`;
|
|
756
|
-
} else {
|
|
757
|
-
html += `></script>${nl}`;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
html += `${indent}</body>${nl}</html>`;
|
|
761
|
-
return html;
|
|
888
|
+
return renderToHTMLDocument(vNode, options);
|
|
762
889
|
}
|
|
763
890
|
// Expose elementCache for reactive updates
|
|
764
891
|
getElementCache() {
|
|
@@ -766,9 +893,9 @@ var DomNode = class {
|
|
|
766
893
|
}
|
|
767
894
|
};
|
|
768
895
|
var dom = new DomNode();
|
|
769
|
-
var
|
|
770
|
-
var
|
|
771
|
-
var mount =
|
|
896
|
+
var render2 = dom.render.bind(dom);
|
|
897
|
+
var renderToString2 = dom.renderToString.bind(dom);
|
|
898
|
+
var mount = render2;
|
|
772
899
|
// Annotate the CommonJS export names for ESM import in node:
|
|
773
900
|
0 && (module.exports = {
|
|
774
901
|
DomNode,
|