solid-js 1.7.11 → 1.8.0-beta.0
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 +16 -13
- package/dist/dev.js +544 -306
- package/dist/server.cjs +7 -6
- package/dist/server.js +175 -80
- package/dist/solid.cjs +16 -13
- package/dist/solid.js +471 -264
- 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 +1 -0
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +45 -31
- package/package.json +2 -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 +72 -9
- package/types/jsx.d.ts +2 -1
- 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 +12 -12
- package/types/server/index.d.ts +56 -2
- package/types/server/reactive.d.ts +67 -40
- 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 +8 -5
- package/web/dist/dev.js +616 -82
- package/web/dist/server.cjs +91 -56
- package/web/dist/server.js +244 -125
- package/web/dist/web.cjs +8 -5
- package/web/dist/web.js +616 -82
- 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
|
@@ -14,27 +14,52 @@ const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
|
14
14
|
const ES2017FLAG = seroval.Feature.AggregateError
|
|
15
15
|
| seroval.Feature.BigInt
|
|
16
16
|
| seroval.Feature.BigIntTypedArray;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
18
|
+
function createSerializer({
|
|
19
|
+
onData,
|
|
20
|
+
onDone,
|
|
21
|
+
scopeId
|
|
22
|
+
}) {
|
|
23
|
+
return new seroval.Serializer({
|
|
24
|
+
scopeId,
|
|
25
|
+
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
26
|
+
disabledFeatures: ES2017FLAG,
|
|
27
|
+
onData,
|
|
28
|
+
onDone
|
|
20
29
|
});
|
|
21
30
|
}
|
|
31
|
+
function getGlobalHeaderScript() {
|
|
32
|
+
return seroval.GLOBAL_CONTEXT_API_SCRIPT;
|
|
33
|
+
}
|
|
34
|
+
function getLocalHeaderScript(id) {
|
|
35
|
+
return seroval.getCrossReferenceHeader(id);
|
|
36
|
+
}
|
|
22
37
|
|
|
23
38
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
24
|
-
const REPLACE_SCRIPT = `function $df(e,n,
|
|
39
|
+
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)}`;
|
|
25
40
|
function renderToString(code, options = {}) {
|
|
41
|
+
const {
|
|
42
|
+
renderId
|
|
43
|
+
} = options;
|
|
26
44
|
let scripts = "";
|
|
45
|
+
const serializer = createSerializer({
|
|
46
|
+
scopeId: renderId,
|
|
47
|
+
onData(script) {
|
|
48
|
+
if (!scripts) {
|
|
49
|
+
scripts = getLocalHeaderScript(renderId);
|
|
50
|
+
}
|
|
51
|
+
scripts += script;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
27
54
|
solidJs.sharedConfig.context = {
|
|
28
|
-
id:
|
|
55
|
+
id: renderId || "",
|
|
29
56
|
count: 0,
|
|
30
57
|
suspense: {},
|
|
31
58
|
lazy: {},
|
|
32
59
|
assets: [],
|
|
33
60
|
nonce: options.nonce,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (error) return scripts += `_$HY.set("${id}", ${stringify(p)});`;
|
|
37
|
-
scripts += `_$HY.set("${id}", ${stringify(p)});`;
|
|
61
|
+
serialize(id, p) {
|
|
62
|
+
!solidJs.sharedConfig.context.noHydrate && serializer.write(id, p);
|
|
38
63
|
}
|
|
39
64
|
};
|
|
40
65
|
let html = solidJs.createRoot(d => {
|
|
@@ -42,6 +67,7 @@ function renderToString(code, options = {}) {
|
|
|
42
67
|
return resolveSSRNode(escape(code()));
|
|
43
68
|
});
|
|
44
69
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
70
|
+
serializer.close();
|
|
45
71
|
html = injectAssets(solidJs.sharedConfig.context.assets, html);
|
|
46
72
|
if (scripts.length) html = injectScripts(html, scripts, options.nonce);
|
|
47
73
|
return html;
|
|
@@ -67,9 +93,17 @@ function renderToStream(code, options = {}) {
|
|
|
67
93
|
renderId
|
|
68
94
|
} = options;
|
|
69
95
|
let dispose;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
96
|
+
const blockingPromises = [];
|
|
97
|
+
const pushTask = task => {
|
|
98
|
+
if (!tasks && !firstFlushed) {
|
|
99
|
+
tasks = getLocalHeaderScript(renderId);
|
|
100
|
+
}
|
|
101
|
+
tasks += task + ";";
|
|
102
|
+
if (!scheduled && firstFlushed) {
|
|
103
|
+
Promise.resolve().then(writeTasks);
|
|
104
|
+
scheduled = true;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
73
107
|
const checkEnd = () => {
|
|
74
108
|
if (!registry.size && !completed) {
|
|
75
109
|
writeTasks();
|
|
@@ -83,13 +117,17 @@ function renderToStream(code, options = {}) {
|
|
|
83
117
|
setTimeout(dispose);
|
|
84
118
|
}
|
|
85
119
|
};
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
120
|
+
const serializer = createSerializer({
|
|
121
|
+
scopeId: options.renderId,
|
|
122
|
+
onData: pushTask,
|
|
123
|
+
onDone: checkEnd
|
|
124
|
+
});
|
|
125
|
+
const flushEnd = () => {
|
|
126
|
+
if (!registry.size) {
|
|
127
|
+
serializer.flush();
|
|
91
128
|
}
|
|
92
129
|
};
|
|
130
|
+
const registry = new Map();
|
|
93
131
|
const writeTasks = () => {
|
|
94
132
|
if (tasks.length && !completed && firstFlushed) {
|
|
95
133
|
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks}</script>`);
|
|
@@ -120,7 +158,7 @@ function renderToStream(code, options = {}) {
|
|
|
120
158
|
assets: [],
|
|
121
159
|
nonce,
|
|
122
160
|
block(p) {
|
|
123
|
-
if (!firstFlushed)
|
|
161
|
+
if (!firstFlushed) blockingPromises.push(p);
|
|
124
162
|
},
|
|
125
163
|
replace(id, payloadFn) {
|
|
126
164
|
if (firstFlushed) return;
|
|
@@ -130,40 +168,51 @@ function renderToStream(code, options = {}) {
|
|
|
130
168
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
131
169
|
html = html.replace(html.slice(first, last + placeholder.length + 1), resolveSSRNode(payloadFn()));
|
|
132
170
|
},
|
|
133
|
-
|
|
171
|
+
serialize(id, p, wait) {
|
|
134
172
|
const serverOnly = solidJs.sharedConfig.context.noHydrate;
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
173
|
+
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
174
|
+
blockingPromises.push(p);
|
|
175
|
+
!serverOnly && p.then(d => {
|
|
176
|
+
serializer.write(id, d);
|
|
177
|
+
}).catch(e => {
|
|
178
|
+
serializer.write(id, e);
|
|
179
|
+
});
|
|
180
|
+
} else if (!serverOnly) serializer.write(id, p);
|
|
144
181
|
},
|
|
145
182
|
registerFragment(key) {
|
|
146
183
|
if (!registry.has(key)) {
|
|
147
|
-
|
|
148
|
-
|
|
184
|
+
let resolve, reject;
|
|
185
|
+
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
186
|
+
registry.set(key, {
|
|
187
|
+
resolve,
|
|
188
|
+
reject
|
|
189
|
+
});
|
|
190
|
+
serializer.write(key, p);
|
|
149
191
|
}
|
|
150
192
|
return (value, error) => {
|
|
151
193
|
if (registry.has(key)) {
|
|
152
|
-
const
|
|
194
|
+
const {
|
|
195
|
+
resolve,
|
|
196
|
+
reject
|
|
197
|
+
} = registry.get(key);
|
|
153
198
|
registry.delete(key);
|
|
154
|
-
if (waitForFragments(registry, key))
|
|
199
|
+
if (waitForFragments(registry, key)) {
|
|
200
|
+
resolve(true);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
155
203
|
if ((value !== undefined || error) && !completed) {
|
|
156
204
|
if (!firstFlushed) {
|
|
157
205
|
Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
158
|
-
error
|
|
206
|
+
error ? reject(error) : resolve(true);
|
|
159
207
|
} else {
|
|
160
208
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
161
|
-
pushTask(`$
|
|
209
|
+
pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
210
|
+
resolve(true);
|
|
162
211
|
scriptFlushed = true;
|
|
163
212
|
}
|
|
164
213
|
}
|
|
165
214
|
}
|
|
166
|
-
if (!registry.size) Promise.resolve().then(
|
|
215
|
+
if (!registry.size) Promise.resolve().then(flushEnd);
|
|
167
216
|
return firstFlushed;
|
|
168
217
|
};
|
|
169
218
|
}
|
|
@@ -176,10 +225,6 @@ function renderToStream(code, options = {}) {
|
|
|
176
225
|
solidJs.sharedConfig.context = context;
|
|
177
226
|
context.noHydrate = true;
|
|
178
227
|
html = injectAssets(context.assets, html);
|
|
179
|
-
for (const key in context.resources) {
|
|
180
|
-
if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
|
|
181
|
-
}
|
|
182
|
-
for (const key of registry.keys()) pushTask(`_$HY.init("${key}")`);
|
|
183
228
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
184
229
|
buffer.write(html);
|
|
185
230
|
tasks = "";
|
|
@@ -203,19 +248,19 @@ function renderToStream(code, options = {}) {
|
|
|
203
248
|
complete();
|
|
204
249
|
};
|
|
205
250
|
} else onCompleteAll = complete;
|
|
206
|
-
if (!registry.size) Promise.resolve().then(
|
|
251
|
+
if (!registry.size) Promise.resolve().then(flushEnd);
|
|
207
252
|
},
|
|
208
253
|
pipe(w) {
|
|
209
|
-
Promise.allSettled(
|
|
254
|
+
Promise.allSettled(blockingPromises).then(() => {
|
|
210
255
|
doShell();
|
|
211
256
|
buffer = writable = w;
|
|
212
257
|
buffer.write(tmp);
|
|
213
258
|
firstFlushed = true;
|
|
214
|
-
if (completed) writable.end();else setTimeout(
|
|
259
|
+
if (completed) writable.end();else setTimeout(flushEnd);
|
|
215
260
|
});
|
|
216
261
|
},
|
|
217
262
|
pipeTo(w) {
|
|
218
|
-
return Promise.allSettled(
|
|
263
|
+
return Promise.allSettled(blockingPromises).then(() => {
|
|
219
264
|
doShell();
|
|
220
265
|
const encoder = new TextEncoder();
|
|
221
266
|
const writer = w.getWriter();
|
|
@@ -235,7 +280,7 @@ function renderToStream(code, options = {}) {
|
|
|
235
280
|
};
|
|
236
281
|
buffer.write(tmp);
|
|
237
282
|
firstFlushed = true;
|
|
238
|
-
if (completed) writable.end();else setTimeout(
|
|
283
|
+
if (completed) writable.end();else setTimeout(flushEnd);
|
|
239
284
|
return p;
|
|
240
285
|
});
|
|
241
286
|
}
|
|
@@ -416,7 +461,7 @@ function generateHydrationScript({
|
|
|
416
461
|
eventNames = ["click", "input"],
|
|
417
462
|
nonce
|
|
418
463
|
} = {}) {
|
|
419
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>(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
|
|
464
|
+
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-->`;
|
|
420
465
|
}
|
|
421
466
|
function Hydration(props) {
|
|
422
467
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
@@ -451,19 +496,10 @@ function injectScripts(html, scripts, nonce) {
|
|
|
451
496
|
}
|
|
452
497
|
function waitForFragments(registry, key) {
|
|
453
498
|
for (const k of [...registry.keys()].reverse()) {
|
|
454
|
-
if (key.startsWith(k))
|
|
455
|
-
registry.get(k).push(key);
|
|
456
|
-
return true;
|
|
457
|
-
}
|
|
499
|
+
if (key.startsWith(k)) return true;
|
|
458
500
|
}
|
|
459
501
|
return false;
|
|
460
502
|
}
|
|
461
|
-
function serializeSet(registry, key, value) {
|
|
462
|
-
const exist = registry.get(value);
|
|
463
|
-
if (exist) return `_$HY.set("${key}", _$HY.r["${exist}"][0])`;
|
|
464
|
-
value !== null && typeof value === "object" && registry.set(value, key);
|
|
465
|
-
return `_$HY.set("${key}", ${stringify(value)})`;
|
|
466
|
-
}
|
|
467
503
|
function replacePlaceholder(html, key, value) {
|
|
468
504
|
const marker = `<template id="pl-${key}">`;
|
|
469
505
|
const close = `<!--pl-${key}-->`;
|
|
@@ -633,5 +669,4 @@ exports.ssrElement = ssrElement;
|
|
|
633
669
|
exports.ssrHydrationKey = ssrHydrationKey;
|
|
634
670
|
exports.ssrSpread = ssrSpread;
|
|
635
671
|
exports.ssrStyle = ssrStyle;
|
|
636
|
-
exports.stringify = stringify;
|
|
637
672
|
exports.useAssets = useAssets;
|