marko 6.4.10 → 6.4.11
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 +0 -3
- package/dist/common/accessor.debug.d.ts +0 -3
- package/dist/common/helpers.d.ts +1 -1
- package/dist/common/types.d.ts +4 -3
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/lazy.feat.js +1 -1
- package/dist/debug/dom/lazy.feat.mjs +1 -1
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-C1V5vpFs.mjs → dom-DjUZd-9y.mjs} +198 -214
- package/dist/debug/{dom-DNB5yq3U.js → dom-mQ5mPBTF.js} +203 -213
- package/dist/debug/dom.js +5 -8
- package/dist/debug/dom.mjs +5 -9
- package/dist/debug/html.js +68 -87
- package/dist/debug/html.mjs +68 -87
- package/dist/dom/abort-signal.d.ts +1 -1
- package/dist/dom/catch.feat.js +3 -3
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/control-flow.d.ts +4 -4
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-script.feat.js +2 -2
- package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +3 -3
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/lazy.feat.js +1 -1
- package/dist/dom/lazy.feat.mjs +1 -1
- package/dist/dom/load.d.ts +3 -4
- package/dist/dom/placeholder.feat.js +1 -1
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/dom/queue.d.ts +1 -2
- package/dist/dom/signals.d.ts +5 -7
- package/dist/{dom-C2-Flitp.js → dom-B8j2453O.js} +143 -155
- package/dist/{dom-DsHYWMCR.mjs → dom-HEWdZCCb.mjs} +119 -136
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +17 -21
- package/dist/dom.mjs +5 -9
- package/dist/html/assets.d.ts +3 -4
- package/dist/html/for.d.ts +0 -1
- package/dist/html/writer.d.ts +2 -2
- package/dist/html.d.ts +1 -1
- package/dist/html.js +60 -72
- package/dist/html.mjs +60 -72
- package/dist/translator/index.d.ts +0 -1
- package/dist/translator/index.js +4629 -4485
- package/dist/translator/interop/out-global.d.ts +5 -0
- package/dist/translator/util/assert.d.ts +4 -0
- package/dist/translator/util/entry-builder.d.ts +1 -1
- package/dist/translator/util/finalize-references.d.ts +2 -1
- package/dist/translator/util/for-selector.d.ts +1 -1
- package/dist/translator/util/known-tag.d.ts +7 -1
- package/dist/translator/util/references.d.ts +11 -5
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/sections.d.ts +6 -1
- package/dist/translator/util/signals.d.ts +2 -1
- package/dist/translator/util/style-interpolation.d.ts +1 -1
- package/dist/translator/util/tag-name-type.d.ts +1 -0
- package/dist/translator/util/visitors.d.ts +1 -1
- package/dist/translator/util/write-guard.d.ts +2 -0
- package/dist/translator/visitors/program/index.d.ts +0 -4
- package/dist/translator/visitors/referenced-identifier.d.ts +3 -1
- package/package.json +4 -4
- package/dist/common/constants/keyed-scopes-prop.d.ts +0 -4
- package/dist/common/constants/keyed-scopes-prop.debug.d.ts +0 -4
|
@@ -52,8 +52,6 @@ const Changed = "Changed";
|
|
|
52
52
|
const ScopesAccessor = "scopesAccessor";
|
|
53
53
|
const SignalIndexAccessor = "signalIndexAccessor";
|
|
54
54
|
const Index = "index";
|
|
55
|
-
// src/common/constants/keyed-scopes-prop.debug.ts
|
|
56
|
-
const PreviousKey = "PreviousKey:";
|
|
57
55
|
const Scope = "scope";
|
|
58
56
|
const Signal = "signal";
|
|
59
57
|
const Value = "value";
|
|
@@ -134,7 +132,7 @@ function escapeStyleValue(str) {
|
|
|
134
132
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
135
133
|
return result + closers;
|
|
136
134
|
}
|
|
137
|
-
|
|
135
|
+
function toDelimitedString(val, delimiter, stringify) {
|
|
138
136
|
let str = "";
|
|
139
137
|
let sep = "";
|
|
140
138
|
let part;
|
|
@@ -156,7 +154,7 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
156
|
return str;
|
|
159
|
-
}
|
|
157
|
+
}
|
|
160
158
|
function isEventHandler(name) {
|
|
161
159
|
return /^on[A-Z-]/.test(name);
|
|
162
160
|
}
|
|
@@ -435,9 +433,9 @@ function prepareEffects(fn) {
|
|
|
435
433
|
}
|
|
436
434
|
return preparedEffects;
|
|
437
435
|
}
|
|
438
|
-
let runEffects = (
|
|
436
|
+
let runEffects = (effects) => {
|
|
439
437
|
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
440
|
-
}
|
|
438
|
+
};
|
|
441
439
|
let runRender = (render) => {
|
|
442
440
|
if (!branchesEnabled || render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) render[Signal](render[Scope], render[Value]);
|
|
443
441
|
};
|
|
@@ -487,7 +485,7 @@ function $signal(scope, id) {
|
|
|
487
485
|
return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
|
|
488
486
|
}
|
|
489
487
|
/** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
|
|
490
|
-
function
|
|
488
|
+
function onAbort(scope, id, abort) {
|
|
491
489
|
abortsEnabled = 1;
|
|
492
490
|
trackCleanup(scope);
|
|
493
491
|
(scope[AbortControllers] ||= {})[id] = { abort };
|
|
@@ -586,7 +584,7 @@ function skipScope() {
|
|
|
586
584
|
return nextScopeId++;
|
|
587
585
|
}
|
|
588
586
|
function destroyBranch(branch) {
|
|
589
|
-
branch[ParentBranch]?.[BranchScopes]
|
|
587
|
+
branch[ParentBranch]?.[BranchScopes].delete(branch);
|
|
590
588
|
destroyNestedScopes(branch);
|
|
591
589
|
}
|
|
592
590
|
function destroyScope(scope) {
|
|
@@ -595,11 +593,11 @@ function destroyScope(scope) {
|
|
|
595
593
|
cleanupScope(scope);
|
|
596
594
|
}
|
|
597
595
|
}
|
|
598
|
-
|
|
596
|
+
function destroyNestedScopes(scope) {
|
|
599
597
|
scope[Gen$1] = 0;
|
|
600
598
|
scope[BranchScopes]?.forEach(destroyNestedScopes);
|
|
601
599
|
scope[AbortScopes]?.forEach(cleanupScope);
|
|
602
|
-
}
|
|
600
|
+
}
|
|
603
601
|
function cleanupScope(scope) {
|
|
604
602
|
if (subscriptionsEnabled) scope[Subscriptions]?.forEach(unsubscribe, scope);
|
|
605
603
|
if (abortsEnabled) for (const id in scope[AbortControllers]) $signalReset(scope, id);
|
|
@@ -691,7 +689,8 @@ function _const(valueAccessor, fn) {
|
|
|
691
689
|
}
|
|
692
690
|
});
|
|
693
691
|
}
|
|
694
|
-
function _or(id, fn, defaultPending = 1, scopeIdAccessor
|
|
692
|
+
function _or(id, fn, defaultPending = 1, scopeIdAccessor) {
|
|
693
|
+
scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
|
|
695
694
|
return (scope) => {
|
|
696
695
|
if (scope["#Gen"] === runId) {
|
|
697
696
|
if (~id in scope) {
|
|
@@ -700,36 +699,33 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
|
700
699
|
} else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
701
700
|
};
|
|
702
701
|
}
|
|
703
|
-
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
702
|
+
function _for_closure(ownerLoopNodeAccessor, fn, id, scopeIdAccessor) {
|
|
703
|
+
scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
|
|
704
704
|
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
705
|
-
const
|
|
706
|
-
const
|
|
707
|
-
queueRender(ownerScope, (_) => {
|
|
708
|
-
for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
|
|
709
|
-
}, -1);
|
|
705
|
+
const render = (ownerScope) => {
|
|
706
|
+
for (const scope of toArray(ownerScope[scopeAccessor])) if (scope["#Gen"] < runId) fn(scope);
|
|
710
707
|
};
|
|
708
|
+
const ownerSignal = (ownerScope) => queueRender(ownerScope, render, id, 0, ownerScope[scopeIdAccessor]);
|
|
711
709
|
ownerSignal._ = (scope) => queueRender(scope, fn, -1);
|
|
712
710
|
return ownerSignal;
|
|
713
711
|
}
|
|
714
|
-
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn) {
|
|
712
|
+
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn, getValueScope) {
|
|
715
713
|
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
716
714
|
const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
|
|
717
|
-
const
|
|
715
|
+
const prevKey = Symbol(ownerValueAccessor);
|
|
718
716
|
const ownerSignal = (ownerScope) => {
|
|
719
717
|
if (ownerScope["#Gen"] < runId) {
|
|
720
|
-
const nextKey = ownerScope[ownerValueAccessor];
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
if (map) map[prevKeyProp] = nextKey;
|
|
732
|
-
}, -1);
|
|
718
|
+
const nextKey = (getValueScope ? getValueScope(ownerScope) : ownerScope)[ownerValueAccessor];
|
|
719
|
+
const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor);
|
|
720
|
+
if (map && prevKey in ownerScope) {
|
|
721
|
+
const prevScope = map.get(ownerScope[prevKey]);
|
|
722
|
+
const nextScope = map.get(nextKey);
|
|
723
|
+
if (prevScope !== nextScope) {
|
|
724
|
+
queueLiveBranch(prevScope, fn);
|
|
725
|
+
queueLiveBranch(nextScope, fn);
|
|
726
|
+
}
|
|
727
|
+
} else for (const scope of toArray(ownerScope[scopeAccessor])) queueLiveBranch(scope, fn);
|
|
728
|
+
ownerScope[prevKey] = nextKey;
|
|
733
729
|
}
|
|
734
730
|
};
|
|
735
731
|
ownerSignal._ = (scope) => queueRender(scope, fn, -1);
|
|
@@ -744,8 +740,8 @@ function keyedScopes(ownerScope, scopeAccessor, mapAccessor) {
|
|
|
744
740
|
}
|
|
745
741
|
return map;
|
|
746
742
|
}
|
|
747
|
-
function
|
|
748
|
-
if (scope
|
|
743
|
+
function queueLiveBranch(scope, fn) {
|
|
744
|
+
if (scope?.["#Gen"] < runId) queueRender(scope, fn, -1);
|
|
749
745
|
}
|
|
750
746
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
751
747
|
const scopeAccessor = BranchScopes$1 + ownerConditionalNodeAccessor;
|
|
@@ -814,9 +810,7 @@ function _id(scope, accessor) {
|
|
|
814
810
|
}
|
|
815
811
|
function _script(id, fn) {
|
|
816
812
|
_resumed[id] = fn;
|
|
817
|
-
return (scope) =>
|
|
818
|
-
queueEffect(scope, fn);
|
|
819
|
-
};
|
|
813
|
+
return (scope) => queueEffect(scope, fn);
|
|
820
814
|
}
|
|
821
815
|
function _global_read($global, key) {
|
|
822
816
|
if (!(key in $global)) console.error(`\`$global.${key}\` is not serialized to the client, so this read is \`undefined\`. Serialized globals are embedded in the page: add \`${key}\` to \`serializedGlobals\` at the render call only if it holds no secrets; otherwise copy the field the client needs into its own \`$global\` key and serialize that.`);
|
|
@@ -856,7 +850,7 @@ function walk(startNode, walkCodes, branch) {
|
|
|
856
850
|
currentNode = startNode;
|
|
857
851
|
walkInternal(0, walkCodes, branch);
|
|
858
852
|
}
|
|
859
|
-
|
|
853
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
860
854
|
let value;
|
|
861
855
|
let currentMultiplier;
|
|
862
856
|
let storedMultiplier = 0;
|
|
@@ -892,7 +886,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
892
886
|
storedMultiplier = currentMultiplier * 10 + value - 117;
|
|
893
887
|
}
|
|
894
888
|
}
|
|
895
|
-
}
|
|
889
|
+
}
|
|
896
890
|
function getDebugKey(index, node) {
|
|
897
891
|
if (typeof node === "string") return `${node}/${index}`;
|
|
898
892
|
else if (node.nodeType === 3) return `#text/${index}`;
|
|
@@ -944,168 +938,166 @@ function init(runtimeId = "M") {
|
|
|
944
938
|
}
|
|
945
939
|
const renders = self[runtimeId];
|
|
946
940
|
const defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc);
|
|
947
|
-
const initRuntime = (renders) => {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
scopeId++;
|
|
973
|
-
}
|
|
941
|
+
const initRuntime = (renders) => defineRuntime({ value: curRenders = ((renderId) => {
|
|
942
|
+
const render = curRenders[renderId] = renders[renderId] || renders(renderId);
|
|
943
|
+
const walk = render.w;
|
|
944
|
+
const scopeLookup = {};
|
|
945
|
+
const pending = [];
|
|
946
|
+
const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
|
|
947
|
+
const initGlobal = (_) => scopeLookup[0] ||= {
|
|
948
|
+
runtimeId,
|
|
949
|
+
renderId
|
|
950
|
+
};
|
|
951
|
+
const initScope = (scope) => {
|
|
952
|
+
scope[Gen$1] ??= 1;
|
|
953
|
+
scope[Global] = initGlobal();
|
|
954
|
+
if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
|
|
955
|
+
return scope;
|
|
956
|
+
};
|
|
957
|
+
const applyScopes = (partials) => {
|
|
958
|
+
let scopeId = partials[0];
|
|
959
|
+
for (let i = 1; i < partials.length; i++) {
|
|
960
|
+
const partial = partials[i];
|
|
961
|
+
if (typeof partial === "number") scopeId += partial;
|
|
962
|
+
else {
|
|
963
|
+
if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
|
|
964
|
+
else Object.assign(initGlobal(), partial);
|
|
965
|
+
scopeId++;
|
|
974
966
|
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
startVisit = branchStarts.pop();
|
|
1008
|
-
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
1009
|
-
branch[StartNode] = startVisit;
|
|
1010
|
-
branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? _resumed[registryId](getScope(data)) : getScope(data) : applyScopes(data));
|
|
970
|
+
const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
|
|
971
|
+
return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
|
|
972
|
+
if (visitType === "*") {
|
|
973
|
+
while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
|
|
974
|
+
if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (visitType !== "[") {
|
|
978
|
+
visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
|
|
979
|
+
accessor = BranchScopes$1 + (nodeAccessor = lastToken);
|
|
980
|
+
singleNode = visitType !== "]" && visitType !== ")";
|
|
981
|
+
nextToken();
|
|
982
|
+
}
|
|
983
|
+
while (branchId = +lastToken) {
|
|
984
|
+
(endedBranches ||= []).push(branch = getScope(branchId));
|
|
985
|
+
setParentBranch(branch, branch[ClosestBranch]);
|
|
986
|
+
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
|
|
987
|
+
if (singleNode) {
|
|
988
|
+
while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
|
|
989
|
+
branch["_"] ??= visitScope;
|
|
990
|
+
branch[EndNode] = branch[StartNode] = startVisit;
|
|
991
|
+
if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
992
|
+
} else {
|
|
993
|
+
branch[BranchAccessor] = nodeAccessor;
|
|
994
|
+
curBranchScopes = push(curBranchScopes, branch);
|
|
995
|
+
if (accessor) {
|
|
996
|
+
visitScope[accessor] = curBranchScopes;
|
|
997
|
+
forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
|
|
998
|
+
curBranchScopes = branchScopesStack.pop();
|
|
1011
999
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1000
|
+
startVisit = branchStarts.pop();
|
|
1001
|
+
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
1002
|
+
branch[StartNode] = startVisit;
|
|
1003
|
+
branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
1014
1004
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1005
|
+
while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
|
|
1006
|
+
nextToken();
|
|
1007
|
+
}
|
|
1008
|
+
if (endedBranches) {
|
|
1009
|
+
for (const ended of endedBranches) pending.push(ended);
|
|
1010
|
+
if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
|
|
1011
|
+
}
|
|
1012
|
+
if (visitType === "[") {
|
|
1013
|
+
if (!endedBranches) {
|
|
1014
|
+
branchScopesStack.push(curBranchScopes);
|
|
1015
|
+
curBranchScopes = void 0;
|
|
1018
1016
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
branchScopesStack.push(curBranchScopes);
|
|
1022
|
-
curBranchScopes = void 0;
|
|
1023
|
-
}
|
|
1024
|
-
branchStarts.push(visit);
|
|
1025
|
-
} else pending.push(visitScope);
|
|
1026
|
-
};
|
|
1017
|
+
branchStarts.push(visit);
|
|
1018
|
+
} else pending.push(visitScope);
|
|
1027
1019
|
};
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1020
|
+
};
|
|
1021
|
+
const nextToken = (_) => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
|
|
1022
|
+
const processResumes = (resumes = [], effects) => {
|
|
1023
|
+
let i = 0;
|
|
1024
|
+
for (; i < resumes.length; i++) {
|
|
1025
|
+
const serialized = resumes[i];
|
|
1026
|
+
if (typeof serialized === "string") {
|
|
1027
|
+
lastTokenIndex = 0;
|
|
1028
|
+
visitText = serialized;
|
|
1029
|
+
while (nextToken()) if (/\D/.test(lastToken)) lastEffect = _resumed[lastToken];
|
|
1030
|
+
else effects.push(lastEffect, getScope(lastToken));
|
|
1031
|
+
} else if (Array.isArray(serialized)) {
|
|
1032
|
+
if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
|
|
1033
|
+
} else if (readyIds && typeof serialized === "number") break;
|
|
1034
|
+
else {
|
|
1035
|
+
const scopes = serialized(serializeContext);
|
|
1036
|
+
if (Array.isArray(scopes)) applyScopes(scopes);
|
|
1045
1037
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1038
|
+
}
|
|
1039
|
+
resumes.splice(0, i);
|
|
1040
|
+
return i;
|
|
1041
|
+
};
|
|
1042
|
+
let lastEffect;
|
|
1043
|
+
let visits;
|
|
1044
|
+
let visit;
|
|
1045
|
+
let visitText;
|
|
1046
|
+
let visitType;
|
|
1047
|
+
let visitScope;
|
|
1048
|
+
let lastToken;
|
|
1049
|
+
let lastTokenIndex;
|
|
1050
|
+
let visitBranches;
|
|
1051
|
+
let htmlStart;
|
|
1052
|
+
let embedAnchor;
|
|
1053
|
+
serializeContext._ = _resumed;
|
|
1054
|
+
if (render.m) throw new Error(`Marko rendered multiple times with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as ${JSON.stringify(renderId)}. Ensure each render into a page has a unique $global.renderId.`);
|
|
1055
|
+
for (const otherId in curRenders) if (otherId !== renderId && (otherId.startsWith(renderId) || renderId.startsWith(otherId))) console.error(`Marko rendered with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as both ${JSON.stringify(otherId)} and ${JSON.stringify(renderId)}, so one render claims the other's resume comments. Ensure no $global.renderId in a page starts another.`);
|
|
1056
|
+
render.m = (effects) => {
|
|
1057
|
+
processResumes(render.r, effects);
|
|
1058
|
+
if (readyIds && render.b) for (let progress = 1; progress;) {
|
|
1059
|
+
progress = 0;
|
|
1060
|
+
for (const readyId of readyIds) {
|
|
1061
|
+
const resumes = render.b[readyId];
|
|
1062
|
+
if (resumes && processResumes(resumes, effects)) progress = 1;
|
|
1071
1063
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
if (visit.parentNode !== htmlStart.parentNode) console.error("An unescaped placeholder (`$!{}`) rendered HTML that does not parse as a balanced fragment where it is placed (an unclosed, stray or misnested tag), so updating it removes the wrong nodes.");
|
|
1082
|
-
visitScope[nextToken()] = htmlStart;
|
|
1083
|
-
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1084
|
-
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1085
|
-
}
|
|
1086
|
-
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1087
|
-
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1064
|
+
}
|
|
1065
|
+
let retained = 0;
|
|
1066
|
+
for (visit of visits = render.v) {
|
|
1067
|
+
lastTokenIndex = render.i.length;
|
|
1068
|
+
visitText = visit.data;
|
|
1069
|
+
visitType = visitText[lastTokenIndex++];
|
|
1070
|
+
visitScope = getScope(nextToken());
|
|
1071
|
+
if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
|
|
1072
|
+
if (visitType === "&") htmlStart = visit;
|
|
1088
1073
|
else {
|
|
1089
|
-
|
|
1074
|
+
if (visit.parentNode !== htmlStart.parentNode) console.error("An unescaped placeholder (`$!{}`) rendered HTML that does not parse as a balanced fragment where it is placed (an unclosed, stray or misnested tag), so updating it removes the wrong nodes.");
|
|
1075
|
+
visitScope[nextToken()] = htmlStart;
|
|
1076
|
+
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1090
1077
|
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1091
1078
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
visitBranches();
|
|
1079
|
+
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1080
|
+
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1081
|
+
else {
|
|
1082
|
+
visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
|
|
1083
|
+
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1098
1084
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1085
|
+
if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
|
|
1086
|
+
}
|
|
1087
|
+
if (branchesEnabled && visitBranches) {
|
|
1088
|
+
visitType = "*";
|
|
1089
|
+
lastToken = "";
|
|
1090
|
+
visitBranches();
|
|
1091
|
+
}
|
|
1092
|
+
visits.length = retained;
|
|
1093
|
+
return effects;
|
|
1094
|
+
};
|
|
1095
|
+
render.w = (_) => {
|
|
1096
|
+
walk();
|
|
1097
|
+
runResumeEffects(render);
|
|
1098
|
+
};
|
|
1099
|
+
return render;
|
|
1100
|
+
}) });
|
|
1109
1101
|
if (renders) {
|
|
1110
1102
|
initRuntime(renders);
|
|
1111
1103
|
for (const renderId in renders) runResumeEffects(curRenders(renderId));
|
|
@@ -1136,7 +1128,7 @@ function _el(id, accessor) {
|
|
|
1136
1128
|
function _dynamic_tag_var_resume(accessor) {
|
|
1137
1129
|
_resumed[DYNAMIC_TAG_VAR_REGISTER_ID + accessor] = (scope) => (_) => {
|
|
1138
1130
|
const node = scope[accessor];
|
|
1139
|
-
return _el_read(node.nodeType
|
|
1131
|
+
return _el_read(node.nodeType > 1 ? node.previousSibling : node);
|
|
1140
1132
|
};
|
|
1141
1133
|
}
|
|
1142
1134
|
// src/dom/renderer.ts
|
|
@@ -1170,11 +1162,8 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
1170
1162
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
1171
1163
|
setup = setup ? setup._ || setup : void 0;
|
|
1172
1164
|
params ||= void 0;
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
} : (branch) => {
|
|
1176
|
-
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
1177
|
-
};
|
|
1165
|
+
const cloneables = {};
|
|
1166
|
+
const clone = template ? (branch, ns) => (cloneables[ns] ||= createCloneableHTML(template, walks, ns))(branch) : (branch) => walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
1178
1167
|
return _resumed[id] = (owner) => {
|
|
1179
1168
|
return {
|
|
1180
1169
|
["id"]: id,
|
|
@@ -1214,14 +1203,11 @@ function _content_closures(renderer, closureFns) {
|
|
|
1214
1203
|
return instance;
|
|
1215
1204
|
};
|
|
1216
1205
|
}
|
|
1217
|
-
|
|
1218
|
-
function createCloneableHTML(html, ns) {
|
|
1206
|
+
function createCloneableHTML(html, walks, ns) {
|
|
1219
1207
|
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
1220
1208
|
const parent = new DocumentFragment();
|
|
1221
1209
|
insertChildNodes(parent, null, firstChild, lastChild);
|
|
1222
|
-
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
1223
|
-
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
1224
|
-
} : (branch, walks) => {
|
|
1210
|
+
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch) => walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch) : (branch) => {
|
|
1225
1211
|
const clone = parent.cloneNode(true);
|
|
1226
1212
|
clone.namespaceURI = ns;
|
|
1227
1213
|
walk(clone.firstChild, walks, branch);
|
|
@@ -1359,7 +1345,12 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
|
1359
1345
|
}
|
|
1360
1346
|
}
|
|
1361
1347
|
function _attr_content(scope, nodeAccessor, value) {
|
|
1362
|
-
const
|
|
1348
|
+
const renderer = normalizeDynamicRenderer(value);
|
|
1349
|
+
let content;
|
|
1350
|
+
if (renderer) {
|
|
1351
|
+
if (renderer["id"]) content = renderer;
|
|
1352
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1353
|
+
}
|
|
1363
1354
|
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = rendererKey(content))) {
|
|
1364
1355
|
setBranch(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1365
1356
|
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
@@ -1394,13 +1385,6 @@ const _html = /*@__PURE__*/ withDynamicHtml(function _html(scope, value, accesso
|
|
|
1394
1385
|
removeChildNodes(firstChild, lastChild);
|
|
1395
1386
|
}
|
|
1396
1387
|
});
|
|
1397
|
-
function normalizeClientRender(value) {
|
|
1398
|
-
const renderer = normalizeDynamicRenderer(value);
|
|
1399
|
-
if (renderer) {
|
|
1400
|
-
if (renderer["id"]) return renderer;
|
|
1401
|
-
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
1388
|
function normalizeAttrValue(value) {
|
|
1405
1389
|
if (isNotNullishOrFalse(value)) return value === true ? "" : value + "";
|
|
1406
1390
|
}
|
|
@@ -1417,7 +1401,7 @@ function _lifecycle(scope, thisObj, index = 0) {
|
|
|
1417
1401
|
Object.assign(thisObj, thisObj.onMount?.());
|
|
1418
1402
|
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1419
1403
|
}
|
|
1420
|
-
|
|
1404
|
+
onAbort(scope, accessor, (_) => thisObj.onDestroy?.());
|
|
1421
1405
|
}
|
|
1422
1406
|
}
|
|
1423
1407
|
function removeChildNodes(startNode, endNode) {
|
|
@@ -1779,7 +1763,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1779
1763
|
let awaitCounter = tryBranch[AwaitCounter];
|
|
1780
1764
|
if (!scope[tryAccessor]) {
|
|
1781
1765
|
scope[tryAccessor] = tryBranch;
|
|
1782
|
-
|
|
1766
|
+
onAbort(scope, promiseAccessor, (_) => {
|
|
1783
1767
|
scope[promiseAccessor] = 0;
|
|
1784
1768
|
if (scope[tryAccessor]) queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
|
|
1785
1769
|
});
|
|
@@ -1957,7 +1941,7 @@ const _show = /*@__PURE__*/ withBranches((nodeAccessor, startNodeAccessor) => {
|
|
|
1957
1941
|
const rangeAccessor = BranchScopes$1 + nodeAccessor;
|
|
1958
1942
|
return (scope, display) => {
|
|
1959
1943
|
const referenceNode = scope[nodeAccessor];
|
|
1960
|
-
const onlyChild = referenceNode.nodeType
|
|
1944
|
+
const onlyChild = referenceNode.nodeType < 3;
|
|
1961
1945
|
const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
|
|
1962
1946
|
let range = scope[rangeAccessor];
|
|
1963
1947
|
if (!range) {
|
|
@@ -2095,7 +2079,7 @@ const loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, tem
|
|
|
2095
2079
|
const oldScope = oldScopes[i];
|
|
2096
2080
|
let branch = oldLen && (oldScopesByKey || key !== (oldScope?.["#LoopKey"] ?? i) ? (oldScopesByKey ||= oldScopes.reduce((map, scope, j) => j < i ? map : (scope["#LoopIndex"] = j, map.set(scope["#LoopKey"] ?? j, scope)), /* @__PURE__ */ new Map())).get(key) : oldScope && (start++, oldScope));
|
|
2097
2081
|
if (branch) {
|
|
2098
|
-
hasPotentialMoves =
|
|
2082
|
+
hasPotentialMoves = 1;
|
|
2099
2083
|
oldScopesByKey?.delete(key);
|
|
2100
2084
|
branch[LoopKey] = key;
|
|
2101
2085
|
} else {
|
|
@@ -3021,6 +3005,12 @@ Object.defineProperty(exports, "installDynamicTagVar", {
|
|
|
3021
3005
|
return installDynamicTagVar;
|
|
3022
3006
|
}
|
|
3023
3007
|
});
|
|
3008
|
+
Object.defineProperty(exports, "onAbort", {
|
|
3009
|
+
enumerable: true,
|
|
3010
|
+
get: function() {
|
|
3011
|
+
return onAbort;
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3024
3014
|
Object.defineProperty(exports, "patchDynamicTag", {
|
|
3025
3015
|
enumerable: true,
|
|
3026
3016
|
get: function() {
|