solid-js 1.8.9 → 1.8.11
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.js +307 -544
- package/dist/server.js +75 -170
- package/dist/solid.js +265 -471
- 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 -47
- package/package.json +1 -1
- package/store/dist/dev.js +42 -117
- package/store/dist/server.js +8 -19
- package/store/dist/store.js +39 -108
- 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 +10 -75
- 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 +142 -233
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +33 -64
- 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 +96 -167
- 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 -3
- package/web/dist/dev.js +84 -623
- package/web/dist/server.cjs +25 -17
- package/web/dist/server.js +117 -217
- package/web/dist/storage.js +3 -3
- package/web/dist/web.cjs +3 -3
- package/web/dist/web.js +83 -617
- package/web/types/client.d.ts +2 -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/dist/server.cjs
CHANGED
|
@@ -113,23 +113,22 @@ function renderToStream(code, options = {}) {
|
|
|
113
113
|
timer = setTimeout(writeTasks);
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
116
|
+
const onDone = () => {
|
|
117
|
+
writeTasks();
|
|
118
|
+
doShell();
|
|
119
|
+
onCompleteAll && onCompleteAll({
|
|
120
|
+
write(v) {
|
|
121
|
+
!completed && buffer.write(v);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
writable && writable.end();
|
|
125
|
+
completed = true;
|
|
126
|
+
if (firstFlushed) dispose();
|
|
128
127
|
};
|
|
129
128
|
const serializer = createSerializer({
|
|
130
129
|
scopeId: options.renderId,
|
|
131
130
|
onData: pushTask,
|
|
132
|
-
onDone
|
|
131
|
+
onDone,
|
|
133
132
|
onError: options.onError
|
|
134
133
|
});
|
|
135
134
|
const flushEnd = () => {
|
|
@@ -152,6 +151,7 @@ function renderToStream(code, options = {}) {
|
|
|
152
151
|
let tasks = "";
|
|
153
152
|
let firstFlushed = false;
|
|
154
153
|
let completed = false;
|
|
154
|
+
let shellCompleted = false;
|
|
155
155
|
let scriptFlushed = false;
|
|
156
156
|
let timer = null;
|
|
157
157
|
let buffer = {
|
|
@@ -237,6 +237,7 @@ function renderToStream(code, options = {}) {
|
|
|
237
237
|
return resolveSSRNode(escape(code()));
|
|
238
238
|
});
|
|
239
239
|
function doShell() {
|
|
240
|
+
if (shellCompleted) return;
|
|
240
241
|
solidJs.sharedConfig.context = context;
|
|
241
242
|
context.noHydrate = true;
|
|
242
243
|
html = injectAssets(context.assets, html);
|
|
@@ -248,11 +249,12 @@ function renderToStream(code, options = {}) {
|
|
|
248
249
|
!completed && buffer.write(v);
|
|
249
250
|
}
|
|
250
251
|
});
|
|
252
|
+
shellCompleted = true;
|
|
251
253
|
}
|
|
252
254
|
return {
|
|
253
255
|
then(fn) {
|
|
254
256
|
function complete() {
|
|
255
|
-
|
|
257
|
+
dispose();
|
|
256
258
|
fn(tmp);
|
|
257
259
|
}
|
|
258
260
|
if (onCompleteAll) {
|
|
@@ -262,7 +264,7 @@ function renderToStream(code, options = {}) {
|
|
|
262
264
|
complete();
|
|
263
265
|
};
|
|
264
266
|
} else onCompleteAll = complete;
|
|
265
|
-
|
|
267
|
+
queue(flushEnd);
|
|
266
268
|
},
|
|
267
269
|
pipe(w) {
|
|
268
270
|
allSettled(blockingPromises).then(() => {
|
|
@@ -271,7 +273,10 @@ function renderToStream(code, options = {}) {
|
|
|
271
273
|
buffer = writable = w;
|
|
272
274
|
buffer.write(tmp);
|
|
273
275
|
firstFlushed = true;
|
|
274
|
-
if (completed)
|
|
276
|
+
if (completed) {
|
|
277
|
+
dispose();
|
|
278
|
+
writable.end();
|
|
279
|
+
} else flushEnd();
|
|
275
280
|
});
|
|
276
281
|
});
|
|
277
282
|
},
|
|
@@ -297,7 +302,10 @@ function renderToStream(code, options = {}) {
|
|
|
297
302
|
};
|
|
298
303
|
buffer.write(tmp);
|
|
299
304
|
firstFlushed = true;
|
|
300
|
-
if (completed)
|
|
305
|
+
if (completed) {
|
|
306
|
+
dispose();
|
|
307
|
+
writable.end();
|
|
308
|
+
} else flushEnd();
|
|
301
309
|
});
|
|
302
310
|
return p;
|
|
303
311
|
});
|
package/web/dist/server.js
CHANGED
|
@@ -1,86 +1,31 @@
|
|
|
1
|
-
import { sharedConfig, createRoot, splitProps } from
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Index,
|
|
6
|
-
Match,
|
|
7
|
-
Show,
|
|
8
|
-
Suspense,
|
|
9
|
-
SuspenseList,
|
|
10
|
-
Switch,
|
|
11
|
-
createComponent,
|
|
12
|
-
mergeProps
|
|
13
|
-
} from "solid-js";
|
|
14
|
-
import { Feature, Serializer, getCrossReferenceHeader } from "seroval";
|
|
15
|
-
import {
|
|
16
|
-
CustomEventPlugin,
|
|
17
|
-
DOMExceptionPlugin,
|
|
18
|
-
EventPlugin,
|
|
19
|
-
FormDataPlugin,
|
|
20
|
-
HeadersPlugin,
|
|
21
|
-
ReadableStreamPlugin,
|
|
22
|
-
RequestPlugin,
|
|
23
|
-
ResponsePlugin,
|
|
24
|
-
URLSearchParamsPlugin,
|
|
25
|
-
URLPlugin
|
|
26
|
-
} from "seroval-plugins/web";
|
|
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, getCrossReferenceHeader } from 'seroval';
|
|
4
|
+
import { CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
27
5
|
|
|
28
|
-
const booleans = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"autoplay",
|
|
33
|
-
"checked",
|
|
34
|
-
"controls",
|
|
35
|
-
"default",
|
|
36
|
-
"disabled",
|
|
37
|
-
"formnovalidate",
|
|
38
|
-
"hidden",
|
|
39
|
-
"indeterminate",
|
|
40
|
-
"inert",
|
|
41
|
-
"ismap",
|
|
42
|
-
"loop",
|
|
43
|
-
"multiple",
|
|
44
|
-
"muted",
|
|
45
|
-
"nomodule",
|
|
46
|
-
"novalidate",
|
|
47
|
-
"open",
|
|
48
|
-
"playsinline",
|
|
49
|
-
"readonly",
|
|
50
|
-
"required",
|
|
51
|
-
"reversed",
|
|
52
|
-
"seamless",
|
|
53
|
-
"selected"
|
|
54
|
-
];
|
|
55
|
-
const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
|
|
56
|
-
const ChildProperties = /*#__PURE__*/ new Set([
|
|
57
|
-
"innerHTML",
|
|
58
|
-
"textContent",
|
|
59
|
-
"innerText",
|
|
60
|
-
"children"
|
|
61
|
-
]);
|
|
62
|
-
const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
|
|
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
|
+
const BooleanAttributes = /*#__PURE__*/new Set(booleans);
|
|
8
|
+
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
9
|
+
const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
63
10
|
className: "class",
|
|
64
11
|
htmlFor: "for"
|
|
65
12
|
});
|
|
66
13
|
|
|
67
|
-
const ES2017FLAG = Feature.AggregateError
|
|
68
|
-
|
|
69
|
-
|
|
14
|
+
const ES2017FLAG = Feature.AggregateError
|
|
15
|
+
| Feature.BigInt
|
|
16
|
+
| Feature.BigIntTypedArray;
|
|
17
|
+
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
18
|
+
function createSerializer({
|
|
19
|
+
onData,
|
|
20
|
+
onDone,
|
|
21
|
+
scopeId,
|
|
22
|
+
onError
|
|
23
|
+
}) {
|
|
70
24
|
return new Serializer({
|
|
71
25
|
scopeId,
|
|
72
26
|
plugins: [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
EventPlugin,
|
|
76
|
-
FormDataPlugin,
|
|
77
|
-
HeadersPlugin,
|
|
78
|
-
ReadableStreamPlugin,
|
|
79
|
-
RequestPlugin,
|
|
80
|
-
ResponsePlugin,
|
|
81
|
-
URLSearchParamsPlugin,
|
|
82
|
-
URLPlugin
|
|
83
|
-
],
|
|
27
|
+
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
28
|
+
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin],
|
|
84
29
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
85
30
|
disabledFeatures: ES2017FLAG,
|
|
86
31
|
onData,
|
|
@@ -89,14 +34,15 @@ function createSerializer({ onData, onDone, scopeId, onError }) {
|
|
|
89
34
|
});
|
|
90
35
|
}
|
|
91
36
|
function getLocalHeaderScript(id) {
|
|
92
|
-
return getCrossReferenceHeader(id) +
|
|
37
|
+
return getCrossReferenceHeader(id) + ';';
|
|
93
38
|
}
|
|
94
39
|
|
|
95
|
-
const VOID_ELEMENTS =
|
|
96
|
-
/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
40
|
+
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
97
41
|
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)}`;
|
|
98
42
|
function renderToString(code, options = {}) {
|
|
99
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
renderId
|
|
45
|
+
} = options;
|
|
100
46
|
let scripts = "";
|
|
101
47
|
const serializer = createSerializer({
|
|
102
48
|
scopeId: renderId,
|
|
@@ -134,7 +80,9 @@ function renderToString(code, options = {}) {
|
|
|
134
80
|
return html;
|
|
135
81
|
}
|
|
136
82
|
function renderToStringAsync(code, options = {}) {
|
|
137
|
-
const {
|
|
83
|
+
const {
|
|
84
|
+
timeoutMs = 30000
|
|
85
|
+
} = options;
|
|
138
86
|
let timeoutHandle;
|
|
139
87
|
const timeout = new Promise((_, reject) => {
|
|
140
88
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -145,7 +93,13 @@ function renderToStringAsync(code, options = {}) {
|
|
|
145
93
|
});
|
|
146
94
|
}
|
|
147
95
|
function renderToStream(code, options = {}) {
|
|
148
|
-
let {
|
|
96
|
+
let {
|
|
97
|
+
nonce,
|
|
98
|
+
onCompleteShell,
|
|
99
|
+
onCompleteAll,
|
|
100
|
+
renderId,
|
|
101
|
+
noScripts
|
|
102
|
+
} = options;
|
|
149
103
|
let dispose;
|
|
150
104
|
const blockingPromises = [];
|
|
151
105
|
const pushTask = task => {
|
|
@@ -158,24 +112,22 @@ function renderToStream(code, options = {}) {
|
|
|
158
112
|
timer = setTimeout(writeTasks);
|
|
159
113
|
}
|
|
160
114
|
};
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
setTimeout(dispose);
|
|
173
|
-
}
|
|
115
|
+
const onDone = () => {
|
|
116
|
+
writeTasks();
|
|
117
|
+
doShell();
|
|
118
|
+
onCompleteAll && onCompleteAll({
|
|
119
|
+
write(v) {
|
|
120
|
+
!completed && buffer.write(v);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
writable && writable.end();
|
|
124
|
+
completed = true;
|
|
125
|
+
if (firstFlushed) dispose();
|
|
174
126
|
};
|
|
175
127
|
const serializer = createSerializer({
|
|
176
128
|
scopeId: options.renderId,
|
|
177
129
|
onData: pushTask,
|
|
178
|
-
onDone
|
|
130
|
+
onDone,
|
|
179
131
|
onError: options.onError
|
|
180
132
|
});
|
|
181
133
|
const flushEnd = () => {
|
|
@@ -198,6 +150,7 @@ function renderToStream(code, options = {}) {
|
|
|
198
150
|
let tasks = "";
|
|
199
151
|
let firstFlushed = false;
|
|
200
152
|
let completed = false;
|
|
153
|
+
let shellCompleted = false;
|
|
201
154
|
let scriptFlushed = false;
|
|
202
155
|
let timer = null;
|
|
203
156
|
let buffer = {
|
|
@@ -223,23 +176,17 @@ function renderToStream(code, options = {}) {
|
|
|
223
176
|
const first = html.indexOf(placeholder);
|
|
224
177
|
if (first === -1) return;
|
|
225
178
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
226
|
-
html = html.replace(
|
|
227
|
-
html.slice(first, last + placeholder.length + 1),
|
|
228
|
-
resolveSSRNode(payloadFn())
|
|
229
|
-
);
|
|
179
|
+
html = html.replace(html.slice(first, last + placeholder.length + 1), resolveSSRNode(payloadFn()));
|
|
230
180
|
},
|
|
231
181
|
serialize(id, p, wait) {
|
|
232
182
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
233
183
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
234
184
|
blockingPromises.push(p);
|
|
235
|
-
!serverOnly &&
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
.catch(e => {
|
|
241
|
-
serializer.write(id, e);
|
|
242
|
-
});
|
|
185
|
+
!serverOnly && p.then(d => {
|
|
186
|
+
serializer.write(id, d);
|
|
187
|
+
}).catch(e => {
|
|
188
|
+
serializer.write(id, e);
|
|
189
|
+
});
|
|
243
190
|
} else if (!serverOnly) serializer.write(id, p);
|
|
244
191
|
},
|
|
245
192
|
roots: 0,
|
|
@@ -249,7 +196,7 @@ function renderToStream(code, options = {}) {
|
|
|
249
196
|
registerFragment(key) {
|
|
250
197
|
if (!registry.has(key)) {
|
|
251
198
|
let resolve, reject;
|
|
252
|
-
const p = new Promise((r, rej) => (
|
|
199
|
+
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
253
200
|
registry.set(key, {
|
|
254
201
|
resolve: v => queue(() => queue(() => resolve(v))),
|
|
255
202
|
reject: e => queue(() => queue(() => reject(e)))
|
|
@@ -258,7 +205,10 @@ function renderToStream(code, options = {}) {
|
|
|
258
205
|
}
|
|
259
206
|
return (value, error) => {
|
|
260
207
|
if (registry.has(key)) {
|
|
261
|
-
const {
|
|
208
|
+
const {
|
|
209
|
+
resolve,
|
|
210
|
+
reject
|
|
211
|
+
} = registry.get(key);
|
|
262
212
|
registry.delete(key);
|
|
263
213
|
if (waitForFragments(registry, key)) {
|
|
264
214
|
resolve(true);
|
|
@@ -266,7 +216,7 @@ function renderToStream(code, options = {}) {
|
|
|
266
216
|
}
|
|
267
217
|
if ((value !== undefined || error) && !completed) {
|
|
268
218
|
if (!firstFlushed) {
|
|
269
|
-
queue(() =>
|
|
219
|
+
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
270
220
|
error ? reject(error) : resolve(true);
|
|
271
221
|
} else {
|
|
272
222
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -286,23 +236,24 @@ function renderToStream(code, options = {}) {
|
|
|
286
236
|
return resolveSSRNode(escape(code()));
|
|
287
237
|
});
|
|
288
238
|
function doShell() {
|
|
239
|
+
if (shellCompleted) return;
|
|
289
240
|
sharedConfig.context = context;
|
|
290
241
|
context.noHydrate = true;
|
|
291
242
|
html = injectAssets(context.assets, html);
|
|
292
243
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
293
244
|
buffer.write(html);
|
|
294
245
|
tasks = "";
|
|
295
|
-
onCompleteShell &&
|
|
296
|
-
|
|
297
|
-
write(v)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
246
|
+
onCompleteShell && onCompleteShell({
|
|
247
|
+
write(v) {
|
|
248
|
+
!completed && buffer.write(v);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
shellCompleted = true;
|
|
301
252
|
}
|
|
302
253
|
return {
|
|
303
254
|
then(fn) {
|
|
304
255
|
function complete() {
|
|
305
|
-
|
|
256
|
+
dispose();
|
|
306
257
|
fn(tmp);
|
|
307
258
|
}
|
|
308
259
|
if (onCompleteAll) {
|
|
@@ -312,7 +263,7 @@ function renderToStream(code, options = {}) {
|
|
|
312
263
|
complete();
|
|
313
264
|
};
|
|
314
265
|
} else onCompleteAll = complete;
|
|
315
|
-
|
|
266
|
+
queue(flushEnd);
|
|
316
267
|
},
|
|
317
268
|
pipe(w) {
|
|
318
269
|
allSettled(blockingPromises).then(() => {
|
|
@@ -321,15 +272,17 @@ function renderToStream(code, options = {}) {
|
|
|
321
272
|
buffer = writable = w;
|
|
322
273
|
buffer.write(tmp);
|
|
323
274
|
firstFlushed = true;
|
|
324
|
-
if (completed)
|
|
325
|
-
|
|
275
|
+
if (completed) {
|
|
276
|
+
dispose();
|
|
277
|
+
writable.end();
|
|
278
|
+
} else flushEnd();
|
|
326
279
|
});
|
|
327
280
|
});
|
|
328
281
|
},
|
|
329
282
|
pipeTo(w) {
|
|
330
283
|
return allSettled(blockingPromises).then(() => {
|
|
331
284
|
let resolve;
|
|
332
|
-
const p = new Promise(r =>
|
|
285
|
+
const p = new Promise(r => resolve = r);
|
|
333
286
|
setTimeout(() => {
|
|
334
287
|
doShell();
|
|
335
288
|
const encoder = new TextEncoder();
|
|
@@ -348,8 +301,10 @@ function renderToStream(code, options = {}) {
|
|
|
348
301
|
};
|
|
349
302
|
buffer.write(tmp);
|
|
350
303
|
firstFlushed = true;
|
|
351
|
-
if (completed)
|
|
352
|
-
|
|
304
|
+
if (completed) {
|
|
305
|
+
dispose();
|
|
306
|
+
writable.end();
|
|
307
|
+
} else flushEnd();
|
|
353
308
|
});
|
|
354
309
|
return p;
|
|
355
310
|
});
|
|
@@ -357,13 +312,13 @@ function renderToStream(code, options = {}) {
|
|
|
357
312
|
};
|
|
358
313
|
}
|
|
359
314
|
function HydrationScript(props) {
|
|
360
|
-
const {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
);
|
|
315
|
+
const {
|
|
316
|
+
nonce
|
|
317
|
+
} = sharedConfig.context;
|
|
318
|
+
return ssr(generateHydrationScript({
|
|
319
|
+
nonce,
|
|
320
|
+
...props
|
|
321
|
+
}));
|
|
367
322
|
}
|
|
368
323
|
function ssr(t, ...nodes) {
|
|
369
324
|
if (nodes.length) {
|
|
@@ -408,8 +363,7 @@ function ssrStyle(value) {
|
|
|
408
363
|
return result;
|
|
409
364
|
}
|
|
410
365
|
function ssrElement(tag, props, children, needsId) {
|
|
411
|
-
if (props == null) props = {};
|
|
412
|
-
else if (typeof props === "function") props = props();
|
|
366
|
+
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
413
367
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
414
368
|
const keys = Object.keys(props);
|
|
415
369
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -417,8 +371,7 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
417
371
|
for (let i = 0; i < keys.length; i++) {
|
|
418
372
|
const prop = keys[i];
|
|
419
373
|
if (ChildProperties.has(prop)) {
|
|
420
|
-
if (children === undefined && !skipChildren)
|
|
421
|
-
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
374
|
+
if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
422
375
|
continue;
|
|
423
376
|
}
|
|
424
377
|
const value = props[prop];
|
|
@@ -427,14 +380,10 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
427
380
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
428
381
|
if (classResolved) continue;
|
|
429
382
|
let n;
|
|
430
|
-
result += `class="${
|
|
431
|
-
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
432
|
-
ssrClassList(props.classList)
|
|
433
|
-
}"`;
|
|
383
|
+
result += `class="${escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) + ssrClassList(props.classList)}"`;
|
|
434
384
|
classResolved = true;
|
|
435
385
|
} else if (BooleanAttributes.has(prop)) {
|
|
436
|
-
if (value) result += prop;
|
|
437
|
-
else continue;
|
|
386
|
+
if (value) result += prop;else continue;
|
|
438
387
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
439
388
|
continue;
|
|
440
389
|
} else {
|
|
@@ -442,17 +391,16 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
442
391
|
}
|
|
443
392
|
if (i !== keys.length - 1) result += " ";
|
|
444
393
|
}
|
|
445
|
-
if (skipChildren)
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
};
|
|
394
|
+
if (skipChildren) return {
|
|
395
|
+
t: result + "/>"
|
|
396
|
+
};
|
|
449
397
|
if (typeof children === "function") children = children();
|
|
450
398
|
return {
|
|
451
399
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
452
400
|
};
|
|
453
401
|
}
|
|
454
402
|
function ssrAttribute(key, value, isBoolean) {
|
|
455
|
-
return isBoolean ?
|
|
403
|
+
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
456
404
|
}
|
|
457
405
|
function ssrHydrationKey() {
|
|
458
406
|
const hk = getHydrationKey();
|
|
@@ -496,13 +444,12 @@ function escape(s, attr) {
|
|
|
496
444
|
left = iDelim + 1;
|
|
497
445
|
iDelim = s.indexOf(delim, left);
|
|
498
446
|
} while (iDelim >= 0);
|
|
499
|
-
} else
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
447
|
+
} else while (iAmp >= 0) {
|
|
448
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
449
|
+
out += "&";
|
|
450
|
+
left = iAmp + 1;
|
|
451
|
+
iAmp = s.indexOf("&", left);
|
|
452
|
+
}
|
|
506
453
|
return left < s.length ? out + s.substring(left) : out;
|
|
507
454
|
}
|
|
508
455
|
function resolveSSRNode(node, top) {
|
|
@@ -514,7 +461,7 @@ function resolveSSRNode(node, top) {
|
|
|
514
461
|
let mapped = "";
|
|
515
462
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
516
463
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
517
|
-
mapped += resolveSSRNode(
|
|
464
|
+
mapped += resolveSSRNode(prev = node[i]);
|
|
518
465
|
}
|
|
519
466
|
return mapped;
|
|
520
467
|
}
|
|
@@ -535,12 +482,11 @@ function getAssets() {
|
|
|
535
482
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
536
483
|
return out;
|
|
537
484
|
}
|
|
538
|
-
function generateHydrationScript({
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
)}"].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-->`;
|
|
485
|
+
function generateHydrationScript({
|
|
486
|
+
eventNames = ["click", "input"],
|
|
487
|
+
nonce
|
|
488
|
+
} = {}) {
|
|
489
|
+
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-->`;
|
|
544
490
|
}
|
|
545
491
|
function Hydration(props) {
|
|
546
492
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -599,20 +545,16 @@ function replacePlaceholder(html, key, value) {
|
|
|
599
545
|
}
|
|
600
546
|
const RequestContext = Symbol();
|
|
601
547
|
function getRequestEvent() {
|
|
602
|
-
return globalThis[RequestContext]
|
|
603
|
-
? globalThis[RequestContext].getStore() ||
|
|
604
|
-
(sharedConfig.context && sharedConfig.context.event) ||
|
|
605
|
-
console.log(
|
|
606
|
-
"RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls."
|
|
607
|
-
)
|
|
608
|
-
: undefined;
|
|
548
|
+
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.log("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
|
|
609
549
|
}
|
|
610
550
|
function Assets(props) {
|
|
611
551
|
useAssets(() => props.children);
|
|
612
552
|
}
|
|
613
553
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
614
554
|
if (options.onReady) {
|
|
615
|
-
options.onCompleteShell = ({
|
|
555
|
+
options.onCompleteShell = ({
|
|
556
|
+
write
|
|
557
|
+
}) => {
|
|
616
558
|
options.onReady({
|
|
617
559
|
write,
|
|
618
560
|
startWriting() {
|
|
@@ -626,7 +568,9 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
626
568
|
}
|
|
627
569
|
function pipeToWritable(code, writable, options = {}) {
|
|
628
570
|
if (options.onReady) {
|
|
629
|
-
options.onCompleteShell = ({
|
|
571
|
+
options.onCompleteShell = ({
|
|
572
|
+
write
|
|
573
|
+
}) => {
|
|
630
574
|
options.onReady({
|
|
631
575
|
write,
|
|
632
576
|
startWriting() {
|
|
@@ -656,19 +600,11 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
656
600
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
657
601
|
if (classResolved) continue;
|
|
658
602
|
let n;
|
|
659
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
660
|
-
(n = props.className) ? n + " " : ""
|
|
661
|
-
}${ssrClassList(props.classList)}"`;
|
|
603
|
+
result += `class="${(n = props.class) ? n + " " : ""}${(n = props.className) ? n + " " : ""}${ssrClassList(props.classList)}"`;
|
|
662
604
|
classResolved = true;
|
|
663
605
|
} else if (BooleanAttributes.has(prop)) {
|
|
664
|
-
if (value) result += prop;
|
|
665
|
-
|
|
666
|
-
} else if (
|
|
667
|
-
value == undefined ||
|
|
668
|
-
prop === "ref" ||
|
|
669
|
-
prop.slice(0, 2) === "on" ||
|
|
670
|
-
prop.slice(0, 5) === "prop:"
|
|
671
|
-
) {
|
|
606
|
+
if (value) result += prop;else continue;
|
|
607
|
+
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
|
|
672
608
|
continue;
|
|
673
609
|
} else {
|
|
674
610
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -692,8 +628,7 @@ function Dynamic(props) {
|
|
|
692
628
|
const comp = p.component,
|
|
693
629
|
t = typeof comp;
|
|
694
630
|
if (comp) {
|
|
695
|
-
if (t === "function") return comp(others);
|
|
696
|
-
else if (t === "string") {
|
|
631
|
+
if (t === "function") return comp(others);else if (t === "string") {
|
|
697
632
|
return ssrElement(comp, others, undefined, true);
|
|
698
633
|
}
|
|
699
634
|
}
|
|
@@ -702,39 +637,4 @@ function Portal(props) {
|
|
|
702
637
|
return "";
|
|
703
638
|
}
|
|
704
639
|
|
|
705
|
-
export {
|
|
706
|
-
Assets,
|
|
707
|
-
Dynamic,
|
|
708
|
-
Hydration,
|
|
709
|
-
HydrationScript,
|
|
710
|
-
NoHydration,
|
|
711
|
-
Portal,
|
|
712
|
-
RequestContext,
|
|
713
|
-
addEventListener,
|
|
714
|
-
delegateEvents,
|
|
715
|
-
escape,
|
|
716
|
-
generateHydrationScript,
|
|
717
|
-
getAssets,
|
|
718
|
-
getHydrationKey,
|
|
719
|
-
getRequestEvent,
|
|
720
|
-
hydrate,
|
|
721
|
-
insert,
|
|
722
|
-
isDev,
|
|
723
|
-
isServer,
|
|
724
|
-
pipeToNodeWritable,
|
|
725
|
-
pipeToWritable,
|
|
726
|
-
render,
|
|
727
|
-
renderToStream,
|
|
728
|
-
renderToString,
|
|
729
|
-
renderToStringAsync,
|
|
730
|
-
resolveSSRNode,
|
|
731
|
-
spread,
|
|
732
|
-
ssr,
|
|
733
|
-
ssrAttribute,
|
|
734
|
-
ssrClassList,
|
|
735
|
-
ssrElement,
|
|
736
|
-
ssrHydrationKey,
|
|
737
|
-
ssrSpread,
|
|
738
|
-
ssrStyle,
|
|
739
|
-
useAssets
|
|
740
|
-
};
|
|
640
|
+
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 };
|
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 =
|
|
6
|
+
const ctx = globalThis[RequestContext] = globalThis[RequestContext] || new AsyncLocalStorage();
|
|
7
7
|
return ctx.run(init, cb);
|
|
8
8
|
}
|
|
9
9
|
|