marko 6.0.0-next.3.37 → 6.0.0-next.3.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug/dom.js +48 -54
- package/dist/debug/dom.mjs +48 -54
- package/dist/dom/compat.d.ts +2 -2
- package/dist/dom/control-flow.d.ts +4 -5
- package/dist/dom/signals.d.ts +1 -2
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +67 -67
- package/dist/dom.mjs +67 -67
- package/dist/translator/core/for.d.ts +0 -9
- package/dist/translator/core/if.d.ts +0 -8
- package/dist/translator/index.js +549 -549
- package/dist/translator/util/is-only-child-in-parent.d.ts +14 -0
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -628,7 +628,7 @@ function toMemberExpression(object, key, optional) {
|
|
628
628
|
var pureFunctions = [
|
629
629
|
"conditional",
|
630
630
|
"conditionalClosure",
|
631
|
-
"
|
631
|
+
"dynamicTag",
|
632
632
|
"createRenderer",
|
633
633
|
"createRendererWithOwner",
|
634
634
|
"createTemplate",
|
@@ -2900,7 +2900,7 @@ var dom_default = {
|
|
2900
2900
|
import_compiler18.types.variableDeclaration("const", [
|
2901
2901
|
import_compiler18.types.variableDeclarator(
|
2902
2902
|
identifier,
|
2903
|
-
isStatefulSection(childSection) ? callRuntime(
|
2903
|
+
!childSection.isBranch && isStatefulSection(childSection) ? callRuntime(
|
2904
2904
|
"register",
|
2905
2905
|
import_compiler18.types.stringLiteral(
|
2906
2906
|
getResumeRegisterId(childSection, "renderer")
|
@@ -4223,8 +4223,8 @@ var debug_default = {
|
|
4223
4223
|
};
|
4224
4224
|
|
4225
4225
|
// src/translator/core/define.ts
|
4226
|
-
var
|
4227
|
-
var
|
4226
|
+
var import_compiler32 = require("@marko/compiler");
|
4227
|
+
var import_babel_utils21 = require("@marko/compiler/babel-utils");
|
4228
4228
|
|
4229
4229
|
// src/translator/util/nested-attribute-tags.ts
|
4230
4230
|
var import_compiler27 = require("@marko/compiler");
|
@@ -4349,10 +4349,14 @@ function getConditionRoot(tag) {
|
|
4349
4349
|
}
|
4350
4350
|
|
4351
4351
|
// src/translator/util/translate-attrs.ts
|
4352
|
+
var import_compiler31 = require("@marko/compiler");
|
4353
|
+
var import_babel_utils20 = require("@marko/compiler/babel-utils");
|
4354
|
+
|
4355
|
+
// src/translator/core/for.ts
|
4352
4356
|
var import_compiler30 = require("@marko/compiler");
|
4353
4357
|
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
4354
4358
|
|
4355
|
-
// src/translator/
|
4359
|
+
// src/translator/util/is-only-child-in-parent.ts
|
4356
4360
|
var import_compiler29 = require("@marko/compiler");
|
4357
4361
|
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
4358
4362
|
|
@@ -5009,16 +5013,46 @@ function isInvokedFunction(expr) {
|
|
5009
5013
|
return parent.type === "CallExpression" && parent.callee === node;
|
5010
5014
|
}
|
5011
5015
|
|
5012
|
-
// src/translator/
|
5013
|
-
var kForMarkerBinding = Symbol("for marker binding");
|
5016
|
+
// src/translator/util/is-only-child-in-parent.ts
|
5014
5017
|
var kOnlyChildInParent = Symbol("only child in parent");
|
5018
|
+
var kNodeRef = Symbol("potential only child node ref");
|
5019
|
+
function isOnlyChildInParent(tag, branchSize = 1) {
|
5020
|
+
const extra = tag.node.extra;
|
5021
|
+
if (extra[kOnlyChildInParent] !== void 0) {
|
5022
|
+
return extra[kOnlyChildInParent];
|
5023
|
+
}
|
5024
|
+
const parentTag = getParentTag(tag);
|
5025
|
+
if (parentTag && (0, import_babel_utils18.getTagDef)(parentTag)?.html) {
|
5026
|
+
return extra[kOnlyChildInParent] = tag.parent.body.length === branchSize;
|
5027
|
+
}
|
5028
|
+
return extra[kOnlyChildInParent] = false;
|
5029
|
+
}
|
5030
|
+
function getOptimizedOnlyChildNodeRef(tag, section, branchSize = 1) {
|
5031
|
+
if (isOnlyChildInParent(tag, branchSize)) {
|
5032
|
+
const parentTag = getParentTag(tag).node;
|
5033
|
+
const parentTagName = parentTag.name?.value;
|
5034
|
+
return (parentTag.extra ??= {})[kNativeTagBinding] ??= createBinding(
|
5035
|
+
"#" + parentTagName,
|
5036
|
+
0 /* dom */,
|
5037
|
+
section
|
5038
|
+
);
|
5039
|
+
} else {
|
5040
|
+
return (tag.node.extra ??= {})[kNodeRef] ??= createBinding(
|
5041
|
+
"#text",
|
5042
|
+
0 /* dom */,
|
5043
|
+
section
|
5044
|
+
);
|
5045
|
+
}
|
5046
|
+
}
|
5047
|
+
|
5048
|
+
// src/translator/core/for.ts
|
5015
5049
|
var for_default = {
|
5016
5050
|
analyze(tag) {
|
5017
5051
|
const tagExtra = tag.node.extra ??= {};
|
5018
5052
|
const isAttrTag = tag.node.body.attributeTags;
|
5019
5053
|
let allowAttrs;
|
5020
|
-
(0,
|
5021
|
-
(0,
|
5054
|
+
(0, import_babel_utils19.assertNoVar)(tag);
|
5055
|
+
(0, import_babel_utils19.assertNoArgs)(tag);
|
5022
5056
|
assertNoSpreadAttrs(tag);
|
5023
5057
|
switch (getForType(tag.node)) {
|
5024
5058
|
case "of":
|
@@ -5038,7 +5072,7 @@ var for_default = {
|
|
5038
5072
|
if (!isAttrTag) {
|
5039
5073
|
allowAttrs.push("by");
|
5040
5074
|
}
|
5041
|
-
(0,
|
5075
|
+
(0, import_babel_utils19.assertAllowedAttributes)(tag, allowAttrs);
|
5042
5076
|
if (isAttrTag) return;
|
5043
5077
|
const tagBody = tag.get("body");
|
5044
5078
|
const bodySection = startSection(tagBody);
|
@@ -5046,26 +5080,12 @@ var for_default = {
|
|
5046
5080
|
dropReferences(getAllTagReferenceNodes(tag.node));
|
5047
5081
|
return;
|
5048
5082
|
}
|
5049
|
-
bodySection.isBranch = true;
|
5050
5083
|
const section = getOrCreateSection(tag);
|
5051
|
-
if (isOnlyChildInParent(tag)) {
|
5052
|
-
const parentTag = getParentTag(tag).node;
|
5053
|
-
const parentTagName = parentTag.name?.value;
|
5054
|
-
(parentTag.extra ??= {})[kNativeTagBinding] ??= createBinding(
|
5055
|
-
"#" + parentTagName,
|
5056
|
-
0 /* dom */,
|
5057
|
-
section
|
5058
|
-
);
|
5059
|
-
} else {
|
5060
|
-
tagExtra[kForMarkerBinding] = createBinding(
|
5061
|
-
"#text",
|
5062
|
-
0 /* dom */,
|
5063
|
-
section
|
5064
|
-
);
|
5065
|
-
}
|
5066
5084
|
trackParamsReferences(tagBody, 3 /* param */, void 0, tagExtra);
|
5067
5085
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
5086
|
+
getOptimizedOnlyChildNodeRef(tag, section);
|
5068
5087
|
bodySection.upstreamExpression = tagExtra;
|
5088
|
+
bodySection.isBranch = true;
|
5069
5089
|
},
|
5070
5090
|
translate: translateByTarget({
|
5071
5091
|
html: {
|
@@ -5092,9 +5112,8 @@ var for_default = {
|
|
5092
5112
|
const { node } = tag;
|
5093
5113
|
const tagExtra = node.extra;
|
5094
5114
|
const isStateful = isStatefulReferences(tagExtra.referencedBindings);
|
5095
|
-
const parentTag = getParentTag(tag);
|
5096
5115
|
const onlyChildInParentOptimization = isOnlyChildInParent(tag);
|
5097
|
-
const nodeRef2 =
|
5116
|
+
const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
|
5098
5117
|
const forAttrs = getKnownAttrValues(node);
|
5099
5118
|
const forType = getForType(node);
|
5100
5119
|
const params = node.body.params;
|
@@ -5103,8 +5122,8 @@ var for_default = {
|
|
5103
5122
|
const hasStatefulClosures = checkStatefulClosures(bodySection, true);
|
5104
5123
|
const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild && bodySection.content.startType !== 4 /* Text */;
|
5105
5124
|
let keyExpression;
|
5106
|
-
if (
|
5107
|
-
|
5125
|
+
if (onlyChildInParentOptimization) {
|
5126
|
+
getParentTag(tag).node.extra[kSerializeMarker] = false;
|
5108
5127
|
}
|
5109
5128
|
if (isStateful || hasStatefulClosures) {
|
5110
5129
|
const defaultParamNames = {
|
@@ -5117,33 +5136,33 @@ var for_default = {
|
|
5117
5136
|
setForceResumeScope(bodySection);
|
5118
5137
|
for (let i = 0; i <= requiredParamsIndex; i++) {
|
5119
5138
|
const existingParam = params[i];
|
5120
|
-
if (!existingParam || !
|
5139
|
+
if (!existingParam || !import_compiler30.types.isIdentifier(existingParam)) {
|
5121
5140
|
const id = params[i] = currentProgramPath.scope.generateUidIdentifier(
|
5122
5141
|
defaultParamNames[i]
|
5123
5142
|
);
|
5124
5143
|
if (existingParam) {
|
5125
5144
|
bodyStatements.unshift(
|
5126
|
-
|
5127
|
-
|
5145
|
+
import_compiler30.types.variableDeclaration("let", [
|
5146
|
+
import_compiler30.types.variableDeclarator(existingParam, id)
|
5128
5147
|
])
|
5129
5148
|
);
|
5130
5149
|
}
|
5131
5150
|
}
|
5132
5151
|
}
|
5133
5152
|
if (forAttrs.by) {
|
5134
|
-
if (
|
5153
|
+
if (import_compiler30.types.isStringLiteral(forAttrs.by)) {
|
5135
5154
|
keyExpression = toMemberExpression(
|
5136
5155
|
params[0],
|
5137
5156
|
forAttrs.by.value
|
5138
5157
|
);
|
5139
|
-
} else if (
|
5158
|
+
} else if (import_compiler30.types.isFunction(forAttrs.by)) {
|
5140
5159
|
const byIdentifier = currentProgramPath.scope.generateUidIdentifier("by");
|
5141
5160
|
statements.push(
|
5142
|
-
|
5143
|
-
|
5161
|
+
import_compiler30.types.variableDeclaration("const", [
|
5162
|
+
import_compiler30.types.variableDeclarator(byIdentifier, forAttrs.by)
|
5144
5163
|
])
|
5145
5164
|
);
|
5146
|
-
keyExpression =
|
5165
|
+
keyExpression = import_compiler30.types.callExpression(
|
5147
5166
|
byIdentifier,
|
5148
5167
|
params
|
5149
5168
|
);
|
@@ -5159,20 +5178,20 @@ var for_default = {
|
|
5159
5178
|
}
|
5160
5179
|
const forScopesIdentifier = getScopeIdentifier(bodySection);
|
5161
5180
|
getHTMLSectionStatements(tagSection).push(
|
5162
|
-
|
5163
|
-
|
5181
|
+
import_compiler30.types.variableDeclaration("const", [
|
5182
|
+
import_compiler30.types.variableDeclarator(
|
5164
5183
|
forScopesIdentifier,
|
5165
|
-
|
5184
|
+
import_compiler30.types.newExpression(import_compiler30.types.identifier("Map"), [])
|
5166
5185
|
)
|
5167
5186
|
])
|
5168
5187
|
);
|
5169
5188
|
if (keyExpression && (isStateful || hasStatefulClosures)) {
|
5170
5189
|
bodyStatements.push(
|
5171
|
-
|
5172
|
-
|
5173
|
-
|
5190
|
+
import_compiler30.types.expressionStatement(
|
5191
|
+
import_compiler30.types.callExpression(
|
5192
|
+
import_compiler30.types.memberExpression(
|
5174
5193
|
getScopeIdentifier(bodySection),
|
5175
|
-
|
5194
|
+
import_compiler30.types.identifier("set")
|
5176
5195
|
),
|
5177
5196
|
[
|
5178
5197
|
keyExpression,
|
@@ -5186,13 +5205,13 @@ var for_default = {
|
|
5186
5205
|
);
|
5187
5206
|
}
|
5188
5207
|
getSerializedScopeProperties(tagSection).set(
|
5189
|
-
|
5208
|
+
import_compiler30.types.stringLiteral(
|
5190
5209
|
getScopeAccessorLiteral(nodeRef2).value + "(" /* LoopScopeMap */
|
5191
5210
|
),
|
5192
|
-
|
5193
|
-
|
5211
|
+
import_compiler30.types.conditionalExpression(
|
5212
|
+
import_compiler30.types.memberExpression(forScopesIdentifier, import_compiler30.types.identifier("size")),
|
5194
5213
|
forScopesIdentifier,
|
5195
|
-
|
5214
|
+
import_compiler30.types.identifier("undefined")
|
5196
5215
|
)
|
5197
5216
|
);
|
5198
5217
|
}
|
@@ -5203,7 +5222,7 @@ var for_default = {
|
|
5203
5222
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
5204
5223
|
const forTagHTMLRuntime = isStateful ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
|
5205
5224
|
forTagArgs.push(
|
5206
|
-
|
5225
|
+
import_compiler30.types.arrowFunctionExpression(params, import_compiler30.types.blockStatement(bodyStatements))
|
5207
5226
|
);
|
5208
5227
|
if (isStateful) {
|
5209
5228
|
forTagArgs.push(
|
@@ -5211,11 +5230,11 @@ var for_default = {
|
|
5211
5230
|
getScopeAccessorLiteral(nodeRef2)
|
5212
5231
|
);
|
5213
5232
|
}
|
5214
|
-
if (
|
5215
|
-
forTagArgs.push(
|
5233
|
+
if (onlyChildInParentOptimization) {
|
5234
|
+
forTagArgs.push(import_compiler30.types.numericLiteral(1));
|
5216
5235
|
}
|
5217
5236
|
statements.push(
|
5218
|
-
|
5237
|
+
import_compiler30.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
5219
5238
|
);
|
5220
5239
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
5221
5240
|
replacement.skip();
|
@@ -5245,7 +5264,7 @@ var for_default = {
|
|
5245
5264
|
const { node } = tag;
|
5246
5265
|
const tagExtra = node.extra;
|
5247
5266
|
const { referencedBindings } = tagExtra;
|
5248
|
-
const nodeRef2 =
|
5267
|
+
const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
|
5249
5268
|
setClosureSignalBuilder(tag, (_closureSignal, render, intersection) => {
|
5250
5269
|
return callRuntime(
|
5251
5270
|
"loopClosure",
|
@@ -5260,7 +5279,7 @@ var for_default = {
|
|
5260
5279
|
return callRuntime(
|
5261
5280
|
forTypeToDOMRuntime(forType),
|
5262
5281
|
getScopeAccessorLiteral(nodeRef2),
|
5263
|
-
|
5282
|
+
import_compiler30.types.identifier(bodySection.name)
|
5264
5283
|
);
|
5265
5284
|
};
|
5266
5285
|
const params = node.body.params;
|
@@ -5294,7 +5313,7 @@ var for_default = {
|
|
5294
5313
|
tagSection,
|
5295
5314
|
referencedBindings,
|
5296
5315
|
signal,
|
5297
|
-
|
5316
|
+
import_compiler30.types.arrayExpression(loopArgs)
|
5298
5317
|
);
|
5299
5318
|
tag.remove();
|
5300
5319
|
}
|
@@ -5360,11 +5379,11 @@ var for_default = {
|
|
5360
5379
|
]
|
5361
5380
|
};
|
5362
5381
|
function buildForRuntimeCall(type, attrs2, params, statements) {
|
5363
|
-
return
|
5382
|
+
return import_compiler30.types.expressionStatement(
|
5364
5383
|
callRuntime(
|
5365
5384
|
forTypeToRuntime(type),
|
5366
5385
|
...getBaseArgsInForTag(type, attrs2),
|
5367
|
-
|
5386
|
+
import_compiler30.types.arrowFunctionExpression(params, import_compiler30.types.blockStatement(statements))
|
5368
5387
|
)
|
5369
5388
|
);
|
5370
5389
|
}
|
@@ -5440,22 +5459,11 @@ function getBaseArgsInForTag(type, attrs2) {
|
|
5440
5459
|
case "to":
|
5441
5460
|
return [
|
5442
5461
|
attrs2.to,
|
5443
|
-
attrs2.from ||
|
5444
|
-
attrs2.step ||
|
5462
|
+
attrs2.from || import_compiler30.types.numericLiteral(0),
|
5463
|
+
attrs2.step || import_compiler30.types.numericLiteral(1)
|
5445
5464
|
];
|
5446
5465
|
}
|
5447
5466
|
}
|
5448
|
-
function isOnlyChildInParent(tag) {
|
5449
|
-
const extra = tag.node.extra;
|
5450
|
-
if (extra[kOnlyChildInParent] !== void 0) {
|
5451
|
-
return extra[kOnlyChildInParent];
|
5452
|
-
}
|
5453
|
-
const parentTag = getParentTag(tag);
|
5454
|
-
if (parentTag && (0, import_babel_utils18.getTagDef)(parentTag)?.html) {
|
5455
|
-
return extra[kOnlyChildInParent] = tag.parent.body.length === 1;
|
5456
|
-
}
|
5457
|
-
return extra[kOnlyChildInParent] = false;
|
5458
|
-
}
|
5459
5467
|
|
5460
5468
|
// src/translator/util/translate-attrs.ts
|
5461
5469
|
var contentProps = /* @__PURE__ */ new WeakSet();
|
@@ -5470,8 +5478,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
5470
5478
|
seen.add(attrTagMeta.name);
|
5471
5479
|
if (attrTagMeta.dynamic) {
|
5472
5480
|
statements.push(
|
5473
|
-
|
5474
|
-
|
5481
|
+
import_compiler31.types.variableDeclaration("let", [
|
5482
|
+
import_compiler31.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
|
5475
5483
|
])
|
5476
5484
|
);
|
5477
5485
|
properties.push(
|
@@ -5487,7 +5495,7 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
5487
5495
|
for (let i = 0; i < attrTags2.length; i++) {
|
5488
5496
|
const child = attrTags2[i];
|
5489
5497
|
if (child.isMarkoTag()) {
|
5490
|
-
if ((0,
|
5498
|
+
if ((0, import_babel_utils20.isAttributeTag)(child)) {
|
5491
5499
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
5492
5500
|
if (attrTagMeta.dynamic) {
|
5493
5501
|
i = addDynamicAttrTagStatements(
|
@@ -5553,8 +5561,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
5553
5561
|
seen.add(contentKey);
|
5554
5562
|
const contentExpression = buildContent(tag.get("body"));
|
5555
5563
|
if (contentExpression) {
|
5556
|
-
const contentProp =
|
5557
|
-
|
5564
|
+
const contentProp = import_compiler31.types.objectProperty(
|
5565
|
+
import_compiler31.types.identifier(contentKey),
|
5558
5566
|
contentExpression
|
5559
5567
|
);
|
5560
5568
|
contentProps.add(contentProp);
|
@@ -5565,8 +5573,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
5565
5573
|
for (let i = attributes.length; i--; ) {
|
5566
5574
|
const attr2 = attributes[i];
|
5567
5575
|
const { value } = attr2;
|
5568
|
-
if (
|
5569
|
-
properties.push(
|
5576
|
+
if (import_compiler31.types.isMarkoSpreadAttribute(attr2)) {
|
5577
|
+
properties.push(import_compiler31.types.spreadElement(value));
|
5570
5578
|
} else if (!seen.has(attr2.name) && usesExport(templateExports, attr2.name)) {
|
5571
5579
|
seen.add(attr2.name);
|
5572
5580
|
properties.push(toObjectProperty(attr2.name, value));
|
@@ -5585,7 +5593,7 @@ function getTranslatedBodyContentProperty(props) {
|
|
5585
5593
|
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, templateExports, contentKey = "content") {
|
5586
5594
|
const tag = attrTags2[index];
|
5587
5595
|
if (tag.isMarkoTag()) {
|
5588
|
-
if ((0,
|
5596
|
+
if ((0, import_babel_utils20.isAttributeTag)(tag)) {
|
5589
5597
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
5590
5598
|
if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
|
5591
5599
|
const translatedAttrTag = translateAttrs(
|
@@ -5596,8 +5604,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
5596
5604
|
);
|
5597
5605
|
if (attrTagMeta.repeated) {
|
5598
5606
|
statements.push(
|
5599
|
-
|
5600
|
-
|
5607
|
+
import_compiler31.types.expressionStatement(
|
5608
|
+
import_compiler31.types.assignmentExpression(
|
5601
5609
|
"=",
|
5602
5610
|
getAttrTagIdentifier(attrTagMeta),
|
5603
5611
|
callRuntime(
|
@@ -5610,8 +5618,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
5610
5618
|
);
|
5611
5619
|
} else {
|
5612
5620
|
statements.push(
|
5613
|
-
|
5614
|
-
|
5621
|
+
import_compiler31.types.expressionStatement(
|
5622
|
+
import_compiler31.types.assignmentExpression(
|
5615
5623
|
"=",
|
5616
5624
|
getAttrTagIdentifier(attrTagMeta),
|
5617
5625
|
callRuntime(
|
@@ -5650,7 +5658,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
5650
5658
|
return index;
|
5651
5659
|
}
|
5652
5660
|
function propsToExpression(props) {
|
5653
|
-
return props.length === 1 &&
|
5661
|
+
return props.length === 1 && import_compiler31.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler31.types.objectExpression(props);
|
5654
5662
|
}
|
5655
5663
|
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
5656
5664
|
const forTag = attrTags2[index];
|
@@ -5675,9 +5683,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
5675
5683
|
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
5676
5684
|
const ifTag = attrTags2[index];
|
5677
5685
|
const consequentStatements = [];
|
5678
|
-
let ifStatement =
|
5686
|
+
let ifStatement = import_compiler31.types.ifStatement(
|
5679
5687
|
getConditionTestValue(ifTag),
|
5680
|
-
|
5688
|
+
import_compiler31.types.blockStatement(consequentStatements)
|
5681
5689
|
);
|
5682
5690
|
statements.push(ifStatement);
|
5683
5691
|
addAllAttrTagsAsDynamic(
|
@@ -5704,14 +5712,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
5704
5712
|
contentKey
|
5705
5713
|
);
|
5706
5714
|
if (testValue) {
|
5707
|
-
ifStatement.alternate = ifStatement =
|
5715
|
+
ifStatement.alternate = ifStatement = import_compiler31.types.ifStatement(
|
5708
5716
|
testValue,
|
5709
|
-
|
5717
|
+
import_compiler31.types.blockStatement(alternateStatements)
|
5710
5718
|
);
|
5711
5719
|
nextIndex++;
|
5712
5720
|
continue;
|
5713
5721
|
} else {
|
5714
|
-
ifStatement.alternate =
|
5722
|
+
ifStatement.alternate = import_compiler31.types.blockStatement(alternateStatements);
|
5715
5723
|
break;
|
5716
5724
|
}
|
5717
5725
|
}
|
@@ -5769,12 +5777,12 @@ function buildContent(body) {
|
|
5769
5777
|
"register",
|
5770
5778
|
callRuntime(
|
5771
5779
|
"createRenderer",
|
5772
|
-
|
5780
|
+
import_compiler31.types.arrowFunctionExpression(
|
5773
5781
|
body.node.params,
|
5774
|
-
|
5782
|
+
import_compiler31.types.blockStatement(body.node.body)
|
5775
5783
|
)
|
5776
5784
|
),
|
5777
|
-
|
5785
|
+
import_compiler31.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
|
5778
5786
|
getScopeIdIdentifier(
|
5779
5787
|
getSection(
|
5780
5788
|
getNonAttributeTagParent(body.parentPath)
|
@@ -5782,7 +5790,7 @@ function buildContent(body) {
|
|
5782
5790
|
)
|
5783
5791
|
);
|
5784
5792
|
} else {
|
5785
|
-
return
|
5793
|
+
return import_compiler31.types.callExpression(import_compiler31.types.identifier(bodySection.name), [
|
5786
5794
|
scopeIdentifier
|
5787
5795
|
]);
|
5788
5796
|
}
|
@@ -5790,7 +5798,7 @@ function buildContent(body) {
|
|
5790
5798
|
}
|
5791
5799
|
function getNonAttributeTagParent(tag) {
|
5792
5800
|
let cur = tag;
|
5793
|
-
while ((0,
|
5801
|
+
while ((0, import_babel_utils20.isAttributeTag)(cur) || (0, import_babel_utils20.isTransparentTag)(cur)) {
|
5794
5802
|
cur = getParentTag(cur);
|
5795
5803
|
}
|
5796
5804
|
return cur;
|
@@ -5799,7 +5807,7 @@ function getNonAttributeTagParent(tag) {
|
|
5799
5807
|
// src/translator/core/define.ts
|
5800
5808
|
var define_default = {
|
5801
5809
|
analyze(tag) {
|
5802
|
-
(0,
|
5810
|
+
(0, import_babel_utils21.assertNoArgs)(tag);
|
5803
5811
|
if (!tag.node.var) {
|
5804
5812
|
throw tag.get("name").buildCodeFrameError("The `define` tag requires a tag variable.");
|
5805
5813
|
}
|
@@ -5861,24 +5869,24 @@ var define_default = {
|
|
5861
5869
|
};
|
5862
5870
|
|
5863
5871
|
// src/translator/core/effect.ts
|
5864
|
-
var
|
5865
|
-
var
|
5872
|
+
var import_compiler33 = require("@marko/compiler");
|
5873
|
+
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
5866
5874
|
var effect_default = {
|
5867
5875
|
migrate: [
|
5868
5876
|
(tag) => {
|
5869
|
-
(0,
|
5870
|
-
(0,
|
5877
|
+
(0, import_babel_utils22.assertNoArgs)(tag);
|
5878
|
+
(0, import_babel_utils22.assertNoParams)(tag);
|
5871
5879
|
assertNoBodyContent(tag);
|
5872
|
-
(0,
|
5880
|
+
(0, import_babel_utils22.assertNoAttributeTags)(tag);
|
5873
5881
|
assertNoSpreadAttrs(tag);
|
5874
|
-
(0,
|
5875
|
-
(0,
|
5882
|
+
(0, import_babel_utils22.assertAllowedAttributes)(tag, ["value"]);
|
5883
|
+
(0, import_babel_utils22.diagnosticDeprecate)(tag, {
|
5876
5884
|
label: "The 'effect' tag has been replaced by the 'script' tag.",
|
5877
5885
|
fix() {
|
5878
5886
|
const { node } = tag;
|
5879
5887
|
tag.replaceWith(
|
5880
|
-
|
5881
|
-
withPreviousLocation(
|
5888
|
+
import_compiler33.types.markoTag(
|
5889
|
+
withPreviousLocation(import_compiler33.types.stringLiteral("script"), node.name),
|
5882
5890
|
node.attributes,
|
5883
5891
|
node.body,
|
5884
5892
|
node.arguments,
|
@@ -5895,12 +5903,12 @@ var effect_default = {
|
|
5895
5903
|
};
|
5896
5904
|
|
5897
5905
|
// src/translator/core/export.ts
|
5898
|
-
var
|
5906
|
+
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
5899
5907
|
var export_default = {
|
5900
5908
|
parse(tag) {
|
5901
5909
|
const { node } = tag;
|
5902
5910
|
tag.replaceWith(
|
5903
|
-
(0,
|
5911
|
+
(0, import_babel_utils23.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
5904
5912
|
);
|
5905
5913
|
},
|
5906
5914
|
parseOptions: {
|
@@ -5915,20 +5923,20 @@ var export_default = {
|
|
5915
5923
|
};
|
5916
5924
|
|
5917
5925
|
// src/translator/core/html-comment.ts
|
5918
|
-
var
|
5919
|
-
var
|
5926
|
+
var import_compiler34 = require("@marko/compiler");
|
5927
|
+
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
5920
5928
|
var kCommentTagBinding = Symbol("comment tag binding");
|
5921
5929
|
var kGetterId2 = Symbol("node getter id");
|
5922
5930
|
var html_comment_default = {
|
5923
5931
|
analyze(tag) {
|
5924
|
-
(0,
|
5925
|
-
(0,
|
5926
|
-
(0,
|
5932
|
+
(0, import_babel_utils24.assertNoArgs)(tag);
|
5933
|
+
(0, import_babel_utils24.assertNoParams)(tag);
|
5934
|
+
(0, import_babel_utils24.assertNoAttributes)(tag);
|
5927
5935
|
const tagVar = tag.node.var;
|
5928
5936
|
let needsBinding = false;
|
5929
5937
|
let needsGetter = false;
|
5930
5938
|
if (tagVar) {
|
5931
|
-
if (!
|
5939
|
+
if (!import_compiler34.types.isIdentifier(tagVar)) {
|
5932
5940
|
throw tag.get("var").buildCodeFrameError(
|
5933
5941
|
"The `html-comment` tag variable cannot be destructured."
|
5934
5942
|
);
|
@@ -5979,7 +5987,7 @@ var html_comment_default = {
|
|
5979
5987
|
callRuntime(
|
5980
5988
|
"nodeRef",
|
5981
5989
|
getterId && getScopeIdIdentifier(getSection(tag)),
|
5982
|
-
getterId &&
|
5990
|
+
getterId && import_compiler34.types.stringLiteral(getterId)
|
5983
5991
|
)
|
5984
5992
|
);
|
5985
5993
|
} else {
|
@@ -5992,12 +6000,12 @@ var html_comment_default = {
|
|
5992
6000
|
);
|
5993
6001
|
currentProgramPath.pushContainer(
|
5994
6002
|
"body",
|
5995
|
-
|
5996
|
-
|
6003
|
+
import_compiler34.types.variableDeclaration("const", [
|
6004
|
+
import_compiler34.types.variableDeclarator(
|
5997
6005
|
getterFnIdentifier,
|
5998
6006
|
callRuntime(
|
5999
6007
|
"nodeRef",
|
6000
|
-
|
6008
|
+
import_compiler34.types.stringLiteral(getterId),
|
6001
6009
|
getScopeAccessorLiteral(commentBinding)
|
6002
6010
|
)
|
6003
6011
|
)
|
@@ -6008,13 +6016,13 @@ var html_comment_default = {
|
|
6008
6016
|
const referenceSection = getSection(reference);
|
6009
6017
|
if (reference.parentPath?.isCallExpression()) {
|
6010
6018
|
reference.parentPath.replaceWith(
|
6011
|
-
|
6019
|
+
import_compiler34.types.expressionStatement(
|
6012
6020
|
createScopeReadExpression(referenceSection, commentBinding)
|
6013
6021
|
)
|
6014
6022
|
);
|
6015
6023
|
} else if (getterFnIdentifier) {
|
6016
6024
|
reference.replaceWith(
|
6017
|
-
|
6025
|
+
import_compiler34.types.callExpression(getterFnIdentifier, [
|
6018
6026
|
getScopeExpression(referenceSection, getSection(tag))
|
6019
6027
|
])
|
6020
6028
|
);
|
@@ -6030,9 +6038,9 @@ var html_comment_default = {
|
|
6030
6038
|
write2`<!--`;
|
6031
6039
|
if (isOutputHTML()) {
|
6032
6040
|
for (const child of tag.node.body.body) {
|
6033
|
-
if (
|
6041
|
+
if (import_compiler34.types.isMarkoText(child)) {
|
6034
6042
|
write2`${child.value}`;
|
6035
|
-
} else if (
|
6043
|
+
} else if (import_compiler34.types.isMarkoPlaceholder(child)) {
|
6036
6044
|
write2`${callRuntime("escapeXML", child.value)}`;
|
6037
6045
|
}
|
6038
6046
|
}
|
@@ -6041,10 +6049,10 @@ var html_comment_default = {
|
|
6041
6049
|
const templateExpressions = [];
|
6042
6050
|
let currentQuasi = "";
|
6043
6051
|
for (const child of tag.node.body.body) {
|
6044
|
-
if (
|
6052
|
+
if (import_compiler34.types.isMarkoText(child)) {
|
6045
6053
|
currentQuasi += child.value;
|
6046
|
-
} else if (
|
6047
|
-
templateQuasis.push(
|
6054
|
+
} else if (import_compiler34.types.isMarkoPlaceholder(child)) {
|
6055
|
+
templateQuasis.push(import_compiler34.types.templateElement({ raw: currentQuasi }));
|
6048
6056
|
templateExpressions.push(child.value);
|
6049
6057
|
currentQuasi = "";
|
6050
6058
|
}
|
@@ -6052,20 +6060,20 @@ var html_comment_default = {
|
|
6052
6060
|
if (templateExpressions.length === 0) {
|
6053
6061
|
write2`${currentQuasi}`;
|
6054
6062
|
} else {
|
6055
|
-
templateQuasis.push(
|
6063
|
+
templateQuasis.push(import_compiler34.types.templateElement({ raw: currentQuasi }));
|
6056
6064
|
addStatement(
|
6057
6065
|
"render",
|
6058
6066
|
getSection(tag),
|
6059
6067
|
tagExtra.referencedBindings,
|
6060
|
-
|
6068
|
+
import_compiler34.types.expressionStatement(
|
6061
6069
|
callRuntime(
|
6062
6070
|
"data",
|
6063
|
-
|
6071
|
+
import_compiler34.types.memberExpression(
|
6064
6072
|
scopeIdentifier,
|
6065
6073
|
getScopeAccessorLiteral(commentBinding),
|
6066
6074
|
true
|
6067
6075
|
),
|
6068
|
-
|
6076
|
+
import_compiler34.types.templateLiteral(templateQuasis, templateExpressions)
|
6069
6077
|
)
|
6070
6078
|
)
|
6071
6079
|
);
|
@@ -6091,15 +6099,15 @@ var html_comment_default = {
|
|
6091
6099
|
};
|
6092
6100
|
|
6093
6101
|
// src/translator/core/html-script.ts
|
6094
|
-
var
|
6095
|
-
var
|
6102
|
+
var import_compiler35 = require("@marko/compiler");
|
6103
|
+
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
6096
6104
|
var kGetterId3 = Symbol("node getter id");
|
6097
6105
|
var html_script_default = {
|
6098
6106
|
analyze(tag) {
|
6099
|
-
(0,
|
6100
|
-
(0,
|
6107
|
+
(0, import_babel_utils25.assertNoArgs)(tag);
|
6108
|
+
(0, import_babel_utils25.assertNoParams)(tag);
|
6101
6109
|
const { node } = tag;
|
6102
|
-
if (node.var && !
|
6110
|
+
if (node.var && !import_compiler35.types.isIdentifier(node.var)) {
|
6103
6111
|
throw tag.get("var").buildCodeFrameError(
|
6104
6112
|
"Tag variables on native elements cannot be destructured."
|
6105
6113
|
);
|
@@ -6112,7 +6120,7 @@ var html_script_default = {
|
|
6112
6120
|
let spreadReferenceNodes;
|
6113
6121
|
for (let i = attributes.length; i--; ) {
|
6114
6122
|
const attr2 = attributes[i];
|
6115
|
-
if (
|
6123
|
+
if (import_compiler35.types.isMarkoAttribute(attr2)) {
|
6116
6124
|
if (seen[attr2.name]) {
|
6117
6125
|
dropReferences(attr2.value);
|
6118
6126
|
continue;
|
@@ -6124,14 +6132,14 @@ var html_script_default = {
|
|
6124
6132
|
} else if (!evaluate(attr2.value).confident) {
|
6125
6133
|
hasDynamicAttributes = true;
|
6126
6134
|
}
|
6127
|
-
} else if (
|
6135
|
+
} else if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
|
6128
6136
|
hasEventHandlers = true;
|
6129
6137
|
hasDynamicAttributes = true;
|
6130
6138
|
(attr2.value.extra ??= {}).isEffect = true;
|
6131
6139
|
}
|
6132
6140
|
if (spreadReferenceNodes) {
|
6133
6141
|
spreadReferenceNodes.push(attr2.value);
|
6134
|
-
} else if (
|
6142
|
+
} else if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
|
6135
6143
|
spreadReferenceNodes = [attr2.value];
|
6136
6144
|
}
|
6137
6145
|
}
|
@@ -6141,10 +6149,10 @@ var html_script_default = {
|
|
6141
6149
|
const bodyPlaceholderNodes = [];
|
6142
6150
|
let hasBodyPlaceholders = false;
|
6143
6151
|
for (const child of tag.node.body.body) {
|
6144
|
-
if (
|
6152
|
+
if (import_compiler35.types.isMarkoPlaceholder(child)) {
|
6145
6153
|
bodyPlaceholderNodes.push(child.value);
|
6146
6154
|
hasBodyPlaceholders = true;
|
6147
|
-
} else if (!
|
6155
|
+
} else if (!import_compiler35.types.isMarkoText(child)) {
|
6148
6156
|
throw tag.hub.buildError(
|
6149
6157
|
child,
|
6150
6158
|
"Invalid child. Only text is allowed inside an html-script."
|
@@ -6194,7 +6202,7 @@ var html_script_default = {
|
|
6194
6202
|
let currentSection = getSection(reference);
|
6195
6203
|
while (currentSection !== section && currentSection.parent) {
|
6196
6204
|
getSerializedScopeProperties(currentSection).set(
|
6197
|
-
|
6205
|
+
import_compiler35.types.stringLiteral("_"),
|
6198
6206
|
callRuntime(
|
6199
6207
|
"ensureScopeWithId",
|
6200
6208
|
getScopeIdIdentifier(currentSection = currentSection.parent)
|
@@ -6207,7 +6215,7 @@ var html_script_default = {
|
|
6207
6215
|
callRuntime(
|
6208
6216
|
"nodeRef",
|
6209
6217
|
getterId && getScopeIdIdentifier(section),
|
6210
|
-
getterId &&
|
6218
|
+
getterId && import_compiler35.types.stringLiteral(getterId)
|
6211
6219
|
)
|
6212
6220
|
);
|
6213
6221
|
} else {
|
@@ -6220,12 +6228,12 @@ var html_script_default = {
|
|
6220
6228
|
);
|
6221
6229
|
currentProgramPath.pushContainer(
|
6222
6230
|
"body",
|
6223
|
-
|
6224
|
-
|
6231
|
+
import_compiler35.types.variableDeclaration("const", [
|
6232
|
+
import_compiler35.types.variableDeclarator(
|
6225
6233
|
getterFnIdentifier,
|
6226
6234
|
callRuntime(
|
6227
6235
|
"nodeRef",
|
6228
|
-
|
6236
|
+
import_compiler35.types.stringLiteral(getterId),
|
6229
6237
|
getScopeAccessorLiteral(nodeRef2)
|
6230
6238
|
)
|
6231
6239
|
)
|
@@ -6236,13 +6244,13 @@ var html_script_default = {
|
|
6236
6244
|
const referenceSection = getSection(reference);
|
6237
6245
|
if (reference.parentPath?.isCallExpression()) {
|
6238
6246
|
reference.parentPath.replaceWith(
|
6239
|
-
|
6247
|
+
import_compiler35.types.expressionStatement(
|
6240
6248
|
createScopeReadExpression(referenceSection, nodeRef2)
|
6241
6249
|
)
|
6242
6250
|
);
|
6243
6251
|
} else if (getterFnIdentifier) {
|
6244
6252
|
reference.replaceWith(
|
6245
|
-
|
6253
|
+
import_compiler35.types.callExpression(getterFnIdentifier, [
|
6246
6254
|
getScopeExpression(referenceSection, getSection(tag))
|
6247
6255
|
])
|
6248
6256
|
);
|
@@ -6275,10 +6283,10 @@ var html_script_default = {
|
|
6275
6283
|
"render",
|
6276
6284
|
section,
|
6277
6285
|
valueReferences,
|
6278
|
-
|
6286
|
+
import_compiler35.types.expressionStatement(
|
6279
6287
|
callRuntime(
|
6280
6288
|
helper,
|
6281
|
-
|
6289
|
+
import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6282
6290
|
value
|
6283
6291
|
)
|
6284
6292
|
)
|
@@ -6293,18 +6301,18 @@ var html_script_default = {
|
|
6293
6301
|
if (isEventHandler(name2)) {
|
6294
6302
|
addHTMLEffectCall(section, valueReferences);
|
6295
6303
|
} else {
|
6296
|
-
write2`${callRuntime("attr",
|
6304
|
+
write2`${callRuntime("attr", import_compiler35.types.stringLiteral(name2), value)}`;
|
6297
6305
|
}
|
6298
6306
|
} else if (isEventHandler(name2)) {
|
6299
6307
|
addStatement(
|
6300
6308
|
"effect",
|
6301
6309
|
section,
|
6302
6310
|
valueReferences,
|
6303
|
-
|
6311
|
+
import_compiler35.types.expressionStatement(
|
6304
6312
|
callRuntime(
|
6305
6313
|
"on",
|
6306
|
-
|
6307
|
-
|
6314
|
+
import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6315
|
+
import_compiler35.types.stringLiteral(getEventHandlerName(name2)),
|
6308
6316
|
value
|
6309
6317
|
)
|
6310
6318
|
)
|
@@ -6314,11 +6322,11 @@ var html_script_default = {
|
|
6314
6322
|
"render",
|
6315
6323
|
section,
|
6316
6324
|
valueReferences,
|
6317
|
-
|
6325
|
+
import_compiler35.types.expressionStatement(
|
6318
6326
|
callRuntime(
|
6319
6327
|
"attr",
|
6320
|
-
|
6321
|
-
|
6328
|
+
import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6329
|
+
import_compiler35.types.stringLiteral(name2),
|
6322
6330
|
value
|
6323
6331
|
)
|
6324
6332
|
)
|
@@ -6331,9 +6339,9 @@ var html_script_default = {
|
|
6331
6339
|
if (isHTML) {
|
6332
6340
|
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
6333
6341
|
if (skipExpression) {
|
6334
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section),
|
6342
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler35.types.stringLiteral("script"))}`;
|
6335
6343
|
} else {
|
6336
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section),
|
6344
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler35.types.stringLiteral("script"))}`;
|
6337
6345
|
}
|
6338
6346
|
} else {
|
6339
6347
|
if (skipExpression) {
|
@@ -6341,7 +6349,7 @@ var html_script_default = {
|
|
6341
6349
|
"render",
|
6342
6350
|
section,
|
6343
6351
|
tagExtra.referencedBindings,
|
6344
|
-
|
6352
|
+
import_compiler35.types.expressionStatement(
|
6345
6353
|
callRuntime(
|
6346
6354
|
"partialAttrs",
|
6347
6355
|
scopeIdentifier,
|
@@ -6356,7 +6364,7 @@ var html_script_default = {
|
|
6356
6364
|
"render",
|
6357
6365
|
section,
|
6358
6366
|
tagExtra.referencedBindings,
|
6359
|
-
|
6367
|
+
import_compiler35.types.expressionStatement(
|
6360
6368
|
callRuntime(
|
6361
6369
|
"attrs",
|
6362
6370
|
scopeIdentifier,
|
@@ -6370,7 +6378,7 @@ var html_script_default = {
|
|
6370
6378
|
"effect",
|
6371
6379
|
section,
|
6372
6380
|
tagExtra.referencedBindings,
|
6373
|
-
|
6381
|
+
import_compiler35.types.expressionStatement(
|
6374
6382
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
6375
6383
|
),
|
6376
6384
|
false
|
@@ -6381,9 +6389,9 @@ var html_script_default = {
|
|
6381
6389
|
enter2(tag);
|
6382
6390
|
if (isOutputHTML()) {
|
6383
6391
|
for (const child of tag.node.body.body) {
|
6384
|
-
if (
|
6392
|
+
if (import_compiler35.types.isMarkoText(child)) {
|
6385
6393
|
write2`${child.value}`;
|
6386
|
-
} else if (
|
6394
|
+
} else if (import_compiler35.types.isMarkoPlaceholder(child)) {
|
6387
6395
|
write2`${callRuntime("escapeScript", child.value)}`;
|
6388
6396
|
}
|
6389
6397
|
}
|
@@ -6393,11 +6401,11 @@ var html_script_default = {
|
|
6393
6401
|
let currentQuasi = "";
|
6394
6402
|
let referencePlaceholder;
|
6395
6403
|
for (const child of tag.node.body.body) {
|
6396
|
-
if (
|
6404
|
+
if (import_compiler35.types.isMarkoText(child)) {
|
6397
6405
|
currentQuasi += child.value;
|
6398
|
-
} else if (
|
6406
|
+
} else if (import_compiler35.types.isMarkoPlaceholder(child)) {
|
6399
6407
|
referencePlaceholder ||= child;
|
6400
|
-
templateQuasis.push(
|
6408
|
+
templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
|
6401
6409
|
templateExpressions.push(child.value);
|
6402
6410
|
currentQuasi = "";
|
6403
6411
|
}
|
@@ -6405,16 +6413,16 @@ var html_script_default = {
|
|
6405
6413
|
if (!referencePlaceholder) {
|
6406
6414
|
write2`${currentQuasi}`;
|
6407
6415
|
} else {
|
6408
|
-
templateQuasis.push(
|
6416
|
+
templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
|
6409
6417
|
addStatement(
|
6410
6418
|
"render",
|
6411
6419
|
getSection(tag),
|
6412
6420
|
referencePlaceholder.value.extra?.referencedBindings,
|
6413
|
-
|
6421
|
+
import_compiler35.types.expressionStatement(
|
6414
6422
|
callRuntime(
|
6415
6423
|
"textContent",
|
6416
|
-
|
6417
|
-
|
6424
|
+
import_compiler35.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6425
|
+
import_compiler35.types.templateLiteral(templateQuasis, templateExpressions)
|
6418
6426
|
)
|
6419
6427
|
)
|
6420
6428
|
);
|
@@ -6453,11 +6461,11 @@ function getUsedAttrs2(tag) {
|
|
6453
6461
|
for (let i = attributes.length; i--; ) {
|
6454
6462
|
const attr2 = attributes[i];
|
6455
6463
|
const { value } = attr2;
|
6456
|
-
if (
|
6464
|
+
if (import_compiler35.types.isMarkoSpreadAttribute(attr2)) {
|
6457
6465
|
if (!spreadProps) {
|
6458
6466
|
spreadProps = [];
|
6459
6467
|
}
|
6460
|
-
spreadProps.push(
|
6468
|
+
spreadProps.push(import_compiler35.types.spreadElement(value));
|
6461
6469
|
} else if (!seen[attr2.name]) {
|
6462
6470
|
seen[attr2.name] = attr2;
|
6463
6471
|
if (spreadProps) {
|
@@ -6471,10 +6479,10 @@ function getUsedAttrs2(tag) {
|
|
6471
6479
|
if (spreadProps) {
|
6472
6480
|
spreadProps.reverse();
|
6473
6481
|
for (const { name: name2 } of staticAttrs) {
|
6474
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
6482
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler35.types.numericLiteral(1)));
|
6475
6483
|
}
|
6476
6484
|
if (skipProps) {
|
6477
|
-
skipExpression =
|
6485
|
+
skipExpression = import_compiler35.types.objectExpression(skipProps);
|
6478
6486
|
}
|
6479
6487
|
spreadExpression = propsToExpression(spreadProps);
|
6480
6488
|
}
|
@@ -6486,15 +6494,15 @@ function getUsedAttrs2(tag) {
|
|
6486
6494
|
}
|
6487
6495
|
|
6488
6496
|
// src/translator/core/html-style.ts
|
6489
|
-
var
|
6490
|
-
var
|
6497
|
+
var import_compiler36 = require("@marko/compiler");
|
6498
|
+
var import_babel_utils26 = require("@marko/compiler/babel-utils");
|
6491
6499
|
var kGetterId4 = Symbol("node getter id");
|
6492
6500
|
var html_style_default = {
|
6493
6501
|
analyze(tag) {
|
6494
|
-
(0,
|
6495
|
-
(0,
|
6502
|
+
(0, import_babel_utils26.assertNoArgs)(tag);
|
6503
|
+
(0, import_babel_utils26.assertNoParams)(tag);
|
6496
6504
|
const { node } = tag;
|
6497
|
-
if (node.var && !
|
6505
|
+
if (node.var && !import_compiler36.types.isIdentifier(node.var)) {
|
6498
6506
|
throw tag.get("var").buildCodeFrameError(
|
6499
6507
|
"Tag variables on native elements cannot be destructured."
|
6500
6508
|
);
|
@@ -6507,7 +6515,7 @@ var html_style_default = {
|
|
6507
6515
|
let spreadReferenceNodes;
|
6508
6516
|
for (let i = attributes.length; i--; ) {
|
6509
6517
|
const attr2 = attributes[i];
|
6510
|
-
if (
|
6518
|
+
if (import_compiler36.types.isMarkoAttribute(attr2)) {
|
6511
6519
|
if (seen[attr2.name]) {
|
6512
6520
|
dropReferences(attr2.value);
|
6513
6521
|
continue;
|
@@ -6519,14 +6527,14 @@ var html_style_default = {
|
|
6519
6527
|
} else if (!evaluate(attr2.value).confident) {
|
6520
6528
|
hasDynamicAttributes = true;
|
6521
6529
|
}
|
6522
|
-
} else if (
|
6530
|
+
} else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
|
6523
6531
|
hasEventHandlers = true;
|
6524
6532
|
hasDynamicAttributes = true;
|
6525
6533
|
(attr2.value.extra ??= {}).isEffect = true;
|
6526
6534
|
}
|
6527
6535
|
if (spreadReferenceNodes) {
|
6528
6536
|
spreadReferenceNodes.push(attr2.value);
|
6529
|
-
} else if (
|
6537
|
+
} else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
|
6530
6538
|
spreadReferenceNodes = [attr2.value];
|
6531
6539
|
}
|
6532
6540
|
}
|
@@ -6536,10 +6544,10 @@ var html_style_default = {
|
|
6536
6544
|
const bodyPlaceholderNodes = [];
|
6537
6545
|
let hasBodyPlaceholders = false;
|
6538
6546
|
for (const child of tag.node.body.body) {
|
6539
|
-
if (
|
6547
|
+
if (import_compiler36.types.isMarkoPlaceholder(child)) {
|
6540
6548
|
bodyPlaceholderNodes.push(child.value);
|
6541
6549
|
hasBodyPlaceholders = true;
|
6542
|
-
} else if (!
|
6550
|
+
} else if (!import_compiler36.types.isMarkoText(child)) {
|
6543
6551
|
throw tag.hub.buildError(
|
6544
6552
|
child,
|
6545
6553
|
"Invalid child. Only text is allowed inside an html-style."
|
@@ -6589,7 +6597,7 @@ var html_style_default = {
|
|
6589
6597
|
let currentSection = getSection(reference);
|
6590
6598
|
while (currentSection !== section && currentSection.parent) {
|
6591
6599
|
getSerializedScopeProperties(currentSection).set(
|
6592
|
-
|
6600
|
+
import_compiler36.types.stringLiteral("_"),
|
6593
6601
|
callRuntime(
|
6594
6602
|
"ensureScopeWithId",
|
6595
6603
|
getScopeIdIdentifier(currentSection = currentSection.parent)
|
@@ -6602,7 +6610,7 @@ var html_style_default = {
|
|
6602
6610
|
callRuntime(
|
6603
6611
|
"nodeRef",
|
6604
6612
|
getterId && getScopeIdIdentifier(section),
|
6605
|
-
getterId &&
|
6613
|
+
getterId && import_compiler36.types.stringLiteral(getterId)
|
6606
6614
|
)
|
6607
6615
|
);
|
6608
6616
|
} else {
|
@@ -6615,12 +6623,12 @@ var html_style_default = {
|
|
6615
6623
|
);
|
6616
6624
|
currentProgramPath.pushContainer(
|
6617
6625
|
"body",
|
6618
|
-
|
6619
|
-
|
6626
|
+
import_compiler36.types.variableDeclaration("const", [
|
6627
|
+
import_compiler36.types.variableDeclarator(
|
6620
6628
|
getterFnIdentifier,
|
6621
6629
|
callRuntime(
|
6622
6630
|
"nodeRef",
|
6623
|
-
|
6631
|
+
import_compiler36.types.stringLiteral(getterId),
|
6624
6632
|
getScopeAccessorLiteral(nodeRef2)
|
6625
6633
|
)
|
6626
6634
|
)
|
@@ -6631,13 +6639,13 @@ var html_style_default = {
|
|
6631
6639
|
const referenceSection = getSection(reference);
|
6632
6640
|
if (reference.parentPath?.isCallExpression()) {
|
6633
6641
|
reference.parentPath.replaceWith(
|
6634
|
-
|
6642
|
+
import_compiler36.types.expressionStatement(
|
6635
6643
|
createScopeReadExpression(referenceSection, nodeRef2)
|
6636
6644
|
)
|
6637
6645
|
);
|
6638
6646
|
} else if (getterFnIdentifier) {
|
6639
6647
|
reference.replaceWith(
|
6640
|
-
|
6648
|
+
import_compiler36.types.callExpression(getterFnIdentifier, [
|
6641
6649
|
getScopeExpression(referenceSection, getSection(tag))
|
6642
6650
|
])
|
6643
6651
|
);
|
@@ -6670,10 +6678,10 @@ var html_style_default = {
|
|
6670
6678
|
"render",
|
6671
6679
|
section,
|
6672
6680
|
valueReferences,
|
6673
|
-
|
6681
|
+
import_compiler36.types.expressionStatement(
|
6674
6682
|
callRuntime(
|
6675
6683
|
helper,
|
6676
|
-
|
6684
|
+
import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6677
6685
|
value
|
6678
6686
|
)
|
6679
6687
|
)
|
@@ -6688,18 +6696,18 @@ var html_style_default = {
|
|
6688
6696
|
if (isEventHandler(name2)) {
|
6689
6697
|
addHTMLEffectCall(section, valueReferences);
|
6690
6698
|
} else {
|
6691
|
-
write2`${callRuntime("attr",
|
6699
|
+
write2`${callRuntime("attr", import_compiler36.types.stringLiteral(name2), value)}`;
|
6692
6700
|
}
|
6693
6701
|
} else if (isEventHandler(name2)) {
|
6694
6702
|
addStatement(
|
6695
6703
|
"effect",
|
6696
6704
|
section,
|
6697
6705
|
valueReferences,
|
6698
|
-
|
6706
|
+
import_compiler36.types.expressionStatement(
|
6699
6707
|
callRuntime(
|
6700
6708
|
"on",
|
6701
|
-
|
6702
|
-
|
6709
|
+
import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6710
|
+
import_compiler36.types.stringLiteral(getEventHandlerName(name2)),
|
6703
6711
|
value
|
6704
6712
|
)
|
6705
6713
|
)
|
@@ -6709,11 +6717,11 @@ var html_style_default = {
|
|
6709
6717
|
"render",
|
6710
6718
|
section,
|
6711
6719
|
valueReferences,
|
6712
|
-
|
6720
|
+
import_compiler36.types.expressionStatement(
|
6713
6721
|
callRuntime(
|
6714
6722
|
"attr",
|
6715
|
-
|
6716
|
-
|
6723
|
+
import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6724
|
+
import_compiler36.types.stringLiteral(name2),
|
6717
6725
|
value
|
6718
6726
|
)
|
6719
6727
|
)
|
@@ -6726,9 +6734,9 @@ var html_style_default = {
|
|
6726
6734
|
if (isHTML) {
|
6727
6735
|
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
6728
6736
|
if (skipExpression) {
|
6729
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section),
|
6737
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler36.types.stringLiteral("style"))}`;
|
6730
6738
|
} else {
|
6731
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section),
|
6739
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler36.types.stringLiteral("style"))}`;
|
6732
6740
|
}
|
6733
6741
|
} else {
|
6734
6742
|
if (skipExpression) {
|
@@ -6736,7 +6744,7 @@ var html_style_default = {
|
|
6736
6744
|
"render",
|
6737
6745
|
section,
|
6738
6746
|
tagExtra.referencedBindings,
|
6739
|
-
|
6747
|
+
import_compiler36.types.expressionStatement(
|
6740
6748
|
callRuntime(
|
6741
6749
|
"partialAttrs",
|
6742
6750
|
scopeIdentifier,
|
@@ -6751,7 +6759,7 @@ var html_style_default = {
|
|
6751
6759
|
"render",
|
6752
6760
|
section,
|
6753
6761
|
tagExtra.referencedBindings,
|
6754
|
-
|
6762
|
+
import_compiler36.types.expressionStatement(
|
6755
6763
|
callRuntime(
|
6756
6764
|
"attrs",
|
6757
6765
|
scopeIdentifier,
|
@@ -6765,7 +6773,7 @@ var html_style_default = {
|
|
6765
6773
|
"effect",
|
6766
6774
|
section,
|
6767
6775
|
tagExtra.referencedBindings,
|
6768
|
-
|
6776
|
+
import_compiler36.types.expressionStatement(
|
6769
6777
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
6770
6778
|
),
|
6771
6779
|
false
|
@@ -6776,9 +6784,9 @@ var html_style_default = {
|
|
6776
6784
|
enter2(tag);
|
6777
6785
|
if (isOutputHTML()) {
|
6778
6786
|
for (const child of tag.node.body.body) {
|
6779
|
-
if (
|
6787
|
+
if (import_compiler36.types.isMarkoText(child)) {
|
6780
6788
|
write2`${child.value}`;
|
6781
|
-
} else if (
|
6789
|
+
} else if (import_compiler36.types.isMarkoPlaceholder(child)) {
|
6782
6790
|
write2`${callRuntime("escapeStyle", child.value)}`;
|
6783
6791
|
}
|
6784
6792
|
}
|
@@ -6788,11 +6796,11 @@ var html_style_default = {
|
|
6788
6796
|
let currentQuasi = "";
|
6789
6797
|
let referencePlaceholder;
|
6790
6798
|
for (const child of tag.node.body.body) {
|
6791
|
-
if (
|
6799
|
+
if (import_compiler36.types.isMarkoText(child)) {
|
6792
6800
|
currentQuasi += child.value;
|
6793
|
-
} else if (
|
6801
|
+
} else if (import_compiler36.types.isMarkoPlaceholder(child)) {
|
6794
6802
|
referencePlaceholder ||= child;
|
6795
|
-
templateQuasis.push(
|
6803
|
+
templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
|
6796
6804
|
templateExpressions.push(child.value);
|
6797
6805
|
currentQuasi = "";
|
6798
6806
|
}
|
@@ -6800,16 +6808,16 @@ var html_style_default = {
|
|
6800
6808
|
if (!referencePlaceholder) {
|
6801
6809
|
write2`${currentQuasi}`;
|
6802
6810
|
} else {
|
6803
|
-
templateQuasis.push(
|
6811
|
+
templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
|
6804
6812
|
addStatement(
|
6805
6813
|
"render",
|
6806
6814
|
getSection(tag),
|
6807
6815
|
referencePlaceholder.value.extra?.referencedBindings,
|
6808
|
-
|
6816
|
+
import_compiler36.types.expressionStatement(
|
6809
6817
|
callRuntime(
|
6810
6818
|
"textContent",
|
6811
|
-
|
6812
|
-
|
6819
|
+
import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6820
|
+
import_compiler36.types.templateLiteral(templateQuasis, templateExpressions)
|
6813
6821
|
)
|
6814
6822
|
)
|
6815
6823
|
);
|
@@ -6843,11 +6851,11 @@ function getUsedAttrs3(tag) {
|
|
6843
6851
|
for (let i = attributes.length; i--; ) {
|
6844
6852
|
const attr2 = attributes[i];
|
6845
6853
|
const { value } = attr2;
|
6846
|
-
if (
|
6854
|
+
if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
|
6847
6855
|
if (!spreadProps) {
|
6848
6856
|
spreadProps = [];
|
6849
6857
|
}
|
6850
|
-
spreadProps.push(
|
6858
|
+
spreadProps.push(import_compiler36.types.spreadElement(value));
|
6851
6859
|
} else if (!seen[attr2.name]) {
|
6852
6860
|
seen[attr2.name] = attr2;
|
6853
6861
|
if (spreadProps) {
|
@@ -6861,10 +6869,10 @@ function getUsedAttrs3(tag) {
|
|
6861
6869
|
if (spreadProps) {
|
6862
6870
|
spreadProps.reverse();
|
6863
6871
|
for (const { name: name2 } of staticAttrs) {
|
6864
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
6872
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler36.types.numericLiteral(1)));
|
6865
6873
|
}
|
6866
6874
|
if (skipProps) {
|
6867
|
-
skipExpression =
|
6875
|
+
skipExpression = import_compiler36.types.objectExpression(skipProps);
|
6868
6876
|
}
|
6869
6877
|
spreadExpression = propsToExpression(spreadProps);
|
6870
6878
|
}
|
@@ -6876,20 +6884,20 @@ function getUsedAttrs3(tag) {
|
|
6876
6884
|
}
|
6877
6885
|
|
6878
6886
|
// src/translator/core/id.ts
|
6879
|
-
var
|
6880
|
-
var
|
6887
|
+
var import_compiler37 = require("@marko/compiler");
|
6888
|
+
var import_babel_utils27 = require("@marko/compiler/babel-utils");
|
6881
6889
|
var id_default = {
|
6882
6890
|
analyze(tag) {
|
6883
|
-
(0,
|
6884
|
-
(0,
|
6885
|
-
(0,
|
6891
|
+
(0, import_babel_utils27.assertNoArgs)(tag);
|
6892
|
+
(0, import_babel_utils27.assertNoParams)(tag);
|
6893
|
+
(0, import_babel_utils27.assertNoAttributes)(tag);
|
6886
6894
|
assertNoBodyContent(tag);
|
6887
|
-
(0,
|
6895
|
+
(0, import_babel_utils27.assertNoAttributeTags)(tag);
|
6888
6896
|
const { node } = tag;
|
6889
6897
|
if (!node.var) {
|
6890
6898
|
throw tag.get("name").buildCodeFrameError("The `id` tag requires a tag variable.");
|
6891
6899
|
}
|
6892
|
-
if (!
|
6900
|
+
if (!import_compiler37.types.isIdentifier(node.var)) {
|
6893
6901
|
throw tag.get("var").buildCodeFrameError("The `id` tag cannot be destructured");
|
6894
6902
|
}
|
6895
6903
|
trackVarReferences(tag, 4 /* derived */);
|
@@ -6900,7 +6908,7 @@ var id_default = {
|
|
6900
6908
|
const id = isOutputHTML() ? callRuntime("nextTagId") : callRuntime("nextTagId", scopeIdentifier);
|
6901
6909
|
if (isOutputHTML()) {
|
6902
6910
|
tag.replaceWith(
|
6903
|
-
|
6911
|
+
import_compiler37.types.variableDeclaration("const", [import_compiler37.types.variableDeclarator(node.var, id)])
|
6904
6912
|
);
|
6905
6913
|
} else {
|
6906
6914
|
const source = initValue(node.var.extra.binding);
|
@@ -6925,23 +6933,22 @@ var id_default = {
|
|
6925
6933
|
};
|
6926
6934
|
|
6927
6935
|
// src/translator/core/if.ts
|
6928
|
-
var
|
6929
|
-
var
|
6936
|
+
var import_compiler39 = require("@marko/compiler");
|
6937
|
+
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
6930
6938
|
|
6931
6939
|
// src/translator/util/to-first-statement-or-block.ts
|
6932
|
-
var
|
6940
|
+
var import_compiler38 = require("@marko/compiler");
|
6933
6941
|
function toFirstStatementOrBlock(body) {
|
6934
6942
|
if (Array.isArray(body)) {
|
6935
6943
|
if (body.length === 1) {
|
6936
6944
|
return body[0];
|
6937
6945
|
}
|
6938
|
-
return
|
6946
|
+
return import_compiler38.types.blockStatement(body);
|
6939
6947
|
}
|
6940
6948
|
return body;
|
6941
6949
|
}
|
6942
6950
|
|
6943
6951
|
// src/translator/core/if.ts
|
6944
|
-
var kBinding = Symbol("if node binding");
|
6945
6952
|
var BRANCHES_LOOKUP = /* @__PURE__ */ new WeakMap();
|
6946
6953
|
var IfTag = {
|
6947
6954
|
analyze(tag) {
|
@@ -6966,15 +6973,9 @@ var IfTag = {
|
|
6966
6973
|
}
|
6967
6974
|
}
|
6968
6975
|
const section = getOrCreateSection(tag);
|
6969
|
-
rootExtra[kBinding] = createBinding(
|
6970
|
-
"#text",
|
6971
|
-
0 /* dom */,
|
6972
|
-
section,
|
6973
|
-
void 0,
|
6974
|
-
rootExtra
|
6975
|
-
);
|
6976
|
-
rootExtra.singleNodeOptimization = singleNodeOptimization;
|
6977
6976
|
mergeReferences(section, rootTag.node, mergeReferenceNodes);
|
6977
|
+
getOptimizedOnlyChildNodeRef(rootTag, section, branches.length);
|
6978
|
+
rootExtra.singleNodeOptimization = singleNodeOptimization;
|
6978
6979
|
}
|
6979
6980
|
},
|
6980
6981
|
translate: translateByTarget({
|
@@ -6983,10 +6984,10 @@ var IfTag = {
|
|
6983
6984
|
if (tag.node.body.attributeTags) return;
|
6984
6985
|
const tagBody = tag.get("body");
|
6985
6986
|
const bodySection = getSectionForBody(tagBody);
|
6986
|
-
if (isRoot(tag)) {
|
6987
|
+
if (isRoot(tag) && !isOnlyChildInParent(tag)) {
|
6987
6988
|
visit(tag, 37 /* Replace */);
|
6989
|
+
enterShallow(tag);
|
6988
6990
|
}
|
6989
|
-
enterShallow(tag);
|
6990
6991
|
flushBefore(tag);
|
6991
6992
|
if (bodySection) {
|
6992
6993
|
setSectionParentIsOwner(bodySection, true);
|
@@ -6998,8 +6999,8 @@ var IfTag = {
|
|
6998
6999
|
const section = getSection(tag);
|
6999
7000
|
const bodySection = getSectionForBody(tagBody);
|
7000
7001
|
const [isLast, branches] = getBranches(tag, bodySection);
|
7001
|
-
const
|
7002
|
-
const
|
7002
|
+
const [rootTag] = branches[0];
|
7003
|
+
const rootExtra = rootTag.node.extra;
|
7003
7004
|
const isStateful = isStatefulReferences(rootExtra.referencedBindings);
|
7004
7005
|
const singleNodeOptimization = rootExtra.singleNodeOptimization;
|
7005
7006
|
const hasStatefulClosures = bodySection && checkStatefulClosures(bodySection, true);
|
@@ -7013,10 +7014,15 @@ var IfTag = {
|
|
7013
7014
|
writeHTMLResumeStatements(tagBody);
|
7014
7015
|
}
|
7015
7016
|
if (isLast) {
|
7017
|
+
const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
|
7018
|
+
const onlyChildInParentOptimization = isOnlyChildInParent(rootTag);
|
7016
7019
|
const nextTag = tag.getNextSibling();
|
7017
|
-
const ifScopeIdIdentifier =
|
7018
|
-
const
|
7020
|
+
const ifScopeIdIdentifier = rootTag.scope.generateUidIdentifier("ifScopeId");
|
7021
|
+
const ifBranchIdentifier = rootTag.scope.generateUidIdentifier("ifBranch");
|
7019
7022
|
let statement;
|
7023
|
+
if (onlyChildInParentOptimization) {
|
7024
|
+
getParentTag(rootTag).node.extra[kSerializeMarker] = false;
|
7025
|
+
}
|
7020
7026
|
for (let i = branches.length; i--; ) {
|
7021
7027
|
const [branchTag, branchBodySection] = branches[i];
|
7022
7028
|
const bodyStatements = branchTag.node.body.body;
|
@@ -7027,28 +7033,19 @@ var IfTag = {
|
|
7027
7033
|
);
|
7028
7034
|
if (isStateful) {
|
7029
7035
|
bodyStatements.push(
|
7030
|
-
|
7031
|
-
|
7032
|
-
"
|
7033
|
-
|
7034
|
-
|
7035
|
-
ifRendererIdentifier,
|
7036
|
-
callRuntime(
|
7037
|
-
"createRenderer",
|
7038
|
-
import_compiler38.types.arrowFunctionExpression([], import_compiler38.types.blockStatement([]))
|
7039
|
-
)
|
7040
|
-
),
|
7041
|
-
import_compiler38.types.stringLiteral(
|
7042
|
-
getResumeRegisterId(branchBodySection, "renderer")
|
7043
|
-
)
|
7036
|
+
import_compiler39.types.expressionStatement(
|
7037
|
+
import_compiler39.types.assignmentExpression(
|
7038
|
+
"=",
|
7039
|
+
ifBranchIdentifier,
|
7040
|
+
import_compiler39.types.numericLiteral(i)
|
7044
7041
|
)
|
7045
7042
|
)
|
7046
7043
|
);
|
7047
7044
|
}
|
7048
7045
|
if (isStateful || branchHasStatefulClosures) {
|
7049
7046
|
bodyStatements.push(
|
7050
|
-
|
7051
|
-
|
7047
|
+
import_compiler39.types.expressionStatement(
|
7048
|
+
import_compiler39.types.assignmentExpression(
|
7052
7049
|
"=",
|
7053
7050
|
ifScopeIdIdentifier,
|
7054
7051
|
getScopeIdIdentifier(branchBodySection)
|
@@ -7060,7 +7057,7 @@ var IfTag = {
|
|
7060
7057
|
const [testAttr] = branchTag.node.attributes;
|
7061
7058
|
const curStatement = toFirstStatementOrBlock(bodyStatements);
|
7062
7059
|
if (testAttr) {
|
7063
|
-
statement =
|
7060
|
+
statement = import_compiler39.types.ifStatement(
|
7064
7061
|
testAttr.value,
|
7065
7062
|
curStatement,
|
7066
7063
|
statement
|
@@ -7075,21 +7072,22 @@ var IfTag = {
|
|
7075
7072
|
} else {
|
7076
7073
|
if (isStateful) {
|
7077
7074
|
getSerializedScopeProperties(section).set(
|
7078
|
-
|
7075
|
+
import_compiler39.types.stringLiteral(
|
7079
7076
|
getScopeAccessorLiteral(nodeRef2).value + "(" /* ConditionalRenderer */
|
7080
7077
|
),
|
7081
|
-
|
7078
|
+
ifBranchIdentifier
|
7082
7079
|
);
|
7083
|
-
const cbNode =
|
7080
|
+
const cbNode = import_compiler39.types.arrowFunctionExpression(
|
7084
7081
|
[],
|
7085
|
-
|
7082
|
+
import_compiler39.types.blockStatement([statement])
|
7086
7083
|
);
|
7087
|
-
statement =
|
7084
|
+
statement = import_compiler39.types.expressionStatement(
|
7088
7085
|
singleNodeOptimization ? callRuntime(
|
7089
7086
|
"resumeSingleNodeConditional",
|
7090
7087
|
cbNode,
|
7091
7088
|
getScopeIdIdentifier(section),
|
7092
|
-
getScopeAccessorLiteral(nodeRef2)
|
7089
|
+
getScopeAccessorLiteral(nodeRef2),
|
7090
|
+
onlyChildInParentOptimization && import_compiler39.types.numericLiteral(1)
|
7093
7091
|
) : callRuntime(
|
7094
7092
|
"resumeConditional",
|
7095
7093
|
cbNode,
|
@@ -7100,16 +7098,16 @@ var IfTag = {
|
|
7100
7098
|
}
|
7101
7099
|
nextTag.insertBefore(statement);
|
7102
7100
|
getHTMLSectionStatements(section).push(
|
7103
|
-
|
7101
|
+
import_compiler39.types.variableDeclaration(
|
7104
7102
|
"let",
|
7105
7103
|
[
|
7106
|
-
|
7107
|
-
isStateful &&
|
7104
|
+
import_compiler39.types.variableDeclarator(ifScopeIdIdentifier),
|
7105
|
+
isStateful && import_compiler39.types.variableDeclarator(ifBranchIdentifier)
|
7108
7106
|
].filter(Boolean)
|
7109
7107
|
)
|
7110
7108
|
);
|
7111
7109
|
getSerializedScopeProperties(section).set(
|
7112
|
-
|
7110
|
+
import_compiler39.types.stringLiteral(
|
7113
7111
|
getScopeAccessorLiteral(nodeRef2).value + "!" /* ConditionalScope */
|
7114
7112
|
),
|
7115
7113
|
callRuntime("getScopeById", ifScopeIdIdentifier)
|
@@ -7126,10 +7124,10 @@ var IfTag = {
|
|
7126
7124
|
if (bodySection) {
|
7127
7125
|
setSectionParentIsOwner(bodySection, true);
|
7128
7126
|
}
|
7129
|
-
if (isRoot(tag)) {
|
7127
|
+
if (isRoot(tag) && !isOnlyChildInParent(tag)) {
|
7130
7128
|
visit(tag, 37 /* Replace */);
|
7129
|
+
enterShallow(tag);
|
7131
7130
|
}
|
7132
|
-
enterShallow(tag);
|
7133
7131
|
},
|
7134
7132
|
exit(tag) {
|
7135
7133
|
if (tag.node.body.attributeTags) return;
|
@@ -7138,38 +7136,40 @@ var IfTag = {
|
|
7138
7136
|
getSectionForBody(tag.get("body"))
|
7139
7137
|
);
|
7140
7138
|
if (isLast) {
|
7141
|
-
const
|
7139
|
+
const [rootTag] = branches[0];
|
7140
|
+
const section = getSection(rootTag);
|
7142
7141
|
const rootExtra = branches[0][0].node.extra;
|
7143
|
-
const nodeRef2 =
|
7144
|
-
|
7142
|
+
const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
|
7143
|
+
const rendererIdentifiers = [];
|
7144
|
+
let expr = import_compiler39.types.numericLiteral(branches.length);
|
7145
7145
|
for (let i = branches.length; i--; ) {
|
7146
7146
|
const [branchTag, branchBodySection] = branches[i];
|
7147
7147
|
const [testAttr] = branchTag.node.attributes;
|
7148
|
-
const consequent =
|
7149
|
-
|
7150
|
-
|
7151
|
-
(
|
7152
|
-
|
7153
|
-
|
7154
|
-
|
7155
|
-
|
7156
|
-
|
7157
|
-
|
7158
|
-
|
7159
|
-
|
7160
|
-
|
7161
|
-
|
7162
|
-
|
7163
|
-
|
7148
|
+
const consequent = import_compiler39.types.numericLiteral(branchBodySection ? i : -1);
|
7149
|
+
if (branchBodySection) {
|
7150
|
+
rendererIdentifiers.push(import_compiler39.types.identifier(branchBodySection.name));
|
7151
|
+
setClosureSignalBuilder(
|
7152
|
+
branchTag,
|
7153
|
+
(_closureSignal, render, intersection) => {
|
7154
|
+
return callRuntime(
|
7155
|
+
"conditionalClosure",
|
7156
|
+
getScopeAccessorLiteral(nodeRef2),
|
7157
|
+
import_compiler39.types.numericLiteral(i),
|
7158
|
+
render,
|
7159
|
+
intersection
|
7160
|
+
);
|
7161
|
+
}
|
7162
|
+
);
|
7163
|
+
}
|
7164
7164
|
branchTag.remove();
|
7165
|
-
expr = testAttr ?
|
7165
|
+
expr = testAttr ? import_compiler39.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
|
7166
7166
|
}
|
7167
7167
|
const signal = getSignal(section, nodeRef2, "if");
|
7168
7168
|
signal.build = () => {
|
7169
7169
|
return callRuntime(
|
7170
7170
|
"conditional",
|
7171
7171
|
getScopeAccessorLiteral(nodeRef2),
|
7172
|
-
|
7172
|
+
...rendererIdentifiers.reverse()
|
7173
7173
|
);
|
7174
7174
|
};
|
7175
7175
|
signal.hasDownstreamIntersections = () => branches.some(([, bodySection]) => bodySection?.closures);
|
@@ -7207,9 +7207,9 @@ var ElseTag = {
|
|
7207
7207
|
]
|
7208
7208
|
};
|
7209
7209
|
function assertValidCondition(tag) {
|
7210
|
-
(0,
|
7211
|
-
(0,
|
7212
|
-
(0,
|
7210
|
+
(0, import_babel_utils28.assertNoVar)(tag);
|
7211
|
+
(0, import_babel_utils28.assertNoArgs)(tag);
|
7212
|
+
(0, import_babel_utils28.assertNoParams)(tag);
|
7213
7213
|
assertHasBody(tag);
|
7214
7214
|
assertNoSpreadAttrs(tag);
|
7215
7215
|
switch (getTagName(tag)) {
|
@@ -7245,7 +7245,7 @@ function assertHasBody(tag) {
|
|
7245
7245
|
function assertHasValueAttribute(tag) {
|
7246
7246
|
const { node } = tag;
|
7247
7247
|
const [valueAttr] = node.attributes;
|
7248
|
-
if (!
|
7248
|
+
if (!import_compiler39.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
|
7249
7249
|
throw tag.get("name").buildCodeFrameError(`The \`${getTagName(tag)}\` tag requires a value.`);
|
7250
7250
|
}
|
7251
7251
|
if (node.attributes.length > 1) {
|
@@ -7297,12 +7297,12 @@ function isRoot(tag) {
|
|
7297
7297
|
}
|
7298
7298
|
|
7299
7299
|
// src/translator/core/import.ts
|
7300
|
-
var
|
7300
|
+
var import_babel_utils29 = require("@marko/compiler/babel-utils");
|
7301
7301
|
var import_default = {
|
7302
7302
|
parse(tag) {
|
7303
7303
|
const { node } = tag;
|
7304
7304
|
tag.replaceWith(
|
7305
|
-
(0,
|
7305
|
+
(0, import_babel_utils29.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
7306
7306
|
);
|
7307
7307
|
},
|
7308
7308
|
parseOptions: {
|
@@ -7320,8 +7320,8 @@ var import_default = {
|
|
7320
7320
|
};
|
7321
7321
|
|
7322
7322
|
// src/translator/core/let.ts
|
7323
|
-
var
|
7324
|
-
var
|
7323
|
+
var import_compiler40 = require("@marko/compiler");
|
7324
|
+
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
7325
7325
|
var let_default = {
|
7326
7326
|
analyze(tag) {
|
7327
7327
|
const { node } = tag;
|
@@ -7329,7 +7329,7 @@ var let_default = {
|
|
7329
7329
|
let valueAttr;
|
7330
7330
|
let valueChangeAttr;
|
7331
7331
|
for (const attr2 of node.attributes) {
|
7332
|
-
if (
|
7332
|
+
if (import_compiler40.types.isMarkoAttribute(attr2)) {
|
7333
7333
|
if (attr2.name === "value") {
|
7334
7334
|
valueAttr = attr2;
|
7335
7335
|
} else if (attr2.name === "valueChange") {
|
@@ -7350,17 +7350,17 @@ var let_default = {
|
|
7350
7350
|
}
|
7351
7351
|
}
|
7352
7352
|
}
|
7353
|
-
(0,
|
7354
|
-
(0,
|
7353
|
+
(0, import_babel_utils30.assertNoArgs)(tag);
|
7354
|
+
(0, import_babel_utils30.assertNoParams)(tag);
|
7355
7355
|
assertNoBodyContent(tag);
|
7356
7356
|
assertNoSpreadAttrs(tag);
|
7357
7357
|
if (!tagVar) {
|
7358
7358
|
throw tag.get("name").buildCodeFrameError("The `let` tag requires a tag variable.");
|
7359
7359
|
}
|
7360
|
-
if (!
|
7360
|
+
if (!import_compiler40.types.isIdentifier(tagVar)) {
|
7361
7361
|
throw tag.get("var").buildCodeFrameError("The `let` tag variable cannot be destructured.");
|
7362
7362
|
}
|
7363
|
-
if (valueChangeAttr && (0,
|
7363
|
+
if (valueChangeAttr && (0, import_babel_utils30.computeNode)(valueChangeAttr.value)) {
|
7364
7364
|
throw tag.get("attributes").find((attr2) => attr2.node === valueChangeAttr).get("value").buildCodeFrameError(
|
7365
7365
|
"The `let` tag `valueChange` attribute must be a function."
|
7366
7366
|
);
|
@@ -7376,10 +7376,10 @@ var let_default = {
|
|
7376
7376
|
const { node } = tag;
|
7377
7377
|
const tagVar = node.var;
|
7378
7378
|
const valueAttr = node.attributes.find(
|
7379
|
-
(attr2) =>
|
7380
|
-
) ??
|
7379
|
+
(attr2) => import_compiler40.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
|
7380
|
+
) ?? import_compiler40.types.markoAttribute("value", import_compiler40.types.identifier("undefined"));
|
7381
7381
|
const valueChangeAttr = node.attributes.find(
|
7382
|
-
(attr2) =>
|
7382
|
+
(attr2) => import_compiler40.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
|
7383
7383
|
);
|
7384
7384
|
const section = getSection(tag);
|
7385
7385
|
const binding = tagVar.extra.binding;
|
@@ -7392,13 +7392,13 @@ var let_default = {
|
|
7392
7392
|
}
|
7393
7393
|
signal.buildAssignment = (valueSection, value) => {
|
7394
7394
|
const scope = getScopeExpression(valueSection, signal.section);
|
7395
|
-
return
|
7395
|
+
return import_compiler40.types.callExpression(signal.identifier, [scope, value]);
|
7396
7396
|
};
|
7397
7397
|
} else {
|
7398
7398
|
translateVar(tag, valueAttr.value);
|
7399
7399
|
if (valueChangeAttr) {
|
7400
7400
|
getSerializedScopeProperties(section).set(
|
7401
|
-
|
7401
|
+
import_compiler40.types.stringLiteral(
|
7402
7402
|
getScopeAccessorLiteral(binding).value + "@" /* TagVariableChange */
|
7403
7403
|
),
|
7404
7404
|
valueChangeAttr.value
|
@@ -7422,14 +7422,14 @@ var let_default = {
|
|
7422
7422
|
};
|
7423
7423
|
|
7424
7424
|
// src/translator/core/lifecycle.ts
|
7425
|
-
var
|
7426
|
-
var
|
7425
|
+
var import_compiler41 = require("@marko/compiler");
|
7426
|
+
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
7427
7427
|
var kRef = Symbol("lifecycle attrs reference");
|
7428
7428
|
var lifecycle_default = {
|
7429
7429
|
analyze(tag) {
|
7430
|
-
(0,
|
7431
|
-
(0,
|
7432
|
-
(0,
|
7430
|
+
(0, import_babel_utils31.assertNoArgs)(tag);
|
7431
|
+
(0, import_babel_utils31.assertNoVar)(tag);
|
7432
|
+
(0, import_babel_utils31.assertNoParams)(tag);
|
7433
7433
|
assertNoBodyContent(tag);
|
7434
7434
|
const { node } = tag;
|
7435
7435
|
const tagExtra = node.extra ??= {};
|
@@ -7447,7 +7447,7 @@ var lifecycle_default = {
|
|
7447
7447
|
);
|
7448
7448
|
}
|
7449
7449
|
for (const attr2 of node.attributes) {
|
7450
|
-
if (
|
7450
|
+
if (import_compiler41.types.isMarkoSpreadAttribute(attr2)) {
|
7451
7451
|
throw tag.get("name").buildCodeFrameError(
|
7452
7452
|
"The `lifecycle` tag does not support `...spread` attributes."
|
7453
7453
|
);
|
@@ -7467,7 +7467,7 @@ var lifecycle_default = {
|
|
7467
7467
|
if (isOutputDOM()) {
|
7468
7468
|
const translatedAttrs = translateAttrs(tag);
|
7469
7469
|
translatedAttrs.statements.push(
|
7470
|
-
|
7470
|
+
import_compiler41.types.expressionStatement(
|
7471
7471
|
callRuntime(
|
7472
7472
|
"lifecycle",
|
7473
7473
|
scopeIdentifier,
|
@@ -7502,19 +7502,19 @@ var lifecycle_default = {
|
|
7502
7502
|
};
|
7503
7503
|
|
7504
7504
|
// src/translator/core/log.ts
|
7505
|
-
var
|
7506
|
-
var
|
7505
|
+
var import_compiler42 = require("@marko/compiler");
|
7506
|
+
var import_babel_utils32 = require("@marko/compiler/babel-utils");
|
7507
7507
|
var log_default = {
|
7508
7508
|
analyze(tag) {
|
7509
7509
|
const [valueAttr] = tag.node.attributes;
|
7510
|
-
(0,
|
7511
|
-
(0,
|
7512
|
-
(0,
|
7510
|
+
(0, import_babel_utils32.assertNoArgs)(tag);
|
7511
|
+
(0, import_babel_utils32.assertNoVar)(tag);
|
7512
|
+
(0, import_babel_utils32.assertNoParams)(tag);
|
7513
7513
|
assertNoBodyContent(tag);
|
7514
7514
|
if (!valueAttr) {
|
7515
7515
|
throw tag.get("name").buildCodeFrameError("The `log` tag requires a value.");
|
7516
7516
|
}
|
7517
|
-
if (tag.node.attributes.length > 1 || !
|
7517
|
+
if (tag.node.attributes.length > 1 || !import_compiler42.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
7518
7518
|
throw tag.get("name").buildCodeFrameError(
|
7519
7519
|
"The `log` tag only supports the `value` attribute."
|
7520
7520
|
);
|
@@ -7526,9 +7526,9 @@ var log_default = {
|
|
7526
7526
|
const [valueAttr] = tag.node.attributes;
|
7527
7527
|
const { value } = valueAttr;
|
7528
7528
|
const referencedBindings = value.extra?.referencedBindings;
|
7529
|
-
const statement =
|
7530
|
-
|
7531
|
-
|
7529
|
+
const statement = import_compiler42.types.expressionStatement(
|
7530
|
+
import_compiler42.types.callExpression(
|
7531
|
+
import_compiler42.types.memberExpression(import_compiler42.types.identifier("console"), import_compiler42.types.identifier("log")),
|
7532
7532
|
[value]
|
7533
7533
|
)
|
7534
7534
|
);
|
@@ -7554,8 +7554,8 @@ var log_default = {
|
|
7554
7554
|
};
|
7555
7555
|
|
7556
7556
|
// src/translator/core/script.ts
|
7557
|
-
var
|
7558
|
-
var
|
7557
|
+
var import_compiler43 = require("@marko/compiler");
|
7558
|
+
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
7559
7559
|
var htmlScriptTagAlternateMsg = " For a native html `script` tag use the `html-script` core tag instead.";
|
7560
7560
|
var script_default = {
|
7561
7561
|
parse(tag) {
|
@@ -7575,22 +7575,22 @@ var script_default = {
|
|
7575
7575
|
}
|
7576
7576
|
const start = body[0]?.start;
|
7577
7577
|
const end = body[body.length - 1]?.end;
|
7578
|
-
const bodyStatements = (0,
|
7579
|
-
const valueFn =
|
7578
|
+
const bodyStatements = (0, import_babel_utils33.parseStatements)(tag.hub.file, code, start, end);
|
7579
|
+
const valueFn = import_compiler43.types.arrowFunctionExpression(
|
7580
7580
|
[],
|
7581
|
-
|
7581
|
+
import_compiler43.types.blockStatement(bodyStatements),
|
7582
7582
|
traverseContains(bodyStatements, isAwaitExpression)
|
7583
7583
|
);
|
7584
|
-
node.attributes.push(
|
7584
|
+
node.attributes.push(import_compiler43.types.markoAttribute("value", valueFn));
|
7585
7585
|
node.body.body = [];
|
7586
7586
|
}
|
7587
7587
|
},
|
7588
7588
|
analyze(tag) {
|
7589
7589
|
const { node } = tag;
|
7590
|
-
(0,
|
7591
|
-
(0,
|
7590
|
+
(0, import_babel_utils33.assertNoArgs)(tag);
|
7591
|
+
(0, import_babel_utils33.assertNoParams)(tag);
|
7592
7592
|
assertNoBodyContent(tag);
|
7593
|
-
(0,
|
7593
|
+
(0, import_babel_utils33.assertNoAttributeTags)(tag);
|
7594
7594
|
if (node.var) {
|
7595
7595
|
throw tag.hub.buildError(
|
7596
7596
|
node.var,
|
@@ -7630,28 +7630,28 @@ var script_default = {
|
|
7630
7630
|
const referencedBindings = value.extra?.referencedBindings;
|
7631
7631
|
if (isOutputDOM()) {
|
7632
7632
|
const { value: value2 } = valueAttr;
|
7633
|
-
const isFunction2 =
|
7633
|
+
const isFunction2 = import_compiler43.types.isFunctionExpression(value2) || import_compiler43.types.isArrowFunctionExpression(value2);
|
7634
7634
|
let inlineBody = null;
|
7635
7635
|
if (isFunction2 && !(value2.async || value2.generator)) {
|
7636
|
-
if (
|
7636
|
+
if (import_compiler43.types.isBlockStatement(value2.body)) {
|
7637
7637
|
let hasDeclaration = false;
|
7638
7638
|
for (const child of value2.body.body) {
|
7639
|
-
if (
|
7639
|
+
if (import_compiler43.types.isDeclaration(child)) {
|
7640
7640
|
hasDeclaration = true;
|
7641
7641
|
break;
|
7642
7642
|
}
|
7643
7643
|
}
|
7644
7644
|
inlineBody = hasDeclaration ? value2.body : value2.body.body;
|
7645
7645
|
} else {
|
7646
|
-
inlineBody =
|
7646
|
+
inlineBody = import_compiler43.types.expressionStatement(value2.body);
|
7647
7647
|
}
|
7648
7648
|
}
|
7649
7649
|
addStatement(
|
7650
7650
|
"effect",
|
7651
7651
|
section,
|
7652
7652
|
referencedBindings,
|
7653
|
-
inlineBody ||
|
7654
|
-
|
7653
|
+
inlineBody || import_compiler43.types.expressionStatement(
|
7654
|
+
import_compiler43.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
|
7655
7655
|
)
|
7656
7656
|
);
|
7657
7657
|
} else {
|
@@ -7691,8 +7691,8 @@ function isAwaitExpression(node) {
|
|
7691
7691
|
}
|
7692
7692
|
|
7693
7693
|
// src/translator/core/server.ts
|
7694
|
-
var
|
7695
|
-
var
|
7694
|
+
var import_compiler44 = require("@marko/compiler");
|
7695
|
+
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
7696
7696
|
var server_default = {
|
7697
7697
|
parse(tag) {
|
7698
7698
|
const {
|
@@ -7702,11 +7702,11 @@ var server_default = {
|
|
7702
7702
|
const rawValue = node.rawValue;
|
7703
7703
|
const code = rawValue.replace(/^server\s*/, "").trim();
|
7704
7704
|
const start = node.name.start + (rawValue.length - code.length);
|
7705
|
-
let body = (0,
|
7706
|
-
if (body.length === 1 &&
|
7705
|
+
let body = (0, import_babel_utils34.parseStatements)(file, code, start, start + code.length);
|
7706
|
+
if (body.length === 1 && import_compiler44.types.isBlockStatement(body[0])) {
|
7707
7707
|
body = body[0].body;
|
7708
7708
|
}
|
7709
|
-
tag.replaceWith(
|
7709
|
+
tag.replaceWith(import_compiler44.types.markoScriptlet(body, true, "server"));
|
7710
7710
|
},
|
7711
7711
|
parseOptions: {
|
7712
7712
|
statement: true,
|
@@ -7722,8 +7722,8 @@ var server_default = {
|
|
7722
7722
|
};
|
7723
7723
|
|
7724
7724
|
// src/translator/core/static.ts
|
7725
|
-
var
|
7726
|
-
var
|
7725
|
+
var import_compiler45 = require("@marko/compiler");
|
7726
|
+
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
7727
7727
|
var static_default = {
|
7728
7728
|
parse(tag) {
|
7729
7729
|
const {
|
@@ -7733,11 +7733,11 @@ var static_default = {
|
|
7733
7733
|
const rawValue = node.rawValue;
|
7734
7734
|
const code = rawValue.replace(/^static\s*/, "").trim();
|
7735
7735
|
const start = node.name.start + (rawValue.length - code.length);
|
7736
|
-
let body = (0,
|
7737
|
-
if (body.length === 1 &&
|
7736
|
+
let body = (0, import_babel_utils35.parseStatements)(file, code, start, start + code.length);
|
7737
|
+
if (body.length === 1 && import_compiler45.types.isBlockStatement(body[0])) {
|
7738
7738
|
body = body[0].body;
|
7739
7739
|
}
|
7740
|
-
tag.replaceWith(
|
7740
|
+
tag.replaceWith(import_compiler45.types.markoScriptlet(body, true));
|
7741
7741
|
},
|
7742
7742
|
parseOptions: {
|
7743
7743
|
statement: true,
|
@@ -7753,17 +7753,17 @@ var static_default = {
|
|
7753
7753
|
};
|
7754
7754
|
|
7755
7755
|
// src/translator/core/style.ts
|
7756
|
-
var
|
7757
|
-
var
|
7756
|
+
var import_compiler46 = require("@marko/compiler");
|
7757
|
+
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
7758
7758
|
var import_magic_string = __toESM(require("magic-string"));
|
7759
7759
|
var import_path3 = __toESM(require("path"));
|
7760
7760
|
var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
7761
7761
|
var htmlStyleTagAlternateMsg = " For a native html `style` tag use the `html-style` core tag instead.";
|
7762
7762
|
var style_default = {
|
7763
7763
|
analyze(tag) {
|
7764
|
-
(0,
|
7765
|
-
(0,
|
7766
|
-
(0,
|
7764
|
+
(0, import_babel_utils36.assertNoArgs)(tag);
|
7765
|
+
(0, import_babel_utils36.assertNoParams)(tag);
|
7766
|
+
(0, import_babel_utils36.assertNoAttributeTags)(tag);
|
7767
7767
|
const { node } = tag;
|
7768
7768
|
const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
|
7769
7769
|
for (const attr2 of node.attributes) {
|
@@ -7802,8 +7802,8 @@ var style_default = {
|
|
7802
7802
|
}
|
7803
7803
|
const markoText = node.body.body[0];
|
7804
7804
|
const { resolveVirtualDependency } = getMarkoOpts();
|
7805
|
-
const start = (0,
|
7806
|
-
const end = (0,
|
7805
|
+
const start = (0, import_babel_utils36.getStart)(file, markoText);
|
7806
|
+
const end = (0, import_babel_utils36.getEnd)(file, markoText);
|
7807
7807
|
let code = markoText.value;
|
7808
7808
|
let map;
|
7809
7809
|
if (resolveVirtualDependency && sourceMaps && start !== null && end !== null) {
|
@@ -7831,23 +7831,23 @@ var style_default = {
|
|
7831
7831
|
if (!node.var) {
|
7832
7832
|
currentProgramPath.pushContainer(
|
7833
7833
|
"body",
|
7834
|
-
|
7834
|
+
import_compiler46.types.importDeclaration([], import_compiler46.types.stringLiteral(importPath))
|
7835
7835
|
);
|
7836
|
-
} else if (
|
7836
|
+
} else if (import_compiler46.types.isIdentifier(node.var)) {
|
7837
7837
|
currentProgramPath.pushContainer(
|
7838
7838
|
"body",
|
7839
|
-
|
7840
|
-
[
|
7841
|
-
|
7839
|
+
import_compiler46.types.importDeclaration(
|
7840
|
+
[import_compiler46.types.importDefaultSpecifier(node.var)],
|
7841
|
+
import_compiler46.types.stringLiteral(importPath)
|
7842
7842
|
)
|
7843
7843
|
);
|
7844
7844
|
} else {
|
7845
7845
|
currentProgramPath.pushContainer(
|
7846
7846
|
"body",
|
7847
|
-
|
7848
|
-
|
7847
|
+
import_compiler46.types.variableDeclaration("const", [
|
7848
|
+
import_compiler46.types.variableDeclarator(
|
7849
7849
|
node.var,
|
7850
|
-
(0,
|
7850
|
+
(0, import_babel_utils36.importDefault)(file, importPath, "style")
|
7851
7851
|
)
|
7852
7852
|
])
|
7853
7853
|
);
|
@@ -7865,14 +7865,14 @@ var style_default = {
|
|
7865
7865
|
};
|
7866
7866
|
|
7867
7867
|
// src/translator/core/try.ts
|
7868
|
-
var
|
7869
|
-
var
|
7868
|
+
var import_compiler47 = require("@marko/compiler");
|
7869
|
+
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
7870
7870
|
var try_default = {
|
7871
7871
|
analyze(tag) {
|
7872
|
-
(0,
|
7873
|
-
(0,
|
7874
|
-
(0,
|
7875
|
-
(0,
|
7872
|
+
(0, import_babel_utils37.assertNoVar)(tag);
|
7873
|
+
(0, import_babel_utils37.assertNoArgs)(tag);
|
7874
|
+
(0, import_babel_utils37.assertNoParams)(tag);
|
7875
|
+
(0, import_babel_utils37.assertNoAttributes)(tag);
|
7876
7876
|
assertNoSpreadAttrs(tag);
|
7877
7877
|
analyzeAttributeTags(tag);
|
7878
7878
|
const { node } = tag;
|
@@ -7899,7 +7899,7 @@ var try_default = {
|
|
7899
7899
|
writeHTMLResumeStatements(tagBody);
|
7900
7900
|
tag.insertBefore(translatedAttrs.statements);
|
7901
7901
|
tag.replaceWith(
|
7902
|
-
|
7902
|
+
import_compiler47.types.expressionStatement(
|
7903
7903
|
callRuntime(
|
7904
7904
|
"tryContent",
|
7905
7905
|
propsToExpression(translatedAttrs.properties)
|
@@ -8013,8 +8013,8 @@ var document_type_default = {
|
|
8013
8013
|
};
|
8014
8014
|
|
8015
8015
|
// src/translator/visitors/function.ts
|
8016
|
-
var
|
8017
|
-
var
|
8016
|
+
var import_compiler48 = require("@marko/compiler");
|
8017
|
+
var import_babel_utils38 = require("@marko/compiler/babel-utils");
|
8018
8018
|
var functionIdsBySection = /* @__PURE__ */ new WeakMap();
|
8019
8019
|
var function_default = {
|
8020
8020
|
analyze(fn) {
|
@@ -8025,14 +8025,14 @@ var function_default = {
|
|
8025
8025
|
if (markoRoot && (markoRoot.isMarkoPlaceholder() || markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server")) {
|
8026
8026
|
return;
|
8027
8027
|
}
|
8028
|
-
if (isMarkoAttribute(markoRoot) && ((0,
|
8028
|
+
if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils38.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
|
8029
8029
|
return;
|
8030
8030
|
}
|
8031
8031
|
const { node } = fn;
|
8032
8032
|
const extra = node.extra ??= {};
|
8033
|
-
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ?
|
8033
|
+
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler48.types.toIdentifier(
|
8034
8034
|
markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
|
8035
|
-
) : markoRoot.node.name :
|
8035
|
+
) : markoRoot.node.name : import_compiler48.types.isVariableDeclarator(fn.parent) && import_compiler48.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler48.types.isObjectMethod(node) && import_compiler48.types.isIdentifier(node.key) ? node.key.name : "anonymous");
|
8036
8036
|
const {
|
8037
8037
|
markoOpts,
|
8038
8038
|
opts: { filename }
|
@@ -8052,7 +8052,7 @@ var function_default = {
|
|
8052
8052
|
id = `_${index}`;
|
8053
8053
|
}
|
8054
8054
|
extra.section = section;
|
8055
|
-
extra.registerId = (0,
|
8055
|
+
extra.registerId = (0, import_babel_utils38.getTemplateId)(
|
8056
8056
|
markoOpts,
|
8057
8057
|
filename,
|
8058
8058
|
`${section.id}/${name2 + id}`
|
@@ -8064,13 +8064,13 @@ function isMarkoAttribute(path5) {
|
|
8064
8064
|
}
|
8065
8065
|
|
8066
8066
|
// src/translator/visitors/import-declaration.ts
|
8067
|
-
var
|
8067
|
+
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
8068
8068
|
var import_declaration_default = {
|
8069
8069
|
analyze(importDecl) {
|
8070
8070
|
const { node } = importDecl;
|
8071
8071
|
const { source } = node;
|
8072
8072
|
const { value } = source;
|
8073
|
-
const tagImport = (0,
|
8073
|
+
const tagImport = (0, import_babel_utils39.resolveTagImport)(importDecl, value);
|
8074
8074
|
if (tagImport) {
|
8075
8075
|
node.extra ??= {};
|
8076
8076
|
node.extra.tagImport = tagImport;
|
@@ -8093,15 +8093,15 @@ var import_declaration_default = {
|
|
8093
8093
|
};
|
8094
8094
|
|
8095
8095
|
// src/translator/visitors/placeholder.ts
|
8096
|
-
var
|
8097
|
-
var
|
8096
|
+
var import_compiler49 = require("@marko/compiler");
|
8097
|
+
var kBinding = Symbol("placeholder node binding");
|
8098
8098
|
var kSiblingText = Symbol("placeholder has sibling text");
|
8099
8099
|
var placeholder_default = {
|
8100
8100
|
analyze(placeholder) {
|
8101
8101
|
const { node } = placeholder;
|
8102
8102
|
const { confident, computed } = evaluate(node.value);
|
8103
8103
|
if (!(confident && (node.escape || isVoid2(computed)))) {
|
8104
|
-
(node.extra ??= {})[
|
8104
|
+
(node.extra ??= {})[kBinding] = createBinding(
|
8105
8105
|
"#text",
|
8106
8106
|
0 /* dom */,
|
8107
8107
|
getOrCreateSection(placeholder),
|
@@ -8123,7 +8123,7 @@ var placeholder_default = {
|
|
8123
8123
|
const isHTML = isOutputHTML();
|
8124
8124
|
const write2 = writeTo(placeholder);
|
8125
8125
|
const extra = node.extra || {};
|
8126
|
-
const nodeBinding = extra[
|
8126
|
+
const nodeBinding = extra[kBinding];
|
8127
8127
|
const canWriteHTML = isHTML || confident && node.escape;
|
8128
8128
|
const method = canWriteHTML ? node.escape ? "escapeXML" : "toString" : node.escape ? "data" : "html";
|
8129
8129
|
const isStateful = isStatefulReferences(referencedBindings);
|
@@ -8152,10 +8152,10 @@ var placeholder_default = {
|
|
8152
8152
|
"render",
|
8153
8153
|
getSection(placeholder),
|
8154
8154
|
value.extra?.referencedBindings,
|
8155
|
-
|
8155
|
+
import_compiler49.types.expressionStatement(
|
8156
8156
|
method === "data" ? callRuntime(
|
8157
8157
|
"data",
|
8158
|
-
|
8158
|
+
import_compiler49.types.memberExpression(
|
8159
8159
|
scopeIdentifier,
|
8160
8160
|
getScopeAccessorLiteral(nodeBinding),
|
8161
8161
|
true
|
@@ -8192,7 +8192,7 @@ function analyzeSiblingText(placeholder) {
|
|
8192
8192
|
break;
|
8193
8193
|
}
|
8194
8194
|
}
|
8195
|
-
if (!prev.node &&
|
8195
|
+
if (!prev.node && import_compiler49.types.isProgram(placeholder.parentPath)) {
|
8196
8196
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
8197
8197
|
}
|
8198
8198
|
let next = placeholder.getNextSibling();
|
@@ -8209,7 +8209,7 @@ function analyzeSiblingText(placeholder) {
|
|
8209
8209
|
break;
|
8210
8210
|
}
|
8211
8211
|
}
|
8212
|
-
if (!next.node &&
|
8212
|
+
if (!next.node && import_compiler49.types.isProgram(placeholder.parentPath)) {
|
8213
8213
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
8214
8214
|
}
|
8215
8215
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
@@ -8219,7 +8219,7 @@ function isVoid2(value) {
|
|
8219
8219
|
}
|
8220
8220
|
|
8221
8221
|
// src/translator/visitors/referenced-identifier.ts
|
8222
|
-
var
|
8222
|
+
var import_compiler50 = require("@marko/compiler");
|
8223
8223
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
8224
8224
|
var referenced_identifier_default = {
|
8225
8225
|
migrate(identifier) {
|
@@ -8227,8 +8227,8 @@ var referenced_identifier_default = {
|
|
8227
8227
|
if (identifier.scope.hasBinding(name2)) return;
|
8228
8228
|
switch (name2) {
|
8229
8229
|
case "out":
|
8230
|
-
if (
|
8231
|
-
identifier.parentPath.replaceWith(
|
8230
|
+
if (import_compiler50.types.isMemberExpression(identifier.parent) && import_compiler50.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
8231
|
+
identifier.parentPath.replaceWith(import_compiler50.types.identifier("$global"));
|
8232
8232
|
} else {
|
8233
8233
|
throw identifier.buildCodeFrameError(
|
8234
8234
|
"Only `out.global` is supported for compatibility."
|
@@ -8255,24 +8255,24 @@ var referenced_identifier_default = {
|
|
8255
8255
|
case "$global":
|
8256
8256
|
if (isOutputHTML()) {
|
8257
8257
|
identifier.replaceWith(
|
8258
|
-
|
8258
|
+
import_compiler50.types.callExpression(importRuntime("$global"), [])
|
8259
8259
|
);
|
8260
8260
|
} else {
|
8261
8261
|
identifier.replaceWith(
|
8262
|
-
|
8262
|
+
import_compiler50.types.memberExpression(scopeIdentifier, import_compiler50.types.identifier("$global"))
|
8263
8263
|
);
|
8264
8264
|
}
|
8265
8265
|
break;
|
8266
8266
|
case "$signal":
|
8267
8267
|
if (isOutputHTML()) {
|
8268
8268
|
identifier.replaceWith(
|
8269
|
-
|
8270
|
-
|
8269
|
+
import_compiler50.types.callExpression(
|
8270
|
+
import_compiler50.types.arrowFunctionExpression(
|
8271
8271
|
[],
|
8272
|
-
|
8273
|
-
|
8274
|
-
|
8275
|
-
|
8272
|
+
import_compiler50.types.blockStatement([
|
8273
|
+
import_compiler50.types.throwStatement(
|
8274
|
+
import_compiler50.types.newExpression(import_compiler50.types.identifier("Error"), [
|
8275
|
+
import_compiler50.types.stringLiteral("Cannot use $signal in a server render.")
|
8276
8276
|
])
|
8277
8277
|
)
|
8278
8278
|
])
|
@@ -8298,18 +8298,18 @@ var referenced_identifier_default = {
|
|
8298
8298
|
"render",
|
8299
8299
|
section,
|
8300
8300
|
exprRoot.node.extra?.referencedBindings,
|
8301
|
-
|
8302
|
-
|
8301
|
+
import_compiler50.types.expressionStatement(
|
8302
|
+
import_compiler50.types.callExpression(importRuntime("resetAbortSignal"), [
|
8303
8303
|
scopeIdentifier,
|
8304
|
-
|
8304
|
+
import_compiler50.types.numericLiteral(exprId)
|
8305
8305
|
])
|
8306
8306
|
)
|
8307
8307
|
);
|
8308
8308
|
}
|
8309
8309
|
identifier.replaceWith(
|
8310
|
-
|
8310
|
+
import_compiler50.types.callExpression(importRuntime("getAbortSignal"), [
|
8311
8311
|
scopeIdentifier,
|
8312
|
-
|
8312
|
+
import_compiler50.types.numericLiteral(exprId)
|
8313
8313
|
])
|
8314
8314
|
);
|
8315
8315
|
}
|
@@ -8349,21 +8349,21 @@ var scriptlet_default = {
|
|
8349
8349
|
};
|
8350
8350
|
|
8351
8351
|
// src/translator/visitors/tag/index.ts
|
8352
|
-
var
|
8353
|
-
var
|
8352
|
+
var import_compiler54 = require("@marko/compiler");
|
8353
|
+
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
8354
8354
|
|
8355
8355
|
// src/translator/visitors/tag/attribute-tag.ts
|
8356
|
-
var
|
8357
|
-
var
|
8356
|
+
var import_compiler51 = require("@marko/compiler");
|
8357
|
+
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
8358
8358
|
var attribute_tag_default = {
|
8359
8359
|
analyze: {
|
8360
8360
|
enter(tag) {
|
8361
|
-
(0,
|
8362
|
-
(0,
|
8361
|
+
(0, import_babel_utils40.assertNoVar)(tag);
|
8362
|
+
(0, import_babel_utils40.assertNoArgs)(tag);
|
8363
8363
|
const body = tag.get("body");
|
8364
8364
|
startSection(body);
|
8365
8365
|
trackParamsReferences(body, 3 /* param */);
|
8366
|
-
if (!(0,
|
8366
|
+
if (!(0, import_babel_utils40.findParentTag)(tag)) {
|
8367
8367
|
throw tag.get("name").buildCodeFrameError("@tags must be nested within another tag.");
|
8368
8368
|
}
|
8369
8369
|
}
|
@@ -8384,17 +8384,17 @@ var attribute_tag_default = {
|
|
8384
8384
|
};
|
8385
8385
|
|
8386
8386
|
// src/translator/visitors/tag/custom-tag.ts
|
8387
|
-
var
|
8388
|
-
var
|
8387
|
+
var import_compiler52 = require("@marko/compiler");
|
8388
|
+
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
8389
8389
|
var import_path4 = __toESM(require("path"));
|
8390
8390
|
var kChildScopeBinding = Symbol("custom tag child scope");
|
8391
8391
|
var kChildAttrExprs = Symbol("custom tag child attribute expressions");
|
8392
8392
|
var custom_tag_default = {
|
8393
8393
|
analyze: {
|
8394
8394
|
enter(tag) {
|
8395
|
-
(0,
|
8395
|
+
(0, import_babel_utils41.assertAttributesOrSingleArg)(tag);
|
8396
8396
|
analyzeAttributeTags(tag);
|
8397
|
-
const templateFile = (0,
|
8397
|
+
const templateFile = (0, import_babel_utils41.getTagTemplate)(tag);
|
8398
8398
|
if (!templateFile) {
|
8399
8399
|
const tagName = getTagName(tag);
|
8400
8400
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
@@ -8418,7 +8418,7 @@ var custom_tag_default = {
|
|
8418
8418
|
tagExtra
|
8419
8419
|
);
|
8420
8420
|
tagExtra[kChildAttrExprs] = /* @__PURE__ */ new Set([tagExtra]);
|
8421
|
-
const childFile = (0,
|
8421
|
+
const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
|
8422
8422
|
if (childFile.opts.filename === tag.hub.file.opts.filename) {
|
8423
8423
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
8424
8424
|
} else {
|
@@ -8455,15 +8455,15 @@ function translateHTML(tag) {
|
|
8455
8455
|
let tagIdentifier;
|
8456
8456
|
flushInto(tag);
|
8457
8457
|
writeHTMLResumeStatements(tagBody);
|
8458
|
-
if (
|
8458
|
+
if (import_compiler52.types.isStringLiteral(node.name)) {
|
8459
8459
|
const relativePath = getTagRelativePath(tag);
|
8460
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? htmlRendererIdentifier : (0,
|
8460
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? htmlRendererIdentifier : (0, import_babel_utils41.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
8461
8461
|
} else {
|
8462
8462
|
tagIdentifier = node.name;
|
8463
8463
|
}
|
8464
8464
|
const tagVar = node.var;
|
8465
8465
|
const section = getSection(tag);
|
8466
|
-
const inputExport = (0,
|
8466
|
+
const inputExport = (0, import_babel_utils41.loadFileForTag)(tag)?.ast.program.extra?.domExports?.params?.props?.[0];
|
8467
8467
|
const { properties, statements } = inputExport ? translateAttrs(tag, inputExport.props) : {
|
8468
8468
|
properties: [],
|
8469
8469
|
statements: []
|
@@ -8481,8 +8481,8 @@ function translateHTML(tag) {
|
|
8481
8481
|
childScopeBinding?.name
|
8482
8482
|
);
|
8483
8483
|
tag.insertBefore(
|
8484
|
-
|
8485
|
-
|
8484
|
+
import_compiler52.types.variableDeclaration("const", [
|
8485
|
+
import_compiler52.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
|
8486
8486
|
])
|
8487
8487
|
);
|
8488
8488
|
getSerializedScopeProperties(section).set(
|
@@ -8491,12 +8491,12 @@ function translateHTML(tag) {
|
|
8491
8491
|
);
|
8492
8492
|
if (tagVar) {
|
8493
8493
|
statements.push(
|
8494
|
-
|
8494
|
+
import_compiler52.types.expressionStatement(
|
8495
8495
|
callRuntime(
|
8496
8496
|
"setTagVar",
|
8497
8497
|
getScopeIdIdentifier(section),
|
8498
8498
|
peekScopeId,
|
8499
|
-
|
8499
|
+
import_compiler52.types.stringLiteral(
|
8500
8500
|
getResumeRegisterId(
|
8501
8501
|
section,
|
8502
8502
|
node.var.extra?.binding,
|
@@ -8516,8 +8516,8 @@ function translateHTML(tag) {
|
|
8516
8516
|
const contentExpression = contentProp.value;
|
8517
8517
|
contentProp.value = contentId = tag.scope.generateUidIdentifier("content");
|
8518
8518
|
const [contentPath] = tag.insertBefore(
|
8519
|
-
|
8520
|
-
|
8519
|
+
import_compiler52.types.variableDeclaration("const", [
|
8520
|
+
import_compiler52.types.variableDeclarator(
|
8521
8521
|
contentId,
|
8522
8522
|
// TODO: only register if needed (child template analysis)
|
8523
8523
|
contentExpression
|
@@ -8531,13 +8531,13 @@ function translateHTML(tag) {
|
|
8531
8531
|
propsToExpression(properties)
|
8532
8532
|
);
|
8533
8533
|
if (tagVar) {
|
8534
|
-
translateVar(tag,
|
8535
|
-
renderTagExpr =
|
8534
|
+
translateVar(tag, import_compiler52.types.unaryExpression("void", import_compiler52.types.numericLiteral(0)), "let");
|
8535
|
+
renderTagExpr = import_compiler52.types.assignmentExpression("=", tagVar, renderTagExpr);
|
8536
8536
|
}
|
8537
8537
|
statements.push(
|
8538
|
-
|
8538
|
+
import_compiler52.types.ifStatement(
|
8539
8539
|
tagIdentifier,
|
8540
|
-
|
8540
|
+
import_compiler52.types.expressionStatement(renderTagExpr),
|
8541
8541
|
contentId && callStatement(contentId)
|
8542
8542
|
)
|
8543
8543
|
);
|
@@ -8563,9 +8563,9 @@ function translateDOM(tag) {
|
|
8563
8563
|
const childScopeBinding = extra[kChildScopeBinding];
|
8564
8564
|
const write2 = writeTo(tag);
|
8565
8565
|
const { file } = tag.hub;
|
8566
|
-
const tagName =
|
8566
|
+
const tagName = import_compiler52.types.isIdentifier(node.name) ? node.name.name : import_compiler52.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
8567
8567
|
const relativePath = getTagRelativePath(tag);
|
8568
|
-
const childFile = (0,
|
8568
|
+
const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
|
8569
8569
|
const childExports = childFile.ast.program.extra.domExports;
|
8570
8570
|
const tagIdentifier = importOrSelfReferenceName(
|
8571
8571
|
file,
|
@@ -8583,10 +8583,10 @@ function translateDOM(tag) {
|
|
8583
8583
|
attrTagCallsByTag: void 0
|
8584
8584
|
});
|
8585
8585
|
}
|
8586
|
-
write2`${(0,
|
8586
|
+
write2`${(0, import_babel_utils41.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
8587
8587
|
injectWalks(
|
8588
8588
|
tag,
|
8589
|
-
(0,
|
8589
|
+
(0, import_babel_utils41.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
8590
8590
|
);
|
8591
8591
|
if (node.var) {
|
8592
8592
|
const source = initValue(
|
@@ -8595,7 +8595,7 @@ function translateDOM(tag) {
|
|
8595
8595
|
);
|
8596
8596
|
source.register = true;
|
8597
8597
|
source.buildAssignment = (valueSection, value) => {
|
8598
|
-
return
|
8598
|
+
return import_compiler52.types.callExpression(importRuntime("tagVarSignalChange"), [
|
8599
8599
|
createScopeReadExpression(valueSection, childScopeBinding),
|
8600
8600
|
value
|
8601
8601
|
]);
|
@@ -8604,7 +8604,7 @@ function translateDOM(tag) {
|
|
8604
8604
|
"render",
|
8605
8605
|
tagSection,
|
8606
8606
|
void 0,
|
8607
|
-
|
8607
|
+
import_compiler52.types.expressionStatement(
|
8608
8608
|
callRuntime(
|
8609
8609
|
"setTagVar",
|
8610
8610
|
scopeIdentifier,
|
@@ -8618,8 +8618,8 @@ function translateDOM(tag) {
|
|
8618
8618
|
"render",
|
8619
8619
|
tagSection,
|
8620
8620
|
void 0,
|
8621
|
-
|
8622
|
-
|
8621
|
+
import_compiler52.types.expressionStatement(
|
8622
|
+
import_compiler52.types.callExpression(tagIdentifier, [
|
8623
8623
|
createScopeReadExpression(tagSection, childScopeBinding)
|
8624
8624
|
])
|
8625
8625
|
)
|
@@ -8632,9 +8632,9 @@ function getTagRelativePath(tag) {
|
|
8632
8632
|
hub: { file }
|
8633
8633
|
} = tag;
|
8634
8634
|
let relativePath;
|
8635
|
-
if (
|
8636
|
-
const template = (0,
|
8637
|
-
relativePath = template && (0,
|
8635
|
+
if (import_compiler52.types.isStringLiteral(node.name)) {
|
8636
|
+
const template = (0, import_babel_utils41.getTagTemplate)(tag);
|
8637
|
+
relativePath = template && (0, import_babel_utils41.resolveRelativePath)(file, template);
|
8638
8638
|
} else if (node.extra?.tagNameImported) {
|
8639
8639
|
relativePath = node.extra.tagNameImported;
|
8640
8640
|
}
|
@@ -8680,7 +8680,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
8680
8680
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
8681
8681
|
for (const child of attrTags2) {
|
8682
8682
|
if (child.isMarkoTag()) {
|
8683
|
-
if ((0,
|
8683
|
+
if ((0, import_babel_utils41.isAttributeTag)(child)) {
|
8684
8684
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
8685
8685
|
const childAttrExports = templateExport.props[attrTagMeta.name];
|
8686
8686
|
if (childAttrExports) {
|
@@ -8721,7 +8721,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
8721
8721
|
let spreadReferenceNodes;
|
8722
8722
|
for (let i = attributes.length; i--; ) {
|
8723
8723
|
const attr2 = attributes[i];
|
8724
|
-
if (
|
8724
|
+
if (import_compiler52.types.isMarkoAttribute(attr2)) {
|
8725
8725
|
if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
|
8726
8726
|
dropReferences(attr2.value);
|
8727
8727
|
continue;
|
@@ -8730,7 +8730,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
8730
8730
|
}
|
8731
8731
|
if (spreadReferenceNodes) {
|
8732
8732
|
spreadReferenceNodes.push(attr2.value);
|
8733
|
-
} else if (
|
8733
|
+
} else if (import_compiler52.types.isMarkoSpreadAttribute(attr2)) {
|
8734
8734
|
spreadReferenceNodes = [attr2.value];
|
8735
8735
|
} else {
|
8736
8736
|
rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
|
@@ -8755,12 +8755,12 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8755
8755
|
// but we should probably ensure all other references are dropped in this case before we do that.
|
8756
8756
|
tag.node.extra?.referencedBindings,
|
8757
8757
|
identifierToSignal(tagInputIdentifier),
|
8758
|
-
|
8758
|
+
import_compiler52.types.isSpreadElement(arg) ? import_compiler52.types.memberExpression(arg.argument, import_compiler52.types.numericLiteral(0), true) : arg,
|
8759
8759
|
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
8760
8760
|
callRuntime(
|
8761
8761
|
"inChild",
|
8762
8762
|
getScopeAccessorLiteral(info.childScopeBinding),
|
8763
|
-
|
8763
|
+
import_compiler52.types.identifier(tagInputIdentifier.name)
|
8764
8764
|
)
|
8765
8765
|
);
|
8766
8766
|
return;
|
@@ -8783,7 +8783,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8783
8783
|
);
|
8784
8784
|
}
|
8785
8785
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
8786
|
-
if ((0,
|
8786
|
+
if ((0, import_babel_utils41.isAttributeTag)(tag)) {
|
8787
8787
|
const attrTagName = getTagName(tag);
|
8788
8788
|
const parentTag = tag.parentPath;
|
8789
8789
|
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
@@ -8808,7 +8808,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8808
8808
|
} else {
|
8809
8809
|
attrTagCallsForTag.set(
|
8810
8810
|
attrTagName,
|
8811
|
-
translatedProps =
|
8811
|
+
translatedProps = import_compiler52.types.parenthesizedExpression(
|
8812
8812
|
callRuntime("attrTag", translatedProps)
|
8813
8813
|
)
|
8814
8814
|
);
|
@@ -8826,7 +8826,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8826
8826
|
callRuntime(
|
8827
8827
|
"inChild",
|
8828
8828
|
getScopeAccessorLiteral(info.childScopeBinding),
|
8829
|
-
|
8829
|
+
import_compiler52.types.identifier(tagInputIdentifier.name)
|
8830
8830
|
)
|
8831
8831
|
);
|
8832
8832
|
return;
|
@@ -8860,7 +8860,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8860
8860
|
for (let i = 0; i < attrTags2.length; i++) {
|
8861
8861
|
const child = attrTags2[i];
|
8862
8862
|
if (child.isMarkoTag()) {
|
8863
|
-
if ((0,
|
8863
|
+
if ((0, import_babel_utils41.isAttributeTag)(child)) {
|
8864
8864
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
8865
8865
|
const childAttrExport = templateExport.props[attrTagMeta.name];
|
8866
8866
|
if (childAttrExport) {
|
@@ -8898,7 +8898,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8898
8898
|
childAttrExports.id,
|
8899
8899
|
`${importAlias}_${attrTagMeta.name}`
|
8900
8900
|
);
|
8901
|
-
decls.push(
|
8901
|
+
decls.push(import_compiler52.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
8902
8902
|
addValue(
|
8903
8903
|
info.tagSection,
|
8904
8904
|
referencedBindings,
|
@@ -8908,12 +8908,12 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8908
8908
|
callRuntime(
|
8909
8909
|
"inChild",
|
8910
8910
|
getScopeAccessorLiteral(info.childScopeBinding),
|
8911
|
-
|
8911
|
+
import_compiler52.types.identifier(attrExportIdentifier.name)
|
8912
8912
|
)
|
8913
8913
|
);
|
8914
8914
|
}
|
8915
8915
|
addStatement("render", info.tagSection, referencedBindings, [
|
8916
|
-
|
8916
|
+
import_compiler52.types.variableDeclaration("let", decls),
|
8917
8917
|
...statements
|
8918
8918
|
]);
|
8919
8919
|
}
|
@@ -8922,7 +8922,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8922
8922
|
if (bodySection && !seen.has("content")) {
|
8923
8923
|
seen.add("content");
|
8924
8924
|
if (templateExport.props.content) {
|
8925
|
-
const contentExportIdentifier = (0,
|
8925
|
+
const contentExportIdentifier = (0, import_babel_utils41.importNamed)(
|
8926
8926
|
tag.hub.file,
|
8927
8927
|
info.relativePath,
|
8928
8928
|
templateExport.props.content.id,
|
@@ -8933,12 +8933,12 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8933
8933
|
void 0,
|
8934
8934
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
8935
8935
|
identifierToSignal(contentExportIdentifier),
|
8936
|
-
|
8936
|
+
import_compiler52.types.callExpression(import_compiler52.types.identifier(bodySection.name), [scopeIdentifier]),
|
8937
8937
|
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
8938
8938
|
callRuntime(
|
8939
8939
|
"inChild",
|
8940
8940
|
getScopeAccessorLiteral(info.childScopeBinding),
|
8941
|
-
|
8941
|
+
import_compiler52.types.identifier(contentExportIdentifier.name)
|
8942
8942
|
)
|
8943
8943
|
);
|
8944
8944
|
}
|
@@ -8948,7 +8948,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8948
8948
|
let spreadProps;
|
8949
8949
|
for (let i = attributes.length; i--; ) {
|
8950
8950
|
const attr2 = attributes[i];
|
8951
|
-
if (
|
8951
|
+
if (import_compiler52.types.isMarkoAttribute(attr2)) {
|
8952
8952
|
const childAttrExports = templateExport.props[attr2.name];
|
8953
8953
|
if (!childAttrExports || seen.has(attr2.name)) continue;
|
8954
8954
|
seen.add(attr2.name);
|
@@ -8958,9 +8958,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8958
8958
|
}
|
8959
8959
|
staticAttrs.push(attr2);
|
8960
8960
|
} else if (spreadProps) {
|
8961
|
-
spreadProps.push(
|
8961
|
+
spreadProps.push(import_compiler52.types.spreadElement(attr2.value));
|
8962
8962
|
} else {
|
8963
|
-
spreadProps = [
|
8963
|
+
spreadProps = [import_compiler52.types.spreadElement(attr2.value)];
|
8964
8964
|
}
|
8965
8965
|
}
|
8966
8966
|
for (const attr2 of staticAttrs.reverse()) {
|
@@ -8980,7 +8980,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8980
8980
|
callRuntime(
|
8981
8981
|
"inChild",
|
8982
8982
|
getScopeAccessorLiteral(info.childScopeBinding),
|
8983
|
-
|
8983
|
+
import_compiler52.types.identifier(attrExportIdentifier.name)
|
8984
8984
|
)
|
8985
8985
|
);
|
8986
8986
|
}
|
@@ -8994,8 +8994,8 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8994
8994
|
spreadProps.reverse();
|
8995
8995
|
getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
|
8996
8996
|
addStatement("render", info.tagSection, referencedBindings, [
|
8997
|
-
|
8998
|
-
|
8997
|
+
import_compiler52.types.variableDeclaration("const", [
|
8998
|
+
import_compiler52.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
|
8999
8999
|
])
|
9000
9000
|
]);
|
9001
9001
|
}
|
@@ -9016,7 +9016,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9016
9016
|
callRuntime(
|
9017
9017
|
"inChild",
|
9018
9018
|
getScopeAccessorLiteral(info.childScopeBinding),
|
9019
|
-
|
9019
|
+
import_compiler52.types.identifier(attrExportIdentifier.name)
|
9020
9020
|
)
|
9021
9021
|
);
|
9022
9022
|
}
|
@@ -9024,19 +9024,19 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9024
9024
|
}
|
9025
9025
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
9026
9026
|
if (isCircularRequest(file, request)) {
|
9027
|
-
return
|
9027
|
+
return import_compiler52.types.identifier(name2);
|
9028
9028
|
}
|
9029
|
-
return (0,
|
9029
|
+
return (0, import_babel_utils41.importNamed)(file, request, name2, nameHint);
|
9030
9030
|
}
|
9031
9031
|
function isCircularRequest(file, request) {
|
9032
9032
|
const { filename } = file.opts;
|
9033
9033
|
return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
|
9034
9034
|
}
|
9035
9035
|
function callStatement(id, ...args) {
|
9036
|
-
return
|
9036
|
+
return import_compiler52.types.expressionStatement(callExpression(id, ...args));
|
9037
9037
|
}
|
9038
9038
|
function callExpression(id, ...args) {
|
9039
|
-
return
|
9039
|
+
return import_compiler52.types.callExpression(id, args.filter(Boolean));
|
9040
9040
|
}
|
9041
9041
|
function identifierToSignal(identifier) {
|
9042
9042
|
return {
|
@@ -9045,20 +9045,20 @@ function identifierToSignal(identifier) {
|
|
9045
9045
|
};
|
9046
9046
|
}
|
9047
9047
|
function buildUndefined2() {
|
9048
|
-
return
|
9048
|
+
return import_compiler52.types.unaryExpression("void", import_compiler52.types.numericLiteral(0));
|
9049
9049
|
}
|
9050
9050
|
function always() {
|
9051
9051
|
return true;
|
9052
9052
|
}
|
9053
9053
|
|
9054
9054
|
// src/translator/visitors/tag/dynamic-tag.ts
|
9055
|
-
var
|
9056
|
-
var
|
9055
|
+
var import_compiler53 = require("@marko/compiler");
|
9056
|
+
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
9057
9057
|
var kDOMBinding = Symbol("dynamic tag dom binding");
|
9058
9058
|
var dynamic_tag_default = {
|
9059
9059
|
analyze: {
|
9060
9060
|
enter(tag) {
|
9061
|
-
(0,
|
9061
|
+
(0, import_babel_utils42.assertAttributesOrArgs)(tag);
|
9062
9062
|
analyzeAttributeTags(tag);
|
9063
9063
|
const section = getOrCreateSection(tag);
|
9064
9064
|
const tagExtra = tag.node.extra ??= {};
|
@@ -9092,8 +9092,8 @@ var dynamic_tag_default = {
|
|
9092
9092
|
const section = getSection(tag);
|
9093
9093
|
const isClassAPI = extra.featureType === "class";
|
9094
9094
|
let tagExpression = node.name;
|
9095
|
-
if (
|
9096
|
-
tagExpression = (0,
|
9095
|
+
if (import_compiler53.types.isStringLiteral(tagExpression)) {
|
9096
|
+
tagExpression = (0, import_babel_utils42.importDefault)(
|
9097
9097
|
tag.hub.file,
|
9098
9098
|
getTagRelativePath(tag),
|
9099
9099
|
tagExpression.value
|
@@ -9103,12 +9103,12 @@ var dynamic_tag_default = {
|
|
9103
9103
|
if (isOutputHTML()) {
|
9104
9104
|
currentProgramPath.pushContainer(
|
9105
9105
|
"body",
|
9106
|
-
|
9107
|
-
|
9108
|
-
(0,
|
9106
|
+
import_compiler53.types.expressionStatement(
|
9107
|
+
import_compiler53.types.callExpression(
|
9108
|
+
(0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
9109
9109
|
[
|
9110
|
-
|
9111
|
-
|
9110
|
+
import_compiler53.types.identifier(tagExpression.name),
|
9111
|
+
import_compiler53.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
|
9112
9112
|
]
|
9113
9113
|
)
|
9114
9114
|
)
|
@@ -9116,11 +9116,11 @@ var dynamic_tag_default = {
|
|
9116
9116
|
} else {
|
9117
9117
|
currentProgramPath.pushContainer(
|
9118
9118
|
"body",
|
9119
|
-
|
9119
|
+
import_compiler53.types.expressionStatement(
|
9120
9120
|
callRuntime(
|
9121
9121
|
"register",
|
9122
|
-
|
9123
|
-
|
9122
|
+
import_compiler53.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
|
9123
|
+
import_compiler53.types.identifier(tagExpression.name)
|
9124
9124
|
)
|
9125
9125
|
)
|
9126
9126
|
);
|
@@ -9140,7 +9140,7 @@ var dynamic_tag_default = {
|
|
9140
9140
|
hasMultipleArgs = true;
|
9141
9141
|
args.push(propsToExpression(properties));
|
9142
9142
|
} else {
|
9143
|
-
hasMultipleArgs = node.arguments.length > 1 ||
|
9143
|
+
hasMultipleArgs = node.arguments.length > 1 || import_compiler53.types.isSpreadElement(node.arguments[0]);
|
9144
9144
|
}
|
9145
9145
|
} else {
|
9146
9146
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
@@ -9156,7 +9156,7 @@ var dynamic_tag_default = {
|
|
9156
9156
|
writeHTMLResumeStatements(tag.get("body"));
|
9157
9157
|
if (node.var) {
|
9158
9158
|
if (!hasMultipleArgs && args.length === 1) {
|
9159
|
-
args.push(
|
9159
|
+
args.push(import_compiler53.types.unaryExpression("void", import_compiler53.types.numericLiteral(0)));
|
9160
9160
|
}
|
9161
9161
|
}
|
9162
9162
|
const dynamicScopeIdentifier = currentProgramPath.scope.generateUidIdentifier("dynamicScope");
|
@@ -9165,7 +9165,7 @@ var dynamic_tag_default = {
|
|
9165
9165
|
getScopeIdIdentifier(section),
|
9166
9166
|
getScopeAccessorLiteral(nodeRef2),
|
9167
9167
|
tagExpression,
|
9168
|
-
|
9168
|
+
import_compiler53.types.arrayExpression(args)
|
9169
9169
|
) : callRuntime(
|
9170
9170
|
"dynamicTagInput",
|
9171
9171
|
getScopeIdIdentifier(section),
|
@@ -9174,8 +9174,8 @@ var dynamic_tag_default = {
|
|
9174
9174
|
...args
|
9175
9175
|
);
|
9176
9176
|
statements.push(
|
9177
|
-
|
9178
|
-
|
9177
|
+
import_compiler53.types.variableDeclaration("const", [
|
9178
|
+
import_compiler53.types.variableDeclarator(
|
9179
9179
|
dynamicScopeIdentifier,
|
9180
9180
|
callRuntime("peekNextScope")
|
9181
9181
|
)
|
@@ -9183,12 +9183,12 @@ var dynamic_tag_default = {
|
|
9183
9183
|
);
|
9184
9184
|
if (node.var) {
|
9185
9185
|
statements.push(
|
9186
|
-
|
9186
|
+
import_compiler53.types.expressionStatement(
|
9187
9187
|
callRuntime(
|
9188
9188
|
"setTagVar",
|
9189
9189
|
getScopeIdIdentifier(section),
|
9190
9190
|
dynamicScopeIdentifier,
|
9191
|
-
|
9191
|
+
import_compiler53.types.stringLiteral(
|
9192
9192
|
getResumeRegisterId(
|
9193
9193
|
section,
|
9194
9194
|
node.var.extra?.binding,
|
@@ -9198,26 +9198,26 @@ var dynamic_tag_default = {
|
|
9198
9198
|
)
|
9199
9199
|
)
|
9200
9200
|
),
|
9201
|
-
|
9202
|
-
|
9201
|
+
import_compiler53.types.variableDeclaration("const", [
|
9202
|
+
import_compiler53.types.variableDeclarator(node.var, dynamicTagExpr)
|
9203
9203
|
])
|
9204
9204
|
);
|
9205
9205
|
} else {
|
9206
|
-
statements.push(
|
9206
|
+
statements.push(import_compiler53.types.expressionStatement(dynamicTagExpr));
|
9207
9207
|
}
|
9208
9208
|
getSerializedScopeProperties(section).set(
|
9209
|
-
|
9209
|
+
import_compiler53.types.stringLiteral(
|
9210
9210
|
getScopeAccessorLiteral(nodeRef2).value + "!" /* ConditionalScope */
|
9211
9211
|
),
|
9212
9212
|
callRuntime("writeExistingScope", dynamicScopeIdentifier)
|
9213
9213
|
);
|
9214
9214
|
getSerializedScopeProperties(section).set(
|
9215
|
-
|
9215
|
+
import_compiler53.types.stringLiteral(
|
9216
9216
|
getScopeAccessorLiteral(nodeRef2).value + "(" /* ConditionalRenderer */
|
9217
9217
|
),
|
9218
9218
|
callRuntime(
|
9219
9219
|
"normalizeDynamicRenderer",
|
9220
|
-
|
9220
|
+
import_compiler53.types.isIdentifier(tagExpression) ? import_compiler53.types.identifier(tagExpression.name) : tagExpression
|
9221
9221
|
)
|
9222
9222
|
);
|
9223
9223
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
@@ -9226,10 +9226,10 @@ var dynamic_tag_default = {
|
|
9226
9226
|
} else {
|
9227
9227
|
const section2 = getSection(tag);
|
9228
9228
|
const bodySection = getSectionForBody(tag.get("body"));
|
9229
|
-
const signal = getSignal(section2, nodeRef2, "
|
9229
|
+
const signal = getSignal(section2, nodeRef2, "dynamicTag");
|
9230
9230
|
signal.build = () => {
|
9231
9231
|
return callRuntime(
|
9232
|
-
"
|
9232
|
+
"dynamicTag",
|
9233
9233
|
getScopeAccessorLiteral(nodeRef2),
|
9234
9234
|
getSignalFn(signal, [scopeIdentifier]),
|
9235
9235
|
buildSignalIntersections(signal)
|
@@ -9240,16 +9240,16 @@ var dynamic_tag_default = {
|
|
9240
9240
|
section2,
|
9241
9241
|
node.name.extra?.referencedBindings,
|
9242
9242
|
signal,
|
9243
|
-
bodySection ?
|
9243
|
+
bodySection ? import_compiler53.types.logicalExpression(
|
9244
9244
|
"||",
|
9245
9245
|
tagExpression,
|
9246
|
-
|
9246
|
+
import_compiler53.types.callExpression(import_compiler53.types.identifier(bodySection.name), [
|
9247
9247
|
scopeIdentifier
|
9248
9248
|
])
|
9249
9249
|
) : tagExpression
|
9250
9250
|
);
|
9251
9251
|
if (tag.node.var) {
|
9252
|
-
const childScopeLiteral =
|
9252
|
+
const childScopeLiteral = import_compiler53.types.stringLiteral(
|
9253
9253
|
getScopeAccessorLiteral(extra[kDOMBinding]).value + "!" /* ConditionalScope */
|
9254
9254
|
);
|
9255
9255
|
const source = initValue(
|
@@ -9258,8 +9258,8 @@ var dynamic_tag_default = {
|
|
9258
9258
|
);
|
9259
9259
|
source.register = true;
|
9260
9260
|
source.buildAssignment = (valueSection, value) => {
|
9261
|
-
return
|
9262
|
-
|
9261
|
+
return import_compiler53.types.callExpression(importRuntime("tagVarSignalChange"), [
|
9262
|
+
import_compiler53.types.memberExpression(
|
9263
9263
|
getScopeExpression(source.section, valueSection),
|
9264
9264
|
childScopeLiteral,
|
9265
9265
|
true
|
@@ -9271,7 +9271,7 @@ var dynamic_tag_default = {
|
|
9271
9271
|
"render",
|
9272
9272
|
section2,
|
9273
9273
|
nodeRef2,
|
9274
|
-
|
9274
|
+
import_compiler53.types.expressionStatement(
|
9275
9275
|
callRuntime(
|
9276
9276
|
"setTagVar",
|
9277
9277
|
scopeIdentifier,
|
@@ -9282,11 +9282,11 @@ var dynamic_tag_default = {
|
|
9282
9282
|
);
|
9283
9283
|
}
|
9284
9284
|
if (args.length) {
|
9285
|
-
const argsOrInput = hasMultipleArgs ?
|
9286
|
-
const attrsGetter =
|
9285
|
+
const argsOrInput = hasMultipleArgs ? import_compiler53.types.arrayExpression(args) : args[0];
|
9286
|
+
const attrsGetter = import_compiler53.types.arrowFunctionExpression(
|
9287
9287
|
[],
|
9288
|
-
statements.length ?
|
9289
|
-
statements.concat(
|
9288
|
+
statements.length ? import_compiler53.types.blockStatement(
|
9289
|
+
statements.concat(import_compiler53.types.returnStatement(argsOrInput))
|
9290
9290
|
) : argsOrInput
|
9291
9291
|
);
|
9292
9292
|
const id = currentProgramPath.scope.generateUidIdentifier(
|
@@ -9301,14 +9301,14 @@ var dynamic_tag_default = {
|
|
9301
9301
|
if (!added) {
|
9302
9302
|
currentProgramPath.pushContainer(
|
9303
9303
|
"body",
|
9304
|
-
|
9305
|
-
|
9304
|
+
import_compiler53.types.variableDeclaration("const", [
|
9305
|
+
import_compiler53.types.variableDeclarator(
|
9306
9306
|
id,
|
9307
9307
|
callRuntime(
|
9308
9308
|
"dynamicTagAttrs",
|
9309
9309
|
getScopeAccessorLiteral(nodeRef2),
|
9310
|
-
bodySection &&
|
9311
|
-
hasMultipleArgs &&
|
9310
|
+
bodySection && import_compiler53.types.identifier(bodySection.name),
|
9311
|
+
hasMultipleArgs && import_compiler53.types.numericLiteral(1)
|
9312
9312
|
)
|
9313
9313
|
)
|
9314
9314
|
])
|
@@ -9337,16 +9337,16 @@ var tag_default = {
|
|
9337
9337
|
const { node } = tag;
|
9338
9338
|
const { name: name2, attributes } = tag.node;
|
9339
9339
|
let crawl = false;
|
9340
|
-
if (
|
9340
|
+
if (import_compiler54.types.isStringLiteral(name2)) {
|
9341
9341
|
const tagName = name2.value;
|
9342
9342
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
9343
|
-
node.name = withPreviousLocation(
|
9343
|
+
node.name = withPreviousLocation(import_compiler54.types.identifier(tagName), name2);
|
9344
9344
|
crawl = true;
|
9345
9345
|
}
|
9346
9346
|
}
|
9347
9347
|
for (let i = 0; i < attributes.length; i++) {
|
9348
9348
|
const attr2 = attributes[i];
|
9349
|
-
if (
|
9349
|
+
if (import_compiler54.types.isMarkoAttribute(attr2) && attr2.bound) {
|
9350
9350
|
attr2.bound = false;
|
9351
9351
|
attributes.splice(++i, 0, getChangeHandler(tag, attr2));
|
9352
9352
|
crawl = true;
|
@@ -9359,7 +9359,7 @@ var tag_default = {
|
|
9359
9359
|
},
|
9360
9360
|
analyze: {
|
9361
9361
|
enter(tag) {
|
9362
|
-
const tagDef = (0,
|
9362
|
+
const tagDef = (0, import_babel_utils43.getTagDef)(tag);
|
9363
9363
|
const type = analyzeTagNameType(tag);
|
9364
9364
|
const hook = tagDef?.analyzer?.hook;
|
9365
9365
|
if (hook) {
|
@@ -9383,7 +9383,7 @@ var tag_default = {
|
|
9383
9383
|
}
|
9384
9384
|
},
|
9385
9385
|
exit(tag) {
|
9386
|
-
const hook = (0,
|
9386
|
+
const hook = (0, import_babel_utils43.getTagDef)(tag)?.analyzer?.hook;
|
9387
9387
|
if (hook) {
|
9388
9388
|
exit(hook, tag);
|
9389
9389
|
return;
|
@@ -9392,7 +9392,7 @@ var tag_default = {
|
|
9392
9392
|
},
|
9393
9393
|
translate: {
|
9394
9394
|
enter(tag) {
|
9395
|
-
const tagDef = (0,
|
9395
|
+
const tagDef = (0, import_babel_utils43.getTagDef)(tag);
|
9396
9396
|
const extra = tag.node.extra;
|
9397
9397
|
if (tagDef?.translator) {
|
9398
9398
|
if (tagDef.translator.path) {
|
@@ -9409,7 +9409,7 @@ var tag_default = {
|
|
9409
9409
|
);
|
9410
9410
|
}
|
9411
9411
|
if (attr2.node.modifier) {
|
9412
|
-
if ((0,
|
9412
|
+
if ((0, import_babel_utils43.isNativeTag)(attr2.parentPath)) {
|
9413
9413
|
attr2.node.name += `:${attr2.node.modifier}`;
|
9414
9414
|
} else {
|
9415
9415
|
throw attr2.buildCodeFrameError(
|
@@ -9422,8 +9422,8 @@ var tag_default = {
|
|
9422
9422
|
if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
9423
9423
|
const tagNameId = tag.scope.generateUidIdentifier("tagName");
|
9424
9424
|
const [tagNameVarPath] = tag.insertBefore(
|
9425
|
-
|
9426
|
-
|
9425
|
+
import_compiler54.types.variableDeclaration("const", [
|
9426
|
+
import_compiler54.types.variableDeclarator(tagNameId, tag.node.name)
|
9427
9427
|
])
|
9428
9428
|
);
|
9429
9429
|
tagNameVarPath.skip();
|
@@ -9445,7 +9445,7 @@ var tag_default = {
|
|
9445
9445
|
}
|
9446
9446
|
},
|
9447
9447
|
exit(tag) {
|
9448
|
-
const translator = (0,
|
9448
|
+
const translator = (0, import_babel_utils43.getTagDef)(tag)?.translator;
|
9449
9449
|
if (translator) {
|
9450
9450
|
exit(translator.hook, tag);
|
9451
9451
|
return;
|
@@ -9470,16 +9470,16 @@ var tag_default = {
|
|
9470
9470
|
function getChangeHandler(tag, attr2) {
|
9471
9471
|
const attrName = attr2.name;
|
9472
9472
|
const changeAttrName = attrName + "Change";
|
9473
|
-
if (
|
9473
|
+
if (import_compiler54.types.isIdentifier(attr2.value)) {
|
9474
9474
|
const binding = tag.scope.getBinding(attr2.value.name);
|
9475
9475
|
if (!binding)
|
9476
|
-
return
|
9476
|
+
return import_compiler54.types.markoAttribute(
|
9477
9477
|
changeAttrName,
|
9478
9478
|
buildChangeHandlerFunction(attr2.value)
|
9479
9479
|
);
|
9480
9480
|
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
9481
9481
|
if (!existingChangedAttr) {
|
9482
|
-
const changeHandlerAttr =
|
9482
|
+
const changeHandlerAttr = import_compiler54.types.markoAttribute(
|
9483
9483
|
changeAttrName,
|
9484
9484
|
buildChangeHandlerFunction(attr2.value)
|
9485
9485
|
);
|
@@ -9487,10 +9487,10 @@ function getChangeHandler(tag, attr2) {
|
|
9487
9487
|
return changeHandlerAttr;
|
9488
9488
|
}
|
9489
9489
|
if (existingChangedAttr.type === "Identifier") {
|
9490
|
-
return
|
9490
|
+
return import_compiler54.types.markoAttribute(
|
9491
9491
|
changeAttrName,
|
9492
9492
|
withPreviousLocation(
|
9493
|
-
|
9493
|
+
import_compiler54.types.identifier(existingChangedAttr.name),
|
9494
9494
|
attr2.value
|
9495
9495
|
)
|
9496
9496
|
);
|
@@ -9500,37 +9500,37 @@ function getChangeHandler(tag, attr2) {
|
|
9500
9500
|
throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
|
9501
9501
|
}
|
9502
9502
|
const changeHandlerId = markoRoot.scope.generateUid(changeAttrName);
|
9503
|
-
const changeHandlerConst =
|
9504
|
-
|
9505
|
-
[
|
9506
|
-
|
9503
|
+
const changeHandlerConst = import_compiler54.types.markoTag(
|
9504
|
+
import_compiler54.types.stringLiteral("const"),
|
9505
|
+
[import_compiler54.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
9506
|
+
import_compiler54.types.markoTagBody([]),
|
9507
9507
|
null,
|
9508
|
-
|
9508
|
+
import_compiler54.types.identifier(changeHandlerId)
|
9509
9509
|
);
|
9510
9510
|
BINDING_CHANGE_HANDLER.set(
|
9511
9511
|
binding.identifier,
|
9512
|
-
existingChangedAttr.value =
|
9512
|
+
existingChangedAttr.value = import_compiler54.types.identifier(changeHandlerId)
|
9513
9513
|
);
|
9514
9514
|
if (markoRoot.isMarkoTag()) {
|
9515
9515
|
markoRoot.insertAfter(changeHandlerConst);
|
9516
9516
|
} else {
|
9517
9517
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
9518
9518
|
}
|
9519
|
-
return
|
9519
|
+
return import_compiler54.types.markoAttribute(
|
9520
9520
|
changeAttrName,
|
9521
|
-
withPreviousLocation(
|
9521
|
+
withPreviousLocation(import_compiler54.types.identifier(changeHandlerId), attr2.value)
|
9522
9522
|
);
|
9523
|
-
} else if (
|
9523
|
+
} else if (import_compiler54.types.isMemberExpression(attr2.value)) {
|
9524
9524
|
const prop = attr2.value.property;
|
9525
|
-
if (!
|
9526
|
-
return
|
9525
|
+
if (!import_compiler54.types.isPrivateName(attr2.value.property)) {
|
9526
|
+
return import_compiler54.types.markoAttribute(
|
9527
9527
|
changeAttrName,
|
9528
|
-
|
9529
|
-
|
9530
|
-
prop.type === "Identifier" ? withPreviousLocation(
|
9528
|
+
import_compiler54.types.memberExpression(
|
9529
|
+
import_compiler54.types.cloneNode(attr2.value.object),
|
9530
|
+
prop.type === "Identifier" ? withPreviousLocation(import_compiler54.types.identifier(prop.name + "Change"), prop) : import_compiler54.types.binaryExpression(
|
9531
9531
|
"+",
|
9532
|
-
|
9533
|
-
|
9532
|
+
import_compiler54.types.cloneNode(prop),
|
9533
|
+
import_compiler54.types.stringLiteral("Change")
|
9534
9534
|
),
|
9535
9535
|
prop.type !== "Identifier"
|
9536
9536
|
)
|
@@ -9544,14 +9544,14 @@ function getChangeHandler(tag, attr2) {
|
|
9544
9544
|
}
|
9545
9545
|
function buildChangeHandlerFunction(id) {
|
9546
9546
|
const newId = "_new_" + id.name;
|
9547
|
-
return
|
9548
|
-
[withPreviousLocation(
|
9549
|
-
|
9550
|
-
|
9551
|
-
|
9547
|
+
return import_compiler54.types.arrowFunctionExpression(
|
9548
|
+
[withPreviousLocation(import_compiler54.types.identifier(newId), id)],
|
9549
|
+
import_compiler54.types.blockStatement([
|
9550
|
+
import_compiler54.types.expressionStatement(
|
9551
|
+
import_compiler54.types.assignmentExpression(
|
9552
9552
|
"=",
|
9553
|
-
withPreviousLocation(
|
9554
|
-
withPreviousLocation(
|
9553
|
+
withPreviousLocation(import_compiler54.types.identifier(id.name), id),
|
9554
|
+
withPreviousLocation(import_compiler54.types.identifier(newId), id)
|
9555
9555
|
)
|
9556
9556
|
)
|
9557
9557
|
])
|
@@ -9559,7 +9559,7 @@ function buildChangeHandlerFunction(id) {
|
|
9559
9559
|
}
|
9560
9560
|
|
9561
9561
|
// src/translator/visitors/text.ts
|
9562
|
-
var
|
9562
|
+
var import_compiler55 = require("@marko/compiler");
|
9563
9563
|
var text_default = {
|
9564
9564
|
translate: {
|
9565
9565
|
exit(text) {
|