marko 6.0.85 → 6.0.87
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/html.js +5 -5
- package/dist/debug/html.mjs +4 -4
- package/dist/html/writer.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/textarea.d.ts +3 -0
- package/dist/translator/index.d.ts +1 -0
- package/dist/translator/index.js +881 -762
- package/dist/translator/util/serialize-guard.d.ts +4 -3
- package/dist/translator/visitors/program/index.d.ts +4 -0
- package/dist/translator/visitors/program/pre-analyze.d.ts +3 -0
- package/dist/translator/visitors/tag/index.d.ts +0 -3
- package/dist/translator/visitors/tag/native-tag.d.ts +0 -3
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
|
@@ -112,7 +112,7 @@ var attrs_default = {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
// src/translator/core/await.ts
|
|
115
|
-
var
|
|
115
|
+
var import_compiler36 = require("@marko/compiler");
|
|
116
116
|
var import_babel_utils26 = require("@marko/compiler/babel-utils");
|
|
117
117
|
|
|
118
118
|
// src/common/accessor.debug.ts
|
|
@@ -235,7 +235,7 @@ function isNullableExpr(expr) {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
// src/translator/util/references.ts
|
|
238
|
-
var
|
|
238
|
+
var import_compiler35 = require("@marko/compiler");
|
|
239
239
|
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
|
240
240
|
|
|
241
241
|
// src/html/serializer.ts
|
|
@@ -690,16 +690,9 @@ function getMarkoRoot(path5) {
|
|
|
690
690
|
}
|
|
691
691
|
function getExprRoot(path5) {
|
|
692
692
|
let curPath = path5;
|
|
693
|
-
let assignmentPath;
|
|
694
693
|
while (!isMarko(curPath.parentPath)) {
|
|
695
|
-
if (curPath.isAssignmentPattern()) {
|
|
696
|
-
assignmentPath = curPath;
|
|
697
|
-
}
|
|
698
694
|
curPath = curPath.parentPath;
|
|
699
695
|
}
|
|
700
|
-
if (assignmentPath && curPath.parentPath.isMarkoTag() && (curPath.key === "var" || curPath.listKey === "params")) {
|
|
701
|
-
return assignmentPath;
|
|
702
|
-
}
|
|
703
696
|
return curPath;
|
|
704
697
|
}
|
|
705
698
|
function getFnRoot(path5) {
|
|
@@ -1627,17 +1620,17 @@ function startSection(path5) {
|
|
|
1627
1620
|
const extra = path5.node.extra ??= {};
|
|
1628
1621
|
let section = extra.section;
|
|
1629
1622
|
if (!section && (path5.type === "Program" || path5.get("body").length)) {
|
|
1623
|
+
const parentTag = path5.parentPath?.isMarkoTag() ? path5.parentPath : void 0;
|
|
1630
1624
|
const parentSection = path5.parentPath ? getOrCreateSection(path5.parentPath) : void 0;
|
|
1631
|
-
const
|
|
1632
|
-
"name"
|
|
1633
|
-
);
|
|
1634
|
-
const sectionName = path5.isProgram() ? "" : generateUid(sectionNamePath.toString() + "_content");
|
|
1625
|
+
const sectionName = parentTag ? generateUid(
|
|
1626
|
+
(isCoreTagName(parentTag, "define") && import_compiler7.types.isIdentifier(parentTag.node.var) ? parentTag.node.var.name : parentTag.get("name").toString()) + "_content"
|
|
1627
|
+
) : "";
|
|
1635
1628
|
const programExtra = path5.hub.file.path.node.extra ??= {};
|
|
1636
1629
|
const sections = programExtra.sections ??= [];
|
|
1637
1630
|
section = extra.section = {
|
|
1638
1631
|
id: sections.length,
|
|
1639
1632
|
name: sectionName,
|
|
1640
|
-
loc:
|
|
1633
|
+
loc: parentTag?.node.name.loc || void 0,
|
|
1641
1634
|
depth: parentSection ? parentSection.depth + 1 : 0,
|
|
1642
1635
|
parent: parentSection,
|
|
1643
1636
|
sectionAccessor: void 0,
|
|
@@ -2113,11 +2106,11 @@ function isEventOrChangeHandler(prop) {
|
|
|
2113
2106
|
}
|
|
2114
2107
|
|
|
2115
2108
|
// src/translator/util/known-tag.ts
|
|
2116
|
-
var
|
|
2109
|
+
var import_compiler34 = require("@marko/compiler");
|
|
2117
2110
|
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
|
2118
2111
|
|
|
2119
2112
|
// src/translator/visitors/program/index.ts
|
|
2120
|
-
var
|
|
2113
|
+
var import_compiler26 = require("@marko/compiler");
|
|
2121
2114
|
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
|
2122
2115
|
var import_path2 = __toESM(require("path"));
|
|
2123
2116
|
|
|
@@ -2650,74 +2643,85 @@ var import_compiler14 = require("@marko/compiler");
|
|
|
2650
2643
|
|
|
2651
2644
|
// src/translator/util/with-comment.ts
|
|
2652
2645
|
function withLeadingComment(node, value) {
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2646
|
+
if (value) {
|
|
2647
|
+
const comment = {
|
|
2648
|
+
type: "CommentBlock",
|
|
2649
|
+
value: ` ${value} `
|
|
2650
|
+
};
|
|
2651
|
+
node.leadingComments = node.leadingComments ? [...node.leadingComments, comment] : [comment];
|
|
2652
|
+
}
|
|
2658
2653
|
return node;
|
|
2659
2654
|
}
|
|
2660
2655
|
|
|
2661
2656
|
// src/translator/util/serialize-guard.ts
|
|
2662
|
-
function getSerializeGuard(reason, optional) {
|
|
2663
|
-
|
|
2657
|
+
function getSerializeGuard(section, reason, optional) {
|
|
2658
|
+
if (!isReasonDynamic(reason)) {
|
|
2659
|
+
return reason ? optional ? void 0 : withLeadingComment(
|
|
2660
|
+
import_compiler14.types.numericLiteral(1),
|
|
2661
|
+
getDebugNames(reason === true ? void 0 : reason.state)
|
|
2662
|
+
) : import_compiler14.types.numericLiteral(0);
|
|
2663
|
+
}
|
|
2664
|
+
let expr;
|
|
2665
|
+
for (const [paramsSection, params] of groupParamsBySection(reason.param)) {
|
|
2666
|
+
if (!isSameOrChildSection(paramsSection, section)) {
|
|
2667
|
+
return optional ? void 0 : withLeadingComment(import_compiler14.types.numericLiteral(1), getDebugNames(params));
|
|
2668
|
+
}
|
|
2669
|
+
const serializeIdentifier = import_compiler14.types.identifier(
|
|
2670
|
+
getSharedUid(`scope${paramsSection.id}_reason`, paramsSection)
|
|
2671
|
+
);
|
|
2672
|
+
const guard = paramsSection.paramReasonGroups ? callRuntime(
|
|
2673
|
+
"_serialize_guard",
|
|
2674
|
+
serializeIdentifier,
|
|
2675
|
+
withLeadingComment(
|
|
2676
|
+
import_compiler14.types.numericLiteral(getParamReasonGroupIndex(paramsSection, params)),
|
|
2677
|
+
getDebugNames(params)
|
|
2678
|
+
)
|
|
2679
|
+
) : serializeIdentifier;
|
|
2680
|
+
expr = expr ? import_compiler14.types.logicalExpression("||", expr, guard) : guard;
|
|
2681
|
+
}
|
|
2682
|
+
return expr;
|
|
2664
2683
|
}
|
|
2665
|
-
function getSerializeGuardForAny(reasons, optional) {
|
|
2684
|
+
function getSerializeGuardForAny(section, reasons, optional) {
|
|
2666
2685
|
if (!reasons || reasons === true) {
|
|
2667
|
-
return getSerializeGuard(reasons, optional);
|
|
2686
|
+
return getSerializeGuard(section, reasons, optional);
|
|
2668
2687
|
}
|
|
2669
2688
|
if (reasons.length === 1) {
|
|
2670
|
-
return getSerializeGuard(reasons[0], optional);
|
|
2689
|
+
return getSerializeGuard(section, reasons[0], optional);
|
|
2671
2690
|
}
|
|
2672
2691
|
let expr;
|
|
2673
2692
|
for (const reason of reasons) {
|
|
2674
|
-
if (reason
|
|
2693
|
+
if (!isReasonDynamic(reason)) {
|
|
2675
2694
|
return optional ? void 0 : withLeadingComment(import_compiler14.types.numericLiteral(1), getDebugNames(reason.state));
|
|
2676
2695
|
}
|
|
2677
|
-
const guard = getSerializeGuard(reason, false);
|
|
2696
|
+
const guard = getSerializeGuard(section, reason, false);
|
|
2678
2697
|
expr = expr ? import_compiler14.types.logicalExpression("||", expr, guard) : guard;
|
|
2679
2698
|
}
|
|
2680
2699
|
return expr;
|
|
2681
2700
|
}
|
|
2682
|
-
function getExprIfSerialized(reason, expr) {
|
|
2701
|
+
function getExprIfSerialized(section, reason, expr) {
|
|
2683
2702
|
if (!isReasonDynamic(reason)) {
|
|
2684
2703
|
return reason && expr;
|
|
2685
2704
|
}
|
|
2686
2705
|
let orExpr;
|
|
2687
|
-
for (const [
|
|
2706
|
+
for (const [paramsSection, params] of groupParamsBySection(reason.param)) {
|
|
2707
|
+
if (!isSameOrChildSection(paramsSection, section)) {
|
|
2708
|
+
return expr;
|
|
2709
|
+
}
|
|
2688
2710
|
const serializeIdentifier = import_compiler14.types.identifier(
|
|
2689
|
-
getSharedUid(
|
|
2711
|
+
getSharedUid(`scope${paramsSection.id}_reason`, paramsSection)
|
|
2690
2712
|
);
|
|
2691
|
-
const guard =
|
|
2713
|
+
const guard = paramsSection.paramReasonGroups ? callRuntime(
|
|
2692
2714
|
"_serialize_if",
|
|
2693
2715
|
serializeIdentifier,
|
|
2694
2716
|
withLeadingComment(
|
|
2695
|
-
import_compiler14.types.numericLiteral(getParamReasonGroupIndex(
|
|
2696
|
-
getDebugNames(
|
|
2717
|
+
import_compiler14.types.numericLiteral(getParamReasonGroupIndex(paramsSection, params)),
|
|
2718
|
+
getDebugNames(params)
|
|
2697
2719
|
)
|
|
2698
2720
|
) : serializeIdentifier;
|
|
2699
2721
|
orExpr = orExpr ? import_compiler14.types.logicalExpression("||", orExpr, guard) : guard;
|
|
2700
2722
|
}
|
|
2701
2723
|
return import_compiler14.types.logicalExpression("&&", orExpr, expr);
|
|
2702
2724
|
}
|
|
2703
|
-
function getInputSerializeReasonGuard(reason) {
|
|
2704
|
-
let expr;
|
|
2705
|
-
for (const [section, reasons] of groupParamsBySection(reason.param)) {
|
|
2706
|
-
const serializeIdentifier = import_compiler14.types.identifier(
|
|
2707
|
-
getSharedUid("serialize", section)
|
|
2708
|
-
);
|
|
2709
|
-
const guard = section.paramReasonGroups ? callRuntime(
|
|
2710
|
-
"_serialize_guard",
|
|
2711
|
-
serializeIdentifier,
|
|
2712
|
-
withLeadingComment(
|
|
2713
|
-
import_compiler14.types.numericLiteral(getParamReasonGroupIndex(section, reasons)),
|
|
2714
|
-
getDebugNames(reasons)
|
|
2715
|
-
)
|
|
2716
|
-
) : serializeIdentifier;
|
|
2717
|
-
expr = expr ? import_compiler14.types.logicalExpression("||", expr, guard) : guard;
|
|
2718
|
-
}
|
|
2719
|
-
return expr;
|
|
2720
|
-
}
|
|
2721
2725
|
|
|
2722
2726
|
// src/translator/util/walks.ts
|
|
2723
2727
|
var import_compiler15 = require("@marko/compiler");
|
|
@@ -2986,7 +2990,7 @@ function markNode(path5, nodeBinding, reason) {
|
|
|
2986
2990
|
"_el_resume",
|
|
2987
2991
|
getScopeIdIdentifier(section),
|
|
2988
2992
|
getScopeAccessorLiteral(nodeBinding),
|
|
2989
|
-
getSerializeGuard(reason, true)
|
|
2993
|
+
getSerializeGuard(section, reason, true)
|
|
2990
2994
|
)}`;
|
|
2991
2995
|
}
|
|
2992
2996
|
}
|
|
@@ -4051,7 +4055,11 @@ function writeHTMLResumeStatements(path5) {
|
|
|
4051
4055
|
serializedProperties.push(
|
|
4052
4056
|
toObjectProperty(
|
|
4053
4057
|
accessor,
|
|
4054
|
-
sectionSerializeReason && (sectionSerializeReason === reason || sectionSerializeReason !== true && reason !== true && compareSources(sectionSerializeReason, reason) === 0) ? getDeclaredBindingExpression(binding) : getExprIfSerialized(
|
|
4058
|
+
sectionSerializeReason && (sectionSerializeReason === reason || sectionSerializeReason !== true && reason !== true && compareSources(sectionSerializeReason, reason) === 0) ? getDeclaredBindingExpression(binding) : getExprIfSerialized(
|
|
4059
|
+
section,
|
|
4060
|
+
reason,
|
|
4061
|
+
getDeclaredBindingExpression(binding)
|
|
4062
|
+
)
|
|
4055
4063
|
)
|
|
4056
4064
|
);
|
|
4057
4065
|
if (debug) {
|
|
@@ -4085,14 +4093,14 @@ function writeHTMLResumeStatements(path5) {
|
|
|
4085
4093
|
serializedProperties.push(
|
|
4086
4094
|
toObjectProperty(
|
|
4087
4095
|
ownerAccessor,
|
|
4088
|
-
sectionSerializeReason && (sectionSerializeReason === ownerReason || sectionSerializeReason !== true && ownerReason !== true && compareSources(sectionSerializeReason, ownerReason) === 0) ? getOwnerExpr : getExprIfSerialized(ownerReason, getOwnerExpr)
|
|
4096
|
+
sectionSerializeReason && (sectionSerializeReason === ownerReason || sectionSerializeReason !== true && ownerReason !== true && compareSources(sectionSerializeReason, ownerReason) === 0) ? getOwnerExpr : getExprIfSerialized(section, ownerReason, getOwnerExpr)
|
|
4089
4097
|
)
|
|
4090
4098
|
);
|
|
4091
4099
|
}
|
|
4092
4100
|
}
|
|
4093
4101
|
for (const [key, { expression, reason }] of serializedLookup) {
|
|
4094
4102
|
serializedProperties.push(
|
|
4095
|
-
toObjectProperty(key, getExprIfSerialized(reason, expression))
|
|
4103
|
+
toObjectProperty(key, getExprIfSerialized(section, reason, expression))
|
|
4096
4104
|
);
|
|
4097
4105
|
}
|
|
4098
4106
|
if (sectionSerializeReason) {
|
|
@@ -4116,15 +4124,15 @@ function writeHTMLResumeStatements(path5) {
|
|
|
4116
4124
|
writeScopeArgs.push(import_compiler22.types.objectExpression(debugVars));
|
|
4117
4125
|
}
|
|
4118
4126
|
}
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4127
|
+
body.push(
|
|
4128
|
+
import_compiler22.types.expressionStatement(
|
|
4129
|
+
getExprIfSerialized(
|
|
4130
|
+
section,
|
|
4131
|
+
sectionSerializeReason,
|
|
4132
|
+
writeScopeBuilder ? writeScopeBuilder(callRuntime("_scope", ...writeScopeArgs)) : callRuntime("_scope", ...writeScopeArgs)
|
|
4133
|
+
)
|
|
4134
|
+
)
|
|
4135
|
+
);
|
|
4128
4136
|
}
|
|
4129
4137
|
const resumeClosestBranch = !section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || !!find(section.bindings, (binding) => binding.type === 1 /* let */));
|
|
4130
4138
|
if (resumeClosestBranch) {
|
|
@@ -4519,8 +4527,8 @@ var html_default = {
|
|
|
4519
4527
|
renderContent.push(
|
|
4520
4528
|
import_compiler24.types.variableDeclaration("const", [
|
|
4521
4529
|
import_compiler24.types.variableDeclarator(
|
|
4522
|
-
import_compiler24.types.identifier(getSharedUid(
|
|
4523
|
-
callRuntime("
|
|
4530
|
+
import_compiler24.types.identifier(getSharedUid(`scope${section.id}_reason`, section)),
|
|
4531
|
+
callRuntime("_scope_reason")
|
|
4524
4532
|
)
|
|
4525
4533
|
])
|
|
4526
4534
|
);
|
|
@@ -4644,6 +4652,285 @@ function getRegisteredFnExpression2(node) {
|
|
|
4644
4652
|
}
|
|
4645
4653
|
}
|
|
4646
4654
|
|
|
4655
|
+
// src/translator/visitors/program/pre-analyze.ts
|
|
4656
|
+
var import_compiler25 = require("@marko/compiler");
|
|
4657
|
+
|
|
4658
|
+
// src/translator/util/with-previous-location.ts
|
|
4659
|
+
function withPreviousLocation(newNode, originalNode) {
|
|
4660
|
+
newNode.start = originalNode.start;
|
|
4661
|
+
newNode.loc = originalNode.loc;
|
|
4662
|
+
newNode.end = originalNode.end;
|
|
4663
|
+
return newNode;
|
|
4664
|
+
}
|
|
4665
|
+
|
|
4666
|
+
// src/translator/visitors/program/pre-analyze.ts
|
|
4667
|
+
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
|
4668
|
+
var BINDING_CHANGE_HANDLER = /* @__PURE__ */ new WeakMap();
|
|
4669
|
+
function preAnalyze(program) {
|
|
4670
|
+
const state = { crawl: false };
|
|
4671
|
+
normalizeBody(state, program.get("body"));
|
|
4672
|
+
if (state.crawl) {
|
|
4673
|
+
program.scope.crawl();
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
function normalizeBody(state, body) {
|
|
4677
|
+
for (const child of body) {
|
|
4678
|
+
if (child.isMarkoTag()) {
|
|
4679
|
+
normalizeTag(state, child);
|
|
4680
|
+
}
|
|
4681
|
+
}
|
|
4682
|
+
}
|
|
4683
|
+
function normalizeTag(state, tag) {
|
|
4684
|
+
const { node } = tag;
|
|
4685
|
+
const { name: name2, attributes } = node;
|
|
4686
|
+
normalizeBody(state, tag.get("body").get("body"));
|
|
4687
|
+
if (node.var) {
|
|
4688
|
+
const insertions = getAssignmentInsertions(node.var);
|
|
4689
|
+
if (insertions) {
|
|
4690
|
+
state.crawl = true;
|
|
4691
|
+
tag.insertAfter(insertions);
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4694
|
+
if (node.body.params.length) {
|
|
4695
|
+
let insertions;
|
|
4696
|
+
for (const param of node.body.params) {
|
|
4697
|
+
insertions = getAssignmentInsertions(param, insertions);
|
|
4698
|
+
}
|
|
4699
|
+
if (insertions) {
|
|
4700
|
+
state.crawl = true;
|
|
4701
|
+
node.body.body = [...insertions, ...node.body.body];
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4704
|
+
if (name2.type === "StringLiteral") {
|
|
4705
|
+
const tagName = name2.value;
|
|
4706
|
+
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
|
4707
|
+
state.crawl = true;
|
|
4708
|
+
node.name = withPreviousLocation(import_compiler25.types.identifier(tagName), name2);
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
4712
|
+
const attr = attributes[i];
|
|
4713
|
+
if (import_compiler25.types.isMarkoAttribute(attr) && attr.bound) {
|
|
4714
|
+
state.crawl = true;
|
|
4715
|
+
attr.bound = false;
|
|
4716
|
+
attributes.splice(++i, 0, getChangeHandler(tag, attr));
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
}
|
|
4720
|
+
function getChangeHandler(tag, attr) {
|
|
4721
|
+
const attrName = attr.name;
|
|
4722
|
+
const changeAttrName = attrName + "Change";
|
|
4723
|
+
if (import_compiler25.types.isIdentifier(attr.value)) {
|
|
4724
|
+
const binding = tag.scope.getBinding(attr.value.name);
|
|
4725
|
+
if (!binding)
|
|
4726
|
+
return import_compiler25.types.markoAttribute(
|
|
4727
|
+
changeAttrName,
|
|
4728
|
+
buildChangeHandlerFunction(attr.value)
|
|
4729
|
+
);
|
|
4730
|
+
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
|
4731
|
+
if (!existingChangedAttr) {
|
|
4732
|
+
const bindingIdentifierPath = binding.path.getOuterBindingIdentifierPaths()[binding.identifier.name];
|
|
4733
|
+
const changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(
|
|
4734
|
+
bindingIdentifierPath.parentPath
|
|
4735
|
+
) : void 0 : void 0;
|
|
4736
|
+
if (!changeAttrExpr) {
|
|
4737
|
+
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
4738
|
+
}
|
|
4739
|
+
const changeHandlerAttr = import_compiler25.types.markoAttribute(
|
|
4740
|
+
changeAttrName,
|
|
4741
|
+
changeAttrExpr
|
|
4742
|
+
);
|
|
4743
|
+
BINDING_CHANGE_HANDLER.set(binding.identifier, changeHandlerAttr);
|
|
4744
|
+
return changeHandlerAttr;
|
|
4745
|
+
}
|
|
4746
|
+
if (existingChangedAttr.type === "Identifier") {
|
|
4747
|
+
return import_compiler25.types.markoAttribute(
|
|
4748
|
+
changeAttrName,
|
|
4749
|
+
withPreviousLocation(
|
|
4750
|
+
import_compiler25.types.identifier(existingChangedAttr.name),
|
|
4751
|
+
attr.value
|
|
4752
|
+
)
|
|
4753
|
+
);
|
|
4754
|
+
}
|
|
4755
|
+
const markoRoot = isMarko(binding.path) ? binding.path : getMarkoRoot(binding.path);
|
|
4756
|
+
if (!(markoRoot?.isMarkoTag() || markoRoot?.isMarkoTagBody())) {
|
|
4757
|
+
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
4758
|
+
}
|
|
4759
|
+
const changeHandlerId = generateUid(changeAttrName);
|
|
4760
|
+
const changeHandlerConst = import_compiler25.types.markoTag(
|
|
4761
|
+
import_compiler25.types.stringLiteral("const"),
|
|
4762
|
+
[import_compiler25.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
|
4763
|
+
import_compiler25.types.markoTagBody([]),
|
|
4764
|
+
null,
|
|
4765
|
+
import_compiler25.types.identifier(changeHandlerId)
|
|
4766
|
+
);
|
|
4767
|
+
BINDING_CHANGE_HANDLER.set(
|
|
4768
|
+
binding.identifier,
|
|
4769
|
+
existingChangedAttr.value = import_compiler25.types.identifier(changeHandlerId)
|
|
4770
|
+
);
|
|
4771
|
+
if (markoRoot.isMarkoTag()) {
|
|
4772
|
+
markoRoot.insertAfter(changeHandlerConst);
|
|
4773
|
+
} else {
|
|
4774
|
+
markoRoot.unshiftContainer("body", changeHandlerConst);
|
|
4775
|
+
}
|
|
4776
|
+
markoRoot.scope.crawl();
|
|
4777
|
+
return import_compiler25.types.markoAttribute(
|
|
4778
|
+
changeAttrName,
|
|
4779
|
+
withPreviousLocation(import_compiler25.types.identifier(changeHandlerId), attr.value)
|
|
4780
|
+
);
|
|
4781
|
+
} else if (import_compiler25.types.isMemberExpression(attr.value)) {
|
|
4782
|
+
const prop = attr.value.property;
|
|
4783
|
+
if (!import_compiler25.types.isPrivateName(attr.value.property)) {
|
|
4784
|
+
return import_compiler25.types.markoAttribute(
|
|
4785
|
+
changeAttrName,
|
|
4786
|
+
import_compiler25.types.memberExpression(
|
|
4787
|
+
import_compiler25.types.cloneNode(attr.value.object),
|
|
4788
|
+
prop.type === "Identifier" ? withPreviousLocation(import_compiler25.types.identifier(prop.name + "Change"), prop) : import_compiler25.types.binaryExpression(
|
|
4789
|
+
"+",
|
|
4790
|
+
import_compiler25.types.cloneNode(prop),
|
|
4791
|
+
import_compiler25.types.stringLiteral("Change")
|
|
4792
|
+
),
|
|
4793
|
+
prop.type !== "Identifier"
|
|
4794
|
+
)
|
|
4795
|
+
);
|
|
4796
|
+
}
|
|
4797
|
+
}
|
|
4798
|
+
throw tag.hub.buildError(
|
|
4799
|
+
attr.value,
|
|
4800
|
+
"Attributes may only be bound to identifiers or member expressions"
|
|
4801
|
+
);
|
|
4802
|
+
}
|
|
4803
|
+
function buildChangeHandlerFunction(id) {
|
|
4804
|
+
const newId = "_new_" + id.name;
|
|
4805
|
+
return import_compiler25.types.arrowFunctionExpression(
|
|
4806
|
+
[withPreviousLocation(import_compiler25.types.identifier(newId), id)],
|
|
4807
|
+
import_compiler25.types.blockStatement([
|
|
4808
|
+
import_compiler25.types.expressionStatement(
|
|
4809
|
+
import_compiler25.types.assignmentExpression(
|
|
4810
|
+
"=",
|
|
4811
|
+
withPreviousLocation(import_compiler25.types.identifier(id.name), id),
|
|
4812
|
+
withPreviousLocation(import_compiler25.types.identifier(newId), id)
|
|
4813
|
+
)
|
|
4814
|
+
)
|
|
4815
|
+
])
|
|
4816
|
+
);
|
|
4817
|
+
}
|
|
4818
|
+
function getChangeHandlerFromObjectPattern(parent) {
|
|
4819
|
+
let changeKey;
|
|
4820
|
+
const pattern = parent.parentPath;
|
|
4821
|
+
if (parent.node.computed) {
|
|
4822
|
+
changeKey = generateUidIdentifier("dynamicChange");
|
|
4823
|
+
pattern.pushContainer(
|
|
4824
|
+
"properties",
|
|
4825
|
+
import_compiler25.types.objectProperty(
|
|
4826
|
+
import_compiler25.types.binaryExpression(
|
|
4827
|
+
"+",
|
|
4828
|
+
parent.get("key").node,
|
|
4829
|
+
import_compiler25.types.stringLiteral("Change")
|
|
4830
|
+
),
|
|
4831
|
+
changeKey,
|
|
4832
|
+
true
|
|
4833
|
+
)
|
|
4834
|
+
);
|
|
4835
|
+
} else {
|
|
4836
|
+
const key = parent.get("key");
|
|
4837
|
+
const searchKey = `${getStringOrIdentifierValue(key)}Change`;
|
|
4838
|
+
for (const prop of pattern.get("properties")) {
|
|
4839
|
+
if (prop.isObjectProperty()) {
|
|
4840
|
+
const propKey = prop.get("key");
|
|
4841
|
+
const propValue = prop.get("value");
|
|
4842
|
+
if (!prop.node.computed && getStringOrIdentifierValue(propKey) === searchKey && propValue.isIdentifier()) {
|
|
4843
|
+
changeKey = propValue.node;
|
|
4844
|
+
break;
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
if (!changeKey) {
|
|
4849
|
+
pattern.unshiftContainer(
|
|
4850
|
+
"properties",
|
|
4851
|
+
import_compiler25.types.objectProperty(
|
|
4852
|
+
import_compiler25.types.stringLiteral(searchKey),
|
|
4853
|
+
changeKey = generateUidIdentifier(searchKey)
|
|
4854
|
+
)
|
|
4855
|
+
);
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
return changeKey;
|
|
4859
|
+
}
|
|
4860
|
+
function getStringOrIdentifierValue(path5) {
|
|
4861
|
+
return getLiteralName(path5.node);
|
|
4862
|
+
}
|
|
4863
|
+
function getLiteralName(node) {
|
|
4864
|
+
switch (node.type) {
|
|
4865
|
+
case "Identifier":
|
|
4866
|
+
return node.name;
|
|
4867
|
+
case "StringLiteral":
|
|
4868
|
+
return node.value;
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
function getAssignmentInsertions(node, insertions) {
|
|
4872
|
+
switch (node.type) {
|
|
4873
|
+
case "ObjectPattern":
|
|
4874
|
+
for (const prop of node.properties) {
|
|
4875
|
+
if (prop.type === "ObjectProperty") {
|
|
4876
|
+
if (prop.value.type === "AssignmentPattern") {
|
|
4877
|
+
const { left, right } = prop.value;
|
|
4878
|
+
const sourceName = generateUid(
|
|
4879
|
+
getLiteralName(left) || getLiteralName(prop.key) || "pattern"
|
|
4880
|
+
);
|
|
4881
|
+
prop.shorthand = false;
|
|
4882
|
+
prop.value = import_compiler25.types.identifier(sourceName);
|
|
4883
|
+
(insertions ||= []).push(
|
|
4884
|
+
toConstTag(left, toFallbackExpr(sourceName, right))
|
|
4885
|
+
);
|
|
4886
|
+
getAssignmentInsertions(left, insertions);
|
|
4887
|
+
} else {
|
|
4888
|
+
insertions = getAssignmentInsertions(prop.value, insertions);
|
|
4889
|
+
}
|
|
4890
|
+
}
|
|
4891
|
+
}
|
|
4892
|
+
break;
|
|
4893
|
+
case "ArrayPattern":
|
|
4894
|
+
for (let i = 0, len = node.elements.length; i < len; i++) {
|
|
4895
|
+
const el = node.elements[i];
|
|
4896
|
+
if (el != null) {
|
|
4897
|
+
if (el.type === "AssignmentPattern") {
|
|
4898
|
+
const { left, right } = el;
|
|
4899
|
+
const sourceName = generateUid(getLiteralName(left) || "pattern");
|
|
4900
|
+
node.elements[i] = import_compiler25.types.identifier(sourceName);
|
|
4901
|
+
(insertions ||= []).push(
|
|
4902
|
+
toConstTag(left, toFallbackExpr(sourceName, right))
|
|
4903
|
+
);
|
|
4904
|
+
getAssignmentInsertions(left, insertions);
|
|
4905
|
+
} else {
|
|
4906
|
+
insertions = getAssignmentInsertions(el, insertions);
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
break;
|
|
4911
|
+
}
|
|
4912
|
+
return insertions;
|
|
4913
|
+
}
|
|
4914
|
+
function toFallbackExpr(id, fallback) {
|
|
4915
|
+
return import_compiler25.types.conditionalExpression(
|
|
4916
|
+
import_compiler25.types.binaryExpression("!==", buildUndefined(), import_compiler25.types.identifier(id)),
|
|
4917
|
+
import_compiler25.types.identifier(id),
|
|
4918
|
+
fallback
|
|
4919
|
+
);
|
|
4920
|
+
}
|
|
4921
|
+
function toConstTag(id, expr) {
|
|
4922
|
+
return import_compiler25.types.markoTag(
|
|
4923
|
+
import_compiler25.types.stringLiteral("const"),
|
|
4924
|
+
[import_compiler25.types.markoAttribute("value", expr, null, null, true)],
|
|
4925
|
+
import_compiler25.types.markoTagBody(),
|
|
4926
|
+
null,
|
|
4927
|
+
id
|
|
4928
|
+
);
|
|
4929
|
+
}
|
|
4930
|
+
function buildUndefined() {
|
|
4931
|
+
return import_compiler25.types.unaryExpression("void", import_compiler25.types.numericLiteral(0));
|
|
4932
|
+
}
|
|
4933
|
+
|
|
4647
4934
|
// src/translator/visitors/program/index.ts
|
|
4648
4935
|
var cleanIdentifier;
|
|
4649
4936
|
var scopeIdentifier;
|
|
@@ -4653,12 +4940,15 @@ function isScopeIdentifier(node) {
|
|
|
4653
4940
|
var program_default = {
|
|
4654
4941
|
migrate: {
|
|
4655
4942
|
enter(program) {
|
|
4656
|
-
program.node.params = [
|
|
4943
|
+
program.node.params = [import_compiler26.types.identifier("input")];
|
|
4657
4944
|
},
|
|
4658
4945
|
exit(program) {
|
|
4659
4946
|
program.scope.crawl();
|
|
4660
4947
|
}
|
|
4661
4948
|
},
|
|
4949
|
+
transform: {
|
|
4950
|
+
exit: preAnalyze
|
|
4951
|
+
},
|
|
4662
4952
|
analyze: {
|
|
4663
4953
|
enter(program) {
|
|
4664
4954
|
startSection(program);
|
|
@@ -4736,7 +5026,7 @@ var program_default = {
|
|
|
4736
5026
|
body.push(child);
|
|
4737
5027
|
}
|
|
4738
5028
|
}
|
|
4739
|
-
body[0] ??=
|
|
5029
|
+
body[0] ??= import_compiler26.types.importDeclaration([], import_compiler26.types.stringLiteral(compatFile));
|
|
4740
5030
|
program.node.body = body;
|
|
4741
5031
|
}
|
|
4742
5032
|
}
|
|
@@ -4750,7 +5040,7 @@ function resolveRelativeToEntry(entryFile, file, req) {
|
|
|
4750
5040
|
}
|
|
4751
5041
|
|
|
4752
5042
|
// src/translator/util/nested-attribute-tags.ts
|
|
4753
|
-
var
|
|
5043
|
+
var import_compiler27 = require("@marko/compiler");
|
|
4754
5044
|
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
|
4755
5045
|
var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
|
|
4756
5046
|
function getAttrTagIdentifier(meta) {
|
|
@@ -4759,7 +5049,7 @@ function getAttrTagIdentifier(meta) {
|
|
|
4759
5049
|
name2 = generateUid(meta.name);
|
|
4760
5050
|
attrTagToIdentifierLookup.set(meta, name2);
|
|
4761
5051
|
}
|
|
4762
|
-
return
|
|
5052
|
+
return import_compiler27.types.identifier(name2);
|
|
4763
5053
|
}
|
|
4764
5054
|
function analyzeAttributeTags(tag) {
|
|
4765
5055
|
if (tag.node.extra?.attributeTags) return tag.node.extra.attributeTags;
|
|
@@ -4872,7 +5162,7 @@ function getConditionRoot(tag) {
|
|
|
4872
5162
|
}
|
|
4873
5163
|
|
|
4874
5164
|
// src/translator/util/set-tag-sections-downstream.ts
|
|
4875
|
-
var
|
|
5165
|
+
var import_compiler28 = require("@marko/compiler");
|
|
4876
5166
|
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
|
4877
5167
|
var [getTagDownstreams] = createSectionState(
|
|
4878
5168
|
"tag-downstreams",
|
|
@@ -4919,23 +5209,23 @@ function crawlSectionsAndSetBinding(tag, binding, tree, skip2) {
|
|
|
4919
5209
|
}
|
|
4920
5210
|
|
|
4921
5211
|
// src/translator/util/translate-attrs.ts
|
|
4922
|
-
var
|
|
5212
|
+
var import_compiler33 = require("@marko/compiler");
|
|
4923
5213
|
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
|
4924
5214
|
|
|
4925
5215
|
// src/translator/core/for.ts
|
|
4926
|
-
var
|
|
5216
|
+
var import_compiler32 = require("@marko/compiler");
|
|
4927
5217
|
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
|
4928
5218
|
|
|
4929
5219
|
// src/translator/util/is-only-child-in-parent.ts
|
|
4930
|
-
var
|
|
5220
|
+
var import_compiler31 = require("@marko/compiler");
|
|
4931
5221
|
var import_babel_utils21 = require("@marko/compiler/babel-utils");
|
|
4932
5222
|
|
|
4933
5223
|
// src/translator/visitors/tag/native-tag.ts
|
|
4934
|
-
var
|
|
5224
|
+
var import_compiler30 = require("@marko/compiler");
|
|
4935
5225
|
var import_babel_utils20 = require("@marko/compiler/babel-utils");
|
|
4936
5226
|
|
|
4937
5227
|
// src/translator/util/translate-var.ts
|
|
4938
|
-
var
|
|
5228
|
+
var import_compiler29 = require("@marko/compiler");
|
|
4939
5229
|
function translateVar(tag, initialValue, kind = "const") {
|
|
4940
5230
|
const {
|
|
4941
5231
|
node: { var: tagVar }
|
|
@@ -4953,15 +5243,15 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
|
4953
5243
|
if (changeBinding && changeName !== changeBinding.name) {
|
|
4954
5244
|
getDestructurePattern(id)?.pushContainer(
|
|
4955
5245
|
"properties",
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
5246
|
+
import_compiler29.types.objectProperty(
|
|
5247
|
+
import_compiler29.types.identifier(changeName),
|
|
5248
|
+
import_compiler29.types.identifier(changeBinding.name)
|
|
4959
5249
|
)
|
|
4960
5250
|
);
|
|
4961
5251
|
}
|
|
4962
5252
|
});
|
|
4963
5253
|
tag.insertBefore(
|
|
4964
|
-
|
|
5254
|
+
import_compiler29.types.variableDeclaration(kind, [import_compiler29.types.variableDeclarator(tagVar, initialValue)])
|
|
4965
5255
|
);
|
|
4966
5256
|
}
|
|
4967
5257
|
function getDestructurePattern(id) {
|
|
@@ -4981,39 +5271,13 @@ var kGetterId = Symbol("node getter id");
|
|
|
4981
5271
|
var kTagContentAttr = Symbol("tag could have dynamic content attribute");
|
|
4982
5272
|
var htmlSelectArgs = /* @__PURE__ */ new WeakMap();
|
|
4983
5273
|
var native_tag_default = {
|
|
4984
|
-
transform: {
|
|
4985
|
-
enter(tag) {
|
|
4986
|
-
const tagName = getTagName(tag);
|
|
4987
|
-
if (tagName === "textarea" && tag.node.body.body.length) {
|
|
4988
|
-
const parts = [];
|
|
4989
|
-
for (const child of tag.node.body.body) {
|
|
4990
|
-
if (child.type === "MarkoText" || child.type === "MarkoPlaceholder" && child.escape) {
|
|
4991
|
-
parts.push(child.value);
|
|
4992
|
-
} else {
|
|
4993
|
-
throw tag.hub.file.hub.buildError(
|
|
4994
|
-
child,
|
|
4995
|
-
"Unexpected content in textarea, only text and placeholders are supported.",
|
|
4996
|
-
SyntaxError
|
|
4997
|
-
);
|
|
4998
|
-
}
|
|
4999
|
-
}
|
|
5000
|
-
tag.node.attributes.push(
|
|
5001
|
-
import_compiler29.types.markoAttribute(
|
|
5002
|
-
"value",
|
|
5003
|
-
normalizeStringExpression(parts) || buildUndefined()
|
|
5004
|
-
)
|
|
5005
|
-
);
|
|
5006
|
-
tag.node.body.body = [];
|
|
5007
|
-
}
|
|
5008
|
-
}
|
|
5009
|
-
},
|
|
5010
5274
|
analyze: {
|
|
5011
5275
|
enter(tag) {
|
|
5012
5276
|
(0, import_babel_utils20.assertNoArgs)(tag);
|
|
5013
5277
|
(0, import_babel_utils20.assertNoParams)(tag);
|
|
5014
5278
|
(0, import_babel_utils20.assertNoAttributeTags)(tag);
|
|
5015
5279
|
const { node } = tag;
|
|
5016
|
-
if (node.var && !
|
|
5280
|
+
if (node.var && !import_compiler30.types.isIdentifier(node.var)) {
|
|
5017
5281
|
throw tag.get("var").buildCodeFrameError(
|
|
5018
5282
|
"Tag variables on [native tags](https://markojs.com/docs/reference/native-tag) cannot be destructured."
|
|
5019
5283
|
);
|
|
@@ -5029,7 +5293,7 @@ var native_tag_default = {
|
|
|
5029
5293
|
for (let i = attributes.length; i--; ) {
|
|
5030
5294
|
const attr = attributes[i];
|
|
5031
5295
|
const valueExtra = attr.value.extra ??= {};
|
|
5032
|
-
if (
|
|
5296
|
+
if (import_compiler30.types.isMarkoAttribute(attr)) {
|
|
5033
5297
|
if (seen[attr.name]) {
|
|
5034
5298
|
dropReferences(attr.value);
|
|
5035
5299
|
continue;
|
|
@@ -5041,14 +5305,14 @@ var native_tag_default = {
|
|
|
5041
5305
|
} else if (!evaluate(attr.value).confident) {
|
|
5042
5306
|
hasDynamicAttributes = true;
|
|
5043
5307
|
}
|
|
5044
|
-
} else if (
|
|
5308
|
+
} else if (import_compiler30.types.isMarkoSpreadAttribute(attr)) {
|
|
5045
5309
|
valueExtra.isEffect = true;
|
|
5046
5310
|
hasEventHandlers = true;
|
|
5047
5311
|
hasDynamicAttributes = true;
|
|
5048
5312
|
}
|
|
5049
5313
|
if (spreadReferenceNodes) {
|
|
5050
5314
|
spreadReferenceNodes.push(attr.value);
|
|
5051
|
-
} else if (
|
|
5315
|
+
} else if (import_compiler30.types.isMarkoSpreadAttribute(attr)) {
|
|
5052
5316
|
spreadReferenceNodes = [attr.value];
|
|
5053
5317
|
relatedControllable = getRelatedControllable(tagName, seen);
|
|
5054
5318
|
} else {
|
|
@@ -5060,7 +5324,7 @@ var native_tag_default = {
|
|
|
5060
5324
|
const tagExtra = node.extra ??= {};
|
|
5061
5325
|
const tagSection = getOrCreateSection(tag);
|
|
5062
5326
|
const nodeBinding = tagExtra[kNativeTagBinding] = createBinding(
|
|
5063
|
-
"#" + (node.name.type === "StringLiteral" ? node.name.value :
|
|
5327
|
+
"#" + (node.name.type === "StringLiteral" ? node.name.value : import_compiler30.types.toIdentifier(tag.get("name"))),
|
|
5064
5328
|
0 /* dom */,
|
|
5065
5329
|
tagSection
|
|
5066
5330
|
);
|
|
@@ -5139,7 +5403,7 @@ var native_tag_default = {
|
|
|
5139
5403
|
callRuntime(
|
|
5140
5404
|
"_el",
|
|
5141
5405
|
getterId && getScopeIdIdentifier(tagSection),
|
|
5142
|
-
getterId &&
|
|
5406
|
+
getterId && import_compiler30.types.stringLiteral(getterId)
|
|
5143
5407
|
)
|
|
5144
5408
|
);
|
|
5145
5409
|
}
|
|
@@ -5165,24 +5429,24 @@ var native_tag_default = {
|
|
|
5165
5429
|
if (tagName === "select") {
|
|
5166
5430
|
if (staticControllable) {
|
|
5167
5431
|
htmlSelectArgs.set(tag.node, {
|
|
5168
|
-
value: staticControllable.attrs[0]?.value ||
|
|
5169
|
-
valueChange: staticControllable.attrs[1]?.value ||
|
|
5432
|
+
value: staticControllable.attrs[0]?.value || buildUndefined2(),
|
|
5433
|
+
valueChange: staticControllable.attrs[1]?.value || buildUndefined2()
|
|
5170
5434
|
});
|
|
5171
5435
|
} else if (spreadExpression) {
|
|
5172
5436
|
const spreadIdentifier = generateUidIdentifier("select_input");
|
|
5173
5437
|
tag.insertBefore(
|
|
5174
|
-
|
|
5175
|
-
|
|
5438
|
+
import_compiler30.types.variableDeclaration("const", [
|
|
5439
|
+
import_compiler30.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5176
5440
|
])
|
|
5177
5441
|
);
|
|
5178
5442
|
htmlSelectArgs.set(tag.node, {
|
|
5179
|
-
value:
|
|
5443
|
+
value: import_compiler30.types.memberExpression(
|
|
5180
5444
|
spreadIdentifier,
|
|
5181
|
-
|
|
5445
|
+
import_compiler30.types.identifier("value")
|
|
5182
5446
|
),
|
|
5183
|
-
valueChange:
|
|
5447
|
+
valueChange: import_compiler30.types.memberExpression(
|
|
5184
5448
|
spreadIdentifier,
|
|
5185
|
-
|
|
5449
|
+
import_compiler30.types.identifier("valueChange")
|
|
5186
5450
|
)
|
|
5187
5451
|
});
|
|
5188
5452
|
spreadExpression = spreadIdentifier;
|
|
@@ -5196,14 +5460,14 @@ var native_tag_default = {
|
|
|
5196
5460
|
} else if (spreadExpression) {
|
|
5197
5461
|
const spreadIdentifier = generateUidIdentifier("textarea_input");
|
|
5198
5462
|
tag.insertBefore(
|
|
5199
|
-
|
|
5200
|
-
|
|
5463
|
+
import_compiler30.types.variableDeclaration("const", [
|
|
5464
|
+
import_compiler30.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5201
5465
|
])
|
|
5202
5466
|
);
|
|
5203
|
-
value =
|
|
5204
|
-
valueChange =
|
|
5467
|
+
value = import_compiler30.types.memberExpression(spreadIdentifier, import_compiler30.types.identifier("value"));
|
|
5468
|
+
valueChange = import_compiler30.types.memberExpression(
|
|
5205
5469
|
spreadIdentifier,
|
|
5206
|
-
|
|
5470
|
+
import_compiler30.types.identifier("valueChange")
|
|
5207
5471
|
);
|
|
5208
5472
|
spreadExpression = spreadIdentifier;
|
|
5209
5473
|
}
|
|
@@ -5244,7 +5508,7 @@ var native_tag_default = {
|
|
|
5244
5508
|
} else if (isEventHandler(name2)) {
|
|
5245
5509
|
addHTMLEffectCall(tagSection, valueReferences);
|
|
5246
5510
|
} else {
|
|
5247
|
-
write`${callRuntime("_attr",
|
|
5511
|
+
write`${callRuntime("_attr", import_compiler30.types.stringLiteral(name2), value)}`;
|
|
5248
5512
|
}
|
|
5249
5513
|
break;
|
|
5250
5514
|
}
|
|
@@ -5276,13 +5540,14 @@ var native_tag_default = {
|
|
|
5276
5540
|
write`>`;
|
|
5277
5541
|
tagExtra[kTagContentAttr] = true;
|
|
5278
5542
|
tag.node.body.body = [
|
|
5279
|
-
|
|
5543
|
+
import_compiler30.types.expressionStatement(
|
|
5280
5544
|
callRuntime(
|
|
5281
5545
|
"_attr_content",
|
|
5282
5546
|
visitAccessor,
|
|
5283
5547
|
getScopeIdIdentifier(tagSection),
|
|
5284
5548
|
usedAttrs.staticContentAttr.value,
|
|
5285
5549
|
getSerializeGuard(
|
|
5550
|
+
tagSection,
|
|
5286
5551
|
nodeBinding && getSerializeReason(tagSection, nodeBinding),
|
|
5287
5552
|
true
|
|
5288
5553
|
)
|
|
@@ -5291,12 +5556,13 @@ var native_tag_default = {
|
|
|
5291
5556
|
];
|
|
5292
5557
|
} else if (spreadExpression && !hasChildren) {
|
|
5293
5558
|
const serializeReason = getSerializeGuard(
|
|
5559
|
+
tagSection,
|
|
5294
5560
|
nodeBinding && getSerializeReason(tagSection, nodeBinding),
|
|
5295
5561
|
true
|
|
5296
5562
|
);
|
|
5297
5563
|
tagExtra[kTagContentAttr] = true;
|
|
5298
5564
|
tag.node.body.body = [
|
|
5299
|
-
skipExpression ?
|
|
5565
|
+
skipExpression ? import_compiler30.types.expressionStatement(
|
|
5300
5566
|
callRuntime(
|
|
5301
5567
|
"_attrs_partial_content",
|
|
5302
5568
|
spreadExpression,
|
|
@@ -5306,7 +5572,7 @@ var native_tag_default = {
|
|
|
5306
5572
|
tag.node.name,
|
|
5307
5573
|
serializeReason
|
|
5308
5574
|
)
|
|
5309
|
-
) :
|
|
5575
|
+
) : import_compiler30.types.expressionStatement(
|
|
5310
5576
|
callRuntime(
|
|
5311
5577
|
"_attrs_content",
|
|
5312
5578
|
spreadExpression,
|
|
@@ -5323,7 +5589,7 @@ var native_tag_default = {
|
|
|
5323
5589
|
}
|
|
5324
5590
|
if (tagExtra.tagNameNullable) {
|
|
5325
5591
|
tag.insertBefore(
|
|
5326
|
-
|
|
5592
|
+
import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
|
|
5327
5593
|
)[0].skip();
|
|
5328
5594
|
}
|
|
5329
5595
|
if (writeAtStartOfBody) {
|
|
@@ -5349,16 +5615,16 @@ var native_tag_default = {
|
|
|
5349
5615
|
}
|
|
5350
5616
|
flushInto(tag);
|
|
5351
5617
|
tag.insertBefore(
|
|
5352
|
-
|
|
5618
|
+
import_compiler30.types.expressionStatement(
|
|
5353
5619
|
callRuntime(
|
|
5354
5620
|
"_attr_select_value",
|
|
5355
5621
|
getScopeIdIdentifier(getSection(tag)),
|
|
5356
5622
|
nodeBinding && getScopeAccessorLiteral(nodeBinding),
|
|
5357
5623
|
selectArgs.value,
|
|
5358
5624
|
selectArgs.valueChange,
|
|
5359
|
-
|
|
5625
|
+
import_compiler30.types.arrowFunctionExpression(
|
|
5360
5626
|
[],
|
|
5361
|
-
|
|
5627
|
+
import_compiler30.types.blockStatement(tag.node.body.body)
|
|
5362
5628
|
)
|
|
5363
5629
|
)
|
|
5364
5630
|
)
|
|
@@ -5375,7 +5641,7 @@ var native_tag_default = {
|
|
|
5375
5641
|
}
|
|
5376
5642
|
if (tagExtra.tagNameNullable) {
|
|
5377
5643
|
tag.insertBefore(
|
|
5378
|
-
|
|
5644
|
+
import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
|
|
5379
5645
|
)[0].skip();
|
|
5380
5646
|
}
|
|
5381
5647
|
if (markerSerializeReason) {
|
|
@@ -5400,13 +5666,13 @@ var native_tag_default = {
|
|
|
5400
5666
|
if (getterId) {
|
|
5401
5667
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
5402
5668
|
(0, import_babel_utils20.getProgram)().node.body.push(
|
|
5403
|
-
|
|
5404
|
-
|
|
5669
|
+
import_compiler30.types.variableDeclaration("const", [
|
|
5670
|
+
import_compiler30.types.variableDeclarator(
|
|
5405
5671
|
getterFnIdentifier,
|
|
5406
5672
|
callRuntime(
|
|
5407
5673
|
"_el",
|
|
5408
|
-
|
|
5409
|
-
|
|
5674
|
+
import_compiler30.types.stringLiteral(getterId),
|
|
5675
|
+
import_compiler30.types.stringLiteral(
|
|
5410
5676
|
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeBinding).value
|
|
5411
5677
|
)
|
|
5412
5678
|
)
|
|
@@ -5419,22 +5685,22 @@ var native_tag_default = {
|
|
|
5419
5685
|
if (isSameOrChildSection(tagSection, referenceSection)) {
|
|
5420
5686
|
if (isInvokedFunction(reference)) {
|
|
5421
5687
|
reference.parentPath.replaceWith(
|
|
5422
|
-
|
|
5688
|
+
import_compiler30.types.expressionStatement(
|
|
5423
5689
|
createScopeReadExpression(referenceSection, nodeBinding)
|
|
5424
5690
|
)
|
|
5425
5691
|
);
|
|
5426
5692
|
} else if (getterFnIdentifier) {
|
|
5427
5693
|
reference.replaceWith(
|
|
5428
|
-
|
|
5694
|
+
import_compiler30.types.callExpression(getterFnIdentifier, [
|
|
5429
5695
|
getScopeExpression(referenceSection, getSection(tag))
|
|
5430
5696
|
])
|
|
5431
5697
|
);
|
|
5432
5698
|
} else {
|
|
5433
5699
|
reference.replaceWith(
|
|
5434
|
-
|
|
5435
|
-
|
|
5700
|
+
import_compiler30.types.expressionStatement(
|
|
5701
|
+
import_compiler30.types.memberExpression(
|
|
5436
5702
|
getScopeExpression(tagSection, referenceSection),
|
|
5437
|
-
|
|
5703
|
+
import_compiler30.types.stringLiteral(
|
|
5438
5704
|
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeBinding).value
|
|
5439
5705
|
),
|
|
5440
5706
|
true
|
|
@@ -5464,7 +5730,7 @@ var native_tag_default = {
|
|
|
5464
5730
|
"render",
|
|
5465
5731
|
tagSection,
|
|
5466
5732
|
referencedBindings,
|
|
5467
|
-
|
|
5733
|
+
import_compiler30.types.expressionStatement(
|
|
5468
5734
|
callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
|
|
5469
5735
|
)
|
|
5470
5736
|
);
|
|
@@ -5473,7 +5739,7 @@ var native_tag_default = {
|
|
|
5473
5739
|
"effect",
|
|
5474
5740
|
tagSection,
|
|
5475
5741
|
void 0,
|
|
5476
|
-
|
|
5742
|
+
import_compiler30.types.expressionStatement(
|
|
5477
5743
|
callRuntime(`${helper}_script`, scopeIdentifier, visitAccessor)
|
|
5478
5744
|
)
|
|
5479
5745
|
);
|
|
@@ -5490,7 +5756,7 @@ var native_tag_default = {
|
|
|
5490
5756
|
if (confident) {
|
|
5491
5757
|
write`${getHTMLRuntime()[helper](computed)}`;
|
|
5492
5758
|
} else {
|
|
5493
|
-
const nodeExpr =
|
|
5759
|
+
const nodeExpr = import_compiler30.types.memberExpression(
|
|
5494
5760
|
scopeIdentifier,
|
|
5495
5761
|
visitAccessor,
|
|
5496
5762
|
true
|
|
@@ -5503,7 +5769,7 @@ var native_tag_default = {
|
|
|
5503
5769
|
let stmt;
|
|
5504
5770
|
trackDelimitedAttrValue(value, meta);
|
|
5505
5771
|
if (meta.dynamicItems) {
|
|
5506
|
-
stmt =
|
|
5772
|
+
stmt = import_compiler30.types.expressionStatement(
|
|
5507
5773
|
callRuntime(helper, nodeExpr, value)
|
|
5508
5774
|
);
|
|
5509
5775
|
} else {
|
|
@@ -5515,11 +5781,11 @@ var native_tag_default = {
|
|
|
5515
5781
|
if (keys.length === 1) {
|
|
5516
5782
|
const [key] = keys;
|
|
5517
5783
|
const value2 = meta.dynamicValues[key];
|
|
5518
|
-
stmt =
|
|
5784
|
+
stmt = import_compiler30.types.expressionStatement(
|
|
5519
5785
|
callRuntime(
|
|
5520
5786
|
`_attr_${name2}_item`,
|
|
5521
5787
|
nodeExpr,
|
|
5522
|
-
|
|
5788
|
+
import_compiler30.types.stringLiteral(key),
|
|
5523
5789
|
value2
|
|
5524
5790
|
)
|
|
5525
5791
|
);
|
|
@@ -5528,14 +5794,14 @@ var native_tag_default = {
|
|
|
5528
5794
|
for (const key of keys) {
|
|
5529
5795
|
const value2 = meta.dynamicValues[key];
|
|
5530
5796
|
props.push(
|
|
5531
|
-
|
|
5797
|
+
import_compiler30.types.objectProperty(toPropertyName(key), value2)
|
|
5532
5798
|
);
|
|
5533
5799
|
}
|
|
5534
|
-
stmt =
|
|
5800
|
+
stmt = import_compiler30.types.expressionStatement(
|
|
5535
5801
|
callRuntime(
|
|
5536
5802
|
`_attr_${name2}_items`,
|
|
5537
5803
|
nodeExpr,
|
|
5538
|
-
|
|
5804
|
+
import_compiler30.types.objectExpression(props)
|
|
5539
5805
|
)
|
|
5540
5806
|
);
|
|
5541
5807
|
}
|
|
@@ -5555,11 +5821,11 @@ var native_tag_default = {
|
|
|
5555
5821
|
"effect",
|
|
5556
5822
|
tagSection,
|
|
5557
5823
|
valueReferences,
|
|
5558
|
-
|
|
5824
|
+
import_compiler30.types.expressionStatement(
|
|
5559
5825
|
callRuntime(
|
|
5560
5826
|
"_on",
|
|
5561
|
-
|
|
5562
|
-
|
|
5827
|
+
import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
5828
|
+
import_compiler30.types.stringLiteral(getEventHandlerName(name2)),
|
|
5563
5829
|
value
|
|
5564
5830
|
)
|
|
5565
5831
|
)
|
|
@@ -5569,11 +5835,11 @@ var native_tag_default = {
|
|
|
5569
5835
|
"render",
|
|
5570
5836
|
tagSection,
|
|
5571
5837
|
valueReferences,
|
|
5572
|
-
|
|
5838
|
+
import_compiler30.types.expressionStatement(
|
|
5573
5839
|
callRuntime(
|
|
5574
5840
|
"_attr",
|
|
5575
|
-
|
|
5576
|
-
|
|
5841
|
+
import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
5842
|
+
import_compiler30.types.stringLiteral(name2),
|
|
5577
5843
|
value
|
|
5578
5844
|
)
|
|
5579
5845
|
)
|
|
@@ -5589,7 +5855,7 @@ var native_tag_default = {
|
|
|
5589
5855
|
"render",
|
|
5590
5856
|
tagSection,
|
|
5591
5857
|
tagExtra.referencedBindings,
|
|
5592
|
-
|
|
5858
|
+
import_compiler30.types.expressionStatement(
|
|
5593
5859
|
callRuntime(
|
|
5594
5860
|
canHaveAttrContent ? "_attrs_partial_content" : "_attrs_partial",
|
|
5595
5861
|
scopeIdentifier,
|
|
@@ -5604,7 +5870,7 @@ var native_tag_default = {
|
|
|
5604
5870
|
"render",
|
|
5605
5871
|
tagSection,
|
|
5606
5872
|
tagExtra.referencedBindings,
|
|
5607
|
-
|
|
5873
|
+
import_compiler30.types.expressionStatement(
|
|
5608
5874
|
callRuntime(
|
|
5609
5875
|
canHaveAttrContent ? "_attrs_content" : "_attrs",
|
|
5610
5876
|
scopeIdentifier,
|
|
@@ -5618,7 +5884,7 @@ var native_tag_default = {
|
|
|
5618
5884
|
"effect",
|
|
5619
5885
|
tagSection,
|
|
5620
5886
|
tagExtra.referencedBindings,
|
|
5621
|
-
|
|
5887
|
+
import_compiler30.types.expressionStatement(
|
|
5622
5888
|
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
5623
5889
|
),
|
|
5624
5890
|
false
|
|
@@ -5630,7 +5896,7 @@ var native_tag_default = {
|
|
|
5630
5896
|
"render",
|
|
5631
5897
|
tagSection,
|
|
5632
5898
|
contentAttrValue.extra?.referencedBindings,
|
|
5633
|
-
|
|
5899
|
+
import_compiler30.types.expressionStatement(
|
|
5634
5900
|
callRuntime(
|
|
5635
5901
|
"_attr_content",
|
|
5636
5902
|
scopeIdentifier,
|
|
@@ -5748,7 +6014,7 @@ function getUsedAttrs(tagName, tag) {
|
|
|
5748
6014
|
for (let i = attributes.length; i--; ) {
|
|
5749
6015
|
const attr = attributes[i];
|
|
5750
6016
|
const { value } = attr;
|
|
5751
|
-
if (
|
|
6017
|
+
if (import_compiler30.types.isMarkoSpreadAttribute(attr)) {
|
|
5752
6018
|
if (!spreadProps) {
|
|
5753
6019
|
spreadProps = [];
|
|
5754
6020
|
staticControllable = getRelatedControllable(tagName, seen);
|
|
@@ -5762,7 +6028,7 @@ function getUsedAttrs(tagName, tag) {
|
|
|
5762
6028
|
staticControllable = void 0;
|
|
5763
6029
|
}
|
|
5764
6030
|
}
|
|
5765
|
-
spreadProps.push(
|
|
6031
|
+
spreadProps.push(import_compiler30.types.spreadElement(value));
|
|
5766
6032
|
} else if (!seen[attr.name] || !(attr.name === "content" && tag.body.body.length)) {
|
|
5767
6033
|
seen[attr.name] = attr;
|
|
5768
6034
|
if (spreadProps) {
|
|
@@ -5794,18 +6060,18 @@ function getUsedAttrs(tagName, tag) {
|
|
|
5794
6060
|
for (const attr of staticControllable.attrs) {
|
|
5795
6061
|
if (attr) {
|
|
5796
6062
|
(skipProps ||= []).push(
|
|
5797
|
-
toObjectProperty(attr.name,
|
|
6063
|
+
toObjectProperty(attr.name, import_compiler30.types.numericLiteral(1))
|
|
5798
6064
|
);
|
|
5799
6065
|
}
|
|
5800
6066
|
}
|
|
5801
6067
|
}
|
|
5802
6068
|
for (const { name: name2 } of staticAttrs) {
|
|
5803
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
|
6069
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler30.types.numericLiteral(1)));
|
|
5804
6070
|
}
|
|
5805
6071
|
spreadExpression = propsToExpression(spreadProps);
|
|
5806
6072
|
}
|
|
5807
6073
|
if (skipProps) {
|
|
5808
|
-
skipExpression =
|
|
6074
|
+
skipExpression = import_compiler30.types.objectExpression(skipProps);
|
|
5809
6075
|
}
|
|
5810
6076
|
return {
|
|
5811
6077
|
staticAttrs,
|
|
@@ -5892,14 +6158,14 @@ function trackDelimitedAttrObjectProperties(obj, meta) {
|
|
|
5892
6158
|
(meta.staticItems ||= []).push(staticProps);
|
|
5893
6159
|
}
|
|
5894
6160
|
if (dynamicProps) {
|
|
5895
|
-
(meta.dynamicItems ||= []).push(
|
|
6161
|
+
(meta.dynamicItems ||= []).push(import_compiler30.types.objectExpression(dynamicProps));
|
|
5896
6162
|
}
|
|
5897
6163
|
}
|
|
5898
6164
|
function isNativeTagChangeHandler(propName) {
|
|
5899
6165
|
return /^(?:value|checked(?:Value)?|open)Change$/.test(propName);
|
|
5900
6166
|
}
|
|
5901
|
-
function
|
|
5902
|
-
return
|
|
6167
|
+
function buildUndefined2() {
|
|
6168
|
+
return import_compiler30.types.unaryExpression("void", import_compiler30.types.numericLiteral(0));
|
|
5903
6169
|
}
|
|
5904
6170
|
|
|
5905
6171
|
// src/translator/util/is-only-child-in-parent.ts
|
|
@@ -6035,39 +6301,45 @@ var for_default = {
|
|
|
6035
6301
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
|
6036
6302
|
const forTagHTMLRuntime = branchSerializeReason ? forTypeToHTMLResumeRuntime(forType) : forTypeToRuntime(forType);
|
|
6037
6303
|
forTagArgs.push(
|
|
6038
|
-
|
|
6304
|
+
import_compiler32.types.arrowFunctionExpression(params, import_compiler32.types.blockStatement(bodyStatements))
|
|
6039
6305
|
);
|
|
6040
6306
|
if (branchSerializeReason) {
|
|
6041
6307
|
const skipParentEnd = onlyChildParentTagName && markerSerializeReason;
|
|
6042
6308
|
const statefulSerializeArg = getSerializeGuard(
|
|
6309
|
+
tagSection,
|
|
6043
6310
|
getSerializeReason(tagSection, kStatefulReason),
|
|
6044
6311
|
!(skipParentEnd || singleNodeOptimization)
|
|
6045
6312
|
);
|
|
6046
6313
|
const markerSerializeArg = getSerializeGuard(
|
|
6314
|
+
tagSection,
|
|
6047
6315
|
markerSerializeReason,
|
|
6048
6316
|
!statefulSerializeArg
|
|
6049
6317
|
);
|
|
6050
6318
|
forTagArgs.push(
|
|
6051
|
-
forAttrs.by ||
|
|
6319
|
+
forAttrs.by || import_compiler32.types.numericLiteral(0),
|
|
6052
6320
|
getScopeIdIdentifier(tagSection),
|
|
6053
6321
|
getScopeAccessorLiteral(nodeBinding),
|
|
6054
|
-
getSerializeGuard(
|
|
6322
|
+
getSerializeGuard(
|
|
6323
|
+
tagSection,
|
|
6324
|
+
branchSerializeReason,
|
|
6325
|
+
!markerSerializeArg
|
|
6326
|
+
),
|
|
6055
6327
|
markerSerializeArg,
|
|
6056
6328
|
statefulSerializeArg
|
|
6057
6329
|
);
|
|
6058
6330
|
if (skipParentEnd) {
|
|
6059
6331
|
getParentTag(tag).node.extra[kSkipEndTag] = true;
|
|
6060
|
-
forTagArgs.push(
|
|
6332
|
+
forTagArgs.push(import_compiler32.types.stringLiteral(`</${onlyChildParentTagName}>`));
|
|
6061
6333
|
}
|
|
6062
6334
|
if (singleNodeOptimization) {
|
|
6063
6335
|
if (!skipParentEnd) {
|
|
6064
|
-
forTagArgs.push(
|
|
6336
|
+
forTagArgs.push(import_compiler32.types.numericLiteral(0));
|
|
6065
6337
|
}
|
|
6066
|
-
forTagArgs.push(
|
|
6338
|
+
forTagArgs.push(import_compiler32.types.numericLiteral(1));
|
|
6067
6339
|
}
|
|
6068
6340
|
}
|
|
6069
6341
|
statements.push(
|
|
6070
|
-
|
|
6342
|
+
import_compiler32.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
|
6071
6343
|
);
|
|
6072
6344
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
6073
6345
|
replacement.skip();
|
|
@@ -6112,7 +6384,7 @@ var for_default = {
|
|
|
6112
6384
|
return callRuntime(
|
|
6113
6385
|
forTypeToDOMRuntime(forType),
|
|
6114
6386
|
getScopeAccessorLiteral(nodeRef),
|
|
6115
|
-
|
|
6387
|
+
import_compiler32.types.identifier(bodySection.name)
|
|
6116
6388
|
);
|
|
6117
6389
|
};
|
|
6118
6390
|
const forAttrs = getKnownAttrValues(node);
|
|
@@ -6124,7 +6396,7 @@ var for_default = {
|
|
|
6124
6396
|
tagSection,
|
|
6125
6397
|
referencedBindings,
|
|
6126
6398
|
signal,
|
|
6127
|
-
|
|
6399
|
+
import_compiler32.types.arrayExpression(loopArgs)
|
|
6128
6400
|
);
|
|
6129
6401
|
tag.remove();
|
|
6130
6402
|
}
|
|
@@ -6202,11 +6474,11 @@ var for_default = {
|
|
|
6202
6474
|
]
|
|
6203
6475
|
};
|
|
6204
6476
|
function buildForRuntimeCall(type, attrs, params, statements) {
|
|
6205
|
-
return
|
|
6477
|
+
return import_compiler32.types.expressionStatement(
|
|
6206
6478
|
callRuntime(
|
|
6207
6479
|
forTypeToRuntime(type),
|
|
6208
6480
|
...getBaseArgsInForTag(type, attrs),
|
|
6209
|
-
|
|
6481
|
+
import_compiler32.types.arrowFunctionExpression(params, import_compiler32.types.blockStatement(statements))
|
|
6210
6482
|
)
|
|
6211
6483
|
);
|
|
6212
6484
|
}
|
|
@@ -6268,14 +6540,14 @@ function getBaseArgsInForTag(type, attrs) {
|
|
|
6268
6540
|
case "to":
|
|
6269
6541
|
return [
|
|
6270
6542
|
attrs.to,
|
|
6271
|
-
attrs.from ||
|
|
6272
|
-
attrs.step ||
|
|
6543
|
+
attrs.from || import_compiler32.types.numericLiteral(0),
|
|
6544
|
+
attrs.step || import_compiler32.types.numericLiteral(1)
|
|
6273
6545
|
];
|
|
6274
6546
|
case "until":
|
|
6275
6547
|
return [
|
|
6276
6548
|
attrs.until,
|
|
6277
|
-
attrs.from ||
|
|
6278
|
-
attrs.step ||
|
|
6549
|
+
attrs.from || import_compiler32.types.numericLiteral(0),
|
|
6550
|
+
attrs.step || import_compiler32.types.numericLiteral(1)
|
|
6279
6551
|
];
|
|
6280
6552
|
}
|
|
6281
6553
|
}
|
|
@@ -6293,8 +6565,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6293
6565
|
seen.add(attrTagMeta.name);
|
|
6294
6566
|
if (attrTagMeta.dynamic) {
|
|
6295
6567
|
statements.push(
|
|
6296
|
-
|
|
6297
|
-
|
|
6568
|
+
import_compiler33.types.variableDeclaration("let", [
|
|
6569
|
+
import_compiler33.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
|
|
6298
6570
|
])
|
|
6299
6571
|
);
|
|
6300
6572
|
properties.push(
|
|
@@ -6375,8 +6647,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6375
6647
|
if (!seen.has(contentKey) && usesExport(templateExports, contentKey)) {
|
|
6376
6648
|
const contentExpression = buildContent(tag.get("body"));
|
|
6377
6649
|
if (contentExpression) {
|
|
6378
|
-
const contentProp =
|
|
6379
|
-
|
|
6650
|
+
const contentProp = import_compiler33.types.objectProperty(
|
|
6651
|
+
import_compiler33.types.identifier(contentKey),
|
|
6380
6652
|
contentExpression
|
|
6381
6653
|
);
|
|
6382
6654
|
seen.add(contentKey);
|
|
@@ -6388,8 +6660,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6388
6660
|
for (let i = attributes.length; i--; ) {
|
|
6389
6661
|
const attr = attributes[i];
|
|
6390
6662
|
const { value } = attr;
|
|
6391
|
-
if (
|
|
6392
|
-
properties.push(
|
|
6663
|
+
if (import_compiler33.types.isMarkoSpreadAttribute(attr)) {
|
|
6664
|
+
properties.push(import_compiler33.types.spreadElement(value));
|
|
6393
6665
|
} else if (!seen.has(attr.name) && usesExport(templateExports, attr.name)) {
|
|
6394
6666
|
seen.add(attr.name);
|
|
6395
6667
|
properties.push(toObjectProperty(attr.name, value));
|
|
@@ -6419,8 +6691,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6419
6691
|
);
|
|
6420
6692
|
if (attrTagMeta.repeated) {
|
|
6421
6693
|
statements.push(
|
|
6422
|
-
|
|
6423
|
-
|
|
6694
|
+
import_compiler33.types.expressionStatement(
|
|
6695
|
+
import_compiler33.types.assignmentExpression(
|
|
6424
6696
|
"=",
|
|
6425
6697
|
getAttrTagIdentifier(attrTagMeta),
|
|
6426
6698
|
callRuntime(
|
|
@@ -6433,8 +6705,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6433
6705
|
);
|
|
6434
6706
|
} else {
|
|
6435
6707
|
statements.push(
|
|
6436
|
-
|
|
6437
|
-
|
|
6708
|
+
import_compiler33.types.expressionStatement(
|
|
6709
|
+
import_compiler33.types.assignmentExpression(
|
|
6438
6710
|
"=",
|
|
6439
6711
|
getAttrTagIdentifier(attrTagMeta),
|
|
6440
6712
|
callRuntime(
|
|
@@ -6473,7 +6745,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6473
6745
|
return index;
|
|
6474
6746
|
}
|
|
6475
6747
|
function propsToExpression(props) {
|
|
6476
|
-
return props.length === 1 &&
|
|
6748
|
+
return props.length === 1 && import_compiler33.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler33.types.objectExpression(props);
|
|
6477
6749
|
}
|
|
6478
6750
|
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6479
6751
|
const forTag = attrTags2[index];
|
|
@@ -6498,9 +6770,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
|
6498
6770
|
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6499
6771
|
const ifTag = attrTags2[index];
|
|
6500
6772
|
const consequentStatements = [];
|
|
6501
|
-
let ifStatement =
|
|
6773
|
+
let ifStatement = import_compiler33.types.ifStatement(
|
|
6502
6774
|
getConditionTestValue(ifTag),
|
|
6503
|
-
|
|
6775
|
+
import_compiler33.types.blockStatement(consequentStatements)
|
|
6504
6776
|
);
|
|
6505
6777
|
statements.push(ifStatement);
|
|
6506
6778
|
addAllAttrTagsAsDynamic(
|
|
@@ -6527,14 +6799,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
6527
6799
|
contentKey
|
|
6528
6800
|
);
|
|
6529
6801
|
if (testValue) {
|
|
6530
|
-
ifStatement.alternate = ifStatement =
|
|
6802
|
+
ifStatement.alternate = ifStatement = import_compiler33.types.ifStatement(
|
|
6531
6803
|
testValue,
|
|
6532
|
-
|
|
6804
|
+
import_compiler33.types.blockStatement(alternateStatements)
|
|
6533
6805
|
);
|
|
6534
6806
|
nextIndex++;
|
|
6535
6807
|
continue;
|
|
6536
6808
|
} else {
|
|
6537
|
-
ifStatement.alternate =
|
|
6809
|
+
ifStatement.alternate = import_compiler33.types.blockStatement(alternateStatements);
|
|
6538
6810
|
break;
|
|
6539
6811
|
}
|
|
6540
6812
|
}
|
|
@@ -6600,20 +6872,22 @@ function buildContent(body) {
|
|
|
6600
6872
|
}
|
|
6601
6873
|
if (dynamicSerializeReason) {
|
|
6602
6874
|
body.node.body.unshift(
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6875
|
+
import_compiler33.types.variableDeclaration("const", [
|
|
6876
|
+
import_compiler33.types.variableDeclarator(
|
|
6877
|
+
import_compiler33.types.identifier(
|
|
6878
|
+
getSharedUid(`scope${bodySection.id}_reason`, bodySection)
|
|
6879
|
+
),
|
|
6880
|
+
callRuntime("_scope_reason")
|
|
6607
6881
|
)
|
|
6608
6882
|
])
|
|
6609
6883
|
);
|
|
6610
6884
|
}
|
|
6611
6885
|
return callRuntime(
|
|
6612
6886
|
serialized ? "_content_resume" : "_content",
|
|
6613
|
-
|
|
6614
|
-
|
|
6887
|
+
import_compiler33.types.stringLiteral(getResumeRegisterId(bodySection, "content")),
|
|
6888
|
+
import_compiler33.types.arrowFunctionExpression(
|
|
6615
6889
|
body.node.params,
|
|
6616
|
-
|
|
6890
|
+
import_compiler33.types.blockStatement(body.node.body)
|
|
6617
6891
|
),
|
|
6618
6892
|
serialized ? getScopeIdIdentifier(
|
|
6619
6893
|
getSection(
|
|
@@ -6624,17 +6898,17 @@ function buildContent(body) {
|
|
|
6624
6898
|
) : void 0
|
|
6625
6899
|
);
|
|
6626
6900
|
} else {
|
|
6627
|
-
return
|
|
6628
|
-
|
|
6901
|
+
return import_compiler33.types.callExpression(
|
|
6902
|
+
import_compiler33.types.identifier(bodySection.name),
|
|
6629
6903
|
bodySection.referencedLocalClosures ? [
|
|
6630
6904
|
scopeIdentifier,
|
|
6631
|
-
|
|
6905
|
+
import_compiler33.types.objectExpression(
|
|
6632
6906
|
toArray(bodySection.referencedLocalClosures, (ref) => {
|
|
6633
6907
|
const accessor = getScopeAccessor(ref);
|
|
6634
6908
|
const isShorthand = accessor === ref.name;
|
|
6635
|
-
return
|
|
6909
|
+
return import_compiler33.types.objectProperty(
|
|
6636
6910
|
toPropertyName(accessor),
|
|
6637
|
-
|
|
6911
|
+
import_compiler33.types.identifier(ref.name),
|
|
6638
6912
|
false,
|
|
6639
6913
|
isShorthand
|
|
6640
6914
|
);
|
|
@@ -6719,8 +6993,8 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
6719
6993
|
if (childScopeSerializeReason) {
|
|
6720
6994
|
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
|
6721
6995
|
tag.insertBefore(
|
|
6722
|
-
|
|
6723
|
-
|
|
6996
|
+
import_compiler34.types.variableDeclaration("const", [
|
|
6997
|
+
import_compiler34.types.variableDeclarator(peekScopeId, callRuntime("_peek_scope_id"))
|
|
6724
6998
|
])
|
|
6725
6999
|
);
|
|
6726
7000
|
setBindingSerializedValue(
|
|
@@ -6730,13 +7004,13 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
6730
7004
|
);
|
|
6731
7005
|
if (tagVar) {
|
|
6732
7006
|
statements.push(
|
|
6733
|
-
|
|
7007
|
+
import_compiler34.types.expressionStatement(
|
|
6734
7008
|
callRuntime(
|
|
6735
7009
|
"_var",
|
|
6736
7010
|
getScopeIdIdentifier(section),
|
|
6737
7011
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
|
6738
7012
|
peekScopeId,
|
|
6739
|
-
|
|
7013
|
+
import_compiler34.types.stringLiteral(
|
|
6740
7014
|
getResumeRegisterId(
|
|
6741
7015
|
section,
|
|
6742
7016
|
node.var.extra?.binding,
|
|
@@ -6754,7 +7028,7 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
6754
7028
|
if (contentSection.paramReasonGroups.length === 1) {
|
|
6755
7029
|
const [group] = contentSection.paramReasonGroups;
|
|
6756
7030
|
const reason = getSerializeReason(section, childScopeBinding, group.id);
|
|
6757
|
-
childSerializeReasonExpr = reason && getSerializeGuard(reason, false);
|
|
7031
|
+
childSerializeReasonExpr = reason && getSerializeGuard(section, reason, false);
|
|
6758
7032
|
} else {
|
|
6759
7033
|
const props = [];
|
|
6760
7034
|
let hasDynamicReasons = false;
|
|
@@ -6765,12 +7039,12 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
6765
7039
|
if (reason) {
|
|
6766
7040
|
hasDynamicReasons ||= reason !== true && !reason.state;
|
|
6767
7041
|
props.push(
|
|
6768
|
-
|
|
7042
|
+
import_compiler34.types.objectProperty(
|
|
6769
7043
|
withLeadingComment(
|
|
6770
|
-
|
|
7044
|
+
import_compiler34.types.numericLiteral(i),
|
|
6771
7045
|
getDebugNames(group.reason)
|
|
6772
7046
|
),
|
|
6773
|
-
getSerializeGuard(reason, false)
|
|
7047
|
+
getSerializeGuard(section, reason, false)
|
|
6774
7048
|
)
|
|
6775
7049
|
);
|
|
6776
7050
|
} else {
|
|
@@ -6778,12 +7052,12 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
6778
7052
|
}
|
|
6779
7053
|
}
|
|
6780
7054
|
if (props.length) {
|
|
6781
|
-
childSerializeReasonExpr = hasDynamicReasons || hasSkippedReasons ?
|
|
7055
|
+
childSerializeReasonExpr = hasDynamicReasons || hasSkippedReasons ? import_compiler34.types.objectExpression(props) : import_compiler34.types.numericLiteral(1);
|
|
6782
7056
|
}
|
|
6783
7057
|
}
|
|
6784
7058
|
if (childSerializeReasonExpr) {
|
|
6785
7059
|
tag.insertBefore(
|
|
6786
|
-
|
|
7060
|
+
import_compiler34.types.expressionStatement(
|
|
6787
7061
|
callRuntime("_set_serialize_reason", childSerializeReasonExpr)
|
|
6788
7062
|
)
|
|
6789
7063
|
);
|
|
@@ -6806,8 +7080,8 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
6806
7080
|
const contentExpression = contentProp.value;
|
|
6807
7081
|
contentProp.value = contentId = generateUidIdentifier("content");
|
|
6808
7082
|
const [contentPath] = tag.insertBefore(
|
|
6809
|
-
|
|
6810
|
-
|
|
7083
|
+
import_compiler34.types.variableDeclaration("const", [
|
|
7084
|
+
import_compiler34.types.variableDeclarator(
|
|
6811
7085
|
contentId,
|
|
6812
7086
|
// TODO: only register if needed (child template analysis)
|
|
6813
7087
|
contentExpression
|
|
@@ -6821,13 +7095,13 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
6821
7095
|
...getArgs()
|
|
6822
7096
|
);
|
|
6823
7097
|
if (tagVar) {
|
|
6824
|
-
translateVar(tag,
|
|
6825
|
-
renderTagExpr =
|
|
7098
|
+
translateVar(tag, import_compiler34.types.unaryExpression("void", import_compiler34.types.numericLiteral(0)), "let");
|
|
7099
|
+
renderTagExpr = import_compiler34.types.assignmentExpression("=", tagVar, renderTagExpr);
|
|
6826
7100
|
}
|
|
6827
7101
|
statements.push(
|
|
6828
|
-
|
|
7102
|
+
import_compiler34.types.ifStatement(
|
|
6829
7103
|
tagIdentifier,
|
|
6830
|
-
|
|
7104
|
+
import_compiler34.types.expressionStatement(renderTagExpr),
|
|
6831
7105
|
contentId && callStatement(contentId)
|
|
6832
7106
|
)
|
|
6833
7107
|
);
|
|
@@ -6858,15 +7132,15 @@ function knownTagTranslateDOM(tag, propTree, getBindingIdentifier, callSetup) {
|
|
|
6858
7132
|
value
|
|
6859
7133
|
];
|
|
6860
7134
|
if (!isOptimize()) {
|
|
6861
|
-
changeArgs.push(
|
|
7135
|
+
changeArgs.push(import_compiler34.types.stringLiteral(varBinding.name));
|
|
6862
7136
|
}
|
|
6863
|
-
return
|
|
7137
|
+
return import_compiler34.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
6864
7138
|
};
|
|
6865
7139
|
addStatement(
|
|
6866
7140
|
"render",
|
|
6867
7141
|
tagSection,
|
|
6868
7142
|
void 0,
|
|
6869
|
-
|
|
7143
|
+
import_compiler34.types.expressionStatement(
|
|
6870
7144
|
callRuntime(
|
|
6871
7145
|
"_var",
|
|
6872
7146
|
scopeIdentifier,
|
|
@@ -6911,7 +7185,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6911
7185
|
dropReferences(getAllTagReferenceNodes(tag.node));
|
|
6912
7186
|
return inputExpr;
|
|
6913
7187
|
}
|
|
6914
|
-
if (!propTree.props || tag.node.arguments?.some((node) =>
|
|
7188
|
+
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler34.types.isSpreadElement(node))) {
|
|
6915
7189
|
const extra = inputExpr.value = mergeReferences(
|
|
6916
7190
|
section,
|
|
6917
7191
|
tag.node,
|
|
@@ -7061,7 +7335,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7061
7335
|
let spreadReferenceNodes;
|
|
7062
7336
|
for (let i = attributes.length; i--; ) {
|
|
7063
7337
|
const attr = attributes[i];
|
|
7064
|
-
if (
|
|
7338
|
+
if (import_compiler34.types.isMarkoAttribute(attr)) {
|
|
7065
7339
|
const templateExportAttr = propTree.props[attr.name];
|
|
7066
7340
|
if (!templateExportAttr || seen.has(attr.name)) {
|
|
7067
7341
|
dropReferences(attr.value);
|
|
@@ -7075,7 +7349,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7075
7349
|
}
|
|
7076
7350
|
if (spreadReferenceNodes) {
|
|
7077
7351
|
spreadReferenceNodes.push(attr.value);
|
|
7078
|
-
} else if (
|
|
7352
|
+
} else if (import_compiler34.types.isMarkoSpreadAttribute(attr)) {
|
|
7079
7353
|
spreadReferenceNodes = [attr.value];
|
|
7080
7354
|
} else {
|
|
7081
7355
|
const attrValueExtra = attr.value.extra ??= {};
|
|
@@ -7107,7 +7381,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7107
7381
|
return inputExpr;
|
|
7108
7382
|
}
|
|
7109
7383
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
7110
|
-
if (!propTree.props || tag.node.arguments?.some((node) =>
|
|
7384
|
+
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler34.types.isSpreadElement(node))) {
|
|
7111
7385
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7112
7386
|
const tagInputIdentifier = info.getBindingIdentifier(
|
|
7113
7387
|
propTree.binding,
|
|
@@ -7135,8 +7409,8 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7135
7409
|
"render",
|
|
7136
7410
|
info.tagSection,
|
|
7137
7411
|
referencedBindings,
|
|
7138
|
-
|
|
7139
|
-
|
|
7412
|
+
import_compiler34.types.expressionStatement(
|
|
7413
|
+
import_compiler34.types.callExpression(tagInputIdentifier, [import_compiler34.types.arrayExpression(renderArgs)])
|
|
7140
7414
|
)
|
|
7141
7415
|
);
|
|
7142
7416
|
return;
|
|
@@ -7155,8 +7429,8 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7155
7429
|
info.tagSection,
|
|
7156
7430
|
arg.extra?.referencedBindings,
|
|
7157
7431
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7158
|
-
|
|
7159
|
-
|
|
7432
|
+
import_compiler34.types.expressionStatement(
|
|
7433
|
+
import_compiler34.types.callExpression(argExportIdentifier, [
|
|
7160
7434
|
createScopeReadExpression(
|
|
7161
7435
|
info.tagSection,
|
|
7162
7436
|
info.childScopeBinding
|
|
@@ -7216,7 +7490,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7216
7490
|
} else {
|
|
7217
7491
|
attrTagCallsForTag.set(
|
|
7218
7492
|
attrTagName,
|
|
7219
|
-
translatedProps =
|
|
7493
|
+
translatedProps = import_compiler34.types.parenthesizedExpression(
|
|
7220
7494
|
callRuntime("attrTag", translatedProps)
|
|
7221
7495
|
)
|
|
7222
7496
|
);
|
|
@@ -7229,8 +7503,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7229
7503
|
"render",
|
|
7230
7504
|
info.tagSection,
|
|
7231
7505
|
referencedBindings,
|
|
7232
|
-
|
|
7233
|
-
|
|
7506
|
+
import_compiler34.types.expressionStatement(
|
|
7507
|
+
import_compiler34.types.callExpression(tagInputIdentifier, [
|
|
7234
7508
|
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
|
7235
7509
|
translatedProps
|
|
7236
7510
|
])
|
|
@@ -7303,17 +7577,17 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7303
7577
|
childAttrExports.binding,
|
|
7304
7578
|
`${importAlias}_${attrTagMeta.name}`
|
|
7305
7579
|
);
|
|
7306
|
-
decls.push(
|
|
7580
|
+
decls.push(import_compiler34.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
7307
7581
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
7308
|
-
|
|
7582
|
+
import_compiler34.types.variableDeclaration("let", decls),
|
|
7309
7583
|
...statements
|
|
7310
7584
|
]);
|
|
7311
7585
|
addStatement(
|
|
7312
7586
|
"render",
|
|
7313
7587
|
info.tagSection,
|
|
7314
7588
|
referencedBindings,
|
|
7315
|
-
|
|
7316
|
-
|
|
7589
|
+
import_compiler34.types.expressionStatement(
|
|
7590
|
+
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7317
7591
|
createScopeReadExpression(
|
|
7318
7592
|
info.tagSection,
|
|
7319
7593
|
info.childScopeBinding
|
|
@@ -7338,10 +7612,10 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7338
7612
|
info.tagSection,
|
|
7339
7613
|
void 0,
|
|
7340
7614
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7341
|
-
|
|
7342
|
-
|
|
7615
|
+
import_compiler34.types.expressionStatement(
|
|
7616
|
+
import_compiler34.types.callExpression(contentExportIdentifier, [
|
|
7343
7617
|
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
|
7344
|
-
|
|
7618
|
+
import_compiler34.types.callExpression(import_compiler34.types.identifier(bodySection.name), [scopeIdentifier])
|
|
7345
7619
|
])
|
|
7346
7620
|
)
|
|
7347
7621
|
);
|
|
@@ -7352,7 +7626,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7352
7626
|
let spreadProps;
|
|
7353
7627
|
for (let i = attributes.length; i--; ) {
|
|
7354
7628
|
const attr = attributes[i];
|
|
7355
|
-
if (
|
|
7629
|
+
if (import_compiler34.types.isMarkoAttribute(attr)) {
|
|
7356
7630
|
const childAttrExports = propTree.props[attr.name];
|
|
7357
7631
|
if (!childAttrExports || seen.has(attr.name)) continue;
|
|
7358
7632
|
seen.add(attr.name);
|
|
@@ -7362,9 +7636,9 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7362
7636
|
}
|
|
7363
7637
|
staticAttrs.push(attr);
|
|
7364
7638
|
} else if (spreadProps) {
|
|
7365
|
-
spreadProps.push(
|
|
7639
|
+
spreadProps.push(import_compiler34.types.spreadElement(attr.value));
|
|
7366
7640
|
} else {
|
|
7367
|
-
spreadProps = [
|
|
7641
|
+
spreadProps = [import_compiler34.types.spreadElement(attr.value)];
|
|
7368
7642
|
}
|
|
7369
7643
|
}
|
|
7370
7644
|
for (const attr of staticAttrs.reverse()) {
|
|
@@ -7377,8 +7651,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7377
7651
|
"render",
|
|
7378
7652
|
info.tagSection,
|
|
7379
7653
|
attr.value.extra?.referencedBindings,
|
|
7380
|
-
|
|
7381
|
-
|
|
7654
|
+
import_compiler34.types.expressionStatement(
|
|
7655
|
+
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7382
7656
|
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
|
7383
7657
|
attr.value
|
|
7384
7658
|
])
|
|
@@ -7389,14 +7663,14 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7389
7663
|
for (const name2 of seen) missing.delete(name2);
|
|
7390
7664
|
if (missing.size) {
|
|
7391
7665
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7392
|
-
let getMissingPropValue =
|
|
7666
|
+
let getMissingPropValue = buildUndefined3;
|
|
7393
7667
|
if (spreadProps) {
|
|
7394
7668
|
const spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
7395
7669
|
spreadProps.reverse();
|
|
7396
7670
|
getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
|
|
7397
7671
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
7398
|
-
|
|
7399
|
-
|
|
7672
|
+
import_compiler34.types.variableDeclaration("const", [
|
|
7673
|
+
import_compiler34.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
|
|
7400
7674
|
])
|
|
7401
7675
|
]);
|
|
7402
7676
|
}
|
|
@@ -7410,8 +7684,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7410
7684
|
"render",
|
|
7411
7685
|
info.tagSection,
|
|
7412
7686
|
referencedBindings,
|
|
7413
|
-
|
|
7414
|
-
|
|
7687
|
+
import_compiler34.types.expressionStatement(
|
|
7688
|
+
import_compiler34.types.callExpression(attrExportIdentifier, [
|
|
7415
7689
|
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
|
7416
7690
|
getMissingPropValue(name2)
|
|
7417
7691
|
])
|
|
@@ -7447,21 +7721,13 @@ function mapParamReasonToExpr(exprs, reason) {
|
|
|
7447
7721
|
}
|
|
7448
7722
|
}
|
|
7449
7723
|
function callStatement(id, ...args) {
|
|
7450
|
-
return
|
|
7724
|
+
return import_compiler34.types.expressionStatement(callExpression(id, ...args));
|
|
7451
7725
|
}
|
|
7452
7726
|
function callExpression(id, ...args) {
|
|
7453
|
-
return
|
|
7454
|
-
}
|
|
7455
|
-
function buildUndefined2() {
|
|
7456
|
-
return import_compiler33.types.unaryExpression("void", import_compiler33.types.numericLiteral(0));
|
|
7727
|
+
return import_compiler34.types.callExpression(id, args.filter(Boolean));
|
|
7457
7728
|
}
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
function withPreviousLocation(newNode, originalNode) {
|
|
7461
|
-
newNode.start = originalNode.start;
|
|
7462
|
-
newNode.loc = originalNode.loc;
|
|
7463
|
-
newNode.end = originalNode.end;
|
|
7464
|
-
return newNode;
|
|
7729
|
+
function buildUndefined3() {
|
|
7730
|
+
return import_compiler34.types.unaryExpression("void", import_compiler34.types.numericLiteral(0));
|
|
7465
7731
|
}
|
|
7466
7732
|
|
|
7467
7733
|
// src/translator/util/references.ts
|
|
@@ -7574,7 +7840,7 @@ function trackParamsReferences(body, type, upstreamAlias) {
|
|
|
7574
7840
|
void 0,
|
|
7575
7841
|
i > 0 ? addNumericPropertiesUntil(void 0, i - 1) : void 0
|
|
7576
7842
|
);
|
|
7577
|
-
} else if (
|
|
7843
|
+
} else if (import_compiler35.types.isLVal(param)) {
|
|
7578
7844
|
createBindingsAndTrackReferences(
|
|
7579
7845
|
param,
|
|
7580
7846
|
type,
|
|
@@ -7745,7 +8011,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
7745
8011
|
if (hasRest) {
|
|
7746
8012
|
excludeProperties = propsUtil.add(excludeProperties, key);
|
|
7747
8013
|
}
|
|
7748
|
-
if (
|
|
8014
|
+
if (import_compiler35.types.isLVal(prop.value)) {
|
|
7749
8015
|
createBindingsAndTrackReferences(
|
|
7750
8016
|
prop.value,
|
|
7751
8017
|
type,
|
|
@@ -7785,7 +8051,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
7785
8051
|
property,
|
|
7786
8052
|
excludeProperties
|
|
7787
8053
|
);
|
|
7788
|
-
} else if (
|
|
8054
|
+
} else if (import_compiler35.types.isLVal(element)) {
|
|
7789
8055
|
createBindingsAndTrackReferences(
|
|
7790
8056
|
element,
|
|
7791
8057
|
type,
|
|
@@ -7800,23 +8066,6 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
7800
8066
|
}
|
|
7801
8067
|
break;
|
|
7802
8068
|
}
|
|
7803
|
-
case "AssignmentPattern":
|
|
7804
|
-
createBindingsAndTrackReferences(
|
|
7805
|
-
lVal.left,
|
|
7806
|
-
type,
|
|
7807
|
-
scope,
|
|
7808
|
-
section,
|
|
7809
|
-
upstreamAlias,
|
|
7810
|
-
property,
|
|
7811
|
-
void 0
|
|
7812
|
-
);
|
|
7813
|
-
if (lVal.left.extra?.binding) {
|
|
7814
|
-
setBindingDownstream(
|
|
7815
|
-
lVal.left.extra.binding,
|
|
7816
|
-
lVal.right.extra ??= {}
|
|
7817
|
-
);
|
|
7818
|
-
}
|
|
7819
|
-
break;
|
|
7820
8069
|
}
|
|
7821
8070
|
}
|
|
7822
8071
|
function trackReference(referencePath, binding) {
|
|
@@ -7825,7 +8074,7 @@ function trackReference(referencePath, binding) {
|
|
|
7825
8074
|
let propPath = binding.name;
|
|
7826
8075
|
while (true) {
|
|
7827
8076
|
const { parent } = root;
|
|
7828
|
-
if (!
|
|
8077
|
+
if (!import_compiler35.types.isMemberExpression(parent)) break;
|
|
7829
8078
|
const prop = getMemberExpressionPropString(parent);
|
|
7830
8079
|
if (prop === void 0) break;
|
|
7831
8080
|
if (reference.upstreamAlias && reference.excludeProperties !== void 0 && !propsUtil.has(reference.excludeProperties, prop)) {
|
|
@@ -8038,6 +8287,8 @@ function finalizeReferences() {
|
|
|
8038
8287
|
}
|
|
8039
8288
|
}
|
|
8040
8289
|
}
|
|
8290
|
+
});
|
|
8291
|
+
forEachSection((section) => {
|
|
8041
8292
|
forEach(section.referencedLocalClosures, (closure) => {
|
|
8042
8293
|
addSerializeReason(
|
|
8043
8294
|
section,
|
|
@@ -8046,41 +8297,39 @@ function finalizeReferences() {
|
|
|
8046
8297
|
);
|
|
8047
8298
|
});
|
|
8048
8299
|
forEach(section.referencedClosures, (closure) => {
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
break;
|
|
8058
|
-
}
|
|
8059
|
-
serializeReason = mergeSerializeReasons(
|
|
8060
|
-
serializeReason,
|
|
8061
|
-
upstreamReason
|
|
8062
|
-
);
|
|
8063
|
-
currentSection = currentSection.parent;
|
|
8300
|
+
const sourceSection = closure.section;
|
|
8301
|
+
let currentSection = section;
|
|
8302
|
+
let branchesReason;
|
|
8303
|
+
while (currentSection !== sourceSection) {
|
|
8304
|
+
const upstreamReason = currentSection.downstreamBinding ? getSectionRegisterReasons(currentSection) || void 0 : !currentSection.upstreamExpression || getSerializeSourcesForExpr(currentSection.upstreamExpression);
|
|
8305
|
+
if (upstreamReason === true) {
|
|
8306
|
+
branchesReason = true;
|
|
8307
|
+
break;
|
|
8064
8308
|
}
|
|
8065
|
-
|
|
8309
|
+
branchesReason = mergeSerializeReasons(branchesReason, upstreamReason);
|
|
8310
|
+
currentSection = currentSection.parent;
|
|
8066
8311
|
}
|
|
8312
|
+
addSerializeReason(sourceSection, branchesReason, closure);
|
|
8067
8313
|
addSerializeReason(
|
|
8068
|
-
|
|
8069
|
-
getSerializeReason(
|
|
8314
|
+
sourceSection,
|
|
8315
|
+
getSerializeReason(sourceSection, closure)
|
|
8070
8316
|
);
|
|
8071
|
-
if (
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8317
|
+
if (isDynamicClosure(section, closure)) {
|
|
8318
|
+
addOwnerSerializeReason(section, sourceSection, branchesReason);
|
|
8319
|
+
if (closure.sources) {
|
|
8320
|
+
addSerializeReason(
|
|
8321
|
+
sourceSection,
|
|
8322
|
+
closure.sources,
|
|
8323
|
+
closure,
|
|
8324
|
+
getAccessorPrefix().ClosureScopes
|
|
8325
|
+
);
|
|
8326
|
+
addSerializeReason(
|
|
8327
|
+
section,
|
|
8328
|
+
closure.sources,
|
|
8329
|
+
closure,
|
|
8330
|
+
getAccessorPrefix().ClosureSignalIndex
|
|
8331
|
+
);
|
|
8332
|
+
}
|
|
8084
8333
|
}
|
|
8085
8334
|
});
|
|
8086
8335
|
});
|
|
@@ -8356,9 +8605,9 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
|
|
|
8356
8605
|
function getScopeAccessorLiteral(binding, includeId) {
|
|
8357
8606
|
const canonicalBinding = getCanonicalBinding(binding);
|
|
8358
8607
|
if (isOptimize()) {
|
|
8359
|
-
return
|
|
8608
|
+
return import_compiler35.types.numericLiteral(canonicalBinding.id);
|
|
8360
8609
|
}
|
|
8361
|
-
return
|
|
8610
|
+
return import_compiler35.types.stringLiteral(
|
|
8362
8611
|
canonicalBinding.name + (includeId || canonicalBinding.type === 0 /* dom */ ? `/${canonicalBinding.id}` : "")
|
|
8363
8612
|
);
|
|
8364
8613
|
}
|
|
@@ -8406,7 +8655,7 @@ function getSectionInstancesAccessor(section) {
|
|
|
8406
8655
|
}
|
|
8407
8656
|
function getSectionInstancesAccessorLiteral(section) {
|
|
8408
8657
|
const accessor = getSectionInstancesAccessor(section);
|
|
8409
|
-
return accessor ? typeof accessor === "number" ?
|
|
8658
|
+
return accessor ? typeof accessor === "number" ? import_compiler35.types.numericLiteral(accessor) : import_compiler35.types.stringLiteral(accessor) : void 0;
|
|
8410
8659
|
}
|
|
8411
8660
|
function getReadReplacement(node) {
|
|
8412
8661
|
const { extra } = node;
|
|
@@ -8424,18 +8673,18 @@ function getReadReplacement(node) {
|
|
|
8424
8673
|
if (binding) {
|
|
8425
8674
|
if (node.type === "Identifier") {
|
|
8426
8675
|
if (binding.type === 6 /* hoist */) {
|
|
8427
|
-
replacement = node.extra?.[kIsInvoked] ?
|
|
8676
|
+
replacement = node.extra?.[kIsInvoked] ? import_compiler35.types.callExpression(getHoistFunctionIdentifier(binding), [
|
|
8428
8677
|
getScopeExpression(node.extra.section, binding.section)
|
|
8429
|
-
]) :
|
|
8678
|
+
]) : import_compiler35.types.identifier(binding.name);
|
|
8430
8679
|
} else if (binding.name !== node.name) {
|
|
8431
8680
|
node.name = binding.name;
|
|
8432
8681
|
}
|
|
8433
8682
|
} else {
|
|
8434
|
-
replacement =
|
|
8683
|
+
replacement = import_compiler35.types.identifier(binding.name);
|
|
8435
8684
|
}
|
|
8436
8685
|
} else if (read) {
|
|
8437
8686
|
replacement = toMemberExpression(
|
|
8438
|
-
|
|
8687
|
+
import_compiler35.types.identifier(read.binding.name),
|
|
8439
8688
|
Array.isArray(read.props) ? read.props[0] : read.props
|
|
8440
8689
|
);
|
|
8441
8690
|
if (Array.isArray(read.props)) {
|
|
@@ -8648,7 +8897,7 @@ var await_default = {
|
|
|
8648
8897
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
8649
8898
|
);
|
|
8650
8899
|
}
|
|
8651
|
-
if (node.attributes.length > 1 || !
|
|
8900
|
+
if (node.attributes.length > 1 || !import_compiler36.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
|
|
8652
8901
|
throw tag.get("name").buildCodeFrameError(
|
|
8653
8902
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
8654
8903
|
);
|
|
@@ -8658,7 +8907,7 @@ var await_default = {
|
|
|
8658
8907
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires [content](https://markojs.com/docs/reference/language#tag-content)."
|
|
8659
8908
|
);
|
|
8660
8909
|
}
|
|
8661
|
-
if (node.body.params.length && (node.body.params.length > 1 ||
|
|
8910
|
+
if (node.body.params.length && (node.body.params.length > 1 || import_compiler36.types.isSpreadElement(node.body.params[0]))) {
|
|
8662
8911
|
throw tag.get("name").buildCodeFrameError(
|
|
8663
8912
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) only supports a single parameter."
|
|
8664
8913
|
);
|
|
@@ -8695,17 +8944,17 @@ var await_default = {
|
|
|
8695
8944
|
flushInto(tag);
|
|
8696
8945
|
writeHTMLResumeStatements(tagBody);
|
|
8697
8946
|
tag.replaceWith(
|
|
8698
|
-
|
|
8947
|
+
import_compiler36.types.expressionStatement(
|
|
8699
8948
|
callRuntime(
|
|
8700
8949
|
"_await",
|
|
8701
8950
|
getScopeIdIdentifier(section),
|
|
8702
8951
|
getScopeAccessorLiteral(nodeRef),
|
|
8703
8952
|
valueAttr.value,
|
|
8704
|
-
|
|
8953
|
+
import_compiler36.types.arrowFunctionExpression(
|
|
8705
8954
|
node.body.params,
|
|
8706
8955
|
toFirstExpressionOrBlock(node.body.body)
|
|
8707
8956
|
),
|
|
8708
|
-
getSerializeGuard(bodySection?.serializeReason, true)
|
|
8957
|
+
getSerializeGuard(section, bodySection?.serializeReason, true)
|
|
8709
8958
|
)
|
|
8710
8959
|
)
|
|
8711
8960
|
)[0].skip();
|
|
@@ -8735,7 +8984,7 @@ var await_default = {
|
|
|
8735
8984
|
return callRuntime(
|
|
8736
8985
|
"_await",
|
|
8737
8986
|
getScopeAccessorLiteral(nodeRef),
|
|
8738
|
-
|
|
8987
|
+
import_compiler36.types.identifier(bodySection.name)
|
|
8739
8988
|
);
|
|
8740
8989
|
};
|
|
8741
8990
|
addValue(
|
|
@@ -8759,7 +9008,7 @@ var await_default = {
|
|
|
8759
9008
|
};
|
|
8760
9009
|
|
|
8761
9010
|
// src/translator/core/client.ts
|
|
8762
|
-
var
|
|
9011
|
+
var import_compiler37 = require("@marko/compiler");
|
|
8763
9012
|
var import_babel_utils27 = require("@marko/compiler/babel-utils");
|
|
8764
9013
|
var client_default = {
|
|
8765
9014
|
parse(tag) {
|
|
@@ -8771,10 +9020,10 @@ var client_default = {
|
|
|
8771
9020
|
const code = rawValue.replace(/^client\s*/, "");
|
|
8772
9021
|
const start = node.start + (rawValue.length - code.length);
|
|
8773
9022
|
let body = (0, import_babel_utils27.parseStatements)(file, code, start, start + code.length);
|
|
8774
|
-
if (body.length === 1 &&
|
|
9023
|
+
if (body.length === 1 && import_compiler37.types.isBlockStatement(body[0])) {
|
|
8775
9024
|
body = body[0].body;
|
|
8776
9025
|
}
|
|
8777
|
-
tag.replaceWith(
|
|
9026
|
+
tag.replaceWith(import_compiler37.types.markoScriptlet(body, true, "client"));
|
|
8778
9027
|
},
|
|
8779
9028
|
parseOptions: {
|
|
8780
9029
|
statement: true,
|
|
@@ -8790,7 +9039,7 @@ var client_default = {
|
|
|
8790
9039
|
};
|
|
8791
9040
|
|
|
8792
9041
|
// src/translator/core/const.ts
|
|
8793
|
-
var
|
|
9042
|
+
var import_compiler38 = require("@marko/compiler");
|
|
8794
9043
|
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
|
8795
9044
|
var const_default = {
|
|
8796
9045
|
analyze(tag) {
|
|
@@ -8809,13 +9058,13 @@ var const_default = {
|
|
|
8809
9058
|
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
8810
9059
|
);
|
|
8811
9060
|
}
|
|
8812
|
-
if (node.attributes.length > 1 || !
|
|
9061
|
+
if (node.attributes.length > 1 || !import_compiler38.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
|
8813
9062
|
throw tag.get("name").buildCodeFrameError(
|
|
8814
9063
|
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
8815
9064
|
);
|
|
8816
9065
|
}
|
|
8817
9066
|
const valueExtra = evaluate(valueAttr.value);
|
|
8818
|
-
const upstreamAlias =
|
|
9067
|
+
const upstreamAlias = import_compiler38.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
|
|
8819
9068
|
if (upstreamAlias) {
|
|
8820
9069
|
valueExtra.pruned = true;
|
|
8821
9070
|
}
|
|
@@ -8865,7 +9114,7 @@ var const_default = {
|
|
|
8865
9114
|
};
|
|
8866
9115
|
|
|
8867
9116
|
// src/translator/core/debug.ts
|
|
8868
|
-
var
|
|
9117
|
+
var import_compiler39 = require("@marko/compiler");
|
|
8869
9118
|
var import_babel_utils29 = require("@marko/compiler/babel-utils");
|
|
8870
9119
|
var debug_default = {
|
|
8871
9120
|
analyze(tag) {
|
|
@@ -8874,7 +9123,7 @@ var debug_default = {
|
|
|
8874
9123
|
(0, import_babel_utils29.assertNoArgs)(tag);
|
|
8875
9124
|
(0, import_babel_utils29.assertNoParams)(tag);
|
|
8876
9125
|
assertNoBodyContent(tag);
|
|
8877
|
-
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!
|
|
9126
|
+
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler39.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
|
8878
9127
|
throw tag.get("name").buildCodeFrameError(
|
|
8879
9128
|
"The [`<debug>` tag](https://markojs.com/docs/reference/core-tag#debug) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
8880
9129
|
);
|
|
@@ -8885,7 +9134,7 @@ var debug_default = {
|
|
|
8885
9134
|
const section = getSection(tag);
|
|
8886
9135
|
const [valueAttr] = tag.node.attributes;
|
|
8887
9136
|
const referencedBindings = valueAttr?.value.extra?.referencedBindings;
|
|
8888
|
-
const statement = withPreviousLocation(
|
|
9137
|
+
const statement = withPreviousLocation(import_compiler39.types.debuggerStatement(), tag.node);
|
|
8889
9138
|
if (isOutputHTML()) {
|
|
8890
9139
|
tag.insertBefore(statement);
|
|
8891
9140
|
} else {
|
|
@@ -8908,7 +9157,7 @@ var debug_default = {
|
|
|
8908
9157
|
};
|
|
8909
9158
|
|
|
8910
9159
|
// src/translator/core/define.ts
|
|
8911
|
-
var
|
|
9160
|
+
var import_compiler40 = require("@marko/compiler");
|
|
8912
9161
|
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
|
8913
9162
|
var define_default = {
|
|
8914
9163
|
analyze(tag) {
|
|
@@ -8928,7 +9177,7 @@ var define_default = {
|
|
|
8928
9177
|
trackParamsReferences(tagBody, 3 /* param */);
|
|
8929
9178
|
setTagDownstream(tag, varBinding);
|
|
8930
9179
|
if (bodySection) {
|
|
8931
|
-
if (
|
|
9180
|
+
if (import_compiler40.types.isIdentifier(tag.node.var)) {
|
|
8932
9181
|
const babelBinding = tag.scope.getBinding(tag.node.var.name);
|
|
8933
9182
|
let allDirectReferences = true;
|
|
8934
9183
|
for (const ref of babelBinding.referencePaths) {
|
|
@@ -8972,7 +9221,7 @@ var define_default = {
|
|
|
8972
9221
|
tag.insertBefore(translatedAttrs.statements);
|
|
8973
9222
|
translateVar(tag, propsToExpression(translatedAttrs.properties));
|
|
8974
9223
|
} else {
|
|
8975
|
-
if (
|
|
9224
|
+
if (import_compiler40.types.isIdentifier(node.var)) {
|
|
8976
9225
|
const babelBinding = tag.scope.getBinding(node.var.name);
|
|
8977
9226
|
let hasDirectReferences = false;
|
|
8978
9227
|
let allDirectReferences = true;
|
|
@@ -9027,7 +9276,7 @@ var define_default = {
|
|
|
9027
9276
|
};
|
|
9028
9277
|
|
|
9029
9278
|
// src/translator/core/effect.ts
|
|
9030
|
-
var
|
|
9279
|
+
var import_compiler41 = require("@marko/compiler");
|
|
9031
9280
|
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
|
9032
9281
|
var effect_default = {
|
|
9033
9282
|
migrate: [
|
|
@@ -9043,8 +9292,8 @@ var effect_default = {
|
|
|
9043
9292
|
fix() {
|
|
9044
9293
|
const { node } = tag;
|
|
9045
9294
|
tag.replaceWith(
|
|
9046
|
-
|
|
9047
|
-
withPreviousLocation(
|
|
9295
|
+
import_compiler41.types.markoTag(
|
|
9296
|
+
withPreviousLocation(import_compiler41.types.stringLiteral("script"), node.name),
|
|
9048
9297
|
node.attributes,
|
|
9049
9298
|
node.body,
|
|
9050
9299
|
node.arguments,
|
|
@@ -9081,20 +9330,20 @@ var export_default = {
|
|
|
9081
9330
|
};
|
|
9082
9331
|
|
|
9083
9332
|
// src/translator/core/html-comment.ts
|
|
9084
|
-
var
|
|
9333
|
+
var import_compiler43 = require("@marko/compiler");
|
|
9085
9334
|
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
|
9086
9335
|
|
|
9087
9336
|
// src/translator/util/body-to-text-literal.ts
|
|
9088
|
-
var
|
|
9337
|
+
var import_compiler42 = require("@marko/compiler");
|
|
9089
9338
|
function bodyToTextLiteral(body) {
|
|
9090
9339
|
const templateQuasis = [];
|
|
9091
9340
|
const templateExpressions = [];
|
|
9092
9341
|
let currentQuasi = "";
|
|
9093
9342
|
let placeholderExtra;
|
|
9094
9343
|
for (const child of body.body) {
|
|
9095
|
-
if (
|
|
9344
|
+
if (import_compiler42.types.isMarkoText(child)) {
|
|
9096
9345
|
currentQuasi += child.value;
|
|
9097
|
-
} else if (
|
|
9346
|
+
} else if (import_compiler42.types.isMarkoPlaceholder(child)) {
|
|
9098
9347
|
placeholderExtra ||= child.value.extra;
|
|
9099
9348
|
templateQuasis.push(templateElement(currentQuasi, false));
|
|
9100
9349
|
templateExpressions.push(child.value);
|
|
@@ -9103,14 +9352,14 @@ function bodyToTextLiteral(body) {
|
|
|
9103
9352
|
}
|
|
9104
9353
|
if (templateExpressions.length) {
|
|
9105
9354
|
templateQuasis.push(templateElement(currentQuasi, true));
|
|
9106
|
-
const literal =
|
|
9355
|
+
const literal = import_compiler42.types.templateLiteral(templateQuasis, templateExpressions);
|
|
9107
9356
|
literal.extra = placeholderExtra;
|
|
9108
9357
|
return literal;
|
|
9109
9358
|
}
|
|
9110
|
-
return
|
|
9359
|
+
return import_compiler42.types.stringLiteral(currentQuasi);
|
|
9111
9360
|
}
|
|
9112
9361
|
function templateElement(value, tail) {
|
|
9113
|
-
return
|
|
9362
|
+
return import_compiler42.types.templateElement(
|
|
9114
9363
|
{
|
|
9115
9364
|
raw: value.replace(/`/g, "\\`"),
|
|
9116
9365
|
cooked: value
|
|
@@ -9131,7 +9380,7 @@ var html_comment_default = {
|
|
|
9131
9380
|
let needsBinding = false;
|
|
9132
9381
|
let needsGetter = false;
|
|
9133
9382
|
if (tagVar) {
|
|
9134
|
-
if (!
|
|
9383
|
+
if (!import_compiler43.types.isIdentifier(tagVar)) {
|
|
9135
9384
|
throw tag.get("var").buildCodeFrameError(
|
|
9136
9385
|
"The [`<html-comment>` tag](https://markojs.com/docs/reference/core-tag#html-comment) tag variable cannot be destructured."
|
|
9137
9386
|
);
|
|
@@ -9183,7 +9432,7 @@ var html_comment_default = {
|
|
|
9183
9432
|
callRuntime(
|
|
9184
9433
|
"_el",
|
|
9185
9434
|
getterId && getScopeIdIdentifier(getSection(tag)),
|
|
9186
|
-
getterId &&
|
|
9435
|
+
getterId && import_compiler43.types.stringLiteral(getterId)
|
|
9187
9436
|
)
|
|
9188
9437
|
);
|
|
9189
9438
|
} else {
|
|
@@ -9193,12 +9442,12 @@ var html_comment_default = {
|
|
|
9193
9442
|
if (getterId) {
|
|
9194
9443
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
9195
9444
|
(0, import_babel_utils33.getProgram)().node.body.push(
|
|
9196
|
-
|
|
9197
|
-
|
|
9445
|
+
import_compiler43.types.variableDeclaration("const", [
|
|
9446
|
+
import_compiler43.types.variableDeclarator(
|
|
9198
9447
|
getterFnIdentifier,
|
|
9199
9448
|
callRuntime(
|
|
9200
9449
|
"_el",
|
|
9201
|
-
|
|
9450
|
+
import_compiler43.types.stringLiteral(getterId),
|
|
9202
9451
|
getScopeAccessorLiteral(nodeBinding)
|
|
9203
9452
|
)
|
|
9204
9453
|
)
|
|
@@ -9209,13 +9458,13 @@ var html_comment_default = {
|
|
|
9209
9458
|
const referenceSection = getSection(reference);
|
|
9210
9459
|
if (isInvokedFunction(reference)) {
|
|
9211
9460
|
reference.parentPath.replaceWith(
|
|
9212
|
-
|
|
9461
|
+
import_compiler43.types.expressionStatement(
|
|
9213
9462
|
createScopeReadExpression(referenceSection, nodeBinding)
|
|
9214
9463
|
)
|
|
9215
9464
|
);
|
|
9216
9465
|
} else if (getterFnIdentifier) {
|
|
9217
9466
|
reference.replaceWith(
|
|
9218
|
-
|
|
9467
|
+
import_compiler43.types.callExpression(getterFnIdentifier, [
|
|
9219
9468
|
getScopeExpression(referenceSection, getSection(tag))
|
|
9220
9469
|
])
|
|
9221
9470
|
);
|
|
@@ -9236,25 +9485,25 @@ var html_comment_default = {
|
|
|
9236
9485
|
const write = writeTo(tag);
|
|
9237
9486
|
if (isOutputHTML()) {
|
|
9238
9487
|
for (const child of tag.node.body.body) {
|
|
9239
|
-
if (
|
|
9488
|
+
if (import_compiler43.types.isMarkoText(child)) {
|
|
9240
9489
|
write`${child.value}`;
|
|
9241
|
-
} else if (
|
|
9490
|
+
} else if (import_compiler43.types.isMarkoPlaceholder(child)) {
|
|
9242
9491
|
write`${callRuntime("_escape", child.value)}`;
|
|
9243
9492
|
}
|
|
9244
9493
|
}
|
|
9245
9494
|
} else {
|
|
9246
9495
|
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
9247
|
-
if (
|
|
9496
|
+
if (import_compiler43.types.isStringLiteral(textLiteral)) {
|
|
9248
9497
|
write`${textLiteral}`;
|
|
9249
9498
|
} else {
|
|
9250
9499
|
addStatement(
|
|
9251
9500
|
"render",
|
|
9252
9501
|
getSection(tag),
|
|
9253
9502
|
tagExtra.referencedBindings,
|
|
9254
|
-
|
|
9503
|
+
import_compiler43.types.expressionStatement(
|
|
9255
9504
|
callRuntime(
|
|
9256
9505
|
"_text",
|
|
9257
|
-
|
|
9506
|
+
import_compiler43.types.memberExpression(
|
|
9258
9507
|
scopeIdentifier,
|
|
9259
9508
|
getScopeAccessorLiteral(nodeBinding),
|
|
9260
9509
|
true
|
|
@@ -9290,7 +9539,7 @@ var html_comment_default = {
|
|
|
9290
9539
|
};
|
|
9291
9540
|
|
|
9292
9541
|
// src/translator/core/html-script.ts
|
|
9293
|
-
var
|
|
9542
|
+
var import_compiler44 = require("@marko/compiler");
|
|
9294
9543
|
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
9295
9544
|
var kNodeBinding2 = Symbol("script tag node binding");
|
|
9296
9545
|
var kGetterId3 = Symbol("node getter id");
|
|
@@ -9299,7 +9548,7 @@ var html_script_default = {
|
|
|
9299
9548
|
(0, import_babel_utils34.assertNoArgs)(tag);
|
|
9300
9549
|
(0, import_babel_utils34.assertNoParams)(tag);
|
|
9301
9550
|
const { node } = tag;
|
|
9302
|
-
if (node.var && !
|
|
9551
|
+
if (node.var && !import_compiler44.types.isIdentifier(node.var)) {
|
|
9303
9552
|
throw tag.get("var").buildCodeFrameError(
|
|
9304
9553
|
"Tag variables on native elements cannot be destructured."
|
|
9305
9554
|
);
|
|
@@ -9313,7 +9562,7 @@ var html_script_default = {
|
|
|
9313
9562
|
for (let i = attributes.length; i--; ) {
|
|
9314
9563
|
const attr = attributes[i];
|
|
9315
9564
|
const valueExtra = attr.value.extra ??= {};
|
|
9316
|
-
if (
|
|
9565
|
+
if (import_compiler44.types.isMarkoAttribute(attr)) {
|
|
9317
9566
|
if (seen[attr.name]) {
|
|
9318
9567
|
dropReferences(attr.value);
|
|
9319
9568
|
continue;
|
|
@@ -9325,14 +9574,14 @@ var html_script_default = {
|
|
|
9325
9574
|
} else if (!evaluate(attr.value).confident) {
|
|
9326
9575
|
hasDynamicAttributes = true;
|
|
9327
9576
|
}
|
|
9328
|
-
} else if (
|
|
9577
|
+
} else if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
9329
9578
|
valueExtra.isEffect = true;
|
|
9330
9579
|
hasEventHandlers = true;
|
|
9331
9580
|
hasDynamicAttributes = true;
|
|
9332
9581
|
}
|
|
9333
9582
|
if (spreadReferenceNodes) {
|
|
9334
9583
|
spreadReferenceNodes.push(attr.value);
|
|
9335
|
-
} else if (
|
|
9584
|
+
} else if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
9336
9585
|
spreadReferenceNodes = [attr.value];
|
|
9337
9586
|
} else {
|
|
9338
9587
|
exprExtras = push(exprExtras, valueExtra);
|
|
@@ -9341,10 +9590,10 @@ var html_script_default = {
|
|
|
9341
9590
|
const bodyPlaceholderNodes = [];
|
|
9342
9591
|
let hasBodyPlaceholders = false;
|
|
9343
9592
|
for (const child of tag.node.body.body) {
|
|
9344
|
-
if (
|
|
9593
|
+
if (import_compiler44.types.isMarkoPlaceholder(child)) {
|
|
9345
9594
|
bodyPlaceholderNodes.push(child.value);
|
|
9346
9595
|
hasBodyPlaceholders = true;
|
|
9347
|
-
} else if (!
|
|
9596
|
+
} else if (!import_compiler44.types.isMarkoText(child)) {
|
|
9348
9597
|
throw tag.hub.buildError(
|
|
9349
9598
|
child,
|
|
9350
9599
|
"Invalid child. Only text is allowed inside an html-script."
|
|
@@ -9413,7 +9662,7 @@ var html_script_default = {
|
|
|
9413
9662
|
callRuntime(
|
|
9414
9663
|
"_el",
|
|
9415
9664
|
getterId && getScopeIdIdentifier(tagSection),
|
|
9416
|
-
getterId &&
|
|
9665
|
+
getterId && import_compiler44.types.stringLiteral(getterId)
|
|
9417
9666
|
)
|
|
9418
9667
|
);
|
|
9419
9668
|
} else {
|
|
@@ -9423,12 +9672,12 @@ var html_script_default = {
|
|
|
9423
9672
|
if (getterId) {
|
|
9424
9673
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
9425
9674
|
(0, import_babel_utils34.getProgram)().node.body.push(
|
|
9426
|
-
|
|
9427
|
-
|
|
9675
|
+
import_compiler44.types.variableDeclaration("const", [
|
|
9676
|
+
import_compiler44.types.variableDeclarator(
|
|
9428
9677
|
getterFnIdentifier,
|
|
9429
9678
|
callRuntime(
|
|
9430
9679
|
"_el",
|
|
9431
|
-
|
|
9680
|
+
import_compiler44.types.stringLiteral(getterId),
|
|
9432
9681
|
getScopeAccessorLiteral(nodeBinding)
|
|
9433
9682
|
)
|
|
9434
9683
|
)
|
|
@@ -9439,13 +9688,13 @@ var html_script_default = {
|
|
|
9439
9688
|
const referenceSection = getSection(reference);
|
|
9440
9689
|
if (isInvokedFunction(reference)) {
|
|
9441
9690
|
reference.parentPath.replaceWith(
|
|
9442
|
-
|
|
9691
|
+
import_compiler44.types.expressionStatement(
|
|
9443
9692
|
createScopeReadExpression(referenceSection, nodeBinding)
|
|
9444
9693
|
)
|
|
9445
9694
|
);
|
|
9446
9695
|
} else if (getterFnIdentifier) {
|
|
9447
9696
|
reference.replaceWith(
|
|
9448
|
-
|
|
9697
|
+
import_compiler44.types.callExpression(getterFnIdentifier, [
|
|
9449
9698
|
getScopeExpression(referenceSection, getSection(tag))
|
|
9450
9699
|
])
|
|
9451
9700
|
);
|
|
@@ -9477,10 +9726,10 @@ var html_script_default = {
|
|
|
9477
9726
|
"render",
|
|
9478
9727
|
tagSection,
|
|
9479
9728
|
valueReferences,
|
|
9480
|
-
|
|
9729
|
+
import_compiler44.types.expressionStatement(
|
|
9481
9730
|
callRuntime(
|
|
9482
9731
|
helper,
|
|
9483
|
-
|
|
9732
|
+
import_compiler44.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
9484
9733
|
value
|
|
9485
9734
|
)
|
|
9486
9735
|
)
|
|
@@ -9495,18 +9744,18 @@ var html_script_default = {
|
|
|
9495
9744
|
if (isEventHandler(name2)) {
|
|
9496
9745
|
addHTMLEffectCall(tagSection, valueReferences);
|
|
9497
9746
|
} else {
|
|
9498
|
-
write`${callRuntime("_attr",
|
|
9747
|
+
write`${callRuntime("_attr", import_compiler44.types.stringLiteral(name2), value)}`;
|
|
9499
9748
|
}
|
|
9500
9749
|
} else if (isEventHandler(name2)) {
|
|
9501
9750
|
addStatement(
|
|
9502
9751
|
"effect",
|
|
9503
9752
|
tagSection,
|
|
9504
9753
|
valueReferences,
|
|
9505
|
-
|
|
9754
|
+
import_compiler44.types.expressionStatement(
|
|
9506
9755
|
callRuntime(
|
|
9507
9756
|
"_on",
|
|
9508
|
-
|
|
9509
|
-
|
|
9757
|
+
import_compiler44.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
9758
|
+
import_compiler44.types.stringLiteral(getEventHandlerName(name2)),
|
|
9510
9759
|
value
|
|
9511
9760
|
)
|
|
9512
9761
|
)
|
|
@@ -9516,11 +9765,11 @@ var html_script_default = {
|
|
|
9516
9765
|
"render",
|
|
9517
9766
|
tagSection,
|
|
9518
9767
|
valueReferences,
|
|
9519
|
-
|
|
9768
|
+
import_compiler44.types.expressionStatement(
|
|
9520
9769
|
callRuntime(
|
|
9521
9770
|
"_attr",
|
|
9522
|
-
|
|
9523
|
-
|
|
9771
|
+
import_compiler44.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
9772
|
+
import_compiler44.types.stringLiteral(name2),
|
|
9524
9773
|
value
|
|
9525
9774
|
)
|
|
9526
9775
|
)
|
|
@@ -9533,9 +9782,9 @@ var html_script_default = {
|
|
|
9533
9782
|
if (isHTML) {
|
|
9534
9783
|
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
9535
9784
|
if (skipExpression) {
|
|
9536
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection),
|
|
9785
|
+
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler44.types.stringLiteral("script"))}`;
|
|
9537
9786
|
} else {
|
|
9538
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection),
|
|
9787
|
+
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler44.types.stringLiteral("script"))}`;
|
|
9539
9788
|
}
|
|
9540
9789
|
} else {
|
|
9541
9790
|
if (skipExpression) {
|
|
@@ -9543,7 +9792,7 @@ var html_script_default = {
|
|
|
9543
9792
|
"render",
|
|
9544
9793
|
tagSection,
|
|
9545
9794
|
tagExtra.referencedBindings,
|
|
9546
|
-
|
|
9795
|
+
import_compiler44.types.expressionStatement(
|
|
9547
9796
|
callRuntime(
|
|
9548
9797
|
"_attrs_partial",
|
|
9549
9798
|
scopeIdentifier,
|
|
@@ -9558,7 +9807,7 @@ var html_script_default = {
|
|
|
9558
9807
|
"render",
|
|
9559
9808
|
tagSection,
|
|
9560
9809
|
tagExtra.referencedBindings,
|
|
9561
|
-
|
|
9810
|
+
import_compiler44.types.expressionStatement(
|
|
9562
9811
|
callRuntime(
|
|
9563
9812
|
"_attrs",
|
|
9564
9813
|
scopeIdentifier,
|
|
@@ -9572,7 +9821,7 @@ var html_script_default = {
|
|
|
9572
9821
|
"effect",
|
|
9573
9822
|
tagSection,
|
|
9574
9823
|
tagExtra.referencedBindings,
|
|
9575
|
-
|
|
9824
|
+
import_compiler44.types.expressionStatement(
|
|
9576
9825
|
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
9577
9826
|
),
|
|
9578
9827
|
false
|
|
@@ -9589,25 +9838,25 @@ var html_script_default = {
|
|
|
9589
9838
|
const write = writeTo(tag);
|
|
9590
9839
|
if (isOutputHTML()) {
|
|
9591
9840
|
for (const child of tag.node.body.body) {
|
|
9592
|
-
if (
|
|
9841
|
+
if (import_compiler44.types.isMarkoText(child)) {
|
|
9593
9842
|
write`${child.value}`;
|
|
9594
|
-
} else if (
|
|
9843
|
+
} else if (import_compiler44.types.isMarkoPlaceholder(child)) {
|
|
9595
9844
|
write`${callRuntime("_escape_script", child.value)}`;
|
|
9596
9845
|
}
|
|
9597
9846
|
}
|
|
9598
9847
|
} else {
|
|
9599
9848
|
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
9600
|
-
if (
|
|
9849
|
+
if (import_compiler44.types.isStringLiteral(textLiteral)) {
|
|
9601
9850
|
write`${textLiteral.value}`;
|
|
9602
9851
|
} else {
|
|
9603
9852
|
addStatement(
|
|
9604
9853
|
"render",
|
|
9605
9854
|
getSection(tag),
|
|
9606
9855
|
textLiteral.extra?.referencedBindings,
|
|
9607
|
-
|
|
9856
|
+
import_compiler44.types.expressionStatement(
|
|
9608
9857
|
callRuntime(
|
|
9609
9858
|
"_text_content",
|
|
9610
|
-
|
|
9859
|
+
import_compiler44.types.memberExpression(
|
|
9611
9860
|
scopeIdentifier,
|
|
9612
9861
|
getScopeAccessorLiteral(nodeBinding),
|
|
9613
9862
|
true
|
|
@@ -9662,11 +9911,11 @@ function getUsedAttrs2(tag) {
|
|
|
9662
9911
|
for (let i = attributes.length; i--; ) {
|
|
9663
9912
|
const attr = attributes[i];
|
|
9664
9913
|
const { value } = attr;
|
|
9665
|
-
if (
|
|
9914
|
+
if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
9666
9915
|
if (!spreadProps) {
|
|
9667
9916
|
spreadProps = [];
|
|
9668
9917
|
}
|
|
9669
|
-
spreadProps.push(
|
|
9918
|
+
spreadProps.push(import_compiler44.types.spreadElement(value));
|
|
9670
9919
|
} else if (!seen[attr.name]) {
|
|
9671
9920
|
seen[attr.name] = attr;
|
|
9672
9921
|
if (spreadProps) {
|
|
@@ -9680,10 +9929,10 @@ function getUsedAttrs2(tag) {
|
|
|
9680
9929
|
if (spreadProps) {
|
|
9681
9930
|
spreadProps.reverse();
|
|
9682
9931
|
for (const { name: name2 } of staticAttrs) {
|
|
9683
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
|
9932
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler44.types.numericLiteral(1)));
|
|
9684
9933
|
}
|
|
9685
9934
|
if (skipProps) {
|
|
9686
|
-
skipExpression =
|
|
9935
|
+
skipExpression = import_compiler44.types.objectExpression(skipProps);
|
|
9687
9936
|
}
|
|
9688
9937
|
spreadExpression = propsToExpression(spreadProps);
|
|
9689
9938
|
}
|
|
@@ -9695,7 +9944,7 @@ function getUsedAttrs2(tag) {
|
|
|
9695
9944
|
}
|
|
9696
9945
|
|
|
9697
9946
|
// src/translator/core/html-style.ts
|
|
9698
|
-
var
|
|
9947
|
+
var import_compiler45 = require("@marko/compiler");
|
|
9699
9948
|
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
9700
9949
|
var kNodeBinding3 = Symbol("style tag node binding");
|
|
9701
9950
|
var kGetterId4 = Symbol("node getter id");
|
|
@@ -9704,7 +9953,7 @@ var html_style_default = {
|
|
|
9704
9953
|
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
9705
9954
|
(0, import_babel_utils35.assertNoParams)(tag);
|
|
9706
9955
|
const { node } = tag;
|
|
9707
|
-
if (node.var && !
|
|
9956
|
+
if (node.var && !import_compiler45.types.isIdentifier(node.var)) {
|
|
9708
9957
|
throw tag.get("var").buildCodeFrameError(
|
|
9709
9958
|
"Tag variables on native elements cannot be destructured."
|
|
9710
9959
|
);
|
|
@@ -9718,7 +9967,7 @@ var html_style_default = {
|
|
|
9718
9967
|
for (let i = attributes.length; i--; ) {
|
|
9719
9968
|
const attr = attributes[i];
|
|
9720
9969
|
const valueExtra = attr.value.extra ??= {};
|
|
9721
|
-
if (
|
|
9970
|
+
if (import_compiler45.types.isMarkoAttribute(attr)) {
|
|
9722
9971
|
if (seen[attr.name]) {
|
|
9723
9972
|
dropReferences(attr.value);
|
|
9724
9973
|
continue;
|
|
@@ -9730,14 +9979,14 @@ var html_style_default = {
|
|
|
9730
9979
|
} else if (!evaluate(attr.value).confident) {
|
|
9731
9980
|
hasDynamicAttributes = true;
|
|
9732
9981
|
}
|
|
9733
|
-
} else if (
|
|
9982
|
+
} else if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
|
9734
9983
|
valueExtra.isEffect = true;
|
|
9735
9984
|
hasEventHandlers = true;
|
|
9736
9985
|
hasDynamicAttributes = true;
|
|
9737
9986
|
}
|
|
9738
9987
|
if (spreadReferenceNodes) {
|
|
9739
9988
|
spreadReferenceNodes.push(attr.value);
|
|
9740
|
-
} else if (
|
|
9989
|
+
} else if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
|
9741
9990
|
spreadReferenceNodes = [attr.value];
|
|
9742
9991
|
} else {
|
|
9743
9992
|
exprExtras = push(exprExtras, valueExtra);
|
|
@@ -9746,10 +9995,10 @@ var html_style_default = {
|
|
|
9746
9995
|
const bodyPlaceholderNodes = [];
|
|
9747
9996
|
let hasBodyPlaceholders = false;
|
|
9748
9997
|
for (const child of tag.node.body.body) {
|
|
9749
|
-
if (
|
|
9998
|
+
if (import_compiler45.types.isMarkoPlaceholder(child)) {
|
|
9750
9999
|
bodyPlaceholderNodes.push(child.value);
|
|
9751
10000
|
hasBodyPlaceholders = true;
|
|
9752
|
-
} else if (!
|
|
10001
|
+
} else if (!import_compiler45.types.isMarkoText(child)) {
|
|
9753
10002
|
throw tag.hub.buildError(
|
|
9754
10003
|
child,
|
|
9755
10004
|
"Invalid child. Only text is allowed inside an html-style."
|
|
@@ -9818,7 +10067,7 @@ var html_style_default = {
|
|
|
9818
10067
|
callRuntime(
|
|
9819
10068
|
"_el",
|
|
9820
10069
|
getterId && getScopeIdIdentifier(tagSection),
|
|
9821
|
-
getterId &&
|
|
10070
|
+
getterId && import_compiler45.types.stringLiteral(getterId)
|
|
9822
10071
|
)
|
|
9823
10072
|
);
|
|
9824
10073
|
} else {
|
|
@@ -9828,12 +10077,12 @@ var html_style_default = {
|
|
|
9828
10077
|
if (getterId) {
|
|
9829
10078
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
9830
10079
|
(0, import_babel_utils35.getProgram)().node.body.push(
|
|
9831
|
-
|
|
9832
|
-
|
|
10080
|
+
import_compiler45.types.variableDeclaration("const", [
|
|
10081
|
+
import_compiler45.types.variableDeclarator(
|
|
9833
10082
|
getterFnIdentifier,
|
|
9834
10083
|
callRuntime(
|
|
9835
10084
|
"_el",
|
|
9836
|
-
|
|
10085
|
+
import_compiler45.types.stringLiteral(getterId),
|
|
9837
10086
|
getScopeAccessorLiteral(nodeBinding)
|
|
9838
10087
|
)
|
|
9839
10088
|
)
|
|
@@ -9844,13 +10093,13 @@ var html_style_default = {
|
|
|
9844
10093
|
const referenceSection = getSection(reference);
|
|
9845
10094
|
if (isInvokedFunction(reference)) {
|
|
9846
10095
|
reference.parentPath.replaceWith(
|
|
9847
|
-
|
|
10096
|
+
import_compiler45.types.expressionStatement(
|
|
9848
10097
|
createScopeReadExpression(referenceSection, nodeBinding)
|
|
9849
10098
|
)
|
|
9850
10099
|
);
|
|
9851
10100
|
} else if (getterFnIdentifier) {
|
|
9852
10101
|
reference.replaceWith(
|
|
9853
|
-
|
|
10102
|
+
import_compiler45.types.callExpression(getterFnIdentifier, [
|
|
9854
10103
|
getScopeExpression(referenceSection, getSection(tag))
|
|
9855
10104
|
])
|
|
9856
10105
|
);
|
|
@@ -9882,10 +10131,10 @@ var html_style_default = {
|
|
|
9882
10131
|
"render",
|
|
9883
10132
|
tagSection,
|
|
9884
10133
|
valueReferences,
|
|
9885
|
-
|
|
10134
|
+
import_compiler45.types.expressionStatement(
|
|
9886
10135
|
callRuntime(
|
|
9887
10136
|
helper,
|
|
9888
|
-
|
|
10137
|
+
import_compiler45.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
9889
10138
|
value
|
|
9890
10139
|
)
|
|
9891
10140
|
)
|
|
@@ -9900,18 +10149,18 @@ var html_style_default = {
|
|
|
9900
10149
|
if (isEventHandler(name2)) {
|
|
9901
10150
|
addHTMLEffectCall(tagSection, valueReferences);
|
|
9902
10151
|
} else {
|
|
9903
|
-
write`${callRuntime("_attr",
|
|
10152
|
+
write`${callRuntime("_attr", import_compiler45.types.stringLiteral(name2), value)}`;
|
|
9904
10153
|
}
|
|
9905
10154
|
} else if (isEventHandler(name2)) {
|
|
9906
10155
|
addStatement(
|
|
9907
10156
|
"effect",
|
|
9908
10157
|
tagSection,
|
|
9909
10158
|
valueReferences,
|
|
9910
|
-
|
|
10159
|
+
import_compiler45.types.expressionStatement(
|
|
9911
10160
|
callRuntime(
|
|
9912
10161
|
"_on",
|
|
9913
|
-
|
|
9914
|
-
|
|
10162
|
+
import_compiler45.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
10163
|
+
import_compiler45.types.stringLiteral(getEventHandlerName(name2)),
|
|
9915
10164
|
value
|
|
9916
10165
|
)
|
|
9917
10166
|
)
|
|
@@ -9921,11 +10170,11 @@ var html_style_default = {
|
|
|
9921
10170
|
"render",
|
|
9922
10171
|
tagSection,
|
|
9923
10172
|
valueReferences,
|
|
9924
|
-
|
|
10173
|
+
import_compiler45.types.expressionStatement(
|
|
9925
10174
|
callRuntime(
|
|
9926
10175
|
"_attr",
|
|
9927
|
-
|
|
9928
|
-
|
|
10176
|
+
import_compiler45.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
10177
|
+
import_compiler45.types.stringLiteral(name2),
|
|
9929
10178
|
value
|
|
9930
10179
|
)
|
|
9931
10180
|
)
|
|
@@ -9938,9 +10187,9 @@ var html_style_default = {
|
|
|
9938
10187
|
if (isHTML) {
|
|
9939
10188
|
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
9940
10189
|
if (skipExpression) {
|
|
9941
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection),
|
|
10190
|
+
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler45.types.stringLiteral("style"))}`;
|
|
9942
10191
|
} else {
|
|
9943
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection),
|
|
10192
|
+
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler45.types.stringLiteral("style"))}`;
|
|
9944
10193
|
}
|
|
9945
10194
|
} else {
|
|
9946
10195
|
if (skipExpression) {
|
|
@@ -9948,7 +10197,7 @@ var html_style_default = {
|
|
|
9948
10197
|
"render",
|
|
9949
10198
|
tagSection,
|
|
9950
10199
|
tagExtra.referencedBindings,
|
|
9951
|
-
|
|
10200
|
+
import_compiler45.types.expressionStatement(
|
|
9952
10201
|
callRuntime(
|
|
9953
10202
|
"_attrs_partial",
|
|
9954
10203
|
scopeIdentifier,
|
|
@@ -9963,7 +10212,7 @@ var html_style_default = {
|
|
|
9963
10212
|
"render",
|
|
9964
10213
|
tagSection,
|
|
9965
10214
|
tagExtra.referencedBindings,
|
|
9966
|
-
|
|
10215
|
+
import_compiler45.types.expressionStatement(
|
|
9967
10216
|
callRuntime(
|
|
9968
10217
|
"_attrs",
|
|
9969
10218
|
scopeIdentifier,
|
|
@@ -9977,7 +10226,7 @@ var html_style_default = {
|
|
|
9977
10226
|
"effect",
|
|
9978
10227
|
tagSection,
|
|
9979
10228
|
tagExtra.referencedBindings,
|
|
9980
|
-
|
|
10229
|
+
import_compiler45.types.expressionStatement(
|
|
9981
10230
|
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
9982
10231
|
),
|
|
9983
10232
|
false
|
|
@@ -9994,25 +10243,25 @@ var html_style_default = {
|
|
|
9994
10243
|
const write = writeTo(tag);
|
|
9995
10244
|
if (isOutputHTML()) {
|
|
9996
10245
|
for (const child of tag.node.body.body) {
|
|
9997
|
-
if (
|
|
10246
|
+
if (import_compiler45.types.isMarkoText(child)) {
|
|
9998
10247
|
write`${child.value}`;
|
|
9999
|
-
} else if (
|
|
10248
|
+
} else if (import_compiler45.types.isMarkoPlaceholder(child)) {
|
|
10000
10249
|
write`${callRuntime("_escape_style", child.value)}`;
|
|
10001
10250
|
}
|
|
10002
10251
|
}
|
|
10003
10252
|
} else {
|
|
10004
10253
|
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
10005
|
-
if (
|
|
10254
|
+
if (import_compiler45.types.isStringLiteral(textLiteral)) {
|
|
10006
10255
|
write`${textLiteral}`;
|
|
10007
10256
|
} else {
|
|
10008
10257
|
addStatement(
|
|
10009
10258
|
"render",
|
|
10010
10259
|
getSection(tag),
|
|
10011
10260
|
textLiteral.extra?.referencedBindings,
|
|
10012
|
-
|
|
10261
|
+
import_compiler45.types.expressionStatement(
|
|
10013
10262
|
callRuntime(
|
|
10014
10263
|
"_text_content",
|
|
10015
|
-
|
|
10264
|
+
import_compiler45.types.memberExpression(
|
|
10016
10265
|
scopeIdentifier,
|
|
10017
10266
|
getScopeAccessorLiteral(nodeBinding),
|
|
10018
10267
|
true
|
|
@@ -10062,11 +10311,11 @@ function getUsedAttrs3(tag) {
|
|
|
10062
10311
|
for (let i = attributes.length; i--; ) {
|
|
10063
10312
|
const attr = attributes[i];
|
|
10064
10313
|
const { value } = attr;
|
|
10065
|
-
if (
|
|
10314
|
+
if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
|
10066
10315
|
if (!spreadProps) {
|
|
10067
10316
|
spreadProps = [];
|
|
10068
10317
|
}
|
|
10069
|
-
spreadProps.push(
|
|
10318
|
+
spreadProps.push(import_compiler45.types.spreadElement(value));
|
|
10070
10319
|
} else if (!seen[attr.name]) {
|
|
10071
10320
|
seen[attr.name] = attr;
|
|
10072
10321
|
if (spreadProps) {
|
|
@@ -10080,10 +10329,10 @@ function getUsedAttrs3(tag) {
|
|
|
10080
10329
|
if (spreadProps) {
|
|
10081
10330
|
spreadProps.reverse();
|
|
10082
10331
|
for (const { name: name2 } of staticAttrs) {
|
|
10083
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
|
10332
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler45.types.numericLiteral(1)));
|
|
10084
10333
|
}
|
|
10085
10334
|
if (skipProps) {
|
|
10086
|
-
skipExpression =
|
|
10335
|
+
skipExpression = import_compiler45.types.objectExpression(skipProps);
|
|
10087
10336
|
}
|
|
10088
10337
|
spreadExpression = propsToExpression(spreadProps);
|
|
10089
10338
|
}
|
|
@@ -10095,7 +10344,7 @@ function getUsedAttrs3(tag) {
|
|
|
10095
10344
|
}
|
|
10096
10345
|
|
|
10097
10346
|
// src/translator/core/id.ts
|
|
10098
|
-
var
|
|
10347
|
+
var import_compiler46 = require("@marko/compiler");
|
|
10099
10348
|
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
|
10100
10349
|
var id_default = {
|
|
10101
10350
|
analyze(tag) {
|
|
@@ -10110,12 +10359,12 @@ var id_default = {
|
|
|
10110
10359
|
"The [`<id>` tag](https://markojs.com/docs/reference/core-tag#id) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
|
10111
10360
|
);
|
|
10112
10361
|
}
|
|
10113
|
-
if (!
|
|
10362
|
+
if (!import_compiler46.types.isIdentifier(node.var)) {
|
|
10114
10363
|
throw tag.get("var").buildCodeFrameError(
|
|
10115
10364
|
"The [`<id>` tag](https://markojs.com/docs/reference/core-tag#id) cannot be destructured."
|
|
10116
10365
|
);
|
|
10117
10366
|
}
|
|
10118
|
-
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!
|
|
10367
|
+
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler46.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
|
10119
10368
|
throw tag.get("name").buildCodeFrameError(
|
|
10120
10369
|
"The [`<id>` tag](https://markojs.com/docs/reference/core-tag#id) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
10121
10370
|
);
|
|
@@ -10132,10 +10381,10 @@ var id_default = {
|
|
|
10132
10381
|
const [valueAttr] = tag.node.attributes;
|
|
10133
10382
|
if (isOutputHTML()) {
|
|
10134
10383
|
tag.replaceWith(
|
|
10135
|
-
|
|
10136
|
-
|
|
10384
|
+
import_compiler46.types.variableDeclaration("const", [
|
|
10385
|
+
import_compiler46.types.variableDeclarator(
|
|
10137
10386
|
node.var,
|
|
10138
|
-
valueAttr ?
|
|
10387
|
+
valueAttr ? import_compiler46.types.logicalExpression("||", valueAttr.value, id) : id
|
|
10139
10388
|
)
|
|
10140
10389
|
])
|
|
10141
10390
|
);
|
|
@@ -10148,7 +10397,7 @@ var id_default = {
|
|
|
10148
10397
|
section,
|
|
10149
10398
|
value.extra?.referencedBindings,
|
|
10150
10399
|
source,
|
|
10151
|
-
|
|
10400
|
+
import_compiler46.types.logicalExpression("||", value, id)
|
|
10152
10401
|
);
|
|
10153
10402
|
} else {
|
|
10154
10403
|
addValue(section, void 0, source, id);
|
|
@@ -10173,17 +10422,17 @@ var id_default = {
|
|
|
10173
10422
|
};
|
|
10174
10423
|
|
|
10175
10424
|
// src/translator/core/if.ts
|
|
10176
|
-
var
|
|
10425
|
+
var import_compiler48 = require("@marko/compiler");
|
|
10177
10426
|
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
|
10178
10427
|
|
|
10179
10428
|
// src/translator/util/to-first-statement-or-block.ts
|
|
10180
|
-
var
|
|
10429
|
+
var import_compiler47 = require("@marko/compiler");
|
|
10181
10430
|
function toFirstStatementOrBlock(body) {
|
|
10182
10431
|
if (Array.isArray(body)) {
|
|
10183
10432
|
if (body.length === 1) {
|
|
10184
10433
|
return body[0];
|
|
10185
10434
|
}
|
|
10186
|
-
return
|
|
10435
|
+
return import_compiler47.types.blockStatement(body);
|
|
10187
10436
|
}
|
|
10188
10437
|
return body;
|
|
10189
10438
|
}
|
|
@@ -10291,14 +10540,14 @@ var IfTag = {
|
|
|
10291
10540
|
}
|
|
10292
10541
|
}
|
|
10293
10542
|
bodyStatements.push(
|
|
10294
|
-
|
|
10543
|
+
import_compiler48.types.returnStatement(import_compiler48.types.numericLiteral(i))
|
|
10295
10544
|
);
|
|
10296
10545
|
}
|
|
10297
10546
|
}
|
|
10298
10547
|
const [testAttr] = branchTag.node.attributes;
|
|
10299
10548
|
const curStatement = toFirstStatementOrBlock(bodyStatements);
|
|
10300
10549
|
if (testAttr) {
|
|
10301
|
-
statement =
|
|
10550
|
+
statement = import_compiler48.types.ifStatement(
|
|
10302
10551
|
testAttr.value,
|
|
10303
10552
|
curStatement,
|
|
10304
10553
|
statement
|
|
@@ -10314,31 +10563,34 @@ var IfTag = {
|
|
|
10314
10563
|
getParentTag(ifTag).node.extra[kSkipEndTag] = true;
|
|
10315
10564
|
}
|
|
10316
10565
|
const statefulSerializeArg = getSerializeGuard(
|
|
10566
|
+
ifTagSection,
|
|
10317
10567
|
getSerializeReason(ifTagSection, kStatefulReason2),
|
|
10318
10568
|
!(skipParentEnd || singleNodeOptimization)
|
|
10319
10569
|
);
|
|
10320
10570
|
const markerSerializeArg = getSerializeGuard(
|
|
10571
|
+
ifTagSection,
|
|
10321
10572
|
markerSerializeReason,
|
|
10322
10573
|
!statefulSerializeArg
|
|
10323
10574
|
);
|
|
10324
|
-
const cbNode =
|
|
10575
|
+
const cbNode = import_compiler48.types.arrowFunctionExpression(
|
|
10325
10576
|
[],
|
|
10326
|
-
|
|
10577
|
+
import_compiler48.types.blockStatement([statement])
|
|
10327
10578
|
);
|
|
10328
|
-
statement =
|
|
10579
|
+
statement = import_compiler48.types.expressionStatement(
|
|
10329
10580
|
callRuntime(
|
|
10330
10581
|
"_if",
|
|
10331
10582
|
cbNode,
|
|
10332
10583
|
getScopeIdIdentifier(ifTagSection),
|
|
10333
10584
|
getScopeAccessorLiteral(nodeBinding),
|
|
10334
10585
|
getSerializeGuardForAny(
|
|
10586
|
+
ifTagSection,
|
|
10335
10587
|
branchSerializeReasons,
|
|
10336
10588
|
!markerSerializeArg
|
|
10337
10589
|
),
|
|
10338
10590
|
markerSerializeArg,
|
|
10339
10591
|
statefulSerializeArg,
|
|
10340
|
-
skipParentEnd ?
|
|
10341
|
-
singleNodeOptimization ?
|
|
10592
|
+
skipParentEnd ? import_compiler48.types.stringLiteral(`</${onlyChildParentTagName}>`) : singleNodeOptimization ? import_compiler48.types.numericLiteral(0) : void 0,
|
|
10593
|
+
singleNodeOptimization ? import_compiler48.types.numericLiteral(1) : void 0
|
|
10342
10594
|
)
|
|
10343
10595
|
);
|
|
10344
10596
|
}
|
|
@@ -10368,25 +10620,25 @@ var IfTag = {
|
|
|
10368
10620
|
const ifTagExtra = branches[0][0].node.extra;
|
|
10369
10621
|
const nodeRef = getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection);
|
|
10370
10622
|
const rendererIdentifiers = [];
|
|
10371
|
-
let expr =
|
|
10623
|
+
let expr = import_compiler48.types.numericLiteral(branches.length);
|
|
10372
10624
|
for (let i = branches.length; i--; ) {
|
|
10373
10625
|
const [branchTag, branchBodySection] = branches[i];
|
|
10374
10626
|
const [testAttr] = branchTag.node.attributes;
|
|
10375
|
-
const consequent =
|
|
10627
|
+
const consequent = import_compiler48.types.numericLiteral(branchBodySection ? i : -1);
|
|
10376
10628
|
if (branchBodySection) {
|
|
10377
|
-
rendererIdentifiers.push(
|
|
10629
|
+
rendererIdentifiers.push(import_compiler48.types.identifier(branchBodySection.name));
|
|
10378
10630
|
setClosureSignalBuilder(branchTag, (closure, render) => {
|
|
10379
10631
|
return callRuntime(
|
|
10380
10632
|
"_if_closure",
|
|
10381
10633
|
getScopeAccessorLiteral(closure),
|
|
10382
10634
|
getScopeAccessorLiteral(nodeRef),
|
|
10383
|
-
|
|
10635
|
+
import_compiler48.types.numericLiteral(i),
|
|
10384
10636
|
render
|
|
10385
10637
|
);
|
|
10386
10638
|
});
|
|
10387
10639
|
}
|
|
10388
10640
|
branchTag.remove();
|
|
10389
|
-
expr = testAttr ?
|
|
10641
|
+
expr = testAttr ? import_compiler48.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
|
|
10390
10642
|
}
|
|
10391
10643
|
const signal = getSignal(ifTagSection, nodeRef, "if");
|
|
10392
10644
|
signal.build = () => {
|
|
@@ -10468,7 +10720,7 @@ function assertHasBody(tag) {
|
|
|
10468
10720
|
function assertHasValueAttribute(tag) {
|
|
10469
10721
|
const { node } = tag;
|
|
10470
10722
|
const [valueAttr] = node.attributes;
|
|
10471
|
-
if (!
|
|
10723
|
+
if (!import_compiler48.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
|
|
10472
10724
|
throw tag.get("name").buildCodeFrameError(
|
|
10473
10725
|
`The [\`${getTagName(tag)}\` tag](https://markojs.com/docs/reference/core-tag#if--else) requires a [\`value=\` attribute](https://markojs.com/docs/reference/language#shorthand-value).`
|
|
10474
10726
|
);
|
|
@@ -10554,7 +10806,7 @@ var import_default = {
|
|
|
10554
10806
|
};
|
|
10555
10807
|
|
|
10556
10808
|
// src/translator/core/let.ts
|
|
10557
|
-
var
|
|
10809
|
+
var import_compiler49 = require("@marko/compiler");
|
|
10558
10810
|
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
|
10559
10811
|
var let_default = {
|
|
10560
10812
|
analyze(tag) {
|
|
@@ -10563,7 +10815,7 @@ var let_default = {
|
|
|
10563
10815
|
let valueAttr;
|
|
10564
10816
|
let valueChangeAttr;
|
|
10565
10817
|
for (const attr of node.attributes) {
|
|
10566
|
-
if (
|
|
10818
|
+
if (import_compiler49.types.isMarkoAttribute(attr)) {
|
|
10567
10819
|
if (attr.name === "value") {
|
|
10568
10820
|
valueAttr = attr;
|
|
10569
10821
|
} else if (attr.name === "valueChange") {
|
|
@@ -10593,7 +10845,7 @@ var let_default = {
|
|
|
10593
10845
|
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
|
10594
10846
|
);
|
|
10595
10847
|
}
|
|
10596
|
-
if (!
|
|
10848
|
+
if (!import_compiler49.types.isIdentifier(tagVar)) {
|
|
10597
10849
|
throw tag.get("var").buildCodeFrameError(
|
|
10598
10850
|
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) variable cannot be destructured."
|
|
10599
10851
|
);
|
|
@@ -10623,10 +10875,10 @@ var let_default = {
|
|
|
10623
10875
|
const { node } = tag;
|
|
10624
10876
|
const tagVar = node.var;
|
|
10625
10877
|
const valueAttr = node.attributes.find(
|
|
10626
|
-
(attr) =>
|
|
10627
|
-
) ??
|
|
10878
|
+
(attr) => import_compiler49.types.isMarkoAttribute(attr) && (attr.default || attr.name === "value")
|
|
10879
|
+
) ?? import_compiler49.types.markoAttribute("value", import_compiler49.types.identifier("undefined"));
|
|
10628
10880
|
const valueChangeAttr = node.attributes.find(
|
|
10629
|
-
(attr) =>
|
|
10881
|
+
(attr) => import_compiler49.types.isMarkoAttribute(attr) && attr.name === "valueChange"
|
|
10630
10882
|
);
|
|
10631
10883
|
const section = getSection(tag);
|
|
10632
10884
|
const binding = tagVar.extra.binding;
|
|
@@ -10639,7 +10891,7 @@ var let_default = {
|
|
|
10639
10891
|
}
|
|
10640
10892
|
signal.buildAssignment = (valueSection, value) => {
|
|
10641
10893
|
if (valueChangeAttr || signalHasStatements(signal)) {
|
|
10642
|
-
return
|
|
10894
|
+
return import_compiler49.types.callExpression(signal.identifier, [
|
|
10643
10895
|
getScopeExpression(valueSection, signal.section),
|
|
10644
10896
|
value
|
|
10645
10897
|
]);
|
|
@@ -10651,10 +10903,10 @@ var let_default = {
|
|
|
10651
10903
|
setBindingSerializedValue(
|
|
10652
10904
|
section,
|
|
10653
10905
|
binding,
|
|
10654
|
-
|
|
10906
|
+
import_compiler49.types.logicalExpression(
|
|
10655
10907
|
"||",
|
|
10656
10908
|
valueChangeAttr.value,
|
|
10657
|
-
|
|
10909
|
+
import_compiler49.types.unaryExpression("void", import_compiler49.types.numericLiteral(0))
|
|
10658
10910
|
),
|
|
10659
10911
|
getAccessorPrefix().TagVariableChange
|
|
10660
10912
|
);
|
|
@@ -10677,7 +10929,7 @@ var let_default = {
|
|
|
10677
10929
|
};
|
|
10678
10930
|
|
|
10679
10931
|
// src/translator/core/lifecycle.ts
|
|
10680
|
-
var
|
|
10932
|
+
var import_compiler50 = require("@marko/compiler");
|
|
10681
10933
|
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
|
10682
10934
|
var kRef = Symbol("lifecycle attrs reference");
|
|
10683
10935
|
var lifecycle_default = {
|
|
@@ -10705,7 +10957,7 @@ var lifecycle_default = {
|
|
|
10705
10957
|
);
|
|
10706
10958
|
}
|
|
10707
10959
|
for (const attr of node.attributes) {
|
|
10708
|
-
if (
|
|
10960
|
+
if (import_compiler50.types.isMarkoSpreadAttribute(attr)) {
|
|
10709
10961
|
throw tag.get("name").buildCodeFrameError(
|
|
10710
10962
|
"The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) does not support [`...spread` attributes](https://markojs.com/docs/reference/language#spread-attributes)."
|
|
10711
10963
|
);
|
|
@@ -10724,7 +10976,7 @@ var lifecycle_default = {
|
|
|
10724
10976
|
if (isOutputDOM()) {
|
|
10725
10977
|
const translatedAttrs = translateAttrs(tag);
|
|
10726
10978
|
translatedAttrs.statements.push(
|
|
10727
|
-
|
|
10979
|
+
import_compiler50.types.expressionStatement(
|
|
10728
10980
|
callRuntime(
|
|
10729
10981
|
"_lifecycle",
|
|
10730
10982
|
scopeIdentifier,
|
|
@@ -10759,7 +11011,7 @@ var lifecycle_default = {
|
|
|
10759
11011
|
};
|
|
10760
11012
|
|
|
10761
11013
|
// src/translator/core/log.ts
|
|
10762
|
-
var
|
|
11014
|
+
var import_compiler51 = require("@marko/compiler");
|
|
10763
11015
|
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
|
10764
11016
|
var log_default = {
|
|
10765
11017
|
analyze(tag) {
|
|
@@ -10773,7 +11025,7 @@ var log_default = {
|
|
|
10773
11025
|
"The [`<log>` tag](https://markojs.com/docs/reference/core-tag#log) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
10774
11026
|
);
|
|
10775
11027
|
}
|
|
10776
|
-
if (tag.node.attributes.length > 1 || !
|
|
11028
|
+
if (tag.node.attributes.length > 1 || !import_compiler51.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
|
10777
11029
|
throw tag.get("name").buildCodeFrameError(
|
|
10778
11030
|
"The [`<log>` tag](https://markojs.com/docs/reference/core-tag#log) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
10779
11031
|
);
|
|
@@ -10785,9 +11037,9 @@ var log_default = {
|
|
|
10785
11037
|
const [valueAttr] = tag.node.attributes;
|
|
10786
11038
|
const { value } = valueAttr;
|
|
10787
11039
|
const referencedBindings = value.extra?.referencedBindings;
|
|
10788
|
-
const statement =
|
|
10789
|
-
|
|
10790
|
-
|
|
11040
|
+
const statement = import_compiler51.types.expressionStatement(
|
|
11041
|
+
import_compiler51.types.callExpression(
|
|
11042
|
+
import_compiler51.types.memberExpression(import_compiler51.types.identifier("console"), import_compiler51.types.identifier("log")),
|
|
10791
11043
|
[value]
|
|
10792
11044
|
)
|
|
10793
11045
|
);
|
|
@@ -10813,7 +11065,7 @@ var log_default = {
|
|
|
10813
11065
|
};
|
|
10814
11066
|
|
|
10815
11067
|
// src/translator/core/script.ts
|
|
10816
|
-
var
|
|
11068
|
+
var import_compiler52 = require("@marko/compiler");
|
|
10817
11069
|
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
|
10818
11070
|
var htmlScriptTagAlternateMsg = " For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.";
|
|
10819
11071
|
var script_default = {
|
|
@@ -10836,12 +11088,12 @@ var script_default = {
|
|
|
10836
11088
|
const end = body[body.length - 1]?.end;
|
|
10837
11089
|
const bodyStatements = (0, import_babel_utils42.parseStatements)(tag.hub.file, code, start, end);
|
|
10838
11090
|
if (bodyStatements.length) {
|
|
10839
|
-
const valueFn =
|
|
11091
|
+
const valueFn = import_compiler52.types.arrowFunctionExpression(
|
|
10840
11092
|
[],
|
|
10841
|
-
|
|
11093
|
+
import_compiler52.types.blockStatement(bodyStatements),
|
|
10842
11094
|
traverseContains(bodyStatements, isAwaitExpression)
|
|
10843
11095
|
);
|
|
10844
|
-
node.attributes.push(
|
|
11096
|
+
node.attributes.push(import_compiler52.types.markoAttribute("value", valueFn));
|
|
10845
11097
|
}
|
|
10846
11098
|
node.body.body = [];
|
|
10847
11099
|
}
|
|
@@ -10891,28 +11143,28 @@ var script_default = {
|
|
|
10891
11143
|
const referencedBindings = value.extra?.referencedBindings;
|
|
10892
11144
|
if (isOutputDOM()) {
|
|
10893
11145
|
const { value: value2 } = valueAttr;
|
|
10894
|
-
const isFunction2 =
|
|
11146
|
+
const isFunction2 = import_compiler52.types.isFunctionExpression(value2) || import_compiler52.types.isArrowFunctionExpression(value2);
|
|
10895
11147
|
let inlineBody = null;
|
|
10896
11148
|
if (isFunction2 && !(value2.async || value2.generator)) {
|
|
10897
|
-
if (
|
|
11149
|
+
if (import_compiler52.types.isBlockStatement(value2.body)) {
|
|
10898
11150
|
let hasDeclaration = false;
|
|
10899
11151
|
for (const child of value2.body.body) {
|
|
10900
|
-
if (
|
|
11152
|
+
if (import_compiler52.types.isDeclaration(child)) {
|
|
10901
11153
|
hasDeclaration = true;
|
|
10902
11154
|
break;
|
|
10903
11155
|
}
|
|
10904
11156
|
}
|
|
10905
11157
|
inlineBody = hasDeclaration ? value2.body : value2.body.body;
|
|
10906
11158
|
} else {
|
|
10907
|
-
inlineBody =
|
|
11159
|
+
inlineBody = import_compiler52.types.expressionStatement(value2.body);
|
|
10908
11160
|
}
|
|
10909
11161
|
}
|
|
10910
11162
|
addStatement(
|
|
10911
11163
|
"effect",
|
|
10912
11164
|
section,
|
|
10913
11165
|
referencedBindings,
|
|
10914
|
-
inlineBody ||
|
|
10915
|
-
|
|
11166
|
+
inlineBody || import_compiler52.types.expressionStatement(
|
|
11167
|
+
import_compiler52.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
|
|
10916
11168
|
)
|
|
10917
11169
|
);
|
|
10918
11170
|
} else {
|
|
@@ -10953,7 +11205,7 @@ function isAwaitExpression(node) {
|
|
|
10953
11205
|
}
|
|
10954
11206
|
|
|
10955
11207
|
// src/translator/core/server.ts
|
|
10956
|
-
var
|
|
11208
|
+
var import_compiler53 = require("@marko/compiler");
|
|
10957
11209
|
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
|
10958
11210
|
var server_default = {
|
|
10959
11211
|
parse(tag) {
|
|
@@ -10965,10 +11217,10 @@ var server_default = {
|
|
|
10965
11217
|
const code = rawValue.replace(/^server\s*/, "");
|
|
10966
11218
|
const start = node.start + (rawValue.length - code.length);
|
|
10967
11219
|
let body = (0, import_babel_utils43.parseStatements)(file, code, start, start + code.length);
|
|
10968
|
-
if (body.length === 1 &&
|
|
11220
|
+
if (body.length === 1 && import_compiler53.types.isBlockStatement(body[0])) {
|
|
10969
11221
|
body = body[0].body;
|
|
10970
11222
|
}
|
|
10971
|
-
tag.replaceWith(
|
|
11223
|
+
tag.replaceWith(import_compiler53.types.markoScriptlet(body, true, "server"));
|
|
10972
11224
|
},
|
|
10973
11225
|
parseOptions: {
|
|
10974
11226
|
statement: true,
|
|
@@ -10984,7 +11236,7 @@ var server_default = {
|
|
|
10984
11236
|
};
|
|
10985
11237
|
|
|
10986
11238
|
// src/translator/core/static.ts
|
|
10987
|
-
var
|
|
11239
|
+
var import_compiler54 = require("@marko/compiler");
|
|
10988
11240
|
var import_babel_utils44 = require("@marko/compiler/babel-utils");
|
|
10989
11241
|
var static_default = {
|
|
10990
11242
|
parse(tag) {
|
|
@@ -10996,10 +11248,10 @@ var static_default = {
|
|
|
10996
11248
|
const code = rawValue.replace(/^static\s*/, "");
|
|
10997
11249
|
const start = node.start + (rawValue.length - code.length);
|
|
10998
11250
|
let body = (0, import_babel_utils44.parseStatements)(file, code, start, start + code.length);
|
|
10999
|
-
if (body.length === 1 &&
|
|
11251
|
+
if (body.length === 1 && import_compiler54.types.isBlockStatement(body[0])) {
|
|
11000
11252
|
body = body[0].body;
|
|
11001
11253
|
}
|
|
11002
|
-
tag.replaceWith(
|
|
11254
|
+
tag.replaceWith(import_compiler54.types.markoScriptlet(body, true));
|
|
11003
11255
|
},
|
|
11004
11256
|
parseOptions: {
|
|
11005
11257
|
statement: true,
|
|
@@ -11015,7 +11267,7 @@ var static_default = {
|
|
|
11015
11267
|
};
|
|
11016
11268
|
|
|
11017
11269
|
// src/translator/core/style.ts
|
|
11018
|
-
var
|
|
11270
|
+
var import_compiler55 = require("@marko/compiler");
|
|
11019
11271
|
var import_babel_utils45 = require("@marko/compiler/babel-utils");
|
|
11020
11272
|
var import_magic_string = __toESM(require("magic-string"));
|
|
11021
11273
|
var import_path3 = __toESM(require("path"));
|
|
@@ -11092,21 +11344,21 @@ var style_default = {
|
|
|
11092
11344
|
if (importPath) {
|
|
11093
11345
|
if (!node.var) {
|
|
11094
11346
|
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11095
|
-
|
|
11347
|
+
import_compiler55.types.importDeclaration([], import_compiler55.types.stringLiteral(importPath))
|
|
11096
11348
|
);
|
|
11097
|
-
} else if (
|
|
11349
|
+
} else if (import_compiler55.types.isIdentifier(node.var)) {
|
|
11098
11350
|
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11099
|
-
|
|
11100
|
-
[
|
|
11101
|
-
|
|
11351
|
+
import_compiler55.types.importDeclaration(
|
|
11352
|
+
[import_compiler55.types.importNamespaceSpecifier(node.var)],
|
|
11353
|
+
import_compiler55.types.stringLiteral(importPath)
|
|
11102
11354
|
)
|
|
11103
11355
|
);
|
|
11104
11356
|
} else {
|
|
11105
|
-
const varDecl =
|
|
11106
|
-
|
|
11357
|
+
const varDecl = import_compiler55.types.variableDeclaration("const", [
|
|
11358
|
+
import_compiler55.types.variableDeclarator(node.var, (0, import_babel_utils45.importStar)(file, importPath, "style"))
|
|
11107
11359
|
]);
|
|
11108
11360
|
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11109
|
-
isOutputDOM() ? varDecl :
|
|
11361
|
+
isOutputDOM() ? varDecl : import_compiler55.types.markoScriptlet([varDecl], true)
|
|
11110
11362
|
);
|
|
11111
11363
|
}
|
|
11112
11364
|
}
|
|
@@ -11121,8 +11373,43 @@ var style_default = {
|
|
|
11121
11373
|
attributes: {}
|
|
11122
11374
|
};
|
|
11123
11375
|
|
|
11376
|
+
// src/translator/core/textarea.ts
|
|
11377
|
+
var import_compiler56 = require("@marko/compiler");
|
|
11378
|
+
var textarea_default = {
|
|
11379
|
+
parse(tag) {
|
|
11380
|
+
if (tag.node.body.body.length) {
|
|
11381
|
+
const parts = [];
|
|
11382
|
+
for (const child of tag.node.body.body) {
|
|
11383
|
+
if (child.type === "MarkoText" || child.type === "MarkoPlaceholder" && child.escape) {
|
|
11384
|
+
parts.push(child.value);
|
|
11385
|
+
} else {
|
|
11386
|
+
throw tag.hub.file.hub.buildError(
|
|
11387
|
+
child,
|
|
11388
|
+
"Unexpected content in textarea, only text and placeholders are supported.",
|
|
11389
|
+
SyntaxError
|
|
11390
|
+
);
|
|
11391
|
+
}
|
|
11392
|
+
}
|
|
11393
|
+
tag.node.attributes.push(
|
|
11394
|
+
import_compiler56.types.markoAttribute(
|
|
11395
|
+
"value",
|
|
11396
|
+
normalizeStringExpression(parts) || buildUndefined4()
|
|
11397
|
+
)
|
|
11398
|
+
);
|
|
11399
|
+
tag.node.body.body = [];
|
|
11400
|
+
}
|
|
11401
|
+
},
|
|
11402
|
+
parseOptions: {
|
|
11403
|
+
text: true,
|
|
11404
|
+
preserveWhitespace: true
|
|
11405
|
+
}
|
|
11406
|
+
};
|
|
11407
|
+
function buildUndefined4() {
|
|
11408
|
+
return import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0));
|
|
11409
|
+
}
|
|
11410
|
+
|
|
11124
11411
|
// src/translator/core/try.ts
|
|
11125
|
-
var
|
|
11412
|
+
var import_compiler57 = require("@marko/compiler");
|
|
11126
11413
|
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
11127
11414
|
var kDOMBinding2 = Symbol("try tag dom binding");
|
|
11128
11415
|
var try_default = {
|
|
@@ -11182,7 +11469,7 @@ var try_default = {
|
|
|
11182
11469
|
writeHTMLResumeStatements(tagBody);
|
|
11183
11470
|
tag.insertBefore(translatedAttrs.statements);
|
|
11184
11471
|
tag.replaceWith(
|
|
11185
|
-
|
|
11472
|
+
import_compiler57.types.expressionStatement(
|
|
11186
11473
|
callRuntime(
|
|
11187
11474
|
"_try",
|
|
11188
11475
|
getScopeIdIdentifier(section),
|
|
@@ -11224,7 +11511,7 @@ var try_default = {
|
|
|
11224
11511
|
return callRuntime(
|
|
11225
11512
|
"_try",
|
|
11226
11513
|
getScopeAccessorLiteral(nodeRef),
|
|
11227
|
-
|
|
11514
|
+
import_compiler57.types.identifier(bodySection.name)
|
|
11228
11515
|
);
|
|
11229
11516
|
};
|
|
11230
11517
|
if (translatedAttrs.statements.length) {
|
|
@@ -11236,7 +11523,7 @@ var try_default = {
|
|
|
11236
11523
|
);
|
|
11237
11524
|
}
|
|
11238
11525
|
(0, import_babel_utils46.getProgram)().node.body.push(
|
|
11239
|
-
|
|
11526
|
+
import_compiler57.types.expressionStatement(callRuntime("_enable_catch"))
|
|
11240
11527
|
);
|
|
11241
11528
|
addValue(
|
|
11242
11529
|
section,
|
|
@@ -11286,6 +11573,7 @@ var core_default = {
|
|
|
11286
11573
|
"<server>": server_default,
|
|
11287
11574
|
"<static>": static_default,
|
|
11288
11575
|
"<style>": style_default,
|
|
11576
|
+
"<textarea>": textarea_default,
|
|
11289
11577
|
"<try>": try_default
|
|
11290
11578
|
};
|
|
11291
11579
|
|
|
@@ -11362,10 +11650,10 @@ var import_declaration_default = {
|
|
|
11362
11650
|
};
|
|
11363
11651
|
|
|
11364
11652
|
// src/translator/visitors/placeholder.ts
|
|
11365
|
-
var
|
|
11653
|
+
var import_compiler59 = require("@marko/compiler");
|
|
11366
11654
|
|
|
11367
11655
|
// src/translator/util/is-non-html-text.ts
|
|
11368
|
-
var
|
|
11656
|
+
var import_compiler58 = require("@marko/compiler");
|
|
11369
11657
|
function isNonHTMLText(placeholder) {
|
|
11370
11658
|
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
11371
11659
|
if (parentTag && isCoreTag(parentTag)) {
|
|
@@ -11435,7 +11723,7 @@ var placeholder_default = {
|
|
|
11435
11723
|
if (markerSerializeReason === true || markerSerializeReason.state) {
|
|
11436
11724
|
write`<!>`;
|
|
11437
11725
|
} else {
|
|
11438
|
-
write`${callRuntime("_sep", getSerializeGuard(markerSerializeReason, true))}`;
|
|
11726
|
+
write`${callRuntime("_sep", getSerializeGuard(section, markerSerializeReason, true))}`;
|
|
11439
11727
|
}
|
|
11440
11728
|
}
|
|
11441
11729
|
visit(placeholder, 37 /* Replace */);
|
|
@@ -11455,10 +11743,10 @@ var placeholder_default = {
|
|
|
11455
11743
|
"render",
|
|
11456
11744
|
getSection(placeholder),
|
|
11457
11745
|
valueExtra.referencedBindings,
|
|
11458
|
-
|
|
11746
|
+
import_compiler59.types.expressionStatement(
|
|
11459
11747
|
method === "_text" ? callRuntime(
|
|
11460
11748
|
"_text",
|
|
11461
|
-
|
|
11749
|
+
import_compiler59.types.memberExpression(
|
|
11462
11750
|
scopeIdentifier,
|
|
11463
11751
|
getScopeAccessorLiteral(nodeBinding),
|
|
11464
11752
|
true
|
|
@@ -11497,7 +11785,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
11497
11785
|
break;
|
|
11498
11786
|
}
|
|
11499
11787
|
}
|
|
11500
|
-
if (!prev.node &&
|
|
11788
|
+
if (!prev.node && import_compiler59.types.isProgram(placeholder.parentPath)) {
|
|
11501
11789
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
|
11502
11790
|
}
|
|
11503
11791
|
let next = placeholder.getNextSibling();
|
|
@@ -11514,7 +11802,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
11514
11802
|
break;
|
|
11515
11803
|
}
|
|
11516
11804
|
}
|
|
11517
|
-
if (!next.node &&
|
|
11805
|
+
if (!next.node && import_compiler59.types.isProgram(placeholder.parentPath)) {
|
|
11518
11806
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
|
11519
11807
|
}
|
|
11520
11808
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
|
@@ -11556,7 +11844,7 @@ function isEmptyPlaceholder(placeholder) {
|
|
|
11556
11844
|
}
|
|
11557
11845
|
|
|
11558
11846
|
// src/translator/visitors/referenced-identifier.ts
|
|
11559
|
-
var
|
|
11847
|
+
var import_compiler60 = require("@marko/compiler");
|
|
11560
11848
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
|
11561
11849
|
var referenced_identifier_default = {
|
|
11562
11850
|
migrate(identifier) {
|
|
@@ -11564,8 +11852,8 @@ var referenced_identifier_default = {
|
|
|
11564
11852
|
if (identifier.scope.hasBinding(name2)) return;
|
|
11565
11853
|
switch (name2) {
|
|
11566
11854
|
case "out":
|
|
11567
|
-
if (
|
|
11568
|
-
identifier.parentPath.replaceWith(
|
|
11855
|
+
if (import_compiler60.types.isMemberExpression(identifier.parent) && import_compiler60.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
|
11856
|
+
identifier.parentPath.replaceWith(import_compiler60.types.identifier("$global"));
|
|
11569
11857
|
} else {
|
|
11570
11858
|
throw identifier.buildCodeFrameError(
|
|
11571
11859
|
"Only `out.global` is supported for compatibility."
|
|
@@ -11592,24 +11880,24 @@ var referenced_identifier_default = {
|
|
|
11592
11880
|
case "$global":
|
|
11593
11881
|
if (isOutputHTML()) {
|
|
11594
11882
|
identifier.replaceWith(
|
|
11595
|
-
|
|
11883
|
+
import_compiler60.types.callExpression(importRuntime("$global"), [])
|
|
11596
11884
|
);
|
|
11597
11885
|
} else {
|
|
11598
11886
|
identifier.replaceWith(
|
|
11599
|
-
|
|
11887
|
+
import_compiler60.types.memberExpression(scopeIdentifier, import_compiler60.types.identifier("$global"))
|
|
11600
11888
|
);
|
|
11601
11889
|
}
|
|
11602
11890
|
break;
|
|
11603
11891
|
case "$signal":
|
|
11604
11892
|
if (isOutputHTML()) {
|
|
11605
11893
|
identifier.replaceWith(
|
|
11606
|
-
|
|
11607
|
-
|
|
11894
|
+
import_compiler60.types.callExpression(
|
|
11895
|
+
import_compiler60.types.arrowFunctionExpression(
|
|
11608
11896
|
[],
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11897
|
+
import_compiler60.types.blockStatement([
|
|
11898
|
+
import_compiler60.types.throwStatement(
|
|
11899
|
+
import_compiler60.types.newExpression(import_compiler60.types.identifier("Error"), [
|
|
11900
|
+
import_compiler60.types.stringLiteral("Cannot use $signal in a server render.")
|
|
11613
11901
|
])
|
|
11614
11902
|
)
|
|
11615
11903
|
])
|
|
@@ -11635,19 +11923,19 @@ var referenced_identifier_default = {
|
|
|
11635
11923
|
"render",
|
|
11636
11924
|
section,
|
|
11637
11925
|
exprRoot.node.extra?.referencedBindings,
|
|
11638
|
-
|
|
11639
|
-
|
|
11926
|
+
import_compiler60.types.expressionStatement(
|
|
11927
|
+
import_compiler60.types.callExpression(importRuntime("$signalReset"), [
|
|
11640
11928
|
scopeIdentifier,
|
|
11641
|
-
|
|
11929
|
+
import_compiler60.types.numericLiteral(exprId)
|
|
11642
11930
|
])
|
|
11643
11931
|
),
|
|
11644
11932
|
false
|
|
11645
11933
|
);
|
|
11646
11934
|
}
|
|
11647
11935
|
identifier.replaceWith(
|
|
11648
|
-
|
|
11936
|
+
import_compiler60.types.callExpression(importRuntime("$signal"), [
|
|
11649
11937
|
scopeIdentifier,
|
|
11650
|
-
|
|
11938
|
+
import_compiler60.types.numericLiteral(exprId)
|
|
11651
11939
|
])
|
|
11652
11940
|
);
|
|
11653
11941
|
}
|
|
@@ -11691,11 +11979,11 @@ var scriptlet_default = {
|
|
|
11691
11979
|
};
|
|
11692
11980
|
|
|
11693
11981
|
// src/translator/visitors/tag/index.ts
|
|
11694
|
-
var
|
|
11982
|
+
var import_compiler64 = require("@marko/compiler");
|
|
11695
11983
|
var import_babel_utils52 = require("@marko/compiler/babel-utils");
|
|
11696
11984
|
|
|
11697
11985
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
11698
|
-
var
|
|
11986
|
+
var import_compiler61 = require("@marko/compiler");
|
|
11699
11987
|
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
11700
11988
|
var attribute_tag_default = {
|
|
11701
11989
|
analyze: {
|
|
@@ -11728,7 +12016,7 @@ var attribute_tag_default = {
|
|
|
11728
12016
|
};
|
|
11729
12017
|
|
|
11730
12018
|
// src/translator/visitors/tag/custom-tag.ts
|
|
11731
|
-
var
|
|
12019
|
+
var import_compiler62 = require("@marko/compiler");
|
|
11732
12020
|
var import_babel_utils50 = require("@marko/compiler/babel-utils");
|
|
11733
12021
|
var import_path4 = __toESM(require("path"));
|
|
11734
12022
|
var custom_tag_default = {
|
|
@@ -11782,9 +12070,9 @@ function translateHTML(tag) {
|
|
|
11782
12070
|
const childProgram = (0, import_babel_utils50.loadFileForTag)(tag).ast.program;
|
|
11783
12071
|
const childExtra = childProgram.extra;
|
|
11784
12072
|
let tagIdentifier;
|
|
11785
|
-
if (
|
|
12073
|
+
if (import_compiler62.types.isStringLiteral(node.name)) {
|
|
11786
12074
|
const relativePath = getTagRelativePath(tag);
|
|
11787
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
|
12075
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler62.types.identifier(getTemplateContentName()) : (0, import_babel_utils50.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
|
11788
12076
|
} else {
|
|
11789
12077
|
tagIdentifier = node.name;
|
|
11790
12078
|
}
|
|
@@ -11805,7 +12093,7 @@ function translateDOM(tag) {
|
|
|
11805
12093
|
const childExtra = childFile.ast.program.extra;
|
|
11806
12094
|
const childExports = childExtra.domExports;
|
|
11807
12095
|
const childSection = childExtra.section;
|
|
11808
|
-
const tagName =
|
|
12096
|
+
const tagName = import_compiler62.types.isIdentifier(node.name) ? node.name.name : import_compiler62.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
11809
12097
|
if (programSection === childSection) {
|
|
11810
12098
|
knownTagTranslateDOM(
|
|
11811
12099
|
tag,
|
|
@@ -11816,16 +12104,16 @@ function translateDOM(tag) {
|
|
|
11816
12104
|
"render",
|
|
11817
12105
|
section,
|
|
11818
12106
|
void 0,
|
|
11819
|
-
|
|
11820
|
-
|
|
12107
|
+
import_compiler62.types.expressionStatement(
|
|
12108
|
+
import_compiler62.types.callExpression(import_compiler62.types.identifier(childExports.setup), [
|
|
11821
12109
|
createScopeReadExpression(section, childBinding)
|
|
11822
12110
|
])
|
|
11823
12111
|
)
|
|
11824
12112
|
);
|
|
11825
12113
|
}
|
|
11826
12114
|
);
|
|
11827
|
-
write`${
|
|
11828
|
-
injectWalks(tag,
|
|
12115
|
+
write`${import_compiler62.types.identifier(childExports.template)}`;
|
|
12116
|
+
injectWalks(tag, import_compiler62.types.identifier(childExports.walks));
|
|
11829
12117
|
} else {
|
|
11830
12118
|
knownTagTranslateDOM(
|
|
11831
12119
|
tag,
|
|
@@ -11841,8 +12129,8 @@ function translateDOM(tag) {
|
|
|
11841
12129
|
"render",
|
|
11842
12130
|
section,
|
|
11843
12131
|
void 0,
|
|
11844
|
-
|
|
11845
|
-
|
|
12132
|
+
import_compiler62.types.expressionStatement(
|
|
12133
|
+
import_compiler62.types.callExpression(
|
|
11846
12134
|
importOrSelfReferenceName(
|
|
11847
12135
|
file,
|
|
11848
12136
|
relativePath,
|
|
@@ -11869,7 +12157,7 @@ function getTagRelativePath(tag) {
|
|
|
11869
12157
|
hub: { file }
|
|
11870
12158
|
} = tag;
|
|
11871
12159
|
let relativePath;
|
|
11872
|
-
if (
|
|
12160
|
+
if (import_compiler62.types.isStringLiteral(node.name)) {
|
|
11873
12161
|
const template = (0, import_babel_utils50.getTagTemplate)(tag);
|
|
11874
12162
|
relativePath = template && (0, import_babel_utils50.resolveRelativePath)(file, template);
|
|
11875
12163
|
} else if (node.extra?.tagNameImported) {
|
|
@@ -11890,7 +12178,7 @@ function getTagRelativePath(tag) {
|
|
|
11890
12178
|
}
|
|
11891
12179
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
11892
12180
|
if (isCircularRequest(file, request)) {
|
|
11893
|
-
return
|
|
12181
|
+
return import_compiler62.types.identifier(name2);
|
|
11894
12182
|
}
|
|
11895
12183
|
return (0, import_babel_utils50.importNamed)(file, request, name2, nameHint);
|
|
11896
12184
|
}
|
|
@@ -11900,7 +12188,7 @@ function isCircularRequest(file, request) {
|
|
|
11900
12188
|
}
|
|
11901
12189
|
|
|
11902
12190
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
11903
|
-
var
|
|
12191
|
+
var import_compiler63 = require("@marko/compiler");
|
|
11904
12192
|
var import_babel_utils51 = require("@marko/compiler/babel-utils");
|
|
11905
12193
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
|
11906
12194
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
|
@@ -11932,7 +12220,7 @@ var dynamic_tag_default = {
|
|
|
11932
12220
|
tagSection
|
|
11933
12221
|
);
|
|
11934
12222
|
if (hasVar || tag.node.attributes.some(
|
|
11935
|
-
(attr) =>
|
|
12223
|
+
(attr) => import_compiler63.types.isMarkoSpreadAttribute(attr) || isEventOrChangeHandler(attr.name)
|
|
11936
12224
|
)) {
|
|
11937
12225
|
(0, import_babel_utils51.getProgram)().node.extra.isInteractive = true;
|
|
11938
12226
|
}
|
|
@@ -11972,7 +12260,7 @@ var dynamic_tag_default = {
|
|
|
11972
12260
|
if (isOutputHTML()) {
|
|
11973
12261
|
knownTagTranslateHTML(
|
|
11974
12262
|
tag,
|
|
11975
|
-
|
|
12263
|
+
import_compiler63.types.memberExpression(tag.node.name, import_compiler63.types.identifier("content")),
|
|
11976
12264
|
definedBodySection,
|
|
11977
12265
|
propTree
|
|
11978
12266
|
);
|
|
@@ -11989,9 +12277,9 @@ var dynamic_tag_default = {
|
|
|
11989
12277
|
"render",
|
|
11990
12278
|
section,
|
|
11991
12279
|
void 0,
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
12280
|
+
import_compiler63.types.expressionStatement(
|
|
12281
|
+
import_compiler63.types.callExpression(
|
|
12282
|
+
import_compiler63.types.memberExpression(signal.identifier, import_compiler63.types.identifier("_")),
|
|
11995
12283
|
[
|
|
11996
12284
|
createScopeReadExpression(section, childBinding),
|
|
11997
12285
|
getScopeExpression(section, definedBodySection.parent)
|
|
@@ -12015,7 +12303,7 @@ var dynamic_tag_default = {
|
|
|
12015
12303
|
const nodeBinding = tagExtra[kDOMBinding3];
|
|
12016
12304
|
const isClassAPI = tagExtra.featureType === "class";
|
|
12017
12305
|
let tagExpression = node.name;
|
|
12018
|
-
if (
|
|
12306
|
+
if (import_compiler63.types.isStringLiteral(tagExpression)) {
|
|
12019
12307
|
tagExpression = (0, import_babel_utils51.importDefault)(
|
|
12020
12308
|
tag.hub.file,
|
|
12021
12309
|
getTagRelativePath(tag),
|
|
@@ -12025,14 +12313,14 @@ var dynamic_tag_default = {
|
|
|
12025
12313
|
if (isClassAPI) {
|
|
12026
12314
|
if (isOutputHTML()) {
|
|
12027
12315
|
(0, import_babel_utils51.getProgram)().node.body.push(
|
|
12028
|
-
|
|
12316
|
+
import_compiler63.types.markoScriptlet(
|
|
12029
12317
|
[
|
|
12030
|
-
|
|
12031
|
-
|
|
12318
|
+
import_compiler63.types.expressionStatement(
|
|
12319
|
+
import_compiler63.types.callExpression(
|
|
12032
12320
|
(0, import_babel_utils51.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
12033
12321
|
[
|
|
12034
|
-
|
|
12035
|
-
|
|
12322
|
+
import_compiler63.types.identifier(tagExpression.name),
|
|
12323
|
+
import_compiler63.types.stringLiteral((0, import_babel_utils51.loadFileForTag)(tag).metadata.marko.id)
|
|
12036
12324
|
]
|
|
12037
12325
|
)
|
|
12038
12326
|
)
|
|
@@ -12042,11 +12330,11 @@ var dynamic_tag_default = {
|
|
|
12042
12330
|
);
|
|
12043
12331
|
} else {
|
|
12044
12332
|
(0, import_babel_utils51.getProgram)().node.body.push(
|
|
12045
|
-
|
|
12333
|
+
import_compiler63.types.expressionStatement(
|
|
12046
12334
|
callRuntime(
|
|
12047
12335
|
"_resume",
|
|
12048
|
-
|
|
12049
|
-
|
|
12336
|
+
import_compiler63.types.stringLiteral((0, import_babel_utils51.loadFileForTag)(tag).metadata.marko.id),
|
|
12337
|
+
import_compiler63.types.identifier(tagExpression.name)
|
|
12050
12338
|
)
|
|
12051
12339
|
)
|
|
12052
12340
|
);
|
|
@@ -12079,6 +12367,7 @@ var dynamic_tag_default = {
|
|
|
12079
12367
|
flushInto(tag);
|
|
12080
12368
|
writeHTMLResumeStatements(tag.get("body"));
|
|
12081
12369
|
const serializeArg = getSerializeGuard(
|
|
12370
|
+
tagSection,
|
|
12082
12371
|
getSerializeReason(tagSection, nodeBinding),
|
|
12083
12372
|
true
|
|
12084
12373
|
);
|
|
@@ -12087,9 +12376,9 @@ var dynamic_tag_default = {
|
|
|
12087
12376
|
getScopeIdIdentifier(tagSection),
|
|
12088
12377
|
getScopeAccessorLiteral(nodeBinding),
|
|
12089
12378
|
tagExpression,
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12379
|
+
import_compiler63.types.arrayExpression(args),
|
|
12380
|
+
import_compiler63.types.numericLiteral(0),
|
|
12381
|
+
import_compiler63.types.numericLiteral(1),
|
|
12093
12382
|
serializeArg
|
|
12094
12383
|
) : callRuntime(
|
|
12095
12384
|
"_dynamic_tag",
|
|
@@ -12097,8 +12386,8 @@ var dynamic_tag_default = {
|
|
|
12097
12386
|
getScopeAccessorLiteral(nodeBinding),
|
|
12098
12387
|
tagExpression,
|
|
12099
12388
|
args[0],
|
|
12100
|
-
args[1] || (serializeArg ?
|
|
12101
|
-
serializeArg ?
|
|
12389
|
+
args[1] || (serializeArg ? import_compiler63.types.numericLiteral(0) : void 0),
|
|
12390
|
+
serializeArg ? import_compiler63.types.numericLiteral(0) : void 0,
|
|
12102
12391
|
serializeArg
|
|
12103
12392
|
);
|
|
12104
12393
|
if (node.var) {
|
|
@@ -12106,18 +12395,18 @@ var dynamic_tag_default = {
|
|
|
12106
12395
|
tag.get("name").toString() + "_scope"
|
|
12107
12396
|
);
|
|
12108
12397
|
statements.push(
|
|
12109
|
-
|
|
12110
|
-
|
|
12398
|
+
import_compiler63.types.variableDeclaration("const", [
|
|
12399
|
+
import_compiler63.types.variableDeclarator(
|
|
12111
12400
|
dynamicScopeIdentifier,
|
|
12112
12401
|
callRuntime("_peek_scope_id")
|
|
12113
12402
|
)
|
|
12114
12403
|
])
|
|
12115
12404
|
);
|
|
12116
12405
|
statements.push(
|
|
12117
|
-
|
|
12118
|
-
|
|
12406
|
+
import_compiler63.types.variableDeclaration("let", [
|
|
12407
|
+
import_compiler63.types.variableDeclarator(node.var, dynamicTagExpr)
|
|
12119
12408
|
]),
|
|
12120
|
-
|
|
12409
|
+
import_compiler63.types.expressionStatement(
|
|
12121
12410
|
callRuntime(
|
|
12122
12411
|
"_var",
|
|
12123
12412
|
getScopeIdIdentifier(tagSection),
|
|
@@ -12125,7 +12414,7 @@ var dynamic_tag_default = {
|
|
|
12125
12414
|
tag.node.extra[kChildOffsetScopeBinding2]
|
|
12126
12415
|
),
|
|
12127
12416
|
dynamicScopeIdentifier,
|
|
12128
|
-
|
|
12417
|
+
import_compiler63.types.stringLiteral(
|
|
12129
12418
|
getResumeRegisterId(
|
|
12130
12419
|
tagSection,
|
|
12131
12420
|
node.var.extra?.binding,
|
|
@@ -12137,7 +12426,7 @@ var dynamic_tag_default = {
|
|
|
12137
12426
|
)
|
|
12138
12427
|
);
|
|
12139
12428
|
} else {
|
|
12140
|
-
statements.push(
|
|
12429
|
+
statements.push(import_compiler63.types.expressionStatement(dynamicTagExpr));
|
|
12141
12430
|
}
|
|
12142
12431
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
12143
12432
|
replacement.skip();
|
|
@@ -12156,9 +12445,9 @@ var dynamic_tag_default = {
|
|
|
12156
12445
|
tagVarSignal.register = true;
|
|
12157
12446
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
|
12158
12447
|
const changeArgs = [
|
|
12159
|
-
|
|
12448
|
+
import_compiler63.types.memberExpression(
|
|
12160
12449
|
getScopeExpression(tagVarSignal.section, valueSection),
|
|
12161
|
-
|
|
12450
|
+
import_compiler63.types.stringLiteral(
|
|
12162
12451
|
getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeBinding)
|
|
12163
12452
|
),
|
|
12164
12453
|
true
|
|
@@ -12166,28 +12455,28 @@ var dynamic_tag_default = {
|
|
|
12166
12455
|
value
|
|
12167
12456
|
];
|
|
12168
12457
|
if (!isOptimize()) {
|
|
12169
|
-
changeArgs.push(
|
|
12458
|
+
changeArgs.push(import_compiler63.types.stringLiteral(varBinding.name));
|
|
12170
12459
|
}
|
|
12171
|
-
return
|
|
12460
|
+
return import_compiler63.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
12172
12461
|
};
|
|
12173
12462
|
}
|
|
12174
12463
|
signal.build = () => {
|
|
12175
12464
|
return callRuntime(
|
|
12176
12465
|
"_dynamic_tag",
|
|
12177
12466
|
getScopeAccessorLiteral(nodeBinding),
|
|
12178
|
-
bodySection &&
|
|
12179
|
-
tagVarSignal ?
|
|
12180
|
-
hasTagArgs &&
|
|
12467
|
+
bodySection && import_compiler63.types.identifier(bodySection.name),
|
|
12468
|
+
tagVarSignal ? import_compiler63.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
|
12469
|
+
hasTagArgs && import_compiler63.types.numericLiteral(1)
|
|
12181
12470
|
);
|
|
12182
12471
|
};
|
|
12183
12472
|
if (args.length) {
|
|
12184
|
-
const argsOrInput = hasTagArgs ?
|
|
12185
|
-
if (!
|
|
12473
|
+
const argsOrInput = hasTagArgs ? import_compiler63.types.arrayExpression(args) : args[0];
|
|
12474
|
+
if (!import_compiler63.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
|
12186
12475
|
signal.extraArgs = [
|
|
12187
|
-
|
|
12476
|
+
import_compiler63.types.arrowFunctionExpression(
|
|
12188
12477
|
[],
|
|
12189
|
-
statements.length ?
|
|
12190
|
-
statements.concat(
|
|
12478
|
+
statements.length ? import_compiler63.types.blockStatement(
|
|
12479
|
+
statements.concat(import_compiler63.types.returnStatement(argsOrInput))
|
|
12191
12480
|
) : argsOrInput
|
|
12192
12481
|
)
|
|
12193
12482
|
];
|
|
@@ -12201,34 +12490,7 @@ var dynamic_tag_default = {
|
|
|
12201
12490
|
};
|
|
12202
12491
|
|
|
12203
12492
|
// src/translator/visitors/tag/index.ts
|
|
12204
|
-
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
|
12205
|
-
var BINDING_CHANGE_HANDLER = /* @__PURE__ */ new WeakMap();
|
|
12206
12493
|
var tag_default = {
|
|
12207
|
-
transform: {
|
|
12208
|
-
enter(tag) {
|
|
12209
|
-
const { node } = tag;
|
|
12210
|
-
const { name: name2, attributes } = tag.node;
|
|
12211
|
-
let crawl = false;
|
|
12212
|
-
if (import_compiler62.types.isStringLiteral(name2)) {
|
|
12213
|
-
const tagName = name2.value;
|
|
12214
|
-
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
|
12215
|
-
node.name = withPreviousLocation(import_compiler62.types.identifier(tagName), name2);
|
|
12216
|
-
crawl = true;
|
|
12217
|
-
}
|
|
12218
|
-
}
|
|
12219
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
12220
|
-
const attr = attributes[i];
|
|
12221
|
-
if (import_compiler62.types.isMarkoAttribute(attr) && attr.bound) {
|
|
12222
|
-
attr.bound = false;
|
|
12223
|
-
attributes.splice(++i, 0, getChangeHandler(tag, attr));
|
|
12224
|
-
crawl = true;
|
|
12225
|
-
}
|
|
12226
|
-
}
|
|
12227
|
-
if (crawl) {
|
|
12228
|
-
tag.scope.crawl();
|
|
12229
|
-
}
|
|
12230
|
-
}
|
|
12231
|
-
},
|
|
12232
12494
|
analyze: {
|
|
12233
12495
|
enter(tag) {
|
|
12234
12496
|
const tagDef = (0, import_babel_utils52.getTagDef)(tag);
|
|
@@ -12294,8 +12556,8 @@ var tag_default = {
|
|
|
12294
12556
|
if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
|
12295
12557
|
const tagNameId = generateUidIdentifier("tagName");
|
|
12296
12558
|
const [tagNameVarPath] = tag.insertBefore(
|
|
12297
|
-
|
|
12298
|
-
|
|
12559
|
+
import_compiler64.types.variableDeclaration("const", [
|
|
12560
|
+
import_compiler64.types.variableDeclarator(tagNameId, tag.node.name)
|
|
12299
12561
|
])
|
|
12300
12562
|
);
|
|
12301
12563
|
tagNameVarPath.skip();
|
|
@@ -12339,152 +12601,9 @@ var tag_default = {
|
|
|
12339
12601
|
}
|
|
12340
12602
|
}
|
|
12341
12603
|
};
|
|
12342
|
-
function getChangeHandler(tag, attr) {
|
|
12343
|
-
const attrName = attr.name;
|
|
12344
|
-
const changeAttrName = attrName + "Change";
|
|
12345
|
-
if (import_compiler62.types.isIdentifier(attr.value)) {
|
|
12346
|
-
const binding = tag.scope.getBinding(attr.value.name);
|
|
12347
|
-
if (!binding)
|
|
12348
|
-
return import_compiler62.types.markoAttribute(
|
|
12349
|
-
changeAttrName,
|
|
12350
|
-
buildChangeHandlerFunction(attr.value)
|
|
12351
|
-
);
|
|
12352
|
-
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
|
12353
|
-
if (!existingChangedAttr) {
|
|
12354
|
-
const bindingIdentifierPath = binding.path.getOuterBindingIdentifierPaths()[binding.identifier.name];
|
|
12355
|
-
const changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(
|
|
12356
|
-
bindingIdentifierPath.parentPath
|
|
12357
|
-
) : void 0 : void 0;
|
|
12358
|
-
if (!changeAttrExpr) {
|
|
12359
|
-
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
12360
|
-
}
|
|
12361
|
-
const changeHandlerAttr = import_compiler62.types.markoAttribute(
|
|
12362
|
-
changeAttrName,
|
|
12363
|
-
changeAttrExpr
|
|
12364
|
-
);
|
|
12365
|
-
BINDING_CHANGE_HANDLER.set(binding.identifier, changeHandlerAttr);
|
|
12366
|
-
return changeHandlerAttr;
|
|
12367
|
-
}
|
|
12368
|
-
if (existingChangedAttr.type === "Identifier") {
|
|
12369
|
-
return import_compiler62.types.markoAttribute(
|
|
12370
|
-
changeAttrName,
|
|
12371
|
-
withPreviousLocation(
|
|
12372
|
-
import_compiler62.types.identifier(existingChangedAttr.name),
|
|
12373
|
-
attr.value
|
|
12374
|
-
)
|
|
12375
|
-
);
|
|
12376
|
-
}
|
|
12377
|
-
const markoRoot = isMarko(binding.path) ? binding.path : getMarkoRoot(binding.path);
|
|
12378
|
-
if (!(markoRoot?.isMarkoTag() || markoRoot?.isMarkoTagBody())) {
|
|
12379
|
-
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
12380
|
-
}
|
|
12381
|
-
const changeHandlerId = generateUid(changeAttrName);
|
|
12382
|
-
const changeHandlerConst = import_compiler62.types.markoTag(
|
|
12383
|
-
import_compiler62.types.stringLiteral("const"),
|
|
12384
|
-
[import_compiler62.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
|
12385
|
-
import_compiler62.types.markoTagBody([]),
|
|
12386
|
-
null,
|
|
12387
|
-
import_compiler62.types.identifier(changeHandlerId)
|
|
12388
|
-
);
|
|
12389
|
-
BINDING_CHANGE_HANDLER.set(
|
|
12390
|
-
binding.identifier,
|
|
12391
|
-
existingChangedAttr.value = import_compiler62.types.identifier(changeHandlerId)
|
|
12392
|
-
);
|
|
12393
|
-
if (markoRoot.isMarkoTag()) {
|
|
12394
|
-
markoRoot.insertAfter(changeHandlerConst);
|
|
12395
|
-
} else {
|
|
12396
|
-
markoRoot.unshiftContainer("body", changeHandlerConst);
|
|
12397
|
-
}
|
|
12398
|
-
markoRoot.scope.crawl();
|
|
12399
|
-
return import_compiler62.types.markoAttribute(
|
|
12400
|
-
changeAttrName,
|
|
12401
|
-
withPreviousLocation(import_compiler62.types.identifier(changeHandlerId), attr.value)
|
|
12402
|
-
);
|
|
12403
|
-
} else if (import_compiler62.types.isMemberExpression(attr.value)) {
|
|
12404
|
-
const prop = attr.value.property;
|
|
12405
|
-
if (!import_compiler62.types.isPrivateName(attr.value.property)) {
|
|
12406
|
-
return import_compiler62.types.markoAttribute(
|
|
12407
|
-
changeAttrName,
|
|
12408
|
-
import_compiler62.types.memberExpression(
|
|
12409
|
-
import_compiler62.types.cloneNode(attr.value.object),
|
|
12410
|
-
prop.type === "Identifier" ? withPreviousLocation(import_compiler62.types.identifier(prop.name + "Change"), prop) : import_compiler62.types.binaryExpression(
|
|
12411
|
-
"+",
|
|
12412
|
-
import_compiler62.types.cloneNode(prop),
|
|
12413
|
-
import_compiler62.types.stringLiteral("Change")
|
|
12414
|
-
),
|
|
12415
|
-
prop.type !== "Identifier"
|
|
12416
|
-
)
|
|
12417
|
-
);
|
|
12418
|
-
}
|
|
12419
|
-
}
|
|
12420
|
-
throw tag.hub.buildError(
|
|
12421
|
-
attr.value,
|
|
12422
|
-
"Attributes may only be bound to identifiers or member expressions"
|
|
12423
|
-
);
|
|
12424
|
-
}
|
|
12425
|
-
function buildChangeHandlerFunction(id) {
|
|
12426
|
-
const newId = "_new_" + id.name;
|
|
12427
|
-
return import_compiler62.types.arrowFunctionExpression(
|
|
12428
|
-
[withPreviousLocation(import_compiler62.types.identifier(newId), id)],
|
|
12429
|
-
import_compiler62.types.blockStatement([
|
|
12430
|
-
import_compiler62.types.expressionStatement(
|
|
12431
|
-
import_compiler62.types.assignmentExpression(
|
|
12432
|
-
"=",
|
|
12433
|
-
withPreviousLocation(import_compiler62.types.identifier(id.name), id),
|
|
12434
|
-
withPreviousLocation(import_compiler62.types.identifier(newId), id)
|
|
12435
|
-
)
|
|
12436
|
-
)
|
|
12437
|
-
])
|
|
12438
|
-
);
|
|
12439
|
-
}
|
|
12440
|
-
function getChangeHandlerFromObjectPattern(parent) {
|
|
12441
|
-
let changeKey;
|
|
12442
|
-
const pattern = parent.parentPath;
|
|
12443
|
-
if (parent.node.computed) {
|
|
12444
|
-
changeKey = generateUidIdentifier(`dynamicChange`);
|
|
12445
|
-
pattern.pushContainer(
|
|
12446
|
-
"properties",
|
|
12447
|
-
import_compiler62.types.objectProperty(
|
|
12448
|
-
import_compiler62.types.binaryExpression(
|
|
12449
|
-
"+",
|
|
12450
|
-
parent.get("key").node,
|
|
12451
|
-
import_compiler62.types.stringLiteral("Change")
|
|
12452
|
-
),
|
|
12453
|
-
changeKey,
|
|
12454
|
-
true
|
|
12455
|
-
)
|
|
12456
|
-
);
|
|
12457
|
-
} else {
|
|
12458
|
-
const key = parent.get("key");
|
|
12459
|
-
const searchKey = `${getStringOrIdentifierValue(key)}Change`;
|
|
12460
|
-
for (const prop of pattern.get("properties")) {
|
|
12461
|
-
if (prop.isObjectProperty()) {
|
|
12462
|
-
const propKey = prop.get("key");
|
|
12463
|
-
const propValue = prop.get("value");
|
|
12464
|
-
if (!prop.node.computed && getStringOrIdentifierValue(propKey) === searchKey && propValue.isIdentifier()) {
|
|
12465
|
-
changeKey = propValue.node;
|
|
12466
|
-
break;
|
|
12467
|
-
}
|
|
12468
|
-
}
|
|
12469
|
-
}
|
|
12470
|
-
if (!changeKey) {
|
|
12471
|
-
pattern.unshiftContainer(
|
|
12472
|
-
"properties",
|
|
12473
|
-
import_compiler62.types.objectProperty(
|
|
12474
|
-
import_compiler62.types.stringLiteral(searchKey),
|
|
12475
|
-
changeKey = generateUidIdentifier(searchKey)
|
|
12476
|
-
)
|
|
12477
|
-
);
|
|
12478
|
-
}
|
|
12479
|
-
}
|
|
12480
|
-
return changeKey;
|
|
12481
|
-
}
|
|
12482
|
-
function getStringOrIdentifierValue(path5) {
|
|
12483
|
-
return path5.isStringLiteral() ? path5.node.value : path5.node.name;
|
|
12484
|
-
}
|
|
12485
12604
|
|
|
12486
12605
|
// src/translator/visitors/text.ts
|
|
12487
|
-
var
|
|
12606
|
+
var import_compiler65 = require("@marko/compiler");
|
|
12488
12607
|
var text_default = {
|
|
12489
12608
|
translate: {
|
|
12490
12609
|
exit(text) {
|