solid-js 1.8.8 → 1.8.10
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.cjs +17 -21
- package/dist/dev.js +554 -321
- package/dist/server.js +170 -75
- package/dist/solid.cjs +17 -21
- package/dist/solid.js +481 -279
- 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/jsx-runtime/types/jsx.d.ts +2 -1
- 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 +3 -2
- package/store/dist/dev.cjs +1 -1
- package/store/dist/dev.js +117 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +1 -1
- package/store/dist/store.js +108 -39
- 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/jsx.d.ts +2 -1
- 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 +1 -1
- package/web/dist/dev.js +621 -82
- package/web/dist/server.cjs +53 -42
- package/web/dist/server.js +244 -127
- package/web/dist/storage.js +3 -3
- package/web/dist/web.cjs +1 -1
- package/web/dist/web.js +615 -81
- 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/server.js
CHANGED
|
@@ -1,32 +1,86 @@
|
|
|
1
|
-
import { sharedConfig, createRoot, splitProps } from
|
|
2
|
-
export {
|
|
3
|
-
|
|
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";
|
|
4
27
|
|
|
5
|
-
const booleans = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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), {
|
|
9
63
|
className: "class",
|
|
10
64
|
htmlFor: "for"
|
|
11
65
|
});
|
|
12
66
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| Feature.BigInt
|
|
17
|
-
| Feature.BigIntTypedArray;
|
|
18
|
-
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
19
|
-
function createSerializer({
|
|
20
|
-
onData,
|
|
21
|
-
onDone,
|
|
22
|
-
scopeId,
|
|
23
|
-
onError
|
|
24
|
-
}) {
|
|
67
|
+
const ES2017FLAG = Feature.AggregateError | Feature.BigInt | Feature.BigIntTypedArray;
|
|
68
|
+
const GLOBAL_IDENTIFIER = "_$HY.r";
|
|
69
|
+
function createSerializer({ onData, onDone, scopeId, onError }) {
|
|
25
70
|
return new Serializer({
|
|
26
71
|
scopeId,
|
|
27
72
|
plugins: [
|
|
28
|
-
|
|
29
|
-
|
|
73
|
+
CustomEventPlugin,
|
|
74
|
+
DOMExceptionPlugin,
|
|
75
|
+
EventPlugin,
|
|
76
|
+
FormDataPlugin,
|
|
77
|
+
HeadersPlugin,
|
|
78
|
+
ReadableStreamPlugin,
|
|
79
|
+
RequestPlugin,
|
|
80
|
+
ResponsePlugin,
|
|
81
|
+
URLSearchParamsPlugin,
|
|
82
|
+
URLPlugin
|
|
83
|
+
],
|
|
30
84
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
31
85
|
disabledFeatures: ES2017FLAG,
|
|
32
86
|
onData,
|
|
@@ -35,15 +89,14 @@ function createSerializer({
|
|
|
35
89
|
});
|
|
36
90
|
}
|
|
37
91
|
function getLocalHeaderScript(id) {
|
|
38
|
-
return getCrossReferenceHeader(id) +
|
|
92
|
+
return getCrossReferenceHeader(id) + ";";
|
|
39
93
|
}
|
|
40
94
|
|
|
41
|
-
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;
|
|
42
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)}`;
|
|
43
98
|
function renderToString(code, options = {}) {
|
|
44
|
-
const {
|
|
45
|
-
renderId
|
|
46
|
-
} = options;
|
|
99
|
+
const { renderId } = options;
|
|
47
100
|
let scripts = "";
|
|
48
101
|
const serializer = createSerializer({
|
|
49
102
|
scopeId: renderId,
|
|
@@ -81,9 +134,7 @@ function renderToString(code, options = {}) {
|
|
|
81
134
|
return html;
|
|
82
135
|
}
|
|
83
136
|
function renderToStringAsync(code, options = {}) {
|
|
84
|
-
const {
|
|
85
|
-
timeoutMs = 30000
|
|
86
|
-
} = options;
|
|
137
|
+
const { timeoutMs = 30000 } = options;
|
|
87
138
|
let timeoutHandle;
|
|
88
139
|
const timeout = new Promise((_, reject) => {
|
|
89
140
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -94,13 +145,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
94
145
|
});
|
|
95
146
|
}
|
|
96
147
|
function renderToStream(code, options = {}) {
|
|
97
|
-
let {
|
|
98
|
-
nonce,
|
|
99
|
-
onCompleteShell,
|
|
100
|
-
onCompleteAll,
|
|
101
|
-
renderId,
|
|
102
|
-
noScripts
|
|
103
|
-
} = options;
|
|
148
|
+
let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
|
|
104
149
|
let dispose;
|
|
105
150
|
const blockingPromises = [];
|
|
106
151
|
const pushTask = task => {
|
|
@@ -113,23 +158,23 @@ function renderToStream(code, options = {}) {
|
|
|
113
158
|
timer = setTimeout(writeTasks);
|
|
114
159
|
}
|
|
115
160
|
};
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
161
|
+
const onDone = () => {
|
|
162
|
+
writeTasks();
|
|
163
|
+
doShell();
|
|
164
|
+
onCompleteAll &&
|
|
165
|
+
onCompleteAll({
|
|
120
166
|
write(v) {
|
|
121
167
|
!completed && buffer.write(v);
|
|
122
168
|
}
|
|
123
169
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
170
|
+
writable && writable.end();
|
|
171
|
+
completed = true;
|
|
172
|
+
if (firstFlushed) dispose();
|
|
128
173
|
};
|
|
129
174
|
const serializer = createSerializer({
|
|
130
175
|
scopeId: options.renderId,
|
|
131
176
|
onData: pushTask,
|
|
132
|
-
onDone
|
|
177
|
+
onDone,
|
|
133
178
|
onError: options.onError
|
|
134
179
|
});
|
|
135
180
|
const flushEnd = () => {
|
|
@@ -152,6 +197,7 @@ function renderToStream(code, options = {}) {
|
|
|
152
197
|
let tasks = "";
|
|
153
198
|
let firstFlushed = false;
|
|
154
199
|
let completed = false;
|
|
200
|
+
let shellCompleted = false;
|
|
155
201
|
let scriptFlushed = false;
|
|
156
202
|
let timer = null;
|
|
157
203
|
let buffer = {
|
|
@@ -177,17 +223,23 @@ function renderToStream(code, options = {}) {
|
|
|
177
223
|
const first = html.indexOf(placeholder);
|
|
178
224
|
if (first === -1) return;
|
|
179
225
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
180
|
-
html = html.replace(
|
|
226
|
+
html = html.replace(
|
|
227
|
+
html.slice(first, last + placeholder.length + 1),
|
|
228
|
+
resolveSSRNode(payloadFn())
|
|
229
|
+
);
|
|
181
230
|
},
|
|
182
231
|
serialize(id, p, wait) {
|
|
183
232
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
184
233
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
185
234
|
blockingPromises.push(p);
|
|
186
|
-
!serverOnly &&
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
235
|
+
!serverOnly &&
|
|
236
|
+
p
|
|
237
|
+
.then(d => {
|
|
238
|
+
serializer.write(id, d);
|
|
239
|
+
})
|
|
240
|
+
.catch(e => {
|
|
241
|
+
serializer.write(id, e);
|
|
242
|
+
});
|
|
191
243
|
} else if (!serverOnly) serializer.write(id, p);
|
|
192
244
|
},
|
|
193
245
|
roots: 0,
|
|
@@ -197,7 +249,7 @@ function renderToStream(code, options = {}) {
|
|
|
197
249
|
registerFragment(key) {
|
|
198
250
|
if (!registry.has(key)) {
|
|
199
251
|
let resolve, reject;
|
|
200
|
-
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
252
|
+
const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
|
|
201
253
|
registry.set(key, {
|
|
202
254
|
resolve: v => queue(() => queue(() => resolve(v))),
|
|
203
255
|
reject: e => queue(() => queue(() => reject(e)))
|
|
@@ -206,10 +258,7 @@ function renderToStream(code, options = {}) {
|
|
|
206
258
|
}
|
|
207
259
|
return (value, error) => {
|
|
208
260
|
if (registry.has(key)) {
|
|
209
|
-
const {
|
|
210
|
-
resolve,
|
|
211
|
-
reject
|
|
212
|
-
} = registry.get(key);
|
|
261
|
+
const { resolve, reject } = registry.get(key);
|
|
213
262
|
registry.delete(key);
|
|
214
263
|
if (waitForFragments(registry, key)) {
|
|
215
264
|
resolve(true);
|
|
@@ -217,7 +266,7 @@ function renderToStream(code, options = {}) {
|
|
|
217
266
|
}
|
|
218
267
|
if ((value !== undefined || error) && !completed) {
|
|
219
268
|
if (!firstFlushed) {
|
|
220
|
-
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
269
|
+
queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
|
|
221
270
|
error ? reject(error) : resolve(true);
|
|
222
271
|
} else {
|
|
223
272
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -237,22 +286,25 @@ function renderToStream(code, options = {}) {
|
|
|
237
286
|
return resolveSSRNode(escape(code()));
|
|
238
287
|
});
|
|
239
288
|
function doShell() {
|
|
289
|
+
if (shellCompleted) return;
|
|
240
290
|
sharedConfig.context = context;
|
|
241
291
|
context.noHydrate = true;
|
|
242
292
|
html = injectAssets(context.assets, html);
|
|
243
293
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
244
294
|
buffer.write(html);
|
|
245
295
|
tasks = "";
|
|
246
|
-
onCompleteShell &&
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
296
|
+
onCompleteShell &&
|
|
297
|
+
onCompleteShell({
|
|
298
|
+
write(v) {
|
|
299
|
+
!completed && buffer.write(v);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
shellCompleted = true;
|
|
251
303
|
}
|
|
252
304
|
return {
|
|
253
305
|
then(fn) {
|
|
254
306
|
function complete() {
|
|
255
|
-
|
|
307
|
+
dispose();
|
|
256
308
|
fn(tmp);
|
|
257
309
|
}
|
|
258
310
|
if (onCompleteAll) {
|
|
@@ -262,52 +314,62 @@ function renderToStream(code, options = {}) {
|
|
|
262
314
|
complete();
|
|
263
315
|
};
|
|
264
316
|
} else onCompleteAll = complete;
|
|
265
|
-
|
|
317
|
+
queue(flushEnd);
|
|
266
318
|
},
|
|
267
319
|
pipe(w) {
|
|
268
320
|
allSettled(blockingPromises).then(() => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
321
|
+
setTimeout(() => {
|
|
322
|
+
doShell();
|
|
323
|
+
buffer = writable = w;
|
|
324
|
+
buffer.write(tmp);
|
|
325
|
+
firstFlushed = true;
|
|
326
|
+
if (completed) {
|
|
327
|
+
dispose();
|
|
328
|
+
writable.end();
|
|
329
|
+
} else flushEnd();
|
|
330
|
+
});
|
|
274
331
|
});
|
|
275
332
|
},
|
|
276
333
|
pipeTo(w) {
|
|
277
334
|
return allSettled(blockingPromises).then(() => {
|
|
278
|
-
doShell();
|
|
279
|
-
const encoder = new TextEncoder();
|
|
280
|
-
const writer = w.getWriter();
|
|
281
335
|
let resolve;
|
|
282
|
-
const p = new Promise(r => resolve = r);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
336
|
+
const p = new Promise(r => (resolve = r));
|
|
337
|
+
setTimeout(() => {
|
|
338
|
+
doShell();
|
|
339
|
+
const encoder = new TextEncoder();
|
|
340
|
+
const writer = w.getWriter();
|
|
341
|
+
writable = {
|
|
342
|
+
end() {
|
|
343
|
+
writer.releaseLock();
|
|
344
|
+
w.close();
|
|
345
|
+
resolve();
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
buffer = {
|
|
349
|
+
write(payload) {
|
|
350
|
+
writer.write(encoder.encode(payload));
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
buffer.write(tmp);
|
|
354
|
+
firstFlushed = true;
|
|
355
|
+
if (completed) {
|
|
356
|
+
dispose();
|
|
357
|
+
writable.end();
|
|
358
|
+
} else flushEnd();
|
|
359
|
+
});
|
|
298
360
|
return p;
|
|
299
361
|
});
|
|
300
362
|
}
|
|
301
363
|
};
|
|
302
364
|
}
|
|
303
365
|
function HydrationScript(props) {
|
|
304
|
-
const {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
366
|
+
const { nonce } = sharedConfig.context;
|
|
367
|
+
return ssr(
|
|
368
|
+
generateHydrationScript({
|
|
369
|
+
nonce,
|
|
370
|
+
...props
|
|
371
|
+
})
|
|
372
|
+
);
|
|
311
373
|
}
|
|
312
374
|
function ssr(t, ...nodes) {
|
|
313
375
|
if (nodes.length) {
|
|
@@ -352,7 +414,8 @@ function ssrStyle(value) {
|
|
|
352
414
|
return result;
|
|
353
415
|
}
|
|
354
416
|
function ssrElement(tag, props, children, needsId) {
|
|
355
|
-
if (props == null) props = {};
|
|
417
|
+
if (props == null) props = {};
|
|
418
|
+
else if (typeof props === "function") props = props();
|
|
356
419
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
357
420
|
const keys = Object.keys(props);
|
|
358
421
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -360,7 +423,8 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
360
423
|
for (let i = 0; i < keys.length; i++) {
|
|
361
424
|
const prop = keys[i];
|
|
362
425
|
if (ChildProperties.has(prop)) {
|
|
363
|
-
if (children === undefined && !skipChildren)
|
|
426
|
+
if (children === undefined && !skipChildren)
|
|
427
|
+
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
364
428
|
continue;
|
|
365
429
|
}
|
|
366
430
|
const value = props[prop];
|
|
@@ -369,10 +433,14 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
369
433
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
370
434
|
if (classResolved) continue;
|
|
371
435
|
let n;
|
|
372
|
-
result += `class="${
|
|
436
|
+
result += `class="${
|
|
437
|
+
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
438
|
+
ssrClassList(props.classList)
|
|
439
|
+
}"`;
|
|
373
440
|
classResolved = true;
|
|
374
441
|
} else if (BooleanAttributes.has(prop)) {
|
|
375
|
-
if (value) result += prop;
|
|
442
|
+
if (value) result += prop;
|
|
443
|
+
else continue;
|
|
376
444
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
377
445
|
continue;
|
|
378
446
|
} else {
|
|
@@ -380,16 +448,17 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
380
448
|
}
|
|
381
449
|
if (i !== keys.length - 1) result += " ";
|
|
382
450
|
}
|
|
383
|
-
if (skipChildren)
|
|
384
|
-
|
|
385
|
-
|
|
451
|
+
if (skipChildren)
|
|
452
|
+
return {
|
|
453
|
+
t: result + "/>"
|
|
454
|
+
};
|
|
386
455
|
if (typeof children === "function") children = children();
|
|
387
456
|
return {
|
|
388
457
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
389
458
|
};
|
|
390
459
|
}
|
|
391
460
|
function ssrAttribute(key, value, isBoolean) {
|
|
392
|
-
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
461
|
+
return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
|
|
393
462
|
}
|
|
394
463
|
function ssrHydrationKey() {
|
|
395
464
|
const hk = getHydrationKey();
|
|
@@ -433,12 +502,13 @@ function escape(s, attr) {
|
|
|
433
502
|
left = iDelim + 1;
|
|
434
503
|
iDelim = s.indexOf(delim, left);
|
|
435
504
|
} while (iDelim >= 0);
|
|
436
|
-
} else
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
505
|
+
} else
|
|
506
|
+
while (iAmp >= 0) {
|
|
507
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
508
|
+
out += "&";
|
|
509
|
+
left = iAmp + 1;
|
|
510
|
+
iAmp = s.indexOf("&", left);
|
|
511
|
+
}
|
|
442
512
|
return left < s.length ? out + s.substring(left) : out;
|
|
443
513
|
}
|
|
444
514
|
function resolveSSRNode(node, top) {
|
|
@@ -450,7 +520,7 @@ function resolveSSRNode(node, top) {
|
|
|
450
520
|
let mapped = "";
|
|
451
521
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
452
522
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
453
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
523
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
454
524
|
}
|
|
455
525
|
return mapped;
|
|
456
526
|
}
|
|
@@ -471,11 +541,12 @@ function getAssets() {
|
|
|
471
541
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
472
542
|
return out;
|
|
473
543
|
}
|
|
474
|
-
function generateHydrationScript({
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
} =
|
|
478
|
-
|
|
544
|
+
function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
|
|
545
|
+
return `<script${
|
|
546
|
+
nonce ? ` nonce="${nonce}"` : ""
|
|
547
|
+
}>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(
|
|
548
|
+
'", "'
|
|
549
|
+
)}"].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-->`;
|
|
479
550
|
}
|
|
480
551
|
function Hydration(props) {
|
|
481
552
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -534,16 +605,20 @@ function replacePlaceholder(html, key, value) {
|
|
|
534
605
|
}
|
|
535
606
|
const RequestContext = Symbol();
|
|
536
607
|
function getRequestEvent() {
|
|
537
|
-
return globalThis[RequestContext]
|
|
608
|
+
return globalThis[RequestContext]
|
|
609
|
+
? globalThis[RequestContext].getStore() ||
|
|
610
|
+
(sharedConfig.context && sharedConfig.context.event) ||
|
|
611
|
+
console.log(
|
|
612
|
+
"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."
|
|
613
|
+
)
|
|
614
|
+
: undefined;
|
|
538
615
|
}
|
|
539
616
|
function Assets(props) {
|
|
540
617
|
useAssets(() => props.children);
|
|
541
618
|
}
|
|
542
619
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
543
620
|
if (options.onReady) {
|
|
544
|
-
options.onCompleteShell = ({
|
|
545
|
-
write
|
|
546
|
-
}) => {
|
|
621
|
+
options.onCompleteShell = ({ write }) => {
|
|
547
622
|
options.onReady({
|
|
548
623
|
write,
|
|
549
624
|
startWriting() {
|
|
@@ -557,9 +632,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
557
632
|
}
|
|
558
633
|
function pipeToWritable(code, writable, options = {}) {
|
|
559
634
|
if (options.onReady) {
|
|
560
|
-
options.onCompleteShell = ({
|
|
561
|
-
write
|
|
562
|
-
}) => {
|
|
635
|
+
options.onCompleteShell = ({ write }) => {
|
|
563
636
|
options.onReady({
|
|
564
637
|
write,
|
|
565
638
|
startWriting() {
|
|
@@ -589,11 +662,19 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
589
662
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
590
663
|
if (classResolved) continue;
|
|
591
664
|
let n;
|
|
592
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
665
|
+
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
666
|
+
(n = props.className) ? n + " " : ""
|
|
667
|
+
}${ssrClassList(props.classList)}"`;
|
|
593
668
|
classResolved = true;
|
|
594
669
|
} else if (BooleanAttributes.has(prop)) {
|
|
595
|
-
if (value) result += prop;
|
|
596
|
-
|
|
670
|
+
if (value) result += prop;
|
|
671
|
+
else continue;
|
|
672
|
+
} else if (
|
|
673
|
+
value == undefined ||
|
|
674
|
+
prop === "ref" ||
|
|
675
|
+
prop.slice(0, 2) === "on" ||
|
|
676
|
+
prop.slice(0, 5) === "prop:"
|
|
677
|
+
) {
|
|
597
678
|
continue;
|
|
598
679
|
} else {
|
|
599
680
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -617,7 +698,8 @@ function Dynamic(props) {
|
|
|
617
698
|
const comp = p.component,
|
|
618
699
|
t = typeof comp;
|
|
619
700
|
if (comp) {
|
|
620
|
-
if (t === "function") return comp(others);
|
|
701
|
+
if (t === "function") return comp(others);
|
|
702
|
+
else if (t === "string") {
|
|
621
703
|
return ssrElement(comp, others, undefined, true);
|
|
622
704
|
}
|
|
623
705
|
}
|
|
@@ -626,4 +708,39 @@ function Portal(props) {
|
|
|
626
708
|
return "";
|
|
627
709
|
}
|
|
628
710
|
|
|
629
|
-
export {
|
|
711
|
+
export {
|
|
712
|
+
Assets,
|
|
713
|
+
Dynamic,
|
|
714
|
+
Hydration,
|
|
715
|
+
HydrationScript,
|
|
716
|
+
NoHydration,
|
|
717
|
+
Portal,
|
|
718
|
+
RequestContext,
|
|
719
|
+
addEventListener,
|
|
720
|
+
delegateEvents,
|
|
721
|
+
escape,
|
|
722
|
+
generateHydrationScript,
|
|
723
|
+
getAssets,
|
|
724
|
+
getHydrationKey,
|
|
725
|
+
getRequestEvent,
|
|
726
|
+
hydrate,
|
|
727
|
+
insert,
|
|
728
|
+
isDev,
|
|
729
|
+
isServer,
|
|
730
|
+
pipeToNodeWritable,
|
|
731
|
+
pipeToWritable,
|
|
732
|
+
render,
|
|
733
|
+
renderToStream,
|
|
734
|
+
renderToString,
|
|
735
|
+
renderToStringAsync,
|
|
736
|
+
resolveSSRNode,
|
|
737
|
+
spread,
|
|
738
|
+
ssr,
|
|
739
|
+
ssrAttribute,
|
|
740
|
+
ssrClassList,
|
|
741
|
+
ssrElement,
|
|
742
|
+
ssrHydrationKey,
|
|
743
|
+
ssrSpread,
|
|
744
|
+
ssrStyle,
|
|
745
|
+
useAssets
|
|
746
|
+
};
|
package/web/dist/storage.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from
|
|
2
|
-
import { isServer, RequestContext } from
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { isServer, RequestContext } from "solid-js/web";
|
|
3
3
|
|
|
4
4
|
function provideRequestEvent(init, cb) {
|
|
5
5
|
if (!isServer) throw new Error("Attempting to use server context in non-server build");
|
|
6
|
-
const ctx = globalThis[RequestContext] = globalThis[RequestContext] || new AsyncLocalStorage();
|
|
6
|
+
const ctx = (globalThis[RequestContext] = globalThis[RequestContext] || new AsyncLocalStorage());
|
|
7
7
|
return ctx.run(init, cb);
|
|
8
8
|
}
|
|
9
9
|
|
package/web/dist/web.cjs
CHANGED
|
@@ -333,7 +333,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
333
333
|
let isCE, isProp, isChildProp, propAlias, forceProp;
|
|
334
334
|
if (prop === "style") return style(node, value, prev);
|
|
335
335
|
if (prop === "classList") return classList(node, value, prev);
|
|
336
|
-
if (value === prev) return prev;
|
|
336
|
+
if (value === prev && prop !== "value" && prop !== "checked") return prev;
|
|
337
337
|
if (prop === "ref") {
|
|
338
338
|
if (!skipRef) value(node);
|
|
339
339
|
} else if (prop.slice(0, 3) === "on:") {
|