marko 6.0.120 → 6.0.123
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 +704 -194
- 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/dist/translator/visitors/scriptlet.d.ts +1 -1
- 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;
|
|
@@ -2663,29 +2662,29 @@ var import_babel_utils14 = require("@marko/compiler/babel-utils");
|
|
|
2663
2662
|
|
|
2664
2663
|
// src/translator/util/plugin-hooks.ts
|
|
2665
2664
|
var import_compiler12 = require("@marko/compiler");
|
|
2666
|
-
function enter(modulePlugin,
|
|
2665
|
+
function enter(modulePlugin, path7) {
|
|
2667
2666
|
if (!modulePlugin) {
|
|
2668
2667
|
return false;
|
|
2669
2668
|
}
|
|
2670
|
-
const { node } =
|
|
2669
|
+
const { node } = path7;
|
|
2671
2670
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
|
2672
2671
|
if (isFunctionPlugin(plugin)) {
|
|
2673
|
-
plugin(
|
|
2672
|
+
plugin(path7, import_compiler12.types);
|
|
2674
2673
|
} else if (plugin.enter) {
|
|
2675
|
-
plugin.enter(
|
|
2674
|
+
plugin.enter(path7, import_compiler12.types);
|
|
2676
2675
|
}
|
|
2677
|
-
return node !==
|
|
2676
|
+
return node !== path7.node;
|
|
2678
2677
|
}
|
|
2679
|
-
function exit(modulePlugin,
|
|
2678
|
+
function exit(modulePlugin, path7) {
|
|
2680
2679
|
if (!modulePlugin) {
|
|
2681
2680
|
return false;
|
|
2682
2681
|
}
|
|
2683
|
-
const { node } =
|
|
2682
|
+
const { node } = path7;
|
|
2684
2683
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
|
2685
2684
|
if (!isFunctionPlugin(plugin) && plugin.exit) {
|
|
2686
|
-
plugin.exit(
|
|
2685
|
+
plugin.exit(path7, import_compiler12.types);
|
|
2687
2686
|
}
|
|
2688
|
-
return node !==
|
|
2687
|
+
return node !== path7.node;
|
|
2689
2688
|
}
|
|
2690
2689
|
function isModulePlugin(plugin) {
|
|
2691
2690
|
return Boolean(plugin.default);
|
|
@@ -2717,11 +2716,11 @@ function translateByTarget({
|
|
|
2717
2716
|
dom
|
|
2718
2717
|
}) {
|
|
2719
2718
|
return {
|
|
2720
|
-
enter(
|
|
2721
|
-
enter(isOutputHTML() ? html : dom,
|
|
2719
|
+
enter(path7) {
|
|
2720
|
+
enter(isOutputHTML() ? html : dom, path7);
|
|
2722
2721
|
},
|
|
2723
|
-
exit(
|
|
2724
|
-
exit(isOutputHTML() ? html : dom,
|
|
2722
|
+
exit(path7) {
|
|
2723
|
+
exit(isOutputHTML() ? html : dom, path7);
|
|
2725
2724
|
}
|
|
2726
2725
|
};
|
|
2727
2726
|
}
|
|
@@ -2896,16 +2895,16 @@ var walkCodeToName = {
|
|
|
2896
2895
|
[116 /* OutEnd */]: "outEnd",
|
|
2897
2896
|
[126 /* MultiplierEnd */]: "multiplierEnd"
|
|
2898
2897
|
};
|
|
2899
|
-
function enter2(
|
|
2900
|
-
const steps = getSteps(getSection(
|
|
2898
|
+
function enter2(path7) {
|
|
2899
|
+
const steps = getSteps(getSection(path7));
|
|
2901
2900
|
steps.push(0 /* Enter */);
|
|
2902
2901
|
}
|
|
2903
|
-
function exit2(
|
|
2904
|
-
const steps = getSteps(getSection(
|
|
2902
|
+
function exit2(path7) {
|
|
2903
|
+
const steps = getSteps(getSection(path7));
|
|
2905
2904
|
steps.push(1 /* Exit */);
|
|
2906
2905
|
}
|
|
2907
|
-
function enterShallow(
|
|
2908
|
-
const section = getSection(
|
|
2906
|
+
function enterShallow(path7) {
|
|
2907
|
+
const section = getSection(path7);
|
|
2909
2908
|
const steps = getSteps(section);
|
|
2910
2909
|
steps.push(0 /* Enter */, 1 /* Exit */);
|
|
2911
2910
|
}
|
|
@@ -2926,16 +2925,16 @@ function injectWalks(tag, name2, expr) {
|
|
|
2926
2925
|
}
|
|
2927
2926
|
walks.push(String.fromCharCode(38 /* EndChild */));
|
|
2928
2927
|
}
|
|
2929
|
-
function visit(
|
|
2928
|
+
function visit(path7, code) {
|
|
2930
2929
|
if (isOutputHTML()) {
|
|
2931
2930
|
return;
|
|
2932
2931
|
}
|
|
2933
|
-
const section = getSection(
|
|
2932
|
+
const section = getSection(path7);
|
|
2934
2933
|
const walks = getWalks(section);
|
|
2935
2934
|
const walkComment = getWalkComment(section);
|
|
2936
2935
|
visitInternal(section);
|
|
2937
2936
|
if (code !== 32 /* Get */) {
|
|
2938
|
-
writeTo(
|
|
2937
|
+
writeTo(path7)`<!>`;
|
|
2939
2938
|
}
|
|
2940
2939
|
walkComment.push(`${walkCodeToName[code]}`);
|
|
2941
2940
|
appendLiteral(walks, String.fromCharCode(code));
|
|
@@ -3029,8 +3028,8 @@ var [getTrailerWrites] = createSectionState(
|
|
|
3029
3028
|
"trailerWrites",
|
|
3030
3029
|
() => [""]
|
|
3031
3030
|
);
|
|
3032
|
-
function writeTo(
|
|
3033
|
-
const section = getSection(
|
|
3031
|
+
function writeTo(path7, trailer) {
|
|
3032
|
+
const section = getSection(path7);
|
|
3034
3033
|
const get = trailer ? getTrailerWrites : getWrites;
|
|
3035
3034
|
return (strs, ...exprs) => {
|
|
3036
3035
|
const exprsLen = exprs.length;
|
|
@@ -3041,8 +3040,8 @@ function writeTo(path5, trailer) {
|
|
|
3041
3040
|
}
|
|
3042
3041
|
};
|
|
3043
3042
|
}
|
|
3044
|
-
function consumeHTML(
|
|
3045
|
-
const section = getSection(
|
|
3043
|
+
function consumeHTML(path7) {
|
|
3044
|
+
const section = getSection(path7);
|
|
3046
3045
|
const writes = getWrites(section);
|
|
3047
3046
|
const trailers = getTrailerWrites(section);
|
|
3048
3047
|
const writeResult = normalizeStringExpression(writes.map(unwrapWrite));
|
|
@@ -3064,14 +3063,14 @@ function consumeHTML(path5) {
|
|
|
3064
3063
|
return import_compiler16.types.expressionStatement(callRuntime("_trailers", trailerResult));
|
|
3065
3064
|
}
|
|
3066
3065
|
}
|
|
3067
|
-
function flushBefore(
|
|
3068
|
-
const expr = consumeHTML(
|
|
3066
|
+
function flushBefore(path7) {
|
|
3067
|
+
const expr = consumeHTML(path7);
|
|
3069
3068
|
if (expr) {
|
|
3070
|
-
|
|
3069
|
+
path7.insertBefore(expr)[0].skip();
|
|
3071
3070
|
}
|
|
3072
3071
|
}
|
|
3073
|
-
function flushInto(
|
|
3074
|
-
const target =
|
|
3072
|
+
function flushInto(path7) {
|
|
3073
|
+
const target = path7.isProgram() ? path7 : path7.get("body");
|
|
3075
3074
|
const expr = consumeHTML(target);
|
|
3076
3075
|
if (expr) {
|
|
3077
3076
|
target.node.body.push(expr);
|
|
@@ -3116,16 +3115,16 @@ function getSectionMetaIdentifiers(section) {
|
|
|
3116
3115
|
}
|
|
3117
3116
|
return meta;
|
|
3118
3117
|
}
|
|
3119
|
-
function markNode(
|
|
3118
|
+
function markNode(path7, nodeBinding, reason) {
|
|
3120
3119
|
if (nodeBinding.type !== 0 /* dom */) {
|
|
3121
|
-
throw
|
|
3120
|
+
throw path7.buildCodeFrameError(
|
|
3122
3121
|
"POTENTIAL MARKO BUG: Tried to mark a node that was not determined to need a mark during analyze."
|
|
3123
3122
|
);
|
|
3124
3123
|
}
|
|
3125
3124
|
if (isOutputHTML()) {
|
|
3126
3125
|
if (reason) {
|
|
3127
|
-
const section = getSection(
|
|
3128
|
-
writeTo(
|
|
3126
|
+
const section = getSection(path7);
|
|
3127
|
+
writeTo(path7)`${callRuntime(
|
|
3129
3128
|
"_el_resume",
|
|
3130
3129
|
getScopeIdIdentifier(section),
|
|
3131
3130
|
getScopeAccessorLiteral(nodeBinding),
|
|
@@ -4021,10 +4020,10 @@ function toReturnedFunction(rawFn) {
|
|
|
4021
4020
|
function addHTMLEffectCall(section, referencedBindings) {
|
|
4022
4021
|
addStatement("effect", section, referencedBindings, void 0, false);
|
|
4023
4022
|
}
|
|
4024
|
-
function writeHTMLResumeStatements(
|
|
4025
|
-
const section = getSectionForBody(
|
|
4023
|
+
function writeHTMLResumeStatements(path7) {
|
|
4024
|
+
const section = getSectionForBody(path7);
|
|
4026
4025
|
if (!section) return;
|
|
4027
|
-
const body =
|
|
4026
|
+
const body = path7.node.body;
|
|
4028
4027
|
const allSignals = Array.from(getSignals(section).values());
|
|
4029
4028
|
const scopeIdIdentifier = getScopeIdIdentifier(section);
|
|
4030
4029
|
forEach(section.referencedClosures, (closure) => {
|
|
@@ -4174,7 +4173,7 @@ function writeHTMLResumeStatements(path5) {
|
|
|
4174
4173
|
];
|
|
4175
4174
|
if (debug) {
|
|
4176
4175
|
writeScopeArgs.push(
|
|
4177
|
-
import_compiler22.types.stringLiteral(
|
|
4176
|
+
import_compiler22.types.stringLiteral(path7.hub.file.opts.filenameRelative),
|
|
4178
4177
|
section.loc && section.loc.start.line != null ? import_compiler22.types.stringLiteral(
|
|
4179
4178
|
`${section.loc.start.line}:${section.loc.start.column + 1}`
|
|
4180
4179
|
) : import_compiler22.types.numericLiteral(0)
|
|
@@ -4587,8 +4586,8 @@ var dom_default = {
|
|
|
4587
4586
|
var import_compiler24 = require("@marko/compiler");
|
|
4588
4587
|
|
|
4589
4588
|
// src/translator/util/is-static.ts
|
|
4590
|
-
function isStatic(
|
|
4591
|
-
return
|
|
4589
|
+
function isStatic(path7) {
|
|
4590
|
+
return path7.isImportDeclaration() || path7.isExportDeclaration() || path7.isMarkoScriptlet({ static: true });
|
|
4592
4591
|
}
|
|
4593
4592
|
|
|
4594
4593
|
// src/translator/visitors/program/html.ts
|
|
@@ -4863,30 +4862,25 @@ function withPreviousLocation(newNode, originalNode) {
|
|
|
4863
4862
|
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
|
4864
4863
|
var BINDING_CHANGE_HANDLER = /* @__PURE__ */ new WeakMap();
|
|
4865
4864
|
function preAnalyze2(program) {
|
|
4866
|
-
|
|
4867
|
-
normalizeBody(state, program.get("body"));
|
|
4868
|
-
if (state.crawl) {
|
|
4869
|
-
program.scope.crawl();
|
|
4870
|
-
}
|
|
4865
|
+
normalizeBody(program.get("body"));
|
|
4871
4866
|
}
|
|
4872
|
-
function normalizeBody(
|
|
4867
|
+
function normalizeBody(body) {
|
|
4873
4868
|
if (body?.length) {
|
|
4874
4869
|
for (const child of body) {
|
|
4875
4870
|
if (child.isMarkoTag()) {
|
|
4876
|
-
normalizeTag(
|
|
4871
|
+
normalizeTag(child);
|
|
4877
4872
|
}
|
|
4878
4873
|
}
|
|
4879
4874
|
}
|
|
4880
4875
|
}
|
|
4881
|
-
function normalizeTag(
|
|
4876
|
+
function normalizeTag(tag) {
|
|
4882
4877
|
const { node } = tag;
|
|
4883
4878
|
const { name: name2, attributes } = node;
|
|
4884
|
-
normalizeBody(
|
|
4885
|
-
normalizeBody(
|
|
4879
|
+
normalizeBody(tag.get("body").get("body"));
|
|
4880
|
+
normalizeBody(tag.get("attributeTags"));
|
|
4886
4881
|
if (node.var) {
|
|
4887
4882
|
const insertions = getAssignmentInsertions(node.var);
|
|
4888
4883
|
if (insertions) {
|
|
4889
|
-
state.crawl = true;
|
|
4890
4884
|
tag.insertAfter(insertions);
|
|
4891
4885
|
}
|
|
4892
4886
|
}
|
|
@@ -4896,14 +4890,12 @@ function normalizeTag(state, tag) {
|
|
|
4896
4890
|
insertions = getAssignmentInsertions(param, insertions);
|
|
4897
4891
|
}
|
|
4898
4892
|
if (insertions) {
|
|
4899
|
-
state.crawl = true;
|
|
4900
4893
|
node.body.body = [...insertions, ...node.body.body];
|
|
4901
4894
|
}
|
|
4902
4895
|
}
|
|
4903
4896
|
if (name2.type === "StringLiteral") {
|
|
4904
4897
|
const tagName = name2.value;
|
|
4905
4898
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
|
4906
|
-
state.crawl = true;
|
|
4907
4899
|
node.name = withPreviousLocation(import_compiler26.types.identifier(tagName), name2);
|
|
4908
4900
|
} else {
|
|
4909
4901
|
switch (tagName) {
|
|
@@ -4916,7 +4908,6 @@ function normalizeTag(state, tag) {
|
|
|
4916
4908
|
for (let i = 0; i < attributes.length; i++) {
|
|
4917
4909
|
const attr = attributes[i];
|
|
4918
4910
|
if (import_compiler26.types.isMarkoAttribute(attr) && attr.bound) {
|
|
4919
|
-
state.crawl = true;
|
|
4920
4911
|
attr.bound = false;
|
|
4921
4912
|
attributes.splice(++i, 0, getChangeHandler(tag, attr));
|
|
4922
4913
|
}
|
|
@@ -4978,7 +4969,6 @@ function getChangeHandler(tag, attr) {
|
|
|
4978
4969
|
} else {
|
|
4979
4970
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
|
4980
4971
|
}
|
|
4981
|
-
markoRoot.scope.crawl();
|
|
4982
4972
|
return import_compiler26.types.markoAttribute(
|
|
4983
4973
|
changeAttrName,
|
|
4984
4974
|
withPreviousLocation(import_compiler26.types.identifier(changeHandlerId), attr.value)
|
|
@@ -5061,8 +5051,8 @@ function getChangeHandlerFromObjectPattern(parent) {
|
|
|
5061
5051
|
}
|
|
5062
5052
|
return changeKey;
|
|
5063
5053
|
}
|
|
5064
|
-
function getStringOrIdentifierValue(
|
|
5065
|
-
return getLiteralName(
|
|
5054
|
+
function getStringOrIdentifierValue(path7) {
|
|
5055
|
+
return getLiteralName(path7.node);
|
|
5066
5056
|
}
|
|
5067
5057
|
function getLiteralName(node) {
|
|
5068
5058
|
switch (node.type) {
|
|
@@ -8394,8 +8384,8 @@ function trackAssignment(assignment, binding) {
|
|
|
8394
8384
|
}
|
|
8395
8385
|
});
|
|
8396
8386
|
}
|
|
8397
|
-
function setReferencesScope(
|
|
8398
|
-
const fnRoot = getFnRoot(
|
|
8387
|
+
function setReferencesScope(path7) {
|
|
8388
|
+
const fnRoot = getFnRoot(path7);
|
|
8399
8389
|
if (fnRoot) {
|
|
8400
8390
|
(fnRoot.node.extra ??= {}).referencesScope = true;
|
|
8401
8391
|
}
|
|
@@ -11530,15 +11520,15 @@ function isStaticText(node) {
|
|
|
11530
11520
|
}
|
|
11531
11521
|
}
|
|
11532
11522
|
}
|
|
11533
|
-
function getPrev(
|
|
11534
|
-
let prev =
|
|
11523
|
+
function getPrev(path7) {
|
|
11524
|
+
let prev = path7.getPrevSibling();
|
|
11535
11525
|
while (prev.node && (prev.isMarkoComment() || prev.isMarkoPlaceholder() && isEmptyPlaceholder(prev.node))) {
|
|
11536
11526
|
prev = prev.getPrevSibling();
|
|
11537
11527
|
}
|
|
11538
11528
|
return prev.node;
|
|
11539
11529
|
}
|
|
11540
|
-
function getNext(
|
|
11541
|
-
let next =
|
|
11530
|
+
function getNext(path7) {
|
|
11531
|
+
let next = path7.getNextSibling();
|
|
11542
11532
|
while (next.node && (next.isMarkoComment() || next.isMarkoPlaceholder() && isEmptyPlaceholder(next.node))) {
|
|
11543
11533
|
next = next.getNextSibling();
|
|
11544
11534
|
}
|
|
@@ -11653,6 +11643,7 @@ var referenced_identifier_default = {
|
|
|
11653
11643
|
};
|
|
11654
11644
|
|
|
11655
11645
|
// src/translator/visitors/scriptlet.ts
|
|
11646
|
+
var import_compiler59 = require("@marko/compiler");
|
|
11656
11647
|
var import_babel_utils47 = require("@marko/compiler/babel-utils");
|
|
11657
11648
|
var scriptlet_default = {
|
|
11658
11649
|
analyze(scriptlet) {
|
|
@@ -11675,7 +11666,21 @@ var scriptlet_default = {
|
|
|
11675
11666
|
const { node } = scriptlet;
|
|
11676
11667
|
const isHTML = isOutputHTML();
|
|
11677
11668
|
if (node.target && node.target !== (isHTML ? "server" : "client")) {
|
|
11678
|
-
scriptlet.
|
|
11669
|
+
const ids = Object.keys(scriptlet.getOuterBindingIdentifiers());
|
|
11670
|
+
const decl = ids.length && import_compiler59.types.variableDeclaration(
|
|
11671
|
+
"var",
|
|
11672
|
+
ids.map((key) => import_compiler59.types.variableDeclarator(import_compiler59.types.identifier(key)))
|
|
11673
|
+
);
|
|
11674
|
+
if (decl) {
|
|
11675
|
+
if (isHTML) {
|
|
11676
|
+
scriptlet.node.target = null;
|
|
11677
|
+
scriptlet.node.body = [decl];
|
|
11678
|
+
} else {
|
|
11679
|
+
scriptlet.replaceWith(decl);
|
|
11680
|
+
}
|
|
11681
|
+
} else {
|
|
11682
|
+
scriptlet.remove();
|
|
11683
|
+
}
|
|
11679
11684
|
return;
|
|
11680
11685
|
}
|
|
11681
11686
|
if (isHTML) {
|
|
@@ -11688,11 +11693,11 @@ var scriptlet_default = {
|
|
|
11688
11693
|
};
|
|
11689
11694
|
|
|
11690
11695
|
// src/translator/visitors/tag/index.ts
|
|
11691
|
-
var
|
|
11696
|
+
var import_compiler63 = require("@marko/compiler");
|
|
11692
11697
|
var import_babel_utils51 = require("@marko/compiler/babel-utils");
|
|
11693
11698
|
|
|
11694
11699
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
11695
|
-
var
|
|
11700
|
+
var import_compiler60 = require("@marko/compiler");
|
|
11696
11701
|
var import_babel_utils48 = require("@marko/compiler/babel-utils");
|
|
11697
11702
|
var attribute_tag_default = {
|
|
11698
11703
|
analyze: {
|
|
@@ -11725,7 +11730,7 @@ var attribute_tag_default = {
|
|
|
11725
11730
|
};
|
|
11726
11731
|
|
|
11727
11732
|
// src/translator/visitors/tag/custom-tag.ts
|
|
11728
|
-
var
|
|
11733
|
+
var import_compiler61 = require("@marko/compiler");
|
|
11729
11734
|
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
11730
11735
|
var import_path4 = __toESM(require("path"));
|
|
11731
11736
|
var custom_tag_default = {
|
|
@@ -11779,9 +11784,9 @@ function translateHTML(tag) {
|
|
|
11779
11784
|
const childProgram = (0, import_babel_utils49.loadFileForTag)(tag).ast.program;
|
|
11780
11785
|
const childExtra = childProgram.extra;
|
|
11781
11786
|
let tagIdentifier;
|
|
11782
|
-
if (
|
|
11787
|
+
if (import_compiler61.types.isStringLiteral(node.name)) {
|
|
11783
11788
|
const relativePath = getTagRelativePath(tag);
|
|
11784
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
|
11789
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler61.types.identifier(getTemplateContentName()) : (0, import_babel_utils49.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
|
11785
11790
|
} else {
|
|
11786
11791
|
tagIdentifier = node.name;
|
|
11787
11792
|
}
|
|
@@ -11802,7 +11807,7 @@ function translateDOM(tag) {
|
|
|
11802
11807
|
const childExtra = childFile.ast.program.extra;
|
|
11803
11808
|
const childExports = childExtra.domExports;
|
|
11804
11809
|
const childSection = childExtra.section;
|
|
11805
|
-
const tagName =
|
|
11810
|
+
const tagName = import_compiler61.types.isIdentifier(node.name) ? node.name.name : import_compiler61.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
11806
11811
|
if (programSection === childSection) {
|
|
11807
11812
|
knownTagTranslateDOM(
|
|
11808
11813
|
tag,
|
|
@@ -11813,16 +11818,16 @@ function translateDOM(tag) {
|
|
|
11813
11818
|
"render",
|
|
11814
11819
|
section,
|
|
11815
11820
|
void 0,
|
|
11816
|
-
|
|
11817
|
-
|
|
11821
|
+
import_compiler61.types.expressionStatement(
|
|
11822
|
+
import_compiler61.types.callExpression(import_compiler61.types.identifier(childExports.setup), [
|
|
11818
11823
|
createScopeReadExpression(childBinding, section)
|
|
11819
11824
|
])
|
|
11820
11825
|
)
|
|
11821
11826
|
);
|
|
11822
11827
|
}
|
|
11823
11828
|
);
|
|
11824
|
-
write`${
|
|
11825
|
-
injectWalks(tag, tagName,
|
|
11829
|
+
write`${import_compiler61.types.identifier(childExports.template)}`;
|
|
11830
|
+
injectWalks(tag, tagName, import_compiler61.types.identifier(childExports.walks));
|
|
11826
11831
|
} else {
|
|
11827
11832
|
knownTagTranslateDOM(
|
|
11828
11833
|
tag,
|
|
@@ -11838,8 +11843,8 @@ function translateDOM(tag) {
|
|
|
11838
11843
|
"render",
|
|
11839
11844
|
section,
|
|
11840
11845
|
void 0,
|
|
11841
|
-
|
|
11842
|
-
|
|
11846
|
+
import_compiler61.types.expressionStatement(
|
|
11847
|
+
import_compiler61.types.callExpression(
|
|
11843
11848
|
importOrSelfReferenceName(
|
|
11844
11849
|
file,
|
|
11845
11850
|
relativePath,
|
|
@@ -11867,7 +11872,7 @@ function getTagRelativePath(tag) {
|
|
|
11867
11872
|
hub: { file }
|
|
11868
11873
|
} = tag;
|
|
11869
11874
|
let relativePath;
|
|
11870
|
-
if (
|
|
11875
|
+
if (import_compiler61.types.isStringLiteral(node.name)) {
|
|
11871
11876
|
const template = (0, import_babel_utils49.getTagTemplate)(tag);
|
|
11872
11877
|
relativePath = template && (0, import_babel_utils49.resolveRelativePath)(file, template);
|
|
11873
11878
|
} else if (node.extra?.tagNameImported) {
|
|
@@ -11888,7 +11893,7 @@ function getTagRelativePath(tag) {
|
|
|
11888
11893
|
}
|
|
11889
11894
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
11890
11895
|
if (isCircularRequest(file, request)) {
|
|
11891
|
-
return
|
|
11896
|
+
return import_compiler61.types.identifier(name2);
|
|
11892
11897
|
}
|
|
11893
11898
|
return (0, import_babel_utils49.importNamed)(file, request, name2, nameHint);
|
|
11894
11899
|
}
|
|
@@ -11898,7 +11903,7 @@ function isCircularRequest(file, request) {
|
|
|
11898
11903
|
}
|
|
11899
11904
|
|
|
11900
11905
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
11901
|
-
var
|
|
11906
|
+
var import_compiler62 = require("@marko/compiler");
|
|
11902
11907
|
var import_babel_utils50 = require("@marko/compiler/babel-utils");
|
|
11903
11908
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
|
11904
11909
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
|
@@ -11931,7 +11936,7 @@ var dynamic_tag_default = {
|
|
|
11931
11936
|
tagSection
|
|
11932
11937
|
);
|
|
11933
11938
|
if (hasVar || tag.node.attributes.some(
|
|
11934
|
-
(attr) =>
|
|
11939
|
+
(attr) => import_compiler62.types.isMarkoSpreadAttribute(attr) || isEventOrChangeHandler(attr.name)
|
|
11935
11940
|
)) {
|
|
11936
11941
|
(0, import_babel_utils50.getProgram)().node.extra.isInteractive = true;
|
|
11937
11942
|
}
|
|
@@ -11971,7 +11976,7 @@ var dynamic_tag_default = {
|
|
|
11971
11976
|
if (isOutputHTML()) {
|
|
11972
11977
|
knownTagTranslateHTML(
|
|
11973
11978
|
tag,
|
|
11974
|
-
|
|
11979
|
+
import_compiler62.types.memberExpression(tag.node.name, import_compiler62.types.identifier("content")),
|
|
11975
11980
|
definedBodySection,
|
|
11976
11981
|
propTree
|
|
11977
11982
|
);
|
|
@@ -11988,9 +11993,9 @@ var dynamic_tag_default = {
|
|
|
11988
11993
|
"render",
|
|
11989
11994
|
section,
|
|
11990
11995
|
void 0,
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11996
|
+
import_compiler62.types.expressionStatement(
|
|
11997
|
+
import_compiler62.types.callExpression(
|
|
11998
|
+
import_compiler62.types.memberExpression(signal.identifier, import_compiler62.types.identifier("_")),
|
|
11994
11999
|
[
|
|
11995
12000
|
createScopeReadExpression(childBinding, section),
|
|
11996
12001
|
getScopeExpression(section, definedBodySection.parent)
|
|
@@ -12015,7 +12020,7 @@ var dynamic_tag_default = {
|
|
|
12015
12020
|
const nodeBinding = tagExtra[kDOMBinding3];
|
|
12016
12021
|
const isClassAPI = tagExtra.featureType === "class";
|
|
12017
12022
|
let tagExpression = node.name;
|
|
12018
|
-
if (
|
|
12023
|
+
if (import_compiler62.types.isStringLiteral(tagExpression)) {
|
|
12019
12024
|
tagExpression = (0, import_babel_utils50.importDefault)(
|
|
12020
12025
|
tag.hub.file,
|
|
12021
12026
|
getTagRelativePath(tag),
|
|
@@ -12025,14 +12030,14 @@ var dynamic_tag_default = {
|
|
|
12025
12030
|
if (isClassAPI) {
|
|
12026
12031
|
if (isOutputHTML()) {
|
|
12027
12032
|
(0, import_babel_utils50.getProgram)().node.body.push(
|
|
12028
|
-
|
|
12033
|
+
import_compiler62.types.markoScriptlet(
|
|
12029
12034
|
[
|
|
12030
|
-
|
|
12031
|
-
|
|
12035
|
+
import_compiler62.types.expressionStatement(
|
|
12036
|
+
import_compiler62.types.callExpression(
|
|
12032
12037
|
(0, import_babel_utils50.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
12033
12038
|
[
|
|
12034
|
-
|
|
12035
|
-
|
|
12039
|
+
import_compiler62.types.identifier(tagExpression.name),
|
|
12040
|
+
import_compiler62.types.stringLiteral((0, import_babel_utils50.loadFileForTag)(tag).metadata.marko.id)
|
|
12036
12041
|
]
|
|
12037
12042
|
)
|
|
12038
12043
|
)
|
|
@@ -12042,11 +12047,11 @@ var dynamic_tag_default = {
|
|
|
12042
12047
|
);
|
|
12043
12048
|
} else {
|
|
12044
12049
|
(0, import_babel_utils50.getProgram)().node.body.push(
|
|
12045
|
-
|
|
12050
|
+
import_compiler62.types.expressionStatement(
|
|
12046
12051
|
callRuntime(
|
|
12047
12052
|
"_resume",
|
|
12048
|
-
|
|
12049
|
-
|
|
12053
|
+
import_compiler62.types.stringLiteral((0, import_babel_utils50.loadFileForTag)(tag).metadata.marko.id),
|
|
12054
|
+
import_compiler62.types.identifier(tagExpression.name)
|
|
12050
12055
|
)
|
|
12051
12056
|
)
|
|
12052
12057
|
);
|
|
@@ -12089,9 +12094,9 @@ var dynamic_tag_default = {
|
|
|
12089
12094
|
getScopeIdIdentifier(tagSection),
|
|
12090
12095
|
getScopeAccessorLiteral(nodeBinding),
|
|
12091
12096
|
tagExpression,
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12097
|
+
import_compiler62.types.arrayExpression(args),
|
|
12098
|
+
import_compiler62.types.numericLiteral(0),
|
|
12099
|
+
import_compiler62.types.numericLiteral(1),
|
|
12095
12100
|
serializeArg
|
|
12096
12101
|
) : callRuntime(
|
|
12097
12102
|
"_dynamic_tag",
|
|
@@ -12099,8 +12104,8 @@ var dynamic_tag_default = {
|
|
|
12099
12104
|
getScopeAccessorLiteral(nodeBinding),
|
|
12100
12105
|
tagExpression,
|
|
12101
12106
|
args[0],
|
|
12102
|
-
args[1] || (serializeArg ?
|
|
12103
|
-
serializeArg ?
|
|
12107
|
+
args[1] || (serializeArg ? import_compiler62.types.numericLiteral(0) : void 0),
|
|
12108
|
+
serializeArg ? import_compiler62.types.numericLiteral(0) : void 0,
|
|
12104
12109
|
serializeArg
|
|
12105
12110
|
);
|
|
12106
12111
|
if (node.var) {
|
|
@@ -12108,18 +12113,18 @@ var dynamic_tag_default = {
|
|
|
12108
12113
|
tag.get("name").toString() + "_scope"
|
|
12109
12114
|
);
|
|
12110
12115
|
statements.push(
|
|
12111
|
-
|
|
12112
|
-
|
|
12116
|
+
import_compiler62.types.variableDeclaration("const", [
|
|
12117
|
+
import_compiler62.types.variableDeclarator(
|
|
12113
12118
|
dynamicScopeIdentifier,
|
|
12114
12119
|
callRuntime("_peek_scope_id")
|
|
12115
12120
|
)
|
|
12116
12121
|
])
|
|
12117
12122
|
);
|
|
12118
12123
|
statements.push(
|
|
12119
|
-
|
|
12120
|
-
|
|
12124
|
+
import_compiler62.types.variableDeclaration("let", [
|
|
12125
|
+
import_compiler62.types.variableDeclarator(node.var, dynamicTagExpr)
|
|
12121
12126
|
]),
|
|
12122
|
-
|
|
12127
|
+
import_compiler62.types.expressionStatement(
|
|
12123
12128
|
callRuntime(
|
|
12124
12129
|
"_var",
|
|
12125
12130
|
getScopeIdIdentifier(tagSection),
|
|
@@ -12127,7 +12132,7 @@ var dynamic_tag_default = {
|
|
|
12127
12132
|
tag.node.extra[kChildOffsetScopeBinding2]
|
|
12128
12133
|
),
|
|
12129
12134
|
dynamicScopeIdentifier,
|
|
12130
|
-
|
|
12135
|
+
import_compiler62.types.stringLiteral(
|
|
12131
12136
|
getResumeRegisterId(
|
|
12132
12137
|
tagSection,
|
|
12133
12138
|
node.var.extra?.binding,
|
|
@@ -12139,7 +12144,7 @@ var dynamic_tag_default = {
|
|
|
12139
12144
|
)
|
|
12140
12145
|
);
|
|
12141
12146
|
} else {
|
|
12142
|
-
statements.push(
|
|
12147
|
+
statements.push(import_compiler62.types.expressionStatement(dynamicTagExpr));
|
|
12143
12148
|
}
|
|
12144
12149
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
12145
12150
|
replacement.skip();
|
|
@@ -12158,9 +12163,9 @@ var dynamic_tag_default = {
|
|
|
12158
12163
|
tagVarSignal.register = true;
|
|
12159
12164
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
|
12160
12165
|
const changeArgs = [
|
|
12161
|
-
|
|
12166
|
+
import_compiler62.types.memberExpression(
|
|
12162
12167
|
getScopeExpression(tagVarSignal.section, valueSection),
|
|
12163
|
-
|
|
12168
|
+
import_compiler62.types.stringLiteral(
|
|
12164
12169
|
getAccessorPrefix().BranchScopes + getScopeAccessor(nodeBinding)
|
|
12165
12170
|
),
|
|
12166
12171
|
true
|
|
@@ -12168,28 +12173,28 @@ var dynamic_tag_default = {
|
|
|
12168
12173
|
value
|
|
12169
12174
|
];
|
|
12170
12175
|
if (!isOptimize()) {
|
|
12171
|
-
changeArgs.push(
|
|
12176
|
+
changeArgs.push(import_compiler62.types.stringLiteral(varBinding.name));
|
|
12172
12177
|
}
|
|
12173
|
-
return
|
|
12178
|
+
return import_compiler62.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
12174
12179
|
};
|
|
12175
12180
|
}
|
|
12176
12181
|
signal.build = () => {
|
|
12177
12182
|
return callRuntime(
|
|
12178
12183
|
"_dynamic_tag",
|
|
12179
12184
|
getScopeAccessorLiteral(nodeBinding, true),
|
|
12180
|
-
bodySection &&
|
|
12181
|
-
tagVarSignal ?
|
|
12182
|
-
hasTagArgs &&
|
|
12185
|
+
bodySection && import_compiler62.types.identifier(bodySection.name),
|
|
12186
|
+
tagVarSignal ? import_compiler62.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
|
12187
|
+
hasTagArgs && import_compiler62.types.numericLiteral(1)
|
|
12183
12188
|
);
|
|
12184
12189
|
};
|
|
12185
12190
|
if (args.length) {
|
|
12186
|
-
const argsOrInput = hasTagArgs ?
|
|
12187
|
-
if (!
|
|
12191
|
+
const argsOrInput = hasTagArgs ? import_compiler62.types.arrayExpression(args) : args[0];
|
|
12192
|
+
if (!import_compiler62.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
|
12188
12193
|
signal.extraArgs = [
|
|
12189
|
-
|
|
12194
|
+
import_compiler62.types.arrowFunctionExpression(
|
|
12190
12195
|
[],
|
|
12191
|
-
statements.length ?
|
|
12192
|
-
statements.concat(
|
|
12196
|
+
statements.length ? import_compiler62.types.blockStatement(
|
|
12197
|
+
statements.concat(import_compiler62.types.returnStatement(argsOrInput))
|
|
12193
12198
|
) : argsOrInput
|
|
12194
12199
|
)
|
|
12195
12200
|
];
|
|
@@ -12209,7 +12214,7 @@ function enableDynamicTagResume(tag) {
|
|
|
12209
12214
|
if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && isEventOrChangeHandler(attr.name)) {
|
|
12210
12215
|
importedDynamicTagResume.add(program);
|
|
12211
12216
|
program.body.push(
|
|
12212
|
-
|
|
12217
|
+
import_compiler62.types.expressionStatement(callRuntime("_resume_dynamic_tag"))
|
|
12213
12218
|
);
|
|
12214
12219
|
return;
|
|
12215
12220
|
}
|
|
@@ -12320,7 +12325,7 @@ var tag_default = {
|
|
|
12320
12325
|
};
|
|
12321
12326
|
|
|
12322
12327
|
// src/translator/visitors/text.ts
|
|
12323
|
-
var
|
|
12328
|
+
var import_compiler64 = require("@marko/compiler");
|
|
12324
12329
|
var text_default = {
|
|
12325
12330
|
translate: {
|
|
12326
12331
|
exit(text) {
|
|
@@ -12332,6 +12337,510 @@ var text_default = {
|
|
|
12332
12337
|
}
|
|
12333
12338
|
};
|
|
12334
12339
|
|
|
12340
|
+
// src/translator/interop/index.ts
|
|
12341
|
+
var import_generator = __toESM(require("@babel/generator"));
|
|
12342
|
+
var import_compiler65 = require("@marko/compiler");
|
|
12343
|
+
var import_babel_utils53 = require("@marko/compiler/babel-utils");
|
|
12344
|
+
var translate6 = __toESM(require("@marko/runtime-tags/translator"));
|
|
12345
|
+
var import_path6 = __toESM(require("path"));
|
|
12346
|
+
|
|
12347
|
+
// src/translator/interop/feature-detection.ts
|
|
12348
|
+
var import_babel_utils52 = require("@marko/compiler/babel-utils");
|
|
12349
|
+
|
|
12350
|
+
// src/translator/interop/build-aggregate-error.ts
|
|
12351
|
+
var import_code_frame = require("@babel/code-frame");
|
|
12352
|
+
var import_path5 = __toESM(require("path"));
|
|
12353
|
+
var CWD = process.cwd();
|
|
12354
|
+
function buildAggregateError(file, rootMsg, ...paths) {
|
|
12355
|
+
const err = new SyntaxError();
|
|
12356
|
+
const fileName = import_path5.default.relative(CWD, file.opts.filename);
|
|
12357
|
+
const finalMsg = `${rootMsg}:
|
|
12358
|
+
|
|
12359
|
+
${paths.map(
|
|
12360
|
+
([msg, path7]) => `\x1B[90m${msg} at ${getFileNameWithLoc(
|
|
12361
|
+
fileName,
|
|
12362
|
+
path7
|
|
12363
|
+
)}:\x1B[0m
|
|
12364
|
+
${getFrame(file, path7)}`
|
|
12365
|
+
).join("\n\n")}`;
|
|
12366
|
+
if (!("MARKO_DEBUG" in process.env)) {
|
|
12367
|
+
err.stack = finalMsg;
|
|
12368
|
+
}
|
|
12369
|
+
Object.defineProperty(err, "message", {
|
|
12370
|
+
get() {
|
|
12371
|
+
return finalMsg;
|
|
12372
|
+
},
|
|
12373
|
+
set() {
|
|
12374
|
+
}
|
|
12375
|
+
});
|
|
12376
|
+
return err;
|
|
12377
|
+
}
|
|
12378
|
+
function getFrame(file, { node: { loc } }) {
|
|
12379
|
+
return loc ? (0, import_code_frame.codeFrameColumns)(
|
|
12380
|
+
file.code,
|
|
12381
|
+
{
|
|
12382
|
+
start: {
|
|
12383
|
+
line: loc.start.line,
|
|
12384
|
+
column: loc.start.column + 1
|
|
12385
|
+
},
|
|
12386
|
+
end: loc.end && loc.start.line === loc.end.line ? {
|
|
12387
|
+
line: loc.end.line,
|
|
12388
|
+
column: loc.end.column + 1
|
|
12389
|
+
} : void 0
|
|
12390
|
+
},
|
|
12391
|
+
{ highlightCode: true }
|
|
12392
|
+
) : "";
|
|
12393
|
+
}
|
|
12394
|
+
function getFileNameWithLoc(fileName, { node: { loc } }) {
|
|
12395
|
+
if (loc) {
|
|
12396
|
+
return `${fileName}(${loc.start.line},${loc.start.column + 1})`;
|
|
12397
|
+
}
|
|
12398
|
+
return fileName;
|
|
12399
|
+
}
|
|
12400
|
+
|
|
12401
|
+
// src/translator/interop/feature-detection.ts
|
|
12402
|
+
function isTagsAPI(file = (0, import_babel_utils52.getFile)()) {
|
|
12403
|
+
const program = file.path;
|
|
12404
|
+
const programExtra = program.node.extra ??= {};
|
|
12405
|
+
let { featureType } = programExtra;
|
|
12406
|
+
if (!featureType) {
|
|
12407
|
+
const lookup = (0, import_babel_utils52.getTaglibLookup)(file);
|
|
12408
|
+
const tagsDir = getTagsDir(file.opts.filename);
|
|
12409
|
+
const state = {};
|
|
12410
|
+
if (tagsDir && !lookup.manualTagsDirs?.has(tagsDir)) {
|
|
12411
|
+
addFeature(
|
|
12412
|
+
state,
|
|
12413
|
+
"tags" /* Tags */,
|
|
12414
|
+
"Template file within a tags directory",
|
|
12415
|
+
program
|
|
12416
|
+
);
|
|
12417
|
+
}
|
|
12418
|
+
scanBody(state, program.get("body"));
|
|
12419
|
+
featureType = file.metadata.marko.api = programExtra.featureType = state.feature?.type || (lookup.exclusiveTagDiscoveryDirs === "tags" ? "tags" /* Tags */ : "class" /* Class */);
|
|
12420
|
+
}
|
|
12421
|
+
return featureType === "tags" /* Tags */;
|
|
12422
|
+
}
|
|
12423
|
+
function getTagsDir(filename) {
|
|
12424
|
+
const pathSeparator = /\/|\\/.exec(filename)?.[0];
|
|
12425
|
+
if (pathSeparator) {
|
|
12426
|
+
let previousIndex = filename.length - 1;
|
|
12427
|
+
while (previousIndex > 0) {
|
|
12428
|
+
const index = filename.lastIndexOf(pathSeparator, previousIndex);
|
|
12429
|
+
switch (previousIndex - index) {
|
|
12430
|
+
case 4: {
|
|
12431
|
+
if (filename.startsWith("tags", index + 1)) {
|
|
12432
|
+
return filename.slice(0, index + 5);
|
|
12433
|
+
}
|
|
12434
|
+
break;
|
|
12435
|
+
}
|
|
12436
|
+
case 10: {
|
|
12437
|
+
if (filename.startsWith("components", index + 1)) {
|
|
12438
|
+
return false;
|
|
12439
|
+
}
|
|
12440
|
+
break;
|
|
12441
|
+
}
|
|
12442
|
+
}
|
|
12443
|
+
previousIndex = index - 1;
|
|
12444
|
+
}
|
|
12445
|
+
}
|
|
12446
|
+
return false;
|
|
12447
|
+
}
|
|
12448
|
+
function scanBody(state, body) {
|
|
12449
|
+
if (body?.length) {
|
|
12450
|
+
for (const child of body) {
|
|
12451
|
+
switch (child.type) {
|
|
12452
|
+
case "MarkoTag":
|
|
12453
|
+
scanTag(state, child);
|
|
12454
|
+
break;
|
|
12455
|
+
case "MarkoComment":
|
|
12456
|
+
if (/^\s*use tags\s*$/.test(child.node.value)) {
|
|
12457
|
+
addFeature(state, "tags" /* Tags */, "<!-- use tags -->", child);
|
|
12458
|
+
} else if (/^\s*use class\s*$/.test(child.node.value)) {
|
|
12459
|
+
addFeature(state, "class" /* Class */, "<!-- use class -->", child);
|
|
12460
|
+
}
|
|
12461
|
+
break;
|
|
12462
|
+
case "MarkoScriptlet":
|
|
12463
|
+
if (!child.node.static) {
|
|
12464
|
+
addFeature(state, "class" /* Class */, "Scriptlet", child);
|
|
12465
|
+
}
|
|
12466
|
+
break;
|
|
12467
|
+
case "MarkoClass":
|
|
12468
|
+
addFeature(
|
|
12469
|
+
state,
|
|
12470
|
+
"class" /* Class */,
|
|
12471
|
+
"Class block",
|
|
12472
|
+
child.get("body")
|
|
12473
|
+
);
|
|
12474
|
+
break;
|
|
12475
|
+
}
|
|
12476
|
+
}
|
|
12477
|
+
}
|
|
12478
|
+
}
|
|
12479
|
+
function scanTag(state, tag) {
|
|
12480
|
+
if (tag.node.var) {
|
|
12481
|
+
addFeature(
|
|
12482
|
+
state,
|
|
12483
|
+
"tags" /* Tags */,
|
|
12484
|
+
"Tag variable",
|
|
12485
|
+
tag.get("var")
|
|
12486
|
+
);
|
|
12487
|
+
}
|
|
12488
|
+
const tagDef = (0, import_babel_utils52.getTagDef)(tag);
|
|
12489
|
+
if (tagDef) {
|
|
12490
|
+
if (tagDef.name === "style") {
|
|
12491
|
+
if (/^style(?:(?:\.[^.\s\\/:*?"<>|({]+)+)?\s*\{/.test(
|
|
12492
|
+
tag.node.rawValue || ""
|
|
12493
|
+
)) {
|
|
12494
|
+
addFeature(state, "class" /* Class */, `style block`, tag.get("name"));
|
|
12495
|
+
}
|
|
12496
|
+
} else if (tagDef.taglibId === runtime_info_default.taglibId) {
|
|
12497
|
+
const feature = getFeatureTypeFromCoreTagName(tagDef.name);
|
|
12498
|
+
if (feature) {
|
|
12499
|
+
addFeature(state, feature, `<${tagDef.name}> tag`, tag.get("name"));
|
|
12500
|
+
}
|
|
12501
|
+
}
|
|
12502
|
+
}
|
|
12503
|
+
if (!tagDef?.parseOptions?.rawOpenTag) {
|
|
12504
|
+
for (const attr of tag.get("attributes")) {
|
|
12505
|
+
if (attr.isMarkoAttribute()) {
|
|
12506
|
+
if (attr.node.arguments?.length) {
|
|
12507
|
+
addFeature(
|
|
12508
|
+
state,
|
|
12509
|
+
"class" /* Class */,
|
|
12510
|
+
"Attribute arguments",
|
|
12511
|
+
attr.get("arguments")[0]
|
|
12512
|
+
);
|
|
12513
|
+
break;
|
|
12514
|
+
} else if (attr.node.modifier) {
|
|
12515
|
+
addFeature(state, "class" /* Class */, "Attribute modifier", attr);
|
|
12516
|
+
break;
|
|
12517
|
+
} else if (attr.node.bound) {
|
|
12518
|
+
addFeature(state, "tags" /* Tags */, "Bound attribute", attr);
|
|
12519
|
+
break;
|
|
12520
|
+
}
|
|
12521
|
+
}
|
|
12522
|
+
}
|
|
12523
|
+
}
|
|
12524
|
+
scanBody(state, tag.get("body").get("body"));
|
|
12525
|
+
scanBody(state, tag.get("attributeTags"));
|
|
12526
|
+
}
|
|
12527
|
+
function getFeatureTypeFromCoreTagName(tagName) {
|
|
12528
|
+
switch (tagName) {
|
|
12529
|
+
case "await-reorderer":
|
|
12530
|
+
case "class":
|
|
12531
|
+
case "include-html":
|
|
12532
|
+
case "include-text":
|
|
12533
|
+
case "init-components":
|
|
12534
|
+
case "macro":
|
|
12535
|
+
case "module-code":
|
|
12536
|
+
case "while":
|
|
12537
|
+
return "class" /* Class */;
|
|
12538
|
+
case "const":
|
|
12539
|
+
case "debug":
|
|
12540
|
+
case "define":
|
|
12541
|
+
case "id":
|
|
12542
|
+
case "let":
|
|
12543
|
+
case "lifecycle":
|
|
12544
|
+
case "log":
|
|
12545
|
+
case "return":
|
|
12546
|
+
case "try":
|
|
12547
|
+
return "tags" /* Tags */;
|
|
12548
|
+
default:
|
|
12549
|
+
return void 0;
|
|
12550
|
+
}
|
|
12551
|
+
}
|
|
12552
|
+
function addFeature(state, type, name2, path7) {
|
|
12553
|
+
if (state.feature) {
|
|
12554
|
+
if (state.feature.type !== type) {
|
|
12555
|
+
throw buildAggregateError(
|
|
12556
|
+
path7.hub.file,
|
|
12557
|
+
"Cannot mix Tags API and Class API features in the same file",
|
|
12558
|
+
[state.feature.name, state.feature.path],
|
|
12559
|
+
[name2, path7]
|
|
12560
|
+
);
|
|
12561
|
+
}
|
|
12562
|
+
} else {
|
|
12563
|
+
state.feature = {
|
|
12564
|
+
name: name2,
|
|
12565
|
+
path: path7,
|
|
12566
|
+
type
|
|
12567
|
+
};
|
|
12568
|
+
}
|
|
12569
|
+
}
|
|
12570
|
+
|
|
12571
|
+
// src/translator/interop/index.ts
|
|
12572
|
+
function createInteropTranslator(translate5) {
|
|
12573
|
+
return {
|
|
12574
|
+
preferAPI: translate5.preferAPI,
|
|
12575
|
+
transform: mergeVisitors(translate5.transform, translate6.transform),
|
|
12576
|
+
analyze: mergeVisitors(translate5.analyze, translate6.analyze),
|
|
12577
|
+
translate: patchTranslateProgram(
|
|
12578
|
+
mergeVisitors(translate5.translate, translate6.translate)
|
|
12579
|
+
),
|
|
12580
|
+
tagDiscoveryDirs: [
|
|
12581
|
+
...translate6.tagDiscoveryDirs,
|
|
12582
|
+
...translate5.tagDiscoveryDirs
|
|
12583
|
+
],
|
|
12584
|
+
taglibs: mergeTaglibs(
|
|
12585
|
+
import_compiler65.taglib.resolveOptionalTaglibs(translate5.optionalTaglibs).concat(translate5.taglibs),
|
|
12586
|
+
translate6.taglibs
|
|
12587
|
+
),
|
|
12588
|
+
getRuntimeEntryFiles(output, optimize) {
|
|
12589
|
+
return [
|
|
12590
|
+
...translate5.getRuntimeEntryFiles(output, optimize),
|
|
12591
|
+
...translate6.getRuntimeEntryFiles(output, optimize)
|
|
12592
|
+
];
|
|
12593
|
+
}
|
|
12594
|
+
};
|
|
12595
|
+
function patchTranslateProgram(visitor) {
|
|
12596
|
+
const { Program } = visitor;
|
|
12597
|
+
const kState2 = Symbol();
|
|
12598
|
+
const entryBuilder = {
|
|
12599
|
+
build(entryFile) {
|
|
12600
|
+
const state = entryFile[kState2];
|
|
12601
|
+
if (!state) {
|
|
12602
|
+
throw entryFile.path.buildCodeFrameError(
|
|
12603
|
+
"Unable to build hydrate code, no files were visited before finalizing the build"
|
|
12604
|
+
);
|
|
12605
|
+
}
|
|
12606
|
+
if (state.has5) {
|
|
12607
|
+
if (state.has6) {
|
|
12608
|
+
const filename = entryFile.opts.filename;
|
|
12609
|
+
const baseName = `./${import_path6.default.basename(filename)}`;
|
|
12610
|
+
const generatorOpts = {
|
|
12611
|
+
...entryFile.opts.generatorOpts,
|
|
12612
|
+
sourceMaps: false
|
|
12613
|
+
};
|
|
12614
|
+
const { resolveVirtualDependency } = entryFile.markoOpts;
|
|
12615
|
+
const importHydrateProgram = (name2, statements) => {
|
|
12616
|
+
return import_compiler65.types.importDeclaration(
|
|
12617
|
+
[import_compiler65.types.importDefaultSpecifier(import_compiler65.types.identifier(`init${name2}`))],
|
|
12618
|
+
import_compiler65.types.stringLiteral(
|
|
12619
|
+
resolveVirtualDependency(filename, {
|
|
12620
|
+
code: (0, import_generator.default)(import_compiler65.types.program(statements), generatorOpts).code,
|
|
12621
|
+
virtualPath: `${baseName}.hydrate-${name2}.js`
|
|
12622
|
+
})
|
|
12623
|
+
)
|
|
12624
|
+
);
|
|
12625
|
+
};
|
|
12626
|
+
return [
|
|
12627
|
+
importHydrateProgram(
|
|
12628
|
+
"6",
|
|
12629
|
+
translate6.internalEntryBuilder.build(entryFile, true)
|
|
12630
|
+
),
|
|
12631
|
+
importHydrateProgram(
|
|
12632
|
+
"5",
|
|
12633
|
+
translate5.internalEntryBuilder.build(entryFile, true)
|
|
12634
|
+
),
|
|
12635
|
+
import_compiler65.types.expressionStatement(
|
|
12636
|
+
import_compiler65.types.callExpression(import_compiler65.types.identifier("init6"), [])
|
|
12637
|
+
),
|
|
12638
|
+
import_compiler65.types.expressionStatement(
|
|
12639
|
+
import_compiler65.types.callExpression(import_compiler65.types.identifier("init5"), [])
|
|
12640
|
+
)
|
|
12641
|
+
];
|
|
12642
|
+
} else {
|
|
12643
|
+
return translate5.internalEntryBuilder.build(entryFile);
|
|
12644
|
+
}
|
|
12645
|
+
} else {
|
|
12646
|
+
return translate6.internalEntryBuilder.build(entryFile);
|
|
12647
|
+
}
|
|
12648
|
+
},
|
|
12649
|
+
visit(file, entryFile, visitChild) {
|
|
12650
|
+
const state = entryFile[kState2] ||= {
|
|
12651
|
+
has5: false,
|
|
12652
|
+
has6: false
|
|
12653
|
+
};
|
|
12654
|
+
if (isTagsAPI(file)) {
|
|
12655
|
+
state.has6 = true;
|
|
12656
|
+
translate6.internalEntryBuilder.visit(file, entryFile, visitChild);
|
|
12657
|
+
} else {
|
|
12658
|
+
state.has5 = true;
|
|
12659
|
+
translate5.internalEntryBuilder.visit(file, entryFile, visitChild);
|
|
12660
|
+
}
|
|
12661
|
+
}
|
|
12662
|
+
};
|
|
12663
|
+
const enterProgram = getVisitorEnter(Program);
|
|
12664
|
+
return {
|
|
12665
|
+
...visitor,
|
|
12666
|
+
Program: {
|
|
12667
|
+
enter(program, state) {
|
|
12668
|
+
const entryFile = program.hub.file;
|
|
12669
|
+
if (entryFile.markoOpts.output !== "hydrate") {
|
|
12670
|
+
return enterProgram?.call(this, program, state);
|
|
12671
|
+
}
|
|
12672
|
+
const visitedFiles = /* @__PURE__ */ new Set([
|
|
12673
|
+
(0, import_babel_utils53.resolveRelativePath)(entryFile, entryFile.opts.filename)
|
|
12674
|
+
]);
|
|
12675
|
+
entryBuilder.visit(
|
|
12676
|
+
entryFile,
|
|
12677
|
+
entryFile,
|
|
12678
|
+
function visitChild(resolved) {
|
|
12679
|
+
if (!visitedFiles.has(resolved)) {
|
|
12680
|
+
visitedFiles.add(resolved);
|
|
12681
|
+
const file = (0, import_babel_utils53.loadFileForImport)(entryFile, resolved);
|
|
12682
|
+
if (file) {
|
|
12683
|
+
entryBuilder.visit(
|
|
12684
|
+
file,
|
|
12685
|
+
entryFile,
|
|
12686
|
+
(id) => visitChild(resolveRelativeToEntry2(entryFile, file, id))
|
|
12687
|
+
);
|
|
12688
|
+
}
|
|
12689
|
+
}
|
|
12690
|
+
}
|
|
12691
|
+
);
|
|
12692
|
+
program.node.body = entryBuilder.build(entryFile);
|
|
12693
|
+
program.skip();
|
|
12694
|
+
},
|
|
12695
|
+
exit: getVisitorExit(Program)
|
|
12696
|
+
}
|
|
12697
|
+
};
|
|
12698
|
+
}
|
|
12699
|
+
}
|
|
12700
|
+
function mergeVisitors(visitor5, visitor6) {
|
|
12701
|
+
return mergeObjects(
|
|
12702
|
+
visitor5,
|
|
12703
|
+
visitor6,
|
|
12704
|
+
(_, value5, value6) => mergeVisit(value5, value6)
|
|
12705
|
+
);
|
|
12706
|
+
}
|
|
12707
|
+
function mergeVisit(visit5, visit6) {
|
|
12708
|
+
const enter5 = getVisitorEnter(visit5);
|
|
12709
|
+
const enter6 = getVisitorEnter(visit6);
|
|
12710
|
+
const enter3 = (enter5 || enter6) && function enter4(path7, state) {
|
|
12711
|
+
return (isTagsAPI() ? enter6 : enter5)?.call(this, path7, state);
|
|
12712
|
+
};
|
|
12713
|
+
const exit5 = getVisitorExit(visit5);
|
|
12714
|
+
const exit6 = getVisitorExit(visit6);
|
|
12715
|
+
const exit3 = (exit5 || exit6) && function exit4(path7, state) {
|
|
12716
|
+
return (isTagsAPI() ? exit6 : exit5)?.call(this, path7, state);
|
|
12717
|
+
};
|
|
12718
|
+
return exit3 ? enter3 ? { enter: enter3, exit: exit3 } : { exit: exit3 } : enter3;
|
|
12719
|
+
}
|
|
12720
|
+
function mergeTaglibs(libs5, libs6) {
|
|
12721
|
+
const libs5Map = new Map(libs5);
|
|
12722
|
+
const libs6Map = new Map(libs6);
|
|
12723
|
+
const merged = [];
|
|
12724
|
+
for (const taglibId2 of /* @__PURE__ */ new Set([...libs5Map.keys(), ...libs6Map.keys()])) {
|
|
12725
|
+
merged.push([
|
|
12726
|
+
taglibId2,
|
|
12727
|
+
mergeObjects(
|
|
12728
|
+
libs5Map.get(taglibId2),
|
|
12729
|
+
libs6Map.get(taglibId2),
|
|
12730
|
+
(key, value5, value6) => {
|
|
12731
|
+
switch (key) {
|
|
12732
|
+
case "migrate":
|
|
12733
|
+
case "analyze":
|
|
12734
|
+
case "transform":
|
|
12735
|
+
case "translate":
|
|
12736
|
+
return mergeVisitors(
|
|
12737
|
+
normalizeVisitor(value5),
|
|
12738
|
+
normalizeVisitor(value6)
|
|
12739
|
+
);
|
|
12740
|
+
default:
|
|
12741
|
+
if (key[0] === "<") {
|
|
12742
|
+
return mergeTagDef(
|
|
12743
|
+
value5,
|
|
12744
|
+
value6
|
|
12745
|
+
);
|
|
12746
|
+
}
|
|
12747
|
+
return value5 ?? value6;
|
|
12748
|
+
}
|
|
12749
|
+
}
|
|
12750
|
+
)
|
|
12751
|
+
]);
|
|
12752
|
+
}
|
|
12753
|
+
return merged;
|
|
12754
|
+
}
|
|
12755
|
+
function mergeTagDef(def5, def6) {
|
|
12756
|
+
return mergeObjects(
|
|
12757
|
+
normalizeTagDef(def5),
|
|
12758
|
+
normalizeTagDef(def6),
|
|
12759
|
+
(key, value5, value6) => {
|
|
12760
|
+
switch (key) {
|
|
12761
|
+
case "parse":
|
|
12762
|
+
case "migrate":
|
|
12763
|
+
case "transform":
|
|
12764
|
+
case "analyze":
|
|
12765
|
+
case "translate":
|
|
12766
|
+
return mergeVisit(normalizeVisit(value5), normalizeVisit(value6));
|
|
12767
|
+
default:
|
|
12768
|
+
return value5 ?? value6;
|
|
12769
|
+
}
|
|
12770
|
+
}
|
|
12771
|
+
);
|
|
12772
|
+
}
|
|
12773
|
+
function mergeObjects(a, b, cb) {
|
|
12774
|
+
const merged = {};
|
|
12775
|
+
if (a) {
|
|
12776
|
+
if (b) {
|
|
12777
|
+
for (const key in a) {
|
|
12778
|
+
merged[key] = cb(key, a[key], b[key]);
|
|
12779
|
+
}
|
|
12780
|
+
for (const key in b) {
|
|
12781
|
+
if (!(key in a)) {
|
|
12782
|
+
merged[key] = cb(key, void 0, b[key]);
|
|
12783
|
+
}
|
|
12784
|
+
}
|
|
12785
|
+
} else {
|
|
12786
|
+
for (const key in a) {
|
|
12787
|
+
merged[key] = cb(key, a[key], void 0);
|
|
12788
|
+
}
|
|
12789
|
+
}
|
|
12790
|
+
} else if (b) {
|
|
12791
|
+
for (const key in b) {
|
|
12792
|
+
merged[key] = cb(key, void 0, b[key]);
|
|
12793
|
+
}
|
|
12794
|
+
}
|
|
12795
|
+
return merged;
|
|
12796
|
+
}
|
|
12797
|
+
function normalizeTagDef(tagDef) {
|
|
12798
|
+
if (tagDef) {
|
|
12799
|
+
const normalized = {};
|
|
12800
|
+
for (const key in tagDef) {
|
|
12801
|
+
normalized[normalizeTagDefKey(key)] = tagDef[key];
|
|
12802
|
+
}
|
|
12803
|
+
return normalized;
|
|
12804
|
+
}
|
|
12805
|
+
return void 0;
|
|
12806
|
+
}
|
|
12807
|
+
function normalizeTagDefKey(key) {
|
|
12808
|
+
switch (key) {
|
|
12809
|
+
case "code-generator":
|
|
12810
|
+
case "codeGenerator":
|
|
12811
|
+
return "translate";
|
|
12812
|
+
case "migrator":
|
|
12813
|
+
return "migrate";
|
|
12814
|
+
case "node-factory":
|
|
12815
|
+
case "nodeFactory":
|
|
12816
|
+
return "parse";
|
|
12817
|
+
case "parse-options":
|
|
12818
|
+
return "parseOptions";
|
|
12819
|
+
case "transformer":
|
|
12820
|
+
return "transform";
|
|
12821
|
+
default:
|
|
12822
|
+
return key;
|
|
12823
|
+
}
|
|
12824
|
+
}
|
|
12825
|
+
function normalizeVisitor(visitor) {
|
|
12826
|
+
return visitor?.default ?? visitor;
|
|
12827
|
+
}
|
|
12828
|
+
function normalizeVisit(visitor) {
|
|
12829
|
+
return typeof visitor === "function" ? visitor : normalizeVisitor(visitor);
|
|
12830
|
+
}
|
|
12831
|
+
function getVisitorEnter(visit2) {
|
|
12832
|
+
return typeof visit2 === "function" ? visit2 : visit2?.enter;
|
|
12833
|
+
}
|
|
12834
|
+
function getVisitorExit(visit2) {
|
|
12835
|
+
return typeof visit2 === "object" ? visit2?.exit : void 0;
|
|
12836
|
+
}
|
|
12837
|
+
function resolveRelativeToEntry2(entryFile, file, req) {
|
|
12838
|
+
return file === entryFile ? (0, import_babel_utils53.resolveRelativePath)(file, req) : (0, import_babel_utils53.resolveRelativePath)(
|
|
12839
|
+
entryFile,
|
|
12840
|
+
req[0] === "." ? import_path6.default.join(file.opts.filename, "..", req) : req
|
|
12841
|
+
);
|
|
12842
|
+
}
|
|
12843
|
+
|
|
12335
12844
|
// src/translator/index.ts
|
|
12336
12845
|
var visitors = extractVisitors({
|
|
12337
12846
|
Program: program_default,
|
|
@@ -12347,10 +12856,10 @@ var visitors = extractVisitors({
|
|
|
12347
12856
|
MarkoScriptlet: scriptlet_default,
|
|
12348
12857
|
MarkoComment: comment_default
|
|
12349
12858
|
});
|
|
12350
|
-
var
|
|
12859
|
+
var tagDiscoveryDirs2 = ["tags"];
|
|
12351
12860
|
var preferAPI = "tags";
|
|
12352
|
-
var { transform, analyze, translate } = visitors;
|
|
12353
|
-
var
|
|
12861
|
+
var { transform: transform2, analyze: analyze2, translate: translate2 } = visitors;
|
|
12862
|
+
var taglibs2 = [
|
|
12354
12863
|
[
|
|
12355
12864
|
core_default.taglibId,
|
|
12356
12865
|
{
|
|
@@ -12359,7 +12868,7 @@ var taglibs = [
|
|
|
12359
12868
|
}
|
|
12360
12869
|
]
|
|
12361
12870
|
];
|
|
12362
|
-
function
|
|
12871
|
+
function getRuntimeEntryFiles2(output, optimize) {
|
|
12363
12872
|
return [
|
|
12364
12873
|
`${runtime_info_default.name}${optimize ? "" : "/debug"}/${output === "html" ? "html" : "dom"}`
|
|
12365
12874
|
];
|
|
@@ -12367,6 +12876,7 @@ function getRuntimeEntryFiles(output, optimize) {
|
|
|
12367
12876
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12368
12877
|
0 && (module.exports = {
|
|
12369
12878
|
analyze,
|
|
12879
|
+
createInteropTranslator,
|
|
12370
12880
|
getRuntimeEntryFiles,
|
|
12371
12881
|
internalEntryBuilder,
|
|
12372
12882
|
preferAPI,
|