@marko/runtime-tags 6.0.100 → 6.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/translator/index.js
CHANGED
|
@@ -757,6 +757,8 @@ function isMarko(path5) {
|
|
|
757
757
|
case "MarkoSpreadAttribute":
|
|
758
758
|
case "MarkoPlaceholder":
|
|
759
759
|
case "MarkoScriptlet":
|
|
760
|
+
case "ExportNamedDeclaration":
|
|
761
|
+
case "ExportDefaultDeclaration":
|
|
760
762
|
return true;
|
|
761
763
|
default:
|
|
762
764
|
return false;
|
|
@@ -1749,6 +1751,7 @@ function getNodeContentType(path5, extraMember, contentInfo) {
|
|
|
1749
1751
|
case "ImportDeclaration":
|
|
1750
1752
|
case "ExportAllDeclaration":
|
|
1751
1753
|
case "ExportNamedDeclaration":
|
|
1754
|
+
case "ExportDefaultDeclaration":
|
|
1752
1755
|
return null;
|
|
1753
1756
|
case "MarkoTag": {
|
|
1754
1757
|
const tag = path5;
|
|
@@ -1936,7 +1939,7 @@ var function_default = {
|
|
|
1936
1939
|
fnExtra.name = node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler8.types.toIdentifier(
|
|
1937
1940
|
markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
|
|
1938
1941
|
) : markoRoot.node.name : import_compiler8.types.isVariableDeclarator(fn.parent) && import_compiler8.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler8.types.isObjectMethod(node) && import_compiler8.types.isIdentifier(node.key) ? node.key.name : "anonymous");
|
|
1939
|
-
if (markoRoot
|
|
1942
|
+
if (isStaticRoot(markoRoot)) {
|
|
1940
1943
|
const refs = getStaticDeclRefs(fnExtra, fn);
|
|
1941
1944
|
if (refs === true) {
|
|
1942
1945
|
registerFunction(fnExtra, true);
|
|
@@ -1968,7 +1971,7 @@ function canIgnoreRegister(markoRoot, exprRoot) {
|
|
|
1968
1971
|
return (
|
|
1969
1972
|
// bail within a placeholder
|
|
1970
1973
|
markoRoot.isMarkoPlaceholder() || // bail within a server only statement
|
|
1971
|
-
markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server" || // bail within the tag name
|
|
1974
|
+
markoRoot.isMarkoScriptlet() && (!markoRoot.node.static || markoRoot.node.target === "server") || // bail within the tag name
|
|
1972
1975
|
markoRoot.isMarkoTag() && markoRoot.node.name == exprRoot.node || isMarkoAttribute(markoRoot) && (analyzeTagNameType(markoRoot.parentPath) === 0 /* NativeTag */ && // TODO: all native tag functions should avoid registration but right now change handlers require it.
|
|
1973
1976
|
/^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))
|
|
1974
1977
|
);
|
|
@@ -1982,11 +1985,12 @@ function getStaticDeclRefs(fnExtra, path5, refs = /* @__PURE__ */ new Set()) {
|
|
|
1982
1985
|
const binding = decl.scope.getBinding(name2);
|
|
1983
1986
|
if (!binding) continue;
|
|
1984
1987
|
for (const ref of binding.referencePaths) {
|
|
1985
|
-
if (isInvokedFunction(ref))
|
|
1988
|
+
if (isInvokedFunction(ref) || ref.parentPath.type === "Program")
|
|
1989
|
+
continue;
|
|
1986
1990
|
const exprRoot = getExprRoot(ref);
|
|
1987
1991
|
const markoRoot = getMarkoRoot(exprRoot);
|
|
1988
1992
|
if (!markoRoot || canIgnoreRegister(markoRoot, exprRoot)) continue;
|
|
1989
|
-
if (markoRoot
|
|
1993
|
+
if (isStaticRoot(markoRoot)) {
|
|
1990
1994
|
if (getStaticDeclRefs(fnExtra, ref, refs) === true) {
|
|
1991
1995
|
return true;
|
|
1992
1996
|
}
|
|
@@ -2043,6 +2047,17 @@ function registerFunction(fnExtra, reason) {
|
|
|
2043
2047
|
function isMarkoAttribute(path5) {
|
|
2044
2048
|
return path5 ? path5.isMarkoAttribute() : false;
|
|
2045
2049
|
}
|
|
2050
|
+
function isStaticRoot(path5) {
|
|
2051
|
+
switch (path5.type) {
|
|
2052
|
+
case "MarkoScriptlet":
|
|
2053
|
+
return path5.node.static;
|
|
2054
|
+
case "ExportDefaultDeclaration":
|
|
2055
|
+
case "ExportNamedDeclaration":
|
|
2056
|
+
return true;
|
|
2057
|
+
default:
|
|
2058
|
+
return false;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2046
2061
|
|
|
2047
2062
|
// src/translator/util/for-each-identifier.ts
|
|
2048
2063
|
function forEachIdentifier(node, cb) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { types as t } from "@marko/compiler";
|
|
2
|
-
export type MarkoExprRootPath = t.NodePath<t.MarkoTag | t.MarkoTagBody | t.MarkoAttribute | t.MarkoSpreadAttribute | t.MarkoScriptlet | t.MarkoPlaceholder>;
|
|
2
|
+
export type MarkoExprRootPath = t.NodePath<t.MarkoTag | t.MarkoTagBody | t.MarkoAttribute | t.MarkoSpreadAttribute | t.MarkoScriptlet | t.MarkoPlaceholder | t.ExportNamedDeclaration | t.ExportDefaultDeclaration>;
|
|
3
3
|
export declare function getMarkoRoot(path: t.NodePath<t.Node>): MarkoExprRootPath | null;
|
|
4
4
|
export declare function getExprRoot(path: t.NodePath<t.Node>): t.NodePath<t.Node>;
|
|
5
5
|
export declare function getFnRoot(path: t.NodePath<t.Node>): t.NodePath<t.ArrowFunctionExpression | t.FunctionExpression | t.ObjectMember> | undefined;
|