solid-js 1.8.11 → 1.8.13
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/dist/dev.js +544 -307
- package/dist/server.js +170 -75
- package/dist/solid.js +471 -265
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -33
- package/package.json +9 -4
- package/store/dist/dev.cjs +12 -2
- package/store/dist/dev.js +133 -44
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +12 -2
- package/store/dist/store.js +124 -41
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -10
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +233 -142
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +64 -33
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +167 -96
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +3 -0
- package/web/dist/dev.js +625 -81
- package/web/dist/server.cjs +10 -15
- package/web/dist/server.js +216 -107
- package/web/dist/web.js +614 -80
- package/web/storage/dist/storage.js +10 -0
- package/web/storage/package.json +15 -0
- package/web/storage/types/index.d.ts +2 -0
- package/web/storage/types/index.js +13 -0
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/dist/storage.js +0 -10
- package/web/types/storage.d.ts +0 -2
- /package/web/{dist → storage/dist}/storage.cjs +0 -0
package/web/dist/server.cjs
CHANGED
|
@@ -13,7 +13,6 @@ const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
const ES2017FLAG = seroval.Feature.AggregateError
|
|
16
|
-
| seroval.Feature.BigInt
|
|
17
16
|
| seroval.Feature.BigIntTypedArray;
|
|
18
17
|
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
19
18
|
function createSerializer({
|
|
@@ -133,7 +132,7 @@ function renderToStream(code, options = {}) {
|
|
|
133
132
|
});
|
|
134
133
|
const flushEnd = () => {
|
|
135
134
|
if (!registry.size) {
|
|
136
|
-
serializer.flush();
|
|
135
|
+
queue(() => queue(() => serializer.flush()));
|
|
137
136
|
}
|
|
138
137
|
};
|
|
139
138
|
const registry = new Map();
|
|
@@ -198,36 +197,32 @@ function renderToStream(code, options = {}) {
|
|
|
198
197
|
if (!registry.has(key)) {
|
|
199
198
|
let resolve, reject;
|
|
200
199
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
201
|
-
registry.set(key, {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
200
|
+
registry.set(key, err => queue(() => queue(() => {
|
|
201
|
+
err ? reject(err) : resolve(true);
|
|
202
|
+
queue(flushEnd);
|
|
203
|
+
})));
|
|
205
204
|
serializer.write(key, p);
|
|
206
205
|
}
|
|
207
206
|
return (value, error) => {
|
|
208
207
|
if (registry.has(key)) {
|
|
209
|
-
const
|
|
210
|
-
resolve,
|
|
211
|
-
reject
|
|
212
|
-
} = registry.get(key);
|
|
208
|
+
const resolve = registry.get(key);
|
|
213
209
|
registry.delete(key);
|
|
214
210
|
if (waitForFragments(registry, key)) {
|
|
215
|
-
resolve(
|
|
211
|
+
resolve();
|
|
216
212
|
return;
|
|
217
213
|
}
|
|
218
|
-
if (
|
|
214
|
+
if (!completed) {
|
|
219
215
|
if (!firstFlushed) {
|
|
220
216
|
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
221
|
-
|
|
217
|
+
resolve(error);
|
|
222
218
|
} else {
|
|
223
219
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
224
220
|
pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
225
|
-
|
|
221
|
+
resolve(error);
|
|
226
222
|
scriptFlushed = true;
|
|
227
223
|
}
|
|
228
224
|
}
|
|
229
225
|
}
|
|
230
|
-
if (!registry.size) queue(flushEnd);
|
|
231
226
|
return firstFlushed;
|
|
232
227
|
};
|
|
233
228
|
}
|
package/web/dist/server.js
CHANGED
|
@@ -1,31 +1,86 @@
|
|
|
1
|
-
import { sharedConfig, createRoot, splitProps } from
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { sharedConfig, createRoot, splitProps } from "solid-js";
|
|
2
|
+
export {
|
|
3
|
+
ErrorBoundary,
|
|
4
|
+
For,
|
|
5
|
+
Index,
|
|
6
|
+
Match,
|
|
7
|
+
Show,
|
|
8
|
+
Suspense,
|
|
9
|
+
SuspenseList,
|
|
10
|
+
Switch,
|
|
11
|
+
createComponent,
|
|
12
|
+
mergeProps
|
|
13
|
+
} from "solid-js";
|
|
14
|
+
import { Feature, Serializer, getCrossReferenceHeader } from "seroval";
|
|
15
|
+
import {
|
|
16
|
+
CustomEventPlugin,
|
|
17
|
+
DOMExceptionPlugin,
|
|
18
|
+
EventPlugin,
|
|
19
|
+
FormDataPlugin,
|
|
20
|
+
HeadersPlugin,
|
|
21
|
+
ReadableStreamPlugin,
|
|
22
|
+
RequestPlugin,
|
|
23
|
+
ResponsePlugin,
|
|
24
|
+
URLSearchParamsPlugin,
|
|
25
|
+
URLPlugin
|
|
26
|
+
} from "seroval-plugins/web";
|
|
5
27
|
|
|
6
|
-
const booleans = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
28
|
+
const booleans = [
|
|
29
|
+
"allowfullscreen",
|
|
30
|
+
"async",
|
|
31
|
+
"autofocus",
|
|
32
|
+
"autoplay",
|
|
33
|
+
"checked",
|
|
34
|
+
"controls",
|
|
35
|
+
"default",
|
|
36
|
+
"disabled",
|
|
37
|
+
"formnovalidate",
|
|
38
|
+
"hidden",
|
|
39
|
+
"indeterminate",
|
|
40
|
+
"inert",
|
|
41
|
+
"ismap",
|
|
42
|
+
"loop",
|
|
43
|
+
"multiple",
|
|
44
|
+
"muted",
|
|
45
|
+
"nomodule",
|
|
46
|
+
"novalidate",
|
|
47
|
+
"open",
|
|
48
|
+
"playsinline",
|
|
49
|
+
"readonly",
|
|
50
|
+
"required",
|
|
51
|
+
"reversed",
|
|
52
|
+
"seamless",
|
|
53
|
+
"selected"
|
|
54
|
+
];
|
|
55
|
+
const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
|
|
56
|
+
const ChildProperties = /*#__PURE__*/ new Set([
|
|
57
|
+
"innerHTML",
|
|
58
|
+
"textContent",
|
|
59
|
+
"innerText",
|
|
60
|
+
"children"
|
|
61
|
+
]);
|
|
62
|
+
const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
|
|
10
63
|
className: "class",
|
|
11
64
|
htmlFor: "for"
|
|
12
65
|
});
|
|
13
66
|
|
|
14
|
-
const ES2017FLAG = Feature.AggregateError
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
18
|
-
function createSerializer({
|
|
19
|
-
onData,
|
|
20
|
-
onDone,
|
|
21
|
-
scopeId,
|
|
22
|
-
onError
|
|
23
|
-
}) {
|
|
67
|
+
const ES2017FLAG = Feature.AggregateError | Feature.BigIntTypedArray;
|
|
68
|
+
const GLOBAL_IDENTIFIER = "_$HY.r";
|
|
69
|
+
function createSerializer({ onData, onDone, scopeId, onError }) {
|
|
24
70
|
return new Serializer({
|
|
25
71
|
scopeId,
|
|
26
72
|
plugins: [
|
|
27
|
-
|
|
28
|
-
|
|
73
|
+
CustomEventPlugin,
|
|
74
|
+
DOMExceptionPlugin,
|
|
75
|
+
EventPlugin,
|
|
76
|
+
FormDataPlugin,
|
|
77
|
+
HeadersPlugin,
|
|
78
|
+
ReadableStreamPlugin,
|
|
79
|
+
RequestPlugin,
|
|
80
|
+
ResponsePlugin,
|
|
81
|
+
URLSearchParamsPlugin,
|
|
82
|
+
URLPlugin
|
|
83
|
+
],
|
|
29
84
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
30
85
|
disabledFeatures: ES2017FLAG,
|
|
31
86
|
onData,
|
|
@@ -34,15 +89,14 @@ function createSerializer({
|
|
|
34
89
|
});
|
|
35
90
|
}
|
|
36
91
|
function getLocalHeaderScript(id) {
|
|
37
|
-
return getCrossReferenceHeader(id) +
|
|
92
|
+
return getCrossReferenceHeader(id) + ";";
|
|
38
93
|
}
|
|
39
94
|
|
|
40
|
-
const VOID_ELEMENTS =
|
|
95
|
+
const VOID_ELEMENTS =
|
|
96
|
+
/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
41
97
|
const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content)}n.remove(),_$HY.fe(e)}`;
|
|
42
98
|
function renderToString(code, options = {}) {
|
|
43
|
-
const {
|
|
44
|
-
renderId
|
|
45
|
-
} = options;
|
|
99
|
+
const { renderId } = options;
|
|
46
100
|
let scripts = "";
|
|
47
101
|
const serializer = createSerializer({
|
|
48
102
|
scopeId: renderId,
|
|
@@ -80,9 +134,7 @@ function renderToString(code, options = {}) {
|
|
|
80
134
|
return html;
|
|
81
135
|
}
|
|
82
136
|
function renderToStringAsync(code, options = {}) {
|
|
83
|
-
const {
|
|
84
|
-
timeoutMs = 30000
|
|
85
|
-
} = options;
|
|
137
|
+
const { timeoutMs = 30000 } = options;
|
|
86
138
|
let timeoutHandle;
|
|
87
139
|
const timeout = new Promise((_, reject) => {
|
|
88
140
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -93,13 +145,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
93
145
|
});
|
|
94
146
|
}
|
|
95
147
|
function renderToStream(code, options = {}) {
|
|
96
|
-
let {
|
|
97
|
-
nonce,
|
|
98
|
-
onCompleteShell,
|
|
99
|
-
onCompleteAll,
|
|
100
|
-
renderId,
|
|
101
|
-
noScripts
|
|
102
|
-
} = options;
|
|
148
|
+
let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
|
|
103
149
|
let dispose;
|
|
104
150
|
const blockingPromises = [];
|
|
105
151
|
const pushTask = task => {
|
|
@@ -115,11 +161,12 @@ function renderToStream(code, options = {}) {
|
|
|
115
161
|
const onDone = () => {
|
|
116
162
|
writeTasks();
|
|
117
163
|
doShell();
|
|
118
|
-
onCompleteAll &&
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
164
|
+
onCompleteAll &&
|
|
165
|
+
onCompleteAll({
|
|
166
|
+
write(v) {
|
|
167
|
+
!completed && buffer.write(v);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
123
170
|
writable && writable.end();
|
|
124
171
|
completed = true;
|
|
125
172
|
if (firstFlushed) dispose();
|
|
@@ -132,7 +179,7 @@ function renderToStream(code, options = {}) {
|
|
|
132
179
|
});
|
|
133
180
|
const flushEnd = () => {
|
|
134
181
|
if (!registry.size) {
|
|
135
|
-
serializer.flush();
|
|
182
|
+
queue(() => queue(() => serializer.flush()));
|
|
136
183
|
}
|
|
137
184
|
};
|
|
138
185
|
const registry = new Map();
|
|
@@ -176,17 +223,23 @@ function renderToStream(code, options = {}) {
|
|
|
176
223
|
const first = html.indexOf(placeholder);
|
|
177
224
|
if (first === -1) return;
|
|
178
225
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
179
|
-
html = html.replace(
|
|
226
|
+
html = html.replace(
|
|
227
|
+
html.slice(first, last + placeholder.length + 1),
|
|
228
|
+
resolveSSRNode(payloadFn())
|
|
229
|
+
);
|
|
180
230
|
},
|
|
181
231
|
serialize(id, p, wait) {
|
|
182
232
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
183
233
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
184
234
|
blockingPromises.push(p);
|
|
185
|
-
!serverOnly &&
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
235
|
+
!serverOnly &&
|
|
236
|
+
p
|
|
237
|
+
.then(d => {
|
|
238
|
+
serializer.write(id, d);
|
|
239
|
+
})
|
|
240
|
+
.catch(e => {
|
|
241
|
+
serializer.write(id, e);
|
|
242
|
+
});
|
|
190
243
|
} else if (!serverOnly) serializer.write(id, p);
|
|
191
244
|
},
|
|
192
245
|
roots: 0,
|
|
@@ -196,37 +249,37 @@ function renderToStream(code, options = {}) {
|
|
|
196
249
|
registerFragment(key) {
|
|
197
250
|
if (!registry.has(key)) {
|
|
198
251
|
let resolve, reject;
|
|
199
|
-
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
200
|
-
registry.set(key,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
252
|
+
const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
|
|
253
|
+
registry.set(key, err =>
|
|
254
|
+
queue(() =>
|
|
255
|
+
queue(() => {
|
|
256
|
+
err ? reject(err) : resolve(true);
|
|
257
|
+
queue(flushEnd);
|
|
258
|
+
})
|
|
259
|
+
)
|
|
260
|
+
);
|
|
204
261
|
serializer.write(key, p);
|
|
205
262
|
}
|
|
206
263
|
return (value, error) => {
|
|
207
264
|
if (registry.has(key)) {
|
|
208
|
-
const
|
|
209
|
-
resolve,
|
|
210
|
-
reject
|
|
211
|
-
} = registry.get(key);
|
|
265
|
+
const resolve = registry.get(key);
|
|
212
266
|
registry.delete(key);
|
|
213
267
|
if (waitForFragments(registry, key)) {
|
|
214
|
-
resolve(
|
|
268
|
+
resolve();
|
|
215
269
|
return;
|
|
216
270
|
}
|
|
217
|
-
if (
|
|
271
|
+
if (!completed) {
|
|
218
272
|
if (!firstFlushed) {
|
|
219
|
-
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
220
|
-
|
|
273
|
+
queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
|
|
274
|
+
resolve(error);
|
|
221
275
|
} else {
|
|
222
276
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
223
277
|
pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
224
|
-
|
|
278
|
+
resolve(error);
|
|
225
279
|
scriptFlushed = true;
|
|
226
280
|
}
|
|
227
281
|
}
|
|
228
282
|
}
|
|
229
|
-
if (!registry.size) queue(flushEnd);
|
|
230
283
|
return firstFlushed;
|
|
231
284
|
};
|
|
232
285
|
}
|
|
@@ -243,11 +296,12 @@ function renderToStream(code, options = {}) {
|
|
|
243
296
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
244
297
|
buffer.write(html);
|
|
245
298
|
tasks = "";
|
|
246
|
-
onCompleteShell &&
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
299
|
+
onCompleteShell &&
|
|
300
|
+
onCompleteShell({
|
|
301
|
+
write(v) {
|
|
302
|
+
!completed && buffer.write(v);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
251
305
|
shellCompleted = true;
|
|
252
306
|
}
|
|
253
307
|
return {
|
|
@@ -282,7 +336,7 @@ function renderToStream(code, options = {}) {
|
|
|
282
336
|
pipeTo(w) {
|
|
283
337
|
return allSettled(blockingPromises).then(() => {
|
|
284
338
|
let resolve;
|
|
285
|
-
const p = new Promise(r => resolve = r);
|
|
339
|
+
const p = new Promise(r => (resolve = r));
|
|
286
340
|
setTimeout(() => {
|
|
287
341
|
doShell();
|
|
288
342
|
const encoder = new TextEncoder();
|
|
@@ -312,13 +366,13 @@ function renderToStream(code, options = {}) {
|
|
|
312
366
|
};
|
|
313
367
|
}
|
|
314
368
|
function HydrationScript(props) {
|
|
315
|
-
const {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
369
|
+
const { nonce } = sharedConfig.context;
|
|
370
|
+
return ssr(
|
|
371
|
+
generateHydrationScript({
|
|
372
|
+
nonce,
|
|
373
|
+
...props
|
|
374
|
+
})
|
|
375
|
+
);
|
|
322
376
|
}
|
|
323
377
|
function ssr(t, ...nodes) {
|
|
324
378
|
if (nodes.length) {
|
|
@@ -363,7 +417,8 @@ function ssrStyle(value) {
|
|
|
363
417
|
return result;
|
|
364
418
|
}
|
|
365
419
|
function ssrElement(tag, props, children, needsId) {
|
|
366
|
-
if (props == null) props = {};
|
|
420
|
+
if (props == null) props = {};
|
|
421
|
+
else if (typeof props === "function") props = props();
|
|
367
422
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
368
423
|
const keys = Object.keys(props);
|
|
369
424
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -371,7 +426,8 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
371
426
|
for (let i = 0; i < keys.length; i++) {
|
|
372
427
|
const prop = keys[i];
|
|
373
428
|
if (ChildProperties.has(prop)) {
|
|
374
|
-
if (children === undefined && !skipChildren)
|
|
429
|
+
if (children === undefined && !skipChildren)
|
|
430
|
+
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
375
431
|
continue;
|
|
376
432
|
}
|
|
377
433
|
const value = props[prop];
|
|
@@ -380,10 +436,14 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
380
436
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
381
437
|
if (classResolved) continue;
|
|
382
438
|
let n;
|
|
383
|
-
result += `class="${
|
|
439
|
+
result += `class="${
|
|
440
|
+
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
441
|
+
ssrClassList(props.classList)
|
|
442
|
+
}"`;
|
|
384
443
|
classResolved = true;
|
|
385
444
|
} else if (BooleanAttributes.has(prop)) {
|
|
386
|
-
if (value) result += prop;
|
|
445
|
+
if (value) result += prop;
|
|
446
|
+
else continue;
|
|
387
447
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
388
448
|
continue;
|
|
389
449
|
} else {
|
|
@@ -391,16 +451,17 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
391
451
|
}
|
|
392
452
|
if (i !== keys.length - 1) result += " ";
|
|
393
453
|
}
|
|
394
|
-
if (skipChildren)
|
|
395
|
-
|
|
396
|
-
|
|
454
|
+
if (skipChildren)
|
|
455
|
+
return {
|
|
456
|
+
t: result + "/>"
|
|
457
|
+
};
|
|
397
458
|
if (typeof children === "function") children = children();
|
|
398
459
|
return {
|
|
399
460
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
400
461
|
};
|
|
401
462
|
}
|
|
402
463
|
function ssrAttribute(key, value, isBoolean) {
|
|
403
|
-
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
464
|
+
return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
|
|
404
465
|
}
|
|
405
466
|
function ssrHydrationKey() {
|
|
406
467
|
const hk = getHydrationKey();
|
|
@@ -444,12 +505,13 @@ function escape(s, attr) {
|
|
|
444
505
|
left = iDelim + 1;
|
|
445
506
|
iDelim = s.indexOf(delim, left);
|
|
446
507
|
} while (iDelim >= 0);
|
|
447
|
-
} else
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
508
|
+
} else
|
|
509
|
+
while (iAmp >= 0) {
|
|
510
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
511
|
+
out += "&";
|
|
512
|
+
left = iAmp + 1;
|
|
513
|
+
iAmp = s.indexOf("&", left);
|
|
514
|
+
}
|
|
453
515
|
return left < s.length ? out + s.substring(left) : out;
|
|
454
516
|
}
|
|
455
517
|
function resolveSSRNode(node, top) {
|
|
@@ -461,7 +523,7 @@ function resolveSSRNode(node, top) {
|
|
|
461
523
|
let mapped = "";
|
|
462
524
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
463
525
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
464
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
526
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
465
527
|
}
|
|
466
528
|
return mapped;
|
|
467
529
|
}
|
|
@@ -482,11 +544,12 @@ function getAssets() {
|
|
|
482
544
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
483
545
|
return out;
|
|
484
546
|
}
|
|
485
|
-
function generateHydrationScript({
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
} =
|
|
489
|
-
|
|
547
|
+
function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
|
|
548
|
+
return `<script${
|
|
549
|
+
nonce ? ` nonce="${nonce}"` : ""
|
|
550
|
+
}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join(
|
|
551
|
+
'", "'
|
|
552
|
+
)}"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
490
553
|
}
|
|
491
554
|
function Hydration(props) {
|
|
492
555
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -545,16 +608,20 @@ function replacePlaceholder(html, key, value) {
|
|
|
545
608
|
}
|
|
546
609
|
const RequestContext = Symbol();
|
|
547
610
|
function getRequestEvent() {
|
|
548
|
-
return globalThis[RequestContext]
|
|
611
|
+
return globalThis[RequestContext]
|
|
612
|
+
? globalThis[RequestContext].getStore() ||
|
|
613
|
+
(sharedConfig.context && sharedConfig.context.event) ||
|
|
614
|
+
console.log(
|
|
615
|
+
"RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls."
|
|
616
|
+
)
|
|
617
|
+
: undefined;
|
|
549
618
|
}
|
|
550
619
|
function Assets(props) {
|
|
551
620
|
useAssets(() => props.children);
|
|
552
621
|
}
|
|
553
622
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
554
623
|
if (options.onReady) {
|
|
555
|
-
options.onCompleteShell = ({
|
|
556
|
-
write
|
|
557
|
-
}) => {
|
|
624
|
+
options.onCompleteShell = ({ write }) => {
|
|
558
625
|
options.onReady({
|
|
559
626
|
write,
|
|
560
627
|
startWriting() {
|
|
@@ -568,9 +635,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
568
635
|
}
|
|
569
636
|
function pipeToWritable(code, writable, options = {}) {
|
|
570
637
|
if (options.onReady) {
|
|
571
|
-
options.onCompleteShell = ({
|
|
572
|
-
write
|
|
573
|
-
}) => {
|
|
638
|
+
options.onCompleteShell = ({ write }) => {
|
|
574
639
|
options.onReady({
|
|
575
640
|
write,
|
|
576
641
|
startWriting() {
|
|
@@ -600,11 +665,19 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
600
665
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
601
666
|
if (classResolved) continue;
|
|
602
667
|
let n;
|
|
603
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
668
|
+
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
669
|
+
(n = props.className) ? n + " " : ""
|
|
670
|
+
}${ssrClassList(props.classList)}"`;
|
|
604
671
|
classResolved = true;
|
|
605
672
|
} else if (BooleanAttributes.has(prop)) {
|
|
606
|
-
if (value) result += prop;
|
|
607
|
-
|
|
673
|
+
if (value) result += prop;
|
|
674
|
+
else continue;
|
|
675
|
+
} else if (
|
|
676
|
+
value == undefined ||
|
|
677
|
+
prop === "ref" ||
|
|
678
|
+
prop.slice(0, 2) === "on" ||
|
|
679
|
+
prop.slice(0, 5) === "prop:"
|
|
680
|
+
) {
|
|
608
681
|
continue;
|
|
609
682
|
} else {
|
|
610
683
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -628,7 +701,8 @@ function Dynamic(props) {
|
|
|
628
701
|
const comp = p.component,
|
|
629
702
|
t = typeof comp;
|
|
630
703
|
if (comp) {
|
|
631
|
-
if (t === "function") return comp(others);
|
|
704
|
+
if (t === "function") return comp(others);
|
|
705
|
+
else if (t === "string") {
|
|
632
706
|
return ssrElement(comp, others, undefined, true);
|
|
633
707
|
}
|
|
634
708
|
}
|
|
@@ -637,4 +711,39 @@ function Portal(props) {
|
|
|
637
711
|
return "";
|
|
638
712
|
}
|
|
639
713
|
|
|
640
|
-
export {
|
|
714
|
+
export {
|
|
715
|
+
Assets,
|
|
716
|
+
Dynamic,
|
|
717
|
+
Hydration,
|
|
718
|
+
HydrationScript,
|
|
719
|
+
NoHydration,
|
|
720
|
+
Portal,
|
|
721
|
+
RequestContext,
|
|
722
|
+
addEventListener,
|
|
723
|
+
delegateEvents,
|
|
724
|
+
escape,
|
|
725
|
+
generateHydrationScript,
|
|
726
|
+
getAssets,
|
|
727
|
+
getHydrationKey,
|
|
728
|
+
getRequestEvent,
|
|
729
|
+
hydrate,
|
|
730
|
+
insert,
|
|
731
|
+
isDev,
|
|
732
|
+
isServer,
|
|
733
|
+
pipeToNodeWritable,
|
|
734
|
+
pipeToWritable,
|
|
735
|
+
render,
|
|
736
|
+
renderToStream,
|
|
737
|
+
renderToString,
|
|
738
|
+
renderToStringAsync,
|
|
739
|
+
resolveSSRNode,
|
|
740
|
+
spread,
|
|
741
|
+
ssr,
|
|
742
|
+
ssrAttribute,
|
|
743
|
+
ssrClassList,
|
|
744
|
+
ssrElement,
|
|
745
|
+
ssrHydrationKey,
|
|
746
|
+
ssrSpread,
|
|
747
|
+
ssrStyle,
|
|
748
|
+
useAssets
|
|
749
|
+
};
|