solid-js 1.8.5 → 1.8.6
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 +12 -9
- package/dist/dev.js +545 -307
- package/dist/server.js +170 -75
- package/dist/solid.cjs +7 -6
- 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 +166 -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 +22 -10
- package/web/dist/server.js +195 -101
- 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,9 +30,6 @@ 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
34
|
return seroval.getCrossReferenceHeader(id);
|
|
38
35
|
}
|
|
@@ -63,6 +60,12 @@ 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
|
+
pushed: 0,
|
|
65
|
+
push(p) {
|
|
66
|
+
const id = this.renderId + "i-" + this.pushed++;
|
|
67
|
+
this.serialize(id, p);
|
|
68
|
+
return id;
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
let html = solidJs.createRoot(d => {
|
|
@@ -185,13 +188,19 @@ function renderToStream(code, options = {}) {
|
|
|
185
188
|
});
|
|
186
189
|
} else if (!serverOnly) serializer.write(id, p);
|
|
187
190
|
},
|
|
191
|
+
pushed: 0,
|
|
192
|
+
push(p) {
|
|
193
|
+
const id = this.renderId + "i-" + this.pushed++;
|
|
194
|
+
this.serialize(id, p);
|
|
195
|
+
return id;
|
|
196
|
+
},
|
|
188
197
|
registerFragment(key) {
|
|
189
198
|
if (!registry.has(key)) {
|
|
190
199
|
let resolve, reject;
|
|
191
200
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
192
201
|
registry.set(key, {
|
|
193
|
-
resolve,
|
|
194
|
-
reject
|
|
202
|
+
resolve: v => queue(() => queue(() => resolve(v))),
|
|
203
|
+
reject: e => queue(() => queue(() => reject(e)))
|
|
195
204
|
});
|
|
196
205
|
serializer.write(key, p);
|
|
197
206
|
}
|
|
@@ -208,7 +217,7 @@ function renderToStream(code, options = {}) {
|
|
|
208
217
|
}
|
|
209
218
|
if ((value !== undefined || error) && !completed) {
|
|
210
219
|
if (!firstFlushed) {
|
|
211
|
-
|
|
220
|
+
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
212
221
|
error ? reject(error) : resolve(true);
|
|
213
222
|
} else {
|
|
214
223
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -218,7 +227,7 @@ function renderToStream(code, options = {}) {
|
|
|
218
227
|
}
|
|
219
228
|
}
|
|
220
229
|
}
|
|
221
|
-
if (!registry.size)
|
|
230
|
+
if (!registry.size) queue(flushEnd);
|
|
222
231
|
return firstFlushed;
|
|
223
232
|
};
|
|
224
233
|
}
|
|
@@ -253,7 +262,7 @@ function renderToStream(code, options = {}) {
|
|
|
253
262
|
complete();
|
|
254
263
|
};
|
|
255
264
|
} else onCompleteAll = complete;
|
|
256
|
-
if (!registry.size)
|
|
265
|
+
if (!registry.size) queue(flushEnd);
|
|
257
266
|
},
|
|
258
267
|
pipe(w) {
|
|
259
268
|
Promise.allSettled(blockingPromises).then(() => {
|
|
@@ -466,7 +475,7 @@ function generateHydrationScript({
|
|
|
466
475
|
eventNames = ["click", "input"],
|
|
467
476
|
nonce
|
|
468
477
|
} = {}) {
|
|
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(){}})
|
|
478
|
+
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
479
|
}
|
|
471
480
|
function Hydration(props) {
|
|
472
481
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
@@ -485,6 +494,9 @@ function NoHydration(props) {
|
|
|
485
494
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
486
495
|
return props.children;
|
|
487
496
|
}
|
|
497
|
+
function queue(fn) {
|
|
498
|
+
return Promise.resolve().then(fn);
|
|
499
|
+
}
|
|
488
500
|
function injectAssets(assets, html) {
|
|
489
501
|
if (!assets || !assets.length) return html;
|
|
490
502
|
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
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,12 @@ 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
|
+
pushed: 0,
|
|
98
|
+
push(p) {
|
|
99
|
+
const id = this.renderId + "i-" + this.pushed++;
|
|
100
|
+
this.serialize(id, p);
|
|
101
|
+
return id;
|
|
65
102
|
}
|
|
66
103
|
};
|
|
67
104
|
let html = createRoot(d => {
|
|
@@ -75,9 +112,7 @@ function renderToString(code, options = {}) {
|
|
|
75
112
|
return html;
|
|
76
113
|
}
|
|
77
114
|
function renderToStringAsync(code, options = {}) {
|
|
78
|
-
const {
|
|
79
|
-
timeoutMs = 30000
|
|
80
|
-
} = options;
|
|
115
|
+
const { timeoutMs = 30000 } = options;
|
|
81
116
|
let timeoutHandle;
|
|
82
117
|
const timeout = new Promise((_, reject) => {
|
|
83
118
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -88,13 +123,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
88
123
|
});
|
|
89
124
|
}
|
|
90
125
|
function renderToStream(code, options = {}) {
|
|
91
|
-
let {
|
|
92
|
-
nonce,
|
|
93
|
-
onCompleteShell,
|
|
94
|
-
onCompleteAll,
|
|
95
|
-
renderId,
|
|
96
|
-
noScripts
|
|
97
|
-
} = options;
|
|
126
|
+
let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
|
|
98
127
|
let dispose;
|
|
99
128
|
const blockingPromises = [];
|
|
100
129
|
const pushTask = task => {
|
|
@@ -110,11 +139,12 @@ function renderToStream(code, options = {}) {
|
|
|
110
139
|
const checkEnd = () => {
|
|
111
140
|
if (!registry.size && !completed) {
|
|
112
141
|
writeTasks();
|
|
113
|
-
onCompleteAll &&
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
142
|
+
onCompleteAll &&
|
|
143
|
+
onCompleteAll({
|
|
144
|
+
write(v) {
|
|
145
|
+
!completed && buffer.write(v);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
118
148
|
writable && writable.end();
|
|
119
149
|
completed = true;
|
|
120
150
|
setTimeout(dispose);
|
|
@@ -171,35 +201,44 @@ function renderToStream(code, options = {}) {
|
|
|
171
201
|
const first = html.indexOf(placeholder);
|
|
172
202
|
if (first === -1) return;
|
|
173
203
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
174
|
-
html = html.replace(
|
|
204
|
+
html = html.replace(
|
|
205
|
+
html.slice(first, last + placeholder.length + 1),
|
|
206
|
+
resolveSSRNode(payloadFn())
|
|
207
|
+
);
|
|
175
208
|
},
|
|
176
209
|
serialize(id, p, wait) {
|
|
177
210
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
178
211
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
179
212
|
blockingPromises.push(p);
|
|
180
|
-
!serverOnly &&
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
213
|
+
!serverOnly &&
|
|
214
|
+
p
|
|
215
|
+
.then(d => {
|
|
216
|
+
serializer.write(id, d);
|
|
217
|
+
})
|
|
218
|
+
.catch(e => {
|
|
219
|
+
serializer.write(id, e);
|
|
220
|
+
});
|
|
185
221
|
} else if (!serverOnly) serializer.write(id, p);
|
|
186
222
|
},
|
|
223
|
+
pushed: 0,
|
|
224
|
+
push(p) {
|
|
225
|
+
const id = this.renderId + "i-" + this.pushed++;
|
|
226
|
+
this.serialize(id, p);
|
|
227
|
+
return id;
|
|
228
|
+
},
|
|
187
229
|
registerFragment(key) {
|
|
188
230
|
if (!registry.has(key)) {
|
|
189
231
|
let resolve, reject;
|
|
190
|
-
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
232
|
+
const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
|
|
191
233
|
registry.set(key, {
|
|
192
|
-
resolve,
|
|
193
|
-
reject
|
|
234
|
+
resolve: v => queue(() => queue(() => resolve(v))),
|
|
235
|
+
reject: e => queue(() => queue(() => reject(e)))
|
|
194
236
|
});
|
|
195
237
|
serializer.write(key, p);
|
|
196
238
|
}
|
|
197
239
|
return (value, error) => {
|
|
198
240
|
if (registry.has(key)) {
|
|
199
|
-
const {
|
|
200
|
-
resolve,
|
|
201
|
-
reject
|
|
202
|
-
} = registry.get(key);
|
|
241
|
+
const { resolve, reject } = registry.get(key);
|
|
203
242
|
registry.delete(key);
|
|
204
243
|
if (waitForFragments(registry, key)) {
|
|
205
244
|
resolve(true);
|
|
@@ -207,7 +246,7 @@ function renderToStream(code, options = {}) {
|
|
|
207
246
|
}
|
|
208
247
|
if ((value !== undefined || error) && !completed) {
|
|
209
248
|
if (!firstFlushed) {
|
|
210
|
-
|
|
249
|
+
queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
|
|
211
250
|
error ? reject(error) : resolve(true);
|
|
212
251
|
} else {
|
|
213
252
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -217,7 +256,7 @@ function renderToStream(code, options = {}) {
|
|
|
217
256
|
}
|
|
218
257
|
}
|
|
219
258
|
}
|
|
220
|
-
if (!registry.size)
|
|
259
|
+
if (!registry.size) queue(flushEnd);
|
|
221
260
|
return firstFlushed;
|
|
222
261
|
};
|
|
223
262
|
}
|
|
@@ -233,11 +272,12 @@ function renderToStream(code, options = {}) {
|
|
|
233
272
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
234
273
|
buffer.write(html);
|
|
235
274
|
tasks = "";
|
|
236
|
-
onCompleteShell &&
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
275
|
+
onCompleteShell &&
|
|
276
|
+
onCompleteShell({
|
|
277
|
+
write(v) {
|
|
278
|
+
!completed && buffer.write(v);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
241
281
|
}
|
|
242
282
|
return {
|
|
243
283
|
then(fn) {
|
|
@@ -252,7 +292,7 @@ function renderToStream(code, options = {}) {
|
|
|
252
292
|
complete();
|
|
253
293
|
};
|
|
254
294
|
} else onCompleteAll = complete;
|
|
255
|
-
if (!registry.size)
|
|
295
|
+
if (!registry.size) queue(flushEnd);
|
|
256
296
|
},
|
|
257
297
|
pipe(w) {
|
|
258
298
|
Promise.allSettled(blockingPromises).then(() => {
|
|
@@ -260,7 +300,8 @@ function renderToStream(code, options = {}) {
|
|
|
260
300
|
buffer = writable = w;
|
|
261
301
|
buffer.write(tmp);
|
|
262
302
|
firstFlushed = true;
|
|
263
|
-
if (completed) writable.end();
|
|
303
|
+
if (completed) writable.end();
|
|
304
|
+
else setTimeout(flushEnd);
|
|
264
305
|
});
|
|
265
306
|
},
|
|
266
307
|
pipeTo(w) {
|
|
@@ -269,7 +310,7 @@ function renderToStream(code, options = {}) {
|
|
|
269
310
|
const encoder = new TextEncoder();
|
|
270
311
|
const writer = w.getWriter();
|
|
271
312
|
let resolve;
|
|
272
|
-
const p = new Promise(r => resolve = r);
|
|
313
|
+
const p = new Promise(r => (resolve = r));
|
|
273
314
|
writable = {
|
|
274
315
|
end() {
|
|
275
316
|
writer.releaseLock();
|
|
@@ -284,20 +325,21 @@ function renderToStream(code, options = {}) {
|
|
|
284
325
|
};
|
|
285
326
|
buffer.write(tmp);
|
|
286
327
|
firstFlushed = true;
|
|
287
|
-
if (completed) writable.end();
|
|
328
|
+
if (completed) writable.end();
|
|
329
|
+
else setTimeout(flushEnd);
|
|
288
330
|
return p;
|
|
289
331
|
});
|
|
290
332
|
}
|
|
291
333
|
};
|
|
292
334
|
}
|
|
293
335
|
function HydrationScript(props) {
|
|
294
|
-
const {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
336
|
+
const { nonce } = sharedConfig.context;
|
|
337
|
+
return ssr(
|
|
338
|
+
generateHydrationScript({
|
|
339
|
+
nonce,
|
|
340
|
+
...props
|
|
341
|
+
})
|
|
342
|
+
);
|
|
301
343
|
}
|
|
302
344
|
function ssr(t, ...nodes) {
|
|
303
345
|
if (nodes.length) {
|
|
@@ -342,7 +384,8 @@ function ssrStyle(value) {
|
|
|
342
384
|
return result;
|
|
343
385
|
}
|
|
344
386
|
function ssrElement(tag, props, children, needsId) {
|
|
345
|
-
if (props == null) props = {};
|
|
387
|
+
if (props == null) props = {};
|
|
388
|
+
else if (typeof props === "function") props = props();
|
|
346
389
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
347
390
|
const keys = Object.keys(props);
|
|
348
391
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -350,7 +393,8 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
350
393
|
for (let i = 0; i < keys.length; i++) {
|
|
351
394
|
const prop = keys[i];
|
|
352
395
|
if (ChildProperties.has(prop)) {
|
|
353
|
-
if (children === undefined && !skipChildren)
|
|
396
|
+
if (children === undefined && !skipChildren)
|
|
397
|
+
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
354
398
|
continue;
|
|
355
399
|
}
|
|
356
400
|
const value = props[prop];
|
|
@@ -359,10 +403,14 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
359
403
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
360
404
|
if (classResolved) continue;
|
|
361
405
|
let n;
|
|
362
|
-
result += `class="${
|
|
406
|
+
result += `class="${
|
|
407
|
+
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
408
|
+
ssrClassList(props.classList)
|
|
409
|
+
}"`;
|
|
363
410
|
classResolved = true;
|
|
364
411
|
} else if (BooleanAttributes.has(prop)) {
|
|
365
|
-
if (value) result += prop;
|
|
412
|
+
if (value) result += prop;
|
|
413
|
+
else continue;
|
|
366
414
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
367
415
|
continue;
|
|
368
416
|
} else {
|
|
@@ -370,16 +418,17 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
370
418
|
}
|
|
371
419
|
if (i !== keys.length - 1) result += " ";
|
|
372
420
|
}
|
|
373
|
-
if (skipChildren)
|
|
374
|
-
|
|
375
|
-
|
|
421
|
+
if (skipChildren)
|
|
422
|
+
return {
|
|
423
|
+
t: result + "/>"
|
|
424
|
+
};
|
|
376
425
|
if (typeof children === "function") children = children();
|
|
377
426
|
return {
|
|
378
427
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
379
428
|
};
|
|
380
429
|
}
|
|
381
430
|
function ssrAttribute(key, value, isBoolean) {
|
|
382
|
-
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
431
|
+
return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
|
|
383
432
|
}
|
|
384
433
|
function ssrHydrationKey() {
|
|
385
434
|
const hk = getHydrationKey();
|
|
@@ -423,12 +472,13 @@ function escape(s, attr) {
|
|
|
423
472
|
left = iDelim + 1;
|
|
424
473
|
iDelim = s.indexOf(delim, left);
|
|
425
474
|
} while (iDelim >= 0);
|
|
426
|
-
} else
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
475
|
+
} else
|
|
476
|
+
while (iAmp >= 0) {
|
|
477
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
478
|
+
out += "&";
|
|
479
|
+
left = iAmp + 1;
|
|
480
|
+
iAmp = s.indexOf("&", left);
|
|
481
|
+
}
|
|
432
482
|
return left < s.length ? out + s.substring(left) : out;
|
|
433
483
|
}
|
|
434
484
|
function resolveSSRNode(node, top) {
|
|
@@ -440,7 +490,7 @@ function resolveSSRNode(node, top) {
|
|
|
440
490
|
let mapped = "";
|
|
441
491
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
442
492
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
443
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
493
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
444
494
|
}
|
|
445
495
|
return mapped;
|
|
446
496
|
}
|
|
@@ -461,11 +511,12 @@ function getAssets() {
|
|
|
461
511
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
462
512
|
return out;
|
|
463
513
|
}
|
|
464
|
-
function generateHydrationScript({
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
} =
|
|
468
|
-
|
|
514
|
+
function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
|
|
515
|
+
return `<script${
|
|
516
|
+
nonce ? ` nonce="${nonce}"` : ""
|
|
517
|
+
}>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(
|
|
518
|
+
'", "'
|
|
519
|
+
)}"].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
520
|
}
|
|
470
521
|
function Hydration(props) {
|
|
471
522
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -484,6 +535,9 @@ function NoHydration(props) {
|
|
|
484
535
|
sharedConfig.context.noHydrate = true;
|
|
485
536
|
return props.children;
|
|
486
537
|
}
|
|
538
|
+
function queue(fn) {
|
|
539
|
+
return Promise.resolve().then(fn);
|
|
540
|
+
}
|
|
487
541
|
function injectAssets(assets, html) {
|
|
488
542
|
if (!assets || !assets.length) return html;
|
|
489
543
|
let out = "";
|
|
@@ -521,9 +575,7 @@ function Assets(props) {
|
|
|
521
575
|
}
|
|
522
576
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
523
577
|
if (options.onReady) {
|
|
524
|
-
options.onCompleteShell = ({
|
|
525
|
-
write
|
|
526
|
-
}) => {
|
|
578
|
+
options.onCompleteShell = ({ write }) => {
|
|
527
579
|
options.onReady({
|
|
528
580
|
write,
|
|
529
581
|
startWriting() {
|
|
@@ -537,9 +589,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
537
589
|
}
|
|
538
590
|
function pipeToWritable(code, writable, options = {}) {
|
|
539
591
|
if (options.onReady) {
|
|
540
|
-
options.onCompleteShell = ({
|
|
541
|
-
write
|
|
542
|
-
}) => {
|
|
592
|
+
options.onCompleteShell = ({ write }) => {
|
|
543
593
|
options.onReady({
|
|
544
594
|
write,
|
|
545
595
|
startWriting() {
|
|
@@ -569,11 +619,19 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
569
619
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
570
620
|
if (classResolved) continue;
|
|
571
621
|
let n;
|
|
572
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
622
|
+
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
623
|
+
(n = props.className) ? n + " " : ""
|
|
624
|
+
}${ssrClassList(props.classList)}"`;
|
|
573
625
|
classResolved = true;
|
|
574
626
|
} else if (BooleanAttributes.has(prop)) {
|
|
575
|
-
if (value) result += prop;
|
|
576
|
-
|
|
627
|
+
if (value) result += prop;
|
|
628
|
+
else continue;
|
|
629
|
+
} else if (
|
|
630
|
+
value == undefined ||
|
|
631
|
+
prop === "ref" ||
|
|
632
|
+
prop.slice(0, 2) === "on" ||
|
|
633
|
+
prop.slice(0, 5) === "prop:"
|
|
634
|
+
) {
|
|
577
635
|
continue;
|
|
578
636
|
} else {
|
|
579
637
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -597,7 +655,8 @@ function Dynamic(props) {
|
|
|
597
655
|
const comp = p.component,
|
|
598
656
|
t = typeof comp;
|
|
599
657
|
if (comp) {
|
|
600
|
-
if (t === "function") return comp(others);
|
|
658
|
+
if (t === "function") return comp(others);
|
|
659
|
+
else if (t === "string") {
|
|
601
660
|
return ssrElement(comp, others, undefined, true);
|
|
602
661
|
}
|
|
603
662
|
}
|
|
@@ -606,4 +665,39 @@ function Portal(props) {
|
|
|
606
665
|
return "";
|
|
607
666
|
}
|
|
608
667
|
|
|
609
|
-
export {
|
|
668
|
+
export {
|
|
669
|
+
Assets,
|
|
670
|
+
Dynamic,
|
|
671
|
+
Hydration,
|
|
672
|
+
HydrationScript,
|
|
673
|
+
NoHydration,
|
|
674
|
+
Portal,
|
|
675
|
+
RequestContext,
|
|
676
|
+
addEventListener,
|
|
677
|
+
delegateEvents,
|
|
678
|
+
escape,
|
|
679
|
+
generateHydrationScript,
|
|
680
|
+
getAssets,
|
|
681
|
+
getHydrationKey,
|
|
682
|
+
getRequestEvent,
|
|
683
|
+
hydrate,
|
|
684
|
+
insert,
|
|
685
|
+
isDev,
|
|
686
|
+
isServer,
|
|
687
|
+
pipeToNodeWritable,
|
|
688
|
+
pipeToWritable,
|
|
689
|
+
render,
|
|
690
|
+
renderToStream,
|
|
691
|
+
renderToString,
|
|
692
|
+
renderToStringAsync,
|
|
693
|
+
resolveSSRNode,
|
|
694
|
+
spread,
|
|
695
|
+
ssr,
|
|
696
|
+
ssrAttribute,
|
|
697
|
+
ssrClassList,
|
|
698
|
+
ssrElement,
|
|
699
|
+
ssrHydrationKey,
|
|
700
|
+
ssrSpread,
|
|
701
|
+
ssrStyle,
|
|
702
|
+
useAssets
|
|
703
|
+
};
|
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), {
|