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