solid-js 1.3.0-beta.2 → 1.3.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/dev.cjs +65 -14
- package/dist/dev.js +64 -15
- package/dist/server.cjs +58 -17
- package/dist/server.js +58 -18
- package/dist/solid.cjs +65 -14
- package/dist/solid.js +64 -15
- package/package.json +27 -15
- package/types/index.d.ts +1 -1
- package/types/reactive/signal.d.ts +7 -0
- package/types/render/component.d.ts +4 -1
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -0
- package/types/server/rendering.d.ts +6 -5
- package/web/dist/dev.cjs +12 -10
- package/web/dist/dev.js +13 -10
- package/web/dist/server.cjs +124 -152
- package/web/dist/server.js +124 -152
- package/web/dist/web.cjs +12 -10
- package/web/dist/web.js +13 -10
- package/web/types/client.d.ts +11 -2
- package/web/types/index.d.ts +2 -0
- package/web/types/server-mock.d.ts +36 -20
package/web/dist/server.js
CHANGED
|
@@ -229,25 +229,32 @@ function stringifyString(str) {
|
|
|
229
229
|
return result;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
const REPLACE_SCRIPT = `function $df(e,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e)}`;
|
|
232
|
+
const REPLACE_SCRIPT = `function $df(e,y,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e,y)}`;
|
|
233
|
+
const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
|
|
233
234
|
function renderToString(code, options = {}) {
|
|
235
|
+
let scripts = "";
|
|
234
236
|
sharedConfig.context = {
|
|
235
|
-
id: "",
|
|
237
|
+
id: options.renderId || "",
|
|
236
238
|
count: 0,
|
|
237
239
|
suspense: {},
|
|
238
240
|
assets: [],
|
|
239
|
-
nonce: options.nonce
|
|
241
|
+
nonce: options.nonce,
|
|
242
|
+
writeResource(id, p, error) {
|
|
243
|
+
if (error) scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
244
|
+
}
|
|
240
245
|
};
|
|
241
|
-
let html = resolveSSRNode(escape(code()));
|
|
242
|
-
|
|
246
|
+
let html = injectAssets(sharedConfig.context.assets, resolveSSRNode(escape(code())));
|
|
247
|
+
if (scripts.length) html = injectScripts(html, scripts, options.nonce);
|
|
248
|
+
return html;
|
|
243
249
|
}
|
|
244
250
|
function renderToStringAsync(code, options = {}) {
|
|
245
251
|
const {
|
|
246
252
|
nonce,
|
|
253
|
+
renderId,
|
|
247
254
|
timeoutMs = 30000
|
|
248
255
|
} = options;
|
|
249
256
|
const context = sharedConfig.context = {
|
|
250
|
-
id: "",
|
|
257
|
+
id: renderId || "",
|
|
251
258
|
count: 0,
|
|
252
259
|
resources: {},
|
|
253
260
|
suspense: {},
|
|
@@ -256,23 +263,56 @@ function renderToStringAsync(code, options = {}) {
|
|
|
256
263
|
nonce
|
|
257
264
|
};
|
|
258
265
|
let scripts = "";
|
|
259
|
-
sharedConfig.context.writeResource = (id, p) =>
|
|
266
|
+
sharedConfig.context.writeResource = (id, p, error) => {
|
|
267
|
+
if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
268
|
+
p.then(d => scripts += `_$HY.set("${id}", ${devalue(d)});`).catch(() => scripts += `_$HY.set("${id}", null);`);
|
|
269
|
+
};
|
|
260
270
|
const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), timeoutMs));
|
|
271
|
+
function asyncWrap(fn) {
|
|
272
|
+
return new Promise(resolve => {
|
|
273
|
+
const registry = new Set();
|
|
274
|
+
const cache = Object.create(null);
|
|
275
|
+
sharedConfig.context.registerFragment = register;
|
|
276
|
+
const rendered = fn();
|
|
277
|
+
if (!registry.size) resolve(rendered);
|
|
278
|
+
function register(key) {
|
|
279
|
+
registry.add(key);
|
|
280
|
+
return (value = "", error) => {
|
|
281
|
+
cache[key] = value;
|
|
282
|
+
registry.delete(key);
|
|
283
|
+
if (error) return scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;
|
|
284
|
+
if (!registry.size) Promise.resolve().then(() => {
|
|
285
|
+
let source = resolveSSRNode(rendered);
|
|
286
|
+
let final = "";
|
|
287
|
+
let match;
|
|
288
|
+
while (match = source.match(FRAGMENT_REPLACE)) {
|
|
289
|
+
final += source.substring(0, match.index);
|
|
290
|
+
source = cache[match[1]] + source.substring(match.index + match[0].length);
|
|
291
|
+
}
|
|
292
|
+
resolve(final + source);
|
|
293
|
+
});
|
|
294
|
+
return true;
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
261
299
|
return Promise.race([asyncWrap(() => escape(code())), timeout]).then(res => {
|
|
262
300
|
let html = injectAssets(context.assets, resolveSSRNode(res));
|
|
263
301
|
if (scripts.length) html = injectScripts(html, scripts, nonce);
|
|
264
302
|
return html;
|
|
265
303
|
});
|
|
266
304
|
}
|
|
267
|
-
function
|
|
305
|
+
function renderToStream(code, options = {}) {
|
|
268
306
|
const {
|
|
269
307
|
nonce,
|
|
270
308
|
onCompleteShell,
|
|
271
|
-
onCompleteAll
|
|
309
|
+
onCompleteAll,
|
|
310
|
+
dataOnly,
|
|
311
|
+
renderId
|
|
272
312
|
} = options;
|
|
273
313
|
const tmp = [];
|
|
274
314
|
const tasks = [];
|
|
275
|
-
const registry = new
|
|
315
|
+
const registry = new Map();
|
|
276
316
|
const checkEnd = () => {
|
|
277
317
|
if (!registry.size && !completed) {
|
|
278
318
|
onCompleteAll && onCompleteAll(result);
|
|
@@ -281,7 +321,7 @@ function renderToPipeableStream(code, options) {
|
|
|
281
321
|
}
|
|
282
322
|
};
|
|
283
323
|
const writeInitialScript = () => {
|
|
284
|
-
if (tasks.length) {
|
|
324
|
+
if (tasks.length && !completed) {
|
|
285
325
|
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
|
|
286
326
|
tasks.length = 0;
|
|
287
327
|
}
|
|
@@ -297,41 +337,47 @@ function renderToPipeableStream(code, options) {
|
|
|
297
337
|
}
|
|
298
338
|
};
|
|
299
339
|
sharedConfig.context = {
|
|
300
|
-
id: "",
|
|
340
|
+
id: renderId || "",
|
|
301
341
|
count: 0,
|
|
302
342
|
async: true,
|
|
303
343
|
streaming: true,
|
|
344
|
+
dataOnly,
|
|
304
345
|
resources: {},
|
|
305
346
|
suspense: {},
|
|
306
347
|
assets: [],
|
|
307
348
|
nonce,
|
|
308
|
-
writeResource(id, p) {
|
|
349
|
+
writeResource(id, p, error) {
|
|
309
350
|
if (!scheduled) {
|
|
310
351
|
Promise.resolve().then(writeInitialScript);
|
|
311
352
|
scheduled = true;
|
|
312
353
|
}
|
|
354
|
+
if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
|
|
313
355
|
tasks.push(`_$HY.init("${id}")`);
|
|
314
356
|
p.then(d => {
|
|
315
|
-
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
|
|
357
|
+
!completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
|
|
358
|
+
}).catch(() => {
|
|
359
|
+
!completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", null)</script>`);
|
|
316
360
|
});
|
|
317
361
|
},
|
|
318
362
|
registerFragment(key) {
|
|
319
|
-
registry.
|
|
320
|
-
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
scheduled = true;
|
|
325
|
-
}
|
|
326
|
-
tasks.push(`_$HY.init("${key}")`);
|
|
363
|
+
registry.set(key, []);
|
|
364
|
+
if (!dataOnly) {
|
|
365
|
+
if (!scheduled) {
|
|
366
|
+
Promise.resolve().then(writeInitialScript);
|
|
367
|
+
scheduled = true;
|
|
327
368
|
}
|
|
328
|
-
|
|
329
|
-
|
|
369
|
+
tasks.push(`_$HY.init("${key}")`);
|
|
370
|
+
}
|
|
371
|
+
return (value, error) => {
|
|
372
|
+
const keys = registry.get(key);
|
|
330
373
|
registry.delete(key);
|
|
331
|
-
if (
|
|
332
|
-
|
|
333
|
-
|
|
374
|
+
if (waitForFragments(registry, key)) return;
|
|
375
|
+
if ((value !== undefined || error) && !completed) {
|
|
376
|
+
buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}$df("${key}"${error ? "," + serializeError(error) : ""})</script>`);
|
|
377
|
+
scriptFlushed = true;
|
|
378
|
+
}
|
|
334
379
|
checkEnd();
|
|
380
|
+
return true;
|
|
335
381
|
};
|
|
336
382
|
}
|
|
337
383
|
};
|
|
@@ -349,109 +395,24 @@ function renderToPipeableStream(code, options) {
|
|
|
349
395
|
buffer = writable = w;
|
|
350
396
|
tmp.forEach(chunk => buffer.write(chunk));
|
|
351
397
|
if (completed) writable.end();else setTimeout(checkEnd);
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
function pipeToWritable(code, writable, options = {}) {
|
|
356
|
-
const {
|
|
357
|
-
nonce,
|
|
358
|
-
onCompleteShell = ({
|
|
359
|
-
startWriting
|
|
360
|
-
}) => startWriting(),
|
|
361
|
-
onCompleteAll
|
|
362
|
-
} = options;
|
|
363
|
-
const tmp = [];
|
|
364
|
-
const tasks = [];
|
|
365
|
-
const writer = writable.getWriter();
|
|
366
|
-
const encoder = new TextEncoder();
|
|
367
|
-
const registry = new Set();
|
|
368
|
-
const checkEnd = () => {
|
|
369
|
-
if (!registry.size && !completed) {
|
|
370
|
-
onCompleteAll && onCompleteAll(result);
|
|
371
|
-
writable && writable.close();
|
|
372
|
-
completed = true;
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
const writeInitialScript = () => {
|
|
376
|
-
if (tasks.length) {
|
|
377
|
-
buffer.write(encoder.encode(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`));
|
|
378
|
-
tasks.length = 0;
|
|
379
|
-
}
|
|
380
|
-
scheduled = false;
|
|
381
|
-
};
|
|
382
|
-
let completed = false;
|
|
383
|
-
let scriptFlushed = false;
|
|
384
|
-
let scheduled = true;
|
|
385
|
-
let buffer = {
|
|
386
|
-
write(payload) {
|
|
387
|
-
tmp.push(payload);
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
const result = {
|
|
391
|
-
startWriting() {
|
|
392
|
-
buffer = writer;
|
|
393
|
-
tmp.forEach(chunk => writer.write(chunk));
|
|
394
|
-
setTimeout(checkEnd);
|
|
395
|
-
},
|
|
396
|
-
write(c) {
|
|
397
|
-
writer.write(encoder.encode(c));
|
|
398
398
|
},
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
suspense: {},
|
|
411
|
-
assets: [],
|
|
412
|
-
nonce,
|
|
413
|
-
writeResource(id, p) {
|
|
414
|
-
if (!scheduled) {
|
|
415
|
-
Promise.resolve().then(writeInitialScript);
|
|
416
|
-
scheduled = true;
|
|
417
|
-
}
|
|
418
|
-
tasks.push(`_$HY.init("${id}")`);
|
|
419
|
-
p.then(d => {
|
|
420
|
-
buffer.write(encoder.encode(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`));
|
|
421
|
-
});
|
|
422
|
-
},
|
|
423
|
-
registerFragment(key) {
|
|
424
|
-
registry.add(key);
|
|
425
|
-
Promise.resolve().then(() => {
|
|
426
|
-
if (registry.has(key)) {
|
|
427
|
-
if (!scheduled) {
|
|
428
|
-
Promise.resolve().then(writeInitialScript);
|
|
429
|
-
scheduled = true;
|
|
430
|
-
}
|
|
431
|
-
tasks.push(`_$HY.init("${key}")`);
|
|
399
|
+
pipeTo(w) {
|
|
400
|
+
const encoder = new TextEncoder();
|
|
401
|
+
const writer = w.getWriter();
|
|
402
|
+
writable = {
|
|
403
|
+
end() {
|
|
404
|
+
w.close();
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
buffer = {
|
|
408
|
+
write(payload) {
|
|
409
|
+
writer.write(encoder.encode(payload));
|
|
432
410
|
}
|
|
433
|
-
});
|
|
434
|
-
return value => {
|
|
435
|
-
registry.delete(key);
|
|
436
|
-
if (!value) return;
|
|
437
|
-
buffer.write(encoder.encode(`<div hidden id="${key}">${value}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}$df("${key}")</script>`));
|
|
438
|
-
scriptFlushed = true;
|
|
439
|
-
checkEnd();
|
|
440
411
|
};
|
|
412
|
+
tmp.forEach(chunk => buffer.write(chunk));
|
|
413
|
+
if (completed) writable.end();else setTimeout(checkEnd);
|
|
441
414
|
}
|
|
442
415
|
};
|
|
443
|
-
let html = resolveSSRNode(escape(code()));
|
|
444
|
-
html = injectAssets(sharedConfig.context.assets, html);
|
|
445
|
-
Promise.resolve().then(() => {
|
|
446
|
-
if (tasks.length) html = injectScripts(html, tasks.join(";"), nonce);
|
|
447
|
-
buffer.write(encoder.encode(html));
|
|
448
|
-
tasks.length = 0;
|
|
449
|
-
scheduled = false;
|
|
450
|
-
onCompleteShell && onCompleteShell(result);
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
function pipeToNodeWritable(code, writable, options = {}) {
|
|
454
|
-
renderToPipeableStream(code, options).pipe(writable);
|
|
455
416
|
}
|
|
456
417
|
function Assets(props) {
|
|
457
418
|
sharedConfig.context.assets.push(() => NoHydration({
|
|
@@ -609,7 +570,7 @@ function generateHydrationScript({
|
|
|
609
570
|
eventNames = ["click", "input"],
|
|
610
571
|
nonce
|
|
611
572
|
}) {
|
|
612
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>((e,t,o={})=>{t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let n=o.composedPath&&o.composedPath()[0]||o.target,s=t(n);s&&!e.completed.has(s)&&e.events.push([s,o])})))),e.init=(e,t)=>{o[e]=[new Promise((e=>t=e)),t]},e.set=(e,t,n)=>{if(!(n=o[e]))return o[e]=[t];n[1](t)},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}))
|
|
573
|
+
return `<script${nonce ? ` nonce="${nonce}"` : ""}>((e,t,o={})=>{t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let n=o.composedPath&&o.composedPath()[0]||o.target,s=t(n);s&&!e.completed.has(s)&&e.events.push([s,o])})))),e.init=(e,t)=>{o[e]=[new Promise((e=>t=e)),t]},e.set=(e,t,n)=>{if(!(n=o[e]))return o[e]=[t];n[1](t)},e.unset=(e)=>{delete o[e]},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}))</script><!xs>`;
|
|
613
574
|
}
|
|
614
575
|
function injectAssets(assets, html) {
|
|
615
576
|
for (let i = 0; i < assets.length; i++) {
|
|
@@ -625,32 +586,43 @@ function injectScripts(html, scripts, nonce) {
|
|
|
625
586
|
}
|
|
626
587
|
return html + tag;
|
|
627
588
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
function register(key) {
|
|
637
|
-
registry.add(key);
|
|
638
|
-
return value => {
|
|
639
|
-
if (value) cache[key] = value;
|
|
640
|
-
registry.delete(key);
|
|
641
|
-
if (!registry.size) Promise.resolve().then(() => {
|
|
642
|
-
let source = resolveSSRNode(rendered);
|
|
643
|
-
let final = "";
|
|
644
|
-
let match;
|
|
645
|
-
while (match = source.match(FRAGMENT_REPLACE)) {
|
|
646
|
-
final += source.substring(0, match.index);
|
|
647
|
-
source = cache[match[1]] + source.substring(match.index + match[0].length);
|
|
648
|
-
}
|
|
649
|
-
resolve(final + source);
|
|
650
|
-
});
|
|
651
|
-
};
|
|
589
|
+
function serializeError(error) {
|
|
590
|
+
return error.message ? `new Error(${devalue(error.message)})` : devalue(error);
|
|
591
|
+
}
|
|
592
|
+
function waitForFragments(registry, key) {
|
|
593
|
+
for (const k of [...registry.keys()].reverse()) {
|
|
594
|
+
if (key.startsWith(k)) {
|
|
595
|
+
registry.get(k).push(key);
|
|
596
|
+
return true;
|
|
652
597
|
}
|
|
653
|
-
}
|
|
598
|
+
}
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
function pipeToNodeWritable(code, writable, options = {}) {
|
|
602
|
+
if (options.onReady) {
|
|
603
|
+
options.onCompleteShell = () => {
|
|
604
|
+
options.onReady({
|
|
605
|
+
startWriting() {
|
|
606
|
+
stream.pipe(writable);
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
const stream = renderToStream(code, options);
|
|
612
|
+
if (!options.onReady) stream.pipe(writable);
|
|
613
|
+
}
|
|
614
|
+
function pipeToWritable(code, writable, options = {}) {
|
|
615
|
+
if (options.onReady) {
|
|
616
|
+
options.onCompleteShell = () => {
|
|
617
|
+
options.onReady({
|
|
618
|
+
startWriting() {
|
|
619
|
+
stream.pipeTo(writable);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
const stream = renderToStream(code, options);
|
|
625
|
+
if (!options.onReady) stream.pipeTo(writable);
|
|
654
626
|
}
|
|
655
627
|
|
|
656
628
|
const isServer = true;
|
|
@@ -670,4 +642,4 @@ function Portal(props) {
|
|
|
670
642
|
return "";
|
|
671
643
|
}
|
|
672
644
|
|
|
673
|
-
export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable,
|
|
645
|
+
export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle };
|
package/web/dist/web.cjs
CHANGED
|
@@ -98,7 +98,7 @@ function render(code, element, init) {
|
|
|
98
98
|
let disposer;
|
|
99
99
|
solidJs.createRoot(dispose => {
|
|
100
100
|
disposer = dispose;
|
|
101
|
-
insert(element, code(), element.firstChild ? null : undefined, init);
|
|
101
|
+
element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
|
|
102
102
|
});
|
|
103
103
|
return () => {
|
|
104
104
|
disposer();
|
|
@@ -217,17 +217,17 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
|
217
217
|
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
function hydrate(code, element) {
|
|
220
|
+
function hydrate$1(code, element, options = {}) {
|
|
221
221
|
solidJs.sharedConfig.completed = globalThis._$HY.completed;
|
|
222
222
|
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
223
223
|
solidJs.sharedConfig.load = globalThis._$HY.load;
|
|
224
224
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
225
225
|
solidJs.sharedConfig.registry = new Map();
|
|
226
226
|
solidJs.sharedConfig.context = {
|
|
227
|
-
id: "",
|
|
227
|
+
id: options.renderId || "",
|
|
228
228
|
count: 0
|
|
229
229
|
};
|
|
230
|
-
gatherHydratable(element);
|
|
230
|
+
gatherHydratable(element, options.renderId);
|
|
231
231
|
const dispose = render(code, element, [...element.childNodes]);
|
|
232
232
|
solidJs.sharedConfig.context = null;
|
|
233
233
|
return dispose;
|
|
@@ -381,8 +381,8 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
381
381
|
return () => current;
|
|
382
382
|
}
|
|
383
383
|
if (solidJs.sharedConfig.context && current && current.length) {
|
|
384
|
-
for (let i; i < array.length; i++) {
|
|
385
|
-
if (array[i].parentNode) return array;
|
|
384
|
+
for (let i = 0; i < array.length; i++) {
|
|
385
|
+
if (array[i].parentNode) return current = array;
|
|
386
386
|
}
|
|
387
387
|
return current;
|
|
388
388
|
}
|
|
@@ -474,8 +474,7 @@ function NoHydration(props) {
|
|
|
474
474
|
|
|
475
475
|
function renderToString(fn, options) {}
|
|
476
476
|
function renderToStringAsync(fn, options) {}
|
|
477
|
-
function
|
|
478
|
-
function pipeToWritable(fn, writable, options) {}
|
|
477
|
+
function renderToStream(fn, options) {}
|
|
479
478
|
function ssr(template, ...nodes) {}
|
|
480
479
|
function resolveSSRNode(node) {}
|
|
481
480
|
function ssrClassList(value) {}
|
|
@@ -491,6 +490,10 @@ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
|
491
490
|
function createElement(tagName, isSVG = false) {
|
|
492
491
|
return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
|
|
493
492
|
}
|
|
493
|
+
const hydrate = (...args) => {
|
|
494
|
+
solidJs.enableHydration();
|
|
495
|
+
return hydrate$1(...args);
|
|
496
|
+
};
|
|
494
497
|
function Portal(props) {
|
|
495
498
|
const {
|
|
496
499
|
useShadow
|
|
@@ -644,9 +647,8 @@ exports.hydrate = hydrate;
|
|
|
644
647
|
exports.insert = insert;
|
|
645
648
|
exports.isServer = isServer;
|
|
646
649
|
exports.memo = memo;
|
|
647
|
-
exports.pipeToNodeWritable = pipeToNodeWritable;
|
|
648
|
-
exports.pipeToWritable = pipeToWritable;
|
|
649
650
|
exports.render = render;
|
|
651
|
+
exports.renderToStream = renderToStream;
|
|
650
652
|
exports.renderToString = renderToString;
|
|
651
653
|
exports.renderToStringAsync = renderToStringAsync;
|
|
652
654
|
exports.resolveSSRNode = resolveSSRNode;
|
package/web/dist/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMemo, createRoot, createRenderEffect, sharedConfig, createSignal, onCleanup, splitProps, untrack } from 'solid-js';
|
|
1
|
+
import { createMemo, createRoot, createRenderEffect, sharedConfig, enableHydration, createSignal, onCleanup, splitProps, untrack } from 'solid-js';
|
|
2
2
|
export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, mergeProps } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
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"];
|
|
@@ -95,7 +95,7 @@ function render(code, element, init) {
|
|
|
95
95
|
let disposer;
|
|
96
96
|
createRoot(dispose => {
|
|
97
97
|
disposer = dispose;
|
|
98
|
-
insert(element, code(), element.firstChild ? null : undefined, init);
|
|
98
|
+
element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
|
|
99
99
|
});
|
|
100
100
|
return () => {
|
|
101
101
|
disposer();
|
|
@@ -214,17 +214,17 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
|
214
214
|
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
function hydrate(code, element) {
|
|
217
|
+
function hydrate$1(code, element, options = {}) {
|
|
218
218
|
sharedConfig.completed = globalThis._$HY.completed;
|
|
219
219
|
sharedConfig.events = globalThis._$HY.events;
|
|
220
220
|
sharedConfig.load = globalThis._$HY.load;
|
|
221
221
|
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
222
222
|
sharedConfig.registry = new Map();
|
|
223
223
|
sharedConfig.context = {
|
|
224
|
-
id: "",
|
|
224
|
+
id: options.renderId || "",
|
|
225
225
|
count: 0
|
|
226
226
|
};
|
|
227
|
-
gatherHydratable(element);
|
|
227
|
+
gatherHydratable(element, options.renderId);
|
|
228
228
|
const dispose = render(code, element, [...element.childNodes]);
|
|
229
229
|
sharedConfig.context = null;
|
|
230
230
|
return dispose;
|
|
@@ -378,8 +378,8 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
378
378
|
return () => current;
|
|
379
379
|
}
|
|
380
380
|
if (sharedConfig.context && current && current.length) {
|
|
381
|
-
for (let i; i < array.length; i++) {
|
|
382
|
-
if (array[i].parentNode) return array;
|
|
381
|
+
for (let i = 0; i < array.length; i++) {
|
|
382
|
+
if (array[i].parentNode) return current = array;
|
|
383
383
|
}
|
|
384
384
|
return current;
|
|
385
385
|
}
|
|
@@ -471,8 +471,7 @@ function NoHydration(props) {
|
|
|
471
471
|
|
|
472
472
|
function renderToString(fn, options) {}
|
|
473
473
|
function renderToStringAsync(fn, options) {}
|
|
474
|
-
function
|
|
475
|
-
function pipeToWritable(fn, writable, options) {}
|
|
474
|
+
function renderToStream(fn, options) {}
|
|
476
475
|
function ssr(template, ...nodes) {}
|
|
477
476
|
function resolveSSRNode(node) {}
|
|
478
477
|
function ssrClassList(value) {}
|
|
@@ -488,6 +487,10 @@ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
|
488
487
|
function createElement(tagName, isSVG = false) {
|
|
489
488
|
return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
|
|
490
489
|
}
|
|
490
|
+
const hydrate = (...args) => {
|
|
491
|
+
enableHydration();
|
|
492
|
+
return hydrate$1(...args);
|
|
493
|
+
};
|
|
491
494
|
function Portal(props) {
|
|
492
495
|
const {
|
|
493
496
|
useShadow
|
|
@@ -541,4 +544,4 @@ function Dynamic(props) {
|
|
|
541
544
|
});
|
|
542
545
|
}
|
|
543
546
|
|
|
544
|
-
export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, insert, isServer, memo,
|
|
547
|
+
export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
|
package/web/types/client.d.ts
CHANGED
|
@@ -30,7 +30,12 @@ export function spread<T>(
|
|
|
30
30
|
export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
31
31
|
export function setAttribute(node: Element, name: string, value: string): void;
|
|
32
32
|
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
33
|
-
export function addEventListener(
|
|
33
|
+
export function addEventListener(
|
|
34
|
+
node: Element,
|
|
35
|
+
name: string,
|
|
36
|
+
handler: () => void,
|
|
37
|
+
delegate: boolean
|
|
38
|
+
): void;
|
|
34
39
|
export function classList(
|
|
35
40
|
node: Element,
|
|
36
41
|
value: { [k: string]: boolean },
|
|
@@ -45,7 +50,11 @@ export function getOwner(): unknown;
|
|
|
45
50
|
export function mergeProps(...sources: unknown[]): unknown;
|
|
46
51
|
export function dynamicProperty(props: unknown, key: string): unknown;
|
|
47
52
|
|
|
48
|
-
export function hydrate(
|
|
53
|
+
export function hydrate(
|
|
54
|
+
fn: () => JSX.Element,
|
|
55
|
+
node: MountableElement,
|
|
56
|
+
options: { renderId?: string }
|
|
57
|
+
): () => void;
|
|
49
58
|
export function getHydrationKey(): string;
|
|
50
59
|
export function getNextElement(template?: HTMLTemplateElement): Element;
|
|
51
60
|
export function getNextMatch(start: Node, elementName: string): Element;
|
package/web/types/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { hydrate as hydrateCore } from "./client";
|
|
1
2
|
import { Component, JSX, Accessor } from "../..";
|
|
2
3
|
export * from "./client";
|
|
3
4
|
export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, mergeProps } from "../..";
|
|
4
5
|
export * from "./server-mock";
|
|
5
6
|
export declare const isServer = false;
|
|
7
|
+
export declare const hydrate: typeof hydrateCore;
|
|
6
8
|
/**
|
|
7
9
|
* renders components somewhere else in the DOM
|
|
8
10
|
*
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
export declare type PipeToWritableResults = {
|
|
2
|
-
startWriting: () => void;
|
|
3
|
-
write: (v: string) => void;
|
|
4
|
-
abort: () => void;
|
|
5
|
-
};
|
|
6
1
|
export declare function renderToString<T>(fn: () => T, options?: {
|
|
7
|
-
eventNames?: string[];
|
|
8
2
|
nonce?: string;
|
|
3
|
+
renderId?: string;
|
|
9
4
|
}): string;
|
|
10
5
|
export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
11
|
-
eventNames?: string[];
|
|
12
6
|
timeoutMs?: number;
|
|
13
7
|
nonce?: string;
|
|
8
|
+
renderId?: string;
|
|
14
9
|
}): Promise<string>;
|
|
15
|
-
export declare function
|
|
16
|
-
write: (v: string) => void;
|
|
17
|
-
}, options?: {
|
|
18
|
-
eventNames?: string[];
|
|
10
|
+
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
19
11
|
nonce?: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
dataOnly?: boolean;
|
|
13
|
+
renderId?: string;
|
|
14
|
+
onCompleteShell?: () => void;
|
|
15
|
+
onCompleteAll?: () => void;
|
|
16
|
+
}): {
|
|
17
|
+
pipe: (writable: {
|
|
18
|
+
write: (v: string) => void;
|
|
19
|
+
}) => void;
|
|
20
|
+
pipeTo: (writable: WritableStream) => void;
|
|
21
|
+
};
|
|
29
22
|
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
30
23
|
t: string;
|
|
31
24
|
};
|
|
@@ -41,3 +34,26 @@ export declare function ssrBoolean(key: string, value: boolean): string;
|
|
|
41
34
|
export declare function ssrHydrationKey(): string;
|
|
42
35
|
export declare function escape(html: string): string;
|
|
43
36
|
export declare function generateHydrationScript(): string;
|
|
37
|
+
export declare type LegacyResults = {
|
|
38
|
+
startWriting: () => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Replaced by renderToStream
|
|
42
|
+
*/
|
|
43
|
+
export declare function pipeToWritable<T>(fn: () => T, writable: WritableStream, options?: {
|
|
44
|
+
nonce?: string;
|
|
45
|
+
dataOnly?: boolean;
|
|
46
|
+
onReady?: (res: LegacyResults) => void;
|
|
47
|
+
onCompleteAll?: () => void;
|
|
48
|
+
}): void;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Replaced by renderToStream
|
|
51
|
+
*/
|
|
52
|
+
export declare function pipeToNodeWritable<T>(fn: () => T, writable: {
|
|
53
|
+
write: (v: string) => void;
|
|
54
|
+
}, options?: {
|
|
55
|
+
nonce?: string;
|
|
56
|
+
dataOnly?: boolean;
|
|
57
|
+
onReady?: (res: LegacyResults) => void;
|
|
58
|
+
onCompleteAll?: () => void;
|
|
59
|
+
}): void;
|