marko 6.0.0-next.3.68 → 6.0.0-next.3.70
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 +1 -1
- package/dist/debug/dom.mjs +1 -1
- package/dist/debug/html.js +390 -345
- package/dist/debug/html.mjs +389 -342
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/html/dynamic-tag.d.ts +2 -4
- package/dist/html/writer.d.ts +14 -12
- package/dist/html.d.ts +1 -1
- package/dist/html.js +220 -212
- package/dist/html.mjs +219 -209
- package/dist/translator/index.js +49 -211
- package/package.json +1 -1
package/dist/html.mjs
CHANGED
@@ -411,10 +411,7 @@ function register(id, val, scope) {
|
|
411
411
|
function getRegistered(val) {
|
412
412
|
let registered = REGISTRY.get(val);
|
413
413
|
if (registered)
|
414
|
-
return {
|
415
|
-
id: registered.id,
|
416
|
-
scope: registered.scope
|
417
|
-
};
|
414
|
+
return { id: registered.id, scope: registered.scope };
|
418
415
|
}
|
419
416
|
function writeRoot(state, root) {
|
420
417
|
let { buf, assigned, mutations } = state, hadBuf = buf.length !== 0, result = "";
|
@@ -510,7 +507,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
|
|
510
507
|
return newScopeRef && ensureId(state, newScopeRef), !0;
|
511
508
|
}
|
512
509
|
if (scopeRef) {
|
513
|
-
if (isCircular(parent, scopeRef))
|
510
|
+
if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef)))
|
514
511
|
return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !1;
|
515
512
|
state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
|
516
513
|
} else {
|
@@ -1012,7 +1009,7 @@ function withContext(key, value, cb) {
|
|
1012
1009
|
let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
|
1013
1010
|
ctx[kPendingContexts]++, ctx[key] = value;
|
1014
1011
|
try {
|
1015
|
-
cb();
|
1012
|
+
return cb();
|
1016
1013
|
} finally {
|
1017
1014
|
ctx[kPendingContexts]--, ctx[key] = prev;
|
1018
1015
|
}
|
@@ -1060,20 +1057,26 @@ function hoist(scopeId, id) {
|
|
1060
1057
|
}
|
1061
1058
|
function resumeClosestBranch(scopeId) {
|
1062
1059
|
let branchId = $chunk.context?.[branchIdKey];
|
1063
|
-
branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, {
|
1064
|
-
g: branchId
|
1065
|
-
});
|
1060
|
+
branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, { g: branchId });
|
1066
1061
|
}
|
1067
1062
|
var branchIdKey = Symbol();
|
1068
|
-
function
|
1069
|
-
|
1063
|
+
function withBranchId(branchId, cb) {
|
1064
|
+
return withContext(branchIdKey, branchId, cb);
|
1065
|
+
}
|
1066
|
+
function resumeForOf(list, cb, by, scopeId, accessor) {
|
1067
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1068
|
+
forOf(list, (item, index) => {
|
1070
1069
|
let branchId = peekNextScopeId();
|
1071
1070
|
$chunk.writeHTML(
|
1072
1071
|
$chunk.boundary.state.mark(
|
1073
1072
|
"[" /* BranchStart */,
|
1074
|
-
branchId + (
|
1073
|
+
branchId + (index ? " " : "")
|
1075
1074
|
)
|
1076
|
-
),
|
1075
|
+
), withBranchId(branchId, () => {
|
1076
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1077
|
+
});
|
1078
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1079
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1077
1080
|
}), $chunk.writeHTML(
|
1078
1081
|
$chunk.boundary.state.mark(
|
1079
1082
|
"]" /* BranchEnd */,
|
@@ -1081,11 +1084,15 @@ function resumeForOf(list, cb, scopeId, accessor) {
|
|
1081
1084
|
)
|
1082
1085
|
);
|
1083
1086
|
}
|
1084
|
-
function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
1085
|
-
let branchIds = "";
|
1087
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
|
1088
|
+
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1086
1089
|
forOf(list, (item, index) => {
|
1087
1090
|
let branchId = peekNextScopeId();
|
1088
|
-
branchIds = " " + branchId + branchIds,
|
1091
|
+
branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
|
1092
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1093
|
+
});
|
1094
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1095
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1089
1096
|
}), $chunk.writeHTML(
|
1090
1097
|
$chunk.boundary.state.mark(
|
1091
1098
|
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -1093,13 +1100,20 @@ function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
|
1093
1100
|
)
|
1094
1101
|
);
|
1095
1102
|
}
|
1096
|
-
function
|
1097
|
-
|
1103
|
+
function forOfBy(by, item, index) {
|
1104
|
+
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
1105
|
+
}
|
1106
|
+
function resumeForIn(obj, cb, by, scopeId, accessor) {
|
1107
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1098
1108
|
forIn(obj, (key, value) => {
|
1099
1109
|
let branchId = peekNextScopeId();
|
1100
1110
|
$chunk.writeHTML(
|
1101
1111
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1102
|
-
), sep = " ",
|
1112
|
+
), sep = " ", withBranchId(branchId, () => {
|
1113
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1114
|
+
});
|
1115
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1116
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1103
1117
|
}), $chunk.writeHTML(
|
1104
1118
|
$chunk.boundary.state.mark(
|
1105
1119
|
"]" /* BranchEnd */,
|
@@ -1107,11 +1121,15 @@ function resumeForIn(obj, cb, scopeId, accessor) {
|
|
1107
1121
|
)
|
1108
1122
|
);
|
1109
1123
|
}
|
1110
|
-
function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
1111
|
-
let branchIds = "";
|
1124
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
|
1125
|
+
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1112
1126
|
forIn(obj, (key, value) => {
|
1113
1127
|
let branchId = peekNextScopeId();
|
1114
|
-
branchIds = " " + branchId + branchIds,
|
1128
|
+
branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
|
1129
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1130
|
+
});
|
1131
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1132
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1115
1133
|
}), $chunk.writeHTML(
|
1116
1134
|
$chunk.boundary.state.mark(
|
1117
1135
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -1119,13 +1137,20 @@ function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
|
1119
1137
|
)
|
1120
1138
|
);
|
1121
1139
|
}
|
1122
|
-
function
|
1123
|
-
|
1140
|
+
function forInBy(by, name, value) {
|
1141
|
+
return by ? by(name, value) : name;
|
1142
|
+
}
|
1143
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
1144
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1124
1145
|
forTo(to, from, step, (index) => {
|
1125
1146
|
let branchId = peekNextScopeId();
|
1126
1147
|
$chunk.writeHTML(
|
1127
1148
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1128
|
-
), sep = " ",
|
1149
|
+
), sep = " ", withBranchId(branchId, () => {
|
1150
|
+
cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
|
1151
|
+
});
|
1152
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1153
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1129
1154
|
}), $chunk.writeHTML(
|
1130
1155
|
$chunk.boundary.state.mark(
|
1131
1156
|
"]" /* BranchEnd */,
|
@@ -1133,11 +1158,15 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1133
1158
|
)
|
1134
1159
|
);
|
1135
1160
|
}
|
1136
|
-
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
|
1137
|
-
let branchIds = "";
|
1161
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
|
1162
|
+
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1138
1163
|
forTo(to, from, step, (index) => {
|
1139
1164
|
let branchId = peekNextScopeId();
|
1140
|
-
branchIds = " " + branchId + branchIds,
|
1165
|
+
branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
|
1166
|
+
cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
|
1167
|
+
});
|
1168
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1169
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1141
1170
|
}), $chunk.writeHTML(
|
1142
1171
|
$chunk.boundary.state.mark(
|
1143
1172
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -1145,22 +1174,31 @@ function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild)
|
|
1145
1174
|
)
|
1146
1175
|
);
|
1147
1176
|
}
|
1148
|
-
function
|
1177
|
+
function forToBy(by, index) {
|
1178
|
+
return by ? by(index) : index;
|
1179
|
+
}
|
1180
|
+
function resumeConditional(cb, scopeId, accessor, dynamic) {
|
1149
1181
|
let branchId = peekNextScopeId();
|
1150
|
-
$chunk.writeHTML(
|
1182
|
+
dynamic && $chunk.writeHTML(
|
1151
1183
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1152
|
-
)
|
1184
|
+
);
|
1185
|
+
let branchIndex = withBranchId(branchId, cb);
|
1186
|
+
branchIndex !== void 0 ? writeScope(scopeId, {
|
1187
|
+
["c" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
|
1188
|
+
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1189
|
+
}) : nextScopeId(), dynamic && $chunk.writeHTML(
|
1153
1190
|
$chunk.boundary.state.mark(
|
1154
1191
|
"]" /* BranchEnd */,
|
1155
1192
|
scopeId + " " + accessor
|
1156
1193
|
)
|
1157
1194
|
);
|
1158
1195
|
}
|
1159
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
|
1160
|
-
let branchId = peekNextScopeId();
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1196
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
|
1197
|
+
let branchId = peekNextScopeId(), branchIndex = withBranchId(branchId, cb), rendered = branchIndex !== void 0;
|
1198
|
+
rendered ? writeScope(scopeId, {
|
1199
|
+
["c" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
|
1200
|
+
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1201
|
+
}) : nextScopeId(), dynamic && $chunk.writeHTML(
|
1164
1202
|
$chunk.boundary.state.mark(
|
1165
1203
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1166
1204
|
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
@@ -1276,7 +1314,7 @@ function tryCatch(content, catchContent) {
|
|
1276
1314
|
}
|
1277
1315
|
let catchChunk = new Chunk(boundary, null, chunk.context);
|
1278
1316
|
catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
|
1279
|
-
} else catchBoundary.
|
1317
|
+
} else catchBoundary.count ? boundary.onNext() : boundary.endAsync();
|
1280
1318
|
};
|
1281
1319
|
}
|
1282
1320
|
var State2 = class {
|
@@ -1294,6 +1332,7 @@ var State2 = class {
|
|
1294
1332
|
hasReorderRuntime = !1;
|
1295
1333
|
hasWrittenResume = !1;
|
1296
1334
|
trailerHTML = "";
|
1335
|
+
resumes = "";
|
1297
1336
|
nonceAttr = "";
|
1298
1337
|
serializer = new Serializer();
|
1299
1338
|
writeReorders = null;
|
@@ -1332,7 +1371,7 @@ var State2 = class {
|
|
1332
1371
|
onNext = NOOP;
|
1333
1372
|
count = 0;
|
1334
1373
|
get done() {
|
1335
|
-
return this.count
|
1374
|
+
return flushSerializer(this), !this.count;
|
1336
1375
|
}
|
1337
1376
|
startAsync() {
|
1338
1377
|
this.signal.aborted || this.count++;
|
@@ -1407,65 +1446,71 @@ var State2 = class {
|
|
1407
1446
|
$chunk = prev;
|
1408
1447
|
}
|
1409
1448
|
}
|
1449
|
+
flushScript() {
|
1450
|
+
flushSerializer(this.boundary);
|
1451
|
+
let { boundary, effects } = this, { state } = boundary, { $global: $global2, runtimePrefix, nonceAttr } = state, { resumes } = state, { html, scripts } = this, hasWalk = !1;
|
1452
|
+
if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
|
1453
|
+
scripts,
|
1454
|
+
WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
|
1455
|
+
)), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), resumes && (state.hasWrittenResume ? scripts = concatScripts(
|
1456
|
+
scripts,
|
1457
|
+
runtimePrefix + ".r.push(" + resumes + ")"
|
1458
|
+
) : (state.hasWrittenResume = !0, scripts = concatScripts(
|
1459
|
+
scripts,
|
1460
|
+
runtimePrefix + ".r=[" + resumes + "]"
|
1461
|
+
))), state.writeReorders) {
|
1462
|
+
hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
|
1463
|
+
scripts,
|
1464
|
+
REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
|
1465
|
+
));
|
1466
|
+
for (let reorderedChunk of state.writeReorders) {
|
1467
|
+
let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
1468
|
+
for (reorderedChunk.reorderId = null; ; ) {
|
1469
|
+
cur.flushPlaceholder();
|
1470
|
+
let { next } = cur;
|
1471
|
+
if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
|
1472
|
+
"#" /* ReorderMarker */,
|
1473
|
+
cur.reorderId = state.nextReorderId()
|
1474
|
+
), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
|
1475
|
+
cur = next;
|
1476
|
+
else
|
1477
|
+
break;
|
1478
|
+
}
|
1479
|
+
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
|
1480
|
+
scripts,
|
1481
|
+
runtimePrefix + ".r=[]"
|
1482
|
+
)), reorderScripts = concatScripts(
|
1483
|
+
reorderScripts,
|
1484
|
+
"_.push(" + reorderEffects + ")"
|
1485
|
+
)), scripts = concatScripts(
|
1486
|
+
scripts,
|
1487
|
+
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
1488
|
+
), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
1489
|
+
}
|
1490
|
+
state.writeReorders = null;
|
1491
|
+
}
|
1492
|
+
return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.effects = state.resumes = "", this.html = html, this.scripts = scripts, this;
|
1493
|
+
}
|
1494
|
+
flushHTML() {
|
1495
|
+
this.flushScript();
|
1496
|
+
let { boundary, scripts } = this, { state } = boundary, { $global: $global2, nonceAttr } = state, { __flush__ } = $global2, { html } = this;
|
1497
|
+
return this.html = this.scripts = "", scripts && (html += "<script" + nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, html = __flush__($global2, html)), boundary.count || (html += state.trailerHTML), html;
|
1498
|
+
}
|
1410
1499
|
};
|
1411
|
-
function
|
1412
|
-
let
|
1413
|
-
|
1414
|
-
|
1415
|
-
WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
|
1416
|
-
));
|
1417
|
-
let resumes = "";
|
1418
|
-
if (state.writeScopes || serializer.flushed) {
|
1419
|
-
let { lastSerializedScopeId } = state, serializeData = [];
|
1500
|
+
function flushSerializer(boundary) {
|
1501
|
+
let { state } = boundary, { writeScopes, serializer } = state;
|
1502
|
+
if (writeScopes || serializer.flushed) {
|
1503
|
+
let serializeData = [], { lastSerializedScopeId } = state;
|
1420
1504
|
state.hasGlobals || (state.hasGlobals = !0, serializeData.push(getFilteredGlobals(state.$global)));
|
1421
|
-
for (let key in
|
1422
|
-
let scope =
|
1505
|
+
for (let key in writeScopes) {
|
1506
|
+
let scope = writeScopes[key], scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
|
1423
1507
|
lastSerializedScopeId = scopeId + 1, scopeIdDelta && serializeData.push(scopeIdDelta), serializeData.push(scope);
|
1424
1508
|
}
|
1425
|
-
resumes =
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
runtimePrefix + ".r.push(" + resumes + ")"
|
1430
|
-
) : (state.hasWrittenResume = !0, scripts = concatScripts(
|
1431
|
-
scripts,
|
1432
|
-
runtimePrefix + ".r=[" + resumes + "]"
|
1433
|
-
))), state.writeReorders) {
|
1434
|
-
hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
|
1435
|
-
scripts,
|
1436
|
-
REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
|
1437
|
-
));
|
1438
|
-
for (let reorderedChunk of state.writeReorders) {
|
1439
|
-
let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
1440
|
-
for (reorderedChunk.reorderId = null; ; ) {
|
1441
|
-
cur.flushPlaceholder();
|
1442
|
-
let { next } = cur;
|
1443
|
-
if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
|
1444
|
-
"#" /* ReorderMarker */,
|
1445
|
-
cur.reorderId = state.nextReorderId()
|
1446
|
-
), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
|
1447
|
-
cur = next;
|
1448
|
-
else
|
1449
|
-
break;
|
1450
|
-
}
|
1451
|
-
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
|
1452
|
-
scripts,
|
1453
|
-
runtimePrefix + ".r=[]"
|
1454
|
-
)), reorderScripts = concatScripts(
|
1455
|
-
reorderScripts,
|
1456
|
-
"_.push(" + reorderEffects + ")"
|
1457
|
-
)), scripts = concatScripts(
|
1458
|
-
scripts,
|
1459
|
-
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
1460
|
-
), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
1461
|
-
}
|
1462
|
-
state.writeReorders = null;
|
1509
|
+
state.resumes = concatEffects(
|
1510
|
+
state.resumes,
|
1511
|
+
serializer.stringify(serializeData, boundary)
|
1512
|
+
), state.lastSerializedScopeId = lastSerializedScopeId, state.writeScopes = null;
|
1463
1513
|
}
|
1464
|
-
return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), head.html = html, head.scripts = scripts, head;
|
1465
|
-
}
|
1466
|
-
function flushChunk(head, last) {
|
1467
|
-
let { boundary } = head, { state } = boundary, { html, scripts } = head, { $global: $global2 } = state, { __flush__ } = $global2, result = html;
|
1468
|
-
return head.html = head.scripts = "", scripts && (result += "<script" + state.nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
|
1469
1514
|
}
|
1470
1515
|
function writeTrailers(html) {
|
1471
1516
|
$chunk.boundary.state.trailerHTML += html;
|
@@ -1713,80 +1758,51 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
|
|
1713
1758
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
1714
1759
|
|
1715
1760
|
// src/html/dynamic-tag.ts
|
1716
|
-
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
}
|
1721
|
-
|
1722
|
-
|
1723
|
-
nextScopeId();
|
1724
|
-
return;
|
1725
|
-
}
|
1726
|
-
if (!tag) {
|
1727
|
-
resumeConditional(content, scopeId, accessor);
|
1728
|
-
return;
|
1729
|
-
}
|
1730
|
-
if (typeof tag == "string") {
|
1731
|
-
resumeSingleNodeConditional(
|
1732
|
-
() => {
|
1733
|
-
nextScopeId(), write(`<${tag}${attrs(input, accessor, scopeId, tag)}>`), voidElementsReg.test(tag) || (tag === "textarea" ? write(
|
1734
|
-
controllable_textarea_value(
|
1735
|
-
scopeId,
|
1736
|
-
accessor,
|
1737
|
-
input.value,
|
1738
|
-
input.valueChange
|
1739
|
-
)
|
1740
|
-
) : content && (tag === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1761
|
+
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
|
1762
|
+
let renderer = normalizeDynamicRenderer(tag), chunk = getChunk(), branchId = peekNextScopeId(), result;
|
1763
|
+
if (typeof renderer == "string") {
|
1764
|
+
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
1765
|
+
nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), voidElementsReg.test(renderer) || (withBranchId(branchId, () => {
|
1766
|
+
renderer === "textarea" ? write(
|
1767
|
+
controllable_textarea_value(
|
1741
1768
|
scopeId,
|
1742
1769
|
accessor,
|
1743
1770
|
input.value,
|
1744
|
-
input.valueChange
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1771
|
+
input.valueChange
|
1772
|
+
)
|
1773
|
+
) : content && (renderer === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1774
|
+
scopeId,
|
1775
|
+
accessor,
|
1776
|
+
input.value,
|
1777
|
+
input.valueChange,
|
1778
|
+
content
|
1779
|
+
) : content());
|
1780
|
+
}), write(`</${renderer}>`)), resume && chunk.writeHTML(
|
1781
|
+
chunk.boundary.state.mark(
|
1782
|
+
"|" /* BranchSingleNode */,
|
1783
|
+
scopeId + " " + accessor + " " + branchId
|
1784
|
+
)
|
1750
1785
|
);
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
return;
|
1767
|
-
}
|
1768
|
-
if (typeof tag == "string") {
|
1769
|
-
resumeSingleNodeConditional(
|
1770
|
-
() => {
|
1771
|
-
nextScopeId(), write(
|
1772
|
-
`<${tag}${attrs(args[0], accessor, scopeId, tag)}>`
|
1773
|
-
), voidElementsReg.test(tag) || write(`</${tag}>`);
|
1774
|
-
},
|
1775
|
-
scopeId,
|
1776
|
-
accessor
|
1786
|
+
} else
|
1787
|
+
resume && chunk.writeHTML(
|
1788
|
+
chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1789
|
+
), result = withBranchId(branchId, () => {
|
1790
|
+
if (renderer)
|
1791
|
+
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
1792
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
1793
|
+
);
|
1794
|
+
if (content)
|
1795
|
+
return content();
|
1796
|
+
}), resume && chunk.writeHTML(
|
1797
|
+
chunk.boundary.state.mark(
|
1798
|
+
"]" /* BranchEnd */,
|
1799
|
+
scopeId + " " + accessor
|
1800
|
+
)
|
1777
1801
|
);
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
), result;
|
1783
|
-
return resumeConditional(
|
1784
|
-
() => {
|
1785
|
-
result = renderer(...args);
|
1786
|
-
},
|
1787
|
-
scopeId,
|
1788
|
-
accessor
|
1789
|
-
), result;
|
1802
|
+
return peekNextScopeId() !== branchId ? resume && writeScope(scopeId, {
|
1803
|
+
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
1804
|
+
["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
|
1805
|
+
}) : nextScopeId(), result;
|
1790
1806
|
};
|
1791
1807
|
function createContent(id, fn) {
|
1792
1808
|
return fn.h = id, fn;
|
@@ -1795,18 +1811,18 @@ function registerContent(id, fn, scopeId) {
|
|
1795
1811
|
return register2(createContent(id, fn), id, scopeId);
|
1796
1812
|
}
|
1797
1813
|
function patchDynamicTag(patch) {
|
1798
|
-
|
1799
|
-
scopeId,
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
)
|
1814
|
+
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
1815
|
+
let patched = patch(scopeId, accessor, tag);
|
1816
|
+
return patched.h = tag, originalDynamicTag(
|
1817
|
+
scopeId,
|
1818
|
+
accessor,
|
1819
|
+
patched,
|
1820
|
+
input,
|
1821
|
+
content,
|
1822
|
+
inputIsArgs,
|
1823
|
+
resume
|
1824
|
+
);
|
1825
|
+
})(dynamicTag);
|
1810
1826
|
}
|
1811
1827
|
|
1812
1828
|
// src/html/compat.ts
|
@@ -1858,14 +1874,16 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1858
1874
|
renderer(normalizedInput);
|
1859
1875
|
});
|
1860
1876
|
let asyncOut = classAPIOut.beginAsync();
|
1861
|
-
(
|
1862
|
-
boundary.
|
1863
|
-
if (
|
1864
|
-
|
1865
|
-
|
1877
|
+
queueMicrotask(
|
1878
|
+
boundary.onNext = () => {
|
1879
|
+
if (boundary.signal.aborted)
|
1880
|
+
asyncOut.error(boundary.signal.reason);
|
1881
|
+
else if (boundary.done) {
|
1882
|
+
let { scripts, html } = head.consume().flushScript();
|
1883
|
+
asyncOut.script(scripts), asyncOut.write(html), asyncOut.end();
|
1866
1884
|
}
|
1867
|
-
}
|
1868
|
-
|
1885
|
+
}
|
1886
|
+
);
|
1869
1887
|
},
|
1870
1888
|
registerRenderer(renderer, id) {
|
1871
1889
|
return register(
|
@@ -1881,13 +1899,13 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1881
1899
|
};
|
1882
1900
|
|
1883
1901
|
// src/html/for.ts
|
1884
|
-
function
|
1902
|
+
function forOfBy2(by, item, index) {
|
1885
1903
|
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
1886
1904
|
}
|
1887
|
-
function
|
1905
|
+
function forInBy2(by, name, value) {
|
1888
1906
|
return by ? by(name, value) : name;
|
1889
1907
|
}
|
1890
|
-
function
|
1908
|
+
function forToBy2(by, index) {
|
1891
1909
|
return by ? by(index) : index;
|
1892
1910
|
}
|
1893
1911
|
|
@@ -1899,10 +1917,7 @@ function render(input = {}) {
|
|
1899
1917
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1900
1918
|
renderId: DEFAULT_RENDER_ID,
|
1901
1919
|
...$global2
|
1902
|
-
}) : $global2 = {
|
1903
|
-
runtimeId: DEFAULT_RUNTIME_ID,
|
1904
|
-
renderId: DEFAULT_RENDER_ID
|
1905
|
-
};
|
1920
|
+
}) : $global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
|
1906
1921
|
let head = new Chunk(
|
1907
1922
|
new Boundary(new State2($global2), $global2.signal),
|
1908
1923
|
null,
|
@@ -1938,16 +1953,10 @@ var ServerRenderResult = class {
|
|
1938
1953
|
} else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
|
1939
1954
|
},
|
1940
1955
|
throw(error) {
|
1941
|
-
return done || aborted || boundary?.abort(error), Promise.resolve({
|
1942
|
-
value: "",
|
1943
|
-
done: !0
|
1944
|
-
});
|
1956
|
+
return done || aborted || boundary?.abort(error), Promise.resolve({ value: "", done: !0 });
|
1945
1957
|
},
|
1946
1958
|
return(value2) {
|
1947
|
-
return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({
|
1948
|
-
value: value2,
|
1949
|
-
done: !0
|
1950
|
-
});
|
1959
|
+
return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({ value: value2, done: !0 });
|
1951
1960
|
}
|
1952
1961
|
};
|
1953
1962
|
function exec(_resolve, _reject) {
|
@@ -2002,7 +2011,7 @@ var ServerRenderResult = class {
|
|
2002
2011
|
return reject(new Error("Cannot read from a consumed render result"));
|
2003
2012
|
let { boundary } = head;
|
2004
2013
|
(boundary.onNext = () => {
|
2005
|
-
boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && (head
|
2014
|
+
boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && resolve(head.consume().flushHTML());
|
2006
2015
|
})();
|
2007
2016
|
});
|
2008
2017
|
}
|
@@ -2015,18 +2024,21 @@ var ServerRenderResult = class {
|
|
2015
2024
|
let { boundary } = head, onNext = boundary.onNext = (write2) => {
|
2016
2025
|
if (boundary.signal.aborted)
|
2017
2026
|
tick2 || offTick(onNext), boundary.onNext = NOOP2, onAbort(boundary.signal.reason);
|
2018
|
-
else
|
2019
|
-
let
|
2020
|
-
|
2021
|
-
|
2027
|
+
else {
|
2028
|
+
let { done } = boundary;
|
2029
|
+
if (done || write2) {
|
2030
|
+
let html = (head = head.consume()).flushHTML();
|
2031
|
+
html && onWrite(html), done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
|
2032
|
+
} else tick2 && (tick2 = !1, queueTick(onNext));
|
2033
|
+
}
|
2022
2034
|
};
|
2023
2035
|
return onNext(), boundary;
|
2024
2036
|
}
|
2025
2037
|
toString() {
|
2026
2038
|
let head = this.#head;
|
2027
|
-
if (!head) throw new Error("Cannot read from a consumed render result");
|
2028
|
-
if (head.
|
2029
|
-
return
|
2039
|
+
if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
|
2040
|
+
if (!head.boundary.done) throw new Error("Cannot fork in sync mode");
|
2041
|
+
return head.consume().flushHTML();
|
2030
2042
|
}
|
2031
2043
|
};
|
2032
2044
|
function NOOP2() {
|
@@ -2047,19 +2059,17 @@ export {
|
|
2047
2059
|
controllable_textarea_value,
|
2048
2060
|
createContent,
|
2049
2061
|
createTemplate,
|
2050
|
-
|
2051
|
-
dynamicTagId,
|
2052
|
-
dynamicTagInput,
|
2062
|
+
dynamicTag,
|
2053
2063
|
ensureScopeWithId,
|
2054
2064
|
escapeScript,
|
2055
2065
|
escapeStyle,
|
2056
2066
|
escapeXML,
|
2057
2067
|
forIn,
|
2058
|
-
forInBy,
|
2068
|
+
forInBy2 as forInBy,
|
2059
2069
|
forOf,
|
2060
|
-
forOfBy,
|
2070
|
+
forOfBy2 as forOfBy,
|
2061
2071
|
forTo,
|
2062
|
-
forToBy,
|
2072
|
+
forToBy2 as forToBy,
|
2063
2073
|
fork,
|
2064
2074
|
getScopeById,
|
2065
2075
|
hoist,
|