marko 6.0.0-next.3.63 → 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 +3 -3
- package/dist/debug/dom.js +140 -110
- package/dist/debug/dom.mjs +140 -110
- package/dist/debug/html.js +5 -5
- package/dist/debug/html.mjs +5 -5
- package/dist/dom/control-flow.d.ts +1 -0
- package/dist/dom/queue.d.ts +4 -2
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.js +188 -185
- package/dist/dom.mjs +188 -185
- package/dist/html.js +7 -7
- package/dist/html.mjs +7 -7
- 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,47 +627,53 @@ function toInsertNode(startNode, endNode) {
|
|
633
627
|
var pendingScopes = [];
|
634
628
|
function createScope($global, closestBranch) {
|
635
629
|
let scope = {
|
636
|
-
|
630
|
+
m: $global.n++,
|
637
631
|
o: 1,
|
638
|
-
|
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
642
|
scope.o = 0;
|
649
643
|
pendingScopes = [];
|
650
644
|
}
|
645
|
+
function findBranchWithKey(scope, key) {
|
646
|
+
let branch = scope.k;
|
647
|
+
for (; branch && !branch[key]; )
|
648
|
+
branch = branch.u;
|
649
|
+
return branch;
|
650
|
+
}
|
651
651
|
function destroyBranch(branch) {
|
652
|
-
branch.
|
652
|
+
branch.u?.A?.delete(branch), destroyNestedBranches(branch);
|
653
653
|
}
|
654
654
|
function destroyNestedBranches(branch) {
|
655
|
-
branch.
|
656
|
-
for (let id in scope.
|
657
|
-
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();
|
658
658
|
});
|
659
659
|
}
|
660
660
|
function removeAndDestroyBranch(branch) {
|
661
|
-
destroyBranch(branch), removeChildNodes(branch.
|
661
|
+
destroyBranch(branch), removeChildNodes(branch.h, branch.j);
|
662
662
|
}
|
663
663
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
664
664
|
insertChildNodes(
|
665
665
|
parentNode,
|
666
666
|
nextSibling,
|
667
|
-
branch.
|
668
|
-
branch.
|
667
|
+
branch.h,
|
668
|
+
branch.j
|
669
669
|
);
|
670
670
|
}
|
671
671
|
function tempDetatchBranch(branch) {
|
672
672
|
insertChildNodes(
|
673
673
|
new DocumentFragment(),
|
674
674
|
null,
|
675
|
-
branch.
|
676
|
-
branch.
|
675
|
+
branch.h,
|
676
|
+
branch.j
|
677
677
|
);
|
678
678
|
}
|
679
679
|
|
@@ -695,7 +695,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
695
695
|
}
|
696
696
|
if (oldStart > oldEnd) {
|
697
697
|
if (newStart <= newEnd) {
|
698
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].
|
698
|
+
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].h : afterReference;
|
699
699
|
do
|
700
700
|
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
701
701
|
while (newStart <= newEnd);
|
@@ -724,10 +724,10 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
724
724
|
if (pos === WRONG_POS) {
|
725
725
|
let seq = longestIncreasingSubsequence(sources);
|
726
726
|
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
727
|
-
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;
|
728
728
|
} else if (synced !== newLength)
|
729
729
|
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
730
|
-
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));
|
731
731
|
}
|
732
732
|
}
|
733
733
|
}
|
@@ -774,7 +774,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
774
774
|
currentWalkIndex = walkInternal(
|
775
775
|
currentWalkIndex,
|
776
776
|
walkCodes,
|
777
|
-
scope[currentScopeIndex++] = createScope(scope.$global, scope.
|
777
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
|
778
778
|
), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
779
779
|
else if (value2 < 92)
|
780
780
|
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
@@ -793,8 +793,8 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
793
793
|
|
794
794
|
// src/dom/renderer.ts
|
795
795
|
function createBranch($global, renderer, parentScope, parentNode) {
|
796
|
-
let branch = createScope($global), parentBranch = parentScope?.
|
797
|
-
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?.(
|
798
798
|
branch,
|
799
799
|
parentNode.namespaceURI
|
800
800
|
), branch;
|
@@ -806,10 +806,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
806
806
|
);
|
807
807
|
}
|
808
808
|
function setupBranch(renderer, branch) {
|
809
|
-
return (renderer.
|
809
|
+
return (renderer.C || renderer.E) && queueRender(
|
810
810
|
branch,
|
811
811
|
(branch2) => {
|
812
|
-
renderer.
|
812
|
+
renderer.C?.(branch2), renderer.E?.(branch2);
|
813
813
|
},
|
814
814
|
-1
|
815
815
|
), branch;
|
@@ -823,19 +823,19 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
823
823
|
))(branch, walks);
|
824
824
|
} : (branch) => {
|
825
825
|
walk(
|
826
|
-
branch.
|
826
|
+
branch.h = branch.j = new Text(),
|
827
827
|
walks,
|
828
828
|
branch
|
829
829
|
);
|
830
830
|
};
|
831
831
|
return (owner) => ({
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
832
|
+
m: id,
|
833
|
+
B: clone,
|
834
|
+
y: owner,
|
835
|
+
C: setup,
|
836
|
+
l: params,
|
837
|
+
E: closures,
|
838
|
+
z: dynamicScopesAccessor
|
839
839
|
});
|
840
840
|
}
|
841
841
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -860,13 +860,13 @@ function createCloneableHTML(html2, ns) {
|
|
860
860
|
let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
|
861
861
|
return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
862
862
|
walk(
|
863
|
-
branch.
|
863
|
+
branch.h = branch.j = firstChild.cloneNode(!0),
|
864
864
|
walks,
|
865
865
|
branch
|
866
866
|
);
|
867
867
|
} : (branch, walks) => {
|
868
868
|
let clone = parent.cloneNode(!0);
|
869
|
-
walk(clone.firstChild, walks, branch), branch.
|
869
|
+
walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
|
870
870
|
};
|
871
871
|
}
|
872
872
|
|
@@ -907,7 +907,7 @@ function value(valueAccessor, fn = () => {
|
|
907
907
|
(!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
|
908
908
|
};
|
909
909
|
}
|
910
|
-
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "
|
910
|
+
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "m") {
|
911
911
|
return (scope) => {
|
912
912
|
scope.o ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
913
913
|
};
|
@@ -919,11 +919,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
919
919
|
ownerScope,
|
920
920
|
() => {
|
921
921
|
for (let scope of scopes)
|
922
|
-
!scope.o && !scope.
|
922
|
+
!scope.o && !scope.p && childSignal(scope);
|
923
923
|
},
|
924
924
|
-1,
|
925
925
|
0,
|
926
|
-
firstScope.
|
926
|
+
firstScope.m
|
927
927
|
);
|
928
928
|
};
|
929
929
|
return ownerSignal._ = childSignal, ownerSignal;
|
@@ -943,9 +943,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
943
943
|
));
|
944
944
|
}
|
945
945
|
function dynamicClosure(...closureSignals) {
|
946
|
-
let [{
|
946
|
+
let [{ F: ___scopeInstancesAccessor, G: ___signalIndexAccessor }] = closureSignals;
|
947
947
|
for (let i = closureSignals.length; i--; )
|
948
|
-
closureSignals[i].
|
948
|
+
closureSignals[i].K = i;
|
949
949
|
return (scope) => {
|
950
950
|
if (scope[___scopeInstancesAccessor])
|
951
951
|
for (let childScope of scope[___scopeInstancesAccessor])
|
@@ -958,13 +958,13 @@ function dynamicClosure(...closureSignals) {
|
|
958
958
|
}
|
959
959
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
960
960
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
961
|
-
scope[closureSignal.
|
961
|
+
scope[closureSignal.G] = closureSignal.K, childSignal(scope), subscribeToScopeSet(
|
962
962
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
963
|
-
closureSignal.
|
963
|
+
closureSignal.F,
|
964
964
|
scope
|
965
965
|
);
|
966
966
|
};
|
967
|
-
return closureSignal.
|
967
|
+
return closureSignal.F = "a" /* ClosureScopes */ + valueAccessor, closureSignal.G = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
|
968
968
|
}
|
969
969
|
function closure(valueAccessor, fn, getOwnerScope) {
|
970
970
|
return (scope) => {
|
@@ -1006,73 +1006,55 @@ function hoist(...path) {
|
|
1006
1006
|
function awaitTag(nodeAccessor, renderer) {
|
1007
1007
|
let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
|
1008
1008
|
return (scope, promise) => {
|
1009
|
-
let
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
if (scope.
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
namespaceNode
|
1023
|
-
),
|
1024
|
-
referenceNode.parentNode,
|
1025
|
-
referenceNode
|
1026
|
-
), referenceNode.remove()), renderer.k?.(awaitBranch, [data2]);
|
1027
|
-
});
|
1028
|
-
if (tryBranch) {
|
1029
|
-
if (!--tryBranch.y) {
|
1030
|
-
let placeholderBranch = tryBranch.c;
|
1031
|
-
placeholderBranch ? (insertBranchBefore(
|
1032
|
-
tryBranch,
|
1033
|
-
placeholderBranch.g.parentNode,
|
1034
|
-
placeholderBranch.g
|
1035
|
-
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1036
|
-
tryBranch,
|
1009
|
+
let tryWithPlaceholder = findBranchWithKey(
|
1010
|
+
scope,
|
1011
|
+
"d" /* PlaceholderContent */
|
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(
|
1014
|
+
prepareEffects(() => {
|
1015
|
+
tryWithPlaceholder && placeholderShown.add(pendingEffects), (!awaitBranch || !tryWithPlaceholder) && (insertBranchBefore(
|
1016
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1017
|
+
scope.$global,
|
1018
|
+
renderer,
|
1019
|
+
scope,
|
1020
|
+
namespaceNode
|
1021
|
+
),
|
1037
1022
|
referenceNode.parentNode,
|
1038
1023
|
referenceNode
|
1039
|
-
);
|
1040
|
-
}
|
1041
|
-
|
1042
|
-
|
1024
|
+
), referenceNode.remove()), renderer.l?.(awaitBranch, [data2]);
|
1025
|
+
})
|
1026
|
+
), tryWithPlaceholder && !--tryWithPlaceholder.q)) {
|
1027
|
+
let placeholderBranch = tryWithPlaceholder.c;
|
1028
|
+
tryWithPlaceholder.c = void 0, placeholderBranch ? (insertBranchBefore(
|
1029
|
+
tryWithPlaceholder,
|
1030
|
+
placeholderBranch.h.parentNode,
|
1031
|
+
placeholderBranch.h
|
1032
|
+
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1033
|
+
tryWithPlaceholder,
|
1034
|
+
referenceNode.parentNode,
|
1035
|
+
referenceNode
|
1036
|
+
), tryWithPlaceholder.H && runEffects(tryWithPlaceholder.H, !0);
|
1037
|
+
}
|
1043
1038
|
}).catch((error) => {
|
1044
|
-
|
1045
|
-
for (; tryBranch2 && !tryBranch2.b; )
|
1046
|
-
tryBranch2 = tryBranch2.n;
|
1047
|
-
tryBranch2 ? (setConditionalRenderer(
|
1048
|
-
tryBranch2._,
|
1049
|
-
tryBranch2.a,
|
1050
|
-
tryBranch2.b,
|
1051
|
-
createAndSetupBranch
|
1052
|
-
), tryBranch2.b.k?.(
|
1053
|
-
tryBranch2._["d" /* ConditionalScope */ + tryBranch2.a],
|
1054
|
-
[error]
|
1055
|
-
)) : setTimeout(() => {
|
1056
|
-
throw error;
|
1057
|
-
});
|
1039
|
+
renderCatch(scope, error, !0);
|
1058
1040
|
});
|
1059
|
-
|
1060
|
-
if (
|
1061
|
-
let placeholderBranch =
|
1041
|
+
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.q || (tryWithPlaceholder.q = 0, requestAnimationFrame(() => {
|
1042
|
+
if (tryWithPlaceholder.q && !tryWithPlaceholder.p) {
|
1043
|
+
let placeholderBranch = tryWithPlaceholder.c = createAndSetupBranch(
|
1062
1044
|
scope.$global,
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1045
|
+
tryWithPlaceholder.d,
|
1046
|
+
tryWithPlaceholder._,
|
1047
|
+
tryWithPlaceholder.h.parentNode
|
1066
1048
|
);
|
1067
1049
|
insertBranchBefore(
|
1068
1050
|
placeholderBranch,
|
1069
|
-
|
1070
|
-
|
1071
|
-
), tempDetatchBranch(
|
1051
|
+
tryWithPlaceholder.h.parentNode,
|
1052
|
+
tryWithPlaceholder.h
|
1053
|
+
), tempDetatchBranch(tryWithPlaceholder);
|
1072
1054
|
}
|
1073
|
-
})),
|
1055
|
+
})), tryWithPlaceholder.q++) : awaitBranch && (awaitBranch.h.parentNode.insertBefore(
|
1074
1056
|
referenceNode,
|
1075
|
-
awaitBranch.
|
1057
|
+
awaitBranch.h
|
1076
1058
|
), tempDetatchBranch(awaitBranch));
|
1077
1059
|
};
|
1078
1060
|
}
|
@@ -1091,6 +1073,26 @@ function createTry(nodeAccessor, tryContent) {
|
|
1091
1073
|
));
|
1092
1074
|
};
|
1093
1075
|
}
|
1076
|
+
function renderCatch(scope, error, async) {
|
1077
|
+
let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
|
1078
|
+
if (tryWithCatch) {
|
1079
|
+
let placeholderBranch = tryWithCatch.c;
|
1080
|
+
placeholderBranch && (tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
|
1081
|
+
tryWithCatch._,
|
1082
|
+
tryWithCatch.a,
|
1083
|
+
tryWithCatch.b,
|
1084
|
+
createAndSetupBranch
|
1085
|
+
), tryWithCatch.b.l?.(
|
1086
|
+
tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
|
1087
|
+
[error]
|
1088
|
+
);
|
1089
|
+
} else if (async)
|
1090
|
+
setTimeout(() => {
|
1091
|
+
throw error;
|
1092
|
+
});
|
1093
|
+
else
|
1094
|
+
throw error;
|
1095
|
+
}
|
1094
1096
|
function conditional(nodeAccessor, ...branches) {
|
1095
1097
|
let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1096
1098
|
return (scope, newBranch) => {
|
@@ -1109,7 +1111,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1109
1111
|
let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1110
1112
|
return (scope, newRenderer, getInput) => {
|
1111
1113
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1112
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
1114
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1113
1115
|
if (setConditionalRenderer(
|
1114
1116
|
scope,
|
1115
1117
|
nodeAccessor,
|
@@ -1123,15 +1125,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1123
1125
|
0,
|
1124
1126
|
content,
|
1125
1127
|
createAndSetupBranch
|
1126
|
-
), content.
|
1127
|
-
content.
|
1128
|
-
content.
|
1128
|
+
), content.z && subscribeToScopeSet(
|
1129
|
+
content.y,
|
1130
|
+
content.z,
|
1129
1131
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1130
1132
|
);
|
1131
1133
|
}
|
1132
|
-
} else normalizedRenderer?.
|
1133
|
-
normalizedRenderer.
|
1134
|
-
normalizedRenderer.
|
1134
|
+
} else normalizedRenderer?.z && subscribeToScopeSet(
|
1135
|
+
normalizedRenderer.y,
|
1136
|
+
normalizedRenderer.z,
|
1135
1137
|
scope[childScopeAccessor]
|
1136
1138
|
);
|
1137
1139
|
if (normalizedRenderer) {
|
@@ -1142,9 +1144,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1142
1144
|
0,
|
1143
1145
|
(inputIsArgs ? args[0] : args) || {}
|
1144
1146
|
);
|
1145
|
-
else if (normalizedRenderer.
|
1147
|
+
else if (normalizedRenderer.l)
|
1146
1148
|
if (inputIsArgs)
|
1147
|
-
normalizedRenderer.
|
1149
|
+
normalizedRenderer.l(
|
1148
1150
|
scope[childScopeAccessor],
|
1149
1151
|
normalizedRenderer._ ? args[0] : args
|
1150
1152
|
);
|
@@ -1153,7 +1155,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1153
1155
|
...args,
|
1154
1156
|
content: getContent(scope)
|
1155
1157
|
} : args || {};
|
1156
|
-
normalizedRenderer.
|
1158
|
+
normalizedRenderer.l(
|
1157
1159
|
scope[childScopeAccessor],
|
1158
1160
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1159
1161
|
);
|
@@ -1162,8 +1164,8 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1162
1164
|
};
|
1163
1165
|
};
|
1164
1166
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1165
|
-
let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.
|
1166
|
-
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());
|
1167
1169
|
}
|
1168
1170
|
function loopOf(nodeAccessor, renderer) {
|
1169
1171
|
return loop(
|
@@ -1192,17 +1194,17 @@ function loopTo(nodeAccessor, renderer) {
|
|
1192
1194
|
);
|
1193
1195
|
}
|
1194
1196
|
function loop(nodeAccessor, renderer, forEach) {
|
1195
|
-
let params = renderer.
|
1197
|
+
let params = renderer.l;
|
1196
1198
|
return (scope, value2) => {
|
1197
1199
|
let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
|
1198
1200
|
...oldMap.values()
|
1199
|
-
] : [], 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] = [];
|
1200
1202
|
forEach(value2, (key, args) => {
|
1201
1203
|
let branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
|
1202
1204
|
params?.(branch, args), newMap.set(key, branch), newArray.push(branch);
|
1203
1205
|
});
|
1204
1206
|
let afterReference = null;
|
1205
|
-
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);
|
1206
1208
|
};
|
1207
1209
|
}
|
1208
1210
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
@@ -1212,7 +1214,7 @@ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentSco
|
|
1212
1214
|
parentScope,
|
1213
1215
|
parentNode
|
1214
1216
|
);
|
1215
|
-
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.
|
1217
|
+
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.h = branch.j = document.createElementNS(
|
1216
1218
|
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1217
1219
|
tagNameOrRenderer
|
1218
1220
|
) : setupBranch(tagNameOrRenderer, branch), branch;
|
@@ -1225,21 +1227,21 @@ function byFirstArg(name) {
|
|
1225
1227
|
}
|
1226
1228
|
|
1227
1229
|
// src/dom/queue.ts
|
1228
|
-
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1229
|
-
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.
|
1230
|
+
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1231
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
|
1230
1232
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1231
1233
|
if (existingRender)
|
1232
|
-
existingRender.
|
1234
|
+
existingRender.I = value2;
|
1233
1235
|
else {
|
1234
1236
|
let render = {
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1237
|
+
t: key,
|
1238
|
+
D: scope,
|
1239
|
+
L: signal,
|
1240
|
+
I: value2
|
1239
1241
|
}, i = pendingRenders.push(render) - 1;
|
1240
1242
|
for (; i; ) {
|
1241
1243
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1242
|
-
if (key - parent.
|
1244
|
+
if (key - parent.t >= 0) break;
|
1243
1245
|
pendingRenders[i] = parent, i = parentIndex;
|
1244
1246
|
}
|
1245
1247
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1267,62 +1269,63 @@ function prepareEffects(fn) {
|
|
1267
1269
|
}
|
1268
1270
|
return preparedEffects;
|
1269
1271
|
}
|
1270
|
-
|
1272
|
+
var runEffects = (effects) => {
|
1271
1273
|
for (let i = 0, scope; i < effects.length; )
|
1272
1274
|
effects[i++](
|
1273
1275
|
scope = effects[i++],
|
1274
1276
|
scope
|
1275
1277
|
);
|
1276
|
-
}
|
1278
|
+
};
|
1277
1279
|
function runRenders() {
|
1278
1280
|
for (; pendingRenders.length; ) {
|
1279
1281
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1280
1282
|
if (render !== item) {
|
1281
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1283
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
|
1282
1284
|
for (; i < mid; ) {
|
1283
1285
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1284
|
-
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)
|
1285
1287
|
break;
|
1286
1288
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1287
1289
|
}
|
1288
1290
|
pendingRenders[i] = item;
|
1289
1291
|
}
|
1290
|
-
render.
|
1292
|
+
render.D.k?.p || runRender(render);
|
1291
1293
|
}
|
1292
1294
|
finishPendingScopes();
|
1293
1295
|
}
|
1294
|
-
var runRender = (render) => render.
|
1296
|
+
var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
|
1295
1297
|
enableCatch = () => {
|
1296
|
-
}
|
1298
|
+
};
|
1299
|
+
let handlePendingTry = (fn, scope, branch) => {
|
1300
|
+
for (; branch; ) {
|
1301
|
+
if (branch.q)
|
1302
|
+
return (branch.H ||= []).push(fn, scope);
|
1303
|
+
branch = branch.u;
|
1304
|
+
}
|
1305
|
+
};
|
1306
|
+
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1307
|
+
if (checkPending || caughtError.has(effects)) {
|
1308
|
+
let i = 0, fn, scope, branch;
|
1309
|
+
for (; i < effects.length; )
|
1310
|
+
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.p && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1311
|
+
} else
|
1312
|
+
runEffects2(effects);
|
1313
|
+
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1297
1314
|
try {
|
1298
1315
|
runRender2(render);
|
1299
1316
|
} catch (error) {
|
1300
|
-
|
1301
|
-
for (; branch && !branch.b; )
|
1302
|
-
branch = branch.n;
|
1303
|
-
if (branch)
|
1304
|
-
setConditionalRenderer(
|
1305
|
-
branch._,
|
1306
|
-
branch.a,
|
1307
|
-
branch.b,
|
1308
|
-
createAndSetupBranch
|
1309
|
-
), branch.b.k?.(
|
1310
|
-
branch._["d" /* ConditionalScope */ + branch.a],
|
1311
|
-
[error]
|
1312
|
-
);
|
1313
|
-
else
|
1314
|
-
throw error;
|
1317
|
+
renderCatch(render.D, error);
|
1315
1318
|
}
|
1316
1319
|
})(runRender);
|
1317
1320
|
};
|
1318
1321
|
|
1319
1322
|
// src/dom/abort-signal.ts
|
1320
1323
|
function resetAbortSignal(scope, id) {
|
1321
|
-
let ctrl = scope.
|
1322
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1324
|
+
let ctrl = scope.x?.[id];
|
1325
|
+
ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
|
1323
1326
|
}
|
1324
1327
|
function getAbortSignal(scope, id) {
|
1325
|
-
return scope.
|
1328
|
+
return scope.k && (scope.k.J ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
|
1326
1329
|
}
|
1327
1330
|
function abort(ctrl) {
|
1328
1331
|
ctrl.abort();
|
@@ -1344,13 +1347,13 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1344
1347
|
register(RENDERER_REGISTER_ID, fn);
|
1345
1348
|
},
|
1346
1349
|
isRenderer(renderer) {
|
1347
|
-
return renderer.
|
1350
|
+
return renderer.B;
|
1348
1351
|
},
|
1349
1352
|
getStartNode(branch) {
|
1350
|
-
return branch.
|
1353
|
+
return branch.h;
|
1351
1354
|
},
|
1352
1355
|
setScopeNodes(branch, startNode, endNode) {
|
1353
|
-
branch.
|
1356
|
+
branch.h = startNode, branch.j = endNode;
|
1354
1357
|
},
|
1355
1358
|
runComponentEffects() {
|
1356
1359
|
runEffects(this.effects);
|
@@ -1369,9 +1372,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1369
1372
|
},
|
1370
1373
|
createRenderer(params, clone) {
|
1371
1374
|
let renderer = createRenderer(0, 0, 0, params);
|
1372
|
-
return renderer.
|
1375
|
+
return renderer.B = (branch) => {
|
1373
1376
|
let cloned = clone();
|
1374
|
-
branch.
|
1377
|
+
branch.h = cloned.startNode, branch.j = cloned.endNode;
|
1375
1378
|
}, renderer;
|
1376
1379
|
},
|
1377
1380
|
render(out, component, renderer, args) {
|
@@ -1384,14 +1387,14 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1384
1387
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1385
1388
|
}
|
1386
1389
|
if (component.effects = prepareEffects(() => {
|
1387
|
-
branch ? existing = !0 : (out.global.
|
1390
|
+
branch ? existing = !0 : (out.global.n ||= 0, branch = component.scope = createAndSetupBranch(
|
1388
1391
|
out.global,
|
1389
1392
|
renderer,
|
1390
|
-
renderer.
|
1393
|
+
renderer.y,
|
1391
1394
|
document.body
|
1392
|
-
)), renderer.
|
1395
|
+
)), renderer.l?.(branch, renderer._ ? args[0] : args);
|
1393
1396
|
}), !existing)
|
1394
|
-
return toInsertNode(branch.
|
1397
|
+
return toInsertNode(branch.h, branch.j);
|
1395
1398
|
}
|
1396
1399
|
};
|
1397
1400
|
|
@@ -1409,12 +1412,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1409
1412
|
function mount(input = {}, reference, position) {
|
1410
1413
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1411
1414
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1412
|
-
|
1415
|
+
n: 0,
|
1413
1416
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1414
1417
|
renderId: DEFAULT_RENDER_ID,
|
1415
1418
|
...$global
|
1416
1419
|
}) : $global = {
|
1417
|
-
|
1420
|
+
n: 0,
|
1418
1421
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1419
1422
|
renderId: DEFAULT_RENDER_ID
|
1420
1423
|
}, position) {
|
@@ -1428,19 +1431,19 @@ function mount(input = {}, reference, position) {
|
|
1428
1431
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1429
1432
|
break;
|
1430
1433
|
}
|
1431
|
-
let args = this.
|
1434
|
+
let args = this.l, effects = prepareEffects(() => {
|
1432
1435
|
branch = createBranch(
|
1433
1436
|
$global,
|
1434
1437
|
this,
|
1435
1438
|
void 0,
|
1436
1439
|
parentNode
|
1437
|
-
), this.
|
1440
|
+
), this.C?.(branch), args?.(branch, input);
|
1438
1441
|
});
|
1439
1442
|
return insertChildNodes(
|
1440
1443
|
parentNode,
|
1441
1444
|
nextSibling,
|
1442
|
-
branch.
|
1443
|
-
branch.
|
1445
|
+
branch.h,
|
1446
|
+
branch.j
|
1444
1447
|
), runEffects(effects), {
|
1445
1448
|
update(newInput) {
|
1446
1449
|
args && runEffects(
|