marko 6.0.0-next.3.39 → 6.0.0-next.3.41
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 +810 -863
- package/dist/debug/dom.mjs +810 -863
- package/dist/debug/html.js +1 -1
- package/dist/debug/html.mjs +1 -1
- package/dist/dom/control-flow.d.ts +1 -2
- package/dist/dom/scope.d.ts +0 -1
- package/dist/dom.js +308 -334
- package/dist/dom.mjs +308 -334
- package/dist/html.js +1 -1
- package/dist/html.mjs +1 -1
- package/dist/translator/index.js +8 -1
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
@@ -186,35 +186,24 @@ function normalizeDynamicRenderer(value2) {
|
|
186
186
|
}
|
187
187
|
|
188
188
|
// src/dom/event.ts
|
189
|
-
var elementHandlersByEvent = /* @__PURE__ */ new Map();
|
190
189
|
var defaultDelegator = createDelegator();
|
191
190
|
function on(element, type, handler) {
|
192
|
-
|
193
|
-
if (!handlersByElement) {
|
194
|
-
elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap());
|
195
|
-
}
|
196
|
-
if (!handlersByElement.has(element)) {
|
191
|
+
if (element["$" + type] === void 0) {
|
197
192
|
defaultDelegator(element, type, handleDelegated);
|
198
193
|
}
|
199
|
-
|
194
|
+
element["$" + type] = handler || null;
|
200
195
|
}
|
201
196
|
function createDelegator() {
|
202
197
|
const kEvents = Symbol();
|
203
198
|
return function ensureDelegated(node, type, handler) {
|
204
|
-
|
205
|
-
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, true), 1);
|
199
|
+
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, true), 1);
|
206
200
|
};
|
207
201
|
}
|
208
202
|
function handleDelegated(ev) {
|
209
203
|
let target = !rendering && ev.target;
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
if (ev.bubbles) {
|
214
|
-
while ((target = target.parentNode) && !ev.cancelBubble) {
|
215
|
-
handlersByElement.get(target)?.(ev, target);
|
216
|
-
}
|
217
|
-
}
|
204
|
+
while (target) {
|
205
|
+
target["$" + ev.type]?.(ev, target);
|
206
|
+
target = ev.bubbles && !ev.cancelBubble && target.parentNode;
|
218
207
|
}
|
219
208
|
}
|
220
209
|
|
@@ -511,7 +500,17 @@ function controllable_input_checkedValue_effect(scope, nodeAccessor) {
|
|
511
500
|
);
|
512
501
|
run();
|
513
502
|
if (scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */) {
|
514
|
-
el.
|
503
|
+
if (el.name && el.type[0] === "r") {
|
504
|
+
for (const radio of el.getRootNode().querySelectorAll(
|
505
|
+
`[type=radio][name=${CSS.escape(el.name)}]`
|
506
|
+
)) {
|
507
|
+
if (radio.form === el.form) {
|
508
|
+
radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
|
509
|
+
}
|
510
|
+
}
|
511
|
+
} else {
|
512
|
+
el.checked = !el.checked;
|
513
|
+
}
|
515
514
|
}
|
516
515
|
}
|
517
516
|
});
|
@@ -591,7 +590,7 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
591
590
|
}
|
592
591
|
}
|
593
592
|
};
|
594
|
-
if (!
|
593
|
+
if (!el._) {
|
595
594
|
new MutationObserver(() => {
|
596
595
|
const value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
597
596
|
if (Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) {
|
@@ -686,9 +685,8 @@ function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
|
686
685
|
}
|
687
686
|
}
|
688
687
|
var controllableDelegate = createDelegator();
|
689
|
-
var controllableHandlers = /* @__PURE__ */ new WeakMap();
|
690
688
|
function syncControllable(el, event, hasChanged, onChange) {
|
691
|
-
if (!
|
689
|
+
if (!el._) {
|
692
690
|
controllableDelegate(el, event, handleChange);
|
693
691
|
if (el.form) {
|
694
692
|
controllableDelegate(el.form, "reset", handleFormReset);
|
@@ -697,17 +695,16 @@ function syncControllable(el, event, hasChanged, onChange) {
|
|
697
695
|
queueMicrotask(onChange);
|
698
696
|
}
|
699
697
|
}
|
700
|
-
|
698
|
+
el._ = onChange;
|
701
699
|
}
|
702
700
|
function handleChange(ev) {
|
703
|
-
|
701
|
+
ev.target._?.(ev);
|
704
702
|
}
|
705
703
|
function handleFormReset(ev) {
|
706
704
|
const handlers = [];
|
707
705
|
for (const el of ev.target.elements) {
|
708
|
-
|
709
|
-
|
710
|
-
handlers.push(handler);
|
706
|
+
if (el._ && hasFormElementChanged(el)) {
|
707
|
+
handlers.push(el._);
|
711
708
|
}
|
712
709
|
}
|
713
710
|
requestAnimationFrame(() => {
|
@@ -1028,11 +1025,6 @@ function finishPendingScopes() {
|
|
1028
1025
|
}
|
1029
1026
|
pendingScopes = [];
|
1030
1027
|
}
|
1031
|
-
var emptyBranch = createScope({});
|
1032
|
-
function getEmptyBranch(marker) {
|
1033
|
-
emptyBranch.___startNode = emptyBranch.___endNode = marker;
|
1034
|
-
return emptyBranch;
|
1035
|
-
}
|
1036
1028
|
function destroyBranch(branch) {
|
1037
1029
|
branch.___parentBranch?.___branchScopes?.delete(branch);
|
1038
1030
|
destroyNestedBranches(branch);
|
@@ -1059,936 +1051,891 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
1059
1051
|
);
|
1060
1052
|
}
|
1061
1053
|
|
1062
|
-
// src/dom/
|
1063
|
-
var
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
let j;
|
1075
|
-
let k;
|
1076
|
-
let nextSibling;
|
1077
|
-
let oldBranch;
|
1078
|
-
let newBranch;
|
1079
|
-
outer: {
|
1080
|
-
while (oldStartBranch === newStartBranch) {
|
1081
|
-
++oldStart;
|
1082
|
-
++newStart;
|
1083
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
1084
|
-
break outer;
|
1085
|
-
}
|
1086
|
-
oldStartBranch = oldBranches[oldStart];
|
1087
|
-
newStartBranch = newBranches[newStart];
|
1054
|
+
// src/dom/schedule.ts
|
1055
|
+
var runTask;
|
1056
|
+
var port2 = /* @__PURE__ */ (() => {
|
1057
|
+
const { port1, port2: port22 } = new MessageChannel();
|
1058
|
+
port1.onmessage = () => {
|
1059
|
+
isScheduled = false;
|
1060
|
+
if (true) {
|
1061
|
+
const run2 = runTask;
|
1062
|
+
runTask = void 0;
|
1063
|
+
run2();
|
1064
|
+
} else {
|
1065
|
+
run();
|
1088
1066
|
}
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1067
|
+
};
|
1068
|
+
return port22;
|
1069
|
+
})();
|
1070
|
+
var isScheduled;
|
1071
|
+
function schedule() {
|
1072
|
+
if (!isScheduled) {
|
1073
|
+
if (true) {
|
1074
|
+
if (console.createTask) {
|
1075
|
+
const task = console.createTask("queue");
|
1076
|
+
runTask = () => task.run(run);
|
1077
|
+
} else {
|
1078
|
+
runTask = run;
|
1094
1079
|
}
|
1095
|
-
oldEndBranch = oldBranches[oldEnd];
|
1096
|
-
newEndBranch = newBranches[newEnd];
|
1097
1080
|
}
|
1081
|
+
isScheduled = true;
|
1082
|
+
queueMicrotask(flushAndWaitFrame);
|
1098
1083
|
}
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
do {
|
1104
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
1105
|
-
} while (newStart <= newEnd);
|
1106
|
-
}
|
1107
|
-
} else if (newStart > newEnd) {
|
1108
|
-
do {
|
1109
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
1110
|
-
} while (oldStart <= oldEnd);
|
1084
|
+
}
|
1085
|
+
function flushAndWaitFrame() {
|
1086
|
+
if (true) {
|
1087
|
+
runTask();
|
1111
1088
|
} else {
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
}
|
1136
|
-
|
1137
|
-
for (; newStart < newLength; ++newStart) {
|
1138
|
-
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
1139
|
-
}
|
1140
|
-
for (; oldStart < oldLength; ++oldStart) {
|
1141
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
1142
|
-
}
|
1089
|
+
run();
|
1090
|
+
}
|
1091
|
+
requestAnimationFrame(triggerMacroTask);
|
1092
|
+
}
|
1093
|
+
function triggerMacroTask() {
|
1094
|
+
port2.postMessage(0);
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
// src/dom/signals.ts
|
1098
|
+
var MARK = true ? Symbol("mark") : {};
|
1099
|
+
var CLEAN = true ? Symbol("clean") : {};
|
1100
|
+
var DIRTY = true ? Symbol("dirty") : {};
|
1101
|
+
function state(valueAccessor, fn, getIntersection) {
|
1102
|
+
const valueSignal = value(valueAccessor, fn, getIntersection);
|
1103
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1104
|
+
const valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1105
|
+
return (scope, valueOrOp, valueChange) => {
|
1106
|
+
if (rendering) {
|
1107
|
+
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
1108
|
+
valueSignal(
|
1109
|
+
scope,
|
1110
|
+
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1111
|
+
);
|
1112
|
+
} else if (scope[valueChangeAccessor]) {
|
1113
|
+
scope[valueChangeAccessor](valueOrOp);
|
1143
1114
|
} else {
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1115
|
+
schedule();
|
1116
|
+
queueSource(scope, valueSignal, valueOrOp);
|
1117
|
+
}
|
1118
|
+
return valueOrOp;
|
1119
|
+
};
|
1120
|
+
}
|
1121
|
+
function value(valueAccessor, fn, getIntersection) {
|
1122
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1123
|
+
let intersection2;
|
1124
|
+
return (scope, valueOrOp) => {
|
1125
|
+
if (valueOrOp === MARK) {
|
1126
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1127
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
|
1151
1128
|
}
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
1162
|
-
} else {
|
1163
|
-
if (j < 0 || i !== seq[j]) {
|
1164
|
-
pos = i + newStart;
|
1165
|
-
newBranch = newBranches[pos++];
|
1166
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1167
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
1168
|
-
} else {
|
1169
|
-
--j;
|
1170
|
-
}
|
1171
|
-
}
|
1172
|
-
}
|
1173
|
-
} else if (synced !== newLength) {
|
1174
|
-
k = newBranches.length;
|
1175
|
-
for (i = newLength - 1; i >= 0; --i) {
|
1176
|
-
if (sources[i] === -1) {
|
1177
|
-
pos = i + newStart;
|
1178
|
-
newBranch = newBranches[pos++];
|
1179
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1180
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
1181
|
-
}
|
1129
|
+
} else if (valueOrOp !== DIRTY) {
|
1130
|
+
const existing = scope[markAccessor] !== void 0;
|
1131
|
+
if ((scope[markAccessor] ||= 1) === 1) {
|
1132
|
+
if (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp) {
|
1133
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN);
|
1134
|
+
} else {
|
1135
|
+
scope[valueAccessor] = valueOrOp;
|
1136
|
+
fn && fn(scope, valueOrOp);
|
1137
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY);
|
1182
1138
|
}
|
1183
1139
|
}
|
1140
|
+
scope[markAccessor]--;
|
1184
1141
|
}
|
1185
|
-
}
|
1142
|
+
};
|
1186
1143
|
}
|
1187
|
-
|
1188
|
-
|
1189
|
-
const
|
1190
|
-
|
1191
|
-
let
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
while (u < v) {
|
1206
|
-
const c = (u + v) / 2 | 0;
|
1207
|
-
if (a[result[c]] < a[i]) {
|
1208
|
-
u = c + 1;
|
1144
|
+
var accessorId = 0;
|
1145
|
+
function intersection(count, fn, getIntersection) {
|
1146
|
+
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
1147
|
+
const markAccessor = dirtyAccessor + "#" /* Mark */;
|
1148
|
+
let intersection2;
|
1149
|
+
return (scope, op) => {
|
1150
|
+
if (op === MARK) {
|
1151
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1152
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
|
1153
|
+
}
|
1154
|
+
} else if (scope[markAccessor] === void 0) {
|
1155
|
+
scope[markAccessor] = count - 1;
|
1156
|
+
scope[dirtyAccessor] = true;
|
1157
|
+
} else if (--scope[markAccessor] === 0) {
|
1158
|
+
if (op === DIRTY || scope[dirtyAccessor]) {
|
1159
|
+
scope[dirtyAccessor] = false;
|
1160
|
+
fn(scope);
|
1161
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY);
|
1209
1162
|
} else {
|
1210
|
-
|
1163
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN);
|
1211
1164
|
}
|
1165
|
+
} else {
|
1166
|
+
scope[dirtyAccessor] ||= op === DIRTY;
|
1212
1167
|
}
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1168
|
+
};
|
1169
|
+
}
|
1170
|
+
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn, getIntersection) {
|
1171
|
+
const childSignal = closure(valueAccessor, fn, getIntersection);
|
1172
|
+
const loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */;
|
1173
|
+
const loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */;
|
1174
|
+
const ownerSignal = (ownerScope) => {
|
1175
|
+
for (const scope of ownerScope[loopScopeAccessor] || ownerScope[loopScopeMapAccessor]?.values() || []) {
|
1176
|
+
if (!scope.___pending) {
|
1177
|
+
queueSource(scope, childSignal);
|
1216
1178
|
}
|
1217
|
-
result[u] = i;
|
1218
1179
|
}
|
1219
|
-
}
|
1220
|
-
|
1221
|
-
|
1222
|
-
while (u-- > 0) {
|
1223
|
-
result[u] = v;
|
1224
|
-
v = p[v];
|
1225
|
-
}
|
1226
|
-
return result;
|
1227
|
-
}
|
1228
|
-
|
1229
|
-
// src/dom/walker.ts
|
1230
|
-
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
1231
|
-
function trimWalkString(walkString) {
|
1232
|
-
let end = walkString.length;
|
1233
|
-
while (walkString.charCodeAt(--end) > 47 /* BeginChild */) ;
|
1234
|
-
return walkString.slice(0, end + 1);
|
1180
|
+
};
|
1181
|
+
ownerSignal._ = childSignal;
|
1182
|
+
return ownerSignal;
|
1235
1183
|
}
|
1236
|
-
function
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1184
|
+
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1185
|
+
const childSignal = closure(valueAccessor, fn, getIntersection);
|
1186
|
+
const scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */;
|
1187
|
+
const branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */;
|
1188
|
+
const ownerSignal = (scope) => {
|
1189
|
+
const ifScope = scope[scopeAccessor];
|
1190
|
+
if (ifScope && !ifScope.___pending && scope[branchAccessor] === branch) {
|
1191
|
+
queueSource(ifScope, childSignal);
|
1192
|
+
}
|
1193
|
+
};
|
1194
|
+
ownerSignal._ = childSignal;
|
1195
|
+
return ownerSignal;
|
1240
1196
|
}
|
1241
|
-
function
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
walker.nextSibling();
|
1257
|
-
} else if (value2 >= 97 /* Over */) {
|
1258
|
-
value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */;
|
1259
|
-
while (value2--) {
|
1260
|
-
walker.nextSibling();
|
1261
|
-
}
|
1262
|
-
} else if (value2 >= 67 /* Next */) {
|
1263
|
-
value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */;
|
1264
|
-
while (value2--) {
|
1265
|
-
walker.nextNode();
|
1197
|
+
function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
1198
|
+
const subscribersAccessor = "?" /* Dynamic */ + accessorId++;
|
1199
|
+
const childSignal = closure(
|
1200
|
+
valueAccessor,
|
1201
|
+
fn,
|
1202
|
+
getIntersection,
|
1203
|
+
getOwnerScope
|
1204
|
+
);
|
1205
|
+
const ownerSignal = (ownerScope) => {
|
1206
|
+
const subscribers = ownerScope[subscribersAccessor];
|
1207
|
+
if (subscribers) {
|
1208
|
+
for (const subscriber of subscribers) {
|
1209
|
+
if (!subscriber.___pending) {
|
1210
|
+
queueSource(subscriber, childSignal);
|
1211
|
+
}
|
1266
1212
|
}
|
1267
|
-
}
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1213
|
+
}
|
1214
|
+
};
|
1215
|
+
const subscribe = (scope) => {
|
1216
|
+
const owner = getOwnerScope ? getOwnerScope(scope) : scope._;
|
1217
|
+
const subscribers = owner[subscribersAccessor] ||= /* @__PURE__ */ new Set();
|
1218
|
+
if (!subscribers.has(scope)) {
|
1219
|
+
subscribers.add(scope);
|
1220
|
+
getAbortSignal(scope, -1).addEventListener(
|
1221
|
+
"abort",
|
1222
|
+
() => subscribers.delete(scope)
|
1272
1223
|
);
|
1273
|
-
} else if (value2 === 38 /* EndChild */) {
|
1274
|
-
return currentWalkIndex;
|
1275
|
-
} else if (value2 === 32 /* Get */) {
|
1276
|
-
scope[true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++] = walker.currentNode;
|
1277
|
-
} else {
|
1278
|
-
const newNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text();
|
1279
|
-
const current = walker.currentNode;
|
1280
|
-
const parentNode = current.parentNode;
|
1281
|
-
if (value2 !== 37 /* Replace */) {
|
1282
|
-
throw new Error(`Unknown walk code: ${value2}`);
|
1283
|
-
}
|
1284
|
-
parentNode.replaceChild(newNode, current);
|
1285
|
-
walker.currentNode = newNode;
|
1286
1224
|
}
|
1287
|
-
}
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
return `#text/${index}`;
|
1295
|
-
} else if (node.nodeType === 8 /* Comment */) {
|
1296
|
-
return `#comment/${index}`;
|
1297
|
-
} else if (node.nodeType === 1 /* Element */) {
|
1298
|
-
return `#${node.tagName.toLowerCase()}/${index}`;
|
1299
|
-
}
|
1300
|
-
return index;
|
1225
|
+
};
|
1226
|
+
ownerSignal.___subscribe = subscribe;
|
1227
|
+
ownerSignal._ = (scope) => {
|
1228
|
+
childSignal(scope);
|
1229
|
+
subscribe(scope);
|
1230
|
+
};
|
1231
|
+
return ownerSignal;
|
1301
1232
|
}
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
parentScope
|
1233
|
+
function registerDynamicClosure(id, valueAccessor, fn, getIntersection, getOwnerScope) {
|
1234
|
+
const signal = dynamicClosure(
|
1235
|
+
valueAccessor,
|
1236
|
+
fn,
|
1237
|
+
getIntersection,
|
1238
|
+
getOwnerScope
|
1309
1239
|
);
|
1310
|
-
|
1311
|
-
|
1312
|
-
}
|
1313
|
-
initBranch(renderer, branch, parentNode);
|
1314
|
-
return branch;
|
1240
|
+
register(id, signal.___subscribe);
|
1241
|
+
return signal;
|
1315
1242
|
}
|
1316
|
-
function
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
parentNode
|
1243
|
+
function closure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
1244
|
+
let intersection2;
|
1245
|
+
return (scope, op) => {
|
1246
|
+
op || fn && fn(
|
1247
|
+
scope,
|
1248
|
+
(getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
|
1323
1249
|
);
|
1250
|
+
getIntersection && (intersection2 ||= getIntersection())(scope, op ? MARK : DIRTY);
|
1251
|
+
};
|
1252
|
+
}
|
1253
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1254
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1255
|
+
}
|
1256
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1257
|
+
function setTagVarChange(scope, changeHandler) {
|
1258
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
1259
|
+
}
|
1260
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1261
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1262
|
+
function nextTagId({ $global }) {
|
1263
|
+
const id = tagIdsByGlobal.get($global) || 0;
|
1264
|
+
tagIdsByGlobal.set($global, id + 1);
|
1265
|
+
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1266
|
+
}
|
1267
|
+
function inChild(childAccessor, signal) {
|
1268
|
+
return (scope, valueOrOp) => {
|
1269
|
+
signal(scope[childAccessor], valueOrOp);
|
1270
|
+
};
|
1271
|
+
}
|
1272
|
+
function intersections(signals) {
|
1273
|
+
return (scope, op) => {
|
1274
|
+
for (const signal of signals) {
|
1275
|
+
signal(scope, op);
|
1276
|
+
}
|
1277
|
+
};
|
1278
|
+
}
|
1279
|
+
function effect(id, fn) {
|
1280
|
+
register(id, fn);
|
1281
|
+
return (scope) => {
|
1282
|
+
queueEffect(scope, fn);
|
1283
|
+
};
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
// src/dom/queue.ts
|
1287
|
+
var pendingRenders = [];
|
1288
|
+
var pendingEffects = [];
|
1289
|
+
var rendering = false;
|
1290
|
+
function queueSource(scope, signal, value2) {
|
1291
|
+
const prevRendering = rendering;
|
1292
|
+
rendering = true;
|
1293
|
+
signal(scope, MARK);
|
1294
|
+
rendering = prevRendering;
|
1295
|
+
queueRender(scope, signal, value2);
|
1296
|
+
}
|
1297
|
+
function queueRender(scope, signal, value2) {
|
1298
|
+
let i = pendingRenders.length;
|
1299
|
+
const render = {
|
1300
|
+
___scope: scope,
|
1301
|
+
___signal: signal,
|
1302
|
+
___value: value2,
|
1303
|
+
___depth: scope.___closestBranch?.___branchDepth || 0,
|
1304
|
+
___index: i
|
1305
|
+
};
|
1306
|
+
pendingRenders.push(render);
|
1307
|
+
while (i) {
|
1308
|
+
const parentIndex = i - 1 >> 1;
|
1309
|
+
const parent = pendingRenders[parentIndex];
|
1310
|
+
if (comparePendingRenders(render, parent) >= 0) break;
|
1311
|
+
pendingRenders[i] = parent;
|
1312
|
+
i = parentIndex;
|
1324
1313
|
}
|
1325
|
-
|
1326
|
-
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
1327
|
-
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1328
|
-
tagNameOrRenderer
|
1329
|
-
);
|
1330
|
-
return branch;
|
1314
|
+
pendingRenders[i] = render;
|
1331
1315
|
}
|
1332
|
-
function
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1316
|
+
function queueEffect(scope, fn) {
|
1317
|
+
pendingEffects.push(scope, fn);
|
1318
|
+
}
|
1319
|
+
function run() {
|
1320
|
+
const effects = pendingEffects;
|
1321
|
+
try {
|
1322
|
+
rendering = true;
|
1323
|
+
runRenders();
|
1324
|
+
} finally {
|
1325
|
+
pendingRenders = [];
|
1326
|
+
pendingEffects = [];
|
1327
|
+
rendering = false;
|
1343
1328
|
}
|
1344
|
-
|
1329
|
+
runEffects(effects);
|
1345
1330
|
}
|
1346
|
-
function
|
1347
|
-
const
|
1348
|
-
const
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1331
|
+
function prepareEffects(fn) {
|
1332
|
+
const prevRenders = pendingRenders;
|
1333
|
+
const prevEffects = pendingEffects;
|
1334
|
+
const preparedEffects = pendingEffects = [];
|
1335
|
+
pendingRenders = [];
|
1336
|
+
try {
|
1337
|
+
rendering = true;
|
1338
|
+
fn();
|
1339
|
+
runRenders();
|
1340
|
+
} finally {
|
1341
|
+
rendering = false;
|
1342
|
+
pendingRenders = prevRenders;
|
1343
|
+
pendingEffects = prevEffects;
|
1356
1344
|
}
|
1357
|
-
|
1358
|
-
|
1345
|
+
return preparedEffects;
|
1346
|
+
}
|
1347
|
+
function runEffects(effects) {
|
1348
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1349
|
+
const scope = effects[i];
|
1350
|
+
const fn = effects[i + 1];
|
1351
|
+
fn(scope, scope);
|
1359
1352
|
}
|
1360
1353
|
}
|
1361
|
-
function
|
1362
|
-
|
1363
|
-
const
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1354
|
+
function runRenders() {
|
1355
|
+
while (pendingRenders.length) {
|
1356
|
+
const render = pendingRenders[0];
|
1357
|
+
const next = pendingRenders.pop();
|
1358
|
+
if (render !== next) {
|
1359
|
+
let i = 0;
|
1360
|
+
const mid = pendingRenders.length >> 1;
|
1361
|
+
const item = pendingRenders[0] = next;
|
1362
|
+
while (i < mid) {
|
1363
|
+
let bestChild = (i << 1) + 1;
|
1364
|
+
const right = bestChild + 1;
|
1365
|
+
if (right < pendingRenders.length && comparePendingRenders(
|
1366
|
+
pendingRenders[right],
|
1367
|
+
pendingRenders[bestChild]
|
1368
|
+
) < 0) {
|
1369
|
+
bestChild = right;
|
1370
|
+
}
|
1371
|
+
if (comparePendingRenders(pendingRenders[bestChild], item) >= 0) {
|
1372
|
+
break;
|
1373
|
+
} else {
|
1374
|
+
pendingRenders[i] = pendingRenders[bestChild];
|
1375
|
+
i = bestChild;
|
1376
|
+
}
|
1378
1377
|
}
|
1379
|
-
|
1380
|
-
childScope,
|
1381
|
-
nodeAccessor2,
|
1382
|
-
content,
|
1383
|
-
createBranchScopeWithTagNameOrRenderer
|
1384
|
-
);
|
1385
|
-
attrs(childScope, nodeAccessor2, attrsOrOp());
|
1386
|
-
} else if (renderer.___args) {
|
1387
|
-
const attributes = attrsOrOp();
|
1388
|
-
renderer.___args(
|
1389
|
-
childScope,
|
1390
|
-
inputIsArgs ? attributes : [
|
1391
|
-
content ? {
|
1392
|
-
...attributes,
|
1393
|
-
content
|
1394
|
-
} : attributes
|
1395
|
-
]
|
1396
|
-
);
|
1378
|
+
pendingRenders[i] = item;
|
1397
1379
|
}
|
1398
|
-
|
1380
|
+
if (!render.___scope.___closestBranch?.___destroyed) {
|
1381
|
+
render.___signal(render.___scope, render.___value);
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
finishPendingScopes();
|
1399
1385
|
}
|
1400
|
-
function
|
1401
|
-
|
1402
|
-
const id = true ? Symbol("Marko Renderer") : {};
|
1403
|
-
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
1404
|
-
return (owner) => {
|
1405
|
-
return {
|
1406
|
-
___id: id,
|
1407
|
-
___template: template,
|
1408
|
-
___walks: walks,
|
1409
|
-
___setup: setup,
|
1410
|
-
___clone: _clone,
|
1411
|
-
___owner: owner,
|
1412
|
-
get ___args() {
|
1413
|
-
return args ||= getArgs?.();
|
1414
|
-
}
|
1415
|
-
};
|
1416
|
-
};
|
1386
|
+
function comparePendingRenders(a, b) {
|
1387
|
+
return a.___depth - b.___depth || a.___index - b.___index;
|
1417
1388
|
}
|
1418
|
-
|
1419
|
-
|
1389
|
+
|
1390
|
+
// src/dom/abort-signal.ts
|
1391
|
+
function resetAbortSignal(scope, id) {
|
1392
|
+
const ctrl = scope.___abortControllers?.[id];
|
1393
|
+
if (ctrl) {
|
1394
|
+
queueEffect(ctrl, abort);
|
1395
|
+
scope.___abortControllers[id] = void 0;
|
1396
|
+
}
|
1420
1397
|
}
|
1421
|
-
function
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
)
|
1398
|
+
function getAbortSignal(scope, id) {
|
1399
|
+
if (scope.___closestBranch) {
|
1400
|
+
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1401
|
+
}
|
1402
|
+
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1426
1403
|
}
|
1427
|
-
|
1428
|
-
|
1429
|
-
const { firstChild, lastChild } = parseHTML(html2, ns);
|
1430
|
-
const parent = document.createElementNS(ns, "t");
|
1431
|
-
insertChildNodes(parent, null, firstChild, lastChild);
|
1432
|
-
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? () => firstChild.cloneNode(true) : () => parent.cloneNode(true).firstChild;
|
1404
|
+
function abort(ctrl) {
|
1405
|
+
ctrl.abort();
|
1433
1406
|
}
|
1434
1407
|
|
1435
|
-
// src/
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
let
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1408
|
+
// src/common/compat-meta.ts
|
1409
|
+
var prefix = true ? "$compat_" : "$C_";
|
1410
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1411
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1412
|
+
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
1413
|
+
|
1414
|
+
// src/dom/reconcile.ts
|
1415
|
+
var WRONG_POS = 2147483647;
|
1416
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
1417
|
+
let oldStart = 0;
|
1418
|
+
let newStart = 0;
|
1419
|
+
let oldEnd = oldBranches.length - 1;
|
1420
|
+
let newEnd = newBranches.length - 1;
|
1421
|
+
let oldStartBranch = oldBranches[oldStart];
|
1422
|
+
let newStartBranch = newBranches[newStart];
|
1423
|
+
let oldEndBranch = oldBranches[oldEnd];
|
1424
|
+
let newEndBranch = newBranches[newEnd];
|
1425
|
+
let i;
|
1426
|
+
let j;
|
1427
|
+
let k;
|
1428
|
+
let nextSibling;
|
1429
|
+
let oldBranch;
|
1430
|
+
let newBranch;
|
1431
|
+
outer: {
|
1432
|
+
while (oldStartBranch === newStartBranch) {
|
1433
|
+
++oldStart;
|
1434
|
+
++newStart;
|
1435
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
1436
|
+
break outer;
|
1437
|
+
}
|
1438
|
+
oldStartBranch = oldBranches[oldStart];
|
1439
|
+
newStartBranch = newBranches[newStart];
|
1440
|
+
}
|
1441
|
+
while (oldEndBranch === newEndBranch) {
|
1442
|
+
--oldEnd;
|
1443
|
+
--newEnd;
|
1444
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
1445
|
+
break outer;
|
1473
1446
|
}
|
1447
|
+
oldEndBranch = oldBranches[oldEnd];
|
1448
|
+
newEndBranch = newBranches[newEnd];
|
1474
1449
|
}
|
1475
|
-
intersection2?.(scope, op);
|
1476
|
-
};
|
1477
|
-
};
|
1478
|
-
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1479
|
-
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]);
|
1480
|
-
const newBranch = newRenderer ? createBranch2(
|
1481
|
-
newRenderer,
|
1482
|
-
scope.$global,
|
1483
|
-
scope,
|
1484
|
-
prevBranch.___endNode.parentNode
|
1485
|
-
) : getEmptyBranch(scope[nodeAccessor]);
|
1486
|
-
if (prevBranch !== newBranch) {
|
1487
|
-
insertBranchBefore(
|
1488
|
-
newBranch,
|
1489
|
-
prevBranch.___endNode.parentNode,
|
1490
|
-
prevBranch.___endNode.nextSibling
|
1491
|
-
);
|
1492
|
-
removeAndDestroyBranch(prevBranch);
|
1493
|
-
scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
1494
1450
|
}
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
insertBranchBefore(newBranch, referenceNode, null);
|
1503
|
-
}
|
1504
|
-
prevBranch && destroyBranch(prevBranch);
|
1505
|
-
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1506
|
-
}
|
1507
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1508
|
-
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
1509
|
-
]);
|
1510
|
-
var emptyMarkerArray = [
|
1511
|
-
/* @__PURE__ */ getEmptyBranch(0)
|
1512
|
-
];
|
1513
|
-
var emptyMap = /* @__PURE__ */ new Map();
|
1514
|
-
var emptyArray = [];
|
1515
|
-
function loopOf(nodeAccessor, renderer) {
|
1516
|
-
return loop(
|
1517
|
-
nodeAccessor,
|
1518
|
-
renderer,
|
1519
|
-
([all, by = bySecondArg], cb) => {
|
1520
|
-
if (typeof by === "string") {
|
1521
|
-
forOf(
|
1522
|
-
all,
|
1523
|
-
(item, i) => cb(item[by], [item, i])
|
1524
|
-
);
|
1525
|
-
} else {
|
1526
|
-
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
1527
|
-
}
|
1451
|
+
if (oldStart > oldEnd) {
|
1452
|
+
if (newStart <= newEnd) {
|
1453
|
+
k = newEnd + 1;
|
1454
|
+
nextSibling = k < newBranches.length ? newBranches[k].___startNode : afterReference;
|
1455
|
+
do {
|
1456
|
+
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
1457
|
+
} while (newStart <= newEnd);
|
1528
1458
|
}
|
1529
|
-
)
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1459
|
+
} else if (newStart > newEnd) {
|
1460
|
+
do {
|
1461
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
1462
|
+
} while (oldStart <= oldEnd);
|
1463
|
+
} else {
|
1464
|
+
const oldLength = oldEnd - oldStart + 1;
|
1465
|
+
const newLength = newEnd - newStart + 1;
|
1466
|
+
const aNullable = oldBranches;
|
1467
|
+
const sources = new Array(newLength);
|
1468
|
+
for (i = 0; i < newLength; ++i) {
|
1469
|
+
sources[i] = -1;
|
1470
|
+
}
|
1471
|
+
let pos = 0;
|
1472
|
+
let synced = 0;
|
1473
|
+
const keyIndex = /* @__PURE__ */ new Map();
|
1474
|
+
for (j = newStart; j <= newEnd; ++j) {
|
1475
|
+
keyIndex.set(newBranches[j], j);
|
1476
|
+
}
|
1477
|
+
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
1478
|
+
oldBranch = oldBranches[i];
|
1479
|
+
j = keyIndex.get(oldBranch);
|
1480
|
+
if (j !== void 0) {
|
1481
|
+
pos = pos > j ? WRONG_POS : j;
|
1482
|
+
++synced;
|
1483
|
+
newBranch = newBranches[j];
|
1484
|
+
sources[j - newStart] = i;
|
1485
|
+
aNullable[i] = null;
|
1556
1486
|
}
|
1557
|
-
return;
|
1558
1487
|
}
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
const oldArray = scope[nodeAccessor + "!" /* LoopScopeArray */] || Array.from(oldMap.values());
|
1563
|
-
const parentNode = referenceIsMarker ? referenceNode.parentNode || oldArray[0].___startNode.parentNode : referenceNode;
|
1564
|
-
let newMap;
|
1565
|
-
let newArray;
|
1566
|
-
let afterReference;
|
1567
|
-
let needsReconciliation = true;
|
1568
|
-
forEach(valueOrOp, (key, args) => {
|
1569
|
-
let branch = oldMap.get(key);
|
1570
|
-
if (!branch) {
|
1571
|
-
branch = createBranchScopeWithRenderer(
|
1572
|
-
renderer,
|
1573
|
-
scope.$global,
|
1574
|
-
scope,
|
1575
|
-
parentNode
|
1576
|
-
);
|
1577
|
-
} else {
|
1488
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
1489
|
+
for (; newStart < newLength; ++newStart) {
|
1490
|
+
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
1578
1491
|
}
|
1579
|
-
|
1580
|
-
|
1492
|
+
for (; oldStart < oldLength; ++oldStart) {
|
1493
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
1581
1494
|
}
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1495
|
+
} else {
|
1496
|
+
i = oldLength - synced;
|
1497
|
+
while (i > 0) {
|
1498
|
+
oldBranch = aNullable[oldStart++];
|
1499
|
+
if (oldBranch !== null) {
|
1500
|
+
removeAndDestroyBranch(oldBranch);
|
1501
|
+
i--;
|
1502
|
+
}
|
1588
1503
|
}
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1504
|
+
if (pos === WRONG_POS) {
|
1505
|
+
const seq = longestIncreasingSubsequence(sources);
|
1506
|
+
j = seq.length - 1;
|
1507
|
+
k = newBranches.length;
|
1508
|
+
for (i = newLength - 1; i >= 0; --i) {
|
1509
|
+
if (sources[i] === -1) {
|
1510
|
+
pos = i + newStart;
|
1511
|
+
newBranch = newBranches[pos++];
|
1512
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1513
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1514
|
+
} else {
|
1515
|
+
if (j < 0 || i !== seq[j]) {
|
1516
|
+
pos = i + newStart;
|
1517
|
+
newBranch = newBranches[pos++];
|
1518
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1519
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1520
|
+
} else {
|
1521
|
+
--j;
|
1522
|
+
}
|
1523
|
+
}
|
1524
|
+
}
|
1525
|
+
} else if (synced !== newLength) {
|
1526
|
+
k = newBranches.length;
|
1527
|
+
for (i = newLength - 1; i >= 0; --i) {
|
1528
|
+
if (sources[i] === -1) {
|
1529
|
+
pos = i + newStart;
|
1530
|
+
newBranch = newBranches[pos++];
|
1531
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1532
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1533
|
+
}
|
1534
|
+
}
|
1601
1535
|
}
|
1602
1536
|
}
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1537
|
+
}
|
1538
|
+
}
|
1539
|
+
function longestIncreasingSubsequence(a) {
|
1540
|
+
const p = a.slice();
|
1541
|
+
const result = [0];
|
1542
|
+
let u;
|
1543
|
+
let v;
|
1544
|
+
for (let i = 0, il = a.length; i < il; ++i) {
|
1545
|
+
if (a[i] === -1) {
|
1546
|
+
continue;
|
1547
|
+
}
|
1548
|
+
const j = result[result.length - 1];
|
1549
|
+
if (a[j] < a[i]) {
|
1550
|
+
p[i] = j;
|
1551
|
+
result.push(i);
|
1552
|
+
continue;
|
1553
|
+
}
|
1554
|
+
u = 0;
|
1555
|
+
v = result.length - 1;
|
1556
|
+
while (u < v) {
|
1557
|
+
const c = (u + v) / 2 | 0;
|
1558
|
+
if (a[result[c]] < a[i]) {
|
1559
|
+
u = c + 1;
|
1610
1560
|
} else {
|
1611
|
-
|
1561
|
+
v = c;
|
1612
1562
|
}
|
1613
|
-
reconcile(parentNode, oldArray, newArray, afterReference);
|
1614
1563
|
}
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
}
|
1619
|
-
|
1620
|
-
|
1564
|
+
if (a[i] < a[result[u]]) {
|
1565
|
+
if (u > 0) {
|
1566
|
+
p[i] = result[u - 1];
|
1567
|
+
}
|
1568
|
+
result[u] = i;
|
1569
|
+
}
|
1570
|
+
}
|
1571
|
+
u = result.length;
|
1572
|
+
v = result[u - 1];
|
1573
|
+
while (u-- > 0) {
|
1574
|
+
result[u] = v;
|
1575
|
+
v = p[v];
|
1576
|
+
}
|
1577
|
+
return result;
|
1621
1578
|
}
|
1622
|
-
|
1623
|
-
|
1579
|
+
|
1580
|
+
// src/dom/walker.ts
|
1581
|
+
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
1582
|
+
function trimWalkString(walkString) {
|
1583
|
+
let end = walkString.length;
|
1584
|
+
while (walkString.charCodeAt(--end) > 47 /* BeginChild */) ;
|
1585
|
+
return walkString.slice(0, end + 1);
|
1624
1586
|
}
|
1625
|
-
function
|
1626
|
-
|
1587
|
+
function walk(startNode, walkCodes, branch) {
|
1588
|
+
walker.currentNode = startNode;
|
1589
|
+
walkInternal(0, walkCodes, branch);
|
1627
1590
|
}
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
} else {
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1591
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
1592
|
+
let value2;
|
1593
|
+
let storedMultiplier = 0;
|
1594
|
+
let currentMultiplier = 0;
|
1595
|
+
let currentScopeIndex = 0;
|
1596
|
+
for (; currentWalkIndex < walkCodes.length; ) {
|
1597
|
+
value2 = walkCodes.charCodeAt(currentWalkIndex++);
|
1598
|
+
currentMultiplier = storedMultiplier;
|
1599
|
+
storedMultiplier = 0;
|
1600
|
+
if (value2 === 32 /* Get */) {
|
1601
|
+
scope[true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++] = walker.currentNode;
|
1602
|
+
} else if (value2 === 37 /* Replace */) {
|
1603
|
+
walker.currentNode.replaceWith(
|
1604
|
+
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text()
|
1605
|
+
);
|
1606
|
+
} else if (value2 === 38 /* EndChild */) {
|
1607
|
+
return currentWalkIndex;
|
1608
|
+
} else if (value2 === 47 /* BeginChild */) {
|
1609
|
+
currentWalkIndex = walkInternal(
|
1610
|
+
currentWalkIndex,
|
1611
|
+
walkCodes,
|
1612
|
+
scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global, scope.___closestBranch)
|
1613
|
+
);
|
1614
|
+
} else if (value2 < 91 /* NextEnd */ + 1) {
|
1615
|
+
value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */;
|
1616
|
+
while (value2--) {
|
1617
|
+
walker.nextNode();
|
1618
|
+
}
|
1619
|
+
} else if (value2 < 106 /* OverEnd */ + 1) {
|
1620
|
+
value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */;
|
1621
|
+
while (value2--) {
|
1622
|
+
walker.nextSibling();
|
1623
|
+
}
|
1624
|
+
} else if (value2 < 116 /* OutEnd */ + 1) {
|
1625
|
+
value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */;
|
1626
|
+
while (value2--) {
|
1627
|
+
walker.parentNode();
|
1628
|
+
}
|
1629
|
+
walker.nextSibling();
|
1630
|
+
} else {
|
1631
|
+
if (value2 < 117 /* Multiplier */ || value2 > 126 /* MultiplierEnd */) {
|
1632
|
+
throw new Error(`Unknown walk code: ${value2}`);
|
1654
1633
|
}
|
1634
|
+
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
1655
1635
|
}
|
1656
|
-
isScheduled = true;
|
1657
|
-
queueMicrotask(flushAndWaitFrame);
|
1658
1636
|
}
|
1659
1637
|
}
|
1660
|
-
function
|
1661
|
-
if (
|
1662
|
-
|
1663
|
-
} else {
|
1664
|
-
|
1638
|
+
function getDebugKey(index, node) {
|
1639
|
+
if (typeof node === "string") {
|
1640
|
+
return `${node}/${index}`;
|
1641
|
+
} else if (node.nodeType === 3 /* Text */) {
|
1642
|
+
return `#text/${index}`;
|
1643
|
+
} else if (node.nodeType === 8 /* Comment */) {
|
1644
|
+
return `#comment/${index}`;
|
1645
|
+
} else if (node.nodeType === 1 /* Element */) {
|
1646
|
+
return `#${node.tagName.toLowerCase()}/${index}`;
|
1665
1647
|
}
|
1666
|
-
|
1667
|
-
}
|
1668
|
-
function triggerMacroTask() {
|
1669
|
-
port2.postMessage(0);
|
1648
|
+
return index;
|
1670
1649
|
}
|
1671
1650
|
|
1672
|
-
// src/dom/
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
scope,
|
1685
|
-
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1686
|
-
);
|
1687
|
-
} else if (scope[valueChangeAccessor]) {
|
1688
|
-
scope[valueChangeAccessor](valueOrOp);
|
1689
|
-
} else {
|
1690
|
-
schedule();
|
1691
|
-
queueSource(scope, valueSignal, valueOrOp);
|
1692
|
-
}
|
1693
|
-
return valueOrOp;
|
1694
|
-
};
|
1651
|
+
// src/dom/renderer.ts
|
1652
|
+
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
1653
|
+
const branch = createBranch(
|
1654
|
+
$global,
|
1655
|
+
renderer.___owner || parentScope,
|
1656
|
+
parentScope
|
1657
|
+
);
|
1658
|
+
if (true) {
|
1659
|
+
branch.___renderer = renderer;
|
1660
|
+
}
|
1661
|
+
initBranch(renderer, branch, parentNode);
|
1662
|
+
return branch;
|
1695
1663
|
}
|
1696
|
-
function
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
fn && fn(scope, valueOrOp);
|
1712
|
-
getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY);
|
1713
|
-
}
|
1714
|
-
}
|
1715
|
-
scope[markAccessor]--;
|
1716
|
-
}
|
1717
|
-
};
|
1664
|
+
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope, parentNode) {
|
1665
|
+
if (typeof tagNameOrRenderer !== "string") {
|
1666
|
+
return createBranchScopeWithRenderer(
|
1667
|
+
tagNameOrRenderer,
|
1668
|
+
$global,
|
1669
|
+
parentScope,
|
1670
|
+
parentNode
|
1671
|
+
);
|
1672
|
+
}
|
1673
|
+
const branch = createBranch($global, parentScope, parentScope);
|
1674
|
+
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
1675
|
+
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1676
|
+
tagNameOrRenderer
|
1677
|
+
);
|
1678
|
+
return branch;
|
1718
1679
|
}
|
1719
|
-
|
1720
|
-
|
1721
|
-
const
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
} else if (--scope[markAccessor] === 0) {
|
1733
|
-
if (op === DIRTY || scope[dirtyAccessor]) {
|
1734
|
-
scope[dirtyAccessor] = false;
|
1735
|
-
fn(scope);
|
1736
|
-
getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY);
|
1737
|
-
} else {
|
1738
|
-
getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN);
|
1739
|
-
}
|
1740
|
-
} else {
|
1741
|
-
scope[dirtyAccessor] ||= op === DIRTY;
|
1742
|
-
}
|
1743
|
-
};
|
1680
|
+
function createBranch($global, ownerScope, parentScope) {
|
1681
|
+
const branch = createScope($global);
|
1682
|
+
const parentBranch = parentScope.___closestBranch;
|
1683
|
+
branch._ = ownerScope;
|
1684
|
+
branch.___closestBranch = branch;
|
1685
|
+
if (parentBranch) {
|
1686
|
+
branch.___branchDepth = parentBranch.___branchDepth + 1;
|
1687
|
+
branch.___parentBranch = parentBranch;
|
1688
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
|
1689
|
+
} else {
|
1690
|
+
branch.___branchDepth = 1;
|
1691
|
+
}
|
1692
|
+
return branch;
|
1744
1693
|
}
|
1745
|
-
function
|
1746
|
-
const
|
1747
|
-
const
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
}
|
1759
|
-
ownerSignal._ = childSignal;
|
1760
|
-
return ownerSignal;
|
1694
|
+
function initBranch(renderer, branch, parentNode) {
|
1695
|
+
const clone = renderer.___clone(parentNode.namespaceURI);
|
1696
|
+
const cloneParent = clone.parentNode;
|
1697
|
+
if (cloneParent) {
|
1698
|
+
walk(cloneParent.firstChild, renderer.___walks, branch);
|
1699
|
+
branch.___startNode = cloneParent.firstChild;
|
1700
|
+
branch.___endNode = cloneParent.lastChild;
|
1701
|
+
} else {
|
1702
|
+
walk(clone, renderer.___walks, branch);
|
1703
|
+
branch.___startNode = branch.___endNode = clone;
|
1704
|
+
}
|
1705
|
+
if (renderer.___setup) {
|
1706
|
+
queueRender(branch, renderer.___setup);
|
1707
|
+
}
|
1761
1708
|
}
|
1762
|
-
function
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
const ifScope = scope[scopeAccessor];
|
1768
|
-
if (ifScope && !ifScope.___pending && scope[branchAccessor] === branch) {
|
1769
|
-
queueSource(ifScope, childSignal);
|
1709
|
+
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
1710
|
+
return (scope, attrsOrOp) => {
|
1711
|
+
const renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
|
1712
|
+
if (!renderer || attrsOrOp === DIRTY) {
|
1713
|
+
return;
|
1770
1714
|
}
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
}
|
1775
|
-
function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
1776
|
-
const subscribersAccessor = "?" /* Dynamic */ + accessorId++;
|
1777
|
-
const childSignal = closure(
|
1778
|
-
valueAccessor,
|
1779
|
-
fn,
|
1780
|
-
getIntersection,
|
1781
|
-
getOwnerScope
|
1782
|
-
);
|
1783
|
-
const ownerSignal = (ownerScope) => {
|
1784
|
-
const subscribers = ownerScope[subscribersAccessor];
|
1785
|
-
if (subscribers) {
|
1786
|
-
for (const subscriber of subscribers) {
|
1787
|
-
if (!subscriber.___pending) {
|
1788
|
-
queueSource(subscriber, childSignal);
|
1789
|
-
}
|
1790
|
-
}
|
1715
|
+
const childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1716
|
+
if (attrsOrOp === MARK || attrsOrOp === CLEAN) {
|
1717
|
+
return renderer.___args?.(childScope, attrsOrOp);
|
1791
1718
|
}
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1719
|
+
const content = getContent?.(scope);
|
1720
|
+
if (typeof renderer === "string") {
|
1721
|
+
const nodeAccessor2 = true ? `#${renderer}/0` : 0;
|
1722
|
+
if (renderer === "textarea" && content) {
|
1723
|
+
throw new Error(
|
1724
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
1725
|
+
);
|
1726
|
+
}
|
1727
|
+
setConditionalRenderer(
|
1728
|
+
childScope,
|
1729
|
+
nodeAccessor2,
|
1730
|
+
content,
|
1731
|
+
createBranchScopeWithTagNameOrRenderer
|
1732
|
+
);
|
1733
|
+
attrs(childScope, nodeAccessor2, attrsOrOp());
|
1734
|
+
} else if (renderer.___args) {
|
1735
|
+
const attributes = attrsOrOp();
|
1736
|
+
renderer.___args(
|
1737
|
+
childScope,
|
1738
|
+
inputIsArgs ? attributes : [
|
1739
|
+
content ? {
|
1740
|
+
...attributes,
|
1741
|
+
content
|
1742
|
+
} : attributes
|
1743
|
+
]
|
1801
1744
|
);
|
1802
1745
|
}
|
1803
1746
|
};
|
1804
|
-
ownerSignal.___subscribe = subscribe;
|
1805
|
-
ownerSignal._ = (scope) => {
|
1806
|
-
childSignal(scope);
|
1807
|
-
subscribe(scope);
|
1808
|
-
};
|
1809
|
-
return ownerSignal;
|
1810
|
-
}
|
1811
|
-
function registerDynamicClosure(id, valueAccessor, fn, getIntersection, getOwnerScope) {
|
1812
|
-
const signal = dynamicClosure(
|
1813
|
-
valueAccessor,
|
1814
|
-
fn,
|
1815
|
-
getIntersection,
|
1816
|
-
getOwnerScope
|
1817
|
-
);
|
1818
|
-
register(id, signal.___subscribe);
|
1819
|
-
return signal;
|
1820
1747
|
}
|
1821
|
-
function
|
1822
|
-
let
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1748
|
+
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
1749
|
+
let args;
|
1750
|
+
const id = true ? Symbol("Marko Renderer") : {};
|
1751
|
+
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
1752
|
+
return (owner) => {
|
1753
|
+
return {
|
1754
|
+
___id: id,
|
1755
|
+
___template: template,
|
1756
|
+
___walks: walks,
|
1757
|
+
___setup: setup,
|
1758
|
+
___clone: _clone,
|
1759
|
+
___owner: owner,
|
1760
|
+
get ___args() {
|
1761
|
+
return args ||= getArgs?.();
|
1762
|
+
}
|
1763
|
+
};
|
1829
1764
|
};
|
1830
1765
|
}
|
1831
|
-
function
|
1832
|
-
|
1833
|
-
}
|
1834
|
-
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1835
|
-
function setTagVarChange(scope, changeHandler) {
|
1836
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
1766
|
+
function createRenderer(template, walks, setup, getArgs) {
|
1767
|
+
return createRendererWithOwner(template, walks, setup, getArgs)();
|
1837
1768
|
}
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1769
|
+
function _clone(ns) {
|
1770
|
+
return ((cloneCache[ns] ||= {})[this.___template] ||= createCloneableHTML(
|
1771
|
+
this.___template,
|
1772
|
+
ns
|
1773
|
+
))();
|
1844
1774
|
}
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1775
|
+
var cloneCache = {};
|
1776
|
+
function createCloneableHTML(html2, ns) {
|
1777
|
+
const { firstChild, lastChild } = parseHTML(html2, ns);
|
1778
|
+
const parent = document.createElementNS(ns, "t");
|
1779
|
+
insertChildNodes(parent, null, firstChild, lastChild);
|
1780
|
+
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? () => firstChild.cloneNode(true) : () => parent.cloneNode(true).firstChild;
|
1849
1781
|
}
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1782
|
+
|
1783
|
+
// src/dom/control-flow.ts
|
1784
|
+
function conditional(nodeAccessor, ...branches) {
|
1785
|
+
const branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1786
|
+
return (scope, newBranchIndexOrOp) => {
|
1787
|
+
if (newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN) {
|
1788
|
+
setConditionalRenderer(
|
1789
|
+
scope,
|
1790
|
+
nodeAccessor,
|
1791
|
+
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
1792
|
+
createBranchScopeWithRenderer
|
1793
|
+
);
|
1854
1794
|
}
|
1855
1795
|
};
|
1856
1796
|
}
|
1857
|
-
function
|
1858
|
-
|
1859
|
-
return (scope) => {
|
1860
|
-
queueEffect(scope, fn);
|
1861
|
-
};
|
1862
|
-
}
|
1863
|
-
|
1864
|
-
// src/dom/queue.ts
|
1865
|
-
var pendingRenders = [];
|
1866
|
-
var pendingEffects = [];
|
1867
|
-
var rendering = false;
|
1868
|
-
function queueSource(scope, signal, value2) {
|
1869
|
-
const prevRendering = rendering;
|
1870
|
-
rendering = true;
|
1871
|
-
signal(scope, MARK);
|
1872
|
-
rendering = prevRendering;
|
1873
|
-
queueRender(scope, signal, value2);
|
1797
|
+
function patchDynamicTag(fn) {
|
1798
|
+
dynamicTag = fn(dynamicTag);
|
1874
1799
|
}
|
1875
|
-
function
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1800
|
+
var dynamicTag = function dynamicTag2(nodeAccessor, fn, getIntersection) {
|
1801
|
+
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1802
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1803
|
+
return (scope, newRendererOrOp) => {
|
1804
|
+
if (newRendererOrOp === DIRTY) return;
|
1805
|
+
const currentRenderer = scope[rendererAccessor];
|
1806
|
+
let op = newRendererOrOp;
|
1807
|
+
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1808
|
+
if (isDifferentRenderer(
|
1809
|
+
currentRenderer,
|
1810
|
+
scope[rendererAccessor] = normalizeDynamicRenderer(newRendererOrOp)
|
1811
|
+
)) {
|
1812
|
+
setConditionalRenderer(
|
1813
|
+
scope,
|
1814
|
+
nodeAccessor,
|
1815
|
+
scope[rendererAccessor],
|
1816
|
+
createBranchScopeWithTagNameOrRenderer
|
1817
|
+
);
|
1818
|
+
fn && fn(scope);
|
1819
|
+
op = DIRTY;
|
1820
|
+
} else {
|
1821
|
+
op = CLEAN;
|
1822
|
+
}
|
1823
|
+
}
|
1824
|
+
intersection2?.(scope, op);
|
1883
1825
|
};
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1826
|
+
};
|
1827
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1828
|
+
const referenceNode = scope[nodeAccessor];
|
1829
|
+
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1830
|
+
const parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.___startNode || referenceNode).parentNode : referenceNode;
|
1831
|
+
const newBranch = scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && createBranch2(newRenderer, scope.$global, scope, parentNode);
|
1832
|
+
if (referenceNode === parentNode) {
|
1833
|
+
if (prevBranch) {
|
1834
|
+
destroyBranch(prevBranch);
|
1835
|
+
referenceNode.textContent = "";
|
1836
|
+
}
|
1837
|
+
if (newBranch) {
|
1838
|
+
insertBranchBefore(newBranch, parentNode, null);
|
1839
|
+
}
|
1840
|
+
} else if (prevBranch) {
|
1841
|
+
if (newBranch) {
|
1842
|
+
insertBranchBefore(newBranch, parentNode, prevBranch.___startNode);
|
1843
|
+
} else {
|
1844
|
+
parentNode.insertBefore(referenceNode, prevBranch.___startNode);
|
1845
|
+
}
|
1846
|
+
removeAndDestroyBranch(prevBranch);
|
1847
|
+
} else if (newBranch) {
|
1848
|
+
insertBranchBefore(newBranch, parentNode, referenceNode);
|
1849
|
+
referenceNode.remove();
|
1891
1850
|
}
|
1892
|
-
pendingRenders[i] = render;
|
1893
1851
|
}
|
1894
|
-
function
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1852
|
+
function loopOf(nodeAccessor, renderer) {
|
1853
|
+
return loop(
|
1854
|
+
nodeAccessor,
|
1855
|
+
renderer,
|
1856
|
+
([all, by = bySecondArg], cb) => {
|
1857
|
+
if (typeof by === "string") {
|
1858
|
+
forOf(
|
1859
|
+
all,
|
1860
|
+
(item, i) => cb(item[by], [item, i])
|
1861
|
+
);
|
1862
|
+
} else {
|
1863
|
+
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
);
|
1908
1867
|
}
|
1909
|
-
function
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
rendering = true;
|
1916
|
-
fn();
|
1917
|
-
runRenders();
|
1918
|
-
} finally {
|
1919
|
-
rendering = false;
|
1920
|
-
pendingRenders = prevRenders;
|
1921
|
-
pendingEffects = prevEffects;
|
1922
|
-
}
|
1923
|
-
return preparedEffects;
|
1868
|
+
function loopIn(nodeAccessor, renderer) {
|
1869
|
+
return loop(
|
1870
|
+
nodeAccessor,
|
1871
|
+
renderer,
|
1872
|
+
([obj, by = byFirstArg], cb) => forIn(obj, (key, value2) => cb(by(key, value2), [key, value2]))
|
1873
|
+
);
|
1924
1874
|
}
|
1925
|
-
function
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1875
|
+
function loopTo(nodeAccessor, renderer) {
|
1876
|
+
return loop(
|
1877
|
+
nodeAccessor,
|
1878
|
+
renderer,
|
1879
|
+
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
1880
|
+
);
|
1931
1881
|
}
|
1932
|
-
function
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
if (
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
let bestChild = (i << 1) + 1;
|
1942
|
-
const right = bestChild + 1;
|
1943
|
-
if (right < pendingRenders.length && comparePendingRenders(
|
1944
|
-
pendingRenders[right],
|
1945
|
-
pendingRenders[bestChild]
|
1946
|
-
) < 0) {
|
1947
|
-
bestChild = right;
|
1882
|
+
function loop(nodeAccessor, renderer, forEach) {
|
1883
|
+
const loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */;
|
1884
|
+
const params = renderer.___args;
|
1885
|
+
return (scope, valueOrOp) => {
|
1886
|
+
if (valueOrOp === DIRTY) {
|
1887
|
+
} else if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1888
|
+
if (params) {
|
1889
|
+
for (const branch of scope[loopScopeAccessor] || scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() || []) {
|
1890
|
+
params(branch, valueOrOp);
|
1948
1891
|
}
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1892
|
+
}
|
1893
|
+
} else {
|
1894
|
+
const referenceNode = scope[nodeAccessor];
|
1895
|
+
const oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */];
|
1896
|
+
const oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
|
1897
|
+
...oldMap.values()
|
1898
|
+
] : [];
|
1899
|
+
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].___startNode.parentNode : referenceNode;
|
1900
|
+
const newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map();
|
1901
|
+
const newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
|
1902
|
+
forEach(valueOrOp, (key, args) => {
|
1903
|
+
const branch = oldMap?.get(key) || createBranchScopeWithRenderer(
|
1904
|
+
renderer,
|
1905
|
+
scope.$global,
|
1906
|
+
scope,
|
1907
|
+
parentNode
|
1908
|
+
);
|
1909
|
+
params?.(branch, args);
|
1910
|
+
newMap.set(key, branch);
|
1911
|
+
newArray.push(branch);
|
1912
|
+
});
|
1913
|
+
let afterReference = null;
|
1914
|
+
if (referenceNode !== parentNode) {
|
1915
|
+
if (oldArray.length) {
|
1916
|
+
afterReference = oldArray[oldArray.length - 1].___endNode.nextSibling;
|
1917
|
+
if (!newArray.length) {
|
1918
|
+
parentNode.insertBefore(referenceNode, afterReference);
|
1919
|
+
}
|
1920
|
+
} else if (newArray.length) {
|
1921
|
+
afterReference = referenceNode.nextSibling;
|
1922
|
+
referenceNode.remove();
|
1954
1923
|
}
|
1955
1924
|
}
|
1956
|
-
|
1957
|
-
}
|
1958
|
-
if (!render.___scope.___closestBranch?.___destroyed) {
|
1959
|
-
render.___signal(render.___scope, render.___value);
|
1925
|
+
reconcile(parentNode, oldArray, newArray, afterReference);
|
1960
1926
|
}
|
1961
|
-
}
|
1962
|
-
finishPendingScopes();
|
1963
|
-
}
|
1964
|
-
function comparePendingRenders(a, b) {
|
1965
|
-
return a.___depth - b.___depth || a.___index - b.___index;
|
1927
|
+
};
|
1966
1928
|
}
|
1967
|
-
|
1968
|
-
|
1969
|
-
function resetAbortSignal(scope, id) {
|
1970
|
-
const ctrl = scope.___abortControllers?.[id];
|
1971
|
-
if (ctrl) {
|
1972
|
-
queueEffect(ctrl, abort);
|
1973
|
-
scope.___abortControllers[id] = void 0;
|
1974
|
-
}
|
1929
|
+
function bySecondArg(_item, index) {
|
1930
|
+
return index;
|
1975
1931
|
}
|
1976
|
-
function
|
1977
|
-
|
1978
|
-
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1979
|
-
}
|
1980
|
-
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1932
|
+
function byFirstArg(name) {
|
1933
|
+
return name;
|
1981
1934
|
}
|
1982
|
-
function
|
1983
|
-
|
1935
|
+
function isDifferentRenderer(a, b) {
|
1936
|
+
return a !== b && (a?.___id || 0) !== b?.___id;
|
1984
1937
|
}
|
1985
1938
|
|
1986
|
-
// src/common/compat-meta.ts
|
1987
|
-
var prefix = true ? "$compat_" : "$C_";
|
1988
|
-
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1989
|
-
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1990
|
-
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
1991
|
-
|
1992
1939
|
// src/dom/compat.ts
|
1993
1940
|
var classIdToBranch = /* @__PURE__ */ new Map();
|
1994
1941
|
var compat = {
|