marko 6.0.121 → 6.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug/html.js +7 -7
- package/dist/debug/html.mjs +7 -7
- package/dist/html/compat.d.ts +2 -3
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html.js +7 -7
- package/dist/html.mjs +7 -7
- package/dist/translator/core/client.d.ts +2 -13
- package/dist/translator/core/index.d.ts +3 -36
- package/dist/translator/core/server.d.ts +2 -13
- package/dist/translator/core/static.d.ts +2 -13
- package/dist/translator/index.d.ts +4 -36
- package/dist/translator/index.js +629 -124
- package/dist/translator/interop/build-aggregate-error.d.ts +2 -0
- package/dist/translator/interop/feature-detection.d.ts +2 -0
- package/dist/translator/interop/index.d.ts +12 -0
- package/package.json +2 -2
package/dist/translator/index.js
CHANGED
|
@@ -30,14 +30,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/translator/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
analyze: () =>
|
|
34
|
-
|
|
33
|
+
analyze: () => analyze2,
|
|
34
|
+
createInteropTranslator: () => createInteropTranslator,
|
|
35
|
+
getRuntimeEntryFiles: () => getRuntimeEntryFiles2,
|
|
35
36
|
internalEntryBuilder: () => entry_builder_default,
|
|
36
37
|
preferAPI: () => preferAPI,
|
|
37
|
-
tagDiscoveryDirs: () =>
|
|
38
|
-
taglibs: () =>
|
|
39
|
-
transform: () =>
|
|
40
|
-
translate: () =>
|
|
38
|
+
tagDiscoveryDirs: () => tagDiscoveryDirs2,
|
|
39
|
+
taglibs: () => taglibs2,
|
|
40
|
+
transform: () => transform2,
|
|
41
|
+
translate: () => translate2
|
|
41
42
|
});
|
|
42
43
|
module.exports = __toCommonJS(index_exports);
|
|
43
44
|
|
|
@@ -747,22 +748,22 @@ function getAttributeTagParent(tag) {
|
|
|
747
748
|
}
|
|
748
749
|
|
|
749
750
|
// src/translator/util/get-root.ts
|
|
750
|
-
function getMarkoRoot(
|
|
751
|
-
let curPath =
|
|
751
|
+
function getMarkoRoot(path7) {
|
|
752
|
+
let curPath = path7;
|
|
752
753
|
do
|
|
753
754
|
curPath = curPath.parentPath;
|
|
754
755
|
while (curPath && !isMarko(curPath));
|
|
755
756
|
return curPath;
|
|
756
757
|
}
|
|
757
|
-
function getExprRoot(
|
|
758
|
-
let curPath =
|
|
758
|
+
function getExprRoot(path7) {
|
|
759
|
+
let curPath = path7;
|
|
759
760
|
while (!isMarko(curPath.parentPath)) {
|
|
760
761
|
curPath = curPath.parentPath;
|
|
761
762
|
}
|
|
762
763
|
return curPath;
|
|
763
764
|
}
|
|
764
|
-
function getFnRoot(
|
|
765
|
-
let curPath =
|
|
765
|
+
function getFnRoot(path7) {
|
|
766
|
+
let curPath = path7;
|
|
766
767
|
let fnPath;
|
|
767
768
|
while (!isMarko(curPath)) {
|
|
768
769
|
if (isFunction(curPath)) {
|
|
@@ -785,8 +786,8 @@ function getFnRoot(path5) {
|
|
|
785
786
|
}
|
|
786
787
|
return fnPath;
|
|
787
788
|
}
|
|
788
|
-
function getFnParent(
|
|
789
|
-
let curPath =
|
|
789
|
+
function getFnParent(path7) {
|
|
790
|
+
let curPath = path7;
|
|
790
791
|
while (!isMarko(curPath)) {
|
|
791
792
|
if (isFunction(curPath)) {
|
|
792
793
|
return curPath;
|
|
@@ -799,8 +800,8 @@ function getFnParent(path5) {
|
|
|
799
800
|
}
|
|
800
801
|
}
|
|
801
802
|
}
|
|
802
|
-
function getDeclarationRoot(
|
|
803
|
-
let curPath =
|
|
803
|
+
function getDeclarationRoot(path7) {
|
|
804
|
+
let curPath = path7;
|
|
804
805
|
let declPath;
|
|
805
806
|
while (!isMarko(curPath)) {
|
|
806
807
|
if (isFunctionOrVariableDeclaration(curPath)) {
|
|
@@ -815,8 +816,8 @@ function getDeclarationRoot(path5) {
|
|
|
815
816
|
}
|
|
816
817
|
return declPath;
|
|
817
818
|
}
|
|
818
|
-
function isMarko(
|
|
819
|
-
switch (
|
|
819
|
+
function isMarko(path7) {
|
|
820
|
+
switch (path7.type) {
|
|
820
821
|
case "MarkoTag":
|
|
821
822
|
case "MarkoTagBody":
|
|
822
823
|
case "MarkoAttribute":
|
|
@@ -830,10 +831,10 @@ function isMarko(path5) {
|
|
|
830
831
|
return false;
|
|
831
832
|
}
|
|
832
833
|
}
|
|
833
|
-
function isFunction(
|
|
834
|
-
switch (
|
|
834
|
+
function isFunction(path7) {
|
|
835
|
+
switch (path7.type) {
|
|
835
836
|
case "FunctionDeclaration":
|
|
836
|
-
return !
|
|
837
|
+
return !path7.node.declare;
|
|
837
838
|
case "FunctionExpression":
|
|
838
839
|
case "ArrowFunctionExpression":
|
|
839
840
|
case "ObjectMethod":
|
|
@@ -842,10 +843,10 @@ function isFunction(path5) {
|
|
|
842
843
|
return false;
|
|
843
844
|
}
|
|
844
845
|
}
|
|
845
|
-
function isFunctionOrVariableDeclaration(
|
|
846
|
-
switch (
|
|
846
|
+
function isFunctionOrVariableDeclaration(path7) {
|
|
847
|
+
switch (path7.type) {
|
|
847
848
|
case "FunctionDeclaration":
|
|
848
|
-
return !
|
|
849
|
+
return !path7.node.declare;
|
|
849
850
|
case "VariableDeclaration":
|
|
850
851
|
return true;
|
|
851
852
|
default:
|
|
@@ -873,14 +874,12 @@ function getTagName(tag) {
|
|
|
873
874
|
// src/translator/util/is-core-tag.ts
|
|
874
875
|
var { taglibId } = runtime_info_default;
|
|
875
876
|
var htmlTaglibId = "marko-html";
|
|
876
|
-
var interopTaglibId = "@marko/translator-interop-class-tags";
|
|
877
877
|
function isCoreTag(tag) {
|
|
878
878
|
if (tag.isMarkoTag()) {
|
|
879
879
|
const tagDef = (0, import_babel_utils6.getTagDef)(tag);
|
|
880
880
|
if (tagDef) {
|
|
881
881
|
switch (tagDef.taglibId) {
|
|
882
882
|
case taglibId:
|
|
883
|
-
case interopTaglibId:
|
|
884
883
|
return true;
|
|
885
884
|
case htmlTaglibId:
|
|
886
885
|
switch (tagDef.name) {
|
|
@@ -1635,37 +1634,37 @@ function analyzeTagNameType(tag, allowDynamic) {
|
|
|
1635
1634
|
}
|
|
1636
1635
|
function analyzeExpressionTagName(name2, extra) {
|
|
1637
1636
|
const pending = [name2];
|
|
1638
|
-
let
|
|
1637
|
+
let path7;
|
|
1639
1638
|
let type;
|
|
1640
1639
|
let nullable = false;
|
|
1641
1640
|
let tagNameImported;
|
|
1642
|
-
while ((
|
|
1643
|
-
if (
|
|
1644
|
-
pending.push(
|
|
1645
|
-
if (
|
|
1646
|
-
pending.push(
|
|
1647
|
-
}
|
|
1648
|
-
} else if (
|
|
1649
|
-
if (
|
|
1650
|
-
pending.push(
|
|
1641
|
+
while ((path7 = pending.pop()) && type !== 2 /* DynamicTag */) {
|
|
1642
|
+
if (path7.isConditionalExpression()) {
|
|
1643
|
+
pending.push(path7.get("consequent"));
|
|
1644
|
+
if (path7.node.alternate) {
|
|
1645
|
+
pending.push(path7.get("alternate"));
|
|
1646
|
+
}
|
|
1647
|
+
} else if (path7.isLogicalExpression()) {
|
|
1648
|
+
if (path7.node.operator === "||") {
|
|
1649
|
+
pending.push(path7.get("left"));
|
|
1651
1650
|
} else {
|
|
1652
1651
|
nullable = true;
|
|
1653
1652
|
}
|
|
1654
|
-
pending.push(
|
|
1655
|
-
} else if (
|
|
1656
|
-
pending.push(
|
|
1657
|
-
} else if (
|
|
1658
|
-
type =
|
|
1659
|
-
} else if (
|
|
1653
|
+
pending.push(path7.get("right"));
|
|
1654
|
+
} else if (path7.isAssignmentExpression()) {
|
|
1655
|
+
pending.push(path7.get("right"));
|
|
1656
|
+
} else if (path7.isBinaryExpression()) {
|
|
1657
|
+
type = path7.node.operator !== "+" || type === void 0 || type === 0 /* NativeTag */ ? 0 /* NativeTag */ : 2 /* DynamicTag */;
|
|
1658
|
+
} else if (path7.isStringLiteral() || path7.isTemplateLiteral()) {
|
|
1660
1659
|
type = type === void 0 || type === 0 /* NativeTag */ ? 0 /* NativeTag */ : 2 /* DynamicTag */;
|
|
1661
|
-
} else if (
|
|
1660
|
+
} else if (path7.isNullLiteral()) {
|
|
1662
1661
|
nullable = true;
|
|
1663
|
-
} else if (
|
|
1664
|
-
if (
|
|
1662
|
+
} else if (path7.isIdentifier()) {
|
|
1663
|
+
if (path7.node.name === "undefined") {
|
|
1665
1664
|
nullable = true;
|
|
1666
1665
|
continue;
|
|
1667
1666
|
}
|
|
1668
|
-
const binding =
|
|
1667
|
+
const binding = path7.scope.getBinding(path7.node.name);
|
|
1669
1668
|
if (!binding) {
|
|
1670
1669
|
type = 2 /* DynamicTag */;
|
|
1671
1670
|
continue;
|
|
@@ -1719,16 +1718,16 @@ function analyzeExpressionTagName(name2, extra) {
|
|
|
1719
1718
|
var sectionUtil = new Sorted(function compareSections(a, b) {
|
|
1720
1719
|
return a.id - b.id;
|
|
1721
1720
|
});
|
|
1722
|
-
function startSection(
|
|
1723
|
-
const extra =
|
|
1721
|
+
function startSection(path7) {
|
|
1722
|
+
const extra = path7.node.extra ??= {};
|
|
1724
1723
|
let section = extra.section;
|
|
1725
|
-
if (!section && (
|
|
1726
|
-
const parentTag =
|
|
1727
|
-
const parentSection =
|
|
1724
|
+
if (!section && (path7.type === "Program" || path7.get("body").length)) {
|
|
1725
|
+
const parentTag = path7.parentPath?.isMarkoTag() ? path7.parentPath : void 0;
|
|
1726
|
+
const parentSection = path7.parentPath ? getOrCreateSection(path7.parentPath) : void 0;
|
|
1728
1727
|
const sectionName = parentTag ? generateUid(
|
|
1729
1728
|
(isCoreTagName(parentTag, "define") && import_compiler7.types.isIdentifier(parentTag.node.var) ? parentTag.node.var.name : parentTag.get("name").toString()) + "_content"
|
|
1730
1729
|
) : "";
|
|
1731
|
-
const programExtra =
|
|
1730
|
+
const programExtra = path7.hub.file.path.node.extra ??= {};
|
|
1732
1731
|
const sections = programExtra.sections ??= [];
|
|
1733
1732
|
section = extra.section = {
|
|
1734
1733
|
id: sections.length,
|
|
@@ -1750,7 +1749,7 @@ function startSection(path5) {
|
|
|
1750
1749
|
serializeReasons: /* @__PURE__ */ new Map(),
|
|
1751
1750
|
paramReasonGroups: void 0,
|
|
1752
1751
|
returnSerializeReason: void 0,
|
|
1753
|
-
content: getContentInfo(
|
|
1752
|
+
content: getContentInfo(path7),
|
|
1754
1753
|
upstreamExpression: void 0,
|
|
1755
1754
|
downstreamBinding: void 0,
|
|
1756
1755
|
hasAbortSignal: false,
|
|
@@ -1760,11 +1759,11 @@ function startSection(path5) {
|
|
|
1760
1759
|
}
|
|
1761
1760
|
return section;
|
|
1762
1761
|
}
|
|
1763
|
-
function getOrCreateSection(
|
|
1764
|
-
let cur =
|
|
1762
|
+
function getOrCreateSection(path7) {
|
|
1763
|
+
let cur = path7;
|
|
1765
1764
|
while (true) {
|
|
1766
1765
|
if (cur.type === "Program" || cur.type === "MarkoTagBody" && !cur.node.attributeTags && !isNativeNode(cur.parentPath)) {
|
|
1767
|
-
return (
|
|
1766
|
+
return (path7.node.extra ??= {}).section = startSection(cur);
|
|
1768
1767
|
}
|
|
1769
1768
|
cur = cur.parentPath;
|
|
1770
1769
|
}
|
|
@@ -1772,9 +1771,9 @@ function getOrCreateSection(path5) {
|
|
|
1772
1771
|
function getSectionForBody(body) {
|
|
1773
1772
|
return body.node.extra?.section;
|
|
1774
1773
|
}
|
|
1775
|
-
function getSection(
|
|
1774
|
+
function getSection(path7) {
|
|
1776
1775
|
let section;
|
|
1777
|
-
let currentPath =
|
|
1776
|
+
let currentPath = path7;
|
|
1778
1777
|
while ((section = currentPath.node.extra?.section) === void 0) {
|
|
1779
1778
|
currentPath = currentPath.parentPath;
|
|
1780
1779
|
}
|
|
@@ -1800,8 +1799,8 @@ function forEachSectionReverse(fn) {
|
|
|
1800
1799
|
fn(sections[i]);
|
|
1801
1800
|
}
|
|
1802
1801
|
}
|
|
1803
|
-
function getContentInfo(
|
|
1804
|
-
const body =
|
|
1802
|
+
function getContentInfo(path7) {
|
|
1803
|
+
const body = path7.get("body");
|
|
1805
1804
|
const contentInfo = {
|
|
1806
1805
|
startType: null,
|
|
1807
1806
|
endType: null,
|
|
@@ -1828,8 +1827,8 @@ function getContentInfo(path5) {
|
|
|
1828
1827
|
}
|
|
1829
1828
|
return null;
|
|
1830
1829
|
}
|
|
1831
|
-
function getNodeContentType(
|
|
1832
|
-
switch (
|
|
1830
|
+
function getNodeContentType(path7, extraMember, contentInfo) {
|
|
1831
|
+
switch (path7.type) {
|
|
1833
1832
|
case "MarkoText":
|
|
1834
1833
|
return 4 /* Text */;
|
|
1835
1834
|
case "MarkoPlaceholder":
|
|
@@ -1842,7 +1841,7 @@ function getNodeContentType(path5, extraMember, contentInfo) {
|
|
|
1842
1841
|
case "ExportDefaultDeclaration":
|
|
1843
1842
|
return null;
|
|
1844
1843
|
case "MarkoTag": {
|
|
1845
|
-
const tag =
|
|
1844
|
+
const tag = path7;
|
|
1846
1845
|
if (isCoreTag(tag)) {
|
|
1847
1846
|
switch (tag.node.name.value) {
|
|
1848
1847
|
case "html-comment":
|
|
@@ -2064,8 +2063,8 @@ function canIgnoreRegister(markoRoot, exprRoot) {
|
|
|
2064
2063
|
/^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))
|
|
2065
2064
|
);
|
|
2066
2065
|
}
|
|
2067
|
-
function getStaticDeclRefs(fnExtra,
|
|
2068
|
-
const decl = getDeclarationRoot(
|
|
2066
|
+
function getStaticDeclRefs(fnExtra, path7, refs = /* @__PURE__ */ new Set()) {
|
|
2067
|
+
const decl = getDeclarationRoot(path7);
|
|
2069
2068
|
if (decl) {
|
|
2070
2069
|
const ids = decl.getOuterBindingIdentifiers();
|
|
2071
2070
|
if (ids) {
|
|
@@ -2132,13 +2131,13 @@ function registerFunction(fnExtra, reason) {
|
|
|
2132
2131
|
`${fnExtra.section.id}/${fnExtra.name.slice(1)}`
|
|
2133
2132
|
);
|
|
2134
2133
|
}
|
|
2135
|
-
function isMarkoAttribute(
|
|
2136
|
-
return
|
|
2134
|
+
function isMarkoAttribute(path7) {
|
|
2135
|
+
return path7 ? path7.isMarkoAttribute() : false;
|
|
2137
2136
|
}
|
|
2138
|
-
function isStaticRoot(
|
|
2139
|
-
switch (
|
|
2137
|
+
function isStaticRoot(path7) {
|
|
2138
|
+
switch (path7.type) {
|
|
2140
2139
|
case "MarkoScriptlet":
|
|
2141
|
-
return
|
|
2140
|
+
return path7.node.static;
|
|
2142
2141
|
case "ExportDefaultDeclaration":
|
|
2143
2142
|
case "ExportNamedDeclaration":
|
|
2144
2143
|
return true;
|
|
@@ -2340,11 +2339,12 @@ var entry_builder_default = {
|
|
|
2340
2339
|
imports: [],
|
|
2341
2340
|
init: false
|
|
2342
2341
|
};
|
|
2342
|
+
const programExtra = file.path.node.extra;
|
|
2343
2343
|
const { analyzedTags } = file.metadata.marko;
|
|
2344
2344
|
state.imports.push(
|
|
2345
2345
|
(0, import_babel_utils12.resolveRelativePath)(entryFile, file.opts.filename)
|
|
2346
2346
|
);
|
|
2347
|
-
if (
|
|
2347
|
+
if (programExtra.isInteractive || programExtra.needsCompat) {
|
|
2348
2348
|
state.init = true;
|
|
2349
2349
|
}
|
|
2350
2350
|
for (const tag of analyzedTags || []) {
|
|
@@ -2663,29 +2663,29 @@ var import_babel_utils14 = require("@marko/compiler/babel-utils");
|
|
|
2663
2663
|
|
|
2664
2664
|
// src/translator/util/plugin-hooks.ts
|
|
2665
2665
|
var import_compiler12 = require("@marko/compiler");
|
|
2666
|
-
function enter(modulePlugin,
|
|
2666
|
+
function enter(modulePlugin, path7) {
|
|
2667
2667
|
if (!modulePlugin) {
|
|
2668
2668
|
return false;
|
|
2669
2669
|
}
|
|
2670
|
-
const { node } =
|
|
2670
|
+
const { node } = path7;
|
|
2671
2671
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
|
2672
2672
|
if (isFunctionPlugin(plugin)) {
|
|
2673
|
-
plugin(
|
|
2673
|
+
plugin(path7, import_compiler12.types);
|
|
2674
2674
|
} else if (plugin.enter) {
|
|
2675
|
-
plugin.enter(
|
|
2675
|
+
plugin.enter(path7, import_compiler12.types);
|
|
2676
2676
|
}
|
|
2677
|
-
return node !==
|
|
2677
|
+
return node !== path7.node;
|
|
2678
2678
|
}
|
|
2679
|
-
function exit(modulePlugin,
|
|
2679
|
+
function exit(modulePlugin, path7) {
|
|
2680
2680
|
if (!modulePlugin) {
|
|
2681
2681
|
return false;
|
|
2682
2682
|
}
|
|
2683
|
-
const { node } =
|
|
2683
|
+
const { node } = path7;
|
|
2684
2684
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
|
2685
2685
|
if (!isFunctionPlugin(plugin) && plugin.exit) {
|
|
2686
|
-
plugin.exit(
|
|
2686
|
+
plugin.exit(path7, import_compiler12.types);
|
|
2687
2687
|
}
|
|
2688
|
-
return node !==
|
|
2688
|
+
return node !== path7.node;
|
|
2689
2689
|
}
|
|
2690
2690
|
function isModulePlugin(plugin) {
|
|
2691
2691
|
return Boolean(plugin.default);
|
|
@@ -2717,11 +2717,11 @@ function translateByTarget({
|
|
|
2717
2717
|
dom
|
|
2718
2718
|
}) {
|
|
2719
2719
|
return {
|
|
2720
|
-
enter(
|
|
2721
|
-
enter(isOutputHTML() ? html : dom,
|
|
2720
|
+
enter(path7) {
|
|
2721
|
+
enter(isOutputHTML() ? html : dom, path7);
|
|
2722
2722
|
},
|
|
2723
|
-
exit(
|
|
2724
|
-
exit(isOutputHTML() ? html : dom,
|
|
2723
|
+
exit(path7) {
|
|
2724
|
+
exit(isOutputHTML() ? html : dom, path7);
|
|
2725
2725
|
}
|
|
2726
2726
|
};
|
|
2727
2727
|
}
|
|
@@ -2896,16 +2896,16 @@ var walkCodeToName = {
|
|
|
2896
2896
|
[116 /* OutEnd */]: "outEnd",
|
|
2897
2897
|
[126 /* MultiplierEnd */]: "multiplierEnd"
|
|
2898
2898
|
};
|
|
2899
|
-
function enter2(
|
|
2900
|
-
const steps = getSteps(getSection(
|
|
2899
|
+
function enter2(path7) {
|
|
2900
|
+
const steps = getSteps(getSection(path7));
|
|
2901
2901
|
steps.push(0 /* Enter */);
|
|
2902
2902
|
}
|
|
2903
|
-
function exit2(
|
|
2904
|
-
const steps = getSteps(getSection(
|
|
2903
|
+
function exit2(path7) {
|
|
2904
|
+
const steps = getSteps(getSection(path7));
|
|
2905
2905
|
steps.push(1 /* Exit */);
|
|
2906
2906
|
}
|
|
2907
|
-
function enterShallow(
|
|
2908
|
-
const section = getSection(
|
|
2907
|
+
function enterShallow(path7) {
|
|
2908
|
+
const section = getSection(path7);
|
|
2909
2909
|
const steps = getSteps(section);
|
|
2910
2910
|
steps.push(0 /* Enter */, 1 /* Exit */);
|
|
2911
2911
|
}
|
|
@@ -2926,16 +2926,16 @@ function injectWalks(tag, name2, expr) {
|
|
|
2926
2926
|
}
|
|
2927
2927
|
walks.push(String.fromCharCode(38 /* EndChild */));
|
|
2928
2928
|
}
|
|
2929
|
-
function visit(
|
|
2929
|
+
function visit(path7, code) {
|
|
2930
2930
|
if (isOutputHTML()) {
|
|
2931
2931
|
return;
|
|
2932
2932
|
}
|
|
2933
|
-
const section = getSection(
|
|
2933
|
+
const section = getSection(path7);
|
|
2934
2934
|
const walks = getWalks(section);
|
|
2935
2935
|
const walkComment = getWalkComment(section);
|
|
2936
2936
|
visitInternal(section);
|
|
2937
2937
|
if (code !== 32 /* Get */) {
|
|
2938
|
-
writeTo(
|
|
2938
|
+
writeTo(path7)`<!>`;
|
|
2939
2939
|
}
|
|
2940
2940
|
walkComment.push(`${walkCodeToName[code]}`);
|
|
2941
2941
|
appendLiteral(walks, String.fromCharCode(code));
|
|
@@ -3029,8 +3029,8 @@ var [getTrailerWrites] = createSectionState(
|
|
|
3029
3029
|
"trailerWrites",
|
|
3030
3030
|
() => [""]
|
|
3031
3031
|
);
|
|
3032
|
-
function writeTo(
|
|
3033
|
-
const section = getSection(
|
|
3032
|
+
function writeTo(path7, trailer) {
|
|
3033
|
+
const section = getSection(path7);
|
|
3034
3034
|
const get = trailer ? getTrailerWrites : getWrites;
|
|
3035
3035
|
return (strs, ...exprs) => {
|
|
3036
3036
|
const exprsLen = exprs.length;
|
|
@@ -3041,8 +3041,8 @@ function writeTo(path5, trailer) {
|
|
|
3041
3041
|
}
|
|
3042
3042
|
};
|
|
3043
3043
|
}
|
|
3044
|
-
function consumeHTML(
|
|
3045
|
-
const section = getSection(
|
|
3044
|
+
function consumeHTML(path7) {
|
|
3045
|
+
const section = getSection(path7);
|
|
3046
3046
|
const writes = getWrites(section);
|
|
3047
3047
|
const trailers = getTrailerWrites(section);
|
|
3048
3048
|
const writeResult = normalizeStringExpression(writes.map(unwrapWrite));
|
|
@@ -3064,14 +3064,14 @@ function consumeHTML(path5) {
|
|
|
3064
3064
|
return import_compiler16.types.expressionStatement(callRuntime("_trailers", trailerResult));
|
|
3065
3065
|
}
|
|
3066
3066
|
}
|
|
3067
|
-
function flushBefore(
|
|
3068
|
-
const expr = consumeHTML(
|
|
3067
|
+
function flushBefore(path7) {
|
|
3068
|
+
const expr = consumeHTML(path7);
|
|
3069
3069
|
if (expr) {
|
|
3070
|
-
|
|
3070
|
+
path7.insertBefore(expr)[0].skip();
|
|
3071
3071
|
}
|
|
3072
3072
|
}
|
|
3073
|
-
function flushInto(
|
|
3074
|
-
const target =
|
|
3073
|
+
function flushInto(path7) {
|
|
3074
|
+
const target = path7.isProgram() ? path7 : path7.get("body");
|
|
3075
3075
|
const expr = consumeHTML(target);
|
|
3076
3076
|
if (expr) {
|
|
3077
3077
|
target.node.body.push(expr);
|
|
@@ -3116,16 +3116,16 @@ function getSectionMetaIdentifiers(section) {
|
|
|
3116
3116
|
}
|
|
3117
3117
|
return meta;
|
|
3118
3118
|
}
|
|
3119
|
-
function markNode(
|
|
3119
|
+
function markNode(path7, nodeBinding, reason) {
|
|
3120
3120
|
if (nodeBinding.type !== 0 /* dom */) {
|
|
3121
|
-
throw
|
|
3121
|
+
throw path7.buildCodeFrameError(
|
|
3122
3122
|
"POTENTIAL MARKO BUG: Tried to mark a node that was not determined to need a mark during analyze."
|
|
3123
3123
|
);
|
|
3124
3124
|
}
|
|
3125
3125
|
if (isOutputHTML()) {
|
|
3126
3126
|
if (reason) {
|
|
3127
|
-
const section = getSection(
|
|
3128
|
-
writeTo(
|
|
3127
|
+
const section = getSection(path7);
|
|
3128
|
+
writeTo(path7)`${callRuntime(
|
|
3129
3129
|
"_el_resume",
|
|
3130
3130
|
getScopeIdIdentifier(section),
|
|
3131
3131
|
getScopeAccessorLiteral(nodeBinding),
|
|
@@ -4021,10 +4021,10 @@ function toReturnedFunction(rawFn) {
|
|
|
4021
4021
|
function addHTMLEffectCall(section, referencedBindings) {
|
|
4022
4022
|
addStatement("effect", section, referencedBindings, void 0, false);
|
|
4023
4023
|
}
|
|
4024
|
-
function writeHTMLResumeStatements(
|
|
4025
|
-
const section = getSectionForBody(
|
|
4024
|
+
function writeHTMLResumeStatements(path7) {
|
|
4025
|
+
const section = getSectionForBody(path7);
|
|
4026
4026
|
if (!section) return;
|
|
4027
|
-
const body =
|
|
4027
|
+
const body = path7.node.body;
|
|
4028
4028
|
const allSignals = Array.from(getSignals(section).values());
|
|
4029
4029
|
const scopeIdIdentifier = getScopeIdIdentifier(section);
|
|
4030
4030
|
forEach(section.referencedClosures, (closure) => {
|
|
@@ -4174,7 +4174,7 @@ function writeHTMLResumeStatements(path5) {
|
|
|
4174
4174
|
];
|
|
4175
4175
|
if (debug) {
|
|
4176
4176
|
writeScopeArgs.push(
|
|
4177
|
-
import_compiler22.types.stringLiteral(
|
|
4177
|
+
import_compiler22.types.stringLiteral(path7.hub.file.opts.filenameRelative),
|
|
4178
4178
|
section.loc && section.loc.start.line != null ? import_compiler22.types.stringLiteral(
|
|
4179
4179
|
`${section.loc.start.line}:${section.loc.start.column + 1}`
|
|
4180
4180
|
) : import_compiler22.types.numericLiteral(0)
|
|
@@ -4587,8 +4587,8 @@ var dom_default = {
|
|
|
4587
4587
|
var import_compiler24 = require("@marko/compiler");
|
|
4588
4588
|
|
|
4589
4589
|
// src/translator/util/is-static.ts
|
|
4590
|
-
function isStatic(
|
|
4591
|
-
return
|
|
4590
|
+
function isStatic(path7) {
|
|
4591
|
+
return path7.isImportDeclaration() || path7.isExportDeclaration() || path7.isMarkoScriptlet({ static: true });
|
|
4592
4592
|
}
|
|
4593
4593
|
|
|
4594
4594
|
// src/translator/visitors/program/html.ts
|
|
@@ -5052,8 +5052,8 @@ function getChangeHandlerFromObjectPattern(parent) {
|
|
|
5052
5052
|
}
|
|
5053
5053
|
return changeKey;
|
|
5054
5054
|
}
|
|
5055
|
-
function getStringOrIdentifierValue(
|
|
5056
|
-
return getLiteralName(
|
|
5055
|
+
function getStringOrIdentifierValue(path7) {
|
|
5056
|
+
return getLiteralName(path7.node);
|
|
5057
5057
|
}
|
|
5058
5058
|
function getLiteralName(node) {
|
|
5059
5059
|
switch (node.type) {
|
|
@@ -8385,8 +8385,8 @@ function trackAssignment(assignment, binding) {
|
|
|
8385
8385
|
}
|
|
8386
8386
|
});
|
|
8387
8387
|
}
|
|
8388
|
-
function setReferencesScope(
|
|
8389
|
-
const fnRoot = getFnRoot(
|
|
8388
|
+
function setReferencesScope(path7) {
|
|
8389
|
+
const fnRoot = getFnRoot(path7);
|
|
8390
8390
|
if (fnRoot) {
|
|
8391
8391
|
(fnRoot.node.extra ??= {}).referencesScope = true;
|
|
8392
8392
|
}
|
|
@@ -11521,15 +11521,15 @@ function isStaticText(node) {
|
|
|
11521
11521
|
}
|
|
11522
11522
|
}
|
|
11523
11523
|
}
|
|
11524
|
-
function getPrev(
|
|
11525
|
-
let prev =
|
|
11524
|
+
function getPrev(path7) {
|
|
11525
|
+
let prev = path7.getPrevSibling();
|
|
11526
11526
|
while (prev.node && (prev.isMarkoComment() || prev.isMarkoPlaceholder() && isEmptyPlaceholder(prev.node))) {
|
|
11527
11527
|
prev = prev.getPrevSibling();
|
|
11528
11528
|
}
|
|
11529
11529
|
return prev.node;
|
|
11530
11530
|
}
|
|
11531
|
-
function getNext(
|
|
11532
|
-
let next =
|
|
11531
|
+
function getNext(path7) {
|
|
11532
|
+
let next = path7.getNextSibling();
|
|
11533
11533
|
while (next.node && (next.isMarkoComment() || next.isMarkoPlaceholder() && isEmptyPlaceholder(next.node))) {
|
|
11534
11534
|
next = next.getNextSibling();
|
|
11535
11535
|
}
|
|
@@ -12338,6 +12338,510 @@ var text_default = {
|
|
|
12338
12338
|
}
|
|
12339
12339
|
};
|
|
12340
12340
|
|
|
12341
|
+
// src/translator/interop/index.ts
|
|
12342
|
+
var import_generator = __toESM(require("@babel/generator"));
|
|
12343
|
+
var import_compiler65 = require("@marko/compiler");
|
|
12344
|
+
var import_babel_utils53 = require("@marko/compiler/babel-utils");
|
|
12345
|
+
var translate6 = __toESM(require("@marko/runtime-tags/translator"));
|
|
12346
|
+
var import_path6 = __toESM(require("path"));
|
|
12347
|
+
|
|
12348
|
+
// src/translator/interop/feature-detection.ts
|
|
12349
|
+
var import_babel_utils52 = require("@marko/compiler/babel-utils");
|
|
12350
|
+
|
|
12351
|
+
// src/translator/interop/build-aggregate-error.ts
|
|
12352
|
+
var import_code_frame = require("@babel/code-frame");
|
|
12353
|
+
var import_path5 = __toESM(require("path"));
|
|
12354
|
+
var CWD = process.cwd();
|
|
12355
|
+
function buildAggregateError(file, rootMsg, ...paths) {
|
|
12356
|
+
const err = new SyntaxError();
|
|
12357
|
+
const fileName = import_path5.default.relative(CWD, file.opts.filename);
|
|
12358
|
+
const finalMsg = `${rootMsg}:
|
|
12359
|
+
|
|
12360
|
+
${paths.map(
|
|
12361
|
+
([msg, path7]) => `\x1B[90m${msg} at ${getFileNameWithLoc(
|
|
12362
|
+
fileName,
|
|
12363
|
+
path7
|
|
12364
|
+
)}:\x1B[0m
|
|
12365
|
+
${getFrame(file, path7)}`
|
|
12366
|
+
).join("\n\n")}`;
|
|
12367
|
+
if (!("MARKO_DEBUG" in process.env)) {
|
|
12368
|
+
err.stack = finalMsg;
|
|
12369
|
+
}
|
|
12370
|
+
Object.defineProperty(err, "message", {
|
|
12371
|
+
get() {
|
|
12372
|
+
return finalMsg;
|
|
12373
|
+
},
|
|
12374
|
+
set() {
|
|
12375
|
+
}
|
|
12376
|
+
});
|
|
12377
|
+
return err;
|
|
12378
|
+
}
|
|
12379
|
+
function getFrame(file, { node: { loc } }) {
|
|
12380
|
+
return loc ? (0, import_code_frame.codeFrameColumns)(
|
|
12381
|
+
file.code,
|
|
12382
|
+
{
|
|
12383
|
+
start: {
|
|
12384
|
+
line: loc.start.line,
|
|
12385
|
+
column: loc.start.column + 1
|
|
12386
|
+
},
|
|
12387
|
+
end: loc.end && loc.start.line === loc.end.line ? {
|
|
12388
|
+
line: loc.end.line,
|
|
12389
|
+
column: loc.end.column + 1
|
|
12390
|
+
} : void 0
|
|
12391
|
+
},
|
|
12392
|
+
{ highlightCode: true }
|
|
12393
|
+
) : "";
|
|
12394
|
+
}
|
|
12395
|
+
function getFileNameWithLoc(fileName, { node: { loc } }) {
|
|
12396
|
+
if (loc) {
|
|
12397
|
+
return `${fileName}(${loc.start.line},${loc.start.column + 1})`;
|
|
12398
|
+
}
|
|
12399
|
+
return fileName;
|
|
12400
|
+
}
|
|
12401
|
+
|
|
12402
|
+
// src/translator/interop/feature-detection.ts
|
|
12403
|
+
function isTagsAPI(file = (0, import_babel_utils52.getFile)()) {
|
|
12404
|
+
const program = file.path;
|
|
12405
|
+
const programExtra = program.node.extra ??= {};
|
|
12406
|
+
let { featureType } = programExtra;
|
|
12407
|
+
if (!featureType) {
|
|
12408
|
+
const lookup = (0, import_babel_utils52.getTaglibLookup)(file);
|
|
12409
|
+
const tagsDir = getTagsDir(file.opts.filename);
|
|
12410
|
+
const state = {};
|
|
12411
|
+
if (tagsDir && !lookup.manualTagsDirs?.has(tagsDir)) {
|
|
12412
|
+
addFeature(
|
|
12413
|
+
state,
|
|
12414
|
+
"tags" /* Tags */,
|
|
12415
|
+
"Template file within a tags directory",
|
|
12416
|
+
program
|
|
12417
|
+
);
|
|
12418
|
+
}
|
|
12419
|
+
scanBody(state, program.get("body"));
|
|
12420
|
+
featureType = file.metadata.marko.api = programExtra.featureType = state.feature?.type || (lookup.exclusiveTagDiscoveryDirs === "tags" ? "tags" /* Tags */ : "class" /* Class */);
|
|
12421
|
+
}
|
|
12422
|
+
return featureType === "tags" /* Tags */;
|
|
12423
|
+
}
|
|
12424
|
+
function getTagsDir(filename) {
|
|
12425
|
+
const pathSeparator = /\/|\\/.exec(filename)?.[0];
|
|
12426
|
+
if (pathSeparator) {
|
|
12427
|
+
let previousIndex = filename.length - 1;
|
|
12428
|
+
while (previousIndex > 0) {
|
|
12429
|
+
const index = filename.lastIndexOf(pathSeparator, previousIndex);
|
|
12430
|
+
switch (previousIndex - index) {
|
|
12431
|
+
case 4: {
|
|
12432
|
+
if (filename.startsWith("tags", index + 1)) {
|
|
12433
|
+
return filename.slice(0, index + 5);
|
|
12434
|
+
}
|
|
12435
|
+
break;
|
|
12436
|
+
}
|
|
12437
|
+
case 10: {
|
|
12438
|
+
if (filename.startsWith("components", index + 1)) {
|
|
12439
|
+
return false;
|
|
12440
|
+
}
|
|
12441
|
+
break;
|
|
12442
|
+
}
|
|
12443
|
+
}
|
|
12444
|
+
previousIndex = index - 1;
|
|
12445
|
+
}
|
|
12446
|
+
}
|
|
12447
|
+
return false;
|
|
12448
|
+
}
|
|
12449
|
+
function scanBody(state, body) {
|
|
12450
|
+
if (body?.length) {
|
|
12451
|
+
for (const child of body) {
|
|
12452
|
+
switch (child.type) {
|
|
12453
|
+
case "MarkoTag":
|
|
12454
|
+
scanTag(state, child);
|
|
12455
|
+
break;
|
|
12456
|
+
case "MarkoComment":
|
|
12457
|
+
if (/^\s*use tags\s*$/.test(child.node.value)) {
|
|
12458
|
+
addFeature(state, "tags" /* Tags */, "<!-- use tags -->", child);
|
|
12459
|
+
} else if (/^\s*use class\s*$/.test(child.node.value)) {
|
|
12460
|
+
addFeature(state, "class" /* Class */, "<!-- use class -->", child);
|
|
12461
|
+
}
|
|
12462
|
+
break;
|
|
12463
|
+
case "MarkoScriptlet":
|
|
12464
|
+
if (!child.node.static) {
|
|
12465
|
+
addFeature(state, "class" /* Class */, "Scriptlet", child);
|
|
12466
|
+
}
|
|
12467
|
+
break;
|
|
12468
|
+
case "MarkoClass":
|
|
12469
|
+
addFeature(
|
|
12470
|
+
state,
|
|
12471
|
+
"class" /* Class */,
|
|
12472
|
+
"Class block",
|
|
12473
|
+
child.get("body")
|
|
12474
|
+
);
|
|
12475
|
+
break;
|
|
12476
|
+
}
|
|
12477
|
+
}
|
|
12478
|
+
}
|
|
12479
|
+
}
|
|
12480
|
+
function scanTag(state, tag) {
|
|
12481
|
+
if (tag.node.var) {
|
|
12482
|
+
addFeature(
|
|
12483
|
+
state,
|
|
12484
|
+
"tags" /* Tags */,
|
|
12485
|
+
"Tag variable",
|
|
12486
|
+
tag.get("var")
|
|
12487
|
+
);
|
|
12488
|
+
}
|
|
12489
|
+
const tagDef = (0, import_babel_utils52.getTagDef)(tag);
|
|
12490
|
+
if (tagDef) {
|
|
12491
|
+
if (tagDef.name === "style") {
|
|
12492
|
+
if (/^style(?:(?:\.[^.\s\\/:*?"<>|({]+)+)?\s*\{/.test(
|
|
12493
|
+
tag.node.rawValue || ""
|
|
12494
|
+
)) {
|
|
12495
|
+
addFeature(state, "class" /* Class */, `style block`, tag.get("name"));
|
|
12496
|
+
}
|
|
12497
|
+
} else if (tagDef.taglibId === runtime_info_default.taglibId) {
|
|
12498
|
+
const feature = getFeatureTypeFromCoreTagName(tagDef.name);
|
|
12499
|
+
if (feature) {
|
|
12500
|
+
addFeature(state, feature, `<${tagDef.name}> tag`, tag.get("name"));
|
|
12501
|
+
}
|
|
12502
|
+
}
|
|
12503
|
+
}
|
|
12504
|
+
if (!tagDef?.parseOptions?.rawOpenTag) {
|
|
12505
|
+
for (const attr of tag.get("attributes")) {
|
|
12506
|
+
if (attr.isMarkoAttribute()) {
|
|
12507
|
+
if (attr.node.arguments?.length) {
|
|
12508
|
+
addFeature(
|
|
12509
|
+
state,
|
|
12510
|
+
"class" /* Class */,
|
|
12511
|
+
"Attribute arguments",
|
|
12512
|
+
attr.get("arguments")[0]
|
|
12513
|
+
);
|
|
12514
|
+
break;
|
|
12515
|
+
} else if (attr.node.modifier) {
|
|
12516
|
+
addFeature(state, "class" /* Class */, "Attribute modifier", attr);
|
|
12517
|
+
break;
|
|
12518
|
+
} else if (attr.node.bound) {
|
|
12519
|
+
addFeature(state, "tags" /* Tags */, "Bound attribute", attr);
|
|
12520
|
+
break;
|
|
12521
|
+
}
|
|
12522
|
+
}
|
|
12523
|
+
}
|
|
12524
|
+
}
|
|
12525
|
+
scanBody(state, tag.get("body").get("body"));
|
|
12526
|
+
scanBody(state, tag.get("attributeTags"));
|
|
12527
|
+
}
|
|
12528
|
+
function getFeatureTypeFromCoreTagName(tagName) {
|
|
12529
|
+
switch (tagName) {
|
|
12530
|
+
case "await-reorderer":
|
|
12531
|
+
case "class":
|
|
12532
|
+
case "include-html":
|
|
12533
|
+
case "include-text":
|
|
12534
|
+
case "init-components":
|
|
12535
|
+
case "macro":
|
|
12536
|
+
case "module-code":
|
|
12537
|
+
case "while":
|
|
12538
|
+
return "class" /* Class */;
|
|
12539
|
+
case "const":
|
|
12540
|
+
case "debug":
|
|
12541
|
+
case "define":
|
|
12542
|
+
case "id":
|
|
12543
|
+
case "let":
|
|
12544
|
+
case "lifecycle":
|
|
12545
|
+
case "log":
|
|
12546
|
+
case "return":
|
|
12547
|
+
case "try":
|
|
12548
|
+
return "tags" /* Tags */;
|
|
12549
|
+
default:
|
|
12550
|
+
return void 0;
|
|
12551
|
+
}
|
|
12552
|
+
}
|
|
12553
|
+
function addFeature(state, type, name2, path7) {
|
|
12554
|
+
if (state.feature) {
|
|
12555
|
+
if (state.feature.type !== type) {
|
|
12556
|
+
throw buildAggregateError(
|
|
12557
|
+
path7.hub.file,
|
|
12558
|
+
"Cannot mix Tags API and Class API features in the same file",
|
|
12559
|
+
[state.feature.name, state.feature.path],
|
|
12560
|
+
[name2, path7]
|
|
12561
|
+
);
|
|
12562
|
+
}
|
|
12563
|
+
} else {
|
|
12564
|
+
state.feature = {
|
|
12565
|
+
name: name2,
|
|
12566
|
+
path: path7,
|
|
12567
|
+
type
|
|
12568
|
+
};
|
|
12569
|
+
}
|
|
12570
|
+
}
|
|
12571
|
+
|
|
12572
|
+
// src/translator/interop/index.ts
|
|
12573
|
+
function createInteropTranslator(translate5) {
|
|
12574
|
+
return {
|
|
12575
|
+
preferAPI: translate5.preferAPI,
|
|
12576
|
+
transform: mergeVisitors(translate5.transform, translate6.transform),
|
|
12577
|
+
analyze: mergeVisitors(translate5.analyze, translate6.analyze),
|
|
12578
|
+
translate: patchTranslateProgram(
|
|
12579
|
+
mergeVisitors(translate5.translate, translate6.translate)
|
|
12580
|
+
),
|
|
12581
|
+
tagDiscoveryDirs: [
|
|
12582
|
+
...translate6.tagDiscoveryDirs,
|
|
12583
|
+
...translate5.tagDiscoveryDirs
|
|
12584
|
+
],
|
|
12585
|
+
taglibs: mergeTaglibs(
|
|
12586
|
+
import_compiler65.taglib.resolveOptionalTaglibs(translate5.optionalTaglibs).concat(translate5.taglibs),
|
|
12587
|
+
translate6.taglibs
|
|
12588
|
+
),
|
|
12589
|
+
getRuntimeEntryFiles(output, optimize) {
|
|
12590
|
+
return [
|
|
12591
|
+
...translate5.getRuntimeEntryFiles(output, optimize),
|
|
12592
|
+
...translate6.getRuntimeEntryFiles(output, optimize)
|
|
12593
|
+
];
|
|
12594
|
+
}
|
|
12595
|
+
};
|
|
12596
|
+
function patchTranslateProgram(visitor) {
|
|
12597
|
+
const { Program } = visitor;
|
|
12598
|
+
const kState2 = Symbol();
|
|
12599
|
+
const entryBuilder = {
|
|
12600
|
+
build(entryFile) {
|
|
12601
|
+
const state = entryFile[kState2];
|
|
12602
|
+
if (!state) {
|
|
12603
|
+
throw entryFile.path.buildCodeFrameError(
|
|
12604
|
+
"Unable to build hydrate code, no files were visited before finalizing the build"
|
|
12605
|
+
);
|
|
12606
|
+
}
|
|
12607
|
+
if (state.has5) {
|
|
12608
|
+
if (state.has6) {
|
|
12609
|
+
const filename = entryFile.opts.filename;
|
|
12610
|
+
const baseName = `./${import_path6.default.basename(filename)}`;
|
|
12611
|
+
const generatorOpts = {
|
|
12612
|
+
...entryFile.opts.generatorOpts,
|
|
12613
|
+
sourceMaps: false
|
|
12614
|
+
};
|
|
12615
|
+
const { resolveVirtualDependency } = entryFile.markoOpts;
|
|
12616
|
+
const importHydrateProgram = (name2, statements) => {
|
|
12617
|
+
return import_compiler65.types.importDeclaration(
|
|
12618
|
+
[import_compiler65.types.importDefaultSpecifier(import_compiler65.types.identifier(`init${name2}`))],
|
|
12619
|
+
import_compiler65.types.stringLiteral(
|
|
12620
|
+
resolveVirtualDependency(filename, {
|
|
12621
|
+
code: (0, import_generator.default)(import_compiler65.types.program(statements), generatorOpts).code,
|
|
12622
|
+
virtualPath: `${baseName}.hydrate-${name2}.js`
|
|
12623
|
+
})
|
|
12624
|
+
)
|
|
12625
|
+
);
|
|
12626
|
+
};
|
|
12627
|
+
return [
|
|
12628
|
+
importHydrateProgram(
|
|
12629
|
+
"6",
|
|
12630
|
+
translate6.internalEntryBuilder.build(entryFile, true)
|
|
12631
|
+
),
|
|
12632
|
+
importHydrateProgram(
|
|
12633
|
+
"5",
|
|
12634
|
+
translate5.internalEntryBuilder.build(entryFile, true)
|
|
12635
|
+
),
|
|
12636
|
+
import_compiler65.types.expressionStatement(
|
|
12637
|
+
import_compiler65.types.callExpression(import_compiler65.types.identifier("init6"), [])
|
|
12638
|
+
),
|
|
12639
|
+
import_compiler65.types.expressionStatement(
|
|
12640
|
+
import_compiler65.types.callExpression(import_compiler65.types.identifier("init5"), [])
|
|
12641
|
+
)
|
|
12642
|
+
];
|
|
12643
|
+
} else {
|
|
12644
|
+
return translate5.internalEntryBuilder.build(entryFile);
|
|
12645
|
+
}
|
|
12646
|
+
} else {
|
|
12647
|
+
return translate6.internalEntryBuilder.build(entryFile);
|
|
12648
|
+
}
|
|
12649
|
+
},
|
|
12650
|
+
visit(file, entryFile, visitChild) {
|
|
12651
|
+
const state = entryFile[kState2] ||= {
|
|
12652
|
+
has5: false,
|
|
12653
|
+
has6: false
|
|
12654
|
+
};
|
|
12655
|
+
if (isTagsAPI(file)) {
|
|
12656
|
+
state.has6 = true;
|
|
12657
|
+
translate6.internalEntryBuilder.visit(file, entryFile, visitChild);
|
|
12658
|
+
} else {
|
|
12659
|
+
state.has5 = true;
|
|
12660
|
+
translate5.internalEntryBuilder.visit(file, entryFile, visitChild);
|
|
12661
|
+
}
|
|
12662
|
+
}
|
|
12663
|
+
};
|
|
12664
|
+
const enterProgram = getVisitorEnter(Program);
|
|
12665
|
+
return {
|
|
12666
|
+
...visitor,
|
|
12667
|
+
Program: {
|
|
12668
|
+
enter(program, state) {
|
|
12669
|
+
const entryFile = program.hub.file;
|
|
12670
|
+
if (entryFile.markoOpts.output !== "hydrate") {
|
|
12671
|
+
return enterProgram?.call(this, program, state);
|
|
12672
|
+
}
|
|
12673
|
+
const visitedFiles = /* @__PURE__ */ new Set([
|
|
12674
|
+
(0, import_babel_utils53.resolveRelativePath)(entryFile, entryFile.opts.filename)
|
|
12675
|
+
]);
|
|
12676
|
+
entryBuilder.visit(
|
|
12677
|
+
entryFile,
|
|
12678
|
+
entryFile,
|
|
12679
|
+
function visitChild(resolved) {
|
|
12680
|
+
if (!visitedFiles.has(resolved)) {
|
|
12681
|
+
visitedFiles.add(resolved);
|
|
12682
|
+
const file = (0, import_babel_utils53.loadFileForImport)(entryFile, resolved);
|
|
12683
|
+
if (file) {
|
|
12684
|
+
entryBuilder.visit(
|
|
12685
|
+
file,
|
|
12686
|
+
entryFile,
|
|
12687
|
+
(id) => visitChild(resolveRelativeToEntry2(entryFile, file, id))
|
|
12688
|
+
);
|
|
12689
|
+
}
|
|
12690
|
+
}
|
|
12691
|
+
}
|
|
12692
|
+
);
|
|
12693
|
+
program.node.body = entryBuilder.build(entryFile);
|
|
12694
|
+
program.skip();
|
|
12695
|
+
},
|
|
12696
|
+
exit: getVisitorExit(Program)
|
|
12697
|
+
}
|
|
12698
|
+
};
|
|
12699
|
+
}
|
|
12700
|
+
}
|
|
12701
|
+
function mergeVisitors(visitor5, visitor6) {
|
|
12702
|
+
return mergeObjects(
|
|
12703
|
+
visitor5,
|
|
12704
|
+
visitor6,
|
|
12705
|
+
(_, value5, value6) => mergeVisit(value5, value6)
|
|
12706
|
+
);
|
|
12707
|
+
}
|
|
12708
|
+
function mergeVisit(visit5, visit6) {
|
|
12709
|
+
const enter5 = getVisitorEnter(visit5);
|
|
12710
|
+
const enter6 = getVisitorEnter(visit6);
|
|
12711
|
+
const enter3 = (enter5 || enter6) && function enter4(path7, state) {
|
|
12712
|
+
return (isTagsAPI() ? enter6 : enter5)?.call(this, path7, state);
|
|
12713
|
+
};
|
|
12714
|
+
const exit5 = getVisitorExit(visit5);
|
|
12715
|
+
const exit6 = getVisitorExit(visit6);
|
|
12716
|
+
const exit3 = (exit5 || exit6) && function exit4(path7, state) {
|
|
12717
|
+
return (isTagsAPI() ? exit6 : exit5)?.call(this, path7, state);
|
|
12718
|
+
};
|
|
12719
|
+
return exit3 ? enter3 ? { enter: enter3, exit: exit3 } : { exit: exit3 } : enter3;
|
|
12720
|
+
}
|
|
12721
|
+
function mergeTaglibs(libs5, libs6) {
|
|
12722
|
+
const libs5Map = new Map(libs5);
|
|
12723
|
+
const libs6Map = new Map(libs6);
|
|
12724
|
+
const merged = [];
|
|
12725
|
+
for (const taglibId2 of /* @__PURE__ */ new Set([...libs5Map.keys(), ...libs6Map.keys()])) {
|
|
12726
|
+
merged.push([
|
|
12727
|
+
taglibId2,
|
|
12728
|
+
mergeObjects(
|
|
12729
|
+
libs5Map.get(taglibId2),
|
|
12730
|
+
libs6Map.get(taglibId2),
|
|
12731
|
+
(key, value5, value6) => {
|
|
12732
|
+
switch (key) {
|
|
12733
|
+
case "migrate":
|
|
12734
|
+
case "analyze":
|
|
12735
|
+
case "transform":
|
|
12736
|
+
case "translate":
|
|
12737
|
+
return mergeVisitors(
|
|
12738
|
+
normalizeVisitor(value5),
|
|
12739
|
+
normalizeVisitor(value6)
|
|
12740
|
+
);
|
|
12741
|
+
default:
|
|
12742
|
+
if (key[0] === "<") {
|
|
12743
|
+
return mergeTagDef(
|
|
12744
|
+
value5,
|
|
12745
|
+
value6
|
|
12746
|
+
);
|
|
12747
|
+
}
|
|
12748
|
+
return value5 ?? value6;
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
)
|
|
12752
|
+
]);
|
|
12753
|
+
}
|
|
12754
|
+
return merged;
|
|
12755
|
+
}
|
|
12756
|
+
function mergeTagDef(def5, def6) {
|
|
12757
|
+
return mergeObjects(
|
|
12758
|
+
normalizeTagDef(def5),
|
|
12759
|
+
normalizeTagDef(def6),
|
|
12760
|
+
(key, value5, value6) => {
|
|
12761
|
+
switch (key) {
|
|
12762
|
+
case "parse":
|
|
12763
|
+
case "migrate":
|
|
12764
|
+
case "transform":
|
|
12765
|
+
case "analyze":
|
|
12766
|
+
case "translate":
|
|
12767
|
+
return mergeVisit(normalizeVisit(value5), normalizeVisit(value6));
|
|
12768
|
+
default:
|
|
12769
|
+
return value5 ?? value6;
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
);
|
|
12773
|
+
}
|
|
12774
|
+
function mergeObjects(a, b, cb) {
|
|
12775
|
+
const merged = {};
|
|
12776
|
+
if (a) {
|
|
12777
|
+
if (b) {
|
|
12778
|
+
for (const key in a) {
|
|
12779
|
+
merged[key] = cb(key, a[key], b[key]);
|
|
12780
|
+
}
|
|
12781
|
+
for (const key in b) {
|
|
12782
|
+
if (!(key in a)) {
|
|
12783
|
+
merged[key] = cb(key, void 0, b[key]);
|
|
12784
|
+
}
|
|
12785
|
+
}
|
|
12786
|
+
} else {
|
|
12787
|
+
for (const key in a) {
|
|
12788
|
+
merged[key] = cb(key, a[key], void 0);
|
|
12789
|
+
}
|
|
12790
|
+
}
|
|
12791
|
+
} else if (b) {
|
|
12792
|
+
for (const key in b) {
|
|
12793
|
+
merged[key] = cb(key, void 0, b[key]);
|
|
12794
|
+
}
|
|
12795
|
+
}
|
|
12796
|
+
return merged;
|
|
12797
|
+
}
|
|
12798
|
+
function normalizeTagDef(tagDef) {
|
|
12799
|
+
if (tagDef) {
|
|
12800
|
+
const normalized = {};
|
|
12801
|
+
for (const key in tagDef) {
|
|
12802
|
+
normalized[normalizeTagDefKey(key)] = tagDef[key];
|
|
12803
|
+
}
|
|
12804
|
+
return normalized;
|
|
12805
|
+
}
|
|
12806
|
+
return void 0;
|
|
12807
|
+
}
|
|
12808
|
+
function normalizeTagDefKey(key) {
|
|
12809
|
+
switch (key) {
|
|
12810
|
+
case "code-generator":
|
|
12811
|
+
case "codeGenerator":
|
|
12812
|
+
return "translate";
|
|
12813
|
+
case "migrator":
|
|
12814
|
+
return "migrate";
|
|
12815
|
+
case "node-factory":
|
|
12816
|
+
case "nodeFactory":
|
|
12817
|
+
return "parse";
|
|
12818
|
+
case "parse-options":
|
|
12819
|
+
return "parseOptions";
|
|
12820
|
+
case "transformer":
|
|
12821
|
+
return "transform";
|
|
12822
|
+
default:
|
|
12823
|
+
return key;
|
|
12824
|
+
}
|
|
12825
|
+
}
|
|
12826
|
+
function normalizeVisitor(visitor) {
|
|
12827
|
+
return visitor?.default ?? visitor;
|
|
12828
|
+
}
|
|
12829
|
+
function normalizeVisit(visitor) {
|
|
12830
|
+
return typeof visitor === "function" ? visitor : normalizeVisitor(visitor);
|
|
12831
|
+
}
|
|
12832
|
+
function getVisitorEnter(visit2) {
|
|
12833
|
+
return typeof visit2 === "function" ? visit2 : visit2?.enter;
|
|
12834
|
+
}
|
|
12835
|
+
function getVisitorExit(visit2) {
|
|
12836
|
+
return typeof visit2 === "object" ? visit2?.exit : void 0;
|
|
12837
|
+
}
|
|
12838
|
+
function resolveRelativeToEntry2(entryFile, file, req) {
|
|
12839
|
+
return file === entryFile ? (0, import_babel_utils53.resolveRelativePath)(file, req) : (0, import_babel_utils53.resolveRelativePath)(
|
|
12840
|
+
entryFile,
|
|
12841
|
+
req[0] === "." ? import_path6.default.join(file.opts.filename, "..", req) : req
|
|
12842
|
+
);
|
|
12843
|
+
}
|
|
12844
|
+
|
|
12341
12845
|
// src/translator/index.ts
|
|
12342
12846
|
var visitors = extractVisitors({
|
|
12343
12847
|
Program: program_default,
|
|
@@ -12353,10 +12857,10 @@ var visitors = extractVisitors({
|
|
|
12353
12857
|
MarkoScriptlet: scriptlet_default,
|
|
12354
12858
|
MarkoComment: comment_default
|
|
12355
12859
|
});
|
|
12356
|
-
var
|
|
12860
|
+
var tagDiscoveryDirs2 = ["tags"];
|
|
12357
12861
|
var preferAPI = "tags";
|
|
12358
|
-
var { transform, analyze, translate } = visitors;
|
|
12359
|
-
var
|
|
12862
|
+
var { transform: transform2, analyze: analyze2, translate: translate2 } = visitors;
|
|
12863
|
+
var taglibs2 = [
|
|
12360
12864
|
[
|
|
12361
12865
|
core_default.taglibId,
|
|
12362
12866
|
{
|
|
@@ -12365,7 +12869,7 @@ var taglibs = [
|
|
|
12365
12869
|
}
|
|
12366
12870
|
]
|
|
12367
12871
|
];
|
|
12368
|
-
function
|
|
12872
|
+
function getRuntimeEntryFiles2(output, optimize) {
|
|
12369
12873
|
return [
|
|
12370
12874
|
`${runtime_info_default.name}${optimize ? "" : "/debug"}/${output === "html" ? "html" : "dom"}`
|
|
12371
12875
|
];
|
|
@@ -12373,6 +12877,7 @@ function getRuntimeEntryFiles(output, optimize) {
|
|
|
12373
12877
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12374
12878
|
0 && (module.exports = {
|
|
12375
12879
|
analyze,
|
|
12880
|
+
createInteropTranslator,
|
|
12376
12881
|
getRuntimeEntryFiles,
|
|
12377
12882
|
internalEntryBuilder,
|
|
12378
12883
|
preferAPI,
|