marko 6.4.9 → 6.4.11
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/cheatsheet.md +1 -1
- package/dist/common/accessor.d.ts +0 -3
- package/dist/common/accessor.debug.d.ts +0 -3
- package/dist/common/helpers.d.ts +1 -1
- package/dist/common/types.d.ts +4 -3
- package/dist/debug/dom/catch.feat.js +2 -3
- package/dist/debug/dom/catch.feat.mjs +2 -3
- package/dist/debug/dom/controllable-input.feat.js +2 -3
- package/dist/debug/dom/controllable-input.feat.mjs +2 -3
- package/dist/debug/dom/controllable-open.feat.js +2 -3
- package/dist/debug/dom/controllable-open.feat.mjs +2 -3
- package/dist/debug/dom/controllable-select.feat.js +2 -3
- package/dist/debug/dom/controllable-select.feat.mjs +2 -3
- package/dist/debug/dom/controllable-textarea.feat.js +2 -3
- package/dist/debug/dom/controllable-textarea.feat.mjs +2 -3
- package/dist/debug/dom/controllable.feat.js +2 -3
- package/dist/debug/dom/controllable.feat.mjs +2 -3
- package/dist/debug/dom/dynamic-tag-script.feat.js +2 -3
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +2 -3
- package/dist/debug/dom/dynamic-tag-var.feat.js +2 -3
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +2 -3
- package/dist/debug/dom/lazy.feat.js +2 -3
- package/dist/debug/dom/lazy.feat.mjs +2 -3
- package/dist/debug/dom/placeholder.feat.js +2 -3
- package/dist/debug/dom/placeholder.feat.mjs +2 -3
- package/dist/debug/{dom-VKjkbuuo.mjs → dom-DjUZd-9y.mjs} +221 -261
- package/dist/debug/{dom-QkYva5Qx.js → dom-mQ5mPBTF.js} +226 -260
- package/dist/debug/dom.js +10 -18
- package/dist/debug/dom.mjs +10 -19
- package/dist/debug/html.js +87 -125
- package/dist/debug/html.mjs +87 -125
- package/dist/dom/abort-signal.d.ts +1 -1
- package/dist/dom/catch.feat.js +4 -5
- package/dist/dom/catch.feat.mjs +2 -3
- package/dist/dom/control-flow.d.ts +4 -4
- package/dist/dom/controllable-input.feat.js +1 -2
- package/dist/dom/controllable-input.feat.mjs +1 -2
- package/dist/dom/controllable-open.feat.js +2 -3
- package/dist/dom/controllable-open.feat.mjs +2 -3
- package/dist/dom/controllable-select.feat.js +2 -3
- package/dist/dom/controllable-select.feat.mjs +2 -3
- package/dist/dom/controllable-textarea.feat.js +2 -3
- package/dist/dom/controllable-textarea.feat.mjs +2 -3
- package/dist/dom/controllable.feat.js +1 -2
- package/dist/dom/controllable.feat.mjs +1 -2
- package/dist/dom/dynamic-tag-script.feat.js +3 -4
- package/dist/dom/dynamic-tag-script.feat.mjs +2 -3
- package/dist/dom/dynamic-tag-var.feat.js +3 -4
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -2
- package/dist/dom/lazy.feat.js +2 -3
- package/dist/dom/lazy.feat.mjs +2 -3
- package/dist/dom/load.d.ts +3 -4
- package/dist/dom/placeholder.feat.js +2 -3
- package/dist/dom/placeholder.feat.mjs +2 -3
- package/dist/dom/queue.d.ts +1 -2
- package/dist/dom/signals.d.ts +5 -7
- package/dist/{dom-IujlfJ6b.js → dom-B8j2453O.js} +158 -190
- package/dist/{dom-DtKQb840.mjs → dom-HEWdZCCb.mjs} +134 -172
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +22 -30
- package/dist/dom.mjs +10 -19
- package/dist/html/assets.d.ts +3 -4
- package/dist/html/for.d.ts +0 -1
- package/dist/html/writer.d.ts +2 -2
- package/dist/html.d.ts +1 -1
- package/dist/html.js +99 -131
- package/dist/html.mjs +99 -132
- package/dist/translator/index.d.ts +0 -1
- package/dist/translator/index.js +4771 -4760
- package/dist/translator/interop/out-global.d.ts +5 -0
- package/dist/translator/util/assert.d.ts +13 -2
- package/dist/translator/util/entry-builder.d.ts +1 -1
- package/dist/translator/util/finalize-references.d.ts +2 -1
- package/dist/translator/util/for-selector.d.ts +1 -1
- package/dist/translator/util/known-tag.d.ts +10 -1
- package/dist/translator/util/references.d.ts +11 -5
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/sections.d.ts +6 -1
- package/dist/translator/util/signals.d.ts +2 -1
- package/dist/translator/util/sources.d.ts +1 -1
- package/dist/translator/util/style-interpolation.d.ts +1 -1
- package/dist/translator/util/tag-name-type.d.ts +4 -0
- package/dist/translator/util/visitors.d.ts +1 -1
- package/dist/translator/util/write-guard.d.ts +2 -0
- package/dist/translator/visitors/program/index.d.ts +0 -4
- package/dist/translator/visitors/referenced-identifier.d.ts +3 -1
- package/package.json +6 -6
- package/tags/lifecycle.d.marko +2 -0
- package/dist/common/constants/keyed-scopes-prop.d.ts +0 -4
- package/dist/common/constants/keyed-scopes-prop.debug.d.ts +0 -4
package/dist/debug/html.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
3
|
+
// src/common/attr-tag.ts
|
|
4
4
|
const empty = [];
|
|
5
5
|
const rest = Symbol("Attribute Tag");
|
|
6
6
|
function attrTag(attrs) {
|
|
@@ -20,8 +20,7 @@ function* attrTagIterator() {
|
|
|
20
20
|
yield this;
|
|
21
21
|
yield* this[rest];
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
//#region src/common/constants/accessor-prefix.debug.ts
|
|
23
|
+
// src/common/constants/accessor-prefix.debug.ts
|
|
25
24
|
const BranchScopes = "BranchScopes:";
|
|
26
25
|
const ConditionalRenderer = "ConditionalRenderer:";
|
|
27
26
|
const ControlledHandler = "ControlledHandler:";
|
|
@@ -38,8 +37,7 @@ const TagVariable = "#TagVariable";
|
|
|
38
37
|
const Owner = "owner";
|
|
39
38
|
const Embed = "embed";
|
|
40
39
|
const Lazy = "lazy";
|
|
41
|
-
|
|
42
|
-
//#region src/common/helpers.ts
|
|
40
|
+
// src/common/helpers.ts
|
|
43
41
|
const invalidNativeAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
44
42
|
const knownWrongAttrs = {
|
|
45
43
|
className: "class",
|
|
@@ -103,7 +101,7 @@ function escapeStyleValue(str) {
|
|
|
103
101
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
104
102
|
return result + closers;
|
|
105
103
|
}
|
|
106
|
-
|
|
104
|
+
function toDelimitedString(val, delimiter, stringify) {
|
|
107
105
|
let str = "";
|
|
108
106
|
let sep = "";
|
|
109
107
|
let part;
|
|
@@ -125,7 +123,7 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
125
123
|
}
|
|
126
124
|
}
|
|
127
125
|
return str;
|
|
128
|
-
}
|
|
126
|
+
}
|
|
129
127
|
function isEventHandler(name) {
|
|
130
128
|
return /^on[A-Z-]/.test(name);
|
|
131
129
|
}
|
|
@@ -156,8 +154,7 @@ function normalizeDynamicRenderer(value) {
|
|
|
156
154
|
if ("id" in normalized) return normalized;
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
|
-
|
|
160
|
-
//#region src/common/errors.ts
|
|
157
|
+
// src/common/errors.ts
|
|
161
158
|
const lowercaseOnAttrReg = /^on[a-z]/;
|
|
162
159
|
function assertValidAttrValue(name, value) {
|
|
163
160
|
if (value && typeof value !== "string" && lowercaseOnAttrReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
|
|
@@ -275,13 +272,14 @@ function joinWithAnd(a) {
|
|
|
275
272
|
default: return `${a.slice(0, -1).join(", ")}, and ${a[a.length - 1]}`;
|
|
276
273
|
}
|
|
277
274
|
}
|
|
278
|
-
|
|
279
|
-
//#region src/common/meta.ts
|
|
275
|
+
// src/common/meta.ts
|
|
280
276
|
const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
281
277
|
const DYNAMIC_TAG_VAR_REGISTER_ID = "_dynamicTagVar";
|
|
282
278
|
const PLACEHOLDER_DISMISS_REGISTER_ID = "_placeholderDismiss";
|
|
283
|
-
|
|
284
|
-
|
|
279
|
+
// src/common/opt.ts
|
|
280
|
+
function toArray(opt) {
|
|
281
|
+
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
282
|
+
}
|
|
285
283
|
function reduce(opt, cb, acc) {
|
|
286
284
|
if (opt) {
|
|
287
285
|
if (Array.isArray(opt)) for (const item of opt) acc = cb(acc, item);
|
|
@@ -302,8 +300,7 @@ function concat(opt, other) {
|
|
|
302
300
|
}
|
|
303
301
|
return Array.isArray(other) ? [opt, ...other] : [opt, other];
|
|
304
302
|
}
|
|
305
|
-
|
|
306
|
-
//#region src/html/serializer.ts
|
|
303
|
+
// src/html/serializer.ts
|
|
307
304
|
const K_SCOPE_ID = Symbol("Scope ID");
|
|
308
305
|
const kTouchedIterator = /* @__PURE__ */ Symbol.for("marko.touchedIterator");
|
|
309
306
|
const { hasOwnProperty } = {};
|
|
@@ -710,7 +707,7 @@ function writeScopesRoot(state, flushes) {
|
|
|
710
707
|
} else buf.pop();
|
|
711
708
|
}
|
|
712
709
|
let extras = "";
|
|
713
|
-
if (state.deferredRefs.size ||
|
|
710
|
+
if (state.deferredRefs.size || hasMatchingCalls(state, state.channel?.readyId)) extras = state.writeTrailing(scopesIndex);
|
|
714
711
|
let result = extras && "(";
|
|
715
712
|
for (const chunk of buf) result += chunk;
|
|
716
713
|
result += extras;
|
|
@@ -804,9 +801,6 @@ function writeCallArg(state, val, valueId) {
|
|
|
804
801
|
}
|
|
805
802
|
} else state.buf.push("void 0");
|
|
806
803
|
}
|
|
807
|
-
function hasChannelCalls(state) {
|
|
808
|
-
return hasMatchingCalls(state, state.channel?.readyId);
|
|
809
|
-
}
|
|
810
804
|
function hasMatchingCalls(state, readyId) {
|
|
811
805
|
if (!readyId) return state.queuedCalls.length > 0;
|
|
812
806
|
for (const call of state.queuedReadyCalls) if (call.channel.readyId === readyId) return true;
|
|
@@ -1327,17 +1321,10 @@ function writeRequest(state, val, ref) {
|
|
|
1327
1321
|
options += sep + "credentials:" + quote(val.credentials, 0);
|
|
1328
1322
|
sep = ",";
|
|
1329
1323
|
}
|
|
1330
|
-
const
|
|
1331
|
-
if (
|
|
1332
|
-
options += sep + "headers:" +
|
|
1324
|
+
const headers = headersOption(state, val.headers, ref);
|
|
1325
|
+
if (headers) {
|
|
1326
|
+
options += sep + "headers:" + headers;
|
|
1333
1327
|
sep = ",";
|
|
1334
|
-
} else {
|
|
1335
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
1336
|
-
const headers = stringEntriesToHeadersInit(val.headers);
|
|
1337
|
-
if (headers) {
|
|
1338
|
-
options += sep + "headers:" + headers;
|
|
1339
|
-
sep = ",";
|
|
1340
|
-
}
|
|
1341
1328
|
}
|
|
1342
1329
|
if (val.integrity) {
|
|
1343
1330
|
options += sep + "integrity:" + quote(val.integrity, 0);
|
|
@@ -1378,13 +1365,8 @@ function writeResponse(state, val, ref) {
|
|
|
1378
1365
|
options += sep + "statusText:" + quote(val.statusText, 0);
|
|
1379
1366
|
sep = ",";
|
|
1380
1367
|
}
|
|
1381
|
-
const
|
|
1382
|
-
if (
|
|
1383
|
-
else {
|
|
1384
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
1385
|
-
const headers = stringEntriesToHeadersInit(val.headers);
|
|
1386
|
-
if (headers) options += sep + "headers:" + headers;
|
|
1387
|
-
}
|
|
1368
|
+
const headers = headersOption(state, val.headers, ref);
|
|
1369
|
+
if (headers) options += sep + "headers:" + headers;
|
|
1388
1370
|
if (!val.body || val.bodyUsed) state.buf.push("new Response" + (options ? "(null,{" + options + "})" : ""));
|
|
1389
1371
|
else {
|
|
1390
1372
|
state.buf.push("new Response(");
|
|
@@ -1392,6 +1374,12 @@ function writeResponse(state, val, ref) {
|
|
|
1392
1374
|
}
|
|
1393
1375
|
return true;
|
|
1394
1376
|
}
|
|
1377
|
+
function headersOption(state, headers, ref) {
|
|
1378
|
+
const seen = state.refs.get(headers);
|
|
1379
|
+
if (seen) return ensureRefAccess(state, seen);
|
|
1380
|
+
state.refs.set(headers, new Reference(ref, "headers", state.flushId, null));
|
|
1381
|
+
return stringEntriesToHeadersInit(headers);
|
|
1382
|
+
}
|
|
1395
1383
|
function writeIntl(state, val, name, ref) {
|
|
1396
1384
|
const { locale, ...options } = val.resolvedOptions();
|
|
1397
1385
|
state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
|
|
@@ -1842,8 +1830,7 @@ function patchIteratorNext(proto) {
|
|
|
1842
1830
|
};
|
|
1843
1831
|
proto.next[kTouchedIterator] = true;
|
|
1844
1832
|
}
|
|
1845
|
-
|
|
1846
|
-
//#region src/html/attrs.ts
|
|
1833
|
+
// src/html/attrs.ts
|
|
1847
1834
|
function _attr_class(value) {
|
|
1848
1835
|
return stringAttr("class", toDelimitedString(value, " ", stringifyClassEntry));
|
|
1849
1836
|
}
|
|
@@ -1920,7 +1907,7 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, s
|
|
|
1920
1907
|
return normalizedOpen ? " open" : "";
|
|
1921
1908
|
}
|
|
1922
1909
|
function _attr_nonce() {
|
|
1923
|
-
return
|
|
1910
|
+
return getState().nonceAttr;
|
|
1924
1911
|
}
|
|
1925
1912
|
function _style_html(decls) {
|
|
1926
1913
|
const id = _id();
|
|
@@ -1984,7 +1971,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
1984
1971
|
break;
|
|
1985
1972
|
default:
|
|
1986
1973
|
if (name) assertValidAttrName(name);
|
|
1987
|
-
if (name && !(isNullishOrFalse(value) ||
|
|
1974
|
+
if (name && !(isNullishOrFalse(value) || name === "content" && tagName !== "meta" || skip.test(name))) {
|
|
1988
1975
|
if (isEventHandler(name)) {
|
|
1989
1976
|
if (!events) {
|
|
1990
1977
|
events = {};
|
|
@@ -2075,8 +2062,7 @@ function normalizedValueMatches(a, b) {
|
|
|
2075
2062
|
function normalizeStrAttrValue(value) {
|
|
2076
2063
|
return isNotNullishOrFalse(value) && value !== true ? value + "" : "";
|
|
2077
2064
|
}
|
|
2078
|
-
|
|
2079
|
-
//#region src/html/inlined-runtimes.debug.ts
|
|
2065
|
+
// src/html/inlined-runtimes.debug.ts
|
|
2080
2066
|
const WALKER_RUNTIME_CODE = `((runtimeId) => (self[runtimeId] ||= (
|
|
2081
2067
|
renderId,
|
|
2082
2068
|
prefix = runtimeId + renderId,
|
|
@@ -2172,8 +2158,7 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
|
|
|
2172
2158
|
}
|
|
2173
2159
|
};
|
|
2174
2160
|
})`;
|
|
2175
|
-
|
|
2176
|
-
//#region src/html/writer.ts
|
|
2161
|
+
// src/html/writer.ts
|
|
2177
2162
|
let $chunk;
|
|
2178
2163
|
function getChunk() {
|
|
2179
2164
|
return $chunk;
|
|
@@ -2200,7 +2185,7 @@ function getScopeId(scope) {
|
|
|
2200
2185
|
return scope[K_SCOPE_ID];
|
|
2201
2186
|
}
|
|
2202
2187
|
function getScopeById(scopeId) {
|
|
2203
|
-
|
|
2188
|
+
return $chunk.boundary.state.scopes.get(scopeId);
|
|
2204
2189
|
}
|
|
2205
2190
|
function $global() {
|
|
2206
2191
|
return $chunk.boundary.state.$global;
|
|
@@ -2262,7 +2247,7 @@ function mayDrop(written) {
|
|
|
2262
2247
|
return false;
|
|
2263
2248
|
}
|
|
2264
2249
|
function _script(scopeId, registryId, markerGuard) {
|
|
2265
|
-
if (markerGuard === 0 && ($chunk.channel.readyId || $chunk
|
|
2250
|
+
if (markerGuard === 0 && ($chunk.channel.readyId || getAsyncContent($chunk))) _resume_branch(scopeId);
|
|
2266
2251
|
$chunk.boundary.state.queueEffect(scopeId, registryId);
|
|
2267
2252
|
}
|
|
2268
2253
|
function _trailers(html) {
|
|
@@ -2306,7 +2291,7 @@ function markText(scopeId, accessor, text, markerGuard) {
|
|
|
2306
2291
|
return text ? (markerGuard === 2 ? "<!>" : "") + text + state.mark("$", scopeId + " " + accessor) : state.mark("%", scopeId + " " + accessor);
|
|
2307
2292
|
}
|
|
2308
2293
|
function _resume_branch(scopeId) {
|
|
2309
|
-
const branchId =
|
|
2294
|
+
const branchId = getContext(kBranchId);
|
|
2310
2295
|
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId]: branchId });
|
|
2311
2296
|
}
|
|
2312
2297
|
function _attr_content(nodeAccessor, scopeId, content, markerGuard) {
|
|
@@ -2443,7 +2428,6 @@ function unsubscribe(subscribed, serializer) {
|
|
|
2443
2428
|
}
|
|
2444
2429
|
}
|
|
2445
2430
|
}
|
|
2446
|
-
const NOOP$2 = () => {};
|
|
2447
2431
|
function countResumeWrite(chunk) {
|
|
2448
2432
|
for (let boundary = chunk.boundary; boundary; boundary = boundary.parent) boundary.resumeWrites++;
|
|
2449
2433
|
}
|
|
@@ -2565,8 +2549,9 @@ var State = class {
|
|
|
2565
2549
|
return "<!--" + this.commentPrefix + code + str + "-->";
|
|
2566
2550
|
}
|
|
2567
2551
|
};
|
|
2552
|
+
function NOOP() {}
|
|
2568
2553
|
var Boundary = class {
|
|
2569
|
-
onNext = NOOP
|
|
2554
|
+
onNext = NOOP;
|
|
2570
2555
|
count = 0;
|
|
2571
2556
|
resumeWrites = 0;
|
|
2572
2557
|
state;
|
|
@@ -2830,7 +2815,7 @@ var Chunk = class Chunk {
|
|
|
2830
2815
|
const { readyId } = channel;
|
|
2831
2816
|
let scripts = "";
|
|
2832
2817
|
const held = this.takeDeferredReady();
|
|
2833
|
-
if (held) for (const chunk of
|
|
2818
|
+
if (held) for (const chunk of toArray(held)) {
|
|
2834
2819
|
if (chunk.boundary.aborted) continue;
|
|
2835
2820
|
scripts = concatScripts(scripts, chunk.flushReadyScripts(boundary, reservations, holdEffects));
|
|
2836
2821
|
if (chunk.effects || chunk.deferredReady) this.deferredReady = push(this.deferredReady, chunk);
|
|
@@ -2883,7 +2868,7 @@ var Chunk = class Chunk {
|
|
|
2883
2868
|
if (effects) {
|
|
2884
2869
|
needsWalk = true;
|
|
2885
2870
|
flushSerializerGlobals(boundary);
|
|
2886
|
-
state.resumes = state.resumes
|
|
2871
|
+
state.resumes = concatSequence(state.resumes, "\"" + effects + "\"");
|
|
2887
2872
|
}
|
|
2888
2873
|
let reordered = "";
|
|
2889
2874
|
let needsResumeArray = false;
|
|
@@ -3067,23 +3052,16 @@ function depsMarker(deps) {
|
|
|
3067
3052
|
return marker;
|
|
3068
3053
|
}
|
|
3069
3054
|
function getFilteredGlobals($global) {
|
|
3070
|
-
if (!$global) return 0;
|
|
3071
3055
|
const serializedGlobals = $global.serializedGlobals;
|
|
3072
3056
|
if (!serializedGlobals) return 0;
|
|
3073
3057
|
let filtered = 0;
|
|
3074
3058
|
if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
|
|
3075
3059
|
const value = $global[key];
|
|
3076
|
-
if (value !== void 0) {
|
|
3077
|
-
if (filtered) filtered[key] = value;
|
|
3078
|
-
else filtered = { [key]: value };
|
|
3079
|
-
}
|
|
3060
|
+
if (value !== void 0) (filtered ||= {})[key] = value;
|
|
3080
3061
|
}
|
|
3081
3062
|
else for (const key in serializedGlobals) if (serializedGlobals[key]) {
|
|
3082
3063
|
const value = $global[key];
|
|
3083
|
-
if (value !== void 0) {
|
|
3084
|
-
if (filtered) filtered[key] = value;
|
|
3085
|
-
else filtered = { [key]: value };
|
|
3086
|
-
}
|
|
3064
|
+
if (value !== void 0) (filtered ||= {})[key] = value;
|
|
3087
3065
|
}
|
|
3088
3066
|
return filtered;
|
|
3089
3067
|
}
|
|
@@ -3119,8 +3097,7 @@ function flushTickQueue() {
|
|
|
3119
3097
|
});
|
|
3120
3098
|
}
|
|
3121
3099
|
}
|
|
3122
|
-
|
|
3123
|
-
//#region src/html/content.ts
|
|
3100
|
+
// src/html/content.ts
|
|
3124
3101
|
function _to_text(val) {
|
|
3125
3102
|
assertValidTextValue(val);
|
|
3126
3103
|
return val || val === 0 ? val + "" : "";
|
|
@@ -3134,7 +3111,7 @@ const replaceUnsafeXML = (c) => c === "&" ? "&" : c === "<" ? "<" : "
|
|
|
3134
3111
|
const escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
|
|
3135
3112
|
function _escape(val) {
|
|
3136
3113
|
assertValidTextValue(val);
|
|
3137
|
-
return val ?
|
|
3114
|
+
return val || val === 0 ? typeof val === "number" ? val + "" : escapeXMLStr(val + "") : "";
|
|
3138
3115
|
}
|
|
3139
3116
|
const unsafeScriptReg = /<(\/?script|!--)/gi;
|
|
3140
3117
|
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\u003C$1") : str;
|
|
@@ -3164,8 +3141,7 @@ function _escape_comment(val) {
|
|
|
3164
3141
|
assertValidTextValue(val);
|
|
3165
3142
|
return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
|
|
3166
3143
|
}
|
|
3167
|
-
|
|
3168
|
-
//#region src/html/dynamic-tag.ts
|
|
3144
|
+
// src/html/dynamic-tag.ts
|
|
3169
3145
|
const voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
|
3170
3146
|
let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, markerGuard, tagVar) => {
|
|
3171
3147
|
const shouldResume = markerGuard !== 0;
|
|
@@ -3178,34 +3154,31 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, m
|
|
|
3178
3154
|
assertValidTagName(renderer);
|
|
3179
3155
|
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
3180
3156
|
rendered = true;
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
if (
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
else if (renderContent) _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, markerGuard);
|
|
3193
|
-
}
|
|
3194
|
-
_html(`</${renderer}>`);
|
|
3195
|
-
} else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
3196
|
-
const childScope = getScopeById(branchId);
|
|
3197
|
-
const needsScript = childScope && (childScope[`EventAttributes:#${renderer.toLowerCase()}/0`] || childScope[`ControlledHandler:#${renderer.toLowerCase()}/0`]);
|
|
3198
|
-
if (needsScript) {
|
|
3199
|
-
writeScope(branchId, { [Renderer]: renderer });
|
|
3200
|
-
_script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
|
|
3157
|
+
_scope_id();
|
|
3158
|
+
_html(`<${renderer}${_attrs(input, `#${renderer.toLowerCase()}/0`, branchId, renderer)}>`);
|
|
3159
|
+
if (!voidElementsReg.test(renderer)) {
|
|
3160
|
+
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
3161
|
+
if (renderer === "textarea") {
|
|
3162
|
+
if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
|
|
3163
|
+
_html(_attrs_textarea_value(branchId, `#${renderer.toLowerCase()}/0`, input));
|
|
3164
|
+
} else {
|
|
3165
|
+
if (renderContent && typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
3166
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, markerGuard) : void 0, 1);
|
|
3167
|
+
else if (renderContent) _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, markerGuard);
|
|
3201
3168
|
}
|
|
3202
|
-
|
|
3203
|
-
};
|
|
3204
|
-
|
|
3169
|
+
_html(`</${renderer}>`);
|
|
3170
|
+
} else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
3171
|
+
const childScope = getScopeById(branchId);
|
|
3172
|
+
const needsScript = childScope && (childScope[`EventAttributes:#${renderer.toLowerCase()}/0`] || childScope[`ControlledHandler:#${renderer.toLowerCase()}/0`]);
|
|
3173
|
+
if (needsScript) {
|
|
3174
|
+
writeScope(branchId, { [Renderer]: renderer });
|
|
3175
|
+
_script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
|
|
3176
|
+
}
|
|
3177
|
+
if (shouldResume || needsScript) _html(state.mark("(", scopeId + " " + accessor + " " + branchId));
|
|
3205
3178
|
result = _el(scopeId, DYNAMIC_TAG_VAR_REGISTER_ID + accessor);
|
|
3206
3179
|
} else {
|
|
3207
3180
|
if (tagVar && renderer?.["lazy"]) throw new Error(`A dynamic tag with a [tag variable](https://markojs.com/docs/reference/language#tag-variables) rendered \`${renderer["id"]}\`, which is lazily loaded, so it does not support one. Import it without \`load\`, or remove the variable.`);
|
|
3208
|
-
const chunk =
|
|
3181
|
+
const chunk = $chunk;
|
|
3209
3182
|
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
3210
3183
|
const render = () => {
|
|
3211
3184
|
if (renderer) try {
|
|
@@ -3247,8 +3220,7 @@ const patchDynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (patch) => {
|
|
|
3247
3220
|
return originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, markerGuard, tagVar);
|
|
3248
3221
|
};
|
|
3249
3222
|
})(_dynamic_tag);
|
|
3250
|
-
|
|
3251
|
-
//#region src/html/template.ts
|
|
3223
|
+
// src/html/template.ts
|
|
3252
3224
|
const CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result";
|
|
3253
3225
|
const _template = (templateId, renderer, page) => {
|
|
3254
3226
|
renderer.render = render;
|
|
@@ -3508,12 +3480,10 @@ var ServerRendered = class {
|
|
|
3508
3480
|
}
|
|
3509
3481
|
};
|
|
3510
3482
|
function settle(boundary) {
|
|
3511
|
-
boundary.onNext = NOOP
|
|
3483
|
+
boundary.onNext = NOOP;
|
|
3512
3484
|
boundary.state.$global.signal?.removeEventListener("abort", boundary);
|
|
3513
3485
|
}
|
|
3514
|
-
|
|
3515
|
-
//#endregion
|
|
3516
|
-
//#region src/html/assets.ts
|
|
3486
|
+
// src/html/assets.ts
|
|
3517
3487
|
const kAssets = Symbol();
|
|
3518
3488
|
const kHead = Symbol();
|
|
3519
3489
|
function withLoadAssets(template, id, flush, assetId, triggers) {
|
|
@@ -3610,17 +3580,18 @@ function addAsset(g, id, flush, triggers) {
|
|
|
3610
3580
|
function triggerScript(id, html, triggers) {
|
|
3611
3581
|
const htmlStr = quoteScriptTemplateLiteral(html);
|
|
3612
3582
|
const insert = `(d=new Range().createContextualFragment(h),d.querySelectorAll("script").forEach(s=>s.onerror=()=>console.error(${quoteScriptTemplateLiteral(`The lazy module for "${id}" failed to load; its server-rendered content cannot become interactive.`)})),document.head.append(d))`;
|
|
3613
|
-
const exprs = triggers.map(
|
|
3614
|
-
const options = trigger.options && toObjectExpression(trigger.options);
|
|
3615
|
-
switch (trigger.type) {
|
|
3616
|
-
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(${querySelectorOrLoad(trigger.selector)})`;
|
|
3617
|
-
case "idle": return `(self.requestIdleCallback||l)(l${options ? `,${options}` : ""})`;
|
|
3618
|
-
case "media": return `(m=>m.matches?l():m.addEventListener("change",l,{once:1}))(matchMedia(${JSON.stringify(trigger.selector)}))`;
|
|
3619
|
-
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(${querySelectorOrLoad(trigger.selector)})`;
|
|
3620
|
-
}
|
|
3621
|
-
});
|
|
3583
|
+
const exprs = triggers.map(triggerExpression);
|
|
3622
3584
|
return `((h,d,l=$=>{d||${insert}})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(${htmlStr})`;
|
|
3623
3585
|
}
|
|
3586
|
+
function triggerExpression(trigger) {
|
|
3587
|
+
const options = trigger.options && toObjectExpression(trigger.options);
|
|
3588
|
+
switch (trigger.type) {
|
|
3589
|
+
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(${querySelectorOrLoad(trigger.selector)})`;
|
|
3590
|
+
case "idle": return `(self.requestIdleCallback||l)(l${options ? `,${options}` : ""})`;
|
|
3591
|
+
case "media": return `(m=>m.matches?l():m.addEventListener("change",l,{once:1}))(matchMedia(${JSON.stringify(trigger.selector)}))`;
|
|
3592
|
+
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(${querySelectorOrLoad(trigger.selector)})`;
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3624
3595
|
function querySelectorOrLoad(selector) {
|
|
3625
3596
|
return `document.querySelector(${JSON.stringify(selector)})||${`(console.warn(${JSON.stringify(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`)}),l())`}`;
|
|
3626
3597
|
}
|
|
@@ -3633,12 +3604,10 @@ function toObjectExpression(options) {
|
|
|
3633
3604
|
}
|
|
3634
3605
|
return result + "}";
|
|
3635
3606
|
}
|
|
3636
|
-
|
|
3637
|
-
//#region src/common/compat-meta.ts
|
|
3607
|
+
// src/common/compat-meta.ts
|
|
3638
3608
|
const SET_SCOPE_REGISTER_ID = "$compat_setScope";
|
|
3639
3609
|
const RENDER_BODY_ID = "$compat_renderBody";
|
|
3640
|
-
|
|
3641
|
-
//#region src/common/for.ts
|
|
3610
|
+
// src/common/for.ts
|
|
3642
3611
|
function forIn(obj, cb) {
|
|
3643
3612
|
for (const key in obj) cb(key, obj[key]);
|
|
3644
3613
|
}
|
|
@@ -3665,8 +3634,7 @@ function forUntil(until, from, step, cb) {
|
|
|
3665
3634
|
const delta = step || 1;
|
|
3666
3635
|
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
3667
3636
|
}
|
|
3668
|
-
|
|
3669
|
-
//#region src/html/for.ts
|
|
3637
|
+
// src/html/for.ts
|
|
3670
3638
|
function forOfBy(by, item, index) {
|
|
3671
3639
|
return by ? typeof by === "string" ? item[by] : by(item, index) : index;
|
|
3672
3640
|
}
|
|
@@ -3676,8 +3644,7 @@ function forInBy(by, name, value) {
|
|
|
3676
3644
|
function forStepBy(by, index) {
|
|
3677
3645
|
return by ? by(index) : index;
|
|
3678
3646
|
}
|
|
3679
|
-
|
|
3680
|
-
//#region src/html/control-flow.ts
|
|
3647
|
+
// src/html/control-flow.ts
|
|
3681
3648
|
function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
|
|
3682
3649
|
if (display) {
|
|
3683
3650
|
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
@@ -3759,7 +3726,8 @@ function forBranches(by, cb, iterate, scopeId, accessor, branchGuard, markerGuar
|
|
|
3759
3726
|
flushBranchIds = branchId + "";
|
|
3760
3727
|
}
|
|
3761
3728
|
}
|
|
3762
|
-
withBranchId(branchId, cb, a, b);
|
|
3729
|
+
if (resumeMarker) withBranchId(branchId, cb, a, b);
|
|
3730
|
+
else cb(a, b);
|
|
3763
3731
|
const branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { [LoopKey]: itemKey } : {});
|
|
3764
3732
|
if (!resumeMarker) loopScopes = push(loopScopes, branchScope);
|
|
3765
3733
|
});
|
|
@@ -3772,7 +3740,7 @@ function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, p
|
|
|
3772
3740
|
const branchId = _peek_scope_id();
|
|
3773
3741
|
const chunk = $chunk;
|
|
3774
3742
|
const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
|
|
3775
|
-
const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
|
|
3743
|
+
const branchIndex = resumeBranch && resumeMarker ? withBranchId(branchId, cb) : cb();
|
|
3776
3744
|
const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
3777
3745
|
if (beforeBranch !== void 0) applyBranchStart(chunk, beforeBranch, shouldWriteBranch);
|
|
3778
3746
|
if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
|
|
@@ -3786,11 +3754,8 @@ function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
|
|
|
3786
3754
|
}
|
|
3787
3755
|
function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
|
|
3788
3756
|
const endTag = parentEndTag || "";
|
|
3789
|
-
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag))
|
|
3790
|
-
|
|
3791
|
-
const mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
|
|
3792
|
-
$chunk.writeHTML(mark + endTag);
|
|
3793
|
-
} else if (markerGuard !== 0) $chunk.writeHTML(endTag + _el_mark(scopeId, accessor));
|
|
3757
|
+
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) $chunk.writeHTML($chunk.boundary.state.mark(singleNode ? parentEndTag ? "}" : "|" : parentEndTag ? ")" : "]", scopeId + " " + accessor + branchIds) + endTag);
|
|
3758
|
+
else if (markerGuard !== 0) $chunk.writeHTML(endTag + _el_mark(scopeId, accessor));
|
|
3794
3759
|
else $chunk.writeHTML(endTag);
|
|
3795
3760
|
}
|
|
3796
3761
|
function _await(scopeId, accessor, promise, content, markerGuard) {
|
|
@@ -3957,8 +3922,7 @@ function writeTryRenderers(branchId, catchContent, placeholderContent) {
|
|
|
3957
3922
|
[PlaceholderContent]: placeholderContent
|
|
3958
3923
|
});
|
|
3959
3924
|
}
|
|
3960
|
-
|
|
3961
|
-
//#region src/html/compat.ts
|
|
3925
|
+
// src/html/compat.ts
|
|
3962
3926
|
const K_TAGS_API_STATE = Symbol();
|
|
3963
3927
|
const COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap();
|
|
3964
3928
|
const compat = {
|
|
@@ -4030,14 +3994,14 @@ const compat = {
|
|
|
4030
3994
|
return joined;
|
|
4031
3995
|
},
|
|
4032
3996
|
appendChunks(chunks) {
|
|
4033
|
-
const chunk =
|
|
3997
|
+
const chunk = $chunk;
|
|
4034
3998
|
for (const part of chunks) {
|
|
4035
3999
|
chunk.append(part);
|
|
4036
4000
|
if (part.effects) chunk.lastEffect = part.lastEffect;
|
|
4037
4001
|
}
|
|
4038
4002
|
},
|
|
4039
4003
|
deferReorders(reorders) {
|
|
4040
|
-
const chunk =
|
|
4004
|
+
const chunk = $chunk;
|
|
4041
4005
|
for (let i = reorders.length; i--;) {
|
|
4042
4006
|
const carrier = chunk.fork(chunk.boundary, chunk.next);
|
|
4043
4007
|
carrier.deferredReorder = reorders[i];
|
|
@@ -4168,8 +4132,6 @@ function swapReorders(state, reorders) {
|
|
|
4168
4132
|
state.writeReorders = reorders;
|
|
4169
4133
|
return writeReorders;
|
|
4170
4134
|
}
|
|
4171
|
-
function NOOP() {}
|
|
4172
|
-
//#endregion
|
|
4173
4135
|
exports.$global = $global;
|
|
4174
4136
|
exports._assert_class_toggles = _assert_class_toggles;
|
|
4175
4137
|
exports._assert_hoist = _assert_hoist;
|