marko 6.0.96 → 6.0.97
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/debug/html.js +65 -80
- package/dist/debug/html.mjs +65 -80
- package/dist/html/serializer.d.ts +2 -2
- package/dist/html.js +59 -40
- package/dist/html.mjs +59 -40
- package/dist/translator/index.js +11 -7
- package/dist/translator/util/sections.d.ts +1 -0
- package/package.json +1 -1
package/dist/debug/html.js
CHANGED
|
@@ -625,13 +625,15 @@ var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
|
|
|
625
625
|
var State = class {
|
|
626
626
|
ids = 0;
|
|
627
627
|
flush = 0;
|
|
628
|
+
registerInstanceId = 0;
|
|
628
629
|
flushed = false;
|
|
629
630
|
wroteUndefined = false;
|
|
630
631
|
buf = [];
|
|
631
632
|
refs = /* @__PURE__ */ new WeakMap();
|
|
632
633
|
assigned = /* @__PURE__ */ new Set();
|
|
634
|
+
registered = [];
|
|
633
635
|
boundary = void 0;
|
|
634
|
-
|
|
636
|
+
mutated = [];
|
|
635
637
|
};
|
|
636
638
|
var Reference = class {
|
|
637
639
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
|
@@ -646,7 +648,7 @@ var Reference = class {
|
|
|
646
648
|
this.pos = pos;
|
|
647
649
|
this.id = id;
|
|
648
650
|
}
|
|
649
|
-
|
|
651
|
+
registered = null;
|
|
650
652
|
assigns = null;
|
|
651
653
|
};
|
|
652
654
|
var DEBUG = /* @__PURE__ */ new WeakMap();
|
|
@@ -678,7 +680,7 @@ var Serializer = class {
|
|
|
678
680
|
}
|
|
679
681
|
writeCall(value, object, property, spread) {
|
|
680
682
|
const state = this.#state;
|
|
681
|
-
state.
|
|
683
|
+
state.mutated.push({
|
|
682
684
|
type: 0 /* call */,
|
|
683
685
|
value,
|
|
684
686
|
object,
|
|
@@ -689,7 +691,7 @@ var Serializer = class {
|
|
|
689
691
|
}
|
|
690
692
|
writeAssign(value, object, property) {
|
|
691
693
|
const state = this.#state;
|
|
692
|
-
state.
|
|
694
|
+
state.mutated.push({
|
|
693
695
|
type: 1 /* assign */,
|
|
694
696
|
value,
|
|
695
697
|
object,
|
|
@@ -697,13 +699,21 @@ var Serializer = class {
|
|
|
697
699
|
});
|
|
698
700
|
state.flushed = true;
|
|
699
701
|
}
|
|
702
|
+
register(id, val, scope) {
|
|
703
|
+
return register(
|
|
704
|
+
id,
|
|
705
|
+
val,
|
|
706
|
+
scope,
|
|
707
|
+
scope ? ++this.#state.registerInstanceId : 0
|
|
708
|
+
);
|
|
709
|
+
}
|
|
700
710
|
};
|
|
701
|
-
function register(id, val, scope) {
|
|
711
|
+
function register(id, val, scope, instanceId) {
|
|
702
712
|
REGISTRY.set(val, {
|
|
703
713
|
id,
|
|
704
714
|
scope,
|
|
705
|
-
|
|
706
|
-
|
|
715
|
+
instanceId: instanceId ?? 0,
|
|
716
|
+
access: "_._" + toAccess(toObjectKey(id))
|
|
707
717
|
});
|
|
708
718
|
return val;
|
|
709
719
|
}
|
|
@@ -714,7 +724,7 @@ function getRegistered(val) {
|
|
|
714
724
|
}
|
|
715
725
|
}
|
|
716
726
|
function writeRoot(state, root) {
|
|
717
|
-
const { buf
|
|
727
|
+
const { buf } = state;
|
|
718
728
|
const hadBuf = buf.length !== 0;
|
|
719
729
|
let result = "";
|
|
720
730
|
if (hadBuf) {
|
|
@@ -724,8 +734,8 @@ function writeRoot(state, root) {
|
|
|
724
734
|
const rootRef = state.refs.get(root);
|
|
725
735
|
if (rootRef) {
|
|
726
736
|
const rootId = ensureId(state, rootRef);
|
|
727
|
-
if (assigned.size ||
|
|
728
|
-
assigned.delete(rootRef);
|
|
737
|
+
if (state.assigned.size || state.registered.length || state.mutated.length) {
|
|
738
|
+
state.assigned.delete(rootRef);
|
|
729
739
|
writeAssigned(state);
|
|
730
740
|
buf.push(
|
|
731
741
|
"," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
|
|
@@ -754,27 +764,30 @@ function writeRoot(state, root) {
|
|
|
754
764
|
}
|
|
755
765
|
function writeAssigned(state) {
|
|
756
766
|
if (state.assigned.size) {
|
|
757
|
-
let
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
inits += "," + (valueRef.assigns ? assignsToString(valueRef.assigns, valueRef.init) : valueRef.init);
|
|
762
|
-
valueRef.init = "";
|
|
763
|
-
} else if (valueRef.assigns) {
|
|
764
|
-
assigns += "," + assignsToString(valueRef.assigns, valueRef.id);
|
|
765
|
-
}
|
|
766
|
-
valueRef.assigns = null;
|
|
767
|
-
}
|
|
768
|
-
if (assigns) {
|
|
769
|
-
state.buf.push(assigns);
|
|
770
|
-
}
|
|
771
|
-
if (inits) {
|
|
772
|
-
state.buf.push(inits);
|
|
767
|
+
let buf = "";
|
|
768
|
+
for (const ref of state.assigned) {
|
|
769
|
+
buf += "," + assignsToString(ref.assigns, ref.id);
|
|
770
|
+
ref.assigns = null;
|
|
773
771
|
}
|
|
772
|
+
state.buf.push(buf);
|
|
774
773
|
state.assigned = /* @__PURE__ */ new Set();
|
|
775
774
|
}
|
|
776
|
-
if (state.
|
|
777
|
-
|
|
775
|
+
if (state.registered.length) {
|
|
776
|
+
let buf = "";
|
|
777
|
+
for (const ref of state.registered.sort(compareRegisteredReferences)) {
|
|
778
|
+
const scopeRef = state.refs.get(ref.registered.scope);
|
|
779
|
+
buf += "," + assignsToString(
|
|
780
|
+
ref.assigns,
|
|
781
|
+
ref.registered.access + "(" + (scopeRef ? ensureId(state, scopeRef) : ref.assigns[0]) + ")"
|
|
782
|
+
);
|
|
783
|
+
ref.assigns = null;
|
|
784
|
+
ref.registered = null;
|
|
785
|
+
}
|
|
786
|
+
state.buf.push(buf);
|
|
787
|
+
state.registered = [];
|
|
788
|
+
}
|
|
789
|
+
if (state.mutated.length) {
|
|
790
|
+
for (const mutation of state.mutated) {
|
|
778
791
|
const hasSeen = state.refs.get(mutation.object)?.id;
|
|
779
792
|
const objectStartIndex = state.buf.push(
|
|
780
793
|
state.buf.length === 0 ? "" : ","
|
|
@@ -811,8 +824,8 @@ function writeAssigned(state) {
|
|
|
811
824
|
state.buf.push(")");
|
|
812
825
|
}
|
|
813
826
|
}
|
|
814
|
-
state.
|
|
815
|
-
if (state.assigned.size) {
|
|
827
|
+
state.mutated = [];
|
|
828
|
+
if (state.assigned.size || state.registered.length) {
|
|
816
829
|
writeAssigned(state);
|
|
817
830
|
}
|
|
818
831
|
}
|
|
@@ -841,17 +854,16 @@ function writeProp(state, val, parent, accessor) {
|
|
|
841
854
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
842
855
|
let ref = state.refs.get(val);
|
|
843
856
|
if (ref) {
|
|
844
|
-
if (
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
if (!ref.assigns) {
|
|
857
|
+
if (parent) {
|
|
858
|
+
if (ref.assigns) {
|
|
859
|
+
addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
|
|
860
|
+
return false;
|
|
861
|
+
} else if (isCircular(parent, ref)) {
|
|
850
862
|
ensureId(state, ref);
|
|
851
863
|
state.assigned.add(ref);
|
|
864
|
+
addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
|
|
865
|
+
return false;
|
|
852
866
|
}
|
|
853
|
-
addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
|
|
854
|
-
return false;
|
|
855
867
|
}
|
|
856
868
|
state.buf.push(ensureId(state, ref));
|
|
857
869
|
return true;
|
|
@@ -870,55 +882,21 @@ function writeReferenceOr(state, write, val, parent, accessor) {
|
|
|
870
882
|
state.refs.delete(val);
|
|
871
883
|
return false;
|
|
872
884
|
}
|
|
873
|
-
function writeRegistered(state, val, parent, accessor,
|
|
874
|
-
if (scope) {
|
|
875
|
-
const scopeRef = state.refs.get(scope);
|
|
885
|
+
function writeRegistered(state, val, parent, accessor, registered) {
|
|
886
|
+
if (parent && registered.scope) {
|
|
876
887
|
const fnRef = new Reference(
|
|
877
888
|
parent,
|
|
878
889
|
accessor,
|
|
879
890
|
state.flush,
|
|
880
891
|
state.buf.length
|
|
881
892
|
);
|
|
893
|
+
fnRef.registered = registered;
|
|
882
894
|
state.refs.set(val, fnRef);
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
return true;
|
|
887
|
-
}
|
|
888
|
-
state.buf.push("(s=>()=>s" + access + ")(");
|
|
889
|
-
writeProp(state, scope, parent, "");
|
|
890
|
-
state.buf.push(")");
|
|
891
|
-
const newScopeRef = state.refs.get(scope);
|
|
892
|
-
if (newScopeRef) ensureId(state, newScopeRef);
|
|
893
|
-
return true;
|
|
894
|
-
}
|
|
895
|
-
if (scopeRef) {
|
|
896
|
-
if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef))) {
|
|
897
|
-
state.assigned.add(parent);
|
|
898
|
-
state.assigned.add(fnRef);
|
|
899
|
-
fnRef.init = access + "(" + ensureId(state, scopeRef) + ")";
|
|
900
|
-
addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
|
|
901
|
-
return false;
|
|
902
|
-
}
|
|
903
|
-
state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
|
|
904
|
-
} else {
|
|
905
|
-
const pos = state.buf.push("") - 1;
|
|
906
|
-
const assigns = state.assigned.size;
|
|
907
|
-
writeProp(state, scope, parent, "");
|
|
908
|
-
const scopeRef2 = parent && state.refs.get(scope);
|
|
909
|
-
const scopeId = scopeRef2 && ensureId(state, scopeRef2);
|
|
910
|
-
if (scopeId && assigns !== state.assigned.size) {
|
|
911
|
-
state.assigned.add(parent);
|
|
912
|
-
state.assigned.add(fnRef);
|
|
913
|
-
fnRef.init = access + "(" + scopeId + ")";
|
|
914
|
-
addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
|
|
915
|
-
} else {
|
|
916
|
-
state.buf[pos] = access + "(" + state.buf[pos];
|
|
917
|
-
state.buf.push(")");
|
|
918
|
-
}
|
|
919
|
-
}
|
|
895
|
+
state.registered.push(fnRef);
|
|
896
|
+
addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
|
|
897
|
+
return !state.refs.has(registered.scope) && writeProp(state, registered.scope, null, "");
|
|
920
898
|
} else {
|
|
921
|
-
state.buf.push(access);
|
|
899
|
+
state.buf.push(registered.access);
|
|
922
900
|
}
|
|
923
901
|
return true;
|
|
924
902
|
}
|
|
@@ -1731,6 +1709,9 @@ function patchIteratorNext(proto) {
|
|
|
1731
1709
|
return next.call(this, value);
|
|
1732
1710
|
};
|
|
1733
1711
|
}
|
|
1712
|
+
function compareRegisteredReferences(a, b) {
|
|
1713
|
+
return a.registered.instanceId - b.registered.instanceId;
|
|
1714
|
+
}
|
|
1734
1715
|
|
|
1735
1716
|
// src/html/writer.ts
|
|
1736
1717
|
var $chunk;
|
|
@@ -1819,7 +1800,11 @@ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
|
|
|
1819
1800
|
);
|
|
1820
1801
|
}
|
|
1821
1802
|
function _resume(val, id, scopeId) {
|
|
1822
|
-
return scopeId === void 0 ? register(id, val) : register(
|
|
1803
|
+
return scopeId === void 0 ? register(id, val) : $chunk.boundary.state.serializer.register(
|
|
1804
|
+
id,
|
|
1805
|
+
val,
|
|
1806
|
+
_scope_with_id(scopeId)
|
|
1807
|
+
);
|
|
1823
1808
|
}
|
|
1824
1809
|
function _id() {
|
|
1825
1810
|
const state = $chunk.boundary.state;
|
package/dist/debug/html.mjs
CHANGED
|
@@ -533,13 +533,15 @@ var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
|
|
|
533
533
|
var State = class {
|
|
534
534
|
ids = 0;
|
|
535
535
|
flush = 0;
|
|
536
|
+
registerInstanceId = 0;
|
|
536
537
|
flushed = false;
|
|
537
538
|
wroteUndefined = false;
|
|
538
539
|
buf = [];
|
|
539
540
|
refs = /* @__PURE__ */ new WeakMap();
|
|
540
541
|
assigned = /* @__PURE__ */ new Set();
|
|
542
|
+
registered = [];
|
|
541
543
|
boundary = void 0;
|
|
542
|
-
|
|
544
|
+
mutated = [];
|
|
543
545
|
};
|
|
544
546
|
var Reference = class {
|
|
545
547
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
|
@@ -554,7 +556,7 @@ var Reference = class {
|
|
|
554
556
|
this.pos = pos;
|
|
555
557
|
this.id = id;
|
|
556
558
|
}
|
|
557
|
-
|
|
559
|
+
registered = null;
|
|
558
560
|
assigns = null;
|
|
559
561
|
};
|
|
560
562
|
var DEBUG = /* @__PURE__ */ new WeakMap();
|
|
@@ -586,7 +588,7 @@ var Serializer = class {
|
|
|
586
588
|
}
|
|
587
589
|
writeCall(value, object, property, spread) {
|
|
588
590
|
const state = this.#state;
|
|
589
|
-
state.
|
|
591
|
+
state.mutated.push({
|
|
590
592
|
type: 0 /* call */,
|
|
591
593
|
value,
|
|
592
594
|
object,
|
|
@@ -597,7 +599,7 @@ var Serializer = class {
|
|
|
597
599
|
}
|
|
598
600
|
writeAssign(value, object, property) {
|
|
599
601
|
const state = this.#state;
|
|
600
|
-
state.
|
|
602
|
+
state.mutated.push({
|
|
601
603
|
type: 1 /* assign */,
|
|
602
604
|
value,
|
|
603
605
|
object,
|
|
@@ -605,13 +607,21 @@ var Serializer = class {
|
|
|
605
607
|
});
|
|
606
608
|
state.flushed = true;
|
|
607
609
|
}
|
|
610
|
+
register(id, val, scope) {
|
|
611
|
+
return register(
|
|
612
|
+
id,
|
|
613
|
+
val,
|
|
614
|
+
scope,
|
|
615
|
+
scope ? ++this.#state.registerInstanceId : 0
|
|
616
|
+
);
|
|
617
|
+
}
|
|
608
618
|
};
|
|
609
|
-
function register(id, val, scope) {
|
|
619
|
+
function register(id, val, scope, instanceId) {
|
|
610
620
|
REGISTRY.set(val, {
|
|
611
621
|
id,
|
|
612
622
|
scope,
|
|
613
|
-
|
|
614
|
-
|
|
623
|
+
instanceId: instanceId ?? 0,
|
|
624
|
+
access: "_._" + toAccess(toObjectKey(id))
|
|
615
625
|
});
|
|
616
626
|
return val;
|
|
617
627
|
}
|
|
@@ -622,7 +632,7 @@ function getRegistered(val) {
|
|
|
622
632
|
}
|
|
623
633
|
}
|
|
624
634
|
function writeRoot(state, root) {
|
|
625
|
-
const { buf
|
|
635
|
+
const { buf } = state;
|
|
626
636
|
const hadBuf = buf.length !== 0;
|
|
627
637
|
let result = "";
|
|
628
638
|
if (hadBuf) {
|
|
@@ -632,8 +642,8 @@ function writeRoot(state, root) {
|
|
|
632
642
|
const rootRef = state.refs.get(root);
|
|
633
643
|
if (rootRef) {
|
|
634
644
|
const rootId = ensureId(state, rootRef);
|
|
635
|
-
if (assigned.size ||
|
|
636
|
-
assigned.delete(rootRef);
|
|
645
|
+
if (state.assigned.size || state.registered.length || state.mutated.length) {
|
|
646
|
+
state.assigned.delete(rootRef);
|
|
637
647
|
writeAssigned(state);
|
|
638
648
|
buf.push(
|
|
639
649
|
"," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
|
|
@@ -662,27 +672,30 @@ function writeRoot(state, root) {
|
|
|
662
672
|
}
|
|
663
673
|
function writeAssigned(state) {
|
|
664
674
|
if (state.assigned.size) {
|
|
665
|
-
let
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
inits += "," + (valueRef.assigns ? assignsToString(valueRef.assigns, valueRef.init) : valueRef.init);
|
|
670
|
-
valueRef.init = "";
|
|
671
|
-
} else if (valueRef.assigns) {
|
|
672
|
-
assigns += "," + assignsToString(valueRef.assigns, valueRef.id);
|
|
673
|
-
}
|
|
674
|
-
valueRef.assigns = null;
|
|
675
|
-
}
|
|
676
|
-
if (assigns) {
|
|
677
|
-
state.buf.push(assigns);
|
|
678
|
-
}
|
|
679
|
-
if (inits) {
|
|
680
|
-
state.buf.push(inits);
|
|
675
|
+
let buf = "";
|
|
676
|
+
for (const ref of state.assigned) {
|
|
677
|
+
buf += "," + assignsToString(ref.assigns, ref.id);
|
|
678
|
+
ref.assigns = null;
|
|
681
679
|
}
|
|
680
|
+
state.buf.push(buf);
|
|
682
681
|
state.assigned = /* @__PURE__ */ new Set();
|
|
683
682
|
}
|
|
684
|
-
if (state.
|
|
685
|
-
|
|
683
|
+
if (state.registered.length) {
|
|
684
|
+
let buf = "";
|
|
685
|
+
for (const ref of state.registered.sort(compareRegisteredReferences)) {
|
|
686
|
+
const scopeRef = state.refs.get(ref.registered.scope);
|
|
687
|
+
buf += "," + assignsToString(
|
|
688
|
+
ref.assigns,
|
|
689
|
+
ref.registered.access + "(" + (scopeRef ? ensureId(state, scopeRef) : ref.assigns[0]) + ")"
|
|
690
|
+
);
|
|
691
|
+
ref.assigns = null;
|
|
692
|
+
ref.registered = null;
|
|
693
|
+
}
|
|
694
|
+
state.buf.push(buf);
|
|
695
|
+
state.registered = [];
|
|
696
|
+
}
|
|
697
|
+
if (state.mutated.length) {
|
|
698
|
+
for (const mutation of state.mutated) {
|
|
686
699
|
const hasSeen = state.refs.get(mutation.object)?.id;
|
|
687
700
|
const objectStartIndex = state.buf.push(
|
|
688
701
|
state.buf.length === 0 ? "" : ","
|
|
@@ -719,8 +732,8 @@ function writeAssigned(state) {
|
|
|
719
732
|
state.buf.push(")");
|
|
720
733
|
}
|
|
721
734
|
}
|
|
722
|
-
state.
|
|
723
|
-
if (state.assigned.size) {
|
|
735
|
+
state.mutated = [];
|
|
736
|
+
if (state.assigned.size || state.registered.length) {
|
|
724
737
|
writeAssigned(state);
|
|
725
738
|
}
|
|
726
739
|
}
|
|
@@ -749,17 +762,16 @@ function writeProp(state, val, parent, accessor) {
|
|
|
749
762
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
750
763
|
let ref = state.refs.get(val);
|
|
751
764
|
if (ref) {
|
|
752
|
-
if (
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
if (!ref.assigns) {
|
|
765
|
+
if (parent) {
|
|
766
|
+
if (ref.assigns) {
|
|
767
|
+
addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
|
|
768
|
+
return false;
|
|
769
|
+
} else if (isCircular(parent, ref)) {
|
|
758
770
|
ensureId(state, ref);
|
|
759
771
|
state.assigned.add(ref);
|
|
772
|
+
addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
|
|
773
|
+
return false;
|
|
760
774
|
}
|
|
761
|
-
addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
|
|
762
|
-
return false;
|
|
763
775
|
}
|
|
764
776
|
state.buf.push(ensureId(state, ref));
|
|
765
777
|
return true;
|
|
@@ -778,55 +790,21 @@ function writeReferenceOr(state, write, val, parent, accessor) {
|
|
|
778
790
|
state.refs.delete(val);
|
|
779
791
|
return false;
|
|
780
792
|
}
|
|
781
|
-
function writeRegistered(state, val, parent, accessor,
|
|
782
|
-
if (scope) {
|
|
783
|
-
const scopeRef = state.refs.get(scope);
|
|
793
|
+
function writeRegistered(state, val, parent, accessor, registered) {
|
|
794
|
+
if (parent && registered.scope) {
|
|
784
795
|
const fnRef = new Reference(
|
|
785
796
|
parent,
|
|
786
797
|
accessor,
|
|
787
798
|
state.flush,
|
|
788
799
|
state.buf.length
|
|
789
800
|
);
|
|
801
|
+
fnRef.registered = registered;
|
|
790
802
|
state.refs.set(val, fnRef);
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
return true;
|
|
795
|
-
}
|
|
796
|
-
state.buf.push("(s=>()=>s" + access + ")(");
|
|
797
|
-
writeProp(state, scope, parent, "");
|
|
798
|
-
state.buf.push(")");
|
|
799
|
-
const newScopeRef = state.refs.get(scope);
|
|
800
|
-
if (newScopeRef) ensureId(state, newScopeRef);
|
|
801
|
-
return true;
|
|
802
|
-
}
|
|
803
|
-
if (scopeRef) {
|
|
804
|
-
if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef))) {
|
|
805
|
-
state.assigned.add(parent);
|
|
806
|
-
state.assigned.add(fnRef);
|
|
807
|
-
fnRef.init = access + "(" + ensureId(state, scopeRef) + ")";
|
|
808
|
-
addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
|
|
809
|
-
return false;
|
|
810
|
-
}
|
|
811
|
-
state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
|
|
812
|
-
} else {
|
|
813
|
-
const pos = state.buf.push("") - 1;
|
|
814
|
-
const assigns = state.assigned.size;
|
|
815
|
-
writeProp(state, scope, parent, "");
|
|
816
|
-
const scopeRef2 = parent && state.refs.get(scope);
|
|
817
|
-
const scopeId = scopeRef2 && ensureId(state, scopeRef2);
|
|
818
|
-
if (scopeId && assigns !== state.assigned.size) {
|
|
819
|
-
state.assigned.add(parent);
|
|
820
|
-
state.assigned.add(fnRef);
|
|
821
|
-
fnRef.init = access + "(" + scopeId + ")";
|
|
822
|
-
addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
|
|
823
|
-
} else {
|
|
824
|
-
state.buf[pos] = access + "(" + state.buf[pos];
|
|
825
|
-
state.buf.push(")");
|
|
826
|
-
}
|
|
827
|
-
}
|
|
803
|
+
state.registered.push(fnRef);
|
|
804
|
+
addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
|
|
805
|
+
return !state.refs.has(registered.scope) && writeProp(state, registered.scope, null, "");
|
|
828
806
|
} else {
|
|
829
|
-
state.buf.push(access);
|
|
807
|
+
state.buf.push(registered.access);
|
|
830
808
|
}
|
|
831
809
|
return true;
|
|
832
810
|
}
|
|
@@ -1639,6 +1617,9 @@ function patchIteratorNext(proto) {
|
|
|
1639
1617
|
return next.call(this, value);
|
|
1640
1618
|
};
|
|
1641
1619
|
}
|
|
1620
|
+
function compareRegisteredReferences(a, b) {
|
|
1621
|
+
return a.registered.instanceId - b.registered.instanceId;
|
|
1622
|
+
}
|
|
1642
1623
|
|
|
1643
1624
|
// src/html/writer.ts
|
|
1644
1625
|
var $chunk;
|
|
@@ -1727,7 +1708,11 @@ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
|
|
|
1727
1708
|
);
|
|
1728
1709
|
}
|
|
1729
1710
|
function _resume(val, id, scopeId) {
|
|
1730
|
-
return scopeId === void 0 ? register(id, val) : register(
|
|
1711
|
+
return scopeId === void 0 ? register(id, val) : $chunk.boundary.state.serializer.register(
|
|
1712
|
+
id,
|
|
1713
|
+
val,
|
|
1714
|
+
_scope_with_id(scopeId)
|
|
1715
|
+
);
|
|
1731
1716
|
}
|
|
1732
1717
|
function _id() {
|
|
1733
1718
|
const state = $chunk.boundary.state;
|
|
@@ -8,9 +8,9 @@ export declare class Serializer {
|
|
|
8
8
|
symbol(id: string): symbol;
|
|
9
9
|
writeCall(value: unknown, object: unknown, property?: string, spread?: boolean): void;
|
|
10
10
|
writeAssign(value: unknown, object: unknown, property: string): void;
|
|
11
|
+
register<T extends WeakKey>(id: string, val: T, scope?: unknown): T;
|
|
11
12
|
}
|
|
12
|
-
export declare function register<T extends WeakKey>(id: string, val: T, scope?: unknown): T;
|
|
13
|
-
export declare function registerGetter<T extends WeakKey>(accessor: string, val: T, scope?: unknown): T;
|
|
13
|
+
export declare function register<T extends WeakKey>(id: string, val: T, scope?: unknown, instanceId?: number): T;
|
|
14
14
|
export declare function getRegistered(val: WeakKey): {
|
|
15
15
|
id: string;
|
|
16
16
|
scope: unknown;
|
package/dist/html.js
CHANGED
|
@@ -453,13 +453,15 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
|
453
453
|
]), State = class {
|
|
454
454
|
ids = 0;
|
|
455
455
|
flush = 0;
|
|
456
|
+
registerInstanceId = 0;
|
|
456
457
|
flushed = !1;
|
|
457
458
|
wroteUndefined = !1;
|
|
458
459
|
buf = [];
|
|
459
460
|
refs = /* @__PURE__ */ new WeakMap();
|
|
460
461
|
assigned = /* @__PURE__ */ new Set();
|
|
462
|
+
registered = [];
|
|
461
463
|
boundary = void 0;
|
|
462
|
-
|
|
464
|
+
mutated = [];
|
|
463
465
|
}, Reference = class {
|
|
464
466
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
|
465
467
|
this.parent = parent;
|
|
@@ -469,7 +471,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
|
469
471
|
this.id = id;
|
|
470
472
|
this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
|
|
471
473
|
}
|
|
472
|
-
|
|
474
|
+
registered = null;
|
|
473
475
|
assigns = null;
|
|
474
476
|
};
|
|
475
477
|
var Serializer = class {
|
|
@@ -493,7 +495,7 @@ var Serializer = class {
|
|
|
493
495
|
}
|
|
494
496
|
writeCall(value, object, property, spread) {
|
|
495
497
|
let state = this.#state;
|
|
496
|
-
state.
|
|
498
|
+
state.mutated.push({
|
|
497
499
|
type: 0 /* call */,
|
|
498
500
|
value,
|
|
499
501
|
object,
|
|
@@ -503,20 +505,28 @@ var Serializer = class {
|
|
|
503
505
|
}
|
|
504
506
|
writeAssign(value, object, property) {
|
|
505
507
|
let state = this.#state;
|
|
506
|
-
state.
|
|
508
|
+
state.mutated.push({
|
|
507
509
|
type: 1 /* assign */,
|
|
508
510
|
value,
|
|
509
511
|
object,
|
|
510
512
|
property
|
|
511
513
|
}), state.flushed = !0;
|
|
512
514
|
}
|
|
515
|
+
register(id, val, scope) {
|
|
516
|
+
return register(
|
|
517
|
+
id,
|
|
518
|
+
val,
|
|
519
|
+
scope,
|
|
520
|
+
scope ? ++this.#state.registerInstanceId : 0
|
|
521
|
+
);
|
|
522
|
+
}
|
|
513
523
|
};
|
|
514
|
-
function register(id, val, scope) {
|
|
524
|
+
function register(id, val, scope, instanceId) {
|
|
515
525
|
return REGISTRY.set(val, {
|
|
516
526
|
id,
|
|
517
527
|
scope,
|
|
518
|
-
|
|
519
|
-
|
|
528
|
+
instanceId: instanceId ?? 0,
|
|
529
|
+
access: "_._" + toAccess(toObjectKey(id))
|
|
520
530
|
}), val;
|
|
521
531
|
}
|
|
522
532
|
function getRegistered(val) {
|
|
@@ -525,12 +535,12 @@ function getRegistered(val) {
|
|
|
525
535
|
return { id: registered.id, scope: registered.scope };
|
|
526
536
|
}
|
|
527
537
|
function writeRoot(state, root) {
|
|
528
|
-
let { buf
|
|
538
|
+
let { buf } = state, hadBuf = buf.length !== 0, result = "";
|
|
529
539
|
if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
|
|
530
540
|
let rootRef = state.refs.get(root);
|
|
531
541
|
if (rootRef) {
|
|
532
542
|
let rootId = ensureId(state, rootRef);
|
|
533
|
-
(assigned.size ||
|
|
543
|
+
(state.assigned.size || state.registered.length || state.mutated.length) && (state.assigned.delete(rootRef), writeAssigned(state), buf.push(
|
|
534
544
|
"," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
|
|
535
545
|
));
|
|
536
546
|
}
|
|
@@ -543,13 +553,24 @@ function writeRoot(state, root) {
|
|
|
543
553
|
}
|
|
544
554
|
function writeAssigned(state) {
|
|
545
555
|
if (state.assigned.size) {
|
|
546
|
-
let
|
|
547
|
-
for (let
|
|
548
|
-
|
|
549
|
-
|
|
556
|
+
let buf = "";
|
|
557
|
+
for (let ref of state.assigned)
|
|
558
|
+
buf += "," + assignsToString(ref.assigns, ref.id), ref.assigns = null;
|
|
559
|
+
state.buf.push(buf), state.assigned = /* @__PURE__ */ new Set();
|
|
550
560
|
}
|
|
551
|
-
if (state.
|
|
552
|
-
|
|
561
|
+
if (state.registered.length) {
|
|
562
|
+
let buf = "";
|
|
563
|
+
for (let ref of state.registered.sort(compareRegisteredReferences)) {
|
|
564
|
+
let scopeRef = state.refs.get(ref.registered.scope);
|
|
565
|
+
buf += "," + assignsToString(
|
|
566
|
+
ref.assigns,
|
|
567
|
+
ref.registered.access + "(" + (scopeRef ? ensureId(state, scopeRef) : ref.assigns[0]) + ")"
|
|
568
|
+
), ref.assigns = null, ref.registered = null;
|
|
569
|
+
}
|
|
570
|
+
state.buf.push(buf), state.registered = [];
|
|
571
|
+
}
|
|
572
|
+
if (state.mutated.length) {
|
|
573
|
+
for (let mutation of state.mutated) {
|
|
553
574
|
let hasSeen = state.refs.get(mutation.object)?.id, objectStartIndex = state.buf.push(
|
|
554
575
|
state.buf.length === 0 ? "" : ","
|
|
555
576
|
);
|
|
@@ -568,7 +589,7 @@ function writeAssigned(state) {
|
|
|
568
589
|
state.buf.push("void 0");
|
|
569
590
|
isCall && state.buf.push(")");
|
|
570
591
|
}
|
|
571
|
-
state.
|
|
592
|
+
state.mutated = [], (state.assigned.size || state.registered.length) && writeAssigned(state);
|
|
572
593
|
}
|
|
573
594
|
}
|
|
574
595
|
function writeProp(state, val, parent, accessor) {
|
|
@@ -593,41 +614,32 @@ function writeProp(state, val, parent, accessor) {
|
|
|
593
614
|
}
|
|
594
615
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
595
616
|
let ref = state.refs.get(val);
|
|
596
|
-
if (ref)
|
|
597
|
-
|
|
617
|
+
if (ref) {
|
|
618
|
+
if (parent) {
|
|
619
|
+
if (ref.assigns)
|
|
620
|
+
return addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
|
|
621
|
+
if (isCircular(parent, ref))
|
|
622
|
+
return ensureId(state, ref), state.assigned.add(ref), addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
|
|
623
|
+
}
|
|
624
|
+
return state.buf.push(ensureId(state, ref)), !0;
|
|
625
|
+
}
|
|
598
626
|
let registered = REGISTRY.get(val);
|
|
599
627
|
return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
|
|
600
628
|
val,
|
|
601
629
|
ref = new Reference(parent, accessor, state.flush, state.buf.length)
|
|
602
630
|
), write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
|
|
603
631
|
}
|
|
604
|
-
function writeRegistered(state, val, parent, accessor,
|
|
605
|
-
if (scope) {
|
|
606
|
-
let
|
|
632
|
+
function writeRegistered(state, val, parent, accessor, registered) {
|
|
633
|
+
if (parent && registered.scope) {
|
|
634
|
+
let fnRef = new Reference(
|
|
607
635
|
parent,
|
|
608
636
|
accessor,
|
|
609
637
|
state.flush,
|
|
610
638
|
state.buf.length
|
|
611
639
|
);
|
|
612
|
-
|
|
613
|
-
if (scopeRef)
|
|
614
|
-
return state.buf.push("()=>" + ensureId(state, scopeRef) + access), !0;
|
|
615
|
-
state.buf.push("(s=>()=>s" + access + ")("), writeProp(state, scope, parent, ""), state.buf.push(")");
|
|
616
|
-
let newScopeRef = state.refs.get(scope);
|
|
617
|
-
return newScopeRef && ensureId(state, newScopeRef), !0;
|
|
618
|
-
}
|
|
619
|
-
if (scopeRef) {
|
|
620
|
-
if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef)))
|
|
621
|
-
return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !1;
|
|
622
|
-
state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
|
|
623
|
-
} else {
|
|
624
|
-
let pos = state.buf.push("") - 1, assigns = state.assigned.size;
|
|
625
|
-
writeProp(state, scope, parent, "");
|
|
626
|
-
let scopeRef2 = parent && state.refs.get(scope), scopeId = scopeRef2 && ensureId(state, scopeRef2);
|
|
627
|
-
scopeId && assigns !== state.assigned.size ? (state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor))) : (state.buf[pos] = access + "(" + state.buf[pos], state.buf.push(")"));
|
|
628
|
-
}
|
|
640
|
+
return fnRef.registered = registered, state.refs.set(val, fnRef), state.registered.push(fnRef), addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !state.refs.has(registered.scope) && writeProp(state, registered.scope, null, "");
|
|
629
641
|
} else
|
|
630
|
-
state.buf.push(access);
|
|
642
|
+
state.buf.push(registered.access);
|
|
631
643
|
return !0;
|
|
632
644
|
}
|
|
633
645
|
function writeString(state, val) {
|
|
@@ -1107,6 +1119,9 @@ function patchIteratorNext(proto) {
|
|
|
1107
1119
|
return this[kTouchedIterator] = 1, next.call(this, value);
|
|
1108
1120
|
};
|
|
1109
1121
|
}
|
|
1122
|
+
function compareRegisteredReferences(a, b) {
|
|
1123
|
+
return a.registered.instanceId - b.registered.instanceId;
|
|
1124
|
+
}
|
|
1110
1125
|
|
|
1111
1126
|
// src/html/writer.ts
|
|
1112
1127
|
var $chunk, NOOP = () => {
|
|
@@ -1165,7 +1180,11 @@ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
|
|
|
1165
1180
|
);
|
|
1166
1181
|
}
|
|
1167
1182
|
function _resume(val, id, scopeId) {
|
|
1168
|
-
return scopeId === void 0 ? register(id, val) : register(
|
|
1183
|
+
return scopeId === void 0 ? register(id, val) : $chunk.boundary.state.serializer.register(
|
|
1184
|
+
id,
|
|
1185
|
+
val,
|
|
1186
|
+
_scope_with_id(scopeId)
|
|
1187
|
+
);
|
|
1169
1188
|
}
|
|
1170
1189
|
function _id() {
|
|
1171
1190
|
let state = $chunk.boundary.state, { $global: $global2 } = state;
|
package/dist/html.mjs
CHANGED
|
@@ -364,13 +364,15 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
|
364
364
|
]), State = class {
|
|
365
365
|
ids = 0;
|
|
366
366
|
flush = 0;
|
|
367
|
+
registerInstanceId = 0;
|
|
367
368
|
flushed = !1;
|
|
368
369
|
wroteUndefined = !1;
|
|
369
370
|
buf = [];
|
|
370
371
|
refs = /* @__PURE__ */ new WeakMap();
|
|
371
372
|
assigned = /* @__PURE__ */ new Set();
|
|
373
|
+
registered = [];
|
|
372
374
|
boundary = void 0;
|
|
373
|
-
|
|
375
|
+
mutated = [];
|
|
374
376
|
}, Reference = class {
|
|
375
377
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
|
376
378
|
this.parent = parent;
|
|
@@ -380,7 +382,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
|
380
382
|
this.id = id;
|
|
381
383
|
this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
|
|
382
384
|
}
|
|
383
|
-
|
|
385
|
+
registered = null;
|
|
384
386
|
assigns = null;
|
|
385
387
|
};
|
|
386
388
|
var Serializer = class {
|
|
@@ -404,7 +406,7 @@ var Serializer = class {
|
|
|
404
406
|
}
|
|
405
407
|
writeCall(value, object, property, spread) {
|
|
406
408
|
let state = this.#state;
|
|
407
|
-
state.
|
|
409
|
+
state.mutated.push({
|
|
408
410
|
type: 0 /* call */,
|
|
409
411
|
value,
|
|
410
412
|
object,
|
|
@@ -414,20 +416,28 @@ var Serializer = class {
|
|
|
414
416
|
}
|
|
415
417
|
writeAssign(value, object, property) {
|
|
416
418
|
let state = this.#state;
|
|
417
|
-
state.
|
|
419
|
+
state.mutated.push({
|
|
418
420
|
type: 1 /* assign */,
|
|
419
421
|
value,
|
|
420
422
|
object,
|
|
421
423
|
property
|
|
422
424
|
}), state.flushed = !0;
|
|
423
425
|
}
|
|
426
|
+
register(id, val, scope) {
|
|
427
|
+
return register(
|
|
428
|
+
id,
|
|
429
|
+
val,
|
|
430
|
+
scope,
|
|
431
|
+
scope ? ++this.#state.registerInstanceId : 0
|
|
432
|
+
);
|
|
433
|
+
}
|
|
424
434
|
};
|
|
425
|
-
function register(id, val, scope) {
|
|
435
|
+
function register(id, val, scope, instanceId) {
|
|
426
436
|
return REGISTRY.set(val, {
|
|
427
437
|
id,
|
|
428
438
|
scope,
|
|
429
|
-
|
|
430
|
-
|
|
439
|
+
instanceId: instanceId ?? 0,
|
|
440
|
+
access: "_._" + toAccess(toObjectKey(id))
|
|
431
441
|
}), val;
|
|
432
442
|
}
|
|
433
443
|
function getRegistered(val) {
|
|
@@ -436,12 +446,12 @@ function getRegistered(val) {
|
|
|
436
446
|
return { id: registered.id, scope: registered.scope };
|
|
437
447
|
}
|
|
438
448
|
function writeRoot(state, root) {
|
|
439
|
-
let { buf
|
|
449
|
+
let { buf } = state, hadBuf = buf.length !== 0, result = "";
|
|
440
450
|
if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
|
|
441
451
|
let rootRef = state.refs.get(root);
|
|
442
452
|
if (rootRef) {
|
|
443
453
|
let rootId = ensureId(state, rootRef);
|
|
444
|
-
(assigned.size ||
|
|
454
|
+
(state.assigned.size || state.registered.length || state.mutated.length) && (state.assigned.delete(rootRef), writeAssigned(state), buf.push(
|
|
445
455
|
"," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
|
|
446
456
|
));
|
|
447
457
|
}
|
|
@@ -454,13 +464,24 @@ function writeRoot(state, root) {
|
|
|
454
464
|
}
|
|
455
465
|
function writeAssigned(state) {
|
|
456
466
|
if (state.assigned.size) {
|
|
457
|
-
let
|
|
458
|
-
for (let
|
|
459
|
-
|
|
460
|
-
|
|
467
|
+
let buf = "";
|
|
468
|
+
for (let ref of state.assigned)
|
|
469
|
+
buf += "," + assignsToString(ref.assigns, ref.id), ref.assigns = null;
|
|
470
|
+
state.buf.push(buf), state.assigned = /* @__PURE__ */ new Set();
|
|
461
471
|
}
|
|
462
|
-
if (state.
|
|
463
|
-
|
|
472
|
+
if (state.registered.length) {
|
|
473
|
+
let buf = "";
|
|
474
|
+
for (let ref of state.registered.sort(compareRegisteredReferences)) {
|
|
475
|
+
let scopeRef = state.refs.get(ref.registered.scope);
|
|
476
|
+
buf += "," + assignsToString(
|
|
477
|
+
ref.assigns,
|
|
478
|
+
ref.registered.access + "(" + (scopeRef ? ensureId(state, scopeRef) : ref.assigns[0]) + ")"
|
|
479
|
+
), ref.assigns = null, ref.registered = null;
|
|
480
|
+
}
|
|
481
|
+
state.buf.push(buf), state.registered = [];
|
|
482
|
+
}
|
|
483
|
+
if (state.mutated.length) {
|
|
484
|
+
for (let mutation of state.mutated) {
|
|
464
485
|
let hasSeen = state.refs.get(mutation.object)?.id, objectStartIndex = state.buf.push(
|
|
465
486
|
state.buf.length === 0 ? "" : ","
|
|
466
487
|
);
|
|
@@ -479,7 +500,7 @@ function writeAssigned(state) {
|
|
|
479
500
|
state.buf.push("void 0");
|
|
480
501
|
isCall && state.buf.push(")");
|
|
481
502
|
}
|
|
482
|
-
state.
|
|
503
|
+
state.mutated = [], (state.assigned.size || state.registered.length) && writeAssigned(state);
|
|
483
504
|
}
|
|
484
505
|
}
|
|
485
506
|
function writeProp(state, val, parent, accessor) {
|
|
@@ -504,41 +525,32 @@ function writeProp(state, val, parent, accessor) {
|
|
|
504
525
|
}
|
|
505
526
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
506
527
|
let ref = state.refs.get(val);
|
|
507
|
-
if (ref)
|
|
508
|
-
|
|
528
|
+
if (ref) {
|
|
529
|
+
if (parent) {
|
|
530
|
+
if (ref.assigns)
|
|
531
|
+
return addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
|
|
532
|
+
if (isCircular(parent, ref))
|
|
533
|
+
return ensureId(state, ref), state.assigned.add(ref), addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
|
|
534
|
+
}
|
|
535
|
+
return state.buf.push(ensureId(state, ref)), !0;
|
|
536
|
+
}
|
|
509
537
|
let registered = REGISTRY.get(val);
|
|
510
538
|
return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
|
|
511
539
|
val,
|
|
512
540
|
ref = new Reference(parent, accessor, state.flush, state.buf.length)
|
|
513
541
|
), write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
|
|
514
542
|
}
|
|
515
|
-
function writeRegistered(state, val, parent, accessor,
|
|
516
|
-
if (scope) {
|
|
517
|
-
let
|
|
543
|
+
function writeRegistered(state, val, parent, accessor, registered) {
|
|
544
|
+
if (parent && registered.scope) {
|
|
545
|
+
let fnRef = new Reference(
|
|
518
546
|
parent,
|
|
519
547
|
accessor,
|
|
520
548
|
state.flush,
|
|
521
549
|
state.buf.length
|
|
522
550
|
);
|
|
523
|
-
|
|
524
|
-
if (scopeRef)
|
|
525
|
-
return state.buf.push("()=>" + ensureId(state, scopeRef) + access), !0;
|
|
526
|
-
state.buf.push("(s=>()=>s" + access + ")("), writeProp(state, scope, parent, ""), state.buf.push(")");
|
|
527
|
-
let newScopeRef = state.refs.get(scope);
|
|
528
|
-
return newScopeRef && ensureId(state, newScopeRef), !0;
|
|
529
|
-
}
|
|
530
|
-
if (scopeRef) {
|
|
531
|
-
if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef)))
|
|
532
|
-
return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !1;
|
|
533
|
-
state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
|
|
534
|
-
} else {
|
|
535
|
-
let pos = state.buf.push("") - 1, assigns = state.assigned.size;
|
|
536
|
-
writeProp(state, scope, parent, "");
|
|
537
|
-
let scopeRef2 = parent && state.refs.get(scope), scopeId = scopeRef2 && ensureId(state, scopeRef2);
|
|
538
|
-
scopeId && assigns !== state.assigned.size ? (state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor))) : (state.buf[pos] = access + "(" + state.buf[pos], state.buf.push(")"));
|
|
539
|
-
}
|
|
551
|
+
return fnRef.registered = registered, state.refs.set(val, fnRef), state.registered.push(fnRef), addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !state.refs.has(registered.scope) && writeProp(state, registered.scope, null, "");
|
|
540
552
|
} else
|
|
541
|
-
state.buf.push(access);
|
|
553
|
+
state.buf.push(registered.access);
|
|
542
554
|
return !0;
|
|
543
555
|
}
|
|
544
556
|
function writeString(state, val) {
|
|
@@ -1018,6 +1030,9 @@ function patchIteratorNext(proto) {
|
|
|
1018
1030
|
return this[kTouchedIterator] = 1, next.call(this, value);
|
|
1019
1031
|
};
|
|
1020
1032
|
}
|
|
1033
|
+
function compareRegisteredReferences(a, b) {
|
|
1034
|
+
return a.registered.instanceId - b.registered.instanceId;
|
|
1035
|
+
}
|
|
1021
1036
|
|
|
1022
1037
|
// src/html/writer.ts
|
|
1023
1038
|
var $chunk, NOOP = () => {
|
|
@@ -1076,7 +1091,11 @@ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
|
|
|
1076
1091
|
);
|
|
1077
1092
|
}
|
|
1078
1093
|
function _resume(val, id, scopeId) {
|
|
1079
|
-
return scopeId === void 0 ? register(id, val) : register(
|
|
1094
|
+
return scopeId === void 0 ? register(id, val) : $chunk.boundary.state.serializer.register(
|
|
1095
|
+
id,
|
|
1096
|
+
val,
|
|
1097
|
+
_scope_with_id(scopeId)
|
|
1098
|
+
);
|
|
1080
1099
|
}
|
|
1081
1100
|
function _id() {
|
|
1082
1101
|
let state = $chunk.boundary.state, { $global: $global2 } = state;
|
package/dist/translator/index.js
CHANGED
|
@@ -1641,6 +1641,7 @@ function startSection(path5) {
|
|
|
1641
1641
|
bindings: void 0,
|
|
1642
1642
|
domGetterBindings: /* @__PURE__ */ new Map(),
|
|
1643
1643
|
hoisted: void 0,
|
|
1644
|
+
hoistedTo: void 0,
|
|
1644
1645
|
isHoistThrough: void 0,
|
|
1645
1646
|
serializeReason: void 0,
|
|
1646
1647
|
serializeReasons: /* @__PURE__ */ new Map(),
|
|
@@ -4137,7 +4138,7 @@ function writeHTMLResumeStatements(path5) {
|
|
|
4137
4138
|
}
|
|
4138
4139
|
}
|
|
4139
4140
|
function getSetup(section) {
|
|
4140
|
-
return getSignals(section).get(void 0)?.identifier;
|
|
4141
|
+
return section.hoistedTo ? getSignal(section, void 0).identifier : getSignals(section).get(void 0)?.identifier;
|
|
4141
4142
|
}
|
|
4142
4143
|
function replaceRenderNode(node) {
|
|
4143
4144
|
return replaceAssignedNode(node) || replaceBindingReadNode(node) || replaceRegisteredFunctionNode(node);
|
|
@@ -7930,6 +7931,7 @@ function trackHoistedReference(referencePath, binding) {
|
|
|
7930
7931
|
)
|
|
7931
7932
|
);
|
|
7932
7933
|
section.hoisted = bindingUtil.add(section.hoisted, binding);
|
|
7934
|
+
hoistSection.hoistedTo = bindingUtil.add(hoistSection.hoistedTo, binding);
|
|
7933
7935
|
let currentSection = section.parent;
|
|
7934
7936
|
while (currentSection && currentSection !== hoistSection) {
|
|
7935
7937
|
currentSection.isHoistThrough = true;
|
|
@@ -8937,9 +8939,8 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
|
8937
8939
|
const rootBindings = getRootBindings(reads);
|
|
8938
8940
|
for (const read of reads) {
|
|
8939
8941
|
let { binding } = read;
|
|
8940
|
-
if (read.node) {
|
|
8941
|
-
|
|
8942
|
-
({ binding } = (read.node.extra ??= {}).read = exprReference);
|
|
8942
|
+
if (read.node && read.node.extra?.assignmentTo !== binding) {
|
|
8943
|
+
({ binding } = (read.node.extra ??= {}).read ??= resolveExpressionReference(rootBindings, binding));
|
|
8943
8944
|
}
|
|
8944
8945
|
referencedBindings = bindingUtil.add(referencedBindings, binding);
|
|
8945
8946
|
}
|
|
@@ -11173,8 +11174,11 @@ var script_default = {
|
|
|
11173
11174
|
const { value: value2 } = valueAttr;
|
|
11174
11175
|
const isFunction2 = import_compiler52.types.isFunctionExpression(value2) || import_compiler52.types.isArrowFunctionExpression(value2);
|
|
11175
11176
|
let inlineBody = null;
|
|
11176
|
-
|
|
11177
|
-
|
|
11177
|
+
let referencesScope = false;
|
|
11178
|
+
if (isFunction2) {
|
|
11179
|
+
if (value2.async || value2.generator) {
|
|
11180
|
+
referencesScope = traverseContains(value2, isScopeIdentifier);
|
|
11181
|
+
} else if (import_compiler52.types.isBlockStatement(value2.body)) {
|
|
11178
11182
|
let hasDeclaration = false;
|
|
11179
11183
|
for (const child of value2.body.body) {
|
|
11180
11184
|
if (import_compiler52.types.isDeclaration(child)) {
|
|
@@ -11192,7 +11196,7 @@ var script_default = {
|
|
|
11192
11196
|
section,
|
|
11193
11197
|
referencedBindings,
|
|
11194
11198
|
inlineBody || import_compiler52.types.expressionStatement(
|
|
11195
|
-
import_compiler52.types.callExpression(value2,
|
|
11199
|
+
import_compiler52.types.callExpression(value2, referencesScope ? [scopeIdentifier] : [])
|
|
11196
11200
|
)
|
|
11197
11201
|
);
|
|
11198
11202
|
} else {
|
|
@@ -35,6 +35,7 @@ export interface Section {
|
|
|
35
35
|
bindings: ReferencedBindings;
|
|
36
36
|
domGetterBindings: Map<Binding, string>;
|
|
37
37
|
hoisted: ReferencedBindings;
|
|
38
|
+
hoistedTo: ReferencedBindings;
|
|
38
39
|
serializeReason: undefined | SerializeReason;
|
|
39
40
|
serializeReasons: Map<symbol, SerializeReason>;
|
|
40
41
|
paramReasonGroups: ParamSerializeReasonGroups | undefined;
|