solid-js 1.8.2 → 1.8.4
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 +1 -1
- package/dist/dev.js +534 -299
- package/dist/server.js +170 -75
- package/dist/solid.cjs +1 -1
- package/dist/solid.js +461 -257
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -31
- package/package.json +7 -3
- 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 +72 -9
- 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 +228 -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 +3 -0
- package/web/dist/dev.js +620 -81
- package/web/dist/server.cjs +17 -5
- package/web/dist/server.js +188 -95
- package/web/dist/storage.cjs +12 -0
- package/web/dist/storage.js +10 -0
- package/web/dist/web.cjs +3 -0
- package/web/dist/web.js +614 -80
- package/web/types/client.d.ts +8 -3
- 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/types/server.d.ts +10 -1
- package/web/types/storage.d.ts +2 -0
package/web/dist/server.cjs
CHANGED
|
@@ -18,14 +18,16 @@ const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
|
18
18
|
function createSerializer({
|
|
19
19
|
onData,
|
|
20
20
|
onDone,
|
|
21
|
-
scopeId
|
|
21
|
+
scopeId,
|
|
22
|
+
onError
|
|
22
23
|
}) {
|
|
23
24
|
return new seroval.Serializer({
|
|
24
25
|
scopeId,
|
|
25
26
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
26
27
|
disabledFeatures: ES2017FLAG,
|
|
27
28
|
onData,
|
|
28
|
-
onDone
|
|
29
|
+
onDone,
|
|
30
|
+
onError
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
function getGlobalHeaderScript() {
|
|
@@ -49,7 +51,8 @@ function renderToString(code, options = {}) {
|
|
|
49
51
|
scripts = getLocalHeaderScript(renderId);
|
|
50
52
|
}
|
|
51
53
|
scripts += script;
|
|
52
|
-
}
|
|
54
|
+
},
|
|
55
|
+
onError: options.onError
|
|
53
56
|
});
|
|
54
57
|
solidJs.sharedConfig.context = {
|
|
55
58
|
id: renderId || "",
|
|
@@ -90,11 +93,13 @@ function renderToStream(code, options = {}) {
|
|
|
90
93
|
nonce,
|
|
91
94
|
onCompleteShell,
|
|
92
95
|
onCompleteAll,
|
|
93
|
-
renderId
|
|
96
|
+
renderId,
|
|
97
|
+
noScripts
|
|
94
98
|
} = options;
|
|
95
99
|
let dispose;
|
|
96
100
|
const blockingPromises = [];
|
|
97
101
|
const pushTask = task => {
|
|
102
|
+
if (noScripts) return;
|
|
98
103
|
if (!tasks && !firstFlushed) {
|
|
99
104
|
tasks = getLocalHeaderScript(renderId);
|
|
100
105
|
}
|
|
@@ -119,7 +124,8 @@ function renderToStream(code, options = {}) {
|
|
|
119
124
|
const serializer = createSerializer({
|
|
120
125
|
scopeId: options.renderId,
|
|
121
126
|
onData: pushTask,
|
|
122
|
-
onDone: checkEnd
|
|
127
|
+
onDone: checkEnd,
|
|
128
|
+
onError: options.onError
|
|
123
129
|
});
|
|
124
130
|
const flushEnd = () => {
|
|
125
131
|
if (!registry.size) {
|
|
@@ -507,6 +513,10 @@ function replacePlaceholder(html, key, value) {
|
|
|
507
513
|
const last = html.indexOf(close, first + marker.length);
|
|
508
514
|
return html.slice(0, first) + value + html.slice(last + close.length);
|
|
509
515
|
}
|
|
516
|
+
const RequestContext = Symbol();
|
|
517
|
+
function getRequestEvent() {
|
|
518
|
+
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() : undefined;
|
|
519
|
+
}
|
|
510
520
|
function Assets(props) {
|
|
511
521
|
useAssets(() => props.children);
|
|
512
522
|
}
|
|
@@ -643,12 +653,14 @@ exports.Hydration = Hydration;
|
|
|
643
653
|
exports.HydrationScript = HydrationScript;
|
|
644
654
|
exports.NoHydration = NoHydration;
|
|
645
655
|
exports.Portal = Portal;
|
|
656
|
+
exports.RequestContext = RequestContext;
|
|
646
657
|
exports.addEventListener = addEventListener;
|
|
647
658
|
exports.delegateEvents = delegateEvents;
|
|
648
659
|
exports.escape = escape;
|
|
649
660
|
exports.generateHydrationScript = generateHydrationScript;
|
|
650
661
|
exports.getAssets = getAssets;
|
|
651
662
|
exports.getHydrationKey = getHydrationKey;
|
|
663
|
+
exports.getRequestEvent = getRequestEvent;
|
|
652
664
|
exports.hydrate = hydrate;
|
|
653
665
|
exports.insert = insert;
|
|
654
666
|
exports.isDev = isDev;
|
package/web/dist/server.js
CHANGED
|
@@ -1,30 +1,66 @@
|
|
|
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, GLOBAL_CONTEXT_API_SCRIPT, 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
|
+
"ismap",
|
|
29
|
+
"loop",
|
|
30
|
+
"multiple",
|
|
31
|
+
"muted",
|
|
32
|
+
"nomodule",
|
|
33
|
+
"novalidate",
|
|
34
|
+
"open",
|
|
35
|
+
"playsinline",
|
|
36
|
+
"readonly",
|
|
37
|
+
"required",
|
|
38
|
+
"reversed",
|
|
39
|
+
"seamless",
|
|
40
|
+
"selected"
|
|
41
|
+
];
|
|
42
|
+
const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
|
|
43
|
+
const ChildProperties = /*#__PURE__*/ new Set([
|
|
44
|
+
"innerHTML",
|
|
45
|
+
"textContent",
|
|
46
|
+
"innerText",
|
|
47
|
+
"children"
|
|
48
|
+
]);
|
|
49
|
+
const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
|
|
9
50
|
className: "class",
|
|
10
51
|
htmlFor: "for"
|
|
11
52
|
});
|
|
12
53
|
|
|
13
|
-
const ES2017FLAG = Feature.AggregateError
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
17
|
-
function createSerializer({
|
|
18
|
-
onData,
|
|
19
|
-
onDone,
|
|
20
|
-
scopeId
|
|
21
|
-
}) {
|
|
54
|
+
const ES2017FLAG = Feature.AggregateError | Feature.BigInt | Feature.BigIntTypedArray;
|
|
55
|
+
const GLOBAL_IDENTIFIER = "_$HY.r";
|
|
56
|
+
function createSerializer({ onData, onDone, scopeId, onError }) {
|
|
22
57
|
return new Serializer({
|
|
23
58
|
scopeId,
|
|
24
59
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
25
60
|
disabledFeatures: ES2017FLAG,
|
|
26
61
|
onData,
|
|
27
|
-
onDone
|
|
62
|
+
onDone,
|
|
63
|
+
onError
|
|
28
64
|
});
|
|
29
65
|
}
|
|
30
66
|
function getGlobalHeaderScript() {
|
|
@@ -34,12 +70,11 @@ function getLocalHeaderScript(id) {
|
|
|
34
70
|
return getCrossReferenceHeader(id);
|
|
35
71
|
}
|
|
36
72
|
|
|
37
|
-
const VOID_ELEMENTS =
|
|
73
|
+
const VOID_ELEMENTS =
|
|
74
|
+
/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
38
75
|
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)}`;
|
|
39
76
|
function renderToString(code, options = {}) {
|
|
40
|
-
const {
|
|
41
|
-
renderId
|
|
42
|
-
} = options;
|
|
77
|
+
const { renderId } = options;
|
|
43
78
|
let scripts = "";
|
|
44
79
|
const serializer = createSerializer({
|
|
45
80
|
scopeId: renderId,
|
|
@@ -48,7 +83,8 @@ function renderToString(code, options = {}) {
|
|
|
48
83
|
scripts = getLocalHeaderScript(renderId);
|
|
49
84
|
}
|
|
50
85
|
scripts += script;
|
|
51
|
-
}
|
|
86
|
+
},
|
|
87
|
+
onError: options.onError
|
|
52
88
|
});
|
|
53
89
|
sharedConfig.context = {
|
|
54
90
|
id: renderId || "",
|
|
@@ -72,9 +108,7 @@ function renderToString(code, options = {}) {
|
|
|
72
108
|
return html;
|
|
73
109
|
}
|
|
74
110
|
function renderToStringAsync(code, options = {}) {
|
|
75
|
-
const {
|
|
76
|
-
timeoutMs = 30000
|
|
77
|
-
} = options;
|
|
111
|
+
const { timeoutMs = 30000 } = options;
|
|
78
112
|
let timeoutHandle;
|
|
79
113
|
const timeout = new Promise((_, reject) => {
|
|
80
114
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -85,15 +119,11 @@ function renderToStringAsync(code, options = {}) {
|
|
|
85
119
|
});
|
|
86
120
|
}
|
|
87
121
|
function renderToStream(code, options = {}) {
|
|
88
|
-
let {
|
|
89
|
-
nonce,
|
|
90
|
-
onCompleteShell,
|
|
91
|
-
onCompleteAll,
|
|
92
|
-
renderId
|
|
93
|
-
} = options;
|
|
122
|
+
let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
|
|
94
123
|
let dispose;
|
|
95
124
|
const blockingPromises = [];
|
|
96
125
|
const pushTask = task => {
|
|
126
|
+
if (noScripts) return;
|
|
97
127
|
if (!tasks && !firstFlushed) {
|
|
98
128
|
tasks = getLocalHeaderScript(renderId);
|
|
99
129
|
}
|
|
@@ -105,11 +135,12 @@ function renderToStream(code, options = {}) {
|
|
|
105
135
|
const checkEnd = () => {
|
|
106
136
|
if (!registry.size && !completed) {
|
|
107
137
|
writeTasks();
|
|
108
|
-
onCompleteAll &&
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
138
|
+
onCompleteAll &&
|
|
139
|
+
onCompleteAll({
|
|
140
|
+
write(v) {
|
|
141
|
+
!completed && buffer.write(v);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
113
144
|
writable && writable.end();
|
|
114
145
|
completed = true;
|
|
115
146
|
setTimeout(dispose);
|
|
@@ -118,7 +149,8 @@ function renderToStream(code, options = {}) {
|
|
|
118
149
|
const serializer = createSerializer({
|
|
119
150
|
scopeId: options.renderId,
|
|
120
151
|
onData: pushTask,
|
|
121
|
-
onDone: checkEnd
|
|
152
|
+
onDone: checkEnd,
|
|
153
|
+
onError: options.onError
|
|
122
154
|
});
|
|
123
155
|
const flushEnd = () => {
|
|
124
156
|
if (!registry.size) {
|
|
@@ -165,23 +197,29 @@ function renderToStream(code, options = {}) {
|
|
|
165
197
|
const first = html.indexOf(placeholder);
|
|
166
198
|
if (first === -1) return;
|
|
167
199
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
168
|
-
html = html.replace(
|
|
200
|
+
html = html.replace(
|
|
201
|
+
html.slice(first, last + placeholder.length + 1),
|
|
202
|
+
resolveSSRNode(payloadFn())
|
|
203
|
+
);
|
|
169
204
|
},
|
|
170
205
|
serialize(id, p, wait) {
|
|
171
206
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
172
207
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
173
208
|
blockingPromises.push(p);
|
|
174
|
-
!serverOnly &&
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
209
|
+
!serverOnly &&
|
|
210
|
+
p
|
|
211
|
+
.then(d => {
|
|
212
|
+
serializer.write(id, d);
|
|
213
|
+
})
|
|
214
|
+
.catch(e => {
|
|
215
|
+
serializer.write(id, e);
|
|
216
|
+
});
|
|
179
217
|
} else if (!serverOnly) serializer.write(id, p);
|
|
180
218
|
},
|
|
181
219
|
registerFragment(key) {
|
|
182
220
|
if (!registry.has(key)) {
|
|
183
221
|
let resolve, reject;
|
|
184
|
-
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
222
|
+
const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
|
|
185
223
|
registry.set(key, {
|
|
186
224
|
resolve,
|
|
187
225
|
reject
|
|
@@ -190,10 +228,7 @@ function renderToStream(code, options = {}) {
|
|
|
190
228
|
}
|
|
191
229
|
return (value, error) => {
|
|
192
230
|
if (registry.has(key)) {
|
|
193
|
-
const {
|
|
194
|
-
resolve,
|
|
195
|
-
reject
|
|
196
|
-
} = registry.get(key);
|
|
231
|
+
const { resolve, reject } = registry.get(key);
|
|
197
232
|
registry.delete(key);
|
|
198
233
|
if (waitForFragments(registry, key)) {
|
|
199
234
|
resolve(true);
|
|
@@ -201,7 +236,9 @@ function renderToStream(code, options = {}) {
|
|
|
201
236
|
}
|
|
202
237
|
if ((value !== undefined || error) && !completed) {
|
|
203
238
|
if (!firstFlushed) {
|
|
204
|
-
Promise.resolve().then(
|
|
239
|
+
Promise.resolve().then(
|
|
240
|
+
() => (html = replacePlaceholder(html, key, value !== undefined ? value : ""))
|
|
241
|
+
);
|
|
205
242
|
error ? reject(error) : resolve(true);
|
|
206
243
|
} else {
|
|
207
244
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -227,11 +264,12 @@ function renderToStream(code, options = {}) {
|
|
|
227
264
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
228
265
|
buffer.write(html);
|
|
229
266
|
tasks = "";
|
|
230
|
-
onCompleteShell &&
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
267
|
+
onCompleteShell &&
|
|
268
|
+
onCompleteShell({
|
|
269
|
+
write(v) {
|
|
270
|
+
!completed && buffer.write(v);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
235
273
|
}
|
|
236
274
|
return {
|
|
237
275
|
then(fn) {
|
|
@@ -254,7 +292,8 @@ function renderToStream(code, options = {}) {
|
|
|
254
292
|
buffer = writable = w;
|
|
255
293
|
buffer.write(tmp);
|
|
256
294
|
firstFlushed = true;
|
|
257
|
-
if (completed) writable.end();
|
|
295
|
+
if (completed) writable.end();
|
|
296
|
+
else setTimeout(flushEnd);
|
|
258
297
|
});
|
|
259
298
|
},
|
|
260
299
|
pipeTo(w) {
|
|
@@ -263,7 +302,7 @@ function renderToStream(code, options = {}) {
|
|
|
263
302
|
const encoder = new TextEncoder();
|
|
264
303
|
const writer = w.getWriter();
|
|
265
304
|
let resolve;
|
|
266
|
-
const p = new Promise(r => resolve = r);
|
|
305
|
+
const p = new Promise(r => (resolve = r));
|
|
267
306
|
writable = {
|
|
268
307
|
end() {
|
|
269
308
|
writer.releaseLock();
|
|
@@ -278,20 +317,21 @@ function renderToStream(code, options = {}) {
|
|
|
278
317
|
};
|
|
279
318
|
buffer.write(tmp);
|
|
280
319
|
firstFlushed = true;
|
|
281
|
-
if (completed) writable.end();
|
|
320
|
+
if (completed) writable.end();
|
|
321
|
+
else setTimeout(flushEnd);
|
|
282
322
|
return p;
|
|
283
323
|
});
|
|
284
324
|
}
|
|
285
325
|
};
|
|
286
326
|
}
|
|
287
327
|
function HydrationScript(props) {
|
|
288
|
-
const {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
328
|
+
const { nonce } = sharedConfig.context;
|
|
329
|
+
return ssr(
|
|
330
|
+
generateHydrationScript({
|
|
331
|
+
nonce,
|
|
332
|
+
...props
|
|
333
|
+
})
|
|
334
|
+
);
|
|
295
335
|
}
|
|
296
336
|
function ssr(t, ...nodes) {
|
|
297
337
|
if (nodes.length) {
|
|
@@ -336,7 +376,8 @@ function ssrStyle(value) {
|
|
|
336
376
|
return result;
|
|
337
377
|
}
|
|
338
378
|
function ssrElement(tag, props, children, needsId) {
|
|
339
|
-
if (props == null) props = {};
|
|
379
|
+
if (props == null) props = {};
|
|
380
|
+
else if (typeof props === "function") props = props();
|
|
340
381
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
341
382
|
const keys = Object.keys(props);
|
|
342
383
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -344,7 +385,8 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
344
385
|
for (let i = 0; i < keys.length; i++) {
|
|
345
386
|
const prop = keys[i];
|
|
346
387
|
if (ChildProperties.has(prop)) {
|
|
347
|
-
if (children === undefined && !skipChildren)
|
|
388
|
+
if (children === undefined && !skipChildren)
|
|
389
|
+
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
348
390
|
continue;
|
|
349
391
|
}
|
|
350
392
|
const value = props[prop];
|
|
@@ -353,10 +395,14 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
353
395
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
354
396
|
if (classResolved) continue;
|
|
355
397
|
let n;
|
|
356
|
-
result += `class="${
|
|
398
|
+
result += `class="${
|
|
399
|
+
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
400
|
+
ssrClassList(props.classList)
|
|
401
|
+
}"`;
|
|
357
402
|
classResolved = true;
|
|
358
403
|
} else if (BooleanAttributes.has(prop)) {
|
|
359
|
-
if (value) result += prop;
|
|
404
|
+
if (value) result += prop;
|
|
405
|
+
else continue;
|
|
360
406
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
361
407
|
continue;
|
|
362
408
|
} else {
|
|
@@ -364,16 +410,17 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
364
410
|
}
|
|
365
411
|
if (i !== keys.length - 1) result += " ";
|
|
366
412
|
}
|
|
367
|
-
if (skipChildren)
|
|
368
|
-
|
|
369
|
-
|
|
413
|
+
if (skipChildren)
|
|
414
|
+
return {
|
|
415
|
+
t: result + "/>"
|
|
416
|
+
};
|
|
370
417
|
if (typeof children === "function") children = children();
|
|
371
418
|
return {
|
|
372
419
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
373
420
|
};
|
|
374
421
|
}
|
|
375
422
|
function ssrAttribute(key, value, isBoolean) {
|
|
376
|
-
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
423
|
+
return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
|
|
377
424
|
}
|
|
378
425
|
function ssrHydrationKey() {
|
|
379
426
|
const hk = getHydrationKey();
|
|
@@ -417,12 +464,13 @@ function escape(s, attr) {
|
|
|
417
464
|
left = iDelim + 1;
|
|
418
465
|
iDelim = s.indexOf(delim, left);
|
|
419
466
|
} while (iDelim >= 0);
|
|
420
|
-
} else
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
467
|
+
} else
|
|
468
|
+
while (iAmp >= 0) {
|
|
469
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
470
|
+
out += "&";
|
|
471
|
+
left = iAmp + 1;
|
|
472
|
+
iAmp = s.indexOf("&", left);
|
|
473
|
+
}
|
|
426
474
|
return left < s.length ? out + s.substring(left) : out;
|
|
427
475
|
}
|
|
428
476
|
function resolveSSRNode(node, top) {
|
|
@@ -434,7 +482,7 @@ function resolveSSRNode(node, top) {
|
|
|
434
482
|
let mapped = "";
|
|
435
483
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
436
484
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
437
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
485
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
438
486
|
}
|
|
439
487
|
return mapped;
|
|
440
488
|
}
|
|
@@ -455,11 +503,12 @@ function getAssets() {
|
|
|
455
503
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
456
504
|
return out;
|
|
457
505
|
}
|
|
458
|
-
function generateHydrationScript({
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
} =
|
|
462
|
-
|
|
506
|
+
function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
|
|
507
|
+
return `<script${
|
|
508
|
+
nonce ? ` nonce="${nonce}"` : ""
|
|
509
|
+
}>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(
|
|
510
|
+
'", "'
|
|
511
|
+
)}"].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(){}});${getGlobalHeaderScript()}</script><!--xs-->`;
|
|
463
512
|
}
|
|
464
513
|
function Hydration(props) {
|
|
465
514
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -506,14 +555,16 @@ function replacePlaceholder(html, key, value) {
|
|
|
506
555
|
const last = html.indexOf(close, first + marker.length);
|
|
507
556
|
return html.slice(0, first) + value + html.slice(last + close.length);
|
|
508
557
|
}
|
|
558
|
+
const RequestContext = Symbol();
|
|
559
|
+
function getRequestEvent() {
|
|
560
|
+
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() : undefined;
|
|
561
|
+
}
|
|
509
562
|
function Assets(props) {
|
|
510
563
|
useAssets(() => props.children);
|
|
511
564
|
}
|
|
512
565
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
513
566
|
if (options.onReady) {
|
|
514
|
-
options.onCompleteShell = ({
|
|
515
|
-
write
|
|
516
|
-
}) => {
|
|
567
|
+
options.onCompleteShell = ({ write }) => {
|
|
517
568
|
options.onReady({
|
|
518
569
|
write,
|
|
519
570
|
startWriting() {
|
|
@@ -527,9 +578,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
527
578
|
}
|
|
528
579
|
function pipeToWritable(code, writable, options = {}) {
|
|
529
580
|
if (options.onReady) {
|
|
530
|
-
options.onCompleteShell = ({
|
|
531
|
-
write
|
|
532
|
-
}) => {
|
|
581
|
+
options.onCompleteShell = ({ write }) => {
|
|
533
582
|
options.onReady({
|
|
534
583
|
write,
|
|
535
584
|
startWriting() {
|
|
@@ -559,11 +608,19 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
559
608
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
560
609
|
if (classResolved) continue;
|
|
561
610
|
let n;
|
|
562
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
611
|
+
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
612
|
+
(n = props.className) ? n + " " : ""
|
|
613
|
+
}${ssrClassList(props.classList)}"`;
|
|
563
614
|
classResolved = true;
|
|
564
615
|
} else if (BooleanAttributes.has(prop)) {
|
|
565
|
-
if (value) result += prop;
|
|
566
|
-
|
|
616
|
+
if (value) result += prop;
|
|
617
|
+
else continue;
|
|
618
|
+
} else if (
|
|
619
|
+
value == undefined ||
|
|
620
|
+
prop === "ref" ||
|
|
621
|
+
prop.slice(0, 2) === "on" ||
|
|
622
|
+
prop.slice(0, 5) === "prop:"
|
|
623
|
+
) {
|
|
567
624
|
continue;
|
|
568
625
|
} else {
|
|
569
626
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -587,7 +644,8 @@ function Dynamic(props) {
|
|
|
587
644
|
const comp = p.component,
|
|
588
645
|
t = typeof comp;
|
|
589
646
|
if (comp) {
|
|
590
|
-
if (t === "function") return comp(others);
|
|
647
|
+
if (t === "function") return comp(others);
|
|
648
|
+
else if (t === "string") {
|
|
591
649
|
return ssrElement(comp, others, undefined, true);
|
|
592
650
|
}
|
|
593
651
|
}
|
|
@@ -596,4 +654,39 @@ function Portal(props) {
|
|
|
596
654
|
return "";
|
|
597
655
|
}
|
|
598
656
|
|
|
599
|
-
export {
|
|
657
|
+
export {
|
|
658
|
+
Assets,
|
|
659
|
+
Dynamic,
|
|
660
|
+
Hydration,
|
|
661
|
+
HydrationScript,
|
|
662
|
+
NoHydration,
|
|
663
|
+
Portal,
|
|
664
|
+
RequestContext,
|
|
665
|
+
addEventListener,
|
|
666
|
+
delegateEvents,
|
|
667
|
+
escape,
|
|
668
|
+
generateHydrationScript,
|
|
669
|
+
getAssets,
|
|
670
|
+
getHydrationKey,
|
|
671
|
+
getRequestEvent,
|
|
672
|
+
hydrate,
|
|
673
|
+
insert,
|
|
674
|
+
isDev,
|
|
675
|
+
isServer,
|
|
676
|
+
pipeToNodeWritable,
|
|
677
|
+
pipeToWritable,
|
|
678
|
+
render,
|
|
679
|
+
renderToStream,
|
|
680
|
+
renderToString,
|
|
681
|
+
renderToStringAsync,
|
|
682
|
+
resolveSSRNode,
|
|
683
|
+
spread,
|
|
684
|
+
ssr,
|
|
685
|
+
ssrAttribute,
|
|
686
|
+
ssrClassList,
|
|
687
|
+
ssrElement,
|
|
688
|
+
ssrHydrationKey,
|
|
689
|
+
ssrSpread,
|
|
690
|
+
ssrStyle,
|
|
691
|
+
useAssets
|
|
692
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_async_hooks = require('node:async_hooks');
|
|
4
|
+
var web = require('solid-js/web');
|
|
5
|
+
|
|
6
|
+
function provideRequestEvent(init, cb) {
|
|
7
|
+
if (!web.isServer) throw new Error("Attempting to use server context in non-server build");
|
|
8
|
+
const ctx = globalThis[web.RequestContext] = globalThis[web.RequestContext] || new node_async_hooks.AsyncLocalStorage();
|
|
9
|
+
return ctx.run(init, cb);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.provideRequestEvent = provideRequestEvent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { isServer, RequestContext } from "solid-js/web";
|
|
3
|
+
|
|
4
|
+
function provideRequestEvent(init, cb) {
|
|
5
|
+
if (!isServer) throw new Error("Attempting to use server context in non-server build");
|
|
6
|
+
const ctx = (globalThis[RequestContext] = globalThis[RequestContext] || new AsyncLocalStorage());
|
|
7
|
+
return ctx.run(init, cb);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { provideRequestEvent };
|
package/web/dist/web.cjs
CHANGED
|
@@ -535,6 +535,7 @@ function Hydration(props) {
|
|
|
535
535
|
return props.children;
|
|
536
536
|
}
|
|
537
537
|
function voidFn() {}
|
|
538
|
+
const RequestContext = Symbol();
|
|
538
539
|
function innerHTML(parent, content) {
|
|
539
540
|
!solidJs.sharedConfig.context && (parent.innerHTML = content);
|
|
540
541
|
}
|
|
@@ -695,6 +696,7 @@ exports.HydrationScript = voidFn;
|
|
|
695
696
|
exports.NoHydration = NoHydration;
|
|
696
697
|
exports.Portal = Portal;
|
|
697
698
|
exports.Properties = Properties;
|
|
699
|
+
exports.RequestContext = RequestContext;
|
|
698
700
|
exports.SVGElements = SVGElements;
|
|
699
701
|
exports.SVGNamespace = SVGNamespace;
|
|
700
702
|
exports.addEventListener = addEventListener;
|
|
@@ -712,6 +714,7 @@ exports.getNextElement = getNextElement;
|
|
|
712
714
|
exports.getNextMarker = getNextMarker;
|
|
713
715
|
exports.getNextMatch = getNextMatch;
|
|
714
716
|
exports.getPropAlias = getPropAlias;
|
|
717
|
+
exports.getRequestEvent = voidFn;
|
|
715
718
|
exports.hydrate = hydrate;
|
|
716
719
|
exports.innerHTML = innerHTML;
|
|
717
720
|
exports.insert = insert;
|