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.mjs
CHANGED
@@ -200,7 +200,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
200
200
|
let parentBranchId = parentBranchIds.get(scopeId);
|
201
201
|
if (parentBranchId && (scope.j = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
202
202
|
let branch = scope, parentBranch = branch.j;
|
203
|
-
scope.j = branch, parentBranch && (branch.
|
203
|
+
scope.j = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
|
204
204
|
branch
|
205
205
|
));
|
206
206
|
}
|
@@ -634,7 +634,7 @@ var pendingScopes = [];
|
|
634
634
|
function createScope($global, closestBranch) {
|
635
635
|
let scope = {
|
636
636
|
l: $global.m++,
|
637
|
-
|
637
|
+
n: 1,
|
638
638
|
j: closestBranch,
|
639
639
|
$global
|
640
640
|
};
|
@@ -645,16 +645,22 @@ function skipScope(scope) {
|
|
645
645
|
}
|
646
646
|
function finishPendingScopes() {
|
647
647
|
for (let scope of pendingScopes)
|
648
|
-
scope.
|
648
|
+
scope.n = 0;
|
649
649
|
pendingScopes = [];
|
650
650
|
}
|
651
|
+
function findBranchWithKey(scope, key) {
|
652
|
+
let branch = scope.j;
|
653
|
+
for (; branch && !branch[key]; )
|
654
|
+
branch = branch.t;
|
655
|
+
return branch;
|
656
|
+
}
|
651
657
|
function destroyBranch(branch) {
|
652
|
-
branch.
|
658
|
+
branch.t?.z?.delete(branch), destroyNestedBranches(branch);
|
653
659
|
}
|
654
660
|
function destroyNestedBranches(branch) {
|
655
|
-
branch.
|
656
|
-
for (let id in scope.
|
657
|
-
scope.
|
661
|
+
branch.o = 1, branch.z?.forEach(destroyNestedBranches), branch.I?.forEach((scope) => {
|
662
|
+
for (let id in scope.u)
|
663
|
+
scope.u[id]?.abort();
|
658
664
|
});
|
659
665
|
}
|
660
666
|
function removeAndDestroyBranch(branch) {
|
@@ -794,7 +800,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
794
800
|
// src/dom/renderer.ts
|
795
801
|
function createBranch($global, renderer, parentScope, parentNode) {
|
796
802
|
let branch = createScope($global), parentBranch = parentScope?.j;
|
797
|
-
return branch._ = renderer.
|
803
|
+
return branch._ = renderer.x || parentScope, branch.j = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(branch)), renderer.A?.(
|
798
804
|
branch,
|
799
805
|
parentNode.namespaceURI
|
800
806
|
), branch;
|
@@ -831,11 +837,11 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
831
837
|
return (owner) => ({
|
832
838
|
l: id,
|
833
839
|
A: clone,
|
834
|
-
|
840
|
+
x: owner,
|
835
841
|
B: setup,
|
836
842
|
k: params,
|
837
843
|
D: closures,
|
838
|
-
|
844
|
+
y: dynamicScopesAccessor
|
839
845
|
});
|
840
846
|
}
|
841
847
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -909,7 +915,7 @@ function value(valueAccessor, fn = () => {
|
|
909
915
|
}
|
910
916
|
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
|
911
917
|
return (scope) => {
|
912
|
-
scope.
|
918
|
+
scope.n ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
913
919
|
};
|
914
920
|
}
|
915
921
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -919,7 +925,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
919
925
|
ownerScope,
|
920
926
|
() => {
|
921
927
|
for (let scope of scopes)
|
922
|
-
!scope.
|
928
|
+
!scope.n && !scope.o && childSignal(scope);
|
923
929
|
},
|
924
930
|
-1,
|
925
931
|
0,
|
@@ -931,7 +937,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
931
937
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
932
938
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
933
939
|
let ifScope = scope[scopeAccessor];
|
934
|
-
ifScope && !ifScope.
|
940
|
+
ifScope && !ifScope.n && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
935
941
|
};
|
936
942
|
return ownerSignal._ = childSignal, ownerSignal;
|
937
943
|
}
|
@@ -945,11 +951,11 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
945
951
|
function dynamicClosure(...closureSignals) {
|
946
952
|
let [{ E: ___scopeInstancesAccessor, F: ___signalIndexAccessor }] = closureSignals;
|
947
953
|
for (let i = closureSignals.length; i--; )
|
948
|
-
closureSignals[i].
|
954
|
+
closureSignals[i].J = i;
|
949
955
|
return (scope) => {
|
950
956
|
if (scope[___scopeInstancesAccessor])
|
951
957
|
for (let childScope of scope[___scopeInstancesAccessor])
|
952
|
-
childScope.
|
958
|
+
childScope.n || queueRender(
|
953
959
|
childScope,
|
954
960
|
closureSignals[childScope[___signalIndexAccessor]],
|
955
961
|
-1
|
@@ -958,7 +964,7 @@ function dynamicClosure(...closureSignals) {
|
|
958
964
|
}
|
959
965
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
960
966
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
961
|
-
scope[closureSignal.F] = closureSignal.
|
967
|
+
scope[closureSignal.F] = closureSignal.J, childSignal(scope), subscribeToScopeSet(
|
962
968
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
963
969
|
closureSignal.E,
|
964
970
|
scope
|
@@ -1006,71 +1012,53 @@ function hoist(...path) {
|
|
1006
1012
|
function awaitTag(nodeAccessor, renderer) {
|
1007
1013
|
let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
|
1008
1014
|
return (scope, promise) => {
|
1009
|
-
let
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
if (scope.j?.
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
namespaceNode
|
1023
|
-
),
|
1024
|
-
referenceNode.parentNode,
|
1025
|
-
referenceNode
|
1026
|
-
), referenceNode.remove()), renderer.k?.(awaitBranch, [data2]);
|
1027
|
-
});
|
1028
|
-
if (tryBranch) {
|
1029
|
-
if (!--tryBranch.y) {
|
1030
|
-
let placeholderBranch = tryBranch.c;
|
1031
|
-
placeholderBranch ? (insertBranchBefore(
|
1032
|
-
tryBranch,
|
1033
|
-
placeholderBranch.g.parentNode,
|
1034
|
-
placeholderBranch.g
|
1035
|
-
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1036
|
-
tryBranch,
|
1015
|
+
let tryWithPlaceholder = findBranchWithKey(
|
1016
|
+
scope,
|
1017
|
+
"d" /* PlaceholderContent */
|
1018
|
+
), awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.g ?? referenceNode).parentNode, thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1019
|
+
if (!(scope.j?.o || scope[promiseAccessor] !== thisPromise) && (scope[promiseAccessor] = void 0, runEffects(
|
1020
|
+
prepareEffects(() => {
|
1021
|
+
tryWithPlaceholder && placeholderShown.add(pendingEffects), (!awaitBranch || !tryWithPlaceholder) && (insertBranchBefore(
|
1022
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1023
|
+
scope.$global,
|
1024
|
+
renderer,
|
1025
|
+
scope,
|
1026
|
+
namespaceNode
|
1027
|
+
),
|
1037
1028
|
referenceNode.parentNode,
|
1038
1029
|
referenceNode
|
1039
|
-
);
|
1040
|
-
}
|
1041
|
-
|
1042
|
-
|
1030
|
+
), referenceNode.remove()), renderer.k?.(awaitBranch, [data2]);
|
1031
|
+
})
|
1032
|
+
), tryWithPlaceholder && !--tryWithPlaceholder.p)) {
|
1033
|
+
let placeholderBranch = tryWithPlaceholder.c;
|
1034
|
+
tryWithPlaceholder.c = void 0, placeholderBranch ? (insertBranchBefore(
|
1035
|
+
tryWithPlaceholder,
|
1036
|
+
placeholderBranch.g.parentNode,
|
1037
|
+
placeholderBranch.g
|
1038
|
+
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1039
|
+
tryWithPlaceholder,
|
1040
|
+
referenceNode.parentNode,
|
1041
|
+
referenceNode
|
1042
|
+
), tryWithPlaceholder.G && runEffects(tryWithPlaceholder.G, !0);
|
1043
|
+
}
|
1043
1044
|
}).catch((error) => {
|
1044
|
-
|
1045
|
-
for (; tryBranch2 && !tryBranch2.b; )
|
1046
|
-
tryBranch2 = tryBranch2.n;
|
1047
|
-
tryBranch2 ? (setConditionalRenderer(
|
1048
|
-
tryBranch2._,
|
1049
|
-
tryBranch2.a,
|
1050
|
-
tryBranch2.b,
|
1051
|
-
createAndSetupBranch
|
1052
|
-
), tryBranch2.b.k?.(
|
1053
|
-
tryBranch2._["d" /* ConditionalScope */ + tryBranch2.a],
|
1054
|
-
[error]
|
1055
|
-
)) : setTimeout(() => {
|
1056
|
-
throw error;
|
1057
|
-
});
|
1045
|
+
renderCatch(scope, error, !0);
|
1058
1046
|
});
|
1059
|
-
|
1060
|
-
if (
|
1061
|
-
let placeholderBranch =
|
1047
|
+
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.p || (tryWithPlaceholder.p = 0, requestAnimationFrame(() => {
|
1048
|
+
if (tryWithPlaceholder.p && !tryWithPlaceholder.o) {
|
1049
|
+
let placeholderBranch = tryWithPlaceholder.c = createAndSetupBranch(
|
1062
1050
|
scope.$global,
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1051
|
+
tryWithPlaceholder.d,
|
1052
|
+
tryWithPlaceholder._,
|
1053
|
+
tryWithPlaceholder.g.parentNode
|
1066
1054
|
);
|
1067
1055
|
insertBranchBefore(
|
1068
1056
|
placeholderBranch,
|
1069
|
-
|
1070
|
-
|
1071
|
-
), tempDetatchBranch(
|
1057
|
+
tryWithPlaceholder.g.parentNode,
|
1058
|
+
tryWithPlaceholder.g
|
1059
|
+
), tempDetatchBranch(tryWithPlaceholder);
|
1072
1060
|
}
|
1073
|
-
})),
|
1061
|
+
})), tryWithPlaceholder.p++) : awaitBranch && (awaitBranch.g.parentNode.insertBefore(
|
1074
1062
|
referenceNode,
|
1075
1063
|
awaitBranch.g
|
1076
1064
|
), tempDetatchBranch(awaitBranch));
|
@@ -1091,6 +1079,26 @@ function createTry(nodeAccessor, tryContent) {
|
|
1091
1079
|
));
|
1092
1080
|
};
|
1093
1081
|
}
|
1082
|
+
function renderCatch(scope, error, async) {
|
1083
|
+
let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
|
1084
|
+
if (tryWithCatch) {
|
1085
|
+
let placeholderBranch = tryWithCatch.c;
|
1086
|
+
placeholderBranch && (tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
|
1087
|
+
tryWithCatch._,
|
1088
|
+
tryWithCatch.a,
|
1089
|
+
tryWithCatch.b,
|
1090
|
+
createAndSetupBranch
|
1091
|
+
), tryWithCatch.b.k?.(
|
1092
|
+
tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
|
1093
|
+
[error]
|
1094
|
+
);
|
1095
|
+
} else if (async)
|
1096
|
+
setTimeout(() => {
|
1097
|
+
throw error;
|
1098
|
+
});
|
1099
|
+
else
|
1100
|
+
throw error;
|
1101
|
+
}
|
1094
1102
|
function conditional(nodeAccessor, ...branches) {
|
1095
1103
|
let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1096
1104
|
return (scope, newBranch) => {
|
@@ -1123,15 +1131,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1123
1131
|
0,
|
1124
1132
|
content,
|
1125
1133
|
createAndSetupBranch
|
1126
|
-
), content.
|
1127
|
-
content.u,
|
1134
|
+
), content.y && subscribeToScopeSet(
|
1128
1135
|
content.x,
|
1136
|
+
content.y,
|
1129
1137
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1130
1138
|
);
|
1131
1139
|
}
|
1132
|
-
} else normalizedRenderer?.
|
1133
|
-
normalizedRenderer.u,
|
1140
|
+
} else normalizedRenderer?.y && subscribeToScopeSet(
|
1134
1141
|
normalizedRenderer.x,
|
1142
|
+
normalizedRenderer.y,
|
1135
1143
|
scope[childScopeAccessor]
|
1136
1144
|
);
|
1137
1145
|
if (normalizedRenderer) {
|
@@ -1225,21 +1233,21 @@ function byFirstArg(name) {
|
|
1225
1233
|
}
|
1226
1234
|
|
1227
1235
|
// src/dom/queue.ts
|
1228
|
-
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1236
|
+
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1229
1237
|
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.l) {
|
1230
1238
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1231
1239
|
if (existingRender)
|
1232
|
-
existingRender.
|
1240
|
+
existingRender.H = value2;
|
1233
1241
|
else {
|
1234
1242
|
let render = {
|
1235
|
-
|
1243
|
+
q: key,
|
1236
1244
|
C: scope,
|
1237
|
-
|
1238
|
-
|
1245
|
+
K: signal,
|
1246
|
+
H: value2
|
1239
1247
|
}, i = pendingRenders.push(render) - 1;
|
1240
1248
|
for (; i; ) {
|
1241
1249
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1242
|
-
if (key - parent.
|
1250
|
+
if (key - parent.q >= 0) break;
|
1243
1251
|
pendingRenders[i] = parent, i = parentIndex;
|
1244
1252
|
}
|
1245
1253
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1267,62 +1275,63 @@ function prepareEffects(fn) {
|
|
1267
1275
|
}
|
1268
1276
|
return preparedEffects;
|
1269
1277
|
}
|
1270
|
-
|
1278
|
+
var runEffects = (effects) => {
|
1271
1279
|
for (let i = 0, scope; i < effects.length; )
|
1272
1280
|
effects[i++](
|
1273
1281
|
scope = effects[i++],
|
1274
1282
|
scope
|
1275
1283
|
);
|
1276
|
-
}
|
1284
|
+
};
|
1277
1285
|
function runRenders() {
|
1278
1286
|
for (; pendingRenders.length; ) {
|
1279
1287
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1280
1288
|
if (render !== item) {
|
1281
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1289
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).q;
|
1282
1290
|
for (; i < mid; ) {
|
1283
1291
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1284
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
1292
|
+
if (right < pendingRenders.length && pendingRenders[right].q - pendingRenders[bestChild].q < 0 && (bestChild = right), pendingRenders[bestChild].q - key >= 0)
|
1285
1293
|
break;
|
1286
1294
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1287
1295
|
}
|
1288
1296
|
pendingRenders[i] = item;
|
1289
1297
|
}
|
1290
|
-
render.C.j?.
|
1298
|
+
render.C.j?.o || runRender(render);
|
1291
1299
|
}
|
1292
1300
|
finishPendingScopes();
|
1293
1301
|
}
|
1294
|
-
var runRender = (render) => render.
|
1302
|
+
var runRender = (render) => render.K(render.C, render.H), enableCatch = () => {
|
1295
1303
|
enableCatch = () => {
|
1296
|
-
}
|
1304
|
+
};
|
1305
|
+
let handlePendingTry = (fn, scope, branch) => {
|
1306
|
+
for (; branch; ) {
|
1307
|
+
if (branch.p)
|
1308
|
+
return (branch.G ||= []).push(fn, scope);
|
1309
|
+
branch = branch.t;
|
1310
|
+
}
|
1311
|
+
};
|
1312
|
+
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1313
|
+
if (checkPending || caughtError.has(effects)) {
|
1314
|
+
let i = 0, fn, scope, branch;
|
1315
|
+
for (; i < effects.length; )
|
1316
|
+
fn = effects[i++], scope = effects[i++], branch = scope.j, !branch?.o && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1317
|
+
} else
|
1318
|
+
runEffects2(effects);
|
1319
|
+
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1297
1320
|
try {
|
1298
1321
|
runRender2(render);
|
1299
1322
|
} catch (error) {
|
1300
|
-
|
1301
|
-
for (; branch && !branch.b; )
|
1302
|
-
branch = branch.n;
|
1303
|
-
if (branch)
|
1304
|
-
setConditionalRenderer(
|
1305
|
-
branch._,
|
1306
|
-
branch.a,
|
1307
|
-
branch.b,
|
1308
|
-
createAndSetupBranch
|
1309
|
-
), branch.b.k?.(
|
1310
|
-
branch._["d" /* ConditionalScope */ + branch.a],
|
1311
|
-
[error]
|
1312
|
-
);
|
1313
|
-
else
|
1314
|
-
throw error;
|
1323
|
+
renderCatch(render.C, error);
|
1315
1324
|
}
|
1316
1325
|
})(runRender);
|
1317
1326
|
};
|
1318
1327
|
|
1319
1328
|
// src/dom/abort-signal.ts
|
1320
1329
|
function resetAbortSignal(scope, id) {
|
1321
|
-
let ctrl = scope.
|
1322
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1330
|
+
let ctrl = scope.u?.[id];
|
1331
|
+
ctrl && (queueEffect(ctrl, abort), scope.u[id] = void 0);
|
1323
1332
|
}
|
1324
1333
|
function getAbortSignal(scope, id) {
|
1325
|
-
return scope.j && (scope.j.
|
1334
|
+
return scope.j && (scope.j.I ||= /* @__PURE__ */ new Set()).add(scope), ((scope.u ||= {})[id] ||= new AbortController()).signal;
|
1326
1335
|
}
|
1327
1336
|
function abort(ctrl) {
|
1328
1337
|
ctrl.abort();
|
@@ -1387,7 +1396,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1387
1396
|
branch ? existing = !0 : (out.global.m ||= 0, branch = component.scope = createAndSetupBranch(
|
1388
1397
|
out.global,
|
1389
1398
|
renderer,
|
1390
|
-
renderer.
|
1399
|
+
renderer.x,
|
1391
1400
|
document.body
|
1392
1401
|
)), renderer.k?.(branch, renderer._ ? args[0] : args);
|
1393
1402
|
}), !existing)
|
package/dist/html.js
CHANGED
@@ -178,7 +178,7 @@ function forTo(to, from, step, cb) {
|
|
178
178
|
}
|
179
179
|
|
180
180
|
// src/html/inlined-runtimes.ts
|
181
|
-
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e)))}})';
|
181
|
+
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e.r)))}})';
|
182
182
|
|
183
183
|
// src/html/serializer.ts
|
184
184
|
var { hasOwnProperty } = {}, Generator = function* () {
|
@@ -424,6 +424,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
424
424
|
ids = 0;
|
425
425
|
flush = 0;
|
426
426
|
flushed = !1;
|
427
|
+
wroteUndefined = !1;
|
427
428
|
buf = [];
|
428
429
|
refs = /* @__PURE__ */ new WeakMap();
|
429
430
|
assigned = /* @__PURE__ */ new Set();
|
@@ -511,7 +512,7 @@ function writeRoot(state, root) {
|
|
511
512
|
hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
|
512
513
|
for (let chunk of buf)
|
513
514
|
result += chunk;
|
514
|
-
return "_=>" + result;
|
515
|
+
return state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result;
|
515
516
|
}
|
516
517
|
function writeAssigned(state) {
|
517
518
|
if (state.assigned.size) {
|
@@ -711,10 +712,12 @@ function writePlainObject(state, val, ref) {
|
|
711
712
|
return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
|
712
713
|
}
|
713
714
|
function writeArray(state, val, ref) {
|
714
|
-
|
715
|
-
for (let i =
|
716
|
-
|
717
|
-
|
715
|
+
let sep = "[";
|
716
|
+
for (let i = 0; i < val.length; i++) {
|
717
|
+
let item = val[i];
|
718
|
+
state.buf.push(sep), sep = ",", item === void 0 ? (state.wroteUndefined = !0, state.buf.push("$")) : writeProp(state, item, ref, "" + i);
|
719
|
+
}
|
720
|
+
return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
|
718
721
|
}
|
719
722
|
function writeDate(state, val) {
|
720
723
|
return state.buf.push('new Date("' + val.toISOString() + '")'), !0;
|
@@ -734,26 +737,38 @@ function writePromise(state, val, ref) {
|
|
734
737
|
function writeMap(state, val, ref) {
|
735
738
|
if (!val.size)
|
736
739
|
return state.buf.push("new Map"), !0;
|
737
|
-
let items = [], assigns;
|
738
|
-
for (let [itemKey, itemValue] of val)
|
739
|
-
itemKey === val && (itemKey = void 0, (assigns ||= []).push("i[" + items.length + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("i[" + items.length + "][1]")), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
|
740
740
|
let arrayRef = new Reference(
|
741
741
|
ref,
|
742
742
|
null,
|
743
743
|
state.flush,
|
744
744
|
null,
|
745
745
|
nextRefAccess(state)
|
746
|
-
);
|
747
|
-
|
748
|
-
|
749
|
-
|
746
|
+
), items = [], assigns, i = 0;
|
747
|
+
if (val.size < 25) {
|
748
|
+
for (let [itemKey, itemValue] of val)
|
749
|
+
itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(
|
750
|
+
itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]
|
751
|
+
);
|
752
|
+
assigns ? state.buf.push(
|
753
|
+
"((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "="
|
754
|
+
) : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
|
755
|
+
} else {
|
756
|
+
for (let [itemKey, itemValue] of val)
|
757
|
+
itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
|
758
|
+
assigns ? state.buf.push(
|
759
|
+
"(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "="
|
760
|
+
) : state.buf.push(
|
761
|
+
"(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="
|
762
|
+
), writeArray(state, items, arrayRef), state.buf.push(")");
|
763
|
+
}
|
764
|
+
return !0;
|
750
765
|
}
|
751
766
|
function writeSet(state, val, ref) {
|
752
767
|
if (!val.size)
|
753
768
|
return state.buf.push("new Set"), !0;
|
754
|
-
let items = [], assigns;
|
769
|
+
let items = [], assigns, i = 0;
|
755
770
|
for (let item of val)
|
756
|
-
item === val && (item =
|
771
|
+
item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
|
757
772
|
let arrayRef = new Reference(
|
758
773
|
ref,
|
759
774
|
null,
|
@@ -806,9 +821,9 @@ function writeHeaders(state, val) {
|
|
806
821
|
function writeFormData(state, val) {
|
807
822
|
let sep = "[", valStr = "";
|
808
823
|
for (let [key, value] of val)
|
809
|
-
typeof value == "string" && (valStr += sep +
|
824
|
+
typeof value == "string" && (valStr += sep + quote(key, 0) + "," + quote(value, 0), sep = ",");
|
810
825
|
return sep === "[" ? state.buf.push("new FormData") : state.buf.push(
|
811
|
-
"((f,i)=>
|
826
|
+
valStr + "].reduce((f,v,i,a)=>i%2&&f.append(v,a[i+1])||f,new FormData)"
|
812
827
|
), !0;
|
813
828
|
}
|
814
829
|
function writeRequest(state, val, ref) {
|
package/dist/html.mjs
CHANGED
@@ -97,7 +97,7 @@ function forTo(to, from, step, cb) {
|
|
97
97
|
}
|
98
98
|
|
99
99
|
// src/html/inlined-runtimes.ts
|
100
|
-
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e)))}})';
|
100
|
+
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e.r)))}})';
|
101
101
|
|
102
102
|
// src/html/serializer.ts
|
103
103
|
var { hasOwnProperty } = {}, Generator = function* () {
|
@@ -343,6 +343,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
343
343
|
ids = 0;
|
344
344
|
flush = 0;
|
345
345
|
flushed = !1;
|
346
|
+
wroteUndefined = !1;
|
346
347
|
buf = [];
|
347
348
|
refs = /* @__PURE__ */ new WeakMap();
|
348
349
|
assigned = /* @__PURE__ */ new Set();
|
@@ -430,7 +431,7 @@ function writeRoot(state, root) {
|
|
430
431
|
hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
|
431
432
|
for (let chunk of buf)
|
432
433
|
result += chunk;
|
433
|
-
return "_=>" + result;
|
434
|
+
return state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result;
|
434
435
|
}
|
435
436
|
function writeAssigned(state) {
|
436
437
|
if (state.assigned.size) {
|
@@ -630,10 +631,12 @@ function writePlainObject(state, val, ref) {
|
|
630
631
|
return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
|
631
632
|
}
|
632
633
|
function writeArray(state, val, ref) {
|
633
|
-
|
634
|
-
for (let i =
|
635
|
-
|
636
|
-
|
634
|
+
let sep = "[";
|
635
|
+
for (let i = 0; i < val.length; i++) {
|
636
|
+
let item = val[i];
|
637
|
+
state.buf.push(sep), sep = ",", item === void 0 ? (state.wroteUndefined = !0, state.buf.push("$")) : writeProp(state, item, ref, "" + i);
|
638
|
+
}
|
639
|
+
return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
|
637
640
|
}
|
638
641
|
function writeDate(state, val) {
|
639
642
|
return state.buf.push('new Date("' + val.toISOString() + '")'), !0;
|
@@ -653,26 +656,38 @@ function writePromise(state, val, ref) {
|
|
653
656
|
function writeMap(state, val, ref) {
|
654
657
|
if (!val.size)
|
655
658
|
return state.buf.push("new Map"), !0;
|
656
|
-
let items = [], assigns;
|
657
|
-
for (let [itemKey, itemValue] of val)
|
658
|
-
itemKey === val && (itemKey = void 0, (assigns ||= []).push("i[" + items.length + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("i[" + items.length + "][1]")), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
|
659
659
|
let arrayRef = new Reference(
|
660
660
|
ref,
|
661
661
|
null,
|
662
662
|
state.flush,
|
663
663
|
null,
|
664
664
|
nextRefAccess(state)
|
665
|
-
);
|
666
|
-
|
667
|
-
|
668
|
-
|
665
|
+
), items = [], assigns, i = 0;
|
666
|
+
if (val.size < 25) {
|
667
|
+
for (let [itemKey, itemValue] of val)
|
668
|
+
itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(
|
669
|
+
itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]
|
670
|
+
);
|
671
|
+
assigns ? state.buf.push(
|
672
|
+
"((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "="
|
673
|
+
) : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
|
674
|
+
} else {
|
675
|
+
for (let [itemKey, itemValue] of val)
|
676
|
+
itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
|
677
|
+
assigns ? state.buf.push(
|
678
|
+
"(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "="
|
679
|
+
) : state.buf.push(
|
680
|
+
"(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="
|
681
|
+
), writeArray(state, items, arrayRef), state.buf.push(")");
|
682
|
+
}
|
683
|
+
return !0;
|
669
684
|
}
|
670
685
|
function writeSet(state, val, ref) {
|
671
686
|
if (!val.size)
|
672
687
|
return state.buf.push("new Set"), !0;
|
673
|
-
let items = [], assigns;
|
688
|
+
let items = [], assigns, i = 0;
|
674
689
|
for (let item of val)
|
675
|
-
item === val && (item =
|
690
|
+
item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
|
676
691
|
let arrayRef = new Reference(
|
677
692
|
ref,
|
678
693
|
null,
|
@@ -725,9 +740,9 @@ function writeHeaders(state, val) {
|
|
725
740
|
function writeFormData(state, val) {
|
726
741
|
let sep = "[", valStr = "";
|
727
742
|
for (let [key, value] of val)
|
728
|
-
typeof value == "string" && (valStr += sep +
|
743
|
+
typeof value == "string" && (valStr += sep + quote(key, 0) + "," + quote(value, 0), sep = ",");
|
729
744
|
return sep === "[" ? state.buf.push("new FormData") : state.buf.push(
|
730
|
-
"((f,i)=>
|
745
|
+
valStr + "].reduce((f,v,i,a)=>i%2&&f.append(v,a[i+1])||f,new FormData)"
|
731
746
|
), !0;
|
732
747
|
}
|
733
748
|
function writeRequest(state, val, ref) {
|