@marko/runtime-tags 0.3.78 → 0.3.80
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/translator/index.js +825 -823
- package/package.json +2 -2
package/dist/translator/index.js
CHANGED
|
@@ -109,8 +109,8 @@ var attrs_default = {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
// src/translator/core/await.ts
|
|
112
|
-
var
|
|
113
|
-
var
|
|
112
|
+
var import_compiler25 = require("@marko/compiler");
|
|
113
|
+
var import_babel_utils16 = require("@marko/compiler/babel-utils");
|
|
114
114
|
|
|
115
115
|
// src/common/accessor.debug.ts
|
|
116
116
|
var AccessorPrefix = /* @__PURE__ */ ((AccessorPrefix3) => {
|
|
@@ -163,17 +163,18 @@ function evaluate(value) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
// src/translator/util/references.ts
|
|
166
|
-
var
|
|
166
|
+
var import_compiler24 = require("@marko/compiler");
|
|
167
167
|
|
|
168
168
|
// src/translator/util/dynamic-sources.ts
|
|
169
|
-
var
|
|
169
|
+
var import_compiler6 = require("@marko/compiler");
|
|
170
170
|
|
|
171
171
|
// src/translator/util/sections.ts
|
|
172
|
-
var
|
|
173
|
-
var
|
|
172
|
+
var import_compiler5 = require("@marko/compiler");
|
|
173
|
+
var import_babel_utils7 = require("@marko/compiler/babel-utils");
|
|
174
174
|
|
|
175
175
|
// src/translator/util/generate-uid.ts
|
|
176
176
|
var import_compiler3 = require("@marko/compiler");
|
|
177
|
+
var import_babel_utils3 = require("@marko/compiler/babel-utils");
|
|
177
178
|
|
|
178
179
|
// src/translator/util/traverse.ts
|
|
179
180
|
var import_compiler2 = require("@marko/compiler");
|
|
@@ -236,7 +237,7 @@ function traverse(visit2, node, parent, grandParent) {
|
|
|
236
237
|
// src/translator/util/generate-uid.ts
|
|
237
238
|
var countsForFile = /* @__PURE__ */ new WeakMap();
|
|
238
239
|
function generateUid(name2 = "") {
|
|
239
|
-
const file = (0,
|
|
240
|
+
const file = (0, import_babel_utils3.getFile)();
|
|
240
241
|
let counts = countsForFile.get(file);
|
|
241
242
|
if (!counts) {
|
|
242
243
|
const { cache } = file.markoOpts;
|
|
@@ -291,7 +292,7 @@ function isTranslate(file) {
|
|
|
291
292
|
}
|
|
292
293
|
|
|
293
294
|
// src/translator/util/is-core-tag.ts
|
|
294
|
-
var
|
|
295
|
+
var import_babel_utils4 = require("@marko/compiler/babel-utils");
|
|
295
296
|
|
|
296
297
|
// src/translator/util/get-tag-name.ts
|
|
297
298
|
function getTagName(tag) {
|
|
@@ -304,7 +305,7 @@ var htmlTaglibId = "marko-html";
|
|
|
304
305
|
var interopTaglibId = "@marko/translator-interop-class-tags";
|
|
305
306
|
function isCoreTag(tag) {
|
|
306
307
|
if (tag.isMarkoTag()) {
|
|
307
|
-
const tagDef = (0,
|
|
308
|
+
const tagDef = (0, import_babel_utils4.getTagDef)(tag);
|
|
308
309
|
if (tagDef) {
|
|
309
310
|
switch (tagDef.taglibId) {
|
|
310
311
|
case taglibId:
|
|
@@ -591,46 +592,46 @@ function joinRepeatable(compare, a, b) {
|
|
|
591
592
|
}
|
|
592
593
|
|
|
593
594
|
// src/translator/util/state.ts
|
|
594
|
-
var
|
|
595
|
+
var import_babel_utils5 = require("@marko/compiler/babel-utils");
|
|
595
596
|
var createProgramState = (init) => {
|
|
596
597
|
const map2 = /* @__PURE__ */ new WeakMap();
|
|
597
598
|
return [
|
|
598
599
|
() => {
|
|
599
|
-
let state = map2.get((0,
|
|
600
|
+
let state = map2.get((0, import_babel_utils5.getProgram)());
|
|
600
601
|
if (!state) {
|
|
601
|
-
map2.set((0,
|
|
602
|
+
map2.set((0, import_babel_utils5.getProgram)(), state = init());
|
|
602
603
|
}
|
|
603
604
|
return state;
|
|
604
605
|
},
|
|
605
606
|
(value) => {
|
|
606
|
-
map2.set((0,
|
|
607
|
+
map2.set((0, import_babel_utils5.getProgram)(), value);
|
|
607
608
|
}
|
|
608
609
|
];
|
|
609
610
|
};
|
|
610
611
|
function createSectionState(key, init) {
|
|
611
612
|
return [
|
|
612
613
|
(section) => {
|
|
613
|
-
const arrayOfSectionData = (0,
|
|
614
|
+
const arrayOfSectionData = (0, import_babel_utils5.getProgram)().state[key] ??= {};
|
|
614
615
|
const sectionData = arrayOfSectionData[section.id] ??= init && init(section);
|
|
615
616
|
return sectionData;
|
|
616
617
|
},
|
|
617
618
|
(section, value) => {
|
|
618
|
-
const arrayOfSectionData = (0,
|
|
619
|
+
const arrayOfSectionData = (0, import_babel_utils5.getProgram)().state[key] ??= {};
|
|
619
620
|
arrayOfSectionData[section.id] = value;
|
|
620
621
|
}
|
|
621
622
|
];
|
|
622
623
|
}
|
|
623
624
|
|
|
624
625
|
// src/translator/util/tag-name-type.ts
|
|
625
|
-
var
|
|
626
|
-
var
|
|
626
|
+
var import_compiler4 = require("@marko/compiler");
|
|
627
|
+
var import_babel_utils6 = require("@marko/compiler/babel-utils");
|
|
627
628
|
var MARKO_FILE_REG = /^<.*>$|\.marko$/;
|
|
628
629
|
function analyzeTagNameType(tag) {
|
|
629
630
|
const extra = tag.node.extra ??= {};
|
|
630
631
|
if (extra.tagNameType === void 0) {
|
|
631
632
|
const name2 = tag.get("name");
|
|
632
633
|
if (name2.isStringLiteral()) {
|
|
633
|
-
extra.tagNameType = name2.node.value[0] === "@" ? 3 /* AttributeTag */ : (0,
|
|
634
|
+
extra.tagNameType = name2.node.value[0] === "@" ? 3 /* AttributeTag */ : (0, import_babel_utils6.isNativeTag)(tag) ? 0 /* NativeTag */ : 1 /* CustomTag */;
|
|
634
635
|
extra.tagNameNullable = extra.tagNameNullable = false;
|
|
635
636
|
} else if (name2.isIdentifier()) {
|
|
636
637
|
analyzeExpressionTagName(name2, extra);
|
|
@@ -646,13 +647,13 @@ function analyzeTagNameType(tag) {
|
|
|
646
647
|
extra.tagNameType = 2 /* DynamicTag */;
|
|
647
648
|
}
|
|
648
649
|
if (extra.tagNameType === 1 /* CustomTag */) {
|
|
649
|
-
const childFile = (0,
|
|
650
|
+
const childFile = (0, import_babel_utils6.loadFileForTag)(tag);
|
|
650
651
|
if (!childFile) {
|
|
651
652
|
extra.tagNameType = 2 /* DynamicTag */;
|
|
652
653
|
} else if (childFile.ast.program.extra.featureType === "class") {
|
|
653
654
|
extra.tagNameType = 2 /* DynamicTag */;
|
|
654
655
|
extra.featureType = "class";
|
|
655
|
-
((0,
|
|
656
|
+
((0, import_babel_utils6.getProgram)().node.extra ??= {}).needsCompat = true;
|
|
656
657
|
}
|
|
657
658
|
}
|
|
658
659
|
}
|
|
@@ -697,8 +698,8 @@ function analyzeExpressionTagName(name2, extra) {
|
|
|
697
698
|
}
|
|
698
699
|
if (binding.kind === "module") {
|
|
699
700
|
const decl = binding.path.parent;
|
|
700
|
-
if (MARKO_FILE_REG.test(decl.source.value) && decl.specifiers.some((it) =>
|
|
701
|
-
const resolvedImport = (0,
|
|
701
|
+
if (MARKO_FILE_REG.test(decl.source.value) && decl.specifiers.some((it) => import_compiler4.types.isImportDefaultSpecifier(it))) {
|
|
702
|
+
const resolvedImport = (0, import_babel_utils6.resolveTagImport)(name2, decl.source.value) || decl.source.value;
|
|
702
703
|
if (type === 0 /* NativeTag */ || tagNameImported && tagNameImported !== resolvedImport) {
|
|
703
704
|
type = 2 /* DynamicTag */;
|
|
704
705
|
tagNameImported = void 0;
|
|
@@ -805,14 +806,14 @@ var [getScopeIdIdentifier] = createSectionState(
|
|
|
805
806
|
var [getSectionParentIsOwner, setSectionParentIsOwner] = createSectionState("parentIsOwner", () => false);
|
|
806
807
|
var [_getScopeIdentifier] = createSectionState(
|
|
807
808
|
"scopeIdentifier",
|
|
808
|
-
() =>
|
|
809
|
+
() => import_compiler5.types.identifier("undefined")
|
|
809
810
|
);
|
|
810
811
|
function forEachSection(fn) {
|
|
811
|
-
const { sections } = (0,
|
|
812
|
+
const { sections } = (0, import_babel_utils7.getProgram)().node.extra;
|
|
812
813
|
sections?.forEach(fn);
|
|
813
814
|
}
|
|
814
815
|
function forEachSectionReverse(fn) {
|
|
815
|
-
const { sections } = (0,
|
|
816
|
+
const { sections } = (0, import_babel_utils7.getProgram)().node.extra;
|
|
816
817
|
for (let i = sections.length; i--; ) {
|
|
817
818
|
fn(sections[i]);
|
|
818
819
|
}
|
|
@@ -871,12 +872,12 @@ function getNodeContentType(path5, extraMember, contentInfo) {
|
|
|
871
872
|
default:
|
|
872
873
|
return null;
|
|
873
874
|
}
|
|
874
|
-
} else if ((0,
|
|
875
|
+
} else if ((0, import_babel_utils7.isNativeTag)(tag)) {
|
|
875
876
|
return 3 /* Tag */;
|
|
876
|
-
} else if ((0,
|
|
877
|
+
} else if ((0, import_babel_utils7.isAttributeTag)(tag)) {
|
|
877
878
|
return null;
|
|
878
|
-
} else if (
|
|
879
|
-
const tagSection = (0,
|
|
879
|
+
} else if (import_compiler5.types.isStringLiteral(tag.node.name)) {
|
|
880
|
+
const tagSection = (0, import_babel_utils7.loadFileForTag)(tag)?.ast.program.extra.section;
|
|
880
881
|
if (tagSection) {
|
|
881
882
|
if (tagSection.content) {
|
|
882
883
|
if (contentInfo && !tagSection.content.singleChild) {
|
|
@@ -1119,7 +1120,7 @@ var AccessorProp2 = /* @__PURE__ */ ((AccessorProp3) => {
|
|
|
1119
1120
|
})(AccessorProp2 || {});
|
|
1120
1121
|
|
|
1121
1122
|
// src/translator/util/marko-config.ts
|
|
1122
|
-
var
|
|
1123
|
+
var import_babel_utils8 = require("@marko/compiler/babel-utils");
|
|
1123
1124
|
function isOutputHTML() {
|
|
1124
1125
|
return getMarkoOpts().output === "html";
|
|
1125
1126
|
}
|
|
@@ -1127,7 +1128,7 @@ function isOutputDOM() {
|
|
|
1127
1128
|
return !isOutputHTML();
|
|
1128
1129
|
}
|
|
1129
1130
|
function getMarkoOpts() {
|
|
1130
|
-
return (0,
|
|
1131
|
+
return (0, import_babel_utils8.getFile)().markoOpts;
|
|
1131
1132
|
}
|
|
1132
1133
|
function isOptimize() {
|
|
1133
1134
|
return getMarkoOpts().optimize;
|
|
@@ -1202,7 +1203,7 @@ function isFunction(path5) {
|
|
|
1202
1203
|
}
|
|
1203
1204
|
|
|
1204
1205
|
// src/translator/util/is-invoked-function.ts
|
|
1205
|
-
var
|
|
1206
|
+
var import_compiler7 = require("@marko/compiler");
|
|
1206
1207
|
function isInvokedFunction(expr) {
|
|
1207
1208
|
let curPath = expr;
|
|
1208
1209
|
while (curPath) {
|
|
@@ -1221,11 +1222,11 @@ function isInvokedFunction(expr) {
|
|
|
1221
1222
|
}
|
|
1222
1223
|
|
|
1223
1224
|
// src/translator/util/scope-read.ts
|
|
1224
|
-
var
|
|
1225
|
+
var import_compiler23 = require("@marko/compiler");
|
|
1225
1226
|
|
|
1226
1227
|
// src/translator/visitors/program/index.ts
|
|
1227
|
-
var
|
|
1228
|
-
var
|
|
1228
|
+
var import_compiler22 = require("@marko/compiler");
|
|
1229
|
+
var import_babel_utils15 = require("@marko/compiler/babel-utils");
|
|
1229
1230
|
var import_path2 = __toESM(require("path"));
|
|
1230
1231
|
|
|
1231
1232
|
// src/translator/util/binding-has-downstream-expressions.ts
|
|
@@ -1241,8 +1242,8 @@ function bindingHasDownstreamExpressions(binding) {
|
|
|
1241
1242
|
}
|
|
1242
1243
|
|
|
1243
1244
|
// src/translator/util/entry-builder.ts
|
|
1244
|
-
var
|
|
1245
|
-
var
|
|
1245
|
+
var import_compiler8 = require("@marko/compiler");
|
|
1246
|
+
var import_babel_utils9 = require("@marko/compiler/babel-utils");
|
|
1246
1247
|
var kState = Symbol();
|
|
1247
1248
|
var entry_builder_default = {
|
|
1248
1249
|
build(entryFile) {
|
|
@@ -1253,19 +1254,19 @@ var entry_builder_default = {
|
|
|
1253
1254
|
);
|
|
1254
1255
|
}
|
|
1255
1256
|
const body = state.imports.map(
|
|
1256
|
-
(it) =>
|
|
1257
|
+
(it) => import_compiler8.types.importDeclaration([], import_compiler8.types.stringLiteral(it))
|
|
1257
1258
|
);
|
|
1258
1259
|
if (state.init) {
|
|
1259
1260
|
body.unshift(
|
|
1260
|
-
|
|
1261
|
-
[
|
|
1262
|
-
|
|
1261
|
+
import_compiler8.types.importDeclaration(
|
|
1262
|
+
[import_compiler8.types.importSpecifier(import_compiler8.types.identifier("init"), import_compiler8.types.identifier("init"))],
|
|
1263
|
+
import_compiler8.types.stringLiteral(
|
|
1263
1264
|
`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`
|
|
1264
1265
|
)
|
|
1265
1266
|
)
|
|
1266
1267
|
);
|
|
1267
1268
|
body.push(
|
|
1268
|
-
|
|
1269
|
+
import_compiler8.types.expressionStatement(import_compiler8.types.callExpression(import_compiler8.types.identifier("init"), []))
|
|
1269
1270
|
);
|
|
1270
1271
|
}
|
|
1271
1272
|
return body;
|
|
@@ -1277,7 +1278,7 @@ var entry_builder_default = {
|
|
|
1277
1278
|
};
|
|
1278
1279
|
const { analyzedTags } = file.metadata.marko;
|
|
1279
1280
|
state.imports.push(
|
|
1280
|
-
(0,
|
|
1281
|
+
(0, import_babel_utils9.resolveRelativePath)(entryFile, file.opts.filename)
|
|
1281
1282
|
);
|
|
1282
1283
|
state.init ||= file.path.node.extra.hasInteractiveChild || file.path.node.extra.isInteractive || false;
|
|
1283
1284
|
for (const tag of analyzedTags || []) {
|
|
@@ -1287,8 +1288,8 @@ var entry_builder_default = {
|
|
|
1287
1288
|
};
|
|
1288
1289
|
|
|
1289
1290
|
// src/translator/util/runtime.ts
|
|
1290
|
-
var
|
|
1291
|
-
var
|
|
1291
|
+
var import_compiler10 = require("@marko/compiler");
|
|
1292
|
+
var import_babel_utils10 = require("@marko/compiler/babel-utils");
|
|
1292
1293
|
|
|
1293
1294
|
// src/common/attr-tag.ts
|
|
1294
1295
|
var rest = false ? Symbol("Attribute Tag") : Symbol();
|
|
@@ -1710,25 +1711,25 @@ var RENDER_BODY_ID = prefix + (false ? "renderBody" : "b");
|
|
|
1710
1711
|
var K_TAGS_API_STATE = Symbol();
|
|
1711
1712
|
|
|
1712
1713
|
// src/translator/util/to-property-name.ts
|
|
1713
|
-
var
|
|
1714
|
+
var import_compiler9 = require("@marko/compiler");
|
|
1714
1715
|
function isValidPropertyIdentifier(name2) {
|
|
1715
1716
|
return /^[a-z_$][a-z0-9_$]*$/i.test(name2);
|
|
1716
1717
|
}
|
|
1717
1718
|
function toPropertyName(name2) {
|
|
1718
1719
|
if (isValidPropertyIdentifier(name2)) {
|
|
1719
|
-
return
|
|
1720
|
+
return import_compiler9.types.identifier(name2);
|
|
1720
1721
|
} else if (/^(?:0|[1-9][0-9]*)$/.test(name2)) {
|
|
1721
|
-
return
|
|
1722
|
+
return import_compiler9.types.numericLiteral(parseInt(name2, 10));
|
|
1722
1723
|
}
|
|
1723
|
-
return
|
|
1724
|
+
return import_compiler9.types.stringLiteral(name2);
|
|
1724
1725
|
}
|
|
1725
1726
|
function toObjectProperty(name2, value) {
|
|
1726
|
-
return
|
|
1727
|
+
return import_compiler9.types.objectProperty(toPropertyName(name2), value);
|
|
1727
1728
|
}
|
|
1728
1729
|
function toMemberExpression(object, key, optional) {
|
|
1729
1730
|
const prop = toPropertyName(key);
|
|
1730
1731
|
const computed = prop.type !== "Identifier";
|
|
1731
|
-
return optional ?
|
|
1732
|
+
return optional ? import_compiler9.types.optionalMemberExpression(object, prop, computed, true) : import_compiler9.types.memberExpression(object, prop, computed);
|
|
1732
1733
|
}
|
|
1733
1734
|
|
|
1734
1735
|
// src/translator/util/runtime.ts
|
|
@@ -1754,12 +1755,12 @@ var pureDOMFunctions = /* @__PURE__ */ new Set([
|
|
|
1754
1755
|
function importRuntime(name2) {
|
|
1755
1756
|
const { output } = getMarkoOpts();
|
|
1756
1757
|
return toMemberExpression(
|
|
1757
|
-
(0,
|
|
1758
|
+
(0, import_babel_utils10.importStar)((0, import_babel_utils10.getFile)(), getRuntimePath(output), "$"),
|
|
1758
1759
|
name2
|
|
1759
1760
|
);
|
|
1760
1761
|
}
|
|
1761
1762
|
function callRuntime(name2, ...args) {
|
|
1762
|
-
const callExpression2 =
|
|
1763
|
+
const callExpression2 = import_compiler10.types.callExpression(
|
|
1763
1764
|
importRuntime(name2),
|
|
1764
1765
|
filterArguments(args)
|
|
1765
1766
|
);
|
|
@@ -1793,7 +1794,7 @@ function filterArguments(args) {
|
|
|
1793
1794
|
for (let i = args.length; i--; ) {
|
|
1794
1795
|
const arg = args[i];
|
|
1795
1796
|
if (arg || filteredArgs.length) {
|
|
1796
|
-
filteredArgs[i] = arg ||
|
|
1797
|
+
filteredArgs[i] = arg || import_compiler10.types.unaryExpression("void", import_compiler10.types.numericLiteral(0));
|
|
1797
1798
|
}
|
|
1798
1799
|
}
|
|
1799
1800
|
return filteredArgs;
|
|
@@ -1804,8 +1805,8 @@ function getCompatRuntimeFile() {
|
|
|
1804
1805
|
}
|
|
1805
1806
|
|
|
1806
1807
|
// src/translator/visitors/program/dom.ts
|
|
1807
|
-
var
|
|
1808
|
-
var
|
|
1808
|
+
var import_compiler20 = require("@marko/compiler");
|
|
1809
|
+
var import_babel_utils13 = require("@marko/compiler/babel-utils");
|
|
1809
1810
|
|
|
1810
1811
|
// src/translator/util/get-style-file.ts
|
|
1811
1812
|
var import_path = __toESM(require("path"));
|
|
@@ -1844,12 +1845,12 @@ function escapeRegExp(str) {
|
|
|
1844
1845
|
}
|
|
1845
1846
|
|
|
1846
1847
|
// src/translator/util/signals.ts
|
|
1847
|
-
var
|
|
1848
|
-
var
|
|
1848
|
+
var import_compiler19 = require("@marko/compiler");
|
|
1849
|
+
var import_babel_utils12 = require("@marko/compiler/babel-utils");
|
|
1849
1850
|
|
|
1850
1851
|
// src/translator/core/return.ts
|
|
1851
|
-
var
|
|
1852
|
-
var
|
|
1852
|
+
var import_compiler15 = require("@marko/compiler");
|
|
1853
|
+
var import_babel_utils11 = require("@marko/compiler/babel-utils");
|
|
1853
1854
|
|
|
1854
1855
|
// src/translator/util/get-known-attr-values.ts
|
|
1855
1856
|
function getKnownAttrValues(tag) {
|
|
@@ -1871,7 +1872,7 @@ function getParentTag(tag) {
|
|
|
1871
1872
|
}
|
|
1872
1873
|
|
|
1873
1874
|
// src/translator/util/plugin-hooks.ts
|
|
1874
|
-
var
|
|
1875
|
+
var import_compiler11 = require("@marko/compiler");
|
|
1875
1876
|
function enter(modulePlugin, path5) {
|
|
1876
1877
|
if (!modulePlugin) {
|
|
1877
1878
|
return false;
|
|
@@ -1879,9 +1880,9 @@ function enter(modulePlugin, path5) {
|
|
|
1879
1880
|
const { node } = path5;
|
|
1880
1881
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
|
1881
1882
|
if (isFunctionPlugin(plugin)) {
|
|
1882
|
-
plugin(path5,
|
|
1883
|
+
plugin(path5, import_compiler11.types);
|
|
1883
1884
|
} else if (plugin.enter) {
|
|
1884
|
-
plugin.enter(path5,
|
|
1885
|
+
plugin.enter(path5, import_compiler11.types);
|
|
1885
1886
|
}
|
|
1886
1887
|
return node !== path5.node;
|
|
1887
1888
|
}
|
|
@@ -1892,7 +1893,7 @@ function exit(modulePlugin, path5) {
|
|
|
1892
1893
|
const { node } = path5;
|
|
1893
1894
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
|
1894
1895
|
if (!isFunctionPlugin(plugin) && plugin.exit) {
|
|
1895
|
-
plugin.exit(path5,
|
|
1896
|
+
plugin.exit(path5, import_compiler11.types);
|
|
1896
1897
|
}
|
|
1897
1898
|
return node !== path5.node;
|
|
1898
1899
|
}
|
|
@@ -1936,10 +1937,10 @@ function translateByTarget({
|
|
|
1936
1937
|
}
|
|
1937
1938
|
|
|
1938
1939
|
// src/translator/util/writer.ts
|
|
1939
|
-
var
|
|
1940
|
+
var import_compiler14 = require("@marko/compiler");
|
|
1940
1941
|
|
|
1941
1942
|
// src/translator/util/normalize-string-expression.ts
|
|
1942
|
-
var
|
|
1943
|
+
var import_compiler12 = require("@marko/compiler");
|
|
1943
1944
|
function normalizeStringExpression(parts) {
|
|
1944
1945
|
const strs = [];
|
|
1945
1946
|
const exprs = [];
|
|
@@ -1947,9 +1948,9 @@ function normalizeStringExpression(parts) {
|
|
|
1947
1948
|
for (let i = 1; i < parts.length; i++) {
|
|
1948
1949
|
let content = parts[i];
|
|
1949
1950
|
if (typeof content === "object") {
|
|
1950
|
-
if (
|
|
1951
|
+
if (import_compiler12.types.isStringLiteral(content)) {
|
|
1951
1952
|
content = content.value;
|
|
1952
|
-
} else if (
|
|
1953
|
+
} else if (import_compiler12.types.isTemplateLiteral(content)) {
|
|
1953
1954
|
let nextIndex = i + 1;
|
|
1954
1955
|
const exprLen = content.expressions.length;
|
|
1955
1956
|
shiftItems(parts, nextIndex, content.quasis.length + exprLen);
|
|
@@ -1973,12 +1974,12 @@ function normalizeStringExpression(parts) {
|
|
|
1973
1974
|
return exprs[0];
|
|
1974
1975
|
}
|
|
1975
1976
|
strs.push(curStr);
|
|
1976
|
-
return
|
|
1977
|
-
strs.map((raw) =>
|
|
1977
|
+
return import_compiler12.types.templateLiteral(
|
|
1978
|
+
strs.map((raw) => import_compiler12.types.templateElement({ raw })),
|
|
1978
1979
|
exprs
|
|
1979
1980
|
);
|
|
1980
1981
|
} else if (curStr) {
|
|
1981
|
-
return
|
|
1982
|
+
return import_compiler12.types.stringLiteral(curStr);
|
|
1982
1983
|
}
|
|
1983
1984
|
}
|
|
1984
1985
|
function appendLiteral(arr, str) {
|
|
@@ -1991,7 +1992,7 @@ function shiftItems(list, start, offset) {
|
|
|
1991
1992
|
}
|
|
1992
1993
|
|
|
1993
1994
|
// src/translator/util/walks.ts
|
|
1994
|
-
var
|
|
1995
|
+
var import_compiler13 = require("@marko/compiler");
|
|
1995
1996
|
var [getWalks] = createSectionState(
|
|
1996
1997
|
"walks",
|
|
1997
1998
|
() => [""]
|
|
@@ -2170,16 +2171,16 @@ function consumeHTML(path5) {
|
|
|
2170
2171
|
trailers.length = 0;
|
|
2171
2172
|
trailers[0] = "";
|
|
2172
2173
|
if (writeResult && trailerResult) {
|
|
2173
|
-
return
|
|
2174
|
-
|
|
2174
|
+
return import_compiler14.types.expressionStatement(
|
|
2175
|
+
import_compiler14.types.sequenceExpression([
|
|
2175
2176
|
callRuntime("write", writeResult),
|
|
2176
2177
|
callRuntime("writeTrailers", trailerResult)
|
|
2177
2178
|
])
|
|
2178
2179
|
);
|
|
2179
2180
|
} else if (writeResult) {
|
|
2180
|
-
return
|
|
2181
|
+
return import_compiler14.types.expressionStatement(callRuntime("write", writeResult));
|
|
2181
2182
|
} else if (trailerResult) {
|
|
2182
|
-
return
|
|
2183
|
+
return import_compiler14.types.expressionStatement(callRuntime("writeTrailers", trailerResult));
|
|
2183
2184
|
}
|
|
2184
2185
|
}
|
|
2185
2186
|
function flushBefore(path5) {
|
|
@@ -2226,14 +2227,14 @@ var tagsWithReturn = /* @__PURE__ */ new WeakSet();
|
|
|
2226
2227
|
var [getSectionReturnValueIdentifier, setReturnValueIdentifier] = createSectionState("returnValue");
|
|
2227
2228
|
var return_default = {
|
|
2228
2229
|
analyze(tag) {
|
|
2229
|
-
(0,
|
|
2230
|
-
(0,
|
|
2231
|
-
(0,
|
|
2230
|
+
(0, import_babel_utils11.assertNoArgs)(tag);
|
|
2231
|
+
(0, import_babel_utils11.assertNoVar)(tag);
|
|
2232
|
+
(0, import_babel_utils11.assertNoParams)(tag);
|
|
2232
2233
|
assertNoBodyContent(tag);
|
|
2233
|
-
(0,
|
|
2234
|
+
(0, import_babel_utils11.assertAllowedAttributes)(tag, ["value", "valueChange"]);
|
|
2234
2235
|
const parentTag = getParentTag(tag);
|
|
2235
2236
|
if (parentTag) {
|
|
2236
|
-
if ((0,
|
|
2237
|
+
if ((0, import_babel_utils11.isNativeTag)(parentTag)) {
|
|
2237
2238
|
throw tag.get("name").buildCodeFrameError(
|
|
2238
2239
|
"The `return` tag can not be used in a native tag."
|
|
2239
2240
|
);
|
|
@@ -2273,8 +2274,8 @@ var return_default = {
|
|
|
2273
2274
|
const returnId = generateUidIdentifier("return");
|
|
2274
2275
|
setReturnValueIdentifier(section, returnId);
|
|
2275
2276
|
tag.replaceWith(
|
|
2276
|
-
|
|
2277
|
-
|
|
2277
|
+
import_compiler15.types.variableDeclaration("const", [
|
|
2278
|
+
import_compiler15.types.variableDeclarator(returnId, attrs2.value)
|
|
2278
2279
|
])
|
|
2279
2280
|
)[0].skip();
|
|
2280
2281
|
}
|
|
@@ -2324,10 +2325,10 @@ var return_default = {
|
|
|
2324
2325
|
};
|
|
2325
2326
|
|
|
2326
2327
|
// src/translator/util/get-defined-binding-expression.ts
|
|
2327
|
-
var
|
|
2328
|
+
var import_compiler16 = require("@marko/compiler");
|
|
2328
2329
|
function getDeclaredBindingExpression(binding) {
|
|
2329
2330
|
if (binding.declared || !binding.upstreamAlias) {
|
|
2330
|
-
return
|
|
2331
|
+
return import_compiler16.types.identifier(binding.name);
|
|
2331
2332
|
} else if (binding.property !== void 0) {
|
|
2332
2333
|
return toMemberExpression(
|
|
2333
2334
|
getDeclaredBindingExpression(binding.upstreamAlias),
|
|
@@ -2340,7 +2341,7 @@ function getDeclaredBindingExpression(binding) {
|
|
|
2340
2341
|
}
|
|
2341
2342
|
|
|
2342
2343
|
// src/translator/util/simplify-fn.ts
|
|
2343
|
-
var
|
|
2344
|
+
var import_compiler17 = require("@marko/compiler");
|
|
2344
2345
|
function simplifyFunction(fn) {
|
|
2345
2346
|
switch (fn.type) {
|
|
2346
2347
|
case "FunctionDeclaration":
|
|
@@ -2348,7 +2349,7 @@ function simplifyFunction(fn) {
|
|
|
2348
2349
|
case "ArrowFunctionExpression":
|
|
2349
2350
|
return fn;
|
|
2350
2351
|
default:
|
|
2351
|
-
return
|
|
2352
|
+
return import_compiler17.types.functionExpression(
|
|
2352
2353
|
null,
|
|
2353
2354
|
fn.params,
|
|
2354
2355
|
fn.body,
|
|
@@ -2359,9 +2360,9 @@ function simplifyFunction(fn) {
|
|
|
2359
2360
|
}
|
|
2360
2361
|
|
|
2361
2362
|
// src/translator/util/to-first-expression-or-block.ts
|
|
2362
|
-
var
|
|
2363
|
+
var import_compiler18 = require("@marko/compiler");
|
|
2363
2364
|
function toFirstExpressionOrBlock(stmts) {
|
|
2364
|
-
if (stmts.length === 1 &&
|
|
2365
|
+
if (stmts.length === 1 && import_compiler18.types.isExpressionStatement(stmts[0])) {
|
|
2365
2366
|
const { expression } = stmts[0];
|
|
2366
2367
|
switch (expression.type) {
|
|
2367
2368
|
case "ObjectExpression":
|
|
@@ -2371,13 +2372,13 @@ function toFirstExpressionOrBlock(stmts) {
|
|
|
2371
2372
|
return expression;
|
|
2372
2373
|
}
|
|
2373
2374
|
}
|
|
2374
|
-
return
|
|
2375
|
+
return import_compiler18.types.blockStatement(stmts);
|
|
2375
2376
|
}
|
|
2376
2377
|
function toParenthesizedExpressionIfNeeded(expr) {
|
|
2377
2378
|
switch (expr.type) {
|
|
2378
2379
|
case "ObjectExpression":
|
|
2379
2380
|
case "AssignmentExpression":
|
|
2380
|
-
return
|
|
2381
|
+
return import_compiler18.types.parenthesizedExpression(expr);
|
|
2381
2382
|
default:
|
|
2382
2383
|
return expr;
|
|
2383
2384
|
}
|
|
@@ -2441,17 +2442,17 @@ function getHoistFunctionIdentifier(hoistedBinding) {
|
|
|
2441
2442
|
return identifier;
|
|
2442
2443
|
}
|
|
2443
2444
|
var unimplementedBuild = () => {
|
|
2444
|
-
return
|
|
2445
|
+
return import_compiler19.types.stringLiteral("SIGNAL NOT INITIALIZED");
|
|
2445
2446
|
};
|
|
2446
2447
|
function getSignal(section, referencedBindings, name2 = generateSignalName(referencedBindings)) {
|
|
2447
2448
|
const signals = getSignals(section);
|
|
2448
2449
|
let signal = signals.get(referencedBindings);
|
|
2449
2450
|
if (!signal) {
|
|
2450
|
-
const exportName = referencedBindings ? !Array.isArray(referencedBindings) && referencedBindings.section === section && referencedBindings.export : !section.parent && (0,
|
|
2451
|
+
const exportName = referencedBindings ? !Array.isArray(referencedBindings) && referencedBindings.section === section && referencedBindings.export : !section.parent && (0, import_babel_utils12.getProgram)().node.extra.domExports?.setup;
|
|
2451
2452
|
signals.set(
|
|
2452
2453
|
referencedBindings,
|
|
2453
2454
|
signal = {
|
|
2454
|
-
identifier: exportName ?
|
|
2455
|
+
identifier: exportName ? import_compiler19.types.identifier(exportName) : generateUidIdentifier(name2 + section.name.replace("_", "$")),
|
|
2455
2456
|
referencedBindings,
|
|
2456
2457
|
section,
|
|
2457
2458
|
values: [],
|
|
@@ -2506,9 +2507,9 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
|
2506
2507
|
const { id, scopeOffset } = intersectionMeta.get(referencedBindings);
|
|
2507
2508
|
return callRuntime(
|
|
2508
2509
|
"intersection",
|
|
2509
|
-
|
|
2510
|
+
import_compiler19.types.numericLiteral(id),
|
|
2510
2511
|
getSignalFn(signal),
|
|
2511
|
-
scopeOffset || referencedBindings.length > 2 ?
|
|
2512
|
+
scopeOffset || referencedBindings.length > 2 ? import_compiler19.types.numericLiteral(referencedBindings.length - 1) : void 0,
|
|
2512
2513
|
scopeOffset && getScopeAccessorLiteral(scopeOffset)
|
|
2513
2514
|
);
|
|
2514
2515
|
};
|
|
@@ -2520,7 +2521,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
|
2520
2521
|
"dynamicClosureRead",
|
|
2521
2522
|
getScopeAccessorLiteral(referencedBindings),
|
|
2522
2523
|
render,
|
|
2523
|
-
isImmediateOwner(section, referencedBindings) ? void 0 :
|
|
2524
|
+
isImmediateOwner(section, referencedBindings) ? void 0 : import_compiler19.types.arrowFunctionExpression(
|
|
2524
2525
|
[scopeIdentifier],
|
|
2525
2526
|
getScopeExpression(section, referencedBindings.section)
|
|
2526
2527
|
)
|
|
@@ -2568,7 +2569,7 @@ function getSignalFn(signal) {
|
|
|
2568
2569
|
const isValue = isBinding && binding.section === section;
|
|
2569
2570
|
let canUseCalleeDirectly = !signal.render.length;
|
|
2570
2571
|
if (isBinding && (signal.renderReferencedBindings || binding.aliases.size || binding.propertyAliases.size)) {
|
|
2571
|
-
const valueParam =
|
|
2572
|
+
const valueParam = import_compiler19.types.identifier(binding.name);
|
|
2572
2573
|
if (binding.loc) {
|
|
2573
2574
|
valueParam.loc = binding.loc;
|
|
2574
2575
|
valueParam.start = binding.loc.start.index;
|
|
@@ -2580,10 +2581,10 @@ function getSignalFn(signal) {
|
|
|
2580
2581
|
for (const alias of binding.aliases) {
|
|
2581
2582
|
const aliasSignal = getSignal(alias.section, alias);
|
|
2582
2583
|
signal.render.push(
|
|
2583
|
-
|
|
2584
|
-
|
|
2584
|
+
import_compiler19.types.expressionStatement(
|
|
2585
|
+
import_compiler19.types.callExpression(aliasSignal.identifier, [
|
|
2585
2586
|
scopeIdentifier,
|
|
2586
|
-
|
|
2587
|
+
import_compiler19.types.identifier(binding.name),
|
|
2587
2588
|
...getTranslatedExtraArgs(aliasSignal)
|
|
2588
2589
|
])
|
|
2589
2590
|
)
|
|
@@ -2592,11 +2593,11 @@ function getSignalFn(signal) {
|
|
|
2592
2593
|
for (const [key, alias] of binding.propertyAliases) {
|
|
2593
2594
|
const aliasSignal = getSignal(alias.section, alias);
|
|
2594
2595
|
signal.render.push(
|
|
2595
|
-
|
|
2596
|
-
|
|
2596
|
+
import_compiler19.types.expressionStatement(
|
|
2597
|
+
import_compiler19.types.callExpression(aliasSignal.identifier, [
|
|
2597
2598
|
scopeIdentifier,
|
|
2598
2599
|
toMemberExpression(
|
|
2599
|
-
|
|
2600
|
+
import_compiler19.types.identifier(binding.name),
|
|
2600
2601
|
key,
|
|
2601
2602
|
binding.nullable
|
|
2602
2603
|
),
|
|
@@ -2608,8 +2609,8 @@ function getSignalFn(signal) {
|
|
|
2608
2609
|
}
|
|
2609
2610
|
for (const value of signal.values) {
|
|
2610
2611
|
signal.render.push(
|
|
2611
|
-
|
|
2612
|
-
|
|
2612
|
+
import_compiler19.types.expressionStatement(
|
|
2613
|
+
import_compiler19.types.callExpression(value.signal.identifier, [
|
|
2613
2614
|
value.scope,
|
|
2614
2615
|
value.value,
|
|
2615
2616
|
...getTranslatedExtraArgs(value.signal)
|
|
@@ -2619,7 +2620,7 @@ function getSignalFn(signal) {
|
|
|
2619
2620
|
}
|
|
2620
2621
|
forEach(signal.intersection, (intersection) => {
|
|
2621
2622
|
signal.render.push(
|
|
2622
|
-
|
|
2623
|
+
import_compiler19.types.expressionStatement(import_compiler19.types.callExpression(intersection, [scopeIdentifier]))
|
|
2623
2624
|
);
|
|
2624
2625
|
});
|
|
2625
2626
|
if (isValue) {
|
|
@@ -2634,8 +2635,8 @@ function getSignalFn(signal) {
|
|
|
2634
2635
|
signal.identifier.name + "_closure"
|
|
2635
2636
|
);
|
|
2636
2637
|
signal.render.push(
|
|
2637
|
-
|
|
2638
|
-
|
|
2638
|
+
import_compiler19.types.expressionStatement(
|
|
2639
|
+
import_compiler19.types.callExpression(dynamicClosureSignalIdentifier, [
|
|
2639
2640
|
scopeIdentifier
|
|
2640
2641
|
])
|
|
2641
2642
|
)
|
|
@@ -2646,8 +2647,8 @@ function getSignalFn(signal) {
|
|
|
2646
2647
|
);
|
|
2647
2648
|
} else {
|
|
2648
2649
|
signal.render.push(
|
|
2649
|
-
|
|
2650
|
-
|
|
2650
|
+
import_compiler19.types.expressionStatement(
|
|
2651
|
+
import_compiler19.types.callExpression(getSignal(closureSection, binding).identifier, [
|
|
2651
2652
|
scopeIdentifier
|
|
2652
2653
|
])
|
|
2653
2654
|
)
|
|
@@ -2657,8 +2658,8 @@ function getSignalFn(signal) {
|
|
|
2657
2658
|
});
|
|
2658
2659
|
if (dynamicClosureSignalIdentifier) {
|
|
2659
2660
|
(signal.prependStatements ||= []).push(
|
|
2660
|
-
|
|
2661
|
-
|
|
2661
|
+
import_compiler19.types.variableDeclaration("const", [
|
|
2662
|
+
import_compiler19.types.variableDeclarator(
|
|
2662
2663
|
dynamicClosureSignalIdentifier,
|
|
2663
2664
|
callRuntime("dynamicClosure", ...dynamicClosureArgs)
|
|
2664
2665
|
)
|
|
@@ -2667,17 +2668,17 @@ function getSignalFn(signal) {
|
|
|
2667
2668
|
}
|
|
2668
2669
|
}
|
|
2669
2670
|
if (signal.effect.length) {
|
|
2670
|
-
const effectIdentifier =
|
|
2671
|
+
const effectIdentifier = import_compiler19.types.identifier(`${signal.identifier.name}_effect`);
|
|
2671
2672
|
signal.render.push(
|
|
2672
|
-
|
|
2673
|
-
|
|
2673
|
+
import_compiler19.types.expressionStatement(
|
|
2674
|
+
import_compiler19.types.callExpression(effectIdentifier, [scopeIdentifier])
|
|
2674
2675
|
)
|
|
2675
2676
|
);
|
|
2676
2677
|
}
|
|
2677
2678
|
if (isIntersection && signal.renderReferencedBindings) {
|
|
2678
2679
|
signal.render.unshift(
|
|
2679
|
-
|
|
2680
|
-
|
|
2680
|
+
import_compiler19.types.variableDeclaration("const", [
|
|
2681
|
+
import_compiler19.types.variableDeclarator(
|
|
2681
2682
|
createScopeReadPattern(section, signal.renderReferencedBindings),
|
|
2682
2683
|
scopeIdentifier
|
|
2683
2684
|
)
|
|
@@ -2706,7 +2707,7 @@ function getSignalFn(signal) {
|
|
|
2706
2707
|
}
|
|
2707
2708
|
}
|
|
2708
2709
|
}
|
|
2709
|
-
return
|
|
2710
|
+
return import_compiler19.types.arrowFunctionExpression(params, import_compiler19.types.blockStatement(signal.render));
|
|
2710
2711
|
}
|
|
2711
2712
|
var hasTranslatedExtraArgs = /* @__PURE__ */ new WeakSet();
|
|
2712
2713
|
var emptyExtraArgs = [];
|
|
@@ -2751,19 +2752,19 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
|
|
|
2751
2752
|
for (let i = args.length; i--; ) {
|
|
2752
2753
|
const arg = args[i];
|
|
2753
2754
|
if (!arg) {
|
|
2754
|
-
args[i] =
|
|
2755
|
-
} else if (
|
|
2755
|
+
args[i] = import_compiler19.types.numericLiteral(0);
|
|
2756
|
+
} else if (import_compiler19.types.isArrowFunctionExpression(arg) && import_compiler19.types.isBlockStatement(arg.body)) {
|
|
2756
2757
|
const body = arg.body.body;
|
|
2757
2758
|
if (body.length === 0) {
|
|
2758
|
-
args[i] =
|
|
2759
|
-
} else if (body.length === 1 &&
|
|
2759
|
+
args[i] = import_compiler19.types.numericLiteral(0);
|
|
2760
|
+
} else if (body.length === 1 && import_compiler19.types.isExpressionStatement(body[0])) {
|
|
2760
2761
|
arg.body = toParenthesizedExpressionIfNeeded(body[0].expression);
|
|
2761
2762
|
}
|
|
2762
|
-
} else if (
|
|
2763
|
-
args[i] =
|
|
2763
|
+
} else if (import_compiler19.types.isNullLiteral(arg) || import_compiler19.types.isUnaryExpression(arg) && arg.operator === "void") {
|
|
2764
|
+
args[i] = import_compiler19.types.numericLiteral(0);
|
|
2764
2765
|
}
|
|
2765
2766
|
}
|
|
2766
|
-
for (let i = args.length - 1;
|
|
2767
|
+
for (let i = args.length - 1; import_compiler19.types.isNumericLiteral(args[i]) && args[i].value === 0; ) {
|
|
2767
2768
|
args.length = i--;
|
|
2768
2769
|
}
|
|
2769
2770
|
return args;
|
|
@@ -2812,7 +2813,7 @@ function getResumeRegisterId(section, referencedBindings, type) {
|
|
|
2812
2813
|
const {
|
|
2813
2814
|
markoOpts,
|
|
2814
2815
|
opts: { filename }
|
|
2815
|
-
} = (0,
|
|
2816
|
+
} = (0, import_babel_utils12.getFile)();
|
|
2816
2817
|
let name2 = "";
|
|
2817
2818
|
if (referencedBindings) {
|
|
2818
2819
|
if (typeof referencedBindings === "string") {
|
|
@@ -2825,7 +2826,7 @@ function getResumeRegisterId(section, referencedBindings, type) {
|
|
|
2825
2826
|
name2 += `_${referencedBindings.name}`;
|
|
2826
2827
|
}
|
|
2827
2828
|
}
|
|
2828
|
-
return (0,
|
|
2829
|
+
return (0, import_babel_utils12.getTemplateId)(
|
|
2829
2830
|
markoOpts,
|
|
2830
2831
|
filename,
|
|
2831
2832
|
`${section.id}${name2}${type ? "/" + type : ""}`
|
|
@@ -2836,10 +2837,10 @@ function getRegisterUID(section, name2) {
|
|
|
2836
2837
|
const {
|
|
2837
2838
|
markoOpts,
|
|
2838
2839
|
opts: { filename }
|
|
2839
|
-
} = (0,
|
|
2840
|
+
} = (0, import_babel_utils12.getFile)();
|
|
2840
2841
|
let used = usedRegisterIdsBySection.get(section);
|
|
2841
2842
|
if (!used) usedRegisterIdsBySection.set(section, used = /* @__PURE__ */ new Set());
|
|
2842
|
-
const baseId = (0,
|
|
2843
|
+
const baseId = (0, import_babel_utils12.getTemplateId)(
|
|
2843
2844
|
markoOpts,
|
|
2844
2845
|
filename,
|
|
2845
2846
|
`${section.id}/${name2}`
|
|
@@ -2856,7 +2857,7 @@ function writeSignals(section) {
|
|
|
2856
2857
|
forEach(section.hoisted, (binding) => {
|
|
2857
2858
|
for (const hoistedBinding of binding.hoists.values()) {
|
|
2858
2859
|
const accessors = [
|
|
2859
|
-
binding.type === 0 /* dom */ ?
|
|
2860
|
+
binding.type === 0 /* dom */ ? import_compiler19.types.stringLiteral(
|
|
2860
2861
|
getAccessorPrefix().Getter + getScopeAccessor(binding)
|
|
2861
2862
|
) : getScopeAccessorLiteral(binding)
|
|
2862
2863
|
];
|
|
@@ -2869,13 +2870,13 @@ function writeSignals(section) {
|
|
|
2869
2870
|
currentSection = parentSection;
|
|
2870
2871
|
}
|
|
2871
2872
|
const hoistIdentifier = getHoistFunctionIdentifier(hoistedBinding);
|
|
2872
|
-
(0,
|
|
2873
|
-
|
|
2874
|
-
|
|
2873
|
+
(0, import_babel_utils12.getProgram)().node.body.push(
|
|
2874
|
+
import_compiler19.types.variableDeclaration("const", [
|
|
2875
|
+
import_compiler19.types.variableDeclarator(
|
|
2875
2876
|
hoistIdentifier,
|
|
2876
2877
|
hoistedBinding.downstreamExpressions.size ? callRuntime(
|
|
2877
2878
|
"register",
|
|
2878
|
-
|
|
2879
|
+
import_compiler19.types.stringLiteral(
|
|
2879
2880
|
getResumeRegisterId(
|
|
2880
2881
|
hoistedBinding.section,
|
|
2881
2882
|
hoistedBinding,
|
|
@@ -2892,7 +2893,7 @@ function writeSignals(section) {
|
|
|
2892
2893
|
hoistedBinding.section,
|
|
2893
2894
|
void 0,
|
|
2894
2895
|
initValue(hoistedBinding),
|
|
2895
|
-
|
|
2896
|
+
import_compiler19.types.callExpression(hoistIdentifier, [scopeIdentifier])
|
|
2896
2897
|
);
|
|
2897
2898
|
}
|
|
2898
2899
|
}
|
|
@@ -2906,20 +2907,20 @@ function writeSignals(section) {
|
|
|
2906
2907
|
let effectDeclarator;
|
|
2907
2908
|
if (signal.effect.length) {
|
|
2908
2909
|
traverseReplace(signal, "effect", replaceEffectNode);
|
|
2909
|
-
const effectIdentifier =
|
|
2910
|
+
const effectIdentifier = import_compiler19.types.identifier(`${signal.identifier.name}_effect`);
|
|
2910
2911
|
const referencedBindings = signal.effectReferencedBindings;
|
|
2911
2912
|
const referencesScope = traverseContains(
|
|
2912
2913
|
signal.effect,
|
|
2913
2914
|
isScopeIdentifier
|
|
2914
2915
|
);
|
|
2915
|
-
effectDeclarator =
|
|
2916
|
+
effectDeclarator = import_compiler19.types.variableDeclarator(
|
|
2916
2917
|
effectIdentifier,
|
|
2917
2918
|
callRuntime(
|
|
2918
2919
|
"effect",
|
|
2919
|
-
|
|
2920
|
+
import_compiler19.types.stringLiteral(
|
|
2920
2921
|
getResumeRegisterId(section, signal.referencedBindings)
|
|
2921
2922
|
),
|
|
2922
|
-
|
|
2923
|
+
import_compiler19.types.arrowFunctionExpression(
|
|
2923
2924
|
referencedBindings ? referencesScope ? [
|
|
2924
2925
|
scopeIdentifier,
|
|
2925
2926
|
createScopeReadPattern(section, referencedBindings)
|
|
@@ -2930,44 +2931,44 @@ function writeSignals(section) {
|
|
|
2930
2931
|
);
|
|
2931
2932
|
}
|
|
2932
2933
|
let value = signal.build();
|
|
2933
|
-
if (
|
|
2934
|
+
if (import_compiler19.types.isCallExpression(value)) {
|
|
2934
2935
|
replaceNullishAndEmptyFunctionsWith0(value.arguments);
|
|
2935
2936
|
}
|
|
2936
2937
|
if (signal.register) {
|
|
2937
2938
|
value = callRuntime(
|
|
2938
2939
|
"registerBoundSignal",
|
|
2939
|
-
|
|
2940
|
+
import_compiler19.types.stringLiteral(
|
|
2940
2941
|
getResumeRegisterId(section, signal.referencedBindings, "var")
|
|
2941
2942
|
),
|
|
2942
2943
|
value
|
|
2943
2944
|
);
|
|
2944
2945
|
}
|
|
2945
|
-
const signalDeclarator =
|
|
2946
|
-
let signalDeclaration = !section.parent && !signal.referencedBindings && (
|
|
2946
|
+
const signalDeclarator = import_compiler19.types.variableDeclarator(signal.identifier, value);
|
|
2947
|
+
let signalDeclaration = !section.parent && !signal.referencedBindings && (import_compiler19.types.isFunctionExpression(value) || import_compiler19.types.isArrowFunctionExpression(value)) ? import_compiler19.types.functionDeclaration(
|
|
2947
2948
|
signal.identifier,
|
|
2948
2949
|
value.params,
|
|
2949
|
-
|
|
2950
|
-
) :
|
|
2950
|
+
import_compiler19.types.isExpression(value.body) ? import_compiler19.types.blockStatement([import_compiler19.types.expressionStatement(value.body)]) : value.body
|
|
2951
|
+
) : import_compiler19.types.variableDeclaration("const", [signalDeclarator]);
|
|
2951
2952
|
if (signal.export) {
|
|
2952
|
-
signalDeclaration =
|
|
2953
|
+
signalDeclaration = import_compiler19.types.exportNamedDeclaration(signalDeclaration);
|
|
2953
2954
|
}
|
|
2954
2955
|
const signalStatements = signal.prependStatements || [];
|
|
2955
2956
|
if (effectDeclarator) {
|
|
2956
|
-
signalStatements.push(
|
|
2957
|
+
signalStatements.push(import_compiler19.types.variableDeclaration("const", [effectDeclarator]));
|
|
2957
2958
|
}
|
|
2958
2959
|
signalStatements.push(signalDeclaration);
|
|
2959
|
-
(0,
|
|
2960
|
+
(0, import_babel_utils12.getProgram)().node.body.push(...signalStatements);
|
|
2960
2961
|
}
|
|
2961
2962
|
}
|
|
2962
2963
|
function writeRegisteredFns() {
|
|
2963
|
-
const registeredFns = registeredFnsForProgram.get((0,
|
|
2964
|
+
const registeredFns = registeredFnsForProgram.get((0, import_babel_utils12.getProgram)().node);
|
|
2964
2965
|
const statements = [];
|
|
2965
2966
|
if (registeredFns) {
|
|
2966
2967
|
for (const registeredFn of registeredFns) {
|
|
2967
2968
|
let fn;
|
|
2968
2969
|
const params = registeredFn.referencedBindings ? registeredFn.referencesScope ? [
|
|
2969
2970
|
scopeIdentifier,
|
|
2970
|
-
|
|
2971
|
+
import_compiler19.types.assignmentPattern(
|
|
2971
2972
|
createScopeReadPattern(
|
|
2972
2973
|
registeredFn.section,
|
|
2973
2974
|
registeredFn.referencedBindings
|
|
@@ -2981,18 +2982,18 @@ function writeRegisteredFns() {
|
|
|
2981
2982
|
)
|
|
2982
2983
|
] : registeredFn.referencesScope ? [scopeIdentifier] : void 0;
|
|
2983
2984
|
if (params) {
|
|
2984
|
-
fn =
|
|
2985
|
-
|
|
2985
|
+
fn = import_compiler19.types.functionDeclaration(
|
|
2986
|
+
import_compiler19.types.identifier(registeredFn.id),
|
|
2986
2987
|
params,
|
|
2987
|
-
|
|
2988
|
+
import_compiler19.types.blockStatement(toReturnedFunction(registeredFn.node))
|
|
2988
2989
|
);
|
|
2989
2990
|
} else if (registeredFn.node.type === "FunctionDeclaration" && registeredFn.node.id?.name === registeredFn.id) {
|
|
2990
2991
|
fn = registeredFn.node;
|
|
2991
2992
|
} else {
|
|
2992
|
-
fn =
|
|
2993
|
-
|
|
2993
|
+
fn = import_compiler19.types.functionDeclaration(
|
|
2994
|
+
import_compiler19.types.identifier(registeredFn.id),
|
|
2994
2995
|
registeredFn.node.params,
|
|
2995
|
-
registeredFn.node.body.type === "BlockStatement" ? registeredFn.node.body :
|
|
2996
|
+
registeredFn.node.body.type === "BlockStatement" ? registeredFn.node.body : import_compiler19.types.blockStatement([import_compiler19.types.returnStatement(registeredFn.node.body)]),
|
|
2996
2997
|
registeredFn.node.generator,
|
|
2997
2998
|
registeredFn.node.async
|
|
2998
2999
|
);
|
|
@@ -3001,21 +3002,21 @@ function writeRegisteredFns() {
|
|
|
3001
3002
|
}
|
|
3002
3003
|
for (const registeredFn of registeredFns) {
|
|
3003
3004
|
statements.push(
|
|
3004
|
-
|
|
3005
|
+
import_compiler19.types.expressionStatement(
|
|
3005
3006
|
callRuntime(
|
|
3006
3007
|
"register",
|
|
3007
|
-
|
|
3008
|
-
|
|
3008
|
+
import_compiler19.types.stringLiteral(registeredFn.registerId),
|
|
3009
|
+
import_compiler19.types.identifier(registeredFn.id)
|
|
3009
3010
|
)
|
|
3010
3011
|
)
|
|
3011
3012
|
);
|
|
3012
3013
|
}
|
|
3013
|
-
(0,
|
|
3014
|
+
(0, import_babel_utils12.getProgram)().node.body.push(...statements);
|
|
3014
3015
|
}
|
|
3015
3016
|
}
|
|
3016
3017
|
function toReturnedFunction(rawFn) {
|
|
3017
3018
|
const fn = simplifyFunction(rawFn);
|
|
3018
|
-
return fn.type === "FunctionDeclaration" ? [fn,
|
|
3019
|
+
return fn.type === "FunctionDeclaration" ? [fn, import_compiler19.types.returnStatement(fn.id)] : [import_compiler19.types.returnStatement(fn)];
|
|
3019
3020
|
}
|
|
3020
3021
|
function sortSignals(a, b) {
|
|
3021
3022
|
const aReferencedBindings = getReferencedBindings(a);
|
|
@@ -3066,10 +3067,10 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3066
3067
|
)
|
|
3067
3068
|
);
|
|
3068
3069
|
getHTMLSectionStatements(closure.section).push(
|
|
3069
|
-
|
|
3070
|
-
|
|
3070
|
+
import_compiler19.types.variableDeclaration("const", [
|
|
3071
|
+
import_compiler19.types.variableDeclarator(
|
|
3071
3072
|
identifier,
|
|
3072
|
-
|
|
3073
|
+
import_compiler19.types.newExpression(import_compiler19.types.identifier("Set"), [])
|
|
3073
3074
|
)
|
|
3074
3075
|
])
|
|
3075
3076
|
);
|
|
@@ -3083,7 +3084,7 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3083
3084
|
setSerializedProperty(
|
|
3084
3085
|
section,
|
|
3085
3086
|
getAccessorPrefix().ClosureSignalIndex + getScopeAccessor(closure),
|
|
3086
|
-
|
|
3087
|
+
import_compiler19.types.numericLiteral(getDynamicClosureIndex(closure, section)),
|
|
3087
3088
|
serializeReason
|
|
3088
3089
|
);
|
|
3089
3090
|
addWriteScopeBuilder(
|
|
@@ -3098,13 +3099,13 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3098
3099
|
for (const hoistedBinding of binding.hoists.values()) {
|
|
3099
3100
|
if (hoistedBinding.downstreamExpressions.size) {
|
|
3100
3101
|
getHTMLSectionStatements(hoistedBinding.section).push(
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3102
|
+
import_compiler19.types.variableDeclaration("const", [
|
|
3103
|
+
import_compiler19.types.variableDeclarator(
|
|
3104
|
+
import_compiler19.types.identifier(hoistedBinding.name),
|
|
3104
3105
|
callRuntime(
|
|
3105
3106
|
"hoist",
|
|
3106
3107
|
getScopeIdIdentifier(hoistedBinding.section),
|
|
3107
|
-
|
|
3108
|
+
import_compiler19.types.stringLiteral(
|
|
3108
3109
|
getResumeRegisterId(
|
|
3109
3110
|
hoistedBinding.section,
|
|
3110
3111
|
hoistedBinding,
|
|
@@ -3125,10 +3126,10 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3125
3126
|
);
|
|
3126
3127
|
sectionDynamicSubscribers.add(currentSection);
|
|
3127
3128
|
getHTMLSectionStatements(parentSection).push(
|
|
3128
|
-
|
|
3129
|
-
|
|
3129
|
+
import_compiler19.types.variableDeclaration("const", [
|
|
3130
|
+
import_compiler19.types.variableDeclarator(
|
|
3130
3131
|
subscribersIdentifier,
|
|
3131
|
-
|
|
3132
|
+
import_compiler19.types.newExpression(import_compiler19.types.identifier("Set"), [])
|
|
3132
3133
|
)
|
|
3133
3134
|
])
|
|
3134
3135
|
);
|
|
@@ -3159,11 +3160,11 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3159
3160
|
if (allSignals[i].effect.length) {
|
|
3160
3161
|
const signalRefs = allSignals[i].referencedBindings;
|
|
3161
3162
|
body.push(
|
|
3162
|
-
|
|
3163
|
+
import_compiler19.types.expressionStatement(
|
|
3163
3164
|
callRuntime(
|
|
3164
3165
|
"writeEffect",
|
|
3165
3166
|
scopeIdIdentifier,
|
|
3166
|
-
|
|
3167
|
+
import_compiler19.types.stringLiteral(getResumeRegisterId(section, signalRefs))
|
|
3167
3168
|
)
|
|
3168
3169
|
)
|
|
3169
3170
|
);
|
|
@@ -3193,7 +3194,7 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3193
3194
|
}
|
|
3194
3195
|
const writeScopeArgs = [
|
|
3195
3196
|
scopeIdIdentifier,
|
|
3196
|
-
|
|
3197
|
+
import_compiler19.types.objectExpression(serializedProperties)
|
|
3197
3198
|
];
|
|
3198
3199
|
if (!isOptimize()) {
|
|
3199
3200
|
let debugVars;
|
|
@@ -3207,30 +3208,30 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3207
3208
|
}
|
|
3208
3209
|
root = root.upstreamAlias;
|
|
3209
3210
|
}
|
|
3210
|
-
const locExpr = root.loc &&
|
|
3211
|
+
const locExpr = root.loc && import_compiler19.types.stringLiteral(
|
|
3211
3212
|
`${root.loc.start.line}:${root.loc.start.column + 1}`
|
|
3212
3213
|
);
|
|
3213
3214
|
(debugVars ||= []).push(
|
|
3214
3215
|
toObjectProperty(
|
|
3215
3216
|
getScopeAccessor(binding),
|
|
3216
|
-
root !== binding ?
|
|
3217
|
-
locExpr ? [
|
|
3218
|
-
) : locExpr ||
|
|
3217
|
+
root !== binding ? import_compiler19.types.arrayExpression(
|
|
3218
|
+
locExpr ? [import_compiler19.types.stringLiteral(root.name + access), locExpr] : [import_compiler19.types.stringLiteral(root.name + access)]
|
|
3219
|
+
) : locExpr || import_compiler19.types.numericLiteral(0)
|
|
3219
3220
|
)
|
|
3220
3221
|
);
|
|
3221
3222
|
});
|
|
3222
3223
|
writeScopeArgs.push(
|
|
3223
|
-
|
|
3224
|
-
section.loc && section.loc.start.line != null ?
|
|
3224
|
+
import_compiler19.types.stringLiteral(path5.hub.file.opts.filenameRelative),
|
|
3225
|
+
section.loc && section.loc.start.line != null ? import_compiler19.types.stringLiteral(
|
|
3225
3226
|
`${section.loc.start.line}:${section.loc.start.column + 1}`
|
|
3226
|
-
) :
|
|
3227
|
+
) : import_compiler19.types.numericLiteral(0)
|
|
3227
3228
|
);
|
|
3228
3229
|
if (debugVars) {
|
|
3229
|
-
writeScopeArgs.push(
|
|
3230
|
+
writeScopeArgs.push(import_compiler19.types.objectExpression(debugVars));
|
|
3230
3231
|
}
|
|
3231
3232
|
}
|
|
3232
3233
|
body.push(
|
|
3233
|
-
|
|
3234
|
+
import_compiler19.types.expressionStatement(
|
|
3234
3235
|
writeScopeBuilder ? writeScopeBuilder(callRuntime("writeScope", ...writeScopeArgs)) : callRuntime("writeScope", ...writeScopeArgs)
|
|
3235
3236
|
)
|
|
3236
3237
|
);
|
|
@@ -3238,7 +3239,7 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3238
3239
|
const resumeClosestBranch2 = !section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || !!find(section.bindings, (binding) => binding.type === 1 /* let */));
|
|
3239
3240
|
if (resumeClosestBranch2) {
|
|
3240
3241
|
body.push(
|
|
3241
|
-
|
|
3242
|
+
import_compiler19.types.expressionStatement(
|
|
3242
3243
|
callRuntime("resumeClosestBranch", scopeIdIdentifier)
|
|
3243
3244
|
)
|
|
3244
3245
|
);
|
|
@@ -3246,15 +3247,15 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3246
3247
|
const additionalStatements = getHTMLSectionStatements(section);
|
|
3247
3248
|
if (body.length || additionalStatements.length) {
|
|
3248
3249
|
body.unshift(
|
|
3249
|
-
|
|
3250
|
-
|
|
3250
|
+
import_compiler19.types.variableDeclaration("const", [
|
|
3251
|
+
import_compiler19.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
|
|
3251
3252
|
]),
|
|
3252
3253
|
...additionalStatements
|
|
3253
3254
|
);
|
|
3254
3255
|
}
|
|
3255
3256
|
const returnIdentifier = getSectionReturnValueIdentifier(section);
|
|
3256
3257
|
if (returnIdentifier !== void 0) {
|
|
3257
|
-
body.push(
|
|
3258
|
+
body.push(import_compiler19.types.returnStatement(returnIdentifier));
|
|
3258
3259
|
}
|
|
3259
3260
|
}
|
|
3260
3261
|
function serializeOwners(from, to) {
|
|
@@ -3301,14 +3302,14 @@ function replaceAssignedNode(node) {
|
|
|
3301
3302
|
if (buildAssignment) {
|
|
3302
3303
|
const replacement = buildAssignment(
|
|
3303
3304
|
extra.section,
|
|
3304
|
-
|
|
3305
|
+
import_compiler19.types.binaryExpression(
|
|
3305
3306
|
node.operator === "++" ? "+" : "-",
|
|
3306
3307
|
node.argument,
|
|
3307
|
-
|
|
3308
|
+
import_compiler19.types.numericLiteral(1)
|
|
3308
3309
|
)
|
|
3309
3310
|
);
|
|
3310
3311
|
if (!node.prefix) {
|
|
3311
|
-
return
|
|
3312
|
+
return import_compiler19.types.sequenceExpression([replacement, node.argument]);
|
|
3312
3313
|
}
|
|
3313
3314
|
return replacement;
|
|
3314
3315
|
}
|
|
@@ -3327,7 +3328,7 @@ function replaceAssignedNode(node) {
|
|
|
3327
3328
|
if (buildAssignment) {
|
|
3328
3329
|
return buildAssignment(
|
|
3329
3330
|
extra.section,
|
|
3330
|
-
node.operator === "=" ? node.right :
|
|
3331
|
+
node.operator === "=" ? node.right : import_compiler19.types.binaryExpression(
|
|
3331
3332
|
node.operator.slice(
|
|
3332
3333
|
0,
|
|
3333
3334
|
-1
|
|
@@ -3353,26 +3354,26 @@ function replaceAssignedNode(node) {
|
|
|
3353
3354
|
);
|
|
3354
3355
|
if (signal?.buildAssignment) {
|
|
3355
3356
|
id.name = generateUid(id.name);
|
|
3356
|
-
(params ||= []).push(
|
|
3357
|
+
(params ||= []).push(import_compiler19.types.identifier(id.name));
|
|
3357
3358
|
(assignments ||= []).push(
|
|
3358
|
-
signal.buildAssignment(extra.section,
|
|
3359
|
+
signal.buildAssignment(extra.section, import_compiler19.types.identifier(id.name))
|
|
3359
3360
|
);
|
|
3360
3361
|
}
|
|
3361
3362
|
}
|
|
3362
3363
|
});
|
|
3363
3364
|
if (params && assignments) {
|
|
3364
3365
|
const resultId = generateUid("result");
|
|
3365
|
-
return
|
|
3366
|
-
|
|
3367
|
-
[
|
|
3368
|
-
|
|
3369
|
-
|
|
3366
|
+
return import_compiler19.types.callExpression(
|
|
3367
|
+
import_compiler19.types.arrowFunctionExpression(
|
|
3368
|
+
[import_compiler19.types.identifier(resultId), ...params],
|
|
3369
|
+
import_compiler19.types.sequenceExpression([
|
|
3370
|
+
import_compiler19.types.assignmentExpression(
|
|
3370
3371
|
"=",
|
|
3371
3372
|
node.left,
|
|
3372
|
-
|
|
3373
|
+
import_compiler19.types.identifier(resultId)
|
|
3373
3374
|
),
|
|
3374
3375
|
...assignments,
|
|
3375
|
-
|
|
3376
|
+
import_compiler19.types.identifier(resultId)
|
|
3376
3377
|
])
|
|
3377
3378
|
),
|
|
3378
3379
|
[node.right]
|
|
@@ -3389,15 +3390,15 @@ function replaceRegisteredFunctionNode(node) {
|
|
|
3389
3390
|
switch (node.type) {
|
|
3390
3391
|
case "ClassMethod": {
|
|
3391
3392
|
const replacement = getRegisteredFnExpression(node);
|
|
3392
|
-
return replacement &&
|
|
3393
|
+
return replacement && import_compiler19.types.classProperty(node.key, replacement);
|
|
3393
3394
|
}
|
|
3394
3395
|
case "ClassPrivateMethod": {
|
|
3395
3396
|
const replacement = getRegisteredFnExpression(node);
|
|
3396
|
-
return replacement &&
|
|
3397
|
+
return replacement && import_compiler19.types.classPrivateProperty(node.key, replacement);
|
|
3397
3398
|
}
|
|
3398
3399
|
case "ObjectMethod": {
|
|
3399
3400
|
const replacement = getRegisteredFnExpression(node);
|
|
3400
|
-
return replacement &&
|
|
3401
|
+
return replacement && import_compiler19.types.objectProperty(node.key, replacement);
|
|
3401
3402
|
}
|
|
3402
3403
|
case "ArrowFunctionExpression":
|
|
3403
3404
|
case "FunctionExpression": {
|
|
@@ -3406,8 +3407,8 @@ function replaceRegisteredFunctionNode(node) {
|
|
|
3406
3407
|
case "FunctionDeclaration": {
|
|
3407
3408
|
const replacement = getRegisteredFnExpression(node);
|
|
3408
3409
|
if (replacement) {
|
|
3409
|
-
return
|
|
3410
|
-
|
|
3410
|
+
return import_compiler19.types.variableDeclaration("const", [
|
|
3411
|
+
import_compiler19.types.variableDeclarator(node.id, replacement)
|
|
3411
3412
|
]);
|
|
3412
3413
|
}
|
|
3413
3414
|
break;
|
|
@@ -3420,9 +3421,9 @@ function getRegisteredFnExpression(node) {
|
|
|
3420
3421
|
const id = generateUid(extra.name);
|
|
3421
3422
|
const referencesScope = extra.referencesScope;
|
|
3422
3423
|
const referencedBindings = extra.referencedBindingsInFunction;
|
|
3423
|
-
let registedFns = registeredFnsForProgram.get((0,
|
|
3424
|
+
let registedFns = registeredFnsForProgram.get((0, import_babel_utils12.getProgram)().node);
|
|
3424
3425
|
if (!registedFns) {
|
|
3425
|
-
registeredFnsForProgram.set((0,
|
|
3426
|
+
registeredFnsForProgram.set((0, import_babel_utils12.getProgram)().node, registedFns = []);
|
|
3426
3427
|
}
|
|
3427
3428
|
registedFns.push({
|
|
3428
3429
|
id,
|
|
@@ -3433,9 +3434,9 @@ function getRegisteredFnExpression(node) {
|
|
|
3433
3434
|
referencedBindings
|
|
3434
3435
|
});
|
|
3435
3436
|
if (referencesScope || referencedBindings) {
|
|
3436
|
-
return
|
|
3437
|
+
return import_compiler19.types.callExpression(import_compiler19.types.identifier(id), [scopeIdentifier]);
|
|
3437
3438
|
} else {
|
|
3438
|
-
return
|
|
3439
|
+
return import_compiler19.types.identifier(id);
|
|
3439
3440
|
}
|
|
3440
3441
|
}
|
|
3441
3442
|
}
|
|
@@ -3459,30 +3460,30 @@ var dom_default = {
|
|
|
3459
3460
|
const section = getSectionForBody(program);
|
|
3460
3461
|
const { walks, writes, setup } = getSectionMeta(section);
|
|
3461
3462
|
const domExports = program.node.extra.domExports;
|
|
3462
|
-
const templateIdentifier =
|
|
3463
|
-
const walksIdentifier =
|
|
3464
|
-
const setupIdentifier =
|
|
3463
|
+
const templateIdentifier = import_compiler20.types.identifier(domExports.template);
|
|
3464
|
+
const walksIdentifier = import_compiler20.types.identifier(domExports.walks);
|
|
3465
|
+
const setupIdentifier = import_compiler20.types.identifier(domExports.setup);
|
|
3465
3466
|
const inputBinding = program.node.params[0].extra?.binding;
|
|
3466
3467
|
const programInputSignal = inputBinding && bindingHasDownstreamExpressions(inputBinding) ? initValue(inputBinding) : void 0;
|
|
3467
3468
|
const styleFile = getStyleFile(program.hub.file);
|
|
3468
3469
|
if (styleFile) {
|
|
3469
|
-
(0,
|
|
3470
|
+
(0, import_babel_utils13.importDefault)(program.hub.file, styleFile);
|
|
3470
3471
|
}
|
|
3471
3472
|
forEachSectionReverse((childSection) => {
|
|
3472
3473
|
if (childSection !== section) {
|
|
3473
3474
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
|
3474
3475
|
const { walks: walks2, writes: writes2, setup: setup2 } = getSectionMeta(childSection);
|
|
3475
|
-
const identifier =
|
|
3476
|
-
const referencedClosures = childSection.referencedClosures ?
|
|
3476
|
+
const identifier = import_compiler20.types.identifier(childSection.name);
|
|
3477
|
+
const referencedClosures = childSection.referencedClosures ? import_compiler20.types.arrowFunctionExpression(
|
|
3477
3478
|
[scopeIdentifier],
|
|
3478
3479
|
toFirstExpressionOrBlock(
|
|
3479
3480
|
map(childSection.referencedClosures, (closure) => {
|
|
3480
3481
|
const closureSignal = getSignal(childSection, closure);
|
|
3481
|
-
return
|
|
3482
|
-
|
|
3483
|
-
isDynamicClosure(childSection, closure) ? closureSignal.identifier :
|
|
3482
|
+
return import_compiler20.types.expressionStatement(
|
|
3483
|
+
import_compiler20.types.callExpression(
|
|
3484
|
+
isDynamicClosure(childSection, closure) ? closureSignal.identifier : import_compiler20.types.memberExpression(
|
|
3484
3485
|
closureSignal.identifier,
|
|
3485
|
-
|
|
3486
|
+
import_compiler20.types.identifier("_")
|
|
3486
3487
|
),
|
|
3487
3488
|
[scopeIdentifier]
|
|
3488
3489
|
)
|
|
@@ -3501,7 +3502,7 @@ var dom_default = {
|
|
|
3501
3502
|
])
|
|
3502
3503
|
) : callRuntime(
|
|
3503
3504
|
isSerializedSection(childSection) ? "registerContent" : "createContent",
|
|
3504
|
-
|
|
3505
|
+
import_compiler20.types.stringLiteral(getResumeRegisterId(childSection, "renderer")),
|
|
3505
3506
|
...replaceNullishAndEmptyFunctionsWith0([
|
|
3506
3507
|
writes2,
|
|
3507
3508
|
walks2,
|
|
@@ -3513,8 +3514,8 @@ var dom_default = {
|
|
|
3513
3514
|
);
|
|
3514
3515
|
writeSignals(childSection);
|
|
3515
3516
|
program.node.body.push(
|
|
3516
|
-
|
|
3517
|
-
|
|
3517
|
+
import_compiler20.types.variableDeclaration("const", [
|
|
3518
|
+
import_compiler20.types.variableDeclarator(identifier, renderer)
|
|
3518
3519
|
])
|
|
3519
3520
|
);
|
|
3520
3521
|
}
|
|
@@ -3523,36 +3524,36 @@ var dom_default = {
|
|
|
3523
3524
|
writeRegisteredFns();
|
|
3524
3525
|
if (!setup) {
|
|
3525
3526
|
program.node.body.unshift(
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3527
|
+
import_compiler20.types.exportNamedDeclaration(
|
|
3528
|
+
import_compiler20.types.variableDeclaration("const", [
|
|
3529
|
+
import_compiler20.types.variableDeclarator(
|
|
3529
3530
|
setupIdentifier,
|
|
3530
|
-
|
|
3531
|
+
import_compiler20.types.arrowFunctionExpression([], import_compiler20.types.blockStatement([]))
|
|
3531
3532
|
)
|
|
3532
3533
|
])
|
|
3533
3534
|
)
|
|
3534
3535
|
);
|
|
3535
3536
|
}
|
|
3536
3537
|
program.node.body.unshift(
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3538
|
+
import_compiler20.types.exportNamedDeclaration(
|
|
3539
|
+
import_compiler20.types.variableDeclaration("const", [
|
|
3540
|
+
import_compiler20.types.variableDeclarator(
|
|
3540
3541
|
templateIdentifier,
|
|
3541
|
-
writes ||
|
|
3542
|
+
writes || import_compiler20.types.stringLiteral("")
|
|
3542
3543
|
)
|
|
3543
3544
|
])
|
|
3544
3545
|
),
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3546
|
+
import_compiler20.types.exportNamedDeclaration(
|
|
3547
|
+
import_compiler20.types.variableDeclaration("const", [
|
|
3548
|
+
import_compiler20.types.variableDeclarator(walksIdentifier, walks || import_compiler20.types.stringLiteral(""))
|
|
3548
3549
|
])
|
|
3549
3550
|
)
|
|
3550
3551
|
);
|
|
3551
3552
|
program.node.body.push(
|
|
3552
|
-
|
|
3553
|
+
import_compiler20.types.exportDefaultDeclaration(
|
|
3553
3554
|
callRuntime(
|
|
3554
3555
|
"createTemplate",
|
|
3555
|
-
|
|
3556
|
+
import_compiler20.types.stringLiteral(program.hub.file.metadata.marko.id),
|
|
3556
3557
|
templateIdentifier,
|
|
3557
3558
|
walksIdentifier,
|
|
3558
3559
|
setupIdentifier,
|
|
@@ -3565,7 +3566,8 @@ var dom_default = {
|
|
|
3565
3566
|
};
|
|
3566
3567
|
|
|
3567
3568
|
// src/translator/visitors/program/html.ts
|
|
3568
|
-
var
|
|
3569
|
+
var import_compiler21 = require("@marko/compiler");
|
|
3570
|
+
var import_babel_utils14 = require("@marko/compiler/babel-utils");
|
|
3569
3571
|
|
|
3570
3572
|
// src/translator/util/is-static.ts
|
|
3571
3573
|
function isStatic(path5) {
|
|
@@ -3575,10 +3577,10 @@ function isStatic(path5) {
|
|
|
3575
3577
|
// src/translator/visitors/program/html.ts
|
|
3576
3578
|
var templateContentIdentifierForProgram = /* @__PURE__ */ new WeakMap();
|
|
3577
3579
|
function getTemplateContentName() {
|
|
3578
|
-
let name2 = templateContentIdentifierForProgram.get((0,
|
|
3580
|
+
let name2 = templateContentIdentifierForProgram.get((0, import_babel_utils14.getProgram)());
|
|
3579
3581
|
if (!name2) {
|
|
3580
3582
|
templateContentIdentifierForProgram.set(
|
|
3581
|
-
(0,
|
|
3583
|
+
(0, import_babel_utils14.getProgram)(),
|
|
3582
3584
|
name2 = generateUid("content")
|
|
3583
3585
|
);
|
|
3584
3586
|
}
|
|
@@ -3604,21 +3606,21 @@ var html_default = {
|
|
|
3604
3606
|
}
|
|
3605
3607
|
}
|
|
3606
3608
|
const contentId = templateContentIdentifierForProgram.get(program);
|
|
3607
|
-
const contentFn =
|
|
3608
|
-
[
|
|
3609
|
-
|
|
3609
|
+
const contentFn = import_compiler21.types.arrowFunctionExpression(
|
|
3610
|
+
[import_compiler21.types.identifier("input")],
|
|
3611
|
+
import_compiler21.types.blockStatement(renderContent)
|
|
3610
3612
|
);
|
|
3611
|
-
const exportDefault =
|
|
3613
|
+
const exportDefault = import_compiler21.types.exportDefaultDeclaration(
|
|
3612
3614
|
callRuntime(
|
|
3613
3615
|
"createTemplate",
|
|
3614
|
-
|
|
3615
|
-
contentId ?
|
|
3616
|
+
import_compiler21.types.stringLiteral(program.hub.file.metadata.marko.id),
|
|
3617
|
+
contentId ? import_compiler21.types.identifier(contentId) : contentFn
|
|
3616
3618
|
)
|
|
3617
3619
|
);
|
|
3618
3620
|
if (contentId) {
|
|
3619
3621
|
program.node.body.push(
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
+
import_compiler21.types.variableDeclaration("const", [
|
|
3623
|
+
import_compiler21.types.variableDeclarator(import_compiler21.types.identifier(contentId), contentFn)
|
|
3622
3624
|
]),
|
|
3623
3625
|
exportDefault
|
|
3624
3626
|
);
|
|
@@ -3646,15 +3648,15 @@ function replaceRegisteredFunctionNode2(node, container) {
|
|
|
3646
3648
|
switch (node.type) {
|
|
3647
3649
|
case "ClassMethod": {
|
|
3648
3650
|
const replacement = getRegisteredFnExpression2(node);
|
|
3649
|
-
return replacement &&
|
|
3651
|
+
return replacement && import_compiler21.types.classProperty(node.key, replacement);
|
|
3650
3652
|
}
|
|
3651
3653
|
case "ClassPrivateMethod": {
|
|
3652
3654
|
const replacement = getRegisteredFnExpression2(node);
|
|
3653
|
-
return replacement &&
|
|
3655
|
+
return replacement && import_compiler21.types.classPrivateProperty(node.key, replacement);
|
|
3654
3656
|
}
|
|
3655
3657
|
case "ObjectMethod": {
|
|
3656
3658
|
const replacement = getRegisteredFnExpression2(node);
|
|
3657
|
-
return replacement &&
|
|
3659
|
+
return replacement && import_compiler21.types.objectProperty(node.key, replacement);
|
|
3658
3660
|
}
|
|
3659
3661
|
case "FunctionDeclaration": {
|
|
3660
3662
|
const { extra } = node;
|
|
@@ -3691,11 +3693,11 @@ function addRegisteredDeclarations(body) {
|
|
|
3691
3693
|
if (registeredFnDeclarations) {
|
|
3692
3694
|
for (const { id, registerId } of registeredFnDeclarations) {
|
|
3693
3695
|
body.push(
|
|
3694
|
-
|
|
3696
|
+
import_compiler21.types.expressionStatement(
|
|
3695
3697
|
callRuntime(
|
|
3696
3698
|
"register",
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
+
import_compiler21.types.identifier(id),
|
|
3700
|
+
import_compiler21.types.stringLiteral(registerId)
|
|
3699
3701
|
)
|
|
3700
3702
|
)
|
|
3701
3703
|
);
|
|
@@ -3708,7 +3710,7 @@ function getRegisteredFnExpression2(node) {
|
|
|
3708
3710
|
return callRuntime(
|
|
3709
3711
|
"register",
|
|
3710
3712
|
simplifyFunction(node),
|
|
3711
|
-
|
|
3713
|
+
import_compiler21.types.stringLiteral(extra.registerId),
|
|
3712
3714
|
(extra.referencedBindingsInFunction || extra.referencesScope) && getScopeIdIdentifier(extra.section)
|
|
3713
3715
|
);
|
|
3714
3716
|
}
|
|
@@ -3723,7 +3725,7 @@ function isScopeIdentifier(node) {
|
|
|
3723
3725
|
var program_default = {
|
|
3724
3726
|
migrate: {
|
|
3725
3727
|
enter(program) {
|
|
3726
|
-
program.node.params = [
|
|
3728
|
+
program.node.params = [import_compiler22.types.identifier("input")];
|
|
3727
3729
|
},
|
|
3728
3730
|
exit(program) {
|
|
3729
3731
|
program.scope.crawl();
|
|
@@ -3765,12 +3767,12 @@ var program_default = {
|
|
|
3765
3767
|
if (getMarkoOpts().output === "hydrate") {
|
|
3766
3768
|
const entryFile = program.hub.file;
|
|
3767
3769
|
const visitedFiles = /* @__PURE__ */ new Set([
|
|
3768
|
-
(0,
|
|
3770
|
+
(0, import_babel_utils15.resolveRelativePath)(entryFile, entryFile.opts.filename)
|
|
3769
3771
|
]);
|
|
3770
3772
|
entry_builder_default.visit(entryFile, entryFile, function visitChild(resolved) {
|
|
3771
3773
|
if (!visitedFiles.has(resolved)) {
|
|
3772
3774
|
visitedFiles.add(resolved);
|
|
3773
|
-
const file = (0,
|
|
3775
|
+
const file = (0, import_babel_utils15.loadFileForImport)(entryFile, resolved);
|
|
3774
3776
|
if (file) {
|
|
3775
3777
|
entry_builder_default.visit(
|
|
3776
3778
|
file,
|
|
@@ -3801,14 +3803,14 @@ var program_default = {
|
|
|
3801
3803
|
body.push(child);
|
|
3802
3804
|
}
|
|
3803
3805
|
}
|
|
3804
|
-
body[0] ??=
|
|
3806
|
+
body[0] ??= import_compiler22.types.importDeclaration([], import_compiler22.types.stringLiteral(compatFile));
|
|
3805
3807
|
program.node.body = body;
|
|
3806
3808
|
}
|
|
3807
3809
|
}
|
|
3808
3810
|
}
|
|
3809
3811
|
};
|
|
3810
3812
|
function resolveRelativeToEntry(entryFile, file, req) {
|
|
3811
|
-
return file === entryFile ? (0,
|
|
3813
|
+
return file === entryFile ? (0, import_babel_utils15.resolveRelativePath)(file, req) : (0, import_babel_utils15.resolveRelativePath)(
|
|
3812
3814
|
entryFile,
|
|
3813
3815
|
req[0] === "." ? import_path2.default.join(file.opts.filename, "..", req) : req
|
|
3814
3816
|
);
|
|
@@ -3831,7 +3833,7 @@ function buildTemplateExports(binding, program) {
|
|
|
3831
3833
|
// src/translator/util/scope-read.ts
|
|
3832
3834
|
function createScopeReadPattern(section, referencedBindings) {
|
|
3833
3835
|
const rootDepth = section.depth;
|
|
3834
|
-
const rootPattern =
|
|
3836
|
+
const rootPattern = import_compiler23.types.objectPattern([]);
|
|
3835
3837
|
let nestedPatterns;
|
|
3836
3838
|
forEach(referencedBindings, (ref) => {
|
|
3837
3839
|
const propertyValue = ref.name;
|
|
@@ -3845,9 +3847,9 @@ function createScopeReadPattern(section, referencedBindings) {
|
|
|
3845
3847
|
let i = nestedPatterns.length;
|
|
3846
3848
|
let prev = nestedPatterns[i - 1];
|
|
3847
3849
|
for (; i <= relativeDepth; i++) {
|
|
3848
|
-
const nestedPattern =
|
|
3850
|
+
const nestedPattern = import_compiler23.types.objectPattern([]);
|
|
3849
3851
|
prev.properties.push(
|
|
3850
|
-
|
|
3852
|
+
import_compiler23.types.objectProperty(import_compiler23.types.identifier("_"), nestedPattern)
|
|
3851
3853
|
);
|
|
3852
3854
|
nestedPatterns.push(nestedPattern);
|
|
3853
3855
|
prev = nestedPattern;
|
|
@@ -3855,9 +3857,9 @@ function createScopeReadPattern(section, referencedBindings) {
|
|
|
3855
3857
|
pattern = nestedPatterns[relativeDepth];
|
|
3856
3858
|
}
|
|
3857
3859
|
pattern.properties.push(
|
|
3858
|
-
|
|
3860
|
+
import_compiler23.types.objectProperty(
|
|
3859
3861
|
toPropertyName(propertyKey),
|
|
3860
|
-
|
|
3862
|
+
import_compiler23.types.identifier(propertyValue),
|
|
3861
3863
|
false,
|
|
3862
3864
|
isShorthand
|
|
3863
3865
|
)
|
|
@@ -3866,10 +3868,10 @@ function createScopeReadPattern(section, referencedBindings) {
|
|
|
3866
3868
|
return rootPattern;
|
|
3867
3869
|
}
|
|
3868
3870
|
function getScopeExpression(section, targetSection) {
|
|
3869
|
-
let scope = scopeIdentifier ??
|
|
3871
|
+
let scope = scopeIdentifier ?? import_compiler23.types.identifier("undefined");
|
|
3870
3872
|
const diff = section.depth - targetSection.depth;
|
|
3871
3873
|
for (let i = 0; i < diff; i++) {
|
|
3872
|
-
scope =
|
|
3874
|
+
scope = import_compiler23.types.memberExpression(scope, import_compiler23.types.identifier("_"));
|
|
3873
3875
|
}
|
|
3874
3876
|
if (diff < 0) {
|
|
3875
3877
|
throw new Error("Unable to find scope for reference.");
|
|
@@ -3878,7 +3880,7 @@ function getScopeExpression(section, targetSection) {
|
|
|
3878
3880
|
}
|
|
3879
3881
|
function createScopeReadExpression(section, reference) {
|
|
3880
3882
|
const propName = toPropertyName(getScopeAccessor(reference));
|
|
3881
|
-
return
|
|
3883
|
+
return import_compiler23.types.memberExpression(
|
|
3882
3884
|
getScopeExpression(section, reference.section),
|
|
3883
3885
|
propName,
|
|
3884
3886
|
propName.type !== "Identifier"
|
|
@@ -4182,7 +4184,7 @@ function trackReference(referencePath, binding) {
|
|
|
4182
4184
|
let propPath = binding.name;
|
|
4183
4185
|
while (true) {
|
|
4184
4186
|
const { parent } = root;
|
|
4185
|
-
if (!
|
|
4187
|
+
if (!import_compiler24.types.isMemberExpression(parent)) break;
|
|
4186
4188
|
const prop = getMemberExpressionPropString(parent);
|
|
4187
4189
|
if (prop === void 0) break;
|
|
4188
4190
|
if (reference.propertyAliases.has(prop)) {
|
|
@@ -4480,9 +4482,9 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
|
|
|
4480
4482
|
}
|
|
4481
4483
|
function getScopeAccessorLiteral(binding, includeId) {
|
|
4482
4484
|
if (isOptimize()) {
|
|
4483
|
-
return
|
|
4485
|
+
return import_compiler24.types.numericLiteral(binding.id);
|
|
4484
4486
|
}
|
|
4485
|
-
return
|
|
4487
|
+
return import_compiler24.types.stringLiteral(
|
|
4486
4488
|
binding.name + (includeId || binding.type === 0 /* dom */ ? `/${binding.id}` : "")
|
|
4487
4489
|
);
|
|
4488
4490
|
}
|
|
@@ -4497,7 +4499,7 @@ function getSectionInstancesAccessor(section) {
|
|
|
4497
4499
|
}
|
|
4498
4500
|
function getSectionInstancesAccessorLiteral(section) {
|
|
4499
4501
|
const accessor = getSectionInstancesAccessor(section);
|
|
4500
|
-
return accessor ? typeof accessor === "number" ?
|
|
4502
|
+
return accessor ? typeof accessor === "number" ? import_compiler24.types.numericLiteral(accessor) : import_compiler24.types.stringLiteral(accessor) : void 0;
|
|
4501
4503
|
}
|
|
4502
4504
|
function getReadReplacement(node) {
|
|
4503
4505
|
const { extra } = node;
|
|
@@ -4515,18 +4517,18 @@ function getReadReplacement(node) {
|
|
|
4515
4517
|
if (binding) {
|
|
4516
4518
|
if (node.type === "Identifier") {
|
|
4517
4519
|
if (binding.type === 5 /* hoist */) {
|
|
4518
|
-
replacement = node.extra?.[kIsInvoked] ?
|
|
4520
|
+
replacement = node.extra?.[kIsInvoked] ? import_compiler24.types.callExpression(getHoistFunctionIdentifier(binding), [
|
|
4519
4521
|
getScopeExpression(node.extra.section, binding.section)
|
|
4520
|
-
]) :
|
|
4522
|
+
]) : import_compiler24.types.identifier(getScopeAccessor(binding));
|
|
4521
4523
|
} else if (binding.name !== node.name) {
|
|
4522
4524
|
node.name = binding.name;
|
|
4523
4525
|
}
|
|
4524
4526
|
} else {
|
|
4525
|
-
replacement =
|
|
4527
|
+
replacement = import_compiler24.types.identifier(binding.name);
|
|
4526
4528
|
}
|
|
4527
4529
|
} else if (read) {
|
|
4528
4530
|
replacement = toMemberExpression(
|
|
4529
|
-
|
|
4531
|
+
import_compiler24.types.identifier(read.binding.name),
|
|
4530
4532
|
Array.isArray(read.props) ? read.props[0] : read.props
|
|
4531
4533
|
);
|
|
4532
4534
|
if (Array.isArray(read.props)) {
|
|
@@ -4646,10 +4648,10 @@ function isRegisteredFnExtra(extra) {
|
|
|
4646
4648
|
var kDOMBinding = Symbol("await tag dom binding");
|
|
4647
4649
|
var await_default = {
|
|
4648
4650
|
analyze(tag) {
|
|
4649
|
-
(0,
|
|
4650
|
-
(0,
|
|
4651
|
+
(0, import_babel_utils16.assertNoVar)(tag);
|
|
4652
|
+
(0, import_babel_utils16.assertNoArgs)(tag);
|
|
4651
4653
|
assertNoSpreadAttrs(tag);
|
|
4652
|
-
(0,
|
|
4654
|
+
(0, import_babel_utils16.assertNoAttributeTags)(tag);
|
|
4653
4655
|
const { node } = tag;
|
|
4654
4656
|
const tagBody = tag.get("body");
|
|
4655
4657
|
const section = getOrCreateSection(tag);
|
|
@@ -4665,7 +4667,7 @@ var await_default = {
|
|
|
4665
4667
|
if (!valueAttr) {
|
|
4666
4668
|
throw tag.get("name").buildCodeFrameError("The `await` tag requires a value.");
|
|
4667
4669
|
}
|
|
4668
|
-
if (node.attributes.length > 1 || !
|
|
4670
|
+
if (node.attributes.length > 1 || !import_compiler25.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
|
|
4669
4671
|
throw tag.get("name").buildCodeFrameError(
|
|
4670
4672
|
"The `await` tag only supports the `value` attribute."
|
|
4671
4673
|
);
|
|
@@ -4673,7 +4675,7 @@ var await_default = {
|
|
|
4673
4675
|
if (!node.body.body.length) {
|
|
4674
4676
|
throw tag.get("name").buildCodeFrameError("The `await` tag requires body content.");
|
|
4675
4677
|
}
|
|
4676
|
-
if (node.body.params.length && (node.body.params.length > 1 ||
|
|
4678
|
+
if (node.body.params.length && (node.body.params.length > 1 || import_compiler25.types.isSpreadElement(node.body.params[0]))) {
|
|
4677
4679
|
throw tag.get("name").buildCodeFrameError(
|
|
4678
4680
|
"The `await` tag only supports a single parameter."
|
|
4679
4681
|
);
|
|
@@ -4710,13 +4712,13 @@ var await_default = {
|
|
|
4710
4712
|
flushInto(tag);
|
|
4711
4713
|
writeHTMLResumeStatements(tagBody);
|
|
4712
4714
|
tag.replaceWith(
|
|
4713
|
-
|
|
4715
|
+
import_compiler25.types.expressionStatement(
|
|
4714
4716
|
callRuntime(
|
|
4715
4717
|
"fork",
|
|
4716
4718
|
getScopeIdIdentifier(section),
|
|
4717
4719
|
getScopeAccessorLiteral(nodeRef2),
|
|
4718
4720
|
valueAttr.value,
|
|
4719
|
-
|
|
4721
|
+
import_compiler25.types.arrowFunctionExpression(
|
|
4720
4722
|
node.body.params,
|
|
4721
4723
|
toFirstExpressionOrBlock(node.body.body)
|
|
4722
4724
|
)
|
|
@@ -4748,7 +4750,7 @@ var await_default = {
|
|
|
4748
4750
|
return callRuntime(
|
|
4749
4751
|
"awaitTag",
|
|
4750
4752
|
getScopeAccessorLiteral(nodeRef2),
|
|
4751
|
-
|
|
4753
|
+
import_compiler25.types.identifier(bodySection.name)
|
|
4752
4754
|
);
|
|
4753
4755
|
};
|
|
4754
4756
|
addValue(
|
|
@@ -4772,8 +4774,8 @@ var await_default = {
|
|
|
4772
4774
|
};
|
|
4773
4775
|
|
|
4774
4776
|
// src/translator/core/client.ts
|
|
4775
|
-
var
|
|
4776
|
-
var
|
|
4777
|
+
var import_compiler26 = require("@marko/compiler");
|
|
4778
|
+
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
|
4777
4779
|
var client_default = {
|
|
4778
4780
|
parse(tag) {
|
|
4779
4781
|
const {
|
|
@@ -4783,11 +4785,11 @@ var client_default = {
|
|
|
4783
4785
|
const rawValue = node.rawValue;
|
|
4784
4786
|
const code = rawValue.replace(/^client\s*/, "").trim();
|
|
4785
4787
|
const start = node.name.start + (rawValue.length - code.length);
|
|
4786
|
-
let body = (0,
|
|
4787
|
-
if (body.length === 1 &&
|
|
4788
|
+
let body = (0, import_babel_utils17.parseStatements)(file, code, start, start + code.length);
|
|
4789
|
+
if (body.length === 1 && import_compiler26.types.isBlockStatement(body[0])) {
|
|
4788
4790
|
body = body[0].body;
|
|
4789
4791
|
}
|
|
4790
|
-
tag.replaceWith(
|
|
4792
|
+
tag.replaceWith(import_compiler26.types.markoScriptlet(body, true, "client"));
|
|
4791
4793
|
},
|
|
4792
4794
|
parseOptions: {
|
|
4793
4795
|
statement: true,
|
|
@@ -4803,11 +4805,11 @@ var client_default = {
|
|
|
4803
4805
|
};
|
|
4804
4806
|
|
|
4805
4807
|
// src/translator/core/const.ts
|
|
4806
|
-
var
|
|
4807
|
-
var
|
|
4808
|
+
var import_compiler28 = require("@marko/compiler");
|
|
4809
|
+
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
|
4808
4810
|
|
|
4809
4811
|
// src/translator/util/translate-var.ts
|
|
4810
|
-
var
|
|
4812
|
+
var import_compiler27 = require("@marko/compiler");
|
|
4811
4813
|
function translateVar(tag, initialValue, kind = "const") {
|
|
4812
4814
|
const {
|
|
4813
4815
|
node: { var: tagVar }
|
|
@@ -4816,15 +4818,15 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
|
4816
4818
|
return;
|
|
4817
4819
|
}
|
|
4818
4820
|
tag.insertBefore(
|
|
4819
|
-
|
|
4821
|
+
import_compiler27.types.variableDeclaration(kind, [import_compiler27.types.variableDeclarator(tagVar, initialValue)])
|
|
4820
4822
|
);
|
|
4821
4823
|
}
|
|
4822
4824
|
|
|
4823
4825
|
// src/translator/core/const.ts
|
|
4824
4826
|
var const_default = {
|
|
4825
4827
|
analyze(tag) {
|
|
4826
|
-
(0,
|
|
4827
|
-
(0,
|
|
4828
|
+
(0, import_babel_utils18.assertNoArgs)(tag);
|
|
4829
|
+
(0, import_babel_utils18.assertNoParams)(tag);
|
|
4828
4830
|
assertNoBodyContent(tag);
|
|
4829
4831
|
const { node } = tag;
|
|
4830
4832
|
const [valueAttr] = node.attributes;
|
|
@@ -4834,12 +4836,12 @@ var const_default = {
|
|
|
4834
4836
|
if (!valueAttr) {
|
|
4835
4837
|
throw tag.get("name").buildCodeFrameError("The `const` tag requires a value.");
|
|
4836
4838
|
}
|
|
4837
|
-
if (node.attributes.length > 1 || !
|
|
4839
|
+
if (node.attributes.length > 1 || !import_compiler28.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
|
4838
4840
|
throw tag.get("name").buildCodeFrameError(
|
|
4839
4841
|
"The `const` tag only supports the `value` attribute."
|
|
4840
4842
|
);
|
|
4841
4843
|
}
|
|
4842
|
-
const upstreamAlias =
|
|
4844
|
+
const upstreamAlias = import_compiler28.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
|
|
4843
4845
|
trackVarReferences(
|
|
4844
4846
|
tag,
|
|
4845
4847
|
4 /* derived */,
|
|
@@ -4880,16 +4882,16 @@ var const_default = {
|
|
|
4880
4882
|
};
|
|
4881
4883
|
|
|
4882
4884
|
// src/translator/core/debug.ts
|
|
4883
|
-
var
|
|
4884
|
-
var
|
|
4885
|
+
var import_compiler29 = require("@marko/compiler");
|
|
4886
|
+
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
|
4885
4887
|
var debug_default = {
|
|
4886
4888
|
analyze(tag) {
|
|
4887
4889
|
const [valueAttr] = tag.node.attributes;
|
|
4888
|
-
(0,
|
|
4889
|
-
(0,
|
|
4890
|
-
(0,
|
|
4890
|
+
(0, import_babel_utils19.assertNoVar)(tag);
|
|
4891
|
+
(0, import_babel_utils19.assertNoArgs)(tag);
|
|
4892
|
+
(0, import_babel_utils19.assertNoParams)(tag);
|
|
4891
4893
|
assertNoBodyContent(tag);
|
|
4892
|
-
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!
|
|
4894
|
+
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler29.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
|
4893
4895
|
throw tag.get("name").buildCodeFrameError(
|
|
4894
4896
|
"The `debug` tag only supports the `value` attribute."
|
|
4895
4897
|
);
|
|
@@ -4900,7 +4902,7 @@ var debug_default = {
|
|
|
4900
4902
|
const section = getSection(tag);
|
|
4901
4903
|
const [valueAttr] = tag.node.attributes;
|
|
4902
4904
|
const referencedBindings = valueAttr?.value.extra?.referencedBindings;
|
|
4903
|
-
const statement = withPreviousLocation(
|
|
4905
|
+
const statement = withPreviousLocation(import_compiler29.types.debuggerStatement(), tag.node);
|
|
4904
4906
|
if (isOutputHTML()) {
|
|
4905
4907
|
tag.insertBefore(statement);
|
|
4906
4908
|
} else {
|
|
@@ -4923,12 +4925,12 @@ var debug_default = {
|
|
|
4923
4925
|
};
|
|
4924
4926
|
|
|
4925
4927
|
// src/translator/core/define.ts
|
|
4926
|
-
var
|
|
4927
|
-
var
|
|
4928
|
+
var import_compiler35 = require("@marko/compiler");
|
|
4929
|
+
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
|
4928
4930
|
|
|
4929
4931
|
// src/translator/util/nested-attribute-tags.ts
|
|
4930
|
-
var
|
|
4931
|
-
var
|
|
4932
|
+
var import_compiler30 = require("@marko/compiler");
|
|
4933
|
+
var import_babel_utils20 = require("@marko/compiler/babel-utils");
|
|
4932
4934
|
var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
|
|
4933
4935
|
function getAttrTagIdentifier(meta) {
|
|
4934
4936
|
let name2 = attrTagToIdentifierLookup.get(meta);
|
|
@@ -4936,7 +4938,7 @@ function getAttrTagIdentifier(meta) {
|
|
|
4936
4938
|
name2 = generateUid(meta.name);
|
|
4937
4939
|
attrTagToIdentifierLookup.set(meta, name2);
|
|
4938
4940
|
}
|
|
4939
|
-
return
|
|
4941
|
+
return import_compiler30.types.identifier(name2);
|
|
4940
4942
|
}
|
|
4941
4943
|
function analyzeAttributeTags(tag) {
|
|
4942
4944
|
if (tag.node.extra?.attributeTags) return tag.node.extra.attributeTags;
|
|
@@ -4948,13 +4950,13 @@ function analyzeAttributeTags(tag) {
|
|
|
4948
4950
|
const sampleAttrTagsForControlFlow = /* @__PURE__ */ new Map();
|
|
4949
4951
|
for (const child of attrTags2) {
|
|
4950
4952
|
if (child.isMarkoTag()) {
|
|
4951
|
-
if ((0,
|
|
4953
|
+
if ((0, import_babel_utils20.isAttributeTag)(child)) {
|
|
4952
4954
|
const name2 = getTagName(child);
|
|
4953
4955
|
lookup[name2] ||= createAttrTagMeta(name2, [name2]);
|
|
4954
4956
|
(attrTagNodesByName[name2] ||= []).push(child);
|
|
4955
4957
|
analyzeAttributeTags(child);
|
|
4956
4958
|
} else {
|
|
4957
|
-
const isRepeated = (0,
|
|
4959
|
+
const isRepeated = (0, import_babel_utils20.isLoopTag)(child);
|
|
4958
4960
|
let curGroup;
|
|
4959
4961
|
for (const name2 of crawlAttrTags(child, attrTagNodesByName)) {
|
|
4960
4962
|
const oldMeta = lookup[name2];
|
|
@@ -5009,7 +5011,7 @@ function crawlAttrTags(tag, attrTagNodesByName, attrTagNames = /* @__PURE__ */ n
|
|
|
5009
5011
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
5010
5012
|
for (const child of attrTags2) {
|
|
5011
5013
|
if (child.isMarkoTag()) {
|
|
5012
|
-
if ((0,
|
|
5014
|
+
if ((0, import_babel_utils20.isAttributeTag)(child)) {
|
|
5013
5015
|
const tagName = getTagName(child);
|
|
5014
5016
|
attrTagNames.add(tagName);
|
|
5015
5017
|
(attrTagNodesByName[tagName] ||= []).push(child);
|
|
@@ -5049,20 +5051,20 @@ function getConditionRoot(tag) {
|
|
|
5049
5051
|
}
|
|
5050
5052
|
|
|
5051
5053
|
// src/translator/util/translate-attrs.ts
|
|
5052
|
-
var
|
|
5053
|
-
var
|
|
5054
|
+
var import_compiler34 = require("@marko/compiler");
|
|
5055
|
+
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
|
5054
5056
|
|
|
5055
5057
|
// src/translator/core/for.ts
|
|
5056
|
-
var
|
|
5057
|
-
var
|
|
5058
|
+
var import_compiler33 = require("@marko/compiler");
|
|
5059
|
+
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
|
5058
5060
|
|
|
5059
5061
|
// src/translator/util/is-only-child-in-parent.ts
|
|
5060
|
-
var
|
|
5061
|
-
var
|
|
5062
|
+
var import_compiler32 = require("@marko/compiler");
|
|
5063
|
+
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
|
5062
5064
|
|
|
5063
5065
|
// src/translator/visitors/tag/native-tag.ts
|
|
5064
|
-
var
|
|
5065
|
-
var
|
|
5066
|
+
var import_compiler31 = require("@marko/compiler");
|
|
5067
|
+
var import_babel_utils21 = require("@marko/compiler/babel-utils");
|
|
5066
5068
|
var kNativeTagBinding = Symbol("native tag binding");
|
|
5067
5069
|
var kSerializeMarker = Symbol("serialize marker");
|
|
5068
5070
|
var kGetterId = Symbol("node getter id");
|
|
@@ -5153,7 +5155,7 @@ var native_tag_default = {
|
|
|
5153
5155
|
}
|
|
5154
5156
|
}
|
|
5155
5157
|
tag.node.attributes.push(
|
|
5156
|
-
|
|
5158
|
+
import_compiler31.types.markoAttribute(
|
|
5157
5159
|
"value",
|
|
5158
5160
|
normalizeStringExpression(parts) || buildUndefined()
|
|
5159
5161
|
)
|
|
@@ -5164,11 +5166,11 @@ var native_tag_default = {
|
|
|
5164
5166
|
},
|
|
5165
5167
|
analyze: {
|
|
5166
5168
|
enter(tag) {
|
|
5167
|
-
(0,
|
|
5168
|
-
(0,
|
|
5169
|
-
(0,
|
|
5169
|
+
(0, import_babel_utils21.assertNoArgs)(tag);
|
|
5170
|
+
(0, import_babel_utils21.assertNoParams)(tag);
|
|
5171
|
+
(0, import_babel_utils21.assertNoAttributeTags)(tag);
|
|
5170
5172
|
const { node } = tag;
|
|
5171
|
-
if (node.var && !
|
|
5173
|
+
if (node.var && !import_compiler31.types.isIdentifier(node.var)) {
|
|
5172
5174
|
throw tag.get("var").buildCodeFrameError(
|
|
5173
5175
|
"Tag variables on native elements cannot be destructured."
|
|
5174
5176
|
);
|
|
@@ -5183,7 +5185,7 @@ var native_tag_default = {
|
|
|
5183
5185
|
let spreadReferenceNodes;
|
|
5184
5186
|
for (let i = attributes.length; i--; ) {
|
|
5185
5187
|
const attr2 = attributes[i];
|
|
5186
|
-
if (
|
|
5188
|
+
if (import_compiler31.types.isMarkoAttribute(attr2)) {
|
|
5187
5189
|
if (seen[attr2.name]) {
|
|
5188
5190
|
dropReferences(attr2.value);
|
|
5189
5191
|
continue;
|
|
@@ -5195,14 +5197,14 @@ var native_tag_default = {
|
|
|
5195
5197
|
} else if (!evaluate(attr2.value).confident) {
|
|
5196
5198
|
hasDynamicAttributes = true;
|
|
5197
5199
|
}
|
|
5198
|
-
} else if (
|
|
5200
|
+
} else if (import_compiler31.types.isMarkoSpreadAttribute(attr2)) {
|
|
5199
5201
|
hasEventHandlers = true;
|
|
5200
5202
|
hasDynamicAttributes = true;
|
|
5201
5203
|
(attr2.value.extra ??= {}).isEffect = true;
|
|
5202
5204
|
}
|
|
5203
5205
|
if (spreadReferenceNodes) {
|
|
5204
5206
|
spreadReferenceNodes.push(attr2.value);
|
|
5205
|
-
} else if (
|
|
5207
|
+
} else if (import_compiler31.types.isMarkoSpreadAttribute(attr2)) {
|
|
5206
5208
|
spreadReferenceNodes = [attr2.value];
|
|
5207
5209
|
relatedControllable = getRelatedControllable(tagName, seen);
|
|
5208
5210
|
}
|
|
@@ -5229,8 +5231,8 @@ var native_tag_default = {
|
|
|
5229
5231
|
);
|
|
5230
5232
|
}
|
|
5231
5233
|
if (node.var || hasEventHandlers || hasDynamicAttributes) {
|
|
5232
|
-
(0,
|
|
5233
|
-
const tagName2 = node.name.type === "StringLiteral" ? node.name.value :
|
|
5234
|
+
(0, import_babel_utils21.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
|
|
5235
|
+
const tagName2 = node.name.type === "StringLiteral" ? node.name.value : import_compiler31.types.toIdentifier(tag.get("name"));
|
|
5234
5236
|
const tagExtra = node.extra ??= {};
|
|
5235
5237
|
const bindingName = "#" + tagName2;
|
|
5236
5238
|
if (hasEventHandlers || node.var) {
|
|
@@ -5266,7 +5268,7 @@ var native_tag_default = {
|
|
|
5266
5268
|
const nodeRef2 = extra[kNativeTagBinding];
|
|
5267
5269
|
const isHTML = isOutputHTML();
|
|
5268
5270
|
const name2 = tag.get("name");
|
|
5269
|
-
const tagDef = (0,
|
|
5271
|
+
const tagDef = (0, import_babel_utils21.getTagDef)(tag);
|
|
5270
5272
|
const write2 = writeTo(tag);
|
|
5271
5273
|
const section = getSection(tag);
|
|
5272
5274
|
if (isHTML && extra.tagNameNullable) {
|
|
@@ -5289,21 +5291,21 @@ var native_tag_default = {
|
|
|
5289
5291
|
callRuntime(
|
|
5290
5292
|
"nodeRef",
|
|
5291
5293
|
getterId && getScopeIdIdentifier(section),
|
|
5292
|
-
getterId &&
|
|
5294
|
+
getterId && import_compiler31.types.stringLiteral(getterId)
|
|
5293
5295
|
)
|
|
5294
5296
|
);
|
|
5295
5297
|
} else {
|
|
5296
5298
|
let getterFnIdentifier;
|
|
5297
5299
|
if (getterId) {
|
|
5298
5300
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
5299
|
-
(0,
|
|
5300
|
-
|
|
5301
|
-
|
|
5301
|
+
(0, import_babel_utils21.getProgram)().node.body.push(
|
|
5302
|
+
import_compiler31.types.variableDeclaration("const", [
|
|
5303
|
+
import_compiler31.types.variableDeclarator(
|
|
5302
5304
|
getterFnIdentifier,
|
|
5303
5305
|
callRuntime(
|
|
5304
5306
|
"nodeRef",
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
+
import_compiler31.types.stringLiteral(getterId),
|
|
5308
|
+
import_compiler31.types.stringLiteral(
|
|
5307
5309
|
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
|
|
5308
5310
|
)
|
|
5309
5311
|
)
|
|
@@ -5316,22 +5318,22 @@ var native_tag_default = {
|
|
|
5316
5318
|
const referenceSection = getSection(reference);
|
|
5317
5319
|
if (isInvokedFunction(reference)) {
|
|
5318
5320
|
reference.parentPath.replaceWith(
|
|
5319
|
-
|
|
5321
|
+
import_compiler31.types.expressionStatement(
|
|
5320
5322
|
createScopeReadExpression(referenceSection, nodeRef2)
|
|
5321
5323
|
)
|
|
5322
5324
|
);
|
|
5323
5325
|
} else if (getterFnIdentifier) {
|
|
5324
5326
|
reference.replaceWith(
|
|
5325
|
-
|
|
5327
|
+
import_compiler31.types.callExpression(getterFnIdentifier, [
|
|
5326
5328
|
getScopeExpression(referenceSection, getSection(tag))
|
|
5327
5329
|
])
|
|
5328
5330
|
);
|
|
5329
5331
|
} else {
|
|
5330
5332
|
reference.replaceWith(
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
+
import_compiler31.types.expressionStatement(
|
|
5334
|
+
import_compiler31.types.memberExpression(
|
|
5333
5335
|
getScopeExpression(section, referenceSection),
|
|
5334
|
-
|
|
5336
|
+
import_compiler31.types.stringLiteral(
|
|
5335
5337
|
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
|
|
5336
5338
|
),
|
|
5337
5339
|
true
|
|
@@ -5367,7 +5369,7 @@ var native_tag_default = {
|
|
|
5367
5369
|
"render",
|
|
5368
5370
|
section,
|
|
5369
5371
|
referencedBindings,
|
|
5370
|
-
|
|
5372
|
+
import_compiler31.types.expressionStatement(
|
|
5371
5373
|
callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
|
|
5372
5374
|
)
|
|
5373
5375
|
);
|
|
@@ -5375,7 +5377,7 @@ var native_tag_default = {
|
|
|
5375
5377
|
"effect",
|
|
5376
5378
|
section,
|
|
5377
5379
|
void 0,
|
|
5378
|
-
|
|
5380
|
+
import_compiler31.types.expressionStatement(
|
|
5379
5381
|
callRuntime(`${helper}_effect`, scopeIdentifier, visitAccessor)
|
|
5380
5382
|
)
|
|
5381
5383
|
);
|
|
@@ -5392,18 +5394,18 @@ var native_tag_default = {
|
|
|
5392
5394
|
} else if (spreadExpression) {
|
|
5393
5395
|
const spreadIdentifier = generateUidIdentifier("select_input");
|
|
5394
5396
|
tag.insertBefore(
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
+
import_compiler31.types.variableDeclaration("const", [
|
|
5398
|
+
import_compiler31.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5397
5399
|
])
|
|
5398
5400
|
);
|
|
5399
5401
|
htmlSelectArgs.set(tag.node, {
|
|
5400
|
-
value:
|
|
5402
|
+
value: import_compiler31.types.memberExpression(
|
|
5401
5403
|
spreadIdentifier,
|
|
5402
|
-
|
|
5404
|
+
import_compiler31.types.identifier("value")
|
|
5403
5405
|
),
|
|
5404
|
-
valueChange:
|
|
5406
|
+
valueChange: import_compiler31.types.memberExpression(
|
|
5405
5407
|
spreadIdentifier,
|
|
5406
|
-
|
|
5408
|
+
import_compiler31.types.identifier("valueChange")
|
|
5407
5409
|
)
|
|
5408
5410
|
});
|
|
5409
5411
|
spreadExpression = spreadIdentifier;
|
|
@@ -5417,14 +5419,14 @@ var native_tag_default = {
|
|
|
5417
5419
|
} else if (spreadExpression) {
|
|
5418
5420
|
const spreadIdentifier = generateUidIdentifier("textarea_input");
|
|
5419
5421
|
tag.insertBefore(
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
+
import_compiler31.types.variableDeclaration("const", [
|
|
5423
|
+
import_compiler31.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5422
5424
|
])
|
|
5423
5425
|
);
|
|
5424
|
-
value =
|
|
5425
|
-
valueChange =
|
|
5426
|
+
value = import_compiler31.types.memberExpression(spreadIdentifier, import_compiler31.types.identifier("value"));
|
|
5427
|
+
valueChange = import_compiler31.types.memberExpression(
|
|
5426
5428
|
spreadIdentifier,
|
|
5427
|
-
|
|
5429
|
+
import_compiler31.types.identifier("valueChange")
|
|
5428
5430
|
);
|
|
5429
5431
|
spreadExpression = spreadIdentifier;
|
|
5430
5432
|
}
|
|
@@ -5460,10 +5462,10 @@ var native_tag_default = {
|
|
|
5460
5462
|
"render",
|
|
5461
5463
|
section,
|
|
5462
5464
|
valueReferences,
|
|
5463
|
-
|
|
5465
|
+
import_compiler31.types.expressionStatement(
|
|
5464
5466
|
callRuntime(
|
|
5465
5467
|
helper,
|
|
5466
|
-
|
|
5468
|
+
import_compiler31.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
5467
5469
|
value
|
|
5468
5470
|
)
|
|
5469
5471
|
)
|
|
@@ -5478,18 +5480,18 @@ var native_tag_default = {
|
|
|
5478
5480
|
if (isEventHandler(name3)) {
|
|
5479
5481
|
addHTMLEffectCall(section, valueReferences);
|
|
5480
5482
|
} else {
|
|
5481
|
-
write2`${callRuntime("attr",
|
|
5483
|
+
write2`${callRuntime("attr", import_compiler31.types.stringLiteral(name3), value)}`;
|
|
5482
5484
|
}
|
|
5483
5485
|
} else if (isEventHandler(name3)) {
|
|
5484
5486
|
addStatement(
|
|
5485
5487
|
"effect",
|
|
5486
5488
|
section,
|
|
5487
5489
|
valueReferences,
|
|
5488
|
-
|
|
5490
|
+
import_compiler31.types.expressionStatement(
|
|
5489
5491
|
callRuntime(
|
|
5490
5492
|
"on",
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
+
import_compiler31.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
5494
|
+
import_compiler31.types.stringLiteral(getEventHandlerName(name3)),
|
|
5493
5495
|
value
|
|
5494
5496
|
)
|
|
5495
5497
|
)
|
|
@@ -5499,11 +5501,11 @@ var native_tag_default = {
|
|
|
5499
5501
|
"render",
|
|
5500
5502
|
section,
|
|
5501
5503
|
valueReferences,
|
|
5502
|
-
|
|
5504
|
+
import_compiler31.types.expressionStatement(
|
|
5503
5505
|
callRuntime(
|
|
5504
5506
|
"attr",
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
+
import_compiler31.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
5508
|
+
import_compiler31.types.stringLiteral(name3),
|
|
5507
5509
|
value
|
|
5508
5510
|
)
|
|
5509
5511
|
)
|
|
@@ -5526,7 +5528,7 @@ var native_tag_default = {
|
|
|
5526
5528
|
"render",
|
|
5527
5529
|
section,
|
|
5528
5530
|
extra.referencedBindings,
|
|
5529
|
-
|
|
5531
|
+
import_compiler31.types.expressionStatement(
|
|
5530
5532
|
callRuntime(
|
|
5531
5533
|
"partialAttrs",
|
|
5532
5534
|
scopeIdentifier,
|
|
@@ -5541,7 +5543,7 @@ var native_tag_default = {
|
|
|
5541
5543
|
"render",
|
|
5542
5544
|
section,
|
|
5543
5545
|
extra.referencedBindings,
|
|
5544
|
-
|
|
5546
|
+
import_compiler31.types.expressionStatement(
|
|
5545
5547
|
callRuntime(
|
|
5546
5548
|
"attrs",
|
|
5547
5549
|
scopeIdentifier,
|
|
@@ -5555,7 +5557,7 @@ var native_tag_default = {
|
|
|
5555
5557
|
"effect",
|
|
5556
5558
|
section,
|
|
5557
5559
|
extra.referencedBindings,
|
|
5558
|
-
|
|
5560
|
+
import_compiler31.types.expressionStatement(
|
|
5559
5561
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
|
5560
5562
|
),
|
|
5561
5563
|
false
|
|
@@ -5576,7 +5578,7 @@ var native_tag_default = {
|
|
|
5576
5578
|
write2`>`;
|
|
5577
5579
|
}
|
|
5578
5580
|
if (isHTML && extra.tagNameNullable) {
|
|
5579
|
-
tag.insertBefore(
|
|
5581
|
+
tag.insertBefore(import_compiler31.types.ifStatement(name2.node, consumeHTML(tag)))[0].skip();
|
|
5580
5582
|
}
|
|
5581
5583
|
if (writeAtStartOfBody) {
|
|
5582
5584
|
write2`${writeAtStartOfBody}`;
|
|
@@ -5587,7 +5589,7 @@ var native_tag_default = {
|
|
|
5587
5589
|
const extra = tag.node.extra;
|
|
5588
5590
|
const nodeRef2 = extra[kNativeTagBinding];
|
|
5589
5591
|
const isHTML = isOutputHTML();
|
|
5590
|
-
const openTagOnly = (0,
|
|
5592
|
+
const openTagOnly = (0, import_babel_utils21.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
|
5591
5593
|
const selectArgs = isHTML && htmlSelectArgs.get(tag.node);
|
|
5592
5594
|
const tagName = getTagName(tag);
|
|
5593
5595
|
if (isHTML && extra.tagNameNullable) {
|
|
@@ -5597,16 +5599,16 @@ var native_tag_default = {
|
|
|
5597
5599
|
writeTo(tag)`</${tag.node.name}>`;
|
|
5598
5600
|
flushInto(tag);
|
|
5599
5601
|
tag.insertBefore(
|
|
5600
|
-
|
|
5602
|
+
import_compiler31.types.expressionStatement(
|
|
5601
5603
|
callRuntime(
|
|
5602
5604
|
"controllable_select_value",
|
|
5603
5605
|
getScopeIdIdentifier(getSection(tag)),
|
|
5604
5606
|
getScopeAccessorLiteral(nodeRef2),
|
|
5605
5607
|
selectArgs.value,
|
|
5606
5608
|
selectArgs.valueChange,
|
|
5607
|
-
|
|
5609
|
+
import_compiler31.types.arrowFunctionExpression(
|
|
5608
5610
|
[],
|
|
5609
|
-
|
|
5611
|
+
import_compiler31.types.blockStatement(tag.node.body.body)
|
|
5610
5612
|
)
|
|
5611
5613
|
)
|
|
5612
5614
|
)
|
|
@@ -5630,7 +5632,7 @@ var native_tag_default = {
|
|
|
5630
5632
|
}
|
|
5631
5633
|
if (isHTML && extra.tagNameNullable) {
|
|
5632
5634
|
tag.insertBefore(
|
|
5633
|
-
|
|
5635
|
+
import_compiler31.types.ifStatement(tag.node.name, consumeHTML(tag))
|
|
5634
5636
|
)[0].skip();
|
|
5635
5637
|
}
|
|
5636
5638
|
if (shouldMark) {
|
|
@@ -5653,7 +5655,7 @@ function getUsedAttrs(tagName, tag) {
|
|
|
5653
5655
|
for (let i = attributes.length; i--; ) {
|
|
5654
5656
|
const attr2 = attributes[i];
|
|
5655
5657
|
const { value } = attr2;
|
|
5656
|
-
if (
|
|
5658
|
+
if (import_compiler31.types.isMarkoSpreadAttribute(attr2)) {
|
|
5657
5659
|
if (!spreadProps) {
|
|
5658
5660
|
spreadProps = [];
|
|
5659
5661
|
staticControllable = getRelatedControllable(tagName, seen);
|
|
@@ -5667,7 +5669,7 @@ function getUsedAttrs(tagName, tag) {
|
|
|
5667
5669
|
staticControllable = void 0;
|
|
5668
5670
|
}
|
|
5669
5671
|
}
|
|
5670
|
-
spreadProps.push(
|
|
5672
|
+
spreadProps.push(import_compiler31.types.spreadElement(value));
|
|
5671
5673
|
} else if (!seen[attr2.name]) {
|
|
5672
5674
|
seen[attr2.name] = attr2;
|
|
5673
5675
|
if (spreadProps) {
|
|
@@ -5697,16 +5699,16 @@ function getUsedAttrs(tagName, tag) {
|
|
|
5697
5699
|
for (const attr2 of staticControllable.attrs) {
|
|
5698
5700
|
if (attr2) {
|
|
5699
5701
|
(skipProps ||= []).push(
|
|
5700
|
-
toObjectProperty(attr2.name,
|
|
5702
|
+
toObjectProperty(attr2.name, import_compiler31.types.numericLiteral(1))
|
|
5701
5703
|
);
|
|
5702
5704
|
}
|
|
5703
5705
|
}
|
|
5704
5706
|
}
|
|
5705
5707
|
for (const { name: name2 } of staticAttrs) {
|
|
5706
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
|
5708
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler31.types.numericLiteral(1)));
|
|
5707
5709
|
}
|
|
5708
5710
|
if (skipProps) {
|
|
5709
|
-
skipExpression =
|
|
5711
|
+
skipExpression = import_compiler31.types.objectExpression(skipProps);
|
|
5710
5712
|
}
|
|
5711
5713
|
spreadExpression = propsToExpression(spreadProps);
|
|
5712
5714
|
}
|
|
@@ -5721,7 +5723,7 @@ function isChangeHandler(propName) {
|
|
|
5721
5723
|
return /^(?:value|checked(?:Value)?|open)Change/.test(propName);
|
|
5722
5724
|
}
|
|
5723
5725
|
function buildUndefined() {
|
|
5724
|
-
return
|
|
5726
|
+
return import_compiler31.types.unaryExpression("void", import_compiler31.types.numericLiteral(0));
|
|
5725
5727
|
}
|
|
5726
5728
|
|
|
5727
5729
|
// src/translator/util/is-only-child-in-parent.ts
|
|
@@ -5733,7 +5735,7 @@ function isOnlyChildInParent(tag, branchSize = 1) {
|
|
|
5733
5735
|
return extra[kOnlyChildInParent];
|
|
5734
5736
|
}
|
|
5735
5737
|
const parentTag = getParentTag(tag);
|
|
5736
|
-
if (parentTag && (0,
|
|
5738
|
+
if (parentTag && (0, import_babel_utils22.getTagDef)(parentTag)?.html) {
|
|
5737
5739
|
return extra[kOnlyChildInParent] = tag.parent.body.length === branchSize;
|
|
5738
5740
|
}
|
|
5739
5741
|
return extra[kOnlyChildInParent] = false;
|
|
@@ -5762,8 +5764,8 @@ var for_default = {
|
|
|
5762
5764
|
const tagExtra = tag.node.extra ??= {};
|
|
5763
5765
|
const isAttrTag = tag.node.body.attributeTags;
|
|
5764
5766
|
let allowAttrs;
|
|
5765
|
-
(0,
|
|
5766
|
-
(0,
|
|
5767
|
+
(0, import_babel_utils23.assertNoVar)(tag);
|
|
5768
|
+
(0, import_babel_utils23.assertNoArgs)(tag);
|
|
5767
5769
|
assertNoSpreadAttrs(tag);
|
|
5768
5770
|
switch (getForType(tag.node)) {
|
|
5769
5771
|
case "of":
|
|
@@ -5783,7 +5785,7 @@ var for_default = {
|
|
|
5783
5785
|
if (!isAttrTag) {
|
|
5784
5786
|
allowAttrs.push("by");
|
|
5785
5787
|
}
|
|
5786
|
-
(0,
|
|
5788
|
+
(0, import_babel_utils23.assertAllowedAttributes)(tag, allowAttrs);
|
|
5787
5789
|
if (isAttrTag) return;
|
|
5788
5790
|
const tagBody = tag.get("body");
|
|
5789
5791
|
const bodySection = startSection(tagBody);
|
|
@@ -5843,20 +5845,20 @@ var for_default = {
|
|
|
5843
5845
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
|
5844
5846
|
const forTagHTMLRuntime = serializeReason ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
|
|
5845
5847
|
forTagArgs.push(
|
|
5846
|
-
|
|
5848
|
+
import_compiler33.types.arrowFunctionExpression(params, import_compiler33.types.blockStatement(bodyStatements))
|
|
5847
5849
|
);
|
|
5848
5850
|
if (serializeReason) {
|
|
5849
5851
|
forTagArgs.push(
|
|
5850
|
-
forAttrs.by ||
|
|
5852
|
+
forAttrs.by || import_compiler33.types.numericLiteral(0),
|
|
5851
5853
|
getScopeIdIdentifier(tagSection),
|
|
5852
5854
|
getScopeAccessorLiteral(nodeRef2)
|
|
5853
5855
|
);
|
|
5854
5856
|
if (onlyChildInParentOptimization) {
|
|
5855
|
-
forTagArgs.push(
|
|
5857
|
+
forTagArgs.push(import_compiler33.types.numericLiteral(1));
|
|
5856
5858
|
}
|
|
5857
5859
|
}
|
|
5858
5860
|
statements.push(
|
|
5859
|
-
|
|
5861
|
+
import_compiler33.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
|
5860
5862
|
);
|
|
5861
5863
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
5862
5864
|
replacement.skip();
|
|
@@ -5901,7 +5903,7 @@ var for_default = {
|
|
|
5901
5903
|
return callRuntime(
|
|
5902
5904
|
forTypeToDOMRuntime(forType),
|
|
5903
5905
|
getScopeAccessorLiteral(nodeRef2),
|
|
5904
|
-
|
|
5906
|
+
import_compiler33.types.identifier(bodySection.name)
|
|
5905
5907
|
);
|
|
5906
5908
|
};
|
|
5907
5909
|
const params = node.body.params;
|
|
@@ -5932,7 +5934,7 @@ var for_default = {
|
|
|
5932
5934
|
tagSection,
|
|
5933
5935
|
referencedBindings,
|
|
5934
5936
|
signal,
|
|
5935
|
-
|
|
5937
|
+
import_compiler33.types.arrayExpression(loopArgs)
|
|
5936
5938
|
);
|
|
5937
5939
|
tag.remove();
|
|
5938
5940
|
}
|
|
@@ -5998,11 +6000,11 @@ var for_default = {
|
|
|
5998
6000
|
]
|
|
5999
6001
|
};
|
|
6000
6002
|
function buildForRuntimeCall(type, attrs2, params, statements) {
|
|
6001
|
-
return
|
|
6003
|
+
return import_compiler33.types.expressionStatement(
|
|
6002
6004
|
callRuntime(
|
|
6003
6005
|
forTypeToRuntime(type),
|
|
6004
6006
|
...getBaseArgsInForTag(type, attrs2),
|
|
6005
|
-
|
|
6007
|
+
import_compiler33.types.arrowFunctionExpression(params, import_compiler33.types.blockStatement(statements))
|
|
6006
6008
|
)
|
|
6007
6009
|
);
|
|
6008
6010
|
}
|
|
@@ -6068,8 +6070,8 @@ function getBaseArgsInForTag(type, attrs2) {
|
|
|
6068
6070
|
case "to":
|
|
6069
6071
|
return [
|
|
6070
6072
|
attrs2.to,
|
|
6071
|
-
attrs2.from ||
|
|
6072
|
-
attrs2.step ||
|
|
6073
|
+
attrs2.from || import_compiler33.types.numericLiteral(0),
|
|
6074
|
+
attrs2.step || import_compiler33.types.numericLiteral(1)
|
|
6073
6075
|
];
|
|
6074
6076
|
}
|
|
6075
6077
|
}
|
|
@@ -6087,8 +6089,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6087
6089
|
seen.add(attrTagMeta.name);
|
|
6088
6090
|
if (attrTagMeta.dynamic) {
|
|
6089
6091
|
statements.push(
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
+
import_compiler34.types.variableDeclaration("let", [
|
|
6093
|
+
import_compiler34.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
|
|
6092
6094
|
])
|
|
6093
6095
|
);
|
|
6094
6096
|
properties.push(
|
|
@@ -6104,7 +6106,7 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6104
6106
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
6105
6107
|
const child = attrTags2[i];
|
|
6106
6108
|
if (child.isMarkoTag()) {
|
|
6107
|
-
if ((0,
|
|
6109
|
+
if ((0, import_babel_utils24.isAttributeTag)(child)) {
|
|
6108
6110
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
6109
6111
|
if (attrTagMeta.dynamic) {
|
|
6110
6112
|
i = addDynamicAttrTagStatements(
|
|
@@ -6170,8 +6172,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6170
6172
|
seen.add(contentKey);
|
|
6171
6173
|
const contentExpression = buildContent(tag.get("body"));
|
|
6172
6174
|
if (contentExpression) {
|
|
6173
|
-
const contentProp =
|
|
6174
|
-
|
|
6175
|
+
const contentProp = import_compiler34.types.objectProperty(
|
|
6176
|
+
import_compiler34.types.identifier(contentKey),
|
|
6175
6177
|
contentExpression
|
|
6176
6178
|
);
|
|
6177
6179
|
contentProps.add(contentProp);
|
|
@@ -6182,8 +6184,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
|
6182
6184
|
for (let i = attributes.length; i--; ) {
|
|
6183
6185
|
const attr2 = attributes[i];
|
|
6184
6186
|
const { value } = attr2;
|
|
6185
|
-
if (
|
|
6186
|
-
properties.push(
|
|
6187
|
+
if (import_compiler34.types.isMarkoSpreadAttribute(attr2)) {
|
|
6188
|
+
properties.push(import_compiler34.types.spreadElement(value));
|
|
6187
6189
|
} else if (!seen.has(attr2.name) && usesExport(templateExports, attr2.name)) {
|
|
6188
6190
|
seen.add(attr2.name);
|
|
6189
6191
|
properties.push(toObjectProperty(attr2.name, value));
|
|
@@ -6202,7 +6204,7 @@ function getTranslatedBodyContentProperty(props) {
|
|
|
6202
6204
|
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, templateExports, contentKey = "content") {
|
|
6203
6205
|
const tag = attrTags2[index];
|
|
6204
6206
|
if (tag.isMarkoTag()) {
|
|
6205
|
-
if ((0,
|
|
6207
|
+
if ((0, import_babel_utils24.isAttributeTag)(tag)) {
|
|
6206
6208
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
|
6207
6209
|
if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
|
|
6208
6210
|
const translatedAttrTag = translateAttrs(
|
|
@@ -6213,8 +6215,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6213
6215
|
);
|
|
6214
6216
|
if (attrTagMeta.repeated) {
|
|
6215
6217
|
statements.push(
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
+
import_compiler34.types.expressionStatement(
|
|
6219
|
+
import_compiler34.types.assignmentExpression(
|
|
6218
6220
|
"=",
|
|
6219
6221
|
getAttrTagIdentifier(attrTagMeta),
|
|
6220
6222
|
callRuntime(
|
|
@@ -6227,8 +6229,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6227
6229
|
);
|
|
6228
6230
|
} else {
|
|
6229
6231
|
statements.push(
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
+
import_compiler34.types.expressionStatement(
|
|
6233
|
+
import_compiler34.types.assignmentExpression(
|
|
6232
6234
|
"=",
|
|
6233
6235
|
getAttrTagIdentifier(attrTagMeta),
|
|
6234
6236
|
callRuntime(
|
|
@@ -6267,7 +6269,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6267
6269
|
return index;
|
|
6268
6270
|
}
|
|
6269
6271
|
function propsToExpression(props) {
|
|
6270
|
-
return props.length === 1 &&
|
|
6272
|
+
return props.length === 1 && import_compiler34.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler34.types.objectExpression(props);
|
|
6271
6273
|
}
|
|
6272
6274
|
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6273
6275
|
const forTag = attrTags2[index];
|
|
@@ -6292,9 +6294,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
|
6292
6294
|
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6293
6295
|
const ifTag = attrTags2[index];
|
|
6294
6296
|
const consequentStatements = [];
|
|
6295
|
-
let ifStatement =
|
|
6297
|
+
let ifStatement = import_compiler34.types.ifStatement(
|
|
6296
6298
|
getConditionTestValue(ifTag),
|
|
6297
|
-
|
|
6299
|
+
import_compiler34.types.blockStatement(consequentStatements)
|
|
6298
6300
|
);
|
|
6299
6301
|
statements.push(ifStatement);
|
|
6300
6302
|
addAllAttrTagsAsDynamic(
|
|
@@ -6321,14 +6323,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
6321
6323
|
contentKey
|
|
6322
6324
|
);
|
|
6323
6325
|
if (testValue) {
|
|
6324
|
-
ifStatement.alternate = ifStatement =
|
|
6326
|
+
ifStatement.alternate = ifStatement = import_compiler34.types.ifStatement(
|
|
6325
6327
|
testValue,
|
|
6326
|
-
|
|
6328
|
+
import_compiler34.types.blockStatement(alternateStatements)
|
|
6327
6329
|
);
|
|
6328
6330
|
nextIndex++;
|
|
6329
6331
|
continue;
|
|
6330
6332
|
} else {
|
|
6331
|
-
ifStatement.alternate =
|
|
6333
|
+
ifStatement.alternate = import_compiler34.types.blockStatement(alternateStatements);
|
|
6332
6334
|
break;
|
|
6333
6335
|
}
|
|
6334
6336
|
}
|
|
@@ -6385,10 +6387,10 @@ function buildContent(body) {
|
|
|
6385
6387
|
const serialized = isSerializedSection(bodySection);
|
|
6386
6388
|
return callRuntime(
|
|
6387
6389
|
serialized ? "registerContent" : "createContent",
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
+
import_compiler34.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
|
|
6391
|
+
import_compiler34.types.arrowFunctionExpression(
|
|
6390
6392
|
body.node.params,
|
|
6391
|
-
|
|
6393
|
+
import_compiler34.types.blockStatement(body.node.body)
|
|
6392
6394
|
),
|
|
6393
6395
|
serialized ? getScopeIdIdentifier(
|
|
6394
6396
|
getSection(
|
|
@@ -6399,7 +6401,7 @@ function buildContent(body) {
|
|
|
6399
6401
|
) : void 0
|
|
6400
6402
|
);
|
|
6401
6403
|
} else {
|
|
6402
|
-
return
|
|
6404
|
+
return import_compiler34.types.callExpression(import_compiler34.types.identifier(bodySection.name), [
|
|
6403
6405
|
scopeIdentifier
|
|
6404
6406
|
]);
|
|
6405
6407
|
}
|
|
@@ -6407,7 +6409,7 @@ function buildContent(body) {
|
|
|
6407
6409
|
}
|
|
6408
6410
|
function getNonAttributeTagParent(tag) {
|
|
6409
6411
|
let cur = tag;
|
|
6410
|
-
while ((0,
|
|
6412
|
+
while ((0, import_babel_utils24.isAttributeTag)(cur) || (0, import_babel_utils24.isTransparentTag)(cur)) {
|
|
6411
6413
|
cur = getParentTag(cur);
|
|
6412
6414
|
}
|
|
6413
6415
|
return cur;
|
|
@@ -6416,7 +6418,7 @@ function getNonAttributeTagParent(tag) {
|
|
|
6416
6418
|
// src/translator/core/define.ts
|
|
6417
6419
|
var define_default = {
|
|
6418
6420
|
analyze(tag) {
|
|
6419
|
-
(0,
|
|
6421
|
+
(0, import_babel_utils25.assertNoArgs)(tag);
|
|
6420
6422
|
if (!tag.node.var) {
|
|
6421
6423
|
throw tag.get("name").buildCodeFrameError("The `define` tag requires a tag variable.");
|
|
6422
6424
|
}
|
|
@@ -6484,24 +6486,24 @@ var define_default = {
|
|
|
6484
6486
|
};
|
|
6485
6487
|
|
|
6486
6488
|
// src/translator/core/effect.ts
|
|
6487
|
-
var
|
|
6488
|
-
var
|
|
6489
|
+
var import_compiler36 = require("@marko/compiler");
|
|
6490
|
+
var import_babel_utils26 = require("@marko/compiler/babel-utils");
|
|
6489
6491
|
var effect_default = {
|
|
6490
6492
|
migrate: [
|
|
6491
6493
|
(tag) => {
|
|
6492
|
-
(0,
|
|
6493
|
-
(0,
|
|
6494
|
+
(0, import_babel_utils26.assertNoArgs)(tag);
|
|
6495
|
+
(0, import_babel_utils26.assertNoParams)(tag);
|
|
6494
6496
|
assertNoBodyContent(tag);
|
|
6495
|
-
(0,
|
|
6497
|
+
(0, import_babel_utils26.assertNoAttributeTags)(tag);
|
|
6496
6498
|
assertNoSpreadAttrs(tag);
|
|
6497
|
-
(0,
|
|
6498
|
-
(0,
|
|
6499
|
+
(0, import_babel_utils26.assertAllowedAttributes)(tag, ["value"]);
|
|
6500
|
+
(0, import_babel_utils26.diagnosticDeprecate)(tag, {
|
|
6499
6501
|
label: "The 'effect' tag has been replaced by the 'script' tag.",
|
|
6500
6502
|
fix() {
|
|
6501
6503
|
const { node } = tag;
|
|
6502
6504
|
tag.replaceWith(
|
|
6503
|
-
|
|
6504
|
-
withPreviousLocation(
|
|
6505
|
+
import_compiler36.types.markoTag(
|
|
6506
|
+
withPreviousLocation(import_compiler36.types.stringLiteral("script"), node.name),
|
|
6505
6507
|
node.attributes,
|
|
6506
6508
|
node.body,
|
|
6507
6509
|
node.arguments,
|
|
@@ -6518,12 +6520,12 @@ var effect_default = {
|
|
|
6518
6520
|
};
|
|
6519
6521
|
|
|
6520
6522
|
// src/translator/core/export.ts
|
|
6521
|
-
var
|
|
6523
|
+
var import_babel_utils27 = require("@marko/compiler/babel-utils");
|
|
6522
6524
|
var export_default = {
|
|
6523
6525
|
parse(tag) {
|
|
6524
6526
|
const { node } = tag;
|
|
6525
6527
|
tag.replaceWith(
|
|
6526
|
-
(0,
|
|
6528
|
+
(0, import_babel_utils27.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
6527
6529
|
);
|
|
6528
6530
|
},
|
|
6529
6531
|
parseOptions: {
|
|
@@ -6538,20 +6540,20 @@ var export_default = {
|
|
|
6538
6540
|
};
|
|
6539
6541
|
|
|
6540
6542
|
// src/translator/core/html-comment.ts
|
|
6541
|
-
var
|
|
6542
|
-
var
|
|
6543
|
+
var import_compiler37 = require("@marko/compiler");
|
|
6544
|
+
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
|
6543
6545
|
var kCommentTagBinding = Symbol("comment tag binding");
|
|
6544
6546
|
var kGetterId2 = Symbol("node getter id");
|
|
6545
6547
|
var html_comment_default = {
|
|
6546
6548
|
analyze(tag) {
|
|
6547
|
-
(0,
|
|
6548
|
-
(0,
|
|
6549
|
-
(0,
|
|
6549
|
+
(0, import_babel_utils28.assertNoArgs)(tag);
|
|
6550
|
+
(0, import_babel_utils28.assertNoParams)(tag);
|
|
6551
|
+
(0, import_babel_utils28.assertNoAttributes)(tag);
|
|
6550
6552
|
const tagVar = tag.node.var;
|
|
6551
6553
|
let needsBinding = false;
|
|
6552
6554
|
let needsGetter = false;
|
|
6553
6555
|
if (tagVar) {
|
|
6554
|
-
if (!
|
|
6556
|
+
if (!import_compiler37.types.isIdentifier(tagVar)) {
|
|
6555
6557
|
throw tag.get("var").buildCodeFrameError(
|
|
6556
6558
|
"The `html-comment` tag variable cannot be destructured."
|
|
6557
6559
|
);
|
|
@@ -6603,7 +6605,7 @@ var html_comment_default = {
|
|
|
6603
6605
|
callRuntime(
|
|
6604
6606
|
"nodeRef",
|
|
6605
6607
|
getterId && getScopeIdIdentifier(getSection(tag)),
|
|
6606
|
-
getterId &&
|
|
6608
|
+
getterId && import_compiler37.types.stringLiteral(getterId)
|
|
6607
6609
|
)
|
|
6608
6610
|
);
|
|
6609
6611
|
} else {
|
|
@@ -6612,13 +6614,13 @@ var html_comment_default = {
|
|
|
6612
6614
|
let getterFnIdentifier;
|
|
6613
6615
|
if (getterId) {
|
|
6614
6616
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
6615
|
-
(0,
|
|
6616
|
-
|
|
6617
|
-
|
|
6617
|
+
(0, import_babel_utils28.getProgram)().node.body.push(
|
|
6618
|
+
import_compiler37.types.variableDeclaration("const", [
|
|
6619
|
+
import_compiler37.types.variableDeclarator(
|
|
6618
6620
|
getterFnIdentifier,
|
|
6619
6621
|
callRuntime(
|
|
6620
6622
|
"nodeRef",
|
|
6621
|
-
|
|
6623
|
+
import_compiler37.types.stringLiteral(getterId),
|
|
6622
6624
|
getScopeAccessorLiteral(commentBinding)
|
|
6623
6625
|
)
|
|
6624
6626
|
)
|
|
@@ -6629,13 +6631,13 @@ var html_comment_default = {
|
|
|
6629
6631
|
const referenceSection = getSection(reference);
|
|
6630
6632
|
if (isInvokedFunction(reference)) {
|
|
6631
6633
|
reference.parentPath.replaceWith(
|
|
6632
|
-
|
|
6634
|
+
import_compiler37.types.expressionStatement(
|
|
6633
6635
|
createScopeReadExpression(referenceSection, commentBinding)
|
|
6634
6636
|
)
|
|
6635
6637
|
);
|
|
6636
6638
|
} else if (getterFnIdentifier) {
|
|
6637
6639
|
reference.replaceWith(
|
|
6638
|
-
|
|
6640
|
+
import_compiler37.types.callExpression(getterFnIdentifier, [
|
|
6639
6641
|
getScopeExpression(referenceSection, getSection(tag))
|
|
6640
6642
|
])
|
|
6641
6643
|
);
|
|
@@ -6655,9 +6657,9 @@ var html_comment_default = {
|
|
|
6655
6657
|
const write2 = writeTo(tag);
|
|
6656
6658
|
if (isOutputHTML()) {
|
|
6657
6659
|
for (const child of tag.node.body.body) {
|
|
6658
|
-
if (
|
|
6660
|
+
if (import_compiler37.types.isMarkoText(child)) {
|
|
6659
6661
|
write2`${child.value}`;
|
|
6660
|
-
} else if (
|
|
6662
|
+
} else if (import_compiler37.types.isMarkoPlaceholder(child)) {
|
|
6661
6663
|
write2`${callRuntime("escapeXML", child.value)}`;
|
|
6662
6664
|
}
|
|
6663
6665
|
}
|
|
@@ -6666,10 +6668,10 @@ var html_comment_default = {
|
|
|
6666
6668
|
const templateExpressions = [];
|
|
6667
6669
|
let currentQuasi = "";
|
|
6668
6670
|
for (const child of tag.node.body.body) {
|
|
6669
|
-
if (
|
|
6671
|
+
if (import_compiler37.types.isMarkoText(child)) {
|
|
6670
6672
|
currentQuasi += child.value;
|
|
6671
|
-
} else if (
|
|
6672
|
-
templateQuasis.push(
|
|
6673
|
+
} else if (import_compiler37.types.isMarkoPlaceholder(child)) {
|
|
6674
|
+
templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
|
|
6673
6675
|
templateExpressions.push(child.value);
|
|
6674
6676
|
currentQuasi = "";
|
|
6675
6677
|
}
|
|
@@ -6677,20 +6679,20 @@ var html_comment_default = {
|
|
|
6677
6679
|
if (templateExpressions.length === 0) {
|
|
6678
6680
|
write2`${currentQuasi}`;
|
|
6679
6681
|
} else {
|
|
6680
|
-
templateQuasis.push(
|
|
6682
|
+
templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
|
|
6681
6683
|
addStatement(
|
|
6682
6684
|
"render",
|
|
6683
6685
|
getSection(tag),
|
|
6684
6686
|
tagExtra.referencedBindings,
|
|
6685
|
-
|
|
6687
|
+
import_compiler37.types.expressionStatement(
|
|
6686
6688
|
callRuntime(
|
|
6687
6689
|
"data",
|
|
6688
|
-
|
|
6690
|
+
import_compiler37.types.memberExpression(
|
|
6689
6691
|
scopeIdentifier,
|
|
6690
6692
|
getScopeAccessorLiteral(commentBinding),
|
|
6691
6693
|
true
|
|
6692
6694
|
),
|
|
6693
|
-
|
|
6695
|
+
import_compiler37.types.templateLiteral(templateQuasis, templateExpressions)
|
|
6694
6696
|
)
|
|
6695
6697
|
)
|
|
6696
6698
|
);
|
|
@@ -6717,15 +6719,15 @@ var html_comment_default = {
|
|
|
6717
6719
|
};
|
|
6718
6720
|
|
|
6719
6721
|
// src/translator/core/html-script.ts
|
|
6720
|
-
var
|
|
6721
|
-
var
|
|
6722
|
+
var import_compiler38 = require("@marko/compiler");
|
|
6723
|
+
var import_babel_utils29 = require("@marko/compiler/babel-utils");
|
|
6722
6724
|
var kGetterId3 = Symbol("node getter id");
|
|
6723
6725
|
var html_script_default = {
|
|
6724
6726
|
analyze(tag) {
|
|
6725
|
-
(0,
|
|
6726
|
-
(0,
|
|
6727
|
+
(0, import_babel_utils29.assertNoArgs)(tag);
|
|
6728
|
+
(0, import_babel_utils29.assertNoParams)(tag);
|
|
6727
6729
|
const { node } = tag;
|
|
6728
|
-
if (node.var && !
|
|
6730
|
+
if (node.var && !import_compiler38.types.isIdentifier(node.var)) {
|
|
6729
6731
|
throw tag.get("var").buildCodeFrameError(
|
|
6730
6732
|
"Tag variables on native elements cannot be destructured."
|
|
6731
6733
|
);
|
|
@@ -6738,7 +6740,7 @@ var html_script_default = {
|
|
|
6738
6740
|
let spreadReferenceNodes;
|
|
6739
6741
|
for (let i = attributes.length; i--; ) {
|
|
6740
6742
|
const attr2 = attributes[i];
|
|
6741
|
-
if (
|
|
6743
|
+
if (import_compiler38.types.isMarkoAttribute(attr2)) {
|
|
6742
6744
|
if (seen[attr2.name]) {
|
|
6743
6745
|
dropReferences(attr2.value);
|
|
6744
6746
|
continue;
|
|
@@ -6750,14 +6752,14 @@ var html_script_default = {
|
|
|
6750
6752
|
} else if (!evaluate(attr2.value).confident) {
|
|
6751
6753
|
hasDynamicAttributes = true;
|
|
6752
6754
|
}
|
|
6753
|
-
} else if (
|
|
6755
|
+
} else if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
|
|
6754
6756
|
hasEventHandlers = true;
|
|
6755
6757
|
hasDynamicAttributes = true;
|
|
6756
6758
|
(attr2.value.extra ??= {}).isEffect = true;
|
|
6757
6759
|
}
|
|
6758
6760
|
if (spreadReferenceNodes) {
|
|
6759
6761
|
spreadReferenceNodes.push(attr2.value);
|
|
6760
|
-
} else if (
|
|
6762
|
+
} else if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
|
|
6761
6763
|
spreadReferenceNodes = [attr2.value];
|
|
6762
6764
|
}
|
|
6763
6765
|
}
|
|
@@ -6767,10 +6769,10 @@ var html_script_default = {
|
|
|
6767
6769
|
const bodyPlaceholderNodes = [];
|
|
6768
6770
|
let hasBodyPlaceholders = false;
|
|
6769
6771
|
for (const child of tag.node.body.body) {
|
|
6770
|
-
if (
|
|
6772
|
+
if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
|
6771
6773
|
bodyPlaceholderNodes.push(child.value);
|
|
6772
6774
|
hasBodyPlaceholders = true;
|
|
6773
|
-
} else if (!
|
|
6775
|
+
} else if (!import_compiler38.types.isMarkoText(child)) {
|
|
6774
6776
|
throw tag.hub.buildError(
|
|
6775
6777
|
child,
|
|
6776
6778
|
"Invalid child. Only text is allowed inside an html-script."
|
|
@@ -6785,7 +6787,7 @@ var html_script_default = {
|
|
|
6785
6787
|
);
|
|
6786
6788
|
}
|
|
6787
6789
|
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
6788
|
-
(0,
|
|
6790
|
+
(0, import_babel_utils29.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
|
|
6789
6791
|
const tagExtra = node.extra ??= {};
|
|
6790
6792
|
const bindingName = "#script";
|
|
6791
6793
|
tagExtra[kSerializeMarker] = hasEventHandlers || !!node.var;
|
|
@@ -6825,7 +6827,7 @@ var html_script_default = {
|
|
|
6825
6827
|
callRuntime(
|
|
6826
6828
|
"nodeRef",
|
|
6827
6829
|
getterId && getScopeIdIdentifier(section),
|
|
6828
|
-
getterId &&
|
|
6830
|
+
getterId && import_compiler38.types.stringLiteral(getterId)
|
|
6829
6831
|
)
|
|
6830
6832
|
);
|
|
6831
6833
|
} else {
|
|
@@ -6834,13 +6836,13 @@ var html_script_default = {
|
|
|
6834
6836
|
let getterFnIdentifier;
|
|
6835
6837
|
if (getterId) {
|
|
6836
6838
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
6837
|
-
(0,
|
|
6838
|
-
|
|
6839
|
-
|
|
6839
|
+
(0, import_babel_utils29.getProgram)().node.body.push(
|
|
6840
|
+
import_compiler38.types.variableDeclaration("const", [
|
|
6841
|
+
import_compiler38.types.variableDeclarator(
|
|
6840
6842
|
getterFnIdentifier,
|
|
6841
6843
|
callRuntime(
|
|
6842
6844
|
"nodeRef",
|
|
6843
|
-
|
|
6845
|
+
import_compiler38.types.stringLiteral(getterId),
|
|
6844
6846
|
getScopeAccessorLiteral(nodeRef2)
|
|
6845
6847
|
)
|
|
6846
6848
|
)
|
|
@@ -6851,13 +6853,13 @@ var html_script_default = {
|
|
|
6851
6853
|
const referenceSection = getSection(reference);
|
|
6852
6854
|
if (isInvokedFunction(reference)) {
|
|
6853
6855
|
reference.parentPath.replaceWith(
|
|
6854
|
-
|
|
6856
|
+
import_compiler38.types.expressionStatement(
|
|
6855
6857
|
createScopeReadExpression(referenceSection, nodeRef2)
|
|
6856
6858
|
)
|
|
6857
6859
|
);
|
|
6858
6860
|
} else if (getterFnIdentifier) {
|
|
6859
6861
|
reference.replaceWith(
|
|
6860
|
-
|
|
6862
|
+
import_compiler38.types.callExpression(getterFnIdentifier, [
|
|
6861
6863
|
getScopeExpression(referenceSection, getSection(tag))
|
|
6862
6864
|
])
|
|
6863
6865
|
);
|
|
@@ -6890,10 +6892,10 @@ var html_script_default = {
|
|
|
6890
6892
|
"render",
|
|
6891
6893
|
section,
|
|
6892
6894
|
valueReferences,
|
|
6893
|
-
|
|
6895
|
+
import_compiler38.types.expressionStatement(
|
|
6894
6896
|
callRuntime(
|
|
6895
6897
|
helper,
|
|
6896
|
-
|
|
6898
|
+
import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
6897
6899
|
value
|
|
6898
6900
|
)
|
|
6899
6901
|
)
|
|
@@ -6908,18 +6910,18 @@ var html_script_default = {
|
|
|
6908
6910
|
if (isEventHandler(name2)) {
|
|
6909
6911
|
addHTMLEffectCall(section, valueReferences);
|
|
6910
6912
|
} else {
|
|
6911
|
-
write2`${callRuntime("attr",
|
|
6913
|
+
write2`${callRuntime("attr", import_compiler38.types.stringLiteral(name2), value)}`;
|
|
6912
6914
|
}
|
|
6913
6915
|
} else if (isEventHandler(name2)) {
|
|
6914
6916
|
addStatement(
|
|
6915
6917
|
"effect",
|
|
6916
6918
|
section,
|
|
6917
6919
|
valueReferences,
|
|
6918
|
-
|
|
6920
|
+
import_compiler38.types.expressionStatement(
|
|
6919
6921
|
callRuntime(
|
|
6920
6922
|
"on",
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
+
import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
6924
|
+
import_compiler38.types.stringLiteral(getEventHandlerName(name2)),
|
|
6923
6925
|
value
|
|
6924
6926
|
)
|
|
6925
6927
|
)
|
|
@@ -6929,11 +6931,11 @@ var html_script_default = {
|
|
|
6929
6931
|
"render",
|
|
6930
6932
|
section,
|
|
6931
6933
|
valueReferences,
|
|
6932
|
-
|
|
6934
|
+
import_compiler38.types.expressionStatement(
|
|
6933
6935
|
callRuntime(
|
|
6934
6936
|
"attr",
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
+
import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
6938
|
+
import_compiler38.types.stringLiteral(name2),
|
|
6937
6939
|
value
|
|
6938
6940
|
)
|
|
6939
6941
|
)
|
|
@@ -6946,9 +6948,9 @@ var html_script_default = {
|
|
|
6946
6948
|
if (isHTML) {
|
|
6947
6949
|
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
|
6948
6950
|
if (skipExpression) {
|
|
6949
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section),
|
|
6951
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler38.types.stringLiteral("script"))}`;
|
|
6950
6952
|
} else {
|
|
6951
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section),
|
|
6953
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler38.types.stringLiteral("script"))}`;
|
|
6952
6954
|
}
|
|
6953
6955
|
} else {
|
|
6954
6956
|
if (skipExpression) {
|
|
@@ -6956,7 +6958,7 @@ var html_script_default = {
|
|
|
6956
6958
|
"render",
|
|
6957
6959
|
section,
|
|
6958
6960
|
tagExtra.referencedBindings,
|
|
6959
|
-
|
|
6961
|
+
import_compiler38.types.expressionStatement(
|
|
6960
6962
|
callRuntime(
|
|
6961
6963
|
"partialAttrs",
|
|
6962
6964
|
scopeIdentifier,
|
|
@@ -6971,7 +6973,7 @@ var html_script_default = {
|
|
|
6971
6973
|
"render",
|
|
6972
6974
|
section,
|
|
6973
6975
|
tagExtra.referencedBindings,
|
|
6974
|
-
|
|
6976
|
+
import_compiler38.types.expressionStatement(
|
|
6975
6977
|
callRuntime(
|
|
6976
6978
|
"attrs",
|
|
6977
6979
|
scopeIdentifier,
|
|
@@ -6985,7 +6987,7 @@ var html_script_default = {
|
|
|
6985
6987
|
"effect",
|
|
6986
6988
|
section,
|
|
6987
6989
|
tagExtra.referencedBindings,
|
|
6988
|
-
|
|
6990
|
+
import_compiler38.types.expressionStatement(
|
|
6989
6991
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
|
6990
6992
|
),
|
|
6991
6993
|
false
|
|
@@ -7002,9 +7004,9 @@ var html_script_default = {
|
|
|
7002
7004
|
const visitAccessor = nodeRef2 && getScopeAccessorLiteral(nodeRef2);
|
|
7003
7005
|
if (isOutputHTML()) {
|
|
7004
7006
|
for (const child of tag.node.body.body) {
|
|
7005
|
-
if (
|
|
7007
|
+
if (import_compiler38.types.isMarkoText(child)) {
|
|
7006
7008
|
write2`${child.value}`;
|
|
7007
|
-
} else if (
|
|
7009
|
+
} else if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
|
7008
7010
|
write2`${callRuntime("escapeScript", child.value)}`;
|
|
7009
7011
|
}
|
|
7010
7012
|
}
|
|
@@ -7014,11 +7016,11 @@ var html_script_default = {
|
|
|
7014
7016
|
let currentQuasi = "";
|
|
7015
7017
|
let referencePlaceholder;
|
|
7016
7018
|
for (const child of tag.node.body.body) {
|
|
7017
|
-
if (
|
|
7019
|
+
if (import_compiler38.types.isMarkoText(child)) {
|
|
7018
7020
|
currentQuasi += child.value;
|
|
7019
|
-
} else if (
|
|
7021
|
+
} else if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
|
7020
7022
|
referencePlaceholder ||= child;
|
|
7021
|
-
templateQuasis.push(
|
|
7023
|
+
templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
|
|
7022
7024
|
templateExpressions.push(child.value);
|
|
7023
7025
|
currentQuasi = "";
|
|
7024
7026
|
}
|
|
@@ -7026,16 +7028,16 @@ var html_script_default = {
|
|
|
7026
7028
|
if (!referencePlaceholder) {
|
|
7027
7029
|
write2`${currentQuasi}`;
|
|
7028
7030
|
} else {
|
|
7029
|
-
templateQuasis.push(
|
|
7031
|
+
templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
|
|
7030
7032
|
addStatement(
|
|
7031
7033
|
"render",
|
|
7032
7034
|
getSection(tag),
|
|
7033
7035
|
referencePlaceholder.value.extra?.referencedBindings,
|
|
7034
|
-
|
|
7036
|
+
import_compiler38.types.expressionStatement(
|
|
7035
7037
|
callRuntime(
|
|
7036
7038
|
"textContent",
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
+
import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
7040
|
+
import_compiler38.types.templateLiteral(templateQuasis, templateExpressions)
|
|
7039
7041
|
)
|
|
7040
7042
|
)
|
|
7041
7043
|
);
|
|
@@ -7075,11 +7077,11 @@ function getUsedAttrs2(tag) {
|
|
|
7075
7077
|
for (let i = attributes.length; i--; ) {
|
|
7076
7078
|
const attr2 = attributes[i];
|
|
7077
7079
|
const { value } = attr2;
|
|
7078
|
-
if (
|
|
7080
|
+
if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
|
|
7079
7081
|
if (!spreadProps) {
|
|
7080
7082
|
spreadProps = [];
|
|
7081
7083
|
}
|
|
7082
|
-
spreadProps.push(
|
|
7084
|
+
spreadProps.push(import_compiler38.types.spreadElement(value));
|
|
7083
7085
|
} else if (!seen[attr2.name]) {
|
|
7084
7086
|
seen[attr2.name] = attr2;
|
|
7085
7087
|
if (spreadProps) {
|
|
@@ -7093,10 +7095,10 @@ function getUsedAttrs2(tag) {
|
|
|
7093
7095
|
if (spreadProps) {
|
|
7094
7096
|
spreadProps.reverse();
|
|
7095
7097
|
for (const { name: name2 } of staticAttrs) {
|
|
7096
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
|
7098
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler38.types.numericLiteral(1)));
|
|
7097
7099
|
}
|
|
7098
7100
|
if (skipProps) {
|
|
7099
|
-
skipExpression =
|
|
7101
|
+
skipExpression = import_compiler38.types.objectExpression(skipProps);
|
|
7100
7102
|
}
|
|
7101
7103
|
spreadExpression = propsToExpression(spreadProps);
|
|
7102
7104
|
}
|
|
@@ -7108,15 +7110,15 @@ function getUsedAttrs2(tag) {
|
|
|
7108
7110
|
}
|
|
7109
7111
|
|
|
7110
7112
|
// src/translator/core/html-style.ts
|
|
7111
|
-
var
|
|
7112
|
-
var
|
|
7113
|
+
var import_compiler39 = require("@marko/compiler");
|
|
7114
|
+
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
|
7113
7115
|
var kGetterId4 = Symbol("node getter id");
|
|
7114
7116
|
var html_style_default = {
|
|
7115
7117
|
analyze(tag) {
|
|
7116
|
-
(0,
|
|
7117
|
-
(0,
|
|
7118
|
+
(0, import_babel_utils30.assertNoArgs)(tag);
|
|
7119
|
+
(0, import_babel_utils30.assertNoParams)(tag);
|
|
7118
7120
|
const { node } = tag;
|
|
7119
|
-
if (node.var && !
|
|
7121
|
+
if (node.var && !import_compiler39.types.isIdentifier(node.var)) {
|
|
7120
7122
|
throw tag.get("var").buildCodeFrameError(
|
|
7121
7123
|
"Tag variables on native elements cannot be destructured."
|
|
7122
7124
|
);
|
|
@@ -7129,7 +7131,7 @@ var html_style_default = {
|
|
|
7129
7131
|
let spreadReferenceNodes;
|
|
7130
7132
|
for (let i = attributes.length; i--; ) {
|
|
7131
7133
|
const attr2 = attributes[i];
|
|
7132
|
-
if (
|
|
7134
|
+
if (import_compiler39.types.isMarkoAttribute(attr2)) {
|
|
7133
7135
|
if (seen[attr2.name]) {
|
|
7134
7136
|
dropReferences(attr2.value);
|
|
7135
7137
|
continue;
|
|
@@ -7141,14 +7143,14 @@ var html_style_default = {
|
|
|
7141
7143
|
} else if (!evaluate(attr2.value).confident) {
|
|
7142
7144
|
hasDynamicAttributes = true;
|
|
7143
7145
|
}
|
|
7144
|
-
} else if (
|
|
7146
|
+
} else if (import_compiler39.types.isMarkoSpreadAttribute(attr2)) {
|
|
7145
7147
|
hasEventHandlers = true;
|
|
7146
7148
|
hasDynamicAttributes = true;
|
|
7147
7149
|
(attr2.value.extra ??= {}).isEffect = true;
|
|
7148
7150
|
}
|
|
7149
7151
|
if (spreadReferenceNodes) {
|
|
7150
7152
|
spreadReferenceNodes.push(attr2.value);
|
|
7151
|
-
} else if (
|
|
7153
|
+
} else if (import_compiler39.types.isMarkoSpreadAttribute(attr2)) {
|
|
7152
7154
|
spreadReferenceNodes = [attr2.value];
|
|
7153
7155
|
}
|
|
7154
7156
|
}
|
|
@@ -7158,10 +7160,10 @@ var html_style_default = {
|
|
|
7158
7160
|
const bodyPlaceholderNodes = [];
|
|
7159
7161
|
let hasBodyPlaceholders = false;
|
|
7160
7162
|
for (const child of tag.node.body.body) {
|
|
7161
|
-
if (
|
|
7163
|
+
if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
|
7162
7164
|
bodyPlaceholderNodes.push(child.value);
|
|
7163
7165
|
hasBodyPlaceholders = true;
|
|
7164
|
-
} else if (!
|
|
7166
|
+
} else if (!import_compiler39.types.isMarkoText(child)) {
|
|
7165
7167
|
throw tag.hub.buildError(
|
|
7166
7168
|
child,
|
|
7167
7169
|
"Invalid child. Only text is allowed inside an html-style."
|
|
@@ -7176,7 +7178,7 @@ var html_style_default = {
|
|
|
7176
7178
|
);
|
|
7177
7179
|
}
|
|
7178
7180
|
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
7179
|
-
(0,
|
|
7181
|
+
(0, import_babel_utils30.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
|
|
7180
7182
|
const tagExtra = node.extra ??= {};
|
|
7181
7183
|
const bindingName = "#style";
|
|
7182
7184
|
tagExtra[kSerializeMarker] = hasEventHandlers || !!node.var;
|
|
@@ -7216,7 +7218,7 @@ var html_style_default = {
|
|
|
7216
7218
|
callRuntime(
|
|
7217
7219
|
"nodeRef",
|
|
7218
7220
|
getterId && getScopeIdIdentifier(section),
|
|
7219
|
-
getterId &&
|
|
7221
|
+
getterId && import_compiler39.types.stringLiteral(getterId)
|
|
7220
7222
|
)
|
|
7221
7223
|
);
|
|
7222
7224
|
} else {
|
|
@@ -7225,13 +7227,13 @@ var html_style_default = {
|
|
|
7225
7227
|
let getterFnIdentifier;
|
|
7226
7228
|
if (getterId) {
|
|
7227
7229
|
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
7228
|
-
(0,
|
|
7229
|
-
|
|
7230
|
-
|
|
7230
|
+
(0, import_babel_utils30.getProgram)().node.body.push(
|
|
7231
|
+
import_compiler39.types.variableDeclaration("const", [
|
|
7232
|
+
import_compiler39.types.variableDeclarator(
|
|
7231
7233
|
getterFnIdentifier,
|
|
7232
7234
|
callRuntime(
|
|
7233
7235
|
"nodeRef",
|
|
7234
|
-
|
|
7236
|
+
import_compiler39.types.stringLiteral(getterId),
|
|
7235
7237
|
getScopeAccessorLiteral(nodeRef2)
|
|
7236
7238
|
)
|
|
7237
7239
|
)
|
|
@@ -7242,13 +7244,13 @@ var html_style_default = {
|
|
|
7242
7244
|
const referenceSection = getSection(reference);
|
|
7243
7245
|
if (isInvokedFunction(reference)) {
|
|
7244
7246
|
reference.parentPath.replaceWith(
|
|
7245
|
-
|
|
7247
|
+
import_compiler39.types.expressionStatement(
|
|
7246
7248
|
createScopeReadExpression(referenceSection, nodeRef2)
|
|
7247
7249
|
)
|
|
7248
7250
|
);
|
|
7249
7251
|
} else if (getterFnIdentifier) {
|
|
7250
7252
|
reference.replaceWith(
|
|
7251
|
-
|
|
7253
|
+
import_compiler39.types.callExpression(getterFnIdentifier, [
|
|
7252
7254
|
getScopeExpression(referenceSection, getSection(tag))
|
|
7253
7255
|
])
|
|
7254
7256
|
);
|
|
@@ -7281,10 +7283,10 @@ var html_style_default = {
|
|
|
7281
7283
|
"render",
|
|
7282
7284
|
section,
|
|
7283
7285
|
valueReferences,
|
|
7284
|
-
|
|
7286
|
+
import_compiler39.types.expressionStatement(
|
|
7285
7287
|
callRuntime(
|
|
7286
7288
|
helper,
|
|
7287
|
-
|
|
7289
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
7288
7290
|
value
|
|
7289
7291
|
)
|
|
7290
7292
|
)
|
|
@@ -7299,18 +7301,18 @@ var html_style_default = {
|
|
|
7299
7301
|
if (isEventHandler(name2)) {
|
|
7300
7302
|
addHTMLEffectCall(section, valueReferences);
|
|
7301
7303
|
} else {
|
|
7302
|
-
write2`${callRuntime("attr",
|
|
7304
|
+
write2`${callRuntime("attr", import_compiler39.types.stringLiteral(name2), value)}`;
|
|
7303
7305
|
}
|
|
7304
7306
|
} else if (isEventHandler(name2)) {
|
|
7305
7307
|
addStatement(
|
|
7306
7308
|
"effect",
|
|
7307
7309
|
section,
|
|
7308
7310
|
valueReferences,
|
|
7309
|
-
|
|
7311
|
+
import_compiler39.types.expressionStatement(
|
|
7310
7312
|
callRuntime(
|
|
7311
7313
|
"on",
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
7315
|
+
import_compiler39.types.stringLiteral(getEventHandlerName(name2)),
|
|
7314
7316
|
value
|
|
7315
7317
|
)
|
|
7316
7318
|
)
|
|
@@ -7320,11 +7322,11 @@ var html_style_default = {
|
|
|
7320
7322
|
"render",
|
|
7321
7323
|
section,
|
|
7322
7324
|
valueReferences,
|
|
7323
|
-
|
|
7325
|
+
import_compiler39.types.expressionStatement(
|
|
7324
7326
|
callRuntime(
|
|
7325
7327
|
"attr",
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
7329
|
+
import_compiler39.types.stringLiteral(name2),
|
|
7328
7330
|
value
|
|
7329
7331
|
)
|
|
7330
7332
|
)
|
|
@@ -7337,9 +7339,9 @@ var html_style_default = {
|
|
|
7337
7339
|
if (isHTML) {
|
|
7338
7340
|
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
|
7339
7341
|
if (skipExpression) {
|
|
7340
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section),
|
|
7342
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("style"))}`;
|
|
7341
7343
|
} else {
|
|
7342
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section),
|
|
7344
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("style"))}`;
|
|
7343
7345
|
}
|
|
7344
7346
|
} else {
|
|
7345
7347
|
if (skipExpression) {
|
|
@@ -7347,7 +7349,7 @@ var html_style_default = {
|
|
|
7347
7349
|
"render",
|
|
7348
7350
|
section,
|
|
7349
7351
|
tagExtra.referencedBindings,
|
|
7350
|
-
|
|
7352
|
+
import_compiler39.types.expressionStatement(
|
|
7351
7353
|
callRuntime(
|
|
7352
7354
|
"partialAttrs",
|
|
7353
7355
|
scopeIdentifier,
|
|
@@ -7362,7 +7364,7 @@ var html_style_default = {
|
|
|
7362
7364
|
"render",
|
|
7363
7365
|
section,
|
|
7364
7366
|
tagExtra.referencedBindings,
|
|
7365
|
-
|
|
7367
|
+
import_compiler39.types.expressionStatement(
|
|
7366
7368
|
callRuntime(
|
|
7367
7369
|
"attrs",
|
|
7368
7370
|
scopeIdentifier,
|
|
@@ -7376,7 +7378,7 @@ var html_style_default = {
|
|
|
7376
7378
|
"effect",
|
|
7377
7379
|
section,
|
|
7378
7380
|
tagExtra.referencedBindings,
|
|
7379
|
-
|
|
7381
|
+
import_compiler39.types.expressionStatement(
|
|
7380
7382
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
|
7381
7383
|
),
|
|
7382
7384
|
false
|
|
@@ -7393,9 +7395,9 @@ var html_style_default = {
|
|
|
7393
7395
|
enter2(tag);
|
|
7394
7396
|
if (isOutputHTML()) {
|
|
7395
7397
|
for (const child of tag.node.body.body) {
|
|
7396
|
-
if (
|
|
7398
|
+
if (import_compiler39.types.isMarkoText(child)) {
|
|
7397
7399
|
write2`${child.value}`;
|
|
7398
|
-
} else if (
|
|
7400
|
+
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
|
7399
7401
|
write2`${callRuntime("escapeStyle", child.value)}`;
|
|
7400
7402
|
}
|
|
7401
7403
|
}
|
|
@@ -7405,11 +7407,11 @@ var html_style_default = {
|
|
|
7405
7407
|
let currentQuasi = "";
|
|
7406
7408
|
let referencePlaceholder;
|
|
7407
7409
|
for (const child of tag.node.body.body) {
|
|
7408
|
-
if (
|
|
7410
|
+
if (import_compiler39.types.isMarkoText(child)) {
|
|
7409
7411
|
currentQuasi += child.value;
|
|
7410
|
-
} else if (
|
|
7412
|
+
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
|
7411
7413
|
referencePlaceholder ||= child;
|
|
7412
|
-
templateQuasis.push(
|
|
7414
|
+
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
|
7413
7415
|
templateExpressions.push(child.value);
|
|
7414
7416
|
currentQuasi = "";
|
|
7415
7417
|
}
|
|
@@ -7417,16 +7419,16 @@ var html_style_default = {
|
|
|
7417
7419
|
if (!referencePlaceholder) {
|
|
7418
7420
|
write2`${currentQuasi}`;
|
|
7419
7421
|
} else {
|
|
7420
|
-
templateQuasis.push(
|
|
7422
|
+
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
|
7421
7423
|
addStatement(
|
|
7422
7424
|
"render",
|
|
7423
7425
|
getSection(tag),
|
|
7424
7426
|
referencePlaceholder.value.extra?.referencedBindings,
|
|
7425
|
-
|
|
7427
|
+
import_compiler39.types.expressionStatement(
|
|
7426
7428
|
callRuntime(
|
|
7427
7429
|
"textContent",
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
|
7431
|
+
import_compiler39.types.templateLiteral(templateQuasis, templateExpressions)
|
|
7430
7432
|
)
|
|
7431
7433
|
)
|
|
7432
7434
|
);
|
|
@@ -7461,11 +7463,11 @@ function getUsedAttrs3(tag) {
|
|
|
7461
7463
|
for (let i = attributes.length; i--; ) {
|
|
7462
7464
|
const attr2 = attributes[i];
|
|
7463
7465
|
const { value } = attr2;
|
|
7464
|
-
if (
|
|
7466
|
+
if (import_compiler39.types.isMarkoSpreadAttribute(attr2)) {
|
|
7465
7467
|
if (!spreadProps) {
|
|
7466
7468
|
spreadProps = [];
|
|
7467
7469
|
}
|
|
7468
|
-
spreadProps.push(
|
|
7470
|
+
spreadProps.push(import_compiler39.types.spreadElement(value));
|
|
7469
7471
|
} else if (!seen[attr2.name]) {
|
|
7470
7472
|
seen[attr2.name] = attr2;
|
|
7471
7473
|
if (spreadProps) {
|
|
@@ -7479,10 +7481,10 @@ function getUsedAttrs3(tag) {
|
|
|
7479
7481
|
if (spreadProps) {
|
|
7480
7482
|
spreadProps.reverse();
|
|
7481
7483
|
for (const { name: name2 } of staticAttrs) {
|
|
7482
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
|
7484
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler39.types.numericLiteral(1)));
|
|
7483
7485
|
}
|
|
7484
7486
|
if (skipProps) {
|
|
7485
|
-
skipExpression =
|
|
7487
|
+
skipExpression = import_compiler39.types.objectExpression(skipProps);
|
|
7486
7488
|
}
|
|
7487
7489
|
spreadExpression = propsToExpression(spreadProps);
|
|
7488
7490
|
}
|
|
@@ -7494,20 +7496,20 @@ function getUsedAttrs3(tag) {
|
|
|
7494
7496
|
}
|
|
7495
7497
|
|
|
7496
7498
|
// src/translator/core/id.ts
|
|
7497
|
-
var
|
|
7498
|
-
var
|
|
7499
|
+
var import_compiler40 = require("@marko/compiler");
|
|
7500
|
+
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
|
7499
7501
|
var id_default = {
|
|
7500
7502
|
analyze(tag) {
|
|
7501
|
-
(0,
|
|
7502
|
-
(0,
|
|
7503
|
-
(0,
|
|
7503
|
+
(0, import_babel_utils31.assertNoArgs)(tag);
|
|
7504
|
+
(0, import_babel_utils31.assertNoParams)(tag);
|
|
7505
|
+
(0, import_babel_utils31.assertNoAttributes)(tag);
|
|
7504
7506
|
assertNoBodyContent(tag);
|
|
7505
|
-
(0,
|
|
7507
|
+
(0, import_babel_utils31.assertNoAttributeTags)(tag);
|
|
7506
7508
|
const { node } = tag;
|
|
7507
7509
|
if (!node.var) {
|
|
7508
7510
|
throw tag.get("name").buildCodeFrameError("The `id` tag requires a tag variable.");
|
|
7509
7511
|
}
|
|
7510
|
-
if (!
|
|
7512
|
+
if (!import_compiler40.types.isIdentifier(node.var)) {
|
|
7511
7513
|
throw tag.get("var").buildCodeFrameError("The `id` tag cannot be destructured");
|
|
7512
7514
|
}
|
|
7513
7515
|
trackVarReferences(tag, 4 /* derived */);
|
|
@@ -7518,7 +7520,7 @@ var id_default = {
|
|
|
7518
7520
|
const id = isOutputHTML() ? callRuntime("nextTagId") : callRuntime("nextTagId", scopeIdentifier);
|
|
7519
7521
|
if (isOutputHTML()) {
|
|
7520
7522
|
tag.replaceWith(
|
|
7521
|
-
|
|
7523
|
+
import_compiler40.types.variableDeclaration("const", [import_compiler40.types.variableDeclarator(node.var, id)])
|
|
7522
7524
|
);
|
|
7523
7525
|
} else {
|
|
7524
7526
|
const source = initValue(node.var.extra.binding);
|
|
@@ -7543,17 +7545,17 @@ var id_default = {
|
|
|
7543
7545
|
};
|
|
7544
7546
|
|
|
7545
7547
|
// src/translator/core/if.ts
|
|
7546
|
-
var
|
|
7547
|
-
var
|
|
7548
|
+
var import_compiler42 = require("@marko/compiler");
|
|
7549
|
+
var import_babel_utils32 = require("@marko/compiler/babel-utils");
|
|
7548
7550
|
|
|
7549
7551
|
// src/translator/util/to-first-statement-or-block.ts
|
|
7550
|
-
var
|
|
7552
|
+
var import_compiler41 = require("@marko/compiler");
|
|
7551
7553
|
function toFirstStatementOrBlock(body) {
|
|
7552
7554
|
if (Array.isArray(body)) {
|
|
7553
7555
|
if (body.length === 1) {
|
|
7554
7556
|
return body[0];
|
|
7555
7557
|
}
|
|
7556
|
-
return
|
|
7558
|
+
return import_compiler41.types.blockStatement(body);
|
|
7557
7559
|
}
|
|
7558
7560
|
return body;
|
|
7559
7561
|
}
|
|
@@ -7640,13 +7642,13 @@ var IfTag = {
|
|
|
7640
7642
|
const bodyStatements = branchTag.node.body.body;
|
|
7641
7643
|
if (serializeReason) {
|
|
7642
7644
|
bodyStatements.push(
|
|
7643
|
-
|
|
7645
|
+
import_compiler42.types.returnStatement(import_compiler42.types.numericLiteral(i))
|
|
7644
7646
|
);
|
|
7645
7647
|
}
|
|
7646
7648
|
const [testAttr] = branchTag.node.attributes;
|
|
7647
7649
|
const curStatement = toFirstStatementOrBlock(bodyStatements);
|
|
7648
7650
|
if (testAttr) {
|
|
7649
|
-
statement =
|
|
7651
|
+
statement = import_compiler42.types.ifStatement(
|
|
7650
7652
|
testAttr.value,
|
|
7651
7653
|
curStatement,
|
|
7652
7654
|
statement
|
|
@@ -7658,24 +7660,24 @@ var IfTag = {
|
|
|
7658
7660
|
}
|
|
7659
7661
|
if (serializeReason) {
|
|
7660
7662
|
const conditionSerializeReason = branchSources?.referenced;
|
|
7661
|
-
const cbNode =
|
|
7663
|
+
const cbNode = import_compiler42.types.arrowFunctionExpression(
|
|
7662
7664
|
[],
|
|
7663
|
-
|
|
7665
|
+
import_compiler42.types.blockStatement([statement])
|
|
7664
7666
|
);
|
|
7665
|
-
statement =
|
|
7667
|
+
statement = import_compiler42.types.expressionStatement(
|
|
7666
7668
|
singleNodeOptimization ? callRuntime(
|
|
7667
7669
|
"resumeSingleNodeConditional",
|
|
7668
7670
|
cbNode,
|
|
7669
7671
|
getScopeIdIdentifier(section),
|
|
7670
7672
|
getScopeAccessorLiteral(nodeRef2),
|
|
7671
|
-
conditionSerializeReason ?
|
|
7672
|
-
onlyChildInParentOptimization &&
|
|
7673
|
+
conditionSerializeReason ? import_compiler42.types.numericLiteral(1) : onlyChildInParentOptimization ? import_compiler42.types.numericLiteral(0) : void 0,
|
|
7674
|
+
onlyChildInParentOptimization && import_compiler42.types.numericLiteral(1)
|
|
7673
7675
|
) : callRuntime(
|
|
7674
7676
|
"resumeConditional",
|
|
7675
7677
|
cbNode,
|
|
7676
7678
|
getScopeIdIdentifier(section),
|
|
7677
7679
|
getScopeAccessorLiteral(nodeRef2),
|
|
7678
|
-
conditionSerializeReason ?
|
|
7680
|
+
conditionSerializeReason ? import_compiler42.types.numericLiteral(1) : void 0
|
|
7679
7681
|
)
|
|
7680
7682
|
);
|
|
7681
7683
|
}
|
|
@@ -7708,25 +7710,25 @@ var IfTag = {
|
|
|
7708
7710
|
const rootExtra = branches[0][0].node.extra;
|
|
7709
7711
|
const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
|
|
7710
7712
|
const rendererIdentifiers = [];
|
|
7711
|
-
let expr =
|
|
7713
|
+
let expr = import_compiler42.types.numericLiteral(branches.length);
|
|
7712
7714
|
for (let i = branches.length; i--; ) {
|
|
7713
7715
|
const [branchTag, branchBodySection] = branches[i];
|
|
7714
7716
|
const [testAttr] = branchTag.node.attributes;
|
|
7715
|
-
const consequent =
|
|
7717
|
+
const consequent = import_compiler42.types.numericLiteral(branchBodySection ? i : -1);
|
|
7716
7718
|
if (branchBodySection) {
|
|
7717
|
-
rendererIdentifiers.push(
|
|
7719
|
+
rendererIdentifiers.push(import_compiler42.types.identifier(branchBodySection.name));
|
|
7718
7720
|
setClosureSignalBuilder(branchTag, (closure, render) => {
|
|
7719
7721
|
return callRuntime(
|
|
7720
7722
|
"conditionalClosure",
|
|
7721
7723
|
getScopeAccessorLiteral(closure),
|
|
7722
7724
|
getScopeAccessorLiteral(nodeRef2),
|
|
7723
|
-
|
|
7725
|
+
import_compiler42.types.numericLiteral(i),
|
|
7724
7726
|
render
|
|
7725
7727
|
);
|
|
7726
7728
|
});
|
|
7727
7729
|
}
|
|
7728
7730
|
branchTag.remove();
|
|
7729
|
-
expr = testAttr ?
|
|
7731
|
+
expr = testAttr ? import_compiler42.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
|
|
7730
7732
|
}
|
|
7731
7733
|
const signal = getSignal(section, nodeRef2, "if");
|
|
7732
7734
|
signal.build = () => {
|
|
@@ -7770,9 +7772,9 @@ var ElseTag = {
|
|
|
7770
7772
|
]
|
|
7771
7773
|
};
|
|
7772
7774
|
function assertValidCondition(tag) {
|
|
7773
|
-
(0,
|
|
7774
|
-
(0,
|
|
7775
|
-
(0,
|
|
7775
|
+
(0, import_babel_utils32.assertNoVar)(tag);
|
|
7776
|
+
(0, import_babel_utils32.assertNoArgs)(tag);
|
|
7777
|
+
(0, import_babel_utils32.assertNoParams)(tag);
|
|
7776
7778
|
assertHasBody(tag);
|
|
7777
7779
|
assertNoSpreadAttrs(tag);
|
|
7778
7780
|
switch (getTagName(tag)) {
|
|
@@ -7808,7 +7810,7 @@ function assertHasBody(tag) {
|
|
|
7808
7810
|
function assertHasValueAttribute(tag) {
|
|
7809
7811
|
const { node } = tag;
|
|
7810
7812
|
const [valueAttr] = node.attributes;
|
|
7811
|
-
if (!
|
|
7813
|
+
if (!import_compiler42.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
|
|
7812
7814
|
throw tag.get("name").buildCodeFrameError(`The \`${getTagName(tag)}\` tag requires a value.`);
|
|
7813
7815
|
}
|
|
7814
7816
|
if (node.attributes.length > 1) {
|
|
@@ -7875,12 +7877,12 @@ function isRoot(tag) {
|
|
|
7875
7877
|
}
|
|
7876
7878
|
|
|
7877
7879
|
// src/translator/core/import.ts
|
|
7878
|
-
var
|
|
7880
|
+
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
|
7879
7881
|
var import_default = {
|
|
7880
7882
|
parse(tag) {
|
|
7881
7883
|
const { node } = tag;
|
|
7882
7884
|
tag.replaceWith(
|
|
7883
|
-
(0,
|
|
7885
|
+
(0, import_babel_utils33.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
7884
7886
|
);
|
|
7885
7887
|
},
|
|
7886
7888
|
parseOptions: {
|
|
@@ -7898,8 +7900,8 @@ var import_default = {
|
|
|
7898
7900
|
};
|
|
7899
7901
|
|
|
7900
7902
|
// src/translator/core/let.ts
|
|
7901
|
-
var
|
|
7902
|
-
var
|
|
7903
|
+
var import_compiler43 = require("@marko/compiler");
|
|
7904
|
+
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
7903
7905
|
var let_default = {
|
|
7904
7906
|
analyze(tag) {
|
|
7905
7907
|
const { node } = tag;
|
|
@@ -7907,7 +7909,7 @@ var let_default = {
|
|
|
7907
7909
|
let valueAttr;
|
|
7908
7910
|
let valueChangeAttr;
|
|
7909
7911
|
for (const attr2 of node.attributes) {
|
|
7910
|
-
if (
|
|
7912
|
+
if (import_compiler43.types.isMarkoAttribute(attr2)) {
|
|
7911
7913
|
if (attr2.name === "value") {
|
|
7912
7914
|
valueAttr = attr2;
|
|
7913
7915
|
} else if (attr2.name === "valueChange") {
|
|
@@ -7928,17 +7930,17 @@ var let_default = {
|
|
|
7928
7930
|
}
|
|
7929
7931
|
}
|
|
7930
7932
|
}
|
|
7931
|
-
(0,
|
|
7932
|
-
(0,
|
|
7933
|
+
(0, import_babel_utils34.assertNoArgs)(tag);
|
|
7934
|
+
(0, import_babel_utils34.assertNoParams)(tag);
|
|
7933
7935
|
assertNoBodyContent(tag);
|
|
7934
7936
|
assertNoSpreadAttrs(tag);
|
|
7935
7937
|
if (!tagVar) {
|
|
7936
7938
|
throw tag.get("name").buildCodeFrameError("The `let` tag requires a tag variable.");
|
|
7937
7939
|
}
|
|
7938
|
-
if (!
|
|
7940
|
+
if (!import_compiler43.types.isIdentifier(tagVar)) {
|
|
7939
7941
|
throw tag.get("var").buildCodeFrameError("The `let` tag variable cannot be destructured.");
|
|
7940
7942
|
}
|
|
7941
|
-
if (valueChangeAttr && (0,
|
|
7943
|
+
if (valueChangeAttr && (0, import_babel_utils34.computeNode)(valueChangeAttr.value)) {
|
|
7942
7944
|
throw tag.get("attributes").find((attr2) => attr2.node === valueChangeAttr).get("value").buildCodeFrameError(
|
|
7943
7945
|
"The `let` tag `valueChange` attribute must be a function."
|
|
7944
7946
|
);
|
|
@@ -7954,10 +7956,10 @@ var let_default = {
|
|
|
7954
7956
|
const { node } = tag;
|
|
7955
7957
|
const tagVar = node.var;
|
|
7956
7958
|
const valueAttr = node.attributes.find(
|
|
7957
|
-
(attr2) =>
|
|
7958
|
-
) ??
|
|
7959
|
+
(attr2) => import_compiler43.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
|
|
7960
|
+
) ?? import_compiler43.types.markoAttribute("value", import_compiler43.types.identifier("undefined"));
|
|
7959
7961
|
const valueChangeAttr = node.attributes.find(
|
|
7960
|
-
(attr2) =>
|
|
7962
|
+
(attr2) => import_compiler43.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
|
|
7961
7963
|
);
|
|
7962
7964
|
const section = getSection(tag);
|
|
7963
7965
|
const binding = tagVar.extra.binding;
|
|
@@ -7970,7 +7972,7 @@ var let_default = {
|
|
|
7970
7972
|
}
|
|
7971
7973
|
signal.buildAssignment = (valueSection, value) => {
|
|
7972
7974
|
const scope = getScopeExpression(valueSection, signal.section);
|
|
7973
|
-
return
|
|
7975
|
+
return import_compiler43.types.callExpression(signal.identifier, [scope, value]);
|
|
7974
7976
|
};
|
|
7975
7977
|
} else {
|
|
7976
7978
|
translateVar(tag, valueAttr.value, "let");
|
|
@@ -8001,14 +8003,14 @@ var let_default = {
|
|
|
8001
8003
|
};
|
|
8002
8004
|
|
|
8003
8005
|
// src/translator/core/lifecycle.ts
|
|
8004
|
-
var
|
|
8005
|
-
var
|
|
8006
|
+
var import_compiler44 = require("@marko/compiler");
|
|
8007
|
+
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
8006
8008
|
var kRef = Symbol("lifecycle attrs reference");
|
|
8007
8009
|
var lifecycle_default = {
|
|
8008
8010
|
analyze(tag) {
|
|
8009
|
-
(0,
|
|
8010
|
-
(0,
|
|
8011
|
-
(0,
|
|
8011
|
+
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
8012
|
+
(0, import_babel_utils35.assertNoVar)(tag);
|
|
8013
|
+
(0, import_babel_utils35.assertNoParams)(tag);
|
|
8012
8014
|
assertNoBodyContent(tag);
|
|
8013
8015
|
const { node } = tag;
|
|
8014
8016
|
const tagExtra = node.extra ??= {};
|
|
@@ -8026,14 +8028,14 @@ var lifecycle_default = {
|
|
|
8026
8028
|
);
|
|
8027
8029
|
}
|
|
8028
8030
|
for (const attr2 of node.attributes) {
|
|
8029
|
-
if (
|
|
8031
|
+
if (import_compiler44.types.isMarkoSpreadAttribute(attr2)) {
|
|
8030
8032
|
throw tag.get("name").buildCodeFrameError(
|
|
8031
8033
|
"The `lifecycle` tag does not support `...spread` attributes."
|
|
8032
8034
|
);
|
|
8033
8035
|
}
|
|
8034
8036
|
(attr2.value.extra ??= {}).isEffect = true;
|
|
8035
8037
|
}
|
|
8036
|
-
((0,
|
|
8038
|
+
((0, import_babel_utils35.getProgram)().node.extra ??= {}).isInteractive = true;
|
|
8037
8039
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
|
8038
8040
|
},
|
|
8039
8041
|
translate: {
|
|
@@ -8046,7 +8048,7 @@ var lifecycle_default = {
|
|
|
8046
8048
|
if (isOutputDOM()) {
|
|
8047
8049
|
const translatedAttrs = translateAttrs(tag);
|
|
8048
8050
|
translatedAttrs.statements.push(
|
|
8049
|
-
|
|
8051
|
+
import_compiler44.types.expressionStatement(
|
|
8050
8052
|
callRuntime(
|
|
8051
8053
|
"lifecycle",
|
|
8052
8054
|
scopeIdentifier,
|
|
@@ -8081,19 +8083,19 @@ var lifecycle_default = {
|
|
|
8081
8083
|
};
|
|
8082
8084
|
|
|
8083
8085
|
// src/translator/core/log.ts
|
|
8084
|
-
var
|
|
8085
|
-
var
|
|
8086
|
+
var import_compiler45 = require("@marko/compiler");
|
|
8087
|
+
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
|
8086
8088
|
var log_default = {
|
|
8087
8089
|
analyze(tag) {
|
|
8088
8090
|
const [valueAttr] = tag.node.attributes;
|
|
8089
|
-
(0,
|
|
8090
|
-
(0,
|
|
8091
|
-
(0,
|
|
8091
|
+
(0, import_babel_utils36.assertNoArgs)(tag);
|
|
8092
|
+
(0, import_babel_utils36.assertNoVar)(tag);
|
|
8093
|
+
(0, import_babel_utils36.assertNoParams)(tag);
|
|
8092
8094
|
assertNoBodyContent(tag);
|
|
8093
8095
|
if (!valueAttr) {
|
|
8094
8096
|
throw tag.get("name").buildCodeFrameError("The `log` tag requires a value.");
|
|
8095
8097
|
}
|
|
8096
|
-
if (tag.node.attributes.length > 1 || !
|
|
8098
|
+
if (tag.node.attributes.length > 1 || !import_compiler45.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
|
8097
8099
|
throw tag.get("name").buildCodeFrameError(
|
|
8098
8100
|
"The `log` tag only supports the `value` attribute."
|
|
8099
8101
|
);
|
|
@@ -8105,9 +8107,9 @@ var log_default = {
|
|
|
8105
8107
|
const [valueAttr] = tag.node.attributes;
|
|
8106
8108
|
const { value } = valueAttr;
|
|
8107
8109
|
const referencedBindings = value.extra?.referencedBindings;
|
|
8108
|
-
const statement =
|
|
8109
|
-
|
|
8110
|
-
|
|
8110
|
+
const statement = import_compiler45.types.expressionStatement(
|
|
8111
|
+
import_compiler45.types.callExpression(
|
|
8112
|
+
import_compiler45.types.memberExpression(import_compiler45.types.identifier("console"), import_compiler45.types.identifier("log")),
|
|
8111
8113
|
[value]
|
|
8112
8114
|
)
|
|
8113
8115
|
);
|
|
@@ -8133,8 +8135,8 @@ var log_default = {
|
|
|
8133
8135
|
};
|
|
8134
8136
|
|
|
8135
8137
|
// src/translator/core/script.ts
|
|
8136
|
-
var
|
|
8137
|
-
var
|
|
8138
|
+
var import_compiler46 = require("@marko/compiler");
|
|
8139
|
+
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
|
8138
8140
|
var htmlScriptTagAlternateMsg = " For a native html `script` tag use the `html-script` core tag instead.";
|
|
8139
8141
|
var script_default = {
|
|
8140
8142
|
parse(tag) {
|
|
@@ -8154,22 +8156,22 @@ var script_default = {
|
|
|
8154
8156
|
}
|
|
8155
8157
|
const start = body[0]?.start;
|
|
8156
8158
|
const end = body[body.length - 1]?.end;
|
|
8157
|
-
const bodyStatements = (0,
|
|
8158
|
-
const valueFn =
|
|
8159
|
+
const bodyStatements = (0, import_babel_utils37.parseStatements)(tag.hub.file, code, start, end);
|
|
8160
|
+
const valueFn = import_compiler46.types.arrowFunctionExpression(
|
|
8159
8161
|
[],
|
|
8160
|
-
|
|
8162
|
+
import_compiler46.types.blockStatement(bodyStatements),
|
|
8161
8163
|
traverseContains(bodyStatements, isAwaitExpression)
|
|
8162
8164
|
);
|
|
8163
|
-
node.attributes.push(
|
|
8165
|
+
node.attributes.push(import_compiler46.types.markoAttribute("value", valueFn));
|
|
8164
8166
|
node.body.body = [];
|
|
8165
8167
|
}
|
|
8166
8168
|
},
|
|
8167
8169
|
analyze(tag) {
|
|
8168
8170
|
const { node } = tag;
|
|
8169
|
-
(0,
|
|
8170
|
-
(0,
|
|
8171
|
+
(0, import_babel_utils37.assertNoArgs)(tag);
|
|
8172
|
+
(0, import_babel_utils37.assertNoParams)(tag);
|
|
8171
8173
|
assertNoBodyContent(tag);
|
|
8172
|
-
(0,
|
|
8174
|
+
(0, import_babel_utils37.assertNoAttributeTags)(tag);
|
|
8173
8175
|
if (node.var) {
|
|
8174
8176
|
throw tag.hub.buildError(
|
|
8175
8177
|
node.var,
|
|
@@ -8184,7 +8186,7 @@ var script_default = {
|
|
|
8184
8186
|
}
|
|
8185
8187
|
seenValueAttr = true;
|
|
8186
8188
|
(attr2.value.extra ??= {}).isEffect = true;
|
|
8187
|
-
((0,
|
|
8189
|
+
((0, import_babel_utils37.getProgram)().node.extra ??= {}).isInteractive = true;
|
|
8188
8190
|
} else {
|
|
8189
8191
|
throw tag.hub.buildError(
|
|
8190
8192
|
attr2,
|
|
@@ -8209,28 +8211,28 @@ var script_default = {
|
|
|
8209
8211
|
const referencedBindings = value.extra?.referencedBindings;
|
|
8210
8212
|
if (isOutputDOM()) {
|
|
8211
8213
|
const { value: value2 } = valueAttr;
|
|
8212
|
-
const isFunction2 =
|
|
8214
|
+
const isFunction2 = import_compiler46.types.isFunctionExpression(value2) || import_compiler46.types.isArrowFunctionExpression(value2);
|
|
8213
8215
|
let inlineBody = null;
|
|
8214
8216
|
if (isFunction2 && !(value2.async || value2.generator)) {
|
|
8215
|
-
if (
|
|
8217
|
+
if (import_compiler46.types.isBlockStatement(value2.body)) {
|
|
8216
8218
|
let hasDeclaration = false;
|
|
8217
8219
|
for (const child of value2.body.body) {
|
|
8218
|
-
if (
|
|
8220
|
+
if (import_compiler46.types.isDeclaration(child)) {
|
|
8219
8221
|
hasDeclaration = true;
|
|
8220
8222
|
break;
|
|
8221
8223
|
}
|
|
8222
8224
|
}
|
|
8223
8225
|
inlineBody = hasDeclaration ? value2.body : value2.body.body;
|
|
8224
8226
|
} else {
|
|
8225
|
-
inlineBody =
|
|
8227
|
+
inlineBody = import_compiler46.types.expressionStatement(value2.body);
|
|
8226
8228
|
}
|
|
8227
8229
|
}
|
|
8228
8230
|
addStatement(
|
|
8229
8231
|
"effect",
|
|
8230
8232
|
section,
|
|
8231
8233
|
referencedBindings,
|
|
8232
|
-
inlineBody ||
|
|
8233
|
-
|
|
8234
|
+
inlineBody || import_compiler46.types.expressionStatement(
|
|
8235
|
+
import_compiler46.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
|
|
8234
8236
|
)
|
|
8235
8237
|
);
|
|
8236
8238
|
} else {
|
|
@@ -8272,8 +8274,8 @@ function isAwaitExpression(node) {
|
|
|
8272
8274
|
}
|
|
8273
8275
|
|
|
8274
8276
|
// src/translator/core/server.ts
|
|
8275
|
-
var
|
|
8276
|
-
var
|
|
8277
|
+
var import_compiler47 = require("@marko/compiler");
|
|
8278
|
+
var import_babel_utils38 = require("@marko/compiler/babel-utils");
|
|
8277
8279
|
var server_default = {
|
|
8278
8280
|
parse(tag) {
|
|
8279
8281
|
const {
|
|
@@ -8283,11 +8285,11 @@ var server_default = {
|
|
|
8283
8285
|
const rawValue = node.rawValue;
|
|
8284
8286
|
const code = rawValue.replace(/^server\s*/, "").trim();
|
|
8285
8287
|
const start = node.name.start + (rawValue.length - code.length);
|
|
8286
|
-
let body = (0,
|
|
8287
|
-
if (body.length === 1 &&
|
|
8288
|
+
let body = (0, import_babel_utils38.parseStatements)(file, code, start, start + code.length);
|
|
8289
|
+
if (body.length === 1 && import_compiler47.types.isBlockStatement(body[0])) {
|
|
8288
8290
|
body = body[0].body;
|
|
8289
8291
|
}
|
|
8290
|
-
tag.replaceWith(
|
|
8292
|
+
tag.replaceWith(import_compiler47.types.markoScriptlet(body, true, "server"));
|
|
8291
8293
|
},
|
|
8292
8294
|
parseOptions: {
|
|
8293
8295
|
statement: true,
|
|
@@ -8303,8 +8305,8 @@ var server_default = {
|
|
|
8303
8305
|
};
|
|
8304
8306
|
|
|
8305
8307
|
// src/translator/core/static.ts
|
|
8306
|
-
var
|
|
8307
|
-
var
|
|
8308
|
+
var import_compiler48 = require("@marko/compiler");
|
|
8309
|
+
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
|
8308
8310
|
var static_default = {
|
|
8309
8311
|
parse(tag) {
|
|
8310
8312
|
const {
|
|
@@ -8314,11 +8316,11 @@ var static_default = {
|
|
|
8314
8316
|
const rawValue = node.rawValue;
|
|
8315
8317
|
const code = rawValue.replace(/^static\s*/, "").trim();
|
|
8316
8318
|
const start = node.name.start + (rawValue.length - code.length);
|
|
8317
|
-
let body = (0,
|
|
8318
|
-
if (body.length === 1 &&
|
|
8319
|
+
let body = (0, import_babel_utils39.parseStatements)(file, code, start, start + code.length);
|
|
8320
|
+
if (body.length === 1 && import_compiler48.types.isBlockStatement(body[0])) {
|
|
8319
8321
|
body = body[0].body;
|
|
8320
8322
|
}
|
|
8321
|
-
tag.replaceWith(
|
|
8323
|
+
tag.replaceWith(import_compiler48.types.markoScriptlet(body, true));
|
|
8322
8324
|
},
|
|
8323
8325
|
parseOptions: {
|
|
8324
8326
|
statement: true,
|
|
@@ -8334,17 +8336,17 @@ var static_default = {
|
|
|
8334
8336
|
};
|
|
8335
8337
|
|
|
8336
8338
|
// src/translator/core/style.ts
|
|
8337
|
-
var
|
|
8338
|
-
var
|
|
8339
|
+
var import_compiler49 = require("@marko/compiler");
|
|
8340
|
+
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
|
8339
8341
|
var import_magic_string = __toESM(require("magic-string"));
|
|
8340
8342
|
var import_path3 = __toESM(require("path"));
|
|
8341
8343
|
var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
|
8342
8344
|
var htmlStyleTagAlternateMsg = " For a native html `style` tag use the `html-style` core tag instead.";
|
|
8343
8345
|
var style_default = {
|
|
8344
8346
|
analyze(tag) {
|
|
8345
|
-
(0,
|
|
8346
|
-
(0,
|
|
8347
|
-
(0,
|
|
8347
|
+
(0, import_babel_utils40.assertNoArgs)(tag);
|
|
8348
|
+
(0, import_babel_utils40.assertNoParams)(tag);
|
|
8349
|
+
(0, import_babel_utils40.assertNoAttributeTags)(tag);
|
|
8348
8350
|
const { node } = tag;
|
|
8349
8351
|
const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
|
|
8350
8352
|
for (const attr2 of node.attributes) {
|
|
@@ -8383,8 +8385,8 @@ var style_default = {
|
|
|
8383
8385
|
}
|
|
8384
8386
|
const markoText = node.body.body[0];
|
|
8385
8387
|
const { resolveVirtualDependency } = getMarkoOpts();
|
|
8386
|
-
const start = (0,
|
|
8387
|
-
const end = (0,
|
|
8388
|
+
const start = (0, import_babel_utils40.getStart)(file, markoText);
|
|
8389
|
+
const end = (0, import_babel_utils40.getEnd)(file, markoText);
|
|
8388
8390
|
let code = markoText.value;
|
|
8389
8391
|
let map2;
|
|
8390
8392
|
if (resolveVirtualDependency && sourceMaps && start !== null && end !== null) {
|
|
@@ -8410,22 +8412,22 @@ var style_default = {
|
|
|
8410
8412
|
});
|
|
8411
8413
|
if (importPath) {
|
|
8412
8414
|
if (!node.var) {
|
|
8413
|
-
(0,
|
|
8414
|
-
|
|
8415
|
+
(0, import_babel_utils40.getProgram)().node.body.push(
|
|
8416
|
+
import_compiler49.types.importDeclaration([], import_compiler49.types.stringLiteral(importPath))
|
|
8415
8417
|
);
|
|
8416
|
-
} else if (
|
|
8417
|
-
(0,
|
|
8418
|
-
|
|
8419
|
-
[
|
|
8420
|
-
|
|
8418
|
+
} else if (import_compiler49.types.isIdentifier(node.var)) {
|
|
8419
|
+
(0, import_babel_utils40.getProgram)().node.body.push(
|
|
8420
|
+
import_compiler49.types.importDeclaration(
|
|
8421
|
+
[import_compiler49.types.importDefaultSpecifier(node.var)],
|
|
8422
|
+
import_compiler49.types.stringLiteral(importPath)
|
|
8421
8423
|
)
|
|
8422
8424
|
);
|
|
8423
8425
|
} else {
|
|
8424
|
-
(0,
|
|
8425
|
-
|
|
8426
|
-
|
|
8426
|
+
(0, import_babel_utils40.getProgram)().node.body.push(
|
|
8427
|
+
import_compiler49.types.variableDeclaration("const", [
|
|
8428
|
+
import_compiler49.types.variableDeclarator(
|
|
8427
8429
|
node.var,
|
|
8428
|
-
(0,
|
|
8430
|
+
(0, import_babel_utils40.importDefault)(file, importPath, "style")
|
|
8429
8431
|
)
|
|
8430
8432
|
])
|
|
8431
8433
|
);
|
|
@@ -8443,15 +8445,15 @@ var style_default = {
|
|
|
8443
8445
|
};
|
|
8444
8446
|
|
|
8445
8447
|
// src/translator/core/try.ts
|
|
8446
|
-
var
|
|
8447
|
-
var
|
|
8448
|
+
var import_compiler50 = require("@marko/compiler");
|
|
8449
|
+
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
|
8448
8450
|
var kDOMBinding2 = Symbol("try tag dom binding");
|
|
8449
8451
|
var try_default = {
|
|
8450
8452
|
analyze(tag) {
|
|
8451
|
-
(0,
|
|
8452
|
-
(0,
|
|
8453
|
-
(0,
|
|
8454
|
-
(0,
|
|
8453
|
+
(0, import_babel_utils41.assertNoVar)(tag);
|
|
8454
|
+
(0, import_babel_utils41.assertNoArgs)(tag);
|
|
8455
|
+
(0, import_babel_utils41.assertNoParams)(tag);
|
|
8456
|
+
(0, import_babel_utils41.assertNoAttributes)(tag);
|
|
8455
8457
|
assertNoSpreadAttrs(tag);
|
|
8456
8458
|
analyzeAttributeTags(tag);
|
|
8457
8459
|
const { node } = tag;
|
|
@@ -8503,7 +8505,7 @@ var try_default = {
|
|
|
8503
8505
|
writeHTMLResumeStatements(tagBody);
|
|
8504
8506
|
tag.insertBefore(translatedAttrs.statements);
|
|
8505
8507
|
tag.replaceWith(
|
|
8506
|
-
|
|
8508
|
+
import_compiler50.types.expressionStatement(
|
|
8507
8509
|
callRuntime(
|
|
8508
8510
|
"tryContent",
|
|
8509
8511
|
getScopeIdIdentifier(section),
|
|
@@ -8545,7 +8547,7 @@ var try_default = {
|
|
|
8545
8547
|
return callRuntime(
|
|
8546
8548
|
"createTry",
|
|
8547
8549
|
getScopeAccessorLiteral(nodeRef2),
|
|
8548
|
-
|
|
8550
|
+
import_compiler50.types.identifier(bodySection.name)
|
|
8549
8551
|
);
|
|
8550
8552
|
};
|
|
8551
8553
|
if (translatedAttrs.statements.length) {
|
|
@@ -8556,8 +8558,8 @@ var try_default = {
|
|
|
8556
8558
|
translatedAttrs.statements
|
|
8557
8559
|
);
|
|
8558
8560
|
}
|
|
8559
|
-
(0,
|
|
8560
|
-
|
|
8561
|
+
(0, import_babel_utils41.getProgram)().node.body.push(
|
|
8562
|
+
import_compiler50.types.expressionStatement(callRuntime("enableCatch"))
|
|
8561
8563
|
);
|
|
8562
8564
|
addValue(
|
|
8563
8565
|
section,
|
|
@@ -8655,8 +8657,8 @@ var document_type_default = {
|
|
|
8655
8657
|
};
|
|
8656
8658
|
|
|
8657
8659
|
// src/translator/visitors/function.ts
|
|
8658
|
-
var
|
|
8659
|
-
var
|
|
8660
|
+
var import_compiler51 = require("@marko/compiler");
|
|
8661
|
+
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
|
8660
8662
|
var functionIdsBySection = /* @__PURE__ */ new WeakMap();
|
|
8661
8663
|
var function_default = {
|
|
8662
8664
|
analyze(fn) {
|
|
@@ -8667,18 +8669,18 @@ var function_default = {
|
|
|
8667
8669
|
if (markoRoot && (markoRoot.isMarkoPlaceholder() || markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server")) {
|
|
8668
8670
|
return;
|
|
8669
8671
|
}
|
|
8670
|
-
if (isMarkoAttribute(markoRoot) && ((0,
|
|
8672
|
+
if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils42.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
|
|
8671
8673
|
return;
|
|
8672
8674
|
}
|
|
8673
8675
|
const { node } = fn;
|
|
8674
8676
|
const extra = node.extra ??= {};
|
|
8675
|
-
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ?
|
|
8677
|
+
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler51.types.toIdentifier(
|
|
8676
8678
|
markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
|
|
8677
|
-
) : markoRoot.node.name :
|
|
8679
|
+
) : markoRoot.node.name : import_compiler51.types.isVariableDeclarator(fn.parent) && import_compiler51.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler51.types.isObjectMethod(node) && import_compiler51.types.isIdentifier(node.key) ? node.key.name : "anonymous");
|
|
8678
8680
|
const {
|
|
8679
8681
|
markoOpts,
|
|
8680
8682
|
opts: { filename }
|
|
8681
|
-
} = (0,
|
|
8683
|
+
} = (0, import_babel_utils42.getFile)();
|
|
8682
8684
|
const section = getSection(fn);
|
|
8683
8685
|
let functionNameCounts = functionIdsBySection.get(section);
|
|
8684
8686
|
if (!functionNameCounts) {
|
|
@@ -8694,7 +8696,7 @@ var function_default = {
|
|
|
8694
8696
|
id = `_${index}`;
|
|
8695
8697
|
}
|
|
8696
8698
|
extra.section = section;
|
|
8697
|
-
extra.registerId = (0,
|
|
8699
|
+
extra.registerId = (0, import_babel_utils42.getTemplateId)(
|
|
8698
8700
|
markoOpts,
|
|
8699
8701
|
filename,
|
|
8700
8702
|
`${section.id}/${name2 + id}`
|
|
@@ -8706,13 +8708,13 @@ function isMarkoAttribute(path5) {
|
|
|
8706
8708
|
}
|
|
8707
8709
|
|
|
8708
8710
|
// src/translator/visitors/import-declaration.ts
|
|
8709
|
-
var
|
|
8711
|
+
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
|
8710
8712
|
var import_declaration_default = {
|
|
8711
8713
|
analyze(importDecl) {
|
|
8712
8714
|
const { node } = importDecl;
|
|
8713
8715
|
const { source } = node;
|
|
8714
8716
|
const { value } = source;
|
|
8715
|
-
const tagImport = (0,
|
|
8717
|
+
const tagImport = (0, import_babel_utils43.resolveTagImport)(importDecl, value);
|
|
8716
8718
|
if (tagImport) {
|
|
8717
8719
|
node.extra ??= {};
|
|
8718
8720
|
node.extra.tagImport = tagImport;
|
|
@@ -8735,10 +8737,10 @@ var import_declaration_default = {
|
|
|
8735
8737
|
};
|
|
8736
8738
|
|
|
8737
8739
|
// src/translator/visitors/placeholder.ts
|
|
8738
|
-
var
|
|
8740
|
+
var import_compiler53 = require("@marko/compiler");
|
|
8739
8741
|
|
|
8740
8742
|
// src/translator/util/is-non-html-text.ts
|
|
8741
|
-
var
|
|
8743
|
+
var import_compiler52 = require("@marko/compiler");
|
|
8742
8744
|
function isNonHTMLText(placeholder) {
|
|
8743
8745
|
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
8744
8746
|
if (parentTag && isCoreTag(parentTag)) {
|
|
@@ -8814,10 +8816,10 @@ var placeholder_default = {
|
|
|
8814
8816
|
"render",
|
|
8815
8817
|
getSection(placeholder),
|
|
8816
8818
|
valueExtra.referencedBindings,
|
|
8817
|
-
|
|
8819
|
+
import_compiler53.types.expressionStatement(
|
|
8818
8820
|
method === "data" ? callRuntime(
|
|
8819
8821
|
"data",
|
|
8820
|
-
|
|
8822
|
+
import_compiler53.types.memberExpression(
|
|
8821
8823
|
scopeIdentifier,
|
|
8822
8824
|
getScopeAccessorLiteral(nodeBinding),
|
|
8823
8825
|
true
|
|
@@ -8854,7 +8856,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
8854
8856
|
break;
|
|
8855
8857
|
}
|
|
8856
8858
|
}
|
|
8857
|
-
if (!prev.node &&
|
|
8859
|
+
if (!prev.node && import_compiler53.types.isProgram(placeholder.parentPath)) {
|
|
8858
8860
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
|
8859
8861
|
}
|
|
8860
8862
|
let next = placeholder.getNextSibling();
|
|
@@ -8871,7 +8873,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
8871
8873
|
break;
|
|
8872
8874
|
}
|
|
8873
8875
|
}
|
|
8874
|
-
if (!next.node &&
|
|
8876
|
+
if (!next.node && import_compiler53.types.isProgram(placeholder.parentPath)) {
|
|
8875
8877
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
|
8876
8878
|
}
|
|
8877
8879
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
|
@@ -8881,7 +8883,7 @@ function isVoid2(value) {
|
|
|
8881
8883
|
}
|
|
8882
8884
|
|
|
8883
8885
|
// src/translator/visitors/referenced-identifier.ts
|
|
8884
|
-
var
|
|
8886
|
+
var import_compiler54 = require("@marko/compiler");
|
|
8885
8887
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
|
8886
8888
|
var referenced_identifier_default = {
|
|
8887
8889
|
migrate(identifier) {
|
|
@@ -8889,8 +8891,8 @@ var referenced_identifier_default = {
|
|
|
8889
8891
|
if (identifier.scope.hasBinding(name2)) return;
|
|
8890
8892
|
switch (name2) {
|
|
8891
8893
|
case "out":
|
|
8892
|
-
if (
|
|
8893
|
-
identifier.parentPath.replaceWith(
|
|
8894
|
+
if (import_compiler54.types.isMemberExpression(identifier.parent) && import_compiler54.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
|
8895
|
+
identifier.parentPath.replaceWith(import_compiler54.types.identifier("$global"));
|
|
8894
8896
|
} else {
|
|
8895
8897
|
throw identifier.buildCodeFrameError(
|
|
8896
8898
|
"Only `out.global` is supported for compatibility."
|
|
@@ -8917,24 +8919,24 @@ var referenced_identifier_default = {
|
|
|
8917
8919
|
case "$global":
|
|
8918
8920
|
if (isOutputHTML()) {
|
|
8919
8921
|
identifier.replaceWith(
|
|
8920
|
-
|
|
8922
|
+
import_compiler54.types.callExpression(importRuntime("$global"), [])
|
|
8921
8923
|
);
|
|
8922
8924
|
} else {
|
|
8923
8925
|
identifier.replaceWith(
|
|
8924
|
-
|
|
8926
|
+
import_compiler54.types.memberExpression(scopeIdentifier, import_compiler54.types.identifier("$global"))
|
|
8925
8927
|
);
|
|
8926
8928
|
}
|
|
8927
8929
|
break;
|
|
8928
8930
|
case "$signal":
|
|
8929
8931
|
if (isOutputHTML()) {
|
|
8930
8932
|
identifier.replaceWith(
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
+
import_compiler54.types.callExpression(
|
|
8934
|
+
import_compiler54.types.arrowFunctionExpression(
|
|
8933
8935
|
[],
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8936
|
+
import_compiler54.types.blockStatement([
|
|
8937
|
+
import_compiler54.types.throwStatement(
|
|
8938
|
+
import_compiler54.types.newExpression(import_compiler54.types.identifier("Error"), [
|
|
8939
|
+
import_compiler54.types.stringLiteral("Cannot use $signal in a server render.")
|
|
8938
8940
|
])
|
|
8939
8941
|
)
|
|
8940
8942
|
])
|
|
@@ -8960,19 +8962,19 @@ var referenced_identifier_default = {
|
|
|
8960
8962
|
"render",
|
|
8961
8963
|
section,
|
|
8962
8964
|
exprRoot.node.extra?.referencedBindings,
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
+
import_compiler54.types.expressionStatement(
|
|
8966
|
+
import_compiler54.types.callExpression(importRuntime("resetAbortSignal"), [
|
|
8965
8967
|
scopeIdentifier,
|
|
8966
|
-
|
|
8968
|
+
import_compiler54.types.numericLiteral(exprId)
|
|
8967
8969
|
])
|
|
8968
8970
|
),
|
|
8969
8971
|
false
|
|
8970
8972
|
);
|
|
8971
8973
|
}
|
|
8972
8974
|
identifier.replaceWith(
|
|
8973
|
-
|
|
8975
|
+
import_compiler54.types.callExpression(importRuntime("getAbortSignal"), [
|
|
8974
8976
|
scopeIdentifier,
|
|
8975
|
-
|
|
8977
|
+
import_compiler54.types.numericLiteral(exprId)
|
|
8976
8978
|
])
|
|
8977
8979
|
);
|
|
8978
8980
|
}
|
|
@@ -9012,21 +9014,21 @@ var scriptlet_default = {
|
|
|
9012
9014
|
};
|
|
9013
9015
|
|
|
9014
9016
|
// src/translator/visitors/tag/index.ts
|
|
9015
|
-
var
|
|
9016
|
-
var
|
|
9017
|
+
var import_compiler58 = require("@marko/compiler");
|
|
9018
|
+
var import_babel_utils47 = require("@marko/compiler/babel-utils");
|
|
9017
9019
|
|
|
9018
9020
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
9019
|
-
var
|
|
9020
|
-
var
|
|
9021
|
+
var import_compiler55 = require("@marko/compiler");
|
|
9022
|
+
var import_babel_utils44 = require("@marko/compiler/babel-utils");
|
|
9021
9023
|
var attribute_tag_default = {
|
|
9022
9024
|
analyze: {
|
|
9023
9025
|
enter(tag) {
|
|
9024
|
-
(0,
|
|
9025
|
-
(0,
|
|
9026
|
+
(0, import_babel_utils44.assertNoVar)(tag);
|
|
9027
|
+
(0, import_babel_utils44.assertNoArgs)(tag);
|
|
9026
9028
|
const body = tag.get("body");
|
|
9027
9029
|
startSection(body);
|
|
9028
9030
|
trackParamsReferences(body, 3 /* param */);
|
|
9029
|
-
if (!(0,
|
|
9031
|
+
if (!(0, import_babel_utils44.findParentTag)(tag)) {
|
|
9030
9032
|
throw tag.get("name").buildCodeFrameError("@tags must be nested within another tag.");
|
|
9031
9033
|
}
|
|
9032
9034
|
}
|
|
@@ -9047,8 +9049,8 @@ var attribute_tag_default = {
|
|
|
9047
9049
|
};
|
|
9048
9050
|
|
|
9049
9051
|
// src/translator/visitors/tag/custom-tag.ts
|
|
9050
|
-
var
|
|
9051
|
-
var
|
|
9052
|
+
var import_compiler56 = require("@marko/compiler");
|
|
9053
|
+
var import_babel_utils45 = require("@marko/compiler/babel-utils");
|
|
9052
9054
|
var import_path4 = __toESM(require("path"));
|
|
9053
9055
|
var kChildScopeBinding = Symbol("custom tag child scope");
|
|
9054
9056
|
var kChildOffsetScopeBinding = Symbol("custom tag scope offset");
|
|
@@ -9056,9 +9058,9 @@ var kChildAttrExprs = Symbol("custom tag child attribute expressions");
|
|
|
9056
9058
|
var custom_tag_default = {
|
|
9057
9059
|
analyze: {
|
|
9058
9060
|
enter(tag) {
|
|
9059
|
-
(0,
|
|
9061
|
+
(0, import_babel_utils45.assertAttributesOrSingleArg)(tag);
|
|
9060
9062
|
analyzeAttributeTags(tag);
|
|
9061
|
-
const templateFile = (0,
|
|
9063
|
+
const templateFile = (0, import_babel_utils45.getTagTemplate)(tag);
|
|
9062
9064
|
if (!templateFile) {
|
|
9063
9065
|
const tagName = getTagName(tag);
|
|
9064
9066
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
|
@@ -9091,7 +9093,7 @@ var custom_tag_default = {
|
|
|
9091
9093
|
}
|
|
9092
9094
|
startSection(tagBody);
|
|
9093
9095
|
trackParamsReferences(tagBody, 3 /* param */);
|
|
9094
|
-
const childFile = (0,
|
|
9096
|
+
const childFile = (0, import_babel_utils45.loadFileForTag)(tag);
|
|
9095
9097
|
if (childFile.opts.filename === tag.hub.file.opts.filename) {
|
|
9096
9098
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
|
9097
9099
|
} else {
|
|
@@ -9102,7 +9104,7 @@ var custom_tag_default = {
|
|
|
9102
9104
|
tag,
|
|
9103
9105
|
childProgramExtra?.domExports.input
|
|
9104
9106
|
);
|
|
9105
|
-
(0,
|
|
9107
|
+
(0, import_babel_utils45.getProgram)().node.extra.hasInteractiveChild = childProgramExtra?.isInteractive || childProgramExtra?.hasInteractiveChild || false;
|
|
9106
9108
|
}
|
|
9107
9109
|
}
|
|
9108
9110
|
},
|
|
@@ -9129,15 +9131,15 @@ function translateHTML(tag) {
|
|
|
9129
9131
|
let tagIdentifier;
|
|
9130
9132
|
flushInto(tag);
|
|
9131
9133
|
writeHTMLResumeStatements(tagBody);
|
|
9132
|
-
if (
|
|
9134
|
+
if (import_compiler56.types.isStringLiteral(node.name)) {
|
|
9133
9135
|
const relativePath = getTagRelativePath(tag);
|
|
9134
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
|
9136
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler56.types.identifier(getTemplateContentName()) : (0, import_babel_utils45.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
|
9135
9137
|
} else {
|
|
9136
9138
|
tagIdentifier = node.name;
|
|
9137
9139
|
}
|
|
9138
9140
|
const tagVar = node.var;
|
|
9139
9141
|
const section = getSection(tag);
|
|
9140
|
-
const inputExport = (0,
|
|
9142
|
+
const inputExport = (0, import_babel_utils45.loadFileForTag)(tag)?.ast.program.extra?.domExports?.input;
|
|
9141
9143
|
const { properties, statements } = inputExport ? translateAttrs(tag, inputExport.props) : {
|
|
9142
9144
|
properties: [],
|
|
9143
9145
|
statements: []
|
|
@@ -9147,8 +9149,8 @@ function translateHTML(tag) {
|
|
|
9147
9149
|
const childScopeBinding = tagExtra[kChildScopeBinding];
|
|
9148
9150
|
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
|
9149
9151
|
tag.insertBefore(
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
+
import_compiler56.types.variableDeclaration("const", [
|
|
9153
|
+
import_compiler56.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
|
|
9152
9154
|
])
|
|
9153
9155
|
);
|
|
9154
9156
|
setSerializedProperty(
|
|
@@ -9159,13 +9161,13 @@ function translateHTML(tag) {
|
|
|
9159
9161
|
);
|
|
9160
9162
|
if (tagVar) {
|
|
9161
9163
|
statements.push(
|
|
9162
|
-
|
|
9164
|
+
import_compiler56.types.expressionStatement(
|
|
9163
9165
|
callRuntime(
|
|
9164
9166
|
"setTagVar",
|
|
9165
9167
|
getScopeIdIdentifier(section),
|
|
9166
9168
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
|
9167
9169
|
peekScopeId,
|
|
9168
|
-
|
|
9170
|
+
import_compiler56.types.stringLiteral(
|
|
9169
9171
|
getResumeRegisterId(
|
|
9170
9172
|
section,
|
|
9171
9173
|
node.var.extra?.binding,
|
|
@@ -9185,8 +9187,8 @@ function translateHTML(tag) {
|
|
|
9185
9187
|
const contentExpression = contentProp.value;
|
|
9186
9188
|
contentProp.value = contentId = generateUidIdentifier("content");
|
|
9187
9189
|
const [contentPath] = tag.insertBefore(
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
+
import_compiler56.types.variableDeclaration("const", [
|
|
9191
|
+
import_compiler56.types.variableDeclarator(
|
|
9190
9192
|
contentId,
|
|
9191
9193
|
// TODO: only register if needed (child template analysis)
|
|
9192
9194
|
contentExpression
|
|
@@ -9200,13 +9202,13 @@ function translateHTML(tag) {
|
|
|
9200
9202
|
propsToExpression(properties)
|
|
9201
9203
|
);
|
|
9202
9204
|
if (tagVar) {
|
|
9203
|
-
translateVar(tag,
|
|
9204
|
-
renderTagExpr =
|
|
9205
|
+
translateVar(tag, import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0)), "let");
|
|
9206
|
+
renderTagExpr = import_compiler56.types.assignmentExpression("=", tagVar, renderTagExpr);
|
|
9205
9207
|
}
|
|
9206
9208
|
statements.push(
|
|
9207
|
-
|
|
9209
|
+
import_compiler56.types.ifStatement(
|
|
9208
9210
|
tagIdentifier,
|
|
9209
|
-
|
|
9211
|
+
import_compiler56.types.expressionStatement(renderTagExpr),
|
|
9210
9212
|
contentId && callStatement(contentId)
|
|
9211
9213
|
)
|
|
9212
9214
|
);
|
|
@@ -9232,9 +9234,9 @@ function translateDOM(tag) {
|
|
|
9232
9234
|
const childScopeBinding = extra[kChildScopeBinding];
|
|
9233
9235
|
const write2 = writeTo(tag);
|
|
9234
9236
|
const { file } = tag.hub;
|
|
9235
|
-
const tagName =
|
|
9237
|
+
const tagName = import_compiler56.types.isIdentifier(node.name) ? node.name.name : import_compiler56.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
9236
9238
|
const relativePath = getTagRelativePath(tag);
|
|
9237
|
-
const childFile = (0,
|
|
9239
|
+
const childFile = (0, import_babel_utils45.loadFileForTag)(tag);
|
|
9238
9240
|
const childExports = childFile.ast.program.extra.domExports;
|
|
9239
9241
|
const tagIdentifier = importOrSelfReferenceName(
|
|
9240
9242
|
file,
|
|
@@ -9252,10 +9254,10 @@ function translateDOM(tag) {
|
|
|
9252
9254
|
attrTagCallsByTag: void 0
|
|
9253
9255
|
});
|
|
9254
9256
|
}
|
|
9255
|
-
write2`${(0,
|
|
9257
|
+
write2`${(0, import_babel_utils45.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
9256
9258
|
injectWalks(
|
|
9257
9259
|
tag,
|
|
9258
|
-
(0,
|
|
9260
|
+
(0, import_babel_utils45.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
|
9259
9261
|
);
|
|
9260
9262
|
if (node.var) {
|
|
9261
9263
|
const source = initValue(
|
|
@@ -9264,7 +9266,7 @@ function translateDOM(tag) {
|
|
|
9264
9266
|
);
|
|
9265
9267
|
source.register = true;
|
|
9266
9268
|
source.buildAssignment = (valueSection, value) => {
|
|
9267
|
-
return
|
|
9269
|
+
return import_compiler56.types.callExpression(importRuntime("tagVarSignalChange"), [
|
|
9268
9270
|
createScopeReadExpression(valueSection, childScopeBinding),
|
|
9269
9271
|
value
|
|
9270
9272
|
]);
|
|
@@ -9273,7 +9275,7 @@ function translateDOM(tag) {
|
|
|
9273
9275
|
"render",
|
|
9274
9276
|
tagSection,
|
|
9275
9277
|
void 0,
|
|
9276
|
-
|
|
9278
|
+
import_compiler56.types.expressionStatement(
|
|
9277
9279
|
callRuntime(
|
|
9278
9280
|
"setTagVar",
|
|
9279
9281
|
scopeIdentifier,
|
|
@@ -9287,8 +9289,8 @@ function translateDOM(tag) {
|
|
|
9287
9289
|
"render",
|
|
9288
9290
|
tagSection,
|
|
9289
9291
|
void 0,
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
+
import_compiler56.types.expressionStatement(
|
|
9293
|
+
import_compiler56.types.callExpression(tagIdentifier, [
|
|
9292
9294
|
createScopeReadExpression(tagSection, childScopeBinding)
|
|
9293
9295
|
])
|
|
9294
9296
|
)
|
|
@@ -9301,9 +9303,9 @@ function getTagRelativePath(tag) {
|
|
|
9301
9303
|
hub: { file }
|
|
9302
9304
|
} = tag;
|
|
9303
9305
|
let relativePath;
|
|
9304
|
-
if (
|
|
9305
|
-
const template = (0,
|
|
9306
|
-
relativePath = template && (0,
|
|
9306
|
+
if (import_compiler56.types.isStringLiteral(node.name)) {
|
|
9307
|
+
const template = (0, import_babel_utils45.getTagTemplate)(tag);
|
|
9308
|
+
relativePath = template && (0, import_babel_utils45.resolveRelativePath)(file, template);
|
|
9307
9309
|
} else if (node.extra?.tagNameImported) {
|
|
9308
9310
|
relativePath = node.extra.tagNameImported;
|
|
9309
9311
|
}
|
|
@@ -9353,7 +9355,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
|
9353
9355
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
9354
9356
|
for (const child of attrTags2) {
|
|
9355
9357
|
if (child.isMarkoTag()) {
|
|
9356
|
-
if ((0,
|
|
9358
|
+
if ((0, import_babel_utils45.isAttributeTag)(child)) {
|
|
9357
9359
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
9358
9360
|
const childAttrExports = templateExport.props[attrTagMeta.name];
|
|
9359
9361
|
if (childAttrExports) {
|
|
@@ -9394,7 +9396,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
|
9394
9396
|
let spreadReferenceNodes;
|
|
9395
9397
|
for (let i = attributes.length; i--; ) {
|
|
9396
9398
|
const attr2 = attributes[i];
|
|
9397
|
-
if (
|
|
9399
|
+
if (import_compiler56.types.isMarkoAttribute(attr2)) {
|
|
9398
9400
|
if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
|
|
9399
9401
|
dropReferences(attr2.value);
|
|
9400
9402
|
continue;
|
|
@@ -9403,7 +9405,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
|
9403
9405
|
}
|
|
9404
9406
|
if (spreadReferenceNodes) {
|
|
9405
9407
|
spreadReferenceNodes.push(attr2.value);
|
|
9406
|
-
} else if (
|
|
9408
|
+
} else if (import_compiler56.types.isMarkoSpreadAttribute(attr2)) {
|
|
9407
9409
|
spreadReferenceNodes = [attr2.value];
|
|
9408
9410
|
} else {
|
|
9409
9411
|
rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
|
|
@@ -9428,7 +9430,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9428
9430
|
// but we should probably ensure all other references are dropped in this case before we do that.
|
|
9429
9431
|
tag.node.extra?.referencedBindings,
|
|
9430
9432
|
identifierToSignal(tagInputIdentifier),
|
|
9431
|
-
|
|
9433
|
+
import_compiler56.types.isSpreadElement(arg) ? import_compiler56.types.memberExpression(arg.argument, import_compiler56.types.numericLiteral(0), true) : arg,
|
|
9432
9434
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
|
9433
9435
|
);
|
|
9434
9436
|
return;
|
|
@@ -9451,7 +9453,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9451
9453
|
);
|
|
9452
9454
|
}
|
|
9453
9455
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
9454
|
-
if ((0,
|
|
9456
|
+
if ((0, import_babel_utils45.isAttributeTag)(tag)) {
|
|
9455
9457
|
const attrTagName = getTagName(tag);
|
|
9456
9458
|
const parentTag = tag.parentPath;
|
|
9457
9459
|
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
|
@@ -9476,7 +9478,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9476
9478
|
} else {
|
|
9477
9479
|
attrTagCallsForTag.set(
|
|
9478
9480
|
attrTagName,
|
|
9479
|
-
translatedProps =
|
|
9481
|
+
translatedProps = import_compiler56.types.parenthesizedExpression(
|
|
9480
9482
|
callRuntime("attrTag", translatedProps)
|
|
9481
9483
|
)
|
|
9482
9484
|
);
|
|
@@ -9523,7 +9525,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9523
9525
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
9524
9526
|
const child = attrTags2[i];
|
|
9525
9527
|
if (child.isMarkoTag()) {
|
|
9526
|
-
if ((0,
|
|
9528
|
+
if ((0, import_babel_utils45.isAttributeTag)(child)) {
|
|
9527
9529
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
9528
9530
|
const childAttrExport = templateExport.props[attrTagMeta.name];
|
|
9529
9531
|
if (childAttrExport) {
|
|
@@ -9561,7 +9563,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9561
9563
|
childAttrExports.id,
|
|
9562
9564
|
`${importAlias}_${attrTagMeta.name}`
|
|
9563
9565
|
);
|
|
9564
|
-
decls.push(
|
|
9566
|
+
decls.push(import_compiler56.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
9565
9567
|
addValue(
|
|
9566
9568
|
info.tagSection,
|
|
9567
9569
|
referencedBindings,
|
|
@@ -9571,7 +9573,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9571
9573
|
);
|
|
9572
9574
|
}
|
|
9573
9575
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
9574
|
-
|
|
9576
|
+
import_compiler56.types.variableDeclaration("let", decls),
|
|
9575
9577
|
...statements
|
|
9576
9578
|
]);
|
|
9577
9579
|
}
|
|
@@ -9580,7 +9582,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9580
9582
|
if (bodySection && !seen.has("content")) {
|
|
9581
9583
|
seen.add("content");
|
|
9582
9584
|
if (templateExport.props.content) {
|
|
9583
|
-
const contentExportIdentifier = (0,
|
|
9585
|
+
const contentExportIdentifier = (0, import_babel_utils45.importNamed)(
|
|
9584
9586
|
tag.hub.file,
|
|
9585
9587
|
info.relativePath,
|
|
9586
9588
|
templateExport.props.content.id,
|
|
@@ -9591,7 +9593,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9591
9593
|
void 0,
|
|
9592
9594
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
9593
9595
|
identifierToSignal(contentExportIdentifier),
|
|
9594
|
-
|
|
9596
|
+
import_compiler56.types.callExpression(import_compiler56.types.identifier(bodySection.name), [scopeIdentifier]),
|
|
9595
9597
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
|
9596
9598
|
);
|
|
9597
9599
|
}
|
|
@@ -9601,7 +9603,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9601
9603
|
let spreadProps;
|
|
9602
9604
|
for (let i = attributes.length; i--; ) {
|
|
9603
9605
|
const attr2 = attributes[i];
|
|
9604
|
-
if (
|
|
9606
|
+
if (import_compiler56.types.isMarkoAttribute(attr2)) {
|
|
9605
9607
|
const childAttrExports = templateExport.props[attr2.name];
|
|
9606
9608
|
if (!childAttrExports || seen.has(attr2.name)) continue;
|
|
9607
9609
|
seen.add(attr2.name);
|
|
@@ -9611,9 +9613,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9611
9613
|
}
|
|
9612
9614
|
staticAttrs.push(attr2);
|
|
9613
9615
|
} else if (spreadProps) {
|
|
9614
|
-
spreadProps.push(
|
|
9616
|
+
spreadProps.push(import_compiler56.types.spreadElement(attr2.value));
|
|
9615
9617
|
} else {
|
|
9616
|
-
spreadProps = [
|
|
9618
|
+
spreadProps = [import_compiler56.types.spreadElement(attr2.value)];
|
|
9617
9619
|
}
|
|
9618
9620
|
}
|
|
9619
9621
|
for (const attr2 of staticAttrs.reverse()) {
|
|
@@ -9642,8 +9644,8 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9642
9644
|
spreadProps.reverse();
|
|
9643
9645
|
getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
|
|
9644
9646
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
+
import_compiler56.types.variableDeclaration("const", [
|
|
9648
|
+
import_compiler56.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
|
|
9647
9649
|
])
|
|
9648
9650
|
]);
|
|
9649
9651
|
}
|
|
@@ -9667,19 +9669,19 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
|
9667
9669
|
}
|
|
9668
9670
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
9669
9671
|
if (isCircularRequest(file, request)) {
|
|
9670
|
-
return
|
|
9672
|
+
return import_compiler56.types.identifier(name2);
|
|
9671
9673
|
}
|
|
9672
|
-
return (0,
|
|
9674
|
+
return (0, import_babel_utils45.importNamed)(file, request, name2, nameHint);
|
|
9673
9675
|
}
|
|
9674
9676
|
function isCircularRequest(file, request) {
|
|
9675
9677
|
const { filename } = file.opts;
|
|
9676
9678
|
return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
|
|
9677
9679
|
}
|
|
9678
9680
|
function callStatement(id, ...args) {
|
|
9679
|
-
return
|
|
9681
|
+
return import_compiler56.types.expressionStatement(callExpression(id, ...args));
|
|
9680
9682
|
}
|
|
9681
9683
|
function callExpression(id, ...args) {
|
|
9682
|
-
return
|
|
9684
|
+
return import_compiler56.types.callExpression(id, args.filter(Boolean));
|
|
9683
9685
|
}
|
|
9684
9686
|
function identifierToSignal(identifier) {
|
|
9685
9687
|
return {
|
|
@@ -9688,21 +9690,21 @@ function identifierToSignal(identifier) {
|
|
|
9688
9690
|
};
|
|
9689
9691
|
}
|
|
9690
9692
|
function buildUndefined2() {
|
|
9691
|
-
return
|
|
9693
|
+
return import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0));
|
|
9692
9694
|
}
|
|
9693
9695
|
function always() {
|
|
9694
9696
|
return true;
|
|
9695
9697
|
}
|
|
9696
9698
|
|
|
9697
9699
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
9698
|
-
var
|
|
9699
|
-
var
|
|
9700
|
+
var import_compiler57 = require("@marko/compiler");
|
|
9701
|
+
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
9700
9702
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
|
9701
9703
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
|
9702
9704
|
var dynamic_tag_default = {
|
|
9703
9705
|
analyze: {
|
|
9704
9706
|
enter(tag) {
|
|
9705
|
-
(0,
|
|
9707
|
+
(0, import_babel_utils46.assertAttributesOrArgs)(tag);
|
|
9706
9708
|
analyzeAttributeTags(tag);
|
|
9707
9709
|
const section = getOrCreateSection(tag);
|
|
9708
9710
|
const tagExtra = tag.node.extra ??= {};
|
|
@@ -9750,8 +9752,8 @@ var dynamic_tag_default = {
|
|
|
9750
9752
|
const section = getSection(tag);
|
|
9751
9753
|
const isClassAPI = tagExtra.featureType === "class";
|
|
9752
9754
|
let tagExpression = node.name;
|
|
9753
|
-
if (
|
|
9754
|
-
tagExpression = (0,
|
|
9755
|
+
if (import_compiler57.types.isStringLiteral(tagExpression)) {
|
|
9756
|
+
tagExpression = (0, import_babel_utils46.importDefault)(
|
|
9755
9757
|
tag.hub.file,
|
|
9756
9758
|
getTagRelativePath(tag),
|
|
9757
9759
|
tagExpression.value
|
|
@@ -9759,15 +9761,15 @@ var dynamic_tag_default = {
|
|
|
9759
9761
|
}
|
|
9760
9762
|
if (isClassAPI) {
|
|
9761
9763
|
if (isOutputHTML()) {
|
|
9762
|
-
(0,
|
|
9763
|
-
|
|
9764
|
+
(0, import_babel_utils46.getProgram)().node.body.push(
|
|
9765
|
+
import_compiler57.types.markoScriptlet(
|
|
9764
9766
|
[
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
(0,
|
|
9767
|
+
import_compiler57.types.expressionStatement(
|
|
9768
|
+
import_compiler57.types.callExpression(
|
|
9769
|
+
(0, import_babel_utils46.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
9768
9770
|
[
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
+
import_compiler57.types.identifier(tagExpression.name),
|
|
9772
|
+
import_compiler57.types.stringLiteral((0, import_babel_utils46.loadFileForTag)(tag).metadata.marko.id)
|
|
9771
9773
|
]
|
|
9772
9774
|
)
|
|
9773
9775
|
)
|
|
@@ -9776,12 +9778,12 @@ var dynamic_tag_default = {
|
|
|
9776
9778
|
)
|
|
9777
9779
|
);
|
|
9778
9780
|
} else {
|
|
9779
|
-
(0,
|
|
9780
|
-
|
|
9781
|
+
(0, import_babel_utils46.getProgram)().node.body.push(
|
|
9782
|
+
import_compiler57.types.expressionStatement(
|
|
9781
9783
|
callRuntime(
|
|
9782
9784
|
"register",
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
+
import_compiler57.types.stringLiteral((0, import_babel_utils46.loadFileForTag)(tag).metadata.marko.id),
|
|
9786
|
+
import_compiler57.types.identifier(tagExpression.name)
|
|
9785
9787
|
)
|
|
9786
9788
|
)
|
|
9787
9789
|
);
|
|
@@ -9801,7 +9803,7 @@ var dynamic_tag_default = {
|
|
|
9801
9803
|
hasMultipleArgs = true;
|
|
9802
9804
|
args.push(propsToExpression(properties));
|
|
9803
9805
|
} else {
|
|
9804
|
-
hasMultipleArgs = node.arguments.length > 1 ||
|
|
9806
|
+
hasMultipleArgs = node.arguments.length > 1 || import_compiler57.types.isSpreadElement(node.arguments[0]);
|
|
9805
9807
|
}
|
|
9806
9808
|
} else {
|
|
9807
9809
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
|
@@ -9821,35 +9823,35 @@ var dynamic_tag_default = {
|
|
|
9821
9823
|
getScopeIdIdentifier(section),
|
|
9822
9824
|
getScopeAccessorLiteral(nodeRef2),
|
|
9823
9825
|
tagExpression,
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
serializeReason ?
|
|
9826
|
+
import_compiler57.types.arrayExpression(args),
|
|
9827
|
+
import_compiler57.types.numericLiteral(0),
|
|
9828
|
+
import_compiler57.types.numericLiteral(1),
|
|
9829
|
+
serializeReason ? import_compiler57.types.numericLiteral(1) : void 0
|
|
9828
9830
|
) : callRuntime(
|
|
9829
9831
|
"dynamicTag",
|
|
9830
9832
|
getScopeIdIdentifier(section),
|
|
9831
9833
|
getScopeAccessorLiteral(nodeRef2),
|
|
9832
9834
|
tagExpression,
|
|
9833
9835
|
args[0],
|
|
9834
|
-
args[1] || (serializeReason ?
|
|
9835
|
-
serializeReason ?
|
|
9836
|
-
serializeReason ?
|
|
9836
|
+
args[1] || (serializeReason ? import_compiler57.types.numericLiteral(0) : void 0),
|
|
9837
|
+
serializeReason ? import_compiler57.types.numericLiteral(0) : void 0,
|
|
9838
|
+
serializeReason ? import_compiler57.types.numericLiteral(1) : void 0
|
|
9837
9839
|
);
|
|
9838
9840
|
if (node.var) {
|
|
9839
9841
|
const dynamicScopeIdentifier = generateUidIdentifier("dynamicScope");
|
|
9840
9842
|
statements.push(
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
+
import_compiler57.types.variableDeclaration("const", [
|
|
9844
|
+
import_compiler57.types.variableDeclarator(
|
|
9843
9845
|
dynamicScopeIdentifier,
|
|
9844
9846
|
callRuntime("peekNextScope")
|
|
9845
9847
|
)
|
|
9846
9848
|
])
|
|
9847
9849
|
);
|
|
9848
9850
|
statements.push(
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
+
import_compiler57.types.variableDeclaration("const", [
|
|
9852
|
+
import_compiler57.types.variableDeclarator(node.var, dynamicTagExpr)
|
|
9851
9853
|
]),
|
|
9852
|
-
|
|
9854
|
+
import_compiler57.types.expressionStatement(
|
|
9853
9855
|
callRuntime(
|
|
9854
9856
|
"setTagVar",
|
|
9855
9857
|
getScopeIdIdentifier(section),
|
|
@@ -9857,7 +9859,7 @@ var dynamic_tag_default = {
|
|
|
9857
9859
|
tag.node.extra[kChildOffsetScopeBinding2]
|
|
9858
9860
|
),
|
|
9859
9861
|
dynamicScopeIdentifier,
|
|
9860
|
-
|
|
9862
|
+
import_compiler57.types.stringLiteral(
|
|
9861
9863
|
getResumeRegisterId(
|
|
9862
9864
|
section,
|
|
9863
9865
|
node.var.extra?.binding,
|
|
@@ -9869,7 +9871,7 @@ var dynamic_tag_default = {
|
|
|
9869
9871
|
)
|
|
9870
9872
|
);
|
|
9871
9873
|
} else {
|
|
9872
|
-
statements.push(
|
|
9874
|
+
statements.push(import_compiler57.types.expressionStatement(dynamicTagExpr));
|
|
9873
9875
|
}
|
|
9874
9876
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
9875
9877
|
replacement.skip();
|
|
@@ -9886,10 +9888,10 @@ var dynamic_tag_default = {
|
|
|
9886
9888
|
);
|
|
9887
9889
|
tagVarSignal.register = true;
|
|
9888
9890
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
|
9889
|
-
return
|
|
9890
|
-
|
|
9891
|
+
return import_compiler57.types.callExpression(importRuntime("tagVarSignalChange"), [
|
|
9892
|
+
import_compiler57.types.memberExpression(
|
|
9891
9893
|
getScopeExpression(tagVarSignal.section, valueSection),
|
|
9892
|
-
|
|
9894
|
+
import_compiler57.types.stringLiteral(
|
|
9893
9895
|
getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2)
|
|
9894
9896
|
),
|
|
9895
9897
|
true
|
|
@@ -9902,19 +9904,19 @@ var dynamic_tag_default = {
|
|
|
9902
9904
|
return callRuntime(
|
|
9903
9905
|
"dynamicTag",
|
|
9904
9906
|
getScopeAccessorLiteral(nodeRef2),
|
|
9905
|
-
bodySection &&
|
|
9906
|
-
tagVarSignal ?
|
|
9907
|
-
hasMultipleArgs &&
|
|
9907
|
+
bodySection && import_compiler57.types.identifier(bodySection.name),
|
|
9908
|
+
tagVarSignal ? import_compiler57.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
|
9909
|
+
hasMultipleArgs && import_compiler57.types.numericLiteral(1)
|
|
9908
9910
|
);
|
|
9909
9911
|
};
|
|
9910
9912
|
if (args.length) {
|
|
9911
|
-
const argsOrInput = hasMultipleArgs ?
|
|
9912
|
-
if (!
|
|
9913
|
+
const argsOrInput = hasMultipleArgs ? import_compiler57.types.arrayExpression(args) : args[0];
|
|
9914
|
+
if (!import_compiler57.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
|
9913
9915
|
signal.extraArgs = [
|
|
9914
|
-
|
|
9916
|
+
import_compiler57.types.arrowFunctionExpression(
|
|
9915
9917
|
[],
|
|
9916
|
-
statements.length ?
|
|
9917
|
-
statements.concat(
|
|
9918
|
+
statements.length ? import_compiler57.types.blockStatement(
|
|
9919
|
+
statements.concat(import_compiler57.types.returnStatement(argsOrInput))
|
|
9918
9920
|
) : argsOrInput
|
|
9919
9921
|
)
|
|
9920
9922
|
];
|
|
@@ -9937,16 +9939,16 @@ var tag_default = {
|
|
|
9937
9939
|
const { node } = tag;
|
|
9938
9940
|
const { name: name2, attributes } = tag.node;
|
|
9939
9941
|
let crawl = false;
|
|
9940
|
-
if (
|
|
9942
|
+
if (import_compiler58.types.isStringLiteral(name2)) {
|
|
9941
9943
|
const tagName = name2.value;
|
|
9942
9944
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
|
9943
|
-
node.name = withPreviousLocation(
|
|
9945
|
+
node.name = withPreviousLocation(import_compiler58.types.identifier(tagName), name2);
|
|
9944
9946
|
crawl = true;
|
|
9945
9947
|
}
|
|
9946
9948
|
}
|
|
9947
9949
|
for (let i = 0; i < attributes.length; i++) {
|
|
9948
9950
|
const attr2 = attributes[i];
|
|
9949
|
-
if (
|
|
9951
|
+
if (import_compiler58.types.isMarkoAttribute(attr2) && attr2.bound) {
|
|
9950
9952
|
attr2.bound = false;
|
|
9951
9953
|
attributes.splice(++i, 0, getChangeHandler(tag, attr2));
|
|
9952
9954
|
crawl = true;
|
|
@@ -9959,7 +9961,7 @@ var tag_default = {
|
|
|
9959
9961
|
},
|
|
9960
9962
|
analyze: {
|
|
9961
9963
|
enter(tag) {
|
|
9962
|
-
const tagDef = (0,
|
|
9964
|
+
const tagDef = (0, import_babel_utils47.getTagDef)(tag);
|
|
9963
9965
|
const type = analyzeTagNameType(tag);
|
|
9964
9966
|
const hook = tagDef?.analyzer?.hook;
|
|
9965
9967
|
if (hook) {
|
|
@@ -9983,7 +9985,7 @@ var tag_default = {
|
|
|
9983
9985
|
}
|
|
9984
9986
|
},
|
|
9985
9987
|
exit(tag) {
|
|
9986
|
-
const hook = (0,
|
|
9988
|
+
const hook = (0, import_babel_utils47.getTagDef)(tag)?.analyzer?.hook;
|
|
9987
9989
|
if (hook) {
|
|
9988
9990
|
exit(hook, tag);
|
|
9989
9991
|
return;
|
|
@@ -9992,7 +9994,7 @@ var tag_default = {
|
|
|
9992
9994
|
},
|
|
9993
9995
|
translate: {
|
|
9994
9996
|
enter(tag) {
|
|
9995
|
-
const tagDef = (0,
|
|
9997
|
+
const tagDef = (0, import_babel_utils47.getTagDef)(tag);
|
|
9996
9998
|
const extra = tag.node.extra;
|
|
9997
9999
|
if (tagDef?.translator) {
|
|
9998
10000
|
if (tagDef.translator.path) {
|
|
@@ -10009,7 +10011,7 @@ var tag_default = {
|
|
|
10009
10011
|
);
|
|
10010
10012
|
}
|
|
10011
10013
|
if (attr2.node.modifier) {
|
|
10012
|
-
if ((0,
|
|
10014
|
+
if ((0, import_babel_utils47.isNativeTag)(attr2.parentPath)) {
|
|
10013
10015
|
attr2.node.name += `:${attr2.node.modifier}`;
|
|
10014
10016
|
} else {
|
|
10015
10017
|
throw attr2.buildCodeFrameError(
|
|
@@ -10022,8 +10024,8 @@ var tag_default = {
|
|
|
10022
10024
|
if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
|
10023
10025
|
const tagNameId = generateUidIdentifier("tagName");
|
|
10024
10026
|
const [tagNameVarPath] = tag.insertBefore(
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
+
import_compiler58.types.variableDeclaration("const", [
|
|
10028
|
+
import_compiler58.types.variableDeclarator(tagNameId, tag.node.name)
|
|
10027
10029
|
])
|
|
10028
10030
|
);
|
|
10029
10031
|
tagNameVarPath.skip();
|
|
@@ -10045,7 +10047,7 @@ var tag_default = {
|
|
|
10045
10047
|
}
|
|
10046
10048
|
},
|
|
10047
10049
|
exit(tag) {
|
|
10048
|
-
const translator = (0,
|
|
10050
|
+
const translator = (0, import_babel_utils47.getTagDef)(tag)?.translator;
|
|
10049
10051
|
if (translator) {
|
|
10050
10052
|
exit(translator.hook, tag);
|
|
10051
10053
|
return;
|
|
@@ -10070,16 +10072,16 @@ var tag_default = {
|
|
|
10070
10072
|
function getChangeHandler(tag, attr2) {
|
|
10071
10073
|
const attrName = attr2.name;
|
|
10072
10074
|
const changeAttrName = attrName + "Change";
|
|
10073
|
-
if (
|
|
10075
|
+
if (import_compiler58.types.isIdentifier(attr2.value)) {
|
|
10074
10076
|
const binding = tag.scope.getBinding(attr2.value.name);
|
|
10075
10077
|
if (!binding)
|
|
10076
|
-
return
|
|
10078
|
+
return import_compiler58.types.markoAttribute(
|
|
10077
10079
|
changeAttrName,
|
|
10078
10080
|
buildChangeHandlerFunction(attr2.value)
|
|
10079
10081
|
);
|
|
10080
10082
|
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
|
10081
10083
|
if (!existingChangedAttr) {
|
|
10082
|
-
const changeHandlerAttr =
|
|
10084
|
+
const changeHandlerAttr = import_compiler58.types.markoAttribute(
|
|
10083
10085
|
changeAttrName,
|
|
10084
10086
|
buildChangeHandlerFunction(attr2.value)
|
|
10085
10087
|
);
|
|
@@ -10087,10 +10089,10 @@ function getChangeHandler(tag, attr2) {
|
|
|
10087
10089
|
return changeHandlerAttr;
|
|
10088
10090
|
}
|
|
10089
10091
|
if (existingChangedAttr.type === "Identifier") {
|
|
10090
|
-
return
|
|
10092
|
+
return import_compiler58.types.markoAttribute(
|
|
10091
10093
|
changeAttrName,
|
|
10092
10094
|
withPreviousLocation(
|
|
10093
|
-
|
|
10095
|
+
import_compiler58.types.identifier(existingChangedAttr.name),
|
|
10094
10096
|
attr2.value
|
|
10095
10097
|
)
|
|
10096
10098
|
);
|
|
@@ -10100,37 +10102,37 @@ function getChangeHandler(tag, attr2) {
|
|
|
10100
10102
|
throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
|
|
10101
10103
|
}
|
|
10102
10104
|
const changeHandlerId = generateUid(changeAttrName);
|
|
10103
|
-
const changeHandlerConst =
|
|
10104
|
-
|
|
10105
|
-
[
|
|
10106
|
-
|
|
10105
|
+
const changeHandlerConst = import_compiler58.types.markoTag(
|
|
10106
|
+
import_compiler58.types.stringLiteral("const"),
|
|
10107
|
+
[import_compiler58.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
|
10108
|
+
import_compiler58.types.markoTagBody([]),
|
|
10107
10109
|
null,
|
|
10108
|
-
|
|
10110
|
+
import_compiler58.types.identifier(changeHandlerId)
|
|
10109
10111
|
);
|
|
10110
10112
|
BINDING_CHANGE_HANDLER.set(
|
|
10111
10113
|
binding.identifier,
|
|
10112
|
-
existingChangedAttr.value =
|
|
10114
|
+
existingChangedAttr.value = import_compiler58.types.identifier(changeHandlerId)
|
|
10113
10115
|
);
|
|
10114
10116
|
if (markoRoot.isMarkoTag()) {
|
|
10115
10117
|
markoRoot.insertAfter(changeHandlerConst);
|
|
10116
10118
|
} else {
|
|
10117
10119
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
|
10118
10120
|
}
|
|
10119
|
-
return
|
|
10121
|
+
return import_compiler58.types.markoAttribute(
|
|
10120
10122
|
changeAttrName,
|
|
10121
|
-
withPreviousLocation(
|
|
10123
|
+
withPreviousLocation(import_compiler58.types.identifier(changeHandlerId), attr2.value)
|
|
10122
10124
|
);
|
|
10123
|
-
} else if (
|
|
10125
|
+
} else if (import_compiler58.types.isMemberExpression(attr2.value)) {
|
|
10124
10126
|
const prop = attr2.value.property;
|
|
10125
|
-
if (!
|
|
10126
|
-
return
|
|
10127
|
+
if (!import_compiler58.types.isPrivateName(attr2.value.property)) {
|
|
10128
|
+
return import_compiler58.types.markoAttribute(
|
|
10127
10129
|
changeAttrName,
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
prop.type === "Identifier" ? withPreviousLocation(
|
|
10130
|
+
import_compiler58.types.memberExpression(
|
|
10131
|
+
import_compiler58.types.cloneNode(attr2.value.object),
|
|
10132
|
+
prop.type === "Identifier" ? withPreviousLocation(import_compiler58.types.identifier(prop.name + "Change"), prop) : import_compiler58.types.binaryExpression(
|
|
10131
10133
|
"+",
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
+
import_compiler58.types.cloneNode(prop),
|
|
10135
|
+
import_compiler58.types.stringLiteral("Change")
|
|
10134
10136
|
),
|
|
10135
10137
|
prop.type !== "Identifier"
|
|
10136
10138
|
)
|
|
@@ -10144,14 +10146,14 @@ function getChangeHandler(tag, attr2) {
|
|
|
10144
10146
|
}
|
|
10145
10147
|
function buildChangeHandlerFunction(id) {
|
|
10146
10148
|
const newId = "_new_" + id.name;
|
|
10147
|
-
return
|
|
10148
|
-
[withPreviousLocation(
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10149
|
+
return import_compiler58.types.arrowFunctionExpression(
|
|
10150
|
+
[withPreviousLocation(import_compiler58.types.identifier(newId), id)],
|
|
10151
|
+
import_compiler58.types.blockStatement([
|
|
10152
|
+
import_compiler58.types.expressionStatement(
|
|
10153
|
+
import_compiler58.types.assignmentExpression(
|
|
10152
10154
|
"=",
|
|
10153
|
-
withPreviousLocation(
|
|
10154
|
-
withPreviousLocation(
|
|
10155
|
+
withPreviousLocation(import_compiler58.types.identifier(id.name), id),
|
|
10156
|
+
withPreviousLocation(import_compiler58.types.identifier(newId), id)
|
|
10155
10157
|
)
|
|
10156
10158
|
)
|
|
10157
10159
|
])
|
|
@@ -10159,7 +10161,7 @@ function buildChangeHandlerFunction(id) {
|
|
|
10159
10161
|
}
|
|
10160
10162
|
|
|
10161
10163
|
// src/translator/visitors/text.ts
|
|
10162
|
-
var
|
|
10164
|
+
var import_compiler59 = require("@marko/compiler");
|
|
10163
10165
|
var text_default = {
|
|
10164
10166
|
translate: {
|
|
10165
10167
|
exit(text) {
|