marko 6.3.48 → 6.3.50
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/common/constants/resume-symbol.d.ts +1 -0
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-CA_HiiES.js → dom-BAGeiafn.js} +25 -17
- package/dist/debug/{dom-DBMLPLeE.mjs → dom-C55iHvof.mjs} +25 -17
- package/dist/debug/dom.js +1 -1
- package/dist/debug/dom.mjs +1 -1
- package/dist/debug/html.js +76 -37
- package/dist/debug/html.mjs +76 -37
- package/dist/dom/catch.feat.js +1 -1
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/placeholder.feat.js +1 -1
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/{dom-BfydlrCq.js → dom-BNmfm4st.js} +15 -15
- package/dist/{dom-UwNQ-AXt.mjs → dom-BsAS26Ze.mjs} +15 -15
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/html/inlined-runtimes.d.ts +2 -2
- package/dist/html/inlined-runtimes.debug.d.ts +2 -2
- package/dist/html/writer.d.ts +3 -1
- package/dist/html.js +46 -36
- package/dist/html.mjs +46 -36
- package/dist/translator/index.js +195 -161
- package/dist/translator/util/asset-imports.d.ts +1 -1
- package/dist/translator/util/body-to-text-literal.d.ts +1 -1
- package/dist/translator/util/get-compile-stage.d.ts +2 -0
- package/dist/translator/util/optional.d.ts +1 -0
- package/dist/translator/util/references.d.ts +8 -3
- package/dist/translator/util/sections.d.ts +24 -6
- package/dist/translator/util/serialize-reasons.d.ts +6 -2
- package/dist/translator/visitors/program/pre-analyze.d.ts +6 -0
- package/package.json +4 -4
package/dist/translator/index.js
CHANGED
|
@@ -378,14 +378,18 @@ function patchIteratorNext(proto) {
|
|
|
378
378
|
}
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/translator/util/constants/compile-stage.ts
|
|
381
|
+
const analyze$1 = "analyze";
|
|
381
382
|
const translate$1 = "translate";
|
|
382
383
|
//#endregion
|
|
383
384
|
//#region src/translator/util/get-compile-stage.ts
|
|
384
385
|
function isTranslate() {
|
|
385
386
|
return getCompileStage() === translate$1;
|
|
386
387
|
}
|
|
387
|
-
function
|
|
388
|
-
return (
|
|
388
|
+
function isAnalyzing(file) {
|
|
389
|
+
return getCompileStage(file) === analyze$1;
|
|
390
|
+
}
|
|
391
|
+
function getCompileStage(file = (0, _marko_compiler_babel_utils.getFile)()) {
|
|
392
|
+
return file.___compileStage;
|
|
389
393
|
}
|
|
390
394
|
//#endregion
|
|
391
395
|
//#region src/translator/util/traverse.ts
|
|
@@ -515,17 +519,6 @@ function getInitialCounts(file) {
|
|
|
515
519
|
return counts;
|
|
516
520
|
}
|
|
517
521
|
//#endregion
|
|
518
|
-
//#region src/translator/util/get-parent-tag.ts
|
|
519
|
-
function getParentTag(tag) {
|
|
520
|
-
const parent = tag.parent.type === "MarkoTagBody" ? tag.parentPath.parentPath : tag.parentPath;
|
|
521
|
-
if (parent.type === "MarkoTag") return parent;
|
|
522
|
-
}
|
|
523
|
-
function getAttributeTagParent(tag) {
|
|
524
|
-
let cur = tag;
|
|
525
|
-
while ((0, _marko_compiler_babel_utils.isAttributeTag)(cur) || (0, _marko_compiler_babel_utils.isTransparentTag)(cur)) cur = getParentTag(cur);
|
|
526
|
-
return cur;
|
|
527
|
-
}
|
|
528
|
-
//#endregion
|
|
529
522
|
//#region src/translator/util/get-root.ts
|
|
530
523
|
function getMarkoRoot(path) {
|
|
531
524
|
let curPath = path;
|
|
@@ -1001,12 +994,7 @@ function getAccessorProp() {
|
|
|
1001
994
|
}
|
|
1002
995
|
//#endregion
|
|
1003
996
|
//#region src/translator/util/serialize-reasons.ts
|
|
1004
|
-
const
|
|
1005
|
-
const propExprsBySection = /* @__PURE__ */ new WeakMap();
|
|
1006
|
-
const scopeProvenanceBySection = /* @__PURE__ */ new WeakMap();
|
|
1007
|
-
const propProvenanceBySection = /* @__PURE__ */ new WeakMap();
|
|
1008
|
-
const serializePropsByBinding = /* @__PURE__ */ new WeakMap();
|
|
1009
|
-
const serializePropByModifier = {};
|
|
997
|
+
const sourcesUtil = new Sorted(compareSources);
|
|
1010
998
|
function isSameReason(a, b) {
|
|
1011
999
|
return a === b || (a && b ? a !== true && b !== true && compareSources(a, b) === 0 : false);
|
|
1012
1000
|
}
|
|
@@ -1040,20 +1028,15 @@ function addSerializeExpr(section, expr, prop, prefix) {
|
|
|
1040
1028
|
if (expr === true) {
|
|
1041
1029
|
if (section.serializeReasons.get(key) !== true) forcePropSerialize(section, key);
|
|
1042
1030
|
} else {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
if (curExprs) curExpr = curExprs.get(key);
|
|
1046
|
-
else {
|
|
1047
|
-
curExprs = /* @__PURE__ */ new Map();
|
|
1048
|
-
propExprsBySection.set(section, curExprs);
|
|
1049
|
-
}
|
|
1031
|
+
const curExprs = section.propSerializeExprs ??= /* @__PURE__ */ new Map();
|
|
1032
|
+
const curExpr = curExprs.get(key);
|
|
1050
1033
|
curExprs.set(key, curExpr ? concat(curExpr, expr) : expr);
|
|
1051
1034
|
}
|
|
1052
1035
|
} else if (expr === true) {
|
|
1053
1036
|
if (section.serializeReason !== true) forceSerialize(section);
|
|
1054
1037
|
} else {
|
|
1055
|
-
const curExpr =
|
|
1056
|
-
|
|
1038
|
+
const curExpr = section.serializeExprs;
|
|
1039
|
+
section.serializeExprs = curExpr ? concat(curExpr, expr) : expr;
|
|
1057
1040
|
}
|
|
1058
1041
|
}
|
|
1059
1042
|
function addOwnerSerializeReason(from, to, reason) {
|
|
@@ -1079,7 +1062,7 @@ function getSerializeReason(section, prop, prefix) {
|
|
|
1079
1062
|
else return section.serializeReason;
|
|
1080
1063
|
}
|
|
1081
1064
|
function getSerializeSourcesForExpr(expr) {
|
|
1082
|
-
|
|
1065
|
+
return isReferencedExtra(expr) ? getSerializeSourcesForRef(expr.referencedBindings) : void 0;
|
|
1083
1066
|
}
|
|
1084
1067
|
function getSerializeSourcesForExprs(exprs) {
|
|
1085
1068
|
if (exprs) if (exprs === true) return exprs;
|
|
@@ -1134,9 +1117,9 @@ function mergeSerializeReasons(a, b) {
|
|
|
1134
1117
|
return mergeSources(a, b);
|
|
1135
1118
|
}
|
|
1136
1119
|
function applySerializeExprs(section) {
|
|
1137
|
-
const propExprs =
|
|
1120
|
+
const propExprs = section.propSerializeExprs;
|
|
1138
1121
|
if (propExprs) {
|
|
1139
|
-
|
|
1122
|
+
section.propSerializeExprs = void 0;
|
|
1140
1123
|
for (const [key, exprs] of propExprs) {
|
|
1141
1124
|
addProvenance(section, getProvenanceForExprs(exprs), key);
|
|
1142
1125
|
const exprReason = getSerializeSourcesForExprs(exprs);
|
|
@@ -1147,9 +1130,9 @@ function applySerializeExprs(section) {
|
|
|
1147
1130
|
}
|
|
1148
1131
|
}
|
|
1149
1132
|
}
|
|
1150
|
-
const scopeExprs =
|
|
1133
|
+
const scopeExprs = section.serializeExprs;
|
|
1151
1134
|
if (scopeExprs) {
|
|
1152
|
-
|
|
1135
|
+
section.serializeExprs = void 0;
|
|
1153
1136
|
addProvenance(section, getProvenanceForExprs(scopeExprs));
|
|
1154
1137
|
const exprReason = getSerializeSourcesForExprs(scopeExprs);
|
|
1155
1138
|
if (exprReason) {
|
|
@@ -1160,6 +1143,11 @@ function applySerializeExprs(section) {
|
|
|
1160
1143
|
}
|
|
1161
1144
|
}
|
|
1162
1145
|
function finalizeSerializeReason(section) {
|
|
1146
|
+
some(section.bindings, (binding) => {
|
|
1147
|
+
const reason = binding.type === 0 && getSerializeReason(section, binding);
|
|
1148
|
+
if (reason) section.domSerializeReasons = reason === true ? true : sourcesUtil.add(section.domSerializeReasons, reason);
|
|
1149
|
+
return reason === true;
|
|
1150
|
+
});
|
|
1163
1151
|
const curReason = section.serializeReason;
|
|
1164
1152
|
let newReason = curReason;
|
|
1165
1153
|
if (newReason !== true) {
|
|
@@ -1172,16 +1160,15 @@ function finalizeSerializeReason(section) {
|
|
|
1172
1160
|
}
|
|
1173
1161
|
if (newReason && curReason !== newReason) setSerializeReason(section, newReason);
|
|
1174
1162
|
}
|
|
1175
|
-
const propProvenance =
|
|
1163
|
+
const propProvenance = section.propSerializeProvenance;
|
|
1176
1164
|
if (propProvenance) for (const provenance of propProvenance.values()) addProvenance(section, provenance);
|
|
1177
1165
|
}
|
|
1178
1166
|
function addProvenance(section, sources, key) {
|
|
1179
1167
|
if (!sources) return;
|
|
1180
1168
|
if (key) {
|
|
1181
|
-
|
|
1182
|
-
if (!provenance) propProvenanceBySection.set(section, provenance = /* @__PURE__ */ new Map());
|
|
1169
|
+
const provenance = section.propSerializeProvenance ??= /* @__PURE__ */ new Map();
|
|
1183
1170
|
provenance.set(key, mergeSources(provenance.get(key), sources));
|
|
1184
|
-
} else
|
|
1171
|
+
} else section.serializeProvenance = mergeSources(section.serializeProvenance, sources);
|
|
1185
1172
|
}
|
|
1186
1173
|
function getProvenanceForExprs(exprs) {
|
|
1187
1174
|
let sources;
|
|
@@ -1195,16 +1182,16 @@ function getProvenanceForExprs(exprs) {
|
|
|
1195
1182
|
}
|
|
1196
1183
|
function getPropKey(section, prop, prefix) {
|
|
1197
1184
|
if (isStrOrSym(prop)) {
|
|
1198
|
-
const keys =
|
|
1199
|
-
let key = keys.get(
|
|
1200
|
-
if (!key) keys.set(
|
|
1185
|
+
const keys = section.serializePropKeys ??= /* @__PURE__ */ new Map();
|
|
1186
|
+
let key = keys.get(prop);
|
|
1187
|
+
if (!key) keys.set(prop, key = Symbol(typeof prop === "symbol" ? `Symbol(${prop.description})` : prop));
|
|
1201
1188
|
if (prefix) throw new Error("Cannot have a scope property reason with a prefix.");
|
|
1202
1189
|
return key;
|
|
1203
1190
|
} else {
|
|
1204
|
-
const keys = prefix ? serializePropByModifier[prefix] ||= /* @__PURE__ */ new WeakMap() : serializePropsByBinding;
|
|
1205
1191
|
const binding = getCanonicalBinding(prop);
|
|
1206
|
-
|
|
1207
|
-
|
|
1192
|
+
const keys = binding.serializePropKeys ??= /* @__PURE__ */ new Map();
|
|
1193
|
+
let key = keys.get(prefix);
|
|
1194
|
+
if (!key) keys.set(prefix, key = Symbol((prefix ? typeof prefix === "symbol" ? `Symbol(${prefix.description})` : prefix : "") + binding.name));
|
|
1208
1195
|
return key;
|
|
1209
1196
|
}
|
|
1210
1197
|
}
|
|
@@ -1281,6 +1268,9 @@ function analyzeTagNameType(tag, allowDynamic) {
|
|
|
1281
1268
|
extra.tagNameDynamic = true;
|
|
1282
1269
|
const tagName = name.node.value;
|
|
1283
1270
|
extra.tagNameUnresolved = !(TAG_NAME_IDENTIFIER_REG$1.test(tagName) && tag.scope.hasBinding(tagName));
|
|
1271
|
+
} else if (childFile !== (0, _marko_compiler_babel_utils.getFile)() && isAnalyzing(childFile)) {
|
|
1272
|
+
extra.tagNameType = 2;
|
|
1273
|
+
extra.tagNameDynamic = true;
|
|
1284
1274
|
}
|
|
1285
1275
|
}
|
|
1286
1276
|
}
|
|
@@ -1368,7 +1358,7 @@ function startSection(path) {
|
|
|
1368
1358
|
const parentTag = path.parentPath?.isMarkoTag() ? path.parentPath : void 0;
|
|
1369
1359
|
const parentSection = path.parentPath ? getOrCreateSection(path.parentPath) : void 0;
|
|
1370
1360
|
const sectionName = parentTag ? generateUid((isCoreTagName(parentTag, "define") && _marko_compiler.types.isIdentifier(parentTag.node.var) ? parentTag.node.var.name : parentTag.get("name").toString()) + "_content") : "";
|
|
1371
|
-
const programExtra =
|
|
1361
|
+
const programExtra = (0, _marko_compiler_babel_utils.getProgram)().node.extra ??= {};
|
|
1372
1362
|
const sections = programExtra.sections ??= [];
|
|
1373
1363
|
section = extra.section = {
|
|
1374
1364
|
id: sections.length,
|
|
@@ -1388,12 +1378,18 @@ function startSection(path) {
|
|
|
1388
1378
|
isHoistThrough: void 0,
|
|
1389
1379
|
serializeReason: void 0,
|
|
1390
1380
|
serializeReasons: /* @__PURE__ */ new Map(),
|
|
1381
|
+
domSerializeReasons: void 0,
|
|
1382
|
+
serializeExprs: void 0,
|
|
1383
|
+
propSerializeExprs: void 0,
|
|
1384
|
+
serializeProvenance: void 0,
|
|
1385
|
+
propSerializeProvenance: void 0,
|
|
1386
|
+
serializePropKeys: void 0,
|
|
1391
1387
|
paramReasonGroups: void 0,
|
|
1392
1388
|
returnValueExpr: void 0,
|
|
1393
1389
|
returnSerializeReason: void 0,
|
|
1394
1390
|
content: getContentInfo(path),
|
|
1395
1391
|
upstreamExpression: void 0,
|
|
1396
|
-
|
|
1392
|
+
downstream: void 0,
|
|
1397
1393
|
hasAbortSignal: false,
|
|
1398
1394
|
abortSignalExprs: 0,
|
|
1399
1395
|
readsOwner: false,
|
|
@@ -1502,14 +1498,14 @@ function getNodeContentType(path, extraMember, contentInfo) {
|
|
|
1502
1498
|
}
|
|
1503
1499
|
function getSectionRegisterReasons(section) {
|
|
1504
1500
|
if (section.isBranch) return false;
|
|
1505
|
-
const {
|
|
1506
|
-
if (
|
|
1507
|
-
let downstreamReasons = getAllSerializeReasonsForBinding(
|
|
1508
|
-
if (downstreamReasons && downstreamReasons !== true) downstreamReasons = mapCrossProgramReason(section.program, downstreamReasons,
|
|
1501
|
+
const { downstream } = section;
|
|
1502
|
+
if (downstream?.binding) {
|
|
1503
|
+
let downstreamReasons = getAllSerializeReasonsForBinding(downstream.binding, downstream.properties);
|
|
1504
|
+
if (downstreamReasons && downstreamReasons !== true) downstreamReasons = mapCrossProgramReason(section.program, downstreamReasons, downstream.exprs);
|
|
1509
1505
|
if (!downstreamReasons) return false;
|
|
1510
1506
|
if (isReasonDynamic(downstreamReasons) && !section.serializeReason && !section.serializeReasons.size && !section.parent?.serializeReason && !section.parent?.serializeReasons.size) return false;
|
|
1511
1507
|
return downstreamReasons;
|
|
1512
|
-
} else if (
|
|
1508
|
+
} else if (downstream) return false;
|
|
1513
1509
|
return true;
|
|
1514
1510
|
}
|
|
1515
1511
|
function isImmediateOwner(section, binding) {
|
|
@@ -1699,7 +1695,7 @@ function resolveRegisteredExport(file, exportName, seen = /* @__PURE__ */ new Se
|
|
|
1699
1695
|
}
|
|
1700
1696
|
function resolveSerializeReason(exprExtras) {
|
|
1701
1697
|
let reason;
|
|
1702
|
-
for (const exprExtra of exprExtras) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(getCanonicalExtra(exprExtra)));
|
|
1698
|
+
for (const exprExtra of exprExtras) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(getCanonicalExtra(exprExtra), true));
|
|
1703
1699
|
return reason;
|
|
1704
1700
|
}
|
|
1705
1701
|
function registerImportedFn({ node, ...importedFn }) {
|
|
@@ -1782,14 +1778,7 @@ function shouldAlwaysRegister(markoRoot) {
|
|
|
1782
1778
|
if (!tag) return false;
|
|
1783
1779
|
if (isCoreTagName(tag, "let")) return true;
|
|
1784
1780
|
if (isCoreTagName(tag, "return")) return true;
|
|
1785
|
-
|
|
1786
|
-
case 2:
|
|
1787
|
-
case 0: return true;
|
|
1788
|
-
case 3:
|
|
1789
|
-
if (analyzeTagNameType(getAttributeTagParent(tag)) === 2) return true;
|
|
1790
|
-
break;
|
|
1791
|
-
}
|
|
1792
|
-
return false;
|
|
1781
|
+
return analyzeTagNameType(tag) === 0;
|
|
1793
1782
|
}
|
|
1794
1783
|
function hasSpreadAttributeAfter(attr) {
|
|
1795
1784
|
const attrs = attr.parent.attributes;
|
|
@@ -1838,8 +1827,8 @@ function hasAnalyzeErrors() {
|
|
|
1838
1827
|
}
|
|
1839
1828
|
//#endregion
|
|
1840
1829
|
//#region src/translator/util/asset-imports.ts
|
|
1841
|
-
function addAssetImport(
|
|
1842
|
-
(
|
|
1830
|
+
function addAssetImport(request) {
|
|
1831
|
+
((0, _marko_compiler_babel_utils.getFile)().metadata.marko.assetImports ??= /* @__PURE__ */ new Set()).add(request);
|
|
1843
1832
|
}
|
|
1844
1833
|
function isClientAssetImport(file, request) {
|
|
1845
1834
|
const { hydrateIncludeImports } = file.markoOpts;
|
|
@@ -1848,7 +1837,7 @@ function isClientAssetImport(file, request) {
|
|
|
1848
1837
|
//#endregion
|
|
1849
1838
|
//#region src/translator/util/binding-has-prop.ts
|
|
1850
1839
|
function isSectionRendererElided(section) {
|
|
1851
|
-
return !!section.
|
|
1840
|
+
return !!section.downstream?.binding && !bindingHasProperty(section.downstream.binding, section.downstream.properties);
|
|
1852
1841
|
}
|
|
1853
1842
|
function bindingHasProperty(binding, properties) {
|
|
1854
1843
|
if (binding.pruned) return false;
|
|
@@ -2252,7 +2241,7 @@ function sectionHasSetupStatements(section) {
|
|
|
2252
2241
|
* reserved a register id without registering it.
|
|
2253
2242
|
*/
|
|
2254
2243
|
function writeModuleRegistrations(program) {
|
|
2255
|
-
const
|
|
2244
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
2256
2245
|
const statements = [];
|
|
2257
2246
|
const seen = /* @__PURE__ */ new Set();
|
|
2258
2247
|
for (const child of program.node.body) {
|
|
@@ -2307,6 +2296,17 @@ function getKnownAttrValues(tag) {
|
|
|
2307
2296
|
return attrs;
|
|
2308
2297
|
}
|
|
2309
2298
|
//#endregion
|
|
2299
|
+
//#region src/translator/util/get-parent-tag.ts
|
|
2300
|
+
function getParentTag(tag) {
|
|
2301
|
+
const parent = tag.parent.type === "MarkoTagBody" ? tag.parentPath.parentPath : tag.parentPath;
|
|
2302
|
+
if (parent.type === "MarkoTag") return parent;
|
|
2303
|
+
}
|
|
2304
|
+
function getAttributeTagParent(tag) {
|
|
2305
|
+
let cur = tag;
|
|
2306
|
+
while ((0, _marko_compiler_babel_utils.isAttributeTag)(cur) || (0, _marko_compiler_babel_utils.isTransparentTag)(cur)) cur = getParentTag(cur);
|
|
2307
|
+
return cur;
|
|
2308
|
+
}
|
|
2309
|
+
//#endregion
|
|
2310
2310
|
//#region src/translator/util/plugin-hooks.ts
|
|
2311
2311
|
function enter$1(modulePlugin, path) {
|
|
2312
2312
|
if (!modulePlugin) return false;
|
|
@@ -2420,7 +2420,6 @@ function withLeadingComment(node, value) {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
//#endregion
|
|
2422
2422
|
//#region src/translator/util/serialize-guard.ts
|
|
2423
|
-
const sourcesUtil = new Sorted(compareSources);
|
|
2424
2423
|
const [getSectionReasonState] = createSectionState("serializeReasonState", (section) => ({
|
|
2425
2424
|
if: createTypeState(),
|
|
2426
2425
|
guard: createTypeState(),
|
|
@@ -2437,8 +2436,7 @@ function getSerializeGuard(section, reason, optional) {
|
|
|
2437
2436
|
return getOrHoist(reason, true);
|
|
2438
2437
|
}
|
|
2439
2438
|
function getSerializeGuardForAny(section, reasons, optional) {
|
|
2440
|
-
if (!reasons
|
|
2441
|
-
if (reasons.length === 1) return getSerializeGuard(section, reasons[0], optional);
|
|
2439
|
+
if (!Array.isArray(reasons)) return getSerializeGuard(section, reasons, optional);
|
|
2442
2440
|
let expr;
|
|
2443
2441
|
for (const reason of reasons) {
|
|
2444
2442
|
if (!isReasonDynamic(reason)) return optional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason.state));
|
|
@@ -3271,6 +3269,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3271
3269
|
const body = path.node.body;
|
|
3272
3270
|
const allSignals = Array.from(getSignals(section).values());
|
|
3273
3271
|
const scopeIdIdentifier = getScopeIdIdentifier(section);
|
|
3272
|
+
const markerSerializeArg = getSerializeGuardForAny(section, section.domSerializeReasons, true);
|
|
3274
3273
|
const sectionSerializeReason = nonAnalyzedForceSerializedSection.has(section) ? true : section.serializeReason;
|
|
3275
3274
|
forEach(section.referencedClosures, (closure) => {
|
|
3276
3275
|
if (closure.sources) {
|
|
@@ -3286,7 +3285,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3286
3285
|
if (closureIndex) setBindingSerializedValue(section, closure, _marko_compiler.types.numericLiteral(closureIndex), getAccessorPrefix().ClosureSignalIndex);
|
|
3287
3286
|
if (underTryPlaceholder(section)) {
|
|
3288
3287
|
const reason = getSerializeReason(section);
|
|
3289
|
-
if (reason) getHTMLSectionStatements(section).push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, reason, callRuntime("_script", getScopeIdIdentifier(section), _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending"))))));
|
|
3288
|
+
if (reason) getHTMLSectionStatements(section).push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, reason, callRuntime("_script", getScopeIdIdentifier(section), _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending")), markerSerializeArg))));
|
|
3290
3289
|
} else {
|
|
3291
3290
|
const closureScopesReason = getSerializeReason(closure.section, closure, getAccessorPrefix().ClosureScopes);
|
|
3292
3291
|
const subscribeArg = isReasonDynamic(closureScopesReason) && !isSameReason(closureScopesReason, sectionSerializeReason) ? getExprIfSerialized(closure.section, closureScopesReason, identifier) : identifier;
|
|
@@ -3297,7 +3296,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3297
3296
|
});
|
|
3298
3297
|
for (let i = allSignals.length; i--;) if (allSignals[i].hasHTMLEffect) {
|
|
3299
3298
|
const signalRefs = allSignals[i].referencedBindings;
|
|
3300
|
-
body.push(_marko_compiler.types.expressionStatement(callRuntime("_script", scopeIdIdentifier, _marko_compiler.types.stringLiteral(getResumeRegisterId(section, signalRefs)))));
|
|
3299
|
+
body.push(_marko_compiler.types.expressionStatement(callRuntime("_script", scopeIdIdentifier, _marko_compiler.types.stringLiteral(getResumeRegisterId(section, signalRefs)), markerSerializeArg)));
|
|
3301
3300
|
}
|
|
3302
3301
|
const debug = !isOptimize();
|
|
3303
3302
|
const writeScopeBuilder = getSectionWriteScopeBuilder(section);
|
|
@@ -3349,13 +3348,17 @@ function writeHTMLResumeStatements(path) {
|
|
|
3349
3348
|
for (const prop of serializedProperties) if (prop.key.type === "Identifier" && prop.value.type === "Identifier" && prop.key.name === prop.value.name) prop.shorthand = true;
|
|
3350
3349
|
const writeScopeArgs = [scopeIdIdentifier, _marko_compiler.types.objectExpression(serializedProperties)];
|
|
3351
3350
|
if (debug) {
|
|
3352
|
-
writeScopeArgs.push(_marko_compiler.types.stringLiteral(
|
|
3351
|
+
writeScopeArgs.push(_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.getFile)().opts.filenameRelative), section.loc && section.loc.start.line != null ? _marko_compiler.types.stringLiteral(`${section.loc.start.line}:${section.loc.start.column + 1}`) : _marko_compiler.types.numericLiteral(0));
|
|
3353
3352
|
for (const [accessor, varLoc] of getSectionDebugVars(section)) (debugVars ||= []).push(toObjectProperty(accessor, _marko_compiler.types.valueToNode(varLoc)));
|
|
3354
3353
|
if (debugVars) writeScopeArgs.push(_marko_compiler.types.objectExpression(debugVars));
|
|
3355
3354
|
}
|
|
3356
3355
|
body.push(_marko_compiler.types.expressionStatement(getExprIfSerialized(section, sectionSerializeReason, writeScopeBuilder ? writeScopeBuilder(callRuntime("_scope", ...writeScopeArgs)) : callRuntime("_scope", ...writeScopeArgs))));
|
|
3357
3356
|
}
|
|
3358
|
-
if (!section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || sectionSerializeReason && !!find(section.bindings, (binding) => binding.type === 1))
|
|
3357
|
+
if (!section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || sectionSerializeReason && !!find(section.bindings, (binding) => binding.type === 1)) && markerSerializeArg) {
|
|
3358
|
+
const call = callRuntime("_resume_branch", scopeIdIdentifier);
|
|
3359
|
+
const link = section.hasAbortSignal ? call : getExprIfSerialized(section, sectionSerializeReason, call);
|
|
3360
|
+
if (link) body.push(_marko_compiler.types.expressionStatement(markerSerializeArg.type === "NumericLiteral" ? link : _marko_compiler.types.logicalExpression("||", markerSerializeArg, link)));
|
|
3361
|
+
}
|
|
3359
3362
|
const additionalStatements = getHTMLSectionStatements(section);
|
|
3360
3363
|
if (body.length || additionalStatements.length) body.unshift(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(scopeIdIdentifier, callRuntime("_scope_id"))]), ...additionalStatements);
|
|
3361
3364
|
if (debug) forEach(section.bindings, (binding) => {
|
|
@@ -3677,7 +3680,7 @@ function refContent(ref) {
|
|
|
3677
3680
|
function resolveRef(ref, part) {
|
|
3678
3681
|
if (ref.kind === "sectionRef") return getSectionMetaIdentifiers(ref.section)[part === "template" ? "writes" : "walks"];
|
|
3679
3682
|
const name = ref.program.domExports[part];
|
|
3680
|
-
return ref.program.section === (0, _marko_compiler_babel_utils.getProgram)().node.extra.section ? _marko_compiler.types.identifier(name) : importOrSelfReferenceName((0, _marko_compiler_babel_utils.
|
|
3683
|
+
return ref.program.section === (0, _marko_compiler_babel_utils.getProgram)().node.extra.section ? _marko_compiler.types.identifier(name) : importOrSelfReferenceName((0, _marko_compiler_babel_utils.getFile)(), ref.path, name, `${ref.hint}_${part}`);
|
|
3681
3684
|
}
|
|
3682
3685
|
const [getSectionMeta] = createSectionState("SectionMeta", (section) => {
|
|
3683
3686
|
if (!section.structure) return {
|
|
@@ -3799,7 +3802,7 @@ var dom_default = { translate: {
|
|
|
3799
3802
|
const programInputSignal = inputBinding && !inputBinding.pruned ? initValue(inputBinding) : void 0;
|
|
3800
3803
|
let extraDecls = decls;
|
|
3801
3804
|
const styleFile = program.node.extra.styleFile;
|
|
3802
|
-
if (styleFile) (0, _marko_compiler_babel_utils.importDefault)(
|
|
3805
|
+
if (styleFile) (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), styleFile);
|
|
3803
3806
|
forEachSectionReverse((childSection) => {
|
|
3804
3807
|
if (childSection !== section) {
|
|
3805
3808
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
|
@@ -3849,7 +3852,7 @@ var dom_default = { translate: {
|
|
|
3849
3852
|
program.node.body.unshift(_marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(templateIdentifier, writes || _marko_compiler.types.stringLiteral(""))])), _marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(walksIdentifier, walks || _marko_compiler.types.stringLiteral(""))])));
|
|
3850
3853
|
if (extraDecls) program.node.body.unshift(_marko_compiler.types.variableDeclaration("const", extraDecls));
|
|
3851
3854
|
writeModuleRegistrations(program);
|
|
3852
|
-
program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(
|
|
3855
|
+
program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.getFile)().metadata.marko.id), ...replaceNullishAndEmptyFunctionsWith0([
|
|
3853
3856
|
templateIdentifier,
|
|
3854
3857
|
walksIdentifier,
|
|
3855
3858
|
domExports.setupEmpty ? void 0 : setupIdentifier,
|
|
@@ -3918,7 +3921,7 @@ var html_default = { translate: {
|
|
|
3918
3921
|
writeModuleRegistrations(program);
|
|
3919
3922
|
const contentId = usedSharedUid("content") && getTemplateContentName();
|
|
3920
3923
|
const contentFn = _marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier("input")], _marko_compiler.types.blockStatement(renderContent));
|
|
3921
|
-
const exportDefault = _marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(
|
|
3924
|
+
const exportDefault = _marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.getFile)().metadata.marko.id), contentId ? _marko_compiler.types.identifier(contentId) : contentFn, program.node.extra.page || !getMarkoOpts().linkAssets ? _marko_compiler.types.numericLiteral(1) : void 0));
|
|
3922
3925
|
if (contentId) program.node.body.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(contentId), contentFn)]), exportDefault);
|
|
3923
3926
|
else program.node.body.push(exportDefault);
|
|
3924
3927
|
}
|
|
@@ -3988,8 +3991,8 @@ function getRegisteredFnExpression(node) {
|
|
|
3988
3991
|
//#endregion
|
|
3989
3992
|
//#region src/translator/util/body-to-text-literal.ts
|
|
3990
3993
|
const kRawText = Symbol("raw text placeholder");
|
|
3991
|
-
function bodyToTextLiteral(body) {
|
|
3992
|
-
return buildTextLiteral(body, toText, true);
|
|
3994
|
+
function bodyToTextLiteral(body, decodeEntities = false) {
|
|
3995
|
+
return buildTextLiteral(body, toText, true, decodeEntities);
|
|
3993
3996
|
}
|
|
3994
3997
|
function bodyToRawTextLiteral(body) {
|
|
3995
3998
|
return buildTextLiteral(body, (value) => value, true);
|
|
@@ -4008,13 +4011,13 @@ function injectTextCoercion(expr) {
|
|
|
4008
4011
|
function toText(value) {
|
|
4009
4012
|
return callRuntime("_to_text", value);
|
|
4010
4013
|
}
|
|
4011
|
-
function buildTextLiteral(body, coerce, bareSingle) {
|
|
4014
|
+
function buildTextLiteral(body, coerce, bareSingle, decodeEntities = false) {
|
|
4012
4015
|
const templateQuasis = [];
|
|
4013
4016
|
const templateExpressions = [];
|
|
4014
4017
|
let currentQuasi = "";
|
|
4015
4018
|
let placeholderExtra;
|
|
4016
4019
|
let singleValue;
|
|
4017
|
-
for (const child of body.body) if (_marko_compiler.types.isMarkoText(child)) currentQuasi += child.value;
|
|
4020
|
+
for (const child of body.body) if (_marko_compiler.types.isMarkoText(child)) currentQuasi += decodeEntities ? (0, _marko_compiler_babel_utils.decodeHTML)(child.value) : child.value;
|
|
4018
4021
|
else if (_marko_compiler.types.isMarkoPlaceholder(child)) {
|
|
4019
4022
|
placeholderExtra ||= child.value.extra;
|
|
4020
4023
|
templateQuasis.push(templateElement(currentQuasi, false));
|
|
@@ -4074,6 +4077,7 @@ function isNonHTMLText(placeholder) {
|
|
|
4074
4077
|
return false;
|
|
4075
4078
|
}
|
|
4076
4079
|
function isTextOnlyNativeTag(tag) {
|
|
4080
|
+
if (analyzeTagNameType(tag) !== 0) return false;
|
|
4077
4081
|
const def = (0, _marko_compiler_babel_utils.getTagDef)(tag);
|
|
4078
4082
|
return !!(def && def.html && (def.name === "title" || def.parseOptions?.text));
|
|
4079
4083
|
}
|
|
@@ -4843,7 +4847,7 @@ var native_tag_default = {
|
|
|
4843
4847
|
const spreads = tag.node.attributes.filter((attr) => _marko_compiler.types.isMarkoSpreadAttribute(attr));
|
|
4844
4848
|
const spreadLoc = spreads.length === 1 && spreads[0].value.loc;
|
|
4845
4849
|
if (spreadLoc && spreadLoc.start.index != null) {
|
|
4846
|
-
const name = "..." +
|
|
4850
|
+
const name = "..." + (0, _marko_compiler_babel_utils.getFile)().code.slice(spreadLoc.start.index, spreadLoc.end.index);
|
|
4847
4851
|
for (const prefix of [getAccessorPrefix().ControlledHandler, getAccessorPrefix().EventAttributes]) if (prefix !== getAccessorPrefix().ControlledHandler || getSpreadControllableValueProps(tagName)) setSectionDebugVar(tagSection, getPrefixedScopeAccessor(nodeBinding, prefix), name, spreadLoc);
|
|
4848
4852
|
}
|
|
4849
4853
|
}
|
|
@@ -5052,7 +5056,7 @@ var native_tag_default = {
|
|
|
5052
5056
|
const openTagOnly = (0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
|
5053
5057
|
const tagName = getCanonicalTagName(tag);
|
|
5054
5058
|
if (!openTagOnly) if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
|
|
5055
|
-
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
5059
|
+
const textLiteral = bodyToTextLiteral(tag.node.body, tagName === "title");
|
|
5056
5060
|
if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), true);
|
|
5057
5061
|
} else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
|
|
5058
5062
|
tag.remove();
|
|
@@ -5573,9 +5577,7 @@ const IfTag = {
|
|
|
5573
5577
|
if (branchBodySection) {
|
|
5574
5578
|
const branchSerializeReason = getSerializeReason(branchBodySection, kBranchSerializeReason);
|
|
5575
5579
|
if (branchSerializeReason) {
|
|
5576
|
-
if (branchSerializeReasons !== true)
|
|
5577
|
-
else if (branchSerializeReasons) branchSerializeReasons = addSorted(compareSources, branchSerializeReasons, branchSerializeReason);
|
|
5578
|
-
else branchSerializeReasons = [branchSerializeReason];
|
|
5580
|
+
if (branchSerializeReasons !== true) branchSerializeReasons = branchSerializeReason === true || branchSerializeReason.state ? true : sourcesUtil.add(branchSerializeReasons, branchSerializeReason);
|
|
5579
5581
|
bodyStatements.push(_marko_compiler.types.returnStatement(_marko_compiler.types.numericLiteral(i)));
|
|
5580
5582
|
}
|
|
5581
5583
|
}
|
|
@@ -5781,11 +5783,11 @@ function preAnalyze$1(tag) {
|
|
|
5781
5783
|
const parts = [];
|
|
5782
5784
|
for (const child of tag.node.body.body) if (child.type === "MarkoText") parts.push((0, _marko_compiler_babel_utils.decodeHTML)(child.value));
|
|
5783
5785
|
else if (child.type === "MarkoPlaceholder" && child.escape) parts.push(child.value);
|
|
5784
|
-
else throw
|
|
5786
|
+
else throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(child, "Unexpected content in textarea, only text and placeholders are supported.", SyntaxError);
|
|
5785
5787
|
const textValue = normalizeStringExpression(parts);
|
|
5786
5788
|
if (textValue) {
|
|
5787
5789
|
const valueAttr = tag.node.attributes.find((attr) => _marko_compiler.types.isMarkoAttribute(attr) && attr.name === "value");
|
|
5788
|
-
if (valueAttr) throw
|
|
5790
|
+
if (valueAttr) throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(valueAttr, "A textarea cannot have both a value attribute and body content.", SyntaxError);
|
|
5789
5791
|
tag.node.attributes.push(_marko_compiler.types.markoAttribute("value", textValue));
|
|
5790
5792
|
}
|
|
5791
5793
|
tag.node.body.body = [];
|
|
@@ -5849,6 +5851,10 @@ function normalizeTag(tag) {
|
|
|
5849
5851
|
const { node } = tag;
|
|
5850
5852
|
const { name, attributes } = node;
|
|
5851
5853
|
let attrNameReg = userAttrNameReg;
|
|
5854
|
+
if (name.type === "StringLiteral") {
|
|
5855
|
+
const tagName = name.value;
|
|
5856
|
+
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) node.name = withPreviousLocation(_marko_compiler.types.identifier(tagName), name);
|
|
5857
|
+
}
|
|
5852
5858
|
normalizeBody(tag.get("body").get("body"));
|
|
5853
5859
|
normalizeBody(tag.get("attributeTags"));
|
|
5854
5860
|
if (node.var) {
|
|
@@ -5860,17 +5866,15 @@ function normalizeTag(tag) {
|
|
|
5860
5866
|
for (const param of node.body.params) insertions = getAssignmentInsertions(param, insertions);
|
|
5861
5867
|
if (insertions) node.body.body = [...insertions, ...node.body.body];
|
|
5862
5868
|
}
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
if (
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
switch (tagName) {
|
|
5869
|
-
case "textarea":
|
|
5870
|
-
preAnalyze$1(tag);
|
|
5871
|
-
break;
|
|
5872
|
-
}
|
|
5869
|
+
const nativeTagDef = getStaticNativeTagDef(tag);
|
|
5870
|
+
if (nativeTagDef) {
|
|
5871
|
+
if (!_marko_compiler.types.isStringLiteral(node.name)) {
|
|
5872
|
+
node.name = withPreviousLocation(_marko_compiler.types.stringLiteral(nativeTagDef.name), node.name);
|
|
5873
|
+
node.tagDef = nativeTagDef;
|
|
5873
5874
|
}
|
|
5875
|
+
attrNameReg = htmlAttrNameReg;
|
|
5876
|
+
if (nativeTagDef.parseOptions?.openTagOnly && node.body.body.length) throw tag.hub.buildError(node.body.body[0], `The \`<${nativeTagDef.name}>\` tag cannot have content, so it does not support a body.`);
|
|
5877
|
+
if (nativeTagDef.name === "textarea") preAnalyze$1(tag);
|
|
5874
5878
|
}
|
|
5875
5879
|
for (let i = 0; i < attributes.length; i++) {
|
|
5876
5880
|
const attr = attributes[i];
|
|
@@ -5890,6 +5894,14 @@ function normalizeTag(tag) {
|
|
|
5890
5894
|
}
|
|
5891
5895
|
}
|
|
5892
5896
|
}
|
|
5897
|
+
function getStaticNativeTagDef(tag) {
|
|
5898
|
+
const { name } = tag.node;
|
|
5899
|
+
if (_marko_compiler.types.isStringLiteral(name)) return (0, _marko_compiler_babel_utils.isNativeTag)(tag) ? (0, _marko_compiler_babel_utils.getTagDef)(tag) : void 0;
|
|
5900
|
+
if (_marko_compiler.types.isTemplateLiteral(name) && name.quasis.length === 1) {
|
|
5901
|
+
const tagDef = (0, _marko_compiler_babel_utils.getTagDefForTagName)((0, _marko_compiler_babel_utils.getFile)(), name.quasis[0].value.cooked);
|
|
5902
|
+
if (tagDef?.taglibId === "marko-html" && tagDef.html && !tagDef.template && !tagDef.renderer) return tagDef;
|
|
5903
|
+
}
|
|
5904
|
+
}
|
|
5893
5905
|
function getChangeHandler(tag, attr) {
|
|
5894
5906
|
const changeAttrName = attr.name + "Change";
|
|
5895
5907
|
let modifier;
|
|
@@ -6042,10 +6054,10 @@ var program_default = {
|
|
|
6042
6054
|
setup: generateUid("setup"),
|
|
6043
6055
|
params: void 0
|
|
6044
6056
|
};
|
|
6045
|
-
const styleFile = getStyleFile(
|
|
6057
|
+
const styleFile = getStyleFile((0, _marko_compiler_babel_utils.getFile)());
|
|
6046
6058
|
if (styleFile) {
|
|
6047
6059
|
programExtra.styleFile = styleFile;
|
|
6048
|
-
addAssetImport(
|
|
6060
|
+
addAssetImport(styleFile);
|
|
6049
6061
|
}
|
|
6050
6062
|
},
|
|
6051
6063
|
exit(program) {
|
|
@@ -6074,7 +6086,7 @@ var program_default = {
|
|
|
6074
6086
|
if (entry && !markoOpts.linkAssets) throw program.buildCodeFrameError("The \"entry\" option requires the `linkAssets` compiler option to be configured.");
|
|
6075
6087
|
if (runtimeId && !/^[_a-z][_a-z0-9]*$/i.test(runtimeId)) throw program.buildCodeFrameError(`Invalid runtimeId: "${runtimeId}". The runtimeId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
6076
6088
|
if (isLoadEntry) {
|
|
6077
|
-
const entryFile =
|
|
6089
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
6078
6090
|
const { filename } = entryFile.opts;
|
|
6079
6091
|
const readyId = getReadyId(entryFile);
|
|
6080
6092
|
const report = !markoOpts.optimize;
|
|
@@ -6083,14 +6095,14 @@ var program_default = {
|
|
|
6083
6095
|
return;
|
|
6084
6096
|
}
|
|
6085
6097
|
if (isDOMPageEntry) {
|
|
6086
|
-
const entryFile =
|
|
6098
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
6087
6099
|
builder.visit(entryFile, entryFile);
|
|
6088
6100
|
program.node.body = builder.build(entryFile);
|
|
6089
6101
|
program.skip();
|
|
6090
6102
|
return;
|
|
6091
6103
|
}
|
|
6092
6104
|
if (isServerEntry) {
|
|
6093
|
-
const entryFile =
|
|
6105
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
6094
6106
|
const { filename } = entryFile.opts;
|
|
6095
6107
|
const relativeImport = (0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename);
|
|
6096
6108
|
const templateId = (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, filename);
|
|
@@ -6139,9 +6151,9 @@ function setTagDownstream(tag, binding, exprs) {
|
|
|
6139
6151
|
});
|
|
6140
6152
|
}
|
|
6141
6153
|
function finalizeTagDownstreams(section) {
|
|
6142
|
-
for (const [tag, { binding, exprs }] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, binding, exprs);
|
|
6154
|
+
for (const [tag, { binding, exprs }] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, tag.node.extra, binding, exprs);
|
|
6143
6155
|
}
|
|
6144
|
-
function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
|
|
6156
|
+
function crawlSectionsAndSetBinding(tag, downstreamTag, binding, exprs, properties, skip) {
|
|
6145
6157
|
if (!skip) {
|
|
6146
6158
|
const contentSection = getSectionForBody(tag.get("body"));
|
|
6147
6159
|
if (contentSection) {
|
|
@@ -6149,10 +6161,12 @@ function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
|
|
|
6149
6161
|
forEach(properties, (property) => {
|
|
6150
6162
|
target = target?.propertyAliases.get(property);
|
|
6151
6163
|
});
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6164
|
+
const serialized = !(target && (target.noSerialize || includes(target.noSerializeProperties, "content")));
|
|
6165
|
+
contentSection.downstream = {
|
|
6166
|
+
tag: downstreamTag,
|
|
6167
|
+
binding: serialized ? binding : void 0,
|
|
6168
|
+
properties: serialized ? concat(properties, "content") : void 0,
|
|
6169
|
+
exprs: serialized ? exprs : void 0
|
|
6156
6170
|
};
|
|
6157
6171
|
}
|
|
6158
6172
|
}
|
|
@@ -6161,8 +6175,8 @@ function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
|
|
|
6161
6175
|
const attrTags = getAttrTagPaths(tag);
|
|
6162
6176
|
for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
|
|
6163
6177
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
6164
|
-
crawlSectionsAndSetBinding(child, binding, exprs, concat(properties, attrTagMeta.name));
|
|
6165
|
-
} else crawlSectionsAndSetBinding(child, binding, exprs, properties, true);
|
|
6178
|
+
crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, concat(properties, attrTagMeta.name));
|
|
6179
|
+
} else crawlSectionsAndSetBinding(child, downstreamTag, binding, exprs, properties, true);
|
|
6166
6180
|
}
|
|
6167
6181
|
//#endregion
|
|
6168
6182
|
//#region src/translator/util/translate-var.ts
|
|
@@ -6812,6 +6826,7 @@ function createBinding(name, type, refSection, upstreamAlias, property, excludeP
|
|
|
6812
6826
|
pruned: void 0,
|
|
6813
6827
|
exposed: false,
|
|
6814
6828
|
forcePersist: false,
|
|
6829
|
+
serializePropKeys: void 0,
|
|
6815
6830
|
reserveSize: 0
|
|
6816
6831
|
};
|
|
6817
6832
|
if (property) {
|
|
@@ -6877,7 +6892,13 @@ function trackParamsReferences(body, type) {
|
|
|
6877
6892
|
if (bodySection) bodySection.params = paramsBinding;
|
|
6878
6893
|
for (let i = 0; i < params.length; i++) {
|
|
6879
6894
|
const param = params[i];
|
|
6880
|
-
if (param.type === "RestElement"
|
|
6895
|
+
if (i === 0 && param.type === "RestElement" && param.argument.type === "Identifier") {
|
|
6896
|
+
const { argument } = param;
|
|
6897
|
+
paramsBinding.name = argument.name;
|
|
6898
|
+
paramsBinding.declared = true;
|
|
6899
|
+
(argument.extra ??= {}).binding = paramsBinding;
|
|
6900
|
+
trackReferencesForBinding(body.scope.getBinding(argument.name), paramsBinding);
|
|
6901
|
+
} else if (param.type === "RestElement") createBindingsAndTrackReferences(param.argument, type, body.scope, section, paramsBinding, void 0, i > 0 ? addNumericPropertiesUntil(void 0, i) : void 0, i);
|
|
6881
6902
|
else if (_marko_compiler.types.isLVal(param)) createBindingsAndTrackReferences(param, type, body.scope, section, paramsBinding, i + "", void 0);
|
|
6882
6903
|
}
|
|
6883
6904
|
return paramsBinding;
|
|
@@ -7054,7 +7075,7 @@ function mergeReferences(section, target, nodes) {
|
|
|
7054
7075
|
const fnReadsByExpression = getFunctionReadsByExpression();
|
|
7055
7076
|
let reads = readsByExpression.get(targetExtra);
|
|
7056
7077
|
let exprFnReads = fnReadsByExpression.get(targetExtra);
|
|
7057
|
-
let { isEffect } = targetExtra;
|
|
7078
|
+
let { isEffect, dynamicTagInput } = targetExtra;
|
|
7058
7079
|
for (const node of nodes) {
|
|
7059
7080
|
if (!node) continue;
|
|
7060
7081
|
const extra = node.extra ??= {};
|
|
@@ -7064,6 +7085,7 @@ function mergeReferences(section, target, nodes) {
|
|
|
7064
7085
|
const additionalReads = readsByExpression.get(extra);
|
|
7065
7086
|
const additionalExprFnReads = fnReadsByExpression.get(extra);
|
|
7066
7087
|
isEffect ||= extra.isEffect;
|
|
7088
|
+
dynamicTagInput ||= extra.dynamicTagInput;
|
|
7067
7089
|
if (additionalReads) {
|
|
7068
7090
|
forEach(additionalReads, (read) => {
|
|
7069
7091
|
read.binding.reads.delete(extra);
|
|
@@ -7074,10 +7096,13 @@ function mergeReferences(section, target, nodes) {
|
|
|
7074
7096
|
}
|
|
7075
7097
|
if (additionalExprFnReads) if (exprFnReads) for (const [key, value] of additionalExprFnReads) exprFnReads.set(key, value);
|
|
7076
7098
|
else fnReadsByExpression.set(targetExtra, exprFnReads = new Map(additionalExprFnReads));
|
|
7077
|
-
} else if (extra?.pruned)
|
|
7099
|
+
} else if (extra?.pruned)
|
|
7100
|
+
/* v8 ignore next -- a dropped reference is never merged into another */
|
|
7101
|
+
throw new Error("Cannot merged a dropped reference.");
|
|
7078
7102
|
}
|
|
7079
7103
|
readsByExpression.set(targetExtra, reads);
|
|
7080
7104
|
targetExtra.isEffect = isEffect;
|
|
7105
|
+
targetExtra.dynamicTagInput = dynamicTagInput;
|
|
7081
7106
|
targetExtra.section = section;
|
|
7082
7107
|
return targetExtra;
|
|
7083
7108
|
}
|
|
@@ -7249,7 +7274,7 @@ function finalizeReferences() {
|
|
|
7249
7274
|
let branchesForced = false;
|
|
7250
7275
|
let branchesSources;
|
|
7251
7276
|
while (currentSection !== sourceSection) {
|
|
7252
|
-
const upstreamReason = currentSection.
|
|
7277
|
+
const upstreamReason = currentSection.downstream?.binding ? getSectionRegisterReasons(currentSection) || void 0 : !currentSection.upstreamExpression || getSerializeSourcesForExpr(currentSection.upstreamExpression);
|
|
7253
7278
|
if (upstreamReason === true) branchesForced = true;
|
|
7254
7279
|
else if (upstreamReason) branchesSources = mergeSources(branchesSources, upstreamReason);
|
|
7255
7280
|
currentSection = currentSection.parent;
|
|
@@ -7456,6 +7481,7 @@ function resolveDerivedSources(binding) {
|
|
|
7456
7481
|
}
|
|
7457
7482
|
}
|
|
7458
7483
|
function createSources(state, param, global) {
|
|
7484
|
+
/* v8 ignore next 6 -- every caller passes at least one source */
|
|
7459
7485
|
if (!(state || param || global)) throw new Error("Cannot create a serialize reason that does not reference state, a param, or $global.");
|
|
7460
7486
|
return {
|
|
7461
7487
|
state,
|
|
@@ -7529,6 +7555,7 @@ function dropNodes(node) {
|
|
|
7529
7555
|
else dropExtra(node.extra ??= {});
|
|
7530
7556
|
}
|
|
7531
7557
|
function dropExtra(exprExtra) {
|
|
7558
|
+
/* v8 ignore next 3 -- a merged reference is never dropped */
|
|
7532
7559
|
if (exprExtra.merged) throw new Error("Cannot drop a merged reference");
|
|
7533
7560
|
const readsByExpr = getReadsByExpression();
|
|
7534
7561
|
const reads = readsByExpr.get(exprExtra);
|
|
@@ -7619,6 +7646,7 @@ function getPrefixedScopeAccessor(binding, prefix) {
|
|
|
7619
7646
|
}
|
|
7620
7647
|
function getClosureAccessorId(binding) {
|
|
7621
7648
|
const id = closureAccessorIds.get(getCanonicalBinding(binding));
|
|
7649
|
+
/* v8 ignore next 5 -- analyze reserves an id for every closure binding */
|
|
7622
7650
|
if (id === void 0) throw new Error(`No closure accessor id was reserved for "${binding.name}".`);
|
|
7623
7651
|
return id;
|
|
7624
7652
|
}
|
|
@@ -7950,16 +7978,18 @@ function getCanonicalExtra(extra) {
|
|
|
7950
7978
|
return extra;
|
|
7951
7979
|
}
|
|
7952
7980
|
const serializeReasonCache = /* @__PURE__ */ new WeakMap();
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7981
|
+
const registerReasonCache = /* @__PURE__ */ new WeakMap();
|
|
7982
|
+
function getAllSerializeReasonsForExtra(extra, register) {
|
|
7983
|
+
if (extra.isEffect || register && extra.dynamicTagInput) return true;
|
|
7984
|
+
const cache = register ? registerReasonCache : serializeReasonCache;
|
|
7985
|
+
let reason = cache.get(extra);
|
|
7956
7986
|
if (reason === false) return;
|
|
7957
7987
|
if (reason === void 0) {
|
|
7958
7988
|
if (extra === (0, _marko_compiler_babel_utils.getProgram)().node.extra?.section.returnValueExpr) reason = true;
|
|
7959
7989
|
else {
|
|
7960
|
-
|
|
7990
|
+
cache.set(extra, false);
|
|
7961
7991
|
forEach(extra.downstream, (binding) => {
|
|
7962
|
-
let linked = getAllSerializeReasonsForBinding(binding, true);
|
|
7992
|
+
let linked = getAllSerializeReasonsForBinding(binding, true, register);
|
|
7963
7993
|
if (linked && linked !== true) {
|
|
7964
7994
|
const exprs = extra.downstreamExprs;
|
|
7965
7995
|
if (exprs) linked = mapDownstreamReason(binding.section.program, linked, exprs);
|
|
@@ -7967,34 +7997,35 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
7967
7997
|
reason = mergeSerializeReasons(reason, linked);
|
|
7968
7998
|
});
|
|
7969
7999
|
}
|
|
7970
|
-
if (reason)
|
|
8000
|
+
if (reason) cache.set(extra, reason);
|
|
7971
8001
|
}
|
|
7972
8002
|
return reason;
|
|
7973
8003
|
}
|
|
7974
|
-
function getAllSerializeReasonsForBinding(binding, properties) {
|
|
7975
|
-
|
|
8004
|
+
function getAllSerializeReasonsForBinding(binding, properties, register) {
|
|
8005
|
+
const cache = register ? registerReasonCache : serializeReasonCache;
|
|
8006
|
+
let reason = cache.get(binding);
|
|
7976
8007
|
if (reason === void 0) {
|
|
7977
8008
|
reason = getSerializeReason(binding.section, binding);
|
|
7978
8009
|
if (reason !== true) {
|
|
7979
|
-
|
|
7980
|
-
if (properties !== true && binding.upstreamAlias) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(binding.upstreamAlias, binding.property));
|
|
8010
|
+
cache.set(binding, reason || false);
|
|
8011
|
+
if (properties !== true && binding.upstreamAlias) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(binding.upstreamAlias, binding.property, register));
|
|
7981
8012
|
if (reason !== true) {
|
|
7982
8013
|
for (const expr of binding.reads) {
|
|
7983
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(expr));
|
|
8014
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(expr, register));
|
|
7984
8015
|
if (reason === true) break;
|
|
7985
8016
|
}
|
|
7986
8017
|
if (reason !== true) for (const alias of binding.aliases) {
|
|
7987
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(alias, properties));
|
|
8018
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(alias, properties, register));
|
|
7988
8019
|
if (reason === true) break;
|
|
7989
8020
|
}
|
|
7990
8021
|
}
|
|
7991
8022
|
}
|
|
7992
|
-
if (reason)
|
|
8023
|
+
if (reason) cache.set(binding, reason);
|
|
7993
8024
|
}
|
|
7994
8025
|
if (reason === false) reason = void 0;
|
|
7995
8026
|
if (properties !== void 0) if (properties === true) {
|
|
7996
8027
|
if (reason !== true) for (const propBinding of binding.propertyAliases.values()) {
|
|
7997
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, true));
|
|
8028
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, true, register));
|
|
7998
8029
|
if (reason === true) break;
|
|
7999
8030
|
}
|
|
8000
8031
|
} else {
|
|
@@ -8007,11 +8038,11 @@ function getAllSerializeReasonsForBinding(binding, properties) {
|
|
|
8007
8038
|
if (includes(binding.excludeProperties, property)) reason = void 0;
|
|
8008
8039
|
else {
|
|
8009
8040
|
const propBinding = binding.propertyAliases.get(property);
|
|
8010
|
-
if (propBinding) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest));
|
|
8041
|
+
if (propBinding) reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest, register));
|
|
8011
8042
|
if (reason !== true) for (const alias of binding.aliases) {
|
|
8012
8043
|
const propBinding = alias.propertyAliases.get(property);
|
|
8013
8044
|
if (propBinding) {
|
|
8014
|
-
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest));
|
|
8045
|
+
reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(propBinding, rest, register));
|
|
8015
8046
|
if (reason === true) break;
|
|
8016
8047
|
}
|
|
8017
8048
|
}
|
|
@@ -8186,7 +8217,8 @@ function createStatementTag(keyword) {
|
|
|
8186
8217
|
const keywordReg = new RegExp(`^${keyword}\\s*`);
|
|
8187
8218
|
return {
|
|
8188
8219
|
parse(tag) {
|
|
8189
|
-
const { node
|
|
8220
|
+
const { node } = tag;
|
|
8221
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
8190
8222
|
const rawValue = node.rawValue;
|
|
8191
8223
|
const code = rawValue.replace(keywordReg, "");
|
|
8192
8224
|
const start = node.start + (rawValue.length - code.length);
|
|
@@ -8408,7 +8440,7 @@ var effect_default = {
|
|
|
8408
8440
|
var export_default = {
|
|
8409
8441
|
parse(tag) {
|
|
8410
8442
|
const { node } = tag;
|
|
8411
|
-
const statements = (0, _marko_compiler_babel_utils.parseStatements)(
|
|
8443
|
+
const statements = (0, _marko_compiler_babel_utils.parseStatements)((0, _marko_compiler_babel_utils.getFile)(), node.rawValue, node.start, node.end);
|
|
8412
8444
|
if (statements.length > 1) throw tag.hub.buildError(statements[1], "The `<export>` tag takes a single export statement.");
|
|
8413
8445
|
const defaultExport = getDefaultExport(statements[0]);
|
|
8414
8446
|
if (defaultExport) throw tag.hub.buildError(defaultExport, "A template is already its own default export. Use a named export instead.");
|
|
@@ -8587,7 +8619,7 @@ var id_default = {
|
|
|
8587
8619
|
var import_default = {
|
|
8588
8620
|
parse(tag) {
|
|
8589
8621
|
const { node } = tag;
|
|
8590
|
-
const statements = (0, _marko_compiler_babel_utils.parseStatements)(
|
|
8622
|
+
const statements = (0, _marko_compiler_babel_utils.parseStatements)((0, _marko_compiler_babel_utils.getFile)(), node.rawValue, node.start, node.end);
|
|
8591
8623
|
if (statements.length > 1) throw tag.hub.buildError(statements[1], "The [`<import>` tag](https://markojs.com/docs/reference/language#import) takes a single import statement.");
|
|
8592
8624
|
tag.replaceWith(statements[0]);
|
|
8593
8625
|
},
|
|
@@ -8751,12 +8783,12 @@ var script_default = {
|
|
|
8751
8783
|
if (body.length) {
|
|
8752
8784
|
let code = "";
|
|
8753
8785
|
for (const child of body) {
|
|
8754
|
-
if (child.type !== "MarkoText") throw
|
|
8786
|
+
if (child.type !== "MarkoText") throw (0, _marko_compiler_babel_utils.getFile)().hub.buildError(child, "Unexpected content in [`<script>` tag](https://markojs.com/docs/reference/core-tag#script). Only javascript and typescript is supported. For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.", SyntaxError);
|
|
8755
8787
|
code += child.value;
|
|
8756
8788
|
}
|
|
8757
8789
|
const start = body[0]?.start;
|
|
8758
8790
|
const end = body[body.length - 1]?.end;
|
|
8759
|
-
const bodyStatements = (0, _marko_compiler_babel_utils.parseStatements)(
|
|
8791
|
+
const bodyStatements = (0, _marko_compiler_babel_utils.parseStatements)((0, _marko_compiler_babel_utils.getFile)(), code, start, end);
|
|
8760
8792
|
if (bodyStatements.length) {
|
|
8761
8793
|
const valueFn = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(bodyStatements), !!traverseFindAwait(bodyStatements));
|
|
8762
8794
|
node.attributes.push(_marko_compiler.types.markoAttribute("value", valueFn));
|
|
@@ -9121,16 +9153,16 @@ var style_default = {
|
|
|
9121
9153
|
(0, _marko_compiler_babel_utils.assertNoArgs)(tag);
|
|
9122
9154
|
(0, _marko_compiler_babel_utils.assertNoParams)(tag);
|
|
9123
9155
|
(0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
|
|
9124
|
-
const { node
|
|
9156
|
+
const { node } = tag;
|
|
9125
9157
|
assertNoStyleAttributes(tag);
|
|
9126
9158
|
const names = collectDynamicStyleNames(tag);
|
|
9127
9159
|
if (names) {
|
|
9128
9160
|
checkStyleInterpolations(tag);
|
|
9129
9161
|
checkDynamicStylePlacement(tag);
|
|
9130
9162
|
}
|
|
9131
|
-
const importPath = getStyleImportPath(
|
|
9163
|
+
const importPath = getStyleImportPath((0, _marko_compiler_babel_utils.getFile)(), node, names);
|
|
9132
9164
|
(node.extra ??= {}).styleImportPath = importPath;
|
|
9133
|
-
if (importPath) addAssetImport(
|
|
9165
|
+
if (importPath) addAssetImport(importPath);
|
|
9134
9166
|
if (names) {
|
|
9135
9167
|
analyzeDynamicStyle(tag, names);
|
|
9136
9168
|
addSetupStatement(getOrCreateSection(tag));
|
|
@@ -9168,14 +9200,14 @@ function collectDynamicStyleNames(tag) {
|
|
|
9168
9200
|
const program = (0, _marko_compiler_babel_utils.getProgram)().node;
|
|
9169
9201
|
const index = programDynamicStyleNameCounts.get(program) ?? 0;
|
|
9170
9202
|
programDynamicStyleNameCounts.set(program, index + 1);
|
|
9171
|
-
(names ??= []).push(dynamicStyleName(
|
|
9203
|
+
(names ??= []).push(dynamicStyleName(index));
|
|
9172
9204
|
} else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, "The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only supports text and `${...}` interpolations. For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.");
|
|
9173
9205
|
return names;
|
|
9174
9206
|
}
|
|
9175
9207
|
const styleNameUnsafeReg = /[^a-zA-Z0-9_]/g;
|
|
9176
9208
|
const encodeStyleNameChar = (c) => "-" + c.charCodeAt(0).toString(36);
|
|
9177
|
-
function dynamicStyleName(
|
|
9178
|
-
const
|
|
9209
|
+
function dynamicStyleName(index) {
|
|
9210
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
9179
9211
|
const id = (0, _marko_compiler_babel_utils.getTemplateId)(file.markoOpts, file.opts.filename, index.toString(36));
|
|
9180
9212
|
return "--" + ((file.markoOpts.runtimeId || "M_") + id).replace(styleNameUnsafeReg, encodeStyleNameChar);
|
|
9181
9213
|
}
|
|
@@ -9230,13 +9262,13 @@ function dynamicStyleValues(node) {
|
|
|
9230
9262
|
return values;
|
|
9231
9263
|
}
|
|
9232
9264
|
function emitStyleImport(tag) {
|
|
9233
|
-
const { node
|
|
9265
|
+
const { node } = tag;
|
|
9234
9266
|
const importPath = node.extra?.styleImportPath;
|
|
9235
9267
|
if (!importPath) return;
|
|
9236
9268
|
if (!node.var) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(importPath)));
|
|
9237
9269
|
else if (_marko_compiler.types.isIdentifier(node.var)) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importNamespaceSpecifier(node.var)], _marko_compiler.types.stringLiteral(importPath)));
|
|
9238
9270
|
else {
|
|
9239
|
-
const varDecl = _marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(node.var, (0, _marko_compiler_babel_utils.importStar)(
|
|
9271
|
+
const varDecl = _marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(node.var, (0, _marko_compiler_babel_utils.importStar)((0, _marko_compiler_babel_utils.getFile)(), importPath, "style"))]);
|
|
9240
9272
|
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(isOutputDOM() ? varDecl : _marko_compiler.types.markoScriptlet([varDecl], true));
|
|
9241
9273
|
}
|
|
9242
9274
|
}
|
|
@@ -9470,7 +9502,7 @@ var export_declaration_default = {
|
|
|
9470
9502
|
const tagImport = (0, _marko_compiler_babel_utils.resolveTagImport)(exportDecl, source.value);
|
|
9471
9503
|
if (tagImport) {
|
|
9472
9504
|
(node.extra ??= {}).tagImport = tagImport;
|
|
9473
|
-
const tags =
|
|
9505
|
+
const tags = (0, _marko_compiler_babel_utils.getFile)().metadata.marko.tags;
|
|
9474
9506
|
if (!tags.includes(tagImport)) tags.push(tagImport);
|
|
9475
9507
|
}
|
|
9476
9508
|
}
|
|
@@ -9490,11 +9522,11 @@ var import_declaration_default = {
|
|
|
9490
9522
|
const { node } = importDecl;
|
|
9491
9523
|
const { source } = node;
|
|
9492
9524
|
const { value } = source;
|
|
9493
|
-
if (_marko_compiler.types.isProgram(importDecl.parent) && isClientAssetImport(
|
|
9525
|
+
if (_marko_compiler.types.isProgram(importDecl.parent) && isClientAssetImport((0, _marko_compiler_babel_utils.getFile)(), value)) addAssetImport(value);
|
|
9494
9526
|
const tagImport = (0, _marko_compiler_babel_utils.resolveTagImport)(importDecl, value);
|
|
9495
9527
|
if (tagImport) {
|
|
9496
9528
|
(node.extra ??= {}).tagImport = tagImport;
|
|
9497
|
-
const tags =
|
|
9529
|
+
const tags = (0, _marko_compiler_babel_utils.getFile)().metadata.marko.tags;
|
|
9498
9530
|
if (!tags.includes(tagImport)) tags.push(tagImport);
|
|
9499
9531
|
trackImportedRegisteredFns(importDecl);
|
|
9500
9532
|
}
|
|
@@ -9509,7 +9541,7 @@ var import_declaration_default = {
|
|
|
9509
9541
|
return;
|
|
9510
9542
|
}
|
|
9511
9543
|
(node.extra ??= {}).loadImport = loadImport;
|
|
9512
|
-
const
|
|
9544
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
9513
9545
|
const loadFile = tagImport && (0, _marko_compiler_babel_utils.loadFileForImport)(file, value);
|
|
9514
9546
|
if (!loadFile) throw importDecl.buildCodeFrameError("Unable to resolve marko file for load import.");
|
|
9515
9547
|
(file.path.node.extra.loadImports ??= /* @__PURE__ */ new Set()).add(loadFile.opts.filename);
|
|
@@ -9526,8 +9558,7 @@ var import_declaration_default = {
|
|
|
9526
9558
|
const { local } = node.specifiers.find(_marko_compiler.types.isImportDefaultSpecifier);
|
|
9527
9559
|
const binding = importDecl.scope.getBinding(local.name);
|
|
9528
9560
|
if (isOutputHTML()) {
|
|
9529
|
-
const
|
|
9530
|
-
const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
|
|
9561
|
+
const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)((0, _marko_compiler_babel_utils.getFile)(), node.source.value);
|
|
9531
9562
|
const wrappedName = getOrCreateHtmlLoadWrapped(getReadyId(loadFile), _marko_compiler.types.identifier(local.name), loadFile.opts.filename, loadImport.render ? void 0 : loadImport.triggers);
|
|
9532
9563
|
for (const ref of binding.referencePaths) ref.replaceWith(_marko_compiler.types.identifier(wrappedName));
|
|
9533
9564
|
node.source.value = tagImport;
|
|
@@ -9535,7 +9566,7 @@ var import_declaration_default = {
|
|
|
9535
9566
|
return;
|
|
9536
9567
|
} else if (binding.referencePaths.every((ref) => _marko_compiler.types.isMarkoTag(ref.parent) && ref.parent.extra?.tagNameLoad)) importDecl.remove();
|
|
9537
9568
|
else {
|
|
9538
|
-
const
|
|
9569
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
9539
9570
|
const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
|
|
9540
9571
|
const resolvedPath = (0, _marko_compiler_babel_utils.resolveRelativePath)(file, loadFile.opts.filename);
|
|
9541
9572
|
importRuntimeFeature("catch");
|
|
@@ -9560,7 +9591,7 @@ function getOrCreateHtmlLoadWrapped(readyId, originalIdentifier, filename, trigg
|
|
|
9560
9591
|
}
|
|
9561
9592
|
function trackImportedRegisteredFns(importDecl) {
|
|
9562
9593
|
const { node } = importDecl;
|
|
9563
|
-
const childFile = (0, _marko_compiler_babel_utils.loadFileForImport)(
|
|
9594
|
+
const childFile = (0, _marko_compiler_babel_utils.loadFileForImport)((0, _marko_compiler_babel_utils.getFile)(), node.source.value);
|
|
9564
9595
|
if (!childFile) return;
|
|
9565
9596
|
for (const specifier of importDecl.get("specifiers")) {
|
|
9566
9597
|
if (!specifier.isImportSpecifier()) continue;
|
|
@@ -9958,13 +9989,13 @@ function translateHTML(tag) {
|
|
|
9958
9989
|
let tagIdentifier;
|
|
9959
9990
|
if (_marko_compiler.types.isStringLiteral(node.name)) {
|
|
9960
9991
|
const relativePath = getTagRelativePath(tag);
|
|
9961
|
-
tagIdentifier = isCircularRequest(
|
|
9992
|
+
tagIdentifier = isCircularRequest((0, _marko_compiler_babel_utils.getFile)(), relativePath) ? _marko_compiler.types.identifier(getTemplateContentName()) : (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), relativePath, getTagName(tag));
|
|
9962
9993
|
} else tagIdentifier = node.name;
|
|
9963
9994
|
knownTagTranslateHTML(tag, tagIdentifier, childExtra.section, childExtra.domExports?.params);
|
|
9964
9995
|
}
|
|
9965
9996
|
function translateDOM(tag) {
|
|
9966
9997
|
const { node } = tag;
|
|
9967
|
-
const
|
|
9998
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
9968
9999
|
const relativePath = getTagRelativePath(tag);
|
|
9969
10000
|
const programSection = (0, _marko_compiler_babel_utils.getProgram)().node.extra.section;
|
|
9970
10001
|
const childFile = (0, _marko_compiler_babel_utils.loadFileForTag)(tag);
|
|
@@ -10007,7 +10038,7 @@ function translateDOM(tag) {
|
|
|
10007
10038
|
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(childExports.setup), [createScopeReadExpression(childBinding, section)])));
|
|
10008
10039
|
});
|
|
10009
10040
|
else {
|
|
10010
|
-
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName, directContent) => importOrSelfReferenceName(
|
|
10041
|
+
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName, directContent) => importOrSelfReferenceName((0, _marko_compiler_babel_utils.getFile)(), relativePath, directContent && binding.directContentExport || binding.export, preferredName), childExports.setupEmpty ? void 0 : (section, childBinding) => {
|
|
10011
10042
|
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importOrSelfReferenceName(file, relativePath, childExports.setup, tagName), [createScopeReadExpression(childBinding, section)])));
|
|
10012
10043
|
});
|
|
10013
10044
|
(0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.template, `${tagName}_template`);
|
|
@@ -10016,7 +10047,8 @@ function translateDOM(tag) {
|
|
|
10016
10047
|
tag.remove();
|
|
10017
10048
|
}
|
|
10018
10049
|
function getTagRelativePath(tag) {
|
|
10019
|
-
const { node
|
|
10050
|
+
const { node } = tag;
|
|
10051
|
+
const file = (0, _marko_compiler_babel_utils.getFile)();
|
|
10020
10052
|
let relativePath;
|
|
10021
10053
|
if (_marko_compiler.types.isStringLiteral(node.name)) {
|
|
10022
10054
|
const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
|
|
@@ -10048,7 +10080,7 @@ function tagNotFoundError(tag) {
|
|
|
10048
10080
|
if (knownWrongTagHint) didYouMean = ` ${knownWrongTagHint}`;
|
|
10049
10081
|
else if (proseText) didYouMean = ` If this line is meant to be text, prefix it with \`--\` (e.g. \`-- ${proseText}\`) or wrap it in an element such as \`<p>${proseText}</p>\`.`;
|
|
10050
10082
|
else if (tagName) {
|
|
10051
|
-
const closestTag = (0, fastest_levenshtein.closest)(tagName, Object.keys((0, _marko_compiler_babel_utils.getTaglibLookup)(
|
|
10083
|
+
const closestTag = (0, fastest_levenshtein.closest)(tagName, Object.keys((0, _marko_compiler_babel_utils.getTaglibLookup)((0, _marko_compiler_babel_utils.getFile)()).merged.tags));
|
|
10052
10084
|
if ((0, fastest_levenshtein.distance)(tagName, closestTag) < 4) didYouMean = ` Did you mean \`<${closestTag}>\`?`;
|
|
10053
10085
|
}
|
|
10054
10086
|
return tag.get("name").buildCodeFrameError(`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName ?? getStaticTagName(tag.node)}>\`.${didYouMean}`);
|
|
@@ -10135,7 +10167,9 @@ var dynamic_tag_default = {
|
|
|
10135
10167
|
}
|
|
10136
10168
|
analyzeAttributeTags(tag);
|
|
10137
10169
|
const tagSection = getOrCreateSection(tag);
|
|
10138
|
-
const
|
|
10170
|
+
const inputNodes = getAllTagReferenceNodes(node);
|
|
10171
|
+
const tagExtra = mergeReferences(tagSection, node, [node.name, ...inputNodes]);
|
|
10172
|
+
if (inputNodes.length) tagExtra.dynamicTagInput = true;
|
|
10139
10173
|
const tagBody = tag.get("body");
|
|
10140
10174
|
const hasVar = !!tag.node.var;
|
|
10141
10175
|
const nodeBinding = tagExtra[kDOMBinding] = createBinding("#text", 0, tagSection);
|
|
@@ -10195,11 +10229,11 @@ var dynamic_tag_default = {
|
|
|
10195
10229
|
return;
|
|
10196
10230
|
}
|
|
10197
10231
|
((0, _marko_compiler_babel_utils.getProgram)().node.extra ??= {}).needsCompat = true;
|
|
10198
|
-
if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(
|
|
10232
|
+
if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), getTagRelativePath(tag), tagExpression.value);
|
|
10199
10233
|
if (classTagTemplate) {
|
|
10200
10234
|
const preserveBoundary = !tagsSerializeReason && (classHydration === "descendant" || classHydration === "self" && !!classFile?.metadata.marko.hasComponentBrowser);
|
|
10201
10235
|
const classId = classFile.metadata.marko.id;
|
|
10202
|
-
const registration = isOutputHTML() ? _marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(
|
|
10236
|
+
const registration = isOutputHTML() ? _marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)((0, _marko_compiler_babel_utils.getFile)(), getCompatRuntimeFile(), "s"), [
|
|
10203
10237
|
_marko_compiler.types.stringLiteral(classId),
|
|
10204
10238
|
_marko_compiler.types.identifier(tagExpression.name),
|
|
10205
10239
|
...preserveBoundary ? [_marko_compiler.types.stringLiteral("preserve")] : []
|
|
@@ -10215,7 +10249,7 @@ var dynamic_tag_default = {
|
|
|
10215
10249
|
const rendererName = tagExpression.name;
|
|
10216
10250
|
pushCompatRegistration(rendererName, _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(rendererName), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(rendererName)))], true));
|
|
10217
10251
|
}
|
|
10218
|
-
} else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(
|
|
10252
|
+
} else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)((0, _marko_compiler_babel_utils.getFile)(), getTagRelativePath(tag), tagExpression.value);
|
|
10219
10253
|
const { properties, statements } = translateAttrs(tag, void 0, void 0, void 0, isClassAPI ? "renderBody" : "content");
|
|
10220
10254
|
const args = [];
|
|
10221
10255
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
|
@@ -10355,7 +10389,7 @@ var tag_default = {
|
|
|
10355
10389
|
enter(tag) {
|
|
10356
10390
|
const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
|
|
10357
10391
|
if (tagDef?.translator) {
|
|
10358
|
-
if (tagDef.translator.path)
|
|
10392
|
+
if (tagDef.translator.path) (0, _marko_compiler_babel_utils.getFile)().metadata.marko.watchFiles.push(tagDef.translator.path);
|
|
10359
10393
|
enter$1(tagDef.translator.hook, tag);
|
|
10360
10394
|
return;
|
|
10361
10395
|
}
|
|
@@ -10539,7 +10573,7 @@ function getFeatureTypeFromCoreTagName(tagName) {
|
|
|
10539
10573
|
}
|
|
10540
10574
|
function addFeature(state, type, name, path) {
|
|
10541
10575
|
if (state.feature) {
|
|
10542
|
-
if (state.feature.type !== type) throw buildAggregateError(
|
|
10576
|
+
if (state.feature.type !== type) throw buildAggregateError((0, _marko_compiler_babel_utils.getFile)(), "Cannot mix Tags API and Class API features in the same file", [state.feature.name, state.feature.path], [name, path]);
|
|
10543
10577
|
} else state.feature = {
|
|
10544
10578
|
name,
|
|
10545
10579
|
path,
|
|
@@ -10616,7 +10650,7 @@ function createInteropTranslator(translate5) {
|
|
|
10616
10650
|
...visitor,
|
|
10617
10651
|
Program: {
|
|
10618
10652
|
enter(program, state) {
|
|
10619
|
-
const entryFile =
|
|
10653
|
+
const entryFile = (0, _marko_compiler_babel_utils.getFile)();
|
|
10620
10654
|
const { output, entry } = entryFile.markoOpts;
|
|
10621
10655
|
if (!(output === "dom" && entry === "page" || output === "hydrate")) return enterProgram?.call(this, program, state);
|
|
10622
10656
|
const visitedFiles = /* @__PURE__ */ new Map([[(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename), false]]);
|