@solidjs/web 2.0.0-beta.24 → 2.0.0-beta.26
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 +11 -8
- package/dist/dev.js +11 -8
- package/dist/web.cjs +11 -8
- package/dist/web.js +11 -8
- package/frames/dist/client.cjs +135 -208
- package/frames/dist/client.dev.cjs +1408 -0
- package/frames/dist/client.dev.js +1396 -0
- package/frames/dist/client.js +136 -209
- package/frames/dist/server.cjs +106 -78
- package/frames/dist/server.js +106 -78
- package/package.json +27 -6
- package/server-functions/dist/client.cjs +3 -3
- package/server-functions/dist/client.js +3 -3
- package/server-functions/dist/server.cjs +3 -3
- package/server-functions/dist/server.js +3 -3
- package/types/frames/client.d.ts +13 -49
- package/types/frames/frame-client.d.ts +34 -28
- package/types/frames/server.d.ts +1 -20
- package/types-cjs/frames/client.d.cts +13 -49
- package/types-cjs/frames/frame-client.d.cts +34 -28
- package/types-cjs/frames/server.d.cts +1 -20
package/frames/dist/client.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
|
+
var web$1 = require('@solidjs/web');
|
|
5
|
+
var client = require('@solidjs/web/server-functions/client');
|
|
4
6
|
var seroval = require('seroval');
|
|
5
7
|
var web = require('seroval-plugins/web');
|
|
6
8
|
|
|
@@ -65,22 +67,6 @@ function chunkToRecords(chunk) {
|
|
|
65
67
|
args: chunk.args
|
|
66
68
|
}
|
|
67
69
|
};
|
|
68
|
-
case "template":
|
|
69
|
-
return {
|
|
70
|
-
[`tpl:${chunk.key}`]: {
|
|
71
|
-
kind: "template",
|
|
72
|
-
html: chunk.html,
|
|
73
|
-
fields: chunk.fields
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
case "block":
|
|
77
|
-
return {
|
|
78
|
-
[`seg:${chunk.key}`]: {
|
|
79
|
-
kind: "block",
|
|
80
|
-
template: `tpl:${chunk.template}`,
|
|
81
|
-
values: chunk.values
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
70
|
case "complete":
|
|
85
71
|
return {
|
|
86
72
|
":complete": true
|
|
@@ -274,7 +260,7 @@ class FrameImpl {
|
|
|
274
260
|
this.#revealed.clear();
|
|
275
261
|
this.#fallbackShown.clear();
|
|
276
262
|
for (const key of Object.keys(this.#store)) {
|
|
277
|
-
if (key.startsWith("seg:") || key
|
|
263
|
+
if (key.startsWith("seg:") || key === ":error") {
|
|
278
264
|
delete this.#store[key];
|
|
279
265
|
}
|
|
280
266
|
}
|
|
@@ -343,10 +329,14 @@ class FrameImpl {
|
|
|
343
329
|
if (record !== undefined) return record;
|
|
344
330
|
return this.#options.resolveSlotRecord?.(occurrence);
|
|
345
331
|
}
|
|
346
|
-
#
|
|
332
|
+
#removeSlotRecord(occurrence) {
|
|
333
|
+
const key = `slot:${occurrence}`;
|
|
334
|
+
if (key in this.#store) delete this.#store[key];else this.#options.removeSlotRecord?.(occurrence);
|
|
335
|
+
}
|
|
336
|
+
#syncSlots(root) {
|
|
347
337
|
if (!this.#slots && !this.#options.resolveSlot) return;
|
|
348
338
|
const found = new Map();
|
|
349
|
-
this.#collectSlots(found);
|
|
339
|
+
if (root) collectSlots(root, found);else this.#collectSlots(found);
|
|
350
340
|
for (const [occurrence, start] of found) {
|
|
351
341
|
const callback = this.#resolveSlot(propOf(occurrence));
|
|
352
342
|
if (!callback) continue;
|
|
@@ -359,6 +349,7 @@ class FrameImpl {
|
|
|
359
349
|
this.#runSlotCleanups(occurrence);
|
|
360
350
|
}
|
|
361
351
|
if (!this.#mountedSlots.has(occurrence)) {
|
|
352
|
+
if (this.#options.adopt) this.#discoverRegions(occurrence, start);
|
|
362
353
|
const nodes = this.#invokeSlot(occurrence, callback, record, start, this.#options.adopt);
|
|
363
354
|
if (nodes) this.#replaceRange(occurrence, start, nodes);
|
|
364
355
|
this.#slotNodes.set(occurrence, nodes);
|
|
@@ -376,8 +367,10 @@ class FrameImpl {
|
|
|
376
367
|
this.#bindRegions(occurrence);
|
|
377
368
|
}
|
|
378
369
|
}
|
|
379
|
-
|
|
380
|
-
|
|
370
|
+
if (!root) {
|
|
371
|
+
for (const occurrence of [...this.#mountedSlots]) {
|
|
372
|
+
if (!found.has(occurrence)) this.#unmountSlot(occurrence);
|
|
373
|
+
}
|
|
381
374
|
}
|
|
382
375
|
}
|
|
383
376
|
#invokeSlot(occurrence, callback, record, start, adopted) {
|
|
@@ -390,6 +383,13 @@ class FrameImpl {
|
|
|
390
383
|
existing: start ? rangeInterior(start, slotEnd(occurrence)) : []
|
|
391
384
|
};
|
|
392
385
|
const props = record && record.kind === "slot" ? this.#resolveArgs(occurrence, record.args) : {};
|
|
386
|
+
const regions = this.#slotRegions.get(occurrence);
|
|
387
|
+
if (regions) {
|
|
388
|
+
for (const entry of regions.values()) {
|
|
389
|
+
const argKey = entry.childId.slice(entry.childId.lastIndexOf(".") + 1);
|
|
390
|
+
if (!(argKey in props)) props[argKey] = entry.element;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
393
|
const content = callback(props, ctx);
|
|
394
394
|
this.#slotArgs.set(occurrence, record);
|
|
395
395
|
if (cleanups.length) this.#slotCleanups.set(occurrence, cleanups);
|
|
@@ -412,7 +412,7 @@ class FrameImpl {
|
|
|
412
412
|
this.#slotNodes.delete(key);
|
|
413
413
|
this.#slotArgs.delete(key);
|
|
414
414
|
this.#slotResolvedRefs.delete(key);
|
|
415
|
-
|
|
415
|
+
this.#removeSlotRecord(key);
|
|
416
416
|
this.#runSlotCleanups(key);
|
|
417
417
|
const regions = this.#slotRegions.get(key);
|
|
418
418
|
if (regions) {
|
|
@@ -446,29 +446,17 @@ class FrameImpl {
|
|
|
446
446
|
cache[key] = resolved;
|
|
447
447
|
props[key] = resolved;
|
|
448
448
|
} else if (isFrameRef(value)) {
|
|
449
|
-
const fragment = document.createDocumentFragment();
|
|
450
449
|
let entry = regions.get(value.$frame);
|
|
451
450
|
if (!entry) {
|
|
452
|
-
const
|
|
453
|
-
const end = document.createComment(`frame:${value.$frame}:end`);
|
|
451
|
+
const element = makeFrameElement(value.$frame);
|
|
454
452
|
entry = {
|
|
455
453
|
childId: value.$frame,
|
|
456
|
-
|
|
457
|
-
end,
|
|
454
|
+
element,
|
|
458
455
|
frame: undefined
|
|
459
456
|
};
|
|
460
457
|
regions.set(value.$frame, entry);
|
|
461
|
-
fragment.append(start, end);
|
|
462
|
-
} else {
|
|
463
|
-
let n = entry.start;
|
|
464
|
-
while (n) {
|
|
465
|
-
const next = n.nextSibling;
|
|
466
|
-
fragment.append(n);
|
|
467
|
-
if (n === entry.end) break;
|
|
468
|
-
n = next;
|
|
469
|
-
}
|
|
470
458
|
}
|
|
471
|
-
props[key] =
|
|
459
|
+
props[key] = entry.element;
|
|
472
460
|
} else {
|
|
473
461
|
props[key] = value;
|
|
474
462
|
}
|
|
@@ -482,49 +470,12 @@ class FrameImpl {
|
|
|
482
470
|
regions = new Map();
|
|
483
471
|
this.#slotRegions.set(slotKey, regions);
|
|
484
472
|
}
|
|
485
|
-
const doc = start.ownerDocument;
|
|
486
473
|
const endData = slotEnd(slotKey);
|
|
487
|
-
const comments = [];
|
|
488
474
|
let n = start.nextSibling;
|
|
489
475
|
while (n && !(n.nodeType === COMMENT_NODE && n.data === endData)) {
|
|
490
|
-
|
|
491
|
-
const walker = doc.createTreeWalker(n, 128 );
|
|
492
|
-
let c;
|
|
493
|
-
while (c = walker.nextNode()) comments.push(c);
|
|
494
|
-
}
|
|
476
|
+
collectRegionElements(n, regions);
|
|
495
477
|
n = n.nextSibling;
|
|
496
478
|
}
|
|
497
|
-
let depth = 0;
|
|
498
|
-
let openId = null;
|
|
499
|
-
let openStart = null;
|
|
500
|
-
for (const c of comments) {
|
|
501
|
-
const data = c.data;
|
|
502
|
-
if (!data.startsWith("frame:")) continue;
|
|
503
|
-
if (data.endsWith(":start")) {
|
|
504
|
-
const childId = data.slice(6, -6);
|
|
505
|
-
if (!childId) continue;
|
|
506
|
-
if (depth === 0) {
|
|
507
|
-
openId = childId;
|
|
508
|
-
openStart = c;
|
|
509
|
-
}
|
|
510
|
-
depth++;
|
|
511
|
-
} else if (data.endsWith(":end")) {
|
|
512
|
-
const childId = data.slice(6, -4);
|
|
513
|
-
if (!childId) continue;
|
|
514
|
-
if (depth > 0) {
|
|
515
|
-
depth--;
|
|
516
|
-
if (depth === 0 && childId === openId && !regions.has(openId)) {
|
|
517
|
-
regions.set(openId, {
|
|
518
|
-
childId: openId,
|
|
519
|
-
start: openStart,
|
|
520
|
-
end: c,
|
|
521
|
-
frame: undefined,
|
|
522
|
-
adopt: true
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
479
|
}
|
|
529
480
|
#refArgsUnchanged(occurrence, record) {
|
|
530
481
|
const old = this.#slotArgs.get(occurrence);
|
|
@@ -568,15 +519,16 @@ class FrameImpl {
|
|
|
568
519
|
const regions = this.#slotRegions.get(slotKey);
|
|
569
520
|
if (!regions) return;
|
|
570
521
|
for (const entry of regions.values()) {
|
|
571
|
-
if (!entry.frame
|
|
572
|
-
entry.frame = new FrameImpl(
|
|
522
|
+
if (!entry.frame) {
|
|
523
|
+
entry.frame = new FrameImpl(entry.element, null, null, {
|
|
573
524
|
id: entry.childId,
|
|
574
525
|
host: this.#options.host,
|
|
575
526
|
adopt: entry.adopt,
|
|
576
527
|
claimScope: this.#options.claimScope ?? this.#options.id,
|
|
577
528
|
ownerScope: this.#options.ownerScope,
|
|
578
529
|
resolveSlot: prop => this.#resolveSlot(prop),
|
|
579
|
-
resolveSlotRecord: occurrence => this.#resolveSlotRecord(occurrence)
|
|
530
|
+
resolveSlotRecord: occurrence => this.#resolveSlotRecord(occurrence),
|
|
531
|
+
removeSlotRecord: occurrence => this.#removeSlotRecord(occurrence)
|
|
580
532
|
});
|
|
581
533
|
}
|
|
582
534
|
}
|
|
@@ -591,12 +543,7 @@ class FrameImpl {
|
|
|
591
543
|
n = afterRange(n, id);
|
|
592
544
|
continue;
|
|
593
545
|
}
|
|
594
|
-
|
|
595
|
-
if (regionId !== null) {
|
|
596
|
-
n = afterFrameRegion(n, regionId);
|
|
597
|
-
continue;
|
|
598
|
-
}
|
|
599
|
-
if (n.nodeType === ELEMENT_NODE) collectSlots(n, found);
|
|
546
|
+
if (n.nodeType === ELEMENT_NODE && !isFrameElement(n)) collectSlots(n, found);
|
|
600
547
|
n = n.nextSibling;
|
|
601
548
|
}
|
|
602
549
|
}
|
|
@@ -618,6 +565,7 @@ class FrameImpl {
|
|
|
618
565
|
if (this.#disposed) return;
|
|
619
566
|
this.#disposed = true;
|
|
620
567
|
for (const key of [...this.#slotCleanups.keys()]) this.#runSlotCleanups(key);
|
|
568
|
+
for (const key of this.#mountedSlots) this.#removeSlotRecord(key);
|
|
621
569
|
for (const regions of this.#slotRegions.values()) {
|
|
622
570
|
for (const {
|
|
623
571
|
frame
|
|
@@ -663,13 +611,7 @@ class FrameImpl {
|
|
|
663
611
|
}
|
|
664
612
|
#segmentReady(name) {
|
|
665
613
|
const content = this.#store[`seg:${name}`];
|
|
666
|
-
if (!content) return false;
|
|
667
|
-
if (content.kind === "block") {
|
|
668
|
-
const template = this.#store[content.template];
|
|
669
|
-
if (!template || template.kind !== "template") return false;
|
|
670
|
-
} else if (content.kind !== "html") {
|
|
671
|
-
return false;
|
|
672
|
-
}
|
|
614
|
+
if (!content || content.kind !== "html") return false;
|
|
673
615
|
if (!this.#store[`seg:${name}:reveal`]) return false;
|
|
674
616
|
const assets = this.#store[`seg:${name}:assets`];
|
|
675
617
|
if (assets && assets.styles) {
|
|
@@ -696,6 +638,23 @@ class FrameImpl {
|
|
|
696
638
|
parent.removeChild(n);
|
|
697
639
|
n = next;
|
|
698
640
|
}
|
|
641
|
+
if (this.#options.reveal) {
|
|
642
|
+
const fallbackFrag = tpl.content.cloneNode(true);
|
|
643
|
+
this.#claimTree(fallbackFrag);
|
|
644
|
+
this.#options.reveal({
|
|
645
|
+
before: closing,
|
|
646
|
+
fallback: [...fallbackFrag.childNodes],
|
|
647
|
+
content: () => {
|
|
648
|
+
const materialized = this.#materialize(content);
|
|
649
|
+
this.#syncSlots(materialized);
|
|
650
|
+
this.#claimTree(materialized);
|
|
651
|
+
return materialized;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
tpl.remove();
|
|
655
|
+
this.#revealed.add(name);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
699
658
|
const materialized = this.#materialize(content);
|
|
700
659
|
this.#claimTree(materialized);
|
|
701
660
|
parent.insertBefore(materialized, closing);
|
|
@@ -714,70 +673,37 @@ class FrameImpl {
|
|
|
714
673
|
return true;
|
|
715
674
|
}
|
|
716
675
|
#materialize(record) {
|
|
717
|
-
|
|
718
|
-
if (record.kind === "block") {
|
|
719
|
-
const template = this.#store[record.template];
|
|
720
|
-
if (!template || template.kind !== "template") return parseFragment("");
|
|
721
|
-
return materializeBlock(template, record.values);
|
|
722
|
-
}
|
|
723
|
-
return parseFragment("");
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
function materializeBlock(template, values) {
|
|
727
|
-
const fragment = parseFragment(template.html);
|
|
728
|
-
for (let i = 0; i < template.fields.length; i++) {
|
|
729
|
-
const marker = `field:${template.fields[i]}`;
|
|
730
|
-
const value = values[i] == null ? "" : String(values[i]);
|
|
731
|
-
let hole = findComment(fragment, marker);
|
|
732
|
-
while (hole) {
|
|
733
|
-
hole.replaceWith(document.createTextNode(value));
|
|
734
|
-
hole = findComment(fragment, marker);
|
|
735
|
-
}
|
|
676
|
+
return record.kind === "html" ? parseFragment(record.value) : parseFragment("");
|
|
736
677
|
}
|
|
737
|
-
return fragment;
|
|
738
678
|
}
|
|
739
679
|
function createFrame(boundary, options) {
|
|
740
680
|
return new FrameImpl(boundary, null, null, options);
|
|
741
681
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
const FRAME = Symbol.for("dom-expressions.frame");
|
|
749
|
-
function createFrameInsertable(options) {
|
|
750
|
-
let frame = null;
|
|
751
|
-
let start = null;
|
|
752
|
-
let end = null;
|
|
682
|
+
const FRAME_TAG = "dx-frame";
|
|
683
|
+
const FRAME_ID_ATTR = "data-fid";
|
|
684
|
+
function createFrameElement(options) {
|
|
685
|
+
const el = makeFrameElement(options.id);
|
|
686
|
+
const frame = new FrameImpl(el, null, null, options);
|
|
753
687
|
return {
|
|
688
|
+
element: el,
|
|
754
689
|
get frame() {
|
|
755
690
|
return frame;
|
|
756
691
|
},
|
|
757
692
|
dispose() {
|
|
758
|
-
if (!frame) return;
|
|
759
693
|
frame.dispose();
|
|
760
|
-
|
|
761
|
-
const parent = start.parentNode;
|
|
762
|
-
if (!parent) return;
|
|
763
|
-
let n = start;
|
|
764
|
-
while (n) {
|
|
765
|
-
const next = n.nextSibling;
|
|
766
|
-
parent.removeChild(n);
|
|
767
|
-
if (n === end) break;
|
|
768
|
-
n = next;
|
|
769
|
-
}
|
|
770
|
-
},
|
|
771
|
-
[FRAME](parent, marker) {
|
|
772
|
-
if (frame) return;
|
|
773
|
-
start = document.createComment("frame:start");
|
|
774
|
-
end = document.createComment("frame:end");
|
|
775
|
-
parent.insertBefore(start, marker);
|
|
776
|
-
parent.insertBefore(end, marker);
|
|
777
|
-
frame = new FrameImpl(null, start, end, options);
|
|
694
|
+
el.remove();
|
|
778
695
|
}
|
|
779
696
|
};
|
|
780
697
|
}
|
|
698
|
+
function makeFrameElement(id) {
|
|
699
|
+
const el = document.createElement(FRAME_TAG);
|
|
700
|
+
el.style.display = "contents";
|
|
701
|
+
if (id !== undefined) el.setAttribute(FRAME_ID_ATTR, id);
|
|
702
|
+
return el;
|
|
703
|
+
}
|
|
704
|
+
function isFrameElement(node) {
|
|
705
|
+
return node.nodeType === ELEMENT_NODE && node.hasAttribute(FRAME_ID_ATTR);
|
|
706
|
+
}
|
|
781
707
|
function segmentName(key) {
|
|
782
708
|
const m = /^seg:([^:]+)$/.exec(key);
|
|
783
709
|
return m ? m[1] : null;
|
|
@@ -876,29 +802,25 @@ function collectSlots(root, out) {
|
|
|
876
802
|
n = afterRange(n, id);
|
|
877
803
|
continue;
|
|
878
804
|
}
|
|
879
|
-
|
|
880
|
-
if (regionId !== null) {
|
|
881
|
-
n = afterFrameRegion(n, regionId);
|
|
882
|
-
continue;
|
|
883
|
-
}
|
|
884
|
-
if (n.nodeType === ELEMENT_NODE) collectSlots(n, out);
|
|
805
|
+
if (n.nodeType === ELEMENT_NODE && !isFrameElement(n)) collectSlots(n, out);
|
|
885
806
|
n = n.nextSibling;
|
|
886
807
|
}
|
|
887
808
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
if (node
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
809
|
+
function collectRegionElements(node, regions) {
|
|
810
|
+
if (node.nodeType !== ELEMENT_NODE) return;
|
|
811
|
+
if (isFrameElement(node)) {
|
|
812
|
+
const childId = node.getAttribute(FRAME_ID_ATTR);
|
|
813
|
+
if (childId && !regions.has(childId)) {
|
|
814
|
+
regions.set(childId, {
|
|
815
|
+
childId,
|
|
816
|
+
element: node,
|
|
817
|
+
frame: undefined,
|
|
818
|
+
adopt: true
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
return;
|
|
900
822
|
}
|
|
901
|
-
|
|
823
|
+
for (let c = node.firstChild; c; c = c.nextSibling) collectRegionElements(c, regions);
|
|
902
824
|
}
|
|
903
825
|
function argsEquivalent(a, b) {
|
|
904
826
|
if (a === b) return true;
|
|
@@ -926,18 +848,6 @@ function rangeInterior(start, endData) {
|
|
|
926
848
|
}
|
|
927
849
|
return nodes;
|
|
928
850
|
}
|
|
929
|
-
function findComment(root, data) {
|
|
930
|
-
const children = root.childNodes;
|
|
931
|
-
for (let i = 0; i < children.length; i++) {
|
|
932
|
-
const node = children[i];
|
|
933
|
-
if (node.nodeType === COMMENT_NODE && node.data === data) return node;
|
|
934
|
-
if (node.nodeType === ELEMENT_NODE) {
|
|
935
|
-
const found = findComment(node, data);
|
|
936
|
-
if (found) return found;
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
return null;
|
|
940
|
-
}
|
|
941
851
|
function slotStartId(node) {
|
|
942
852
|
if (node.nodeType !== COMMENT_NODE) return null;
|
|
943
853
|
const m = SLOT_START.exec(node.data);
|
|
@@ -953,12 +863,18 @@ function compatible(a, b) {
|
|
|
953
863
|
if (a.nodeType === ELEMENT_NODE) return a.nodeName === b.nodeName;
|
|
954
864
|
return a.nodeType === TEXT_NODE || a.nodeType === COMMENT_NODE;
|
|
955
865
|
}
|
|
866
|
+
function preservesOpen(el) {
|
|
867
|
+
const t = el.tagName;
|
|
868
|
+
return t === "DETAILS" || t === "DIALOG";
|
|
869
|
+
}
|
|
956
870
|
function morphAttributes(oldEl, newEl, claim) {
|
|
957
871
|
let reclaim = false;
|
|
958
872
|
let changed = false;
|
|
873
|
+
const keepOpen = preservesOpen(oldEl);
|
|
959
874
|
const oldAttrs = oldEl.attributes;
|
|
960
875
|
for (let i = oldAttrs.length - 1; i >= 0; i--) {
|
|
961
876
|
const name = oldAttrs[i].name;
|
|
877
|
+
if (keepOpen && name === "open") continue;
|
|
962
878
|
if (!newEl.hasAttribute(name)) {
|
|
963
879
|
oldEl.removeAttribute(name);
|
|
964
880
|
changed = true;
|
|
@@ -968,6 +884,7 @@ function morphAttributes(oldEl, newEl, claim) {
|
|
|
968
884
|
const newAttrs = newEl.attributes;
|
|
969
885
|
for (let i = 0; i < newAttrs.length; i++) {
|
|
970
886
|
const attr = newAttrs[i];
|
|
887
|
+
if (keepOpen && attr.name === "open") continue;
|
|
971
888
|
if (oldEl.getAttribute(attr.name) !== attr.value) {
|
|
972
889
|
oldEl.setAttribute(attr.name, attr.value);
|
|
973
890
|
changed = true;
|
|
@@ -978,6 +895,7 @@ function morphAttributes(oldEl, newEl, claim) {
|
|
|
978
895
|
}
|
|
979
896
|
function morphNode(oldNode, newNode, claim) {
|
|
980
897
|
if (oldNode.nodeType === ELEMENT_NODE) {
|
|
898
|
+
if (oldNode.hasAttribute("data-preserve")) return;
|
|
981
899
|
morphAttributes(oldNode, newNode, claim);
|
|
982
900
|
reconcileChildren(oldNode, newNode, null, null, claim);
|
|
983
901
|
} else if (oldNode.data !== newNode.data) {
|
|
@@ -1162,15 +1080,15 @@ class ChunkReader {
|
|
|
1162
1080
|
}
|
|
1163
1081
|
}
|
|
1164
1082
|
async next() {
|
|
1165
|
-
|
|
1083
|
+
while (this.buffer.length < 12) {
|
|
1166
1084
|
if (this.done) {
|
|
1167
|
-
return {
|
|
1085
|
+
if (this.buffer.length === 0) return {
|
|
1168
1086
|
done: true,
|
|
1169
1087
|
value: undefined
|
|
1170
1088
|
};
|
|
1089
|
+
throw new Error("Malformed server function stream.");
|
|
1171
1090
|
}
|
|
1172
1091
|
await this.readChunk();
|
|
1173
|
-
return await this.next();
|
|
1174
1092
|
}
|
|
1175
1093
|
const head = new TextDecoder().decode(this.buffer.subarray(1, 11));
|
|
1176
1094
|
const bytes = Number.parseInt(head, 16);
|
|
@@ -1283,6 +1201,9 @@ function tableFor(id) {
|
|
|
1283
1201
|
for (const [root, t] of tables) if (id.startsWith(root + ".")) return t;
|
|
1284
1202
|
return undefined;
|
|
1285
1203
|
}
|
|
1204
|
+
function beginStream(frameId) {
|
|
1205
|
+
tables.set(frameId, createJSONDataTable());
|
|
1206
|
+
}
|
|
1286
1207
|
function getFrameHost() {
|
|
1287
1208
|
if (!sharedHost) {
|
|
1288
1209
|
sharedHost = createFrameHost({
|
|
@@ -1355,50 +1276,44 @@ function slotsFor(props) {
|
|
|
1355
1276
|
}
|
|
1356
1277
|
});
|
|
1357
1278
|
}
|
|
1279
|
+
function revealSeam(owner) {
|
|
1280
|
+
return seam => solidJs.runWithOwner(owner, () => web$1.insert(seam.before.parentNode, solidJs.createLoadingBoundary(() => seam.content(), () => seam.fallback), seam.before));
|
|
1281
|
+
}
|
|
1358
1282
|
function boundaryComponent(host, id) {
|
|
1359
1283
|
return props => {
|
|
1360
1284
|
const owner = solidJs.getOwner();
|
|
1361
|
-
const
|
|
1285
|
+
const {
|
|
1286
|
+
element,
|
|
1287
|
+
dispose
|
|
1288
|
+
} = createFrameElement({
|
|
1362
1289
|
host,
|
|
1363
1290
|
id,
|
|
1364
1291
|
slots: slotsFor(props),
|
|
1365
|
-
ownerScope: fn => solidJs.runWithOwner(owner, fn)
|
|
1292
|
+
ownerScope: fn => solidJs.runWithOwner(owner, fn),
|
|
1293
|
+
reveal: revealSeam(owner)
|
|
1366
1294
|
});
|
|
1367
|
-
solidJs.onCleanup(
|
|
1368
|
-
return
|
|
1295
|
+
solidJs.onCleanup(dispose);
|
|
1296
|
+
return element;
|
|
1369
1297
|
};
|
|
1370
1298
|
}
|
|
1371
1299
|
const claimedBoundaries = new Set();
|
|
1372
1300
|
let boundaryIndex = null;
|
|
1373
|
-
function
|
|
1301
|
+
function findBoundaryElement(id) {
|
|
1374
1302
|
if (!boundaryIndex) {
|
|
1375
1303
|
boundaryIndex = new Map();
|
|
1376
1304
|
if (typeof document !== "undefined" && document.body) {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
const d = c.data;
|
|
1382
|
-
if (!d.startsWith("frame:")) continue;
|
|
1383
|
-
if (d.endsWith(":start")) {
|
|
1384
|
-
const key = d.slice(6, -6);
|
|
1385
|
-
if (key && !(key in opens)) opens[key] = c;
|
|
1386
|
-
} else if (d.endsWith(":end")) {
|
|
1387
|
-
const key = d.slice(6, -4);
|
|
1388
|
-
if (key && opens[key] && !boundaryIndex.has(key)) {
|
|
1389
|
-
boundaryIndex.set(key, [opens[key], c]);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1305
|
+
document.body.querySelectorAll(`[${FRAME_ID_ATTR}]`).forEach(el => {
|
|
1306
|
+
const key = el.getAttribute(FRAME_ID_ATTR);
|
|
1307
|
+
if (key && !boundaryIndex.has(key)) boundaryIndex.set(key, el);
|
|
1308
|
+
});
|
|
1393
1309
|
}
|
|
1394
1310
|
}
|
|
1395
1311
|
return boundaryIndex.get(id);
|
|
1396
1312
|
}
|
|
1397
1313
|
function documentBoundary(host, id, props) {
|
|
1398
|
-
const
|
|
1399
|
-
if (!
|
|
1314
|
+
const el = !claimedBoundaries.has(id) ? findBoundaryElement(id) : undefined;
|
|
1315
|
+
if (!el) return boundaryComponent(host, id)(props);
|
|
1400
1316
|
claimedBoundaries.add(id);
|
|
1401
|
-
const [start, end] = range;
|
|
1402
1317
|
const hy = globalThis._$HY;
|
|
1403
1318
|
if (hy && hy.r) {
|
|
1404
1319
|
const slotPrefix = `sc:slot:${id}:`;
|
|
@@ -1427,19 +1342,16 @@ function documentBoundary(host, id, props) {
|
|
|
1427
1342
|
}
|
|
1428
1343
|
}
|
|
1429
1344
|
const owner = solidJs.getOwner();
|
|
1430
|
-
const frame =
|
|
1345
|
+
const frame = createFrame(el, {
|
|
1346
|
+
adopt: true,
|
|
1431
1347
|
host,
|
|
1432
1348
|
id,
|
|
1433
1349
|
slots: slotsFor(props),
|
|
1434
|
-
ownerScope: fn => solidJs.runWithOwner(owner, fn)
|
|
1350
|
+
ownerScope: fn => solidJs.runWithOwner(owner, fn),
|
|
1351
|
+
reveal: revealSeam(owner)
|
|
1435
1352
|
});
|
|
1436
1353
|
solidJs.onCleanup(() => frame.dispose());
|
|
1437
|
-
|
|
1438
|
-
for (let n = start; n; n = n.nextSibling) {
|
|
1439
|
-
nodes.push(n);
|
|
1440
|
-
if (n === end) break;
|
|
1441
|
-
}
|
|
1442
|
-
return nodes;
|
|
1354
|
+
return el;
|
|
1443
1355
|
}
|
|
1444
1356
|
function installServerComponents(host = getFrameHost()) {
|
|
1445
1357
|
const g = globalThis;
|
|
@@ -1452,14 +1364,29 @@ function installServerComponents(host = getFrameHost()) {
|
|
|
1452
1364
|
};
|
|
1453
1365
|
}
|
|
1454
1366
|
g._$SC.impl = (id, props) => documentBoundary(host, id, props);
|
|
1367
|
+
client.configureServerFunctionsClient({
|
|
1368
|
+
responseHandler: createServerComponentHandler({
|
|
1369
|
+
host,
|
|
1370
|
+
capture: () => solidJs.getOwner() ?? undefined,
|
|
1371
|
+
component: frameId => boundaryComponent(host, frameId),
|
|
1372
|
+
onStream: frameId => beginStream(frameId),
|
|
1373
|
+
documentComponent: functionId => g._$SC.c[functionId],
|
|
1374
|
+
intercept: ({
|
|
1375
|
+
id
|
|
1376
|
+
}) => {
|
|
1377
|
+
if (claimedBoundaries.has(id) || !findBoundaryElement(id)) return undefined;
|
|
1378
|
+
return g._$SC.r(id);
|
|
1379
|
+
}
|
|
1380
|
+
})
|
|
1381
|
+
});
|
|
1455
1382
|
}
|
|
1456
1383
|
|
|
1457
1384
|
exports.FRAME_APPLIED_EVENT = FRAME_APPLIED_EVENT;
|
|
1458
1385
|
exports.FRAME_STREAM_HEADER = FRAME_STREAM_HEADER;
|
|
1459
1386
|
exports.applyFrameResponse = applyFrameResponse;
|
|
1460
1387
|
exports.createFrame = createFrame;
|
|
1388
|
+
exports.createFrameElement = createFrameElement;
|
|
1461
1389
|
exports.createFrameHost = createFrameHost;
|
|
1462
|
-
exports.createFrameInsertable = createFrameInsertable;
|
|
1463
1390
|
exports.createJSONDataTable = createJSONDataTable;
|
|
1464
1391
|
exports.createServerComponentHandler = createServerComponentHandler;
|
|
1465
1392
|
exports.getFrameHost = getFrameHost;
|