marko 6.0.0-next.3.24 → 6.0.0-next.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/types.d.ts +1 -0
- package/dist/debug/dom.js +106 -87
- package/dist/debug/dom.mjs +106 -87
- package/dist/debug/html.js +7 -7
- package/dist/debug/html.mjs +7 -7
- package/dist/dom/renderer.d.ts +1 -1
- package/dist/dom/scope.d.ts +2 -2
- package/dist/dom/signals.d.ts +1 -1
- package/dist/dom.js +111 -102
- package/dist/dom.mjs +111 -102
- package/dist/html/writer.d.ts +3 -3
- package/dist/html.js +7 -7
- package/dist/html.mjs +7 -7
- package/dist/translator/index.js +40 -46
- package/package.json +1 -1
package/dist/dom.mjs
CHANGED
@@ -49,25 +49,28 @@ function triggerMacroTask() {
|
|
49
49
|
var pendingScopes = [];
|
50
50
|
function createScope($global) {
|
51
51
|
let scope = {
|
52
|
-
|
52
|
+
f: 1,
|
53
53
|
$global
|
54
54
|
};
|
55
55
|
return pendingScopes.push(scope), scope;
|
56
56
|
}
|
57
57
|
function finishPendingScopes() {
|
58
58
|
for (let scope of pendingScopes)
|
59
|
-
scope.
|
59
|
+
scope.f = 0;
|
60
60
|
pendingScopes = [];
|
61
61
|
}
|
62
|
-
var
|
63
|
-
function
|
64
|
-
return
|
62
|
+
var emptyBranch = createScope({});
|
63
|
+
function getEmptyBranch(marker) {
|
64
|
+
return emptyBranch.a = emptyBranch.c = marker, emptyBranch;
|
65
65
|
}
|
66
66
|
function destroyBranch(branch) {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
branch.n?.k?.delete(branch), destroyNestedBranches(branch);
|
68
|
+
}
|
69
|
+
function destroyNestedBranches(branch) {
|
70
|
+
branch.z = 1, branch.k?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
|
71
|
+
for (let id in scope.g)
|
72
|
+
scope.g[id]?.abort();
|
73
|
+
});
|
71
74
|
}
|
72
75
|
function removeAndDestroyBranch(branch) {
|
73
76
|
destroyBranch(branch);
|
@@ -77,8 +80,8 @@ function removeAndDestroyBranch(branch) {
|
|
77
80
|
current.remove(), current = next;
|
78
81
|
}
|
79
82
|
}
|
80
|
-
function
|
81
|
-
let current =
|
83
|
+
function insertBranchBefore(branch, parent, nextSibling) {
|
84
|
+
let current = branch.a, stop = branch.c.nextSibling;
|
82
85
|
for (; current !== stop; ) {
|
83
86
|
let next = current.nextSibling;
|
84
87
|
parent.insertBefore(current, nextSibling), current = next;
|
@@ -151,7 +154,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
151
154
|
if (newStart <= newEnd) {
|
152
155
|
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
|
153
156
|
do
|
154
|
-
|
157
|
+
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
155
158
|
while (newStart <= newEnd);
|
156
159
|
}
|
157
160
|
} else if (newStart > newEnd)
|
@@ -169,7 +172,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
169
172
|
oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
|
170
173
|
if (oldLength === oldBranches.length && synced === 0) {
|
171
174
|
for (; newStart < newLength; ++newStart)
|
172
|
-
|
175
|
+
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
173
176
|
for (; oldStart < oldLength; ++oldStart)
|
174
177
|
removeAndDestroyBranch(oldBranches[oldStart]);
|
175
178
|
} else {
|
@@ -178,10 +181,10 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
178
181
|
if (pos === WRONG_POS) {
|
179
182
|
let seq = longestIncreasingSubsequence(sources);
|
180
183
|
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
181
|
-
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference,
|
184
|
+
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
|
182
185
|
} else if (synced !== newLength)
|
183
186
|
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
184
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference,
|
187
|
+
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
185
188
|
}
|
186
189
|
}
|
187
190
|
}
|
@@ -260,17 +263,17 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
260
263
|
var registeredValues = {}, Render = class {
|
261
264
|
o = [];
|
262
265
|
p = {};
|
263
|
-
|
266
|
+
B = {
|
264
267
|
_: registeredValues
|
265
268
|
};
|
266
269
|
constructor(renders, runtimeId, renderId) {
|
267
|
-
this.
|
270
|
+
this.C = renders, this.D = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
|
268
271
|
}
|
269
272
|
w() {
|
270
273
|
this.s.w(), this.t();
|
271
274
|
}
|
272
275
|
t() {
|
273
|
-
let data2 = this.s, serializeContext = this.
|
276
|
+
let data2 = this.s, serializeContext = this.B, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
274
277
|
if (visits.length) {
|
275
278
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
|
276
279
|
data2.v = [];
|
@@ -292,15 +295,15 @@ var registeredValues = {}, Render = class {
|
|
292
295
|
else if (token === "$" /* ClosestBranch */)
|
293
296
|
closestBranchMarkers.set(scopeId, visit);
|
294
297
|
else if (token === "[" /* BranchStart */)
|
295
|
-
this.
|
298
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.o.push(this.e)), this.e = scopeId, scope.a = visit;
|
296
299
|
else if (token === "]" /* BranchEnd */) {
|
297
300
|
scope[data3] = visit;
|
298
301
|
let curParent = visit.parentNode, startNode = branchEnd(
|
299
|
-
this.
|
302
|
+
this.e,
|
300
303
|
visit,
|
301
304
|
visit
|
302
305
|
).a;
|
303
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.
|
306
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.o.pop();
|
304
307
|
} else if (token === "|" /* BranchSingleNode */) {
|
305
308
|
let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
306
309
|
for (; ~next; ) {
|
@@ -321,7 +324,7 @@ var registeredValues = {}, Render = class {
|
|
321
324
|
let resumeData = resumes[i++];
|
322
325
|
if (typeof resumeData == "function") {
|
323
326
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
324
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.
|
327
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.D, $global.renderId = this.q);
|
325
328
|
for (let scopeId in scopes)
|
326
329
|
if (scopeId !== "$") {
|
327
330
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -332,10 +335,10 @@ var registeredValues = {}, Render = class {
|
|
332
335
|
let parentBranchId = parentBranchIds.get(scopeId);
|
333
336
|
if (parentBranchId && (scope.b = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
334
337
|
let branch = scope, parentBranch = branch.b;
|
335
|
-
scope.b = branch, parentBranch && (branch.
|
338
|
+
branch.h = +scopeId, scope.b = branch, parentBranch && (branch.n = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
|
336
339
|
}
|
337
340
|
}
|
338
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.
|
341
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.C[this.q] : registeredValues[resumes[i++]](
|
339
342
|
scopeLookup[resumeData],
|
340
343
|
scopeLookup[resumeData]
|
341
344
|
);
|
@@ -373,7 +376,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
373
376
|
}
|
374
377
|
}
|
375
378
|
function registerSubscriber(id, signal) {
|
376
|
-
return register(id, signal.
|
379
|
+
return register(id, signal.E), signal;
|
377
380
|
}
|
378
381
|
function nodeRef(id, key) {
|
379
382
|
return register(id, (scope) => () => scope[key]);
|
@@ -787,7 +790,7 @@ function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
|
787
790
|
renderer.u || parentScope,
|
788
791
|
parentScope
|
789
792
|
);
|
790
|
-
return
|
793
|
+
return initBranch(renderer, branch), branch;
|
791
794
|
}
|
792
795
|
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
793
796
|
if (typeof tagNameOrRenderer != "string")
|
@@ -801,15 +804,15 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
801
804
|
}
|
802
805
|
function createBranch($global, ownerScope, parentScope) {
|
803
806
|
let branch = createScope($global), parentBranch = parentScope.b;
|
804
|
-
return branch._ = ownerScope, branch.b = branch, parentBranch
|
807
|
+
return branch._ = ownerScope, branch.b = branch, parentBranch ? (branch.h = parentBranch.h + 1, branch.n = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch)) : branch.h = 1, branch;
|
805
808
|
}
|
806
|
-
function
|
809
|
+
function initBranch(renderer, branch) {
|
807
810
|
let dom = renderer.l();
|
808
811
|
return walk(
|
809
812
|
dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
|
810
|
-
renderer.
|
811
|
-
|
812
|
-
),
|
813
|
+
renderer.F,
|
814
|
+
branch
|
815
|
+
), branch.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, branch.c = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(branch, renderer.x), dom;
|
813
816
|
}
|
814
817
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
815
818
|
return (scope, attrsOrOp) => {
|
@@ -818,13 +821,13 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
818
821
|
return;
|
819
822
|
let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
|
820
823
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN)
|
821
|
-
return renderer.
|
824
|
+
return renderer.d?.(childScope, attrsOrOp);
|
822
825
|
let content = getContent?.(scope);
|
823
826
|
if (typeof renderer == "string")
|
824
827
|
setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
|
825
|
-
else if (renderer.
|
828
|
+
else if (renderer.d) {
|
826
829
|
let attributes = attrsOrOp();
|
827
|
-
renderer.
|
830
|
+
renderer.d(
|
828
831
|
childScope,
|
829
832
|
inputIsArgs ? attributes : [
|
830
833
|
content ? {
|
@@ -840,13 +843,13 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
840
843
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
841
844
|
return (owner) => ({
|
842
845
|
j: id,
|
843
|
-
|
844
|
-
|
846
|
+
G: template,
|
847
|
+
F: walks,
|
845
848
|
x: setup,
|
846
849
|
l: _clone,
|
847
850
|
u: owner,
|
848
|
-
|
849
|
-
get
|
851
|
+
H: void 0,
|
852
|
+
get d() {
|
850
853
|
return args ||= getArgs?.();
|
851
854
|
}
|
852
855
|
});
|
@@ -855,8 +858,8 @@ function createRenderer(template, walks, setup, getArgs) {
|
|
855
858
|
return createRendererWithOwner(template, walks, setup, getArgs)();
|
856
859
|
}
|
857
860
|
function _clone() {
|
858
|
-
return (this.
|
859
|
-
this.
|
861
|
+
return (this.H ||= parseHTMLOrSingleNode(
|
862
|
+
this.G
|
860
863
|
)).cloneNode(!0);
|
861
864
|
}
|
862
865
|
|
@@ -871,18 +874,18 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
|
|
871
874
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
872
875
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
873
876
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
874
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
877
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
875
878
|
}
|
876
879
|
intersection2?.(scope, op);
|
877
880
|
};
|
878
881
|
};
|
879
882
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
880
|
-
let
|
881
|
-
|
882
|
-
newBranch
|
883
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
|
884
|
+
insertBranchBefore(
|
885
|
+
newBranch,
|
883
886
|
prevBranch.a.parentNode,
|
884
887
|
prevBranch.a
|
885
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "
|
888
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
886
889
|
}
|
887
890
|
var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
888
891
|
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
@@ -902,12 +905,12 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
902
905
|
};
|
903
906
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
904
907
|
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
905
|
-
referenceNode.textContent = "", newBranch &&
|
908
|
+
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
906
909
|
}
|
907
910
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
908
|
-
[Symbol(),
|
911
|
+
[Symbol(), getEmptyBranch(void 0)]
|
909
912
|
]), emptyMarkerArray = [
|
910
|
-
/* @__PURE__ */
|
913
|
+
/* @__PURE__ */ getEmptyBranch(void 0)
|
911
914
|
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
912
915
|
function loopOf(nodeAccessor, renderer) {
|
913
916
|
return loop(
|
@@ -936,7 +939,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
936
939
|
);
|
937
940
|
}
|
938
941
|
function loop(nodeAccessor, renderer, forEach) {
|
939
|
-
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.
|
942
|
+
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.d;
|
940
943
|
return (scope, valueOrOp) => {
|
941
944
|
if (valueOrOp === DIRTY) return;
|
942
945
|
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
@@ -950,9 +953,9 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
950
953
|
if (forEach(valueOrOp, (key, args) => {
|
951
954
|
let branch = oldMap.get(key);
|
952
955
|
branch || (branch = createBranchScopeWithRenderer(renderer, scope.$global, scope)), params && params(branch, args), newMap ? (newMap.set(key, branch), newArray.push(branch)) : (newMap = /* @__PURE__ */ new Map([[key, branch]]), newArray = [branch]);
|
953
|
-
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray,
|
956
|
+
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyBranch(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
|
954
957
|
if (referenceIsMarker) {
|
955
|
-
oldMap === emptyMarkerMap &&
|
958
|
+
oldMap === emptyMarkerMap && getEmptyBranch(referenceNode);
|
956
959
|
let oldLastChild = oldArray[oldArray.length - 1];
|
957
960
|
afterReference = oldLastChild.c.nextSibling, parentNode = oldLastChild.a.parentNode;
|
958
961
|
} else
|
@@ -1010,24 +1013,24 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
|
1010
1013
|
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1011
1014
|
if (loopScopes !== emptyMarkerArray)
|
1012
1015
|
for (let scope of loopScopes)
|
1013
|
-
scope.
|
1016
|
+
scope.f || queueSource(scope, signal, value2);
|
1014
1017
|
};
|
1015
1018
|
return helperSignal._ = signal, helperSignal;
|
1016
1019
|
}
|
1017
1020
|
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1018
1021
|
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1019
1022
|
let conditionalScope = scope[scopeAccessor];
|
1020
|
-
conditionalScope && !conditionalScope.
|
1023
|
+
conditionalScope && !conditionalScope.f && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
|
1021
1024
|
};
|
1022
1025
|
return helperSignal._ = signal, helperSignal;
|
1023
1026
|
}
|
1024
1027
|
var defaultGetOwnerScope = (scope) => scope._;
|
1025
|
-
function dynamicClosure(
|
1026
|
-
let ownerSubscribersAccessor =
|
1028
|
+
function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1029
|
+
let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
|
1027
1030
|
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1028
1031
|
if (subscribers)
|
1029
1032
|
for (let subscriber of subscribers)
|
1030
|
-
subscriber.
|
1033
|
+
subscriber.f || queueSource(subscriber, _signal, value2);
|
1031
1034
|
}, setupSignal = (scope, value2) => {
|
1032
1035
|
_signal(scope, value2), subscribe(scope);
|
1033
1036
|
}, subscribe = (scope) => {
|
@@ -1035,7 +1038,7 @@ function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerS
|
|
1035
1038
|
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1036
1039
|
});
|
1037
1040
|
};
|
1038
|
-
return helperSignal._ = setupSignal, helperSignal.
|
1041
|
+
return helperSignal._ = setupSignal, helperSignal.E = subscribe, helperSignal;
|
1039
1042
|
}
|
1040
1043
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1041
1044
|
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
@@ -1068,29 +1071,25 @@ function effect(id, fn) {
|
|
1068
1071
|
}
|
1069
1072
|
|
1070
1073
|
// src/dom/queue.ts
|
1071
|
-
var
|
1074
|
+
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
1072
1075
|
function queueSource(scope, signal, value2) {
|
1073
1076
|
schedule();
|
1074
1077
|
let prevRendering = rendering;
|
1075
1078
|
return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
|
1076
1079
|
}
|
1077
1080
|
function queueRender(scope, signal, value2) {
|
1078
|
-
let
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1081
|
+
let i = pendingRenders.length, render = {
|
1082
|
+
m: scope,
|
1083
|
+
I: signal,
|
1084
|
+
J: value2,
|
1085
|
+
y: i
|
1083
1086
|
};
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
else {
|
1089
|
-
let curRender = pendingRender;
|
1090
|
-
for (; curRender.d && comparePendingRenders(curRender.d, nextRender) >= 0; )
|
1091
|
-
curRender = curRender.d;
|
1092
|
-
nextRender.d = curRender.d, curRender.d = nextRender;
|
1087
|
+
for (pendingRenders.push(render); i; ) {
|
1088
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1089
|
+
if (comparePendingRenders(render, parent) >= 0) break;
|
1090
|
+
pendingRenders[i] = parent, i = parentIndex;
|
1093
1091
|
}
|
1092
|
+
pendingRenders[i] = render;
|
1094
1093
|
}
|
1095
1094
|
function queueEffect(scope, fn) {
|
1096
1095
|
pendingEffects.push(scope, fn);
|
@@ -1100,17 +1099,17 @@ function run() {
|
|
1100
1099
|
try {
|
1101
1100
|
rendering = !0, runRenders();
|
1102
1101
|
} finally {
|
1103
|
-
|
1102
|
+
pendingRenders = [], pendingEffects = [], rendering = !1;
|
1104
1103
|
}
|
1105
|
-
|
1104
|
+
runEffects(effects);
|
1106
1105
|
}
|
1107
1106
|
function prepareEffects(fn) {
|
1108
|
-
let
|
1109
|
-
|
1107
|
+
let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1108
|
+
pendingRenders = [];
|
1110
1109
|
try {
|
1111
1110
|
rendering = !0, fn(), runRenders();
|
1112
1111
|
} finally {
|
1113
|
-
rendering = !1,
|
1112
|
+
rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
1114
1113
|
}
|
1115
1114
|
return preparedEffects;
|
1116
1115
|
}
|
@@ -1121,25 +1120,39 @@ function runEffects(effects = pendingEffects) {
|
|
1121
1120
|
}
|
1122
1121
|
}
|
1123
1122
|
function runRenders() {
|
1124
|
-
for (;
|
1125
|
-
|
1123
|
+
for (; pendingRenders.length; ) {
|
1124
|
+
let render = pendingRenders[0], next = pendingRenders.pop();
|
1125
|
+
if (render !== next) {
|
1126
|
+
let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
|
1127
|
+
for (; i < mid; ) {
|
1128
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1129
|
+
if (right < pendingRenders.length && comparePendingRenders(
|
1130
|
+
pendingRenders[right],
|
1131
|
+
pendingRenders[bestChild]
|
1132
|
+
) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
|
1133
|
+
break;
|
1134
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1135
|
+
}
|
1136
|
+
pendingRenders[i] = item;
|
1137
|
+
}
|
1138
|
+
render.m.b?.z || render.I(render.m, render.J);
|
1139
|
+
}
|
1126
1140
|
finishPendingScopes();
|
1127
1141
|
}
|
1128
1142
|
function comparePendingRenders(a, b) {
|
1129
|
-
|
1130
|
-
return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
|
1143
|
+
return getBranchDepth(a) - getBranchDepth(b) || a.y - b.y;
|
1131
1144
|
}
|
1132
|
-
function
|
1133
|
-
return
|
1145
|
+
function getBranchDepth(render) {
|
1146
|
+
return render.m.b?.h || 0;
|
1134
1147
|
}
|
1135
1148
|
|
1136
1149
|
// src/dom/abort-signal.ts
|
1137
1150
|
function resetAbortSignal(scope, id) {
|
1138
|
-
let ctrl = scope.
|
1139
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1151
|
+
let ctrl = scope.g?.[id];
|
1152
|
+
ctrl && (queueEffect(ctrl, abort), scope.g[id] = void 0);
|
1140
1153
|
}
|
1141
1154
|
function getAbortSignal(scope, id) {
|
1142
|
-
return scope.b && (scope.b.
|
1155
|
+
return scope.b && (scope.b.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.g ||= {})[id] ||= new AbortController()).signal;
|
1143
1156
|
}
|
1144
1157
|
function abort(ctrl) {
|
1145
1158
|
ctrl.abort();
|
@@ -1194,14 +1207,14 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1194
1207
|
render(out, component, renderer, args) {
|
1195
1208
|
let scope = component.scope;
|
1196
1209
|
scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
|
1197
|
-
let applyArgs = renderer.
|
1210
|
+
let applyArgs = renderer.d || noop, existing = !1;
|
1198
1211
|
if (typeof args[0] == "object" && "renderBody" in args[0]) {
|
1199
1212
|
let input = args[0], normalizedInput = args[0] = {};
|
1200
1213
|
for (let key in input)
|
1201
1214
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1202
1215
|
}
|
1203
1216
|
if (component.effects = prepareEffects(() => {
|
1204
|
-
scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u,
|
1217
|
+
scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initBranch(renderer, scope)), applyArgs(scope, args);
|
1205
1218
|
}), !existing)
|
1206
1219
|
return scope.a === scope.c ? scope.a : scope.a.parentNode;
|
1207
1220
|
}
|
@@ -1215,33 +1228,29 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
1215
1228
|
return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
|
1216
1229
|
};
|
1217
1230
|
function mount(input = {}, reference, position) {
|
1218
|
-
let branch, dom, { $global } = input;
|
1219
|
-
$global ? ({ $global, ...input } = input, $global = {
|
1231
|
+
let branch, dom, parentNode = reference, nextSibling = null, { $global } = input;
|
1232
|
+
switch ($global ? ({ $global, ...input } = input, $global = {
|
1220
1233
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1221
1234
|
renderId: DEFAULT_RENDER_ID,
|
1222
1235
|
...$global
|
1223
1236
|
}) : $global = {
|
1224
1237
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1225
1238
|
renderId: DEFAULT_RENDER_ID
|
1226
|
-
}
|
1227
|
-
let args = this.e, effects = prepareEffects(() => {
|
1228
|
-
branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
|
1229
|
-
});
|
1230
|
-
switch (position) {
|
1239
|
+
}, position) {
|
1231
1240
|
case "beforebegin":
|
1232
|
-
reference.parentNode
|
1241
|
+
parentNode = reference.parentNode, nextSibling = reference;
|
1233
1242
|
break;
|
1234
1243
|
case "afterbegin":
|
1235
|
-
|
1244
|
+
nextSibling = reference.firstChild;
|
1236
1245
|
break;
|
1237
1246
|
case "afterend":
|
1238
|
-
reference.parentNode
|
1239
|
-
break;
|
1240
|
-
default:
|
1241
|
-
reference.appendChild(dom);
|
1247
|
+
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1242
1248
|
break;
|
1243
1249
|
}
|
1244
|
-
|
1250
|
+
let args = this.d, effects = prepareEffects(() => {
|
1251
|
+
branch = createScope($global), dom = initBranch(this, branch), args?.(branch, [input]);
|
1252
|
+
});
|
1253
|
+
return parentNode.insertBefore(dom, nextSibling), runEffects(effects), {
|
1245
1254
|
update: (newInput) => {
|
1246
1255
|
args && runEffects(
|
1247
1256
|
prepareEffects(() => {
|
package/dist/html/writer.d.ts
CHANGED
@@ -55,9 +55,9 @@ export declare class State {
|
|
55
55
|
renderId: string;
|
56
56
|
runtimeId: string;
|
57
57
|
};
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
tagId: number;
|
59
|
+
scopeId: number;
|
60
|
+
reorderId: number;
|
61
61
|
hasGlobals: boolean;
|
62
62
|
needsMainRuntime: boolean;
|
63
63
|
hasMainRuntime: boolean;
|
package/dist/html.js
CHANGED
@@ -1006,13 +1006,13 @@ function register2(val, id, scopeId) {
|
|
1006
1006
|
}
|
1007
1007
|
function nextTagId() {
|
1008
1008
|
let state = $chunk.boundary.state, { $global: $global2 } = state;
|
1009
|
-
return "s" + $global2.runtimeId + $global2.renderId + (state.
|
1009
|
+
return "s" + $global2.runtimeId + $global2.renderId + (state.tagId++).toString(36);
|
1010
1010
|
}
|
1011
1011
|
function nextScopeId() {
|
1012
|
-
return $chunk.boundary.state.
|
1012
|
+
return $chunk.boundary.state.scopeId++;
|
1013
1013
|
}
|
1014
1014
|
function peekNextScopeId() {
|
1015
|
-
return $chunk.boundary.state.
|
1015
|
+
return $chunk.boundary.state.scopeId;
|
1016
1016
|
}
|
1017
1017
|
function peekNextScope() {
|
1018
1018
|
return ensureScopeWithId(peekNextScopeId());
|
@@ -1220,9 +1220,9 @@ var State2 = class {
|
|
1220
1220
|
this.$global = $global2;
|
1221
1221
|
this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
|
1222
1222
|
}
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1223
|
+
tagId = 1;
|
1224
|
+
scopeId = 1;
|
1225
|
+
reorderId = 1;
|
1226
1226
|
hasGlobals = !1;
|
1227
1227
|
needsMainRuntime = !1;
|
1228
1228
|
hasMainRuntime = !1;
|
@@ -1246,7 +1246,7 @@ var State2 = class {
|
|
1246
1246
|
this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
|
1247
1247
|
}
|
1248
1248
|
nextReorderId() {
|
1249
|
-
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.
|
1249
|
+
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.reorderId++, mod = index % encodeStartLen, id = encodeChars[mod];
|
1250
1250
|
for (index = (index - mod) / encodeStartLen; index > 0; )
|
1251
1251
|
mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
|
1252
1252
|
return id;
|
package/dist/html.mjs
CHANGED
@@ -929,13 +929,13 @@ function register2(val, id, scopeId) {
|
|
929
929
|
}
|
930
930
|
function nextTagId() {
|
931
931
|
let state = $chunk.boundary.state, { $global: $global2 } = state;
|
932
|
-
return "s" + $global2.runtimeId + $global2.renderId + (state.
|
932
|
+
return "s" + $global2.runtimeId + $global2.renderId + (state.tagId++).toString(36);
|
933
933
|
}
|
934
934
|
function nextScopeId() {
|
935
|
-
return $chunk.boundary.state.
|
935
|
+
return $chunk.boundary.state.scopeId++;
|
936
936
|
}
|
937
937
|
function peekNextScopeId() {
|
938
|
-
return $chunk.boundary.state.
|
938
|
+
return $chunk.boundary.state.scopeId;
|
939
939
|
}
|
940
940
|
function peekNextScope() {
|
941
941
|
return ensureScopeWithId(peekNextScopeId());
|
@@ -1143,9 +1143,9 @@ var State2 = class {
|
|
1143
1143
|
this.$global = $global2;
|
1144
1144
|
this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
|
1145
1145
|
}
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1146
|
+
tagId = 1;
|
1147
|
+
scopeId = 1;
|
1148
|
+
reorderId = 1;
|
1149
1149
|
hasGlobals = !1;
|
1150
1150
|
needsMainRuntime = !1;
|
1151
1151
|
hasMainRuntime = !1;
|
@@ -1169,7 +1169,7 @@ var State2 = class {
|
|
1169
1169
|
this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
|
1170
1170
|
}
|
1171
1171
|
nextReorderId() {
|
1172
|
-
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.
|
1172
|
+
let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.reorderId++, mod = index % encodeStartLen, id = encodeChars[mod];
|
1173
1173
|
for (index = (index - mod) / encodeStartLen; index > 0; )
|
1174
1174
|
mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
|
1175
1175
|
return id;
|