marko 6.3.35 → 6.3.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/meta.d.ts +1 -0
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +7 -0
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +6 -0
- package/dist/debug/{dom-Bt4OoZ-j.js → dom-BkYlHM4b.js} +46 -12
- package/dist/debug/{dom-B57LrRnX.mjs → dom-woc_wRhN.mjs} +29 -13
- package/dist/debug/dom.js +7 -7
- package/dist/debug/dom.mjs +7 -7
- package/dist/debug/html.js +6 -4
- package/dist/debug/html.mjs +6 -4
- package/dist/dom/abort-signal.d.ts +2 -0
- package/dist/dom/catch.feat.js +4 -4
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/control-flow.d.ts +2 -0
- package/dist/dom/controllable-input.feat.js +2 -2
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +2 -2
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +2 -2
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +2 -2
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +2 -2
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.d.ts +1 -0
- package/dist/dom/dynamic-tag-var.feat.js +3 -0
- package/dist/dom/dynamic-tag-var.feat.mjs +4 -0
- package/dist/dom/load.d.ts +3 -3
- package/dist/dom/resume.d.ts +1 -0
- package/dist/{dom-BeF9xIzO.js → dom-B15s3PHD.js} +132 -120
- package/dist/{dom-BP2XSglG.mjs → dom-CPUybM_C.mjs} +19 -17
- package/dist/dom.js +57 -60
- package/dist/dom.mjs +28 -31
- package/dist/html.js +4 -4
- package/dist/html.mjs +4 -4
- package/dist/translator/index.js +177 -43
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/util/runtime.d.ts +1 -1
- package/dist/translator/util/traverse.d.ts +2 -0
- package/package.json +4 -4
package/dist/translator/index.js
CHANGED
|
@@ -377,6 +377,7 @@ const Generator = (function* () {})().constructor;
|
|
|
377
377
|
const AsyncGenerator = (async function* () {})().constructor;
|
|
378
378
|
patchIteratorNext(Generator.prototype);
|
|
379
379
|
patchIteratorNext(AsyncGenerator.prototype);
|
|
380
|
+
const REGISTRY = /* @__PURE__ */ new WeakMap();
|
|
380
381
|
(() => {
|
|
381
382
|
const KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
|
|
382
383
|
for (const name of Object.getOwnPropertyNames(Symbol)) {
|
|
@@ -387,10 +388,88 @@ patchIteratorNext(AsyncGenerator.prototype);
|
|
|
387
388
|
})();
|
|
388
389
|
Array.from, Array.isArray, Array.of, ArrayBuffer.isView, Atomics.add, Atomics.and, Atomics.compareExchange, Atomics.exchange, Atomics.isLockFree, Atomics.load, Atomics.notify, Atomics.or, Atomics.store, Atomics.sub, Atomics.wait, BigInt.asIntN, BigInt.asUintN, BigInt64Array, BigInt64Array.from, BigInt64Array.of, BigUint64Array, BigUint64Array.from, BigUint64Array.of, console.timeStamp, Date.now, Date.parse, Date.UTC, Float32Array.from, Float32Array.of, Float64Array.from, Float64Array.of, globalThis.atob, globalThis.btoa, globalThis.clearImmediate, globalThis.clearInterval, globalThis.clearTimeout, globalThis.crypto?.getRandomValues, globalThis.crypto?.randomUUID, globalThis.fetch, globalThis.performance?.now, globalThis.queueMicrotask, globalThis.setImmediate, globalThis.setInterval, globalThis.setTimeout, globalThis.structuredClone, globalThis.URL, globalThis.URLSearchParams, globalThis.WritableStream, Int16Array.from, Int16Array.of, Int32Array.from, Int32Array.of, Int8Array.from, Int8Array.of, Intl.Collator, Intl.DateTimeFormat, Intl.DisplayNames, Intl.getCanonicalLocales, Intl.ListFormat, Intl.Locale, Intl.NumberFormat, Intl.PluralRules, Intl.RelativeTimeFormat, Intl.Segmenter, Intl.supportedValuesOf, Map.groupBy, Number.isFinite, Number.isInteger, Number.isNaN, Number.isSafeInteger, Number.parseFloat, Number.parseInt, String.fromCharCode, String.fromCodePoint, String.raw, Symbol.for, Uint16Array.from, Uint16Array.of, Uint32Array.from, Uint32Array.of, Uint8Array.from, Uint8Array.of, Uint8ClampedArray.from, Uint8ClampedArray.of;
|
|
389
390
|
Atomics, globalThis.crypto;
|
|
391
|
+
function register(id, val, scope) {
|
|
392
|
+
REGISTRY.set(val, {
|
|
393
|
+
id,
|
|
394
|
+
scope,
|
|
395
|
+
access: "_._" + toAccess(toObjectKey(id))
|
|
396
|
+
});
|
|
397
|
+
return val;
|
|
398
|
+
}
|
|
399
|
+
function toObjectKey(name) {
|
|
400
|
+
if (name === "") return "\"\"";
|
|
401
|
+
if (name === "__proto__") return "[\"__proto__\"]";
|
|
402
|
+
const len = name.length;
|
|
403
|
+
const c0 = name.charCodeAt(0);
|
|
404
|
+
if (c0 >= 48 && c0 <= 57) if (c0 === 48) {
|
|
405
|
+
if (len !== 1) return quote(name, 1);
|
|
406
|
+
} else {
|
|
407
|
+
for (let i = 1; i < len; i++) {
|
|
408
|
+
const c = name.charCodeAt(i);
|
|
409
|
+
if (c < 48 || c > 57) return quote(name, i);
|
|
410
|
+
}
|
|
411
|
+
if (len > 15 && "" + +name !== name) return quote(name, 0);
|
|
412
|
+
}
|
|
413
|
+
else if (c0 >= 97 && c0 <= 122 || c0 >= 65 && c0 <= 90 || c0 === 95 || c0 === 36) for (let i = 1; i < len; i++) {
|
|
414
|
+
const c = name.charCodeAt(i);
|
|
415
|
+
if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 95 || c === 36)) return quote(name, i);
|
|
416
|
+
}
|
|
417
|
+
else return quote(name, 0);
|
|
418
|
+
return name;
|
|
419
|
+
}
|
|
390
420
|
function toAccess(accessor) {
|
|
391
421
|
const start = accessor[0];
|
|
392
422
|
return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
393
423
|
}
|
|
424
|
+
const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
|
|
425
|
+
function quote(str, startPos) {
|
|
426
|
+
if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
|
|
427
|
+
let result = "";
|
|
428
|
+
let lastPos = 0;
|
|
429
|
+
for (let i = startPos; i < str.length; i++) {
|
|
430
|
+
let replacement;
|
|
431
|
+
const code = str.charCodeAt(i);
|
|
432
|
+
switch (code) {
|
|
433
|
+
case 34:
|
|
434
|
+
replacement = "\\\"";
|
|
435
|
+
break;
|
|
436
|
+
case 92:
|
|
437
|
+
replacement = "\\\\";
|
|
438
|
+
break;
|
|
439
|
+
case 60:
|
|
440
|
+
replacement = "\\x3C";
|
|
441
|
+
break;
|
|
442
|
+
case 10:
|
|
443
|
+
replacement = "\\n";
|
|
444
|
+
break;
|
|
445
|
+
case 13:
|
|
446
|
+
replacement = "\\r";
|
|
447
|
+
break;
|
|
448
|
+
case 8232:
|
|
449
|
+
replacement = "\\u2028";
|
|
450
|
+
break;
|
|
451
|
+
case 8233:
|
|
452
|
+
replacement = "\\u2029";
|
|
453
|
+
break;
|
|
454
|
+
case 0:
|
|
455
|
+
replacement = "\\x00";
|
|
456
|
+
break;
|
|
457
|
+
default:
|
|
458
|
+
if (code < 55296 || code > 57343) continue;
|
|
459
|
+
if (code < 56320) {
|
|
460
|
+
const next = str.charCodeAt(i + 1);
|
|
461
|
+
if (next >= 56320 && next <= 57343) {
|
|
462
|
+
i++;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
replacement = "\\u" + code.toString(16);
|
|
467
|
+
}
|
|
468
|
+
result += str.slice(lastPos, i) + replacement;
|
|
469
|
+
lastPos = i + 1;
|
|
470
|
+
}
|
|
471
|
+
return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
|
|
472
|
+
}
|
|
394
473
|
function patchIteratorNext(proto) {
|
|
395
474
|
if (proto.next[kTouchedIterator]) return;
|
|
396
475
|
const { next } = proto;
|
|
@@ -425,16 +504,37 @@ function traverseReplace(container, key, enter, state) {
|
|
|
425
504
|
}
|
|
426
505
|
}
|
|
427
506
|
function traverseContains(node, check) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
507
|
+
return !!traverseFind(node, check);
|
|
508
|
+
}
|
|
509
|
+
function traverseFind(node, check) {
|
|
510
|
+
if (node) if (Array.isArray(node)) for (const item of node) {
|
|
511
|
+
const found = traverseFind(item, check);
|
|
512
|
+
if (found) return found;
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
431
515
|
switch (check(node)) {
|
|
432
|
-
case true: return
|
|
433
|
-
case skip: return
|
|
516
|
+
case true: return node;
|
|
517
|
+
case skip: return;
|
|
518
|
+
}
|
|
519
|
+
for (const key of _marko_compiler.types.VISITOR_KEYS[node.type]) {
|
|
520
|
+
const found = traverseFind(node[key], check);
|
|
521
|
+
if (found) return found;
|
|
434
522
|
}
|
|
435
|
-
for (const key of _marko_compiler.types.VISITOR_KEYS[node.type]) if (traverseContains(node[key], check)) return true;
|
|
436
523
|
}
|
|
437
|
-
|
|
524
|
+
}
|
|
525
|
+
function traverseFindAwait(node) {
|
|
526
|
+
return traverseFind(node, (child) => {
|
|
527
|
+
switch (child.type) {
|
|
528
|
+
case "ForOfStatement": return child.await;
|
|
529
|
+
case "FunctionDeclaration":
|
|
530
|
+
case "FunctionExpression":
|
|
531
|
+
case "ArrowFunctionExpression":
|
|
532
|
+
case "ClassMethod":
|
|
533
|
+
case "ObjectMethod":
|
|
534
|
+
case "ClassPrivateMethod": return skip;
|
|
535
|
+
case "AwaitExpression": return true;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
438
538
|
}
|
|
439
539
|
function traverse(visit, node, parent, grandParent) {
|
|
440
540
|
if (node) {
|
|
@@ -1443,7 +1543,7 @@ function getNodeContentType(path, extraMember, contentInfo) {
|
|
|
1443
1543
|
case "for":
|
|
1444
1544
|
case "if":
|
|
1445
1545
|
case "await":
|
|
1446
|
-
case "try":
|
|
1546
|
+
case "try": return 1;
|
|
1447
1547
|
case "show": return 1;
|
|
1448
1548
|
default: return null;
|
|
1449
1549
|
}
|
|
@@ -1565,6 +1665,13 @@ function isNativeNode(tag) {
|
|
|
1565
1665
|
const [getReferencesByFn] = createProgramState(() => /* @__PURE__ */ new Map());
|
|
1566
1666
|
const [getReferencesByImportedFn] = createProgramState(() => /* @__PURE__ */ new Map());
|
|
1567
1667
|
var function_default = { analyze(fn) {
|
|
1668
|
+
const awaitNode = isMarkoAttribute(fn.parentPath) && _marko_compiler.types.isFunctionExpression(fn.node) && !fn.node.async && traverseFindAwait(fn.node.body);
|
|
1669
|
+
if (awaitNode) {
|
|
1670
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
1671
|
+
const start = file.code.indexOf("await", awaitNode.start ?? 0);
|
|
1672
|
+
const highlight = start >= 0 && (awaitNode.end == null || start < awaitNode.end) ? (0, _marko_compiler_babel_utils.withLoc)(file, _marko_compiler.types.cloneNode(awaitNode), start, start + 5) : awaitNode;
|
|
1673
|
+
throw fn.hub.buildError(highlight, "Attribute methods containing `await` must be `async`. Add `async` before the method name.");
|
|
1674
|
+
}
|
|
1568
1675
|
if (fn !== getFnRoot(fn)) return;
|
|
1569
1676
|
const exprRoot = getExprRoot(fn);
|
|
1570
1677
|
const markoRoot = getMarkoRoot(exprRoot);
|
|
@@ -1928,8 +2035,6 @@ const regexpCharsReg = /[\\^$.*+?()[\]{}|]/g;
|
|
|
1928
2035
|
function escapeRegExp(str) {
|
|
1929
2036
|
return str.replace(regexpCharsReg, "\\$&");
|
|
1930
2037
|
}
|
|
1931
|
-
//#endregion
|
|
1932
|
-
//#region src/common/errors.ts
|
|
1933
2038
|
function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
1934
2039
|
if (attrs) {
|
|
1935
2040
|
let exclusiveAttrs;
|
|
@@ -2032,6 +2137,12 @@ function _script(scopeId, registryId) {
|
|
|
2032
2137
|
$chunk.boundary.state.needsMainRuntime = true;
|
|
2033
2138
|
$chunk.writeEffect(scopeId, registryId);
|
|
2034
2139
|
}
|
|
2140
|
+
function _resume(val, id, scopeId) {
|
|
2141
|
+
return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
|
|
2142
|
+
}
|
|
2143
|
+
function _el(scopeId, id) {
|
|
2144
|
+
return _resume(() => void 0, id, scopeId);
|
|
2145
|
+
}
|
|
2035
2146
|
function _resume_branch(scopeId) {
|
|
2036
2147
|
const branchId = $chunk.context?.[kBranchId];
|
|
2037
2148
|
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId$1]: branchId });
|
|
@@ -2056,6 +2167,9 @@ let writeScope = (scopeId, partialScope) => {
|
|
|
2056
2167
|
target.flushScopes = true;
|
|
2057
2168
|
return scope;
|
|
2058
2169
|
};
|
|
2170
|
+
function _scope_with_id(scopeId) {
|
|
2171
|
+
return scopeWithId($chunk.boundary.state, scopeId);
|
|
2172
|
+
}
|
|
2059
2173
|
function scopeWithId(state, scopeId) {
|
|
2060
2174
|
const { scopes } = state;
|
|
2061
2175
|
let scope = scopes.get(scopeId);
|
|
@@ -2250,10 +2364,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2250
2364
|
if (!voidElementsReg.test(renderer)) {
|
|
2251
2365
|
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
2252
2366
|
if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
|
|
2253
|
-
else
|
|
2254
|
-
if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2255
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent, 1);
|
|
2256
|
-
else _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
2367
|
+
else {
|
|
2368
|
+
if (renderContent && typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2369
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason) : void 0, 1);
|
|
2370
|
+
else if (renderContent) _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
2257
2371
|
}
|
|
2258
2372
|
_html(`</${renderer}>`);
|
|
2259
2373
|
}
|
|
@@ -2263,6 +2377,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2263
2377
|
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
2264
2378
|
};
|
|
2265
2379
|
renderNative();
|
|
2380
|
+
result = _el(branchId, "e");
|
|
2266
2381
|
} else {
|
|
2267
2382
|
const chunk = void 0;
|
|
2268
2383
|
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
@@ -2334,10 +2449,17 @@ const pureDOMFunctions = /* @__PURE__ */ new Set([
|
|
|
2334
2449
|
"_load_media_trigger",
|
|
2335
2450
|
"_load_race_trigger"
|
|
2336
2451
|
]);
|
|
2452
|
+
const [getRuntimeImports] = createProgramState(() => /* @__PURE__ */ new Map());
|
|
2337
2453
|
function importRuntime(name) {
|
|
2338
2454
|
if (!isTranslate()) throw new Error(`\`importRuntime(${JSON.stringify(name)})\` may only be called during the translate stage.`);
|
|
2339
2455
|
const { output } = getMarkoOpts();
|
|
2340
|
-
|
|
2456
|
+
const imports = getRuntimeImports();
|
|
2457
|
+
let localName = imports.get(name);
|
|
2458
|
+
if (!localName) {
|
|
2459
|
+
localName = (0, _marko_compiler_babel_utils.importNamed)((0, _marko_compiler_babel_utils.getFile)(), getRuntimePath(output), name).name;
|
|
2460
|
+
imports.set(name, localName);
|
|
2461
|
+
}
|
|
2462
|
+
return _marko_compiler.types.identifier(localName);
|
|
2341
2463
|
}
|
|
2342
2464
|
function callRuntime(name, ...args) {
|
|
2343
2465
|
const callExpression = _marko_compiler.types.callExpression(importRuntime(name), filterArguments(args));
|
|
@@ -3538,7 +3660,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3538
3660
|
}
|
|
3539
3661
|
body.push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, sectionSerializeReason, writeScopeBuilder ? writeScopeBuilder(callRuntime("_scope", ...writeScopeArgs)) : callRuntime("_scope", ...writeScopeArgs))));
|
|
3540
3662
|
}
|
|
3541
|
-
if (!section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || !!find(section.bindings, (binding) => binding.type === 1))) body.push(_marko_compiler.types.expressionStatement(callRuntime("_resume_branch", scopeIdIdentifier)));
|
|
3663
|
+
if (!section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || sectionSerializeReason && !!find(section.bindings, (binding) => binding.type === 1))) body.push(_marko_compiler.types.expressionStatement(callRuntime("_resume_branch", scopeIdIdentifier)));
|
|
3542
3664
|
const additionalStatements = getHTMLSectionStatements(section);
|
|
3543
3665
|
if (body.length || additionalStatements.length) body.unshift(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(scopeIdIdentifier, callRuntime("_scope_id"))]), ...additionalStatements);
|
|
3544
3666
|
if (debug) forEach(section.bindings, (binding) => {
|
|
@@ -4005,7 +4127,12 @@ var dom_default = { translate: {
|
|
|
4005
4127
|
program.node.body.unshift(_marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(templateIdentifier, writes || _marko_compiler.types.stringLiteral(""))])), _marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(walksIdentifier, walks || _marko_compiler.types.stringLiteral(""))])));
|
|
4006
4128
|
if (extraDecls) program.node.body.unshift(_marko_compiler.types.variableDeclaration("const", extraDecls));
|
|
4007
4129
|
writeModuleRegistrations(program);
|
|
4008
|
-
program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(program.hub.file.metadata.marko.id),
|
|
4130
|
+
program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(program.hub.file.metadata.marko.id), ...replaceNullishAndEmptyFunctionsWith0([
|
|
4131
|
+
templateIdentifier,
|
|
4132
|
+
walksIdentifier,
|
|
4133
|
+
domExports.setupEmpty ? void 0 : setupIdentifier,
|
|
4134
|
+
programInputSignal?.identifier
|
|
4135
|
+
]))));
|
|
4009
4136
|
}
|
|
4010
4137
|
} };
|
|
4011
4138
|
//#endregion
|
|
@@ -6966,6 +7093,7 @@ function createBinding(name, type, refSection, upstreamAlias, property, excludeP
|
|
|
6966
7093
|
const declared = sameSection && refDeclared;
|
|
6967
7094
|
const binding = {
|
|
6968
7095
|
id,
|
|
7096
|
+
uid: id,
|
|
6969
7097
|
name,
|
|
6970
7098
|
originalName: void 0,
|
|
6971
7099
|
type,
|
|
@@ -7096,7 +7224,7 @@ function trackReferencesForBinding(babelBinding, binding) {
|
|
|
7096
7224
|
for (const ref of referencePaths) {
|
|
7097
7225
|
const refSection = getOrCreateSection(ref);
|
|
7098
7226
|
const markoRoot = getMarkoRoot(ref);
|
|
7099
|
-
if (markoRoot?.type === "MarkoAttribute" && markoRoot.parentPath === babelBinding.path) throw ref.buildCodeFrameError(`\`${ref.node.name}\` is the [tag variable](https://markojs.com/docs/reference/language#tag-variables) this tag declares, so its own attributes cannot read it.`);
|
|
7227
|
+
if (markoRoot?.type === "MarkoAttribute" && markoRoot.parentPath === babelBinding.path && !getFnRoot(ref)) throw ref.buildCodeFrameError(`\`${ref.node.name}\` is the [tag variable](https://markojs.com/docs/reference/language#tag-variables) this tag declares, so its own attributes cannot read it.`);
|
|
7100
7228
|
else if (isReferenceHoisted(babelBinding.path, ref)) {
|
|
7101
7229
|
const invoked = isInvokedFunction(ref);
|
|
7102
7230
|
if (invoked) setReferencesScope(ref);
|
|
@@ -7316,6 +7444,7 @@ function finalizeReferences() {
|
|
|
7316
7444
|
}
|
|
7317
7445
|
}
|
|
7318
7446
|
}
|
|
7447
|
+
const bindingNamesBySection = /* @__PURE__ */ new Map();
|
|
7319
7448
|
for (const binding of bindings) {
|
|
7320
7449
|
if (binding.type !== 0) {
|
|
7321
7450
|
if (pruneBinding(binding)) bindings.delete(binding);
|
|
@@ -7346,7 +7475,12 @@ function finalizeReferences() {
|
|
|
7346
7475
|
setReadsOwner(assignedSection, section);
|
|
7347
7476
|
addOwnerSerializeReason(assignedSection, section, true);
|
|
7348
7477
|
});
|
|
7349
|
-
|
|
7478
|
+
let bindingNames = bindingNamesBySection.get(section);
|
|
7479
|
+
if (!bindingNames) {
|
|
7480
|
+
bindingNamesBySection.set(section, bindingNames = /* @__PURE__ */ new Set());
|
|
7481
|
+
forEach(section.bindings, ({ name }) => bindingNames.add(name));
|
|
7482
|
+
}
|
|
7483
|
+
if (bindingNames.has(binding.name)) binding.name = generateUid(name);
|
|
7350
7484
|
}
|
|
7351
7485
|
if (binding.hoists) {
|
|
7352
7486
|
let highestHoistSection;
|
|
@@ -7362,7 +7496,9 @@ function finalizeReferences() {
|
|
|
7362
7496
|
currentSection = currentSection.parent;
|
|
7363
7497
|
}
|
|
7364
7498
|
}
|
|
7365
|
-
|
|
7499
|
+
const canonicalBinding = getCanonicalBinding(binding);
|
|
7500
|
+
section.bindings = bindingUtil.add(section.bindings, canonicalBinding);
|
|
7501
|
+
bindingNamesBySection.get(section)?.add(canonicalBinding.name);
|
|
7366
7502
|
for (const exprExtra of binding.reads) {
|
|
7367
7503
|
const { isEffect, section } = exprExtra;
|
|
7368
7504
|
if (section.depth > binding.section.depth) {
|
|
@@ -7467,30 +7603,32 @@ function finalizeReferences() {
|
|
|
7467
7603
|
forEachSection((section) => {
|
|
7468
7604
|
const { id, bindings } = section;
|
|
7469
7605
|
const isOwnedBinding = ({ section }) => section.id === id;
|
|
7606
|
+
const ownedBindings = filter(bindings, isOwnedBinding);
|
|
7470
7607
|
const intersections = (intersectionsBySection.get(section) || []).filter((intersection) => {
|
|
7471
7608
|
const collapseSource = getCollapsibleIntersectionSource(intersection, section);
|
|
7472
7609
|
if (collapseSource) collapsedIntersectionSource.set(intersection, collapseSource);
|
|
7473
7610
|
return !collapseSource;
|
|
7474
7611
|
});
|
|
7612
|
+
let anchors;
|
|
7475
7613
|
if (intersections.length) {
|
|
7476
|
-
const anchors = /* @__PURE__ */ new Map();
|
|
7614
|
+
const sectionAnchors = anchors = /* @__PURE__ */ new Map();
|
|
7477
7615
|
for (const intersection of intersections) for (let i = intersection.length; i--;) if (isOwnedBinding(intersection[i])) {
|
|
7478
|
-
|
|
7616
|
+
sectionAnchors.set(intersection, intersection[i]);
|
|
7479
7617
|
break;
|
|
7480
7618
|
}
|
|
7481
7619
|
intersections.sort((a, b) => {
|
|
7482
|
-
const aAnchor =
|
|
7483
|
-
const bAnchor =
|
|
7620
|
+
const aAnchor = sectionAnchors.get(a);
|
|
7621
|
+
const bAnchor = sectionAnchors.get(b);
|
|
7484
7622
|
return aAnchor ? bAnchor ? bindingUtil.compare(aAnchor, bAnchor) : -1 : bAnchor ? 1 : 0;
|
|
7485
7623
|
});
|
|
7486
7624
|
}
|
|
7487
7625
|
let intersectionIndex = 0;
|
|
7488
7626
|
let nextId = 0;
|
|
7489
7627
|
let intersection;
|
|
7490
|
-
forEach(
|
|
7628
|
+
forEach(ownedBindings, (binding) => {
|
|
7491
7629
|
binding.id = nextId++;
|
|
7492
7630
|
nextId += binding.reserveSize;
|
|
7493
|
-
while (intersectionIndex < intersections.length && (intersection = intersections[intersectionIndex])
|
|
7631
|
+
while (intersectionIndex < intersections.length && anchors.get(intersection = intersections[intersectionIndex]) === binding) {
|
|
7494
7632
|
intersectionIndex++;
|
|
7495
7633
|
intersectionMeta.set(intersection, {
|
|
7496
7634
|
id: nextId++,
|
|
@@ -7506,7 +7644,7 @@ function finalizeReferences() {
|
|
|
7506
7644
|
scopeOffset: getMaxOwnSourceOffset(intersection, section)
|
|
7507
7645
|
});
|
|
7508
7646
|
}
|
|
7509
|
-
forEach(
|
|
7647
|
+
forEach(ownedBindings, (binding) => {
|
|
7510
7648
|
if (binding.closureSections) closureAccessorIds.set(binding, nextId++);
|
|
7511
7649
|
});
|
|
7512
7650
|
});
|
|
@@ -7658,7 +7796,7 @@ function unionParamSources(a, b) {
|
|
|
7658
7796
|
return merged;
|
|
7659
7797
|
}
|
|
7660
7798
|
const bindingUtil = new Sorted(function compareBindings(a, b) {
|
|
7661
|
-
return a === b ? 0 : a.section.id - b.section.id || (a.type !== b.type && (a.type === 0 || b.type === 0) ? a.type - b.type || a.id - b.id : a.id - b.id);
|
|
7799
|
+
return a === b ? 0 : a.section.id - b.section.id || (a.type !== b.type && (a.type === 0 || b.type === 0) ? a.type - b.type || a.id - b.id : a.id - b.id) || a.uid - b.uid;
|
|
7662
7800
|
});
|
|
7663
7801
|
const propsUtil = new Sorted(function compareProps(a, b) {
|
|
7664
7802
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
@@ -8881,7 +9019,7 @@ var script_default = {
|
|
|
8881
9019
|
const end = body[body.length - 1]?.end;
|
|
8882
9020
|
const bodyStatements = (0, _marko_compiler_babel_utils.parseStatements)(tag.hub.file, code, start, end);
|
|
8883
9021
|
if (bodyStatements.length) {
|
|
8884
|
-
const valueFn = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(bodyStatements),
|
|
9022
|
+
const valueFn = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(bodyStatements), !!traverseFindAwait(bodyStatements));
|
|
8885
9023
|
node.attributes.push(_marko_compiler.types.markoAttribute("value", valueFn));
|
|
8886
9024
|
}
|
|
8887
9025
|
node.body.body = [];
|
|
@@ -8942,19 +9080,6 @@ var script_default = {
|
|
|
8942
9080
|
}],
|
|
8943
9081
|
types: runtime_info_default.name + "/tags/script.d.marko"
|
|
8944
9082
|
};
|
|
8945
|
-
function isAwaitExpression(node) {
|
|
8946
|
-
switch (node.type) {
|
|
8947
|
-
case "ForOfStatement": return node.await;
|
|
8948
|
-
case "FunctionDeclaration":
|
|
8949
|
-
case "FunctionExpression":
|
|
8950
|
-
case "ArrowFunctionExpression":
|
|
8951
|
-
case "ClassMethod":
|
|
8952
|
-
case "ObjectMethod":
|
|
8953
|
-
case "ClassPrivateMethod": return skip;
|
|
8954
|
-
case "AwaitExpression": return true;
|
|
8955
|
-
default: return false;
|
|
8956
|
-
}
|
|
8957
|
-
}
|
|
8958
9083
|
function isReturnedFunction(node) {
|
|
8959
9084
|
switch (node.type) {
|
|
8960
9085
|
case "FunctionDeclaration":
|
|
@@ -10228,6 +10353,7 @@ function optionalValueToNode(value) {
|
|
|
10228
10353
|
const kDOMBinding = Symbol("dynamic tag dom binding");
|
|
10229
10354
|
const kChildOffsetScopeBinding = Symbol("custom tag scope offset");
|
|
10230
10355
|
const importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
10356
|
+
const importedDynamicTagVarResume = /* @__PURE__ */ new WeakSet();
|
|
10231
10357
|
const [getCompatRegistrations] = createProgramState(() => /* @__PURE__ */ new Set());
|
|
10232
10358
|
const [getCompatBoundaryCalls] = createProgramState(() => /* @__PURE__ */ new Map());
|
|
10233
10359
|
function pushCompatRegistration(key, statement) {
|
|
@@ -10241,9 +10367,9 @@ var dynamic_tag_default = {
|
|
|
10241
10367
|
analyze: { enter(tag) {
|
|
10242
10368
|
(0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
|
|
10243
10369
|
const { node } = tag;
|
|
10244
|
-
addSetupStatement(getOrCreateSection(tag));
|
|
10245
10370
|
const definedBodySection = node.extra?.defineBodySection;
|
|
10246
10371
|
if (definedBodySection) {
|
|
10372
|
+
addSetupStatement(getOrCreateSection(tag));
|
|
10247
10373
|
knownTagAnalyze(tag, definedBodySection, definedBodySection.params && getBindingPropTree(definedBodySection.params));
|
|
10248
10374
|
child(tag, getStaticTagName(tag.node), {
|
|
10249
10375
|
kind: SectionRef,
|
|
@@ -10384,6 +10510,7 @@ var dynamic_tag_default = {
|
|
|
10384
10510
|
}
|
|
10385
10511
|
if (!isClassAPI) {
|
|
10386
10512
|
enableDynamicTagResume(tag);
|
|
10513
|
+
enableDynamicTagVarResume(tag);
|
|
10387
10514
|
enableDynamicTagControllables(tag);
|
|
10388
10515
|
}
|
|
10389
10516
|
addValue(section, tagExtra.referencedBindings, signal, tagExpression);
|
|
@@ -10401,6 +10528,13 @@ function enableDynamicTagControllables(tag) {
|
|
|
10401
10528
|
return;
|
|
10402
10529
|
}
|
|
10403
10530
|
}
|
|
10531
|
+
function enableDynamicTagVarResume(tag) {
|
|
10532
|
+
const program = (0, _marko_compiler_babel_utils.getProgram)().node;
|
|
10533
|
+
if (tag.node.var && !importedDynamicTagVarResume.has(program) && analyzeTagNameType(tag, true) !== 1) {
|
|
10534
|
+
importedDynamicTagVarResume.add(program);
|
|
10535
|
+
importRuntimeFeature("dynamic-tag-var");
|
|
10536
|
+
}
|
|
10537
|
+
}
|
|
10404
10538
|
function enableDynamicTagResume(tag) {
|
|
10405
10539
|
const program = (0, _marko_compiler_babel_utils.getProgram)().node;
|
|
10406
10540
|
if (!importedDynamicTagResume.has(program) && analyzeTagNameType(tag, true) !== 1) {
|
|
@@ -5,7 +5,7 @@ export type DOMRuntimeHelpers = keyof typeof import("../../dom");
|
|
|
5
5
|
export type HTMLRuntimeHelpers = keyof typeof import("../../html");
|
|
6
6
|
export declare function importRuntime(name: DOMRuntimeHelpers | HTMLRuntimeHelpers): t.Identifier;
|
|
7
7
|
export declare function callRuntime(name: DOMRuntimeHelpers | HTMLRuntimeHelpers, ...args: Array<Parameters<typeof t.callExpression>[1][number] | Falsy>): t.CallExpression;
|
|
8
|
-
export type DOMRuntimeFeature = "catch" | "controllable" | "controllable-input" | "controllable-open" | "controllable-select" | "controllable-textarea";
|
|
8
|
+
export type DOMRuntimeFeature = "catch" | "controllable" | "controllable-input" | "controllable-open" | "controllable-select" | "controllable-textarea" | "dynamic-tag-var";
|
|
9
9
|
export declare function importRuntimeFeature(feature: DOMRuntimeFeature): void;
|
|
10
10
|
export declare function getHTMLRuntime(): {
|
|
11
11
|
_escape: typeof _escape;
|
|
@@ -6,5 +6,7 @@ type VisitKeys<T> = (string | number) & (T extends T ? {
|
|
|
6
6
|
}[keyof T] : never);
|
|
7
7
|
export declare function traverseReplace<T, K extends VisitKeys<T>, S>(container: T, key: K, enter: (node: t.Node, state?: S) => t.Node | void, state?: S): void;
|
|
8
8
|
export declare function traverseContains(node: undefined | null | t.Node | t.Node[], check: (node: t.Node) => void | boolean | typeof skip): boolean;
|
|
9
|
+
export declare function traverseFind(node: undefined | null | t.Node | t.Node[], check: (node: t.Node) => void | boolean | typeof skip): t.Node | undefined;
|
|
10
|
+
export declare function traverseFindAwait(node: undefined | null | t.Node | t.Node[]): t.Node | undefined;
|
|
9
11
|
export declare function traverse(visit: (node: t.Node, parent?: t.Node, grandParent?: t.Node) => void | typeof skip, node: undefined | t.Node | t.Node[], parent?: t.Node, grandParent?: t.Node): void;
|
|
10
12
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.37",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@marko/compiler": "^5.42.
|
|
51
|
+
"@marko/compiler": "^5.42.1",
|
|
52
52
|
"csstype": "^3.2.3",
|
|
53
53
|
"fastest-levenshtein": "^1.0.16",
|
|
54
54
|
"magic-string": "^0.30.21"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@marko/runtime-tags": "npm:marko@6.3.
|
|
58
|
-
"marko": "5.39.
|
|
57
|
+
"@marko/runtime-tags": "npm:marko@6.3.37",
|
|
58
|
+
"marko": "5.39.34"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=22"
|