marko 6.0.0-next.3.25 → 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 -88
- package/dist/debug/dom.mjs +106 -88
- 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 +113 -105
- package/dist/dom.mjs +113 -105
- 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.js
CHANGED
@@ -133,25 +133,28 @@ function triggerMacroTask() {
|
|
133
133
|
var pendingScopes = [];
|
134
134
|
function createScope($global) {
|
135
135
|
let scope = {
|
136
|
-
|
136
|
+
f: 1,
|
137
137
|
$global
|
138
138
|
};
|
139
139
|
return pendingScopes.push(scope), scope;
|
140
140
|
}
|
141
141
|
function finishPendingScopes() {
|
142
142
|
for (let scope of pendingScopes)
|
143
|
-
scope.
|
143
|
+
scope.f = 0;
|
144
144
|
pendingScopes = [];
|
145
145
|
}
|
146
|
-
var
|
147
|
-
function
|
148
|
-
return
|
146
|
+
var emptyBranch = createScope({});
|
147
|
+
function getEmptyBranch(marker) {
|
148
|
+
return emptyBranch.a = emptyBranch.c = marker, emptyBranch;
|
149
149
|
}
|
150
150
|
function destroyBranch(branch) {
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
151
|
+
branch.n?.k?.delete(branch), destroyNestedBranches(branch);
|
152
|
+
}
|
153
|
+
function destroyNestedBranches(branch) {
|
154
|
+
branch.z = 1, branch.k?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
|
155
|
+
for (let id in scope.g)
|
156
|
+
scope.g[id]?.abort();
|
157
|
+
});
|
155
158
|
}
|
156
159
|
function removeAndDestroyBranch(branch) {
|
157
160
|
destroyBranch(branch);
|
@@ -161,8 +164,8 @@ function removeAndDestroyBranch(branch) {
|
|
161
164
|
current.remove(), current = next;
|
162
165
|
}
|
163
166
|
}
|
164
|
-
function
|
165
|
-
let current =
|
167
|
+
function insertBranchBefore(branch, parent, nextSibling) {
|
168
|
+
let current = branch.a, stop = branch.c.nextSibling;
|
166
169
|
for (; current !== stop; ) {
|
167
170
|
let next = current.nextSibling;
|
168
171
|
parent.insertBefore(current, nextSibling), current = next;
|
@@ -235,7 +238,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
235
238
|
if (newStart <= newEnd) {
|
236
239
|
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
|
237
240
|
do
|
238
|
-
|
241
|
+
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
239
242
|
while (newStart <= newEnd);
|
240
243
|
}
|
241
244
|
} else if (newStart > newEnd)
|
@@ -253,7 +256,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
253
256
|
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);
|
254
257
|
if (oldLength === oldBranches.length && synced === 0) {
|
255
258
|
for (; newStart < newLength; ++newStart)
|
256
|
-
|
259
|
+
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
257
260
|
for (; oldStart < oldLength; ++oldStart)
|
258
261
|
removeAndDestroyBranch(oldBranches[oldStart]);
|
259
262
|
} else {
|
@@ -262,10 +265,10 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
262
265
|
if (pos === WRONG_POS) {
|
263
266
|
let seq = longestIncreasingSubsequence(sources);
|
264
267
|
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
265
|
-
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference,
|
268
|
+
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;
|
266
269
|
} else if (synced !== newLength)
|
267
270
|
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
268
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference,
|
271
|
+
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
269
272
|
}
|
270
273
|
}
|
271
274
|
}
|
@@ -344,17 +347,17 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
344
347
|
var registeredValues = {}, Render = class {
|
345
348
|
o = [];
|
346
349
|
p = {};
|
347
|
-
|
350
|
+
B = {
|
348
351
|
_: registeredValues
|
349
352
|
};
|
350
353
|
constructor(renders, runtimeId, renderId) {
|
351
|
-
this.
|
354
|
+
this.C = renders, this.D = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
|
352
355
|
}
|
353
356
|
w() {
|
354
357
|
this.s.w(), this.t();
|
355
358
|
}
|
356
359
|
t() {
|
357
|
-
let data2 = this.s, serializeContext = this.
|
360
|
+
let data2 = this.s, serializeContext = this.B, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
358
361
|
if (visits.length) {
|
359
362
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
|
360
363
|
data2.v = [];
|
@@ -376,15 +379,15 @@ var registeredValues = {}, Render = class {
|
|
376
379
|
else if (token === "$" /* ClosestBranch */)
|
377
380
|
closestBranchMarkers.set(scopeId, visit);
|
378
381
|
else if (token === "[" /* BranchStart */)
|
379
|
-
this.
|
382
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.o.push(this.e)), this.e = scopeId, scope.a = visit;
|
380
383
|
else if (token === "]" /* BranchEnd */) {
|
381
384
|
scope[data3] = visit;
|
382
385
|
let curParent = visit.parentNode, startNode = branchEnd(
|
383
|
-
this.
|
386
|
+
this.e,
|
384
387
|
visit,
|
385
388
|
visit
|
386
389
|
).a;
|
387
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.
|
390
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.o.pop();
|
388
391
|
} else if (token === "|" /* BranchSingleNode */) {
|
389
392
|
let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
390
393
|
for (; ~next; ) {
|
@@ -405,7 +408,7 @@ var registeredValues = {}, Render = class {
|
|
405
408
|
let resumeData = resumes[i++];
|
406
409
|
if (typeof resumeData == "function") {
|
407
410
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
408
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.
|
411
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.D, $global.renderId = this.q);
|
409
412
|
for (let scopeId in scopes)
|
410
413
|
if (scopeId !== "$") {
|
411
414
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -416,10 +419,10 @@ var registeredValues = {}, Render = class {
|
|
416
419
|
let parentBranchId = parentBranchIds.get(scopeId);
|
417
420
|
if (parentBranchId && (scope.b = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
418
421
|
let branch = scope, parentBranch = branch.b;
|
419
|
-
scope.b = branch, parentBranch && (branch.
|
422
|
+
branch.h = +scopeId, scope.b = branch, parentBranch && (branch.n = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
|
420
423
|
}
|
421
424
|
}
|
422
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.
|
425
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.C[this.q] : registeredValues[resumes[i++]](
|
423
426
|
scopeLookup[resumeData],
|
424
427
|
scopeLookup[resumeData]
|
425
428
|
);
|
@@ -457,7 +460,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
457
460
|
}
|
458
461
|
}
|
459
462
|
function registerSubscriber(id, signal) {
|
460
|
-
return register(id, signal.
|
463
|
+
return register(id, signal.E), signal;
|
461
464
|
}
|
462
465
|
function nodeRef(id, key) {
|
463
466
|
return register(id, (scope) => () => scope[key]);
|
@@ -871,7 +874,7 @@ function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
|
871
874
|
renderer.u || parentScope,
|
872
875
|
parentScope
|
873
876
|
);
|
874
|
-
return
|
877
|
+
return initBranch(renderer, branch), branch;
|
875
878
|
}
|
876
879
|
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
877
880
|
if (typeof tagNameOrRenderer != "string")
|
@@ -885,15 +888,15 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
885
888
|
}
|
886
889
|
function createBranch($global, ownerScope, parentScope) {
|
887
890
|
let branch = createScope($global), parentBranch = parentScope.b;
|
888
|
-
return branch._ = ownerScope, branch.b = branch, parentBranch
|
891
|
+
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;
|
889
892
|
}
|
890
|
-
function
|
893
|
+
function initBranch(renderer, branch) {
|
891
894
|
let dom = renderer.l();
|
892
895
|
return walk(
|
893
896
|
dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
|
894
|
-
renderer.
|
895
|
-
|
896
|
-
),
|
897
|
+
renderer.F,
|
898
|
+
branch
|
899
|
+
), 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;
|
897
900
|
}
|
898
901
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
899
902
|
return (scope, attrsOrOp) => {
|
@@ -902,13 +905,13 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
902
905
|
return;
|
903
906
|
let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
|
904
907
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN)
|
905
|
-
return renderer.
|
908
|
+
return renderer.d?.(childScope, attrsOrOp);
|
906
909
|
let content = getContent?.(scope);
|
907
910
|
if (typeof renderer == "string")
|
908
911
|
setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
|
909
|
-
else if (renderer.
|
912
|
+
else if (renderer.d) {
|
910
913
|
let attributes = attrsOrOp();
|
911
|
-
renderer.
|
914
|
+
renderer.d(
|
912
915
|
childScope,
|
913
916
|
inputIsArgs ? attributes : [
|
914
917
|
content ? {
|
@@ -923,14 +926,14 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
923
926
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
924
927
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
925
928
|
return (owner) => ({
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
+
j: id,
|
930
|
+
G: template,
|
931
|
+
F: walks,
|
929
932
|
x: setup,
|
930
933
|
l: _clone,
|
931
934
|
u: owner,
|
932
|
-
|
933
|
-
get
|
935
|
+
H: void 0,
|
936
|
+
get d() {
|
934
937
|
return args ||= getArgs?.();
|
935
938
|
}
|
936
939
|
});
|
@@ -939,8 +942,8 @@ function createRenderer(template, walks, setup, getArgs) {
|
|
939
942
|
return createRendererWithOwner(template, walks, setup, getArgs)();
|
940
943
|
}
|
941
944
|
function _clone() {
|
942
|
-
return (this.
|
943
|
-
this.
|
945
|
+
return (this.H ||= parseHTMLOrSingleNode(
|
946
|
+
this.G
|
944
947
|
)).cloneNode(!0);
|
945
948
|
}
|
946
949
|
|
@@ -955,18 +958,18 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
|
|
955
958
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
956
959
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
957
960
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
958
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
961
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
959
962
|
}
|
960
963
|
intersection2?.(scope, op);
|
961
964
|
};
|
962
965
|
};
|
963
966
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
964
|
-
let
|
965
|
-
|
966
|
-
newBranch
|
967
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
|
968
|
+
insertBranchBefore(
|
969
|
+
newBranch,
|
967
970
|
prevBranch.a.parentNode,
|
968
971
|
prevBranch.a
|
969
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "
|
972
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
970
973
|
}
|
971
974
|
var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
972
975
|
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
@@ -986,12 +989,12 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
986
989
|
};
|
987
990
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
988
991
|
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
989
|
-
referenceNode.textContent = "", newBranch &&
|
992
|
+
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
990
993
|
}
|
991
994
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
992
|
-
[Symbol(),
|
995
|
+
[Symbol(), getEmptyBranch(void 0)]
|
993
996
|
]), emptyMarkerArray = [
|
994
|
-
/* @__PURE__ */
|
997
|
+
/* @__PURE__ */ getEmptyBranch(void 0)
|
995
998
|
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
996
999
|
function loopOf(nodeAccessor, renderer) {
|
997
1000
|
return loop(
|
@@ -1020,7 +1023,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1020
1023
|
);
|
1021
1024
|
}
|
1022
1025
|
function loop(nodeAccessor, renderer, forEach) {
|
1023
|
-
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.
|
1026
|
+
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.d;
|
1024
1027
|
return (scope, valueOrOp) => {
|
1025
1028
|
if (valueOrOp === DIRTY) return;
|
1026
1029
|
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
@@ -1034,9 +1037,9 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1034
1037
|
if (forEach(valueOrOp, (key, args) => {
|
1035
1038
|
let branch = oldMap.get(key);
|
1036
1039
|
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]);
|
1037
|
-
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray,
|
1040
|
+
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyBranch(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
|
1038
1041
|
if (referenceIsMarker) {
|
1039
|
-
oldMap === emptyMarkerMap &&
|
1042
|
+
oldMap === emptyMarkerMap && getEmptyBranch(referenceNode);
|
1040
1043
|
let oldLastChild = oldArray[oldArray.length - 1];
|
1041
1044
|
afterReference = oldLastChild.c.nextSibling, parentNode = oldLastChild.a.parentNode;
|
1042
1045
|
} else
|
@@ -1053,7 +1056,7 @@ function byFirstArg(name) {
|
|
1053
1056
|
return name;
|
1054
1057
|
}
|
1055
1058
|
function isDifferentRenderer(a, b) {
|
1056
|
-
return a !== b && (a?.
|
1059
|
+
return a !== b && (a?.j || 0) !== b?.j;
|
1057
1060
|
}
|
1058
1061
|
|
1059
1062
|
// src/dom/signals.ts
|
@@ -1094,24 +1097,24 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
|
1094
1097
|
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1095
1098
|
if (loopScopes !== emptyMarkerArray)
|
1096
1099
|
for (let scope of loopScopes)
|
1097
|
-
scope.
|
1100
|
+
scope.f || queueSource(scope, signal, value2);
|
1098
1101
|
};
|
1099
1102
|
return helperSignal._ = signal, helperSignal;
|
1100
1103
|
}
|
1101
1104
|
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1102
1105
|
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1103
1106
|
let conditionalScope = scope[scopeAccessor];
|
1104
|
-
conditionalScope && !conditionalScope.
|
1107
|
+
conditionalScope && !conditionalScope.f && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
|
1105
1108
|
};
|
1106
1109
|
return helperSignal._ = signal, helperSignal;
|
1107
1110
|
}
|
1108
1111
|
var defaultGetOwnerScope = (scope) => scope._;
|
1109
|
-
function dynamicClosure(
|
1110
|
-
let ownerSubscribersAccessor =
|
1112
|
+
function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1113
|
+
let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
|
1111
1114
|
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1112
1115
|
if (subscribers)
|
1113
1116
|
for (let subscriber of subscribers)
|
1114
|
-
subscriber.
|
1117
|
+
subscriber.f || queueSource(subscriber, _signal, value2);
|
1115
1118
|
}, setupSignal = (scope, value2) => {
|
1116
1119
|
_signal(scope, value2), subscribe(scope);
|
1117
1120
|
}, subscribe = (scope) => {
|
@@ -1119,7 +1122,7 @@ function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerS
|
|
1119
1122
|
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1120
1123
|
});
|
1121
1124
|
};
|
1122
|
-
return helperSignal._ = setupSignal, helperSignal.
|
1125
|
+
return helperSignal._ = setupSignal, helperSignal.E = subscribe, helperSignal;
|
1123
1126
|
}
|
1124
1127
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1125
1128
|
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
@@ -1152,29 +1155,25 @@ function effect(id, fn) {
|
|
1152
1155
|
}
|
1153
1156
|
|
1154
1157
|
// src/dom/queue.ts
|
1155
|
-
var
|
1158
|
+
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
1156
1159
|
function queueSource(scope, signal, value2) {
|
1157
1160
|
schedule();
|
1158
1161
|
let prevRendering = rendering;
|
1159
1162
|
return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
|
1160
1163
|
}
|
1161
1164
|
function queueRender(scope, signal, value2) {
|
1162
|
-
let
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1165
|
+
let i = pendingRenders.length, render = {
|
1166
|
+
m: scope,
|
1167
|
+
I: signal,
|
1168
|
+
J: value2,
|
1169
|
+
y: i
|
1167
1170
|
};
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
else {
|
1173
|
-
let curRender = pendingRender;
|
1174
|
-
for (; curRender.d && comparePendingRenders(curRender.d, nextRender) >= 0; )
|
1175
|
-
curRender = curRender.d;
|
1176
|
-
nextRender.d = curRender.d, curRender.d = nextRender;
|
1171
|
+
for (pendingRenders.push(render); i; ) {
|
1172
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1173
|
+
if (comparePendingRenders(render, parent) >= 0) break;
|
1174
|
+
pendingRenders[i] = parent, i = parentIndex;
|
1177
1175
|
}
|
1176
|
+
pendingRenders[i] = render;
|
1178
1177
|
}
|
1179
1178
|
function queueEffect(scope, fn) {
|
1180
1179
|
pendingEffects.push(scope, fn);
|
@@ -1184,17 +1183,17 @@ function run() {
|
|
1184
1183
|
try {
|
1185
1184
|
rendering = !0, runRenders();
|
1186
1185
|
} finally {
|
1187
|
-
|
1186
|
+
pendingRenders = [], pendingEffects = [], rendering = !1;
|
1188
1187
|
}
|
1189
|
-
|
1188
|
+
runEffects(effects);
|
1190
1189
|
}
|
1191
1190
|
function prepareEffects(fn) {
|
1192
|
-
let
|
1193
|
-
|
1191
|
+
let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1192
|
+
pendingRenders = [];
|
1194
1193
|
try {
|
1195
1194
|
rendering = !0, fn(), runRenders();
|
1196
1195
|
} finally {
|
1197
|
-
rendering = !1,
|
1196
|
+
rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
1198
1197
|
}
|
1199
1198
|
return preparedEffects;
|
1200
1199
|
}
|
@@ -1205,26 +1204,39 @@ function runEffects(effects = pendingEffects) {
|
|
1205
1204
|
}
|
1206
1205
|
}
|
1207
1206
|
function runRenders() {
|
1208
|
-
for (;
|
1209
|
-
|
1207
|
+
for (; pendingRenders.length; ) {
|
1208
|
+
let render = pendingRenders[0], next = pendingRenders.pop();
|
1209
|
+
if (render !== next) {
|
1210
|
+
let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
|
1211
|
+
for (; i < mid; ) {
|
1212
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1213
|
+
if (right < pendingRenders.length && comparePendingRenders(
|
1214
|
+
pendingRenders[right],
|
1215
|
+
pendingRenders[bestChild]
|
1216
|
+
) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
|
1217
|
+
break;
|
1218
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1219
|
+
}
|
1220
|
+
pendingRenders[i] = item;
|
1221
|
+
}
|
1222
|
+
render.m.b?.z || render.I(render.m, render.J);
|
1223
|
+
}
|
1210
1224
|
finishPendingScopes();
|
1211
1225
|
}
|
1212
1226
|
function comparePendingRenders(a, b) {
|
1213
|
-
|
1214
|
-
let aStart = ownerStartNode(a.g), bStart = ownerStartNode(b.g);
|
1215
|
-
return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
|
1227
|
+
return getBranchDepth(a) - getBranchDepth(b) || a.y - b.y;
|
1216
1228
|
}
|
1217
|
-
function
|
1218
|
-
return
|
1229
|
+
function getBranchDepth(render) {
|
1230
|
+
return render.m.b?.h || 0;
|
1219
1231
|
}
|
1220
1232
|
|
1221
1233
|
// src/dom/abort-signal.ts
|
1222
1234
|
function resetAbortSignal(scope, id) {
|
1223
|
-
let ctrl = scope.
|
1224
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1235
|
+
let ctrl = scope.g?.[id];
|
1236
|
+
ctrl && (queueEffect(ctrl, abort), scope.g[id] = void 0);
|
1225
1237
|
}
|
1226
1238
|
function getAbortSignal(scope, id) {
|
1227
|
-
return scope.b && (scope.b.
|
1239
|
+
return scope.b && (scope.b.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.g ||= {})[id] ||= new AbortController()).signal;
|
1228
1240
|
}
|
1229
1241
|
function abort(ctrl) {
|
1230
1242
|
ctrl.abort();
|
@@ -1279,14 +1291,14 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1279
1291
|
render(out, component, renderer, args) {
|
1280
1292
|
let scope = component.scope;
|
1281
1293
|
scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
|
1282
|
-
let applyArgs = renderer.
|
1294
|
+
let applyArgs = renderer.d || noop, existing = !1;
|
1283
1295
|
if (typeof args[0] == "object" && "renderBody" in args[0]) {
|
1284
1296
|
let input = args[0], normalizedInput = args[0] = {};
|
1285
1297
|
for (let key in input)
|
1286
1298
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1287
1299
|
}
|
1288
1300
|
if (component.effects = prepareEffects(() => {
|
1289
|
-
scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u,
|
1301
|
+
scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initBranch(renderer, scope)), applyArgs(scope, args);
|
1290
1302
|
}), !existing)
|
1291
1303
|
return scope.a === scope.c ? scope.a : scope.a.parentNode;
|
1292
1304
|
}
|
@@ -1300,33 +1312,29 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
1300
1312
|
return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
|
1301
1313
|
};
|
1302
1314
|
function mount(input = {}, reference, position) {
|
1303
|
-
let branch, dom, { $global } = input;
|
1304
|
-
$global ? ({ $global, ...input } = input, $global = {
|
1315
|
+
let branch, dom, parentNode = reference, nextSibling = null, { $global } = input;
|
1316
|
+
switch ($global ? ({ $global, ...input } = input, $global = {
|
1305
1317
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1306
1318
|
renderId: DEFAULT_RENDER_ID,
|
1307
1319
|
...$global
|
1308
1320
|
}) : $global = {
|
1309
1321
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1310
1322
|
renderId: DEFAULT_RENDER_ID
|
1311
|
-
}
|
1312
|
-
let args = this.f, effects = prepareEffects(() => {
|
1313
|
-
branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
|
1314
|
-
});
|
1315
|
-
switch (position) {
|
1323
|
+
}, position) {
|
1316
1324
|
case "beforebegin":
|
1317
|
-
reference.parentNode
|
1325
|
+
parentNode = reference.parentNode, nextSibling = reference;
|
1318
1326
|
break;
|
1319
1327
|
case "afterbegin":
|
1320
|
-
|
1328
|
+
nextSibling = reference.firstChild;
|
1321
1329
|
break;
|
1322
1330
|
case "afterend":
|
1323
|
-
reference.parentNode
|
1324
|
-
break;
|
1325
|
-
default:
|
1326
|
-
reference.appendChild(dom);
|
1331
|
+
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1327
1332
|
break;
|
1328
1333
|
}
|
1329
|
-
|
1334
|
+
let args = this.d, effects = prepareEffects(() => {
|
1335
|
+
branch = createScope($global), dom = initBranch(this, branch), args?.(branch, [input]);
|
1336
|
+
});
|
1337
|
+
return parentNode.insertBefore(dom, nextSibling), runEffects(effects), {
|
1330
1338
|
update: (newInput) => {
|
1331
1339
|
args && runEffects(
|
1332
1340
|
prepareEffects(() => {
|