solid-js 1.8.19 → 1.8.21
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 +6 -6
- package/dist/dev.js +562 -321
- package/dist/server.js +168 -74
- package/dist/solid.cjs +6 -6
- package/dist/solid.js +489 -279
- package/h/dist/h.js +38 -9
- 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 +1 -1
- package/store/dist/dev.js +122 -43
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +113 -40
- 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 +913 -862
- 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 +15 -15
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +169 -98
- 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 +34 -18
- package/web/dist/dev.js +655 -97
- package/web/dist/server.cjs +1 -1
- package/web/dist/server.js +210 -96
- package/web/dist/web.cjs +32 -16
- package/web/dist/web.js +646 -95
- package/web/storage/dist/storage.js +3 -3
- 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.cjs
CHANGED
|
@@ -482,7 +482,7 @@ function generateHydrationScript({
|
|
|
482
482
|
eventNames = ["click", "input"],
|
|
483
483
|
nonce
|
|
484
484
|
} = {}) {
|
|
485
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>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('", "')}"].forEach((o=>document.addEventListener(o,(o=>{let
|
|
485
|
+
return `<script${nonce ? ` nonce="${nonce}"` : ""}>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('", "')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
486
486
|
}
|
|
487
487
|
function Hydration(props) {
|
|
488
488
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
package/web/dist/server.js
CHANGED
|
@@ -1,30 +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
|
-
function createSerializer({
|
|
18
|
-
onData,
|
|
19
|
-
onDone,
|
|
20
|
-
scopeId,
|
|
21
|
-
onError
|
|
22
|
-
}) {
|
|
67
|
+
const ES2017FLAG = Feature.AggregateError | Feature.BigIntTypedArray;
|
|
68
|
+
const GLOBAL_IDENTIFIER = "_$HY.r";
|
|
69
|
+
function createSerializer({ onData, onDone, scopeId, onError }) {
|
|
23
70
|
return new Serializer({
|
|
24
71
|
scopeId,
|
|
25
72
|
plugins: [
|
|
26
|
-
|
|
27
|
-
|
|
73
|
+
CustomEventPlugin,
|
|
74
|
+
DOMExceptionPlugin,
|
|
75
|
+
EventPlugin,
|
|
76
|
+
FormDataPlugin,
|
|
77
|
+
HeadersPlugin,
|
|
78
|
+
ReadableStreamPlugin,
|
|
79
|
+
RequestPlugin,
|
|
80
|
+
ResponsePlugin,
|
|
81
|
+
URLSearchParamsPlugin,
|
|
82
|
+
URLPlugin
|
|
83
|
+
],
|
|
28
84
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
29
85
|
disabledFeatures: ES2017FLAG,
|
|
30
86
|
onData,
|
|
@@ -33,15 +89,14 @@ function createSerializer({
|
|
|
33
89
|
});
|
|
34
90
|
}
|
|
35
91
|
function getLocalHeaderScript(id) {
|
|
36
|
-
return getCrossReferenceHeader(id) +
|
|
92
|
+
return getCrossReferenceHeader(id) + ";";
|
|
37
93
|
}
|
|
38
94
|
|
|
39
|
-
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;
|
|
40
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)}`;
|
|
41
98
|
function renderToString(code, options = {}) {
|
|
42
|
-
const {
|
|
43
|
-
renderId
|
|
44
|
-
} = options;
|
|
99
|
+
const { renderId } = options;
|
|
45
100
|
let scripts = "";
|
|
46
101
|
const serializer = createSerializer({
|
|
47
102
|
scopeId: renderId,
|
|
@@ -79,9 +134,7 @@ function renderToString(code, options = {}) {
|
|
|
79
134
|
return html;
|
|
80
135
|
}
|
|
81
136
|
function renderToStringAsync(code, options = {}) {
|
|
82
|
-
const {
|
|
83
|
-
timeoutMs = 30000
|
|
84
|
-
} = options;
|
|
137
|
+
const { timeoutMs = 30000 } = options;
|
|
85
138
|
let timeoutHandle;
|
|
86
139
|
const timeout = new Promise((_, reject) => {
|
|
87
140
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -92,13 +145,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
92
145
|
});
|
|
93
146
|
}
|
|
94
147
|
function renderToStream(code, options = {}) {
|
|
95
|
-
let {
|
|
96
|
-
nonce,
|
|
97
|
-
onCompleteShell,
|
|
98
|
-
onCompleteAll,
|
|
99
|
-
renderId,
|
|
100
|
-
noScripts
|
|
101
|
-
} = options;
|
|
148
|
+
let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
|
|
102
149
|
let dispose;
|
|
103
150
|
const blockingPromises = [];
|
|
104
151
|
const pushTask = task => {
|
|
@@ -114,11 +161,12 @@ function renderToStream(code, options = {}) {
|
|
|
114
161
|
const onDone = () => {
|
|
115
162
|
writeTasks();
|
|
116
163
|
doShell();
|
|
117
|
-
onCompleteAll &&
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
164
|
+
onCompleteAll &&
|
|
165
|
+
onCompleteAll({
|
|
166
|
+
write(v) {
|
|
167
|
+
!completed && buffer.write(v);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
122
170
|
writable && writable.end();
|
|
123
171
|
completed = true;
|
|
124
172
|
if (firstFlushed) dispose();
|
|
@@ -175,17 +223,23 @@ function renderToStream(code, options = {}) {
|
|
|
175
223
|
const first = html.indexOf(placeholder);
|
|
176
224
|
if (first === -1) return;
|
|
177
225
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
178
|
-
html = html.replace(
|
|
226
|
+
html = html.replace(
|
|
227
|
+
html.slice(first, last + placeholder.length + 1),
|
|
228
|
+
resolveSSRNode(payloadFn())
|
|
229
|
+
);
|
|
179
230
|
},
|
|
180
231
|
serialize(id, p, wait) {
|
|
181
232
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
182
233
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
183
234
|
blockingPromises.push(p);
|
|
184
|
-
!serverOnly &&
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
235
|
+
!serverOnly &&
|
|
236
|
+
p
|
|
237
|
+
.then(d => {
|
|
238
|
+
serializer.write(id, d);
|
|
239
|
+
})
|
|
240
|
+
.catch(e => {
|
|
241
|
+
serializer.write(id, e);
|
|
242
|
+
});
|
|
189
243
|
} else if (!serverOnly) serializer.write(id, p);
|
|
190
244
|
},
|
|
191
245
|
roots: 0,
|
|
@@ -195,11 +249,15 @@ function renderToStream(code, options = {}) {
|
|
|
195
249
|
registerFragment(key) {
|
|
196
250
|
if (!registry.has(key)) {
|
|
197
251
|
let resolve, reject;
|
|
198
|
-
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
199
|
-
registry.set(key, err =>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
+
);
|
|
203
261
|
serializer.write(key, p);
|
|
204
262
|
}
|
|
205
263
|
return (value, error) => {
|
|
@@ -212,7 +270,7 @@ function renderToStream(code, options = {}) {
|
|
|
212
270
|
}
|
|
213
271
|
if (!completed) {
|
|
214
272
|
if (!firstFlushed) {
|
|
215
|
-
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
273
|
+
queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
|
|
216
274
|
resolve(error);
|
|
217
275
|
} else {
|
|
218
276
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -238,11 +296,12 @@ function renderToStream(code, options = {}) {
|
|
|
238
296
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
239
297
|
buffer.write(html);
|
|
240
298
|
tasks = "";
|
|
241
|
-
onCompleteShell &&
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
299
|
+
onCompleteShell &&
|
|
300
|
+
onCompleteShell({
|
|
301
|
+
write(v) {
|
|
302
|
+
!completed && buffer.write(v);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
246
305
|
shellCompleted = true;
|
|
247
306
|
}
|
|
248
307
|
return {
|
|
@@ -277,7 +336,7 @@ function renderToStream(code, options = {}) {
|
|
|
277
336
|
pipeTo(w) {
|
|
278
337
|
return allSettled(blockingPromises).then(() => {
|
|
279
338
|
let resolve;
|
|
280
|
-
const p = new Promise(r => resolve = r);
|
|
339
|
+
const p = new Promise(r => (resolve = r));
|
|
281
340
|
setTimeout(() => {
|
|
282
341
|
doShell();
|
|
283
342
|
const encoder = new TextEncoder();
|
|
@@ -307,13 +366,13 @@ function renderToStream(code, options = {}) {
|
|
|
307
366
|
};
|
|
308
367
|
}
|
|
309
368
|
function HydrationScript(props) {
|
|
310
|
-
const {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
369
|
+
const { nonce } = sharedConfig.context;
|
|
370
|
+
return ssr(
|
|
371
|
+
generateHydrationScript({
|
|
372
|
+
nonce,
|
|
373
|
+
...props
|
|
374
|
+
})
|
|
375
|
+
);
|
|
317
376
|
}
|
|
318
377
|
function ssr(t, ...nodes) {
|
|
319
378
|
if (nodes.length) {
|
|
@@ -358,7 +417,8 @@ function ssrStyle(value) {
|
|
|
358
417
|
return result;
|
|
359
418
|
}
|
|
360
419
|
function ssrElement(tag, props, children, needsId) {
|
|
361
|
-
if (props == null) props = {};
|
|
420
|
+
if (props == null) props = {};
|
|
421
|
+
else if (typeof props === "function") props = props();
|
|
362
422
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
363
423
|
const keys = Object.keys(props);
|
|
364
424
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -366,7 +426,8 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
366
426
|
for (let i = 0; i < keys.length; i++) {
|
|
367
427
|
const prop = keys[i];
|
|
368
428
|
if (ChildProperties.has(prop)) {
|
|
369
|
-
if (children === undefined && !skipChildren)
|
|
429
|
+
if (children === undefined && !skipChildren)
|
|
430
|
+
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
370
431
|
continue;
|
|
371
432
|
}
|
|
372
433
|
const value = props[prop];
|
|
@@ -375,10 +436,14 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
375
436
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
376
437
|
if (classResolved) continue;
|
|
377
438
|
let n;
|
|
378
|
-
result += `class="${
|
|
439
|
+
result += `class="${
|
|
440
|
+
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
441
|
+
ssrClassList(props.classList)
|
|
442
|
+
}"`;
|
|
379
443
|
classResolved = true;
|
|
380
444
|
} else if (BooleanAttributes.has(prop)) {
|
|
381
|
-
if (value) result += prop;
|
|
445
|
+
if (value) result += prop;
|
|
446
|
+
else continue;
|
|
382
447
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
383
448
|
continue;
|
|
384
449
|
} else {
|
|
@@ -386,16 +451,17 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
386
451
|
}
|
|
387
452
|
if (i !== keys.length - 1) result += " ";
|
|
388
453
|
}
|
|
389
|
-
if (skipChildren)
|
|
390
|
-
|
|
391
|
-
|
|
454
|
+
if (skipChildren)
|
|
455
|
+
return {
|
|
456
|
+
t: result + "/>"
|
|
457
|
+
};
|
|
392
458
|
if (typeof children === "function") children = children();
|
|
393
459
|
return {
|
|
394
460
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
395
461
|
};
|
|
396
462
|
}
|
|
397
463
|
function ssrAttribute(key, value, isBoolean) {
|
|
398
|
-
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
464
|
+
return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
|
|
399
465
|
}
|
|
400
466
|
function ssrHydrationKey() {
|
|
401
467
|
const hk = getHydrationKey();
|
|
@@ -439,12 +505,13 @@ function escape(s, attr) {
|
|
|
439
505
|
left = iDelim + 1;
|
|
440
506
|
iDelim = s.indexOf(delim, left);
|
|
441
507
|
} while (iDelim >= 0);
|
|
442
|
-
} else
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
+
}
|
|
448
515
|
return left < s.length ? out + s.substring(left) : out;
|
|
449
516
|
}
|
|
450
517
|
function resolveSSRNode(node, top) {
|
|
@@ -456,7 +523,7 @@ function resolveSSRNode(node, top) {
|
|
|
456
523
|
let mapped = "";
|
|
457
524
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
458
525
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
459
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
526
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
460
527
|
}
|
|
461
528
|
return mapped;
|
|
462
529
|
}
|
|
@@ -477,11 +544,12 @@ function getAssets() {
|
|
|
477
544
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
478
545
|
return out;
|
|
479
546
|
}
|
|
480
|
-
function generateHydrationScript({
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
} =
|
|
484
|
-
|
|
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=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
485
553
|
}
|
|
486
554
|
function Hydration(props) {
|
|
487
555
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -540,16 +608,20 @@ function replacePlaceholder(html, key, value) {
|
|
|
540
608
|
}
|
|
541
609
|
const RequestContext = Symbol();
|
|
542
610
|
function getRequestEvent() {
|
|
543
|
-
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;
|
|
544
618
|
}
|
|
545
619
|
function Assets(props) {
|
|
546
620
|
useAssets(() => props.children);
|
|
547
621
|
}
|
|
548
622
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
549
623
|
if (options.onReady) {
|
|
550
|
-
options.onCompleteShell = ({
|
|
551
|
-
write
|
|
552
|
-
}) => {
|
|
624
|
+
options.onCompleteShell = ({ write }) => {
|
|
553
625
|
options.onReady({
|
|
554
626
|
write,
|
|
555
627
|
startWriting() {
|
|
@@ -563,9 +635,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
563
635
|
}
|
|
564
636
|
function pipeToWritable(code, writable, options = {}) {
|
|
565
637
|
if (options.onReady) {
|
|
566
|
-
options.onCompleteShell = ({
|
|
567
|
-
write
|
|
568
|
-
}) => {
|
|
638
|
+
options.onCompleteShell = ({ write }) => {
|
|
569
639
|
options.onReady({
|
|
570
640
|
write,
|
|
571
641
|
startWriting() {
|
|
@@ -595,11 +665,19 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
595
665
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
596
666
|
if (classResolved) continue;
|
|
597
667
|
let n;
|
|
598
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
668
|
+
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
669
|
+
(n = props.className) ? n + " " : ""
|
|
670
|
+
}${ssrClassList(props.classList)}"`;
|
|
599
671
|
classResolved = true;
|
|
600
672
|
} else if (prop !== "value" && Properties.has(prop)) {
|
|
601
|
-
if (value) result += prop;
|
|
602
|
-
|
|
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
|
+
) {
|
|
603
681
|
continue;
|
|
604
682
|
} else {
|
|
605
683
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -623,7 +701,8 @@ function Dynamic(props) {
|
|
|
623
701
|
const comp = p.component,
|
|
624
702
|
t = typeof comp;
|
|
625
703
|
if (comp) {
|
|
626
|
-
if (t === "function") return comp(others);
|
|
704
|
+
if (t === "function") return comp(others);
|
|
705
|
+
else if (t === "string") {
|
|
627
706
|
return ssrElement(comp, others, undefined, true);
|
|
628
707
|
}
|
|
629
708
|
}
|
|
@@ -632,4 +711,39 @@ function Portal(props) {
|
|
|
632
711
|
return "";
|
|
633
712
|
}
|
|
634
713
|
|
|
635
|
-
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
|
+
};
|
package/web/dist/web.cjs
CHANGED
|
@@ -147,19 +147,19 @@ function clearDelegatedEvents(document = window.document) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
function setProperty(node, name, value) {
|
|
150
|
-
if (
|
|
150
|
+
if (isHydrating(node)) return;
|
|
151
151
|
node[name] = value;
|
|
152
152
|
}
|
|
153
153
|
function setAttribute(node, name, value) {
|
|
154
|
-
if (
|
|
154
|
+
if (isHydrating(node)) return;
|
|
155
155
|
if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
|
|
156
156
|
}
|
|
157
157
|
function setAttributeNS(node, namespace, name, value) {
|
|
158
|
-
if (
|
|
158
|
+
if (isHydrating(node)) return;
|
|
159
159
|
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
160
160
|
}
|
|
161
161
|
function className(node, value) {
|
|
162
|
-
if (
|
|
162
|
+
if (isHydrating(node)) return;
|
|
163
163
|
if (value == null) node.removeAttribute("class");else node.className = value;
|
|
164
164
|
}
|
|
165
165
|
function addEventListener(node, name, handler, delegate) {
|
|
@@ -258,6 +258,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
function hydrate$1(code, element, options = {}) {
|
|
261
|
+
if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
|
|
261
262
|
solidJs.sharedConfig.completed = globalThis._$HY.completed;
|
|
262
263
|
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
263
264
|
solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
|
|
@@ -268,14 +269,18 @@ function hydrate$1(code, element, options = {}) {
|
|
|
268
269
|
id: options.renderId || "",
|
|
269
270
|
count: 0
|
|
270
271
|
};
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
try {
|
|
273
|
+
gatherHydratable(element, options.renderId);
|
|
274
|
+
return render(code, element, [...element.childNodes], options);
|
|
275
|
+
} finally {
|
|
276
|
+
solidJs.sharedConfig.context = null;
|
|
277
|
+
}
|
|
275
278
|
}
|
|
276
279
|
function getNextElement(template) {
|
|
277
|
-
let node,
|
|
278
|
-
|
|
280
|
+
let node,
|
|
281
|
+
key,
|
|
282
|
+
hydrating = isHydrating();
|
|
283
|
+
if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
279
284
|
return template();
|
|
280
285
|
}
|
|
281
286
|
if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
|
|
@@ -290,7 +295,7 @@ function getNextMarker(start) {
|
|
|
290
295
|
let end = start,
|
|
291
296
|
count = 0,
|
|
292
297
|
current = [];
|
|
293
|
-
if (
|
|
298
|
+
if (isHydrating(start)) {
|
|
294
299
|
while (end) {
|
|
295
300
|
if (end.nodeType === 8) {
|
|
296
301
|
const v = end.nodeValue;
|
|
@@ -316,13 +321,20 @@ function runHydrationEvents() {
|
|
|
316
321
|
while (events.length) {
|
|
317
322
|
const [el, e] = events[0];
|
|
318
323
|
if (!completed.has(el)) return;
|
|
319
|
-
eventHandler(e);
|
|
320
324
|
events.shift();
|
|
325
|
+
eventHandler(e);
|
|
326
|
+
}
|
|
327
|
+
if (solidJs.sharedConfig.done) {
|
|
328
|
+
solidJs.sharedConfig.events = _$HY.events = null;
|
|
329
|
+
solidJs.sharedConfig.completed = _$HY.completed = null;
|
|
321
330
|
}
|
|
322
331
|
});
|
|
323
332
|
solidJs.sharedConfig.events.queued = true;
|
|
324
333
|
}
|
|
325
334
|
}
|
|
335
|
+
function isHydrating(node) {
|
|
336
|
+
return !!solidJs.sharedConfig.context && !solidJs.sharedConfig.done && (!node || node.isConnected);
|
|
337
|
+
}
|
|
326
338
|
function toPropertyName(name) {
|
|
327
339
|
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
328
340
|
}
|
|
@@ -362,7 +374,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
362
374
|
if (forceProp) {
|
|
363
375
|
prop = prop.slice(5);
|
|
364
376
|
isProp = true;
|
|
365
|
-
} else if (
|
|
377
|
+
} else if (isHydrating(node)) return value;
|
|
366
378
|
if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[propAlias || prop] = value;
|
|
367
379
|
} else {
|
|
368
380
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
@@ -371,6 +383,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
371
383
|
return value;
|
|
372
384
|
}
|
|
373
385
|
function eventHandler(e) {
|
|
386
|
+
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
|
|
387
|
+
if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
388
|
+
}
|
|
374
389
|
const key = `$$${e.type}`;
|
|
375
390
|
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
376
391
|
if (e.target !== node) {
|
|
@@ -397,7 +412,7 @@ function eventHandler(e) {
|
|
|
397
412
|
}
|
|
398
413
|
}
|
|
399
414
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
400
|
-
const hydrating =
|
|
415
|
+
const hydrating = isHydrating(parent);
|
|
401
416
|
if (hydrating) {
|
|
402
417
|
!current && (current = [...parent.childNodes]);
|
|
403
418
|
let cleaned = [];
|
|
@@ -448,9 +463,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
448
463
|
}
|
|
449
464
|
if (hydrating) {
|
|
450
465
|
if (!array.length) return current;
|
|
451
|
-
if (marker === undefined) return [...parent.childNodes];
|
|
466
|
+
if (marker === undefined) return current = [...parent.childNodes];
|
|
452
467
|
let node = array[0];
|
|
453
|
-
|
|
468
|
+
if (node.parentNode !== parent) return current;
|
|
469
|
+
const nodes = [node];
|
|
454
470
|
while ((node = node.nextSibling) !== marker) nodes.push(node);
|
|
455
471
|
return current = nodes;
|
|
456
472
|
}
|