marko 6.0.0-next.3.38 → 6.0.0-next.3.40
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/debug/dom.js +696 -741
- package/dist/debug/dom.mjs +696 -741
- package/dist/dom/control-flow.d.ts +1 -2
- package/dist/dom/queue.d.ts +2 -2
- package/dist/dom/resume.d.ts +0 -1
- package/dist/dom/scope.d.ts +1 -2
- package/dist/dom/signals.d.ts +14 -6
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +323 -340
- package/dist/dom.mjs +323 -340
- package/dist/translator/index.js +40 -27
- package/dist/translator/util/signals.d.ts +2 -3
- package/package.json +1 -1
package/dist/debug/dom.mjs
CHANGED
@@ -44,49 +44,6 @@ function forTo(to, from, step, cb) {
|
|
44
44
|
}
|
45
45
|
}
|
46
46
|
|
47
|
-
// src/dom/schedule.ts
|
48
|
-
var runTask;
|
49
|
-
var port2 = /* @__PURE__ */ (() => {
|
50
|
-
const { port1, port2: port22 } = new MessageChannel();
|
51
|
-
port1.onmessage = () => {
|
52
|
-
isScheduled = false;
|
53
|
-
if (true) {
|
54
|
-
const run2 = runTask;
|
55
|
-
runTask = void 0;
|
56
|
-
run2();
|
57
|
-
} else {
|
58
|
-
run();
|
59
|
-
}
|
60
|
-
};
|
61
|
-
return port22;
|
62
|
-
})();
|
63
|
-
var isScheduled;
|
64
|
-
function schedule() {
|
65
|
-
if (!isScheduled) {
|
66
|
-
if (true) {
|
67
|
-
if (console.createTask) {
|
68
|
-
const task = console.createTask("queue");
|
69
|
-
runTask = () => task.run(run);
|
70
|
-
} else {
|
71
|
-
runTask = run;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
isScheduled = true;
|
75
|
-
queueMicrotask(flushAndWaitFrame);
|
76
|
-
}
|
77
|
-
}
|
78
|
-
function flushAndWaitFrame() {
|
79
|
-
if (true) {
|
80
|
-
runTask();
|
81
|
-
} else {
|
82
|
-
run();
|
83
|
-
}
|
84
|
-
requestAnimationFrame(triggerMacroTask);
|
85
|
-
}
|
86
|
-
function triggerMacroTask() {
|
87
|
-
port2.postMessage(0);
|
88
|
-
}
|
89
|
-
|
90
47
|
// src/common/helpers.ts
|
91
48
|
function classValue(value2) {
|
92
49
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -143,35 +100,24 @@ function normalizeDynamicRenderer(value2) {
|
|
143
100
|
}
|
144
101
|
|
145
102
|
// src/dom/event.ts
|
146
|
-
var elementHandlersByEvent = /* @__PURE__ */ new Map();
|
147
103
|
var defaultDelegator = createDelegator();
|
148
104
|
function on(element, type, handler) {
|
149
|
-
|
150
|
-
if (!handlersByElement) {
|
151
|
-
elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap());
|
152
|
-
}
|
153
|
-
if (!handlersByElement.has(element)) {
|
105
|
+
if (element["$" + type] === void 0) {
|
154
106
|
defaultDelegator(element, type, handleDelegated);
|
155
107
|
}
|
156
|
-
|
108
|
+
element["$" + type] = handler || null;
|
157
109
|
}
|
158
110
|
function createDelegator() {
|
159
111
|
const kEvents = Symbol();
|
160
112
|
return function ensureDelegated(node, type, handler) {
|
161
|
-
|
162
|
-
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, true), 1);
|
113
|
+
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, true), 1);
|
163
114
|
};
|
164
115
|
}
|
165
116
|
function handleDelegated(ev) {
|
166
117
|
let target = !rendering && ev.target;
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
if (ev.bubbles) {
|
171
|
-
while ((target = target.parentNode) && !ev.cancelBubble) {
|
172
|
-
handlersByElement.get(target)?.(ev, target);
|
173
|
-
}
|
174
|
-
}
|
118
|
+
while (target) {
|
119
|
+
target["$" + ev.type]?.(ev, target);
|
120
|
+
target = ev.bubbles && !ev.cancelBubble && target.parentNode;
|
175
121
|
}
|
176
122
|
}
|
177
123
|
|
@@ -417,10 +363,6 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
417
363
|
});
|
418
364
|
}
|
419
365
|
}
|
420
|
-
function registerSubscriber(id, signal) {
|
421
|
-
register(id, signal.___subscribe);
|
422
|
-
return signal;
|
423
|
-
}
|
424
366
|
function nodeRef(id, key) {
|
425
367
|
return register(id, (scope) => () => scope[key]);
|
426
368
|
}
|
@@ -552,7 +494,7 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
552
494
|
}
|
553
495
|
}
|
554
496
|
};
|
555
|
-
if (!
|
497
|
+
if (!el._) {
|
556
498
|
new MutationObserver(() => {
|
557
499
|
const value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
558
500
|
if (Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) {
|
@@ -647,9 +589,8 @@ function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
|
647
589
|
}
|
648
590
|
}
|
649
591
|
var controllableDelegate = createDelegator();
|
650
|
-
var controllableHandlers = /* @__PURE__ */ new WeakMap();
|
651
592
|
function syncControllable(el, event, hasChanged, onChange) {
|
652
|
-
if (!
|
593
|
+
if (!el._) {
|
653
594
|
controllableDelegate(el, event, handleChange);
|
654
595
|
if (el.form) {
|
655
596
|
controllableDelegate(el.form, "reset", handleFormReset);
|
@@ -658,17 +599,16 @@ function syncControllable(el, event, hasChanged, onChange) {
|
|
658
599
|
queueMicrotask(onChange);
|
659
600
|
}
|
660
601
|
}
|
661
|
-
|
602
|
+
el._ = onChange;
|
662
603
|
}
|
663
604
|
function handleChange(ev) {
|
664
|
-
|
605
|
+
ev.target._?.(ev);
|
665
606
|
}
|
666
607
|
function handleFormReset(ev) {
|
667
608
|
const handlers = [];
|
668
609
|
for (const el of ev.target.elements) {
|
669
|
-
|
670
|
-
|
671
|
-
handlers.push(handler);
|
610
|
+
if (el._ && hasFormElementChanged(el)) {
|
611
|
+
handlers.push(el._);
|
672
612
|
}
|
673
613
|
}
|
674
614
|
requestAnimationFrame(() => {
|
@@ -971,9 +911,10 @@ function toInsertNode(startNode, endNode) {
|
|
971
911
|
// src/dom/scope.ts
|
972
912
|
var pendingScopes = [];
|
973
913
|
var debugID = 0;
|
974
|
-
function createScope($global) {
|
914
|
+
function createScope($global, closestBranch) {
|
975
915
|
const scope = {
|
976
916
|
___pending: 1,
|
917
|
+
___closestBranch: closestBranch,
|
977
918
|
$global
|
978
919
|
};
|
979
920
|
if (true) {
|
@@ -988,11 +929,6 @@ function finishPendingScopes() {
|
|
988
929
|
}
|
989
930
|
pendingScopes = [];
|
990
931
|
}
|
991
|
-
var emptyBranch = createScope({});
|
992
|
-
function getEmptyBranch(marker) {
|
993
|
-
emptyBranch.___startNode = emptyBranch.___endNode = marker;
|
994
|
-
return emptyBranch;
|
995
|
-
}
|
996
932
|
function destroyBranch(branch) {
|
997
933
|
branch.___parentBranch?.___branchScopes?.delete(branch);
|
998
934
|
destroyNestedBranches(branch);
|
@@ -1019,135 +955,494 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
1019
955
|
);
|
1020
956
|
}
|
1021
957
|
|
1022
|
-
// src/dom/
|
1023
|
-
var
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
let j;
|
1035
|
-
let k;
|
1036
|
-
let nextSibling;
|
1037
|
-
let oldBranch;
|
1038
|
-
let newBranch;
|
1039
|
-
outer: {
|
1040
|
-
while (oldStartBranch === newStartBranch) {
|
1041
|
-
++oldStart;
|
1042
|
-
++newStart;
|
1043
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
1044
|
-
break outer;
|
1045
|
-
}
|
1046
|
-
oldStartBranch = oldBranches[oldStart];
|
1047
|
-
newStartBranch = newBranches[newStart];
|
958
|
+
// src/dom/schedule.ts
|
959
|
+
var runTask;
|
960
|
+
var port2 = /* @__PURE__ */ (() => {
|
961
|
+
const { port1, port2: port22 } = new MessageChannel();
|
962
|
+
port1.onmessage = () => {
|
963
|
+
isScheduled = false;
|
964
|
+
if (true) {
|
965
|
+
const run2 = runTask;
|
966
|
+
runTask = void 0;
|
967
|
+
run2();
|
968
|
+
} else {
|
969
|
+
run();
|
1048
970
|
}
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
971
|
+
};
|
972
|
+
return port22;
|
973
|
+
})();
|
974
|
+
var isScheduled;
|
975
|
+
function schedule() {
|
976
|
+
if (!isScheduled) {
|
977
|
+
if (true) {
|
978
|
+
if (console.createTask) {
|
979
|
+
const task = console.createTask("queue");
|
980
|
+
runTask = () => task.run(run);
|
981
|
+
} else {
|
982
|
+
runTask = run;
|
1054
983
|
}
|
1055
|
-
oldEndBranch = oldBranches[oldEnd];
|
1056
|
-
newEndBranch = newBranches[newEnd];
|
1057
984
|
}
|
985
|
+
isScheduled = true;
|
986
|
+
queueMicrotask(flushAndWaitFrame);
|
1058
987
|
}
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
do {
|
1064
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
1065
|
-
} while (newStart <= newEnd);
|
1066
|
-
}
|
1067
|
-
} else if (newStart > newEnd) {
|
1068
|
-
do {
|
1069
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
1070
|
-
} while (oldStart <= oldEnd);
|
988
|
+
}
|
989
|
+
function flushAndWaitFrame() {
|
990
|
+
if (true) {
|
991
|
+
runTask();
|
1071
992
|
} else {
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
993
|
+
run();
|
994
|
+
}
|
995
|
+
requestAnimationFrame(triggerMacroTask);
|
996
|
+
}
|
997
|
+
function triggerMacroTask() {
|
998
|
+
port2.postMessage(0);
|
999
|
+
}
|
1000
|
+
|
1001
|
+
// src/dom/signals.ts
|
1002
|
+
var MARK = true ? Symbol("mark") : {};
|
1003
|
+
var CLEAN = true ? Symbol("clean") : {};
|
1004
|
+
var DIRTY = true ? Symbol("dirty") : {};
|
1005
|
+
function state(valueAccessor, fn, getIntersection) {
|
1006
|
+
const valueSignal = value(valueAccessor, fn, getIntersection);
|
1007
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1008
|
+
const valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1009
|
+
return (scope, valueOrOp, valueChange) => {
|
1010
|
+
if (rendering) {
|
1011
|
+
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
1012
|
+
valueSignal(
|
1013
|
+
scope,
|
1014
|
+
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1015
|
+
);
|
1016
|
+
} else if (scope[valueChangeAccessor]) {
|
1017
|
+
scope[valueChangeAccessor](valueOrOp);
|
1018
|
+
} else {
|
1019
|
+
schedule();
|
1020
|
+
queueSource(scope, valueSignal, valueOrOp);
|
1084
1021
|
}
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1022
|
+
return valueOrOp;
|
1023
|
+
};
|
1024
|
+
}
|
1025
|
+
function value(valueAccessor, fn, getIntersection) {
|
1026
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1027
|
+
let intersection2;
|
1028
|
+
return (scope, valueOrOp) => {
|
1029
|
+
if (valueOrOp === MARK) {
|
1030
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1031
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
|
1032
|
+
}
|
1033
|
+
} else if (valueOrOp !== DIRTY) {
|
1034
|
+
const existing = scope[markAccessor] !== void 0;
|
1035
|
+
if ((scope[markAccessor] ||= 1) === 1) {
|
1036
|
+
if (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp) {
|
1037
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN);
|
1038
|
+
} else {
|
1039
|
+
scope[valueAccessor] = valueOrOp;
|
1040
|
+
fn && fn(scope, valueOrOp);
|
1041
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY);
|
1042
|
+
}
|
1094
1043
|
}
|
1044
|
+
scope[markAccessor]--;
|
1095
1045
|
}
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1046
|
+
};
|
1047
|
+
}
|
1048
|
+
var accessorId = 0;
|
1049
|
+
function intersection(count, fn, getIntersection) {
|
1050
|
+
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
1051
|
+
const markAccessor = dirtyAccessor + "#" /* Mark */;
|
1052
|
+
let intersection2;
|
1053
|
+
return (scope, op) => {
|
1054
|
+
if (op === MARK) {
|
1055
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1056
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
|
1099
1057
|
}
|
1100
|
-
|
1101
|
-
|
1058
|
+
} else if (scope[markAccessor] === void 0) {
|
1059
|
+
scope[markAccessor] = count - 1;
|
1060
|
+
scope[dirtyAccessor] = true;
|
1061
|
+
} else if (--scope[markAccessor] === 0) {
|
1062
|
+
if (op === DIRTY || scope[dirtyAccessor]) {
|
1063
|
+
scope[dirtyAccessor] = false;
|
1064
|
+
fn(scope);
|
1065
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY);
|
1066
|
+
} else {
|
1067
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN);
|
1102
1068
|
}
|
1103
1069
|
} else {
|
1104
|
-
|
1105
|
-
while (i > 0) {
|
1106
|
-
oldBranch = aNullable[oldStart++];
|
1107
|
-
if (oldBranch !== null) {
|
1108
|
-
removeAndDestroyBranch(oldBranch);
|
1109
|
-
i--;
|
1110
|
-
}
|
1111
|
-
}
|
1112
|
-
if (pos === WRONG_POS) {
|
1113
|
-
const seq = longestIncreasingSubsequence(sources);
|
1114
|
-
j = seq.length - 1;
|
1115
|
-
k = newBranches.length;
|
1116
|
-
for (i = newLength - 1; i >= 0; --i) {
|
1117
|
-
if (sources[i] === -1) {
|
1118
|
-
pos = i + newStart;
|
1119
|
-
newBranch = newBranches[pos++];
|
1120
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1121
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
1122
|
-
} else {
|
1123
|
-
if (j < 0 || i !== seq[j]) {
|
1124
|
-
pos = i + newStart;
|
1125
|
-
newBranch = newBranches[pos++];
|
1126
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1127
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
1128
|
-
} else {
|
1129
|
-
--j;
|
1130
|
-
}
|
1131
|
-
}
|
1132
|
-
}
|
1133
|
-
} else if (synced !== newLength) {
|
1134
|
-
k = newBranches.length;
|
1135
|
-
for (i = newLength - 1; i >= 0; --i) {
|
1136
|
-
if (sources[i] === -1) {
|
1137
|
-
pos = i + newStart;
|
1138
|
-
newBranch = newBranches[pos++];
|
1139
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1140
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
1141
|
-
}
|
1142
|
-
}
|
1143
|
-
}
|
1070
|
+
scope[dirtyAccessor] ||= op === DIRTY;
|
1144
1071
|
}
|
1145
|
-
}
|
1072
|
+
};
|
1146
1073
|
}
|
1147
|
-
function
|
1074
|
+
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn, getIntersection) {
|
1075
|
+
const childSignal = closure(valueAccessor, fn, getIntersection);
|
1076
|
+
const loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */;
|
1077
|
+
const loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */;
|
1078
|
+
const ownerSignal = (ownerScope) => {
|
1079
|
+
for (const scope of ownerScope[loopScopeAccessor] || ownerScope[loopScopeMapAccessor]?.values() || []) {
|
1080
|
+
if (!scope.___pending) {
|
1081
|
+
queueSource(scope, childSignal);
|
1082
|
+
}
|
1083
|
+
}
|
1084
|
+
};
|
1085
|
+
ownerSignal._ = childSignal;
|
1086
|
+
return ownerSignal;
|
1087
|
+
}
|
1088
|
+
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1089
|
+
const childSignal = closure(valueAccessor, fn, getIntersection);
|
1090
|
+
const scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */;
|
1091
|
+
const branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */;
|
1092
|
+
const ownerSignal = (scope) => {
|
1093
|
+
const ifScope = scope[scopeAccessor];
|
1094
|
+
if (ifScope && !ifScope.___pending && scope[branchAccessor] === branch) {
|
1095
|
+
queueSource(ifScope, childSignal);
|
1096
|
+
}
|
1097
|
+
};
|
1098
|
+
ownerSignal._ = childSignal;
|
1099
|
+
return ownerSignal;
|
1100
|
+
}
|
1101
|
+
function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
1102
|
+
const subscribersAccessor = "?" /* Dynamic */ + accessorId++;
|
1103
|
+
const childSignal = closure(
|
1104
|
+
valueAccessor,
|
1105
|
+
fn,
|
1106
|
+
getIntersection,
|
1107
|
+
getOwnerScope
|
1108
|
+
);
|
1109
|
+
const ownerSignal = (ownerScope) => {
|
1110
|
+
const subscribers = ownerScope[subscribersAccessor];
|
1111
|
+
if (subscribers) {
|
1112
|
+
for (const subscriber of subscribers) {
|
1113
|
+
if (!subscriber.___pending) {
|
1114
|
+
queueSource(subscriber, childSignal);
|
1115
|
+
}
|
1116
|
+
}
|
1117
|
+
}
|
1118
|
+
};
|
1119
|
+
const subscribe = (scope) => {
|
1120
|
+
const owner = getOwnerScope ? getOwnerScope(scope) : scope._;
|
1121
|
+
const subscribers = owner[subscribersAccessor] ||= /* @__PURE__ */ new Set();
|
1122
|
+
if (!subscribers.has(scope)) {
|
1123
|
+
subscribers.add(scope);
|
1124
|
+
getAbortSignal(scope, -1).addEventListener(
|
1125
|
+
"abort",
|
1126
|
+
() => subscribers.delete(scope)
|
1127
|
+
);
|
1128
|
+
}
|
1129
|
+
};
|
1130
|
+
ownerSignal.___subscribe = subscribe;
|
1131
|
+
ownerSignal._ = (scope) => {
|
1132
|
+
childSignal(scope);
|
1133
|
+
subscribe(scope);
|
1134
|
+
};
|
1135
|
+
return ownerSignal;
|
1136
|
+
}
|
1137
|
+
function registerDynamicClosure(id, valueAccessor, fn, getIntersection, getOwnerScope) {
|
1138
|
+
const signal = dynamicClosure(
|
1139
|
+
valueAccessor,
|
1140
|
+
fn,
|
1141
|
+
getIntersection,
|
1142
|
+
getOwnerScope
|
1143
|
+
);
|
1144
|
+
register(id, signal.___subscribe);
|
1145
|
+
return signal;
|
1146
|
+
}
|
1147
|
+
function closure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
1148
|
+
let intersection2;
|
1149
|
+
return (scope, op) => {
|
1150
|
+
op || fn && fn(
|
1151
|
+
scope,
|
1152
|
+
(getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
|
1153
|
+
);
|
1154
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, op ? MARK : DIRTY);
|
1155
|
+
};
|
1156
|
+
}
|
1157
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1158
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1159
|
+
}
|
1160
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1161
|
+
function setTagVarChange(scope, changeHandler) {
|
1162
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
1163
|
+
}
|
1164
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1165
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1166
|
+
function nextTagId({ $global }) {
|
1167
|
+
const id = tagIdsByGlobal.get($global) || 0;
|
1168
|
+
tagIdsByGlobal.set($global, id + 1);
|
1169
|
+
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1170
|
+
}
|
1171
|
+
function inChild(childAccessor, signal) {
|
1172
|
+
return (scope, valueOrOp) => {
|
1173
|
+
signal(scope[childAccessor], valueOrOp);
|
1174
|
+
};
|
1175
|
+
}
|
1176
|
+
function intersections(signals) {
|
1177
|
+
return (scope, op) => {
|
1178
|
+
for (const signal of signals) {
|
1179
|
+
signal(scope, op);
|
1180
|
+
}
|
1181
|
+
};
|
1182
|
+
}
|
1183
|
+
function effect(id, fn) {
|
1184
|
+
register(id, fn);
|
1185
|
+
return (scope) => {
|
1186
|
+
queueEffect(scope, fn);
|
1187
|
+
};
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
// src/dom/queue.ts
|
1191
|
+
var pendingRenders = [];
|
1192
|
+
var pendingEffects = [];
|
1193
|
+
var rendering = false;
|
1194
|
+
function queueSource(scope, signal, value2) {
|
1195
|
+
const prevRendering = rendering;
|
1196
|
+
rendering = true;
|
1197
|
+
signal(scope, MARK);
|
1198
|
+
rendering = prevRendering;
|
1199
|
+
queueRender(scope, signal, value2);
|
1200
|
+
}
|
1201
|
+
function queueRender(scope, signal, value2) {
|
1202
|
+
let i = pendingRenders.length;
|
1203
|
+
const render = {
|
1204
|
+
___scope: scope,
|
1205
|
+
___signal: signal,
|
1206
|
+
___value: value2,
|
1207
|
+
___depth: scope.___closestBranch?.___branchDepth || 0,
|
1208
|
+
___index: i
|
1209
|
+
};
|
1210
|
+
pendingRenders.push(render);
|
1211
|
+
while (i) {
|
1212
|
+
const parentIndex = i - 1 >> 1;
|
1213
|
+
const parent = pendingRenders[parentIndex];
|
1214
|
+
if (comparePendingRenders(render, parent) >= 0) break;
|
1215
|
+
pendingRenders[i] = parent;
|
1216
|
+
i = parentIndex;
|
1217
|
+
}
|
1218
|
+
pendingRenders[i] = render;
|
1219
|
+
}
|
1220
|
+
function queueEffect(scope, fn) {
|
1221
|
+
pendingEffects.push(scope, fn);
|
1222
|
+
}
|
1223
|
+
function run() {
|
1224
|
+
const effects = pendingEffects;
|
1225
|
+
try {
|
1226
|
+
rendering = true;
|
1227
|
+
runRenders();
|
1228
|
+
} finally {
|
1229
|
+
pendingRenders = [];
|
1230
|
+
pendingEffects = [];
|
1231
|
+
rendering = false;
|
1232
|
+
}
|
1233
|
+
runEffects(effects);
|
1234
|
+
}
|
1235
|
+
function prepareEffects(fn) {
|
1236
|
+
const prevRenders = pendingRenders;
|
1237
|
+
const prevEffects = pendingEffects;
|
1238
|
+
const preparedEffects = pendingEffects = [];
|
1239
|
+
pendingRenders = [];
|
1240
|
+
try {
|
1241
|
+
rendering = true;
|
1242
|
+
fn();
|
1243
|
+
runRenders();
|
1244
|
+
} finally {
|
1245
|
+
rendering = false;
|
1246
|
+
pendingRenders = prevRenders;
|
1247
|
+
pendingEffects = prevEffects;
|
1248
|
+
}
|
1249
|
+
return preparedEffects;
|
1250
|
+
}
|
1251
|
+
function runEffects(effects) {
|
1252
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1253
|
+
const scope = effects[i];
|
1254
|
+
const fn = effects[i + 1];
|
1255
|
+
fn(scope, scope);
|
1256
|
+
}
|
1257
|
+
}
|
1258
|
+
function runRenders() {
|
1259
|
+
while (pendingRenders.length) {
|
1260
|
+
const render = pendingRenders[0];
|
1261
|
+
const next = pendingRenders.pop();
|
1262
|
+
if (render !== next) {
|
1263
|
+
let i = 0;
|
1264
|
+
const mid = pendingRenders.length >> 1;
|
1265
|
+
const item = pendingRenders[0] = next;
|
1266
|
+
while (i < mid) {
|
1267
|
+
let bestChild = (i << 1) + 1;
|
1268
|
+
const right = bestChild + 1;
|
1269
|
+
if (right < pendingRenders.length && comparePendingRenders(
|
1270
|
+
pendingRenders[right],
|
1271
|
+
pendingRenders[bestChild]
|
1272
|
+
) < 0) {
|
1273
|
+
bestChild = right;
|
1274
|
+
}
|
1275
|
+
if (comparePendingRenders(pendingRenders[bestChild], item) >= 0) {
|
1276
|
+
break;
|
1277
|
+
} else {
|
1278
|
+
pendingRenders[i] = pendingRenders[bestChild];
|
1279
|
+
i = bestChild;
|
1280
|
+
}
|
1281
|
+
}
|
1282
|
+
pendingRenders[i] = item;
|
1283
|
+
}
|
1284
|
+
if (!render.___scope.___closestBranch?.___destroyed) {
|
1285
|
+
render.___signal(render.___scope, render.___value);
|
1286
|
+
}
|
1287
|
+
}
|
1288
|
+
finishPendingScopes();
|
1289
|
+
}
|
1290
|
+
function comparePendingRenders(a, b) {
|
1291
|
+
return a.___depth - b.___depth || a.___index - b.___index;
|
1292
|
+
}
|
1293
|
+
|
1294
|
+
// src/dom/abort-signal.ts
|
1295
|
+
function resetAbortSignal(scope, id) {
|
1296
|
+
const ctrl = scope.___abortControllers?.[id];
|
1297
|
+
if (ctrl) {
|
1298
|
+
queueEffect(ctrl, abort);
|
1299
|
+
scope.___abortControllers[id] = void 0;
|
1300
|
+
}
|
1301
|
+
}
|
1302
|
+
function getAbortSignal(scope, id) {
|
1303
|
+
if (scope.___closestBranch) {
|
1304
|
+
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1305
|
+
}
|
1306
|
+
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1307
|
+
}
|
1308
|
+
function abort(ctrl) {
|
1309
|
+
ctrl.abort();
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
// src/common/compat-meta.ts
|
1313
|
+
var prefix = true ? "$compat_" : "$C_";
|
1314
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1315
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1316
|
+
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
1317
|
+
|
1318
|
+
// src/dom/reconcile.ts
|
1319
|
+
var WRONG_POS = 2147483647;
|
1320
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
1321
|
+
let oldStart = 0;
|
1322
|
+
let newStart = 0;
|
1323
|
+
let oldEnd = oldBranches.length - 1;
|
1324
|
+
let newEnd = newBranches.length - 1;
|
1325
|
+
let oldStartBranch = oldBranches[oldStart];
|
1326
|
+
let newStartBranch = newBranches[newStart];
|
1327
|
+
let oldEndBranch = oldBranches[oldEnd];
|
1328
|
+
let newEndBranch = newBranches[newEnd];
|
1329
|
+
let i;
|
1330
|
+
let j;
|
1331
|
+
let k;
|
1332
|
+
let nextSibling;
|
1333
|
+
let oldBranch;
|
1334
|
+
let newBranch;
|
1335
|
+
outer: {
|
1336
|
+
while (oldStartBranch === newStartBranch) {
|
1337
|
+
++oldStart;
|
1338
|
+
++newStart;
|
1339
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
1340
|
+
break outer;
|
1341
|
+
}
|
1342
|
+
oldStartBranch = oldBranches[oldStart];
|
1343
|
+
newStartBranch = newBranches[newStart];
|
1344
|
+
}
|
1345
|
+
while (oldEndBranch === newEndBranch) {
|
1346
|
+
--oldEnd;
|
1347
|
+
--newEnd;
|
1348
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
1349
|
+
break outer;
|
1350
|
+
}
|
1351
|
+
oldEndBranch = oldBranches[oldEnd];
|
1352
|
+
newEndBranch = newBranches[newEnd];
|
1353
|
+
}
|
1354
|
+
}
|
1355
|
+
if (oldStart > oldEnd) {
|
1356
|
+
if (newStart <= newEnd) {
|
1357
|
+
k = newEnd + 1;
|
1358
|
+
nextSibling = k < newBranches.length ? newBranches[k].___startNode : afterReference;
|
1359
|
+
do {
|
1360
|
+
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
1361
|
+
} while (newStart <= newEnd);
|
1362
|
+
}
|
1363
|
+
} else if (newStart > newEnd) {
|
1364
|
+
do {
|
1365
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
1366
|
+
} while (oldStart <= oldEnd);
|
1367
|
+
} else {
|
1368
|
+
const oldLength = oldEnd - oldStart + 1;
|
1369
|
+
const newLength = newEnd - newStart + 1;
|
1370
|
+
const aNullable = oldBranches;
|
1371
|
+
const sources = new Array(newLength);
|
1372
|
+
for (i = 0; i < newLength; ++i) {
|
1373
|
+
sources[i] = -1;
|
1374
|
+
}
|
1375
|
+
let pos = 0;
|
1376
|
+
let synced = 0;
|
1377
|
+
const keyIndex = /* @__PURE__ */ new Map();
|
1378
|
+
for (j = newStart; j <= newEnd; ++j) {
|
1379
|
+
keyIndex.set(newBranches[j], j);
|
1380
|
+
}
|
1381
|
+
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
1382
|
+
oldBranch = oldBranches[i];
|
1383
|
+
j = keyIndex.get(oldBranch);
|
1384
|
+
if (j !== void 0) {
|
1385
|
+
pos = pos > j ? WRONG_POS : j;
|
1386
|
+
++synced;
|
1387
|
+
newBranch = newBranches[j];
|
1388
|
+
sources[j - newStart] = i;
|
1389
|
+
aNullable[i] = null;
|
1390
|
+
}
|
1391
|
+
}
|
1392
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
1393
|
+
for (; newStart < newLength; ++newStart) {
|
1394
|
+
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
1395
|
+
}
|
1396
|
+
for (; oldStart < oldLength; ++oldStart) {
|
1397
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
1398
|
+
}
|
1399
|
+
} else {
|
1400
|
+
i = oldLength - synced;
|
1401
|
+
while (i > 0) {
|
1402
|
+
oldBranch = aNullable[oldStart++];
|
1403
|
+
if (oldBranch !== null) {
|
1404
|
+
removeAndDestroyBranch(oldBranch);
|
1405
|
+
i--;
|
1406
|
+
}
|
1407
|
+
}
|
1408
|
+
if (pos === WRONG_POS) {
|
1409
|
+
const seq = longestIncreasingSubsequence(sources);
|
1410
|
+
j = seq.length - 1;
|
1411
|
+
k = newBranches.length;
|
1412
|
+
for (i = newLength - 1; i >= 0; --i) {
|
1413
|
+
if (sources[i] === -1) {
|
1414
|
+
pos = i + newStart;
|
1415
|
+
newBranch = newBranches[pos++];
|
1416
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1417
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1418
|
+
} else {
|
1419
|
+
if (j < 0 || i !== seq[j]) {
|
1420
|
+
pos = i + newStart;
|
1421
|
+
newBranch = newBranches[pos++];
|
1422
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1423
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1424
|
+
} else {
|
1425
|
+
--j;
|
1426
|
+
}
|
1427
|
+
}
|
1428
|
+
}
|
1429
|
+
} else if (synced !== newLength) {
|
1430
|
+
k = newBranches.length;
|
1431
|
+
for (i = newLength - 1; i >= 0; --i) {
|
1432
|
+
if (sources[i] === -1) {
|
1433
|
+
pos = i + newStart;
|
1434
|
+
newBranch = newBranches[pos++];
|
1435
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1436
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1437
|
+
}
|
1438
|
+
}
|
1439
|
+
}
|
1440
|
+
}
|
1441
|
+
}
|
1442
|
+
}
|
1443
|
+
function longestIncreasingSubsequence(a) {
|
1148
1444
|
const p = a.slice();
|
1149
|
-
const result = [];
|
1150
|
-
result.push(0);
|
1445
|
+
const result = [0];
|
1151
1446
|
let u;
|
1152
1447
|
let v;
|
1153
1448
|
for (let i = 0, il = a.length; i < il; ++i) {
|
@@ -1195,55 +1490,54 @@ function trimWalkString(walkString) {
|
|
1195
1490
|
}
|
1196
1491
|
function walk(startNode, walkCodes, branch) {
|
1197
1492
|
walker.currentNode = startNode;
|
1198
|
-
walkInternal(walkCodes, branch
|
1199
|
-
walker.currentNode = document;
|
1493
|
+
walkInternal(0, walkCodes, branch);
|
1200
1494
|
}
|
1201
|
-
function walkInternal(walkCodes, scope
|
1495
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
1202
1496
|
let value2;
|
1203
1497
|
let storedMultiplier = 0;
|
1204
1498
|
let currentMultiplier = 0;
|
1205
1499
|
let currentScopeIndex = 0;
|
1206
|
-
|
1500
|
+
for (; currentWalkIndex < walkCodes.length; ) {
|
1501
|
+
value2 = walkCodes.charCodeAt(currentWalkIndex++);
|
1207
1502
|
currentMultiplier = storedMultiplier;
|
1208
1503
|
storedMultiplier = 0;
|
1209
|
-
if (value2
|
1210
|
-
|
1211
|
-
} else if (value2
|
1212
|
-
|
1504
|
+
if (value2 === 32 /* Get */) {
|
1505
|
+
scope[true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++] = walker.currentNode;
|
1506
|
+
} else if (value2 === 37 /* Replace */) {
|
1507
|
+
walker.currentNode.replaceWith(
|
1508
|
+
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text()
|
1509
|
+
);
|
1510
|
+
} else if (value2 === 38 /* EndChild */) {
|
1511
|
+
return currentWalkIndex;
|
1512
|
+
} else if (value2 === 47 /* BeginChild */) {
|
1513
|
+
currentWalkIndex = walkInternal(
|
1514
|
+
currentWalkIndex,
|
1515
|
+
walkCodes,
|
1516
|
+
scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global, scope.___closestBranch)
|
1517
|
+
);
|
1518
|
+
} else if (value2 < 91 /* NextEnd */ + 1) {
|
1519
|
+
value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */;
|
1213
1520
|
while (value2--) {
|
1214
|
-
walker.
|
1521
|
+
walker.nextNode();
|
1215
1522
|
}
|
1216
|
-
|
1217
|
-
} else if (value2 >= 97 /* Over */) {
|
1523
|
+
} else if (value2 < 106 /* OverEnd */ + 1) {
|
1218
1524
|
value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */;
|
1219
1525
|
while (value2--) {
|
1220
1526
|
walker.nextSibling();
|
1221
1527
|
}
|
1222
|
-
} else if (value2
|
1223
|
-
value2 =
|
1528
|
+
} else if (value2 < 116 /* OutEnd */ + 1) {
|
1529
|
+
value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */;
|
1224
1530
|
while (value2--) {
|
1225
|
-
walker.
|
1531
|
+
walker.parentNode();
|
1226
1532
|
}
|
1227
|
-
|
1228
|
-
const childScope = scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global);
|
1229
|
-
childScope.___closestBranch = scope.___closestBranch;
|
1230
|
-
currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
1231
|
-
} else if (value2 === 38 /* EndChild */) {
|
1232
|
-
return currentWalkIndex;
|
1233
|
-
} else if (value2 === 32 /* Get */) {
|
1234
|
-
scope[true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++] = walker.currentNode;
|
1533
|
+
walker.nextSibling();
|
1235
1534
|
} else {
|
1236
|
-
|
1237
|
-
const current = walker.currentNode;
|
1238
|
-
const parentNode = current.parentNode;
|
1239
|
-
if (value2 !== 37 /* Replace */) {
|
1535
|
+
if (value2 < 117 /* Multiplier */ || value2 > 126 /* MultiplierEnd */) {
|
1240
1536
|
throw new Error(`Unknown walk code: ${value2}`);
|
1241
1537
|
}
|
1242
|
-
|
1243
|
-
walker.currentNode = newNode;
|
1538
|
+
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
1244
1539
|
}
|
1245
1540
|
}
|
1246
|
-
return currentWalkIndex;
|
1247
1541
|
}
|
1248
1542
|
function getDebugKey(index, node) {
|
1249
1543
|
if (typeof node === "string") {
|
@@ -1304,9 +1598,14 @@ function createBranch($global, ownerScope, parentScope) {
|
|
1304
1598
|
function initBranch(renderer, branch, parentNode) {
|
1305
1599
|
const clone = renderer.___clone(parentNode.namespaceURI);
|
1306
1600
|
const cloneParent = clone.parentNode;
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1601
|
+
if (cloneParent) {
|
1602
|
+
walk(cloneParent.firstChild, renderer.___walks, branch);
|
1603
|
+
branch.___startNode = cloneParent.firstChild;
|
1604
|
+
branch.___endNode = cloneParent.lastChild;
|
1605
|
+
} else {
|
1606
|
+
walk(clone, renderer.___walks, branch);
|
1607
|
+
branch.___startNode = branch.___endNode = clone;
|
1608
|
+
}
|
1310
1609
|
if (renderer.___setup) {
|
1311
1610
|
queueRender(branch, renderer.___setup);
|
1312
1611
|
}
|
@@ -1329,7 +1628,7 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
1329
1628
|
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
1330
1629
|
);
|
1331
1630
|
}
|
1332
|
-
|
1631
|
+
setConditionalRenderer(
|
1333
1632
|
childScope,
|
1334
1633
|
nodeAccessor2,
|
1335
1634
|
content,
|
@@ -1350,541 +1649,197 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
1350
1649
|
}
|
1351
1650
|
};
|
1352
1651
|
}
|
1353
|
-
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
1354
|
-
let args;
|
1355
|
-
const id = true ? Symbol("Marko Renderer") : {};
|
1356
|
-
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
1357
|
-
return (owner) => {
|
1358
|
-
return {
|
1359
|
-
___id: id,
|
1360
|
-
___template: template,
|
1361
|
-
___walks: walks,
|
1362
|
-
___setup: setup,
|
1363
|
-
___clone: _clone,
|
1364
|
-
___owner: owner,
|
1365
|
-
get ___args() {
|
1366
|
-
return args ||= getArgs?.();
|
1367
|
-
}
|
1368
|
-
};
|
1369
|
-
};
|
1370
|
-
}
|
1371
|
-
function createRenderer(template, walks, setup, getArgs) {
|
1372
|
-
return createRendererWithOwner(template, walks, setup, getArgs)();
|
1373
|
-
}
|
1374
|
-
function _clone(ns) {
|
1375
|
-
return ((cloneCache[ns] ||= {})[this.___template] ||= createCloneableHTML(
|
1376
|
-
this.___template,
|
1377
|
-
ns
|
1378
|
-
))();
|
1379
|
-
}
|
1380
|
-
var cloneCache = {};
|
1381
|
-
function createCloneableHTML(html2, ns) {
|
1382
|
-
const { firstChild, lastChild } = parseHTML(html2, ns);
|
1383
|
-
const parent = document.createElementNS(ns, "t");
|
1384
|
-
insertChildNodes(parent, null, firstChild, lastChild);
|
1385
|
-
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? () => firstChild.cloneNode(true) : () => parent.cloneNode(true).firstChild;
|
1386
|
-
}
|
1387
|
-
|
1388
|
-
// src/dom/control-flow.ts
|
1389
|
-
function conditional(nodeAccessor, ...branches) {
|
1390
|
-
const branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1391
|
-
return (scope, newBranchIndexOrOp) => {
|
1392
|
-
if (newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN) {
|
1393
|
-
(scope[nodeAccessor].nodeType > 1 /* Element */ ? setConditionalRenderer : setConditionalRendererOnlyChild)(
|
1394
|
-
scope,
|
1395
|
-
nodeAccessor,
|
1396
|
-
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
1397
|
-
createBranchScopeWithRenderer
|
1398
|
-
);
|
1399
|
-
}
|
1400
|
-
};
|
1401
|
-
}
|
1402
|
-
function patchDynamicTag(fn) {
|
1403
|
-
dynamicTag = fn(dynamicTag);
|
1404
|
-
}
|
1405
|
-
var dynamicTag = function dynamicTag2(nodeAccessor, fn, getIntersection) {
|
1406
|
-
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1407
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1408
|
-
return (scope, newRendererOrOp) => {
|
1409
|
-
if (newRendererOrOp === DIRTY) return;
|
1410
|
-
const currentRenderer = scope[rendererAccessor];
|
1411
|
-
let op = newRendererOrOp;
|
1412
|
-
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1413
|
-
const normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1414
|
-
if (isDifferentRenderer(normalizedRenderer, currentRenderer)) {
|
1415
|
-
scope[rendererAccessor] = normalizedRenderer;
|
1416
|
-
setConditionalRenderer(
|
1417
|
-
scope,
|
1418
|
-
nodeAccessor,
|
1419
|
-
normalizedRenderer,
|
1420
|
-
createBranchScopeWithTagNameOrRenderer
|
1421
|
-
);
|
1422
|
-
fn && fn(scope);
|
1423
|
-
op = DIRTY;
|
1424
|
-
} else {
|
1425
|
-
op = CLEAN;
|
1426
|
-
}
|
1427
|
-
}
|
1428
|
-
intersection2?.(scope, op);
|
1429
|
-
};
|
1430
|
-
};
|
1431
|
-
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1432
|
-
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]);
|
1433
|
-
const newBranch = newRenderer ? createBranch2(
|
1434
|
-
newRenderer,
|
1435
|
-
scope.$global,
|
1436
|
-
scope,
|
1437
|
-
prevBranch.___endNode.parentNode
|
1438
|
-
) : getEmptyBranch(scope[nodeAccessor]);
|
1439
|
-
if (prevBranch !== newBranch) {
|
1440
|
-
insertBranchBefore(
|
1441
|
-
newBranch,
|
1442
|
-
prevBranch.___endNode.parentNode,
|
1443
|
-
prevBranch.___endNode.nextSibling
|
1444
|
-
);
|
1445
|
-
removeAndDestroyBranch(prevBranch);
|
1446
|
-
scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
1447
|
-
}
|
1448
|
-
}
|
1449
|
-
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer, createBranch2) {
|
1450
|
-
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1451
|
-
const referenceNode = scope[nodeAccessor];
|
1452
|
-
const newBranch = newRenderer && createBranch2(newRenderer, scope.$global, scope, referenceNode);
|
1453
|
-
referenceNode.textContent = "";
|
1454
|
-
if (newBranch) {
|
1455
|
-
insertBranchBefore(newBranch, referenceNode, null);
|
1456
|
-
}
|
1457
|
-
prevBranch && destroyBranch(prevBranch);
|
1458
|
-
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1459
|
-
}
|
1460
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1461
|
-
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
1462
|
-
]);
|
1463
|
-
var emptyMarkerArray = [
|
1464
|
-
/* @__PURE__ */ getEmptyBranch(0)
|
1465
|
-
];
|
1466
|
-
var emptyMap = /* @__PURE__ */ new Map();
|
1467
|
-
var emptyArray = [];
|
1468
|
-
function loopOf(nodeAccessor, renderer) {
|
1469
|
-
return loop(
|
1470
|
-
nodeAccessor,
|
1471
|
-
renderer,
|
1472
|
-
([all, by = bySecondArg], cb) => {
|
1473
|
-
if (typeof by === "string") {
|
1474
|
-
forOf(
|
1475
|
-
all,
|
1476
|
-
(item, i) => cb(item[by], [item, i])
|
1477
|
-
);
|
1478
|
-
} else {
|
1479
|
-
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
1480
|
-
}
|
1481
|
-
}
|
1482
|
-
);
|
1483
|
-
}
|
1484
|
-
function loopIn(nodeAccessor, renderer) {
|
1485
|
-
return loop(
|
1486
|
-
nodeAccessor,
|
1487
|
-
renderer,
|
1488
|
-
([obj, by = byFirstArg], cb) => forIn(obj, (key, value2) => cb(by(key, value2), [key, value2]))
|
1489
|
-
);
|
1490
|
-
}
|
1491
|
-
function loopTo(nodeAccessor, renderer) {
|
1492
|
-
return loop(
|
1493
|
-
nodeAccessor,
|
1494
|
-
renderer,
|
1495
|
-
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
1496
|
-
);
|
1497
|
-
}
|
1498
|
-
function loop(nodeAccessor, renderer, forEach) {
|
1499
|
-
const loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */;
|
1500
|
-
const params = renderer.___args;
|
1501
|
-
return (scope, valueOrOp) => {
|
1502
|
-
if (valueOrOp === DIRTY) return;
|
1503
|
-
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1504
|
-
const loopBranches = scope[loopScopeAccessor] ?? scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1505
|
-
if (loopBranches !== emptyMarkerArray) {
|
1506
|
-
for (const branch of loopBranches) {
|
1507
|
-
params?.(branch, valueOrOp);
|
1508
|
-
}
|
1509
|
-
}
|
1510
|
-
return;
|
1511
|
-
}
|
1512
|
-
const referenceNode = scope[nodeAccessor];
|
1513
|
-
const referenceIsMarker = referenceNode.nodeType > 1 /* Element */;
|
1514
|
-
const oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */] || (referenceIsMarker ? emptyMarkerMap : emptyMap);
|
1515
|
-
const oldArray = scope[nodeAccessor + "!" /* LoopScopeArray */] || Array.from(oldMap.values());
|
1516
|
-
const parentNode = referenceIsMarker ? referenceNode.parentNode || oldArray[0].___startNode.parentNode : referenceNode;
|
1517
|
-
let newMap;
|
1518
|
-
let newArray;
|
1519
|
-
let afterReference;
|
1520
|
-
let needsReconciliation = true;
|
1521
|
-
forEach(valueOrOp, (key, args) => {
|
1522
|
-
let branch = oldMap.get(key);
|
1523
|
-
if (!branch) {
|
1524
|
-
branch = createBranchScopeWithRenderer(
|
1525
|
-
renderer,
|
1526
|
-
scope.$global,
|
1527
|
-
scope,
|
1528
|
-
parentNode
|
1529
|
-
);
|
1530
|
-
} else {
|
1531
|
-
}
|
1532
|
-
if (params) {
|
1533
|
-
params(branch, args);
|
1534
|
-
}
|
1535
|
-
if (newMap) {
|
1536
|
-
newMap.set(key, branch);
|
1537
|
-
newArray.push(branch);
|
1538
|
-
} else {
|
1539
|
-
newMap = /* @__PURE__ */ new Map([[key, branch]]);
|
1540
|
-
newArray = [branch];
|
1541
|
-
}
|
1542
|
-
});
|
1543
|
-
if (!newMap) {
|
1544
|
-
if (referenceIsMarker) {
|
1545
|
-
newMap = emptyMarkerMap;
|
1546
|
-
newArray = emptyMarkerArray;
|
1547
|
-
getEmptyBranch(referenceNode);
|
1548
|
-
} else {
|
1549
|
-
oldArray.forEach(destroyBranch);
|
1550
|
-
referenceNode.textContent = "";
|
1551
|
-
newMap = emptyMap;
|
1552
|
-
newArray = emptyArray;
|
1553
|
-
needsReconciliation = false;
|
1554
|
-
}
|
1555
|
-
}
|
1556
|
-
if (needsReconciliation) {
|
1557
|
-
if (referenceIsMarker) {
|
1558
|
-
if (oldMap === emptyMarkerMap) {
|
1559
|
-
getEmptyBranch(referenceNode);
|
1560
|
-
}
|
1561
|
-
const oldLastChild = oldArray[oldArray.length - 1];
|
1562
|
-
afterReference = oldLastChild.___endNode.nextSibling;
|
1563
|
-
} else {
|
1564
|
-
afterReference = null;
|
1565
|
-
}
|
1566
|
-
reconcile(parentNode, oldArray, newArray, afterReference);
|
1567
|
-
}
|
1568
|
-
scope[nodeAccessor + "(" /* LoopScopeMap */] = newMap;
|
1569
|
-
scope[nodeAccessor + "!" /* LoopScopeArray */] = newArray;
|
1570
|
-
};
|
1571
|
-
}
|
1572
|
-
function bySecondArg(_item, index) {
|
1573
|
-
return index;
|
1574
|
-
}
|
1575
|
-
function byFirstArg(name) {
|
1576
|
-
return name;
|
1577
|
-
}
|
1578
|
-
function isDifferentRenderer(a, b) {
|
1579
|
-
return a !== b && (a?.___id || 0) !== b?.___id;
|
1580
|
-
}
|
1581
|
-
|
1582
|
-
// src/dom/signals.ts
|
1583
|
-
var MARK = true ? Symbol("mark") : {};
|
1584
|
-
var CLEAN = true ? Symbol("clean") : {};
|
1585
|
-
var DIRTY = true ? Symbol("dirty") : {};
|
1586
|
-
function state(valueAccessor, fn, getIntersection) {
|
1587
|
-
const valueSignal = value(valueAccessor, fn, getIntersection);
|
1588
|
-
const markAccessor = valueAccessor + "#" /* Mark */;
|
1589
|
-
const valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1590
|
-
return (scope, valueOrOp, valueChange) => {
|
1591
|
-
if (rendering) {
|
1592
|
-
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
1593
|
-
valueSignal(
|
1594
|
-
scope,
|
1595
|
-
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1596
|
-
);
|
1597
|
-
} else if (scope[valueChangeAccessor]) {
|
1598
|
-
scope[valueChangeAccessor](valueOrOp);
|
1599
|
-
} else {
|
1600
|
-
queueSource(scope, valueSignal, valueOrOp);
|
1601
|
-
}
|
1602
|
-
return valueOrOp;
|
1603
|
-
};
|
1604
|
-
}
|
1605
|
-
function value(valueAccessor, fn, getIntersection) {
|
1606
|
-
const markAccessor = valueAccessor + "#" /* Mark */;
|
1607
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1608
|
-
return (scope, valueOrOp) => {
|
1609
|
-
if (valueOrOp === MARK) {
|
1610
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1611
|
-
intersection2?.(scope, MARK);
|
1612
|
-
}
|
1613
|
-
} else if (valueOrOp !== DIRTY) {
|
1614
|
-
const existing = scope[markAccessor] !== void 0;
|
1615
|
-
if ((scope[markAccessor] ||= 1) === 1) {
|
1616
|
-
if (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp) {
|
1617
|
-
intersection2?.(scope, CLEAN);
|
1618
|
-
} else {
|
1619
|
-
scope[valueAccessor] = valueOrOp;
|
1620
|
-
fn && fn(scope, valueOrOp);
|
1621
|
-
intersection2?.(scope, DIRTY);
|
1622
|
-
}
|
1623
|
-
}
|
1624
|
-
scope[markAccessor]--;
|
1625
|
-
}
|
1626
|
-
};
|
1627
|
-
}
|
1628
|
-
var accessorId = 0;
|
1629
|
-
function intersection(count, fn, getIntersection) {
|
1630
|
-
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
1631
|
-
const markAccessor = dirtyAccessor + "#" /* Mark */;
|
1632
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1633
|
-
return (scope, op) => {
|
1634
|
-
if (op === MARK) {
|
1635
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1636
|
-
intersection2?.(scope, MARK);
|
1637
|
-
}
|
1638
|
-
} else if (scope[markAccessor] === void 0) {
|
1639
|
-
scope[markAccessor] = count - 1;
|
1640
|
-
scope[dirtyAccessor] = true;
|
1641
|
-
} else if (--scope[markAccessor] === 0) {
|
1642
|
-
if (op === DIRTY || scope[dirtyAccessor]) {
|
1643
|
-
scope[dirtyAccessor] = false;
|
1644
|
-
fn(scope, 0);
|
1645
|
-
intersection2?.(scope, DIRTY);
|
1646
|
-
} else {
|
1647
|
-
intersection2?.(scope, CLEAN);
|
1648
|
-
}
|
1649
|
-
} else {
|
1650
|
-
scope[dirtyAccessor] ||= op === DIRTY;
|
1651
|
-
}
|
1652
|
-
};
|
1653
|
-
}
|
1654
|
-
function closure(fn, getIntersection) {
|
1655
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1656
|
-
return (scope, valueOrOp) => {
|
1657
|
-
if (valueOrOp === MARK) {
|
1658
|
-
intersection2?.(scope, MARK);
|
1659
|
-
} else {
|
1660
|
-
fn && fn(scope, valueOrOp);
|
1661
|
-
intersection2?.(scope, DIRTY);
|
1662
|
-
}
|
1663
|
-
};
|
1664
|
-
}
|
1665
|
-
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1666
|
-
const signal = closure(fn, getIntersection);
|
1667
|
-
const loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */;
|
1668
|
-
const loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */;
|
1669
|
-
const helperSignal = (ownerScope, value2) => {
|
1670
|
-
const loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1671
|
-
if (loopScopes !== emptyMarkerArray) {
|
1672
|
-
for (const scope of loopScopes) {
|
1673
|
-
if (!scope.___pending) {
|
1674
|
-
queueSource(scope, signal, value2);
|
1675
|
-
}
|
1676
|
-
}
|
1677
|
-
}
|
1678
|
-
};
|
1679
|
-
helperSignal._ = signal;
|
1680
|
-
return helperSignal;
|
1681
|
-
}
|
1682
|
-
function conditionalClosure(ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1683
|
-
const signal = closure(fn, getIntersection);
|
1684
|
-
const scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */;
|
1685
|
-
const branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */;
|
1686
|
-
const helperSignal = (scope, value2) => {
|
1687
|
-
const ifScope = scope[scopeAccessor];
|
1688
|
-
if (ifScope && !ifScope.___pending && scope[branchAccessor] === branch) {
|
1689
|
-
queueSource(ifScope, signal, value2);
|
1690
|
-
}
|
1691
|
-
};
|
1692
|
-
helperSignal._ = signal;
|
1693
|
-
return helperSignal;
|
1694
|
-
}
|
1695
|
-
var defaultGetOwnerScope = (scope) => scope._;
|
1696
|
-
function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1697
|
-
const ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++;
|
1698
|
-
const _signal = closure(fn, getIntersection);
|
1699
|
-
const helperSignal = (ownerScope, value2) => {
|
1700
|
-
const subscribers = ownerScope[ownerSubscribersAccessor];
|
1701
|
-
if (subscribers) {
|
1702
|
-
for (const subscriber of subscribers) {
|
1703
|
-
if (!subscriber.___pending) {
|
1704
|
-
queueSource(subscriber, _signal, value2);
|
1705
|
-
}
|
1706
|
-
}
|
1707
|
-
}
|
1708
|
-
};
|
1709
|
-
const setupSignal = (scope, value2) => {
|
1710
|
-
_signal(scope, value2);
|
1711
|
-
subscribe(scope);
|
1712
|
-
};
|
1713
|
-
const subscribe = (scope) => {
|
1714
|
-
(getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope);
|
1715
|
-
getAbortSignal(scope, -1).addEventListener("abort", () => {
|
1716
|
-
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1717
|
-
});
|
1718
|
-
};
|
1719
|
-
helperSignal._ = setupSignal;
|
1720
|
-
helperSignal.___subscribe = subscribe;
|
1721
|
-
return helperSignal;
|
1722
|
-
}
|
1723
|
-
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1724
|
-
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1652
|
+
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
1653
|
+
let args;
|
1654
|
+
const id = true ? Symbol("Marko Renderer") : {};
|
1655
|
+
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
1656
|
+
return (owner) => {
|
1657
|
+
return {
|
1658
|
+
___id: id,
|
1659
|
+
___template: template,
|
1660
|
+
___walks: walks,
|
1661
|
+
___setup: setup,
|
1662
|
+
___clone: _clone,
|
1663
|
+
___owner: owner,
|
1664
|
+
get ___args() {
|
1665
|
+
return args ||= getArgs?.();
|
1666
|
+
}
|
1667
|
+
};
|
1668
|
+
};
|
1725
1669
|
}
|
1726
|
-
|
1727
|
-
|
1728
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
1670
|
+
function createRenderer(template, walks, setup, getArgs) {
|
1671
|
+
return createRendererWithOwner(template, walks, setup, getArgs)();
|
1729
1672
|
}
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1673
|
+
function _clone(ns) {
|
1674
|
+
return ((cloneCache[ns] ||= {})[this.___template] ||= createCloneableHTML(
|
1675
|
+
this.___template,
|
1676
|
+
ns
|
1677
|
+
))();
|
1736
1678
|
}
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1679
|
+
var cloneCache = {};
|
1680
|
+
function createCloneableHTML(html2, ns) {
|
1681
|
+
const { firstChild, lastChild } = parseHTML(html2, ns);
|
1682
|
+
const parent = document.createElementNS(ns, "t");
|
1683
|
+
insertChildNodes(parent, null, firstChild, lastChild);
|
1684
|
+
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? () => firstChild.cloneNode(true) : () => parent.cloneNode(true).firstChild;
|
1741
1685
|
}
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1686
|
+
|
1687
|
+
// src/dom/control-flow.ts
|
1688
|
+
function conditional(nodeAccessor, ...branches) {
|
1689
|
+
const branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1690
|
+
return (scope, newBranchIndexOrOp) => {
|
1691
|
+
if (newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN) {
|
1692
|
+
setConditionalRenderer(
|
1693
|
+
scope,
|
1694
|
+
nodeAccessor,
|
1695
|
+
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
1696
|
+
createBranchScopeWithRenderer
|
1697
|
+
);
|
1746
1698
|
}
|
1747
1699
|
};
|
1748
1700
|
}
|
1749
|
-
function
|
1750
|
-
|
1751
|
-
return (scope) => {
|
1752
|
-
queueEffect(scope, fn);
|
1753
|
-
};
|
1754
|
-
}
|
1755
|
-
|
1756
|
-
// src/dom/queue.ts
|
1757
|
-
var pendingRenders = [];
|
1758
|
-
var pendingEffects = [];
|
1759
|
-
var rendering = false;
|
1760
|
-
function queueSource(scope, signal, value2) {
|
1761
|
-
schedule();
|
1762
|
-
const prevRendering = rendering;
|
1763
|
-
rendering = true;
|
1764
|
-
signal(scope, MARK);
|
1765
|
-
rendering = prevRendering;
|
1766
|
-
queueRender(scope, signal, value2);
|
1767
|
-
return value2;
|
1701
|
+
function patchDynamicTag(fn) {
|
1702
|
+
dynamicTag = fn(dynamicTag);
|
1768
1703
|
}
|
1769
|
-
function
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1704
|
+
var dynamicTag = function dynamicTag2(nodeAccessor, fn, getIntersection) {
|
1705
|
+
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1706
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1707
|
+
return (scope, newRendererOrOp) => {
|
1708
|
+
if (newRendererOrOp === DIRTY) return;
|
1709
|
+
const currentRenderer = scope[rendererAccessor];
|
1710
|
+
let op = newRendererOrOp;
|
1711
|
+
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1712
|
+
if (isDifferentRenderer(
|
1713
|
+
currentRenderer,
|
1714
|
+
scope[rendererAccessor] = normalizeDynamicRenderer(newRendererOrOp)
|
1715
|
+
)) {
|
1716
|
+
setConditionalRenderer(
|
1717
|
+
scope,
|
1718
|
+
nodeAccessor,
|
1719
|
+
scope[rendererAccessor],
|
1720
|
+
createBranchScopeWithTagNameOrRenderer
|
1721
|
+
);
|
1722
|
+
fn && fn(scope);
|
1723
|
+
op = DIRTY;
|
1724
|
+
} else {
|
1725
|
+
op = CLEAN;
|
1726
|
+
}
|
1727
|
+
}
|
1728
|
+
intersection2?.(scope, op);
|
1776
1729
|
};
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1730
|
+
};
|
1731
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1732
|
+
const referenceNode = scope[nodeAccessor];
|
1733
|
+
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1734
|
+
const parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.___startNode || referenceNode).parentNode : referenceNode;
|
1735
|
+
const newBranch = scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && createBranch2(newRenderer, scope.$global, scope, parentNode);
|
1736
|
+
if (referenceNode === parentNode) {
|
1737
|
+
if (prevBranch) {
|
1738
|
+
destroyBranch(prevBranch);
|
1739
|
+
referenceNode.textContent = "";
|
1740
|
+
}
|
1741
|
+
if (newBranch) {
|
1742
|
+
insertBranchBefore(newBranch, parentNode, null);
|
1743
|
+
}
|
1744
|
+
} else if (prevBranch) {
|
1745
|
+
if (newBranch) {
|
1746
|
+
insertBranchBefore(newBranch, parentNode, prevBranch.___startNode);
|
1747
|
+
} else {
|
1748
|
+
parentNode.insertBefore(referenceNode, prevBranch.___startNode);
|
1749
|
+
}
|
1750
|
+
removeAndDestroyBranch(prevBranch);
|
1751
|
+
} else if (newBranch) {
|
1752
|
+
insertBranchBefore(newBranch, parentNode, referenceNode);
|
1753
|
+
referenceNode.remove();
|
1784
1754
|
}
|
1785
|
-
pendingRenders[i] = render;
|
1786
|
-
}
|
1787
|
-
function queueEffect(scope, fn) {
|
1788
|
-
pendingEffects.push(scope, fn);
|
1789
1755
|
}
|
1790
|
-
function
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1756
|
+
function loopOf(nodeAccessor, renderer) {
|
1757
|
+
return loop(
|
1758
|
+
nodeAccessor,
|
1759
|
+
renderer,
|
1760
|
+
([all, by = bySecondArg], cb) => {
|
1761
|
+
if (typeof by === "string") {
|
1762
|
+
forOf(
|
1763
|
+
all,
|
1764
|
+
(item, i) => cb(item[by], [item, i])
|
1765
|
+
);
|
1766
|
+
} else {
|
1767
|
+
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
1768
|
+
}
|
1769
|
+
}
|
1770
|
+
);
|
1801
1771
|
}
|
1802
|
-
function
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
rendering = true;
|
1809
|
-
fn();
|
1810
|
-
runRenders();
|
1811
|
-
} finally {
|
1812
|
-
rendering = false;
|
1813
|
-
pendingRenders = prevRenders;
|
1814
|
-
pendingEffects = prevEffects;
|
1815
|
-
}
|
1816
|
-
return preparedEffects;
|
1772
|
+
function loopIn(nodeAccessor, renderer) {
|
1773
|
+
return loop(
|
1774
|
+
nodeAccessor,
|
1775
|
+
renderer,
|
1776
|
+
([obj, by = byFirstArg], cb) => forIn(obj, (key, value2) => cb(by(key, value2), [key, value2]))
|
1777
|
+
);
|
1817
1778
|
}
|
1818
|
-
function
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1779
|
+
function loopTo(nodeAccessor, renderer) {
|
1780
|
+
return loop(
|
1781
|
+
nodeAccessor,
|
1782
|
+
renderer,
|
1783
|
+
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
1784
|
+
);
|
1824
1785
|
}
|
1825
|
-
function
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
if (
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
let bestChild = (i << 1) + 1;
|
1835
|
-
const right = bestChild + 1;
|
1836
|
-
if (right < pendingRenders.length && comparePendingRenders(
|
1837
|
-
pendingRenders[right],
|
1838
|
-
pendingRenders[bestChild]
|
1839
|
-
) < 0) {
|
1840
|
-
bestChild = right;
|
1786
|
+
function loop(nodeAccessor, renderer, forEach) {
|
1787
|
+
const loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */;
|
1788
|
+
const params = renderer.___args;
|
1789
|
+
return (scope, valueOrOp) => {
|
1790
|
+
if (valueOrOp === DIRTY) {
|
1791
|
+
} else if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1792
|
+
if (params) {
|
1793
|
+
for (const branch of scope[loopScopeAccessor] || scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() || []) {
|
1794
|
+
params(branch, valueOrOp);
|
1841
1795
|
}
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1796
|
+
}
|
1797
|
+
} else {
|
1798
|
+
const referenceNode = scope[nodeAccessor];
|
1799
|
+
const oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */];
|
1800
|
+
const oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
|
1801
|
+
...oldMap.values()
|
1802
|
+
] : [];
|
1803
|
+
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].___startNode.parentNode : referenceNode;
|
1804
|
+
const newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map();
|
1805
|
+
const newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
|
1806
|
+
forEach(valueOrOp, (key, args) => {
|
1807
|
+
const branch = oldMap?.get(key) || createBranchScopeWithRenderer(
|
1808
|
+
renderer,
|
1809
|
+
scope.$global,
|
1810
|
+
scope,
|
1811
|
+
parentNode
|
1812
|
+
);
|
1813
|
+
params?.(branch, args);
|
1814
|
+
newMap.set(key, branch);
|
1815
|
+
newArray.push(branch);
|
1816
|
+
});
|
1817
|
+
let afterReference = null;
|
1818
|
+
if (referenceNode !== parentNode) {
|
1819
|
+
if (oldArray.length) {
|
1820
|
+
afterReference = oldArray[oldArray.length - 1].___endNode.nextSibling;
|
1821
|
+
if (!newArray.length) {
|
1822
|
+
parentNode.insertBefore(referenceNode, afterReference);
|
1823
|
+
}
|
1824
|
+
} else if (newArray.length) {
|
1825
|
+
afterReference = referenceNode.nextSibling;
|
1826
|
+
referenceNode.remove();
|
1847
1827
|
}
|
1848
1828
|
}
|
1849
|
-
|
1850
|
-
}
|
1851
|
-
if (!render.___scope.___closestBranch?.___destroyed) {
|
1852
|
-
render.___signal(render.___scope, render.___value);
|
1829
|
+
reconcile(parentNode, oldArray, newArray, afterReference);
|
1853
1830
|
}
|
1854
|
-
}
|
1855
|
-
finishPendingScopes();
|
1856
|
-
}
|
1857
|
-
function comparePendingRenders(a, b) {
|
1858
|
-
return getBranchDepth(a) - getBranchDepth(b) || a.___index - b.___index;
|
1859
|
-
}
|
1860
|
-
function getBranchDepth(render) {
|
1861
|
-
return render.___scope.___closestBranch?.___branchDepth || 0;
|
1831
|
+
};
|
1862
1832
|
}
|
1863
|
-
|
1864
|
-
|
1865
|
-
function resetAbortSignal(scope, id) {
|
1866
|
-
const ctrl = scope.___abortControllers?.[id];
|
1867
|
-
if (ctrl) {
|
1868
|
-
queueEffect(ctrl, abort);
|
1869
|
-
scope.___abortControllers[id] = void 0;
|
1870
|
-
}
|
1833
|
+
function bySecondArg(_item, index) {
|
1834
|
+
return index;
|
1871
1835
|
}
|
1872
|
-
function
|
1873
|
-
|
1874
|
-
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1875
|
-
}
|
1876
|
-
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1836
|
+
function byFirstArg(name) {
|
1837
|
+
return name;
|
1877
1838
|
}
|
1878
|
-
function
|
1879
|
-
|
1839
|
+
function isDifferentRenderer(a, b) {
|
1840
|
+
return a !== b && (a?.___id || 0) !== b?.___id;
|
1880
1841
|
}
|
1881
1842
|
|
1882
|
-
// src/common/compat-meta.ts
|
1883
|
-
var prefix = true ? "$compat_" : "$C_";
|
1884
|
-
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1885
|
-
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1886
|
-
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
1887
|
-
|
1888
1843
|
// src/dom/compat.ts
|
1889
1844
|
var classIdToBranch = /* @__PURE__ */ new Map();
|
1890
1845
|
var compat = {
|
@@ -2033,7 +1988,7 @@ function mount(input = {}, reference, position) {
|
|
2033
1988
|
);
|
2034
1989
|
runEffects(effects);
|
2035
1990
|
return {
|
2036
|
-
update
|
1991
|
+
update(newInput) {
|
2037
1992
|
if (args) {
|
2038
1993
|
runEffects(
|
2039
1994
|
prepareEffects(() => {
|
@@ -2043,7 +1998,7 @@ function mount(input = {}, reference, position) {
|
|
2043
1998
|
);
|
2044
1999
|
}
|
2045
2000
|
},
|
2046
|
-
destroy
|
2001
|
+
destroy() {
|
2047
2002
|
removeAndDestroyBranch(branch);
|
2048
2003
|
}
|
2049
2004
|
};
|
@@ -2099,7 +2054,7 @@ export {
|
|
2099
2054
|
props,
|
2100
2055
|
register,
|
2101
2056
|
registerBoundSignal,
|
2102
|
-
|
2057
|
+
registerDynamicClosure,
|
2103
2058
|
resetAbortSignal,
|
2104
2059
|
run,
|
2105
2060
|
setTagVar,
|