marko 6.0.0-next.3.21 → 6.0.0-next.3.22
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
CHANGED
@@ -110,7 +110,7 @@ var attrs_default = {
|
|
110
110
|
|
111
111
|
// src/translator/core/await.ts
|
112
112
|
var import_compiler22 = require("@marko/compiler");
|
113
|
-
var
|
113
|
+
var import_babel_utils12 = require("@marko/compiler/babel-utils");
|
114
114
|
|
115
115
|
// src/translator/util/evaluate.ts
|
116
116
|
var import_babel_utils2 = require("@marko/compiler/babel-utils");
|
@@ -137,8 +137,8 @@ var import_compiler21 = require("@marko/compiler");
|
|
137
137
|
|
138
138
|
// src/translator/visitors/program/index.ts
|
139
139
|
var import_compiler20 = require("@marko/compiler");
|
140
|
-
var
|
141
|
-
var
|
140
|
+
var import_babel_utils11 = require("@marko/compiler/babel-utils");
|
141
|
+
var import_path2 = __toESM(require("path"));
|
142
142
|
|
143
143
|
// src/translator/util/binding-has-downstream-expressions.ts
|
144
144
|
function bindingHasDownstreamExpressions(binding) {
|
@@ -1021,37 +1021,37 @@ function analyzeTagNameType(tag) {
|
|
1021
1021
|
}
|
1022
1022
|
function analyzeExpressionTagName(name2, extra) {
|
1023
1023
|
const pending = [name2];
|
1024
|
-
let
|
1024
|
+
let path5;
|
1025
1025
|
let type;
|
1026
1026
|
let nullable = false;
|
1027
1027
|
let tagNameImported;
|
1028
|
-
while ((
|
1029
|
-
if (
|
1030
|
-
pending.push(
|
1031
|
-
if (
|
1032
|
-
pending.push(
|
1033
|
-
}
|
1034
|
-
} else if (
|
1035
|
-
if (
|
1036
|
-
pending.push(
|
1028
|
+
while ((path5 = pending.pop()) && type !== 2 /* DynamicTag */) {
|
1029
|
+
if (path5.isConditionalExpression()) {
|
1030
|
+
pending.push(path5.get("consequent"));
|
1031
|
+
if (path5.node.alternate) {
|
1032
|
+
pending.push(path5.get("alternate"));
|
1033
|
+
}
|
1034
|
+
} else if (path5.isLogicalExpression()) {
|
1035
|
+
if (path5.node.operator === "||") {
|
1036
|
+
pending.push(path5.get("left"));
|
1037
1037
|
} else {
|
1038
1038
|
nullable = true;
|
1039
1039
|
}
|
1040
|
-
pending.push(
|
1041
|
-
} else if (
|
1042
|
-
pending.push(
|
1043
|
-
} else if (
|
1044
|
-
type =
|
1045
|
-
} else if (
|
1040
|
+
pending.push(path5.get("right"));
|
1041
|
+
} else if (path5.isAssignmentExpression()) {
|
1042
|
+
pending.push(path5.get("right"));
|
1043
|
+
} else if (path5.isBinaryExpression()) {
|
1044
|
+
type = path5.node.operator !== "+" || type !== void 0 ? 2 /* DynamicTag */ : 0 /* NativeTag */;
|
1045
|
+
} else if (path5.isStringLiteral() || path5.isTemplateLiteral()) {
|
1046
1046
|
type = type !== void 0 ? 2 /* DynamicTag */ : 0 /* NativeTag */;
|
1047
|
-
} else if (
|
1047
|
+
} else if (path5.isNullLiteral()) {
|
1048
1048
|
nullable = true;
|
1049
|
-
} else if (
|
1050
|
-
if (
|
1049
|
+
} else if (path5.isIdentifier()) {
|
1050
|
+
if (path5.node.name === "undefined") {
|
1051
1051
|
nullable = true;
|
1052
1052
|
continue;
|
1053
1053
|
}
|
1054
|
-
const binding =
|
1054
|
+
const binding = path5.scope.getBinding(path5.node.name);
|
1055
1055
|
if (!binding) {
|
1056
1056
|
type = 2 /* DynamicTag */;
|
1057
1057
|
continue;
|
@@ -1101,18 +1101,18 @@ function analyzeExpressionTagName(name2, extra) {
|
|
1101
1101
|
}
|
1102
1102
|
|
1103
1103
|
// src/translator/util/sections.ts
|
1104
|
-
function startSection(
|
1105
|
-
const extra =
|
1104
|
+
function startSection(path5) {
|
1105
|
+
const extra = path5.node.extra ??= {};
|
1106
1106
|
let section = extra.section;
|
1107
|
-
if (!section && (
|
1108
|
-
const parentSection =
|
1109
|
-
const sectionNamePath =
|
1107
|
+
if (!section && (path5.type === "Program" || path5.get("body").length)) {
|
1108
|
+
const parentSection = path5.parentPath ? getOrCreateSection(path5.parentPath) : void 0;
|
1109
|
+
const sectionNamePath = path5.parentPath?.get(
|
1110
1110
|
"name"
|
1111
1111
|
);
|
1112
|
-
const sectionName =
|
1112
|
+
const sectionName = path5.isProgram() ? "" : currentProgramPath.scope.generateUid(
|
1113
1113
|
sectionNamePath.toString() + "_content"
|
1114
1114
|
);
|
1115
|
-
const programExtra =
|
1115
|
+
const programExtra = path5.hub.file.path.node.extra ??= {};
|
1116
1116
|
const sections = programExtra.sections ??= [];
|
1117
1117
|
section = extra.section = {
|
1118
1118
|
id: sections.length,
|
@@ -1122,7 +1122,7 @@ function startSection(path4) {
|
|
1122
1122
|
params: void 0,
|
1123
1123
|
closures: void 0,
|
1124
1124
|
bindings: void 0,
|
1125
|
-
content: getContentInfo(
|
1125
|
+
content: getContentInfo(path5),
|
1126
1126
|
upstreamExpression: void 0,
|
1127
1127
|
hasCleanup: false
|
1128
1128
|
};
|
@@ -1130,8 +1130,8 @@ function startSection(path4) {
|
|
1130
1130
|
}
|
1131
1131
|
return section;
|
1132
1132
|
}
|
1133
|
-
function getOrCreateSection(
|
1134
|
-
let cur =
|
1133
|
+
function getOrCreateSection(path5) {
|
1134
|
+
let cur = path5;
|
1135
1135
|
while (true) {
|
1136
1136
|
if (cur.type === "Program" || cur.type === "MarkoTagBody" && !cur.node.attributeTags && analyzeTagNameType(cur.parentPath) !== 0 /* NativeTag */ && cur.parent.name.value !== "html-comment") {
|
1137
1137
|
return startSection(cur);
|
@@ -1142,9 +1142,9 @@ function getOrCreateSection(path4) {
|
|
1142
1142
|
function getSectionForBody(body) {
|
1143
1143
|
return body.node.extra?.section;
|
1144
1144
|
}
|
1145
|
-
function getSection(
|
1145
|
+
function getSection(path5) {
|
1146
1146
|
let section;
|
1147
|
-
let currentPath =
|
1147
|
+
let currentPath = path5;
|
1148
1148
|
while ((section = currentPath.node.extra?.section) === void 0) {
|
1149
1149
|
currentPath = currentPath.parentPath;
|
1150
1150
|
}
|
@@ -1176,8 +1176,8 @@ function forEachSectionReverse(fn) {
|
|
1176
1176
|
fn(sections[i]);
|
1177
1177
|
}
|
1178
1178
|
}
|
1179
|
-
function getContentInfo(
|
1180
|
-
const body =
|
1179
|
+
function getContentInfo(path5) {
|
1180
|
+
const body = path5.get("body");
|
1181
1181
|
const contentInfo = {
|
1182
1182
|
startType: null,
|
1183
1183
|
endType: null,
|
@@ -1201,8 +1201,8 @@ function getContentInfo(path4) {
|
|
1201
1201
|
}
|
1202
1202
|
return null;
|
1203
1203
|
}
|
1204
|
-
function getNodeContentType(
|
1205
|
-
switch (
|
1204
|
+
function getNodeContentType(path5, extraMember, contentInfo) {
|
1205
|
+
switch (path5.type) {
|
1206
1206
|
case "MarkoText":
|
1207
1207
|
return 4 /* Text */;
|
1208
1208
|
case "MarkoPlaceholder":
|
@@ -1214,7 +1214,7 @@ function getNodeContentType(path4, extraMember, contentInfo) {
|
|
1214
1214
|
case "ExportNamedDeclaration":
|
1215
1215
|
return null;
|
1216
1216
|
case "MarkoTag": {
|
1217
|
-
const tag =
|
1217
|
+
const tag = path5;
|
1218
1218
|
if (isCoreTag(tag)) {
|
1219
1219
|
switch (tag.node.name.value) {
|
1220
1220
|
case "html-comment":
|
@@ -1265,6 +1265,43 @@ var checkStatefulClosures = (section, immediateOnly) => {
|
|
1265
1265
|
|
1266
1266
|
// src/translator/visitors/program/dom.ts
|
1267
1267
|
var import_compiler18 = require("@marko/compiler");
|
1268
|
+
var import_babel_utils10 = require("@marko/compiler/babel-utils");
|
1269
|
+
|
1270
|
+
// src/translator/util/get-style-file.ts
|
1271
|
+
var import_path = __toESM(require("path"));
|
1272
|
+
function getStyleFile(file) {
|
1273
|
+
const { filename } = file.opts;
|
1274
|
+
const fs = file.markoOpts.fileSystem;
|
1275
|
+
const base = getBase(filename);
|
1276
|
+
const styleMatch = new RegExp(
|
1277
|
+
`^(${escapeRegExp(base)}\\.${"index" === base ? "|" : ""})style\\.\\w+$`
|
1278
|
+
);
|
1279
|
+
for (const file2 of fs.readdirSync(import_path.default.dirname(filename)).sort()) {
|
1280
|
+
if (styleMatch.test(file2)) {
|
1281
|
+
return `./${file2}`;
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
}
|
1285
|
+
function getBase(filename) {
|
1286
|
+
const start = filename.lastIndexOf(import_path.default.sep) + 1;
|
1287
|
+
const leftDot = filename.indexOf(".", start);
|
1288
|
+
if (leftDot === -1) {
|
1289
|
+
return filename.slice(start);
|
1290
|
+
}
|
1291
|
+
const rightDot = filename.lastIndexOf(".");
|
1292
|
+
const closeBracket = leftDot - 1;
|
1293
|
+
if (filename[closeBracket] === "]") {
|
1294
|
+
const openBracket = filename.lastIndexOf("[", closeBracket);
|
1295
|
+
if (openBracket > start) {
|
1296
|
+
return filename.slice(start, openBracket) + filename.slice(leftDot, rightDot);
|
1297
|
+
}
|
1298
|
+
}
|
1299
|
+
return filename.slice(start, rightDot);
|
1300
|
+
}
|
1301
|
+
var regexpCharsReg = /[\\^$.*+?()[\]{}|]/g;
|
1302
|
+
function escapeRegExp(str) {
|
1303
|
+
return str.replace(regexpCharsReg, "\\$&");
|
1304
|
+
}
|
1268
1305
|
|
1269
1306
|
// src/translator/util/signals.ts
|
1270
1307
|
var import_compiler17 = require("@marko/compiler");
|
@@ -1287,29 +1324,29 @@ function getKnownAttrValues(tag) {
|
|
1287
1324
|
|
1288
1325
|
// src/translator/util/plugin-hooks.ts
|
1289
1326
|
var import_compiler7 = require("@marko/compiler");
|
1290
|
-
function enter(modulePlugin,
|
1327
|
+
function enter(modulePlugin, path5) {
|
1291
1328
|
if (!modulePlugin) {
|
1292
1329
|
return false;
|
1293
1330
|
}
|
1294
|
-
const { node } =
|
1331
|
+
const { node } = path5;
|
1295
1332
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
1296
1333
|
if (isFunctionPlugin(plugin)) {
|
1297
|
-
plugin(
|
1334
|
+
plugin(path5, import_compiler7.types);
|
1298
1335
|
} else if (plugin.enter) {
|
1299
|
-
plugin.enter(
|
1336
|
+
plugin.enter(path5, import_compiler7.types);
|
1300
1337
|
}
|
1301
|
-
return node !==
|
1338
|
+
return node !== path5.node;
|
1302
1339
|
}
|
1303
|
-
function exit(modulePlugin,
|
1340
|
+
function exit(modulePlugin, path5) {
|
1304
1341
|
if (!modulePlugin) {
|
1305
1342
|
return false;
|
1306
1343
|
}
|
1307
|
-
const { node } =
|
1344
|
+
const { node } = path5;
|
1308
1345
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
1309
1346
|
if (!isFunctionPlugin(plugin) && plugin.exit) {
|
1310
|
-
plugin.exit(
|
1347
|
+
plugin.exit(path5, import_compiler7.types);
|
1311
1348
|
}
|
1312
|
-
return node !==
|
1349
|
+
return node !== path5.node;
|
1313
1350
|
}
|
1314
1351
|
function isModulePlugin(plugin) {
|
1315
1352
|
return Boolean(plugin.default);
|
@@ -1341,11 +1378,11 @@ function translateByTarget({
|
|
1341
1378
|
dom
|
1342
1379
|
}) {
|
1343
1380
|
return {
|
1344
|
-
enter(
|
1345
|
-
enter(isOutputHTML() ? html : dom,
|
1381
|
+
enter(path5) {
|
1382
|
+
enter(isOutputHTML() ? html : dom, path5);
|
1346
1383
|
},
|
1347
|
-
exit(
|
1348
|
-
exit(isOutputHTML() ? html : dom,
|
1384
|
+
exit(path5) {
|
1385
|
+
exit(isOutputHTML() ? html : dom, path5);
|
1349
1386
|
}
|
1350
1387
|
};
|
1351
1388
|
}
|
@@ -1431,18 +1468,18 @@ var walkCodeToName = {
|
|
1431
1468
|
[116 /* OutEnd */]: "outEnd",
|
1432
1469
|
[126 /* MultiplierEnd */]: "multiplierEnd"
|
1433
1470
|
};
|
1434
|
-
function enter2(
|
1435
|
-
getSteps(getSection(
|
1471
|
+
function enter2(path5) {
|
1472
|
+
getSteps(getSection(path5)).push(0 /* Enter */);
|
1436
1473
|
}
|
1437
|
-
function exit2(
|
1438
|
-
getSteps(getSection(
|
1474
|
+
function exit2(path5) {
|
1475
|
+
getSteps(getSection(path5)).push(1 /* Exit */);
|
1439
1476
|
}
|
1440
|
-
function enterShallow(
|
1441
|
-
getSteps(getSection(
|
1477
|
+
function enterShallow(path5) {
|
1478
|
+
getSteps(getSection(path5)).push(0 /* Enter */, 1 /* Exit */);
|
1442
1479
|
}
|
1443
|
-
function injectWalks(
|
1444
|
-
const walks = getWalks(getSection(
|
1445
|
-
const walkComment = getWalkComment(getSection(
|
1480
|
+
function injectWalks(path5, expr) {
|
1481
|
+
const walks = getWalks(getSection(path5));
|
1482
|
+
const walkComment = getWalkComment(getSection(path5));
|
1446
1483
|
walkComment.push(
|
1447
1484
|
`${walkCodeToName[47 /* BeginChild */]}`,
|
1448
1485
|
expr.name,
|
@@ -1451,11 +1488,11 @@ function injectWalks(path4, expr) {
|
|
1451
1488
|
appendLiteral(walks, String.fromCharCode(47 /* BeginChild */));
|
1452
1489
|
walks.push(expr, String.fromCharCode(38 /* EndChild */));
|
1453
1490
|
}
|
1454
|
-
function visit(
|
1491
|
+
function visit(path5, code) {
|
1455
1492
|
if (isOutputHTML()) {
|
1456
1493
|
return;
|
1457
1494
|
}
|
1458
|
-
const section = getSection(
|
1495
|
+
const section = getSection(path5);
|
1459
1496
|
const steps = getSteps(section);
|
1460
1497
|
const walks = getWalks(section);
|
1461
1498
|
const walkComment = getWalkComment(section);
|
@@ -1497,7 +1534,7 @@ function visit(path4, code) {
|
|
1497
1534
|
}
|
1498
1535
|
if (code !== void 0) {
|
1499
1536
|
if (code !== 32 /* Get */) {
|
1500
|
-
writeTo(
|
1537
|
+
writeTo(path5)`<!>`;
|
1501
1538
|
}
|
1502
1539
|
walkComment.push(`${walkCodeToName[code]}`);
|
1503
1540
|
walkString += String.fromCharCode(code);
|
@@ -1555,8 +1592,8 @@ var [getTrailerWrites] = createSectionState(
|
|
1555
1592
|
"trailerWrites",
|
1556
1593
|
() => [""]
|
1557
1594
|
);
|
1558
|
-
function writeTo(
|
1559
|
-
const section = getSection(
|
1595
|
+
function writeTo(path5, trailer) {
|
1596
|
+
const section = getSection(path5);
|
1560
1597
|
const get = trailer ? getTrailerWrites : getWrites;
|
1561
1598
|
return (strs, ...exprs) => {
|
1562
1599
|
const exprsLen = exprs.length;
|
@@ -1567,8 +1604,8 @@ function writeTo(path4, trailer) {
|
|
1567
1604
|
}
|
1568
1605
|
};
|
1569
1606
|
}
|
1570
|
-
function consumeHTML(
|
1571
|
-
const section = getSection(
|
1607
|
+
function consumeHTML(path5) {
|
1608
|
+
const section = getSection(path5);
|
1572
1609
|
const writes = getWrites(section);
|
1573
1610
|
const trailers = getTrailerWrites(section);
|
1574
1611
|
const writeResult = normalizeStringExpression(writes);
|
@@ -1590,14 +1627,14 @@ function consumeHTML(path4) {
|
|
1590
1627
|
return import_compiler10.types.expressionStatement(callRuntime("writeTrailers", trailerResult));
|
1591
1628
|
}
|
1592
1629
|
}
|
1593
|
-
function flushBefore(
|
1594
|
-
const expr = consumeHTML(
|
1630
|
+
function flushBefore(path5) {
|
1631
|
+
const expr = consumeHTML(path5);
|
1595
1632
|
if (expr) {
|
1596
|
-
|
1633
|
+
path5.insertBefore(expr)[0].skip();
|
1597
1634
|
}
|
1598
1635
|
}
|
1599
|
-
function flushInto(
|
1600
|
-
const target =
|
1636
|
+
function flushInto(path5) {
|
1637
|
+
const target = path5.isProgram() ? path5 : path5.get("body");
|
1601
1638
|
const expr = consumeHTML(target);
|
1602
1639
|
if (expr) {
|
1603
1640
|
target.pushContainer("body", expr)[0].skip();
|
@@ -1613,15 +1650,15 @@ function getSectionMeta(section) {
|
|
1613
1650
|
writes: normalizeStringExpression([writePrefix, ...writes, writePostfix]) || import_compiler10.types.stringLiteral("")
|
1614
1651
|
};
|
1615
1652
|
}
|
1616
|
-
function markNode(
|
1617
|
-
const section = getSection(
|
1653
|
+
function markNode(path5, binding) {
|
1654
|
+
const section = getSection(path5);
|
1618
1655
|
if (binding.type !== 0 /* dom */) {
|
1619
|
-
throw
|
1656
|
+
throw path5.buildCodeFrameError(
|
1620
1657
|
"Tried to mark a node that was not determined to need a mark during analyze."
|
1621
1658
|
);
|
1622
1659
|
}
|
1623
1660
|
if (isOutputHTML()) {
|
1624
|
-
writeTo(
|
1661
|
+
writeTo(path5)`${callRuntime(
|
1625
1662
|
"markResumeNode",
|
1626
1663
|
getScopeIdIdentifier(section),
|
1627
1664
|
getScopeAccessorLiteral(binding)
|
@@ -2474,8 +2511,8 @@ function getMappedId(reference) {
|
|
2474
2511
|
function addHTMLEffectCall(section, referencedBindings) {
|
2475
2512
|
addStatement("effect", section, referencedBindings, void 0, false);
|
2476
2513
|
}
|
2477
|
-
function writeHTMLResumeStatements(
|
2478
|
-
const section = getSectionForBody(
|
2514
|
+
function writeHTMLResumeStatements(path5, tagVarIdentifier) {
|
2515
|
+
const section = getSectionForBody(path5);
|
2479
2516
|
if (!section) return;
|
2480
2517
|
const allSignals = Array.from(getSignals(section).values());
|
2481
2518
|
const scopeIdIdentifier = getScopeIdIdentifier(section);
|
@@ -2495,7 +2532,7 @@ function writeHTMLResumeStatements(path4, tagVarIdentifier) {
|
|
2495
2532
|
const isImmediateOwner = section.parent?.id === closure.section.id;
|
2496
2533
|
const isDynamicClosure = !getSubscribeBuilder(section) || !isImmediateOwner;
|
2497
2534
|
if (isDynamicClosure) {
|
2498
|
-
|
2535
|
+
path5.pushContainer(
|
2499
2536
|
"body",
|
2500
2537
|
import_compiler17.types.expressionStatement(
|
2501
2538
|
callRuntime(
|
@@ -2513,7 +2550,7 @@ function writeHTMLResumeStatements(path4, tagVarIdentifier) {
|
|
2513
2550
|
for (let i = allSignals.length; i--; ) {
|
2514
2551
|
if (allSignals[i].effect.length) {
|
2515
2552
|
const signalRefs = allSignals[i].referencedBindings;
|
2516
|
-
|
2553
|
+
path5.pushContainer(
|
2517
2554
|
"body",
|
2518
2555
|
import_compiler17.types.expressionStatement(
|
2519
2556
|
callRuntime(
|
@@ -2554,7 +2591,7 @@ function writeHTMLResumeStatements(path4, tagVarIdentifier) {
|
|
2554
2591
|
}
|
2555
2592
|
}
|
2556
2593
|
if (serializedProperties.length || forceResumeScope(section)) {
|
2557
|
-
|
2594
|
+
path5.pushContainer(
|
2558
2595
|
"body",
|
2559
2596
|
import_compiler17.types.expressionStatement(
|
2560
2597
|
callRuntime(
|
@@ -2565,8 +2602,8 @@ function writeHTMLResumeStatements(path4, tagVarIdentifier) {
|
|
2565
2602
|
)
|
2566
2603
|
);
|
2567
2604
|
}
|
2568
|
-
if (
|
2569
|
-
|
2605
|
+
if (path5.get("body").length) {
|
2606
|
+
path5.unshiftContainer(
|
2570
2607
|
"body",
|
2571
2608
|
import_compiler17.types.variableDeclaration("const", [
|
2572
2609
|
import_compiler17.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
|
@@ -2756,6 +2793,10 @@ var dom_default = {
|
|
2756
2793
|
const closuresIdentifier = import_compiler18.types.identifier(domExports.closures);
|
2757
2794
|
const paramsBinding = program.node.extra.binding;
|
2758
2795
|
const programParamsSignal = paramsBinding && bindingHasDownstreamExpressions(paramsBinding) ? initValue(paramsBinding) : void 0;
|
2796
|
+
const styleFile = getStyleFile(program.hub.file);
|
2797
|
+
if (styleFile) {
|
2798
|
+
(0, import_babel_utils10.importDefault)(program.hub.file, styleFile);
|
2799
|
+
}
|
2759
2800
|
forEachSectionReverse((childSection) => {
|
2760
2801
|
if (childSection !== section) {
|
2761
2802
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
@@ -2857,8 +2898,8 @@ function getSectionClosuresExpr(section) {
|
|
2857
2898
|
var import_compiler19 = require("@marko/compiler");
|
2858
2899
|
|
2859
2900
|
// src/translator/util/is-static.ts
|
2860
|
-
function isStatic(
|
2861
|
-
return
|
2901
|
+
function isStatic(path5) {
|
2902
|
+
return path5.isImportDeclaration() || path5.isExportDeclaration() || path5.isMarkoScriptlet({ static: true });
|
2862
2903
|
}
|
2863
2904
|
|
2864
2905
|
// src/translator/visitors/program/html.ts
|
@@ -3057,12 +3098,12 @@ var program_default = {
|
|
3057
3098
|
if (getMarkoOpts().output === "hydrate") {
|
3058
3099
|
const entryFile = program.hub.file;
|
3059
3100
|
const visitedFiles = /* @__PURE__ */ new Set([
|
3060
|
-
(0,
|
3101
|
+
(0, import_babel_utils11.resolveRelativePath)(entryFile, entryFile.opts.filename)
|
3061
3102
|
]);
|
3062
3103
|
entry_builder_default.visit(entryFile, entryFile, function visitChild(resolved) {
|
3063
3104
|
if (!visitedFiles.has(resolved)) {
|
3064
3105
|
visitedFiles.add(resolved);
|
3065
|
-
const file = (0,
|
3106
|
+
const file = (0, import_babel_utils11.loadFileForImport)(entryFile, resolved);
|
3066
3107
|
if (file) {
|
3067
3108
|
entry_builder_default.visit(
|
3068
3109
|
file,
|
@@ -3101,9 +3142,9 @@ var program_default = {
|
|
3101
3142
|
}
|
3102
3143
|
};
|
3103
3144
|
function resolveRelativeToEntry(entryFile, file, req) {
|
3104
|
-
return file === entryFile ? (0,
|
3145
|
+
return file === entryFile ? (0, import_babel_utils11.resolveRelativePath)(file, req) : (0, import_babel_utils11.resolveRelativePath)(
|
3105
3146
|
entryFile,
|
3106
|
-
req[0] === "." ?
|
3147
|
+
req[0] === "." ? import_path2.default.join(file.opts.filename, "..", req) : req
|
3107
3148
|
);
|
3108
3149
|
}
|
3109
3150
|
function buildTemplateExports(binding, scope) {
|
@@ -3131,22 +3172,22 @@ function buildTemplateExports(binding, scope) {
|
|
3131
3172
|
}
|
3132
3173
|
|
3133
3174
|
// src/translator/util/get-root.ts
|
3134
|
-
function getMarkoRoot(
|
3135
|
-
let curPath =
|
3175
|
+
function getMarkoRoot(path5) {
|
3176
|
+
let curPath = path5;
|
3136
3177
|
do
|
3137
3178
|
curPath = curPath.parentPath;
|
3138
3179
|
while (curPath && !isMarko(curPath));
|
3139
3180
|
return curPath;
|
3140
3181
|
}
|
3141
|
-
function getExprRoot(
|
3142
|
-
let curPath =
|
3182
|
+
function getExprRoot(path5) {
|
3183
|
+
let curPath = path5;
|
3143
3184
|
while (!isMarko(curPath.parentPath)) {
|
3144
3185
|
curPath = curPath.parentPath;
|
3145
3186
|
}
|
3146
3187
|
return curPath;
|
3147
3188
|
}
|
3148
|
-
function getFnRoot(
|
3149
|
-
let curPath =
|
3189
|
+
function getFnRoot(path5) {
|
3190
|
+
let curPath = path5;
|
3150
3191
|
if (curPath.isProgram()) return;
|
3151
3192
|
while (!isFunctionExpression(curPath)) {
|
3152
3193
|
if (isMarko(curPath)) return;
|
@@ -3154,8 +3195,8 @@ function getFnRoot(path4) {
|
|
3154
3195
|
}
|
3155
3196
|
return curPath;
|
3156
3197
|
}
|
3157
|
-
function isMarko(
|
3158
|
-
switch (
|
3198
|
+
function isMarko(path5) {
|
3199
|
+
switch (path5.type) {
|
3159
3200
|
case "MarkoTag":
|
3160
3201
|
case "MarkoTagBody":
|
3161
3202
|
case "MarkoAttribute":
|
@@ -3167,8 +3208,8 @@ function isMarko(path4) {
|
|
3167
3208
|
return false;
|
3168
3209
|
}
|
3169
3210
|
}
|
3170
|
-
function isFunctionExpression(
|
3171
|
-
switch (
|
3211
|
+
function isFunctionExpression(path5) {
|
3212
|
+
switch (path5.type) {
|
3172
3213
|
case "FunctionExpression":
|
3173
3214
|
case "ArrowFunctionExpression":
|
3174
3215
|
return true;
|
@@ -3292,8 +3333,8 @@ function trackAssignment(assignment, binding) {
|
|
3292
3333
|
}
|
3293
3334
|
});
|
3294
3335
|
}
|
3295
|
-
function setReferencesScope(
|
3296
|
-
let fnRoot = getFnRoot(
|
3336
|
+
function setReferencesScope(path5) {
|
3337
|
+
let fnRoot = getFnRoot(path5);
|
3297
3338
|
while (fnRoot) {
|
3298
3339
|
(fnRoot.node.extra ??= {}).referencesScope = true;
|
3299
3340
|
fnRoot = getFnRoot(fnRoot.parentPath);
|
@@ -3635,10 +3676,10 @@ var [getReadsByExpression] = createProgramState(
|
|
3635
3676
|
var [getReadsByFunction] = createProgramState(
|
3636
3677
|
() => /* @__PURE__ */ new Map()
|
3637
3678
|
);
|
3638
|
-
function addReadToExpression(
|
3639
|
-
const exprExtra =
|
3679
|
+
function addReadToExpression(path5, binding, node) {
|
3680
|
+
const exprExtra = path5.node.extra ??= {};
|
3640
3681
|
const readsByExpression = getReadsByExpression();
|
3641
|
-
exprExtra.section = getOrCreateSection(
|
3682
|
+
exprExtra.section = getOrCreateSection(path5);
|
3642
3683
|
readsByExpression.set(
|
3643
3684
|
exprExtra,
|
3644
3685
|
push(readsByExpression.get(exprExtra), { binding, node })
|
@@ -3855,10 +3896,10 @@ function isStatefulBinding(binding) {
|
|
3855
3896
|
// src/translator/core/await.ts
|
3856
3897
|
var await_default = {
|
3857
3898
|
analyze(tag) {
|
3858
|
-
(0,
|
3859
|
-
(0,
|
3899
|
+
(0, import_babel_utils12.assertNoVar)(tag);
|
3900
|
+
(0, import_babel_utils12.assertNoArgs)(tag);
|
3860
3901
|
assertNoSpreadAttrs(tag);
|
3861
|
-
(0,
|
3902
|
+
(0, import_babel_utils12.assertNoAttributeTags)(tag);
|
3862
3903
|
const { node } = tag;
|
3863
3904
|
const [valueAttr] = node.attributes;
|
3864
3905
|
if (!valueAttr) {
|
@@ -3951,7 +3992,7 @@ var await_default = {
|
|
3951
3992
|
|
3952
3993
|
// src/translator/core/client.ts
|
3953
3994
|
var import_compiler23 = require("@marko/compiler");
|
3954
|
-
var
|
3995
|
+
var import_babel_utils13 = require("@marko/compiler/babel-utils");
|
3955
3996
|
var client_default = {
|
3956
3997
|
parse(tag) {
|
3957
3998
|
const {
|
@@ -3961,7 +4002,7 @@ var client_default = {
|
|
3961
4002
|
const rawValue = node.rawValue;
|
3962
4003
|
const code = rawValue.replace(/^client\s*/, "").trim();
|
3963
4004
|
const start = node.name.start + (rawValue.length - code.length);
|
3964
|
-
let body = (0,
|
4005
|
+
let body = (0, import_babel_utils13.parseStatements)(file, code, start, start + code.length);
|
3965
4006
|
if (body.length === 1 && import_compiler23.types.isBlockStatement(body[0])) {
|
3966
4007
|
body = body[0].body;
|
3967
4008
|
}
|
@@ -3982,7 +4023,7 @@ var client_default = {
|
|
3982
4023
|
|
3983
4024
|
// src/translator/core/const.ts
|
3984
4025
|
var import_compiler25 = require("@marko/compiler");
|
3985
|
-
var
|
4026
|
+
var import_babel_utils14 = require("@marko/compiler/babel-utils");
|
3986
4027
|
|
3987
4028
|
// src/translator/util/translate-var.ts
|
3988
4029
|
var import_compiler24 = require("@marko/compiler");
|
@@ -4001,8 +4042,8 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
4001
4042
|
// src/translator/core/const.ts
|
4002
4043
|
var const_default = {
|
4003
4044
|
analyze(tag) {
|
4004
|
-
(0,
|
4005
|
-
(0,
|
4045
|
+
(0, import_babel_utils14.assertNoArgs)(tag);
|
4046
|
+
(0, import_babel_utils14.assertNoParams)(tag);
|
4006
4047
|
assertNoBodyContent(tag);
|
4007
4048
|
const { node } = tag;
|
4008
4049
|
const [valueAttr] = node.attributes;
|
@@ -4059,13 +4100,13 @@ var const_default = {
|
|
4059
4100
|
|
4060
4101
|
// src/translator/core/debug.ts
|
4061
4102
|
var import_compiler26 = require("@marko/compiler");
|
4062
|
-
var
|
4103
|
+
var import_babel_utils15 = require("@marko/compiler/babel-utils");
|
4063
4104
|
var debug_default = {
|
4064
4105
|
analyze(tag) {
|
4065
4106
|
const [valueAttr] = tag.node.attributes;
|
4066
|
-
(0,
|
4067
|
-
(0,
|
4068
|
-
(0,
|
4107
|
+
(0, import_babel_utils15.assertNoVar)(tag);
|
4108
|
+
(0, import_babel_utils15.assertNoArgs)(tag);
|
4109
|
+
(0, import_babel_utils15.assertNoParams)(tag);
|
4069
4110
|
assertNoBodyContent(tag);
|
4070
4111
|
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler26.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
4071
4112
|
throw tag.get("name").buildCodeFrameError(
|
@@ -4102,11 +4143,11 @@ var debug_default = {
|
|
4102
4143
|
|
4103
4144
|
// src/translator/core/define.ts
|
4104
4145
|
var import_compiler31 = require("@marko/compiler");
|
4105
|
-
var
|
4146
|
+
var import_babel_utils20 = require("@marko/compiler/babel-utils");
|
4106
4147
|
|
4107
4148
|
// src/translator/util/nested-attribute-tags.ts
|
4108
4149
|
var import_compiler27 = require("@marko/compiler");
|
4109
|
-
var
|
4150
|
+
var import_babel_utils16 = require("@marko/compiler/babel-utils");
|
4110
4151
|
|
4111
4152
|
// src/translator/util/get-parent-tag.ts
|
4112
4153
|
function getParentTag(tag) {
|
@@ -4136,12 +4177,12 @@ function analyzeAttributeTags(tag) {
|
|
4136
4177
|
const sampleAttrTagsForControlFlow = /* @__PURE__ */ new Map();
|
4137
4178
|
for (const child of attrTags2) {
|
4138
4179
|
if (child.isMarkoTag()) {
|
4139
|
-
if ((0,
|
4180
|
+
if ((0, import_babel_utils16.isAttributeTag)(child)) {
|
4140
4181
|
const name2 = getTagName(child);
|
4141
4182
|
lookup[name2] ||= createAttrTagMeta(name2, [name2]);
|
4142
4183
|
analyzeAttributeTags(child);
|
4143
4184
|
} else {
|
4144
|
-
const isRepeated = (0,
|
4185
|
+
const isRepeated = (0, import_babel_utils16.isLoopTag)(child);
|
4145
4186
|
let curGroup;
|
4146
4187
|
for (const name2 of crawlAttrTags(child, attrTagNodesByName)) {
|
4147
4188
|
const oldMeta = lookup[name2];
|
@@ -4196,7 +4237,7 @@ function crawlAttrTags(tag, attrTagNodesByName, attrTagNames = /* @__PURE__ */ n
|
|
4196
4237
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
4197
4238
|
for (const child of attrTags2) {
|
4198
4239
|
if (child.isMarkoTag()) {
|
4199
|
-
if ((0,
|
4240
|
+
if ((0, import_babel_utils16.isAttributeTag)(child)) {
|
4200
4241
|
const tagName = getTagName(child);
|
4201
4242
|
attrTagNames.add(tagName);
|
4202
4243
|
(attrTagNodesByName[tagName] ||= []).push(child);
|
@@ -4237,15 +4278,15 @@ function getConditionRoot(tag) {
|
|
4237
4278
|
|
4238
4279
|
// src/translator/util/translate-attrs.ts
|
4239
4280
|
var import_compiler30 = require("@marko/compiler");
|
4240
|
-
var
|
4281
|
+
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
4241
4282
|
|
4242
4283
|
// src/translator/core/for.ts
|
4243
4284
|
var import_compiler29 = require("@marko/compiler");
|
4244
|
-
var
|
4285
|
+
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
4245
4286
|
|
4246
4287
|
// src/translator/visitors/tag/native-tag.ts
|
4247
4288
|
var import_compiler28 = require("@marko/compiler");
|
4248
|
-
var
|
4289
|
+
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
4249
4290
|
var kNativeTagBinding = Symbol("native tag binding");
|
4250
4291
|
var kSerializeMarker = Symbol("serialize marker");
|
4251
4292
|
var kGetterId = Symbol("node getter id");
|
@@ -4347,9 +4388,9 @@ var native_tag_default = {
|
|
4347
4388
|
},
|
4348
4389
|
analyze: {
|
4349
4390
|
enter(tag) {
|
4350
|
-
(0,
|
4351
|
-
(0,
|
4352
|
-
(0,
|
4391
|
+
(0, import_babel_utils17.assertNoArgs)(tag);
|
4392
|
+
(0, import_babel_utils17.assertNoParams)(tag);
|
4393
|
+
(0, import_babel_utils17.assertNoAttributeTags)(tag);
|
4353
4394
|
const { node } = tag;
|
4354
4395
|
if (node.var && !import_compiler28.types.isIdentifier(node.var)) {
|
4355
4396
|
throw tag.get("var").buildCodeFrameError(
|
@@ -4441,7 +4482,7 @@ var native_tag_default = {
|
|
4441
4482
|
const nodeRef2 = extra[kNativeTagBinding];
|
4442
4483
|
const isHTML = isOutputHTML();
|
4443
4484
|
const name2 = tag.get("name");
|
4444
|
-
const tagDef = (0,
|
4485
|
+
const tagDef = (0, import_babel_utils17.getTagDef)(tag);
|
4445
4486
|
const write2 = writeTo(tag);
|
4446
4487
|
const section = getSection(tag);
|
4447
4488
|
if (isHTML && extra.tagNameNullable) {
|
@@ -4758,7 +4799,7 @@ var native_tag_default = {
|
|
4758
4799
|
const extra = tag.node.extra;
|
4759
4800
|
const nodeRef2 = extra[kNativeTagBinding];
|
4760
4801
|
const isHTML = isOutputHTML();
|
4761
|
-
const openTagOnly = (0,
|
4802
|
+
const openTagOnly = (0, import_babel_utils17.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
4762
4803
|
const selectArgs = isHTML && htmlSelectArgs.get(tag.node);
|
4763
4804
|
const tagName = getTagName(tag);
|
4764
4805
|
if (isHTML && extra.tagNameNullable) {
|
@@ -4902,8 +4943,8 @@ var for_default = {
|
|
4902
4943
|
const tagExtra = tag.node.extra ??= {};
|
4903
4944
|
const isAttrTag = tag.node.body.attributeTags;
|
4904
4945
|
let allowAttrs;
|
4905
|
-
(0,
|
4906
|
-
(0,
|
4946
|
+
(0, import_babel_utils18.assertNoVar)(tag);
|
4947
|
+
(0, import_babel_utils18.assertNoArgs)(tag);
|
4907
4948
|
assertNoSpreadAttrs(tag);
|
4908
4949
|
switch (getForType(tag.node)) {
|
4909
4950
|
case "of":
|
@@ -4923,7 +4964,7 @@ var for_default = {
|
|
4923
4964
|
if (!isAttrTag) {
|
4924
4965
|
allowAttrs.push("by");
|
4925
4966
|
}
|
4926
|
-
(0,
|
4967
|
+
(0, import_babel_utils18.assertAllowedAttributes)(tag, allowAttrs);
|
4927
4968
|
if (isAttrTag) return;
|
4928
4969
|
const tagBody = tag.get("body");
|
4929
4970
|
const bodySection = startSection(tagBody);
|
@@ -5354,7 +5395,7 @@ function isOnlyChildInParent(tag) {
|
|
5354
5395
|
return extra[kOnlyChildInParent];
|
5355
5396
|
}
|
5356
5397
|
const parentTag = getParentTag(tag);
|
5357
|
-
if (parentTag && (0,
|
5398
|
+
if (parentTag && (0, import_babel_utils18.getTagDef)(parentTag)?.html) {
|
5358
5399
|
return extra[kOnlyChildInParent] = tag.parent.body.length === 1;
|
5359
5400
|
}
|
5360
5401
|
return extra[kOnlyChildInParent] = false;
|
@@ -5390,7 +5431,7 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
5390
5431
|
for (let i = 0; i < attrTags2.length; i++) {
|
5391
5432
|
const child = attrTags2[i];
|
5392
5433
|
if (child.isMarkoTag()) {
|
5393
|
-
if ((0,
|
5434
|
+
if ((0, import_babel_utils19.isAttributeTag)(child)) {
|
5394
5435
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
5395
5436
|
if (attrTagMeta.dynamic) {
|
5396
5437
|
i = addDynamicAttrTagStatements(
|
@@ -5488,7 +5529,7 @@ function getTranslatedBodyContentProperty(props) {
|
|
5488
5529
|
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, templateExports, contentKey = "content") {
|
5489
5530
|
const tag = attrTags2[index];
|
5490
5531
|
if (tag.isMarkoTag()) {
|
5491
|
-
if ((0,
|
5532
|
+
if ((0, import_babel_utils19.isAttributeTag)(tag)) {
|
5492
5533
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
5493
5534
|
if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
|
5494
5535
|
const translatedAttrTag = translateAttrs(
|
@@ -5693,7 +5734,7 @@ function buildContent(body) {
|
|
5693
5734
|
}
|
5694
5735
|
function getNonAttributeTagParent(tag) {
|
5695
5736
|
let cur = tag;
|
5696
|
-
while ((0,
|
5737
|
+
while ((0, import_babel_utils19.isAttributeTag)(cur) || (0, import_babel_utils19.isTransparentTag)(cur)) {
|
5697
5738
|
cur = getParentTag(cur);
|
5698
5739
|
}
|
5699
5740
|
return cur;
|
@@ -5702,7 +5743,7 @@ function getNonAttributeTagParent(tag) {
|
|
5702
5743
|
// src/translator/core/define.ts
|
5703
5744
|
var define_default = {
|
5704
5745
|
analyze(tag) {
|
5705
|
-
(0,
|
5746
|
+
(0, import_babel_utils20.assertNoArgs)(tag);
|
5706
5747
|
if (!tag.node.var) {
|
5707
5748
|
throw tag.get("name").buildCodeFrameError("The `define` tag requires a tag variable.");
|
5708
5749
|
}
|
@@ -5765,17 +5806,17 @@ var define_default = {
|
|
5765
5806
|
|
5766
5807
|
// src/translator/core/effect.ts
|
5767
5808
|
var import_compiler32 = require("@marko/compiler");
|
5768
|
-
var
|
5809
|
+
var import_babel_utils21 = require("@marko/compiler/babel-utils");
|
5769
5810
|
var effect_default = {
|
5770
5811
|
migrate: [
|
5771
5812
|
(tag) => {
|
5772
|
-
(0,
|
5773
|
-
(0,
|
5813
|
+
(0, import_babel_utils21.assertNoArgs)(tag);
|
5814
|
+
(0, import_babel_utils21.assertNoParams)(tag);
|
5774
5815
|
assertNoBodyContent(tag);
|
5775
|
-
(0,
|
5816
|
+
(0, import_babel_utils21.assertNoAttributeTags)(tag);
|
5776
5817
|
assertNoSpreadAttrs(tag);
|
5777
|
-
(0,
|
5778
|
-
(0,
|
5818
|
+
(0, import_babel_utils21.assertAllowedAttributes)(tag, ["value"]);
|
5819
|
+
(0, import_babel_utils21.diagnosticDeprecate)(tag, {
|
5779
5820
|
label: "The 'effect' tag has been replaced by the 'script' tag.",
|
5780
5821
|
fix() {
|
5781
5822
|
const { node } = tag;
|
@@ -5798,12 +5839,12 @@ var effect_default = {
|
|
5798
5839
|
};
|
5799
5840
|
|
5800
5841
|
// src/translator/core/export.ts
|
5801
|
-
var
|
5842
|
+
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
5802
5843
|
var export_default = {
|
5803
5844
|
parse(tag) {
|
5804
5845
|
const { node } = tag;
|
5805
5846
|
tag.replaceWith(
|
5806
|
-
(0,
|
5847
|
+
(0, import_babel_utils22.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
5807
5848
|
);
|
5808
5849
|
},
|
5809
5850
|
parseOptions: {
|
@@ -5819,14 +5860,14 @@ var export_default = {
|
|
5819
5860
|
|
5820
5861
|
// src/translator/core/html-comment.ts
|
5821
5862
|
var import_compiler33 = require("@marko/compiler");
|
5822
|
-
var
|
5863
|
+
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
5823
5864
|
var kCommentTagBinding = Symbol("comment tag binding");
|
5824
5865
|
var kGetterId2 = Symbol("node getter id");
|
5825
5866
|
var html_comment_default = {
|
5826
5867
|
analyze(tag) {
|
5827
|
-
(0,
|
5828
|
-
(0,
|
5829
|
-
(0,
|
5868
|
+
(0, import_babel_utils23.assertNoArgs)(tag);
|
5869
|
+
(0, import_babel_utils23.assertNoParams)(tag);
|
5870
|
+
(0, import_babel_utils23.assertNoAttributes)(tag);
|
5830
5871
|
const tagVar = tag.node.var;
|
5831
5872
|
let needsBinding = false;
|
5832
5873
|
let needsGetter = false;
|
@@ -5995,12 +6036,12 @@ var html_comment_default = {
|
|
5995
6036
|
|
5996
6037
|
// src/translator/core/html-script.ts
|
5997
6038
|
var import_compiler34 = require("@marko/compiler");
|
5998
|
-
var
|
6039
|
+
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
5999
6040
|
var kGetterId3 = Symbol("node getter id");
|
6000
6041
|
var html_script_default = {
|
6001
6042
|
analyze(tag) {
|
6002
|
-
(0,
|
6003
|
-
(0,
|
6043
|
+
(0, import_babel_utils24.assertNoArgs)(tag);
|
6044
|
+
(0, import_babel_utils24.assertNoParams)(tag);
|
6004
6045
|
const { node } = tag;
|
6005
6046
|
if (node.var && !import_compiler34.types.isIdentifier(node.var)) {
|
6006
6047
|
throw tag.get("var").buildCodeFrameError(
|
@@ -6390,12 +6431,12 @@ function getUsedAttrs2(tag) {
|
|
6390
6431
|
|
6391
6432
|
// src/translator/core/html-style.ts
|
6392
6433
|
var import_compiler35 = require("@marko/compiler");
|
6393
|
-
var
|
6434
|
+
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
6394
6435
|
var kGetterId4 = Symbol("node getter id");
|
6395
6436
|
var html_style_default = {
|
6396
6437
|
analyze(tag) {
|
6397
|
-
(0,
|
6398
|
-
(0,
|
6438
|
+
(0, import_babel_utils25.assertNoArgs)(tag);
|
6439
|
+
(0, import_babel_utils25.assertNoParams)(tag);
|
6399
6440
|
const { node } = tag;
|
6400
6441
|
if (node.var && !import_compiler35.types.isIdentifier(node.var)) {
|
6401
6442
|
throw tag.get("var").buildCodeFrameError(
|
@@ -6780,14 +6821,14 @@ function getUsedAttrs3(tag) {
|
|
6780
6821
|
|
6781
6822
|
// src/translator/core/id.ts
|
6782
6823
|
var import_compiler36 = require("@marko/compiler");
|
6783
|
-
var
|
6824
|
+
var import_babel_utils26 = require("@marko/compiler/babel-utils");
|
6784
6825
|
var id_default = {
|
6785
6826
|
analyze(tag) {
|
6786
|
-
(0,
|
6787
|
-
(0,
|
6788
|
-
(0,
|
6827
|
+
(0, import_babel_utils26.assertNoArgs)(tag);
|
6828
|
+
(0, import_babel_utils26.assertNoParams)(tag);
|
6829
|
+
(0, import_babel_utils26.assertNoAttributes)(tag);
|
6789
6830
|
assertNoBodyContent(tag);
|
6790
|
-
(0,
|
6831
|
+
(0, import_babel_utils26.assertNoAttributeTags)(tag);
|
6791
6832
|
const { node } = tag;
|
6792
6833
|
if (!node.var) {
|
6793
6834
|
throw tag.get("name").buildCodeFrameError("The `id` tag requires a tag variable.");
|
@@ -6829,7 +6870,7 @@ var id_default = {
|
|
6829
6870
|
|
6830
6871
|
// src/translator/core/if.ts
|
6831
6872
|
var import_compiler38 = require("@marko/compiler");
|
6832
|
-
var
|
6873
|
+
var import_babel_utils27 = require("@marko/compiler/babel-utils");
|
6833
6874
|
|
6834
6875
|
// src/translator/util/to-first-statement-or-block.ts
|
6835
6876
|
var import_compiler37 = require("@marko/compiler");
|
@@ -7109,9 +7150,9 @@ var ElseTag = {
|
|
7109
7150
|
]
|
7110
7151
|
};
|
7111
7152
|
function assertValidCondition(tag) {
|
7112
|
-
(0,
|
7113
|
-
(0,
|
7114
|
-
(0,
|
7153
|
+
(0, import_babel_utils27.assertNoVar)(tag);
|
7154
|
+
(0, import_babel_utils27.assertNoArgs)(tag);
|
7155
|
+
(0, import_babel_utils27.assertNoParams)(tag);
|
7115
7156
|
assertHasBody(tag);
|
7116
7157
|
assertNoSpreadAttrs(tag);
|
7117
7158
|
switch (getTagName(tag)) {
|
@@ -7202,12 +7243,12 @@ function isRoot(tag) {
|
|
7202
7243
|
}
|
7203
7244
|
|
7204
7245
|
// src/translator/core/import.ts
|
7205
|
-
var
|
7246
|
+
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
7206
7247
|
var import_default = {
|
7207
7248
|
parse(tag) {
|
7208
7249
|
const { node } = tag;
|
7209
7250
|
tag.replaceWith(
|
7210
|
-
(0,
|
7251
|
+
(0, import_babel_utils28.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
7211
7252
|
);
|
7212
7253
|
},
|
7213
7254
|
parseOptions: {
|
@@ -7226,7 +7267,7 @@ var import_default = {
|
|
7226
7267
|
|
7227
7268
|
// src/translator/core/let.ts
|
7228
7269
|
var import_compiler39 = require("@marko/compiler");
|
7229
|
-
var
|
7270
|
+
var import_babel_utils29 = require("@marko/compiler/babel-utils");
|
7230
7271
|
var let_default = {
|
7231
7272
|
analyze(tag) {
|
7232
7273
|
const { node } = tag;
|
@@ -7255,8 +7296,8 @@ var let_default = {
|
|
7255
7296
|
}
|
7256
7297
|
}
|
7257
7298
|
}
|
7258
|
-
(0,
|
7259
|
-
(0,
|
7299
|
+
(0, import_babel_utils29.assertNoArgs)(tag);
|
7300
|
+
(0, import_babel_utils29.assertNoParams)(tag);
|
7260
7301
|
assertNoBodyContent(tag);
|
7261
7302
|
assertNoSpreadAttrs(tag);
|
7262
7303
|
if (!tagVar) {
|
@@ -7265,7 +7306,7 @@ var let_default = {
|
|
7265
7306
|
if (!import_compiler39.types.isIdentifier(tagVar)) {
|
7266
7307
|
throw tag.get("var").buildCodeFrameError("The `let` tag variable cannot be destructured.");
|
7267
7308
|
}
|
7268
|
-
if (valueChangeAttr && (0,
|
7309
|
+
if (valueChangeAttr && (0, import_babel_utils29.computeNode)(valueChangeAttr.value)) {
|
7269
7310
|
throw tag.get("attributes").find((attr2) => attr2.node === valueChangeAttr).get("value").buildCodeFrameError(
|
7270
7311
|
"The `let` tag `valueChange` attribute must be a function."
|
7271
7312
|
);
|
@@ -7328,13 +7369,13 @@ var let_default = {
|
|
7328
7369
|
|
7329
7370
|
// src/translator/core/lifecycle.ts
|
7330
7371
|
var import_compiler40 = require("@marko/compiler");
|
7331
|
-
var
|
7372
|
+
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
7332
7373
|
var kRef = Symbol("lifecycle attrs reference");
|
7333
7374
|
var lifecycle_default = {
|
7334
7375
|
analyze(tag) {
|
7335
|
-
(0,
|
7336
|
-
(0,
|
7337
|
-
(0,
|
7376
|
+
(0, import_babel_utils30.assertNoArgs)(tag);
|
7377
|
+
(0, import_babel_utils30.assertNoVar)(tag);
|
7378
|
+
(0, import_babel_utils30.assertNoParams)(tag);
|
7338
7379
|
assertNoBodyContent(tag);
|
7339
7380
|
const { node } = tag;
|
7340
7381
|
const tagExtra = node.extra ??= {};
|
@@ -7408,13 +7449,13 @@ var lifecycle_default = {
|
|
7408
7449
|
|
7409
7450
|
// src/translator/core/log.ts
|
7410
7451
|
var import_compiler41 = require("@marko/compiler");
|
7411
|
-
var
|
7452
|
+
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
7412
7453
|
var log_default = {
|
7413
7454
|
analyze(tag) {
|
7414
7455
|
const [valueAttr] = tag.node.attributes;
|
7415
|
-
(0,
|
7416
|
-
(0,
|
7417
|
-
(0,
|
7456
|
+
(0, import_babel_utils31.assertNoArgs)(tag);
|
7457
|
+
(0, import_babel_utils31.assertNoVar)(tag);
|
7458
|
+
(0, import_babel_utils31.assertNoParams)(tag);
|
7418
7459
|
assertNoBodyContent(tag);
|
7419
7460
|
if (!valueAttr) {
|
7420
7461
|
throw tag.get("name").buildCodeFrameError("The `log` tag requires a value.");
|
@@ -7460,7 +7501,7 @@ var log_default = {
|
|
7460
7501
|
|
7461
7502
|
// src/translator/core/script.ts
|
7462
7503
|
var import_compiler42 = require("@marko/compiler");
|
7463
|
-
var
|
7504
|
+
var import_babel_utils32 = require("@marko/compiler/babel-utils");
|
7464
7505
|
var htmlScriptTagAlternateMsg = " For a native html `script` tag use the `html-script` core tag instead.";
|
7465
7506
|
var script_default = {
|
7466
7507
|
parse(tag) {
|
@@ -7480,7 +7521,7 @@ var script_default = {
|
|
7480
7521
|
}
|
7481
7522
|
const start = body[0]?.start;
|
7482
7523
|
const end = body[body.length - 1]?.end;
|
7483
|
-
const bodyStatements = (0,
|
7524
|
+
const bodyStatements = (0, import_babel_utils32.parseStatements)(tag.hub.file, code, start, end);
|
7484
7525
|
const valueFn = import_compiler42.types.arrowFunctionExpression(
|
7485
7526
|
[],
|
7486
7527
|
import_compiler42.types.blockStatement(bodyStatements),
|
@@ -7492,10 +7533,10 @@ var script_default = {
|
|
7492
7533
|
},
|
7493
7534
|
analyze(tag) {
|
7494
7535
|
const { node } = tag;
|
7495
|
-
(0,
|
7496
|
-
(0,
|
7536
|
+
(0, import_babel_utils32.assertNoArgs)(tag);
|
7537
|
+
(0, import_babel_utils32.assertNoParams)(tag);
|
7497
7538
|
assertNoBodyContent(tag);
|
7498
|
-
(0,
|
7539
|
+
(0, import_babel_utils32.assertNoAttributeTags)(tag);
|
7499
7540
|
if (node.var) {
|
7500
7541
|
throw tag.hub.buildError(
|
7501
7542
|
node.var,
|
@@ -7597,7 +7638,7 @@ function isAwaitExpression(node) {
|
|
7597
7638
|
|
7598
7639
|
// src/translator/core/server.ts
|
7599
7640
|
var import_compiler43 = require("@marko/compiler");
|
7600
|
-
var
|
7641
|
+
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
7601
7642
|
var server_default = {
|
7602
7643
|
parse(tag) {
|
7603
7644
|
const {
|
@@ -7607,7 +7648,7 @@ var server_default = {
|
|
7607
7648
|
const rawValue = node.rawValue;
|
7608
7649
|
const code = rawValue.replace(/^server\s*/, "").trim();
|
7609
7650
|
const start = node.name.start + (rawValue.length - code.length);
|
7610
|
-
let body = (0,
|
7651
|
+
let body = (0, import_babel_utils33.parseStatements)(file, code, start, start + code.length);
|
7611
7652
|
if (body.length === 1 && import_compiler43.types.isBlockStatement(body[0])) {
|
7612
7653
|
body = body[0].body;
|
7613
7654
|
}
|
@@ -7628,7 +7669,7 @@ var server_default = {
|
|
7628
7669
|
|
7629
7670
|
// src/translator/core/static.ts
|
7630
7671
|
var import_compiler44 = require("@marko/compiler");
|
7631
|
-
var
|
7672
|
+
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
7632
7673
|
var static_default = {
|
7633
7674
|
parse(tag) {
|
7634
7675
|
const {
|
@@ -7638,7 +7679,7 @@ var static_default = {
|
|
7638
7679
|
const rawValue = node.rawValue;
|
7639
7680
|
const code = rawValue.replace(/^static\s*/, "").trim();
|
7640
7681
|
const start = node.name.start + (rawValue.length - code.length);
|
7641
|
-
let body = (0,
|
7682
|
+
let body = (0, import_babel_utils34.parseStatements)(file, code, start, start + code.length);
|
7642
7683
|
if (body.length === 1 && import_compiler44.types.isBlockStatement(body[0])) {
|
7643
7684
|
body = body[0].body;
|
7644
7685
|
}
|
@@ -7659,16 +7700,16 @@ var static_default = {
|
|
7659
7700
|
|
7660
7701
|
// src/translator/core/style.ts
|
7661
7702
|
var import_compiler45 = require("@marko/compiler");
|
7662
|
-
var
|
7703
|
+
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
7663
7704
|
var import_magic_string = __toESM(require("magic-string"));
|
7664
|
-
var
|
7705
|
+
var import_path3 = __toESM(require("path"));
|
7665
7706
|
var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
7666
7707
|
var htmlStyleTagAlternateMsg = " For a native html `style` tag use the `html-style` core tag instead.";
|
7667
7708
|
var style_default = {
|
7668
7709
|
analyze(tag) {
|
7669
|
-
(0,
|
7670
|
-
(0,
|
7671
|
-
(0,
|
7710
|
+
(0, import_babel_utils35.assertNoArgs)(tag);
|
7711
|
+
(0, import_babel_utils35.assertNoParams)(tag);
|
7712
|
+
(0, import_babel_utils35.assertNoAttributeTags)(tag);
|
7672
7713
|
const { node } = tag;
|
7673
7714
|
const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
|
7674
7715
|
for (const attr2 of node.attributes) {
|
@@ -7707,8 +7748,8 @@ var style_default = {
|
|
7707
7748
|
}
|
7708
7749
|
const markoText = node.body.body[0];
|
7709
7750
|
const { resolveVirtualDependency } = getMarkoOpts();
|
7710
|
-
const start = (0,
|
7711
|
-
const end = (0,
|
7751
|
+
const start = (0, import_babel_utils35.getStart)(file, markoText);
|
7752
|
+
const end = (0, import_babel_utils35.getEnd)(file, markoText);
|
7712
7753
|
let code = markoText.value;
|
7713
7754
|
let map2;
|
7714
7755
|
if (resolveVirtualDependency && sourceMaps && start !== null && end !== null) {
|
@@ -7728,7 +7769,7 @@ var style_default = {
|
|
7728
7769
|
}
|
7729
7770
|
}
|
7730
7771
|
const importPath = resolveVirtualDependency?.(filename, {
|
7731
|
-
virtualPath: `./${
|
7772
|
+
virtualPath: `./${import_path3.default.basename(filename) + ext}`,
|
7732
7773
|
code,
|
7733
7774
|
map: map2
|
7734
7775
|
});
|
@@ -7752,7 +7793,7 @@ var style_default = {
|
|
7752
7793
|
import_compiler45.types.variableDeclaration("const", [
|
7753
7794
|
import_compiler45.types.variableDeclarator(
|
7754
7795
|
node.var,
|
7755
|
-
(0,
|
7796
|
+
(0, import_babel_utils35.importDefault)(file, importPath, "style")
|
7756
7797
|
)
|
7757
7798
|
])
|
7758
7799
|
);
|
@@ -7771,13 +7812,13 @@ var style_default = {
|
|
7771
7812
|
|
7772
7813
|
// src/translator/core/try.ts
|
7773
7814
|
var import_compiler46 = require("@marko/compiler");
|
7774
|
-
var
|
7815
|
+
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
7775
7816
|
var try_default = {
|
7776
7817
|
analyze(tag) {
|
7777
|
-
(0,
|
7778
|
-
(0,
|
7779
|
-
(0,
|
7780
|
-
(0,
|
7818
|
+
(0, import_babel_utils36.assertNoVar)(tag);
|
7819
|
+
(0, import_babel_utils36.assertNoArgs)(tag);
|
7820
|
+
(0, import_babel_utils36.assertNoParams)(tag);
|
7821
|
+
(0, import_babel_utils36.assertNoAttributes)(tag);
|
7781
7822
|
assertNoSpreadAttrs(tag);
|
7782
7823
|
analyzeAttributeTags(tag);
|
7783
7824
|
const { node } = tag;
|
@@ -7920,7 +7961,7 @@ var document_type_default = {
|
|
7920
7961
|
|
7921
7962
|
// src/translator/visitors/function.ts
|
7922
7963
|
var import_compiler47 = require("@marko/compiler");
|
7923
|
-
var
|
7964
|
+
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
7924
7965
|
var functionIdsBySection = /* @__PURE__ */ new WeakMap();
|
7925
7966
|
var function_default = {
|
7926
7967
|
analyze(fn) {
|
@@ -7936,7 +7977,7 @@ var function_default = {
|
|
7936
7977
|
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler47.types.toIdentifier(
|
7937
7978
|
markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
|
7938
7979
|
) : markoRoot.node.name : import_compiler47.types.isVariableDeclarator(fn.parent) && import_compiler47.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : "anonymous");
|
7939
|
-
if (isMarkoAttribute(markoRoot) && ((0,
|
7980
|
+
if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils37.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
|
7940
7981
|
return;
|
7941
7982
|
}
|
7942
7983
|
const {
|
@@ -7957,7 +7998,7 @@ var function_default = {
|
|
7957
7998
|
id = `_${index}`;
|
7958
7999
|
}
|
7959
8000
|
extra.section = section;
|
7960
|
-
extra.registerId = (0,
|
8001
|
+
extra.registerId = (0, import_babel_utils37.getTemplateId)(
|
7961
8002
|
markoOpts,
|
7962
8003
|
filename,
|
7963
8004
|
`${section.id}/${name2 + id}`
|
@@ -7975,18 +8016,18 @@ function isFunction(fn, isStatic2) {
|
|
7975
8016
|
return false;
|
7976
8017
|
}
|
7977
8018
|
}
|
7978
|
-
function isMarkoAttribute(
|
7979
|
-
return
|
8019
|
+
function isMarkoAttribute(path5) {
|
8020
|
+
return path5 ? path5.isMarkoAttribute() : false;
|
7980
8021
|
}
|
7981
8022
|
|
7982
8023
|
// src/translator/visitors/import-declaration.ts
|
7983
|
-
var
|
8024
|
+
var import_babel_utils38 = require("@marko/compiler/babel-utils");
|
7984
8025
|
var import_declaration_default = {
|
7985
8026
|
analyze(importDecl) {
|
7986
8027
|
const { node } = importDecl;
|
7987
8028
|
const { source } = node;
|
7988
8029
|
const { value } = source;
|
7989
|
-
const tagImport = (0,
|
8030
|
+
const tagImport = (0, import_babel_utils38.resolveTagImport)(importDecl, value);
|
7990
8031
|
if (tagImport) {
|
7991
8032
|
node.extra ??= {};
|
7992
8033
|
node.extra.tagImport = tagImport;
|
@@ -8269,20 +8310,20 @@ var scriptlet_default = {
|
|
8269
8310
|
|
8270
8311
|
// src/translator/visitors/tag/index.ts
|
8271
8312
|
var import_compiler53 = require("@marko/compiler");
|
8272
|
-
var
|
8313
|
+
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
8273
8314
|
|
8274
8315
|
// src/translator/visitors/tag/attribute-tag.ts
|
8275
8316
|
var import_compiler50 = require("@marko/compiler");
|
8276
|
-
var
|
8317
|
+
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
8277
8318
|
var attribute_tag_default = {
|
8278
8319
|
analyze: {
|
8279
8320
|
enter(tag) {
|
8280
|
-
(0,
|
8281
|
-
(0,
|
8321
|
+
(0, import_babel_utils39.assertNoVar)(tag);
|
8322
|
+
(0, import_babel_utils39.assertNoArgs)(tag);
|
8282
8323
|
const body = tag.get("body");
|
8283
8324
|
startSection(body);
|
8284
8325
|
trackParamsReferences(body, 3 /* param */);
|
8285
|
-
if (!(0,
|
8326
|
+
if (!(0, import_babel_utils39.findParentTag)(tag)) {
|
8286
8327
|
throw tag.get("name").buildCodeFrameError("@tags must be nested within another tag.");
|
8287
8328
|
}
|
8288
8329
|
}
|
@@ -8304,15 +8345,15 @@ var attribute_tag_default = {
|
|
8304
8345
|
|
8305
8346
|
// src/translator/visitors/tag/custom-tag.ts
|
8306
8347
|
var import_compiler51 = require("@marko/compiler");
|
8307
|
-
var
|
8308
|
-
var
|
8348
|
+
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
8349
|
+
var import_path4 = __toESM(require("path"));
|
8309
8350
|
var kChildScopeBinding = Symbol("custom tag child scope");
|
8310
8351
|
var custom_tag_default = {
|
8311
8352
|
analyze: {
|
8312
8353
|
enter(tag) {
|
8313
|
-
(0,
|
8354
|
+
(0, import_babel_utils40.assertAttributesOrSingleArg)(tag);
|
8314
8355
|
analyzeAttributeTags(tag);
|
8315
|
-
const templateFile = (0,
|
8356
|
+
const templateFile = (0, import_babel_utils40.getTagTemplate)(tag);
|
8316
8357
|
if (!templateFile) {
|
8317
8358
|
const tagName = getTagName(tag);
|
8318
8359
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
@@ -8335,7 +8376,7 @@ var custom_tag_default = {
|
|
8335
8376
|
void 0,
|
8336
8377
|
tagExtra
|
8337
8378
|
);
|
8338
|
-
const childFile = (0,
|
8379
|
+
const childFile = (0, import_babel_utils40.loadFileForTag)(tag);
|
8339
8380
|
if (childFile.opts.filename === tag.hub.file.opts.filename) {
|
8340
8381
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
8341
8382
|
} else {
|
@@ -8373,7 +8414,7 @@ function translateHTML(tag) {
|
|
8373
8414
|
writeHTMLResumeStatements(tagBody);
|
8374
8415
|
if (import_compiler51.types.isStringLiteral(node.name)) {
|
8375
8416
|
const relativePath = getTagRelativePath(tag);
|
8376
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? htmlRendererIdentifier : (0,
|
8417
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? htmlRendererIdentifier : (0, import_babel_utils40.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
8377
8418
|
} else {
|
8378
8419
|
tagIdentifier = node.name;
|
8379
8420
|
}
|
@@ -8390,7 +8431,7 @@ function translateHTML(tag) {
|
|
8390
8431
|
getScopeAccessorLiteral(childScopeBinding),
|
8391
8432
|
callRuntime("writeExistingScope", peekScopeId)
|
8392
8433
|
);
|
8393
|
-
const inputExport = (0,
|
8434
|
+
const inputExport = (0, import_babel_utils40.loadFileForTag)(tag)?.ast.program.extra?.domExports?.params?.props?.[0];
|
8394
8435
|
const { properties, statements } = inputExport ? translateAttrs(tag, inputExport.props) : {
|
8395
8436
|
properties: [],
|
8396
8437
|
statements: []
|
@@ -8467,7 +8508,7 @@ function translateDOM(tag) {
|
|
8467
8508
|
const { file } = tag.hub;
|
8468
8509
|
const tagName = import_compiler51.types.isIdentifier(node.name) ? node.name.name : import_compiler51.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
8469
8510
|
const relativePath = getTagRelativePath(tag);
|
8470
|
-
const childFile = (0,
|
8511
|
+
const childFile = (0, import_babel_utils40.loadFileForTag)(tag);
|
8471
8512
|
const childExports = childFile.ast.program.extra.domExports;
|
8472
8513
|
const tagIdentifier = importOrSelfReferenceName(
|
8473
8514
|
file,
|
@@ -8484,10 +8525,10 @@ function translateDOM(tag) {
|
|
8484
8525
|
childScopeBinding
|
8485
8526
|
});
|
8486
8527
|
}
|
8487
|
-
write2`${(0,
|
8528
|
+
write2`${(0, import_babel_utils40.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
8488
8529
|
injectWalks(
|
8489
8530
|
tag,
|
8490
|
-
(0,
|
8531
|
+
(0, import_babel_utils40.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
8491
8532
|
);
|
8492
8533
|
if (node.var) {
|
8493
8534
|
const source = initValue(
|
@@ -8534,8 +8575,8 @@ function getTagRelativePath(tag) {
|
|
8534
8575
|
} = tag;
|
8535
8576
|
let relativePath;
|
8536
8577
|
if (import_compiler51.types.isStringLiteral(node.name)) {
|
8537
|
-
const template = (0,
|
8538
|
-
relativePath = template && (0,
|
8578
|
+
const template = (0, import_babel_utils40.getTagTemplate)(tag);
|
8579
|
+
relativePath = template && (0, import_babel_utils40.resolveRelativePath)(file, template);
|
8539
8580
|
} else if (node.extra?.tagNameImported) {
|
8540
8581
|
relativePath = node.extra.tagNameImported;
|
8541
8582
|
}
|
@@ -8581,7 +8622,7 @@ function analyzeAttrs(section, tag, templateExport) {
|
|
8581
8622
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
8582
8623
|
for (const child of attrTags2) {
|
8583
8624
|
if (child.isMarkoTag()) {
|
8584
|
-
if ((0,
|
8625
|
+
if ((0, import_babel_utils40.isAttributeTag)(child)) {
|
8585
8626
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
8586
8627
|
const childAttrExports = templateExport.props[attrTagMeta.name];
|
8587
8628
|
if (childAttrExports) {
|
@@ -8678,7 +8719,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8678
8719
|
);
|
8679
8720
|
}
|
8680
8721
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
8681
|
-
if ((0,
|
8722
|
+
if ((0, import_babel_utils40.isAttributeTag)(tag)) {
|
8682
8723
|
translatedProps = callRuntime("attrTag", translatedProps);
|
8683
8724
|
}
|
8684
8725
|
addValue(
|
@@ -8724,7 +8765,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8724
8765
|
for (let i = 0; i < attrTags2.length; i++) {
|
8725
8766
|
const child = attrTags2[i];
|
8726
8767
|
if (child.isMarkoTag()) {
|
8727
|
-
if ((0,
|
8768
|
+
if ((0, import_babel_utils40.isAttributeTag)(child)) {
|
8728
8769
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
8729
8770
|
const childAttrExport = templateExport.props[attrTagMeta.name];
|
8730
8771
|
if (childAttrExport) {
|
@@ -8786,7 +8827,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8786
8827
|
if (bodySection && !seen.has("content")) {
|
8787
8828
|
seen.add("content");
|
8788
8829
|
if (templateExport.props.content) {
|
8789
|
-
const contentExportIdentifier = (0,
|
8830
|
+
const contentExportIdentifier = (0, import_babel_utils40.importNamed)(
|
8790
8831
|
tag.hub.file,
|
8791
8832
|
info.relativePath,
|
8792
8833
|
templateExport.props.content.id,
|
@@ -8890,11 +8931,11 @@ function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
8890
8931
|
if (isCircularRequest(file, request)) {
|
8891
8932
|
return import_compiler51.types.identifier(name2);
|
8892
8933
|
}
|
8893
|
-
return (0,
|
8934
|
+
return (0, import_babel_utils40.importNamed)(file, request, name2, nameHint);
|
8894
8935
|
}
|
8895
8936
|
function isCircularRequest(file, request) {
|
8896
8937
|
const { filename } = file.opts;
|
8897
|
-
return request === filename || request[0] === "." &&
|
8938
|
+
return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
|
8898
8939
|
}
|
8899
8940
|
function callStatement(id, ...args) {
|
8900
8941
|
return import_compiler51.types.expressionStatement(callExpression(id, ...args));
|
@@ -8917,12 +8958,12 @@ function always() {
|
|
8917
8958
|
|
8918
8959
|
// src/translator/visitors/tag/dynamic-tag.ts
|
8919
8960
|
var import_compiler52 = require("@marko/compiler");
|
8920
|
-
var
|
8961
|
+
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
8921
8962
|
var kDOMBinding = Symbol("dynamic tag dom binding");
|
8922
8963
|
var dynamic_tag_default = {
|
8923
8964
|
analyze: {
|
8924
8965
|
enter(tag) {
|
8925
|
-
(0,
|
8966
|
+
(0, import_babel_utils41.assertAttributesOrArgs)(tag);
|
8926
8967
|
analyzeAttributeTags(tag);
|
8927
8968
|
const section = getOrCreateSection(tag);
|
8928
8969
|
const tagExtra = tag.node.extra ??= {};
|
@@ -8957,7 +8998,7 @@ var dynamic_tag_default = {
|
|
8957
8998
|
const isClassAPI = extra.featureType === "class";
|
8958
8999
|
let tagExpression = node.name;
|
8959
9000
|
if (import_compiler52.types.isStringLiteral(tagExpression)) {
|
8960
|
-
tagExpression = (0,
|
9001
|
+
tagExpression = (0, import_babel_utils41.importDefault)(
|
8961
9002
|
tag.hub.file,
|
8962
9003
|
getTagRelativePath(tag),
|
8963
9004
|
tagExpression.value
|
@@ -8969,10 +9010,10 @@ var dynamic_tag_default = {
|
|
8969
9010
|
"body",
|
8970
9011
|
import_compiler52.types.expressionStatement(
|
8971
9012
|
import_compiler52.types.callExpression(
|
8972
|
-
(0,
|
9013
|
+
(0, import_babel_utils41.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
8973
9014
|
[
|
8974
9015
|
import_compiler52.types.identifier(tagExpression.name),
|
8975
|
-
import_compiler52.types.stringLiteral((0,
|
9016
|
+
import_compiler52.types.stringLiteral((0, import_babel_utils41.loadFileForTag)(tag).metadata.marko.id)
|
8976
9017
|
]
|
8977
9018
|
)
|
8978
9019
|
)
|
@@ -8983,7 +9024,7 @@ var dynamic_tag_default = {
|
|
8983
9024
|
import_compiler52.types.expressionStatement(
|
8984
9025
|
callRuntime(
|
8985
9026
|
"register",
|
8986
|
-
import_compiler52.types.stringLiteral((0,
|
9027
|
+
import_compiler52.types.stringLiteral((0, import_babel_utils41.loadFileForTag)(tag).metadata.marko.id),
|
8987
9028
|
import_compiler52.types.identifier(tagExpression.name)
|
8988
9029
|
)
|
8989
9030
|
)
|
@@ -9219,7 +9260,7 @@ var tag_default = {
|
|
9219
9260
|
},
|
9220
9261
|
analyze: {
|
9221
9262
|
enter(tag) {
|
9222
|
-
const tagDef = (0,
|
9263
|
+
const tagDef = (0, import_babel_utils42.getTagDef)(tag);
|
9223
9264
|
const type = analyzeTagNameType(tag);
|
9224
9265
|
const hook = tagDef?.analyzer?.hook;
|
9225
9266
|
if (hook) {
|
@@ -9243,7 +9284,7 @@ var tag_default = {
|
|
9243
9284
|
}
|
9244
9285
|
},
|
9245
9286
|
exit(tag) {
|
9246
|
-
const hook = (0,
|
9287
|
+
const hook = (0, import_babel_utils42.getTagDef)(tag)?.analyzer?.hook;
|
9247
9288
|
if (hook) {
|
9248
9289
|
exit(hook, tag);
|
9249
9290
|
return;
|
@@ -9252,7 +9293,7 @@ var tag_default = {
|
|
9252
9293
|
},
|
9253
9294
|
translate: {
|
9254
9295
|
enter(tag) {
|
9255
|
-
const tagDef = (0,
|
9296
|
+
const tagDef = (0, import_babel_utils42.getTagDef)(tag);
|
9256
9297
|
const extra = tag.node.extra;
|
9257
9298
|
if (tagDef?.translator) {
|
9258
9299
|
if (tagDef.translator.path) {
|
@@ -9269,7 +9310,7 @@ var tag_default = {
|
|
9269
9310
|
);
|
9270
9311
|
}
|
9271
9312
|
if (attr2.node.modifier) {
|
9272
|
-
if ((0,
|
9313
|
+
if ((0, import_babel_utils42.isNativeTag)(attr2.parentPath)) {
|
9273
9314
|
attr2.node.name += `:${attr2.node.modifier}`;
|
9274
9315
|
} else {
|
9275
9316
|
throw attr2.buildCodeFrameError(
|
@@ -9305,7 +9346,7 @@ var tag_default = {
|
|
9305
9346
|
}
|
9306
9347
|
},
|
9307
9348
|
exit(tag) {
|
9308
|
-
const translator = (0,
|
9349
|
+
const translator = (0, import_babel_utils42.getTagDef)(tag)?.translator;
|
9309
9350
|
if (translator) {
|
9310
9351
|
exit(translator.hook, tag);
|
9311
9352
|
return;
|