@marko/runtime-tags 6.0.103 → 6.0.105
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/common/accessor.d.ts +18 -20
- package/dist/common/accessor.debug.d.ts +4 -6
- package/dist/common/opt.d.ts +6 -0
- package/dist/common/types.d.ts +2 -2
- package/dist/debug/dom.js +120 -103
- package/dist/debug/dom.mjs +120 -103
- package/dist/debug/html.js +124 -81
- package/dist/debug/html.mjs +124 -81
- package/dist/dom.js +146 -131
- package/dist/dom.mjs +146 -131
- package/dist/html/writer.d.ts +6 -1
- package/dist/html.js +73 -55
- package/dist/html.mjs +73 -55
- package/dist/translator/index.js +25 -29
- package/package.json +1 -1
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
export declare enum AccessorPrefix {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
BranchScopes = "A",
|
|
3
|
+
ClosureScopes = "B",
|
|
4
|
+
ClosureSignalIndex = "C",
|
|
5
|
+
ConditionalRenderer = "D",
|
|
6
6
|
ControlledHandler = "E",
|
|
7
7
|
ControlledType = "F",
|
|
8
8
|
ControlledValue = "G",
|
|
9
|
-
|
|
9
|
+
DynamicHTMLLastChild = "H",
|
|
10
10
|
EventAttributes = "I",
|
|
11
11
|
Getter = "J",
|
|
12
12
|
LifecycleAbortController = "K",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Promise = "N",
|
|
16
|
-
TagVariableChange = "O"
|
|
13
|
+
Promise = "L",
|
|
14
|
+
TagVariableChange = "M"
|
|
17
15
|
}
|
|
18
16
|
export declare enum AccessorProp {
|
|
19
17
|
Global = "$",
|
|
20
18
|
Owner = "_",
|
|
21
19
|
AbortControllers = "A",
|
|
22
20
|
AbortScopes = "B",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
BranchAccessor = "C",
|
|
22
|
+
BranchScopes = "D",
|
|
23
|
+
CatchContent = "E",
|
|
24
|
+
ClosestBranch = "F",
|
|
25
|
+
ClosestBranchId = "G",
|
|
26
|
+
Creating = "H",
|
|
27
|
+
Destroyed = "I",
|
|
28
|
+
PendingEffects = "J",
|
|
29
|
+
EndNode = "K",
|
|
30
|
+
Id = "L",
|
|
31
|
+
LoopKey = "M",
|
|
34
32
|
ParentBranch = "N",
|
|
35
33
|
PendingAsyncCount = "O",
|
|
36
34
|
PlaceholderBranch = "P",
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
export declare enum AccessorPrefix {
|
|
2
|
+
BranchScopes = "BranchScopes:",
|
|
2
3
|
ClosureScopes = "ClosureScopes:",
|
|
3
4
|
ClosureSignalIndex = "ClosureSignalIndex:",
|
|
4
5
|
ConditionalRenderer = "ConditionalRenderer:",
|
|
5
|
-
ConditionalScope = "ConditionalScope:",
|
|
6
6
|
ControlledHandler = "ControlledHandler:",
|
|
7
7
|
ControlledType = "ControlledType:",
|
|
8
8
|
ControlledValue = "ControlledValue:",
|
|
9
|
-
|
|
9
|
+
DynamicHTMLLastChild = "DynamicHTMLLastChild:",
|
|
10
10
|
EventAttributes = "EventAttributes:",
|
|
11
11
|
Getter = "Getter:",
|
|
12
12
|
LifecycleAbortController = "LifecycleAbortController:",
|
|
13
|
-
LoopScopeArray = "LoopScopeArray:",
|
|
14
|
-
LoopScopeMap = "LoopScopeMap:",
|
|
15
13
|
Promise = "Promise:",
|
|
16
14
|
TagVariableChange = "TagVariableChange:"
|
|
17
15
|
}
|
|
@@ -20,7 +18,6 @@ export declare enum AccessorProp {
|
|
|
20
18
|
Owner = "_",
|
|
21
19
|
AbortControllers = "#AbortControllers",
|
|
22
20
|
AbortScopes = "#AbortScopes",
|
|
23
|
-
Args = "#Args",
|
|
24
21
|
BranchAccessor = "#BranchAccessor",
|
|
25
22
|
BranchScopes = "#BranchScopes",
|
|
26
23
|
CatchContent = "#CatchContent",
|
|
@@ -28,9 +25,10 @@ export declare enum AccessorProp {
|
|
|
28
25
|
ClosestBranchId = "#ClosestBranchId",
|
|
29
26
|
Creating = "#Creating",
|
|
30
27
|
Destroyed = "#Destroyed",
|
|
31
|
-
|
|
28
|
+
PendingEffects = "#PendingEffects",
|
|
32
29
|
EndNode = "#EndNode",
|
|
33
30
|
Id = "#Id",
|
|
31
|
+
LoopKey = "#LoopKey",
|
|
34
32
|
ParentBranch = "#ParentBranch",
|
|
35
33
|
PendingAsyncCount = "#PendingAsyncCount",
|
|
36
34
|
PlaceholderBranch = "#PlaceholderBranch",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type OneMany<T> = T[] | T;
|
|
2
|
+
export type Opt<T> = OneMany<T> | undefined;
|
|
3
|
+
export declare function toArray<T>(oneMany: OneMany<T>): [T, ...T[]];
|
|
4
|
+
export declare function toArray<T>(opt: Opt<T>): T[];
|
|
5
|
+
export declare function push<T>(opt: Opt<T>, item: T): OneMany<T>;
|
|
6
|
+
export declare function push<T>(oneMany: OneMany<T>, item: T): T[];
|
package/dist/common/types.d.ts
CHANGED
|
@@ -11,16 +11,16 @@ export interface BranchScope extends Scope {
|
|
|
11
11
|
[AccessorProp.BranchScopes]: Set<BranchScope> | undefined;
|
|
12
12
|
[AccessorProp.Renderer]: ClientRenderer | string;
|
|
13
13
|
[AccessorProp.PendingAsyncCount]: number | undefined;
|
|
14
|
-
[AccessorProp.
|
|
14
|
+
[AccessorProp.PendingEffects]: unknown[] | undefined;
|
|
15
15
|
}
|
|
16
16
|
export interface Scope {
|
|
17
17
|
[AccessorProp.Owner]: Scope | undefined;
|
|
18
18
|
[AccessorProp.Global]: Record<string, unknown>;
|
|
19
19
|
[AccessorProp.Id]: number;
|
|
20
|
-
[AccessorProp.Args]: unknown;
|
|
21
20
|
[AccessorProp.Creating]: 1 | 0 | undefined;
|
|
22
21
|
[AccessorProp.AbortControllers]: Record<string | number, AbortController | void> | undefined;
|
|
23
22
|
[AccessorProp.ClosestBranch]: BranchScope | undefined;
|
|
23
|
+
[AccessorProp.ClosestBranchId]: number | undefined;
|
|
24
24
|
[x: `___${string}`]: never;
|
|
25
25
|
[x: string | number]: any;
|
|
26
26
|
}
|
package/dist/debug/dom.js
CHANGED
|
@@ -292,6 +292,14 @@ var DEFAULT_RUNTIME_ID = "M";
|
|
|
292
292
|
var DEFAULT_RENDER_ID = "_";
|
|
293
293
|
var DYNAMIC_TAG_SCRIPT_REGISTER_ID = true ? "_dynamicTagScript" : "d";
|
|
294
294
|
|
|
295
|
+
// src/common/opt.ts
|
|
296
|
+
function toArray(opt) {
|
|
297
|
+
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
298
|
+
}
|
|
299
|
+
function push(opt, item) {
|
|
300
|
+
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
301
|
+
}
|
|
302
|
+
|
|
295
303
|
// src/dom/event.ts
|
|
296
304
|
var defaultDelegator = createDelegator();
|
|
297
305
|
function _on(element, type, handler) {
|
|
@@ -528,19 +536,26 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
528
536
|
const serializeContext = {
|
|
529
537
|
_: registeredValues
|
|
530
538
|
};
|
|
531
|
-
const
|
|
532
|
-
|
|
539
|
+
const visitBranches = branchesEnabled && /* @__PURE__ */ (() => {
|
|
540
|
+
let curBranchScopes;
|
|
541
|
+
const branchScopesStack = [];
|
|
533
542
|
const branchStarts = [];
|
|
534
543
|
const orphanBranches = [];
|
|
535
|
-
const endBranch = (singleNode) => {
|
|
544
|
+
const endBranch = (accessor, singleNode) => {
|
|
536
545
|
const parent = visit.parentNode;
|
|
537
546
|
let startVisit = visit;
|
|
538
547
|
let i = orphanBranches.length;
|
|
539
|
-
let claimed = 0;
|
|
540
548
|
let branchId;
|
|
541
549
|
let branch;
|
|
550
|
+
let childBranch;
|
|
551
|
+
let endedBranches;
|
|
542
552
|
while (branchId = +lastToken) {
|
|
543
|
-
|
|
553
|
+
(endedBranches ||= []).push(
|
|
554
|
+
branch = scopeLookup[branchId] ||= {
|
|
555
|
+
["#Id" /* Id */]: branchId
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
branch["#ClosestBranch" /* ClosestBranch */] = branch;
|
|
544
559
|
if (singleNode) {
|
|
545
560
|
while (startVisit.previousSibling && ~visits.indexOf(
|
|
546
561
|
startVisit = startVisit.previousSibling
|
|
@@ -550,6 +565,11 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
550
565
|
branch[true ? getDebugKey(0, startVisit) : "a"] = startVisit;
|
|
551
566
|
}
|
|
552
567
|
} else {
|
|
568
|
+
curBranchScopes = push(curBranchScopes, branch);
|
|
569
|
+
if (accessor) {
|
|
570
|
+
visitScope[accessor] = curBranchScopes;
|
|
571
|
+
curBranchScopes = branchScopesStack.pop();
|
|
572
|
+
}
|
|
553
573
|
startVisit = branchStarts.pop();
|
|
554
574
|
if (parent !== startVisit.parentNode) {
|
|
555
575
|
parent.prepend(startVisit);
|
|
@@ -557,42 +577,44 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
557
577
|
branch["#StartNode" /* StartNode */] = startVisit;
|
|
558
578
|
branch["#EndNode" /* EndNode */] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
559
579
|
}
|
|
560
|
-
while (i
|
|
561
|
-
|
|
562
|
-
|
|
580
|
+
while (i && orphanBranches[--i]["#Id" /* Id */] > branchId) {
|
|
581
|
+
(childBranch = orphanBranches.pop())["#ParentBranch" /* ParentBranch */] = branch;
|
|
582
|
+
(branch["#BranchScopes" /* BranchScopes */] ||= /* @__PURE__ */ new Set()).add(
|
|
583
|
+
childBranch
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
nextToken(
|
|
587
|
+
/* read optional next branchId */
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
if (endedBranches) {
|
|
591
|
+
orphanBranches.push(...endedBranches);
|
|
592
|
+
if (singleNode) {
|
|
593
|
+
visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
|
|
563
594
|
}
|
|
564
|
-
orphanBranches.push(branchId);
|
|
565
|
-
branchParents.set(branchId, 0);
|
|
566
|
-
nextToken();
|
|
567
595
|
}
|
|
568
|
-
orphanBranches.splice(i, claimed);
|
|
569
596
|
};
|
|
570
|
-
return {
|
|
571
|
-
|
|
572
|
-
if (
|
|
597
|
+
return () => {
|
|
598
|
+
if (visitType === "[" /* BranchStart */) {
|
|
599
|
+
if (lastToken) {
|
|
573
600
|
endBranch();
|
|
574
|
-
branchStarts.push(visit);
|
|
575
601
|
} else {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
/* read accessor */
|
|
579
|
-
] = /* @__PURE__ */ ((node) => () => node)(
|
|
580
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit
|
|
581
|
-
);
|
|
582
|
-
nextToken();
|
|
583
|
-
endBranch(
|
|
584
|
-
visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */
|
|
585
|
-
);
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
___scope(scope) {
|
|
589
|
-
scope["#ClosestBranch" /* ClosestBranch */] = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */] || branchParents.get(scopeId)];
|
|
590
|
-
if (branchParents.has(scopeId)) {
|
|
591
|
-
if (scope["#ClosestBranch" /* ClosestBranch */]) {
|
|
592
|
-
((scope["#ParentBranch" /* ParentBranch */] = scope["#ClosestBranch" /* ClosestBranch */])["#BranchScopes" /* BranchScopes */] ||= /* @__PURE__ */ new Set()).add(scope);
|
|
593
|
-
}
|
|
594
|
-
scope["#ClosestBranch" /* ClosestBranch */] = scope;
|
|
602
|
+
branchScopesStack.push(curBranchScopes);
|
|
603
|
+
curBranchScopes = void 0;
|
|
595
604
|
}
|
|
605
|
+
branchStarts.push(visit);
|
|
606
|
+
} else {
|
|
607
|
+
visitScope["Getter:" /* Getter */ + nextToken(
|
|
608
|
+
/* read accessor */
|
|
609
|
+
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
610
|
+
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit
|
|
611
|
+
);
|
|
612
|
+
endBranch(
|
|
613
|
+
"BranchScopes:" /* BranchScopes */ + lastToken,
|
|
614
|
+
(nextToken(
|
|
615
|
+
/* read optional first branchId */
|
|
616
|
+
), visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */)
|
|
617
|
+
);
|
|
596
618
|
}
|
|
597
619
|
};
|
|
598
620
|
})();
|
|
@@ -601,7 +623,6 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
601
623
|
let lastEffect;
|
|
602
624
|
let visits;
|
|
603
625
|
let resumes;
|
|
604
|
-
let scopeId;
|
|
605
626
|
let visit;
|
|
606
627
|
let visitText;
|
|
607
628
|
let visitType;
|
|
@@ -617,29 +638,15 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
617
638
|
try {
|
|
618
639
|
walk2();
|
|
619
640
|
isResuming = 1;
|
|
620
|
-
for (visit of visits = render.v) {
|
|
621
|
-
lastTokenIndex = render.i.length;
|
|
622
|
-
visitText = visit.data;
|
|
623
|
-
visitType = visitText[lastTokenIndex++];
|
|
624
|
-
if (scopeId = +nextToken()) {
|
|
625
|
-
visitScope = scopeLookup[scopeId] ||= {
|
|
626
|
-
["#Id" /* Id */]: scopeId
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
if (visitType === "*" /* Node */) {
|
|
630
|
-
visitScope["Getter:" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling);
|
|
631
|
-
} else if (branchesEnabled) {
|
|
632
|
-
branches.___visit();
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
641
|
for (const serialized of resumes = render.r || []) {
|
|
636
642
|
if (typeof serialized === "string") {
|
|
637
643
|
lastEffect = serialized;
|
|
638
644
|
} else if (typeof serialized === "number") {
|
|
639
|
-
|
|
645
|
+
queueEffect(
|
|
640
646
|
scopeLookup[serialized] ||= {
|
|
641
|
-
["#Id" /* Id */]:
|
|
642
|
-
}
|
|
647
|
+
["#Id" /* Id */]: serialized
|
|
648
|
+
},
|
|
649
|
+
registeredValues[lastEffect]
|
|
643
650
|
);
|
|
644
651
|
} else {
|
|
645
652
|
for (const scope of serialized(serializeContext)) {
|
|
@@ -650,22 +657,31 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
650
657
|
} else if (typeof scope === "number") {
|
|
651
658
|
lastScopeId += scope;
|
|
652
659
|
} else {
|
|
653
|
-
|
|
660
|
+
scopeLookup[scope["#Id" /* Id */] = ++lastScopeId] = scope;
|
|
654
661
|
scope["$global" /* Global */] = $global;
|
|
655
|
-
scope["#Id" /* Id */] = scopeId;
|
|
656
|
-
if (scopeLookup[scopeId] !== scope) {
|
|
657
|
-
scopeLookup[scopeId] = Object.assign(
|
|
658
|
-
scope,
|
|
659
|
-
scopeLookup[scopeId]
|
|
660
|
-
);
|
|
661
|
-
}
|
|
662
662
|
if (branchesEnabled) {
|
|
663
|
-
|
|
663
|
+
scope["#ClosestBranch" /* ClosestBranch */] = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */]];
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
|
+
for (visit of visits = render.v) {
|
|
670
|
+
lastTokenIndex = render.i.length;
|
|
671
|
+
visitText = visit.data;
|
|
672
|
+
visitType = visitText[lastTokenIndex++];
|
|
673
|
+
visitScope = scopeLookup[+nextToken(
|
|
674
|
+
/* read scope id */
|
|
675
|
+
)] ||= {
|
|
676
|
+
["#Id" /* Id */]: +lastToken
|
|
677
|
+
};
|
|
678
|
+
if (visitType === "*" /* Node */) {
|
|
679
|
+
visitScope["Getter:" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling);
|
|
680
|
+
} else if (branchesEnabled) {
|
|
681
|
+
visitBranches();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
run();
|
|
669
685
|
} finally {
|
|
670
686
|
isResuming = visits.length = resumes.length = 0;
|
|
671
687
|
}
|
|
@@ -969,9 +985,9 @@ function normalizeStrProp(value) {
|
|
|
969
985
|
function normalizeBoolProp(value) {
|
|
970
986
|
return value != null && value !== false;
|
|
971
987
|
}
|
|
972
|
-
function updateList(arr, val,
|
|
988
|
+
function updateList(arr, val, push2) {
|
|
973
989
|
const index = arr.indexOf(val);
|
|
974
|
-
return (
|
|
990
|
+
return (push2 ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
|
|
975
991
|
}
|
|
976
992
|
function toValueProp(it) {
|
|
977
993
|
return it.value;
|
|
@@ -1033,7 +1049,7 @@ function _let(id, fn) {
|
|
|
1033
1049
|
const valueAccessor = true ? id.slice(0, id.lastIndexOf("/")) : decodeAccessor3(id);
|
|
1034
1050
|
const valueChangeAccessor = "TagVariableChange:" /* TagVariableChange */ + valueAccessor;
|
|
1035
1051
|
if (true) {
|
|
1036
|
-
id = +
|
|
1052
|
+
id = +id.slice(id.lastIndexOf("/") + 1);
|
|
1037
1053
|
}
|
|
1038
1054
|
return (scope, value, valueChange) => {
|
|
1039
1055
|
if (rendering) {
|
|
@@ -1077,12 +1093,10 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id" /* Id */) {
|
|
|
1077
1093
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
1078
1094
|
if (false)
|
|
1079
1095
|
ownerLoopNodeAccessor = decodeAccessor3(ownerLoopNodeAccessor);
|
|
1080
|
-
const
|
|
1081
|
-
const loopScopeMapAccessor = "LoopScopeMap:" /* LoopScopeMap */ + ownerLoopNodeAccessor;
|
|
1096
|
+
const scopeAccessor = "BranchScopes:" /* BranchScopes */ + ownerLoopNodeAccessor;
|
|
1082
1097
|
const ownerSignal = (ownerScope) => {
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
if (firstScope) {
|
|
1098
|
+
let scopes = ownerScope[scopeAccessor];
|
|
1099
|
+
if (scopes) {
|
|
1086
1100
|
queueRender(
|
|
1087
1101
|
ownerScope,
|
|
1088
1102
|
() => {
|
|
@@ -1094,7 +1108,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
1094
1108
|
},
|
|
1095
1109
|
-1,
|
|
1096
1110
|
0,
|
|
1097
|
-
|
|
1111
|
+
(scopes = toArray(scopes))[0]["#Id" /* Id */]
|
|
1098
1112
|
);
|
|
1099
1113
|
}
|
|
1100
1114
|
};
|
|
@@ -1106,7 +1120,7 @@ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
|
1106
1120
|
ownerConditionalNodeAccessor = decodeAccessor3(
|
|
1107
1121
|
ownerConditionalNodeAccessor
|
|
1108
1122
|
);
|
|
1109
|
-
const scopeAccessor = "
|
|
1123
|
+
const scopeAccessor = "BranchScopes:" /* BranchScopes */ + ownerConditionalNodeAccessor;
|
|
1110
1124
|
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + ownerConditionalNodeAccessor;
|
|
1111
1125
|
const ownerSignal = (scope) => {
|
|
1112
1126
|
const ifScope = scope[scopeAccessor];
|
|
@@ -1510,7 +1524,7 @@ function _attr_content(scope, nodeAccessor, value) {
|
|
|
1510
1524
|
subscribeToScopeSet(
|
|
1511
1525
|
content.___owner,
|
|
1512
1526
|
content.___accessor,
|
|
1513
|
-
scope["
|
|
1527
|
+
scope["BranchScopes:" /* BranchScopes */ + nodeAccessor]
|
|
1514
1528
|
);
|
|
1515
1529
|
}
|
|
1516
1530
|
}
|
|
@@ -1542,7 +1556,7 @@ function _attrs_script(scope, nodeAccessor) {
|
|
|
1542
1556
|
function _html(scope, value, accessor) {
|
|
1543
1557
|
const firstChild = scope[accessor];
|
|
1544
1558
|
const parentNode = firstChild.parentNode;
|
|
1545
|
-
const lastChild = scope["
|
|
1559
|
+
const lastChild = scope["DynamicHTMLLastChild:" /* DynamicHTMLLastChild */ + accessor] || firstChild;
|
|
1546
1560
|
const newContent = parseHTML(
|
|
1547
1561
|
value || value === 0 ? value + "" : "",
|
|
1548
1562
|
parentNode.namespaceURI
|
|
@@ -1551,7 +1565,7 @@ function _html(scope, value, accessor) {
|
|
|
1551
1565
|
parentNode,
|
|
1552
1566
|
firstChild,
|
|
1553
1567
|
scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
|
|
1554
|
-
scope["
|
|
1568
|
+
scope["DynamicHTMLLastChild:" /* DynamicHTMLLastChild */ + accessor] = newContent.lastChild
|
|
1555
1569
|
);
|
|
1556
1570
|
removeChildNodes(firstChild, lastChild);
|
|
1557
1571
|
}
|
|
@@ -1781,7 +1795,7 @@ function longestIncreasingSubsequence(a) {
|
|
|
1781
1795
|
function _await(nodeAccessor, renderer) {
|
|
1782
1796
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1783
1797
|
const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
|
|
1784
|
-
const branchAccessor = "
|
|
1798
|
+
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1785
1799
|
enableBranches();
|
|
1786
1800
|
return (scope, promise) => {
|
|
1787
1801
|
const referenceNode = scope[nodeAccessor];
|
|
@@ -1865,9 +1879,9 @@ function _await(nodeAccessor, renderer) {
|
|
|
1865
1879
|
removeAndDestroyBranch(placeholderBranch);
|
|
1866
1880
|
}
|
|
1867
1881
|
queueEffect(tryWithPlaceholder, (scope2) => {
|
|
1868
|
-
const pendingEffects2 = scope2["#
|
|
1882
|
+
const pendingEffects2 = scope2["#PendingEffects" /* PendingEffects */];
|
|
1869
1883
|
if (pendingEffects2) {
|
|
1870
|
-
scope2["#
|
|
1884
|
+
scope2["#PendingEffects" /* PendingEffects */] = [];
|
|
1871
1885
|
runEffects(pendingEffects2, true);
|
|
1872
1886
|
}
|
|
1873
1887
|
});
|
|
@@ -1892,7 +1906,7 @@ function _await(nodeAccessor, renderer) {
|
|
|
1892
1906
|
}
|
|
1893
1907
|
function _try(nodeAccessor, content) {
|
|
1894
1908
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1895
|
-
const branchAccessor = "
|
|
1909
|
+
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1896
1910
|
return (scope, input) => {
|
|
1897
1911
|
if (!scope[branchAccessor]) {
|
|
1898
1912
|
setConditionalRenderer(
|
|
@@ -1921,7 +1935,7 @@ function renderCatch(scope, error) {
|
|
|
1921
1935
|
const placeholderBranch = tryWithCatch["#PlaceholderBranch" /* PlaceholderBranch */];
|
|
1922
1936
|
if (placeholderBranch) {
|
|
1923
1937
|
tryWithCatch["#PendingAsyncCount" /* PendingAsyncCount */] = 0;
|
|
1924
|
-
owner["
|
|
1938
|
+
owner["BranchScopes:" /* BranchScopes */ + tryWithCatch["#BranchAccessor" /* BranchAccessor */]] = placeholderBranch;
|
|
1925
1939
|
destroyBranch(tryWithCatch);
|
|
1926
1940
|
}
|
|
1927
1941
|
caughtError.add(pendingEffects);
|
|
@@ -1932,7 +1946,7 @@ function renderCatch(scope, error) {
|
|
|
1932
1946
|
createAndSetupBranch
|
|
1933
1947
|
);
|
|
1934
1948
|
tryWithCatch["#CatchContent" /* CatchContent */].___params?.(
|
|
1935
|
-
owner["
|
|
1949
|
+
owner["BranchScopes:" /* BranchScopes */ + tryWithCatch["#BranchAccessor" /* BranchAccessor */]],
|
|
1936
1950
|
[error]
|
|
1937
1951
|
);
|
|
1938
1952
|
}
|
|
@@ -1957,7 +1971,7 @@ function patchDynamicTag(fn) {
|
|
|
1957
1971
|
}
|
|
1958
1972
|
var _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1959
1973
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1960
|
-
const childScopeAccessor = "
|
|
1974
|
+
const childScopeAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1961
1975
|
const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
|
1962
1976
|
enableBranches();
|
|
1963
1977
|
return (scope, newRenderer, getInput) => {
|
|
@@ -1985,7 +1999,7 @@ var _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
|
|
|
1985
1999
|
subscribeToScopeSet(
|
|
1986
2000
|
content.___owner,
|
|
1987
2001
|
content.___accessor,
|
|
1988
|
-
scope[childScopeAccessor]["
|
|
2002
|
+
scope[childScopeAccessor]["BranchScopes:" /* BranchScopes */ + (true ? `#${normalizedRenderer}/0` : "a")]
|
|
1989
2003
|
);
|
|
1990
2004
|
}
|
|
1991
2005
|
}
|
|
@@ -2045,9 +2059,9 @@ function dynamicTagScript(branch) {
|
|
|
2045
2059
|
}
|
|
2046
2060
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
|
2047
2061
|
const referenceNode = scope[nodeAccessor];
|
|
2048
|
-
const prevBranch = scope["
|
|
2062
|
+
const prevBranch = scope["BranchScopes:" /* BranchScopes */ + nodeAccessor];
|
|
2049
2063
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.["#StartNode" /* StartNode */] || referenceNode).parentNode : referenceNode;
|
|
2050
|
-
const newBranch = scope["
|
|
2064
|
+
const newBranch = scope["BranchScopes:" /* BranchScopes */ + nodeAccessor] = newRenderer && createBranch2(scope["$global" /* Global */], newRenderer, scope, parentNode);
|
|
2051
2065
|
if (referenceNode === parentNode) {
|
|
2052
2066
|
if (prevBranch) {
|
|
2053
2067
|
destroyBranch(prevBranch);
|
|
@@ -2114,49 +2128,52 @@ function _for_until(nodeAccessor, renderer) {
|
|
|
2114
2128
|
}
|
|
2115
2129
|
function loop(nodeAccessor, renderer, forEach) {
|
|
2116
2130
|
const params = renderer.___params;
|
|
2131
|
+
const scopesAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
2132
|
+
const scopesByKeyAccessor = "BranchScopes:" /* BranchScopes */ + scopesAccessor;
|
|
2117
2133
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
2118
2134
|
enableBranches();
|
|
2119
2135
|
return (scope, value) => {
|
|
2120
2136
|
const referenceNode = scope[nodeAccessor];
|
|
2121
|
-
const
|
|
2122
|
-
const
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
const
|
|
2127
|
-
const
|
|
2137
|
+
const oldScopes = toArray(scope[scopesAccessor]);
|
|
2138
|
+
const oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
2139
|
+
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2140
|
+
/* @__PURE__ */ new Map()
|
|
2141
|
+
);
|
|
2142
|
+
const newScopes = scope[scopesAccessor] = [];
|
|
2143
|
+
const newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map();
|
|
2144
|
+
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.["#StartNode" /* StartNode */].parentNode : referenceNode;
|
|
2128
2145
|
forEach(value, (key, args) => {
|
|
2129
2146
|
if (true) {
|
|
2130
|
-
if (
|
|
2147
|
+
if (newScopesByKey.has(key)) {
|
|
2131
2148
|
console.error(
|
|
2132
2149
|
`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
|
|
2133
2150
|
key
|
|
2134
2151
|
);
|
|
2135
2152
|
}
|
|
2136
2153
|
}
|
|
2137
|
-
const branch =
|
|
2154
|
+
const branch = oldScopesByKey.get(key) || createAndSetupBranch(
|
|
2138
2155
|
scope["$global" /* Global */],
|
|
2139
2156
|
renderer,
|
|
2140
2157
|
scope,
|
|
2141
2158
|
parentNode
|
|
2142
2159
|
);
|
|
2143
2160
|
params?.(branch, args);
|
|
2144
|
-
|
|
2145
|
-
|
|
2161
|
+
newScopesByKey.set(key, branch);
|
|
2162
|
+
newScopes.push(branch);
|
|
2146
2163
|
});
|
|
2147
2164
|
let afterReference = null;
|
|
2148
2165
|
if (referenceNode !== parentNode) {
|
|
2149
|
-
if (
|
|
2150
|
-
afterReference =
|
|
2151
|
-
if (!
|
|
2166
|
+
if (oldScopes.length) {
|
|
2167
|
+
afterReference = oldScopes[oldScopes.length - 1]["#EndNode" /* EndNode */].nextSibling;
|
|
2168
|
+
if (!newScopes.length) {
|
|
2152
2169
|
parentNode.insertBefore(referenceNode, afterReference);
|
|
2153
2170
|
}
|
|
2154
|
-
} else if (
|
|
2171
|
+
} else if (newScopes.length) {
|
|
2155
2172
|
afterReference = referenceNode.nextSibling;
|
|
2156
2173
|
referenceNode.remove();
|
|
2157
2174
|
}
|
|
2158
2175
|
}
|
|
2159
|
-
reconcile(parentNode,
|
|
2176
|
+
reconcile(parentNode, oldScopes, newScopes, afterReference);
|
|
2160
2177
|
};
|
|
2161
2178
|
}
|
|
2162
2179
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
@@ -2299,7 +2316,7 @@ var _enable_catch = () => {
|
|
|
2299
2316
|
const handlePendingTry = (fn, scope, branch) => {
|
|
2300
2317
|
while (branch) {
|
|
2301
2318
|
if (branch["#PendingAsyncCount" /* PendingAsyncCount */]) {
|
|
2302
|
-
return (branch["#
|
|
2319
|
+
return (branch["#PendingEffects" /* PendingEffects */] ||= []).push(fn, scope);
|
|
2303
2320
|
}
|
|
2304
2321
|
branch = branch["#ParentBranch" /* ParentBranch */];
|
|
2305
2322
|
}
|