solid-js 1.8.5 → 1.8.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/dist/dev.cjs +13 -10
- package/dist/dev.js +545 -307
- package/dist/server.js +170 -75
- package/dist/solid.cjs +8 -7
- package/dist/solid.js +467 -262
- 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 +12 -5
- 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 +7 -2
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -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 -9
- package/types/jsx.d.ts +11 -5
- 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 +229 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- 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 -95
- 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 +620 -81
- package/web/dist/server.cjs +28 -13
- package/web/dist/server.js +201 -104
- package/web/dist/storage.js +3 -3
- package/web/dist/web.cjs +1 -1
- package/web/dist/web.js +614 -80
- 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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
var seroval = require('seroval');
|
|
5
5
|
|
|
6
|
-
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
|
|
6
|
+
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
|
|
7
7
|
const BooleanAttributes = /*#__PURE__*/new Set(booleans);
|
|
8
8
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
9
9
|
const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
@@ -30,11 +30,8 @@ function createSerializer({
|
|
|
30
30
|
onError
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function getGlobalHeaderScript() {
|
|
34
|
-
return seroval.GLOBAL_CONTEXT_API_SCRIPT;
|
|
35
|
-
}
|
|
36
33
|
function getLocalHeaderScript(id) {
|
|
37
|
-
return seroval.getCrossReferenceHeader(id);
|
|
34
|
+
return seroval.getCrossReferenceHeader(id) + ';';
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
@@ -63,6 +60,10 @@ function renderToString(code, options = {}) {
|
|
|
63
60
|
nonce: options.nonce,
|
|
64
61
|
serialize(id, p) {
|
|
65
62
|
!solidJs.sharedConfig.context.noHydrate && serializer.write(id, p);
|
|
63
|
+
},
|
|
64
|
+
roots: 0,
|
|
65
|
+
nextRoot() {
|
|
66
|
+
return this.renderId + "i-" + this.roots++;
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
69
|
let html = solidJs.createRoot(d => {
|
|
@@ -185,13 +186,17 @@ function renderToStream(code, options = {}) {
|
|
|
185
186
|
});
|
|
186
187
|
} else if (!serverOnly) serializer.write(id, p);
|
|
187
188
|
},
|
|
189
|
+
roots: 0,
|
|
190
|
+
nextRoot() {
|
|
191
|
+
return this.renderId + "i-" + this.roots++;
|
|
192
|
+
},
|
|
188
193
|
registerFragment(key) {
|
|
189
194
|
if (!registry.has(key)) {
|
|
190
195
|
let resolve, reject;
|
|
191
196
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
192
197
|
registry.set(key, {
|
|
193
|
-
resolve,
|
|
194
|
-
reject
|
|
198
|
+
resolve: v => queue(() => queue(() => resolve(v))),
|
|
199
|
+
reject: e => queue(() => queue(() => reject(e)))
|
|
195
200
|
});
|
|
196
201
|
serializer.write(key, p);
|
|
197
202
|
}
|
|
@@ -208,7 +213,7 @@ function renderToStream(code, options = {}) {
|
|
|
208
213
|
}
|
|
209
214
|
if ((value !== undefined || error) && !completed) {
|
|
210
215
|
if (!firstFlushed) {
|
|
211
|
-
|
|
216
|
+
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
212
217
|
error ? reject(error) : resolve(true);
|
|
213
218
|
} else {
|
|
214
219
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -218,7 +223,7 @@ function renderToStream(code, options = {}) {
|
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
}
|
|
221
|
-
if (!registry.size)
|
|
226
|
+
if (!registry.size) queue(flushEnd);
|
|
222
227
|
return firstFlushed;
|
|
223
228
|
};
|
|
224
229
|
}
|
|
@@ -253,10 +258,10 @@ function renderToStream(code, options = {}) {
|
|
|
253
258
|
complete();
|
|
254
259
|
};
|
|
255
260
|
} else onCompleteAll = complete;
|
|
256
|
-
if (!registry.size)
|
|
261
|
+
if (!registry.size) queue(flushEnd);
|
|
257
262
|
},
|
|
258
263
|
pipe(w) {
|
|
259
|
-
|
|
264
|
+
allSettled(blockingPromises).then(() => {
|
|
260
265
|
doShell();
|
|
261
266
|
buffer = writable = w;
|
|
262
267
|
buffer.write(tmp);
|
|
@@ -265,7 +270,7 @@ function renderToStream(code, options = {}) {
|
|
|
265
270
|
});
|
|
266
271
|
},
|
|
267
272
|
pipeTo(w) {
|
|
268
|
-
return
|
|
273
|
+
return allSettled(blockingPromises).then(() => {
|
|
269
274
|
doShell();
|
|
270
275
|
const encoder = new TextEncoder();
|
|
271
276
|
const writer = w.getWriter();
|
|
@@ -466,7 +471,7 @@ function generateHydrationScript({
|
|
|
466
471
|
eventNames = ["click", "input"],
|
|
467
472
|
nonce
|
|
468
473
|
} = {}) {
|
|
469
|
-
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 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(){}})
|
|
474
|
+
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 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-->`;
|
|
470
475
|
}
|
|
471
476
|
function Hydration(props) {
|
|
472
477
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
@@ -485,6 +490,16 @@ function NoHydration(props) {
|
|
|
485
490
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
486
491
|
return props.children;
|
|
487
492
|
}
|
|
493
|
+
function queue(fn) {
|
|
494
|
+
return Promise.resolve().then(fn);
|
|
495
|
+
}
|
|
496
|
+
function allSettled(promises) {
|
|
497
|
+
let length = promises.length;
|
|
498
|
+
return Promise.allSettled(promises).then(() => {
|
|
499
|
+
if (promises.length !== length) return allSettled(promises);
|
|
500
|
+
return;
|
|
501
|
+
});
|
|
502
|
+
}
|
|
488
503
|
function injectAssets(assets, html) {
|
|
489
504
|
if (!assets || !assets.length) return html;
|
|
490
505
|
let out = "";
|
package/web/dist/server.js
CHANGED
|
@@ -1,25 +1,60 @@
|
|
|
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";
|
|
4
15
|
|
|
5
|
-
const booleans = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
const booleans = [
|
|
17
|
+
"allowfullscreen",
|
|
18
|
+
"async",
|
|
19
|
+
"autofocus",
|
|
20
|
+
"autoplay",
|
|
21
|
+
"checked",
|
|
22
|
+
"controls",
|
|
23
|
+
"default",
|
|
24
|
+
"disabled",
|
|
25
|
+
"formnovalidate",
|
|
26
|
+
"hidden",
|
|
27
|
+
"indeterminate",
|
|
28
|
+
"inert",
|
|
29
|
+
"ismap",
|
|
30
|
+
"loop",
|
|
31
|
+
"multiple",
|
|
32
|
+
"muted",
|
|
33
|
+
"nomodule",
|
|
34
|
+
"novalidate",
|
|
35
|
+
"open",
|
|
36
|
+
"playsinline",
|
|
37
|
+
"readonly",
|
|
38
|
+
"required",
|
|
39
|
+
"reversed",
|
|
40
|
+
"seamless",
|
|
41
|
+
"selected"
|
|
42
|
+
];
|
|
43
|
+
const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
|
|
44
|
+
const ChildProperties = /*#__PURE__*/ new Set([
|
|
45
|
+
"innerHTML",
|
|
46
|
+
"textContent",
|
|
47
|
+
"innerText",
|
|
48
|
+
"children"
|
|
49
|
+
]);
|
|
50
|
+
const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
|
|
9
51
|
className: "class",
|
|
10
52
|
htmlFor: "for"
|
|
11
53
|
});
|
|
12
54
|
|
|
13
|
-
const ES2017FLAG = Feature.AggregateError
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
17
|
-
function createSerializer({
|
|
18
|
-
onData,
|
|
19
|
-
onDone,
|
|
20
|
-
scopeId,
|
|
21
|
-
onError
|
|
22
|
-
}) {
|
|
55
|
+
const ES2017FLAG = Feature.AggregateError | Feature.BigInt | Feature.BigIntTypedArray;
|
|
56
|
+
const GLOBAL_IDENTIFIER = "_$HY.r";
|
|
57
|
+
function createSerializer({ onData, onDone, scopeId, onError }) {
|
|
23
58
|
return new Serializer({
|
|
24
59
|
scopeId,
|
|
25
60
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
@@ -29,19 +64,15 @@ function createSerializer({
|
|
|
29
64
|
onError
|
|
30
65
|
});
|
|
31
66
|
}
|
|
32
|
-
function getGlobalHeaderScript() {
|
|
33
|
-
return GLOBAL_CONTEXT_API_SCRIPT;
|
|
34
|
-
}
|
|
35
67
|
function getLocalHeaderScript(id) {
|
|
36
|
-
return getCrossReferenceHeader(id);
|
|
68
|
+
return getCrossReferenceHeader(id) + ";";
|
|
37
69
|
}
|
|
38
70
|
|
|
39
|
-
const VOID_ELEMENTS =
|
|
71
|
+
const VOID_ELEMENTS =
|
|
72
|
+
/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
40
73
|
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
74
|
function renderToString(code, options = {}) {
|
|
42
|
-
const {
|
|
43
|
-
renderId
|
|
44
|
-
} = options;
|
|
75
|
+
const { renderId } = options;
|
|
45
76
|
let scripts = "";
|
|
46
77
|
const serializer = createSerializer({
|
|
47
78
|
scopeId: renderId,
|
|
@@ -62,6 +93,10 @@ function renderToString(code, options = {}) {
|
|
|
62
93
|
nonce: options.nonce,
|
|
63
94
|
serialize(id, p) {
|
|
64
95
|
!sharedConfig.context.noHydrate && serializer.write(id, p);
|
|
96
|
+
},
|
|
97
|
+
roots: 0,
|
|
98
|
+
nextRoot() {
|
|
99
|
+
return this.renderId + "i-" + this.roots++;
|
|
65
100
|
}
|
|
66
101
|
};
|
|
67
102
|
let html = createRoot(d => {
|
|
@@ -75,9 +110,7 @@ function renderToString(code, options = {}) {
|
|
|
75
110
|
return html;
|
|
76
111
|
}
|
|
77
112
|
function renderToStringAsync(code, options = {}) {
|
|
78
|
-
const {
|
|
79
|
-
timeoutMs = 30000
|
|
80
|
-
} = options;
|
|
113
|
+
const { timeoutMs = 30000 } = options;
|
|
81
114
|
let timeoutHandle;
|
|
82
115
|
const timeout = new Promise((_, reject) => {
|
|
83
116
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -88,13 +121,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
88
121
|
});
|
|
89
122
|
}
|
|
90
123
|
function renderToStream(code, options = {}) {
|
|
91
|
-
let {
|
|
92
|
-
nonce,
|
|
93
|
-
onCompleteShell,
|
|
94
|
-
onCompleteAll,
|
|
95
|
-
renderId,
|
|
96
|
-
noScripts
|
|
97
|
-
} = options;
|
|
124
|
+
let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
|
|
98
125
|
let dispose;
|
|
99
126
|
const blockingPromises = [];
|
|
100
127
|
const pushTask = task => {
|
|
@@ -110,11 +137,12 @@ function renderToStream(code, options = {}) {
|
|
|
110
137
|
const checkEnd = () => {
|
|
111
138
|
if (!registry.size && !completed) {
|
|
112
139
|
writeTasks();
|
|
113
|
-
onCompleteAll &&
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
140
|
+
onCompleteAll &&
|
|
141
|
+
onCompleteAll({
|
|
142
|
+
write(v) {
|
|
143
|
+
!completed && buffer.write(v);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
118
146
|
writable && writable.end();
|
|
119
147
|
completed = true;
|
|
120
148
|
setTimeout(dispose);
|
|
@@ -171,35 +199,42 @@ function renderToStream(code, options = {}) {
|
|
|
171
199
|
const first = html.indexOf(placeholder);
|
|
172
200
|
if (first === -1) return;
|
|
173
201
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
174
|
-
html = html.replace(
|
|
202
|
+
html = html.replace(
|
|
203
|
+
html.slice(first, last + placeholder.length + 1),
|
|
204
|
+
resolveSSRNode(payloadFn())
|
|
205
|
+
);
|
|
175
206
|
},
|
|
176
207
|
serialize(id, p, wait) {
|
|
177
208
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
178
209
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
179
210
|
blockingPromises.push(p);
|
|
180
|
-
!serverOnly &&
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
211
|
+
!serverOnly &&
|
|
212
|
+
p
|
|
213
|
+
.then(d => {
|
|
214
|
+
serializer.write(id, d);
|
|
215
|
+
})
|
|
216
|
+
.catch(e => {
|
|
217
|
+
serializer.write(id, e);
|
|
218
|
+
});
|
|
185
219
|
} else if (!serverOnly) serializer.write(id, p);
|
|
186
220
|
},
|
|
221
|
+
roots: 0,
|
|
222
|
+
nextRoot() {
|
|
223
|
+
return this.renderId + "i-" + this.roots++;
|
|
224
|
+
},
|
|
187
225
|
registerFragment(key) {
|
|
188
226
|
if (!registry.has(key)) {
|
|
189
227
|
let resolve, reject;
|
|
190
|
-
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
228
|
+
const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
|
|
191
229
|
registry.set(key, {
|
|
192
|
-
resolve,
|
|
193
|
-
reject
|
|
230
|
+
resolve: v => queue(() => queue(() => resolve(v))),
|
|
231
|
+
reject: e => queue(() => queue(() => reject(e)))
|
|
194
232
|
});
|
|
195
233
|
serializer.write(key, p);
|
|
196
234
|
}
|
|
197
235
|
return (value, error) => {
|
|
198
236
|
if (registry.has(key)) {
|
|
199
|
-
const {
|
|
200
|
-
resolve,
|
|
201
|
-
reject
|
|
202
|
-
} = registry.get(key);
|
|
237
|
+
const { resolve, reject } = registry.get(key);
|
|
203
238
|
registry.delete(key);
|
|
204
239
|
if (waitForFragments(registry, key)) {
|
|
205
240
|
resolve(true);
|
|
@@ -207,7 +242,7 @@ function renderToStream(code, options = {}) {
|
|
|
207
242
|
}
|
|
208
243
|
if ((value !== undefined || error) && !completed) {
|
|
209
244
|
if (!firstFlushed) {
|
|
210
|
-
|
|
245
|
+
queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
|
|
211
246
|
error ? reject(error) : resolve(true);
|
|
212
247
|
} else {
|
|
213
248
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -217,7 +252,7 @@ function renderToStream(code, options = {}) {
|
|
|
217
252
|
}
|
|
218
253
|
}
|
|
219
254
|
}
|
|
220
|
-
if (!registry.size)
|
|
255
|
+
if (!registry.size) queue(flushEnd);
|
|
221
256
|
return firstFlushed;
|
|
222
257
|
};
|
|
223
258
|
}
|
|
@@ -233,11 +268,12 @@ function renderToStream(code, options = {}) {
|
|
|
233
268
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
234
269
|
buffer.write(html);
|
|
235
270
|
tasks = "";
|
|
236
|
-
onCompleteShell &&
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
271
|
+
onCompleteShell &&
|
|
272
|
+
onCompleteShell({
|
|
273
|
+
write(v) {
|
|
274
|
+
!completed && buffer.write(v);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
241
277
|
}
|
|
242
278
|
return {
|
|
243
279
|
then(fn) {
|
|
@@ -252,24 +288,25 @@ function renderToStream(code, options = {}) {
|
|
|
252
288
|
complete();
|
|
253
289
|
};
|
|
254
290
|
} else onCompleteAll = complete;
|
|
255
|
-
if (!registry.size)
|
|
291
|
+
if (!registry.size) queue(flushEnd);
|
|
256
292
|
},
|
|
257
293
|
pipe(w) {
|
|
258
|
-
|
|
294
|
+
allSettled(blockingPromises).then(() => {
|
|
259
295
|
doShell();
|
|
260
296
|
buffer = writable = w;
|
|
261
297
|
buffer.write(tmp);
|
|
262
298
|
firstFlushed = true;
|
|
263
|
-
if (completed) writable.end();
|
|
299
|
+
if (completed) writable.end();
|
|
300
|
+
else setTimeout(flushEnd);
|
|
264
301
|
});
|
|
265
302
|
},
|
|
266
303
|
pipeTo(w) {
|
|
267
|
-
return
|
|
304
|
+
return allSettled(blockingPromises).then(() => {
|
|
268
305
|
doShell();
|
|
269
306
|
const encoder = new TextEncoder();
|
|
270
307
|
const writer = w.getWriter();
|
|
271
308
|
let resolve;
|
|
272
|
-
const p = new Promise(r => resolve = r);
|
|
309
|
+
const p = new Promise(r => (resolve = r));
|
|
273
310
|
writable = {
|
|
274
311
|
end() {
|
|
275
312
|
writer.releaseLock();
|
|
@@ -284,20 +321,21 @@ function renderToStream(code, options = {}) {
|
|
|
284
321
|
};
|
|
285
322
|
buffer.write(tmp);
|
|
286
323
|
firstFlushed = true;
|
|
287
|
-
if (completed) writable.end();
|
|
324
|
+
if (completed) writable.end();
|
|
325
|
+
else setTimeout(flushEnd);
|
|
288
326
|
return p;
|
|
289
327
|
});
|
|
290
328
|
}
|
|
291
329
|
};
|
|
292
330
|
}
|
|
293
331
|
function HydrationScript(props) {
|
|
294
|
-
const {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
332
|
+
const { nonce } = sharedConfig.context;
|
|
333
|
+
return ssr(
|
|
334
|
+
generateHydrationScript({
|
|
335
|
+
nonce,
|
|
336
|
+
...props
|
|
337
|
+
})
|
|
338
|
+
);
|
|
301
339
|
}
|
|
302
340
|
function ssr(t, ...nodes) {
|
|
303
341
|
if (nodes.length) {
|
|
@@ -342,7 +380,8 @@ function ssrStyle(value) {
|
|
|
342
380
|
return result;
|
|
343
381
|
}
|
|
344
382
|
function ssrElement(tag, props, children, needsId) {
|
|
345
|
-
if (props == null) props = {};
|
|
383
|
+
if (props == null) props = {};
|
|
384
|
+
else if (typeof props === "function") props = props();
|
|
346
385
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
347
386
|
const keys = Object.keys(props);
|
|
348
387
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -350,7 +389,8 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
350
389
|
for (let i = 0; i < keys.length; i++) {
|
|
351
390
|
const prop = keys[i];
|
|
352
391
|
if (ChildProperties.has(prop)) {
|
|
353
|
-
if (children === undefined && !skipChildren)
|
|
392
|
+
if (children === undefined && !skipChildren)
|
|
393
|
+
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
354
394
|
continue;
|
|
355
395
|
}
|
|
356
396
|
const value = props[prop];
|
|
@@ -359,10 +399,14 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
359
399
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
360
400
|
if (classResolved) continue;
|
|
361
401
|
let n;
|
|
362
|
-
result += `class="${
|
|
402
|
+
result += `class="${
|
|
403
|
+
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
404
|
+
ssrClassList(props.classList)
|
|
405
|
+
}"`;
|
|
363
406
|
classResolved = true;
|
|
364
407
|
} else if (BooleanAttributes.has(prop)) {
|
|
365
|
-
if (value) result += prop;
|
|
408
|
+
if (value) result += prop;
|
|
409
|
+
else continue;
|
|
366
410
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
367
411
|
continue;
|
|
368
412
|
} else {
|
|
@@ -370,16 +414,17 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
370
414
|
}
|
|
371
415
|
if (i !== keys.length - 1) result += " ";
|
|
372
416
|
}
|
|
373
|
-
if (skipChildren)
|
|
374
|
-
|
|
375
|
-
|
|
417
|
+
if (skipChildren)
|
|
418
|
+
return {
|
|
419
|
+
t: result + "/>"
|
|
420
|
+
};
|
|
376
421
|
if (typeof children === "function") children = children();
|
|
377
422
|
return {
|
|
378
423
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
379
424
|
};
|
|
380
425
|
}
|
|
381
426
|
function ssrAttribute(key, value, isBoolean) {
|
|
382
|
-
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
427
|
+
return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
|
|
383
428
|
}
|
|
384
429
|
function ssrHydrationKey() {
|
|
385
430
|
const hk = getHydrationKey();
|
|
@@ -423,12 +468,13 @@ function escape(s, attr) {
|
|
|
423
468
|
left = iDelim + 1;
|
|
424
469
|
iDelim = s.indexOf(delim, left);
|
|
425
470
|
} while (iDelim >= 0);
|
|
426
|
-
} else
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
471
|
+
} else
|
|
472
|
+
while (iAmp >= 0) {
|
|
473
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
474
|
+
out += "&";
|
|
475
|
+
left = iAmp + 1;
|
|
476
|
+
iAmp = s.indexOf("&", left);
|
|
477
|
+
}
|
|
432
478
|
return left < s.length ? out + s.substring(left) : out;
|
|
433
479
|
}
|
|
434
480
|
function resolveSSRNode(node, top) {
|
|
@@ -440,7 +486,7 @@ function resolveSSRNode(node, top) {
|
|
|
440
486
|
let mapped = "";
|
|
441
487
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
442
488
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
443
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
489
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
444
490
|
}
|
|
445
491
|
return mapped;
|
|
446
492
|
}
|
|
@@ -461,11 +507,12 @@ function getAssets() {
|
|
|
461
507
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
462
508
|
return out;
|
|
463
509
|
}
|
|
464
|
-
function generateHydrationScript({
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
} =
|
|
468
|
-
|
|
510
|
+
function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
|
|
511
|
+
return `<script${
|
|
512
|
+
nonce ? ` nonce="${nonce}"` : ""
|
|
513
|
+
}>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(
|
|
514
|
+
'", "'
|
|
515
|
+
)}"].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-->`;
|
|
469
516
|
}
|
|
470
517
|
function Hydration(props) {
|
|
471
518
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -484,6 +531,16 @@ function NoHydration(props) {
|
|
|
484
531
|
sharedConfig.context.noHydrate = true;
|
|
485
532
|
return props.children;
|
|
486
533
|
}
|
|
534
|
+
function queue(fn) {
|
|
535
|
+
return Promise.resolve().then(fn);
|
|
536
|
+
}
|
|
537
|
+
function allSettled(promises) {
|
|
538
|
+
let length = promises.length;
|
|
539
|
+
return Promise.allSettled(promises).then(() => {
|
|
540
|
+
if (promises.length !== length) return allSettled(promises);
|
|
541
|
+
return;
|
|
542
|
+
});
|
|
543
|
+
}
|
|
487
544
|
function injectAssets(assets, html) {
|
|
488
545
|
if (!assets || !assets.length) return html;
|
|
489
546
|
let out = "";
|
|
@@ -521,9 +578,7 @@ function Assets(props) {
|
|
|
521
578
|
}
|
|
522
579
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
523
580
|
if (options.onReady) {
|
|
524
|
-
options.onCompleteShell = ({
|
|
525
|
-
write
|
|
526
|
-
}) => {
|
|
581
|
+
options.onCompleteShell = ({ write }) => {
|
|
527
582
|
options.onReady({
|
|
528
583
|
write,
|
|
529
584
|
startWriting() {
|
|
@@ -537,9 +592,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
537
592
|
}
|
|
538
593
|
function pipeToWritable(code, writable, options = {}) {
|
|
539
594
|
if (options.onReady) {
|
|
540
|
-
options.onCompleteShell = ({
|
|
541
|
-
write
|
|
542
|
-
}) => {
|
|
595
|
+
options.onCompleteShell = ({ write }) => {
|
|
543
596
|
options.onReady({
|
|
544
597
|
write,
|
|
545
598
|
startWriting() {
|
|
@@ -569,11 +622,19 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
569
622
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
570
623
|
if (classResolved) continue;
|
|
571
624
|
let n;
|
|
572
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
625
|
+
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
626
|
+
(n = props.className) ? n + " " : ""
|
|
627
|
+
}${ssrClassList(props.classList)}"`;
|
|
573
628
|
classResolved = true;
|
|
574
629
|
} else if (BooleanAttributes.has(prop)) {
|
|
575
|
-
if (value) result += prop;
|
|
576
|
-
|
|
630
|
+
if (value) result += prop;
|
|
631
|
+
else continue;
|
|
632
|
+
} else if (
|
|
633
|
+
value == undefined ||
|
|
634
|
+
prop === "ref" ||
|
|
635
|
+
prop.slice(0, 2) === "on" ||
|
|
636
|
+
prop.slice(0, 5) === "prop:"
|
|
637
|
+
) {
|
|
577
638
|
continue;
|
|
578
639
|
} else {
|
|
579
640
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -597,7 +658,8 @@ function Dynamic(props) {
|
|
|
597
658
|
const comp = p.component,
|
|
598
659
|
t = typeof comp;
|
|
599
660
|
if (comp) {
|
|
600
|
-
if (t === "function") return comp(others);
|
|
661
|
+
if (t === "function") return comp(others);
|
|
662
|
+
else if (t === "string") {
|
|
601
663
|
return ssrElement(comp, others, undefined, true);
|
|
602
664
|
}
|
|
603
665
|
}
|
|
@@ -606,4 +668,39 @@ function Portal(props) {
|
|
|
606
668
|
return "";
|
|
607
669
|
}
|
|
608
670
|
|
|
609
|
-
export {
|
|
671
|
+
export {
|
|
672
|
+
Assets,
|
|
673
|
+
Dynamic,
|
|
674
|
+
Hydration,
|
|
675
|
+
HydrationScript,
|
|
676
|
+
NoHydration,
|
|
677
|
+
Portal,
|
|
678
|
+
RequestContext,
|
|
679
|
+
addEventListener,
|
|
680
|
+
delegateEvents,
|
|
681
|
+
escape,
|
|
682
|
+
generateHydrationScript,
|
|
683
|
+
getAssets,
|
|
684
|
+
getHydrationKey,
|
|
685
|
+
getRequestEvent,
|
|
686
|
+
hydrate,
|
|
687
|
+
insert,
|
|
688
|
+
isDev,
|
|
689
|
+
isServer,
|
|
690
|
+
pipeToNodeWritable,
|
|
691
|
+
pipeToWritable,
|
|
692
|
+
render,
|
|
693
|
+
renderToStream,
|
|
694
|
+
renderToString,
|
|
695
|
+
renderToStringAsync,
|
|
696
|
+
resolveSSRNode,
|
|
697
|
+
spread,
|
|
698
|
+
ssr,
|
|
699
|
+
ssrAttribute,
|
|
700
|
+
ssrClassList,
|
|
701
|
+
ssrElement,
|
|
702
|
+
ssrHydrationKey,
|
|
703
|
+
ssrSpread,
|
|
704
|
+
ssrStyle,
|
|
705
|
+
useAssets
|
|
706
|
+
};
|
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
|
|
5
|
-
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
|
|
5
|
+
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
|
|
6
6
|
const Properties = /*#__PURE__*/new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
|
|
7
7
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
8
8
|
const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|