solid-js 1.2.4 → 1.3.0-beta.2
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 +66 -35
- package/dist/dev.js +67 -35
- package/dist/server.cjs +20 -51
- package/dist/server.js +21 -51
- package/dist/solid.cjs +66 -35
- package/dist/solid.js +67 -35
- package/package.json +2 -2
- package/types/index.d.ts +0 -1
- package/types/reactive/signal.d.ts +76 -78
- package/types/render/hydration.d.ts +3 -2
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -2
- package/types/server/rendering.d.ts +2 -1
- package/web/dist/dev.cjs +24 -19
- package/web/dist/dev.js +25 -19
- package/web/dist/server.cjs +213 -102
- package/web/dist/server.js +214 -104
- package/web/dist/web.cjs +24 -19
- package/web/dist/web.js +25 -19
- package/web/types/client.d.ts +0 -1
- package/web/types/core.d.ts +2 -2
package/web/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sharedConfig,
|
|
1
|
+
import { sharedConfig, splitProps } from 'solid-js';
|
|
2
2
|
export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, 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"];
|
|
@@ -229,111 +229,160 @@ 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
233
|
function renderToString(code, options = {}) {
|
|
233
|
-
sharedConfig.context =
|
|
234
|
+
sharedConfig.context = {
|
|
234
235
|
id: "",
|
|
235
236
|
count: 0,
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
suspense: {},
|
|
238
|
+
assets: [],
|
|
239
|
+
nonce: options.nonce
|
|
240
|
+
};
|
|
238
241
|
let html = resolveSSRNode(escape(code()));
|
|
239
242
|
return injectAssets(sharedConfig.context.assets, html);
|
|
240
243
|
}
|
|
241
244
|
function renderToStringAsync(code, options = {}) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
};
|
|
246
|
-
const context = sharedConfig.context =
|
|
245
|
+
const {
|
|
246
|
+
nonce,
|
|
247
|
+
timeoutMs = 30000
|
|
248
|
+
} = options;
|
|
249
|
+
const context = sharedConfig.context = {
|
|
247
250
|
id: "",
|
|
248
251
|
count: 0,
|
|
249
252
|
resources: {},
|
|
250
253
|
suspense: {},
|
|
251
254
|
assets: [],
|
|
252
|
-
async: true
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
async: true,
|
|
256
|
+
nonce
|
|
257
|
+
};
|
|
258
|
+
let scripts = "";
|
|
259
|
+
sharedConfig.context.writeResource = (id, p) => p.then(d => scripts += `_$HY.set("${id}", ${devalue(d)});`);
|
|
260
|
+
const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), timeoutMs));
|
|
261
|
+
return Promise.race([asyncWrap(() => escape(code())), timeout]).then(res => {
|
|
262
|
+
let html = injectAssets(context.assets, resolveSSRNode(res));
|
|
263
|
+
if (scripts.length) html = injectScripts(html, scripts, nonce);
|
|
264
|
+
return html;
|
|
258
265
|
});
|
|
259
266
|
}
|
|
260
|
-
function
|
|
267
|
+
function renderToPipeableStream(code, options) {
|
|
261
268
|
const {
|
|
262
269
|
nonce,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}) => startWriting(),
|
|
266
|
-
onComplete
|
|
270
|
+
onCompleteShell,
|
|
271
|
+
onCompleteAll
|
|
267
272
|
} = options;
|
|
268
273
|
const tmp = [];
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
+
const tasks = [];
|
|
275
|
+
const registry = new Set();
|
|
276
|
+
const checkEnd = () => {
|
|
277
|
+
if (!registry.size && !completed) {
|
|
278
|
+
onCompleteAll && onCompleteAll(result);
|
|
279
|
+
writable && writable.end();
|
|
280
|
+
completed = true;
|
|
274
281
|
}
|
|
275
282
|
};
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
buffer =
|
|
279
|
-
|
|
280
|
-
setTimeout(checkEnd);
|
|
281
|
-
},
|
|
282
|
-
write(c) {
|
|
283
|
-
writable.write(c);
|
|
284
|
-
},
|
|
285
|
-
abort() {
|
|
286
|
-
completed = count;
|
|
287
|
-
checkEnd();
|
|
283
|
+
const writeInitialScript = () => {
|
|
284
|
+
if (tasks.length) {
|
|
285
|
+
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
|
|
286
|
+
tasks.length = 0;
|
|
288
287
|
}
|
|
288
|
+
scheduled = false;
|
|
289
289
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
let writable;
|
|
291
|
+
let completed = false;
|
|
292
|
+
let scriptFlushed = false;
|
|
293
|
+
let scheduled = true;
|
|
294
|
+
let buffer = {
|
|
295
|
+
write(payload) {
|
|
296
|
+
tmp.push(payload);
|
|
294
297
|
}
|
|
295
298
|
};
|
|
296
|
-
sharedConfig.context =
|
|
299
|
+
sharedConfig.context = {
|
|
297
300
|
id: "",
|
|
298
301
|
count: 0,
|
|
302
|
+
async: true,
|
|
299
303
|
streaming: true,
|
|
304
|
+
resources: {},
|
|
300
305
|
suspense: {},
|
|
301
|
-
assets: []
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
assets: [],
|
|
307
|
+
nonce,
|
|
308
|
+
writeResource(id, p) {
|
|
309
|
+
if (!scheduled) {
|
|
310
|
+
Promise.resolve().then(writeInitialScript);
|
|
311
|
+
scheduled = true;
|
|
312
|
+
}
|
|
313
|
+
tasks.push(`_$HY.init("${id}")`);
|
|
314
|
+
p.then(d => {
|
|
315
|
+
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
|
|
316
|
+
});
|
|
317
|
+
},
|
|
318
|
+
registerFragment(key) {
|
|
319
|
+
registry.add(key);
|
|
320
|
+
Promise.resolve().then(() => {
|
|
321
|
+
if (registry.has(key)) {
|
|
322
|
+
if (!scheduled) {
|
|
323
|
+
Promise.resolve().then(writeInitialScript);
|
|
324
|
+
scheduled = true;
|
|
325
|
+
}
|
|
326
|
+
tasks.push(`_$HY.init("${key}")`);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
return value => {
|
|
330
|
+
registry.delete(key);
|
|
331
|
+
if (!value) return;
|
|
332
|
+
buffer.write(`<div hidden id="${key}">${value}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}$df("${key}")</script>`);
|
|
333
|
+
scriptFlushed = true;
|
|
334
|
+
checkEnd();
|
|
335
|
+
};
|
|
336
|
+
}
|
|
310
337
|
};
|
|
311
338
|
let html = resolveSSRNode(escape(code()));
|
|
312
339
|
html = injectAssets(sharedConfig.context.assets, html);
|
|
313
|
-
|
|
314
|
-
|
|
340
|
+
Promise.resolve().then(() => {
|
|
341
|
+
if (tasks.length) html = injectScripts(html, tasks.join(";"), nonce);
|
|
342
|
+
buffer.write(html);
|
|
343
|
+
tasks.length = 0;
|
|
344
|
+
scheduled = false;
|
|
345
|
+
onCompleteShell && onCompleteShell();
|
|
346
|
+
});
|
|
347
|
+
return {
|
|
348
|
+
pipe(w) {
|
|
349
|
+
buffer = writable = w;
|
|
350
|
+
tmp.forEach(chunk => buffer.write(chunk));
|
|
351
|
+
if (completed) writable.end();else setTimeout(checkEnd);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
315
354
|
}
|
|
316
355
|
function pipeToWritable(code, writable, options = {}) {
|
|
317
356
|
const {
|
|
318
357
|
nonce,
|
|
319
|
-
|
|
358
|
+
onCompleteShell = ({
|
|
320
359
|
startWriting
|
|
321
360
|
}) => startWriting(),
|
|
322
|
-
|
|
361
|
+
onCompleteAll
|
|
323
362
|
} = options;
|
|
324
363
|
const tmp = [];
|
|
364
|
+
const tasks = [];
|
|
325
365
|
const writer = writable.getWriter();
|
|
326
366
|
const encoder = new TextEncoder();
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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 = {
|
|
337
386
|
write(payload) {
|
|
338
387
|
tmp.push(payload);
|
|
339
388
|
}
|
|
@@ -348,28 +397,61 @@ function pipeToWritable(code, writable, options = {}) {
|
|
|
348
397
|
writer.write(encoder.encode(c));
|
|
349
398
|
},
|
|
350
399
|
abort() {
|
|
351
|
-
|
|
400
|
+
registry.clear();
|
|
352
401
|
checkEnd();
|
|
353
402
|
}
|
|
354
403
|
};
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
404
|
+
sharedConfig.context = {
|
|
405
|
+
id: "",
|
|
406
|
+
count: 0,
|
|
407
|
+
async: true,
|
|
408
|
+
streaming: true,
|
|
409
|
+
resources: {},
|
|
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}")`);
|
|
432
|
+
}
|
|
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
|
+
};
|
|
359
441
|
}
|
|
360
442
|
};
|
|
361
|
-
sharedConfig.context.writeResource = (id, p) => {
|
|
362
|
-
count++;
|
|
363
|
-
Promise.resolve().then(() => buffer.write(encoder.encode(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HYDRATION.startResource("${id}")</script>`)));
|
|
364
|
-
p.then(d => {
|
|
365
|
-
buffer.write(encoder.encode(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HYDRATION.resolveResource("${id}", ${devalue(d)})</script>`));
|
|
366
|
-
++completed && checkEnd();
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
443
|
let html = resolveSSRNode(escape(code()));
|
|
370
444
|
html = injectAssets(sharedConfig.context.assets, html);
|
|
371
|
-
|
|
372
|
-
|
|
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);
|
|
373
455
|
}
|
|
374
456
|
function Assets(props) {
|
|
375
457
|
sharedConfig.context.assets.push(() => NoHydration({
|
|
@@ -379,15 +461,21 @@ function Assets(props) {
|
|
|
379
461
|
}));
|
|
380
462
|
return ssr(`%%$${sharedConfig.context.assets.length - 1}%%`);
|
|
381
463
|
}
|
|
382
|
-
function HydrationScript() {
|
|
383
|
-
|
|
464
|
+
function HydrationScript(props) {
|
|
465
|
+
const {
|
|
466
|
+
nonce
|
|
467
|
+
} = sharedConfig.context;
|
|
468
|
+
sharedConfig.context.assets.push(() => generateHydrationScript({
|
|
469
|
+
nonce,
|
|
470
|
+
...props
|
|
471
|
+
}));
|
|
384
472
|
return ssr(`%%$${sharedConfig.context.assets.length - 1}%%`);
|
|
385
473
|
}
|
|
386
474
|
function NoHydration(props) {
|
|
387
475
|
const c = sharedConfig.context;
|
|
388
|
-
|
|
476
|
+
c.noHydrate = true;
|
|
389
477
|
const children = props.children;
|
|
390
|
-
|
|
478
|
+
c.noHydrate = false;
|
|
391
479
|
return children;
|
|
392
480
|
}
|
|
393
481
|
function ssr(t, ...nodes) {
|
|
@@ -515,26 +603,13 @@ function resolveSSRNode(node) {
|
|
|
515
603
|
}
|
|
516
604
|
function getHydrationKey() {
|
|
517
605
|
const hydrate = sharedConfig.context;
|
|
518
|
-
return hydrate && `${hydrate.id}${hydrate.count++}`;
|
|
606
|
+
return hydrate && !hydrate.noHydrate && `${hydrate.id}${hydrate.count++}`;
|
|
519
607
|
}
|
|
520
|
-
function generateHydrationScript(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
eventNames = ["click", "input"]
|
|
526
|
-
} = sharedConfig.context;
|
|
527
|
-
let s = `<script${nonce ? ` nonce="${nonce}"` : ""}>(()=>{_$HYDRATION={events:[],completed:new WeakSet};const t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),e=e=>{let o=e.composedPath&&e.composedPath()[0]||e.target,s=t(o);s&&!_$HYDRATION.completed.has(s)&&_$HYDRATION.events.push([s,e])};["${eventNames.join('","')}"].forEach(t=>document.addEventListener(t,e))})();`;
|
|
528
|
-
if (streaming) {
|
|
529
|
-
s += `(()=>{const e=_$HYDRATION,o={};e.startResource=e=>{let r;o[e]=[new Promise(e=>r=e),r]},e.resolveResource=(e,r)=>{const n=o[e];if(!n)return o[e]=[r];n[1](r)},e.loadResource=e=>{const r=o[e];if(r)return r[0]}})();`;
|
|
530
|
-
}
|
|
531
|
-
if (resources) {
|
|
532
|
-
s += `_$HYDRATION.resources = ${devalue(Object.keys(resources).reduce((r, k) => {
|
|
533
|
-
r[k] = resources[k].data;
|
|
534
|
-
return r;
|
|
535
|
-
}, {}))};`;
|
|
536
|
-
}
|
|
537
|
-
return s + `</script>`;
|
|
608
|
+
function generateHydrationScript({
|
|
609
|
+
eventNames = ["click", "input"],
|
|
610
|
+
nonce
|
|
611
|
+
}) {
|
|
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}));</script><!xs>`;
|
|
538
613
|
}
|
|
539
614
|
function injectAssets(assets, html) {
|
|
540
615
|
for (let i = 0; i < assets.length; i++) {
|
|
@@ -542,6 +617,41 @@ function injectAssets(assets, html) {
|
|
|
542
617
|
}
|
|
543
618
|
return html;
|
|
544
619
|
}
|
|
620
|
+
function injectScripts(html, scripts, nonce) {
|
|
621
|
+
const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
|
|
622
|
+
const index = html.indexOf("<!xs>");
|
|
623
|
+
if (index > -1) {
|
|
624
|
+
return html.slice(0, index) + tag + html.slice(index);
|
|
625
|
+
}
|
|
626
|
+
return html + tag;
|
|
627
|
+
}
|
|
628
|
+
const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
|
|
629
|
+
function asyncWrap(fn) {
|
|
630
|
+
return new Promise(resolve => {
|
|
631
|
+
const registry = new Set();
|
|
632
|
+
const cache = Object.create(null);
|
|
633
|
+
sharedConfig.context.registerFragment = register;
|
|
634
|
+
const rendered = fn();
|
|
635
|
+
if (!registry.size) resolve(rendered);
|
|
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
|
+
};
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
}
|
|
545
655
|
|
|
546
656
|
const isServer = true;
|
|
547
657
|
function spread() {}
|
|
@@ -560,4 +670,4 @@ function Portal(props) {
|
|
|
560
670
|
return "";
|
|
561
671
|
}
|
|
562
672
|
|
|
563
|
-
export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle };
|
|
673
|
+
export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToPipeableStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle };
|
package/web/dist/web.cjs
CHANGED
|
@@ -214,32 +214,24 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
|
214
214
|
continue;
|
|
215
215
|
}
|
|
216
216
|
const value = props[prop];
|
|
217
|
-
assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
218
|
-
prevProps[prop] = value;
|
|
217
|
+
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
219
218
|
}
|
|
220
219
|
}
|
|
221
220
|
function hydrate(code, element) {
|
|
222
|
-
solidJs.sharedConfig.
|
|
223
|
-
solidJs.sharedConfig.
|
|
224
|
-
solidJs.sharedConfig.
|
|
221
|
+
solidJs.sharedConfig.completed = globalThis._$HY.completed;
|
|
222
|
+
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
223
|
+
solidJs.sharedConfig.load = globalThis._$HY.load;
|
|
224
|
+
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
225
|
+
solidJs.sharedConfig.registry = new Map();
|
|
225
226
|
solidJs.sharedConfig.context = {
|
|
226
227
|
id: "",
|
|
227
|
-
count: 0
|
|
228
|
-
loadResource: globalThis._$HYDRATION.loadResource
|
|
228
|
+
count: 0
|
|
229
229
|
};
|
|
230
|
-
solidJs.sharedConfig.registry = new Map();
|
|
231
230
|
gatherHydratable(element);
|
|
232
231
|
const dispose = render(code, element, [...element.childNodes]);
|
|
233
232
|
solidJs.sharedConfig.context = null;
|
|
234
233
|
return dispose;
|
|
235
234
|
}
|
|
236
|
-
function gatherHydratable(element) {
|
|
237
|
-
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
238
|
-
for (let i = 0; i < templates.length; i++) {
|
|
239
|
-
const node = templates[i];
|
|
240
|
-
solidJs.sharedConfig.registry.set(node.getAttribute("data-hk"), node);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
235
|
function getNextElement(template) {
|
|
244
236
|
let node, key;
|
|
245
237
|
if (!solidJs.sharedConfig.context || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
@@ -301,7 +293,7 @@ function assignProp(node, prop, value, prev, isSVG) {
|
|
|
301
293
|
let isCE, isProp, isChildProp;
|
|
302
294
|
if (prop === "style") return style(node, value, prev);
|
|
303
295
|
if (prop === "classList") return classList(node, value, prev);
|
|
304
|
-
if (value === prev) return;
|
|
296
|
+
if (value === prev) return prev;
|
|
305
297
|
if (prop === "ref") {
|
|
306
298
|
value(node);
|
|
307
299
|
} else if (prop.slice(0, 3) === "on:") {
|
|
@@ -319,6 +311,7 @@ function assignProp(node, prop, value, prev, isSVG) {
|
|
|
319
311
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
320
312
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
|
|
321
313
|
}
|
|
314
|
+
return value;
|
|
322
315
|
}
|
|
323
316
|
function eventHandler(e) {
|
|
324
317
|
const key = `$$${e.type}`;
|
|
@@ -332,7 +325,7 @@ function eventHandler(e) {
|
|
|
332
325
|
Object.defineProperty(e, "currentTarget", {
|
|
333
326
|
configurable: true,
|
|
334
327
|
get() {
|
|
335
|
-
return node;
|
|
328
|
+
return node || document;
|
|
336
329
|
}
|
|
337
330
|
});
|
|
338
331
|
while (node !== null) {
|
|
@@ -387,7 +380,12 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
387
380
|
solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
388
381
|
return () => current;
|
|
389
382
|
}
|
|
390
|
-
if (solidJs.sharedConfig.context && current && current.length)
|
|
383
|
+
if (solidJs.sharedConfig.context && current && current.length) {
|
|
384
|
+
for (let i; i < array.length; i++) {
|
|
385
|
+
if (array[i].parentNode) return array;
|
|
386
|
+
}
|
|
387
|
+
return current;
|
|
388
|
+
}
|
|
391
389
|
if (array.length === 0) {
|
|
392
390
|
current = cleanChildren(parent, current, marker);
|
|
393
391
|
if (multi) return current;
|
|
@@ -455,6 +453,14 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
455
453
|
} else parent.insertBefore(node, marker);
|
|
456
454
|
return [node];
|
|
457
455
|
}
|
|
456
|
+
function gatherHydratable(element, root) {
|
|
457
|
+
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
458
|
+
for (let i = 0; i < templates.length; i++) {
|
|
459
|
+
const node = templates[i];
|
|
460
|
+
const key = node.getAttribute("data-hk");
|
|
461
|
+
if (!root || key.startsWith(root)) solidJs.sharedConfig.registry.set(key, node);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
458
464
|
function getHydrationKey() {
|
|
459
465
|
const hydrate = solidJs.sharedConfig.context;
|
|
460
466
|
return `${hydrate.id}${hydrate.count++}`;
|
|
@@ -629,7 +635,6 @@ exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
|
629
635
|
exports.delegateEvents = delegateEvents;
|
|
630
636
|
exports.dynamicProperty = dynamicProperty;
|
|
631
637
|
exports.escape = escape;
|
|
632
|
-
exports.gatherHydratable = gatherHydratable;
|
|
633
638
|
exports.generateHydrationScript = generateHydrationScript;
|
|
634
639
|
exports.getHydrationKey = getHydrationKey;
|
|
635
640
|
exports.getNextElement = getNextElement;
|
package/web/dist/web.js
CHANGED
|
@@ -211,32 +211,24 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
|
211
211
|
continue;
|
|
212
212
|
}
|
|
213
213
|
const value = props[prop];
|
|
214
|
-
assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
215
|
-
prevProps[prop] = value;
|
|
214
|
+
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
216
215
|
}
|
|
217
216
|
}
|
|
218
217
|
function hydrate(code, element) {
|
|
219
|
-
sharedConfig.
|
|
220
|
-
sharedConfig.
|
|
221
|
-
sharedConfig.
|
|
218
|
+
sharedConfig.completed = globalThis._$HY.completed;
|
|
219
|
+
sharedConfig.events = globalThis._$HY.events;
|
|
220
|
+
sharedConfig.load = globalThis._$HY.load;
|
|
221
|
+
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
222
|
+
sharedConfig.registry = new Map();
|
|
222
223
|
sharedConfig.context = {
|
|
223
224
|
id: "",
|
|
224
|
-
count: 0
|
|
225
|
-
loadResource: globalThis._$HYDRATION.loadResource
|
|
225
|
+
count: 0
|
|
226
226
|
};
|
|
227
|
-
sharedConfig.registry = new Map();
|
|
228
227
|
gatherHydratable(element);
|
|
229
228
|
const dispose = render(code, element, [...element.childNodes]);
|
|
230
229
|
sharedConfig.context = null;
|
|
231
230
|
return dispose;
|
|
232
231
|
}
|
|
233
|
-
function gatherHydratable(element) {
|
|
234
|
-
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
235
|
-
for (let i = 0; i < templates.length; i++) {
|
|
236
|
-
const node = templates[i];
|
|
237
|
-
sharedConfig.registry.set(node.getAttribute("data-hk"), node);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
232
|
function getNextElement(template) {
|
|
241
233
|
let node, key;
|
|
242
234
|
if (!sharedConfig.context || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
@@ -298,7 +290,7 @@ function assignProp(node, prop, value, prev, isSVG) {
|
|
|
298
290
|
let isCE, isProp, isChildProp;
|
|
299
291
|
if (prop === "style") return style(node, value, prev);
|
|
300
292
|
if (prop === "classList") return classList(node, value, prev);
|
|
301
|
-
if (value === prev) return;
|
|
293
|
+
if (value === prev) return prev;
|
|
302
294
|
if (prop === "ref") {
|
|
303
295
|
value(node);
|
|
304
296
|
} else if (prop.slice(0, 3) === "on:") {
|
|
@@ -316,6 +308,7 @@ function assignProp(node, prop, value, prev, isSVG) {
|
|
|
316
308
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
317
309
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
|
|
318
310
|
}
|
|
311
|
+
return value;
|
|
319
312
|
}
|
|
320
313
|
function eventHandler(e) {
|
|
321
314
|
const key = `$$${e.type}`;
|
|
@@ -329,7 +322,7 @@ function eventHandler(e) {
|
|
|
329
322
|
Object.defineProperty(e, "currentTarget", {
|
|
330
323
|
configurable: true,
|
|
331
324
|
get() {
|
|
332
|
-
return node;
|
|
325
|
+
return node || document;
|
|
333
326
|
}
|
|
334
327
|
});
|
|
335
328
|
while (node !== null) {
|
|
@@ -384,7 +377,12 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
384
377
|
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
385
378
|
return () => current;
|
|
386
379
|
}
|
|
387
|
-
if (sharedConfig.context && current && current.length)
|
|
380
|
+
if (sharedConfig.context && current && current.length) {
|
|
381
|
+
for (let i; i < array.length; i++) {
|
|
382
|
+
if (array[i].parentNode) return array;
|
|
383
|
+
}
|
|
384
|
+
return current;
|
|
385
|
+
}
|
|
388
386
|
if (array.length === 0) {
|
|
389
387
|
current = cleanChildren(parent, current, marker);
|
|
390
388
|
if (multi) return current;
|
|
@@ -452,6 +450,14 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
452
450
|
} else parent.insertBefore(node, marker);
|
|
453
451
|
return [node];
|
|
454
452
|
}
|
|
453
|
+
function gatherHydratable(element, root) {
|
|
454
|
+
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
455
|
+
for (let i = 0; i < templates.length; i++) {
|
|
456
|
+
const node = templates[i];
|
|
457
|
+
const key = node.getAttribute("data-hk");
|
|
458
|
+
if (!root || key.startsWith(root)) sharedConfig.registry.set(key, node);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
455
461
|
function getHydrationKey() {
|
|
456
462
|
const hydrate = sharedConfig.context;
|
|
457
463
|
return `${hydrate.id}${hydrate.count++}`;
|
|
@@ -535,4 +541,4 @@ function Dynamic(props) {
|
|
|
535
541
|
});
|
|
536
542
|
}
|
|
537
543
|
|
|
538
|
-
export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape,
|
|
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, pipeToNodeWritable, pipeToWritable, render, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
|
package/web/types/client.d.ts
CHANGED
|
@@ -46,7 +46,6 @@ export function mergeProps(...sources: unknown[]): unknown;
|
|
|
46
46
|
export function dynamicProperty(props: unknown, key: string): unknown;
|
|
47
47
|
|
|
48
48
|
export function hydrate(fn: () => JSX.Element, node: MountableElement): () => void;
|
|
49
|
-
export function gatherHydratable(node: Element): void;
|
|
50
49
|
export function getHydrationKey(): string;
|
|
51
50
|
export function getNextElement(template?: HTMLTemplateElement): Element;
|
|
52
51
|
export function getNextMatch(start: Node, elementName: string): Element;
|
package/web/types/core.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createRoot, createRenderEffect, createComponent, getOwner, sharedConfig
|
|
1
|
+
import { createRoot, createRenderEffect, createComponent, getOwner, sharedConfig } from "../..";
|
|
2
2
|
declare function memo<T>(fn: () => T, equals: boolean): import("../..").Accessor<T>;
|
|
3
|
-
export { getOwner, createComponent, createRoot as root, createRenderEffect as effect, memo, sharedConfig
|
|
3
|
+
export { getOwner, createComponent, createRoot as root, createRenderEffect as effect, memo, sharedConfig };
|