@tamagui/static 1.0.1-beta.20 → 1.0.1-beta.201
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/{cjs/constants.js → constants.js} +9 -4
- package/dist/constants.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/accessSafe.js +14 -4
- package/dist/{esm/extractor → extractor}/accessSafe.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/babelParse.js +20 -17
- package/dist/extractor/babelParse.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/buildClassName.js +40 -11
- package/dist/extractor/buildClassName.js.map +7 -0
- package/dist/extractor/bundle.js +117 -0
- package/dist/extractor/bundle.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/createEvaluator.js +19 -14
- package/dist/extractor/createEvaluator.js.map +7 -0
- package/dist/extractor/createExtractor.js +1650 -0
- package/dist/extractor/createExtractor.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/ensureImportingConcat.js +18 -8
- package/dist/extractor/ensureImportingConcat.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/evaluateAstNode.js +14 -6
- package/dist/{esm/extractor → extractor}/evaluateAstNode.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/extractHelpers.js +91 -27
- package/dist/extractor/extractHelpers.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractMediaStyle.js +49 -50
- package/dist/extractor/extractMediaStyle.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractToClassNames.js +161 -109
- package/dist/extractor/extractToClassNames.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/findTopmostFunction.js +2 -3
- package/dist/{esm/extractor → extractor}/findTopmostFunction.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/generatedUid.js +9 -4
- package/dist/{cjs/extractor → extractor}/generatedUid.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/getPrefixLogs.js +1 -2
- package/dist/extractor/getPrefixLogs.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getPropValueFromAttributes.js +24 -15
- package/dist/extractor/getPropValueFromAttributes.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getSourceModule.js +5 -3
- package/dist/{esm/extractor → extractor}/getSourceModule.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/getStaticBindingsForScope.js +88 -38
- package/dist/extractor/getStaticBindingsForScope.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/hoistClassNames.js +5 -4
- package/dist/{esm/extractor → extractor}/hoistClassNames.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/literalToAst.js +26 -34
- package/dist/{cjs/extractor → extractor}/literalToAst.js.map +2 -2
- package/dist/extractor/loadFile.js +21 -0
- package/dist/extractor/loadFile.js.map +7 -0
- package/dist/extractor/loadTamagui.js +421 -0
- package/dist/extractor/loadTamagui.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/logLines.js +3 -3
- package/dist/{cjs/extractor → extractor}/logLines.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/normalizeTernaries.js +13 -36
- package/dist/extractor/normalizeTernaries.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js +7 -5
- package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/timer.js +11 -4
- package/dist/extractor/timer.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/validHTMLAttributes.js +52 -0
- package/dist/extractor/validHTMLAttributes.js.map +7 -0
- package/dist/getPragmaOptions.js +68 -0
- package/dist/getPragmaOptions.js.map +7 -0
- package/dist/helpers/memoize.js +46 -0
- package/dist/helpers/memoize.js.map +7 -0
- package/dist/{cjs/index.js → index.js} +10 -7
- package/dist/index.js.map +7 -0
- package/dist/require.js +90 -0
- package/dist/require.js.map +7 -0
- package/dist/tamagui-node/tamagui.config.js +6781 -0
- package/dist/{jsx/types.js → tamagui-node/tamaguicore-components.config.js} +0 -0
- package/dist/tamagui-node/tamaguitestdesignsystem-components.config.js +31 -0
- package/dist/{cjs/types.js → types.js} +1 -0
- package/dist/types.js.map +7 -0
- package/dist/webpackPlugin.js +35 -0
- package/dist/webpackPlugin.js.map +7 -0
- package/package.json +47 -35
- package/src/constants.ts +14 -0
- package/src/extractor/accessSafe.ts +18 -0
- package/src/extractor/babelParse.ts +28 -0
- package/src/extractor/buildClassName.ts +77 -0
- package/src/extractor/bundle.ts +110 -0
- package/src/extractor/createEvaluator.ts +73 -0
- package/src/extractor/createExtractor.ts +2147 -0
- package/src/extractor/ensureImportingConcat.ts +32 -0
- package/src/extractor/evaluateAstNode.ts +121 -0
- package/src/extractor/extractHelpers.ts +201 -0
- package/src/extractor/extractMediaStyle.ts +199 -0
- package/src/extractor/extractToClassNames.ts +445 -0
- package/src/extractor/findTopmostFunction.ts +22 -0
- package/src/extractor/generatedUid.ts +43 -0
- package/src/extractor/getPrefixLogs.ts +6 -0
- package/src/extractor/getPropValueFromAttributes.ts +92 -0
- package/src/extractor/getSourceModule.ts +101 -0
- package/src/extractor/getStaticBindingsForScope.ts +227 -0
- package/src/extractor/hoistClassNames.ts +45 -0
- package/src/extractor/literalToAst.ts +84 -0
- package/src/extractor/loadFile.ts +17 -0
- package/src/extractor/loadTamagui.ts +478 -0
- package/src/extractor/logLines.ts +16 -0
- package/src/extractor/normalizeTernaries.ts +63 -0
- package/src/extractor/removeUnusedHooks.ts +76 -0
- package/src/extractor/timer.ts +29 -0
- package/src/extractor/validHTMLAttributes.ts +99 -0
- package/src/getPragmaOptions.ts +53 -0
- package/src/helpers/memoize.ts +21 -0
- package/src/index.ts +11 -0
- package/src/require.ts +107 -0
- package/src/types.ts +98 -0
- package/src/webpackPlugin.ts +9 -0
- package/tamagui.tsconfig.json +5 -0
- package/types/constants.d.ts +1 -1
- package/types/extractor/babelParse.d.ts +2 -1
- package/types/extractor/buildClassName.d.ts +5 -2
- package/types/extractor/bundle.d.ts +13 -0
- package/types/extractor/createEvaluator.d.ts +4 -4
- package/types/extractor/createExtractor.d.ts +26 -11
- package/types/extractor/extractHelpers.d.ts +16 -4
- package/types/extractor/extractMediaStyle.d.ts +3 -3
- package/types/extractor/extractToClassNames.d.ts +5 -9
- package/types/extractor/getPrefixLogs.d.ts +1 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +16 -0
- package/types/extractor/getStaticBindingsForScope.d.ts +2 -1
- package/types/extractor/loadFile.d.ts +1 -0
- package/types/extractor/loadTamagui.d.ts +22 -6
- package/types/extractor/normalizeTernaries.d.ts +1 -1
- package/types/extractor/validHTMLAttributes.d.ts +49 -0
- package/types/getPragmaOptions.d.ts +9 -0
- package/types/helpers/memoize.d.ts +8 -0
- package/types/index.d.ts +9 -7
- package/types/require.d.ts +4 -0
- package/types/types.d.ts +32 -32
- package/types/webpackPlugin.d.ts +4 -0
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/extractor/accessSafe.js.map +0 -7
- package/dist/cjs/extractor/babelParse.js.map +0 -7
- package/dist/cjs/extractor/buildClassName.js.map +0 -7
- package/dist/cjs/extractor/createEvaluator.js.map +0 -7
- package/dist/cjs/extractor/createExtractor.js +0 -1221
- package/dist/cjs/extractor/createExtractor.js.map +0 -7
- package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
- package/dist/cjs/extractor/extractHelpers.js.map +0 -7
- package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
- package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
- package/dist/cjs/extractor/findTopmostFunction.js.map +0 -7
- package/dist/cjs/extractor/getPrefixLogs.js.map +0 -7
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/cjs/extractor/getSourceModule.js.map +0 -7
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
- package/dist/cjs/extractor/loadTamagui.js +0 -106
- package/dist/cjs/extractor/loadTamagui.js.map +0 -7
- package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
- package/dist/cjs/extractor/timer.js.map +0 -7
- package/dist/cjs/extractor/validHTMLAttributes.js.map +0 -7
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/patchReactNativeWeb.js +0 -167
- package/dist/cjs/patchReactNativeWeb.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/constants.js +0 -14
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/extractor/accessSafe.js +0 -11
- package/dist/esm/extractor/babelParse.js +0 -30
- package/dist/esm/extractor/babelParse.js.map +0 -7
- package/dist/esm/extractor/buildClassName.js +0 -40
- package/dist/esm/extractor/buildClassName.js.map +0 -7
- package/dist/esm/extractor/createEvaluator.js +0 -52
- package/dist/esm/extractor/createEvaluator.js.map +0 -7
- package/dist/esm/extractor/createExtractor.js +0 -1169
- package/dist/esm/extractor/createExtractor.js.map +0 -7
- package/dist/esm/extractor/ensureImportingConcat.js +0 -24
- package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/esm/extractor/evaluateAstNode.js +0 -94
- package/dist/esm/extractor/extractHelpers.js +0 -103
- package/dist/esm/extractor/extractHelpers.js.map +0 -7
- package/dist/esm/extractor/extractMediaStyle.js +0 -152
- package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
- package/dist/esm/extractor/extractToClassNames.js +0 -293
- package/dist/esm/extractor/extractToClassNames.js.map +0 -7
- package/dist/esm/extractor/findTopmostFunction.js +0 -23
- package/dist/esm/extractor/generatedUid.js +0 -28
- package/dist/esm/extractor/generatedUid.js.map +0 -7
- package/dist/esm/extractor/getPrefixLogs.js +0 -12
- package/dist/esm/extractor/getPrefixLogs.js.map +0 -7
- package/dist/esm/extractor/getPropValueFromAttributes.js +0 -49
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/esm/extractor/getSourceModule.js +0 -69
- package/dist/esm/extractor/getStaticBindingsForScope.js +0 -137
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/esm/extractor/hoistClassNames.js +0 -44
- package/dist/esm/extractor/literalToAst.js +0 -80
- package/dist/esm/extractor/literalToAst.js.map +0 -7
- package/dist/esm/extractor/loadTamagui.js +0 -84
- package/dist/esm/extractor/loadTamagui.js.map +0 -7
- package/dist/esm/extractor/logLines.js +0 -22
- package/dist/esm/extractor/logLines.js.map +0 -7
- package/dist/esm/extractor/normalizeTernaries.js +0 -53
- package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
- package/dist/esm/extractor/removeUnusedHooks.js +0 -80
- package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/esm/extractor/timer.js +0 -24
- package/dist/esm/extractor/timer.js.map +0 -7
- package/dist/esm/extractor/validHTMLAttributes.js +0 -52
- package/dist/esm/extractor/validHTMLAttributes.js.map +0 -7
- package/dist/esm/index.js +0 -14
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/patchReactNativeWeb.js +0 -142
- package/dist/esm/patchReactNativeWeb.js.map +0 -7
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/jsx/constants.js +0 -13
- package/dist/jsx/extractor/accessSafe.js +0 -10
- package/dist/jsx/extractor/babelParse.js +0 -29
- package/dist/jsx/extractor/buildClassName.js +0 -39
- package/dist/jsx/extractor/createEvaluator.js +0 -51
- package/dist/jsx/extractor/createExtractor.js +0 -1168
- package/dist/jsx/extractor/ensureImportingConcat.js +0 -23
- package/dist/jsx/extractor/evaluateAstNode.js +0 -93
- package/dist/jsx/extractor/extractHelpers.js +0 -102
- package/dist/jsx/extractor/extractMediaStyle.js +0 -151
- package/dist/jsx/extractor/extractToClassNames.js +0 -292
- package/dist/jsx/extractor/findTopmostFunction.js +0 -22
- package/dist/jsx/extractor/generatedUid.js +0 -27
- package/dist/jsx/extractor/getPrefixLogs.js +0 -11
- package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -48
- package/dist/jsx/extractor/getSourceModule.js +0 -68
- package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -136
- package/dist/jsx/extractor/hoistClassNames.js +0 -43
- package/dist/jsx/extractor/literalToAst.js +0 -79
- package/dist/jsx/extractor/loadTamagui.js +0 -83
- package/dist/jsx/extractor/logLines.js +0 -21
- package/dist/jsx/extractor/normalizeTernaries.js +0 -52
- package/dist/jsx/extractor/removeUnusedHooks.js +0 -79
- package/dist/jsx/extractor/timer.js +0 -23
- package/dist/jsx/extractor/validHTMLAttributes.js +0 -51
- package/dist/jsx/index.js +0 -13
- package/dist/jsx/patchReactNativeWeb.js +0 -141
- package/types/constants.d.ts.map +0 -1
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadTamagui.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/patchReactNativeWeb.d.ts +0 -2
- package/types/patchReactNativeWeb.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
import { CONCAT_CLASSNAME_IMPORT } from "../constants";
|
|
5
|
-
const importConcatPkg = "@tamagui/helpers";
|
|
6
|
-
function ensureImportingConcat(path) {
|
|
7
|
-
const bodyPath = path.get("body");
|
|
8
|
-
const imported = bodyPath.find((x) => x.isImportDeclaration() && x.node.source.value === importConcatPkg);
|
|
9
|
-
const importSpecifier = t.importSpecifier(t.identifier(CONCAT_CLASSNAME_IMPORT), t.identifier(CONCAT_CLASSNAME_IMPORT));
|
|
10
|
-
if (!imported) {
|
|
11
|
-
path.node.body.push(t.importDeclaration([importSpecifier], t.stringLiteral(importConcatPkg)));
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const specifiers = imported.node.specifiers;
|
|
15
|
-
const alreadyImported = specifiers.some((x) => t.isImportSpecifier(x) && t.isIdentifier(x.imported) && x.imported.name === CONCAT_CLASSNAME_IMPORT);
|
|
16
|
-
if (!alreadyImported) {
|
|
17
|
-
specifiers.push(t.importSpecifier(t.identifier(CONCAT_CLASSNAME_IMPORT), t.identifier(CONCAT_CLASSNAME_IMPORT)));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
__name(ensureImportingConcat, "ensureImportingConcat");
|
|
21
|
-
export {
|
|
22
|
-
ensureImportingConcat
|
|
23
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
function evaluateAstNode(exprNode, evalFn, shouldPrintDebug) {
|
|
5
|
-
if (exprNode === void 0) {
|
|
6
|
-
return void 0;
|
|
7
|
-
}
|
|
8
|
-
if (exprNode === null) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
if (t.isJSXExpressionContainer(exprNode)) {
|
|
12
|
-
return evaluateAstNode(exprNode.expression);
|
|
13
|
-
}
|
|
14
|
-
if (t.isObjectExpression(exprNode)) {
|
|
15
|
-
const ret = {};
|
|
16
|
-
for (let idx = -1, len = exprNode.properties.length; ++idx < len; ) {
|
|
17
|
-
const value = exprNode.properties[idx];
|
|
18
|
-
if (!t.isObjectProperty(value)) {
|
|
19
|
-
throw new Error("evaluateAstNode can only evaluate object properties");
|
|
20
|
-
}
|
|
21
|
-
let key;
|
|
22
|
-
if (value.computed) {
|
|
23
|
-
if (typeof evalFn !== "function") {
|
|
24
|
-
throw new Error("evaluateAstNode does not support computed keys unless an eval function is provided");
|
|
25
|
-
}
|
|
26
|
-
key = evaluateAstNode(value.key, evalFn);
|
|
27
|
-
} else if (t.isIdentifier(value.key)) {
|
|
28
|
-
key = value.key.name;
|
|
29
|
-
} else if (t.isStringLiteral(value.key) || t.isNumericLiteral(value.key)) {
|
|
30
|
-
key = value.key.value;
|
|
31
|
-
} else {
|
|
32
|
-
throw new Error("Unsupported key type: " + value.key.type);
|
|
33
|
-
}
|
|
34
|
-
if (typeof key !== "string" && typeof key !== "number") {
|
|
35
|
-
throw new Error("key must be either a string or a number");
|
|
36
|
-
}
|
|
37
|
-
ret[key] = evaluateAstNode(value.value, evalFn);
|
|
38
|
-
}
|
|
39
|
-
return ret;
|
|
40
|
-
}
|
|
41
|
-
if (t.isArrayExpression(exprNode)) {
|
|
42
|
-
return exprNode.elements.map((x) => {
|
|
43
|
-
return evaluateAstNode(x, evalFn);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (t.isUnaryExpression(exprNode) && exprNode.operator === "-") {
|
|
47
|
-
const ret = evaluateAstNode(exprNode.argument, evalFn);
|
|
48
|
-
if (ret == null) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return -ret;
|
|
52
|
-
}
|
|
53
|
-
if (t.isTemplateLiteral(exprNode)) {
|
|
54
|
-
if (typeof evalFn !== "function") {
|
|
55
|
-
throw new Error("evaluateAstNode does not support template literals unless an eval function is provided");
|
|
56
|
-
}
|
|
57
|
-
let ret = "";
|
|
58
|
-
for (let idx = -1, len = exprNode.quasis.length; ++idx < len; ) {
|
|
59
|
-
const quasi = exprNode.quasis[idx];
|
|
60
|
-
const expr = exprNode.expressions[idx];
|
|
61
|
-
ret += quasi.value.raw;
|
|
62
|
-
if (expr) {
|
|
63
|
-
ret += evaluateAstNode(expr, evalFn);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return ret;
|
|
67
|
-
}
|
|
68
|
-
if (t.isNullLiteral(exprNode)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
if (t.isNumericLiteral(exprNode) || t.isStringLiteral(exprNode) || t.isBooleanLiteral(exprNode)) {
|
|
72
|
-
return exprNode.value;
|
|
73
|
-
}
|
|
74
|
-
if (t.isBinaryExpression(exprNode)) {
|
|
75
|
-
if (exprNode.operator === "+") {
|
|
76
|
-
return evaluateAstNode(exprNode.left, evalFn) + evaluateAstNode(exprNode.right, evalFn);
|
|
77
|
-
} else if (exprNode.operator === "-") {
|
|
78
|
-
return evaluateAstNode(exprNode.left, evalFn) - evaluateAstNode(exprNode.right, evalFn);
|
|
79
|
-
} else if (exprNode.operator === "*") {
|
|
80
|
-
return evaluateAstNode(exprNode.left, evalFn) * evaluateAstNode(exprNode.right, evalFn);
|
|
81
|
-
} else if (exprNode.operator === "/") {
|
|
82
|
-
return evaluateAstNode(exprNode.left, evalFn) / evaluateAstNode(exprNode.right, evalFn);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (typeof evalFn !== "function") {
|
|
86
|
-
throw new Error("evaluateAstNode does not support non-literal values unless an eval function is provided");
|
|
87
|
-
}
|
|
88
|
-
return evalFn(exprNode);
|
|
89
|
-
}
|
|
90
|
-
__name(evaluateAstNode, "evaluateAstNode");
|
|
91
|
-
export {
|
|
92
|
-
evaluateAstNode
|
|
93
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import generate from "@babel/generator";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
function isPresent(input) {
|
|
6
|
-
return input != null;
|
|
7
|
-
}
|
|
8
|
-
__name(isPresent, "isPresent");
|
|
9
|
-
function isSimpleSpread(node) {
|
|
10
|
-
return t.isIdentifier(node.argument) || t.isMemberExpression(node.argument);
|
|
11
|
-
}
|
|
12
|
-
__name(isSimpleSpread, "isSimpleSpread");
|
|
13
|
-
const attrStr = /* @__PURE__ */ __name((attr) => {
|
|
14
|
-
return !attr ? "" : attr.type === "attr" ? getNameAttr(attr.value) : attr.type === "ternary" ? `...${ternaryStr(attr.value)}` : `${attr.type}(${objToStr(attr.value)})`;
|
|
15
|
-
}, "attrStr");
|
|
16
|
-
const objToStr = /* @__PURE__ */ __name((obj, spacer = ", ") => {
|
|
17
|
-
if (!obj) {
|
|
18
|
-
return `${obj}`;
|
|
19
|
-
}
|
|
20
|
-
return `{${Object.entries(obj).map(([k, v]) => `${k}:${Array.isArray(v) ? `[...]` : v && typeof v === "object" ? `${objToStr(v, ",")}` : JSON.stringify(v)}`).join(spacer)}}`;
|
|
21
|
-
}, "objToStr");
|
|
22
|
-
const getNameAttr = /* @__PURE__ */ __name((attr) => {
|
|
23
|
-
if (t.isJSXSpreadAttribute(attr)) {
|
|
24
|
-
return `...${attr.argument["name"]}`;
|
|
25
|
-
}
|
|
26
|
-
return "name" in attr ? attr.name.name : `unknown-${attr["type"]}`;
|
|
27
|
-
}, "getNameAttr");
|
|
28
|
-
const ternaryStr = /* @__PURE__ */ __name((x) => {
|
|
29
|
-
const conditional = t.isIdentifier(x.test) ? x.test.name : t.isMemberExpression(x.test) ? [x.test.object["name"], x.test.property["name"]] : generate(x.test).code;
|
|
30
|
-
return [
|
|
31
|
-
"ternary(",
|
|
32
|
-
conditional,
|
|
33
|
-
isFilledObj(x.consequent) ? ` ? ${objToStr(x.consequent)}` : " ? \u{1F6AB}",
|
|
34
|
-
isFilledObj(x.alternate) ? ` : ${objToStr(x.alternate)}` : " : \u{1F6AB}",
|
|
35
|
-
")"
|
|
36
|
-
].flat().join("");
|
|
37
|
-
}, "ternaryStr");
|
|
38
|
-
const isFilledObj = /* @__PURE__ */ __name((obj) => obj && Object.keys(obj).length, "isFilledObj");
|
|
39
|
-
function findComponentName(scope) {
|
|
40
|
-
var _a;
|
|
41
|
-
let componentName = "";
|
|
42
|
-
let cur = scope.path;
|
|
43
|
-
while (cur.parentPath && !t.isProgram(cur.parentPath.parent)) {
|
|
44
|
-
cur = cur.parentPath;
|
|
45
|
-
}
|
|
46
|
-
let node = cur.parent;
|
|
47
|
-
if (t.isExportNamedDeclaration(node)) {
|
|
48
|
-
node = node.declaration;
|
|
49
|
-
}
|
|
50
|
-
if (t.isVariableDeclaration(node)) {
|
|
51
|
-
const [dec] = node.declarations;
|
|
52
|
-
if (t.isVariableDeclarator(dec) && t.isIdentifier(dec.id)) {
|
|
53
|
-
return dec.id.name;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (t.isFunctionDeclaration(node)) {
|
|
57
|
-
return (_a = node.id) == null ? void 0 : _a.name;
|
|
58
|
-
}
|
|
59
|
-
return componentName;
|
|
60
|
-
}
|
|
61
|
-
__name(findComponentName, "findComponentName");
|
|
62
|
-
function isValidThemeHook(jsxPath, n, sourcePath) {
|
|
63
|
-
var _a;
|
|
64
|
-
if (!t.isIdentifier(n.object) || !t.isIdentifier(n.property))
|
|
65
|
-
return false;
|
|
66
|
-
const bindings = jsxPath.scope.getAllBindings();
|
|
67
|
-
const binding = bindings[n.object.name];
|
|
68
|
-
if (!(binding == null ? void 0 : binding.path))
|
|
69
|
-
return false;
|
|
70
|
-
if (!binding.path.isVariableDeclarator())
|
|
71
|
-
return false;
|
|
72
|
-
const init = binding.path.node.init;
|
|
73
|
-
if (!t.isCallExpression(init))
|
|
74
|
-
return false;
|
|
75
|
-
if (!t.isIdentifier(init.callee))
|
|
76
|
-
return false;
|
|
77
|
-
if (init.callee.name !== "useTheme")
|
|
78
|
-
return false;
|
|
79
|
-
const importNode = (_a = binding.scope.getBinding("useTheme")) == null ? void 0 : _a.path.parent;
|
|
80
|
-
if (!t.isImportDeclaration(importNode))
|
|
81
|
-
return false;
|
|
82
|
-
if (importNode.source.value !== "tamagui") {
|
|
83
|
-
if (!isInsideTamagui(sourcePath)) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
__name(isValidThemeHook, "isValidThemeHook");
|
|
90
|
-
const isInsideTamagui = /* @__PURE__ */ __name((srcName) => {
|
|
91
|
-
return srcName.includes("/dist/jsx") || srcName.includes("/core/src");
|
|
92
|
-
}, "isInsideTamagui");
|
|
93
|
-
export {
|
|
94
|
-
attrStr,
|
|
95
|
-
findComponentName,
|
|
96
|
-
isInsideTamagui,
|
|
97
|
-
isPresent,
|
|
98
|
-
isSimpleSpread,
|
|
99
|
-
isValidThemeHook,
|
|
100
|
-
objToStr,
|
|
101
|
-
ternaryStr
|
|
102
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
import { getStylesAtomic, mediaObjectToString } from "@tamagui/core-node";
|
|
5
|
-
import { MEDIA_SEP } from "../constants";
|
|
6
|
-
import { isInsideTamagui, isPresent } from "./extractHelpers";
|
|
7
|
-
function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importance = 0, shouldPrintDebug = false) {
|
|
8
|
-
const mt = getMediaQueryTernary(ternary, jsxPath, sourcePath);
|
|
9
|
-
if (!mt) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
const { key } = mt;
|
|
13
|
-
const mq = tamaguiConfig.media[key];
|
|
14
|
-
if (!mq) {
|
|
15
|
-
console.error(`Media query "${key}" not found: ${Object.keys(tamaguiConfig.media)}`);
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const getStyleObj = /* @__PURE__ */ __name((styleObj, negate = false) => {
|
|
19
|
-
return styleObj ? { styleObj, negate } : null;
|
|
20
|
-
}, "getStyleObj");
|
|
21
|
-
const styleOpts = [
|
|
22
|
-
getStyleObj(ternary.consequent, false),
|
|
23
|
-
getStyleObj(ternary.alternate, true)
|
|
24
|
-
].filter(isPresent);
|
|
25
|
-
if (shouldPrintDebug && !styleOpts.length) {
|
|
26
|
-
console.log(" media query, no styles?");
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
const mediaKeys = Object.keys(tamaguiConfig.media);
|
|
30
|
-
const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {
|
|
31
|
-
acc[cur] = new Array(importance + 1).fill(":root").join("");
|
|
32
|
-
return acc;
|
|
33
|
-
}, {});
|
|
34
|
-
let mediaStyles = [];
|
|
35
|
-
for (const { styleObj, negate } of styleOpts) {
|
|
36
|
-
const styles = getStylesAtomic(styleObj);
|
|
37
|
-
const singleMediaStyles = styles.map((style) => {
|
|
38
|
-
const negKey = negate ? "0" : "";
|
|
39
|
-
const ogPrefix = style.identifier.slice(0, style.identifier.indexOf("-") + 1);
|
|
40
|
-
const identifier = `${style.identifier.replace(ogPrefix, `${ogPrefix}${MEDIA_SEP}${key}${negKey}${MEDIA_SEP}`)}`;
|
|
41
|
-
const className = `.${identifier}`;
|
|
42
|
-
const mediaSelector = mediaObjectToString(tamaguiConfig.media[key]);
|
|
43
|
-
const screenStr = negate ? "not all" : "screen";
|
|
44
|
-
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
45
|
-
const precendencePrefix = mediaKeyPrecendence[key];
|
|
46
|
-
const styleInner = style.rules[0].replace(style.identifier, identifier);
|
|
47
|
-
let styleRule = "";
|
|
48
|
-
if (styleInner.includes("@media")) {
|
|
49
|
-
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
50
|
-
} else {
|
|
51
|
-
styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`;
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
...style,
|
|
55
|
-
identifier,
|
|
56
|
-
className,
|
|
57
|
-
rules: [styleRule]
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
if (shouldPrintDebug === "verbose") {
|
|
61
|
-
console.log(" media styles:", importance, styleObj, singleMediaStyles.map((x) => x.identifier).join(", "));
|
|
62
|
-
}
|
|
63
|
-
mediaStyles = [...mediaStyles, ...singleMediaStyles];
|
|
64
|
-
}
|
|
65
|
-
ternary.remove();
|
|
66
|
-
return { mediaStyles, ternaryWithoutMedia: mt.ternaryWithoutMedia };
|
|
67
|
-
}
|
|
68
|
-
__name(extractMediaStyle, "extractMediaStyle");
|
|
69
|
-
function getMediaQueryTernary(ternary, jsxPath, sourcePath) {
|
|
70
|
-
if (t.isLogicalExpression(ternary.test) && ternary.test.operator === "&&") {
|
|
71
|
-
const mediaLeft = getMediaInfoFromExpression(ternary.test.left, jsxPath, sourcePath, ternary.inlineMediaQuery);
|
|
72
|
-
if (mediaLeft) {
|
|
73
|
-
return {
|
|
74
|
-
...mediaLeft,
|
|
75
|
-
ternaryWithoutMedia: {
|
|
76
|
-
...ternary,
|
|
77
|
-
test: ternary.test.right
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const result = getMediaInfoFromExpression(ternary.test, jsxPath, sourcePath, ternary.inlineMediaQuery);
|
|
83
|
-
if (result) {
|
|
84
|
-
return {
|
|
85
|
-
...result,
|
|
86
|
-
ternaryWithoutMedia: null
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
__name(getMediaQueryTernary, "getMediaQueryTernary");
|
|
92
|
-
function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery) {
|
|
93
|
-
var _a, _b, _c;
|
|
94
|
-
if (inlineMediaQuery) {
|
|
95
|
-
return {
|
|
96
|
-
key: inlineMediaQuery,
|
|
97
|
-
bindingName: inlineMediaQuery
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
if (t.isMemberExpression(test) && t.isIdentifier(test.object) && t.isIdentifier(test.property)) {
|
|
101
|
-
const name = test.object["name"];
|
|
102
|
-
const key = test.property["name"];
|
|
103
|
-
const bindings = jsxPath.scope.getAllBindings();
|
|
104
|
-
const binding = bindings[name];
|
|
105
|
-
if (!binding)
|
|
106
|
-
return false;
|
|
107
|
-
const bindingNode = (_a = binding.path) == null ? void 0 : _a.node;
|
|
108
|
-
if (!t.isVariableDeclarator(bindingNode) || !bindingNode.init)
|
|
109
|
-
return false;
|
|
110
|
-
if (!isValidMediaCall(jsxPath, bindingNode.init, sourcePath))
|
|
111
|
-
return false;
|
|
112
|
-
return { key, bindingName: name };
|
|
113
|
-
}
|
|
114
|
-
if (t.isIdentifier(test)) {
|
|
115
|
-
const key = test.name;
|
|
116
|
-
const node = (_c = (_b = jsxPath.scope.getBinding(test.name)) == null ? void 0 : _b.path) == null ? void 0 : _c.node;
|
|
117
|
-
if (!t.isVariableDeclarator(node))
|
|
118
|
-
return false;
|
|
119
|
-
if (!node.init || !isValidMediaCall(jsxPath, node.init, sourcePath))
|
|
120
|
-
return false;
|
|
121
|
-
return { key, bindingName: key };
|
|
122
|
-
}
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
__name(getMediaInfoFromExpression, "getMediaInfoFromExpression");
|
|
126
|
-
function isValidMediaCall(jsxPath, init, sourcePath) {
|
|
127
|
-
if (!t.isCallExpression(init))
|
|
128
|
-
return false;
|
|
129
|
-
if (!t.isIdentifier(init.callee))
|
|
130
|
-
return false;
|
|
131
|
-
if (init.callee.name !== "useMedia")
|
|
132
|
-
return false;
|
|
133
|
-
const bindings = jsxPath.scope.getAllBindings();
|
|
134
|
-
const mediaBinding = bindings["useMedia"];
|
|
135
|
-
if (!mediaBinding)
|
|
136
|
-
return false;
|
|
137
|
-
const useMediaImport = mediaBinding.path.parent;
|
|
138
|
-
if (!t.isImportDeclaration(useMediaImport))
|
|
139
|
-
return false;
|
|
140
|
-
if (useMediaImport.source.value !== "tamagui") {
|
|
141
|
-
if (!isInsideTamagui(sourcePath)) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
__name(isValidMediaCall, "isValidMediaCall");
|
|
148
|
-
export {
|
|
149
|
-
extractMediaStyle,
|
|
150
|
-
isValidMediaCall
|
|
151
|
-
};
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import { basename } from "path";
|
|
5
|
-
import * as util from "util";
|
|
6
|
-
import generate from "@babel/generator";
|
|
7
|
-
import * as t from "@babel/types";
|
|
8
|
-
import { getStylesAtomic } from "@tamagui/core-node";
|
|
9
|
-
import { concatClassName } from "@tamagui/helpers";
|
|
10
|
-
import invariant from "invariant";
|
|
11
|
-
import { CONCAT_CLASSNAME_IMPORT } from "../constants";
|
|
12
|
-
import { babelParse } from "./babelParse";
|
|
13
|
-
import { buildClassName } from "./buildClassName";
|
|
14
|
-
import { ensureImportingConcat } from "./ensureImportingConcat";
|
|
15
|
-
import { isSimpleSpread } from "./extractHelpers";
|
|
16
|
-
import { extractMediaStyle } from "./extractMediaStyle";
|
|
17
|
-
import { getPrefixLogs } from "./getPrefixLogs";
|
|
18
|
-
import { hoistClassNames } from "./hoistClassNames";
|
|
19
|
-
import { literalToAst } from "./literalToAst";
|
|
20
|
-
import { logLines } from "./logLines";
|
|
21
|
-
import { timer } from "./timer";
|
|
22
|
-
const mergeStyleGroups = {
|
|
23
|
-
shadowOpacity: true,
|
|
24
|
-
shadowRadius: true,
|
|
25
|
-
shadowColor: true,
|
|
26
|
-
shadowOffset: true
|
|
27
|
-
};
|
|
28
|
-
function extractToClassNames({
|
|
29
|
-
loader,
|
|
30
|
-
extractor,
|
|
31
|
-
source,
|
|
32
|
-
sourcePath,
|
|
33
|
-
options,
|
|
34
|
-
shouldPrintDebug,
|
|
35
|
-
cssLoaderPath,
|
|
36
|
-
threaded,
|
|
37
|
-
cssPath
|
|
38
|
-
}) {
|
|
39
|
-
var _a;
|
|
40
|
-
const tm = timer();
|
|
41
|
-
if (typeof source !== "string") {
|
|
42
|
-
throw new Error("`source` must be a string of javascript");
|
|
43
|
-
}
|
|
44
|
-
invariant(typeof sourcePath === "string" && path.isAbsolute(sourcePath), "`sourcePath` must be an absolute path to a .js file");
|
|
45
|
-
const shouldLogTiming = (_a = options.logTimings) != null ? _a : true;
|
|
46
|
-
const start = Date.now();
|
|
47
|
-
const mem = shouldLogTiming ? process.memoryUsage() : null;
|
|
48
|
-
let ast;
|
|
49
|
-
try {
|
|
50
|
-
ast = babelParse(source);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
console.error("babel parse error:", sourcePath);
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
tm.mark(`babel-parse`, shouldPrintDebug === "verbose");
|
|
56
|
-
const cssMap = /* @__PURE__ */ new Map();
|
|
57
|
-
const existingHoists = {};
|
|
58
|
-
let hasFlattened = false;
|
|
59
|
-
const res = extractor.parse(ast, {
|
|
60
|
-
sourcePath,
|
|
61
|
-
shouldPrintDebug,
|
|
62
|
-
...options,
|
|
63
|
-
getFlattenedNode: ({ tag }) => {
|
|
64
|
-
hasFlattened = true;
|
|
65
|
-
return tag;
|
|
66
|
-
},
|
|
67
|
-
onExtractTag: ({
|
|
68
|
-
attrs,
|
|
69
|
-
node,
|
|
70
|
-
attemptEval,
|
|
71
|
-
jsxPath,
|
|
72
|
-
originalNodeName,
|
|
73
|
-
filePath,
|
|
74
|
-
lineNumbers,
|
|
75
|
-
programPath,
|
|
76
|
-
isFlattened
|
|
77
|
-
}) => {
|
|
78
|
-
var _a2, _b;
|
|
79
|
-
let finalClassNames = [];
|
|
80
|
-
let finalAttrs = [];
|
|
81
|
-
let finalStyles = [];
|
|
82
|
-
const viewStyles = {};
|
|
83
|
-
for (const attr of attrs) {
|
|
84
|
-
if (attr.type === "style") {
|
|
85
|
-
Object.assign(viewStyles, attr.value);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const ensureNeededPrevStyle = /* @__PURE__ */ __name((style) => {
|
|
89
|
-
var _a3;
|
|
90
|
-
const keys = Object.keys(style);
|
|
91
|
-
if (!keys.some((key) => mergeStyleGroups[key])) {
|
|
92
|
-
return style;
|
|
93
|
-
}
|
|
94
|
-
for (const k in mergeStyleGroups) {
|
|
95
|
-
if (k in viewStyles) {
|
|
96
|
-
style[k] = (_a3 = style[k]) != null ? _a3 : viewStyles[k];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return style;
|
|
100
|
-
}, "ensureNeededPrevStyle");
|
|
101
|
-
const addStyles = /* @__PURE__ */ __name((style) => {
|
|
102
|
-
if (!style)
|
|
103
|
-
return [];
|
|
104
|
-
const styleWithPrev = ensureNeededPrevStyle(style);
|
|
105
|
-
const res2 = getStylesAtomic(styleWithPrev);
|
|
106
|
-
if (res2.length) {
|
|
107
|
-
finalStyles = [...finalStyles, ...res2];
|
|
108
|
-
}
|
|
109
|
-
return res2;
|
|
110
|
-
}, "addStyles");
|
|
111
|
-
let lastMediaImportance = 1;
|
|
112
|
-
for (const attr of attrs) {
|
|
113
|
-
switch (attr.type) {
|
|
114
|
-
case "style":
|
|
115
|
-
if (!isFlattened) {
|
|
116
|
-
const { hoverStyle, pressStyle, focusStyle } = attr.value;
|
|
117
|
-
const pseudos = [
|
|
118
|
-
["hoverStyle", hoverStyle],
|
|
119
|
-
["pressStyle", pressStyle],
|
|
120
|
-
["focusStyle", focusStyle]
|
|
121
|
-
];
|
|
122
|
-
const styles2 = getStylesAtomic(attr.value, {
|
|
123
|
-
splitTransforms: true
|
|
124
|
-
});
|
|
125
|
-
finalStyles = [...finalStyles, ...styles2];
|
|
126
|
-
for (const [key, value] of pseudos) {
|
|
127
|
-
if (value && Object.keys(value).length) {
|
|
128
|
-
finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(literalToAst(value))));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
for (const style of styles2) {
|
|
132
|
-
finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(style.property), t.stringLiteral(style.identifier)));
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
const styles2 = addStyles(attr.value);
|
|
136
|
-
const newClassNames = concatClassName(styles2.map((x) => x.identifier).join(" "));
|
|
137
|
-
const existing = finalClassNames.find((x) => x.type == "StringLiteral");
|
|
138
|
-
if (existing) {
|
|
139
|
-
existing.value = `${existing.value} ${newClassNames}`;
|
|
140
|
-
} else {
|
|
141
|
-
finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)];
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
break;
|
|
145
|
-
case "attr":
|
|
146
|
-
const val = attr.value;
|
|
147
|
-
if (t.isJSXSpreadAttribute(val)) {
|
|
148
|
-
if (isSimpleSpread(val)) {
|
|
149
|
-
finalClassNames.push(t.logicalExpression("&&", val.argument, t.memberExpression(val.argument, t.identifier("className"))));
|
|
150
|
-
}
|
|
151
|
-
} else if (val.name.name === "className") {
|
|
152
|
-
const value = val.value;
|
|
153
|
-
if (value) {
|
|
154
|
-
try {
|
|
155
|
-
const evaluatedValue = attemptEval(value);
|
|
156
|
-
finalClassNames.push(t.stringLiteral(evaluatedValue));
|
|
157
|
-
} catch (e) {
|
|
158
|
-
finalClassNames.push(value["expression"]);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
finalAttrs.push(val);
|
|
164
|
-
break;
|
|
165
|
-
case "ternary":
|
|
166
|
-
const mediaExtraction = extractMediaStyle(attr.value, jsxPath, extractor.getTamagui(), sourcePath, lastMediaImportance, shouldPrintDebug);
|
|
167
|
-
if (shouldPrintDebug) {
|
|
168
|
-
if (mediaExtraction) {
|
|
169
|
-
console.log("ternary (mediaStyles)", (_b = (_a2 = mediaExtraction.ternaryWithoutMedia) == null ? void 0 : _a2.inlineMediaQuery) != null ? _b : "", mediaExtraction.mediaStyles.map((x) => x.identifier).join("."));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (!mediaExtraction) {
|
|
173
|
-
addTernaryStyle(attr.value, addStyles(attr.value.consequent), addStyles(attr.value.alternate));
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
lastMediaImportance++;
|
|
177
|
-
if (mediaExtraction.mediaStyles) {
|
|
178
|
-
finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles];
|
|
179
|
-
}
|
|
180
|
-
if (mediaExtraction.ternaryWithoutMedia) {
|
|
181
|
-
addTernaryStyle(mediaExtraction.ternaryWithoutMedia, mediaExtraction.mediaStyles, []);
|
|
182
|
-
} else {
|
|
183
|
-
finalClassNames = [
|
|
184
|
-
...finalClassNames,
|
|
185
|
-
...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier))
|
|
186
|
-
];
|
|
187
|
-
}
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
function addTernaryStyle(ternary, a, b) {
|
|
192
|
-
const cCN = a.map((x) => x.identifier).join(" ");
|
|
193
|
-
const aCN = b.map((x) => x.identifier).join(" ");
|
|
194
|
-
if (a.length && b.length) {
|
|
195
|
-
finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN)));
|
|
196
|
-
} else {
|
|
197
|
-
finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(" " + cCN), t.stringLiteral(" " + aCN)));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
__name(addTernaryStyle, "addTernaryStyle");
|
|
201
|
-
if (shouldPrintDebug) {
|
|
202
|
-
console.log(" finalClassNames\n", logLines(finalClassNames.map((x) => x["value"]).join(" ")));
|
|
203
|
-
}
|
|
204
|
-
node.attributes = finalAttrs;
|
|
205
|
-
if (finalClassNames.length) {
|
|
206
|
-
let names = buildClassName(finalClassNames);
|
|
207
|
-
if (t.isStringLiteral(names)) {
|
|
208
|
-
names.value = concatClassName(names.value);
|
|
209
|
-
}
|
|
210
|
-
const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null;
|
|
211
|
-
let expr = nameExpr;
|
|
212
|
-
if (nameExpr && !t.isIdentifier(nameExpr)) {
|
|
213
|
-
if (!hasFlattened) {
|
|
214
|
-
} else {
|
|
215
|
-
ensureImportingConcat(programPath);
|
|
216
|
-
const simpleSpreads = attrs.filter((x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value));
|
|
217
|
-
expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [
|
|
218
|
-
expr,
|
|
219
|
-
...simpleSpreads.map((val) => val.value["argument"])
|
|
220
|
-
]);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
node.attributes.push(t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr)));
|
|
224
|
-
}
|
|
225
|
-
const comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName);
|
|
226
|
-
for (const { className, rules, identifier, value } of finalStyles) {
|
|
227
|
-
if (cssMap.has(className)) {
|
|
228
|
-
if (comment) {
|
|
229
|
-
const val = cssMap.get(className);
|
|
230
|
-
val.commentTexts.push(comment);
|
|
231
|
-
cssMap.set(className, val);
|
|
232
|
-
}
|
|
233
|
-
} else if (rules.length) {
|
|
234
|
-
if (rules.length > 1) {
|
|
235
|
-
console.log(" rules error", { rules });
|
|
236
|
-
throw new Error(`Shouldn't have more than one rule`);
|
|
237
|
-
}
|
|
238
|
-
cssMap.set(className, {
|
|
239
|
-
css: rules[0],
|
|
240
|
-
commentTexts: [comment]
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
if (!res || !res.modified && !res.optimized && !res.flattened) {
|
|
247
|
-
if (shouldPrintDebug) {
|
|
248
|
-
console.log("no res or none modified", res);
|
|
249
|
-
}
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
const styles = Array.from(cssMap.values()).map((x) => x.css).join("\n").trim();
|
|
253
|
-
if (styles) {
|
|
254
|
-
const cssQuery = threaded ? `cssData=${Buffer.from(styles).toString("base64")}` : `cssPath=${cssPath}`;
|
|
255
|
-
const remReq = loader.remainingRequest;
|
|
256
|
-
const importPath = `${cssPath}!=!${cssLoaderPath}?${cssQuery}!${remReq}`;
|
|
257
|
-
ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)));
|
|
258
|
-
}
|
|
259
|
-
const result = generate(ast, {
|
|
260
|
-
concise: false,
|
|
261
|
-
filename: sourcePath,
|
|
262
|
-
retainLines: false,
|
|
263
|
-
sourceFileName: sourcePath,
|
|
264
|
-
sourceMaps: true
|
|
265
|
-
}, source);
|
|
266
|
-
if (shouldPrintDebug) {
|
|
267
|
-
console.log("\n -------- output code ------- \n\n", result.code.split("\n").filter((x) => !x.startsWith("//")).join("\n"));
|
|
268
|
-
console.log("\n -------- output style -------- \n\n", styles);
|
|
269
|
-
}
|
|
270
|
-
if (shouldLogTiming) {
|
|
271
|
-
const memUsed = mem ? Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10 : 0;
|
|
272
|
-
const path2 = basename(sourcePath).replace(/\.[jt]sx?$/, "").slice(0, 22).trim().padStart(24);
|
|
273
|
-
const numOptimized = `${res.optimized}`.padStart(3);
|
|
274
|
-
const numFound = `${res.found}`.padStart(3);
|
|
275
|
-
const numFlattened = `${res.flattened}`.padStart(3);
|
|
276
|
-
const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : "";
|
|
277
|
-
const timing = Date.now() - start;
|
|
278
|
-
const timingWarning = timing > 50 ? "\u26A0\uFE0F" : timing > 150 ? "\u2622\uFE0F" : "";
|
|
279
|
-
const timingStr = `${timing}ms${timingWarning}`.padStart(6);
|
|
280
|
-
console.log(`${getPrefixLogs(options)} ${path2} ${numFound} \xB7 ${numOptimized} \xB7 ${numFlattened} ${timingStr} ${memory ? `(${memory})` : ""}`);
|
|
281
|
-
}
|
|
282
|
-
return {
|
|
283
|
-
ast,
|
|
284
|
-
styles,
|
|
285
|
-
js: result.code,
|
|
286
|
-
map: result.map
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
__name(extractToClassNames, "extractToClassNames");
|
|
290
|
-
export {
|
|
291
|
-
extractToClassNames
|
|
292
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
function findTopmostFunction(jsxPath) {
|
|
4
|
-
const isFunction = /* @__PURE__ */ __name((path) => path.isArrowFunctionExpression() || path.isFunctionDeclaration() || path.isFunctionExpression(), "isFunction");
|
|
5
|
-
let compFn = jsxPath.findParent(isFunction);
|
|
6
|
-
while (compFn) {
|
|
7
|
-
const parent = compFn.findParent(isFunction);
|
|
8
|
-
if (parent) {
|
|
9
|
-
compFn = parent;
|
|
10
|
-
} else {
|
|
11
|
-
break;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
if (!compFn) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return compFn;
|
|
18
|
-
}
|
|
19
|
-
__name(findTopmostFunction, "findTopmostFunction");
|
|
20
|
-
export {
|
|
21
|
-
findTopmostFunction
|
|
22
|
-
};
|