@tamagui/static 1.115.1 → 1.115.3
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/check-dep-versions.js +389 -0
- package/dist/checkDeps.js +26 -0
- package/dist/{constants.cjs → constants.js} +14 -29
- package/dist/exports.js +33 -0
- package/dist/extractor/accessSafe.js +47 -0
- package/dist/extractor/babelParse.js +59 -0
- package/dist/extractor/buildClassName.js +72 -0
- package/dist/extractor/bundle.js +133 -0
- package/dist/extractor/bundleConfig.js +350 -0
- package/dist/extractor/{createEvaluator.cjs → createEvaluator.js} +21 -37
- package/dist/extractor/createExtractor.js +1217 -0
- package/dist/extractor/createLogger.js +32 -0
- package/dist/extractor/ensureImportingConcat.js +50 -0
- package/dist/extractor/esbuildAliasPlugin.js +36 -0
- package/dist/extractor/evaluateAstNode.js +99 -0
- package/dist/extractor/extractHelpers.js +109 -0
- package/dist/extractor/extractMediaStyle.js +123 -0
- package/dist/extractor/extractToClassNames.js +291 -0
- package/dist/extractor/extractToNative.js +319 -0
- package/dist/extractor/findTopmostFunction.js +32 -0
- package/dist/extractor/generatedUid.js +42 -0
- package/dist/extractor/getPrefixLogs.js +23 -0
- package/dist/extractor/getPropValueFromAttributes.js +65 -0
- package/dist/extractor/getSourceModule.js +66 -0
- package/dist/extractor/{getStaticBindingsForScope.cjs → getStaticBindingsForScope.js} +61 -66
- package/dist/extractor/{getTamaguiConfigPathFromOptionsConfig.cjs → getTamaguiConfigPathFromOptionsConfig.js} +11 -16
- package/dist/extractor/{hoistClassNames.cjs → hoistClassNames.js} +32 -31
- package/dist/extractor/{literalToAst.cjs → literalToAst.js} +44 -38
- package/dist/extractor/{loadFile.cjs → loadFile.js} +6 -3
- package/dist/extractor/{loadTamagui.cjs → loadTamagui.js} +78 -99
- package/dist/extractor/logLines.js +30 -0
- package/dist/extractor/{normalizeTernaries.cjs → normalizeTernaries.js} +29 -38
- package/dist/extractor/{propsToFontFamilyCache.cjs → propsToFontFamilyCache.js} +14 -18
- package/dist/extractor/regenerateConfig.js +111 -0
- package/dist/extractor/{removeUnusedHooks.cjs → removeUnusedHooks.js} +27 -31
- package/dist/extractor/{timer.cjs → timer.js} +11 -16
- package/dist/extractor/{validHTMLAttributes.cjs → validHTMLAttributes.js} +11 -16
- package/dist/extractor/{watchTamaguiConfig.cjs → watchTamaguiConfig.js} +29 -30
- package/dist/{getPragmaOptions.cjs → getPragmaOptions.js} +17 -22
- package/dist/helpers/memoize.js +33 -0
- package/dist/helpers/requireTamaguiCore.js +30 -0
- package/dist/index.js +30 -0
- package/dist/registerRequire.js +96 -0
- package/dist/{server.cjs → server.js} +21 -38
- package/dist/setup.js +1 -0
- package/dist/types.js +14 -0
- package/package.json +16 -16
- package/dist/check-dep-versions.cjs +0 -267
- package/dist/checkDeps.cjs +0 -32
- package/dist/exports.cjs +0 -40
- package/dist/extractor/accessSafe.cjs +0 -46
- package/dist/extractor/babelParse.cjs +0 -54
- package/dist/extractor/buildClassName.cjs +0 -62
- package/dist/extractor/bundle.cjs +0 -146
- package/dist/extractor/bundleConfig.cjs +0 -322
- package/dist/extractor/createExtractor.cjs +0 -1008
- package/dist/extractor/createLogger.cjs +0 -45
- package/dist/extractor/ensureImportingConcat.cjs +0 -48
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -44
- package/dist/extractor/evaluateAstNode.cjs +0 -83
- package/dist/extractor/extractHelpers.cjs +0 -120
- package/dist/extractor/extractMediaStyle.cjs +0 -129
- package/dist/extractor/extractToClassNames.cjs +0 -254
- package/dist/extractor/extractToNative.cjs +0 -274
- package/dist/extractor/findTopmostFunction.cjs +0 -34
- package/dist/extractor/generatedUid.cjs +0 -47
- package/dist/extractor/getPrefixLogs.cjs +0 -28
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -67
- package/dist/extractor/getSourceModule.cjs +0 -68
- package/dist/extractor/logLines.cjs +0 -35
- package/dist/extractor/regenerateConfig.cjs +0 -144
- package/dist/helpers/memoize.cjs +0 -37
- package/dist/helpers/requireTamaguiCore.cjs +0 -33
- package/dist/index.cjs +0 -40
- package/dist/registerRequire.cjs +0 -102
- package/dist/setup.cjs +0 -0
- package/dist/types.cjs +0 -16
- /package/dist/{check-dep-versions.cjs.map → check-dep-versions.js.map} +0 -0
- /package/dist/{checkDeps.cjs.map → checkDeps.js.map} +0 -0
- /package/dist/{constants.cjs.map → constants.js.map} +0 -0
- /package/dist/{exports.cjs.map → exports.js.map} +0 -0
- /package/dist/extractor/{accessSafe.cjs.map → accessSafe.js.map} +0 -0
- /package/dist/extractor/{babelParse.cjs.map → babelParse.js.map} +0 -0
- /package/dist/extractor/{buildClassName.cjs.map → buildClassName.js.map} +0 -0
- /package/dist/extractor/{bundle.cjs.map → bundle.js.map} +0 -0
- /package/dist/extractor/{bundleConfig.cjs.map → bundleConfig.js.map} +0 -0
- /package/dist/extractor/{createEvaluator.cjs.map → createEvaluator.js.map} +0 -0
- /package/dist/extractor/{createExtractor.cjs.map → createExtractor.js.map} +0 -0
- /package/dist/extractor/{createLogger.cjs.map → createLogger.js.map} +0 -0
- /package/dist/extractor/{ensureImportingConcat.cjs.map → ensureImportingConcat.js.map} +0 -0
- /package/dist/extractor/{esbuildAliasPlugin.cjs.map → esbuildAliasPlugin.js.map} +0 -0
- /package/dist/extractor/{evaluateAstNode.cjs.map → evaluateAstNode.js.map} +0 -0
- /package/dist/extractor/{extractHelpers.cjs.map → extractHelpers.js.map} +0 -0
- /package/dist/extractor/{extractMediaStyle.cjs.map → extractMediaStyle.js.map} +0 -0
- /package/dist/extractor/{extractToClassNames.cjs.map → extractToClassNames.js.map} +0 -0
- /package/dist/extractor/{extractToNative.cjs.map → extractToNative.js.map} +0 -0
- /package/dist/extractor/{findTopmostFunction.cjs.map → findTopmostFunction.js.map} +0 -0
- /package/dist/extractor/{generatedUid.cjs.map → generatedUid.js.map} +0 -0
- /package/dist/extractor/{getPrefixLogs.cjs.map → getPrefixLogs.js.map} +0 -0
- /package/dist/extractor/{getPropValueFromAttributes.cjs.map → getPropValueFromAttributes.js.map} +0 -0
- /package/dist/extractor/{getSourceModule.cjs.map → getSourceModule.js.map} +0 -0
- /package/dist/extractor/{getStaticBindingsForScope.cjs.map → getStaticBindingsForScope.js.map} +0 -0
- /package/dist/extractor/{getTamaguiConfigPathFromOptionsConfig.cjs.map → getTamaguiConfigPathFromOptionsConfig.js.map} +0 -0
- /package/dist/extractor/{hoistClassNames.cjs.map → hoistClassNames.js.map} +0 -0
- /package/dist/extractor/{literalToAst.cjs.map → literalToAst.js.map} +0 -0
- /package/dist/extractor/{loadFile.cjs.map → loadFile.js.map} +0 -0
- /package/dist/extractor/{loadTamagui.cjs.map → loadTamagui.js.map} +0 -0
- /package/dist/extractor/{logLines.cjs.map → logLines.js.map} +0 -0
- /package/dist/extractor/{normalizeTernaries.cjs.map → normalizeTernaries.js.map} +0 -0
- /package/dist/extractor/{propsToFontFamilyCache.cjs.map → propsToFontFamilyCache.js.map} +0 -0
- /package/dist/extractor/{regenerateConfig.cjs.map → regenerateConfig.js.map} +0 -0
- /package/dist/extractor/{removeUnusedHooks.cjs.map → removeUnusedHooks.js.map} +0 -0
- /package/dist/extractor/{timer.cjs.map → timer.js.map} +0 -0
- /package/dist/extractor/{validHTMLAttributes.cjs.map → validHTMLAttributes.js.map} +0 -0
- /package/dist/extractor/{watchTamaguiConfig.cjs.map → watchTamaguiConfig.js.map} +0 -0
- /package/dist/{getPragmaOptions.cjs.map → getPragmaOptions.js.map} +0 -0
- /package/dist/helpers/{memoize.cjs.map → memoize.js.map} +0 -0
- /package/dist/helpers/{requireTamaguiCore.cjs.map → requireTamaguiCore.js.map} +0 -0
- /package/dist/{index.cjs.map → index.js.map} +0 -0
- /package/dist/{registerRequire.cjs.map → registerRequire.js.map} +0 -0
- /package/dist/{server.cjs.map → server.js.map} +0 -0
- /package/dist/{setup.cjs.map → setup.js.map} +0 -0
- /package/dist/{types.cjs.map → types.js.map} +0 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
15
|
+
var createLogger_exports = {};
|
16
|
+
__export(createLogger_exports, {
|
17
|
+
createLogger: () => createLogger
|
18
|
+
});
|
19
|
+
module.exports = __toCommonJS(createLogger_exports);
|
20
|
+
var import_node_path = require("node:path"), import_getPrefixLogs = require("./getPrefixLogs");
|
21
|
+
function createLogger(sourcePath, options) {
|
22
|
+
const shouldLogTiming = options.logTimings ?? !0, start = Date.now(), mem = process.env.TAMAGUI_SHOW_MEMORY_USAGE && shouldLogTiming ? process.memoryUsage() : null;
|
23
|
+
return (res) => {
|
24
|
+
if (!shouldLogTiming)
|
25
|
+
return;
|
26
|
+
const memUsed = mem ? Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10 : 0, path = (0, import_node_path.basename)(sourcePath || "").replace(/\.[jt]sx?$/, "").slice(0, 22).trim().padStart(24), numOptimized = `${res.optimized + res.styled}`.padStart(3), numFound = `${res.found + res.styled}`.padStart(3), numFlattened = `${res.flattened}`.padStart(3), memory = memUsed ? ` ${memUsed}MB` : "", timingStr = `${Date.now() - start}ms`.padStart(6), pre = (0, import_getPrefixLogs.getPrefixLogs)(options), memStr = memory ? `(${memory})` : "";
|
27
|
+
console.info(
|
28
|
+
`${pre} ${path} \xB7 ${numFound} found \xB7 ${numOptimized} opt \xB7 ${numFlattened} flat ${timingStr} ${memStr}`
|
29
|
+
);
|
30
|
+
};
|
31
|
+
}
|
32
|
+
//# sourceMappingURL=createLogger.js.map
|
@@ -0,0 +1,50 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
21
|
+
mod
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
23
|
+
var ensureImportingConcat_exports = {};
|
24
|
+
__export(ensureImportingConcat_exports, {
|
25
|
+
ensureImportingConcat: () => ensureImportingConcat
|
26
|
+
});
|
27
|
+
module.exports = __toCommonJS(ensureImportingConcat_exports);
|
28
|
+
var t = __toESM(require("@babel/types"));
|
29
|
+
const importConcatPkg = "@tamagui/helpers";
|
30
|
+
function ensureImportingConcat(path) {
|
31
|
+
const imported = path.get("body").find(
|
32
|
+
(x) => x.isImportDeclaration() && x.node.source.value === importConcatPkg
|
33
|
+
), importSpecifier = t.importSpecifier(
|
34
|
+
t.identifier("concatClassName"),
|
35
|
+
t.identifier("concatClassName")
|
36
|
+
);
|
37
|
+
if (!imported) {
|
38
|
+
path.node.body.push(
|
39
|
+
t.importDeclaration([importSpecifier], t.stringLiteral(importConcatPkg))
|
40
|
+
);
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
const specifiers = imported.node.specifiers;
|
44
|
+
specifiers.some(
|
45
|
+
(x) => t.isImportSpecifier(x) && t.isIdentifier(x.imported) && x.imported.name === "concatClassName"
|
46
|
+
) || specifiers.push(
|
47
|
+
t.importSpecifier(t.identifier("concatClassName"), t.identifier("concatClassName"))
|
48
|
+
);
|
49
|
+
}
|
50
|
+
//# sourceMappingURL=ensureImportingConcat.js.map
|
@@ -0,0 +1,36 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
15
|
+
var esbuildAliasPlugin_exports = {};
|
16
|
+
__export(esbuildAliasPlugin_exports, {
|
17
|
+
esbuildAliasPlugin: () => esbuildAliasPlugin
|
18
|
+
});
|
19
|
+
module.exports = __toCommonJS(esbuildAliasPlugin_exports);
|
20
|
+
const esbuildAliasPlugin = (config) => {
|
21
|
+
const alias = config && Object.keys(config);
|
22
|
+
return {
|
23
|
+
name: "path-alias",
|
24
|
+
setup(build) {
|
25
|
+
if (!alias || !alias.length)
|
26
|
+
return;
|
27
|
+
const main = (k, args) => ({
|
28
|
+
path: config[k].replace(/\/$/, "")
|
29
|
+
});
|
30
|
+
alias.forEach((k) => {
|
31
|
+
build.onResolve({ filter: new RegExp(`^.*${k}$`) }, (args) => main(k, args)), build.onResolve({ filter: new RegExp(`^.*\\/${k}\\/.*$`) }, (args) => main(k, args));
|
32
|
+
});
|
33
|
+
}
|
34
|
+
};
|
35
|
+
};
|
36
|
+
//# sourceMappingURL=esbuildAliasPlugin.js.map
|
@@ -0,0 +1,99 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
21
|
+
mod
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
23
|
+
var evaluateAstNode_exports = {};
|
24
|
+
__export(evaluateAstNode_exports, {
|
25
|
+
evaluateAstNode: () => evaluateAstNode
|
26
|
+
});
|
27
|
+
module.exports = __toCommonJS(evaluateAstNode_exports);
|
28
|
+
var t = __toESM(require("@babel/types"));
|
29
|
+
function evaluateAstNode(exprNode, evalFn, shouldPrintDebug) {
|
30
|
+
if (exprNode !== void 0) {
|
31
|
+
if (exprNode === null)
|
32
|
+
return !0;
|
33
|
+
if (t.isJSXExpressionContainer(exprNode))
|
34
|
+
return evaluateAstNode(exprNode.expression);
|
35
|
+
if (t.isObjectExpression(exprNode)) {
|
36
|
+
const ret = {};
|
37
|
+
for (let idx = -1, len = exprNode.properties.length; ++idx < len; ) {
|
38
|
+
const value = exprNode.properties[idx];
|
39
|
+
if (!t.isObjectProperty(value))
|
40
|
+
throw new Error("evaluateAstNode can only evaluate object properties");
|
41
|
+
let key;
|
42
|
+
if (value.computed) {
|
43
|
+
if (typeof evalFn != "function")
|
44
|
+
throw new Error(
|
45
|
+
"evaluateAstNode does not support computed keys unless an eval function is provided"
|
46
|
+
);
|
47
|
+
key = evaluateAstNode(value.key, evalFn);
|
48
|
+
} else if (t.isIdentifier(value.key))
|
49
|
+
key = value.key.name;
|
50
|
+
else if (t.isStringLiteral(value.key) || t.isNumericLiteral(value.key))
|
51
|
+
key = value.key.value;
|
52
|
+
else
|
53
|
+
throw new Error("Unsupported key type: " + value.key.type);
|
54
|
+
if (typeof key != "string" && typeof key != "number")
|
55
|
+
throw new Error("key must be either a string or a number");
|
56
|
+
ret[key] = evaluateAstNode(value.value, evalFn);
|
57
|
+
}
|
58
|
+
return ret;
|
59
|
+
}
|
60
|
+
if (t.isArrayExpression(exprNode))
|
61
|
+
return exprNode.elements.map((x) => evaluateAstNode(x, evalFn));
|
62
|
+
if (t.isUnaryExpression(exprNode) && exprNode.operator === "-") {
|
63
|
+
const ret = evaluateAstNode(exprNode.argument, evalFn);
|
64
|
+
return ret == null ? null : -ret;
|
65
|
+
}
|
66
|
+
if (t.isTemplateLiteral(exprNode)) {
|
67
|
+
if (typeof evalFn != "function")
|
68
|
+
throw new Error(
|
69
|
+
"evaluateAstNode does not support template literals unless an eval function is provided"
|
70
|
+
);
|
71
|
+
let ret = "";
|
72
|
+
for (let idx = -1, len = exprNode.quasis.length; ++idx < len; ) {
|
73
|
+
const quasi = exprNode.quasis[idx], expr = exprNode.expressions[idx];
|
74
|
+
ret += quasi.value.raw, expr && (ret += evaluateAstNode(expr, evalFn));
|
75
|
+
}
|
76
|
+
return ret;
|
77
|
+
}
|
78
|
+
if (t.isNullLiteral(exprNode))
|
79
|
+
return null;
|
80
|
+
if (t.isNumericLiteral(exprNode) || t.isStringLiteral(exprNode) || t.isBooleanLiteral(exprNode))
|
81
|
+
return exprNode.value;
|
82
|
+
if (t.isBinaryExpression(exprNode)) {
|
83
|
+
if (exprNode.operator === "+")
|
84
|
+
return evaluateAstNode(exprNode.left, evalFn) + evaluateAstNode(exprNode.right, evalFn);
|
85
|
+
if (exprNode.operator === "-")
|
86
|
+
return evaluateAstNode(exprNode.left, evalFn) - evaluateAstNode(exprNode.right, evalFn);
|
87
|
+
if (exprNode.operator === "*")
|
88
|
+
return evaluateAstNode(exprNode.left, evalFn) * evaluateAstNode(exprNode.right, evalFn);
|
89
|
+
if (exprNode.operator === "/")
|
90
|
+
return evaluateAstNode(exprNode.left, evalFn) / evaluateAstNode(exprNode.right, evalFn);
|
91
|
+
}
|
92
|
+
if (typeof evalFn != "function")
|
93
|
+
throw new Error(
|
94
|
+
"evaluateAstNode does not support non-literal values unless an eval function is provided"
|
95
|
+
);
|
96
|
+
return evalFn(exprNode);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
//# sourceMappingURL=evaluateAstNode.js.map
|
@@ -0,0 +1,109 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
21
|
+
mod
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
23
|
+
var extractHelpers_exports = {};
|
24
|
+
__export(extractHelpers_exports, {
|
25
|
+
attrStr: () => attrStr,
|
26
|
+
findComponentName: () => findComponentName,
|
27
|
+
getValidComponent: () => getValidComponent,
|
28
|
+
getValidComponentsPaths: () => getValidComponentsPaths,
|
29
|
+
getValidImport: () => getValidImport,
|
30
|
+
isComponentPackage: () => isComponentPackage,
|
31
|
+
isInsideComponentPackage: () => isInsideComponentPackage,
|
32
|
+
isPresent: () => isPresent,
|
33
|
+
isSimpleSpread: () => isSimpleSpread,
|
34
|
+
isValidImport: () => isValidImport,
|
35
|
+
isValidModule: () => isValidModule,
|
36
|
+
isValidThemeHook: () => isValidThemeHook,
|
37
|
+
objToStr: () => objToStr,
|
38
|
+
ternaryStr: () => ternaryStr
|
39
|
+
});
|
40
|
+
module.exports = __toCommonJS(extractHelpers_exports);
|
41
|
+
var import_node_path = require("node:path"), import_generator = __toESM(require("@babel/generator")), t = __toESM(require("@babel/types")), import_find_root = __toESM(require("find-root")), import_memoize = require("../helpers/memoize");
|
42
|
+
function isPresent(input) {
|
43
|
+
return input != null;
|
44
|
+
}
|
45
|
+
function isSimpleSpread(node) {
|
46
|
+
return t.isIdentifier(node.argument) || t.isMemberExpression(node.argument);
|
47
|
+
}
|
48
|
+
const attrStr = (attr) => attr ? attr.type === "attr" ? getNameAttr(attr.value) : attr.type === "ternary" ? `...${ternaryStr(attr.value)}` : `${attr.type}(${objToStr(attr.value)})` : "", objToStr = (obj, spacer = ", ") => obj ? `{${Object.entries(obj).map(
|
49
|
+
([k, v]) => `${k}:${Array.isArray(v) ? "[...]" : v && typeof v == "object" ? `${objToStr(v, ",")}` : JSON.stringify(v)}`
|
50
|
+
).join(spacer)}}` : `${obj}`, getNameAttr = (attr) => t.isJSXSpreadAttribute(attr) ? `...${attr.argument.name}` : "name" in attr ? attr.name.name : `unknown-${attr.type}`, ternaryStr = (x) => [
|
51
|
+
"ternary(",
|
52
|
+
t.isIdentifier(x.test) ? x.test.name : t.isMemberExpression(x.test) ? [x.test.object.name, x.test.property.name] : (
|
53
|
+
// @ts-ignore
|
54
|
+
(0, import_generator.default)(x.test).code
|
55
|
+
),
|
56
|
+
isFilledObj(x.consequent) ? ` ? ${objToStr(x.consequent)}` : " ? \u{1F6AB}",
|
57
|
+
isFilledObj(x.alternate) ? ` : ${objToStr(x.alternate)}` : " : \u{1F6AB}",
|
58
|
+
")"
|
59
|
+
].flat().join(""), isFilledObj = (obj) => obj && Object.keys(obj).length;
|
60
|
+
function findComponentName(scope) {
|
61
|
+
const componentName = "";
|
62
|
+
let cur = scope.path;
|
63
|
+
for (; cur.parentPath && !t.isProgram(cur.parentPath.parent); )
|
64
|
+
cur = cur.parentPath;
|
65
|
+
let node = cur.parent;
|
66
|
+
if (t.isExportNamedDeclaration(node) && (node = node.declaration), t.isVariableDeclaration(node)) {
|
67
|
+
const [dec] = node.declarations;
|
68
|
+
if (t.isVariableDeclarator(dec) && t.isIdentifier(dec.id))
|
69
|
+
return dec.id.name;
|
70
|
+
}
|
71
|
+
return t.isFunctionDeclaration(node) ? node.id?.name : componentName;
|
72
|
+
}
|
73
|
+
function isValidThemeHook(props, jsxPath, n, sourcePath) {
|
74
|
+
if (!t.isIdentifier(n.object) || !t.isIdentifier(n.property)) return !1;
|
75
|
+
const binding = jsxPath.scope.getAllBindings()[n.object.name];
|
76
|
+
if (!binding?.path || !binding.path.isVariableDeclarator()) return !1;
|
77
|
+
const init = binding.path.node.init;
|
78
|
+
if (!init || !t.isCallExpression(init) || !t.isIdentifier(init.callee) || init.callee.name !== "useTheme") return !1;
|
79
|
+
const importNode = binding.scope.getBinding("useTheme")?.path.parent;
|
80
|
+
return !(!t.isImportDeclaration(importNode) || sourcePath && !isValidImport(props, sourcePath));
|
81
|
+
}
|
82
|
+
const isInsideComponentPackage = (props, moduleName) => getValidComponentsPaths(props).some((path) => moduleName.startsWith(path)), isComponentPackage = (props, srcName) => getValidComponentsPaths(props).some((path) => srcName.startsWith(path));
|
83
|
+
function getValidComponent(props, moduleName, componentName) {
|
84
|
+
if (componentName[0].toUpperCase() !== componentName[0])
|
85
|
+
return !1;
|
86
|
+
for (const loaded of props.allLoadedComponents) {
|
87
|
+
if (!loaded) continue;
|
88
|
+
const isInModule = moduleName === "*" || moduleName.startsWith(loaded.moduleName), foundComponent = loaded.nameToInfo[componentName];
|
89
|
+
if (isInModule && foundComponent)
|
90
|
+
return foundComponent;
|
91
|
+
}
|
92
|
+
return null;
|
93
|
+
}
|
94
|
+
const isValidModule = (props, moduleName) => {
|
95
|
+
if (typeof moduleName != "string")
|
96
|
+
throw new Error("No module name");
|
97
|
+
const isLocal = moduleName.startsWith(".");
|
98
|
+
return {
|
99
|
+
isLocal,
|
100
|
+
isValid: isLocal ? isInsideComponentPackage(props, moduleName) : isComponentPackage(props, moduleName)
|
101
|
+
};
|
102
|
+
}, getValidImport = (props, moduleName, componentName) => {
|
103
|
+
const { isValid, isLocal } = isValidModule(props, moduleName);
|
104
|
+
return !isValid || !componentName ? null : getValidComponent(props, isLocal ? "*" : moduleName, componentName) || null;
|
105
|
+
}, isValidImport = (props, moduleName, componentName) => componentName ? !!getValidImport(props, moduleName, componentName) : isValidModule(props, moduleName).isValid, getValidComponentPackages = (0, import_memoize.memoize)((props) => [.../* @__PURE__ */ new Set(["@tamagui/core", "tamagui", ...props.components || []])]), getValidComponentsPaths = (0, import_memoize.memoize)((props) => getValidComponentPackages(props).flatMap((pkg) => {
|
106
|
+
const root = (0, import_find_root.default)(pkg);
|
107
|
+
return [(0, import_node_path.basename)(root), pkg].filter(Boolean);
|
108
|
+
}));
|
109
|
+
//# sourceMappingURL=extractHelpers.js.map
|
@@ -0,0 +1,123 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
21
|
+
mod
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
23
|
+
var extractMediaStyle_exports = {};
|
24
|
+
__export(extractMediaStyle_exports, {
|
25
|
+
extractMediaStyle: () => extractMediaStyle,
|
26
|
+
isValidMediaCall: () => isValidMediaCall
|
27
|
+
});
|
28
|
+
module.exports = __toCommonJS(extractMediaStyle_exports);
|
29
|
+
var t = __toESM(require("@babel/types")), core = __toESM(require("@tamagui/core")), import_requireTamaguiCore = require("../helpers/requireTamaguiCore"), import_extractHelpers = require("./extractHelpers");
|
30
|
+
function extractMediaStyle(props, ternary, jsxPath, tamaguiConfig, sourcePath, importance = 0, shouldPrintDebug = !1) {
|
31
|
+
const { getStylesAtomic, mediaObjectToString } = (0, import_requireTamaguiCore.requireTamaguiCore)("web"), mt = getMediaQueryTernary(props, ternary, jsxPath, sourcePath);
|
32
|
+
if (!mt)
|
33
|
+
return null;
|
34
|
+
const { key } = mt;
|
35
|
+
if (!tamaguiConfig.media[key])
|
36
|
+
return console.error(`Media query "${key}" not found: ${Object.keys(tamaguiConfig.media)}`), null;
|
37
|
+
const getStyleObj = (styleObj, negate = !1) => styleObj ? { styleObj, negate } : null, styleOpts = [
|
38
|
+
getStyleObj(ternary.consequent, !1),
|
39
|
+
getStyleObj(ternary.alternate, !0)
|
40
|
+
].filter(import_extractHelpers.isPresent);
|
41
|
+
if (shouldPrintDebug && !styleOpts.length)
|
42
|
+
return console.info(" media query, no styles?"), null;
|
43
|
+
const mediaKeyPrecendence = Object.keys(tamaguiConfig.media).reduce((acc, cur, i) => (acc[cur] = new Array(importance + 1).fill(":root").join(""), acc), {});
|
44
|
+
let mediaStyles = [];
|
45
|
+
for (const { styleObj, negate } of styleOpts) {
|
46
|
+
const singleMediaStyles = getStylesAtomic(styleObj).map((style) => {
|
47
|
+
const mediaStyle = core.createMediaStyle(
|
48
|
+
style,
|
49
|
+
key,
|
50
|
+
tamaguiConfig.media,
|
51
|
+
!0,
|
52
|
+
negate
|
53
|
+
), className = `.${mediaStyle[core.StyleObjectIdentifier]}`;
|
54
|
+
return {
|
55
|
+
...mediaStyle,
|
56
|
+
className
|
57
|
+
};
|
58
|
+
});
|
59
|
+
shouldPrintDebug === "verbose" && console.info(
|
60
|
+
" media styles:",
|
61
|
+
importance,
|
62
|
+
styleObj,
|
63
|
+
singleMediaStyles.map((x) => x[core.StyleObjectIdentifier]).join(", ")
|
64
|
+
), mediaStyles = [...mediaStyles, ...singleMediaStyles];
|
65
|
+
}
|
66
|
+
return ternary.remove(), { mediaStyles, ternaryWithoutMedia: mt.ternaryWithoutMedia };
|
67
|
+
}
|
68
|
+
function getMediaQueryTernary(props, ternary, jsxPath, sourcePath) {
|
69
|
+
if (t.isLogicalExpression(ternary.test) && ternary.test.operator === "&&") {
|
70
|
+
const mediaLeft = getMediaInfoFromExpression(
|
71
|
+
props,
|
72
|
+
ternary.test.left,
|
73
|
+
jsxPath,
|
74
|
+
sourcePath,
|
75
|
+
ternary.inlineMediaQuery
|
76
|
+
);
|
77
|
+
if (mediaLeft)
|
78
|
+
return {
|
79
|
+
...mediaLeft,
|
80
|
+
ternaryWithoutMedia: {
|
81
|
+
...ternary,
|
82
|
+
test: ternary.test.right
|
83
|
+
}
|
84
|
+
};
|
85
|
+
}
|
86
|
+
const result = getMediaInfoFromExpression(
|
87
|
+
props,
|
88
|
+
ternary.test,
|
89
|
+
jsxPath,
|
90
|
+
sourcePath,
|
91
|
+
ternary.inlineMediaQuery
|
92
|
+
);
|
93
|
+
return result ? {
|
94
|
+
...result,
|
95
|
+
ternaryWithoutMedia: null
|
96
|
+
} : null;
|
97
|
+
}
|
98
|
+
function getMediaInfoFromExpression(props, test, jsxPath, sourcePath, inlineMediaQuery) {
|
99
|
+
if (inlineMediaQuery)
|
100
|
+
return {
|
101
|
+
key: inlineMediaQuery,
|
102
|
+
bindingName: inlineMediaQuery
|
103
|
+
};
|
104
|
+
if (t.isMemberExpression(test) && t.isIdentifier(test.object) && t.isIdentifier(test.property)) {
|
105
|
+
const name = test.object.name, key = test.property.name, binding = jsxPath.scope.getAllBindings()[name];
|
106
|
+
if (!binding) return !1;
|
107
|
+
const bindingNode = binding.path?.node;
|
108
|
+
return !t.isVariableDeclarator(bindingNode) || !bindingNode.init || !isValidMediaCall(props, jsxPath, bindingNode.init, sourcePath) ? !1 : { key, bindingName: name };
|
109
|
+
}
|
110
|
+
if (t.isIdentifier(test)) {
|
111
|
+
const key = test.name, node = jsxPath.scope.getBinding(test.name)?.path?.node;
|
112
|
+
return !t.isVariableDeclarator(node) || !node.init || !isValidMediaCall(props, jsxPath, node.init, sourcePath) ? !1 : { key, bindingName: key };
|
113
|
+
}
|
114
|
+
return null;
|
115
|
+
}
|
116
|
+
function isValidMediaCall(props, jsxPath, init, sourcePath) {
|
117
|
+
if (!init || !t.isCallExpression(init) || !t.isIdentifier(init.callee) || init.callee.name !== "useMedia") return !1;
|
118
|
+
const mediaBinding = jsxPath.scope.getAllBindings().useMedia;
|
119
|
+
if (!mediaBinding) return !1;
|
120
|
+
const useMediaImport = mediaBinding.path.parent;
|
121
|
+
return !(!t.isImportDeclaration(useMediaImport) || !(0, import_extractHelpers.isValidImport)(props, sourcePath));
|
122
|
+
}
|
123
|
+
//# sourceMappingURL=extractMediaStyle.js.map
|