marko 6.3.43 → 6.3.45
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/cheatsheet.md +7 -3
- 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-BbtmY5_5.js → dom-DBuLwSOh.js} +10 -0
- package/dist/debug/{dom-DYV177a1.mjs → dom-ky42a_qY.mjs} +5 -1
- package/dist/debug/dom.js +2 -1
- package/dist/debug/dom.mjs +2 -2
- package/dist/debug/html.js +2 -1
- package/dist/debug/html.mjs +2 -1
- package/dist/dom/catch.feat.js +3 -3
- 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 +2 -2
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/dom/signals.d.ts +1 -0
- package/dist/{dom-HMfNm7KC.mjs → dom-BSAs0ur8.mjs} +4 -1
- package/dist/{dom-CKak9Qet.js → dom-DHJCbngT.js} +45 -37
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +21 -21
- package/dist/dom.mjs +2 -2
- package/dist/html.js +1 -1
- package/dist/html.mjs +1 -1
- package/dist/translator/index.js +236 -129
- package/dist/translator/interop/index.d.ts +8 -0
- package/dist/translator/util/entry-builder.d.ts +17 -3
- package/dist/translator/util/known-tag.d.ts +1 -5
- package/dist/translator/util/references.d.ts +10 -1
- package/dist/translator/util/sections.d.ts +3 -1
- package/dist/translator/util/serialize-reasons.d.ts +3 -1
- package/dist/translator/util/set-tag-sections-downstream.d.ts +2 -2
- package/dist/translator/util/tag-name-type.d.ts +3 -0
- package/dist/translator/visitors/import-declaration.d.ts +4 -0
- package/dist/translator/visitors/program/index.d.ts +1 -0
- package/dist/translator/visitors/tag/custom-tag.d.ts +1 -0
- package/package.json +4 -4
package/dist/translator/index.js
CHANGED
|
@@ -35,8 +35,6 @@ let package_json = require("../../package.json");
|
|
|
35
35
|
package_json = __toESM(package_json, 1);
|
|
36
36
|
let _marko_compiler = require("@marko/compiler");
|
|
37
37
|
let _marko_compiler_babel_utils = require("@marko/compiler/babel-utils");
|
|
38
|
-
let node_path = require("node:path");
|
|
39
|
-
node_path = __toESM(node_path, 1);
|
|
40
38
|
let path = require("path");
|
|
41
39
|
path = __toESM(path, 1);
|
|
42
40
|
let magic_string = require("magic-string");
|
|
@@ -1201,6 +1199,37 @@ function getSerializeSourcesForRef(ref) {
|
|
|
1201
1199
|
} else return ref.sources;
|
|
1202
1200
|
}
|
|
1203
1201
|
}
|
|
1202
|
+
function mapCrossProgramReason(program, reason, exprs) {
|
|
1203
|
+
let params;
|
|
1204
|
+
let mapped;
|
|
1205
|
+
let crossProgram = false;
|
|
1206
|
+
forEach(reason.param, (param) => {
|
|
1207
|
+
if (param.section.program === program) params = bindingUtil.add(params, param);
|
|
1208
|
+
else {
|
|
1209
|
+
crossProgram = true;
|
|
1210
|
+
mapped = exprs ? mergeSerializeReasons(mapped, getSerializeSourcesForExprs(mapParamBindingToExpr(exprs, param))) : true;
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
if (!crossProgram) return reason;
|
|
1214
|
+
return mergeRemappedSources(reason, params, mapped);
|
|
1215
|
+
}
|
|
1216
|
+
function mapDownstreamReason(program, reason, exprs) {
|
|
1217
|
+
let params;
|
|
1218
|
+
let mapped;
|
|
1219
|
+
let downstream = false;
|
|
1220
|
+
forEach(reason.param, (param) => {
|
|
1221
|
+
if (param.section.program === program) {
|
|
1222
|
+
downstream = true;
|
|
1223
|
+
mapped = mergeSerializeReasons(mapped, getSerializeSourcesForExprs(mapParamBindingToExpr(exprs, param)));
|
|
1224
|
+
} else params = bindingUtil.add(params, param);
|
|
1225
|
+
});
|
|
1226
|
+
if (!downstream) return reason;
|
|
1227
|
+
return mergeRemappedSources(reason, params, mapped);
|
|
1228
|
+
}
|
|
1229
|
+
function mergeRemappedSources(reason, params, mapped) {
|
|
1230
|
+
if (mapped !== true && (reason.state || reason.global || params)) mapped = mergeSerializeReasons(mapped, createSources(reason.state, params, reason.global));
|
|
1231
|
+
return mapped;
|
|
1232
|
+
}
|
|
1204
1233
|
function mergeSerializeReasons(a, b) {
|
|
1205
1234
|
if (a === true || b === true) return true;
|
|
1206
1235
|
return mergeSources(a, b);
|
|
@@ -1323,6 +1352,7 @@ function createSectionState(key, init) {
|
|
|
1323
1352
|
//#endregion
|
|
1324
1353
|
//#region src/translator/util/tag-name-type.ts
|
|
1325
1354
|
const MARKO_FILE_REG = /^<.*>$|\.marko$/;
|
|
1355
|
+
const TAG_NAME_IDENTIFIER_REG$1 = /^[A-Z][a-zA-Z0-9_$]*$/;
|
|
1326
1356
|
function analyzeTagNameType(tag, allowDynamic) {
|
|
1327
1357
|
const extra = tag.node.extra ??= {};
|
|
1328
1358
|
if (extra.tagNameType === void 0) {
|
|
@@ -1346,9 +1376,12 @@ function analyzeTagNameType(tag, allowDynamic) {
|
|
|
1346
1376
|
extra.tagNameType = 2;
|
|
1347
1377
|
extra.tagNameDynamic = true;
|
|
1348
1378
|
extra.featureType = "class";
|
|
1379
|
+
if (childFile?.ast.program.extra?.hydratesTags) (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
|
|
1349
1380
|
} else if (!childFile) {
|
|
1350
1381
|
extra.tagNameType = 2;
|
|
1351
1382
|
extra.tagNameDynamic = true;
|
|
1383
|
+
const tagName = name.node.value;
|
|
1384
|
+
extra.tagNameUnresolved = !(TAG_NAME_IDENTIFIER_REG$1.test(tagName) && tag.scope.hasBinding(tagName));
|
|
1352
1385
|
}
|
|
1353
1386
|
}
|
|
1354
1387
|
}
|
|
@@ -1444,6 +1477,7 @@ function startSection(path) {
|
|
|
1444
1477
|
loc: parentTag?.node.name.loc || void 0,
|
|
1445
1478
|
depth: parentSection ? parentSection.depth + 1 : 0,
|
|
1446
1479
|
parent: parentSection,
|
|
1480
|
+
program: void 0,
|
|
1447
1481
|
sectionAccessor: void 0,
|
|
1448
1482
|
params: void 0,
|
|
1449
1483
|
referencedLocalClosures: void 0,
|
|
@@ -1467,6 +1501,7 @@ function startSection(path) {
|
|
|
1467
1501
|
isBranch: false,
|
|
1468
1502
|
structure: parentSection && !parentSection.structure ? null : []
|
|
1469
1503
|
};
|
|
1504
|
+
section.program = parentSection ? parentSection.program : section;
|
|
1470
1505
|
sections.push(section);
|
|
1471
1506
|
}
|
|
1472
1507
|
return section;
|
|
@@ -1570,7 +1605,8 @@ function getSectionRegisterReasons(section) {
|
|
|
1570
1605
|
if (section.isBranch) return false;
|
|
1571
1606
|
const { downstreamBinding } = section;
|
|
1572
1607
|
if (downstreamBinding) {
|
|
1573
|
-
|
|
1608
|
+
let downstreamReasons = getAllSerializeReasonsForBinding(downstreamBinding.binding, downstreamBinding.properties);
|
|
1609
|
+
if (downstreamReasons && downstreamReasons !== true) downstreamReasons = mapCrossProgramReason(section.program, downstreamReasons, downstreamBinding.exprs);
|
|
1574
1610
|
if (!downstreamReasons) return false;
|
|
1575
1611
|
if (isReasonDynamic(downstreamReasons) && !section.serializeReason && !section.serializeReasons.size && !section.parent?.serializeReason && !section.parent?.serializeReasons.size) return false;
|
|
1576
1612
|
return downstreamReasons;
|
|
@@ -1910,6 +1946,26 @@ function isClientAssetImport(file, request) {
|
|
|
1910
1946
|
return typeof hydrateIncludeImports === "function" ? hydrateIncludeImports(request) : !!hydrateIncludeImports?.test(request);
|
|
1911
1947
|
}
|
|
1912
1948
|
//#endregion
|
|
1949
|
+
//#region src/translator/util/binding-has-prop.ts
|
|
1950
|
+
function isSectionRendererElided(section) {
|
|
1951
|
+
return !!section.downstreamBinding && !bindingHasProperty(section.downstreamBinding.binding, section.downstreamBinding.properties);
|
|
1952
|
+
}
|
|
1953
|
+
function bindingHasProperty(binding, properties) {
|
|
1954
|
+
if (binding.pruned) return false;
|
|
1955
|
+
else if (binding.pruned === void 0) throw new Error("Binding must be pruned before checking properties");
|
|
1956
|
+
if (binding.reads.size || !properties) return true;
|
|
1957
|
+
let property;
|
|
1958
|
+
let rest;
|
|
1959
|
+
if (Array.isArray(properties)) {
|
|
1960
|
+
property = properties[0];
|
|
1961
|
+
rest = properties.length === 2 ? properties[1] : properties.slice(1);
|
|
1962
|
+
} else property = properties;
|
|
1963
|
+
const propBinding = binding.propertyAliases.get(property);
|
|
1964
|
+
if (propBinding && bindingHasProperty(propBinding, rest)) return true;
|
|
1965
|
+
for (const alias of binding.aliases) if (bindingHasProperty(alias, properties)) return true;
|
|
1966
|
+
return false;
|
|
1967
|
+
}
|
|
1968
|
+
//#endregion
|
|
1913
1969
|
//#region src/translator/util/binding-prop-tree.ts
|
|
1914
1970
|
const kDirectContent = Symbol("direct content");
|
|
1915
1971
|
function getBindingPropTree(binding) {
|
|
@@ -1970,35 +2026,70 @@ function resolveRelativeToEntry(entryFile, file, req) {
|
|
|
1970
2026
|
//#endregion
|
|
1971
2027
|
//#region src/translator/util/entry-builder.ts
|
|
1972
2028
|
const kState = Symbol();
|
|
1973
|
-
|
|
2029
|
+
const builder = {
|
|
1974
2030
|
build(entryFile, exportInit) {
|
|
1975
2031
|
const state = entryFile[kState];
|
|
1976
2032
|
if (!state) throw entryFile.path.buildCodeFrameError("Unable to build hydrate code, no files were visited before finalizing the build");
|
|
1977
2033
|
const body = [];
|
|
1978
|
-
|
|
2034
|
+
for (const asset of state.assets) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(asset)));
|
|
2035
|
+
if (state.init || state.load) {
|
|
1979
2036
|
const isPage = entryFile.path.node.extra.page;
|
|
1980
2037
|
const initHelper = isPage ? "init" : "initEmbedded";
|
|
1981
|
-
body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier(initHelper), _marko_compiler.types.identifier(initHelper))], _marko_compiler.types.stringLiteral(`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`))
|
|
2038
|
+
if (state.init) body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier(initHelper), _marko_compiler.types.identifier(initHelper))], _marko_compiler.types.stringLiteral(`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`)));
|
|
2039
|
+
for (const root of state.roots) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(root)));
|
|
2040
|
+
if (!state.init) {
|
|
2041
|
+
if (exportInit) body.push(_marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([]))));
|
|
2042
|
+
return body;
|
|
2043
|
+
}
|
|
1982
2044
|
const { runtimeId } = entryFile.markoOpts;
|
|
1983
2045
|
const readyId = !isPage && (0, _marko_compiler_babel_utils.getTemplateId)(entryFile.markoOpts, entryFile.opts.filename);
|
|
1984
2046
|
const initExpression = _marko_compiler.types.callExpression(_marko_compiler.types.identifier(initHelper), readyId ? runtimeId ? [_marko_compiler.types.stringLiteral(readyId), _marko_compiler.types.stringLiteral(runtimeId)] : [_marko_compiler.types.stringLiteral(readyId)] : runtimeId ? [_marko_compiler.types.stringLiteral(runtimeId)] : []);
|
|
1985
2047
|
body.push(exportInit ? _marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.arrowFunctionExpression([], initExpression)) : _marko_compiler.types.expressionStatement(initExpression));
|
|
1986
2048
|
} else {
|
|
1987
|
-
for (const asset of state.
|
|
2049
|
+
for (const asset of state.bundledAssets) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(asset)));
|
|
1988
2050
|
if (exportInit) body.push(_marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([]))));
|
|
1989
2051
|
}
|
|
1990
2052
|
return body;
|
|
1991
2053
|
},
|
|
1992
|
-
visit(file, entryFile, visitChild) {
|
|
2054
|
+
visit(file, entryFile, visitChild = (id, bundled = false) => {
|
|
2055
|
+
const state = entryFile[kState];
|
|
2056
|
+
const resolved = resolveRelativeToEntry(entryFile, file, id);
|
|
2057
|
+
const seenBundled = state.visited.get(resolved);
|
|
2058
|
+
if (seenBundled === false || seenBundled && bundled) return;
|
|
2059
|
+
state.visited.set(resolved, bundled);
|
|
2060
|
+
const childFile = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
|
|
2061
|
+
if (childFile) builder.visit(childFile, entryFile);
|
|
2062
|
+
}) {
|
|
1993
2063
|
const state = entryFile[kState] ||= {
|
|
1994
2064
|
init: false,
|
|
1995
|
-
|
|
2065
|
+
load: false,
|
|
2066
|
+
bundled: 0,
|
|
2067
|
+
roots: [],
|
|
2068
|
+
assets: /* @__PURE__ */ new Set(),
|
|
2069
|
+
bundledAssets: /* @__PURE__ */ new Set(),
|
|
2070
|
+
visited: /* @__PURE__ */ new Map([[(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename), false]])
|
|
1996
2071
|
};
|
|
1997
2072
|
const programExtra = file.path.node.extra;
|
|
1998
2073
|
const { analyzedTags, assetImports } = file.metadata.marko;
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2074
|
+
const { loadImports } = programExtra;
|
|
2075
|
+
const init = !!(programExtra.isInteractive || programExtra.needsCompat);
|
|
2076
|
+
const load = !!programExtra.hasClientStatement;
|
|
2077
|
+
const isRoot = !state.bundled && (init || load || !!programExtra.hasResumes);
|
|
2078
|
+
if (init) state.init = true;
|
|
2079
|
+
if (load) state.load = true;
|
|
2080
|
+
if (isRoot) state.roots.push((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, file.opts.filename));
|
|
2081
|
+
if (assetImports) {
|
|
2082
|
+
const assets = isRoot || state.bundled ? state.bundledAssets : state.assets;
|
|
2083
|
+
for (const request of assetImports) assets.add(resolveRelativeToEntry(entryFile, file, request));
|
|
2084
|
+
}
|
|
2085
|
+
if (isRoot) state.bundled++;
|
|
2086
|
+
for (const tag of analyzedTags ? [...analyzedTags] : []) {
|
|
2087
|
+
const lazy = loadImports?.has(tag);
|
|
2088
|
+
if (lazy) state.bundled++;
|
|
2089
|
+
visitChild(tag, !!state.bundled);
|
|
2090
|
+
if (lazy) state.bundled--;
|
|
2091
|
+
}
|
|
2092
|
+
if (isRoot) state.bundled--;
|
|
2002
2093
|
}
|
|
2003
2094
|
};
|
|
2004
2095
|
//#endregion
|
|
@@ -2533,26 +2624,6 @@ function sectionHasSetupStatements(section) {
|
|
|
2533
2624
|
return false;
|
|
2534
2625
|
}
|
|
2535
2626
|
//#endregion
|
|
2536
|
-
//#region src/translator/util/binding-has-prop.ts
|
|
2537
|
-
function isSectionRendererElided(section) {
|
|
2538
|
-
return !!section.downstreamBinding && !bindingHasProperty(section.downstreamBinding.binding, section.downstreamBinding.properties);
|
|
2539
|
-
}
|
|
2540
|
-
function bindingHasProperty(binding, properties) {
|
|
2541
|
-
if (binding.pruned) return false;
|
|
2542
|
-
else if (binding.pruned === void 0) throw new Error("Binding must be pruned before checking properties");
|
|
2543
|
-
if (binding.reads.size || !properties) return true;
|
|
2544
|
-
let property;
|
|
2545
|
-
let rest;
|
|
2546
|
-
if (Array.isArray(properties)) {
|
|
2547
|
-
property = properties[0];
|
|
2548
|
-
rest = properties.length === 2 ? properties[1] : properties.slice(1);
|
|
2549
|
-
} else property = properties;
|
|
2550
|
-
const propBinding = binding.propertyAliases.get(property);
|
|
2551
|
-
if (propBinding && bindingHasProperty(propBinding, rest)) return true;
|
|
2552
|
-
for (const alias of binding.aliases) if (bindingHasProperty(alias, properties)) return true;
|
|
2553
|
-
return false;
|
|
2554
|
-
}
|
|
2555
|
-
//#endregion
|
|
2556
2627
|
//#region src/translator/util/module-registrations.ts
|
|
2557
2628
|
/**
|
|
2558
2629
|
* Writes the registrations for module scoped functions: the ones this template
|
|
@@ -6085,7 +6156,8 @@ function preAnalyze$1(tag) {
|
|
|
6085
6156
|
const [firstChild] = tag.node.body.body;
|
|
6086
6157
|
if (firstChild.type === "MarkoText") firstChild.value = firstChild.value.replace(/^\r?\n/, "");
|
|
6087
6158
|
const parts = [];
|
|
6088
|
-
for (const child of tag.node.body.body) if (child.type === "MarkoText"
|
|
6159
|
+
for (const child of tag.node.body.body) if (child.type === "MarkoText") parts.push((0, _marko_compiler_babel_utils.decodeHTML)(child.value));
|
|
6160
|
+
else if (child.type === "MarkoPlaceholder" && child.escape) parts.push(child.value);
|
|
6089
6161
|
else throw tag.hub.file.hub.buildError(child, "Unexpected content in textarea, only text and placeholders are supported.", SyntaxError);
|
|
6090
6162
|
const textValue = normalizeStringExpression(parts);
|
|
6091
6163
|
if (textValue) {
|
|
@@ -6360,6 +6432,9 @@ var program_default = {
|
|
|
6360
6432
|
const paramsBinding = programExtra.binding;
|
|
6361
6433
|
if (paramsBinding && !paramsBinding.pruned) programExtra.domExports.params = getBindingPropTree(paramsBinding);
|
|
6362
6434
|
const section = programExtra.section;
|
|
6435
|
+
forEachSection((childSection) => {
|
|
6436
|
+
programExtra.hasResumes ||= !!(childSection.serializeReason || childSection.serializeReasons.size || childSection !== section && !isSectionRendererElided(childSection) && getSectionRegisterReasons(childSection));
|
|
6437
|
+
});
|
|
6363
6438
|
if (!section.hoistedTo && !sectionHasSetupStatements(section)) programExtra.domExports.setupEmpty = true;
|
|
6364
6439
|
}
|
|
6365
6440
|
},
|
|
@@ -6384,16 +6459,8 @@ var program_default = {
|
|
|
6384
6459
|
}
|
|
6385
6460
|
if (isDOMPageEntry) {
|
|
6386
6461
|
const entryFile = program.hub.file;
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
entry_builder_default.visit(entryFile, entryFile, function visitChild(resolved) {
|
|
6390
|
-
if (!visitedFiles.has(resolved)) {
|
|
6391
|
-
visitedFiles.add(resolved);
|
|
6392
|
-
const file = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
|
|
6393
|
-
if (file) entry_builder_default.visit(file, entryFile, (id) => visitChild(resolveRelativeToEntry(entryFile, file, id)));
|
|
6394
|
-
}
|
|
6395
|
-
});
|
|
6396
|
-
program.node.body = entry_builder_default.build(entryFile);
|
|
6462
|
+
builder.visit(entryFile, entryFile);
|
|
6463
|
+
program.node.body = builder.build(entryFile);
|
|
6397
6464
|
program.skip();
|
|
6398
6465
|
return;
|
|
6399
6466
|
}
|
|
@@ -6440,13 +6507,16 @@ var program_default = {
|
|
|
6440
6507
|
//#endregion
|
|
6441
6508
|
//#region src/translator/util/set-tag-sections-downstream.ts
|
|
6442
6509
|
const [getTagDownstreams] = createSectionState("tag-downstreams", () => /* @__PURE__ */ new Map());
|
|
6443
|
-
function setTagDownstream(tag, binding) {
|
|
6444
|
-
if (binding) getTagDownstreams(getSection(tag)).set(tag,
|
|
6510
|
+
function setTagDownstream(tag, binding, exprs) {
|
|
6511
|
+
if (binding) getTagDownstreams(getSection(tag)).set(tag, {
|
|
6512
|
+
binding,
|
|
6513
|
+
exprs
|
|
6514
|
+
});
|
|
6445
6515
|
}
|
|
6446
6516
|
function finalizeTagDownstreams(section) {
|
|
6447
|
-
for (const [tag, binding] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, binding);
|
|
6517
|
+
for (const [tag, { binding, exprs }] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, binding, exprs);
|
|
6448
6518
|
}
|
|
6449
|
-
function crawlSectionsAndSetBinding(tag, binding, properties, skip) {
|
|
6519
|
+
function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
|
|
6450
6520
|
if (!skip) {
|
|
6451
6521
|
const contentSection = getSectionForBody(tag.get("body"));
|
|
6452
6522
|
if (contentSection) {
|
|
@@ -6456,7 +6526,8 @@ function crawlSectionsAndSetBinding(tag, binding, properties, skip) {
|
|
|
6456
6526
|
});
|
|
6457
6527
|
contentSection.downstreamBinding = target && (target.noSerialize || includes(target.noSerializeProperties, "content")) ? false : {
|
|
6458
6528
|
binding,
|
|
6459
|
-
properties: concat(properties, "content")
|
|
6529
|
+
properties: concat(properties, "content"),
|
|
6530
|
+
exprs
|
|
6460
6531
|
};
|
|
6461
6532
|
}
|
|
6462
6533
|
}
|
|
@@ -6465,8 +6536,8 @@ function crawlSectionsAndSetBinding(tag, binding, properties, skip) {
|
|
|
6465
6536
|
const attrTags = getAttrTagPaths(tag);
|
|
6466
6537
|
for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
|
|
6467
6538
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
6468
|
-
crawlSectionsAndSetBinding(child, binding, concat(properties, attrTagMeta.name));
|
|
6469
|
-
} else crawlSectionsAndSetBinding(child, binding, properties, true);
|
|
6539
|
+
crawlSectionsAndSetBinding(child, binding, exprs, concat(properties, attrTagMeta.name));
|
|
6540
|
+
} else crawlSectionsAndSetBinding(child, binding, exprs, properties, true);
|
|
6470
6541
|
}
|
|
6471
6542
|
//#endregion
|
|
6472
6543
|
//#region src/translator/util/translate-var.ts
|
|
@@ -6533,10 +6604,10 @@ function knownTagAnalyze(tag, contentSection, propTree) {
|
|
|
6533
6604
|
startSection(tagBody);
|
|
6534
6605
|
trackParamsReferences(tagBody, 3);
|
|
6535
6606
|
getKnownTags(section).push(tagExtra);
|
|
6536
|
-
setTagDownstream(tag, propTree?.props?.[0]?.binding);
|
|
6537
6607
|
tagExtra[kContentSection] = contentSection;
|
|
6538
6608
|
const varBinding = trackVarReferences(tag, 5);
|
|
6539
6609
|
const exprs = tagExtra[kKnownExprs] = analyzeParams(tagExtra, section, tag, propTree, attrExprs);
|
|
6610
|
+
setTagDownstream(tag, propTree?.props?.[0]?.binding, exprs);
|
|
6540
6611
|
if (varBinding) {
|
|
6541
6612
|
addSetupStatement(section);
|
|
6542
6613
|
const mutatesTagVar = !!(tag.node.var.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
|
@@ -6652,7 +6723,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6652
6723
|
}
|
|
6653
6724
|
if (!propTree.props || propTree.rest || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
|
|
6654
6725
|
const extra = inputExpr.value = mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
|
6655
|
-
setBindingDownstream(propTree.binding, extra);
|
|
6726
|
+
setBindingDownstream(propTree.binding, extra, inputExpr);
|
|
6656
6727
|
return inputExpr;
|
|
6657
6728
|
}
|
|
6658
6729
|
const known = inputExpr.known = {};
|
|
@@ -6667,7 +6738,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6667
6738
|
i++;
|
|
6668
6739
|
}
|
|
6669
6740
|
const attrPropsTree = propTree.props[i];
|
|
6670
|
-
if (attrPropsTree) known[i] = analyzeAttrs(rootTagExtra, section, tag, attrPropsTree, rootAttrExprs);
|
|
6741
|
+
if (attrPropsTree) known[i] = analyzeAttrs(rootTagExtra, section, tag, attrPropsTree, rootAttrExprs, inputExpr);
|
|
6671
6742
|
else {
|
|
6672
6743
|
const args = tag.node.arguments;
|
|
6673
6744
|
tag.node.arguments = null;
|
|
@@ -6676,11 +6747,11 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6676
6747
|
}
|
|
6677
6748
|
return inputExpr;
|
|
6678
6749
|
}
|
|
6679
|
-
function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
6750
|
+
function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs, rootExprs) {
|
|
6680
6751
|
const inputExpr = {};
|
|
6681
6752
|
if (!propTree.props) {
|
|
6682
6753
|
const extra = inputExpr.value = mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
|
6683
|
-
setBindingDownstream(propTree.binding, extra);
|
|
6754
|
+
setBindingDownstream(propTree.binding, extra, rootExprs);
|
|
6684
6755
|
return inputExpr;
|
|
6685
6756
|
}
|
|
6686
6757
|
const known = inputExpr.known = {};
|
|
@@ -6712,7 +6783,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6712
6783
|
known[attrTagMeta.name] = { value: rootTagExtra };
|
|
6713
6784
|
} else if (childAttrExport.props) {
|
|
6714
6785
|
remaining.delete(attrTagMeta.name);
|
|
6715
|
-
known[attrTagMeta.name] = analyzeAttrs(rootTagExtra, section, child, childAttrExport, rootAttrExprs);
|
|
6786
|
+
known[attrTagMeta.name] = analyzeAttrs(rootTagExtra, section, child, childAttrExport, rootAttrExprs, rootExprs);
|
|
6716
6787
|
} else analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
|
|
6717
6788
|
} else {
|
|
6718
6789
|
const group = child.node.extra.attributeTagGroup;
|
|
@@ -6748,7 +6819,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6748
6819
|
const groupKnownValue = { value: groupExtra };
|
|
6749
6820
|
rootAttrExprs.add(groupExtra);
|
|
6750
6821
|
forEach(bindings, (binding) => {
|
|
6751
|
-
setBindingDownstream(binding, groupExtra);
|
|
6822
|
+
setBindingDownstream(binding, groupExtra, rootExprs);
|
|
6752
6823
|
});
|
|
6753
6824
|
for (const name of group) {
|
|
6754
6825
|
const attrTagMeta = attrTagLookup[name];
|
|
@@ -6791,7 +6862,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6791
6862
|
known[attr.name] = { value: attrExtra };
|
|
6792
6863
|
rootAttrExprs.add(attrExtra);
|
|
6793
6864
|
addSetupExpr(section, attr.value);
|
|
6794
|
-
setBindingDownstream(templateExportAttr.binding, attrExtra);
|
|
6865
|
+
setBindingDownstream(templateExportAttr.binding, attrExtra, rootExprs);
|
|
6795
6866
|
if (getRootSection(templateExportAttr.binding.section) !== (0, _marko_compiler_babel_utils.getProgram)().node.extra.section && isInvokeOnlyBinding(templateExportAttr.binding)) attrExtra.invokeOnly = true;
|
|
6796
6867
|
if (knownSpread && !includes(knownSpread.binding.excludeProperties, attr.name)) addRead(attrExtra, {}, getOrCreatePropertyAlias(knownSpread.binding, attr.name), section, void 0);
|
|
6797
6868
|
}
|
|
@@ -6809,16 +6880,16 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6809
6880
|
known[prop] = { value: propExtra };
|
|
6810
6881
|
rootAttrExprs.add(propExtra);
|
|
6811
6882
|
addRead(propExtra, propExtra, propBinding, section, void 0);
|
|
6812
|
-
setBindingDownstream(templateExportAttr === true ? propTree.rest.binding : templateExportAttr.binding, propExtra);
|
|
6883
|
+
setBindingDownstream(templateExportAttr === true ? propTree.rest.binding : templateExportAttr.binding, propExtra, rootExprs);
|
|
6813
6884
|
}
|
|
6814
6885
|
else if (spreadReferenceNodes) if (remaining.size || propTree.rest && !propTree.rest.props) {
|
|
6815
6886
|
inputExpr.value = mergeReferences(section, tag.node, spreadReferenceNodes);
|
|
6816
|
-
setBindingDownstream(propTree.rest?.binding || propTree.binding, inputExpr.value);
|
|
6887
|
+
setBindingDownstream(propTree.rest?.binding || propTree.binding, inputExpr.value, rootExprs);
|
|
6817
6888
|
} else dropNodes(spreadReferenceNodes);
|
|
6818
6889
|
else {
|
|
6819
6890
|
if (restReferenceNodes) {
|
|
6820
6891
|
inputExpr.value = mergeReferences(section, tag.node, restReferenceNodes);
|
|
6821
|
-
setBindingDownstream(propTree.rest.binding, inputExpr.value);
|
|
6892
|
+
setBindingDownstream(propTree.rest.binding, inputExpr.value, rootExprs);
|
|
6822
6893
|
}
|
|
6823
6894
|
if (remaining.size) addSetupStatement(section);
|
|
6824
6895
|
if (propTree.rest && !propTree.rest.props) addSetupExpr(section, tag.node);
|
|
@@ -7053,41 +7124,6 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7053
7124
|
if (propTree.rest && !propTree.rest.props) addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.objectExpression(restProps || [])])), true);
|
|
7054
7125
|
}
|
|
7055
7126
|
}
|
|
7056
|
-
function mapParamReasonToExpr(exprs, reason) {
|
|
7057
|
-
if (reason) {
|
|
7058
|
-
if (reason === true) return true;
|
|
7059
|
-
const result = /* @__PURE__ */ new Set();
|
|
7060
|
-
forEach(reason, (prop) => {
|
|
7061
|
-
forEach(mapParamBindingToExpr(exprs, prop), (expr) => {
|
|
7062
|
-
result.add(expr);
|
|
7063
|
-
});
|
|
7064
|
-
});
|
|
7065
|
-
return fromIter(result);
|
|
7066
|
-
}
|
|
7067
|
-
}
|
|
7068
|
-
function mapParamBindingToExpr(exprs, binding) {
|
|
7069
|
-
const isWholeAlias = binding.property === void 0 && binding.upstreamAlias !== void 0;
|
|
7070
|
-
const props = [];
|
|
7071
|
-
let curBinding = isWholeAlias ? binding.upstreamAlias : binding;
|
|
7072
|
-
while (curBinding && (curBinding.property !== void 0 || curBinding.upstreamAlias)) {
|
|
7073
|
-
if (curBinding.property !== void 0) props.push(curBinding.property);
|
|
7074
|
-
curBinding = curBinding.upstreamAlias;
|
|
7075
|
-
}
|
|
7076
|
-
let curExpr = exprs;
|
|
7077
|
-
for (let i = props.length; i--;) {
|
|
7078
|
-
const nestedExpr = curExpr.known?.[props[i]];
|
|
7079
|
-
if (!nestedExpr) return curExpr.value;
|
|
7080
|
-
curExpr = nestedExpr;
|
|
7081
|
-
}
|
|
7082
|
-
if (isWholeAlias) {
|
|
7083
|
-
let result = curExpr.value;
|
|
7084
|
-
if (curExpr.known) {
|
|
7085
|
-
for (const key in curExpr.known) if (!includes(binding.excludeProperties, key)) result = concat(result, curExpr.known[key].value);
|
|
7086
|
-
}
|
|
7087
|
-
return result;
|
|
7088
|
-
}
|
|
7089
|
-
return curExpr.value;
|
|
7090
|
-
}
|
|
7091
7127
|
function callStatement(id, ...args) {
|
|
7092
7128
|
return _marko_compiler.types.expressionStatement(callExpression(id, ...args));
|
|
7093
7129
|
}
|
|
@@ -7726,10 +7762,11 @@ function getCollapsibleIntersectionSource(intersection, section) {
|
|
|
7726
7762
|
const source = sources.state || sources.param;
|
|
7727
7763
|
return source && !Array.isArray(source) && source.section === section && !source.scopeOffset ? source : void 0;
|
|
7728
7764
|
}
|
|
7729
|
-
function setBindingDownstream(binding, expr) {
|
|
7765
|
+
function setBindingDownstream(binding, expr, exprs) {
|
|
7730
7766
|
getBindingValueExprs().set(binding, expr || false);
|
|
7731
7767
|
if (expr && expr !== true) forEach(expr, (expr) => {
|
|
7732
7768
|
expr.downstream = bindingUtil.add(expr.downstream, binding);
|
|
7769
|
+
if (exprs) expr.downstreamExprs = exprs;
|
|
7733
7770
|
});
|
|
7734
7771
|
}
|
|
7735
7772
|
const [getResolvedSources] = createProgramState(() => /* @__PURE__ */ new Set());
|
|
@@ -8297,7 +8334,12 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
8297
8334
|
else {
|
|
8298
8335
|
serializeReasonCache.set(extra, false);
|
|
8299
8336
|
forEach(extra.downstream, (binding) => {
|
|
8300
|
-
|
|
8337
|
+
let linked = getAllSerializeReasonsForBinding(binding, true);
|
|
8338
|
+
if (linked && linked !== true) {
|
|
8339
|
+
const exprs = extra.downstreamExprs;
|
|
8340
|
+
if (exprs) linked = mapDownstreamReason(binding.section.program, linked, exprs);
|
|
8341
|
+
}
|
|
8342
|
+
reason = mergeSerializeReasons(reason, linked);
|
|
8301
8343
|
});
|
|
8302
8344
|
}
|
|
8303
8345
|
if (reason) serializeReasonCache.set(extra, reason);
|
|
@@ -8379,6 +8421,41 @@ function setReadsOwner(from, to) {
|
|
|
8379
8421
|
cur = cur.parent;
|
|
8380
8422
|
}
|
|
8381
8423
|
}
|
|
8424
|
+
function mapParamReasonToExpr(exprs, reason) {
|
|
8425
|
+
if (reason) {
|
|
8426
|
+
if (reason === true) return true;
|
|
8427
|
+
const result = /* @__PURE__ */ new Set();
|
|
8428
|
+
forEach(reason, (prop) => {
|
|
8429
|
+
forEach(mapParamBindingToExpr(exprs, prop), (expr) => {
|
|
8430
|
+
result.add(expr);
|
|
8431
|
+
});
|
|
8432
|
+
});
|
|
8433
|
+
return fromIter(result);
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
function mapParamBindingToExpr(exprs, binding) {
|
|
8437
|
+
const isWholeAlias = binding.property === void 0 && binding.upstreamAlias !== void 0;
|
|
8438
|
+
const props = [];
|
|
8439
|
+
let curBinding = isWholeAlias ? binding.upstreamAlias : binding;
|
|
8440
|
+
while (curBinding && (curBinding.property !== void 0 || curBinding.upstreamAlias)) {
|
|
8441
|
+
if (curBinding.property !== void 0) props.push(curBinding.property);
|
|
8442
|
+
curBinding = curBinding.upstreamAlias;
|
|
8443
|
+
}
|
|
8444
|
+
let curExpr = exprs;
|
|
8445
|
+
for (let i = props.length; i--;) {
|
|
8446
|
+
const nestedExpr = curExpr.known?.[props[i]];
|
|
8447
|
+
if (!nestedExpr) return curExpr.value;
|
|
8448
|
+
curExpr = nestedExpr;
|
|
8449
|
+
}
|
|
8450
|
+
if (isWholeAlias) {
|
|
8451
|
+
let result = curExpr.value;
|
|
8452
|
+
if (curExpr.known) {
|
|
8453
|
+
for (const key in curExpr.known) if (!includes(binding.excludeProperties, key)) result = concat(result, curExpr.known[key].value);
|
|
8454
|
+
}
|
|
8455
|
+
return result;
|
|
8456
|
+
}
|
|
8457
|
+
return curExpr.value;
|
|
8458
|
+
}
|
|
8382
8459
|
//#endregion
|
|
8383
8460
|
//#region src/translator/core/await.ts
|
|
8384
8461
|
const kDOMBinding$2 = Symbol("await tag dom binding");
|
|
@@ -9805,7 +9882,10 @@ var import_declaration_default = {
|
|
|
9805
9882
|
}
|
|
9806
9883
|
(node.extra ??= {}).loadImport = loadImport;
|
|
9807
9884
|
const { file } = importDecl.hub;
|
|
9808
|
-
|
|
9885
|
+
const loadFile = tagImport && (0, _marko_compiler_babel_utils.loadFileForImport)(file, value);
|
|
9886
|
+
if (!loadFile) throw importDecl.buildCodeFrameError("Unable to resolve marko file for load import.");
|
|
9887
|
+
(file.path.node.extra.loadImports ??= /* @__PURE__ */ new Set()).add(loadFile.opts.filename);
|
|
9888
|
+
if (loadFile.ast.program.extra?.featureType === "class") throw importDecl.buildCodeFrameError(`The [\`load\` import attribute](https://markojs.com/docs/reference/lazy-loading) is not supported for the Marko 5 (class API) tag \`${value}\`. Import it without \`load\`, or migrate the tag to the tags API.`);
|
|
9809
9889
|
}
|
|
9810
9890
|
},
|
|
9811
9891
|
translate: { exit(importDecl) {
|
|
@@ -10127,9 +10207,14 @@ var referenced_identifier_default = {
|
|
|
10127
10207
|
const { name } = identifier.node;
|
|
10128
10208
|
if (identifier.scope.hasBinding(name)) return;
|
|
10129
10209
|
switch (name) {
|
|
10130
|
-
case "$global":
|
|
10131
|
-
if (
|
|
10210
|
+
case "$global": {
|
|
10211
|
+
if (isOutputHTML()) break;
|
|
10212
|
+
const globalRead = _marko_compiler.types.memberExpression(scopeIdentifier, _marko_compiler.types.identifier(getAccessorProp().Global));
|
|
10213
|
+
const key = !isOptimize() && getSignalGlobalKey(identifier);
|
|
10214
|
+
if (key) identifier.parentPath.replaceWith(callRuntime("_global_read", globalRead, _marko_compiler.types.stringLiteral(key)));
|
|
10215
|
+
else identifier.replaceWith(globalRead);
|
|
10132
10216
|
break;
|
|
10217
|
+
}
|
|
10133
10218
|
case "$signal": if (isOutputHTML()) identifier.replaceWith(_marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([_marko_compiler.types.throwStatement(_marko_compiler.types.newExpression(_marko_compiler.types.identifier("Error"), [_marko_compiler.types.stringLiteral("Cannot use $signal in a server render.")]))])), []));
|
|
10134
10219
|
else {
|
|
10135
10220
|
const section = getSection(identifier);
|
|
@@ -10145,6 +10230,13 @@ var referenced_identifier_default = {
|
|
|
10145
10230
|
}
|
|
10146
10231
|
}
|
|
10147
10232
|
};
|
|
10233
|
+
function getSignalGlobalKey(identifier) {
|
|
10234
|
+
const { parent } = identifier;
|
|
10235
|
+
if (!_marko_compiler.types.isMemberExpression(parent) || parent.computed || !_marko_compiler.types.isIdentifier(parent.property) || parent.object !== identifier.node) return;
|
|
10236
|
+
const { name } = parent.property;
|
|
10237
|
+
if (name === "runtimeId" || name === "renderId") return;
|
|
10238
|
+
return getExprRoot(identifier).node.extra?.referencedBindings ? name : void 0;
|
|
10239
|
+
}
|
|
10148
10240
|
//#endregion
|
|
10149
10241
|
//#region src/translator/visitors/scriptlet.ts
|
|
10150
10242
|
var scriptlet_default = {
|
|
@@ -10155,7 +10247,7 @@ var scriptlet_default = {
|
|
|
10155
10247
|
return;
|
|
10156
10248
|
}
|
|
10157
10249
|
mergeReferences(getOrCreateSection(scriptlet), scriptlet.node, scriptlet.node.body);
|
|
10158
|
-
if (scriptlet.node.target === "client") (0, _marko_compiler_babel_utils.getProgram)().node.extra.
|
|
10250
|
+
if (scriptlet.node.target === "client") (0, _marko_compiler_babel_utils.getProgram)().node.extra.hasClientStatement = true;
|
|
10159
10251
|
},
|
|
10160
10252
|
translate: { exit(scriptlet) {
|
|
10161
10253
|
const { node } = scriptlet;
|
|
@@ -10317,10 +10409,18 @@ function getTagRelativePath(tag) {
|
|
|
10317
10409
|
if (!relativePath) throw tagNotFoundError(tag);
|
|
10318
10410
|
return relativePath;
|
|
10319
10411
|
}
|
|
10412
|
+
const staticHint = "To declare module level JavaScript, prefix the statement with `static`.";
|
|
10320
10413
|
const knownWrongTags = /* @__PURE__ */ new Map([
|
|
10321
10414
|
["slot", "To render content passed to this tag, use a [dynamic tag](https://markojs.com/docs/reference/language#dynamic-tags): `<${input.content}/>`."],
|
|
10322
10415
|
["state", "Reactive state is declared with the [`<let>` tag](https://markojs.com/docs/reference/core-tag#let): `<let/name=initialValue>`."],
|
|
10323
|
-
["fragment", "Marko templates and tag bodies may have multiple root nodes; no fragment wrapper is needed."]
|
|
10416
|
+
["fragment", "Marko templates and tag bodies may have multiple root nodes; no fragment wrapper is needed."],
|
|
10417
|
+
["async", staticHint],
|
|
10418
|
+
["class", staticHint],
|
|
10419
|
+
["declare", staticHint],
|
|
10420
|
+
["enum", staticHint],
|
|
10421
|
+
["function", staticHint],
|
|
10422
|
+
["interface", staticHint],
|
|
10423
|
+
["type", staticHint]
|
|
10324
10424
|
]);
|
|
10325
10425
|
function tagNotFoundError(tag) {
|
|
10326
10426
|
const tagName = getTagName(tag);
|
|
@@ -10334,7 +10434,7 @@ function tagNotFoundError(tag) {
|
|
|
10334
10434
|
const closestTag = (0, fastest_levenshtein.closest)(tagName, Object.keys((0, _marko_compiler_babel_utils.getTaglibLookup)(tag.hub.file).merged.tags));
|
|
10335
10435
|
if ((0, fastest_levenshtein.distance)(tagName, closestTag) < 4) didYouMean = ` Did you mean \`<${closestTag}>\`?`;
|
|
10336
10436
|
}
|
|
10337
|
-
return tag.get("name").buildCodeFrameError(`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.${didYouMean}`);
|
|
10437
|
+
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}`);
|
|
10338
10438
|
}
|
|
10339
10439
|
const wordReg = /^[A-Za-z]+$/;
|
|
10340
10440
|
function getProseText(tag) {
|
|
@@ -10403,6 +10503,7 @@ function pushCompatRegistration(key, statement) {
|
|
|
10403
10503
|
}
|
|
10404
10504
|
var dynamic_tag_default = {
|
|
10405
10505
|
analyze: { enter(tag) {
|
|
10506
|
+
if (tag.node.extra?.tagNameUnresolved) throw tagNotFoundError(tag);
|
|
10406
10507
|
(0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
|
|
10407
10508
|
const { node } = tag;
|
|
10408
10509
|
const definedBodySection = node.extra?.defineBodySection;
|
|
@@ -10701,7 +10802,7 @@ var text_default = {
|
|
|
10701
10802
|
function buildAggregateError(file, rootMsg, ...paths) {
|
|
10702
10803
|
const err = /* @__PURE__ */ new SyntaxError();
|
|
10703
10804
|
const fileName = path.default.relative(_marko_compiler_modules.cwd, file.opts.filename);
|
|
10704
|
-
const finalMsg = `${rootMsg}:\n\n${paths.map(([msg, path$
|
|
10805
|
+
const finalMsg = `${rootMsg}:\n\n${paths.map(([msg, path$13]) => `\x1b[90m${msg} at ${getFileNameWithLoc(fileName, path$13)}:\x1b[0m\n${getFrame(file, path$13)}`).join("\n\n")}`;
|
|
10705
10806
|
if (!("MARKO_DEBUG" in process.env)) err.stack = finalMsg;
|
|
10706
10807
|
Object.defineProperty(err, "message", {
|
|
10707
10808
|
get() {
|
|
@@ -10865,24 +10966,30 @@ function createInteropTranslator(translate5) {
|
|
|
10865
10966
|
})));
|
|
10866
10967
|
};
|
|
10867
10968
|
return [
|
|
10868
|
-
|
|
10969
|
+
...state.needsCompat ? [_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(getCompatRuntimeFile()))] : [],
|
|
10970
|
+
...Array.from(state.compatFiles, (compatFile) => _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(compatFile))),
|
|
10971
|
+
importHydrateProgram("6", builder.build(entryFile, true)),
|
|
10869
10972
|
importHydrateProgram("5", translate5.internalEntryBuilder.build(entryFile, true)),
|
|
10870
10973
|
_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init6"), [])),
|
|
10871
10974
|
_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init5"), []))
|
|
10872
10975
|
];
|
|
10873
10976
|
} else return translate5.internalEntryBuilder.build(entryFile);
|
|
10874
|
-
else return
|
|
10977
|
+
else return builder.build(entryFile);
|
|
10875
10978
|
},
|
|
10876
10979
|
visit(file, entryFile, visitChild) {
|
|
10877
10980
|
const state = entryFile[kState] ||= {
|
|
10878
10981
|
has5: false,
|
|
10879
|
-
has6: false
|
|
10982
|
+
has6: false,
|
|
10983
|
+
needsCompat: false,
|
|
10984
|
+
compatFiles: /* @__PURE__ */ new Set()
|
|
10880
10985
|
};
|
|
10881
10986
|
if (isTagsAPI(file)) {
|
|
10882
10987
|
state.has6 = true;
|
|
10883
|
-
|
|
10988
|
+
builder.visit(file, entryFile, visitChild);
|
|
10884
10989
|
} else {
|
|
10885
10990
|
state.has5 = true;
|
|
10991
|
+
if (file.path.node.extra?.resumesCompat) state.needsCompat = true;
|
|
10992
|
+
if (file.path.node.extra?.resumesClassFns) state.compatFiles.add((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, file.opts.filename));
|
|
10886
10993
|
translate5.internalEntryBuilder.visit(file, entryFile, visitChild);
|
|
10887
10994
|
}
|
|
10888
10995
|
}
|
|
@@ -10895,13 +11002,13 @@ function createInteropTranslator(translate5) {
|
|
|
10895
11002
|
const entryFile = program.hub.file;
|
|
10896
11003
|
const { output, entry } = entryFile.markoOpts;
|
|
10897
11004
|
if (!(output === "dom" && entry === "page" || output === "hydrate")) return enterProgram?.call(this, program, state);
|
|
10898
|
-
const visitedFiles = /* @__PURE__ */ new
|
|
10899
|
-
entryBuilder.visit(entryFile, entryFile, function visitChild(resolved) {
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
11005
|
+
const visitedFiles = /* @__PURE__ */ new Map([[(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename), false]]);
|
|
11006
|
+
entryBuilder.visit(entryFile, entryFile, function visitChild(resolved, bundled = false) {
|
|
11007
|
+
const seenBundled = visitedFiles.get(resolved);
|
|
11008
|
+
if (seenBundled === false || seenBundled && bundled) return;
|
|
11009
|
+
visitedFiles.set(resolved, bundled);
|
|
11010
|
+
const file = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
|
|
11011
|
+
if (file) entryBuilder.visit(file, entryFile, (id, childBundled = false) => visitChild(resolveRelativeToEntry(entryFile, file, id), childBundled || bundled));
|
|
10905
11012
|
});
|
|
10906
11013
|
program.node.body = entryBuilder.build(entryFile);
|
|
10907
11014
|
program.skip();
|
|
@@ -10917,13 +11024,13 @@ function mergeVisitors(visitor5, visitor6) {
|
|
|
10917
11024
|
function mergeVisit(visit5, visit6) {
|
|
10918
11025
|
const enter5 = getVisitorEnter(visit5);
|
|
10919
11026
|
const enter6 = getVisitorEnter(visit6);
|
|
10920
|
-
const enter = (enter5 || enter6) && function enter(path$
|
|
10921
|
-
return (isTagsAPI() ? enter6 : enter5)?.call(this, path$
|
|
11027
|
+
const enter = (enter5 || enter6) && function enter(path$9, state) {
|
|
11028
|
+
return (isTagsAPI() ? enter6 : enter5)?.call(this, path$9, state);
|
|
10922
11029
|
};
|
|
10923
11030
|
const exit5 = getVisitorExit(visit5);
|
|
10924
11031
|
const exit6 = getVisitorExit(visit6);
|
|
10925
|
-
const exit = (exit5 || exit6) && function exit(path$
|
|
10926
|
-
return (isTagsAPI() ? exit6 : exit5)?.call(this, path$
|
|
11032
|
+
const exit = (exit5 || exit6) && function exit(path$10, state) {
|
|
11033
|
+
return (isTagsAPI() ? exit6 : exit5)?.call(this, path$10, state);
|
|
10927
11034
|
};
|
|
10928
11035
|
return exit ? enter ? {
|
|
10929
11036
|
enter,
|
|
@@ -11006,17 +11113,17 @@ function sequenceVisit(first, second) {
|
|
|
11006
11113
|
if (!first || !second) return first || second;
|
|
11007
11114
|
const enterFirst = getVisitorEnter(first);
|
|
11008
11115
|
const enterSecond = getVisitorEnter(second);
|
|
11009
|
-
const enter = (enterFirst || enterSecond) && function enter(path$
|
|
11010
|
-
const { node } = path$
|
|
11011
|
-
enterFirst?.call(this, path$
|
|
11012
|
-
if (path$
|
|
11116
|
+
const enter = (enterFirst || enterSecond) && function enter(path$11, state) {
|
|
11117
|
+
const { node } = path$11;
|
|
11118
|
+
enterFirst?.call(this, path$11, state);
|
|
11119
|
+
if (path$11.node === node) enterSecond?.call(this, path$11, state);
|
|
11013
11120
|
};
|
|
11014
11121
|
const exitFirst = getVisitorExit(first);
|
|
11015
11122
|
const exitSecond = getVisitorExit(second);
|
|
11016
|
-
const exit = (exitFirst || exitSecond) && function exit(path$
|
|
11017
|
-
const { node } = path$
|
|
11018
|
-
exitFirst?.call(this, path$
|
|
11019
|
-
if (path$
|
|
11123
|
+
const exit = (exitFirst || exitSecond) && function exit(path$12, state) {
|
|
11124
|
+
const { node } = path$12;
|
|
11125
|
+
exitFirst?.call(this, path$12, state);
|
|
11126
|
+
if (path$12.node === node) exitSecond?.call(this, path$12, state);
|
|
11020
11127
|
};
|
|
11021
11128
|
return exit ? enter ? {
|
|
11022
11129
|
enter,
|
|
@@ -11064,7 +11171,7 @@ exports.analyze = analyze;
|
|
|
11064
11171
|
exports.cheatsheet = cheatsheet;
|
|
11065
11172
|
exports.createInteropTranslator = createInteropTranslator;
|
|
11066
11173
|
exports.getRuntimeEntryFiles = getRuntimeEntryFiles;
|
|
11067
|
-
exports.internalEntryBuilder =
|
|
11174
|
+
exports.internalEntryBuilder = builder;
|
|
11068
11175
|
exports.preferAPI = preferAPI;
|
|
11069
11176
|
exports.tagDiscoveryDirs = tagDiscoveryDirs;
|
|
11070
11177
|
exports.taglibs = taglibs;
|