@marko/runtime-tags 6.3.0 → 6.3.2
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/html.js +57 -30
- package/dist/debug/html.mjs +57 -30
- package/dist/html/writer.d.ts +3 -2
- package/dist/html.js +50 -26
- package/dist/html.mjs +50 -26
- package/dist/translator/index.js +58 -16
- package/dist/translator/util/binding-has-prop.d.ts +2 -0
- package/dist/translator/visitors/placeholder.d.ts +2 -1
- package/package.json +1 -1
package/dist/debug/html.js
CHANGED
|
@@ -220,8 +220,8 @@ function _escape(val) {
|
|
|
220
220
|
assertValidTextValue(val);
|
|
221
221
|
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
|
|
222
222
|
}
|
|
223
|
-
const unsafeScriptReg =
|
|
224
|
-
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C
|
|
223
|
+
const unsafeScriptReg = /<(\/?script|!--)/gi;
|
|
224
|
+
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str;
|
|
225
225
|
function _escape_script(val) {
|
|
226
226
|
assertValidTextValue(val);
|
|
227
227
|
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
|
@@ -648,7 +648,7 @@ function writeAssigned(state) {
|
|
|
648
648
|
} else state.buf.push("void 0");
|
|
649
649
|
const valueStartIndex = state.buf.push(toAccess(toObjectKey(mutation.property)) + "(");
|
|
650
650
|
if (mutation.value === void 0) {} else if (writeProp(state, mutation.value, null, "")) {
|
|
651
|
-
const valueRef = state.refs.get(mutation.value);
|
|
651
|
+
const valueRef = typeof mutation.value === "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
|
|
652
652
|
if (valueRef && !valueRef.id && valueRef.scopeId === void 0) {
|
|
653
653
|
valueRef.id = mutation.valueId || nextRefAccess(state);
|
|
654
654
|
state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex];
|
|
@@ -1161,7 +1161,7 @@ function writeReadableStream(state, val, ref) {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
function writeGenerator(state, iter, ref) {
|
|
1163
1163
|
if (iter[kTouchedIterator]) {
|
|
1164
|
-
state.buf.push("(
|
|
1164
|
+
state.buf.push("(function*(){}())");
|
|
1165
1165
|
return true;
|
|
1166
1166
|
}
|
|
1167
1167
|
let sep = "";
|
|
@@ -1323,34 +1323,49 @@ function toAccess(accessor) {
|
|
|
1323
1323
|
const start = accessor[0];
|
|
1324
1324
|
return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
1325
1325
|
}
|
|
1326
|
+
const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
|
|
1326
1327
|
function quote(str, startPos) {
|
|
1328
|
+
if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
|
|
1327
1329
|
let result = "";
|
|
1328
1330
|
let lastPos = 0;
|
|
1329
1331
|
for (let i = startPos; i < str.length; i++) {
|
|
1330
1332
|
let replacement;
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
+
const code = str.charCodeAt(i);
|
|
1334
|
+
switch (code) {
|
|
1335
|
+
case 34:
|
|
1333
1336
|
replacement = "\\\"";
|
|
1334
1337
|
break;
|
|
1335
|
-
case
|
|
1338
|
+
case 92:
|
|
1336
1339
|
replacement = "\\\\";
|
|
1337
1340
|
break;
|
|
1338
|
-
case
|
|
1341
|
+
case 60:
|
|
1339
1342
|
replacement = "\\x3C";
|
|
1340
1343
|
break;
|
|
1341
|
-
case
|
|
1344
|
+
case 10:
|
|
1342
1345
|
replacement = "\\n";
|
|
1343
1346
|
break;
|
|
1344
|
-
case
|
|
1347
|
+
case 13:
|
|
1345
1348
|
replacement = "\\r";
|
|
1346
1349
|
break;
|
|
1347
|
-
case
|
|
1350
|
+
case 8232:
|
|
1348
1351
|
replacement = "\\u2028";
|
|
1349
1352
|
break;
|
|
1350
|
-
case
|
|
1353
|
+
case 8233:
|
|
1351
1354
|
replacement = "\\u2029";
|
|
1352
1355
|
break;
|
|
1353
|
-
|
|
1356
|
+
case 0:
|
|
1357
|
+
replacement = "\\x00";
|
|
1358
|
+
break;
|
|
1359
|
+
default:
|
|
1360
|
+
if (code < 55296 || code > 57343) continue;
|
|
1361
|
+
if (code < 56320) {
|
|
1362
|
+
const next = str.charCodeAt(i + 1);
|
|
1363
|
+
if (next >= 56320 && next <= 57343) {
|
|
1364
|
+
i++;
|
|
1365
|
+
continue;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
replacement = "\\u" + code.toString(16);
|
|
1354
1369
|
}
|
|
1355
1370
|
result += str.slice(lastPos, i) + replacement;
|
|
1356
1371
|
lastPos = i + 1;
|
|
@@ -1917,7 +1932,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
|
1917
1932
|
$chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
1918
1933
|
} else withIsAsync(content, value);
|
|
1919
1934
|
});
|
|
1920
|
-
boundary.endAsync(
|
|
1935
|
+
boundary.endAsync();
|
|
1921
1936
|
}
|
|
1922
1937
|
}
|
|
1923
1938
|
}, (err) => {
|
|
@@ -1959,7 +1974,7 @@ function tryCatch(content, catchContent) {
|
|
|
1959
1974
|
const chunk = $chunk;
|
|
1960
1975
|
const { boundary } = chunk;
|
|
1961
1976
|
const { state } = boundary;
|
|
1962
|
-
const catchBoundary = new Boundary(state);
|
|
1977
|
+
const catchBoundary = new Boundary(state, void 0, boundary);
|
|
1963
1978
|
const body = chunk.fork(catchBoundary, null);
|
|
1964
1979
|
const bodyEnd = body.render(content);
|
|
1965
1980
|
if (catchBoundary.signal.aborted) {
|
|
@@ -2073,19 +2088,21 @@ var State = class {
|
|
|
2073
2088
|
};
|
|
2074
2089
|
var Boundary = class extends AbortController {
|
|
2075
2090
|
state;
|
|
2091
|
+
parent;
|
|
2076
2092
|
onNext = NOOP$2;
|
|
2077
2093
|
count = 0;
|
|
2078
|
-
constructor(state, parent) {
|
|
2094
|
+
constructor(state, signal, parent) {
|
|
2079
2095
|
super();
|
|
2080
2096
|
this.state = state;
|
|
2097
|
+
this.parent = parent;
|
|
2081
2098
|
this.signal.addEventListener("abort", () => {
|
|
2082
2099
|
this.count = 0;
|
|
2083
2100
|
this.state = new State(this.state.$global);
|
|
2084
2101
|
this.onNext();
|
|
2085
2102
|
});
|
|
2086
|
-
if (
|
|
2087
|
-
else
|
|
2088
|
-
this.abort(
|
|
2103
|
+
if (signal) if (signal.aborted) this.abort(signal.reason);
|
|
2104
|
+
else signal.addEventListener("abort", () => {
|
|
2105
|
+
this.abort(signal.reason);
|
|
2089
2106
|
});
|
|
2090
2107
|
}
|
|
2091
2108
|
flush() {
|
|
@@ -2095,10 +2112,9 @@ var Boundary = class extends AbortController {
|
|
|
2095
2112
|
startAsync() {
|
|
2096
2113
|
if (!this.signal.aborted) this.count++;
|
|
2097
2114
|
}
|
|
2098
|
-
endAsync(
|
|
2115
|
+
endAsync() {
|
|
2099
2116
|
if (!this.signal.aborted && this.count) {
|
|
2100
2117
|
this.count--;
|
|
2101
|
-
if (chunk?.reorderId) this.state.reorder(chunk);
|
|
2102
2118
|
this.onNext();
|
|
2103
2119
|
}
|
|
2104
2120
|
}
|
|
@@ -2285,12 +2301,22 @@ var Chunk = class Chunk {
|
|
|
2285
2301
|
scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
|
|
2286
2302
|
}
|
|
2287
2303
|
if (state.writeReorders) {
|
|
2288
|
-
|
|
2289
|
-
if (!state.hasReorderRuntime) {
|
|
2290
|
-
state.hasReorderRuntime = true;
|
|
2291
|
-
scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
|
|
2292
|
-
}
|
|
2304
|
+
let carried = null;
|
|
2293
2305
|
for (const reorderedChunk of state.writeReorders) {
|
|
2306
|
+
if (reorderedChunk.async && reorderedChunk.consumed) {
|
|
2307
|
+
let aborted = reorderedChunk.boundary;
|
|
2308
|
+
while (aborted && !aborted.signal.aborted) aborted = aborted.parent;
|
|
2309
|
+
if (!aborted) {
|
|
2310
|
+
(carried ||= []).push(reorderedChunk);
|
|
2311
|
+
continue;
|
|
2312
|
+
}
|
|
2313
|
+
reorderedChunk.async = false;
|
|
2314
|
+
}
|
|
2315
|
+
needsWalk = true;
|
|
2316
|
+
if (!state.hasReorderRuntime) {
|
|
2317
|
+
state.hasReorderRuntime = true;
|
|
2318
|
+
scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
|
|
2319
|
+
}
|
|
2294
2320
|
const { reorderId } = reorderedChunk;
|
|
2295
2321
|
const readyReservations = [];
|
|
2296
2322
|
let reorderHTML = "";
|
|
@@ -2309,6 +2335,7 @@ var Chunk = class Chunk {
|
|
|
2309
2335
|
reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
|
|
2310
2336
|
if (cur.async) {
|
|
2311
2337
|
reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
|
|
2338
|
+
state.reorder(cur);
|
|
2312
2339
|
cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
|
|
2313
2340
|
cur.next = null;
|
|
2314
2341
|
}
|
|
@@ -2326,7 +2353,7 @@ var Chunk = class Chunk {
|
|
|
2326
2353
|
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
|
|
2327
2354
|
html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2328
2355
|
}
|
|
2329
|
-
state.writeReorders =
|
|
2356
|
+
state.writeReorders = carried;
|
|
2330
2357
|
}
|
|
2331
2358
|
if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
|
|
2332
2359
|
this.html = html;
|
|
@@ -2656,9 +2683,9 @@ function nonVoidAttr(name, value) {
|
|
|
2656
2683
|
}
|
|
2657
2684
|
return " " + name + attrAssignment(value + "");
|
|
2658
2685
|
}
|
|
2659
|
-
const singleQuoteAttrReplacements = /'|&(
|
|
2660
|
-
const doubleQuoteAttrReplacements = /"|&(
|
|
2661
|
-
const needsQuotedAttr = /["'>\s]
|
|
2686
|
+
const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
|
|
2687
|
+
const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
|
|
2688
|
+
const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
|
|
2662
2689
|
function attrAssignment(value) {
|
|
2663
2690
|
return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
|
|
2664
2691
|
}
|
package/dist/debug/html.mjs
CHANGED
|
@@ -218,8 +218,8 @@ function _escape(val) {
|
|
|
218
218
|
assertValidTextValue(val);
|
|
219
219
|
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
|
|
220
220
|
}
|
|
221
|
-
const unsafeScriptReg =
|
|
222
|
-
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C
|
|
221
|
+
const unsafeScriptReg = /<(\/?script|!--)/gi;
|
|
222
|
+
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str;
|
|
223
223
|
function _escape_script(val) {
|
|
224
224
|
assertValidTextValue(val);
|
|
225
225
|
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
|
@@ -646,7 +646,7 @@ function writeAssigned(state) {
|
|
|
646
646
|
} else state.buf.push("void 0");
|
|
647
647
|
const valueStartIndex = state.buf.push(toAccess(toObjectKey(mutation.property)) + "(");
|
|
648
648
|
if (mutation.value === void 0) {} else if (writeProp(state, mutation.value, null, "")) {
|
|
649
|
-
const valueRef = state.refs.get(mutation.value);
|
|
649
|
+
const valueRef = typeof mutation.value === "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
|
|
650
650
|
if (valueRef && !valueRef.id && valueRef.scopeId === void 0) {
|
|
651
651
|
valueRef.id = mutation.valueId || nextRefAccess(state);
|
|
652
652
|
state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex];
|
|
@@ -1159,7 +1159,7 @@ function writeReadableStream(state, val, ref) {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
function writeGenerator(state, iter, ref) {
|
|
1161
1161
|
if (iter[kTouchedIterator]) {
|
|
1162
|
-
state.buf.push("(
|
|
1162
|
+
state.buf.push("(function*(){}())");
|
|
1163
1163
|
return true;
|
|
1164
1164
|
}
|
|
1165
1165
|
let sep = "";
|
|
@@ -1321,34 +1321,49 @@ function toAccess(accessor) {
|
|
|
1321
1321
|
const start = accessor[0];
|
|
1322
1322
|
return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
1323
1323
|
}
|
|
1324
|
+
const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
|
|
1324
1325
|
function quote(str, startPos) {
|
|
1326
|
+
if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
|
|
1325
1327
|
let result = "";
|
|
1326
1328
|
let lastPos = 0;
|
|
1327
1329
|
for (let i = startPos; i < str.length; i++) {
|
|
1328
1330
|
let replacement;
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
+
const code = str.charCodeAt(i);
|
|
1332
|
+
switch (code) {
|
|
1333
|
+
case 34:
|
|
1331
1334
|
replacement = "\\\"";
|
|
1332
1335
|
break;
|
|
1333
|
-
case
|
|
1336
|
+
case 92:
|
|
1334
1337
|
replacement = "\\\\";
|
|
1335
1338
|
break;
|
|
1336
|
-
case
|
|
1339
|
+
case 60:
|
|
1337
1340
|
replacement = "\\x3C";
|
|
1338
1341
|
break;
|
|
1339
|
-
case
|
|
1342
|
+
case 10:
|
|
1340
1343
|
replacement = "\\n";
|
|
1341
1344
|
break;
|
|
1342
|
-
case
|
|
1345
|
+
case 13:
|
|
1343
1346
|
replacement = "\\r";
|
|
1344
1347
|
break;
|
|
1345
|
-
case
|
|
1348
|
+
case 8232:
|
|
1346
1349
|
replacement = "\\u2028";
|
|
1347
1350
|
break;
|
|
1348
|
-
case
|
|
1351
|
+
case 8233:
|
|
1349
1352
|
replacement = "\\u2029";
|
|
1350
1353
|
break;
|
|
1351
|
-
|
|
1354
|
+
case 0:
|
|
1355
|
+
replacement = "\\x00";
|
|
1356
|
+
break;
|
|
1357
|
+
default:
|
|
1358
|
+
if (code < 55296 || code > 57343) continue;
|
|
1359
|
+
if (code < 56320) {
|
|
1360
|
+
const next = str.charCodeAt(i + 1);
|
|
1361
|
+
if (next >= 56320 && next <= 57343) {
|
|
1362
|
+
i++;
|
|
1363
|
+
continue;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
replacement = "\\u" + code.toString(16);
|
|
1352
1367
|
}
|
|
1353
1368
|
result += str.slice(lastPos, i) + replacement;
|
|
1354
1369
|
lastPos = i + 1;
|
|
@@ -1915,7 +1930,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
|
1915
1930
|
$chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
1916
1931
|
} else withIsAsync(content, value);
|
|
1917
1932
|
});
|
|
1918
|
-
boundary.endAsync(
|
|
1933
|
+
boundary.endAsync();
|
|
1919
1934
|
}
|
|
1920
1935
|
}
|
|
1921
1936
|
}, (err) => {
|
|
@@ -1957,7 +1972,7 @@ function tryCatch(content, catchContent) {
|
|
|
1957
1972
|
const chunk = $chunk;
|
|
1958
1973
|
const { boundary } = chunk;
|
|
1959
1974
|
const { state } = boundary;
|
|
1960
|
-
const catchBoundary = new Boundary(state);
|
|
1975
|
+
const catchBoundary = new Boundary(state, void 0, boundary);
|
|
1961
1976
|
const body = chunk.fork(catchBoundary, null);
|
|
1962
1977
|
const bodyEnd = body.render(content);
|
|
1963
1978
|
if (catchBoundary.signal.aborted) {
|
|
@@ -2071,19 +2086,21 @@ var State = class {
|
|
|
2071
2086
|
};
|
|
2072
2087
|
var Boundary = class extends AbortController {
|
|
2073
2088
|
state;
|
|
2089
|
+
parent;
|
|
2074
2090
|
onNext = NOOP$2;
|
|
2075
2091
|
count = 0;
|
|
2076
|
-
constructor(state, parent) {
|
|
2092
|
+
constructor(state, signal, parent) {
|
|
2077
2093
|
super();
|
|
2078
2094
|
this.state = state;
|
|
2095
|
+
this.parent = parent;
|
|
2079
2096
|
this.signal.addEventListener("abort", () => {
|
|
2080
2097
|
this.count = 0;
|
|
2081
2098
|
this.state = new State(this.state.$global);
|
|
2082
2099
|
this.onNext();
|
|
2083
2100
|
});
|
|
2084
|
-
if (
|
|
2085
|
-
else
|
|
2086
|
-
this.abort(
|
|
2101
|
+
if (signal) if (signal.aborted) this.abort(signal.reason);
|
|
2102
|
+
else signal.addEventListener("abort", () => {
|
|
2103
|
+
this.abort(signal.reason);
|
|
2087
2104
|
});
|
|
2088
2105
|
}
|
|
2089
2106
|
flush() {
|
|
@@ -2093,10 +2110,9 @@ var Boundary = class extends AbortController {
|
|
|
2093
2110
|
startAsync() {
|
|
2094
2111
|
if (!this.signal.aborted) this.count++;
|
|
2095
2112
|
}
|
|
2096
|
-
endAsync(
|
|
2113
|
+
endAsync() {
|
|
2097
2114
|
if (!this.signal.aborted && this.count) {
|
|
2098
2115
|
this.count--;
|
|
2099
|
-
if (chunk?.reorderId) this.state.reorder(chunk);
|
|
2100
2116
|
this.onNext();
|
|
2101
2117
|
}
|
|
2102
2118
|
}
|
|
@@ -2283,12 +2299,22 @@ var Chunk = class Chunk {
|
|
|
2283
2299
|
scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
|
|
2284
2300
|
}
|
|
2285
2301
|
if (state.writeReorders) {
|
|
2286
|
-
|
|
2287
|
-
if (!state.hasReorderRuntime) {
|
|
2288
|
-
state.hasReorderRuntime = true;
|
|
2289
|
-
scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
|
|
2290
|
-
}
|
|
2302
|
+
let carried = null;
|
|
2291
2303
|
for (const reorderedChunk of state.writeReorders) {
|
|
2304
|
+
if (reorderedChunk.async && reorderedChunk.consumed) {
|
|
2305
|
+
let aborted = reorderedChunk.boundary;
|
|
2306
|
+
while (aborted && !aborted.signal.aborted) aborted = aborted.parent;
|
|
2307
|
+
if (!aborted) {
|
|
2308
|
+
(carried ||= []).push(reorderedChunk);
|
|
2309
|
+
continue;
|
|
2310
|
+
}
|
|
2311
|
+
reorderedChunk.async = false;
|
|
2312
|
+
}
|
|
2313
|
+
needsWalk = true;
|
|
2314
|
+
if (!state.hasReorderRuntime) {
|
|
2315
|
+
state.hasReorderRuntime = true;
|
|
2316
|
+
scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
|
|
2317
|
+
}
|
|
2292
2318
|
const { reorderId } = reorderedChunk;
|
|
2293
2319
|
const readyReservations = [];
|
|
2294
2320
|
let reorderHTML = "";
|
|
@@ -2307,6 +2333,7 @@ var Chunk = class Chunk {
|
|
|
2307
2333
|
reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
|
|
2308
2334
|
if (cur.async) {
|
|
2309
2335
|
reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
|
|
2336
|
+
state.reorder(cur);
|
|
2310
2337
|
cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
|
|
2311
2338
|
cur.next = null;
|
|
2312
2339
|
}
|
|
@@ -2324,7 +2351,7 @@ var Chunk = class Chunk {
|
|
|
2324
2351
|
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
|
|
2325
2352
|
html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2326
2353
|
}
|
|
2327
|
-
state.writeReorders =
|
|
2354
|
+
state.writeReorders = carried;
|
|
2328
2355
|
}
|
|
2329
2356
|
if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
|
|
2330
2357
|
this.html = html;
|
|
@@ -2654,9 +2681,9 @@ function nonVoidAttr(name, value) {
|
|
|
2654
2681
|
}
|
|
2655
2682
|
return " " + name + attrAssignment(value + "");
|
|
2656
2683
|
}
|
|
2657
|
-
const singleQuoteAttrReplacements = /'|&(
|
|
2658
|
-
const doubleQuoteAttrReplacements = /"|&(
|
|
2659
|
-
const needsQuotedAttr = /["'>\s]
|
|
2684
|
+
const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
|
|
2685
|
+
const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
|
|
2686
|
+
const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
|
|
2660
2687
|
function attrAssignment(value) {
|
|
2661
2688
|
return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
|
|
2662
2689
|
}
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -121,12 +121,13 @@ export declare enum FlushStatus {
|
|
|
121
121
|
}
|
|
122
122
|
export declare class Boundary extends AbortController {
|
|
123
123
|
state: State;
|
|
124
|
+
parent?: Boundary | undefined;
|
|
124
125
|
onNext: () => void;
|
|
125
126
|
count: number;
|
|
126
|
-
constructor(state: State, parent?:
|
|
127
|
+
constructor(state: State, signal?: AbortSignal, parent?: Boundary | undefined);
|
|
127
128
|
flush(): FlushStatus;
|
|
128
129
|
startAsync(): void;
|
|
129
|
-
endAsync(
|
|
130
|
+
endAsync(): void;
|
|
130
131
|
}
|
|
131
132
|
export declare class Chunk {
|
|
132
133
|
boundary: Boundary;
|
package/dist/html.js
CHANGED
|
@@ -4,7 +4,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
4
4
|
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
5
|
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
6
|
return str;
|
|
7
|
-
}, unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : "<", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg =
|
|
7
|
+
}, unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : "<", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str, unsafeStyleReg = /<\/style/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = Symbol.for("marko.touchedIterator"), { hasOwnProperty: hasOwnProperty$1 } = {}, Generator = (function* () {})().constructor, AsyncGenerator = (async function* () {})().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
8
8
|
let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
|
|
9
9
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
|
10
10
|
let symbol = Symbol[name];
|
|
@@ -238,10 +238,10 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
238
238
|
[JSON, "JSON"],
|
|
239
239
|
[Math, "Math"],
|
|
240
240
|
[Reflect, "Reflect"]
|
|
241
|
-
]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
241
|
+
]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
242
242
|
let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
|
|
243
243
|
return state.needsMainRuntime = !0, Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
|
|
244
|
-
}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(
|
|
244
|
+
}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
|
245
245
|
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
|
|
246
246
|
if (typeof renderer == "string") {
|
|
247
247
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
@@ -534,7 +534,7 @@ function writeAssigned(state) {
|
|
|
534
534
|
} else state.buf.push("void 0");
|
|
535
535
|
let valueStartIndex = state.buf.push(toAccess(toObjectKey(mutation.property)) + "(");
|
|
536
536
|
if (mutation.value !== void 0) if (writeProp(state, mutation.value, null, "")) {
|
|
537
|
-
let valueRef = state.refs.get(mutation.value);
|
|
537
|
+
let valueRef = typeof mutation.value == "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
|
|
538
538
|
valueRef && !valueRef.id && valueRef.scopeId === void 0 && (valueRef.id = mutation.valueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
|
|
539
539
|
} else state.buf.push("void 0");
|
|
540
540
|
state.buf.push(")");
|
|
@@ -819,7 +819,7 @@ function writeReadableStream(state, val, ref) {
|
|
|
819
819
|
return state.buf.push("new ReadableStream({start(c){(async(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()]))=>{for(i of a)v=await i,i==l?c.close():c.enqueue(v)})(" + iterId + "={}).catch(e=>c.error(e))}})"), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
|
|
820
820
|
}
|
|
821
821
|
function writeGenerator(state, iter, ref) {
|
|
822
|
-
if (iter[kTouchedIterator]) return state.buf.push("(
|
|
822
|
+
if (iter[kTouchedIterator]) return state.buf.push("(function*(){}())"), !0;
|
|
823
823
|
let sep = "";
|
|
824
824
|
for (state.buf.push("(function*(){");;) {
|
|
825
825
|
let { value, done } = iter.next();
|
|
@@ -907,32 +907,45 @@ function toAccess(accessor) {
|
|
|
907
907
|
return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
908
908
|
}
|
|
909
909
|
function quote(str, startPos) {
|
|
910
|
+
if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
|
|
910
911
|
let result = "", lastPos = 0;
|
|
911
912
|
for (let i = startPos; i < str.length; i++) {
|
|
912
|
-
let replacement;
|
|
913
|
-
switch (
|
|
914
|
-
case
|
|
913
|
+
let replacement, code = str.charCodeAt(i);
|
|
914
|
+
switch (code) {
|
|
915
|
+
case 34:
|
|
915
916
|
replacement = "\\\"";
|
|
916
917
|
break;
|
|
917
|
-
case
|
|
918
|
+
case 92:
|
|
918
919
|
replacement = "\\\\";
|
|
919
920
|
break;
|
|
920
|
-
case
|
|
921
|
+
case 60:
|
|
921
922
|
replacement = "\\x3C";
|
|
922
923
|
break;
|
|
923
|
-
case
|
|
924
|
+
case 10:
|
|
924
925
|
replacement = "\\n";
|
|
925
926
|
break;
|
|
926
|
-
case
|
|
927
|
+
case 13:
|
|
927
928
|
replacement = "\\r";
|
|
928
929
|
break;
|
|
929
|
-
case
|
|
930
|
+
case 8232:
|
|
930
931
|
replacement = "\\u2028";
|
|
931
932
|
break;
|
|
932
|
-
case
|
|
933
|
+
case 8233:
|
|
933
934
|
replacement = "\\u2029";
|
|
934
935
|
break;
|
|
935
|
-
|
|
936
|
+
case 0:
|
|
937
|
+
replacement = "\\x00";
|
|
938
|
+
break;
|
|
939
|
+
default:
|
|
940
|
+
if (code < 55296 || code > 57343) continue;
|
|
941
|
+
if (code < 56320) {
|
|
942
|
+
let next = str.charCodeAt(i + 1);
|
|
943
|
+
if (next >= 56320 && next <= 57343) {
|
|
944
|
+
i++;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
replacement = "\\u" + code.toString(16);
|
|
936
949
|
}
|
|
937
950
|
result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
|
|
938
951
|
}
|
|
@@ -1282,7 +1295,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
|
1282
1295
|
let branchId = _peek_scope_id();
|
|
1283
1296
|
$chunk.writeHTML($chunk.boundary.state.mark("[", "")), withIsAsync(content, value), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
1284
1297
|
} else withIsAsync(content, value);
|
|
1285
|
-
}), boundary.endAsync(
|
|
1298
|
+
}), boundary.endAsync()));
|
|
1286
1299
|
}, (err) => {
|
|
1287
1300
|
chunk.async = !1, boundary.abort(err);
|
|
1288
1301
|
});
|
|
@@ -1310,7 +1323,7 @@ function tryPlaceholder(content, placeholder, branchId) {
|
|
|
1310
1323
|
};
|
|
1311
1324
|
}
|
|
1312
1325
|
function tryCatch(content, catchContent) {
|
|
1313
|
-
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
|
|
1326
|
+
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, void 0, boundary), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
|
|
1314
1327
|
if (catchBoundary.signal.aborted) {
|
|
1315
1328
|
catchContent(catchBoundary.signal.reason);
|
|
1316
1329
|
return;
|
|
@@ -1388,13 +1401,14 @@ var State = class {
|
|
|
1388
1401
|
}
|
|
1389
1402
|
}, Boundary = class extends AbortController {
|
|
1390
1403
|
state;
|
|
1404
|
+
parent;
|
|
1391
1405
|
onNext = NOOP$2;
|
|
1392
1406
|
count = 0;
|
|
1393
|
-
constructor(state, parent) {
|
|
1394
|
-
super(), this.state = state, this.signal.addEventListener("abort", () => {
|
|
1407
|
+
constructor(state, signal, parent) {
|
|
1408
|
+
super(), this.state = state, this.parent = parent, this.signal.addEventListener("abort", () => {
|
|
1395
1409
|
this.count = 0, this.state = new State(this.state.$global), this.onNext();
|
|
1396
|
-
}),
|
|
1397
|
-
this.abort(
|
|
1410
|
+
}), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", () => {
|
|
1411
|
+
this.abort(signal.reason);
|
|
1398
1412
|
}));
|
|
1399
1413
|
}
|
|
1400
1414
|
flush() {
|
|
@@ -1403,8 +1417,8 @@ var State = class {
|
|
|
1403
1417
|
startAsync() {
|
|
1404
1418
|
this.signal.aborted || this.count++;
|
|
1405
1419
|
}
|
|
1406
|
-
endAsync(
|
|
1407
|
-
!this.signal.aborted && this.count && (this.count--,
|
|
1420
|
+
endAsync() {
|
|
1421
|
+
!this.signal.aborted && this.count && (this.count--, this.onNext());
|
|
1408
1422
|
}
|
|
1409
1423
|
}, Chunk = class Chunk {
|
|
1410
1424
|
boundary;
|
|
@@ -1509,20 +1523,30 @@ var State = class {
|
|
|
1509
1523
|
readyResumeScripts && (needsWalk = !0);
|
|
1510
1524
|
let effects = this.async ? "" : this.effects, { html, scripts } = this;
|
|
1511
1525
|
if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
|
|
1512
|
-
|
|
1526
|
+
let carried = null;
|
|
1513
1527
|
for (let reorderedChunk of state.writeReorders) {
|
|
1528
|
+
if (reorderedChunk.async && reorderedChunk.consumed) {
|
|
1529
|
+
let aborted = reorderedChunk.boundary;
|
|
1530
|
+
for (; aborted && !aborted.signal.aborted;) aborted = aborted.parent;
|
|
1531
|
+
if (!aborted) {
|
|
1532
|
+
(carried ||= []).push(reorderedChunk);
|
|
1533
|
+
continue;
|
|
1534
|
+
}
|
|
1535
|
+
reorderedChunk.async = !1;
|
|
1536
|
+
}
|
|
1537
|
+
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
|
|
1514
1538
|
let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
|
1515
1539
|
for (reorderedChunk.reorderId = null;;) {
|
|
1516
1540
|
cur.flushPlaceholder(), cur.deferOwnReady();
|
|
1517
1541
|
let { next } = cur, readyResumeScripts = cur.flushReadyScripts(readyReservations);
|
|
1518
|
-
if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
|
|
1542
|
+
if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), state.reorder(cur), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
|
|
1519
1543
|
else break;
|
|
1520
1544
|
}
|
|
1521
1545
|
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
|
|
1522
1546
|
for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
|
|
1523
1547
|
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1524
1548
|
}
|
|
1525
|
-
state.writeReorders =
|
|
1549
|
+
state.writeReorders = carried;
|
|
1526
1550
|
}
|
|
1527
1551
|
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
|
|
1528
1552
|
}
|
package/dist/html.mjs
CHANGED
|
@@ -4,7 +4,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
4
4
|
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
5
|
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
6
|
return str;
|
|
7
|
-
}, unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : "<", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg =
|
|
7
|
+
}, unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : "<", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str, unsafeStyleReg = /<\/style/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = Symbol.for("marko.touchedIterator"), { hasOwnProperty: hasOwnProperty$1 } = {}, Generator = (function* () {})().constructor, AsyncGenerator = (async function* () {})().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
8
8
|
let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
|
|
9
9
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
|
10
10
|
let symbol = Symbol[name];
|
|
@@ -238,10 +238,10 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
238
238
|
[JSON, "JSON"],
|
|
239
239
|
[Math, "Math"],
|
|
240
240
|
[Reflect, "Reflect"]
|
|
241
|
-
]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
241
|
+
]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
242
242
|
let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
|
|
243
243
|
return state.needsMainRuntime = !0, Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
|
|
244
|
-
}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(
|
|
244
|
+
}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
|
245
245
|
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
|
|
246
246
|
if (typeof renderer == "string") {
|
|
247
247
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
@@ -533,7 +533,7 @@ function writeAssigned(state) {
|
|
|
533
533
|
} else state.buf.push("void 0");
|
|
534
534
|
let valueStartIndex = state.buf.push(toAccess(toObjectKey(mutation.property)) + "(");
|
|
535
535
|
if (mutation.value !== void 0) if (writeProp(state, mutation.value, null, "")) {
|
|
536
|
-
let valueRef = state.refs.get(mutation.value);
|
|
536
|
+
let valueRef = typeof mutation.value == "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
|
|
537
537
|
valueRef && !valueRef.id && valueRef.scopeId === void 0 && (valueRef.id = mutation.valueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
|
|
538
538
|
} else state.buf.push("void 0");
|
|
539
539
|
state.buf.push(")");
|
|
@@ -818,7 +818,7 @@ function writeReadableStream(state, val, ref) {
|
|
|
818
818
|
return state.buf.push("new ReadableStream({start(c){(async(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()]))=>{for(i of a)v=await i,i==l?c.close():c.enqueue(v)})(" + iterId + "={}).catch(e=>c.error(e))}})"), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
|
|
819
819
|
}
|
|
820
820
|
function writeGenerator(state, iter, ref) {
|
|
821
|
-
if (iter[kTouchedIterator]) return state.buf.push("(
|
|
821
|
+
if (iter[kTouchedIterator]) return state.buf.push("(function*(){}())"), !0;
|
|
822
822
|
let sep = "";
|
|
823
823
|
for (state.buf.push("(function*(){");;) {
|
|
824
824
|
let { value, done } = iter.next();
|
|
@@ -906,32 +906,45 @@ function toAccess(accessor) {
|
|
|
906
906
|
return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
907
907
|
}
|
|
908
908
|
function quote(str, startPos) {
|
|
909
|
+
if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
|
|
909
910
|
let result = "", lastPos = 0;
|
|
910
911
|
for (let i = startPos; i < str.length; i++) {
|
|
911
|
-
let replacement;
|
|
912
|
-
switch (
|
|
913
|
-
case
|
|
912
|
+
let replacement, code = str.charCodeAt(i);
|
|
913
|
+
switch (code) {
|
|
914
|
+
case 34:
|
|
914
915
|
replacement = "\\\"";
|
|
915
916
|
break;
|
|
916
|
-
case
|
|
917
|
+
case 92:
|
|
917
918
|
replacement = "\\\\";
|
|
918
919
|
break;
|
|
919
|
-
case
|
|
920
|
+
case 60:
|
|
920
921
|
replacement = "\\x3C";
|
|
921
922
|
break;
|
|
922
|
-
case
|
|
923
|
+
case 10:
|
|
923
924
|
replacement = "\\n";
|
|
924
925
|
break;
|
|
925
|
-
case
|
|
926
|
+
case 13:
|
|
926
927
|
replacement = "\\r";
|
|
927
928
|
break;
|
|
928
|
-
case
|
|
929
|
+
case 8232:
|
|
929
930
|
replacement = "\\u2028";
|
|
930
931
|
break;
|
|
931
|
-
case
|
|
932
|
+
case 8233:
|
|
932
933
|
replacement = "\\u2029";
|
|
933
934
|
break;
|
|
934
|
-
|
|
935
|
+
case 0:
|
|
936
|
+
replacement = "\\x00";
|
|
937
|
+
break;
|
|
938
|
+
default:
|
|
939
|
+
if (code < 55296 || code > 57343) continue;
|
|
940
|
+
if (code < 56320) {
|
|
941
|
+
let next = str.charCodeAt(i + 1);
|
|
942
|
+
if (next >= 56320 && next <= 57343) {
|
|
943
|
+
i++;
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
replacement = "\\u" + code.toString(16);
|
|
935
948
|
}
|
|
936
949
|
result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
|
|
937
950
|
}
|
|
@@ -1281,7 +1294,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
|
1281
1294
|
let branchId = _peek_scope_id();
|
|
1282
1295
|
$chunk.writeHTML($chunk.boundary.state.mark("[", "")), withIsAsync(content, value), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
1283
1296
|
} else withIsAsync(content, value);
|
|
1284
|
-
}), boundary.endAsync(
|
|
1297
|
+
}), boundary.endAsync()));
|
|
1285
1298
|
}, (err) => {
|
|
1286
1299
|
chunk.async = !1, boundary.abort(err);
|
|
1287
1300
|
});
|
|
@@ -1309,7 +1322,7 @@ function tryPlaceholder(content, placeholder, branchId) {
|
|
|
1309
1322
|
};
|
|
1310
1323
|
}
|
|
1311
1324
|
function tryCatch(content, catchContent) {
|
|
1312
|
-
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
|
|
1325
|
+
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, void 0, boundary), body = chunk.fork(catchBoundary, null), bodyEnd = body.render(content);
|
|
1313
1326
|
if (catchBoundary.signal.aborted) {
|
|
1314
1327
|
catchContent(catchBoundary.signal.reason);
|
|
1315
1328
|
return;
|
|
@@ -1387,13 +1400,14 @@ var State = class {
|
|
|
1387
1400
|
}
|
|
1388
1401
|
}, Boundary = class extends AbortController {
|
|
1389
1402
|
state;
|
|
1403
|
+
parent;
|
|
1390
1404
|
onNext = NOOP$2;
|
|
1391
1405
|
count = 0;
|
|
1392
|
-
constructor(state, parent) {
|
|
1393
|
-
super(), this.state = state, this.signal.addEventListener("abort", () => {
|
|
1406
|
+
constructor(state, signal, parent) {
|
|
1407
|
+
super(), this.state = state, this.parent = parent, this.signal.addEventListener("abort", () => {
|
|
1394
1408
|
this.count = 0, this.state = new State(this.state.$global), this.onNext();
|
|
1395
|
-
}),
|
|
1396
|
-
this.abort(
|
|
1409
|
+
}), signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", () => {
|
|
1410
|
+
this.abort(signal.reason);
|
|
1397
1411
|
}));
|
|
1398
1412
|
}
|
|
1399
1413
|
flush() {
|
|
@@ -1402,8 +1416,8 @@ var State = class {
|
|
|
1402
1416
|
startAsync() {
|
|
1403
1417
|
this.signal.aborted || this.count++;
|
|
1404
1418
|
}
|
|
1405
|
-
endAsync(
|
|
1406
|
-
!this.signal.aborted && this.count && (this.count--,
|
|
1419
|
+
endAsync() {
|
|
1420
|
+
!this.signal.aborted && this.count && (this.count--, this.onNext());
|
|
1407
1421
|
}
|
|
1408
1422
|
}, Chunk = class Chunk {
|
|
1409
1423
|
boundary;
|
|
@@ -1508,20 +1522,30 @@ var State = class {
|
|
|
1508
1522
|
readyResumeScripts && (needsWalk = !0);
|
|
1509
1523
|
let effects = this.async ? "" : this.effects, { html, scripts } = this;
|
|
1510
1524
|
if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
|
|
1511
|
-
|
|
1525
|
+
let carried = null;
|
|
1512
1526
|
for (let reorderedChunk of state.writeReorders) {
|
|
1527
|
+
if (reorderedChunk.async && reorderedChunk.consumed) {
|
|
1528
|
+
let aborted = reorderedChunk.boundary;
|
|
1529
|
+
for (; aborted && !aborted.signal.aborted;) aborted = aborted.parent;
|
|
1530
|
+
if (!aborted) {
|
|
1531
|
+
(carried ||= []).push(reorderedChunk);
|
|
1532
|
+
continue;
|
|
1533
|
+
}
|
|
1534
|
+
reorderedChunk.async = !1;
|
|
1535
|
+
}
|
|
1536
|
+
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
|
|
1513
1537
|
let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
|
1514
1538
|
for (reorderedChunk.reorderId = null;;) {
|
|
1515
1539
|
cur.flushPlaceholder(), cur.deferOwnReady();
|
|
1516
1540
|
let { next } = cur, readyResumeScripts = cur.flushReadyScripts(readyReservations);
|
|
1517
|
-
if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
|
|
1541
|
+
if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), state.reorder(cur), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
|
|
1518
1542
|
else break;
|
|
1519
1543
|
}
|
|
1520
1544
|
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
|
|
1521
1545
|
for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
|
|
1522
1546
|
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1523
1547
|
}
|
|
1524
|
-
state.writeReorders =
|
|
1548
|
+
state.writeReorders = carried;
|
|
1525
1549
|
}
|
|
1526
1550
|
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
|
|
1527
1551
|
}
|
package/dist/translator/index.js
CHANGED
|
@@ -1713,8 +1713,8 @@ const escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg,
|
|
|
1713
1713
|
function _escape(val) {
|
|
1714
1714
|
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
|
|
1715
1715
|
}
|
|
1716
|
-
const unsafeScriptReg =
|
|
1717
|
-
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C
|
|
1716
|
+
const unsafeScriptReg = /<(\/?script|!--)/gi;
|
|
1717
|
+
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str;
|
|
1718
1718
|
function _escape_script(val) {
|
|
1719
1719
|
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
|
1720
1720
|
}
|
|
@@ -1931,9 +1931,9 @@ function nonVoidAttr(name, value) {
|
|
|
1931
1931
|
}
|
|
1932
1932
|
return " " + name + attrAssignment(value + "");
|
|
1933
1933
|
}
|
|
1934
|
-
const singleQuoteAttrReplacements = /'|&(
|
|
1935
|
-
const doubleQuoteAttrReplacements = /"|&(
|
|
1936
|
-
const needsQuotedAttr = /["'>\s]
|
|
1934
|
+
const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
|
|
1935
|
+
const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
|
|
1936
|
+
const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
|
|
1937
1937
|
function attrAssignment(value) {
|
|
1938
1938
|
return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
|
|
1939
1939
|
}
|
|
@@ -2134,6 +2134,9 @@ function sectionHasSetupStatements(section) {
|
|
|
2134
2134
|
}
|
|
2135
2135
|
//#endregion
|
|
2136
2136
|
//#region src/translator/util/binding-has-prop.ts
|
|
2137
|
+
function isSectionRendererElided(section) {
|
|
2138
|
+
return !!section.downstreamBinding && !bindingHasProperty(section.downstreamBinding.binding, section.downstreamBinding.properties);
|
|
2139
|
+
}
|
|
2137
2140
|
function bindingHasProperty(binding, properties) {
|
|
2138
2141
|
if (binding.pruned) return false;
|
|
2139
2142
|
else if (binding.pruned === void 0) throw new Error("Binding must be pruned before checking properties");
|
|
@@ -3513,7 +3516,7 @@ var dom_default = { translate: {
|
|
|
3513
3516
|
const setup = getSetup(childSection);
|
|
3514
3517
|
const written = writeSignals(childSection);
|
|
3515
3518
|
const setupIdentifier = setup && written.has(setup) ? setup.identifier : void 0;
|
|
3516
|
-
if (!
|
|
3519
|
+
if (!isSectionRendererElided(childSection)) if (getSectionParentIsOwner(childSection)) setBranchRendererArgs(childSection, [
|
|
3517
3520
|
writes,
|
|
3518
3521
|
walks,
|
|
3519
3522
|
setupIdentifier,
|
|
@@ -4269,9 +4272,12 @@ function buildContent(body) {
|
|
|
4269
4272
|
if (dynamicSerializeReason) body.node.body.unshift(getScopeReasonDeclaration(bodySection));
|
|
4270
4273
|
else body.node.body.unshift(_marko_compiler.types.expressionStatement(callRuntime("_scope_reason")));
|
|
4271
4274
|
return callRuntime(serialized ? "_content_resume" : "_content", _marko_compiler.types.stringLiteral(getResumeRegisterId(bodySection, "content")), _marko_compiler.types.arrowFunctionExpression(body.node.params, _marko_compiler.types.blockStatement(body.node.body)), serialized ? getScopeIdIdentifier(getSection(getAttributeTagParent(body.parentPath))) : void 0);
|
|
4272
|
-
} else
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
+
} else {
|
|
4276
|
+
if (isSectionRendererElided(bodySection)) return;
|
|
4277
|
+
return _marko_compiler.types.callExpression(_marko_compiler.types.identifier(bodySection.name), bodySection.referencedLocalClosures ? [scopeIdentifier, _marko_compiler.types.objectExpression(toArray(bodySection.referencedLocalClosures, (ref) => {
|
|
4278
|
+
return toObjectProperty(getScopeAccessor(ref, true), getDeclaredBindingExpression(ref));
|
|
4279
|
+
}))] : [scopeIdentifier]);
|
|
4280
|
+
}
|
|
4275
4281
|
}
|
|
4276
4282
|
//#endregion
|
|
4277
4283
|
//#region src/translator/visitors/tag/native-tag.ts
|
|
@@ -4294,6 +4300,7 @@ var native_tag_default = {
|
|
|
4294
4300
|
(0, _marko_compiler_babel_utils.getProgram)().node.extra.page ??= true;
|
|
4295
4301
|
break;
|
|
4296
4302
|
}
|
|
4303
|
+
if (tagName === "option") assertOptionInSelectWithValue(tag);
|
|
4297
4304
|
const isTextOnly = isTextOnlyNativeTag(tag);
|
|
4298
4305
|
const seen = {};
|
|
4299
4306
|
const { attributes } = tag.node;
|
|
@@ -4790,6 +4797,31 @@ function getCanonicalTagName(tag) {
|
|
|
4790
4797
|
default: return tagName;
|
|
4791
4798
|
}
|
|
4792
4799
|
}
|
|
4800
|
+
function assertOptionInSelectWithValue(tag) {
|
|
4801
|
+
let parent = tag.parentPath;
|
|
4802
|
+
while (parent) {
|
|
4803
|
+
if (parent.isMarkoTag()) {
|
|
4804
|
+
if (analyzeTagNameType(parent) === 0) {
|
|
4805
|
+
const parentName = getCanonicalTagName(parent);
|
|
4806
|
+
if (parentName === "select") {
|
|
4807
|
+
if (parent.node.attributes.some((attr) => _marko_compiler.types.isMarkoAttribute(attr) && (attr.name === "value" || attr.name === "valueChange"))) {
|
|
4808
|
+
let hasValue = false;
|
|
4809
|
+
const attributes = tag.get("attributes");
|
|
4810
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
4811
|
+
const attr = attributes[i].node;
|
|
4812
|
+
if (!_marko_compiler.types.isMarkoAttribute(attr) || attr.name === "value") hasValue = true;
|
|
4813
|
+
else if (attr.name === "selected") throw attributes[i].buildCodeFrameError("The `selected` attribute is not supported on an `<option>` within a `<select>` that has a `value` attribute; include the option's `value` in the select's `value` instead.");
|
|
4814
|
+
}
|
|
4815
|
+
if (!hasValue) throw tag.buildCodeFrameError("An `<option>` within a `<select>` that has a `value` attribute must also have a `value` attribute.");
|
|
4816
|
+
}
|
|
4817
|
+
return;
|
|
4818
|
+
}
|
|
4819
|
+
if (parentName !== "optgroup") return;
|
|
4820
|
+
} else if (!isControlFlowTag(parent)) return;
|
|
4821
|
+
} else if (parent.isProgram()) return;
|
|
4822
|
+
parent = parent.parentPath;
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4793
4825
|
function getTextOnlyEscapeHelper(tagName) {
|
|
4794
4826
|
switch (tagName) {
|
|
4795
4827
|
case "script": return "_escape_script";
|
|
@@ -7766,6 +7798,7 @@ var export_default = {
|
|
|
7766
7798
|
//#endregion
|
|
7767
7799
|
//#region src/translator/core/html-comment.ts
|
|
7768
7800
|
const kNodeBinding$1 = Symbol("comment tag binding");
|
|
7801
|
+
const escapeCommentText = (text) => text.replace(/>/g, ">");
|
|
7769
7802
|
var html_comment_default = {
|
|
7770
7803
|
analyze(tag) {
|
|
7771
7804
|
(0, _marko_compiler_babel_utils.assertNoArgs)(tag);
|
|
@@ -7803,11 +7836,11 @@ var html_comment_default = {
|
|
|
7803
7836
|
const nodeBinding = tagExtra[kNodeBinding$1];
|
|
7804
7837
|
const write = writeTo(tag);
|
|
7805
7838
|
if (isOutputHTML()) {
|
|
7806
|
-
for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoText(child)) write`${child.value}`;
|
|
7839
|
+
for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoText(child)) write`${escapeCommentText(child.value)}`;
|
|
7807
7840
|
else if (_marko_compiler.types.isMarkoPlaceholder(child)) write`${callRuntime(child.escape ? "_escape_comment" : "_unescaped", child.value)}`;
|
|
7808
7841
|
} else {
|
|
7809
7842
|
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
7810
|
-
if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${textLiteral}`;
|
|
7843
|
+
if (_marko_compiler.types.isStringLiteral(textLiteral)) write`${escapeCommentText(textLiteral.value)}`;
|
|
7811
7844
|
else addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text", createScopeReadExpression(nodeBinding), textLiteral)));
|
|
7812
7845
|
}
|
|
7813
7846
|
exit(tag);
|
|
@@ -8953,12 +8986,13 @@ var placeholder_default = {
|
|
|
8953
8986
|
const siblingText = extra[kSiblingText];
|
|
8954
8987
|
const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding);
|
|
8955
8988
|
if (siblingText === 1) {
|
|
8956
|
-
if (isHTML && markerSerializeReason)
|
|
8957
|
-
else write`${callRuntime("_sep", getSerializeGuard(section, markerSerializeReason, true))}`;
|
|
8989
|
+
if (isHTML && markerSerializeReason) writeSeparator(write, section, markerSerializeReason);
|
|
8958
8990
|
visit(placeholder, 37);
|
|
8959
8991
|
} else if (siblingText === 2) visit(placeholder, 37);
|
|
8960
8992
|
else {
|
|
8961
|
-
if (
|
|
8993
|
+
if (isHTML) {
|
|
8994
|
+
if (siblingText === 3 && markerSerializeReason) writeSeparator(write, section, markerSerializeReason);
|
|
8995
|
+
} else write` `;
|
|
8962
8996
|
visit(placeholder, 32);
|
|
8963
8997
|
}
|
|
8964
8998
|
if (isHTML) {
|
|
@@ -8990,8 +9024,13 @@ function buildEscapedTextExpression(value) {
|
|
|
8990
9024
|
default: return callRuntime("_escape", value);
|
|
8991
9025
|
}
|
|
8992
9026
|
}
|
|
9027
|
+
function writeSeparator(write, section, reason) {
|
|
9028
|
+
if (reason === true || reason.state) write`<!>`;
|
|
9029
|
+
else write`${callRuntime("_sep", getSerializeGuard(section, reason, true))}`;
|
|
9030
|
+
}
|
|
8993
9031
|
function analyzeSiblingText(placeholder) {
|
|
8994
9032
|
const placeholderExtra = placeholder.node.extra;
|
|
9033
|
+
let hasNodeBefore = false;
|
|
8995
9034
|
let prev = placeholder.getPrevSibling();
|
|
8996
9035
|
let prevParent = placeholder.parentPath;
|
|
8997
9036
|
for (;;) {
|
|
@@ -9007,7 +9046,10 @@ function analyzeSiblingText(placeholder) {
|
|
|
9007
9046
|
const contentType = getNodeContentType(prev, "endType");
|
|
9008
9047
|
if (contentType === null) prev = prev.getPrevSibling();
|
|
9009
9048
|
else if (contentType === 4 || contentType === 1 || contentType === 2) return placeholderExtra[kSiblingText] = 1;
|
|
9010
|
-
else
|
|
9049
|
+
else {
|
|
9050
|
+
hasNodeBefore = true;
|
|
9051
|
+
break;
|
|
9052
|
+
}
|
|
9011
9053
|
}
|
|
9012
9054
|
if (!prev.node && prevParent.isProgram()) return placeholderExtra[kSiblingText] = 1;
|
|
9013
9055
|
let next = placeholder.getNextSibling();
|
|
@@ -9028,7 +9070,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
9028
9070
|
else break;
|
|
9029
9071
|
}
|
|
9030
9072
|
if (!next.node && nextParent.isProgram()) return placeholderExtra[kSiblingText] = 2;
|
|
9031
|
-
return placeholderExtra[kSiblingText] = 0;
|
|
9073
|
+
return placeholderExtra[kSiblingText] = hasNodeBefore ? 3 : 0;
|
|
9032
9074
|
}
|
|
9033
9075
|
function getInlinedBodyTag(parent) {
|
|
9034
9076
|
if (parent.isMarkoTagBody()) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Opt } from "./optional";
|
|
2
2
|
import type { Binding } from "./references";
|
|
3
|
+
import type { Section } from "./sections";
|
|
4
|
+
export declare function isSectionRendererElided(section: Section): boolean;
|
|
3
5
|
export declare function bindingHasProperty(binding: Binding, properties: Opt<string>): boolean;
|