marko 6.3.48 → 6.3.49
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/constants/resume-symbol.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 +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-CA_HiiES.js → dom-BAGeiafn.js} +25 -17
- package/dist/debug/{dom-DBMLPLeE.mjs → dom-C55iHvof.mjs} +25 -17
- package/dist/debug/dom.js +1 -1
- package/dist/debug/dom.mjs +1 -1
- package/dist/debug/html.js +76 -37
- package/dist/debug/html.mjs +76 -37
- package/dist/dom/catch.feat.js +1 -1
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/placeholder.feat.js +1 -1
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/{dom-BfydlrCq.js → dom-BNmfm4st.js} +15 -15
- package/dist/{dom-UwNQ-AXt.mjs → dom-BsAS26Ze.mjs} +15 -15
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/html/inlined-runtimes.d.ts +2 -2
- package/dist/html/inlined-runtimes.debug.d.ts +2 -2
- package/dist/html/writer.d.ts +3 -1
- package/dist/html.js +46 -36
- package/dist/html.mjs +46 -36
- package/dist/translator/index.js +108 -82
- package/dist/translator/util/get-compile-stage.d.ts +2 -0
- package/dist/translator/util/references.d.ts +4 -2
- package/dist/translator/util/sections.d.ts +4 -1
- package/dist/translator/util/serialize-reasons.d.ts +3 -2
- package/package.json +4 -4
package/dist/translator/index.js
CHANGED
|
@@ -378,14 +378,18 @@ function patchIteratorNext(proto) {
|
|
|
378
378
|
}
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/translator/util/constants/compile-stage.ts
|
|
381
|
+
const analyze$1 = "analyze";
|
|
381
382
|
const translate$1 = "translate";
|
|
382
383
|
//#endregion
|
|
383
384
|
//#region src/translator/util/get-compile-stage.ts
|
|
384
385
|
function isTranslate() {
|
|
385
386
|
return getCompileStage() === translate$1;
|
|
386
387
|
}
|
|
387
|
-
function
|
|
388
|
-
return (
|
|
388
|
+
function isAnalyzing(file) {
|
|
389
|
+
return getCompileStage(file) === analyze$1;
|
|
390
|
+
}
|
|
391
|
+
function getCompileStage(file = (0, _marko_compiler_babel_utils.getFile)()) {
|
|
392
|
+
return file.___compileStage;
|
|
389
393
|
}
|
|
390
394
|
//#endregion
|
|
391
395
|
//#region src/translator/util/traverse.ts
|
|
@@ -515,17 +519,6 @@ function getInitialCounts(file) {
|
|
|
515
519
|
return counts;
|
|
516
520
|
}
|
|
517
521
|
//#endregion
|
|
518
|
-
//#region src/translator/util/get-parent-tag.ts
|
|
519
|
-
function getParentTag(tag) {
|
|
520
|
-
const parent = tag.parent.type === "MarkoTagBody" ? tag.parentPath.parentPath : tag.parentPath;
|
|
521
|
-
if (parent.type === "MarkoTag") return parent;
|
|
522
|
-
}
|
|
523
|
-
function getAttributeTagParent(tag) {
|
|
524
|
-
let cur = tag;
|
|
525
|
-
while ((0, _marko_compiler_babel_utils.isAttributeTag)(cur) || (0, _marko_compiler_babel_utils.isTransparentTag)(cur)) cur = getParentTag(cur);
|
|
526
|
-
return cur;
|
|
527
|
-
}
|
|
528
|
-
//#endregion
|
|
529
522
|
//#region src/translator/util/get-root.ts
|
|
530
523
|
function getMarkoRoot(path) {
|
|
531
524
|
let curPath = path;
|
|
@@ -1001,6 +994,7 @@ function getAccessorProp() {
|
|
|
1001
994
|
}
|
|
1002
995
|
//#endregion
|
|
1003
996
|
//#region src/translator/util/serialize-reasons.ts
|
|
997
|
+
const sourcesUtil = new Sorted(compareSources);
|
|
1004
998
|
const scopeExprsBySection = /* @__PURE__ */ new WeakMap();
|
|
1005
999
|
const propExprsBySection = /* @__PURE__ */ new WeakMap();
|
|
1006
1000
|
const scopeProvenanceBySection = /* @__PURE__ */ new WeakMap();
|
|
@@ -1160,6 +1154,11 @@ function applySerializeExprs(section) {
|
|
|
1160
1154
|
}
|
|
1161
1155
|
}
|
|
1162
1156
|
function finalizeSerializeReason(section) {
|
|
1157
|
+
some(section.bindings, (binding) => {
|
|
1158
|
+
const reason = binding.type === 0 && getSerializeReason(section, binding);
|
|
1159
|
+
if (reason) section.domSerializeReasons = reason === true ? true : sourcesUtil.add(section.domSerializeReasons, reason);
|
|
1160
|
+
return reason === true;
|
|
1161
|
+
});
|
|
1163
1162
|
const curReason = section.serializeReason;
|
|
1164
1163
|
let newReason = curReason;
|
|
1165
1164
|
if (newReason !== true) {
|
|
@@ -1281,6 +1280,9 @@ function analyzeTagNameType(tag, allowDynamic) {
|
|
|
1281
1280
|
extra.tagNameDynamic = true;
|
|
1282
1281
|
const tagName = name.node.value;
|
|
1283
1282
|
extra.tagNameUnresolved = !(TAG_NAME_IDENTIFIER_REG$1.test(tagName) && tag.scope.hasBinding(tagName));
|
|
1283
|
+
} else if (childFile !== (0, _marko_compiler_babel_utils.getFile)() && isAnalyzing(childFile)) {
|
|
1284
|
+
extra.tagNameType = 2;
|
|
1285
|
+
extra.tagNameDynamic = true;
|
|
1284
1286
|
}
|
|
1285
1287
|
}
|
|
1286
1288
|
}
|
|
@@ -1368,7 +1370,7 @@ function startSection(path) {
|
|
|
1368
1370
|
const parentTag = path.parentPath?.isMarkoTag() ? path.parentPath : void 0;
|
|
1369
1371
|
const parentSection = path.parentPath ? getOrCreateSection(path.parentPath) : void 0;
|
|
1370
1372
|
const sectionName = parentTag ? generateUid((isCoreTagName(parentTag, "define") && _marko_compiler.types.isIdentifier(parentTag.node.var) ? parentTag.node.var.name : parentTag.get("name").toString()) + "_content") : "";
|
|
1371
|
-
const programExtra =
|
|
1373
|
+
const programExtra = (0, _marko_compiler_babel_utils.getProgram)().node.extra ??= {};
|
|
1372
1374
|
const sections = programExtra.sections ??= [];
|
|
1373
1375
|
section = extra.section = {
|
|
1374
1376
|
id: sections.length,
|
|
@@ -1388,6 +1390,7 @@ function startSection(path) {
|
|
|
1388
1390
|
isHoistThrough: void 0,
|
|
1389
1391
|
serializeReason: void 0,
|
|
1390
1392
|
serializeReasons: /* @__PURE__ */ new Map(),
|
|
1393
|
+
domSerializeReasons: void 0,
|
|
1391
1394
|
paramReasonGroups: void 0,
|
|
1392
1395
|
returnValueExpr: void 0,
|
|
1393
1396
|
returnSerializeReason: void 0,
|
|
@@ -1699,7 +1702,7 @@ function resolveRegisteredExport(file, exportName, seen = /* @__PURE__ */ new Se
|
|
|
1699
1702
|
}
|
|
1700
1703
|
function resolveSerializeReason(exprExtras) {
|
|
1701
1704
|
let reason;
|
|
1702
|
-
for (const exprExtra of exprExtras) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(getCanonicalExtra(exprExtra)));
|
|
1705
|
+
for (const exprExtra of exprExtras) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(getCanonicalExtra(exprExtra), true));
|
|
1703
1706
|
return reason;
|
|
1704
1707
|
}
|
|
1705
1708
|
function registerImportedFn({ node, ...importedFn }) {
|
|
@@ -1782,14 +1785,7 @@ function shouldAlwaysRegister(markoRoot) {
|
|
|
1782
1785
|
if (!tag) return false;
|
|
1783
1786
|
if (isCoreTagName(tag, "let")) return true;
|
|
1784
1787
|
if (isCoreTagName(tag, "return")) return true;
|
|
1785
|
-
|
|
1786
|
-
case 2:
|
|
1787
|
-
case 0: return true;
|
|
1788
|
-
case 3:
|
|
1789
|
-
if (analyzeTagNameType(getAttributeTagParent(tag)) === 2) return true;
|
|
1790
|
-
break;
|
|
1791
|
-
}
|
|
1792
|
-
return false;
|
|
1788
|
+
return analyzeTagNameType(tag) === 0;
|
|
1793
1789
|
}
|
|
1794
1790
|
function hasSpreadAttributeAfter(attr) {
|
|
1795
1791
|
const attrs = attr.parent.attributes;
|
|
@@ -2307,6 +2303,17 @@ function getKnownAttrValues(tag) {
|
|
|
2307
2303
|
return attrs;
|
|
2308
2304
|
}
|
|
2309
2305
|
//#endregion
|
|
2306
|
+
//#region src/translator/util/get-parent-tag.ts
|
|
2307
|
+
function getParentTag(tag) {
|
|
2308
|
+
const parent = tag.parent.type === "MarkoTagBody" ? tag.parentPath.parentPath : tag.parentPath;
|
|
2309
|
+
if (parent.type === "MarkoTag") return parent;
|
|
2310
|
+
}
|
|
2311
|
+
function getAttributeTagParent(tag) {
|
|
2312
|
+
let cur = tag;
|
|
2313
|
+
while ((0, _marko_compiler_babel_utils.isAttributeTag)(cur) || (0, _marko_compiler_babel_utils.isTransparentTag)(cur)) cur = getParentTag(cur);
|
|
2314
|
+
return cur;
|
|
2315
|
+
}
|
|
2316
|
+
//#endregion
|
|
2310
2317
|
//#region src/translator/util/plugin-hooks.ts
|
|
2311
2318
|
function enter$1(modulePlugin, path) {
|
|
2312
2319
|
if (!modulePlugin) return false;
|
|
@@ -2420,7 +2427,6 @@ function withLeadingComment(node, value) {
|
|
|
2420
2427
|
}
|
|
2421
2428
|
//#endregion
|
|
2422
2429
|
//#region src/translator/util/serialize-guard.ts
|
|
2423
|
-
const sourcesUtil = new Sorted(compareSources);
|
|
2424
2430
|
const [getSectionReasonState] = createSectionState("serializeReasonState", (section) => ({
|
|
2425
2431
|
if: createTypeState(),
|
|
2426
2432
|
guard: createTypeState(),
|
|
@@ -2437,8 +2443,7 @@ function getSerializeGuard(section, reason, optional) {
|
|
|
2437
2443
|
return getOrHoist(reason, true);
|
|
2438
2444
|
}
|
|
2439
2445
|
function getSerializeGuardForAny(section, reasons, optional) {
|
|
2440
|
-
if (!reasons
|
|
2441
|
-
if (reasons.length === 1) return getSerializeGuard(section, reasons[0], optional);
|
|
2446
|
+
if (!Array.isArray(reasons)) return getSerializeGuard(section, reasons, optional);
|
|
2442
2447
|
let expr;
|
|
2443
2448
|
for (const reason of reasons) {
|
|
2444
2449
|
if (!isReasonDynamic(reason)) return optional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason.state));
|
|
@@ -3271,6 +3276,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3271
3276
|
const body = path.node.body;
|
|
3272
3277
|
const allSignals = Array.from(getSignals(section).values());
|
|
3273
3278
|
const scopeIdIdentifier = getScopeIdIdentifier(section);
|
|
3279
|
+
const markerSerializeArg = getSerializeGuardForAny(section, section.domSerializeReasons, true);
|
|
3274
3280
|
const sectionSerializeReason = nonAnalyzedForceSerializedSection.has(section) ? true : section.serializeReason;
|
|
3275
3281
|
forEach(section.referencedClosures, (closure) => {
|
|
3276
3282
|
if (closure.sources) {
|
|
@@ -3286,7 +3292,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3286
3292
|
if (closureIndex) setBindingSerializedValue(section, closure, _marko_compiler.types.numericLiteral(closureIndex), getAccessorPrefix().ClosureSignalIndex);
|
|
3287
3293
|
if (underTryPlaceholder(section)) {
|
|
3288
3294
|
const reason = getSerializeReason(section);
|
|
3289
|
-
if (reason) getHTMLSectionStatements(section).push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, reason, callRuntime("_script", getScopeIdIdentifier(section), _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending"))))));
|
|
3295
|
+
if (reason) getHTMLSectionStatements(section).push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, reason, callRuntime("_script", getScopeIdIdentifier(section), _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending")), markerSerializeArg))));
|
|
3290
3296
|
} else {
|
|
3291
3297
|
const closureScopesReason = getSerializeReason(closure.section, closure, getAccessorPrefix().ClosureScopes);
|
|
3292
3298
|
const subscribeArg = isReasonDynamic(closureScopesReason) && !isSameReason(closureScopesReason, sectionSerializeReason) ? getExprIfSerialized(closure.section, closureScopesReason, identifier) : identifier;
|
|
@@ -3297,7 +3303,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3297
3303
|
});
|
|
3298
3304
|
for (let i = allSignals.length; i--;) if (allSignals[i].hasHTMLEffect) {
|
|
3299
3305
|
const signalRefs = allSignals[i].referencedBindings;
|
|
3300
|
-
body.push(_marko_compiler.types.expressionStatement(callRuntime("_script", scopeIdIdentifier, _marko_compiler.types.stringLiteral(getResumeRegisterId(section, signalRefs)))));
|
|
3306
|
+
body.push(_marko_compiler.types.expressionStatement(callRuntime("_script", scopeIdIdentifier, _marko_compiler.types.stringLiteral(getResumeRegisterId(section, signalRefs)), markerSerializeArg)));
|
|
3301
3307
|
}
|
|
3302
3308
|
const debug = !isOptimize();
|
|
3303
3309
|
const writeScopeBuilder = getSectionWriteScopeBuilder(section);
|
|
@@ -3349,13 +3355,17 @@ function writeHTMLResumeStatements(path) {
|
|
|
3349
3355
|
for (const prop of serializedProperties) if (prop.key.type === "Identifier" && prop.value.type === "Identifier" && prop.key.name === prop.value.name) prop.shorthand = true;
|
|
3350
3356
|
const writeScopeArgs = [scopeIdIdentifier, _marko_compiler.types.objectExpression(serializedProperties)];
|
|
3351
3357
|
if (debug) {
|
|
3352
|
-
writeScopeArgs.push(_marko_compiler.types.stringLiteral(
|
|
3358
|
+
writeScopeArgs.push(_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.getFile)().opts.filenameRelative), section.loc && section.loc.start.line != null ? _marko_compiler.types.stringLiteral(`${section.loc.start.line}:${section.loc.start.column + 1}`) : _marko_compiler.types.numericLiteral(0));
|
|
3353
3359
|
for (const [accessor, varLoc] of getSectionDebugVars(section)) (debugVars ||= []).push(toObjectProperty(accessor, _marko_compiler.types.valueToNode(varLoc)));
|
|
3354
3360
|
if (debugVars) writeScopeArgs.push(_marko_compiler.types.objectExpression(debugVars));
|
|
3355
3361
|
}
|
|
3356
3362
|
body.push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, sectionSerializeReason, writeScopeBuilder ? writeScopeBuilder(callRuntime("_scope", ...writeScopeArgs)) : callRuntime("_scope", ...writeScopeArgs))));
|
|
3357
3363
|
}
|
|
3358
|
-
if (!section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || sectionSerializeReason && !!find(section.bindings, (binding) => binding.type === 1))
|
|
3364
|
+
if (!section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || sectionSerializeReason && !!find(section.bindings, (binding) => binding.type === 1)) && markerSerializeArg) {
|
|
3365
|
+
const call = callRuntime("_resume_branch", scopeIdIdentifier);
|
|
3366
|
+
const link = section.hasAbortSignal ? call : getExprIfSerialized(section, sectionSerializeReason, call);
|
|
3367
|
+
if (link) body.push(_marko_compiler.types.expressionStatement(markerSerializeArg.type === "NumericLiteral" ? link : _marko_compiler.types.logicalExpression("||", markerSerializeArg, link)));
|
|
3368
|
+
}
|
|
3359
3369
|
const additionalStatements = getHTMLSectionStatements(section);
|
|
3360
3370
|
if (body.length || additionalStatements.length) body.unshift(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(scopeIdIdentifier, callRuntime("_scope_id"))]), ...additionalStatements);
|
|
3361
3371
|
if (debug) forEach(section.bindings, (binding) => {
|
|
@@ -3677,7 +3687,7 @@ function refContent(ref) {
|
|
|
3677
3687
|
function resolveRef(ref, part) {
|
|
3678
3688
|
if (ref.kind === "sectionRef") return getSectionMetaIdentifiers(ref.section)[part === "template" ? "writes" : "walks"];
|
|
3679
3689
|
const name = ref.program.domExports[part];
|
|
3680
|
-
return ref.program.section === (0, _marko_compiler_babel_utils.getProgram)().node.extra.section ? _marko_compiler.types.identifier(name) : importOrSelfReferenceName((0, _marko_compiler_babel_utils.
|
|
3690
|
+
return ref.program.section === (0, _marko_compiler_babel_utils.getProgram)().node.extra.section ? _marko_compiler.types.identifier(name) : importOrSelfReferenceName((0, _marko_compiler_babel_utils.getFile)(), ref.path, name, `${ref.hint}_${part}`);
|
|
3681
3691
|
}
|
|
3682
3692
|
const [getSectionMeta] = createSectionState("SectionMeta", (section) => {
|
|
3683
3693
|
if (!section.structure) return {
|
|
@@ -3799,7 +3809,7 @@ var dom_default = { translate: {
|
|
|
3799
3809
|
const programInputSignal = inputBinding && !inputBinding.pruned ? initValue(inputBinding) : void 0;
|
|
3800
3810
|
let extraDecls = decls;
|
|
3801
3811
|
const styleFile = program.node.extra.styleFile;
|
|
3802
|
-
if (styleFile) (0, _marko_compiler_babel_utils.importDefault)(
|
|
3812
|
+
if (styleFile) (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), styleFile);
|
|
3803
3813
|
forEachSectionReverse((childSection) => {
|
|
3804
3814
|
if (childSection !== section) {
|
|
3805
3815
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
|
@@ -3849,7 +3859,7 @@ var dom_default = { translate: {
|
|
|
3849
3859
|
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(""))])));
|
|
3850
3860
|
if (extraDecls) program.node.body.unshift(_marko_compiler.types.variableDeclaration("const", extraDecls));
|
|
3851
3861
|
writeModuleRegistrations(program);
|
|
3852
|
-
program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(
|
|
3862
|
+
program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.getFile)().metadata.marko.id), ...replaceNullishAndEmptyFunctionsWith0([
|
|
3853
3863
|
templateIdentifier,
|
|
3854
3864
|
walksIdentifier,
|
|
3855
3865
|
domExports.setupEmpty ? void 0 : setupIdentifier,
|
|
@@ -3918,7 +3928,7 @@ var html_default = { translate: {
|
|
|
3918
3928
|
writeModuleRegistrations(program);
|
|
3919
3929
|
const contentId = usedSharedUid("content") && getTemplateContentName();
|
|
3920
3930
|
const contentFn = _marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier("input")], _marko_compiler.types.blockStatement(renderContent));
|
|
3921
|
-
const exportDefault = _marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(
|
|
3931
|
+
const exportDefault = _marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.getFile)().metadata.marko.id), contentId ? _marko_compiler.types.identifier(contentId) : contentFn, program.node.extra.page || !getMarkoOpts().linkAssets ? _marko_compiler.types.numericLiteral(1) : void 0));
|
|
3922
3932
|
if (contentId) program.node.body.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(contentId), contentFn)]), exportDefault);
|
|
3923
3933
|
else program.node.body.push(exportDefault);
|
|
3924
3934
|
}
|
|
@@ -4843,7 +4853,7 @@ var native_tag_default = {
|
|
|
4843
4853
|
const spreads = tag.node.attributes.filter((attr) => _marko_compiler.types.isMarkoSpreadAttribute(attr));
|
|
4844
4854
|
const spreadLoc = spreads.length === 1 && spreads[0].value.loc;
|
|
4845
4855
|
if (spreadLoc && spreadLoc.start.index != null) {
|
|
4846
|
-
const name = "..." +
|
|
4856
|
+
const name = "..." + (0, _marko_compiler_babel_utils.getFile)().code.slice(spreadLoc.start.index, spreadLoc.end.index);
|
|
4847
4857
|
for (const prefix of [getAccessorPrefix().ControlledHandler, getAccessorPrefix().EventAttributes]) if (prefix !== getAccessorPrefix().ControlledHandler || getSpreadControllableValueProps(tagName)) setSectionDebugVar(tagSection, getPrefixedScopeAccessor(nodeBinding, prefix), name, spreadLoc);
|
|
4848
4858
|
}
|
|
4849
4859
|
}
|
|
@@ -5573,9 +5583,7 @@ const IfTag = {
|
|
|
5573
5583
|
if (branchBodySection) {
|
|
5574
5584
|
const branchSerializeReason = getSerializeReason(branchBodySection, kBranchSerializeReason);
|
|
5575
5585
|
if (branchSerializeReason) {
|
|
5576
|
-
if (branchSerializeReasons !== true)
|
|
5577
|
-
else if (branchSerializeReasons) branchSerializeReasons = addSorted(compareSources, branchSerializeReasons, branchSerializeReason);
|
|
5578
|
-
else branchSerializeReasons = [branchSerializeReason];
|
|
5586
|
+
if (branchSerializeReasons !== true) branchSerializeReasons = branchSerializeReason === true || branchSerializeReason.state ? true : sourcesUtil.add(branchSerializeReasons, branchSerializeReason);
|
|
5579
5587
|
bodyStatements.push(_marko_compiler.types.returnStatement(_marko_compiler.types.numericLiteral(i)));
|
|
5580
5588
|
}
|
|
5581
5589
|
}
|
|
@@ -5781,11 +5789,11 @@ function preAnalyze$1(tag) {
|
|
|
5781
5789
|
const parts = [];
|
|
5782
5790
|
for (const child of tag.node.body.body) if (child.type === "MarkoText") parts.push((0, _marko_compiler_babel_utils.decodeHTML)(child.value));
|
|
5783
5791
|
else if (child.type === "MarkoPlaceholder" && child.escape) parts.push(child.value);
|
|
5784
|
-
else throw
|
|
5792
|
+
else throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(child, "Unexpected content in textarea, only text and placeholders are supported.", SyntaxError);
|
|
5785
5793
|
const textValue = normalizeStringExpression(parts);
|
|
5786
5794
|
if (textValue) {
|
|
5787
5795
|
const valueAttr = tag.node.attributes.find((attr) => _marko_compiler.types.isMarkoAttribute(attr) && attr.name === "value");
|
|
5788
|
-
if (valueAttr) throw
|
|
5796
|
+
if (valueAttr) throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(valueAttr, "A textarea cannot have both a value attribute and body content.", SyntaxError);
|
|
5789
5797
|
tag.node.attributes.push(_marko_compiler.types.markoAttribute("value", textValue));
|
|
5790
5798
|
}
|
|
5791
5799
|
tag.node.body.body = [];
|
|
@@ -6042,10 +6050,10 @@ var program_default = {
|
|
|
6042
6050
|
setup: generateUid("setup"),
|
|
6043
6051
|
params: void 0
|
|
6044
6052
|
};
|
|
6045
|
-
const styleFile = getStyleFile(
|
|
6053
|
+
const styleFile = getStyleFile((0, _marko_compiler_babel_utils.getFile)());
|
|
6046
6054
|
if (styleFile) {
|
|
6047
6055
|
programExtra.styleFile = styleFile;
|
|
6048
|
-
addAssetImport(
|
|
6056
|
+
addAssetImport((0, _marko_compiler_babel_utils.getFile)(), styleFile);
|
|
6049
6057
|
}
|
|
6050
6058
|
},
|
|
6051
6059
|
exit(program) {
|
|
@@ -6074,7 +6082,7 @@ var program_default = {
|
|
|
6074
6082
|
if (entry && !markoOpts.linkAssets) throw program.buildCodeFrameError("The \"entry\" option requires the `linkAssets` compiler option to be configured.");
|
|
6075
6083
|
if (runtimeId && !/^[_a-z][_a-z0-9]*$/i.test(runtimeId)) throw program.buildCodeFrameError(`Invalid runtimeId: "${runtimeId}". The runtimeId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
6076
6084
|
if (isLoadEntry) {
|
|
6077
|
-
const entryFile =
|
|
6085
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
6078
6086
|
const { filename } = entryFile.opts;
|
|
6079
6087
|
const readyId = getReadyId(entryFile);
|
|
6080
6088
|
const report = !markoOpts.optimize;
|
|
@@ -6083,14 +6091,14 @@ var program_default = {
|
|
|
6083
6091
|
return;
|
|
6084
6092
|
}
|
|
6085
6093
|
if (isDOMPageEntry) {
|
|
6086
|
-
const entryFile =
|
|
6094
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
6087
6095
|
builder.visit(entryFile, entryFile);
|
|
6088
6096
|
program.node.body = builder.build(entryFile);
|
|
6089
6097
|
program.skip();
|
|
6090
6098
|
return;
|
|
6091
6099
|
}
|
|
6092
6100
|
if (isServerEntry) {
|
|
6093
|
-
const entryFile =
|
|
6101
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
6094
6102
|
const { filename } = entryFile.opts;
|
|
6095
6103
|
const relativeImport = (0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename);
|
|
6096
6104
|
const templateId = (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, filename);
|
|
@@ -6877,7 +6885,13 @@ function trackParamsReferences(body, type) {
|
|
|
6877
6885
|
if (bodySection) bodySection.params = paramsBinding;
|
|
6878
6886
|
for (let i = 0; i < params.length; i++) {
|
|
6879
6887
|
const param = params[i];
|
|
6880
|
-
if (param.type === "RestElement"
|
|
6888
|
+
if (i === 0 && param.type === "RestElement" && param.argument.type === "Identifier") {
|
|
6889
|
+
const { argument } = param;
|
|
6890
|
+
paramsBinding.name = argument.name;
|
|
6891
|
+
paramsBinding.declared = true;
|
|
6892
|
+
(argument.extra ??= {}).binding = paramsBinding;
|
|
6893
|
+
trackReferencesForBinding(body.scope.getBinding(argument.name), paramsBinding);
|
|
6894
|
+
} else if (param.type === "RestElement") createBindingsAndTrackReferences(param.argument, type, body.scope, section, paramsBinding, void 0, i > 0 ? addNumericPropertiesUntil(void 0, i) : void 0, i);
|
|
6881
6895
|
else if (_marko_compiler.types.isLVal(param)) createBindingsAndTrackReferences(param, type, body.scope, section, paramsBinding, i + "", void 0);
|
|
6882
6896
|
}
|
|
6883
6897
|
return paramsBinding;
|
|
@@ -7054,7 +7068,7 @@ function mergeReferences(section, target, nodes) {
|
|
|
7054
7068
|
const fnReadsByExpression = getFunctionReadsByExpression();
|
|
7055
7069
|
let reads = readsByExpression.get(targetExtra);
|
|
7056
7070
|
let exprFnReads = fnReadsByExpression.get(targetExtra);
|
|
7057
|
-
let { isEffect } = targetExtra;
|
|
7071
|
+
let { isEffect, dynamicTagInput } = targetExtra;
|
|
7058
7072
|
for (const node of nodes) {
|
|
7059
7073
|
if (!node) continue;
|
|
7060
7074
|
const extra = node.extra ??= {};
|
|
@@ -7064,6 +7078,7 @@ function mergeReferences(section, target, nodes) {
|
|
|
7064
7078
|
const additionalReads = readsByExpression.get(extra);
|
|
7065
7079
|
const additionalExprFnReads = fnReadsByExpression.get(extra);
|
|
7066
7080
|
isEffect ||= extra.isEffect;
|
|
7081
|
+
dynamicTagInput ||= extra.dynamicTagInput;
|
|
7067
7082
|
if (additionalReads) {
|
|
7068
7083
|
forEach(additionalReads, (read) => {
|
|
7069
7084
|
read.binding.reads.delete(extra);
|
|
@@ -7074,10 +7089,13 @@ function mergeReferences(section, target, nodes) {
|
|
|
7074
7089
|
}
|
|
7075
7090
|
if (additionalExprFnReads) if (exprFnReads) for (const [key, value] of additionalExprFnReads) exprFnReads.set(key, value);
|
|
7076
7091
|
else fnReadsByExpression.set(targetExtra, exprFnReads = new Map(additionalExprFnReads));
|
|
7077
|
-
} else if (extra?.pruned)
|
|
7092
|
+
} else if (extra?.pruned)
|
|
7093
|
+
/* v8 ignore next -- a dropped reference is never merged into another */
|
|
7094
|
+
throw new Error("Cannot merged a dropped reference.");
|
|
7078
7095
|
}
|
|
7079
7096
|
readsByExpression.set(targetExtra, reads);
|
|
7080
7097
|
targetExtra.isEffect = isEffect;
|
|
7098
|
+
targetExtra.dynamicTagInput = dynamicTagInput;
|
|
7081
7099
|
targetExtra.section = section;
|
|
7082
7100
|
return targetExtra;
|
|
7083
7101
|
}
|
|
@@ -7456,6 +7474,7 @@ function resolveDerivedSources(binding) {
|
|
|
7456
7474
|
}
|
|
7457
7475
|
}
|
|
7458
7476
|
function createSources(state, param, global) {
|
|
7477
|
+
/* v8 ignore next 6 -- every caller passes at least one source */
|
|
7459
7478
|
if (!(state || param || global)) throw new Error("Cannot create a serialize reason that does not reference state, a param, or $global.");
|
|
7460
7479
|
return {
|
|
7461
7480
|
state,
|
|
@@ -7529,6 +7548,7 @@ function dropNodes(node) {
|
|
|
7529
7548
|
else dropExtra(node.extra ??= {});
|
|
7530
7549
|
}
|
|
7531
7550
|
function dropExtra(exprExtra) {
|
|
7551
|
+
/* v8 ignore next 3 -- a merged reference is never dropped */
|
|
7532
7552
|
if (exprExtra.merged) throw new Error("Cannot drop a merged reference");
|
|
7533
7553
|
const readsByExpr = getReadsByExpression();
|
|
7534
7554
|
const reads = readsByExpr.get(exprExtra);
|
|
@@ -7619,6 +7639,7 @@ function getPrefixedScopeAccessor(binding, prefix) {
|
|
|
7619
7639
|
}
|
|
7620
7640
|
function getClosureAccessorId(binding) {
|
|
7621
7641
|
const id = closureAccessorIds.get(getCanonicalBinding(binding));
|
|
7642
|
+
/* v8 ignore next 5 -- analyze reserves an id for every closure binding */
|
|
7622
7643
|
if (id === void 0) throw new Error(`No closure accessor id was reserved for "${binding.name}".`);
|
|
7623
7644
|
return id;
|
|
7624
7645
|
}
|
|
@@ -7950,16 +7971,18 @@ function getCanonicalExtra(extra) {
|
|
|
7950
7971
|
return extra;
|
|
7951
7972
|
}
|
|
7952
7973
|
const serializeReasonCache = /* @__PURE__ */ new WeakMap();
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7974
|
+
const registerReasonCache = /* @__PURE__ */ new WeakMap();
|
|
7975
|
+
function getAllSerializeReasonsForExtra(extra, register) {
|
|
7976
|
+
if (extra.isEffect || register && extra.dynamicTagInput) return true;
|
|
7977
|
+
const cache = register ? registerReasonCache : serializeReasonCache;
|
|
7978
|
+
let reason = cache.get(extra);
|
|
7956
7979
|
if (reason === false) return;
|
|
7957
7980
|
if (reason === void 0) {
|
|
7958
7981
|
if (extra === (0, _marko_compiler_babel_utils.getProgram)().node.extra?.section.returnValueExpr) reason = true;
|
|
7959
7982
|
else {
|
|
7960
|
-
|
|
7983
|
+
cache.set(extra, false);
|
|
7961
7984
|
forEach(extra.downstream, (binding) => {
|
|
7962
|
-
let linked = getAllSerializeReasonsForBinding(binding, true);
|
|
7985
|
+
let linked = getAllSerializeReasonsForBinding(binding, true, register);
|
|
7963
7986
|
if (linked && linked !== true) {
|
|
7964
7987
|
const exprs = extra.downstreamExprs;
|
|
7965
7988
|
if (exprs) linked = mapDownstreamReason(binding.section.program, linked, exprs);
|
|
@@ -7967,34 +7990,35 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
7967
7990
|
reason = mergeSerializeReasons(reason, linked);
|
|
7968
7991
|
});
|
|
7969
7992
|
}
|
|
7970
|
-
if (reason)
|
|
7993
|
+
if (reason) cache.set(extra, reason);
|
|
7971
7994
|
}
|
|
7972
7995
|
return reason;
|
|
7973
7996
|
}
|
|
7974
|
-
function getAllSerializeReasonsForBinding(binding, properties) {
|
|
7975
|
-
|
|
7997
|
+
function getAllSerializeReasonsForBinding(binding, properties, register) {
|
|
7998
|
+
const cache = register ? registerReasonCache : serializeReasonCache;
|
|
7999
|
+
let reason = cache.get(binding);
|
|
7976
8000
|
if (reason === void 0) {
|
|
7977
8001
|
reason = getSerializeReason(binding.section, binding);
|
|
7978
8002
|
if (reason !== true) {
|
|
7979
|
-
|
|
7980
|
-
if (properties !== true && binding.upstreamAlias) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(binding.upstreamAlias, binding.property));
|
|
8003
|
+
cache.set(binding, reason || false);
|
|
8004
|
+
if (properties !== true && binding.upstreamAlias) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(binding.upstreamAlias, binding.property, register));
|
|
7981
8005
|
if (reason !== true) {
|
|
7982
8006
|
for (const expr of binding.reads) {
|
|
7983
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(expr));
|
|
8007
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(expr, register));
|
|
7984
8008
|
if (reason === true) break;
|
|
7985
8009
|
}
|
|
7986
8010
|
if (reason !== true) for (const alias of binding.aliases) {
|
|
7987
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(alias, properties));
|
|
8011
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(alias, properties, register));
|
|
7988
8012
|
if (reason === true) break;
|
|
7989
8013
|
}
|
|
7990
8014
|
}
|
|
7991
8015
|
}
|
|
7992
|
-
if (reason)
|
|
8016
|
+
if (reason) cache.set(binding, reason);
|
|
7993
8017
|
}
|
|
7994
8018
|
if (reason === false) reason = void 0;
|
|
7995
8019
|
if (properties !== void 0) if (properties === true) {
|
|
7996
8020
|
if (reason !== true) for (const propBinding of binding.propertyAliases.values()) {
|
|
7997
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, true));
|
|
8021
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, true, register));
|
|
7998
8022
|
if (reason === true) break;
|
|
7999
8023
|
}
|
|
8000
8024
|
} else {
|
|
@@ -8007,11 +8031,11 @@ function getAllSerializeReasonsForBinding(binding, properties) {
|
|
|
8007
8031
|
if (includes(binding.excludeProperties, property)) reason = void 0;
|
|
8008
8032
|
else {
|
|
8009
8033
|
const propBinding = binding.propertyAliases.get(property);
|
|
8010
|
-
if (propBinding) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest));
|
|
8034
|
+
if (propBinding) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest, register));
|
|
8011
8035
|
if (reason !== true) for (const alias of binding.aliases) {
|
|
8012
8036
|
const propBinding = alias.propertyAliases.get(property);
|
|
8013
8037
|
if (propBinding) {
|
|
8014
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest));
|
|
8038
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest, register));
|
|
8015
8039
|
if (reason === true) break;
|
|
8016
8040
|
}
|
|
8017
8041
|
}
|
|
@@ -8408,7 +8432,7 @@ var effect_default = {
|
|
|
8408
8432
|
var export_default = {
|
|
8409
8433
|
parse(tag) {
|
|
8410
8434
|
const { node } = tag;
|
|
8411
|
-
const statements = (0, _marko_compiler_babel_utils.parseStatements)(
|
|
8435
|
+
const statements = (0, _marko_compiler_babel_utils.parseStatements)((0, _marko_compiler_babel_utils.getFile)(), node.rawValue, node.start, node.end);
|
|
8412
8436
|
if (statements.length > 1) throw tag.hub.buildError(statements[1], "The `<export>` tag takes a single export statement.");
|
|
8413
8437
|
const defaultExport = getDefaultExport(statements[0]);
|
|
8414
8438
|
if (defaultExport) throw tag.hub.buildError(defaultExport, "A template is already its own default export. Use a named export instead.");
|
|
@@ -8587,7 +8611,7 @@ var id_default = {
|
|
|
8587
8611
|
var import_default = {
|
|
8588
8612
|
parse(tag) {
|
|
8589
8613
|
const { node } = tag;
|
|
8590
|
-
const statements = (0, _marko_compiler_babel_utils.parseStatements)(
|
|
8614
|
+
const statements = (0, _marko_compiler_babel_utils.parseStatements)((0, _marko_compiler_babel_utils.getFile)(), node.rawValue, node.start, node.end);
|
|
8591
8615
|
if (statements.length > 1) throw tag.hub.buildError(statements[1], "The [`<import>` tag](https://markojs.com/docs/reference/language#import) takes a single import statement.");
|
|
8592
8616
|
tag.replaceWith(statements[0]);
|
|
8593
8617
|
},
|
|
@@ -8751,12 +8775,12 @@ var script_default = {
|
|
|
8751
8775
|
if (body.length) {
|
|
8752
8776
|
let code = "";
|
|
8753
8777
|
for (const child of body) {
|
|
8754
|
-
if (child.type !== "MarkoText") throw
|
|
8778
|
+
if (child.type !== "MarkoText") throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(child, "Unexpected content in [`<script>` tag](https://markojs.com/docs/reference/core-tag#script). Only javascript and typescript is supported. For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.", SyntaxError);
|
|
8755
8779
|
code += child.value;
|
|
8756
8780
|
}
|
|
8757
8781
|
const start = body[0]?.start;
|
|
8758
8782
|
const end = body[body.length - 1]?.end;
|
|
8759
|
-
const bodyStatements = (0, _marko_compiler_babel_utils.parseStatements)(
|
|
8783
|
+
const bodyStatements = (0, _marko_compiler_babel_utils.parseStatements)((0, _marko_compiler_babel_utils.getFile)(), code, start, end);
|
|
8760
8784
|
if (bodyStatements.length) {
|
|
8761
8785
|
const valueFn = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(bodyStatements), !!traverseFindAwait(bodyStatements));
|
|
8762
8786
|
node.attributes.push(_marko_compiler.types.markoAttribute("value", valueFn));
|
|
@@ -9470,7 +9494,7 @@ var export_declaration_default = {
|
|
|
9470
9494
|
const tagImport = (0, _marko_compiler_babel_utils.resolveTagImport)(exportDecl, source.value);
|
|
9471
9495
|
if (tagImport) {
|
|
9472
9496
|
(node.extra ??= {}).tagImport = tagImport;
|
|
9473
|
-
const tags =
|
|
9497
|
+
const tags = (0, _marko_compiler_babel_utils.getFile)().metadata.marko.tags;
|
|
9474
9498
|
if (!tags.includes(tagImport)) tags.push(tagImport);
|
|
9475
9499
|
}
|
|
9476
9500
|
}
|
|
@@ -9490,11 +9514,11 @@ var import_declaration_default = {
|
|
|
9490
9514
|
const { node } = importDecl;
|
|
9491
9515
|
const { source } = node;
|
|
9492
9516
|
const { value } = source;
|
|
9493
|
-
if (_marko_compiler.types.isProgram(importDecl.parent) && isClientAssetImport(
|
|
9517
|
+
if (_marko_compiler.types.isProgram(importDecl.parent) && isClientAssetImport((0, _marko_compiler_babel_utils.getFile)(), value)) addAssetImport((0, _marko_compiler_babel_utils.getFile)(), value);
|
|
9494
9518
|
const tagImport = (0, _marko_compiler_babel_utils.resolveTagImport)(importDecl, value);
|
|
9495
9519
|
if (tagImport) {
|
|
9496
9520
|
(node.extra ??= {}).tagImport = tagImport;
|
|
9497
|
-
const tags =
|
|
9521
|
+
const tags = (0, _marko_compiler_babel_utils.getFile)().metadata.marko.tags;
|
|
9498
9522
|
if (!tags.includes(tagImport)) tags.push(tagImport);
|
|
9499
9523
|
trackImportedRegisteredFns(importDecl);
|
|
9500
9524
|
}
|
|
@@ -9560,7 +9584,7 @@ function getOrCreateHtmlLoadWrapped(readyId, originalIdentifier, filename, trigg
|
|
|
9560
9584
|
}
|
|
9561
9585
|
function trackImportedRegisteredFns(importDecl) {
|
|
9562
9586
|
const { node } = importDecl;
|
|
9563
|
-
const childFile = (0, _marko_compiler_babel_utils.loadFileForImport)(
|
|
9587
|
+
const childFile = (0, _marko_compiler_babel_utils.loadFileForImport)((0, _marko_compiler_babel_utils.getFile)(), node.source.value);
|
|
9564
9588
|
if (!childFile) return;
|
|
9565
9589
|
for (const specifier of importDecl.get("specifiers")) {
|
|
9566
9590
|
if (!specifier.isImportSpecifier()) continue;
|
|
@@ -9958,7 +9982,7 @@ function translateHTML(tag) {
|
|
|
9958
9982
|
let tagIdentifier;
|
|
9959
9983
|
if (_marko_compiler.types.isStringLiteral(node.name)) {
|
|
9960
9984
|
const relativePath = getTagRelativePath(tag);
|
|
9961
|
-
tagIdentifier = isCircularRequest(
|
|
9985
|
+
tagIdentifier = isCircularRequest((0, _marko_compiler_babel_utils.getFile)(), relativePath) ? _marko_compiler.types.identifier(getTemplateContentName()) : (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), relativePath, getTagName(tag));
|
|
9962
9986
|
} else tagIdentifier = node.name;
|
|
9963
9987
|
knownTagTranslateHTML(tag, tagIdentifier, childExtra.section, childExtra.domExports?.params);
|
|
9964
9988
|
}
|
|
@@ -10007,7 +10031,7 @@ function translateDOM(tag) {
|
|
|
10007
10031
|
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(childExports.setup), [createScopeReadExpression(childBinding, section)])));
|
|
10008
10032
|
});
|
|
10009
10033
|
else {
|
|
10010
|
-
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName, directContent) => importOrSelfReferenceName(
|
|
10034
|
+
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName, directContent) => importOrSelfReferenceName((0, _marko_compiler_babel_utils.getFile)(), relativePath, directContent && binding.directContentExport || binding.export, preferredName), childExports.setupEmpty ? void 0 : (section, childBinding) => {
|
|
10011
10035
|
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importOrSelfReferenceName(file, relativePath, childExports.setup, tagName), [createScopeReadExpression(childBinding, section)])));
|
|
10012
10036
|
});
|
|
10013
10037
|
(0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.template, `${tagName}_template`);
|
|
@@ -10048,7 +10072,7 @@ function tagNotFoundError(tag) {
|
|
|
10048
10072
|
if (knownWrongTagHint) didYouMean = ` ${knownWrongTagHint}`;
|
|
10049
10073
|
else if (proseText) didYouMean = ` If this line is meant to be text, prefix it with \`--\` (e.g. \`-- ${proseText}\`) or wrap it in an element such as \`<p>${proseText}</p>\`.`;
|
|
10050
10074
|
else if (tagName) {
|
|
10051
|
-
const closestTag = (0, fastest_levenshtein.closest)(tagName, Object.keys((0, _marko_compiler_babel_utils.getTaglibLookup)(
|
|
10075
|
+
const closestTag = (0, fastest_levenshtein.closest)(tagName, Object.keys((0, _marko_compiler_babel_utils.getTaglibLookup)((0, _marko_compiler_babel_utils.getFile)()).merged.tags));
|
|
10052
10076
|
if ((0, fastest_levenshtein.distance)(tagName, closestTag) < 4) didYouMean = ` Did you mean \`<${closestTag}>\`?`;
|
|
10053
10077
|
}
|
|
10054
10078
|
return tag.get("name").buildCodeFrameError(`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName ?? getStaticTagName(tag.node)}>\`.${didYouMean}`);
|
|
@@ -10135,7 +10159,9 @@ var dynamic_tag_default = {
|
|
|
10135
10159
|
}
|
|
10136
10160
|
analyzeAttributeTags(tag);
|
|
10137
10161
|
const tagSection = getOrCreateSection(tag);
|
|
10138
|
-
const
|
|
10162
|
+
const inputNodes = getAllTagReferenceNodes(node);
|
|
10163
|
+
const tagExtra = mergeReferences(tagSection, node, [node.name, ...inputNodes]);
|
|
10164
|
+
if (inputNodes.length) tagExtra.dynamicTagInput = true;
|
|
10139
10165
|
const tagBody = tag.get("body");
|
|
10140
10166
|
const hasVar = !!tag.node.var;
|
|
10141
10167
|
const nodeBinding = tagExtra[kDOMBinding] = createBinding("#text", 0, tagSection);
|
|
@@ -10195,11 +10221,11 @@ var dynamic_tag_default = {
|
|
|
10195
10221
|
return;
|
|
10196
10222
|
}
|
|
10197
10223
|
((0, _marko_compiler_babel_utils.getProgram)().node.extra ??= {}).needsCompat = true;
|
|
10198
|
-
if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(
|
|
10224
|
+
if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), getTagRelativePath(tag), tagExpression.value);
|
|
10199
10225
|
if (classTagTemplate) {
|
|
10200
10226
|
const preserveBoundary = !tagsSerializeReason && (classHydration === "descendant" || classHydration === "self" && !!classFile?.metadata.marko.hasComponentBrowser);
|
|
10201
10227
|
const classId = classFile.metadata.marko.id;
|
|
10202
|
-
const registration = isOutputHTML() ? _marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(
|
|
10228
|
+
const registration = isOutputHTML() ? _marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)((0, _marko_compiler_babel_utils.getFile)(), getCompatRuntimeFile(), "s"), [
|
|
10203
10229
|
_marko_compiler.types.stringLiteral(classId),
|
|
10204
10230
|
_marko_compiler.types.identifier(tagExpression.name),
|
|
10205
10231
|
...preserveBoundary ? [_marko_compiler.types.stringLiteral("preserve")] : []
|
|
@@ -10215,7 +10241,7 @@ var dynamic_tag_default = {
|
|
|
10215
10241
|
const rendererName = tagExpression.name;
|
|
10216
10242
|
pushCompatRegistration(rendererName, _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(rendererName), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(rendererName)))], true));
|
|
10217
10243
|
}
|
|
10218
|
-
} else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(
|
|
10244
|
+
} else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), getTagRelativePath(tag), tagExpression.value);
|
|
10219
10245
|
const { properties, statements } = translateAttrs(tag, void 0, void 0, void 0, isClassAPI ? "renderBody" : "content");
|
|
10220
10246
|
const args = [];
|
|
10221
10247
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
|
@@ -10355,7 +10381,7 @@ var tag_default = {
|
|
|
10355
10381
|
enter(tag) {
|
|
10356
10382
|
const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
|
|
10357
10383
|
if (tagDef?.translator) {
|
|
10358
|
-
if (tagDef.translator.path)
|
|
10384
|
+
if (tagDef.translator.path) (0, _marko_compiler_babel_utils.getFile)().metadata.marko.watchFiles.push(tagDef.translator.path);
|
|
10359
10385
|
enter$1(tagDef.translator.hook, tag);
|
|
10360
10386
|
return;
|
|
10361
10387
|
}
|
|
@@ -10539,7 +10565,7 @@ function getFeatureTypeFromCoreTagName(tagName) {
|
|
|
10539
10565
|
}
|
|
10540
10566
|
function addFeature(state, type, name, path) {
|
|
10541
10567
|
if (state.feature) {
|
|
10542
|
-
if (state.feature.type !== type) throw buildAggregateError(
|
|
10568
|
+
if (state.feature.type !== type) throw buildAggregateError((0, _marko_compiler_babel_utils.getFile)(), "Cannot mix Tags API and Class API features in the same file", [state.feature.name, state.feature.path], [name, path]);
|
|
10543
10569
|
} else state.feature = {
|
|
10544
10570
|
name,
|
|
10545
10571
|
path,
|
|
@@ -10616,7 +10642,7 @@ function createInteropTranslator(translate5) {
|
|
|
10616
10642
|
...visitor,
|
|
10617
10643
|
Program: {
|
|
10618
10644
|
enter(program, state) {
|
|
10619
|
-
const entryFile =
|
|
10645
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
10620
10646
|
const { output, entry } = entryFile.markoOpts;
|
|
10621
10647
|
if (!(output === "dom" && entry === "page" || output === "hydrate")) return enterProgram?.call(this, program, state);
|
|
10622
10648
|
const visitedFiles = /* @__PURE__ */ new Map([[(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename), false]]);
|
|
@@ -99,6 +99,8 @@ declare module "@marko/compiler/dist/types" {
|
|
|
99
99
|
read?: ExtraRead;
|
|
100
100
|
pruned?: true;
|
|
101
101
|
isEffect?: true;
|
|
102
|
+
/** The expression is a dynamic tag's input (attrs, args, attr tags). */
|
|
103
|
+
dynamicTagInput?: true;
|
|
102
104
|
invokeOnly?: true;
|
|
103
105
|
lazyBindings?: ReferencedBindings;
|
|
104
106
|
/** `$global` bindings this expression reads: the root means an opaque
|
|
@@ -192,8 +194,8 @@ export interface RegisteredFnExtra extends ReferencedExtra, t.FunctionExtra {
|
|
|
192
194
|
}
|
|
193
195
|
export declare function isRegisteredFnExtra(extra: t.NodeExtra | undefined): extra is RegisteredFnExtra;
|
|
194
196
|
export declare function getCanonicalExtra<T extends t.NodeExtra>(extra: T): T;
|
|
195
|
-
export declare function getAllSerializeReasonsForExtra(extra: t.NodeExtra): undefined | SerializeReason;
|
|
196
|
-
export declare function getAllSerializeReasonsForBinding(binding: Binding, properties?: Opt<string> | true): undefined | SerializeReason;
|
|
197
|
+
export declare function getAllSerializeReasonsForExtra(extra: t.NodeExtra, register?: boolean): undefined | SerializeReason;
|
|
198
|
+
export declare function getAllSerializeReasonsForBinding(binding: Binding, properties?: Opt<string> | true, register?: boolean): undefined | SerializeReason;
|
|
197
199
|
export interface KnownExprs {
|
|
198
200
|
known?: Record<string, KnownExprs>;
|
|
199
201
|
value?: t.NodeExtra;
|