marko 6.0.115 → 6.0.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug/dom.js +4 -0
- package/dist/debug/dom.mjs +4 -0
- package/dist/debug/html.js +4 -4
- package/dist/debug/html.mjs +3 -3
- package/dist/dom/dom.d.ts +1 -0
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +4 -0
- package/dist/dom.mjs +4 -0
- package/dist/html/content.d.ts +1 -1
- package/dist/html.d.ts +1 -1
- package/dist/html.js +4 -4
- package/dist/html.mjs +3 -3
- package/dist/translator/core/index.d.ts +1 -0
- package/dist/translator/core/title.d.ts +10 -0
- package/dist/translator/index.d.ts +1 -0
- package/dist/translator/index.js +779 -343
- package/dist/translator/util/binding-prop-tree.d.ts +1 -0
- package/dist/translator/util/optional.d.ts +1 -0
- package/dist/translator/util/references.d.ts +2 -0
- package/dist/translator/util/translate-attrs.d.ts +2 -1
- package/package.json +1 -1
- package/tags-html.d.ts +5 -0
package/dist/translator/index.js
CHANGED
|
@@ -1839,6 +1839,7 @@ function getNodeContentType(path5, extraMember, contentInfo) {
|
|
|
1839
1839
|
return 0 /* Comment */;
|
|
1840
1840
|
case "html-script":
|
|
1841
1841
|
case "html-style":
|
|
1842
|
+
case "title":
|
|
1842
1843
|
return 3 /* Tag */;
|
|
1843
1844
|
case "for":
|
|
1844
1845
|
case "if":
|
|
@@ -1992,6 +1993,7 @@ function isNativeNode(tag) {
|
|
|
1992
1993
|
case "html-comment":
|
|
1993
1994
|
case "html-script":
|
|
1994
1995
|
case "html-style":
|
|
1996
|
+
case "title":
|
|
1995
1997
|
return true;
|
|
1996
1998
|
default:
|
|
1997
1999
|
return false;
|
|
@@ -2237,21 +2239,50 @@ function bindingHasDownstreamExpressions(binding) {
|
|
|
2237
2239
|
|
|
2238
2240
|
// src/translator/util/binding-prop-tree.ts
|
|
2239
2241
|
function getBindingPropTree(binding) {
|
|
2240
|
-
if (binding.type === 2 /* input */) {
|
|
2241
|
-
binding.export ??= generateUid(binding.name);
|
|
2242
|
-
}
|
|
2243
2242
|
const props = {
|
|
2244
2243
|
binding,
|
|
2245
|
-
props: void 0
|
|
2244
|
+
props: void 0,
|
|
2245
|
+
rest: void 0
|
|
2246
2246
|
};
|
|
2247
|
-
if (!
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2247
|
+
if (!binding.downstreamExpressions.size) {
|
|
2248
|
+
if (!binding.aliases.size) {
|
|
2249
|
+
props.props = {};
|
|
2250
|
+
for (const [property, alias] of binding.propertyAliases) {
|
|
2251
|
+
props.props[property] = getBindingPropTree(alias);
|
|
2252
|
+
}
|
|
2253
|
+
} else if (binding.aliases.size === 1) {
|
|
2254
|
+
const [restAlias] = binding.aliases;
|
|
2255
|
+
if (hasSupersetExcludeProperties(binding, restAlias.excludeProperties)) {
|
|
2256
|
+
props.rest = getBindingPropTree(restAlias);
|
|
2257
|
+
props.props = {};
|
|
2258
|
+
if (restAlias.type === 2 /* input */) {
|
|
2259
|
+
restAlias.export ??= generateUid(restAlias.name);
|
|
2260
|
+
}
|
|
2261
|
+
forEach(restAlias.excludeProperties, (property) => {
|
|
2262
|
+
const propAlias = binding.propertyAliases.get(property);
|
|
2263
|
+
if (propAlias) {
|
|
2264
|
+
props.props[property] = getBindingPropTree(propAlias);
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2251
2268
|
}
|
|
2252
2269
|
}
|
|
2270
|
+
if (binding.type === 2 /* input */) {
|
|
2271
|
+
binding.export ??= generateUid(binding.name);
|
|
2272
|
+
}
|
|
2253
2273
|
return props;
|
|
2254
2274
|
}
|
|
2275
|
+
function hasSupersetExcludeProperties(binding, excludeProperties) {
|
|
2276
|
+
if (excludeProperties === void 0) {
|
|
2277
|
+
return false;
|
|
2278
|
+
}
|
|
2279
|
+
for (const prop of binding.propertyAliases.keys()) {
|
|
2280
|
+
if (!propsUtil.has(excludeProperties, prop)) {
|
|
2281
|
+
return false;
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
return true;
|
|
2285
|
+
}
|
|
2255
2286
|
|
|
2256
2287
|
// src/translator/util/entry-builder.ts
|
|
2257
2288
|
var import_compiler9 = require("@marko/compiler");
|
|
@@ -5577,7 +5608,7 @@ var native_tag_default = {
|
|
|
5577
5608
|
valueChange
|
|
5578
5609
|
);
|
|
5579
5610
|
} else if (value) {
|
|
5580
|
-
writeAtStartOfBody = callRuntime("
|
|
5611
|
+
writeAtStartOfBody = callRuntime("_to_text", value);
|
|
5581
5612
|
}
|
|
5582
5613
|
}
|
|
5583
5614
|
for (const attr of staticAttrs) {
|
|
@@ -6582,14 +6613,15 @@ function getBaseArgsInForTag(type, attrs) {
|
|
|
6582
6613
|
|
|
6583
6614
|
// src/translator/util/translate-attrs.ts
|
|
6584
6615
|
var contentProps = /* @__PURE__ */ new WeakSet();
|
|
6585
|
-
function translateAttrs(tag,
|
|
6586
|
-
const
|
|
6616
|
+
function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "content") {
|
|
6617
|
+
const templateExports = propTree && !propTree.rest ? propTree.props : void 0;
|
|
6587
6618
|
const properties = [];
|
|
6588
6619
|
const attrTagLookup = tag.node.extra?.attributeTags;
|
|
6620
|
+
const seen = new Set(skip2);
|
|
6589
6621
|
if (attrTagLookup) {
|
|
6590
6622
|
for (const name2 in attrTagLookup) {
|
|
6591
6623
|
const attrTagMeta = attrTagLookup[name2];
|
|
6592
|
-
if (usesExport(templateExports, attrTagMeta.name)) {
|
|
6624
|
+
if (!seen.has(name2) && usesExport(templateExports, attrTagMeta.name)) {
|
|
6593
6625
|
seen.add(attrTagMeta.name);
|
|
6594
6626
|
if (attrTagMeta.dynamic) {
|
|
6595
6627
|
statements.push(
|
|
@@ -6624,7 +6656,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6624
6656
|
} else {
|
|
6625
6657
|
const translatedAttrTag = translateAttrs(
|
|
6626
6658
|
child,
|
|
6627
|
-
templateExports?.[attrTagMeta.name]
|
|
6659
|
+
templateExports?.[attrTagMeta.name],
|
|
6660
|
+
void 0,
|
|
6628
6661
|
statements,
|
|
6629
6662
|
contentKey
|
|
6630
6663
|
);
|
|
@@ -6713,7 +6746,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6713
6746
|
if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
|
|
6714
6747
|
const translatedAttrTag = translateAttrs(
|
|
6715
6748
|
tag,
|
|
6716
|
-
templateExports?.[attrTagMeta.name]
|
|
6749
|
+
templateExports?.[attrTagMeta.name],
|
|
6750
|
+
void 0,
|
|
6717
6751
|
statements,
|
|
6718
6752
|
contentKey
|
|
6719
6753
|
);
|
|
@@ -7009,7 +7043,7 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7009
7043
|
const tagVar = node.var;
|
|
7010
7044
|
const section = getSection(tag);
|
|
7011
7045
|
const attrsPropTree = propTree?.props?.[tag.node.arguments?.length || 0];
|
|
7012
|
-
const { properties, statements } = propTree && !propTree.props || attrsPropTree ? translateAttrs(tag, attrsPropTree
|
|
7046
|
+
const { properties, statements } = propTree && !propTree.props || attrsPropTree ? translateAttrs(tag, attrsPropTree) : {
|
|
7013
7047
|
properties: [],
|
|
7014
7048
|
statements: []
|
|
7015
7049
|
};
|
|
@@ -7267,6 +7301,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7267
7301
|
const known = inputExpr.known = {};
|
|
7268
7302
|
const attrTagLookup = analyzeAttributeTags(tag);
|
|
7269
7303
|
const seen = /* @__PURE__ */ new Set();
|
|
7304
|
+
const unknownReferences = [];
|
|
7270
7305
|
if (attrTagLookup) {
|
|
7271
7306
|
const nodeReferencesByGroup = /* @__PURE__ */ new Map();
|
|
7272
7307
|
const analyzeDynamicChildGroup = (group, child) => {
|
|
@@ -7303,7 +7338,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7303
7338
|
analyzeDynamicChildGroup(attrTagMeta.group, child);
|
|
7304
7339
|
}
|
|
7305
7340
|
} else {
|
|
7306
|
-
|
|
7341
|
+
unknownReferences.push(getAllTagReferenceNodes(child.node));
|
|
7307
7342
|
}
|
|
7308
7343
|
} else {
|
|
7309
7344
|
const group = child.node.extra.attributeTagGroup;
|
|
@@ -7317,7 +7352,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7317
7352
|
if (childUsesGroupProp) {
|
|
7318
7353
|
analyzeDynamicChildGroup(group, child);
|
|
7319
7354
|
} else {
|
|
7320
|
-
|
|
7355
|
+
unknownReferences.push(getAllTagReferenceNodes(child.node));
|
|
7321
7356
|
}
|
|
7322
7357
|
}
|
|
7323
7358
|
}
|
|
@@ -7366,7 +7401,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7366
7401
|
if (import_compiler34.types.isMarkoAttribute(attr)) {
|
|
7367
7402
|
const templateExportAttr = propTree.props[attr.name];
|
|
7368
7403
|
if (!templateExportAttr || seen.has(attr.name)) {
|
|
7369
|
-
|
|
7404
|
+
unknownReferences.push(attr.value);
|
|
7370
7405
|
continue;
|
|
7371
7406
|
}
|
|
7372
7407
|
seen.add(attr.name);
|
|
@@ -7406,6 +7441,16 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7406
7441
|
}
|
|
7407
7442
|
setBindingDownstream(spreadBinding, extra);
|
|
7408
7443
|
}
|
|
7444
|
+
if (propTree.rest) {
|
|
7445
|
+
const extra = inputExpr.value = mergeReferences(
|
|
7446
|
+
section,
|
|
7447
|
+
tag.node,
|
|
7448
|
+
unknownReferences.flat()
|
|
7449
|
+
);
|
|
7450
|
+
setBindingDownstream(propTree.binding, extra);
|
|
7451
|
+
} else {
|
|
7452
|
+
unknownReferences.forEach(dropReferences);
|
|
7453
|
+
}
|
|
7409
7454
|
return inputExpr;
|
|
7410
7455
|
}
|
|
7411
7456
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
@@ -7477,13 +7522,231 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7477
7522
|
}
|
|
7478
7523
|
}
|
|
7479
7524
|
function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
7480
|
-
|
|
7525
|
+
let translatedAttrs;
|
|
7526
|
+
let seen;
|
|
7527
|
+
let spreadId;
|
|
7528
|
+
if (propTree.props) {
|
|
7529
|
+
const attrTagLookup = analyzeAttributeTags(tag);
|
|
7530
|
+
seen = /* @__PURE__ */ new Set();
|
|
7531
|
+
if (attrTagLookup) {
|
|
7532
|
+
const attrTags2 = tag.get("attributeTags");
|
|
7533
|
+
const statementsByGroup = /* @__PURE__ */ new Map();
|
|
7534
|
+
const translateDynamicAttrTagChildInGroup = (group, index) => {
|
|
7535
|
+
const child = attrTags2[index];
|
|
7536
|
+
let statements = statementsByGroup.get(group)?.statements;
|
|
7537
|
+
if (!statements) {
|
|
7538
|
+
statements = [];
|
|
7539
|
+
statementsByGroup.set(group, {
|
|
7540
|
+
referencedBindings: child.node.extra?.referencedBindings,
|
|
7541
|
+
statements
|
|
7542
|
+
});
|
|
7543
|
+
}
|
|
7544
|
+
return addDynamicAttrTagStatements(
|
|
7545
|
+
attrTags2,
|
|
7546
|
+
index,
|
|
7547
|
+
attrTagLookup,
|
|
7548
|
+
statements,
|
|
7549
|
+
propTree.props
|
|
7550
|
+
);
|
|
7551
|
+
};
|
|
7552
|
+
for (const attrTagName in attrTagLookup) {
|
|
7553
|
+
seen.add(attrTagLookup[attrTagName].name);
|
|
7554
|
+
}
|
|
7555
|
+
for (let i = 0; i < attrTags2.length; i++) {
|
|
7556
|
+
const child = attrTags2[i];
|
|
7557
|
+
if (child.isMarkoTag()) {
|
|
7558
|
+
if ((0, import_babel_utils24.isAttributeTag)(child)) {
|
|
7559
|
+
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7560
|
+
const childAttrExport = propTree.props[attrTagMeta.name];
|
|
7561
|
+
if (childAttrExport) {
|
|
7562
|
+
if (attrTagMeta.dynamic) {
|
|
7563
|
+
i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
|
|
7564
|
+
} else {
|
|
7565
|
+
writeAttrsToSignals(
|
|
7566
|
+
child,
|
|
7567
|
+
childAttrExport,
|
|
7568
|
+
`${importAlias}_${attrTagMeta.name}`,
|
|
7569
|
+
info
|
|
7570
|
+
);
|
|
7571
|
+
}
|
|
7572
|
+
}
|
|
7573
|
+
} else if (child.node.extra?.attributeTagGroup) {
|
|
7574
|
+
i = translateDynamicAttrTagChildInGroup(
|
|
7575
|
+
child.node.extra.attributeTagGroup,
|
|
7576
|
+
i
|
|
7577
|
+
);
|
|
7578
|
+
}
|
|
7579
|
+
}
|
|
7580
|
+
}
|
|
7581
|
+
for (const [
|
|
7582
|
+
group,
|
|
7583
|
+
{ referencedBindings, statements }
|
|
7584
|
+
] of statementsByGroup) {
|
|
7585
|
+
const decls = [];
|
|
7586
|
+
for (const name2 of group) {
|
|
7587
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
7588
|
+
const childAttrExports = propTree.props[attrTagMeta.name];
|
|
7589
|
+
if (!childAttrExports) continue;
|
|
7590
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7591
|
+
childAttrExports.binding,
|
|
7592
|
+
`${importAlias}_${attrTagMeta.name}`
|
|
7593
|
+
);
|
|
7594
|
+
decls.push(import_compiler34.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
7595
|
+
addStatement("render", info.tagSection, referencedBindings, [
|
|
7596
|
+
import_compiler34.types.variableDeclaration("let", decls),
|
|
7597
|
+
...statements
|
|
7598
|
+
]);
|
|
7599
|
+
addStatement(
|
|
7600
|
+
"render",
|
|
7601
|
+
info.tagSection,
|
|
7602
|
+
referencedBindings,
|
|
7603
|
+
import_compiler34.types.expressionStatement(
|
|
7604
|
+
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7605
|
+
createScopeReadExpression(
|
|
7606
|
+
info.childScopeBinding,
|
|
7607
|
+
info.tagSection
|
|
7608
|
+
),
|
|
7609
|
+
getAttrTagIdentifier(attrTagMeta)
|
|
7610
|
+
])
|
|
7611
|
+
)
|
|
7612
|
+
);
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
}
|
|
7616
|
+
const bodySection = tag.node.body.extra?.section;
|
|
7617
|
+
if (bodySection && !seen.has("content")) {
|
|
7618
|
+
seen.add("content");
|
|
7619
|
+
if (propTree.props.content) {
|
|
7620
|
+
const contentExportIdentifier = info.getBindingIdentifier(
|
|
7621
|
+
propTree.props.content.binding,
|
|
7622
|
+
`${importAlias}_content`
|
|
7623
|
+
);
|
|
7624
|
+
addStatement(
|
|
7625
|
+
"render",
|
|
7626
|
+
info.tagSection,
|
|
7627
|
+
void 0,
|
|
7628
|
+
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7629
|
+
import_compiler34.types.expressionStatement(
|
|
7630
|
+
import_compiler34.types.callExpression(contentExportIdentifier, [
|
|
7631
|
+
createScopeReadExpression(
|
|
7632
|
+
info.childScopeBinding,
|
|
7633
|
+
info.tagSection
|
|
7634
|
+
),
|
|
7635
|
+
import_compiler34.types.callExpression(import_compiler34.types.identifier(bodySection.name), [
|
|
7636
|
+
scopeIdentifier
|
|
7637
|
+
])
|
|
7638
|
+
])
|
|
7639
|
+
)
|
|
7640
|
+
);
|
|
7641
|
+
}
|
|
7642
|
+
}
|
|
7643
|
+
const { attributes } = tag.node;
|
|
7644
|
+
const staticAttrs = [];
|
|
7645
|
+
let spreadProps;
|
|
7646
|
+
for (let i = attributes.length; i--; ) {
|
|
7647
|
+
const attr = attributes[i];
|
|
7648
|
+
if (import_compiler34.types.isMarkoAttribute(attr)) {
|
|
7649
|
+
const childAttrExports = propTree.props[attr.name];
|
|
7650
|
+
if (!childAttrExports || seen.has(attr.name)) continue;
|
|
7651
|
+
if (spreadProps) {
|
|
7652
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
7653
|
+
continue;
|
|
7654
|
+
}
|
|
7655
|
+
seen.add(attr.name);
|
|
7656
|
+
staticAttrs.push(attr);
|
|
7657
|
+
} else if (spreadProps) {
|
|
7658
|
+
spreadProps.push(import_compiler34.types.spreadElement(attr.value));
|
|
7659
|
+
} else {
|
|
7660
|
+
spreadProps = [import_compiler34.types.spreadElement(attr.value)];
|
|
7661
|
+
}
|
|
7662
|
+
}
|
|
7663
|
+
for (const attr of staticAttrs.reverse()) {
|
|
7664
|
+
const childAttrExports = propTree.props[attr.name];
|
|
7665
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7666
|
+
childAttrExports.binding,
|
|
7667
|
+
`${importAlias}_${attr.name}`
|
|
7668
|
+
);
|
|
7669
|
+
addStatement(
|
|
7670
|
+
"render",
|
|
7671
|
+
info.tagSection,
|
|
7672
|
+
attr.value.extra?.referencedBindings,
|
|
7673
|
+
import_compiler34.types.expressionStatement(
|
|
7674
|
+
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7675
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7676
|
+
attr.value
|
|
7677
|
+
])
|
|
7678
|
+
)
|
|
7679
|
+
);
|
|
7680
|
+
}
|
|
7681
|
+
const missing = new Set(Object.keys(propTree.props));
|
|
7682
|
+
for (const name2 of seen) missing.delete(name2);
|
|
7683
|
+
if (missing.size) {
|
|
7684
|
+
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7685
|
+
if (spreadProps) {
|
|
7686
|
+
const spreadExpr = propsToExpression(
|
|
7687
|
+
propTree.rest ? (translatedAttrs = translateAttrs(tag, propTree, seen)).properties : spreadProps.reverse()
|
|
7688
|
+
);
|
|
7689
|
+
if (isSimpleReference(spreadExpr)) {
|
|
7690
|
+
spreadId = spreadExpr;
|
|
7691
|
+
} else {
|
|
7692
|
+
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
7693
|
+
if (translatedAttrs) {
|
|
7694
|
+
translatedAttrs.properties = [import_compiler34.types.spreadElement(spreadId)];
|
|
7695
|
+
}
|
|
7696
|
+
addStatement("render", info.tagSection, referencedBindings, [
|
|
7697
|
+
import_compiler34.types.variableDeclaration("const", [
|
|
7698
|
+
import_compiler34.types.variableDeclarator(spreadId, spreadExpr)
|
|
7699
|
+
])
|
|
7700
|
+
]);
|
|
7701
|
+
}
|
|
7702
|
+
}
|
|
7703
|
+
for (const name2 of missing) {
|
|
7704
|
+
const childAttrExports = propTree.props[name2];
|
|
7705
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7706
|
+
childAttrExports.binding,
|
|
7707
|
+
`${importAlias}_${name2}`
|
|
7708
|
+
);
|
|
7709
|
+
addStatement(
|
|
7710
|
+
"render",
|
|
7711
|
+
info.tagSection,
|
|
7712
|
+
referencedBindings,
|
|
7713
|
+
import_compiler34.types.expressionStatement(
|
|
7714
|
+
import_compiler34.types.callExpression(
|
|
7715
|
+
attrExportIdentifier,
|
|
7716
|
+
spreadId ? [
|
|
7717
|
+
createScopeReadExpression(
|
|
7718
|
+
info.childScopeBinding,
|
|
7719
|
+
info.tagSection
|
|
7720
|
+
),
|
|
7721
|
+
toMemberExpression(import_compiler34.types.cloneNode(spreadId, true), name2)
|
|
7722
|
+
] : [
|
|
7723
|
+
createScopeReadExpression(
|
|
7724
|
+
info.childScopeBinding,
|
|
7725
|
+
info.tagSection
|
|
7726
|
+
)
|
|
7727
|
+
]
|
|
7728
|
+
)
|
|
7729
|
+
)
|
|
7730
|
+
);
|
|
7731
|
+
}
|
|
7732
|
+
}
|
|
7733
|
+
}
|
|
7734
|
+
if (!propTree.props || propTree.rest) {
|
|
7735
|
+
if (!translatedAttrs) {
|
|
7736
|
+
if (propTree.rest) {
|
|
7737
|
+
seen ||= /* @__PURE__ */ new Set();
|
|
7738
|
+
forEach(
|
|
7739
|
+
propTree.rest.binding.excludeProperties,
|
|
7740
|
+
(prop) => seen.add(prop)
|
|
7741
|
+
);
|
|
7742
|
+
}
|
|
7743
|
+
translatedAttrs = translateAttrs(tag, propTree.rest, seen);
|
|
7744
|
+
}
|
|
7481
7745
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7482
7746
|
const tagInputIdentifier = info.getBindingIdentifier(
|
|
7483
|
-
propTree.binding,
|
|
7484
|
-
importAlias
|
|
7747
|
+
propTree.rest?.binding || propTree.binding,
|
|
7748
|
+
propTree.rest ? importAlias + "_$rest" : importAlias
|
|
7485
7749
|
);
|
|
7486
|
-
const translatedAttrs = translateAttrs(tag);
|
|
7487
7750
|
if (translatedAttrs.statements.length) {
|
|
7488
7751
|
addStatement(
|
|
7489
7752
|
"render",
|
|
@@ -7493,6 +7756,27 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7493
7756
|
);
|
|
7494
7757
|
}
|
|
7495
7758
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7759
|
+
if (propTree.rest && spreadId) {
|
|
7760
|
+
const props = [];
|
|
7761
|
+
const restId = import_compiler34.types.identifier(propTree.rest.binding.name);
|
|
7762
|
+
forEach(propTree.rest.binding.excludeProperties, (name2) => {
|
|
7763
|
+
const propId = toPropertyName(name2);
|
|
7764
|
+
const shorthand = propId.type === "Identifier" && import_compiler34.types.isValidIdentifier(name2);
|
|
7765
|
+
props.push(
|
|
7766
|
+
import_compiler34.types.objectProperty(
|
|
7767
|
+
propId,
|
|
7768
|
+
shorthand ? propId : generateUidIdentifier(name2),
|
|
7769
|
+
false,
|
|
7770
|
+
shorthand
|
|
7771
|
+
)
|
|
7772
|
+
);
|
|
7773
|
+
});
|
|
7774
|
+
props.push(import_compiler34.types.restElement(restId));
|
|
7775
|
+
translatedProps = import_compiler34.types.callExpression(
|
|
7776
|
+
import_compiler34.types.arrowFunctionExpression([import_compiler34.types.objectPattern(props)], restId),
|
|
7777
|
+
[spreadId]
|
|
7778
|
+
);
|
|
7779
|
+
}
|
|
7496
7780
|
if ((0, import_babel_utils24.isAttributeTag)(tag)) {
|
|
7497
7781
|
const attrTagName = getTagName(tag);
|
|
7498
7782
|
const parentTag = tag.parentPath;
|
|
@@ -7538,188 +7822,6 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7538
7822
|
])
|
|
7539
7823
|
)
|
|
7540
7824
|
);
|
|
7541
|
-
return;
|
|
7542
|
-
}
|
|
7543
|
-
const seen = /* @__PURE__ */ new Set();
|
|
7544
|
-
const attrTagLookup = analyzeAttributeTags(tag);
|
|
7545
|
-
if (attrTagLookup) {
|
|
7546
|
-
const attrTags2 = tag.get("attributeTags");
|
|
7547
|
-
const statementsByGroup = /* @__PURE__ */ new Map();
|
|
7548
|
-
const translateDynamicAttrTagChildInGroup = (group, index) => {
|
|
7549
|
-
const child = attrTags2[index];
|
|
7550
|
-
let statements = statementsByGroup.get(group)?.statements;
|
|
7551
|
-
if (!statements) {
|
|
7552
|
-
statements = [];
|
|
7553
|
-
statementsByGroup.set(group, {
|
|
7554
|
-
referencedBindings: child.node.extra?.referencedBindings,
|
|
7555
|
-
statements
|
|
7556
|
-
});
|
|
7557
|
-
}
|
|
7558
|
-
return addDynamicAttrTagStatements(
|
|
7559
|
-
attrTags2,
|
|
7560
|
-
index,
|
|
7561
|
-
attrTagLookup,
|
|
7562
|
-
statements,
|
|
7563
|
-
propTree.props
|
|
7564
|
-
);
|
|
7565
|
-
};
|
|
7566
|
-
for (const attrTagName in attrTagLookup) {
|
|
7567
|
-
seen.add(attrTagLookup[attrTagName].name);
|
|
7568
|
-
}
|
|
7569
|
-
for (let i = 0; i < attrTags2.length; i++) {
|
|
7570
|
-
const child = attrTags2[i];
|
|
7571
|
-
if (child.isMarkoTag()) {
|
|
7572
|
-
if ((0, import_babel_utils24.isAttributeTag)(child)) {
|
|
7573
|
-
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7574
|
-
const childAttrExport = propTree.props[attrTagMeta.name];
|
|
7575
|
-
if (childAttrExport) {
|
|
7576
|
-
if (attrTagMeta.dynamic) {
|
|
7577
|
-
i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
|
|
7578
|
-
} else {
|
|
7579
|
-
writeAttrsToSignals(
|
|
7580
|
-
child,
|
|
7581
|
-
childAttrExport,
|
|
7582
|
-
`${importAlias}_${attrTagMeta.name}`,
|
|
7583
|
-
info
|
|
7584
|
-
);
|
|
7585
|
-
}
|
|
7586
|
-
}
|
|
7587
|
-
} else if (child.node.extra?.attributeTagGroup) {
|
|
7588
|
-
i = translateDynamicAttrTagChildInGroup(
|
|
7589
|
-
child.node.extra.attributeTagGroup,
|
|
7590
|
-
i
|
|
7591
|
-
);
|
|
7592
|
-
}
|
|
7593
|
-
}
|
|
7594
|
-
}
|
|
7595
|
-
for (const [
|
|
7596
|
-
group,
|
|
7597
|
-
{ referencedBindings, statements }
|
|
7598
|
-
] of statementsByGroup) {
|
|
7599
|
-
const decls = [];
|
|
7600
|
-
for (const name2 of group) {
|
|
7601
|
-
const attrTagMeta = attrTagLookup[name2];
|
|
7602
|
-
const childAttrExports = propTree.props[attrTagMeta.name];
|
|
7603
|
-
if (!childAttrExports) continue;
|
|
7604
|
-
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7605
|
-
childAttrExports.binding,
|
|
7606
|
-
`${importAlias}_${attrTagMeta.name}`
|
|
7607
|
-
);
|
|
7608
|
-
decls.push(import_compiler34.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
7609
|
-
addStatement("render", info.tagSection, referencedBindings, [
|
|
7610
|
-
import_compiler34.types.variableDeclaration("let", decls),
|
|
7611
|
-
...statements
|
|
7612
|
-
]);
|
|
7613
|
-
addStatement(
|
|
7614
|
-
"render",
|
|
7615
|
-
info.tagSection,
|
|
7616
|
-
referencedBindings,
|
|
7617
|
-
import_compiler34.types.expressionStatement(
|
|
7618
|
-
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7619
|
-
createScopeReadExpression(
|
|
7620
|
-
info.childScopeBinding,
|
|
7621
|
-
info.tagSection
|
|
7622
|
-
),
|
|
7623
|
-
getAttrTagIdentifier(attrTagMeta)
|
|
7624
|
-
])
|
|
7625
|
-
)
|
|
7626
|
-
);
|
|
7627
|
-
}
|
|
7628
|
-
}
|
|
7629
|
-
}
|
|
7630
|
-
const bodySection = tag.node.body.extra?.section;
|
|
7631
|
-
if (bodySection && !seen.has("content")) {
|
|
7632
|
-
seen.add("content");
|
|
7633
|
-
if (propTree.props.content) {
|
|
7634
|
-
const contentExportIdentifier = info.getBindingIdentifier(
|
|
7635
|
-
propTree.props.content.binding,
|
|
7636
|
-
`${importAlias}_content`
|
|
7637
|
-
);
|
|
7638
|
-
addStatement(
|
|
7639
|
-
"render",
|
|
7640
|
-
info.tagSection,
|
|
7641
|
-
void 0,
|
|
7642
|
-
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7643
|
-
import_compiler34.types.expressionStatement(
|
|
7644
|
-
import_compiler34.types.callExpression(contentExportIdentifier, [
|
|
7645
|
-
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7646
|
-
import_compiler34.types.callExpression(import_compiler34.types.identifier(bodySection.name), [scopeIdentifier])
|
|
7647
|
-
])
|
|
7648
|
-
)
|
|
7649
|
-
);
|
|
7650
|
-
}
|
|
7651
|
-
}
|
|
7652
|
-
const { attributes } = tag.node;
|
|
7653
|
-
const staticAttrs = [];
|
|
7654
|
-
let spreadProps;
|
|
7655
|
-
for (let i = attributes.length; i--; ) {
|
|
7656
|
-
const attr = attributes[i];
|
|
7657
|
-
if (import_compiler34.types.isMarkoAttribute(attr)) {
|
|
7658
|
-
const childAttrExports = propTree.props[attr.name];
|
|
7659
|
-
if (!childAttrExports || seen.has(attr.name)) continue;
|
|
7660
|
-
seen.add(attr.name);
|
|
7661
|
-
if (spreadProps) {
|
|
7662
|
-
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
7663
|
-
continue;
|
|
7664
|
-
}
|
|
7665
|
-
staticAttrs.push(attr);
|
|
7666
|
-
} else if (spreadProps) {
|
|
7667
|
-
spreadProps.push(import_compiler34.types.spreadElement(attr.value));
|
|
7668
|
-
} else {
|
|
7669
|
-
spreadProps = [import_compiler34.types.spreadElement(attr.value)];
|
|
7670
|
-
}
|
|
7671
|
-
}
|
|
7672
|
-
for (const attr of staticAttrs.reverse()) {
|
|
7673
|
-
const childAttrExports = propTree.props[attr.name];
|
|
7674
|
-
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7675
|
-
childAttrExports.binding,
|
|
7676
|
-
`${importAlias}_${attr.name}`
|
|
7677
|
-
);
|
|
7678
|
-
addStatement(
|
|
7679
|
-
"render",
|
|
7680
|
-
info.tagSection,
|
|
7681
|
-
attr.value.extra?.referencedBindings,
|
|
7682
|
-
import_compiler34.types.expressionStatement(
|
|
7683
|
-
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7684
|
-
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7685
|
-
attr.value
|
|
7686
|
-
])
|
|
7687
|
-
)
|
|
7688
|
-
);
|
|
7689
|
-
}
|
|
7690
|
-
const missing = new Set(Object.keys(propTree.props));
|
|
7691
|
-
for (const name2 of seen) missing.delete(name2);
|
|
7692
|
-
if (missing.size) {
|
|
7693
|
-
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7694
|
-
let getMissingPropValue = buildUndefined3;
|
|
7695
|
-
if (spreadProps) {
|
|
7696
|
-
const spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
7697
|
-
spreadProps.reverse();
|
|
7698
|
-
getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
|
|
7699
|
-
addStatement("render", info.tagSection, referencedBindings, [
|
|
7700
|
-
import_compiler34.types.variableDeclaration("const", [
|
|
7701
|
-
import_compiler34.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
|
|
7702
|
-
])
|
|
7703
|
-
]);
|
|
7704
|
-
}
|
|
7705
|
-
for (const name2 of missing) {
|
|
7706
|
-
const childAttrExports = propTree.props[name2];
|
|
7707
|
-
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7708
|
-
childAttrExports.binding,
|
|
7709
|
-
`${importAlias}_${name2}`
|
|
7710
|
-
);
|
|
7711
|
-
addStatement(
|
|
7712
|
-
"render",
|
|
7713
|
-
info.tagSection,
|
|
7714
|
-
referencedBindings,
|
|
7715
|
-
import_compiler34.types.expressionStatement(
|
|
7716
|
-
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7717
|
-
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7718
|
-
getMissingPropValue(name2)
|
|
7719
|
-
])
|
|
7720
|
-
)
|
|
7721
|
-
);
|
|
7722
|
-
}
|
|
7723
7825
|
}
|
|
7724
7826
|
}
|
|
7725
7827
|
function mapParamReasonToExpr(exprs, reason) {
|
|
@@ -7754,8 +7856,15 @@ function callStatement(id, ...args) {
|
|
|
7754
7856
|
function callExpression(id, ...args) {
|
|
7755
7857
|
return import_compiler34.types.callExpression(id, args.filter(Boolean));
|
|
7756
7858
|
}
|
|
7757
|
-
function
|
|
7758
|
-
|
|
7859
|
+
function isSimpleReference(expr) {
|
|
7860
|
+
switch (expr.type) {
|
|
7861
|
+
case "Identifier":
|
|
7862
|
+
return true;
|
|
7863
|
+
case "MemberExpression":
|
|
7864
|
+
return !expr.computed && isSimpleReference(expr.object);
|
|
7865
|
+
default:
|
|
7866
|
+
return false;
|
|
7867
|
+
}
|
|
7759
7868
|
}
|
|
7760
7869
|
|
|
7761
7870
|
// src/translator/util/references.ts
|
|
@@ -9614,7 +9723,7 @@ function bodyToTextLiteral(body) {
|
|
|
9614
9723
|
} else if (import_compiler42.types.isMarkoPlaceholder(child)) {
|
|
9615
9724
|
placeholderExtra ||= child.value.extra;
|
|
9616
9725
|
templateQuasis.push(templateElement(currentQuasi, false));
|
|
9617
|
-
templateExpressions.push(child.value);
|
|
9726
|
+
templateExpressions.push(callRuntime("_to_text", child.value));
|
|
9618
9727
|
currentQuasi = "";
|
|
9619
9728
|
}
|
|
9620
9729
|
}
|
|
@@ -9700,7 +9809,7 @@ var html_comment_default = {
|
|
|
9700
9809
|
if (import_compiler43.types.isMarkoText(child)) {
|
|
9701
9810
|
write`${child.value}`;
|
|
9702
9811
|
} else if (import_compiler43.types.isMarkoPlaceholder(child)) {
|
|
9703
|
-
write`${callRuntime("
|
|
9812
|
+
write`${callRuntime("_to_text", child.value)}`;
|
|
9704
9813
|
}
|
|
9705
9814
|
}
|
|
9706
9815
|
} else {
|
|
@@ -11520,7 +11629,7 @@ var textarea_default = {
|
|
|
11520
11629
|
tag.node.attributes.push(
|
|
11521
11630
|
import_compiler56.types.markoAttribute(
|
|
11522
11631
|
"value",
|
|
11523
|
-
normalizeStringExpression(parts) ||
|
|
11632
|
+
normalizeStringExpression(parts) || buildUndefined3()
|
|
11524
11633
|
)
|
|
11525
11634
|
);
|
|
11526
11635
|
tag.node.body.body = [];
|
|
@@ -11531,28 +11640,352 @@ var textarea_default = {
|
|
|
11531
11640
|
preserveWhitespace: true
|
|
11532
11641
|
}
|
|
11533
11642
|
};
|
|
11534
|
-
function
|
|
11643
|
+
function buildUndefined3() {
|
|
11535
11644
|
return import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0));
|
|
11536
11645
|
}
|
|
11537
11646
|
|
|
11538
|
-
// src/translator/core/
|
|
11647
|
+
// src/translator/core/title.ts
|
|
11539
11648
|
var import_compiler57 = require("@marko/compiler");
|
|
11540
11649
|
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
11541
|
-
var
|
|
11542
|
-
var
|
|
11543
|
-
var try_default = {
|
|
11650
|
+
var kNodeBinding4 = Symbol("title tag node binding");
|
|
11651
|
+
var title_default = {
|
|
11544
11652
|
analyze(tag) {
|
|
11545
|
-
(0, import_babel_utils46.assertNoVar)(tag);
|
|
11546
11653
|
(0, import_babel_utils46.assertNoArgs)(tag);
|
|
11547
11654
|
(0, import_babel_utils46.assertNoParams)(tag);
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11655
|
+
const { node } = tag;
|
|
11656
|
+
if (node.var && !import_compiler57.types.isIdentifier(node.var)) {
|
|
11657
|
+
throw tag.get("var").buildCodeFrameError(
|
|
11658
|
+
"Tag variables on native elements cannot be destructured."
|
|
11659
|
+
);
|
|
11660
|
+
}
|
|
11661
|
+
const seen = {};
|
|
11662
|
+
const { attributes } = tag.node;
|
|
11663
|
+
let spreadReferenceNodes;
|
|
11664
|
+
let exprExtras;
|
|
11665
|
+
let hasEventHandlers = false;
|
|
11666
|
+
let hasDynamicAttributes = false;
|
|
11667
|
+
for (let i = attributes.length; i--; ) {
|
|
11668
|
+
const attr = attributes[i];
|
|
11669
|
+
const valueExtra = attr.value.extra ??= {};
|
|
11670
|
+
if (import_compiler57.types.isMarkoAttribute(attr)) {
|
|
11671
|
+
if (seen[attr.name]) {
|
|
11672
|
+
dropReferences(attr.value);
|
|
11673
|
+
continue;
|
|
11674
|
+
}
|
|
11675
|
+
seen[attr.name] = attr;
|
|
11676
|
+
if (isEventHandler(attr.name)) {
|
|
11677
|
+
valueExtra.isEffect = true;
|
|
11678
|
+
hasEventHandlers = true;
|
|
11679
|
+
} else if (!evaluate(attr.value).confident) {
|
|
11680
|
+
hasDynamicAttributes = true;
|
|
11681
|
+
}
|
|
11682
|
+
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11683
|
+
valueExtra.isEffect = true;
|
|
11684
|
+
hasEventHandlers = true;
|
|
11685
|
+
hasDynamicAttributes = true;
|
|
11686
|
+
}
|
|
11687
|
+
if (spreadReferenceNodes) {
|
|
11688
|
+
spreadReferenceNodes.push(attr.value);
|
|
11689
|
+
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11690
|
+
spreadReferenceNodes = [attr.value];
|
|
11691
|
+
} else {
|
|
11692
|
+
exprExtras = push(exprExtras, valueExtra);
|
|
11693
|
+
}
|
|
11694
|
+
}
|
|
11695
|
+
const bodyPlaceholderNodes = [];
|
|
11696
|
+
let hasBodyPlaceholders = false;
|
|
11697
|
+
for (const child of tag.node.body.body) {
|
|
11698
|
+
if (import_compiler57.types.isMarkoPlaceholder(child)) {
|
|
11699
|
+
bodyPlaceholderNodes.push(child.value);
|
|
11700
|
+
hasBodyPlaceholders = true;
|
|
11701
|
+
} else if (!import_compiler57.types.isMarkoText(child)) {
|
|
11702
|
+
throw tag.hub.buildError(
|
|
11703
|
+
child,
|
|
11704
|
+
"Invalid child. Only text is allowed inside a `<title>`."
|
|
11705
|
+
);
|
|
11706
|
+
}
|
|
11707
|
+
}
|
|
11708
|
+
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
11709
|
+
const tagExtra = node.extra ??= {};
|
|
11710
|
+
const tagSection = getOrCreateSection(tag);
|
|
11711
|
+
const nodeBinding = tagExtra[kNodeBinding4] = createBinding(
|
|
11712
|
+
"#title",
|
|
11713
|
+
0 /* dom */,
|
|
11714
|
+
tagSection
|
|
11715
|
+
);
|
|
11716
|
+
if (hasEventHandlers) {
|
|
11717
|
+
(0, import_babel_utils46.getProgram)().node.extra.isInteractive = true;
|
|
11718
|
+
}
|
|
11719
|
+
if (spreadReferenceNodes) {
|
|
11720
|
+
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
11721
|
+
}
|
|
11722
|
+
if (hasBodyPlaceholders) {
|
|
11723
|
+
exprExtras = push(
|
|
11724
|
+
exprExtras,
|
|
11725
|
+
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
11726
|
+
tagSection,
|
|
11727
|
+
bodyPlaceholderNodes[0],
|
|
11728
|
+
bodyPlaceholderNodes.slice(1)
|
|
11729
|
+
)
|
|
11730
|
+
);
|
|
11731
|
+
}
|
|
11732
|
+
trackDomVarReferences(tag, nodeBinding);
|
|
11733
|
+
addSerializeExpr(
|
|
11734
|
+
tagSection,
|
|
11735
|
+
!!(node.var || hasEventHandlers),
|
|
11736
|
+
nodeBinding
|
|
11737
|
+
);
|
|
11738
|
+
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
11739
|
+
}
|
|
11740
|
+
},
|
|
11741
|
+
translate: {
|
|
11742
|
+
enter(tag) {
|
|
11743
|
+
const tagExtra = tag.node.extra;
|
|
11744
|
+
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11745
|
+
const isHTML = isOutputHTML();
|
|
11746
|
+
const write = writeTo(tag);
|
|
11747
|
+
const tagSection = getSection(tag);
|
|
11748
|
+
if (isHTML) {
|
|
11749
|
+
translateDomVar(tag, nodeBinding);
|
|
11750
|
+
}
|
|
11751
|
+
if (nodeBinding) {
|
|
11752
|
+
visit(tag, 32 /* Get */);
|
|
11753
|
+
}
|
|
11754
|
+
write`<title`;
|
|
11755
|
+
const usedAttrs = getUsedAttrs4(tag.node);
|
|
11756
|
+
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
11757
|
+
for (const attr of staticAttrs) {
|
|
11758
|
+
const { name: name2, value } = attr;
|
|
11759
|
+
const { confident, computed } = value.extra || {};
|
|
11760
|
+
const valueReferences = value.extra?.referencedBindings;
|
|
11761
|
+
switch (name2) {
|
|
11762
|
+
case "class":
|
|
11763
|
+
case "style": {
|
|
11764
|
+
const helper = `_attr_${name2}`;
|
|
11765
|
+
if (confident) {
|
|
11766
|
+
write`${getHTMLRuntime()[helper](computed)}`;
|
|
11767
|
+
} else if (isHTML) {
|
|
11768
|
+
write`${callRuntime(helper, value)}`;
|
|
11769
|
+
} else {
|
|
11770
|
+
addStatement(
|
|
11771
|
+
"render",
|
|
11772
|
+
tagSection,
|
|
11773
|
+
valueReferences,
|
|
11774
|
+
import_compiler57.types.expressionStatement(
|
|
11775
|
+
callRuntime(
|
|
11776
|
+
helper,
|
|
11777
|
+
createScopeReadExpression(nodeBinding),
|
|
11778
|
+
value
|
|
11779
|
+
)
|
|
11780
|
+
)
|
|
11781
|
+
);
|
|
11782
|
+
}
|
|
11783
|
+
break;
|
|
11784
|
+
}
|
|
11785
|
+
default:
|
|
11786
|
+
if (confident) {
|
|
11787
|
+
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
11788
|
+
} else if (isHTML) {
|
|
11789
|
+
if (isEventHandler(name2)) {
|
|
11790
|
+
addHTMLEffectCall(tagSection, valueReferences);
|
|
11791
|
+
} else {
|
|
11792
|
+
write`${callRuntime("_attr", import_compiler57.types.stringLiteral(name2), value)}`;
|
|
11793
|
+
}
|
|
11794
|
+
} else if (isEventHandler(name2)) {
|
|
11795
|
+
addStatement(
|
|
11796
|
+
"effect",
|
|
11797
|
+
tagSection,
|
|
11798
|
+
valueReferences,
|
|
11799
|
+
import_compiler57.types.expressionStatement(
|
|
11800
|
+
callRuntime(
|
|
11801
|
+
"_on",
|
|
11802
|
+
createScopeReadExpression(nodeBinding),
|
|
11803
|
+
import_compiler57.types.stringLiteral(getEventHandlerName(name2)),
|
|
11804
|
+
value
|
|
11805
|
+
)
|
|
11806
|
+
)
|
|
11807
|
+
);
|
|
11808
|
+
} else {
|
|
11809
|
+
addStatement(
|
|
11810
|
+
"render",
|
|
11811
|
+
tagSection,
|
|
11812
|
+
valueReferences,
|
|
11813
|
+
import_compiler57.types.expressionStatement(
|
|
11814
|
+
callRuntime(
|
|
11815
|
+
"_attr",
|
|
11816
|
+
createScopeReadExpression(nodeBinding),
|
|
11817
|
+
import_compiler57.types.stringLiteral(name2),
|
|
11818
|
+
value
|
|
11819
|
+
)
|
|
11820
|
+
)
|
|
11821
|
+
);
|
|
11822
|
+
}
|
|
11823
|
+
break;
|
|
11824
|
+
}
|
|
11825
|
+
}
|
|
11826
|
+
if (spreadExpression) {
|
|
11827
|
+
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
|
11828
|
+
if (isHTML) {
|
|
11829
|
+
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
11830
|
+
if (skipExpression) {
|
|
11831
|
+
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11832
|
+
} else {
|
|
11833
|
+
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11834
|
+
}
|
|
11835
|
+
} else {
|
|
11836
|
+
if (skipExpression) {
|
|
11837
|
+
addStatement(
|
|
11838
|
+
"render",
|
|
11839
|
+
tagSection,
|
|
11840
|
+
tagExtra.referencedBindings,
|
|
11841
|
+
import_compiler57.types.expressionStatement(
|
|
11842
|
+
callRuntime(
|
|
11843
|
+
"_attrs_partial",
|
|
11844
|
+
scopeIdentifier,
|
|
11845
|
+
visitAccessor,
|
|
11846
|
+
spreadExpression,
|
|
11847
|
+
skipExpression
|
|
11848
|
+
)
|
|
11849
|
+
)
|
|
11850
|
+
);
|
|
11851
|
+
} else {
|
|
11852
|
+
addStatement(
|
|
11853
|
+
"render",
|
|
11854
|
+
tagSection,
|
|
11855
|
+
tagExtra.referencedBindings,
|
|
11856
|
+
import_compiler57.types.expressionStatement(
|
|
11857
|
+
callRuntime(
|
|
11858
|
+
"_attrs",
|
|
11859
|
+
scopeIdentifier,
|
|
11860
|
+
visitAccessor,
|
|
11861
|
+
spreadExpression
|
|
11862
|
+
)
|
|
11863
|
+
)
|
|
11864
|
+
);
|
|
11865
|
+
}
|
|
11866
|
+
addStatement(
|
|
11867
|
+
"effect",
|
|
11868
|
+
tagSection,
|
|
11869
|
+
tagExtra.referencedBindings,
|
|
11870
|
+
import_compiler57.types.expressionStatement(
|
|
11871
|
+
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
11872
|
+
),
|
|
11873
|
+
false
|
|
11874
|
+
);
|
|
11875
|
+
}
|
|
11876
|
+
}
|
|
11877
|
+
write`>`;
|
|
11878
|
+
enter2(tag);
|
|
11879
|
+
},
|
|
11880
|
+
exit(tag) {
|
|
11881
|
+
const tagSection = getSection(tag);
|
|
11882
|
+
const tagExtra = tag.node.extra;
|
|
11883
|
+
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11884
|
+
const write = writeTo(tag);
|
|
11885
|
+
if (isOutputHTML()) {
|
|
11886
|
+
for (const child of tag.node.body.body) {
|
|
11887
|
+
if (import_compiler57.types.isMarkoText(child)) {
|
|
11888
|
+
write`${child.value}`;
|
|
11889
|
+
} else if (import_compiler57.types.isMarkoPlaceholder(child)) {
|
|
11890
|
+
write`${callRuntime("_to_text", child.value)}`;
|
|
11891
|
+
}
|
|
11892
|
+
}
|
|
11893
|
+
} else {
|
|
11894
|
+
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
11895
|
+
if (import_compiler57.types.isStringLiteral(textLiteral)) {
|
|
11896
|
+
write`${textLiteral}`;
|
|
11897
|
+
} else {
|
|
11898
|
+
addStatement(
|
|
11899
|
+
"render",
|
|
11900
|
+
getSection(tag),
|
|
11901
|
+
textLiteral.extra?.referencedBindings,
|
|
11902
|
+
import_compiler57.types.expressionStatement(
|
|
11903
|
+
callRuntime(
|
|
11904
|
+
"_text_content",
|
|
11905
|
+
createScopeReadExpression(nodeBinding),
|
|
11906
|
+
textLiteral
|
|
11907
|
+
)
|
|
11908
|
+
)
|
|
11909
|
+
);
|
|
11910
|
+
}
|
|
11911
|
+
}
|
|
11912
|
+
write`</title>`;
|
|
11913
|
+
if (nodeBinding) {
|
|
11914
|
+
markNode(
|
|
11915
|
+
tag,
|
|
11916
|
+
nodeBinding,
|
|
11917
|
+
getSerializeReason(tagSection, nodeBinding)
|
|
11918
|
+
);
|
|
11919
|
+
}
|
|
11920
|
+
exit2(tag);
|
|
11921
|
+
tag.remove();
|
|
11922
|
+
}
|
|
11923
|
+
},
|
|
11924
|
+
parseOptions: {
|
|
11925
|
+
text: true
|
|
11926
|
+
}
|
|
11927
|
+
};
|
|
11928
|
+
function getUsedAttrs4(tag) {
|
|
11929
|
+
const seen = {};
|
|
11930
|
+
const { attributes } = tag;
|
|
11931
|
+
const maybeStaticAttrs = /* @__PURE__ */ new Set();
|
|
11932
|
+
let spreadExpression;
|
|
11933
|
+
let skipExpression;
|
|
11934
|
+
let spreadProps;
|
|
11935
|
+
let skipProps;
|
|
11936
|
+
for (let i = attributes.length; i--; ) {
|
|
11937
|
+
const attr = attributes[i];
|
|
11938
|
+
const { value } = attr;
|
|
11939
|
+
if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11940
|
+
if (!spreadProps) {
|
|
11941
|
+
spreadProps = [];
|
|
11942
|
+
}
|
|
11943
|
+
spreadProps.push(import_compiler57.types.spreadElement(value));
|
|
11944
|
+
} else if (!seen[attr.name]) {
|
|
11945
|
+
seen[attr.name] = attr;
|
|
11946
|
+
if (spreadProps) {
|
|
11947
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
11948
|
+
} else {
|
|
11949
|
+
maybeStaticAttrs.add(attr);
|
|
11950
|
+
}
|
|
11951
|
+
}
|
|
11952
|
+
}
|
|
11953
|
+
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
11954
|
+
if (spreadProps) {
|
|
11955
|
+
spreadProps.reverse();
|
|
11956
|
+
for (const { name: name2 } of staticAttrs) {
|
|
11957
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler57.types.numericLiteral(1)));
|
|
11958
|
+
}
|
|
11959
|
+
if (skipProps) {
|
|
11960
|
+
skipExpression = import_compiler57.types.objectExpression(skipProps);
|
|
11961
|
+
}
|
|
11962
|
+
spreadExpression = propsToExpression(spreadProps);
|
|
11963
|
+
}
|
|
11964
|
+
return {
|
|
11965
|
+
staticAttrs,
|
|
11966
|
+
spreadExpression,
|
|
11967
|
+
skipExpression
|
|
11968
|
+
};
|
|
11969
|
+
}
|
|
11970
|
+
|
|
11971
|
+
// src/translator/core/try.ts
|
|
11972
|
+
var import_compiler58 = require("@marko/compiler");
|
|
11973
|
+
var import_babel_utils47 = require("@marko/compiler/babel-utils");
|
|
11974
|
+
var hasEnabledCatch = /* @__PURE__ */ new WeakSet();
|
|
11975
|
+
var kDOMBinding2 = Symbol("try tag dom binding");
|
|
11976
|
+
var try_default = {
|
|
11977
|
+
analyze(tag) {
|
|
11978
|
+
(0, import_babel_utils47.assertNoVar)(tag);
|
|
11979
|
+
(0, import_babel_utils47.assertNoArgs)(tag);
|
|
11980
|
+
(0, import_babel_utils47.assertNoParams)(tag);
|
|
11981
|
+
(0, import_babel_utils47.assertNoAttributes)(tag);
|
|
11982
|
+
assertNoSpreadAttrs(tag);
|
|
11983
|
+
analyzeAttributeTags(tag);
|
|
11984
|
+
const section = getOrCreateSection(tag);
|
|
11985
|
+
const tagExtra = mergeReferences(
|
|
11986
|
+
section,
|
|
11987
|
+
tag.node,
|
|
11988
|
+
getAllTagReferenceNodes(tag.node)
|
|
11556
11989
|
);
|
|
11557
11990
|
tagExtra[kDOMBinding2] = createBinding("#text", 0 /* dom */, section);
|
|
11558
11991
|
if (!tag.node.body.body.length) {
|
|
@@ -11597,7 +12030,7 @@ var try_default = {
|
|
|
11597
12030
|
writeHTMLResumeStatements(tagBody);
|
|
11598
12031
|
tag.insertBefore(translatedAttrs.statements);
|
|
11599
12032
|
tag.replaceWith(
|
|
11600
|
-
|
|
12033
|
+
import_compiler58.types.expressionStatement(
|
|
11601
12034
|
callRuntime(
|
|
11602
12035
|
"_try",
|
|
11603
12036
|
getScopeIdIdentifier(section),
|
|
@@ -11652,11 +12085,11 @@ var try_default = {
|
|
|
11652
12085
|
translatedAttrs.statements
|
|
11653
12086
|
);
|
|
11654
12087
|
}
|
|
11655
|
-
const program = (0,
|
|
12088
|
+
const program = (0, import_babel_utils47.getProgram)().node;
|
|
11656
12089
|
if (!hasEnabledCatch.has(program)) {
|
|
11657
12090
|
hasEnabledCatch.add(program);
|
|
11658
12091
|
program.body.push(
|
|
11659
|
-
|
|
12092
|
+
import_compiler58.types.expressionStatement(callRuntime("_enable_catch"))
|
|
11660
12093
|
);
|
|
11661
12094
|
}
|
|
11662
12095
|
addValue(
|
|
@@ -11708,6 +12141,7 @@ var core_default = {
|
|
|
11708
12141
|
"<static>": static_default,
|
|
11709
12142
|
"<style>": style_default,
|
|
11710
12143
|
"<textarea>": textarea_default,
|
|
12144
|
+
"<title>": title_default,
|
|
11711
12145
|
"<try>": try_default
|
|
11712
12146
|
};
|
|
11713
12147
|
|
|
@@ -11755,13 +12189,13 @@ var document_type_default = {
|
|
|
11755
12189
|
};
|
|
11756
12190
|
|
|
11757
12191
|
// src/translator/visitors/import-declaration.ts
|
|
11758
|
-
var
|
|
12192
|
+
var import_babel_utils48 = require("@marko/compiler/babel-utils");
|
|
11759
12193
|
var import_declaration_default = {
|
|
11760
12194
|
analyze(importDecl) {
|
|
11761
12195
|
const { node } = importDecl;
|
|
11762
12196
|
const { source } = node;
|
|
11763
12197
|
const { value } = source;
|
|
11764
|
-
const tagImport = (0,
|
|
12198
|
+
const tagImport = (0, import_babel_utils48.resolveTagImport)(importDecl, value);
|
|
11765
12199
|
if (tagImport) {
|
|
11766
12200
|
node.extra ??= {};
|
|
11767
12201
|
node.extra.tagImport = tagImport;
|
|
@@ -11784,10 +12218,10 @@ var import_declaration_default = {
|
|
|
11784
12218
|
};
|
|
11785
12219
|
|
|
11786
12220
|
// src/translator/visitors/placeholder.ts
|
|
11787
|
-
var
|
|
12221
|
+
var import_compiler60 = require("@marko/compiler");
|
|
11788
12222
|
|
|
11789
12223
|
// src/translator/util/is-non-html-text.ts
|
|
11790
|
-
var
|
|
12224
|
+
var import_compiler59 = require("@marko/compiler");
|
|
11791
12225
|
function isNonHTMLText(placeholder) {
|
|
11792
12226
|
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
11793
12227
|
if (parentTag && isCoreTag(parentTag)) {
|
|
@@ -11795,6 +12229,7 @@ function isNonHTMLText(placeholder) {
|
|
|
11795
12229
|
case "html-comment":
|
|
11796
12230
|
case "html-script":
|
|
11797
12231
|
case "html-style":
|
|
12232
|
+
case "title":
|
|
11798
12233
|
return true;
|
|
11799
12234
|
}
|
|
11800
12235
|
}
|
|
@@ -11802,7 +12237,7 @@ function isNonHTMLText(placeholder) {
|
|
|
11802
12237
|
}
|
|
11803
12238
|
|
|
11804
12239
|
// src/translator/visitors/placeholder.ts
|
|
11805
|
-
var
|
|
12240
|
+
var kNodeBinding5 = Symbol("placeholder node binding");
|
|
11806
12241
|
var kSiblingText = Symbol("placeholder has sibling text");
|
|
11807
12242
|
var kSharedText = Symbol(
|
|
11808
12243
|
"placeholder will merge its visitor with a another node"
|
|
@@ -11820,7 +12255,7 @@ var placeholder_default = {
|
|
|
11820
12255
|
}
|
|
11821
12256
|
} else {
|
|
11822
12257
|
const section = getOrCreateSection(placeholder);
|
|
11823
|
-
const nodeBinding = (node.extra ??= {})[
|
|
12258
|
+
const nodeBinding = (node.extra ??= {})[kNodeBinding5] = createBinding(
|
|
11824
12259
|
"#text",
|
|
11825
12260
|
0 /* dom */,
|
|
11826
12261
|
section
|
|
@@ -11843,7 +12278,7 @@ var placeholder_default = {
|
|
|
11843
12278
|
const isHTML = isOutputHTML();
|
|
11844
12279
|
const write = writeTo(placeholder);
|
|
11845
12280
|
const extra = node.extra || {};
|
|
11846
|
-
const nodeBinding = extra[
|
|
12281
|
+
const nodeBinding = extra[kNodeBinding5];
|
|
11847
12282
|
const canWriteHTML = isHTML || confident && node.escape;
|
|
11848
12283
|
const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
|
|
11849
12284
|
if (confident && canWriteHTML) {
|
|
@@ -11877,7 +12312,7 @@ var placeholder_default = {
|
|
|
11877
12312
|
"render",
|
|
11878
12313
|
getSection(placeholder),
|
|
11879
12314
|
valueExtra.referencedBindings,
|
|
11880
|
-
|
|
12315
|
+
import_compiler60.types.expressionStatement(
|
|
11881
12316
|
method === "_text" ? callRuntime(
|
|
11882
12317
|
"_text",
|
|
11883
12318
|
createScopeReadExpression(nodeBinding),
|
|
@@ -11915,7 +12350,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
11915
12350
|
break;
|
|
11916
12351
|
}
|
|
11917
12352
|
}
|
|
11918
|
-
if (!prev.node &&
|
|
12353
|
+
if (!prev.node && import_compiler60.types.isProgram(placeholder.parentPath)) {
|
|
11919
12354
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
|
11920
12355
|
}
|
|
11921
12356
|
let next = placeholder.getNextSibling();
|
|
@@ -11932,7 +12367,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
11932
12367
|
break;
|
|
11933
12368
|
}
|
|
11934
12369
|
}
|
|
11935
|
-
if (!next.node &&
|
|
12370
|
+
if (!next.node && import_compiler60.types.isProgram(placeholder.parentPath)) {
|
|
11936
12371
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
|
11937
12372
|
}
|
|
11938
12373
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
|
@@ -11974,7 +12409,7 @@ function isEmptyPlaceholder(placeholder) {
|
|
|
11974
12409
|
}
|
|
11975
12410
|
|
|
11976
12411
|
// src/translator/visitors/referenced-identifier.ts
|
|
11977
|
-
var
|
|
12412
|
+
var import_compiler61 = require("@marko/compiler");
|
|
11978
12413
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
|
11979
12414
|
var referenced_identifier_default = {
|
|
11980
12415
|
migrate(identifier) {
|
|
@@ -11982,8 +12417,8 @@ var referenced_identifier_default = {
|
|
|
11982
12417
|
if (identifier.scope.hasBinding(name2)) return;
|
|
11983
12418
|
switch (name2) {
|
|
11984
12419
|
case "out":
|
|
11985
|
-
if (
|
|
11986
|
-
identifier.parentPath.replaceWith(
|
|
12420
|
+
if (import_compiler61.types.isMemberExpression(identifier.parent) && import_compiler61.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
|
12421
|
+
identifier.parentPath.replaceWith(import_compiler61.types.identifier("$global"));
|
|
11987
12422
|
} else {
|
|
11988
12423
|
throw identifier.buildCodeFrameError(
|
|
11989
12424
|
"Only `out.global` is supported for compatibility."
|
|
@@ -12010,13 +12445,13 @@ var referenced_identifier_default = {
|
|
|
12010
12445
|
case "$global":
|
|
12011
12446
|
if (isOutputHTML()) {
|
|
12012
12447
|
identifier.replaceWith(
|
|
12013
|
-
|
|
12448
|
+
import_compiler61.types.callExpression(importRuntime("$global"), [])
|
|
12014
12449
|
);
|
|
12015
12450
|
} else {
|
|
12016
12451
|
identifier.replaceWith(
|
|
12017
|
-
|
|
12452
|
+
import_compiler61.types.memberExpression(
|
|
12018
12453
|
scopeIdentifier,
|
|
12019
|
-
|
|
12454
|
+
import_compiler61.types.identifier(getAccessorProp().Global)
|
|
12020
12455
|
)
|
|
12021
12456
|
);
|
|
12022
12457
|
}
|
|
@@ -12024,13 +12459,13 @@ var referenced_identifier_default = {
|
|
|
12024
12459
|
case "$signal":
|
|
12025
12460
|
if (isOutputHTML()) {
|
|
12026
12461
|
identifier.replaceWith(
|
|
12027
|
-
|
|
12028
|
-
|
|
12462
|
+
import_compiler61.types.callExpression(
|
|
12463
|
+
import_compiler61.types.arrowFunctionExpression(
|
|
12029
12464
|
[],
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12465
|
+
import_compiler61.types.blockStatement([
|
|
12466
|
+
import_compiler61.types.throwStatement(
|
|
12467
|
+
import_compiler61.types.newExpression(import_compiler61.types.identifier("Error"), [
|
|
12468
|
+
import_compiler61.types.stringLiteral("Cannot use $signal in a server render.")
|
|
12034
12469
|
])
|
|
12035
12470
|
)
|
|
12036
12471
|
])
|
|
@@ -12056,19 +12491,19 @@ var referenced_identifier_default = {
|
|
|
12056
12491
|
"render",
|
|
12057
12492
|
section,
|
|
12058
12493
|
exprRoot.node.extra?.referencedBindings,
|
|
12059
|
-
|
|
12060
|
-
|
|
12494
|
+
import_compiler61.types.expressionStatement(
|
|
12495
|
+
import_compiler61.types.callExpression(importRuntime("$signalReset"), [
|
|
12061
12496
|
scopeIdentifier,
|
|
12062
|
-
|
|
12497
|
+
import_compiler61.types.numericLiteral(exprId)
|
|
12063
12498
|
])
|
|
12064
12499
|
),
|
|
12065
12500
|
false
|
|
12066
12501
|
);
|
|
12067
12502
|
}
|
|
12068
12503
|
identifier.replaceWith(
|
|
12069
|
-
|
|
12504
|
+
import_compiler61.types.callExpression(importRuntime("$signal"), [
|
|
12070
12505
|
scopeIdentifier,
|
|
12071
|
-
|
|
12506
|
+
import_compiler61.types.numericLiteral(exprId)
|
|
12072
12507
|
])
|
|
12073
12508
|
);
|
|
12074
12509
|
}
|
|
@@ -12077,7 +12512,7 @@ var referenced_identifier_default = {
|
|
|
12077
12512
|
};
|
|
12078
12513
|
|
|
12079
12514
|
// src/translator/visitors/scriptlet.ts
|
|
12080
|
-
var
|
|
12515
|
+
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
12081
12516
|
var scriptlet_default = {
|
|
12082
12517
|
analyze(scriptlet) {
|
|
12083
12518
|
if (!scriptlet.node.static) {
|
|
@@ -12091,7 +12526,7 @@ var scriptlet_default = {
|
|
|
12091
12526
|
scriptlet.node.body
|
|
12092
12527
|
);
|
|
12093
12528
|
if (scriptlet.node.target === "client") {
|
|
12094
|
-
(0,
|
|
12529
|
+
(0, import_babel_utils49.getProgram)().node.extra.isInteractive = true;
|
|
12095
12530
|
}
|
|
12096
12531
|
},
|
|
12097
12532
|
translate: {
|
|
@@ -12112,21 +12547,21 @@ var scriptlet_default = {
|
|
|
12112
12547
|
};
|
|
12113
12548
|
|
|
12114
12549
|
// src/translator/visitors/tag/index.ts
|
|
12115
|
-
var
|
|
12116
|
-
var
|
|
12550
|
+
var import_compiler65 = require("@marko/compiler");
|
|
12551
|
+
var import_babel_utils53 = require("@marko/compiler/babel-utils");
|
|
12117
12552
|
|
|
12118
12553
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
12119
|
-
var
|
|
12120
|
-
var
|
|
12554
|
+
var import_compiler62 = require("@marko/compiler");
|
|
12555
|
+
var import_babel_utils50 = require("@marko/compiler/babel-utils");
|
|
12121
12556
|
var attribute_tag_default = {
|
|
12122
12557
|
analyze: {
|
|
12123
12558
|
enter(tag) {
|
|
12124
|
-
(0,
|
|
12125
|
-
(0,
|
|
12559
|
+
(0, import_babel_utils50.assertNoVar)(tag);
|
|
12560
|
+
(0, import_babel_utils50.assertNoArgs)(tag);
|
|
12126
12561
|
const body = tag.get("body");
|
|
12127
12562
|
startSection(body);
|
|
12128
12563
|
trackParamsReferences(body, 3 /* param */);
|
|
12129
|
-
if (!(0,
|
|
12564
|
+
if (!(0, import_babel_utils50.findParentTag)(tag)) {
|
|
12130
12565
|
throw tag.get("name").buildCodeFrameError(
|
|
12131
12566
|
"[Attribute tags](https://markojs.com/docs/reference/language#attribute-tags) must be nested within another tag."
|
|
12132
12567
|
);
|
|
@@ -12149,13 +12584,13 @@ var attribute_tag_default = {
|
|
|
12149
12584
|
};
|
|
12150
12585
|
|
|
12151
12586
|
// src/translator/visitors/tag/custom-tag.ts
|
|
12152
|
-
var
|
|
12153
|
-
var
|
|
12587
|
+
var import_compiler63 = require("@marko/compiler");
|
|
12588
|
+
var import_babel_utils51 = require("@marko/compiler/babel-utils");
|
|
12154
12589
|
var import_path4 = __toESM(require("path"));
|
|
12155
12590
|
var custom_tag_default = {
|
|
12156
12591
|
analyze: {
|
|
12157
12592
|
enter(tag) {
|
|
12158
|
-
const templateFile = (0,
|
|
12593
|
+
const templateFile = (0, import_babel_utils51.getTagTemplate)(tag);
|
|
12159
12594
|
if (!templateFile) {
|
|
12160
12595
|
const tagName = getTagName(tag);
|
|
12161
12596
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
|
@@ -12167,12 +12602,12 @@ var custom_tag_default = {
|
|
|
12167
12602
|
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
|
12168
12603
|
);
|
|
12169
12604
|
}
|
|
12170
|
-
(0,
|
|
12171
|
-
const childFile = (0,
|
|
12605
|
+
(0, import_babel_utils51.assertAttributesOrSingleArg)(tag);
|
|
12606
|
+
const childFile = (0, import_babel_utils51.loadFileForTag)(tag);
|
|
12172
12607
|
if (!childFile) {
|
|
12173
12608
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
|
12174
12609
|
}
|
|
12175
|
-
const programSection = (0,
|
|
12610
|
+
const programSection = (0, import_babel_utils51.getProgram)().node.extra.section;
|
|
12176
12611
|
const childProgram = childFile.ast.program;
|
|
12177
12612
|
const childExtra = childProgram.extra;
|
|
12178
12613
|
const childSection = childExtra.section;
|
|
@@ -12200,12 +12635,12 @@ var custom_tag_default = {
|
|
|
12200
12635
|
};
|
|
12201
12636
|
function translateHTML(tag) {
|
|
12202
12637
|
const { node } = tag;
|
|
12203
|
-
const childProgram = (0,
|
|
12638
|
+
const childProgram = (0, import_babel_utils51.loadFileForTag)(tag).ast.program;
|
|
12204
12639
|
const childExtra = childProgram.extra;
|
|
12205
12640
|
let tagIdentifier;
|
|
12206
|
-
if (
|
|
12641
|
+
if (import_compiler63.types.isStringLiteral(node.name)) {
|
|
12207
12642
|
const relativePath = getTagRelativePath(tag);
|
|
12208
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
|
12643
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler63.types.identifier(getTemplateContentName()) : (0, import_babel_utils51.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
|
12209
12644
|
} else {
|
|
12210
12645
|
tagIdentifier = node.name;
|
|
12211
12646
|
}
|
|
@@ -12221,12 +12656,12 @@ function translateDOM(tag) {
|
|
|
12221
12656
|
const { file } = tag.hub;
|
|
12222
12657
|
const write = writeTo(tag);
|
|
12223
12658
|
const relativePath = getTagRelativePath(tag);
|
|
12224
|
-
const programSection = (0,
|
|
12225
|
-
const childFile = (0,
|
|
12659
|
+
const programSection = (0, import_babel_utils51.getProgram)().node.extra.section;
|
|
12660
|
+
const childFile = (0, import_babel_utils51.loadFileForTag)(tag);
|
|
12226
12661
|
const childExtra = childFile.ast.program.extra;
|
|
12227
12662
|
const childExports = childExtra.domExports;
|
|
12228
12663
|
const childSection = childExtra.section;
|
|
12229
|
-
const tagName =
|
|
12664
|
+
const tagName = import_compiler63.types.isIdentifier(node.name) ? node.name.name : import_compiler63.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
12230
12665
|
if (programSection === childSection) {
|
|
12231
12666
|
knownTagTranslateDOM(
|
|
12232
12667
|
tag,
|
|
@@ -12237,16 +12672,16 @@ function translateDOM(tag) {
|
|
|
12237
12672
|
"render",
|
|
12238
12673
|
section,
|
|
12239
12674
|
void 0,
|
|
12240
|
-
|
|
12241
|
-
|
|
12675
|
+
import_compiler63.types.expressionStatement(
|
|
12676
|
+
import_compiler63.types.callExpression(import_compiler63.types.identifier(childExports.setup), [
|
|
12242
12677
|
createScopeReadExpression(childBinding, section)
|
|
12243
12678
|
])
|
|
12244
12679
|
)
|
|
12245
12680
|
);
|
|
12246
12681
|
}
|
|
12247
12682
|
);
|
|
12248
|
-
write`${
|
|
12249
|
-
injectWalks(tag, tagName,
|
|
12683
|
+
write`${import_compiler63.types.identifier(childExports.template)}`;
|
|
12684
|
+
injectWalks(tag, tagName, import_compiler63.types.identifier(childExports.walks));
|
|
12250
12685
|
} else {
|
|
12251
12686
|
knownTagTranslateDOM(
|
|
12252
12687
|
tag,
|
|
@@ -12262,8 +12697,8 @@ function translateDOM(tag) {
|
|
|
12262
12697
|
"render",
|
|
12263
12698
|
section,
|
|
12264
12699
|
void 0,
|
|
12265
|
-
|
|
12266
|
-
|
|
12700
|
+
import_compiler63.types.expressionStatement(
|
|
12701
|
+
import_compiler63.types.callExpression(
|
|
12267
12702
|
importOrSelfReferenceName(
|
|
12268
12703
|
file,
|
|
12269
12704
|
relativePath,
|
|
@@ -12276,11 +12711,11 @@ function translateDOM(tag) {
|
|
|
12276
12711
|
);
|
|
12277
12712
|
}
|
|
12278
12713
|
);
|
|
12279
|
-
write`${(0,
|
|
12714
|
+
write`${(0, import_babel_utils51.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
12280
12715
|
injectWalks(
|
|
12281
12716
|
tag,
|
|
12282
12717
|
tagName,
|
|
12283
|
-
(0,
|
|
12718
|
+
(0, import_babel_utils51.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
|
12284
12719
|
);
|
|
12285
12720
|
}
|
|
12286
12721
|
tag.remove();
|
|
@@ -12291,9 +12726,9 @@ function getTagRelativePath(tag) {
|
|
|
12291
12726
|
hub: { file }
|
|
12292
12727
|
} = tag;
|
|
12293
12728
|
let relativePath;
|
|
12294
|
-
if (
|
|
12295
|
-
const template = (0,
|
|
12296
|
-
relativePath = template && (0,
|
|
12729
|
+
if (import_compiler63.types.isStringLiteral(node.name)) {
|
|
12730
|
+
const template = (0, import_babel_utils51.getTagTemplate)(tag);
|
|
12731
|
+
relativePath = template && (0, import_babel_utils51.resolveRelativePath)(file, template);
|
|
12297
12732
|
} else if (node.extra?.tagNameImported) {
|
|
12298
12733
|
relativePath = node.extra.tagNameImported;
|
|
12299
12734
|
}
|
|
@@ -12312,9 +12747,9 @@ function getTagRelativePath(tag) {
|
|
|
12312
12747
|
}
|
|
12313
12748
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
12314
12749
|
if (isCircularRequest(file, request)) {
|
|
12315
|
-
return
|
|
12750
|
+
return import_compiler63.types.identifier(name2);
|
|
12316
12751
|
}
|
|
12317
|
-
return (0,
|
|
12752
|
+
return (0, import_babel_utils51.importNamed)(file, request, name2, nameHint);
|
|
12318
12753
|
}
|
|
12319
12754
|
function isCircularRequest(file, request) {
|
|
12320
12755
|
const { filename } = file.opts;
|
|
@@ -12322,15 +12757,15 @@ function isCircularRequest(file, request) {
|
|
|
12322
12757
|
}
|
|
12323
12758
|
|
|
12324
12759
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
12325
|
-
var
|
|
12326
|
-
var
|
|
12760
|
+
var import_compiler64 = require("@marko/compiler");
|
|
12761
|
+
var import_babel_utils52 = require("@marko/compiler/babel-utils");
|
|
12327
12762
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
|
12328
12763
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
|
12329
12764
|
var importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
12330
12765
|
var dynamic_tag_default = {
|
|
12331
12766
|
analyze: {
|
|
12332
12767
|
enter(tag) {
|
|
12333
|
-
(0,
|
|
12768
|
+
(0, import_babel_utils52.assertAttributesOrArgs)(tag);
|
|
12334
12769
|
const { node } = tag;
|
|
12335
12770
|
const definedBodySection = node.extra?.defineBodySection;
|
|
12336
12771
|
if (definedBodySection) {
|
|
@@ -12355,9 +12790,9 @@ var dynamic_tag_default = {
|
|
|
12355
12790
|
tagSection
|
|
12356
12791
|
);
|
|
12357
12792
|
if (hasVar || tag.node.attributes.some(
|
|
12358
|
-
(attr) =>
|
|
12793
|
+
(attr) => import_compiler64.types.isMarkoSpreadAttribute(attr) || isEventOrChangeHandler(attr.name)
|
|
12359
12794
|
)) {
|
|
12360
|
-
(0,
|
|
12795
|
+
(0, import_babel_utils52.getProgram)().node.extra.isInteractive = true;
|
|
12361
12796
|
}
|
|
12362
12797
|
if (hasVar) {
|
|
12363
12798
|
trackVarReferences(tag, 5 /* derived */);
|
|
@@ -12395,7 +12830,7 @@ var dynamic_tag_default = {
|
|
|
12395
12830
|
if (isOutputHTML()) {
|
|
12396
12831
|
knownTagTranslateHTML(
|
|
12397
12832
|
tag,
|
|
12398
|
-
|
|
12833
|
+
import_compiler64.types.memberExpression(tag.node.name, import_compiler64.types.identifier("content")),
|
|
12399
12834
|
definedBodySection,
|
|
12400
12835
|
propTree
|
|
12401
12836
|
);
|
|
@@ -12412,9 +12847,9 @@ var dynamic_tag_default = {
|
|
|
12412
12847
|
"render",
|
|
12413
12848
|
section,
|
|
12414
12849
|
void 0,
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12850
|
+
import_compiler64.types.expressionStatement(
|
|
12851
|
+
import_compiler64.types.callExpression(
|
|
12852
|
+
import_compiler64.types.memberExpression(signal.identifier, import_compiler64.types.identifier("_")),
|
|
12418
12853
|
[
|
|
12419
12854
|
createScopeReadExpression(childBinding, section),
|
|
12420
12855
|
getScopeExpression(section, definedBodySection.parent)
|
|
@@ -12439,8 +12874,8 @@ var dynamic_tag_default = {
|
|
|
12439
12874
|
const nodeBinding = tagExtra[kDOMBinding3];
|
|
12440
12875
|
const isClassAPI = tagExtra.featureType === "class";
|
|
12441
12876
|
let tagExpression = node.name;
|
|
12442
|
-
if (
|
|
12443
|
-
tagExpression = (0,
|
|
12877
|
+
if (import_compiler64.types.isStringLiteral(tagExpression)) {
|
|
12878
|
+
tagExpression = (0, import_babel_utils52.importDefault)(
|
|
12444
12879
|
tag.hub.file,
|
|
12445
12880
|
getTagRelativePath(tag),
|
|
12446
12881
|
tagExpression.value
|
|
@@ -12448,15 +12883,15 @@ var dynamic_tag_default = {
|
|
|
12448
12883
|
}
|
|
12449
12884
|
if (isClassAPI) {
|
|
12450
12885
|
if (isOutputHTML()) {
|
|
12451
|
-
(0,
|
|
12452
|
-
|
|
12886
|
+
(0, import_babel_utils52.getProgram)().node.body.push(
|
|
12887
|
+
import_compiler64.types.markoScriptlet(
|
|
12453
12888
|
[
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
(0,
|
|
12889
|
+
import_compiler64.types.expressionStatement(
|
|
12890
|
+
import_compiler64.types.callExpression(
|
|
12891
|
+
(0, import_babel_utils52.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
12457
12892
|
[
|
|
12458
|
-
|
|
12459
|
-
|
|
12893
|
+
import_compiler64.types.identifier(tagExpression.name),
|
|
12894
|
+
import_compiler64.types.stringLiteral((0, import_babel_utils52.loadFileForTag)(tag).metadata.marko.id)
|
|
12460
12895
|
]
|
|
12461
12896
|
)
|
|
12462
12897
|
)
|
|
@@ -12465,12 +12900,12 @@ var dynamic_tag_default = {
|
|
|
12465
12900
|
)
|
|
12466
12901
|
);
|
|
12467
12902
|
} else {
|
|
12468
|
-
(0,
|
|
12469
|
-
|
|
12903
|
+
(0, import_babel_utils52.getProgram)().node.body.push(
|
|
12904
|
+
import_compiler64.types.expressionStatement(
|
|
12470
12905
|
callRuntime(
|
|
12471
12906
|
"_resume",
|
|
12472
|
-
|
|
12473
|
-
|
|
12907
|
+
import_compiler64.types.stringLiteral((0, import_babel_utils52.loadFileForTag)(tag).metadata.marko.id),
|
|
12908
|
+
import_compiler64.types.identifier(tagExpression.name)
|
|
12474
12909
|
)
|
|
12475
12910
|
)
|
|
12476
12911
|
);
|
|
@@ -12480,6 +12915,7 @@ var dynamic_tag_default = {
|
|
|
12480
12915
|
tag,
|
|
12481
12916
|
void 0,
|
|
12482
12917
|
void 0,
|
|
12918
|
+
void 0,
|
|
12483
12919
|
isClassAPI ? "renderBody" : "content"
|
|
12484
12920
|
);
|
|
12485
12921
|
const args = [];
|
|
@@ -12512,9 +12948,9 @@ var dynamic_tag_default = {
|
|
|
12512
12948
|
getScopeIdIdentifier(tagSection),
|
|
12513
12949
|
getScopeAccessorLiteral(nodeBinding),
|
|
12514
12950
|
tagExpression,
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12951
|
+
import_compiler64.types.arrayExpression(args),
|
|
12952
|
+
import_compiler64.types.numericLiteral(0),
|
|
12953
|
+
import_compiler64.types.numericLiteral(1),
|
|
12518
12954
|
serializeArg
|
|
12519
12955
|
) : callRuntime(
|
|
12520
12956
|
"_dynamic_tag",
|
|
@@ -12522,8 +12958,8 @@ var dynamic_tag_default = {
|
|
|
12522
12958
|
getScopeAccessorLiteral(nodeBinding),
|
|
12523
12959
|
tagExpression,
|
|
12524
12960
|
args[0],
|
|
12525
|
-
args[1] || (serializeArg ?
|
|
12526
|
-
serializeArg ?
|
|
12961
|
+
args[1] || (serializeArg ? import_compiler64.types.numericLiteral(0) : void 0),
|
|
12962
|
+
serializeArg ? import_compiler64.types.numericLiteral(0) : void 0,
|
|
12527
12963
|
serializeArg
|
|
12528
12964
|
);
|
|
12529
12965
|
if (node.var) {
|
|
@@ -12531,18 +12967,18 @@ var dynamic_tag_default = {
|
|
|
12531
12967
|
tag.get("name").toString() + "_scope"
|
|
12532
12968
|
);
|
|
12533
12969
|
statements.push(
|
|
12534
|
-
|
|
12535
|
-
|
|
12970
|
+
import_compiler64.types.variableDeclaration("const", [
|
|
12971
|
+
import_compiler64.types.variableDeclarator(
|
|
12536
12972
|
dynamicScopeIdentifier,
|
|
12537
12973
|
callRuntime("_peek_scope_id")
|
|
12538
12974
|
)
|
|
12539
12975
|
])
|
|
12540
12976
|
);
|
|
12541
12977
|
statements.push(
|
|
12542
|
-
|
|
12543
|
-
|
|
12978
|
+
import_compiler64.types.variableDeclaration("let", [
|
|
12979
|
+
import_compiler64.types.variableDeclarator(node.var, dynamicTagExpr)
|
|
12544
12980
|
]),
|
|
12545
|
-
|
|
12981
|
+
import_compiler64.types.expressionStatement(
|
|
12546
12982
|
callRuntime(
|
|
12547
12983
|
"_var",
|
|
12548
12984
|
getScopeIdIdentifier(tagSection),
|
|
@@ -12550,7 +12986,7 @@ var dynamic_tag_default = {
|
|
|
12550
12986
|
tag.node.extra[kChildOffsetScopeBinding2]
|
|
12551
12987
|
),
|
|
12552
12988
|
dynamicScopeIdentifier,
|
|
12553
|
-
|
|
12989
|
+
import_compiler64.types.stringLiteral(
|
|
12554
12990
|
getResumeRegisterId(
|
|
12555
12991
|
tagSection,
|
|
12556
12992
|
node.var.extra?.binding,
|
|
@@ -12562,7 +12998,7 @@ var dynamic_tag_default = {
|
|
|
12562
12998
|
)
|
|
12563
12999
|
);
|
|
12564
13000
|
} else {
|
|
12565
|
-
statements.push(
|
|
13001
|
+
statements.push(import_compiler64.types.expressionStatement(dynamicTagExpr));
|
|
12566
13002
|
}
|
|
12567
13003
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
12568
13004
|
replacement.skip();
|
|
@@ -12581,9 +13017,9 @@ var dynamic_tag_default = {
|
|
|
12581
13017
|
tagVarSignal.register = true;
|
|
12582
13018
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
|
12583
13019
|
const changeArgs = [
|
|
12584
|
-
|
|
13020
|
+
import_compiler64.types.memberExpression(
|
|
12585
13021
|
getScopeExpression(tagVarSignal.section, valueSection),
|
|
12586
|
-
|
|
13022
|
+
import_compiler64.types.stringLiteral(
|
|
12587
13023
|
getAccessorPrefix().BranchScopes + getScopeAccessor(nodeBinding)
|
|
12588
13024
|
),
|
|
12589
13025
|
true
|
|
@@ -12591,28 +13027,28 @@ var dynamic_tag_default = {
|
|
|
12591
13027
|
value
|
|
12592
13028
|
];
|
|
12593
13029
|
if (!isOptimize()) {
|
|
12594
|
-
changeArgs.push(
|
|
13030
|
+
changeArgs.push(import_compiler64.types.stringLiteral(varBinding.name));
|
|
12595
13031
|
}
|
|
12596
|
-
return
|
|
13032
|
+
return import_compiler64.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
12597
13033
|
};
|
|
12598
13034
|
}
|
|
12599
13035
|
signal.build = () => {
|
|
12600
13036
|
return callRuntime(
|
|
12601
13037
|
"_dynamic_tag",
|
|
12602
13038
|
getScopeAccessorLiteral(nodeBinding, true),
|
|
12603
|
-
bodySection &&
|
|
12604
|
-
tagVarSignal ?
|
|
12605
|
-
hasTagArgs &&
|
|
13039
|
+
bodySection && import_compiler64.types.identifier(bodySection.name),
|
|
13040
|
+
tagVarSignal ? import_compiler64.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
|
13041
|
+
hasTagArgs && import_compiler64.types.numericLiteral(1)
|
|
12606
13042
|
);
|
|
12607
13043
|
};
|
|
12608
13044
|
if (args.length) {
|
|
12609
|
-
const argsOrInput = hasTagArgs ?
|
|
12610
|
-
if (!
|
|
13045
|
+
const argsOrInput = hasTagArgs ? import_compiler64.types.arrayExpression(args) : args[0];
|
|
13046
|
+
if (!import_compiler64.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
|
12611
13047
|
signal.extraArgs = [
|
|
12612
|
-
|
|
13048
|
+
import_compiler64.types.arrowFunctionExpression(
|
|
12613
13049
|
[],
|
|
12614
|
-
statements.length ?
|
|
12615
|
-
statements.concat(
|
|
13050
|
+
statements.length ? import_compiler64.types.blockStatement(
|
|
13051
|
+
statements.concat(import_compiler64.types.returnStatement(argsOrInput))
|
|
12616
13052
|
) : argsOrInput
|
|
12617
13053
|
)
|
|
12618
13054
|
];
|
|
@@ -12626,13 +13062,13 @@ var dynamic_tag_default = {
|
|
|
12626
13062
|
}
|
|
12627
13063
|
};
|
|
12628
13064
|
function enableDynamicTagResume(tag) {
|
|
12629
|
-
const program = (0,
|
|
13065
|
+
const program = (0, import_babel_utils52.getProgram)().node;
|
|
12630
13066
|
if (!importedDynamicTagResume.has(program) && analyzeTagNameType(tag, true) !== 1 /* CustomTag */) {
|
|
12631
13067
|
for (const attr of tag.node.attributes) {
|
|
12632
13068
|
if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && isEventOrChangeHandler(attr.name)) {
|
|
12633
13069
|
importedDynamicTagResume.add(program);
|
|
12634
13070
|
program.body.push(
|
|
12635
|
-
|
|
13071
|
+
import_compiler64.types.expressionStatement(callRuntime("_resume_dynamic_tag"))
|
|
12636
13072
|
);
|
|
12637
13073
|
return;
|
|
12638
13074
|
}
|
|
@@ -12644,7 +13080,7 @@ function enableDynamicTagResume(tag) {
|
|
|
12644
13080
|
var tag_default = {
|
|
12645
13081
|
analyze: {
|
|
12646
13082
|
enter(tag) {
|
|
12647
|
-
const tagDef = (0,
|
|
13083
|
+
const tagDef = (0, import_babel_utils53.getTagDef)(tag);
|
|
12648
13084
|
const type = analyzeTagNameType(tag);
|
|
12649
13085
|
const hook = tagDef?.analyzer?.hook;
|
|
12650
13086
|
if (hook) {
|
|
@@ -12668,7 +13104,7 @@ var tag_default = {
|
|
|
12668
13104
|
}
|
|
12669
13105
|
},
|
|
12670
13106
|
exit(tag) {
|
|
12671
|
-
const hook = (0,
|
|
13107
|
+
const hook = (0, import_babel_utils53.getTagDef)(tag)?.analyzer?.hook;
|
|
12672
13108
|
if (hook) {
|
|
12673
13109
|
exit(hook, tag);
|
|
12674
13110
|
return;
|
|
@@ -12677,7 +13113,7 @@ var tag_default = {
|
|
|
12677
13113
|
},
|
|
12678
13114
|
translate: {
|
|
12679
13115
|
enter(tag) {
|
|
12680
|
-
const tagDef = (0,
|
|
13116
|
+
const tagDef = (0, import_babel_utils53.getTagDef)(tag);
|
|
12681
13117
|
const extra = tag.node.extra;
|
|
12682
13118
|
if (tagDef?.translator) {
|
|
12683
13119
|
if (tagDef.translator.path) {
|
|
@@ -12694,7 +13130,7 @@ var tag_default = {
|
|
|
12694
13130
|
);
|
|
12695
13131
|
}
|
|
12696
13132
|
if (attr.node.modifier) {
|
|
12697
|
-
if ((0,
|
|
13133
|
+
if ((0, import_babel_utils53.isNativeTag)(attr.parentPath)) {
|
|
12698
13134
|
attr.node.name += `:${attr.node.modifier}`;
|
|
12699
13135
|
} else {
|
|
12700
13136
|
throw attr.buildCodeFrameError(
|
|
@@ -12708,8 +13144,8 @@ var tag_default = {
|
|
|
12708
13144
|
if (extra.tagNameDynamic && extra.tagNameNullable && type === 0 /* NativeTag */ && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
|
12709
13145
|
const tagNameId = generateUidIdentifier("tagName");
|
|
12710
13146
|
const [tagNameVarPath] = tag.insertBefore(
|
|
12711
|
-
|
|
12712
|
-
|
|
13147
|
+
import_compiler65.types.variableDeclaration("const", [
|
|
13148
|
+
import_compiler65.types.variableDeclarator(tagNameId, tag.node.name)
|
|
12713
13149
|
])
|
|
12714
13150
|
);
|
|
12715
13151
|
tagNameVarPath.skip();
|
|
@@ -12731,7 +13167,7 @@ var tag_default = {
|
|
|
12731
13167
|
}
|
|
12732
13168
|
},
|
|
12733
13169
|
exit(tag) {
|
|
12734
|
-
const translator = (0,
|
|
13170
|
+
const translator = (0, import_babel_utils53.getTagDef)(tag)?.translator;
|
|
12735
13171
|
if (translator) {
|
|
12736
13172
|
exit(translator.hook, tag);
|
|
12737
13173
|
return;
|
|
@@ -12755,7 +13191,7 @@ var tag_default = {
|
|
|
12755
13191
|
};
|
|
12756
13192
|
|
|
12757
13193
|
// src/translator/visitors/text.ts
|
|
12758
|
-
var
|
|
13194
|
+
var import_compiler66 = require("@marko/compiler");
|
|
12759
13195
|
var text_default = {
|
|
12760
13196
|
translate: {
|
|
12761
13197
|
exit(text) {
|