marko 6.0.114 → 6.0.116
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 +776 -351
- 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 +1 -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,19 +2239,37 @@ 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 (restAlias.excludeProperties !== void 0) {
|
|
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
|
}
|
|
2255
2275
|
|
|
@@ -5577,7 +5597,7 @@ var native_tag_default = {
|
|
|
5577
5597
|
valueChange
|
|
5578
5598
|
);
|
|
5579
5599
|
} else if (value) {
|
|
5580
|
-
writeAtStartOfBody = callRuntime("
|
|
5600
|
+
writeAtStartOfBody = callRuntime("_to_text", value);
|
|
5581
5601
|
}
|
|
5582
5602
|
}
|
|
5583
5603
|
for (const attr of staticAttrs) {
|
|
@@ -6056,7 +6076,7 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6056
6076
|
}
|
|
6057
6077
|
}
|
|
6058
6078
|
spreadProps.push(import_compiler30.types.spreadElement(value));
|
|
6059
|
-
} else if (!seen[attr.name] ||
|
|
6079
|
+
} else if (!(seen[attr.name] || attr.name === "content" && tag.body.body.length)) {
|
|
6060
6080
|
seen[attr.name] = attr;
|
|
6061
6081
|
if (spreadProps) {
|
|
6062
6082
|
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
@@ -6582,14 +6602,15 @@ function getBaseArgsInForTag(type, attrs) {
|
|
|
6582
6602
|
|
|
6583
6603
|
// src/translator/util/translate-attrs.ts
|
|
6584
6604
|
var contentProps = /* @__PURE__ */ new WeakSet();
|
|
6585
|
-
function translateAttrs(tag,
|
|
6586
|
-
const
|
|
6605
|
+
function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "content") {
|
|
6606
|
+
const templateExports = propTree && !propTree.rest ? propTree.props : void 0;
|
|
6587
6607
|
const properties = [];
|
|
6588
6608
|
const attrTagLookup = tag.node.extra?.attributeTags;
|
|
6609
|
+
const seen = new Set(skip2);
|
|
6589
6610
|
if (attrTagLookup) {
|
|
6590
6611
|
for (const name2 in attrTagLookup) {
|
|
6591
6612
|
const attrTagMeta = attrTagLookup[name2];
|
|
6592
|
-
if (usesExport(templateExports, attrTagMeta.name)) {
|
|
6613
|
+
if (!seen.has(name2) && usesExport(templateExports, attrTagMeta.name)) {
|
|
6593
6614
|
seen.add(attrTagMeta.name);
|
|
6594
6615
|
if (attrTagMeta.dynamic) {
|
|
6595
6616
|
statements.push(
|
|
@@ -6624,7 +6645,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6624
6645
|
} else {
|
|
6625
6646
|
const translatedAttrTag = translateAttrs(
|
|
6626
6647
|
child,
|
|
6627
|
-
templateExports?.[attrTagMeta.name]
|
|
6648
|
+
templateExports?.[attrTagMeta.name],
|
|
6649
|
+
void 0,
|
|
6628
6650
|
statements,
|
|
6629
6651
|
contentKey
|
|
6630
6652
|
);
|
|
@@ -6713,7 +6735,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6713
6735
|
if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
|
|
6714
6736
|
const translatedAttrTag = translateAttrs(
|
|
6715
6737
|
tag,
|
|
6716
|
-
templateExports?.[attrTagMeta.name]
|
|
6738
|
+
templateExports?.[attrTagMeta.name],
|
|
6739
|
+
void 0,
|
|
6717
6740
|
statements,
|
|
6718
6741
|
contentKey
|
|
6719
6742
|
);
|
|
@@ -7009,7 +7032,7 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7009
7032
|
const tagVar = node.var;
|
|
7010
7033
|
const section = getSection(tag);
|
|
7011
7034
|
const attrsPropTree = propTree?.props?.[tag.node.arguments?.length || 0];
|
|
7012
|
-
const { properties, statements } = propTree && !propTree.props || attrsPropTree ? translateAttrs(tag, attrsPropTree
|
|
7035
|
+
const { properties, statements } = propTree && !propTree.props || attrsPropTree ? translateAttrs(tag, attrsPropTree) : {
|
|
7013
7036
|
properties: [],
|
|
7014
7037
|
statements: []
|
|
7015
7038
|
};
|
|
@@ -7267,6 +7290,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7267
7290
|
const known = inputExpr.known = {};
|
|
7268
7291
|
const attrTagLookup = analyzeAttributeTags(tag);
|
|
7269
7292
|
const seen = /* @__PURE__ */ new Set();
|
|
7293
|
+
const unknownReferences = [];
|
|
7270
7294
|
if (attrTagLookup) {
|
|
7271
7295
|
const nodeReferencesByGroup = /* @__PURE__ */ new Map();
|
|
7272
7296
|
const analyzeDynamicChildGroup = (group, child) => {
|
|
@@ -7303,7 +7327,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7303
7327
|
analyzeDynamicChildGroup(attrTagMeta.group, child);
|
|
7304
7328
|
}
|
|
7305
7329
|
} else {
|
|
7306
|
-
|
|
7330
|
+
unknownReferences.push(getAllTagReferenceNodes(child.node));
|
|
7307
7331
|
}
|
|
7308
7332
|
} else {
|
|
7309
7333
|
const group = child.node.extra.attributeTagGroup;
|
|
@@ -7317,7 +7341,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7317
7341
|
if (childUsesGroupProp) {
|
|
7318
7342
|
analyzeDynamicChildGroup(group, child);
|
|
7319
7343
|
} else {
|
|
7320
|
-
|
|
7344
|
+
unknownReferences.push(getAllTagReferenceNodes(child.node));
|
|
7321
7345
|
}
|
|
7322
7346
|
}
|
|
7323
7347
|
}
|
|
@@ -7366,7 +7390,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7366
7390
|
if (import_compiler34.types.isMarkoAttribute(attr)) {
|
|
7367
7391
|
const templateExportAttr = propTree.props[attr.name];
|
|
7368
7392
|
if (!templateExportAttr || seen.has(attr.name)) {
|
|
7369
|
-
|
|
7393
|
+
unknownReferences.push(attr.value);
|
|
7370
7394
|
continue;
|
|
7371
7395
|
}
|
|
7372
7396
|
seen.add(attr.name);
|
|
@@ -7406,6 +7430,16 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7406
7430
|
}
|
|
7407
7431
|
setBindingDownstream(spreadBinding, extra);
|
|
7408
7432
|
}
|
|
7433
|
+
if (propTree.rest) {
|
|
7434
|
+
const extra = inputExpr.value = mergeReferences(
|
|
7435
|
+
section,
|
|
7436
|
+
tag.node,
|
|
7437
|
+
unknownReferences.flat()
|
|
7438
|
+
);
|
|
7439
|
+
setBindingDownstream(propTree.binding, extra);
|
|
7440
|
+
} else {
|
|
7441
|
+
unknownReferences.forEach(dropReferences);
|
|
7442
|
+
}
|
|
7409
7443
|
return inputExpr;
|
|
7410
7444
|
}
|
|
7411
7445
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
@@ -7477,13 +7511,231 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7477
7511
|
}
|
|
7478
7512
|
}
|
|
7479
7513
|
function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
7480
|
-
|
|
7514
|
+
let translatedAttrs;
|
|
7515
|
+
let seen;
|
|
7516
|
+
let spreadId;
|
|
7517
|
+
if (propTree.props) {
|
|
7518
|
+
const attrTagLookup = analyzeAttributeTags(tag);
|
|
7519
|
+
seen = /* @__PURE__ */ new Set();
|
|
7520
|
+
if (attrTagLookup) {
|
|
7521
|
+
const attrTags2 = tag.get("attributeTags");
|
|
7522
|
+
const statementsByGroup = /* @__PURE__ */ new Map();
|
|
7523
|
+
const translateDynamicAttrTagChildInGroup = (group, index) => {
|
|
7524
|
+
const child = attrTags2[index];
|
|
7525
|
+
let statements = statementsByGroup.get(group)?.statements;
|
|
7526
|
+
if (!statements) {
|
|
7527
|
+
statements = [];
|
|
7528
|
+
statementsByGroup.set(group, {
|
|
7529
|
+
referencedBindings: child.node.extra?.referencedBindings,
|
|
7530
|
+
statements
|
|
7531
|
+
});
|
|
7532
|
+
}
|
|
7533
|
+
return addDynamicAttrTagStatements(
|
|
7534
|
+
attrTags2,
|
|
7535
|
+
index,
|
|
7536
|
+
attrTagLookup,
|
|
7537
|
+
statements,
|
|
7538
|
+
propTree.props
|
|
7539
|
+
);
|
|
7540
|
+
};
|
|
7541
|
+
for (const attrTagName in attrTagLookup) {
|
|
7542
|
+
seen.add(attrTagLookup[attrTagName].name);
|
|
7543
|
+
}
|
|
7544
|
+
for (let i = 0; i < attrTags2.length; i++) {
|
|
7545
|
+
const child = attrTags2[i];
|
|
7546
|
+
if (child.isMarkoTag()) {
|
|
7547
|
+
if ((0, import_babel_utils24.isAttributeTag)(child)) {
|
|
7548
|
+
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7549
|
+
const childAttrExport = propTree.props[attrTagMeta.name];
|
|
7550
|
+
if (childAttrExport) {
|
|
7551
|
+
if (attrTagMeta.dynamic) {
|
|
7552
|
+
i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
|
|
7553
|
+
} else {
|
|
7554
|
+
writeAttrsToSignals(
|
|
7555
|
+
child,
|
|
7556
|
+
childAttrExport,
|
|
7557
|
+
`${importAlias}_${attrTagMeta.name}`,
|
|
7558
|
+
info
|
|
7559
|
+
);
|
|
7560
|
+
}
|
|
7561
|
+
}
|
|
7562
|
+
} else if (child.node.extra?.attributeTagGroup) {
|
|
7563
|
+
i = translateDynamicAttrTagChildInGroup(
|
|
7564
|
+
child.node.extra.attributeTagGroup,
|
|
7565
|
+
i
|
|
7566
|
+
);
|
|
7567
|
+
}
|
|
7568
|
+
}
|
|
7569
|
+
}
|
|
7570
|
+
for (const [
|
|
7571
|
+
group,
|
|
7572
|
+
{ referencedBindings, statements }
|
|
7573
|
+
] of statementsByGroup) {
|
|
7574
|
+
const decls = [];
|
|
7575
|
+
for (const name2 of group) {
|
|
7576
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
7577
|
+
const childAttrExports = propTree.props[attrTagMeta.name];
|
|
7578
|
+
if (!childAttrExports) continue;
|
|
7579
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7580
|
+
childAttrExports.binding,
|
|
7581
|
+
`${importAlias}_${attrTagMeta.name}`
|
|
7582
|
+
);
|
|
7583
|
+
decls.push(import_compiler34.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
7584
|
+
addStatement("render", info.tagSection, referencedBindings, [
|
|
7585
|
+
import_compiler34.types.variableDeclaration("let", decls),
|
|
7586
|
+
...statements
|
|
7587
|
+
]);
|
|
7588
|
+
addStatement(
|
|
7589
|
+
"render",
|
|
7590
|
+
info.tagSection,
|
|
7591
|
+
referencedBindings,
|
|
7592
|
+
import_compiler34.types.expressionStatement(
|
|
7593
|
+
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7594
|
+
createScopeReadExpression(
|
|
7595
|
+
info.childScopeBinding,
|
|
7596
|
+
info.tagSection
|
|
7597
|
+
),
|
|
7598
|
+
getAttrTagIdentifier(attrTagMeta)
|
|
7599
|
+
])
|
|
7600
|
+
)
|
|
7601
|
+
);
|
|
7602
|
+
}
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
const bodySection = tag.node.body.extra?.section;
|
|
7606
|
+
if (bodySection && !seen.has("content")) {
|
|
7607
|
+
seen.add("content");
|
|
7608
|
+
if (propTree.props.content) {
|
|
7609
|
+
const contentExportIdentifier = info.getBindingIdentifier(
|
|
7610
|
+
propTree.props.content.binding,
|
|
7611
|
+
`${importAlias}_content`
|
|
7612
|
+
);
|
|
7613
|
+
addStatement(
|
|
7614
|
+
"render",
|
|
7615
|
+
info.tagSection,
|
|
7616
|
+
void 0,
|
|
7617
|
+
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7618
|
+
import_compiler34.types.expressionStatement(
|
|
7619
|
+
import_compiler34.types.callExpression(contentExportIdentifier, [
|
|
7620
|
+
createScopeReadExpression(
|
|
7621
|
+
info.childScopeBinding,
|
|
7622
|
+
info.tagSection
|
|
7623
|
+
),
|
|
7624
|
+
import_compiler34.types.callExpression(import_compiler34.types.identifier(bodySection.name), [
|
|
7625
|
+
scopeIdentifier
|
|
7626
|
+
])
|
|
7627
|
+
])
|
|
7628
|
+
)
|
|
7629
|
+
);
|
|
7630
|
+
}
|
|
7631
|
+
}
|
|
7632
|
+
const { attributes } = tag.node;
|
|
7633
|
+
const staticAttrs = [];
|
|
7634
|
+
let spreadProps;
|
|
7635
|
+
for (let i = attributes.length; i--; ) {
|
|
7636
|
+
const attr = attributes[i];
|
|
7637
|
+
if (import_compiler34.types.isMarkoAttribute(attr)) {
|
|
7638
|
+
const childAttrExports = propTree.props[attr.name];
|
|
7639
|
+
if (!childAttrExports || seen.has(attr.name)) continue;
|
|
7640
|
+
if (spreadProps) {
|
|
7641
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
7642
|
+
continue;
|
|
7643
|
+
}
|
|
7644
|
+
seen.add(attr.name);
|
|
7645
|
+
staticAttrs.push(attr);
|
|
7646
|
+
} else if (spreadProps) {
|
|
7647
|
+
spreadProps.push(import_compiler34.types.spreadElement(attr.value));
|
|
7648
|
+
} else {
|
|
7649
|
+
spreadProps = [import_compiler34.types.spreadElement(attr.value)];
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
for (const attr of staticAttrs.reverse()) {
|
|
7653
|
+
const childAttrExports = propTree.props[attr.name];
|
|
7654
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7655
|
+
childAttrExports.binding,
|
|
7656
|
+
`${importAlias}_${attr.name}`
|
|
7657
|
+
);
|
|
7658
|
+
addStatement(
|
|
7659
|
+
"render",
|
|
7660
|
+
info.tagSection,
|
|
7661
|
+
attr.value.extra?.referencedBindings,
|
|
7662
|
+
import_compiler34.types.expressionStatement(
|
|
7663
|
+
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7664
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7665
|
+
attr.value
|
|
7666
|
+
])
|
|
7667
|
+
)
|
|
7668
|
+
);
|
|
7669
|
+
}
|
|
7670
|
+
const missing = new Set(Object.keys(propTree.props));
|
|
7671
|
+
for (const name2 of seen) missing.delete(name2);
|
|
7672
|
+
if (missing.size) {
|
|
7673
|
+
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7674
|
+
if (spreadProps) {
|
|
7675
|
+
const spreadExpr = propsToExpression(
|
|
7676
|
+
propTree.rest ? (translatedAttrs = translateAttrs(tag, propTree, seen)).properties : spreadProps.reverse()
|
|
7677
|
+
);
|
|
7678
|
+
if (isSimpleReference(spreadExpr)) {
|
|
7679
|
+
spreadId = spreadExpr;
|
|
7680
|
+
} else {
|
|
7681
|
+
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
7682
|
+
if (translatedAttrs) {
|
|
7683
|
+
translatedAttrs.properties = [import_compiler34.types.spreadElement(spreadId)];
|
|
7684
|
+
}
|
|
7685
|
+
addStatement("render", info.tagSection, referencedBindings, [
|
|
7686
|
+
import_compiler34.types.variableDeclaration("const", [
|
|
7687
|
+
import_compiler34.types.variableDeclarator(spreadId, spreadExpr)
|
|
7688
|
+
])
|
|
7689
|
+
]);
|
|
7690
|
+
}
|
|
7691
|
+
}
|
|
7692
|
+
for (const name2 of missing) {
|
|
7693
|
+
const childAttrExports = propTree.props[name2];
|
|
7694
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7695
|
+
childAttrExports.binding,
|
|
7696
|
+
`${importAlias}_${name2}`
|
|
7697
|
+
);
|
|
7698
|
+
addStatement(
|
|
7699
|
+
"render",
|
|
7700
|
+
info.tagSection,
|
|
7701
|
+
referencedBindings,
|
|
7702
|
+
import_compiler34.types.expressionStatement(
|
|
7703
|
+
import_compiler34.types.callExpression(
|
|
7704
|
+
attrExportIdentifier,
|
|
7705
|
+
spreadId ? [
|
|
7706
|
+
createScopeReadExpression(
|
|
7707
|
+
info.childScopeBinding,
|
|
7708
|
+
info.tagSection
|
|
7709
|
+
),
|
|
7710
|
+
toMemberExpression(import_compiler34.types.cloneNode(spreadId, true), name2)
|
|
7711
|
+
] : [
|
|
7712
|
+
createScopeReadExpression(
|
|
7713
|
+
info.childScopeBinding,
|
|
7714
|
+
info.tagSection
|
|
7715
|
+
)
|
|
7716
|
+
]
|
|
7717
|
+
)
|
|
7718
|
+
)
|
|
7719
|
+
);
|
|
7720
|
+
}
|
|
7721
|
+
}
|
|
7722
|
+
}
|
|
7723
|
+
if (!propTree.props || propTree.rest) {
|
|
7724
|
+
if (!translatedAttrs) {
|
|
7725
|
+
if (propTree.rest) {
|
|
7726
|
+
seen ||= /* @__PURE__ */ new Set();
|
|
7727
|
+
forEach(
|
|
7728
|
+
propTree.rest.binding.excludeProperties,
|
|
7729
|
+
(prop) => seen.add(prop)
|
|
7730
|
+
);
|
|
7731
|
+
}
|
|
7732
|
+
translatedAttrs = translateAttrs(tag, propTree.rest, seen);
|
|
7733
|
+
}
|
|
7481
7734
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7482
7735
|
const tagInputIdentifier = info.getBindingIdentifier(
|
|
7483
|
-
propTree.binding,
|
|
7484
|
-
importAlias
|
|
7736
|
+
propTree.rest?.binding || propTree.binding,
|
|
7737
|
+
propTree.rest ? importAlias + "_$rest" : importAlias
|
|
7485
7738
|
);
|
|
7486
|
-
const translatedAttrs = translateAttrs(tag);
|
|
7487
7739
|
if (translatedAttrs.statements.length) {
|
|
7488
7740
|
addStatement(
|
|
7489
7741
|
"render",
|
|
@@ -7493,6 +7745,27 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7493
7745
|
);
|
|
7494
7746
|
}
|
|
7495
7747
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7748
|
+
if (propTree.rest && spreadId) {
|
|
7749
|
+
const props = [];
|
|
7750
|
+
const restId = import_compiler34.types.identifier(propTree.rest.binding.name);
|
|
7751
|
+
forEach(propTree.rest.binding.excludeProperties, (name2) => {
|
|
7752
|
+
const propId = toPropertyName(name2);
|
|
7753
|
+
const shorthand = propId.type === "Identifier" && import_compiler34.types.isValidIdentifier(name2);
|
|
7754
|
+
props.push(
|
|
7755
|
+
import_compiler34.types.objectProperty(
|
|
7756
|
+
propId,
|
|
7757
|
+
shorthand ? propId : generateUidIdentifier(name2),
|
|
7758
|
+
false,
|
|
7759
|
+
shorthand
|
|
7760
|
+
)
|
|
7761
|
+
);
|
|
7762
|
+
});
|
|
7763
|
+
props.push(import_compiler34.types.restElement(restId));
|
|
7764
|
+
translatedProps = import_compiler34.types.callExpression(
|
|
7765
|
+
import_compiler34.types.arrowFunctionExpression([import_compiler34.types.objectPattern(props)], restId),
|
|
7766
|
+
[spreadId]
|
|
7767
|
+
);
|
|
7768
|
+
}
|
|
7496
7769
|
if ((0, import_babel_utils24.isAttributeTag)(tag)) {
|
|
7497
7770
|
const attrTagName = getTagName(tag);
|
|
7498
7771
|
const parentTag = tag.parentPath;
|
|
@@ -7538,188 +7811,6 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7538
7811
|
])
|
|
7539
7812
|
)
|
|
7540
7813
|
);
|
|
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
7814
|
}
|
|
7724
7815
|
}
|
|
7725
7816
|
function mapParamReasonToExpr(exprs, reason) {
|
|
@@ -7754,8 +7845,15 @@ function callStatement(id, ...args) {
|
|
|
7754
7845
|
function callExpression(id, ...args) {
|
|
7755
7846
|
return import_compiler34.types.callExpression(id, args.filter(Boolean));
|
|
7756
7847
|
}
|
|
7757
|
-
function
|
|
7758
|
-
|
|
7848
|
+
function isSimpleReference(expr) {
|
|
7849
|
+
switch (expr.type) {
|
|
7850
|
+
case "Identifier":
|
|
7851
|
+
return true;
|
|
7852
|
+
case "MemberExpression":
|
|
7853
|
+
return !expr.computed && isSimpleReference(expr.object);
|
|
7854
|
+
default:
|
|
7855
|
+
return false;
|
|
7856
|
+
}
|
|
7759
7857
|
}
|
|
7760
7858
|
|
|
7761
7859
|
// src/translator/util/references.ts
|
|
@@ -9614,7 +9712,7 @@ function bodyToTextLiteral(body) {
|
|
|
9614
9712
|
} else if (import_compiler42.types.isMarkoPlaceholder(child)) {
|
|
9615
9713
|
placeholderExtra ||= child.value.extra;
|
|
9616
9714
|
templateQuasis.push(templateElement(currentQuasi, false));
|
|
9617
|
-
templateExpressions.push(child.value);
|
|
9715
|
+
templateExpressions.push(callRuntime("_to_text", child.value));
|
|
9618
9716
|
currentQuasi = "";
|
|
9619
9717
|
}
|
|
9620
9718
|
}
|
|
@@ -9700,7 +9798,7 @@ var html_comment_default = {
|
|
|
9700
9798
|
if (import_compiler43.types.isMarkoText(child)) {
|
|
9701
9799
|
write`${child.value}`;
|
|
9702
9800
|
} else if (import_compiler43.types.isMarkoPlaceholder(child)) {
|
|
9703
|
-
write`${callRuntime("
|
|
9801
|
+
write`${callRuntime("_to_text", child.value)}`;
|
|
9704
9802
|
}
|
|
9705
9803
|
}
|
|
9706
9804
|
} else {
|
|
@@ -11520,7 +11618,7 @@ var textarea_default = {
|
|
|
11520
11618
|
tag.node.attributes.push(
|
|
11521
11619
|
import_compiler56.types.markoAttribute(
|
|
11522
11620
|
"value",
|
|
11523
|
-
normalizeStringExpression(parts) ||
|
|
11621
|
+
normalizeStringExpression(parts) || buildUndefined3()
|
|
11524
11622
|
)
|
|
11525
11623
|
);
|
|
11526
11624
|
tag.node.body.body = [];
|
|
@@ -11531,35 +11629,359 @@ var textarea_default = {
|
|
|
11531
11629
|
preserveWhitespace: true
|
|
11532
11630
|
}
|
|
11533
11631
|
};
|
|
11534
|
-
function
|
|
11632
|
+
function buildUndefined3() {
|
|
11535
11633
|
return import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0));
|
|
11536
11634
|
}
|
|
11537
11635
|
|
|
11538
|
-
// src/translator/core/
|
|
11636
|
+
// src/translator/core/title.ts
|
|
11539
11637
|
var import_compiler57 = require("@marko/compiler");
|
|
11540
11638
|
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
11541
|
-
var
|
|
11542
|
-
var
|
|
11543
|
-
var try_default = {
|
|
11639
|
+
var kNodeBinding4 = Symbol("title tag node binding");
|
|
11640
|
+
var title_default = {
|
|
11544
11641
|
analyze(tag) {
|
|
11545
|
-
(0, import_babel_utils46.assertNoVar)(tag);
|
|
11546
11642
|
(0, import_babel_utils46.assertNoArgs)(tag);
|
|
11547
11643
|
(0, import_babel_utils46.assertNoParams)(tag);
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11644
|
+
const { node } = tag;
|
|
11645
|
+
if (node.var && !import_compiler57.types.isIdentifier(node.var)) {
|
|
11646
|
+
throw tag.get("var").buildCodeFrameError(
|
|
11647
|
+
"Tag variables on native elements cannot be destructured."
|
|
11648
|
+
);
|
|
11649
|
+
}
|
|
11650
|
+
const seen = {};
|
|
11651
|
+
const { attributes } = tag.node;
|
|
11652
|
+
let spreadReferenceNodes;
|
|
11653
|
+
let exprExtras;
|
|
11654
|
+
let hasEventHandlers = false;
|
|
11655
|
+
let hasDynamicAttributes = false;
|
|
11656
|
+
for (let i = attributes.length; i--; ) {
|
|
11657
|
+
const attr = attributes[i];
|
|
11658
|
+
const valueExtra = attr.value.extra ??= {};
|
|
11659
|
+
if (import_compiler57.types.isMarkoAttribute(attr)) {
|
|
11660
|
+
if (seen[attr.name]) {
|
|
11661
|
+
dropReferences(attr.value);
|
|
11662
|
+
continue;
|
|
11663
|
+
}
|
|
11664
|
+
seen[attr.name] = attr;
|
|
11665
|
+
if (isEventHandler(attr.name)) {
|
|
11666
|
+
valueExtra.isEffect = true;
|
|
11667
|
+
hasEventHandlers = true;
|
|
11668
|
+
} else if (!evaluate(attr.value).confident) {
|
|
11669
|
+
hasDynamicAttributes = true;
|
|
11670
|
+
}
|
|
11671
|
+
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11672
|
+
valueExtra.isEffect = true;
|
|
11673
|
+
hasEventHandlers = true;
|
|
11674
|
+
hasDynamicAttributes = true;
|
|
11675
|
+
}
|
|
11676
|
+
if (spreadReferenceNodes) {
|
|
11677
|
+
spreadReferenceNodes.push(attr.value);
|
|
11678
|
+
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11679
|
+
spreadReferenceNodes = [attr.value];
|
|
11680
|
+
} else {
|
|
11681
|
+
exprExtras = push(exprExtras, valueExtra);
|
|
11682
|
+
}
|
|
11683
|
+
}
|
|
11684
|
+
const bodyPlaceholderNodes = [];
|
|
11685
|
+
let hasBodyPlaceholders = false;
|
|
11686
|
+
for (const child of tag.node.body.body) {
|
|
11687
|
+
if (import_compiler57.types.isMarkoPlaceholder(child)) {
|
|
11688
|
+
bodyPlaceholderNodes.push(child.value);
|
|
11689
|
+
hasBodyPlaceholders = true;
|
|
11690
|
+
} else if (!import_compiler57.types.isMarkoText(child)) {
|
|
11691
|
+
throw tag.hub.buildError(
|
|
11692
|
+
child,
|
|
11693
|
+
"Invalid child. Only text is allowed inside a `<title>`."
|
|
11694
|
+
);
|
|
11695
|
+
}
|
|
11696
|
+
}
|
|
11697
|
+
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
11698
|
+
const tagExtra = node.extra ??= {};
|
|
11699
|
+
const tagSection = getOrCreateSection(tag);
|
|
11700
|
+
const nodeBinding = tagExtra[kNodeBinding4] = createBinding(
|
|
11701
|
+
"#title",
|
|
11702
|
+
0 /* dom */,
|
|
11703
|
+
tagSection
|
|
11704
|
+
);
|
|
11705
|
+
if (hasEventHandlers) {
|
|
11706
|
+
(0, import_babel_utils46.getProgram)().node.extra.isInteractive = true;
|
|
11707
|
+
}
|
|
11708
|
+
if (spreadReferenceNodes) {
|
|
11709
|
+
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
11710
|
+
}
|
|
11711
|
+
if (hasBodyPlaceholders) {
|
|
11712
|
+
exprExtras = push(
|
|
11713
|
+
exprExtras,
|
|
11714
|
+
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
11715
|
+
tagSection,
|
|
11716
|
+
bodyPlaceholderNodes[0],
|
|
11717
|
+
bodyPlaceholderNodes.slice(1)
|
|
11718
|
+
)
|
|
11719
|
+
);
|
|
11720
|
+
}
|
|
11721
|
+
trackDomVarReferences(tag, nodeBinding);
|
|
11722
|
+
addSerializeExpr(
|
|
11723
|
+
tagSection,
|
|
11724
|
+
!!(node.var || hasEventHandlers),
|
|
11725
|
+
nodeBinding
|
|
11726
|
+
);
|
|
11727
|
+
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
11728
|
+
}
|
|
11729
|
+
},
|
|
11730
|
+
translate: {
|
|
11731
|
+
enter(tag) {
|
|
11732
|
+
const tagExtra = tag.node.extra;
|
|
11733
|
+
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11734
|
+
const isHTML = isOutputHTML();
|
|
11735
|
+
const write = writeTo(tag);
|
|
11736
|
+
const tagSection = getSection(tag);
|
|
11737
|
+
if (isHTML) {
|
|
11738
|
+
translateDomVar(tag, nodeBinding);
|
|
11739
|
+
}
|
|
11740
|
+
if (nodeBinding) {
|
|
11741
|
+
visit(tag, 32 /* Get */);
|
|
11742
|
+
}
|
|
11743
|
+
write`<title`;
|
|
11744
|
+
const usedAttrs = getUsedAttrs4(tag.node);
|
|
11745
|
+
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
11746
|
+
for (const attr of staticAttrs) {
|
|
11747
|
+
const { name: name2, value } = attr;
|
|
11748
|
+
const { confident, computed } = value.extra || {};
|
|
11749
|
+
const valueReferences = value.extra?.referencedBindings;
|
|
11750
|
+
switch (name2) {
|
|
11751
|
+
case "class":
|
|
11752
|
+
case "style": {
|
|
11753
|
+
const helper = `_attr_${name2}`;
|
|
11754
|
+
if (confident) {
|
|
11755
|
+
write`${getHTMLRuntime()[helper](computed)}`;
|
|
11756
|
+
} else if (isHTML) {
|
|
11757
|
+
write`${callRuntime(helper, value)}`;
|
|
11758
|
+
} else {
|
|
11759
|
+
addStatement(
|
|
11760
|
+
"render",
|
|
11761
|
+
tagSection,
|
|
11762
|
+
valueReferences,
|
|
11763
|
+
import_compiler57.types.expressionStatement(
|
|
11764
|
+
callRuntime(
|
|
11765
|
+
helper,
|
|
11766
|
+
createScopeReadExpression(nodeBinding),
|
|
11767
|
+
value
|
|
11768
|
+
)
|
|
11769
|
+
)
|
|
11770
|
+
);
|
|
11771
|
+
}
|
|
11772
|
+
break;
|
|
11773
|
+
}
|
|
11774
|
+
default:
|
|
11775
|
+
if (confident) {
|
|
11776
|
+
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
11777
|
+
} else if (isHTML) {
|
|
11778
|
+
if (isEventHandler(name2)) {
|
|
11779
|
+
addHTMLEffectCall(tagSection, valueReferences);
|
|
11780
|
+
} else {
|
|
11781
|
+
write`${callRuntime("_attr", import_compiler57.types.stringLiteral(name2), value)}`;
|
|
11782
|
+
}
|
|
11783
|
+
} else if (isEventHandler(name2)) {
|
|
11784
|
+
addStatement(
|
|
11785
|
+
"effect",
|
|
11786
|
+
tagSection,
|
|
11787
|
+
valueReferences,
|
|
11788
|
+
import_compiler57.types.expressionStatement(
|
|
11789
|
+
callRuntime(
|
|
11790
|
+
"_on",
|
|
11791
|
+
createScopeReadExpression(nodeBinding),
|
|
11792
|
+
import_compiler57.types.stringLiteral(getEventHandlerName(name2)),
|
|
11793
|
+
value
|
|
11794
|
+
)
|
|
11795
|
+
)
|
|
11796
|
+
);
|
|
11797
|
+
} else {
|
|
11798
|
+
addStatement(
|
|
11799
|
+
"render",
|
|
11800
|
+
tagSection,
|
|
11801
|
+
valueReferences,
|
|
11802
|
+
import_compiler57.types.expressionStatement(
|
|
11803
|
+
callRuntime(
|
|
11804
|
+
"_attr",
|
|
11805
|
+
createScopeReadExpression(nodeBinding),
|
|
11806
|
+
import_compiler57.types.stringLiteral(name2),
|
|
11807
|
+
value
|
|
11808
|
+
)
|
|
11809
|
+
)
|
|
11810
|
+
);
|
|
11811
|
+
}
|
|
11812
|
+
break;
|
|
11813
|
+
}
|
|
11814
|
+
}
|
|
11815
|
+
if (spreadExpression) {
|
|
11816
|
+
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
|
11817
|
+
if (isHTML) {
|
|
11818
|
+
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
11819
|
+
if (skipExpression) {
|
|
11820
|
+
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11821
|
+
} else {
|
|
11822
|
+
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11823
|
+
}
|
|
11824
|
+
} else {
|
|
11825
|
+
if (skipExpression) {
|
|
11826
|
+
addStatement(
|
|
11827
|
+
"render",
|
|
11828
|
+
tagSection,
|
|
11829
|
+
tagExtra.referencedBindings,
|
|
11830
|
+
import_compiler57.types.expressionStatement(
|
|
11831
|
+
callRuntime(
|
|
11832
|
+
"_attrs_partial",
|
|
11833
|
+
scopeIdentifier,
|
|
11834
|
+
visitAccessor,
|
|
11835
|
+
spreadExpression,
|
|
11836
|
+
skipExpression
|
|
11837
|
+
)
|
|
11838
|
+
)
|
|
11839
|
+
);
|
|
11840
|
+
} else {
|
|
11841
|
+
addStatement(
|
|
11842
|
+
"render",
|
|
11843
|
+
tagSection,
|
|
11844
|
+
tagExtra.referencedBindings,
|
|
11845
|
+
import_compiler57.types.expressionStatement(
|
|
11846
|
+
callRuntime(
|
|
11847
|
+
"_attrs",
|
|
11848
|
+
scopeIdentifier,
|
|
11849
|
+
visitAccessor,
|
|
11850
|
+
spreadExpression
|
|
11851
|
+
)
|
|
11852
|
+
)
|
|
11853
|
+
);
|
|
11854
|
+
}
|
|
11855
|
+
addStatement(
|
|
11856
|
+
"effect",
|
|
11857
|
+
tagSection,
|
|
11858
|
+
tagExtra.referencedBindings,
|
|
11859
|
+
import_compiler57.types.expressionStatement(
|
|
11860
|
+
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
11861
|
+
),
|
|
11862
|
+
false
|
|
11863
|
+
);
|
|
11864
|
+
}
|
|
11865
|
+
}
|
|
11866
|
+
write`>`;
|
|
11867
|
+
enter2(tag);
|
|
11868
|
+
},
|
|
11869
|
+
exit(tag) {
|
|
11870
|
+
const tagSection = getSection(tag);
|
|
11871
|
+
const tagExtra = tag.node.extra;
|
|
11872
|
+
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11873
|
+
const write = writeTo(tag);
|
|
11874
|
+
if (isOutputHTML()) {
|
|
11875
|
+
for (const child of tag.node.body.body) {
|
|
11876
|
+
if (import_compiler57.types.isMarkoText(child)) {
|
|
11877
|
+
write`${child.value}`;
|
|
11878
|
+
} else if (import_compiler57.types.isMarkoPlaceholder(child)) {
|
|
11879
|
+
write`${callRuntime("_to_text", child.value)}`;
|
|
11880
|
+
}
|
|
11881
|
+
}
|
|
11882
|
+
} else {
|
|
11883
|
+
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
11884
|
+
if (import_compiler57.types.isStringLiteral(textLiteral)) {
|
|
11885
|
+
write`${textLiteral}`;
|
|
11886
|
+
} else {
|
|
11887
|
+
addStatement(
|
|
11888
|
+
"render",
|
|
11889
|
+
getSection(tag),
|
|
11890
|
+
textLiteral.extra?.referencedBindings,
|
|
11891
|
+
import_compiler57.types.expressionStatement(
|
|
11892
|
+
callRuntime(
|
|
11893
|
+
"_text_content",
|
|
11894
|
+
createScopeReadExpression(nodeBinding),
|
|
11895
|
+
textLiteral
|
|
11896
|
+
)
|
|
11897
|
+
)
|
|
11898
|
+
);
|
|
11899
|
+
}
|
|
11900
|
+
}
|
|
11901
|
+
write`</title>`;
|
|
11902
|
+
if (nodeBinding) {
|
|
11903
|
+
markNode(
|
|
11904
|
+
tag,
|
|
11905
|
+
nodeBinding,
|
|
11906
|
+
getSerializeReason(tagSection, nodeBinding)
|
|
11907
|
+
);
|
|
11908
|
+
}
|
|
11909
|
+
exit2(tag);
|
|
11910
|
+
tag.remove();
|
|
11911
|
+
}
|
|
11912
|
+
},
|
|
11913
|
+
parseOptions: {
|
|
11914
|
+
text: true
|
|
11915
|
+
}
|
|
11916
|
+
};
|
|
11917
|
+
function getUsedAttrs4(tag) {
|
|
11918
|
+
const seen = {};
|
|
11919
|
+
const { attributes } = tag;
|
|
11920
|
+
const maybeStaticAttrs = /* @__PURE__ */ new Set();
|
|
11921
|
+
let spreadExpression;
|
|
11922
|
+
let skipExpression;
|
|
11923
|
+
let spreadProps;
|
|
11924
|
+
let skipProps;
|
|
11925
|
+
for (let i = attributes.length; i--; ) {
|
|
11926
|
+
const attr = attributes[i];
|
|
11927
|
+
const { value } = attr;
|
|
11928
|
+
if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11929
|
+
if (!spreadProps) {
|
|
11930
|
+
spreadProps = [];
|
|
11931
|
+
}
|
|
11932
|
+
spreadProps.push(import_compiler57.types.spreadElement(value));
|
|
11933
|
+
} else if (!seen[attr.name]) {
|
|
11934
|
+
seen[attr.name] = attr;
|
|
11935
|
+
if (spreadProps) {
|
|
11936
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
11937
|
+
} else {
|
|
11938
|
+
maybeStaticAttrs.add(attr);
|
|
11939
|
+
}
|
|
11940
|
+
}
|
|
11941
|
+
}
|
|
11942
|
+
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
11943
|
+
if (spreadProps) {
|
|
11944
|
+
spreadProps.reverse();
|
|
11945
|
+
for (const { name: name2 } of staticAttrs) {
|
|
11946
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler57.types.numericLiteral(1)));
|
|
11947
|
+
}
|
|
11948
|
+
if (skipProps) {
|
|
11949
|
+
skipExpression = import_compiler57.types.objectExpression(skipProps);
|
|
11950
|
+
}
|
|
11951
|
+
spreadExpression = propsToExpression(spreadProps);
|
|
11952
|
+
}
|
|
11953
|
+
return {
|
|
11954
|
+
staticAttrs,
|
|
11955
|
+
spreadExpression,
|
|
11956
|
+
skipExpression
|
|
11957
|
+
};
|
|
11958
|
+
}
|
|
11959
|
+
|
|
11960
|
+
// src/translator/core/try.ts
|
|
11961
|
+
var import_compiler58 = require("@marko/compiler");
|
|
11962
|
+
var import_babel_utils47 = require("@marko/compiler/babel-utils");
|
|
11963
|
+
var hasEnabledCatch = /* @__PURE__ */ new WeakSet();
|
|
11964
|
+
var kDOMBinding2 = Symbol("try tag dom binding");
|
|
11965
|
+
var try_default = {
|
|
11966
|
+
analyze(tag) {
|
|
11967
|
+
(0, import_babel_utils47.assertNoVar)(tag);
|
|
11968
|
+
(0, import_babel_utils47.assertNoArgs)(tag);
|
|
11969
|
+
(0, import_babel_utils47.assertNoParams)(tag);
|
|
11970
|
+
(0, import_babel_utils47.assertNoAttributes)(tag);
|
|
11971
|
+
assertNoSpreadAttrs(tag);
|
|
11972
|
+
analyzeAttributeTags(tag);
|
|
11973
|
+
const section = getOrCreateSection(tag);
|
|
11974
|
+
const tagExtra = mergeReferences(
|
|
11975
|
+
section,
|
|
11976
|
+
tag.node,
|
|
11977
|
+
getAllTagReferenceNodes(tag.node)
|
|
11978
|
+
);
|
|
11979
|
+
tagExtra[kDOMBinding2] = createBinding("#text", 0 /* dom */, section);
|
|
11980
|
+
if (!tag.node.body.body.length) {
|
|
11981
|
+
throw tag.get("name").buildCodeFrameError(
|
|
11982
|
+
"The [`<try>` tag](https://markojs.com/docs/reference/core-tag#try) requires [body content](https://markojs.com/docs/reference/language#tag-content)."
|
|
11983
|
+
);
|
|
11984
|
+
}
|
|
11563
11985
|
const bodySection = startSection(tag.get("body"));
|
|
11564
11986
|
if (bodySection) {
|
|
11565
11987
|
bodySection.upstreamExpression = tagExtra;
|
|
@@ -11597,7 +12019,7 @@ var try_default = {
|
|
|
11597
12019
|
writeHTMLResumeStatements(tagBody);
|
|
11598
12020
|
tag.insertBefore(translatedAttrs.statements);
|
|
11599
12021
|
tag.replaceWith(
|
|
11600
|
-
|
|
12022
|
+
import_compiler58.types.expressionStatement(
|
|
11601
12023
|
callRuntime(
|
|
11602
12024
|
"_try",
|
|
11603
12025
|
getScopeIdIdentifier(section),
|
|
@@ -11652,11 +12074,11 @@ var try_default = {
|
|
|
11652
12074
|
translatedAttrs.statements
|
|
11653
12075
|
);
|
|
11654
12076
|
}
|
|
11655
|
-
const program = (0,
|
|
12077
|
+
const program = (0, import_babel_utils47.getProgram)().node;
|
|
11656
12078
|
if (!hasEnabledCatch.has(program)) {
|
|
11657
12079
|
hasEnabledCatch.add(program);
|
|
11658
12080
|
program.body.push(
|
|
11659
|
-
|
|
12081
|
+
import_compiler58.types.expressionStatement(callRuntime("_enable_catch"))
|
|
11660
12082
|
);
|
|
11661
12083
|
}
|
|
11662
12084
|
addValue(
|
|
@@ -11708,6 +12130,7 @@ var core_default = {
|
|
|
11708
12130
|
"<static>": static_default,
|
|
11709
12131
|
"<style>": style_default,
|
|
11710
12132
|
"<textarea>": textarea_default,
|
|
12133
|
+
"<title>": title_default,
|
|
11711
12134
|
"<try>": try_default
|
|
11712
12135
|
};
|
|
11713
12136
|
|
|
@@ -11755,13 +12178,13 @@ var document_type_default = {
|
|
|
11755
12178
|
};
|
|
11756
12179
|
|
|
11757
12180
|
// src/translator/visitors/import-declaration.ts
|
|
11758
|
-
var
|
|
12181
|
+
var import_babel_utils48 = require("@marko/compiler/babel-utils");
|
|
11759
12182
|
var import_declaration_default = {
|
|
11760
12183
|
analyze(importDecl) {
|
|
11761
12184
|
const { node } = importDecl;
|
|
11762
12185
|
const { source } = node;
|
|
11763
12186
|
const { value } = source;
|
|
11764
|
-
const tagImport = (0,
|
|
12187
|
+
const tagImport = (0, import_babel_utils48.resolveTagImport)(importDecl, value);
|
|
11765
12188
|
if (tagImport) {
|
|
11766
12189
|
node.extra ??= {};
|
|
11767
12190
|
node.extra.tagImport = tagImport;
|
|
@@ -11784,10 +12207,10 @@ var import_declaration_default = {
|
|
|
11784
12207
|
};
|
|
11785
12208
|
|
|
11786
12209
|
// src/translator/visitors/placeholder.ts
|
|
11787
|
-
var
|
|
12210
|
+
var import_compiler60 = require("@marko/compiler");
|
|
11788
12211
|
|
|
11789
12212
|
// src/translator/util/is-non-html-text.ts
|
|
11790
|
-
var
|
|
12213
|
+
var import_compiler59 = require("@marko/compiler");
|
|
11791
12214
|
function isNonHTMLText(placeholder) {
|
|
11792
12215
|
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
11793
12216
|
if (parentTag && isCoreTag(parentTag)) {
|
|
@@ -11795,6 +12218,7 @@ function isNonHTMLText(placeholder) {
|
|
|
11795
12218
|
case "html-comment":
|
|
11796
12219
|
case "html-script":
|
|
11797
12220
|
case "html-style":
|
|
12221
|
+
case "title":
|
|
11798
12222
|
return true;
|
|
11799
12223
|
}
|
|
11800
12224
|
}
|
|
@@ -11802,7 +12226,7 @@ function isNonHTMLText(placeholder) {
|
|
|
11802
12226
|
}
|
|
11803
12227
|
|
|
11804
12228
|
// src/translator/visitors/placeholder.ts
|
|
11805
|
-
var
|
|
12229
|
+
var kNodeBinding5 = Symbol("placeholder node binding");
|
|
11806
12230
|
var kSiblingText = Symbol("placeholder has sibling text");
|
|
11807
12231
|
var kSharedText = Symbol(
|
|
11808
12232
|
"placeholder will merge its visitor with a another node"
|
|
@@ -11820,7 +12244,7 @@ var placeholder_default = {
|
|
|
11820
12244
|
}
|
|
11821
12245
|
} else {
|
|
11822
12246
|
const section = getOrCreateSection(placeholder);
|
|
11823
|
-
const nodeBinding = (node.extra ??= {})[
|
|
12247
|
+
const nodeBinding = (node.extra ??= {})[kNodeBinding5] = createBinding(
|
|
11824
12248
|
"#text",
|
|
11825
12249
|
0 /* dom */,
|
|
11826
12250
|
section
|
|
@@ -11843,7 +12267,7 @@ var placeholder_default = {
|
|
|
11843
12267
|
const isHTML = isOutputHTML();
|
|
11844
12268
|
const write = writeTo(placeholder);
|
|
11845
12269
|
const extra = node.extra || {};
|
|
11846
|
-
const nodeBinding = extra[
|
|
12270
|
+
const nodeBinding = extra[kNodeBinding5];
|
|
11847
12271
|
const canWriteHTML = isHTML || confident && node.escape;
|
|
11848
12272
|
const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
|
|
11849
12273
|
if (confident && canWriteHTML) {
|
|
@@ -11877,7 +12301,7 @@ var placeholder_default = {
|
|
|
11877
12301
|
"render",
|
|
11878
12302
|
getSection(placeholder),
|
|
11879
12303
|
valueExtra.referencedBindings,
|
|
11880
|
-
|
|
12304
|
+
import_compiler60.types.expressionStatement(
|
|
11881
12305
|
method === "_text" ? callRuntime(
|
|
11882
12306
|
"_text",
|
|
11883
12307
|
createScopeReadExpression(nodeBinding),
|
|
@@ -11915,7 +12339,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
11915
12339
|
break;
|
|
11916
12340
|
}
|
|
11917
12341
|
}
|
|
11918
|
-
if (!prev.node &&
|
|
12342
|
+
if (!prev.node && import_compiler60.types.isProgram(placeholder.parentPath)) {
|
|
11919
12343
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
|
11920
12344
|
}
|
|
11921
12345
|
let next = placeholder.getNextSibling();
|
|
@@ -11932,7 +12356,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
11932
12356
|
break;
|
|
11933
12357
|
}
|
|
11934
12358
|
}
|
|
11935
|
-
if (!next.node &&
|
|
12359
|
+
if (!next.node && import_compiler60.types.isProgram(placeholder.parentPath)) {
|
|
11936
12360
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
|
11937
12361
|
}
|
|
11938
12362
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
|
@@ -11974,7 +12398,7 @@ function isEmptyPlaceholder(placeholder) {
|
|
|
11974
12398
|
}
|
|
11975
12399
|
|
|
11976
12400
|
// src/translator/visitors/referenced-identifier.ts
|
|
11977
|
-
var
|
|
12401
|
+
var import_compiler61 = require("@marko/compiler");
|
|
11978
12402
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
|
11979
12403
|
var referenced_identifier_default = {
|
|
11980
12404
|
migrate(identifier) {
|
|
@@ -11982,8 +12406,8 @@ var referenced_identifier_default = {
|
|
|
11982
12406
|
if (identifier.scope.hasBinding(name2)) return;
|
|
11983
12407
|
switch (name2) {
|
|
11984
12408
|
case "out":
|
|
11985
|
-
if (
|
|
11986
|
-
identifier.parentPath.replaceWith(
|
|
12409
|
+
if (import_compiler61.types.isMemberExpression(identifier.parent) && import_compiler61.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
|
12410
|
+
identifier.parentPath.replaceWith(import_compiler61.types.identifier("$global"));
|
|
11987
12411
|
} else {
|
|
11988
12412
|
throw identifier.buildCodeFrameError(
|
|
11989
12413
|
"Only `out.global` is supported for compatibility."
|
|
@@ -12010,13 +12434,13 @@ var referenced_identifier_default = {
|
|
|
12010
12434
|
case "$global":
|
|
12011
12435
|
if (isOutputHTML()) {
|
|
12012
12436
|
identifier.replaceWith(
|
|
12013
|
-
|
|
12437
|
+
import_compiler61.types.callExpression(importRuntime("$global"), [])
|
|
12014
12438
|
);
|
|
12015
12439
|
} else {
|
|
12016
12440
|
identifier.replaceWith(
|
|
12017
|
-
|
|
12441
|
+
import_compiler61.types.memberExpression(
|
|
12018
12442
|
scopeIdentifier,
|
|
12019
|
-
|
|
12443
|
+
import_compiler61.types.identifier(getAccessorProp().Global)
|
|
12020
12444
|
)
|
|
12021
12445
|
);
|
|
12022
12446
|
}
|
|
@@ -12024,13 +12448,13 @@ var referenced_identifier_default = {
|
|
|
12024
12448
|
case "$signal":
|
|
12025
12449
|
if (isOutputHTML()) {
|
|
12026
12450
|
identifier.replaceWith(
|
|
12027
|
-
|
|
12028
|
-
|
|
12451
|
+
import_compiler61.types.callExpression(
|
|
12452
|
+
import_compiler61.types.arrowFunctionExpression(
|
|
12029
12453
|
[],
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12454
|
+
import_compiler61.types.blockStatement([
|
|
12455
|
+
import_compiler61.types.throwStatement(
|
|
12456
|
+
import_compiler61.types.newExpression(import_compiler61.types.identifier("Error"), [
|
|
12457
|
+
import_compiler61.types.stringLiteral("Cannot use $signal in a server render.")
|
|
12034
12458
|
])
|
|
12035
12459
|
)
|
|
12036
12460
|
])
|
|
@@ -12056,19 +12480,19 @@ var referenced_identifier_default = {
|
|
|
12056
12480
|
"render",
|
|
12057
12481
|
section,
|
|
12058
12482
|
exprRoot.node.extra?.referencedBindings,
|
|
12059
|
-
|
|
12060
|
-
|
|
12483
|
+
import_compiler61.types.expressionStatement(
|
|
12484
|
+
import_compiler61.types.callExpression(importRuntime("$signalReset"), [
|
|
12061
12485
|
scopeIdentifier,
|
|
12062
|
-
|
|
12486
|
+
import_compiler61.types.numericLiteral(exprId)
|
|
12063
12487
|
])
|
|
12064
12488
|
),
|
|
12065
12489
|
false
|
|
12066
12490
|
);
|
|
12067
12491
|
}
|
|
12068
12492
|
identifier.replaceWith(
|
|
12069
|
-
|
|
12493
|
+
import_compiler61.types.callExpression(importRuntime("$signal"), [
|
|
12070
12494
|
scopeIdentifier,
|
|
12071
|
-
|
|
12495
|
+
import_compiler61.types.numericLiteral(exprId)
|
|
12072
12496
|
])
|
|
12073
12497
|
);
|
|
12074
12498
|
}
|
|
@@ -12077,7 +12501,7 @@ var referenced_identifier_default = {
|
|
|
12077
12501
|
};
|
|
12078
12502
|
|
|
12079
12503
|
// src/translator/visitors/scriptlet.ts
|
|
12080
|
-
var
|
|
12504
|
+
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
12081
12505
|
var scriptlet_default = {
|
|
12082
12506
|
analyze(scriptlet) {
|
|
12083
12507
|
if (!scriptlet.node.static) {
|
|
@@ -12091,7 +12515,7 @@ var scriptlet_default = {
|
|
|
12091
12515
|
scriptlet.node.body
|
|
12092
12516
|
);
|
|
12093
12517
|
if (scriptlet.node.target === "client") {
|
|
12094
|
-
(0,
|
|
12518
|
+
(0, import_babel_utils49.getProgram)().node.extra.isInteractive = true;
|
|
12095
12519
|
}
|
|
12096
12520
|
},
|
|
12097
12521
|
translate: {
|
|
@@ -12112,21 +12536,21 @@ var scriptlet_default = {
|
|
|
12112
12536
|
};
|
|
12113
12537
|
|
|
12114
12538
|
// src/translator/visitors/tag/index.ts
|
|
12115
|
-
var
|
|
12116
|
-
var
|
|
12539
|
+
var import_compiler65 = require("@marko/compiler");
|
|
12540
|
+
var import_babel_utils53 = require("@marko/compiler/babel-utils");
|
|
12117
12541
|
|
|
12118
12542
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
12119
|
-
var
|
|
12120
|
-
var
|
|
12543
|
+
var import_compiler62 = require("@marko/compiler");
|
|
12544
|
+
var import_babel_utils50 = require("@marko/compiler/babel-utils");
|
|
12121
12545
|
var attribute_tag_default = {
|
|
12122
12546
|
analyze: {
|
|
12123
12547
|
enter(tag) {
|
|
12124
|
-
(0,
|
|
12125
|
-
(0,
|
|
12548
|
+
(0, import_babel_utils50.assertNoVar)(tag);
|
|
12549
|
+
(0, import_babel_utils50.assertNoArgs)(tag);
|
|
12126
12550
|
const body = tag.get("body");
|
|
12127
12551
|
startSection(body);
|
|
12128
12552
|
trackParamsReferences(body, 3 /* param */);
|
|
12129
|
-
if (!(0,
|
|
12553
|
+
if (!(0, import_babel_utils50.findParentTag)(tag)) {
|
|
12130
12554
|
throw tag.get("name").buildCodeFrameError(
|
|
12131
12555
|
"[Attribute tags](https://markojs.com/docs/reference/language#attribute-tags) must be nested within another tag."
|
|
12132
12556
|
);
|
|
@@ -12149,13 +12573,13 @@ var attribute_tag_default = {
|
|
|
12149
12573
|
};
|
|
12150
12574
|
|
|
12151
12575
|
// src/translator/visitors/tag/custom-tag.ts
|
|
12152
|
-
var
|
|
12153
|
-
var
|
|
12576
|
+
var import_compiler63 = require("@marko/compiler");
|
|
12577
|
+
var import_babel_utils51 = require("@marko/compiler/babel-utils");
|
|
12154
12578
|
var import_path4 = __toESM(require("path"));
|
|
12155
12579
|
var custom_tag_default = {
|
|
12156
12580
|
analyze: {
|
|
12157
12581
|
enter(tag) {
|
|
12158
|
-
const templateFile = (0,
|
|
12582
|
+
const templateFile = (0, import_babel_utils51.getTagTemplate)(tag);
|
|
12159
12583
|
if (!templateFile) {
|
|
12160
12584
|
const tagName = getTagName(tag);
|
|
12161
12585
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
|
@@ -12167,12 +12591,12 @@ var custom_tag_default = {
|
|
|
12167
12591
|
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
|
12168
12592
|
);
|
|
12169
12593
|
}
|
|
12170
|
-
(0,
|
|
12171
|
-
const childFile = (0,
|
|
12594
|
+
(0, import_babel_utils51.assertAttributesOrSingleArg)(tag);
|
|
12595
|
+
const childFile = (0, import_babel_utils51.loadFileForTag)(tag);
|
|
12172
12596
|
if (!childFile) {
|
|
12173
12597
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
|
12174
12598
|
}
|
|
12175
|
-
const programSection = (0,
|
|
12599
|
+
const programSection = (0, import_babel_utils51.getProgram)().node.extra.section;
|
|
12176
12600
|
const childProgram = childFile.ast.program;
|
|
12177
12601
|
const childExtra = childProgram.extra;
|
|
12178
12602
|
const childSection = childExtra.section;
|
|
@@ -12200,12 +12624,12 @@ var custom_tag_default = {
|
|
|
12200
12624
|
};
|
|
12201
12625
|
function translateHTML(tag) {
|
|
12202
12626
|
const { node } = tag;
|
|
12203
|
-
const childProgram = (0,
|
|
12627
|
+
const childProgram = (0, import_babel_utils51.loadFileForTag)(tag).ast.program;
|
|
12204
12628
|
const childExtra = childProgram.extra;
|
|
12205
12629
|
let tagIdentifier;
|
|
12206
|
-
if (
|
|
12630
|
+
if (import_compiler63.types.isStringLiteral(node.name)) {
|
|
12207
12631
|
const relativePath = getTagRelativePath(tag);
|
|
12208
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
|
12632
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler63.types.identifier(getTemplateContentName()) : (0, import_babel_utils51.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
|
12209
12633
|
} else {
|
|
12210
12634
|
tagIdentifier = node.name;
|
|
12211
12635
|
}
|
|
@@ -12221,12 +12645,12 @@ function translateDOM(tag) {
|
|
|
12221
12645
|
const { file } = tag.hub;
|
|
12222
12646
|
const write = writeTo(tag);
|
|
12223
12647
|
const relativePath = getTagRelativePath(tag);
|
|
12224
|
-
const programSection = (0,
|
|
12225
|
-
const childFile = (0,
|
|
12648
|
+
const programSection = (0, import_babel_utils51.getProgram)().node.extra.section;
|
|
12649
|
+
const childFile = (0, import_babel_utils51.loadFileForTag)(tag);
|
|
12226
12650
|
const childExtra = childFile.ast.program.extra;
|
|
12227
12651
|
const childExports = childExtra.domExports;
|
|
12228
12652
|
const childSection = childExtra.section;
|
|
12229
|
-
const tagName =
|
|
12653
|
+
const tagName = import_compiler63.types.isIdentifier(node.name) ? node.name.name : import_compiler63.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
12230
12654
|
if (programSection === childSection) {
|
|
12231
12655
|
knownTagTranslateDOM(
|
|
12232
12656
|
tag,
|
|
@@ -12237,16 +12661,16 @@ function translateDOM(tag) {
|
|
|
12237
12661
|
"render",
|
|
12238
12662
|
section,
|
|
12239
12663
|
void 0,
|
|
12240
|
-
|
|
12241
|
-
|
|
12664
|
+
import_compiler63.types.expressionStatement(
|
|
12665
|
+
import_compiler63.types.callExpression(import_compiler63.types.identifier(childExports.setup), [
|
|
12242
12666
|
createScopeReadExpression(childBinding, section)
|
|
12243
12667
|
])
|
|
12244
12668
|
)
|
|
12245
12669
|
);
|
|
12246
12670
|
}
|
|
12247
12671
|
);
|
|
12248
|
-
write`${
|
|
12249
|
-
injectWalks(tag, tagName,
|
|
12672
|
+
write`${import_compiler63.types.identifier(childExports.template)}`;
|
|
12673
|
+
injectWalks(tag, tagName, import_compiler63.types.identifier(childExports.walks));
|
|
12250
12674
|
} else {
|
|
12251
12675
|
knownTagTranslateDOM(
|
|
12252
12676
|
tag,
|
|
@@ -12262,8 +12686,8 @@ function translateDOM(tag) {
|
|
|
12262
12686
|
"render",
|
|
12263
12687
|
section,
|
|
12264
12688
|
void 0,
|
|
12265
|
-
|
|
12266
|
-
|
|
12689
|
+
import_compiler63.types.expressionStatement(
|
|
12690
|
+
import_compiler63.types.callExpression(
|
|
12267
12691
|
importOrSelfReferenceName(
|
|
12268
12692
|
file,
|
|
12269
12693
|
relativePath,
|
|
@@ -12276,11 +12700,11 @@ function translateDOM(tag) {
|
|
|
12276
12700
|
);
|
|
12277
12701
|
}
|
|
12278
12702
|
);
|
|
12279
|
-
write`${(0,
|
|
12703
|
+
write`${(0, import_babel_utils51.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
12280
12704
|
injectWalks(
|
|
12281
12705
|
tag,
|
|
12282
12706
|
tagName,
|
|
12283
|
-
(0,
|
|
12707
|
+
(0, import_babel_utils51.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
|
12284
12708
|
);
|
|
12285
12709
|
}
|
|
12286
12710
|
tag.remove();
|
|
@@ -12291,9 +12715,9 @@ function getTagRelativePath(tag) {
|
|
|
12291
12715
|
hub: { file }
|
|
12292
12716
|
} = tag;
|
|
12293
12717
|
let relativePath;
|
|
12294
|
-
if (
|
|
12295
|
-
const template = (0,
|
|
12296
|
-
relativePath = template && (0,
|
|
12718
|
+
if (import_compiler63.types.isStringLiteral(node.name)) {
|
|
12719
|
+
const template = (0, import_babel_utils51.getTagTemplate)(tag);
|
|
12720
|
+
relativePath = template && (0, import_babel_utils51.resolveRelativePath)(file, template);
|
|
12297
12721
|
} else if (node.extra?.tagNameImported) {
|
|
12298
12722
|
relativePath = node.extra.tagNameImported;
|
|
12299
12723
|
}
|
|
@@ -12312,9 +12736,9 @@ function getTagRelativePath(tag) {
|
|
|
12312
12736
|
}
|
|
12313
12737
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
12314
12738
|
if (isCircularRequest(file, request)) {
|
|
12315
|
-
return
|
|
12739
|
+
return import_compiler63.types.identifier(name2);
|
|
12316
12740
|
}
|
|
12317
|
-
return (0,
|
|
12741
|
+
return (0, import_babel_utils51.importNamed)(file, request, name2, nameHint);
|
|
12318
12742
|
}
|
|
12319
12743
|
function isCircularRequest(file, request) {
|
|
12320
12744
|
const { filename } = file.opts;
|
|
@@ -12322,15 +12746,15 @@ function isCircularRequest(file, request) {
|
|
|
12322
12746
|
}
|
|
12323
12747
|
|
|
12324
12748
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
12325
|
-
var
|
|
12326
|
-
var
|
|
12749
|
+
var import_compiler64 = require("@marko/compiler");
|
|
12750
|
+
var import_babel_utils52 = require("@marko/compiler/babel-utils");
|
|
12327
12751
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
|
12328
12752
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
|
12329
12753
|
var importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
12330
12754
|
var dynamic_tag_default = {
|
|
12331
12755
|
analyze: {
|
|
12332
12756
|
enter(tag) {
|
|
12333
|
-
(0,
|
|
12757
|
+
(0, import_babel_utils52.assertAttributesOrArgs)(tag);
|
|
12334
12758
|
const { node } = tag;
|
|
12335
12759
|
const definedBodySection = node.extra?.defineBodySection;
|
|
12336
12760
|
if (definedBodySection) {
|
|
@@ -12355,9 +12779,9 @@ var dynamic_tag_default = {
|
|
|
12355
12779
|
tagSection
|
|
12356
12780
|
);
|
|
12357
12781
|
if (hasVar || tag.node.attributes.some(
|
|
12358
|
-
(attr) =>
|
|
12782
|
+
(attr) => import_compiler64.types.isMarkoSpreadAttribute(attr) || isEventOrChangeHandler(attr.name)
|
|
12359
12783
|
)) {
|
|
12360
|
-
(0,
|
|
12784
|
+
(0, import_babel_utils52.getProgram)().node.extra.isInteractive = true;
|
|
12361
12785
|
}
|
|
12362
12786
|
if (hasVar) {
|
|
12363
12787
|
trackVarReferences(tag, 5 /* derived */);
|
|
@@ -12395,7 +12819,7 @@ var dynamic_tag_default = {
|
|
|
12395
12819
|
if (isOutputHTML()) {
|
|
12396
12820
|
knownTagTranslateHTML(
|
|
12397
12821
|
tag,
|
|
12398
|
-
|
|
12822
|
+
import_compiler64.types.memberExpression(tag.node.name, import_compiler64.types.identifier("content")),
|
|
12399
12823
|
definedBodySection,
|
|
12400
12824
|
propTree
|
|
12401
12825
|
);
|
|
@@ -12412,9 +12836,9 @@ var dynamic_tag_default = {
|
|
|
12412
12836
|
"render",
|
|
12413
12837
|
section,
|
|
12414
12838
|
void 0,
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12839
|
+
import_compiler64.types.expressionStatement(
|
|
12840
|
+
import_compiler64.types.callExpression(
|
|
12841
|
+
import_compiler64.types.memberExpression(signal.identifier, import_compiler64.types.identifier("_")),
|
|
12418
12842
|
[
|
|
12419
12843
|
createScopeReadExpression(childBinding, section),
|
|
12420
12844
|
getScopeExpression(section, definedBodySection.parent)
|
|
@@ -12439,8 +12863,8 @@ var dynamic_tag_default = {
|
|
|
12439
12863
|
const nodeBinding = tagExtra[kDOMBinding3];
|
|
12440
12864
|
const isClassAPI = tagExtra.featureType === "class";
|
|
12441
12865
|
let tagExpression = node.name;
|
|
12442
|
-
if (
|
|
12443
|
-
tagExpression = (0,
|
|
12866
|
+
if (import_compiler64.types.isStringLiteral(tagExpression)) {
|
|
12867
|
+
tagExpression = (0, import_babel_utils52.importDefault)(
|
|
12444
12868
|
tag.hub.file,
|
|
12445
12869
|
getTagRelativePath(tag),
|
|
12446
12870
|
tagExpression.value
|
|
@@ -12448,15 +12872,15 @@ var dynamic_tag_default = {
|
|
|
12448
12872
|
}
|
|
12449
12873
|
if (isClassAPI) {
|
|
12450
12874
|
if (isOutputHTML()) {
|
|
12451
|
-
(0,
|
|
12452
|
-
|
|
12875
|
+
(0, import_babel_utils52.getProgram)().node.body.push(
|
|
12876
|
+
import_compiler64.types.markoScriptlet(
|
|
12453
12877
|
[
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
(0,
|
|
12878
|
+
import_compiler64.types.expressionStatement(
|
|
12879
|
+
import_compiler64.types.callExpression(
|
|
12880
|
+
(0, import_babel_utils52.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
12457
12881
|
[
|
|
12458
|
-
|
|
12459
|
-
|
|
12882
|
+
import_compiler64.types.identifier(tagExpression.name),
|
|
12883
|
+
import_compiler64.types.stringLiteral((0, import_babel_utils52.loadFileForTag)(tag).metadata.marko.id)
|
|
12460
12884
|
]
|
|
12461
12885
|
)
|
|
12462
12886
|
)
|
|
@@ -12465,12 +12889,12 @@ var dynamic_tag_default = {
|
|
|
12465
12889
|
)
|
|
12466
12890
|
);
|
|
12467
12891
|
} else {
|
|
12468
|
-
(0,
|
|
12469
|
-
|
|
12892
|
+
(0, import_babel_utils52.getProgram)().node.body.push(
|
|
12893
|
+
import_compiler64.types.expressionStatement(
|
|
12470
12894
|
callRuntime(
|
|
12471
12895
|
"_resume",
|
|
12472
|
-
|
|
12473
|
-
|
|
12896
|
+
import_compiler64.types.stringLiteral((0, import_babel_utils52.loadFileForTag)(tag).metadata.marko.id),
|
|
12897
|
+
import_compiler64.types.identifier(tagExpression.name)
|
|
12474
12898
|
)
|
|
12475
12899
|
)
|
|
12476
12900
|
);
|
|
@@ -12480,6 +12904,7 @@ var dynamic_tag_default = {
|
|
|
12480
12904
|
tag,
|
|
12481
12905
|
void 0,
|
|
12482
12906
|
void 0,
|
|
12907
|
+
void 0,
|
|
12483
12908
|
isClassAPI ? "renderBody" : "content"
|
|
12484
12909
|
);
|
|
12485
12910
|
const args = [];
|
|
@@ -12512,9 +12937,9 @@ var dynamic_tag_default = {
|
|
|
12512
12937
|
getScopeIdIdentifier(tagSection),
|
|
12513
12938
|
getScopeAccessorLiteral(nodeBinding),
|
|
12514
12939
|
tagExpression,
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12940
|
+
import_compiler64.types.arrayExpression(args),
|
|
12941
|
+
import_compiler64.types.numericLiteral(0),
|
|
12942
|
+
import_compiler64.types.numericLiteral(1),
|
|
12518
12943
|
serializeArg
|
|
12519
12944
|
) : callRuntime(
|
|
12520
12945
|
"_dynamic_tag",
|
|
@@ -12522,8 +12947,8 @@ var dynamic_tag_default = {
|
|
|
12522
12947
|
getScopeAccessorLiteral(nodeBinding),
|
|
12523
12948
|
tagExpression,
|
|
12524
12949
|
args[0],
|
|
12525
|
-
args[1] || (serializeArg ?
|
|
12526
|
-
serializeArg ?
|
|
12950
|
+
args[1] || (serializeArg ? import_compiler64.types.numericLiteral(0) : void 0),
|
|
12951
|
+
serializeArg ? import_compiler64.types.numericLiteral(0) : void 0,
|
|
12527
12952
|
serializeArg
|
|
12528
12953
|
);
|
|
12529
12954
|
if (node.var) {
|
|
@@ -12531,18 +12956,18 @@ var dynamic_tag_default = {
|
|
|
12531
12956
|
tag.get("name").toString() + "_scope"
|
|
12532
12957
|
);
|
|
12533
12958
|
statements.push(
|
|
12534
|
-
|
|
12535
|
-
|
|
12959
|
+
import_compiler64.types.variableDeclaration("const", [
|
|
12960
|
+
import_compiler64.types.variableDeclarator(
|
|
12536
12961
|
dynamicScopeIdentifier,
|
|
12537
12962
|
callRuntime("_peek_scope_id")
|
|
12538
12963
|
)
|
|
12539
12964
|
])
|
|
12540
12965
|
);
|
|
12541
12966
|
statements.push(
|
|
12542
|
-
|
|
12543
|
-
|
|
12967
|
+
import_compiler64.types.variableDeclaration("let", [
|
|
12968
|
+
import_compiler64.types.variableDeclarator(node.var, dynamicTagExpr)
|
|
12544
12969
|
]),
|
|
12545
|
-
|
|
12970
|
+
import_compiler64.types.expressionStatement(
|
|
12546
12971
|
callRuntime(
|
|
12547
12972
|
"_var",
|
|
12548
12973
|
getScopeIdIdentifier(tagSection),
|
|
@@ -12550,7 +12975,7 @@ var dynamic_tag_default = {
|
|
|
12550
12975
|
tag.node.extra[kChildOffsetScopeBinding2]
|
|
12551
12976
|
),
|
|
12552
12977
|
dynamicScopeIdentifier,
|
|
12553
|
-
|
|
12978
|
+
import_compiler64.types.stringLiteral(
|
|
12554
12979
|
getResumeRegisterId(
|
|
12555
12980
|
tagSection,
|
|
12556
12981
|
node.var.extra?.binding,
|
|
@@ -12562,7 +12987,7 @@ var dynamic_tag_default = {
|
|
|
12562
12987
|
)
|
|
12563
12988
|
);
|
|
12564
12989
|
} else {
|
|
12565
|
-
statements.push(
|
|
12990
|
+
statements.push(import_compiler64.types.expressionStatement(dynamicTagExpr));
|
|
12566
12991
|
}
|
|
12567
12992
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
12568
12993
|
replacement.skip();
|
|
@@ -12581,9 +13006,9 @@ var dynamic_tag_default = {
|
|
|
12581
13006
|
tagVarSignal.register = true;
|
|
12582
13007
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
|
12583
13008
|
const changeArgs = [
|
|
12584
|
-
|
|
13009
|
+
import_compiler64.types.memberExpression(
|
|
12585
13010
|
getScopeExpression(tagVarSignal.section, valueSection),
|
|
12586
|
-
|
|
13011
|
+
import_compiler64.types.stringLiteral(
|
|
12587
13012
|
getAccessorPrefix().BranchScopes + getScopeAccessor(nodeBinding)
|
|
12588
13013
|
),
|
|
12589
13014
|
true
|
|
@@ -12591,28 +13016,28 @@ var dynamic_tag_default = {
|
|
|
12591
13016
|
value
|
|
12592
13017
|
];
|
|
12593
13018
|
if (!isOptimize()) {
|
|
12594
|
-
changeArgs.push(
|
|
13019
|
+
changeArgs.push(import_compiler64.types.stringLiteral(varBinding.name));
|
|
12595
13020
|
}
|
|
12596
|
-
return
|
|
13021
|
+
return import_compiler64.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
12597
13022
|
};
|
|
12598
13023
|
}
|
|
12599
13024
|
signal.build = () => {
|
|
12600
13025
|
return callRuntime(
|
|
12601
13026
|
"_dynamic_tag",
|
|
12602
13027
|
getScopeAccessorLiteral(nodeBinding, true),
|
|
12603
|
-
bodySection &&
|
|
12604
|
-
tagVarSignal ?
|
|
12605
|
-
hasTagArgs &&
|
|
13028
|
+
bodySection && import_compiler64.types.identifier(bodySection.name),
|
|
13029
|
+
tagVarSignal ? import_compiler64.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
|
13030
|
+
hasTagArgs && import_compiler64.types.numericLiteral(1)
|
|
12606
13031
|
);
|
|
12607
13032
|
};
|
|
12608
13033
|
if (args.length) {
|
|
12609
|
-
const argsOrInput = hasTagArgs ?
|
|
12610
|
-
if (!
|
|
13034
|
+
const argsOrInput = hasTagArgs ? import_compiler64.types.arrayExpression(args) : args[0];
|
|
13035
|
+
if (!import_compiler64.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
|
12611
13036
|
signal.extraArgs = [
|
|
12612
|
-
|
|
13037
|
+
import_compiler64.types.arrowFunctionExpression(
|
|
12613
13038
|
[],
|
|
12614
|
-
statements.length ?
|
|
12615
|
-
statements.concat(
|
|
13039
|
+
statements.length ? import_compiler64.types.blockStatement(
|
|
13040
|
+
statements.concat(import_compiler64.types.returnStatement(argsOrInput))
|
|
12616
13041
|
) : argsOrInput
|
|
12617
13042
|
)
|
|
12618
13043
|
];
|
|
@@ -12626,13 +13051,13 @@ var dynamic_tag_default = {
|
|
|
12626
13051
|
}
|
|
12627
13052
|
};
|
|
12628
13053
|
function enableDynamicTagResume(tag) {
|
|
12629
|
-
const program = (0,
|
|
13054
|
+
const program = (0, import_babel_utils52.getProgram)().node;
|
|
12630
13055
|
if (!importedDynamicTagResume.has(program) && analyzeTagNameType(tag, true) !== 1 /* CustomTag */) {
|
|
12631
13056
|
for (const attr of tag.node.attributes) {
|
|
12632
13057
|
if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && isEventOrChangeHandler(attr.name)) {
|
|
12633
13058
|
importedDynamicTagResume.add(program);
|
|
12634
13059
|
program.body.push(
|
|
12635
|
-
|
|
13060
|
+
import_compiler64.types.expressionStatement(callRuntime("_resume_dynamic_tag"))
|
|
12636
13061
|
);
|
|
12637
13062
|
return;
|
|
12638
13063
|
}
|
|
@@ -12644,7 +13069,7 @@ function enableDynamicTagResume(tag) {
|
|
|
12644
13069
|
var tag_default = {
|
|
12645
13070
|
analyze: {
|
|
12646
13071
|
enter(tag) {
|
|
12647
|
-
const tagDef = (0,
|
|
13072
|
+
const tagDef = (0, import_babel_utils53.getTagDef)(tag);
|
|
12648
13073
|
const type = analyzeTagNameType(tag);
|
|
12649
13074
|
const hook = tagDef?.analyzer?.hook;
|
|
12650
13075
|
if (hook) {
|
|
@@ -12668,7 +13093,7 @@ var tag_default = {
|
|
|
12668
13093
|
}
|
|
12669
13094
|
},
|
|
12670
13095
|
exit(tag) {
|
|
12671
|
-
const hook = (0,
|
|
13096
|
+
const hook = (0, import_babel_utils53.getTagDef)(tag)?.analyzer?.hook;
|
|
12672
13097
|
if (hook) {
|
|
12673
13098
|
exit(hook, tag);
|
|
12674
13099
|
return;
|
|
@@ -12677,7 +13102,7 @@ var tag_default = {
|
|
|
12677
13102
|
},
|
|
12678
13103
|
translate: {
|
|
12679
13104
|
enter(tag) {
|
|
12680
|
-
const tagDef = (0,
|
|
13105
|
+
const tagDef = (0, import_babel_utils53.getTagDef)(tag);
|
|
12681
13106
|
const extra = tag.node.extra;
|
|
12682
13107
|
if (tagDef?.translator) {
|
|
12683
13108
|
if (tagDef.translator.path) {
|
|
@@ -12694,7 +13119,7 @@ var tag_default = {
|
|
|
12694
13119
|
);
|
|
12695
13120
|
}
|
|
12696
13121
|
if (attr.node.modifier) {
|
|
12697
|
-
if ((0,
|
|
13122
|
+
if ((0, import_babel_utils53.isNativeTag)(attr.parentPath)) {
|
|
12698
13123
|
attr.node.name += `:${attr.node.modifier}`;
|
|
12699
13124
|
} else {
|
|
12700
13125
|
throw attr.buildCodeFrameError(
|
|
@@ -12708,8 +13133,8 @@ var tag_default = {
|
|
|
12708
13133
|
if (extra.tagNameDynamic && extra.tagNameNullable && type === 0 /* NativeTag */ && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
|
12709
13134
|
const tagNameId = generateUidIdentifier("tagName");
|
|
12710
13135
|
const [tagNameVarPath] = tag.insertBefore(
|
|
12711
|
-
|
|
12712
|
-
|
|
13136
|
+
import_compiler65.types.variableDeclaration("const", [
|
|
13137
|
+
import_compiler65.types.variableDeclarator(tagNameId, tag.node.name)
|
|
12713
13138
|
])
|
|
12714
13139
|
);
|
|
12715
13140
|
tagNameVarPath.skip();
|
|
@@ -12731,7 +13156,7 @@ var tag_default = {
|
|
|
12731
13156
|
}
|
|
12732
13157
|
},
|
|
12733
13158
|
exit(tag) {
|
|
12734
|
-
const translator = (0,
|
|
13159
|
+
const translator = (0, import_babel_utils53.getTagDef)(tag)?.translator;
|
|
12735
13160
|
if (translator) {
|
|
12736
13161
|
exit(translator.hook, tag);
|
|
12737
13162
|
return;
|
|
@@ -12755,7 +13180,7 @@ var tag_default = {
|
|
|
12755
13180
|
};
|
|
12756
13181
|
|
|
12757
13182
|
// src/translator/visitors/text.ts
|
|
12758
|
-
var
|
|
13183
|
+
var import_compiler66 = require("@marko/compiler");
|
|
12759
13184
|
var text_default = {
|
|
12760
13185
|
translate: {
|
|
12761
13186
|
exit(text) {
|