marko 6.0.0-next.3.64 → 6.0.0-next.3.65
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 +2 -1
- package/dist/common/accessor.debug.d.ts +2 -1
- package/dist/common/types.d.ts +1 -2
- package/dist/debug/dom.js +18 -26
- package/dist/debug/dom.mjs +18 -26
- package/dist/debug/html.js +3 -3
- package/dist/debug/html.mjs +3 -3
- package/dist/dom.js +128 -134
- package/dist/dom.mjs +128 -134
- package/dist/html.js +6 -6
- package/dist/html.mjs +6 -6
- package/dist/translator/index.js +2 -0
- package/package.json +1 -1
package/dist/dom.mjs
CHANGED
@@ -126,48 +126,42 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
126
126
|
let renders = window[runtimeId], defineRuntime = (desc) => Object.defineProperty(window, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
127
127
|
defineRuntime({
|
128
128
|
value: resumeRender = (renderId) => {
|
129
|
-
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length,
|
129
|
+
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, branchStack = [], scopeLookup = render.s = {}, serializeContext = {
|
130
130
|
_: registeredValues
|
131
|
-
}, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(),
|
131
|
+
}, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), currentBranchId;
|
132
132
|
return render.w = () => {
|
133
133
|
walk2.call(render);
|
134
134
|
let visits = render.v, resumes = render.r;
|
135
135
|
if (visits.length) {
|
136
136
|
let visitNodes = new Set(visits), lastEndNode;
|
137
|
-
|
138
|
-
let branchEnd = (branchId,
|
137
|
+
visits.length = 0;
|
138
|
+
let branchEnd = (branchId, reference) => {
|
139
139
|
let branch = scopeLookup[branchId] ||= {}, endNode = reference;
|
140
140
|
for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
|
141
|
-
endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
|
141
|
+
return endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
|
142
142
|
new Text(),
|
143
143
|
reference
|
144
|
-
)), branch.
|
145
|
-
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
146
|
-
branch.g.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
147
|
-
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
144
|
+
)), branch.j = lastEndNode = endNode, branch.h ||= endNode, branchIds.add(branchId), branch;
|
148
145
|
};
|
149
|
-
for (let visit of
|
146
|
+
for (let visit of visitNodes) {
|
150
147
|
let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = commentText.slice(
|
151
148
|
commentPrefixLen + 1,
|
152
149
|
dataIndex ? dataIndex - 1 : commentText.length
|
153
150
|
), scope = scopeLookup[scopeId] ||= {
|
154
|
-
|
151
|
+
m: +scopeId
|
155
152
|
}, data2 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
|
156
153
|
if (token === "*" /* Node */) {
|
157
154
|
let node = scope[data2] = visit.previousSibling;
|
158
155
|
scope["j" /* Getter */ + data2] = () => node;
|
159
|
-
} else if (token === "
|
160
|
-
|
161
|
-
else if (token === "[" /* BranchStart */)
|
162
|
-
currentScopeId && (dataIndex && branchEnd(currentScopeId, visit, visit), scopeStack.push(currentScopeId)), currentScopeId = scopeId, scope.g = visit;
|
156
|
+
} else if (token === "[" /* BranchStart */)
|
157
|
+
currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
|
163
158
|
else if (token === "]" /* BranchEnd */) {
|
164
159
|
scope[data2] = visit;
|
165
160
|
let curParent = visit.parentNode, startNode = branchEnd(
|
166
|
-
|
167
|
-
visit,
|
161
|
+
currentBranchId,
|
168
162
|
visit
|
169
|
-
).
|
170
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode),
|
163
|
+
).h;
|
164
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
171
165
|
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
172
166
|
let next = data2.indexOf(" "), curNode = visit;
|
173
167
|
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
@@ -177,7 +171,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
177
171
|
start,
|
178
172
|
~next ? next : data2.length
|
179
173
|
);
|
180
|
-
curNode = branchEnd(childScopeId,
|
174
|
+
curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
181
175
|
}
|
182
176
|
}
|
183
177
|
}
|
@@ -189,18 +183,18 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
189
183
|
let serialized = resumes[i];
|
190
184
|
if (typeof serialized == "function") {
|
191
185
|
let scopes = serialized(serializeContext), { $global } = scopeLookup;
|
192
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.
|
186
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.n = 1e6);
|
193
187
|
for (let scopeId in scopes)
|
194
188
|
if (scopeId !== "$") {
|
195
189
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
196
|
-
scope.$global = $global, scope.
|
190
|
+
scope.$global = $global, scope.m = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
197
191
|
scope,
|
198
192
|
prevScope
|
199
193
|
));
|
200
|
-
let parentBranchId = parentBranchIds.get(scopeId);
|
201
|
-
if (parentBranchId && (scope.
|
202
|
-
let branch = scope, parentBranch = branch.
|
203
|
-
scope.
|
194
|
+
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
195
|
+
if (parentBranchId && (scope.k = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
196
|
+
let branch = scope, parentBranch = branch.k;
|
197
|
+
scope.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(
|
204
198
|
branch
|
205
199
|
));
|
206
200
|
}
|
@@ -633,53 +627,53 @@ function toInsertNode(startNode, endNode) {
|
|
633
627
|
var pendingScopes = [];
|
634
628
|
function createScope($global, closestBranch) {
|
635
629
|
let scope = {
|
636
|
-
|
637
|
-
|
638
|
-
|
630
|
+
m: $global.n++,
|
631
|
+
o: 1,
|
632
|
+
k: closestBranch,
|
639
633
|
$global
|
640
634
|
};
|
641
635
|
return pendingScopes.push(scope), scope;
|
642
636
|
}
|
643
637
|
function skipScope(scope) {
|
644
|
-
return scope.$global.
|
638
|
+
return scope.$global.n++;
|
645
639
|
}
|
646
640
|
function finishPendingScopes() {
|
647
641
|
for (let scope of pendingScopes)
|
648
|
-
scope.
|
642
|
+
scope.o = 0;
|
649
643
|
pendingScopes = [];
|
650
644
|
}
|
651
645
|
function findBranchWithKey(scope, key) {
|
652
|
-
let branch = scope.
|
646
|
+
let branch = scope.k;
|
653
647
|
for (; branch && !branch[key]; )
|
654
|
-
branch = branch.
|
648
|
+
branch = branch.u;
|
655
649
|
return branch;
|
656
650
|
}
|
657
651
|
function destroyBranch(branch) {
|
658
|
-
branch.
|
652
|
+
branch.u?.A?.delete(branch), destroyNestedBranches(branch);
|
659
653
|
}
|
660
654
|
function destroyNestedBranches(branch) {
|
661
|
-
branch.
|
662
|
-
for (let id in scope.
|
663
|
-
scope.
|
655
|
+
branch.p = 1, branch.A?.forEach(destroyNestedBranches), branch.J?.forEach((scope) => {
|
656
|
+
for (let id in scope.x)
|
657
|
+
scope.x[id]?.abort();
|
664
658
|
});
|
665
659
|
}
|
666
660
|
function removeAndDestroyBranch(branch) {
|
667
|
-
destroyBranch(branch), removeChildNodes(branch.
|
661
|
+
destroyBranch(branch), removeChildNodes(branch.h, branch.j);
|
668
662
|
}
|
669
663
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
670
664
|
insertChildNodes(
|
671
665
|
parentNode,
|
672
666
|
nextSibling,
|
673
|
-
branch.
|
674
|
-
branch.
|
667
|
+
branch.h,
|
668
|
+
branch.j
|
675
669
|
);
|
676
670
|
}
|
677
671
|
function tempDetatchBranch(branch) {
|
678
672
|
insertChildNodes(
|
679
673
|
new DocumentFragment(),
|
680
674
|
null,
|
681
|
-
branch.
|
682
|
-
branch.
|
675
|
+
branch.h,
|
676
|
+
branch.j
|
683
677
|
);
|
684
678
|
}
|
685
679
|
|
@@ -701,7 +695,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
701
695
|
}
|
702
696
|
if (oldStart > oldEnd) {
|
703
697
|
if (newStart <= newEnd) {
|
704
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].
|
698
|
+
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].h : afterReference;
|
705
699
|
do
|
706
700
|
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
707
701
|
while (newStart <= newEnd);
|
@@ -730,10 +724,10 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
730
724
|
if (pos === WRONG_POS) {
|
731
725
|
let seq = longestIncreasingSubsequence(sources);
|
732
726
|
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
733
|
-
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].
|
727
|
+
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].h : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].h : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
|
734
728
|
} else if (synced !== newLength)
|
735
729
|
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
736
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].
|
730
|
+
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].h : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
737
731
|
}
|
738
732
|
}
|
739
733
|
}
|
@@ -780,7 +774,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
780
774
|
currentWalkIndex = walkInternal(
|
781
775
|
currentWalkIndex,
|
782
776
|
walkCodes,
|
783
|
-
scope[currentScopeIndex++] = createScope(scope.$global, scope.
|
777
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
|
784
778
|
), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
785
779
|
else if (value2 < 92)
|
786
780
|
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
@@ -799,8 +793,8 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
799
793
|
|
800
794
|
// src/dom/renderer.ts
|
801
795
|
function createBranch($global, renderer, parentScope, parentNode) {
|
802
|
-
let branch = createScope($global), parentBranch = parentScope?.
|
803
|
-
return branch._ = renderer.
|
796
|
+
let branch = createScope($global), parentBranch = parentScope?.k;
|
797
|
+
return branch._ = renderer.y || parentScope, branch.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.B?.(
|
804
798
|
branch,
|
805
799
|
parentNode.namespaceURI
|
806
800
|
), branch;
|
@@ -812,10 +806,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
812
806
|
);
|
813
807
|
}
|
814
808
|
function setupBranch(renderer, branch) {
|
815
|
-
return (renderer.
|
809
|
+
return (renderer.C || renderer.E) && queueRender(
|
816
810
|
branch,
|
817
811
|
(branch2) => {
|
818
|
-
renderer.
|
812
|
+
renderer.C?.(branch2), renderer.E?.(branch2);
|
819
813
|
},
|
820
814
|
-1
|
821
815
|
), branch;
|
@@ -829,19 +823,19 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
829
823
|
))(branch, walks);
|
830
824
|
} : (branch) => {
|
831
825
|
walk(
|
832
|
-
branch.
|
826
|
+
branch.h = branch.j = new Text(),
|
833
827
|
walks,
|
834
828
|
branch
|
835
829
|
);
|
836
830
|
};
|
837
831
|
return (owner) => ({
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
832
|
+
m: id,
|
833
|
+
B: clone,
|
834
|
+
y: owner,
|
835
|
+
C: setup,
|
836
|
+
l: params,
|
837
|
+
E: closures,
|
838
|
+
z: dynamicScopesAccessor
|
845
839
|
});
|
846
840
|
}
|
847
841
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -866,13 +860,13 @@ function createCloneableHTML(html2, ns) {
|
|
866
860
|
let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
|
867
861
|
return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
868
862
|
walk(
|
869
|
-
branch.
|
863
|
+
branch.h = branch.j = firstChild.cloneNode(!0),
|
870
864
|
walks,
|
871
865
|
branch
|
872
866
|
);
|
873
867
|
} : (branch, walks) => {
|
874
868
|
let clone = parent.cloneNode(!0);
|
875
|
-
walk(clone.firstChild, walks, branch), branch.
|
869
|
+
walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
|
876
870
|
};
|
877
871
|
}
|
878
872
|
|
@@ -913,9 +907,9 @@ function value(valueAccessor, fn = () => {
|
|
913
907
|
(!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
|
914
908
|
};
|
915
909
|
}
|
916
|
-
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "
|
910
|
+
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "m") {
|
917
911
|
return (scope) => {
|
918
|
-
scope.
|
912
|
+
scope.o ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
919
913
|
};
|
920
914
|
}
|
921
915
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -925,11 +919,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
925
919
|
ownerScope,
|
926
920
|
() => {
|
927
921
|
for (let scope of scopes)
|
928
|
-
!scope.
|
922
|
+
!scope.o && !scope.p && childSignal(scope);
|
929
923
|
},
|
930
924
|
-1,
|
931
925
|
0,
|
932
|
-
firstScope.
|
926
|
+
firstScope.m
|
933
927
|
);
|
934
928
|
};
|
935
929
|
return ownerSignal._ = childSignal, ownerSignal;
|
@@ -937,7 +931,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
937
931
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
938
932
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
939
933
|
let ifScope = scope[scopeAccessor];
|
940
|
-
ifScope && !ifScope.
|
934
|
+
ifScope && !ifScope.o && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
941
935
|
};
|
942
936
|
return ownerSignal._ = childSignal, ownerSignal;
|
943
937
|
}
|
@@ -949,13 +943,13 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
949
943
|
));
|
950
944
|
}
|
951
945
|
function dynamicClosure(...closureSignals) {
|
952
|
-
let [{
|
946
|
+
let [{ F: ___scopeInstancesAccessor, G: ___signalIndexAccessor }] = closureSignals;
|
953
947
|
for (let i = closureSignals.length; i--; )
|
954
|
-
closureSignals[i].
|
948
|
+
closureSignals[i].K = i;
|
955
949
|
return (scope) => {
|
956
950
|
if (scope[___scopeInstancesAccessor])
|
957
951
|
for (let childScope of scope[___scopeInstancesAccessor])
|
958
|
-
childScope.
|
952
|
+
childScope.o || queueRender(
|
959
953
|
childScope,
|
960
954
|
closureSignals[childScope[___signalIndexAccessor]],
|
961
955
|
-1
|
@@ -964,13 +958,13 @@ function dynamicClosure(...closureSignals) {
|
|
964
958
|
}
|
965
959
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
966
960
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
967
|
-
scope[closureSignal.
|
961
|
+
scope[closureSignal.G] = closureSignal.K, childSignal(scope), subscribeToScopeSet(
|
968
962
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
969
|
-
closureSignal.
|
963
|
+
closureSignal.F,
|
970
964
|
scope
|
971
965
|
);
|
972
966
|
};
|
973
|
-
return closureSignal.
|
967
|
+
return closureSignal.F = "a" /* ClosureScopes */ + valueAccessor, closureSignal.G = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
|
974
968
|
}
|
975
969
|
function closure(valueAccessor, fn, getOwnerScope) {
|
976
970
|
return (scope) => {
|
@@ -1015,8 +1009,8 @@ function awaitTag(nodeAccessor, renderer) {
|
|
1015
1009
|
let tryWithPlaceholder = findBranchWithKey(
|
1016
1010
|
scope,
|
1017
1011
|
"d" /* PlaceholderContent */
|
1018
|
-
), awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.
|
1019
|
-
if (!(scope.
|
1012
|
+
), awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.h ?? referenceNode).parentNode, thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1013
|
+
if (!(scope.k?.p || scope[promiseAccessor] !== thisPromise) && (scope[promiseAccessor] = void 0, runEffects(
|
1020
1014
|
prepareEffects(() => {
|
1021
1015
|
tryWithPlaceholder && placeholderShown.add(pendingEffects), (!awaitBranch || !tryWithPlaceholder) && (insertBranchBefore(
|
1022
1016
|
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
@@ -1027,40 +1021,40 @@ function awaitTag(nodeAccessor, renderer) {
|
|
1027
1021
|
),
|
1028
1022
|
referenceNode.parentNode,
|
1029
1023
|
referenceNode
|
1030
|
-
), referenceNode.remove()), renderer.
|
1024
|
+
), referenceNode.remove()), renderer.l?.(awaitBranch, [data2]);
|
1031
1025
|
})
|
1032
|
-
), tryWithPlaceholder && !--tryWithPlaceholder.
|
1026
|
+
), tryWithPlaceholder && !--tryWithPlaceholder.q)) {
|
1033
1027
|
let placeholderBranch = tryWithPlaceholder.c;
|
1034
1028
|
tryWithPlaceholder.c = void 0, placeholderBranch ? (insertBranchBefore(
|
1035
1029
|
tryWithPlaceholder,
|
1036
|
-
placeholderBranch.
|
1037
|
-
placeholderBranch.
|
1030
|
+
placeholderBranch.h.parentNode,
|
1031
|
+
placeholderBranch.h
|
1038
1032
|
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1039
1033
|
tryWithPlaceholder,
|
1040
1034
|
referenceNode.parentNode,
|
1041
1035
|
referenceNode
|
1042
|
-
), tryWithPlaceholder.
|
1036
|
+
), tryWithPlaceholder.H && runEffects(tryWithPlaceholder.H, !0);
|
1043
1037
|
}
|
1044
1038
|
}).catch((error) => {
|
1045
1039
|
renderCatch(scope, error, !0);
|
1046
1040
|
});
|
1047
|
-
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.
|
1048
|
-
if (tryWithPlaceholder.
|
1041
|
+
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.q || (tryWithPlaceholder.q = 0, requestAnimationFrame(() => {
|
1042
|
+
if (tryWithPlaceholder.q && !tryWithPlaceholder.p) {
|
1049
1043
|
let placeholderBranch = tryWithPlaceholder.c = createAndSetupBranch(
|
1050
1044
|
scope.$global,
|
1051
1045
|
tryWithPlaceholder.d,
|
1052
1046
|
tryWithPlaceholder._,
|
1053
|
-
tryWithPlaceholder.
|
1047
|
+
tryWithPlaceholder.h.parentNode
|
1054
1048
|
);
|
1055
1049
|
insertBranchBefore(
|
1056
1050
|
placeholderBranch,
|
1057
|
-
tryWithPlaceholder.
|
1058
|
-
tryWithPlaceholder.
|
1051
|
+
tryWithPlaceholder.h.parentNode,
|
1052
|
+
tryWithPlaceholder.h
|
1059
1053
|
), tempDetatchBranch(tryWithPlaceholder);
|
1060
1054
|
}
|
1061
|
-
})), tryWithPlaceholder.
|
1055
|
+
})), tryWithPlaceholder.q++) : awaitBranch && (awaitBranch.h.parentNode.insertBefore(
|
1062
1056
|
referenceNode,
|
1063
|
-
awaitBranch.
|
1057
|
+
awaitBranch.h
|
1064
1058
|
), tempDetatchBranch(awaitBranch));
|
1065
1059
|
};
|
1066
1060
|
}
|
@@ -1088,7 +1082,7 @@ function renderCatch(scope, error, async) {
|
|
1088
1082
|
tryWithCatch.a,
|
1089
1083
|
tryWithCatch.b,
|
1090
1084
|
createAndSetupBranch
|
1091
|
-
), tryWithCatch.b.
|
1085
|
+
), tryWithCatch.b.l?.(
|
1092
1086
|
tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
|
1093
1087
|
[error]
|
1094
1088
|
);
|
@@ -1117,7 +1111,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1117
1111
|
let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1118
1112
|
return (scope, newRenderer, getInput) => {
|
1119
1113
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1120
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
1114
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1121
1115
|
if (setConditionalRenderer(
|
1122
1116
|
scope,
|
1123
1117
|
nodeAccessor,
|
@@ -1131,15 +1125,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1131
1125
|
0,
|
1132
1126
|
content,
|
1133
1127
|
createAndSetupBranch
|
1134
|
-
), content.
|
1135
|
-
content.x,
|
1128
|
+
), content.z && subscribeToScopeSet(
|
1136
1129
|
content.y,
|
1130
|
+
content.z,
|
1137
1131
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1138
1132
|
);
|
1139
1133
|
}
|
1140
|
-
} else normalizedRenderer?.
|
1141
|
-
normalizedRenderer.x,
|
1134
|
+
} else normalizedRenderer?.z && subscribeToScopeSet(
|
1142
1135
|
normalizedRenderer.y,
|
1136
|
+
normalizedRenderer.z,
|
1143
1137
|
scope[childScopeAccessor]
|
1144
1138
|
);
|
1145
1139
|
if (normalizedRenderer) {
|
@@ -1150,9 +1144,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1150
1144
|
0,
|
1151
1145
|
(inputIsArgs ? args[0] : args) || {}
|
1152
1146
|
);
|
1153
|
-
else if (normalizedRenderer.
|
1147
|
+
else if (normalizedRenderer.l)
|
1154
1148
|
if (inputIsArgs)
|
1155
|
-
normalizedRenderer.
|
1149
|
+
normalizedRenderer.l(
|
1156
1150
|
scope[childScopeAccessor],
|
1157
1151
|
normalizedRenderer._ ? args[0] : args
|
1158
1152
|
);
|
@@ -1161,7 +1155,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1161
1155
|
...args,
|
1162
1156
|
content: getContent(scope)
|
1163
1157
|
} : args || {};
|
1164
|
-
normalizedRenderer.
|
1158
|
+
normalizedRenderer.l(
|
1165
1159
|
scope[childScopeAccessor],
|
1166
1160
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1167
1161
|
);
|
@@ -1170,8 +1164,8 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1170
1164
|
};
|
1171
1165
|
};
|
1172
1166
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1173
|
-
let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.
|
1174
|
-
referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.
|
1167
|
+
let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.h || referenceNode).parentNode : referenceNode, newBranch = scope["d" /* ConditionalScope */ + nodeAccessor] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
|
1168
|
+
referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.h) : parentNode.insertBefore(referenceNode, prevBranch.h), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
|
1175
1169
|
}
|
1176
1170
|
function loopOf(nodeAccessor, renderer) {
|
1177
1171
|
return loop(
|
@@ -1200,17 +1194,17 @@ function loopTo(nodeAccessor, renderer) {
|
|
1200
1194
|
);
|
1201
1195
|
}
|
1202
1196
|
function loop(nodeAccessor, renderer, forEach) {
|
1203
|
-
let params = renderer.
|
1197
|
+
let params = renderer.l;
|
1204
1198
|
return (scope, value2) => {
|
1205
1199
|
let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
|
1206
1200
|
...oldMap.values()
|
1207
|
-
] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].
|
1201
|
+
] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].h.parentNode : referenceNode, newMap = scope["m" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map(), newArray = scope["l" /* LoopScopeArray */ + nodeAccessor] = [];
|
1208
1202
|
forEach(value2, (key, args) => {
|
1209
1203
|
let branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
|
1210
1204
|
params?.(branch, args), newMap.set(key, branch), newArray.push(branch);
|
1211
1205
|
});
|
1212
1206
|
let afterReference = null;
|
1213
|
-
referenceNode !== parentNode && (oldArray.length ? (afterReference = oldArray[oldArray.length - 1].
|
1207
|
+
referenceNode !== parentNode && (oldArray.length ? (afterReference = oldArray[oldArray.length - 1].j.nextSibling, newArray.length || parentNode.insertBefore(referenceNode, afterReference)) : newArray.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldArray, newArray, afterReference);
|
1214
1208
|
};
|
1215
1209
|
}
|
1216
1210
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
@@ -1220,7 +1214,7 @@ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentSco
|
|
1220
1214
|
parentScope,
|
1221
1215
|
parentNode
|
1222
1216
|
);
|
1223
|
-
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.
|
1217
|
+
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.h = branch.j = document.createElementNS(
|
1224
1218
|
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1225
1219
|
tagNameOrRenderer
|
1226
1220
|
) : setupBranch(tagNameOrRenderer, branch), branch;
|
@@ -1234,20 +1228,20 @@ function byFirstArg(name) {
|
|
1234
1228
|
|
1235
1229
|
// src/dom/queue.ts
|
1236
1230
|
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1237
|
-
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.
|
1231
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
|
1238
1232
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1239
1233
|
if (existingRender)
|
1240
|
-
existingRender.
|
1234
|
+
existingRender.I = value2;
|
1241
1235
|
else {
|
1242
1236
|
let render = {
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1237
|
+
t: key,
|
1238
|
+
D: scope,
|
1239
|
+
L: signal,
|
1240
|
+
I: value2
|
1247
1241
|
}, i = pendingRenders.push(render) - 1;
|
1248
1242
|
for (; i; ) {
|
1249
1243
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1250
|
-
if (key - parent.
|
1244
|
+
if (key - parent.t >= 0) break;
|
1251
1245
|
pendingRenders[i] = parent, i = parentIndex;
|
1252
1246
|
}
|
1253
1247
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1286,52 +1280,52 @@ function runRenders() {
|
|
1286
1280
|
for (; pendingRenders.length; ) {
|
1287
1281
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1288
1282
|
if (render !== item) {
|
1289
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1283
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
|
1290
1284
|
for (; i < mid; ) {
|
1291
1285
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1292
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
1286
|
+
if (right < pendingRenders.length && pendingRenders[right].t - pendingRenders[bestChild].t < 0 && (bestChild = right), pendingRenders[bestChild].t - key >= 0)
|
1293
1287
|
break;
|
1294
1288
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1295
1289
|
}
|
1296
1290
|
pendingRenders[i] = item;
|
1297
1291
|
}
|
1298
|
-
render.
|
1292
|
+
render.D.k?.p || runRender(render);
|
1299
1293
|
}
|
1300
1294
|
finishPendingScopes();
|
1301
1295
|
}
|
1302
|
-
var runRender = (render) => render.
|
1296
|
+
var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
|
1303
1297
|
enableCatch = () => {
|
1304
1298
|
};
|
1305
1299
|
let handlePendingTry = (fn, scope, branch) => {
|
1306
1300
|
for (; branch; ) {
|
1307
|
-
if (branch.
|
1308
|
-
return (branch.
|
1309
|
-
branch = branch.
|
1301
|
+
if (branch.q)
|
1302
|
+
return (branch.H ||= []).push(fn, scope);
|
1303
|
+
branch = branch.u;
|
1310
1304
|
}
|
1311
1305
|
};
|
1312
1306
|
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1313
1307
|
if (checkPending || caughtError.has(effects)) {
|
1314
1308
|
let i = 0, fn, scope, branch;
|
1315
1309
|
for (; i < effects.length; )
|
1316
|
-
fn = effects[i++], scope = effects[i++], branch = scope.
|
1310
|
+
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.p && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1317
1311
|
} else
|
1318
1312
|
runEffects2(effects);
|
1319
1313
|
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1320
1314
|
try {
|
1321
1315
|
runRender2(render);
|
1322
1316
|
} catch (error) {
|
1323
|
-
renderCatch(render.
|
1317
|
+
renderCatch(render.D, error);
|
1324
1318
|
}
|
1325
1319
|
})(runRender);
|
1326
1320
|
};
|
1327
1321
|
|
1328
1322
|
// src/dom/abort-signal.ts
|
1329
1323
|
function resetAbortSignal(scope, id) {
|
1330
|
-
let ctrl = scope.
|
1331
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1324
|
+
let ctrl = scope.x?.[id];
|
1325
|
+
ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
|
1332
1326
|
}
|
1333
1327
|
function getAbortSignal(scope, id) {
|
1334
|
-
return scope.
|
1328
|
+
return scope.k && (scope.k.J ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
|
1335
1329
|
}
|
1336
1330
|
function abort(ctrl) {
|
1337
1331
|
ctrl.abort();
|
@@ -1353,13 +1347,13 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1353
1347
|
register(RENDERER_REGISTER_ID, fn);
|
1354
1348
|
},
|
1355
1349
|
isRenderer(renderer) {
|
1356
|
-
return renderer.
|
1350
|
+
return renderer.B;
|
1357
1351
|
},
|
1358
1352
|
getStartNode(branch) {
|
1359
|
-
return branch.
|
1353
|
+
return branch.h;
|
1360
1354
|
},
|
1361
1355
|
setScopeNodes(branch, startNode, endNode) {
|
1362
|
-
branch.
|
1356
|
+
branch.h = startNode, branch.j = endNode;
|
1363
1357
|
},
|
1364
1358
|
runComponentEffects() {
|
1365
1359
|
runEffects(this.effects);
|
@@ -1378,9 +1372,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1378
1372
|
},
|
1379
1373
|
createRenderer(params, clone) {
|
1380
1374
|
let renderer = createRenderer(0, 0, 0, params);
|
1381
|
-
return renderer.
|
1375
|
+
return renderer.B = (branch) => {
|
1382
1376
|
let cloned = clone();
|
1383
|
-
branch.
|
1377
|
+
branch.h = cloned.startNode, branch.j = cloned.endNode;
|
1384
1378
|
}, renderer;
|
1385
1379
|
},
|
1386
1380
|
render(out, component, renderer, args) {
|
@@ -1393,14 +1387,14 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1393
1387
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1394
1388
|
}
|
1395
1389
|
if (component.effects = prepareEffects(() => {
|
1396
|
-
branch ? existing = !0 : (out.global.
|
1390
|
+
branch ? existing = !0 : (out.global.n ||= 0, branch = component.scope = createAndSetupBranch(
|
1397
1391
|
out.global,
|
1398
1392
|
renderer,
|
1399
|
-
renderer.
|
1393
|
+
renderer.y,
|
1400
1394
|
document.body
|
1401
|
-
)), renderer.
|
1395
|
+
)), renderer.l?.(branch, renderer._ ? args[0] : args);
|
1402
1396
|
}), !existing)
|
1403
|
-
return toInsertNode(branch.
|
1397
|
+
return toInsertNode(branch.h, branch.j);
|
1404
1398
|
}
|
1405
1399
|
};
|
1406
1400
|
|
@@ -1418,12 +1412,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1418
1412
|
function mount(input = {}, reference, position) {
|
1419
1413
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1420
1414
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1421
|
-
|
1415
|
+
n: 0,
|
1422
1416
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1423
1417
|
renderId: DEFAULT_RENDER_ID,
|
1424
1418
|
...$global
|
1425
1419
|
}) : $global = {
|
1426
|
-
|
1420
|
+
n: 0,
|
1427
1421
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1428
1422
|
renderId: DEFAULT_RENDER_ID
|
1429
1423
|
}, position) {
|
@@ -1437,19 +1431,19 @@ function mount(input = {}, reference, position) {
|
|
1437
1431
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1438
1432
|
break;
|
1439
1433
|
}
|
1440
|
-
let args = this.
|
1434
|
+
let args = this.l, effects = prepareEffects(() => {
|
1441
1435
|
branch = createBranch(
|
1442
1436
|
$global,
|
1443
1437
|
this,
|
1444
1438
|
void 0,
|
1445
1439
|
parentNode
|
1446
|
-
), this.
|
1440
|
+
), this.C?.(branch), args?.(branch, input);
|
1447
1441
|
});
|
1448
1442
|
return insertChildNodes(
|
1449
1443
|
parentNode,
|
1450
1444
|
nextSibling,
|
1451
|
-
branch.
|
1452
|
-
branch.
|
1445
|
+
branch.h,
|
1446
|
+
branch.j
|
1453
1447
|
), runEffects(effects), {
|
1454
1448
|
update(newInput) {
|
1455
1449
|
args && runEffects(
|