marko 6.0.0-next.3.62 → 6.0.0-next.3.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/types.d.ts +2 -1
- package/dist/debug/dom.js +122 -84
- package/dist/debug/dom.mjs +122 -84
- package/dist/debug/html.js +81 -36
- package/dist/debug/html.mjs +81 -36
- package/dist/dom/control-flow.d.ts +1 -0
- package/dist/dom/queue.d.ts +4 -2
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.js +117 -108
- package/dist/dom.mjs +117 -108
- package/dist/html.js +32 -17
- package/dist/html.mjs +32 -17
- package/package.json +1 -1
package/dist/dom.js
CHANGED
@@ -285,7 +285,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
285
285
|
let parentBranchId = parentBranchIds.get(scopeId);
|
286
286
|
if (parentBranchId && (scope.j = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
287
287
|
let branch = scope, parentBranch = branch.j;
|
288
|
-
scope.j = branch, parentBranch && (branch.
|
288
|
+
scope.j = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
|
289
289
|
branch
|
290
290
|
));
|
291
291
|
}
|
@@ -719,7 +719,7 @@ var pendingScopes = [];
|
|
719
719
|
function createScope($global, closestBranch) {
|
720
720
|
let scope = {
|
721
721
|
l: $global.m++,
|
722
|
-
|
722
|
+
n: 1,
|
723
723
|
j: closestBranch,
|
724
724
|
$global
|
725
725
|
};
|
@@ -730,16 +730,22 @@ function skipScope(scope) {
|
|
730
730
|
}
|
731
731
|
function finishPendingScopes() {
|
732
732
|
for (let scope of pendingScopes)
|
733
|
-
scope.
|
733
|
+
scope.n = 0;
|
734
734
|
pendingScopes = [];
|
735
735
|
}
|
736
|
+
function findBranchWithKey(scope, key) {
|
737
|
+
let branch = scope.j;
|
738
|
+
for (; branch && !branch[key]; )
|
739
|
+
branch = branch.t;
|
740
|
+
return branch;
|
741
|
+
}
|
736
742
|
function destroyBranch(branch) {
|
737
|
-
branch.
|
743
|
+
branch.t?.z?.delete(branch), destroyNestedBranches(branch);
|
738
744
|
}
|
739
745
|
function destroyNestedBranches(branch) {
|
740
|
-
branch.
|
741
|
-
for (let id in scope.
|
742
|
-
scope.
|
746
|
+
branch.o = 1, branch.z?.forEach(destroyNestedBranches), branch.I?.forEach((scope) => {
|
747
|
+
for (let id in scope.u)
|
748
|
+
scope.u[id]?.abort();
|
743
749
|
});
|
744
750
|
}
|
745
751
|
function removeAndDestroyBranch(branch) {
|
@@ -879,7 +885,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
879
885
|
// src/dom/renderer.ts
|
880
886
|
function createBranch($global, renderer, parentScope, parentNode) {
|
881
887
|
let branch = createScope($global), parentBranch = parentScope?.j;
|
882
|
-
return branch._ = renderer.
|
888
|
+
return branch._ = renderer.x || parentScope, branch.j = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(branch)), renderer.A?.(
|
883
889
|
branch,
|
884
890
|
parentNode.namespaceURI
|
885
891
|
), branch;
|
@@ -916,11 +922,11 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
916
922
|
return (owner) => ({
|
917
923
|
l: id,
|
918
924
|
A: clone,
|
919
|
-
|
925
|
+
x: owner,
|
920
926
|
B: setup,
|
921
927
|
k: params,
|
922
928
|
D: closures,
|
923
|
-
|
929
|
+
y: dynamicScopesAccessor
|
924
930
|
});
|
925
931
|
}
|
926
932
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -994,7 +1000,7 @@ function value(valueAccessor, fn = () => {
|
|
994
1000
|
}
|
995
1001
|
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
|
996
1002
|
return (scope) => {
|
997
|
-
scope.
|
1003
|
+
scope.n ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
998
1004
|
};
|
999
1005
|
}
|
1000
1006
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -1004,7 +1010,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1004
1010
|
ownerScope,
|
1005
1011
|
() => {
|
1006
1012
|
for (let scope of scopes)
|
1007
|
-
!scope.
|
1013
|
+
!scope.n && !scope.o && childSignal(scope);
|
1008
1014
|
},
|
1009
1015
|
-1,
|
1010
1016
|
0,
|
@@ -1016,7 +1022,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1016
1022
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
1017
1023
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
1018
1024
|
let ifScope = scope[scopeAccessor];
|
1019
|
-
ifScope && !ifScope.
|
1025
|
+
ifScope && !ifScope.n && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
1020
1026
|
};
|
1021
1027
|
return ownerSignal._ = childSignal, ownerSignal;
|
1022
1028
|
}
|
@@ -1030,11 +1036,11 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1030
1036
|
function dynamicClosure(...closureSignals) {
|
1031
1037
|
let [{ E: ___scopeInstancesAccessor, F: ___signalIndexAccessor }] = closureSignals;
|
1032
1038
|
for (let i = closureSignals.length; i--; )
|
1033
|
-
closureSignals[i].
|
1039
|
+
closureSignals[i].J = i;
|
1034
1040
|
return (scope) => {
|
1035
1041
|
if (scope[___scopeInstancesAccessor])
|
1036
1042
|
for (let childScope of scope[___scopeInstancesAccessor])
|
1037
|
-
childScope.
|
1043
|
+
childScope.n || queueRender(
|
1038
1044
|
childScope,
|
1039
1045
|
closureSignals[childScope[___signalIndexAccessor]],
|
1040
1046
|
-1
|
@@ -1043,7 +1049,7 @@ function dynamicClosure(...closureSignals) {
|
|
1043
1049
|
}
|
1044
1050
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1045
1051
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
1046
|
-
scope[closureSignal.F] = closureSignal.
|
1052
|
+
scope[closureSignal.F] = closureSignal.J, childSignal(scope), subscribeToScopeSet(
|
1047
1053
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1048
1054
|
closureSignal.E,
|
1049
1055
|
scope
|
@@ -1091,71 +1097,53 @@ function hoist(...path) {
|
|
1091
1097
|
function awaitTag(nodeAccessor, renderer) {
|
1092
1098
|
let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
|
1093
1099
|
return (scope, promise) => {
|
1094
|
-
let
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
if (scope.j?.
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
namespaceNode
|
1108
|
-
),
|
1109
|
-
referenceNode.parentNode,
|
1110
|
-
referenceNode
|
1111
|
-
), referenceNode.remove()), renderer.k?.(awaitBranch, [data2]);
|
1112
|
-
});
|
1113
|
-
if (tryBranch) {
|
1114
|
-
if (!--tryBranch.y) {
|
1115
|
-
let placeholderBranch = tryBranch.c;
|
1116
|
-
placeholderBranch ? (insertBranchBefore(
|
1117
|
-
tryBranch,
|
1118
|
-
placeholderBranch.g.parentNode,
|
1119
|
-
placeholderBranch.g
|
1120
|
-
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1121
|
-
tryBranch,
|
1100
|
+
let tryWithPlaceholder = findBranchWithKey(
|
1101
|
+
scope,
|
1102
|
+
"d" /* PlaceholderContent */
|
1103
|
+
), awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.g ?? referenceNode).parentNode, thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1104
|
+
if (!(scope.j?.o || scope[promiseAccessor] !== thisPromise) && (scope[promiseAccessor] = void 0, runEffects(
|
1105
|
+
prepareEffects(() => {
|
1106
|
+
tryWithPlaceholder && placeholderShown.add(pendingEffects), (!awaitBranch || !tryWithPlaceholder) && (insertBranchBefore(
|
1107
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1108
|
+
scope.$global,
|
1109
|
+
renderer,
|
1110
|
+
scope,
|
1111
|
+
namespaceNode
|
1112
|
+
),
|
1122
1113
|
referenceNode.parentNode,
|
1123
1114
|
referenceNode
|
1124
|
-
);
|
1125
|
-
}
|
1126
|
-
|
1127
|
-
|
1115
|
+
), referenceNode.remove()), renderer.k?.(awaitBranch, [data2]);
|
1116
|
+
})
|
1117
|
+
), tryWithPlaceholder && !--tryWithPlaceholder.p)) {
|
1118
|
+
let placeholderBranch = tryWithPlaceholder.c;
|
1119
|
+
tryWithPlaceholder.c = void 0, placeholderBranch ? (insertBranchBefore(
|
1120
|
+
tryWithPlaceholder,
|
1121
|
+
placeholderBranch.g.parentNode,
|
1122
|
+
placeholderBranch.g
|
1123
|
+
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1124
|
+
tryWithPlaceholder,
|
1125
|
+
referenceNode.parentNode,
|
1126
|
+
referenceNode
|
1127
|
+
), tryWithPlaceholder.G && runEffects(tryWithPlaceholder.G, !0);
|
1128
|
+
}
|
1128
1129
|
}).catch((error) => {
|
1129
|
-
|
1130
|
-
for (; tryBranch2 && !tryBranch2.b; )
|
1131
|
-
tryBranch2 = tryBranch2.n;
|
1132
|
-
tryBranch2 ? (setConditionalRenderer(
|
1133
|
-
tryBranch2._,
|
1134
|
-
tryBranch2.a,
|
1135
|
-
tryBranch2.b,
|
1136
|
-
createAndSetupBranch
|
1137
|
-
), tryBranch2.b.k?.(
|
1138
|
-
tryBranch2._["d" /* ConditionalScope */ + tryBranch2.a],
|
1139
|
-
[error]
|
1140
|
-
)) : setTimeout(() => {
|
1141
|
-
throw error;
|
1142
|
-
});
|
1130
|
+
renderCatch(scope, error, !0);
|
1143
1131
|
});
|
1144
|
-
|
1145
|
-
if (
|
1146
|
-
let placeholderBranch =
|
1132
|
+
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.p || (tryWithPlaceholder.p = 0, requestAnimationFrame(() => {
|
1133
|
+
if (tryWithPlaceholder.p && !tryWithPlaceholder.o) {
|
1134
|
+
let placeholderBranch = tryWithPlaceholder.c = createAndSetupBranch(
|
1147
1135
|
scope.$global,
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1136
|
+
tryWithPlaceholder.d,
|
1137
|
+
tryWithPlaceholder._,
|
1138
|
+
tryWithPlaceholder.g.parentNode
|
1151
1139
|
);
|
1152
1140
|
insertBranchBefore(
|
1153
1141
|
placeholderBranch,
|
1154
|
-
|
1155
|
-
|
1156
|
-
), tempDetatchBranch(
|
1142
|
+
tryWithPlaceholder.g.parentNode,
|
1143
|
+
tryWithPlaceholder.g
|
1144
|
+
), tempDetatchBranch(tryWithPlaceholder);
|
1157
1145
|
}
|
1158
|
-
})),
|
1146
|
+
})), tryWithPlaceholder.p++) : awaitBranch && (awaitBranch.g.parentNode.insertBefore(
|
1159
1147
|
referenceNode,
|
1160
1148
|
awaitBranch.g
|
1161
1149
|
), tempDetatchBranch(awaitBranch));
|
@@ -1176,6 +1164,26 @@ function createTry(nodeAccessor, tryContent) {
|
|
1176
1164
|
));
|
1177
1165
|
};
|
1178
1166
|
}
|
1167
|
+
function renderCatch(scope, error, async) {
|
1168
|
+
let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
|
1169
|
+
if (tryWithCatch) {
|
1170
|
+
let placeholderBranch = tryWithCatch.c;
|
1171
|
+
placeholderBranch && (tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
|
1172
|
+
tryWithCatch._,
|
1173
|
+
tryWithCatch.a,
|
1174
|
+
tryWithCatch.b,
|
1175
|
+
createAndSetupBranch
|
1176
|
+
), tryWithCatch.b.k?.(
|
1177
|
+
tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
|
1178
|
+
[error]
|
1179
|
+
);
|
1180
|
+
} else if (async)
|
1181
|
+
setTimeout(() => {
|
1182
|
+
throw error;
|
1183
|
+
});
|
1184
|
+
else
|
1185
|
+
throw error;
|
1186
|
+
}
|
1179
1187
|
function conditional(nodeAccessor, ...branches) {
|
1180
1188
|
let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1181
1189
|
return (scope, newBranch) => {
|
@@ -1208,15 +1216,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1208
1216
|
0,
|
1209
1217
|
content,
|
1210
1218
|
createAndSetupBranch
|
1211
|
-
), content.
|
1212
|
-
content.u,
|
1219
|
+
), content.y && subscribeToScopeSet(
|
1213
1220
|
content.x,
|
1221
|
+
content.y,
|
1214
1222
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1215
1223
|
);
|
1216
1224
|
}
|
1217
|
-
} else normalizedRenderer?.
|
1218
|
-
normalizedRenderer.u,
|
1225
|
+
} else normalizedRenderer?.y && subscribeToScopeSet(
|
1219
1226
|
normalizedRenderer.x,
|
1227
|
+
normalizedRenderer.y,
|
1220
1228
|
scope[childScopeAccessor]
|
1221
1229
|
);
|
1222
1230
|
if (normalizedRenderer) {
|
@@ -1310,21 +1318,21 @@ function byFirstArg(name) {
|
|
1310
1318
|
}
|
1311
1319
|
|
1312
1320
|
// src/dom/queue.ts
|
1313
|
-
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1321
|
+
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1314
1322
|
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.l) {
|
1315
1323
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1316
1324
|
if (existingRender)
|
1317
|
-
existingRender.
|
1325
|
+
existingRender.H = value2;
|
1318
1326
|
else {
|
1319
1327
|
let render = {
|
1320
|
-
|
1328
|
+
q: key,
|
1321
1329
|
C: scope,
|
1322
|
-
|
1323
|
-
|
1330
|
+
K: signal,
|
1331
|
+
H: value2
|
1324
1332
|
}, i = pendingRenders.push(render) - 1;
|
1325
1333
|
for (; i; ) {
|
1326
1334
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1327
|
-
if (key - parent.
|
1335
|
+
if (key - parent.q >= 0) break;
|
1328
1336
|
pendingRenders[i] = parent, i = parentIndex;
|
1329
1337
|
}
|
1330
1338
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1352,62 +1360,63 @@ function prepareEffects(fn) {
|
|
1352
1360
|
}
|
1353
1361
|
return preparedEffects;
|
1354
1362
|
}
|
1355
|
-
|
1363
|
+
var runEffects = (effects) => {
|
1356
1364
|
for (let i = 0, scope; i < effects.length; )
|
1357
1365
|
effects[i++](
|
1358
1366
|
scope = effects[i++],
|
1359
1367
|
scope
|
1360
1368
|
);
|
1361
|
-
}
|
1369
|
+
};
|
1362
1370
|
function runRenders() {
|
1363
1371
|
for (; pendingRenders.length; ) {
|
1364
1372
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1365
1373
|
if (render !== item) {
|
1366
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1374
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).q;
|
1367
1375
|
for (; i < mid; ) {
|
1368
1376
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1369
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
1377
|
+
if (right < pendingRenders.length && pendingRenders[right].q - pendingRenders[bestChild].q < 0 && (bestChild = right), pendingRenders[bestChild].q - key >= 0)
|
1370
1378
|
break;
|
1371
1379
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1372
1380
|
}
|
1373
1381
|
pendingRenders[i] = item;
|
1374
1382
|
}
|
1375
|
-
render.C.j?.
|
1383
|
+
render.C.j?.o || runRender(render);
|
1376
1384
|
}
|
1377
1385
|
finishPendingScopes();
|
1378
1386
|
}
|
1379
|
-
var runRender = (render) => render.
|
1387
|
+
var runRender = (render) => render.K(render.C, render.H), enableCatch = () => {
|
1380
1388
|
enableCatch = () => {
|
1381
|
-
}
|
1389
|
+
};
|
1390
|
+
let handlePendingTry = (fn, scope, branch) => {
|
1391
|
+
for (; branch; ) {
|
1392
|
+
if (branch.p)
|
1393
|
+
return (branch.G ||= []).push(fn, scope);
|
1394
|
+
branch = branch.t;
|
1395
|
+
}
|
1396
|
+
};
|
1397
|
+
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1398
|
+
if (checkPending || caughtError.has(effects)) {
|
1399
|
+
let i = 0, fn, scope, branch;
|
1400
|
+
for (; i < effects.length; )
|
1401
|
+
fn = effects[i++], scope = effects[i++], branch = scope.j, !branch?.o && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1402
|
+
} else
|
1403
|
+
runEffects2(effects);
|
1404
|
+
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1382
1405
|
try {
|
1383
1406
|
runRender2(render);
|
1384
1407
|
} catch (error) {
|
1385
|
-
|
1386
|
-
for (; branch && !branch.b; )
|
1387
|
-
branch = branch.n;
|
1388
|
-
if (branch)
|
1389
|
-
setConditionalRenderer(
|
1390
|
-
branch._,
|
1391
|
-
branch.a,
|
1392
|
-
branch.b,
|
1393
|
-
createAndSetupBranch
|
1394
|
-
), branch.b.k?.(
|
1395
|
-
branch._["d" /* ConditionalScope */ + branch.a],
|
1396
|
-
[error]
|
1397
|
-
);
|
1398
|
-
else
|
1399
|
-
throw error;
|
1408
|
+
renderCatch(render.C, error);
|
1400
1409
|
}
|
1401
1410
|
})(runRender);
|
1402
1411
|
};
|
1403
1412
|
|
1404
1413
|
// src/dom/abort-signal.ts
|
1405
1414
|
function resetAbortSignal(scope, id) {
|
1406
|
-
let ctrl = scope.
|
1407
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1415
|
+
let ctrl = scope.u?.[id];
|
1416
|
+
ctrl && (queueEffect(ctrl, abort), scope.u[id] = void 0);
|
1408
1417
|
}
|
1409
1418
|
function getAbortSignal(scope, id) {
|
1410
|
-
return scope.j && (scope.j.
|
1419
|
+
return scope.j && (scope.j.I ||= /* @__PURE__ */ new Set()).add(scope), ((scope.u ||= {})[id] ||= new AbortController()).signal;
|
1411
1420
|
}
|
1412
1421
|
function abort(ctrl) {
|
1413
1422
|
ctrl.abort();
|
@@ -1472,7 +1481,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1472
1481
|
branch ? existing = !0 : (out.global.m ||= 0, branch = component.scope = createAndSetupBranch(
|
1473
1482
|
out.global,
|
1474
1483
|
renderer,
|
1475
|
-
renderer.
|
1484
|
+
renderer.x,
|
1476
1485
|
document.body
|
1477
1486
|
)), renderer.k?.(branch, renderer._ ? args[0] : args);
|
1478
1487
|
}), !existing)
|