solid-js 1.8.3 → 1.8.5
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 +2 -2
- package/dist/dev.js +299 -534
- package/dist/server.js +75 -170
- package/dist/solid.cjs +2 -2
- package/dist/solid.js +257 -461
- package/h/dist/h.js +8 -34
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +8 -11
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -216
- package/html/types/lit.d.ts +33 -45
- package/package.json +7 -3
- package/store/dist/dev.js +42 -114
- package/store/dist/server.js +8 -19
- package/store/dist/store.js +39 -105
- package/store/types/index.d.ts +7 -21
- package/store/types/modifiers.d.ts +3 -6
- package/store/types/mutable.d.ts +2 -5
- package/store/types/server.d.ts +4 -12
- package/store/types/store.d.ts +61 -218
- package/types/index.d.ts +9 -72
- package/types/reactive/array.d.ts +4 -12
- package/types/reactive/observable.d.ts +17 -25
- package/types/reactive/scheduler.d.ts +6 -9
- package/types/reactive/signal.d.ts +140 -228
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +31 -62
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +2 -57
- package/types/server/reactive.d.ts +42 -73
- package/types/server/rendering.d.ts +95 -166
- package/universal/dist/dev.js +12 -28
- package/universal/dist/universal.js +12 -28
- package/universal/types/index.d.ts +1 -3
- package/universal/types/universal.d.ts +1 -0
- package/web/dist/dev.cjs +3 -0
- package/web/dist/dev.js +82 -617
- package/web/dist/server.cjs +17 -5
- package/web/dist/server.js +105 -178
- 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 +81 -611
- package/web/types/client.d.ts +7 -2
- package/web/types/core.d.ts +1 -10
- package/web/types/index.d.ts +10 -27
- package/web/types/server-mock.d.ts +32 -47
- 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,65 +1,32 @@
|
|
|
1
|
-
import { sharedConfig, createRoot, splitProps } from
|
|
2
|
-
export {
|
|
3
|
-
|
|
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";
|
|
1
|
+
import { sharedConfig, createRoot, splitProps } from 'solid-js';
|
|
2
|
+
export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, mergeProps } from 'solid-js';
|
|
3
|
+
import { Feature, Serializer, GLOBAL_CONTEXT_API_SCRIPT, getCrossReferenceHeader } from 'seroval';
|
|
15
4
|
|
|
16
|
-
const booleans = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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), {
|
|
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"];
|
|
6
|
+
const BooleanAttributes = /*#__PURE__*/new Set(booleans);
|
|
7
|
+
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
8
|
+
const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
50
9
|
className: "class",
|
|
51
10
|
htmlFor: "for"
|
|
52
11
|
});
|
|
53
12
|
|
|
54
|
-
const ES2017FLAG = Feature.AggregateError
|
|
55
|
-
|
|
56
|
-
|
|
13
|
+
const ES2017FLAG = Feature.AggregateError
|
|
14
|
+
| Feature.BigInt
|
|
15
|
+
| Feature.BigIntTypedArray;
|
|
16
|
+
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
17
|
+
function createSerializer({
|
|
18
|
+
onData,
|
|
19
|
+
onDone,
|
|
20
|
+
scopeId,
|
|
21
|
+
onError
|
|
22
|
+
}) {
|
|
57
23
|
return new Serializer({
|
|
58
24
|
scopeId,
|
|
59
25
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
60
26
|
disabledFeatures: ES2017FLAG,
|
|
61
27
|
onData,
|
|
62
|
-
onDone
|
|
28
|
+
onDone,
|
|
29
|
+
onError
|
|
63
30
|
});
|
|
64
31
|
}
|
|
65
32
|
function getGlobalHeaderScript() {
|
|
@@ -69,11 +36,12 @@ function getLocalHeaderScript(id) {
|
|
|
69
36
|
return getCrossReferenceHeader(id);
|
|
70
37
|
}
|
|
71
38
|
|
|
72
|
-
const VOID_ELEMENTS =
|
|
73
|
-
/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
39
|
+
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
74
40
|
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)}`;
|
|
75
41
|
function renderToString(code, options = {}) {
|
|
76
|
-
const {
|
|
42
|
+
const {
|
|
43
|
+
renderId
|
|
44
|
+
} = options;
|
|
77
45
|
let scripts = "";
|
|
78
46
|
const serializer = createSerializer({
|
|
79
47
|
scopeId: renderId,
|
|
@@ -82,7 +50,8 @@ function renderToString(code, options = {}) {
|
|
|
82
50
|
scripts = getLocalHeaderScript(renderId);
|
|
83
51
|
}
|
|
84
52
|
scripts += script;
|
|
85
|
-
}
|
|
53
|
+
},
|
|
54
|
+
onError: options.onError
|
|
86
55
|
});
|
|
87
56
|
sharedConfig.context = {
|
|
88
57
|
id: renderId || "",
|
|
@@ -106,7 +75,9 @@ function renderToString(code, options = {}) {
|
|
|
106
75
|
return html;
|
|
107
76
|
}
|
|
108
77
|
function renderToStringAsync(code, options = {}) {
|
|
109
|
-
const {
|
|
78
|
+
const {
|
|
79
|
+
timeoutMs = 30000
|
|
80
|
+
} = options;
|
|
110
81
|
let timeoutHandle;
|
|
111
82
|
const timeout = new Promise((_, reject) => {
|
|
112
83
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -117,10 +88,17 @@ function renderToStringAsync(code, options = {}) {
|
|
|
117
88
|
});
|
|
118
89
|
}
|
|
119
90
|
function renderToStream(code, options = {}) {
|
|
120
|
-
let {
|
|
91
|
+
let {
|
|
92
|
+
nonce,
|
|
93
|
+
onCompleteShell,
|
|
94
|
+
onCompleteAll,
|
|
95
|
+
renderId,
|
|
96
|
+
noScripts
|
|
97
|
+
} = options;
|
|
121
98
|
let dispose;
|
|
122
99
|
const blockingPromises = [];
|
|
123
100
|
const pushTask = task => {
|
|
101
|
+
if (noScripts) return;
|
|
124
102
|
if (!tasks && !firstFlushed) {
|
|
125
103
|
tasks = getLocalHeaderScript(renderId);
|
|
126
104
|
}
|
|
@@ -132,12 +110,11 @@ function renderToStream(code, options = {}) {
|
|
|
132
110
|
const checkEnd = () => {
|
|
133
111
|
if (!registry.size && !completed) {
|
|
134
112
|
writeTasks();
|
|
135
|
-
onCompleteAll &&
|
|
136
|
-
|
|
137
|
-
write(v)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
113
|
+
onCompleteAll && onCompleteAll({
|
|
114
|
+
write(v) {
|
|
115
|
+
!completed && buffer.write(v);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
141
118
|
writable && writable.end();
|
|
142
119
|
completed = true;
|
|
143
120
|
setTimeout(dispose);
|
|
@@ -146,7 +123,8 @@ function renderToStream(code, options = {}) {
|
|
|
146
123
|
const serializer = createSerializer({
|
|
147
124
|
scopeId: options.renderId,
|
|
148
125
|
onData: pushTask,
|
|
149
|
-
onDone: checkEnd
|
|
126
|
+
onDone: checkEnd,
|
|
127
|
+
onError: options.onError
|
|
150
128
|
});
|
|
151
129
|
const flushEnd = () => {
|
|
152
130
|
if (!registry.size) {
|
|
@@ -193,29 +171,23 @@ function renderToStream(code, options = {}) {
|
|
|
193
171
|
const first = html.indexOf(placeholder);
|
|
194
172
|
if (first === -1) return;
|
|
195
173
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
196
|
-
html = html.replace(
|
|
197
|
-
html.slice(first, last + placeholder.length + 1),
|
|
198
|
-
resolveSSRNode(payloadFn())
|
|
199
|
-
);
|
|
174
|
+
html = html.replace(html.slice(first, last + placeholder.length + 1), resolveSSRNode(payloadFn()));
|
|
200
175
|
},
|
|
201
176
|
serialize(id, p, wait) {
|
|
202
177
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
203
178
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
204
179
|
blockingPromises.push(p);
|
|
205
|
-
!serverOnly &&
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
.catch(e => {
|
|
211
|
-
serializer.write(id, e);
|
|
212
|
-
});
|
|
180
|
+
!serverOnly && p.then(d => {
|
|
181
|
+
serializer.write(id, d);
|
|
182
|
+
}).catch(e => {
|
|
183
|
+
serializer.write(id, e);
|
|
184
|
+
});
|
|
213
185
|
} else if (!serverOnly) serializer.write(id, p);
|
|
214
186
|
},
|
|
215
187
|
registerFragment(key) {
|
|
216
188
|
if (!registry.has(key)) {
|
|
217
189
|
let resolve, reject;
|
|
218
|
-
const p = new Promise((r, rej) => (
|
|
190
|
+
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
219
191
|
registry.set(key, {
|
|
220
192
|
resolve,
|
|
221
193
|
reject
|
|
@@ -224,7 +196,10 @@ function renderToStream(code, options = {}) {
|
|
|
224
196
|
}
|
|
225
197
|
return (value, error) => {
|
|
226
198
|
if (registry.has(key)) {
|
|
227
|
-
const {
|
|
199
|
+
const {
|
|
200
|
+
resolve,
|
|
201
|
+
reject
|
|
202
|
+
} = registry.get(key);
|
|
228
203
|
registry.delete(key);
|
|
229
204
|
if (waitForFragments(registry, key)) {
|
|
230
205
|
resolve(true);
|
|
@@ -232,9 +207,7 @@ function renderToStream(code, options = {}) {
|
|
|
232
207
|
}
|
|
233
208
|
if ((value !== undefined || error) && !completed) {
|
|
234
209
|
if (!firstFlushed) {
|
|
235
|
-
Promise.resolve().then(
|
|
236
|
-
() => (html = replacePlaceholder(html, key, value !== undefined ? value : ""))
|
|
237
|
-
);
|
|
210
|
+
Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
238
211
|
error ? reject(error) : resolve(true);
|
|
239
212
|
} else {
|
|
240
213
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -260,12 +233,11 @@ function renderToStream(code, options = {}) {
|
|
|
260
233
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
261
234
|
buffer.write(html);
|
|
262
235
|
tasks = "";
|
|
263
|
-
onCompleteShell &&
|
|
264
|
-
|
|
265
|
-
write(v)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
});
|
|
236
|
+
onCompleteShell && onCompleteShell({
|
|
237
|
+
write(v) {
|
|
238
|
+
!completed && buffer.write(v);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
269
241
|
}
|
|
270
242
|
return {
|
|
271
243
|
then(fn) {
|
|
@@ -288,8 +260,7 @@ function renderToStream(code, options = {}) {
|
|
|
288
260
|
buffer = writable = w;
|
|
289
261
|
buffer.write(tmp);
|
|
290
262
|
firstFlushed = true;
|
|
291
|
-
if (completed) writable.end();
|
|
292
|
-
else setTimeout(flushEnd);
|
|
263
|
+
if (completed) writable.end();else setTimeout(flushEnd);
|
|
293
264
|
});
|
|
294
265
|
},
|
|
295
266
|
pipeTo(w) {
|
|
@@ -298,7 +269,7 @@ function renderToStream(code, options = {}) {
|
|
|
298
269
|
const encoder = new TextEncoder();
|
|
299
270
|
const writer = w.getWriter();
|
|
300
271
|
let resolve;
|
|
301
|
-
const p = new Promise(r =>
|
|
272
|
+
const p = new Promise(r => resolve = r);
|
|
302
273
|
writable = {
|
|
303
274
|
end() {
|
|
304
275
|
writer.releaseLock();
|
|
@@ -313,21 +284,20 @@ function renderToStream(code, options = {}) {
|
|
|
313
284
|
};
|
|
314
285
|
buffer.write(tmp);
|
|
315
286
|
firstFlushed = true;
|
|
316
|
-
if (completed) writable.end();
|
|
317
|
-
else setTimeout(flushEnd);
|
|
287
|
+
if (completed) writable.end();else setTimeout(flushEnd);
|
|
318
288
|
return p;
|
|
319
289
|
});
|
|
320
290
|
}
|
|
321
291
|
};
|
|
322
292
|
}
|
|
323
293
|
function HydrationScript(props) {
|
|
324
|
-
const {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
);
|
|
294
|
+
const {
|
|
295
|
+
nonce
|
|
296
|
+
} = sharedConfig.context;
|
|
297
|
+
return ssr(generateHydrationScript({
|
|
298
|
+
nonce,
|
|
299
|
+
...props
|
|
300
|
+
}));
|
|
331
301
|
}
|
|
332
302
|
function ssr(t, ...nodes) {
|
|
333
303
|
if (nodes.length) {
|
|
@@ -372,8 +342,7 @@ function ssrStyle(value) {
|
|
|
372
342
|
return result;
|
|
373
343
|
}
|
|
374
344
|
function ssrElement(tag, props, children, needsId) {
|
|
375
|
-
if (props == null) props = {};
|
|
376
|
-
else if (typeof props === "function") props = props();
|
|
345
|
+
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
377
346
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
378
347
|
const keys = Object.keys(props);
|
|
379
348
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -381,8 +350,7 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
381
350
|
for (let i = 0; i < keys.length; i++) {
|
|
382
351
|
const prop = keys[i];
|
|
383
352
|
if (ChildProperties.has(prop)) {
|
|
384
|
-
if (children === undefined && !skipChildren)
|
|
385
|
-
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
353
|
+
if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
386
354
|
continue;
|
|
387
355
|
}
|
|
388
356
|
const value = props[prop];
|
|
@@ -391,14 +359,10 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
391
359
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
392
360
|
if (classResolved) continue;
|
|
393
361
|
let n;
|
|
394
|
-
result += `class="${
|
|
395
|
-
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
396
|
-
ssrClassList(props.classList)
|
|
397
|
-
}"`;
|
|
362
|
+
result += `class="${escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) + ssrClassList(props.classList)}"`;
|
|
398
363
|
classResolved = true;
|
|
399
364
|
} else if (BooleanAttributes.has(prop)) {
|
|
400
|
-
if (value) result += prop;
|
|
401
|
-
else continue;
|
|
365
|
+
if (value) result += prop;else continue;
|
|
402
366
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
403
367
|
continue;
|
|
404
368
|
} else {
|
|
@@ -406,17 +370,16 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
406
370
|
}
|
|
407
371
|
if (i !== keys.length - 1) result += " ";
|
|
408
372
|
}
|
|
409
|
-
if (skipChildren)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
};
|
|
373
|
+
if (skipChildren) return {
|
|
374
|
+
t: result + "/>"
|
|
375
|
+
};
|
|
413
376
|
if (typeof children === "function") children = children();
|
|
414
377
|
return {
|
|
415
378
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
416
379
|
};
|
|
417
380
|
}
|
|
418
381
|
function ssrAttribute(key, value, isBoolean) {
|
|
419
|
-
return isBoolean ?
|
|
382
|
+
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
420
383
|
}
|
|
421
384
|
function ssrHydrationKey() {
|
|
422
385
|
const hk = getHydrationKey();
|
|
@@ -460,13 +423,12 @@ function escape(s, attr) {
|
|
|
460
423
|
left = iDelim + 1;
|
|
461
424
|
iDelim = s.indexOf(delim, left);
|
|
462
425
|
} while (iDelim >= 0);
|
|
463
|
-
} else
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
426
|
+
} else while (iAmp >= 0) {
|
|
427
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
428
|
+
out += "&";
|
|
429
|
+
left = iAmp + 1;
|
|
430
|
+
iAmp = s.indexOf("&", left);
|
|
431
|
+
}
|
|
470
432
|
return left < s.length ? out + s.substring(left) : out;
|
|
471
433
|
}
|
|
472
434
|
function resolveSSRNode(node, top) {
|
|
@@ -478,7 +440,7 @@ function resolveSSRNode(node, top) {
|
|
|
478
440
|
let mapped = "";
|
|
479
441
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
480
442
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
481
|
-
mapped += resolveSSRNode(
|
|
443
|
+
mapped += resolveSSRNode(prev = node[i]);
|
|
482
444
|
}
|
|
483
445
|
return mapped;
|
|
484
446
|
}
|
|
@@ -499,12 +461,11 @@ function getAssets() {
|
|
|
499
461
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
500
462
|
return out;
|
|
501
463
|
}
|
|
502
|
-
function generateHydrationScript({
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
)}"].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-->`;
|
|
464
|
+
function generateHydrationScript({
|
|
465
|
+
eventNames = ["click", "input"],
|
|
466
|
+
nonce
|
|
467
|
+
} = {}) {
|
|
468
|
+
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(){}});${getGlobalHeaderScript()}</script><!--xs-->`;
|
|
508
469
|
}
|
|
509
470
|
function Hydration(props) {
|
|
510
471
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -551,12 +512,18 @@ function replacePlaceholder(html, key, value) {
|
|
|
551
512
|
const last = html.indexOf(close, first + marker.length);
|
|
552
513
|
return html.slice(0, first) + value + html.slice(last + close.length);
|
|
553
514
|
}
|
|
515
|
+
const RequestContext = Symbol();
|
|
516
|
+
function getRequestEvent() {
|
|
517
|
+
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() : undefined;
|
|
518
|
+
}
|
|
554
519
|
function Assets(props) {
|
|
555
520
|
useAssets(() => props.children);
|
|
556
521
|
}
|
|
557
522
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
558
523
|
if (options.onReady) {
|
|
559
|
-
options.onCompleteShell = ({
|
|
524
|
+
options.onCompleteShell = ({
|
|
525
|
+
write
|
|
526
|
+
}) => {
|
|
560
527
|
options.onReady({
|
|
561
528
|
write,
|
|
562
529
|
startWriting() {
|
|
@@ -570,7 +537,9 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
570
537
|
}
|
|
571
538
|
function pipeToWritable(code, writable, options = {}) {
|
|
572
539
|
if (options.onReady) {
|
|
573
|
-
options.onCompleteShell = ({
|
|
540
|
+
options.onCompleteShell = ({
|
|
541
|
+
write
|
|
542
|
+
}) => {
|
|
574
543
|
options.onReady({
|
|
575
544
|
write,
|
|
576
545
|
startWriting() {
|
|
@@ -600,19 +569,11 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
600
569
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
601
570
|
if (classResolved) continue;
|
|
602
571
|
let n;
|
|
603
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
604
|
-
(n = props.className) ? n + " " : ""
|
|
605
|
-
}${ssrClassList(props.classList)}"`;
|
|
572
|
+
result += `class="${(n = props.class) ? n + " " : ""}${(n = props.className) ? n + " " : ""}${ssrClassList(props.classList)}"`;
|
|
606
573
|
classResolved = true;
|
|
607
574
|
} else if (BooleanAttributes.has(prop)) {
|
|
608
|
-
if (value) result += prop;
|
|
609
|
-
|
|
610
|
-
} else if (
|
|
611
|
-
value == undefined ||
|
|
612
|
-
prop === "ref" ||
|
|
613
|
-
prop.slice(0, 2) === "on" ||
|
|
614
|
-
prop.slice(0, 5) === "prop:"
|
|
615
|
-
) {
|
|
575
|
+
if (value) result += prop;else continue;
|
|
576
|
+
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
|
|
616
577
|
continue;
|
|
617
578
|
} else {
|
|
618
579
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -636,8 +597,7 @@ function Dynamic(props) {
|
|
|
636
597
|
const comp = p.component,
|
|
637
598
|
t = typeof comp;
|
|
638
599
|
if (comp) {
|
|
639
|
-
if (t === "function") return comp(others);
|
|
640
|
-
else if (t === "string") {
|
|
600
|
+
if (t === "function") return comp(others);else if (t === "string") {
|
|
641
601
|
return ssrElement(comp, others, undefined, true);
|
|
642
602
|
}
|
|
643
603
|
}
|
|
@@ -646,37 +606,4 @@ function Portal(props) {
|
|
|
646
606
|
return "";
|
|
647
607
|
}
|
|
648
608
|
|
|
649
|
-
export {
|
|
650
|
-
Assets,
|
|
651
|
-
Dynamic,
|
|
652
|
-
Hydration,
|
|
653
|
-
HydrationScript,
|
|
654
|
-
NoHydration,
|
|
655
|
-
Portal,
|
|
656
|
-
addEventListener,
|
|
657
|
-
delegateEvents,
|
|
658
|
-
escape,
|
|
659
|
-
generateHydrationScript,
|
|
660
|
-
getAssets,
|
|
661
|
-
getHydrationKey,
|
|
662
|
-
hydrate,
|
|
663
|
-
insert,
|
|
664
|
-
isDev,
|
|
665
|
-
isServer,
|
|
666
|
-
pipeToNodeWritable,
|
|
667
|
-
pipeToWritable,
|
|
668
|
-
render,
|
|
669
|
-
renderToStream,
|
|
670
|
-
renderToString,
|
|
671
|
-
renderToStringAsync,
|
|
672
|
-
resolveSSRNode,
|
|
673
|
-
spread,
|
|
674
|
-
ssr,
|
|
675
|
-
ssrAttribute,
|
|
676
|
-
ssrClassList,
|
|
677
|
-
ssrElement,
|
|
678
|
-
ssrHydrationKey,
|
|
679
|
-
ssrSpread,
|
|
680
|
-
ssrStyle,
|
|
681
|
-
useAssets
|
|
682
|
-
};
|
|
609
|
+
export { Assets, Dynamic, Hydration, HydrationScript, NoHydration, Portal, RequestContext, addEventListener, delegateEvents, escape, generateHydrationScript, getAssets, getHydrationKey, getRequestEvent, hydrate, insert, isDev, isServer, pipeToNodeWritable, pipeToWritable, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, useAssets };
|
|
@@ -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;
|