@tamagui/static 1.61.3 → 1.62.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/constants.js +8 -19
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/constants.native.js +43 -0
- package/dist/cjs/constants.native.js.map +6 -0
- package/dist/cjs/extractor/accessSafe.js +8 -14
- package/dist/cjs/extractor/accessSafe.js.map +1 -1
- package/dist/cjs/extractor/accessSafe.native.js +52 -0
- package/dist/cjs/extractor/accessSafe.native.js.map +6 -0
- package/dist/cjs/extractor/babelParse.js +9 -17
- package/dist/cjs/extractor/babelParse.js.map +1 -1
- package/dist/cjs/extractor/babelParse.native.js +65 -0
- package/dist/cjs/extractor/babelParse.native.js.map +6 -0
- package/dist/cjs/extractor/buildClassName.js +44 -67
- package/dist/cjs/extractor/buildClassName.js.map +1 -1
- package/dist/cjs/extractor/buildClassName.native.js +78 -0
- package/dist/cjs/extractor/buildClassName.native.js.map +6 -0
- package/dist/cjs/extractor/bundle.js +44 -79
- package/dist/cjs/extractor/bundle.js.map +1 -1
- package/dist/cjs/extractor/bundle.native.js +118 -0
- package/dist/cjs/extractor/bundle.native.js.map +6 -0
- package/dist/cjs/extractor/bundleConfig.js +107 -204
- package/dist/cjs/extractor/bundleConfig.js.map +1 -1
- package/dist/cjs/extractor/bundleConfig.native.js +316 -0
- package/dist/cjs/extractor/bundleConfig.native.js.map +6 -0
- package/dist/cjs/extractor/createEvaluator.js +13 -41
- package/dist/cjs/extractor/createEvaluator.js.map +1 -1
- package/dist/cjs/extractor/createEvaluator.native.js +60 -0
- package/dist/cjs/extractor/createEvaluator.native.js.map +6 -0
- package/dist/cjs/extractor/createExtractor.js +497 -1128
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/createExtractor.native.js +1067 -0
- package/dist/cjs/extractor/createExtractor.native.js.map +6 -0
- package/dist/cjs/extractor/ensureImportingConcat.js +12 -23
- package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/cjs/extractor/ensureImportingConcat.native.js +55 -0
- package/dist/cjs/extractor/ensureImportingConcat.native.js.map +6 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.js +40 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.js.map +6 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.native.js +41 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.native.js.map +6 -0
- package/dist/cjs/extractor/evaluateAstNode.js +67 -95
- package/dist/cjs/extractor/evaluateAstNode.js.map +1 -1
- package/dist/cjs/extractor/evaluateAstNode.native.js +104 -0
- package/dist/cjs/extractor/evaluateAstNode.native.js.map +6 -0
- package/dist/cjs/extractor/extractHelpers.js +43 -123
- package/dist/cjs/extractor/extractHelpers.js.map +1 -1
- package/dist/cjs/extractor/extractHelpers.native.js +131 -0
- package/dist/cjs/extractor/extractHelpers.native.js.map +6 -0
- package/dist/cjs/extractor/extractMediaStyle.js +42 -110
- package/dist/cjs/extractor/extractMediaStyle.js.map +1 -1
- package/dist/cjs/extractor/extractMediaStyle.native.js +127 -0
- package/dist/cjs/extractor/extractMediaStyle.native.js.map +6 -0
- package/dist/cjs/extractor/extractToClassNames.js +134 -254
- package/dist/cjs/extractor/extractToClassNames.js.map +1 -1
- package/dist/cjs/extractor/extractToClassNames.native.js +304 -0
- package/dist/cjs/extractor/extractToClassNames.native.js.map +6 -0
- package/dist/cjs/extractor/findTopmostFunction.js +9 -17
- package/dist/cjs/extractor/findTopmostFunction.js.map +1 -1
- package/dist/cjs/extractor/findTopmostFunction.native.js +37 -0
- package/dist/cjs/extractor/findTopmostFunction.native.js.map +6 -0
- package/dist/cjs/extractor/generateTamaguiStudioConfig.js +37 -81
- package/dist/cjs/extractor/generateTamaguiStudioConfig.js.map +1 -1
- package/dist/cjs/extractor/generateTamaguiStudioConfig.native.js +120 -0
- package/dist/cjs/extractor/generateTamaguiStudioConfig.native.js.map +6 -0
- package/dist/cjs/extractor/generatedUid.js +14 -28
- package/dist/cjs/extractor/generatedUid.js.map +1 -1
- package/dist/cjs/extractor/generatedUid.native.js +47 -0
- package/dist/cjs/extractor/generatedUid.native.js.map +6 -0
- package/dist/cjs/extractor/getPrefixLogs.js +6 -10
- package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
- package/dist/cjs/extractor/getPrefixLogs.native.js +29 -0
- package/dist/cjs/extractor/getPrefixLogs.native.js.map +6 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js +21 -42
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.native.js +70 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.native.js.map +6 -0
- package/dist/cjs/extractor/getSourceModule.js +23 -57
- package/dist/cjs/extractor/getSourceModule.js.map +1 -1
- package/dist/cjs/extractor/getSourceModule.native.js +71 -0
- package/dist/cjs/extractor/getSourceModule.native.js.map +6 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js +42 -116
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/cjs/extractor/getStaticBindingsForScope.native.js +153 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.native.js.map +6 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.js +6 -13
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +1 -1
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.native.js +29 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +6 -0
- package/dist/cjs/extractor/hoistClassNames.js +16 -30
- package/dist/cjs/extractor/hoistClassNames.js.map +1 -1
- package/dist/cjs/extractor/hoistClassNames.native.js +66 -0
- package/dist/cjs/extractor/hoistClassNames.native.js.map +6 -0
- package/dist/cjs/extractor/literalToAst.js +32 -53
- package/dist/cjs/extractor/literalToAst.js.map +1 -1
- package/dist/cjs/extractor/literalToAst.native.js +96 -0
- package/dist/cjs/extractor/literalToAst.native.js.map +6 -0
- package/dist/cjs/extractor/loadFile.js +4 -11
- package/dist/cjs/extractor/loadFile.js.map +1 -1
- package/dist/cjs/extractor/loadFile.native.js +15 -0
- package/dist/cjs/extractor/loadFile.native.js.map +6 -0
- package/dist/cjs/extractor/loadTamagui.js +76 -147
- package/dist/cjs/extractor/loadTamagui.js.map +1 -1
- package/dist/cjs/extractor/loadTamagui.native.js +240 -0
- package/dist/cjs/extractor/loadTamagui.native.js.map +6 -0
- package/dist/cjs/extractor/logLines.js +12 -22
- package/dist/cjs/extractor/logLines.js.map +1 -1
- package/dist/cjs/extractor/logLines.native.js +35 -0
- package/dist/cjs/extractor/logLines.native.js.map +6 -0
- package/dist/cjs/extractor/normalizeTernaries.js +27 -54
- package/dist/cjs/extractor/normalizeTernaries.js.map +1 -1
- package/dist/cjs/extractor/normalizeTernaries.native.js +64 -0
- package/dist/cjs/extractor/normalizeTernaries.native.js.map +6 -0
- package/dist/cjs/extractor/propsToFontFamilyCache.js +6 -11
- package/dist/cjs/extractor/propsToFontFamilyCache.js.map +1 -1
- package/dist/cjs/extractor/propsToFontFamilyCache.native.js +41 -0
- package/dist/cjs/extractor/propsToFontFamilyCache.native.js.map +6 -0
- package/dist/cjs/extractor/removeUnusedHooks.js +25 -56
- package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/cjs/extractor/removeUnusedHooks.native.js +80 -0
- package/dist/cjs/extractor/removeUnusedHooks.native.js.map +6 -0
- package/dist/cjs/extractor/timer.js +9 -20
- package/dist/cjs/extractor/timer.js.map +1 -1
- package/dist/cjs/extractor/timer.native.js +43 -0
- package/dist/cjs/extractor/timer.native.js.map +6 -0
- package/dist/cjs/extractor/validHTMLAttributes.js +51 -55
- package/dist/cjs/extractor/validHTMLAttributes.js.map +1 -1
- package/dist/cjs/extractor/validHTMLAttributes.native.js +73 -0
- package/dist/cjs/extractor/validHTMLAttributes.native.js.map +6 -0
- package/dist/cjs/getPragmaOptions.js +12 -38
- package/dist/cjs/getPragmaOptions.js.map +1 -1
- package/dist/cjs/getPragmaOptions.native.js +43 -0
- package/dist/cjs/getPragmaOptions.native.js.map +6 -0
- package/dist/cjs/helpers/memoize.js +10 -19
- package/dist/cjs/helpers/memoize.js.map +1 -1
- package/dist/cjs/helpers/memoize.native.js +38 -0
- package/dist/cjs/helpers/memoize.native.js.map +6 -0
- package/dist/cjs/helpers/requireTamaguiCore.js +29 -0
- package/dist/cjs/helpers/requireTamaguiCore.js.map +6 -0
- package/dist/cjs/helpers/requireTamaguiCore.native.js +30 -0
- package/dist/cjs/helpers/requireTamaguiCore.native.js.map +6 -0
- package/dist/cjs/index.js +7 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +21 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/registerRequire.js +93 -0
- package/dist/cjs/registerRequire.js.map +6 -0
- package/dist/cjs/registerRequire.native.js +94 -0
- package/dist/cjs/registerRequire.native.js.map +6 -0
- package/dist/cjs/setup.js +2 -0
- package/dist/cjs/setup.js.map +6 -0
- package/dist/cjs/setup.native.js +3 -0
- package/dist/cjs/setup.native.js.map +6 -0
- package/dist/cjs/static.js +41 -0
- package/dist/cjs/static.js.map +6 -0
- package/dist/cjs/static.native.js +42 -0
- package/dist/cjs/static.native.js.map +6 -0
- package/dist/cjs/types.js +3 -6
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/types.native.js +15 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/cjs/webpackPlugin.js +5 -9
- package/dist/cjs/webpackPlugin.js.map +1 -1
- package/dist/cjs/webpackPlugin.native.js +32 -0
- package/dist/cjs/webpackPlugin.native.js.map +6 -0
- package/dist/esm/constants.js +1 -6
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/extractor/accessSafe.js +1 -1
- package/dist/esm/extractor/accessSafe.js.map +1 -1
- package/dist/esm/extractor/babelParse.js +2 -4
- package/dist/esm/extractor/babelParse.js.map +1 -1
- package/dist/esm/extractor/buildClassName.js +37 -54
- package/dist/esm/extractor/buildClassName.js.map +1 -1
- package/dist/esm/extractor/bundle.js +36 -60
- package/dist/esm/extractor/bundle.js.map +1 -1
- package/dist/esm/extractor/bundleConfig.js +100 -180
- package/dist/esm/extractor/bundleConfig.js.map +1 -1
- package/dist/esm/extractor/createEvaluator.js +5 -22
- package/dist/esm/extractor/createEvaluator.js.map +1 -1
- package/dist/esm/extractor/createExtractor.js +484 -1098
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/ensureImportingConcat.js +5 -10
- package/dist/esm/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/esm/extractor/esbuildAliasPlugin.js +20 -0
- package/dist/esm/extractor/esbuildAliasPlugin.js.map +6 -0
- package/dist/esm/extractor/evaluateAstNode.js +60 -82
- package/dist/esm/extractor/evaluateAstNode.js.map +1 -1
- package/dist/esm/extractor/extractHelpers.js +35 -105
- package/dist/esm/extractor/extractHelpers.js.map +1 -1
- package/dist/esm/extractor/extractMediaStyle.js +35 -97
- package/dist/esm/extractor/extractMediaStyle.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.js +126 -224
- package/dist/esm/extractor/extractToClassNames.js.map +1 -1
- package/dist/esm/extractor/findTopmostFunction.js +4 -8
- package/dist/esm/extractor/findTopmostFunction.js.map +1 -1
- package/dist/esm/extractor/generateTamaguiStudioConfig.js +28 -62
- package/dist/esm/extractor/generateTamaguiStudioConfig.js.map +1 -1
- package/dist/esm/extractor/generatedUid.js +7 -15
- package/dist/esm/extractor/generatedUid.js.map +1 -1
- package/dist/esm/extractor/getPrefixLogs.js +1 -1
- package/dist/esm/extractor/getPrefixLogs.js.map +1 -1
- package/dist/esm/extractor/getPropValueFromAttributes.js +13 -26
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/esm/extractor/getSourceModule.js +16 -44
- package/dist/esm/extractor/getSourceModule.js.map +1 -1
- package/dist/esm/extractor/getStaticBindingsForScope.js +34 -98
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.js +1 -4
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +1 -1
- package/dist/esm/extractor/hoistClassNames.js +9 -17
- package/dist/esm/extractor/hoistClassNames.js.map +1 -1
- package/dist/esm/extractor/literalToAst.js +25 -40
- package/dist/esm/extractor/literalToAst.js.map +1 -1
- package/dist/esm/extractor/loadFile.js +4 -10
- package/dist/esm/extractor/loadFile.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.js +69 -124
- package/dist/esm/extractor/loadTamagui.js.map +1 -1
- package/dist/esm/extractor/logLines.js +7 -13
- package/dist/esm/extractor/logLines.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.js +19 -38
- package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
- package/dist/esm/extractor/propsToFontFamilyCache.js +1 -2
- package/dist/esm/extractor/propsToFontFamilyCache.js.map +1 -1
- package/dist/esm/extractor/removeUnusedHooks.js +18 -43
- package/dist/esm/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/esm/extractor/timer.js +4 -11
- package/dist/esm/extractor/timer.js.map +1 -1
- package/dist/esm/extractor/validHTMLAttributes.js +46 -46
- package/dist/esm/getPragmaOptions.js +7 -29
- package/dist/esm/getPragmaOptions.js.map +1 -1
- package/dist/esm/helpers/memoize.js +5 -10
- package/dist/esm/helpers/memoize.js.map +1 -1
- package/dist/esm/helpers/requireTamaguiCore.js +9 -0
- package/dist/esm/helpers/requireTamaguiCore.js.map +6 -0
- package/dist/esm/index.js +2 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/registerRequire.js +73 -0
- package/dist/esm/registerRequire.js.map +6 -0
- package/dist/esm/setup.js +2 -0
- package/dist/esm/setup.js.map +6 -0
- package/dist/esm/static.js +15 -0
- package/dist/esm/static.js.map +6 -0
- package/package.json +15 -15
- package/src/extractor/bundle.ts +12 -10
- package/src/extractor/bundleConfig.ts +25 -20
- package/src/extractor/createEvaluator.ts +0 -16
- package/src/extractor/createExtractor.ts +12 -9
- package/src/extractor/esbuildAliasPlugin.ts +40 -0
- package/src/extractor/extractMediaStyle.ts +3 -5
- package/src/extractor/extractToClassNames.ts +2 -1
- package/src/extractor/generateTamaguiStudioConfig.ts +7 -4
- package/src/extractor/loadTamagui.ts +26 -22
- package/src/helpers/requireTamaguiCore.ts +13 -0
- package/src/index.ts +2 -9
- package/src/registerRequire.ts +156 -0
- package/src/setup.ts +1 -0
- package/src/static.ts +9 -0
- package/src/types.ts +3 -1
- package/types/extractor/bundle.d.ts +2 -2
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts +18 -0
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -0
- package/types/extractor/extractMediaStyle.d.ts +1 -1
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/generateTamaguiStudioConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +2 -2
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/helpers/requireTamaguiCore.d.ts +3 -0
- package/types/helpers/requireTamaguiCore.d.ts.map +1 -0
- package/types/index.d.ts +2 -9
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +7 -0
- package/types/registerRequire.d.ts.map +1 -0
- package/types/setup.d.ts +2 -0
- package/types/setup.d.ts.map +1 -0
- package/types/static.d.ts +10 -0
- package/types/static.d.ts.map +1 -0
- package/types/types.d.ts +2 -1
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/require.js +0 -125
- package/dist/cjs/require.js.map +0 -6
- package/dist/esm/require.js +0 -100
- package/dist/esm/require.js.map +0 -6
- package/src/require.ts +0 -150
- package/types/require.d.ts +0 -3
- package/types/require.d.ts.map +0 -1
@@ -1,16 +1,9 @@
|
|
1
1
|
import { basename, relative } from "path";
|
2
2
|
import traverse from "@babel/traverse";
|
3
3
|
import * as t from "@babel/types";
|
4
|
-
import {
|
5
|
-
expandStylesAndRemoveNullishValues,
|
6
|
-
getSplitStyles,
|
7
|
-
mediaQueryConfig,
|
8
|
-
propMapper,
|
9
|
-
proxyThemeVariables,
|
10
|
-
pseudoDescriptors
|
11
|
-
} from "@tamagui/core-node";
|
12
4
|
import { createDOMProps } from "react-native-web-internals";
|
13
5
|
import { FAILED_EVAL } from "../constants";
|
6
|
+
import { requireTamaguiCore } from "../helpers/requireTamaguiCore";
|
14
7
|
import { createEvaluator, createSafeEvaluator } from "./createEvaluator";
|
15
8
|
import { evaluateAstNode } from "./evaluateAstNode";
|
16
9
|
import {
|
@@ -34,63 +27,46 @@ import { removeUnusedHooks } from "./removeUnusedHooks";
|
|
34
27
|
import { timer } from "./timer";
|
35
28
|
import { validHTMLAttributes } from "./validHTMLAttributes";
|
36
29
|
const UNTOUCHED_PROPS = {
|
37
|
-
key:
|
38
|
-
style:
|
39
|
-
className:
|
40
|
-
}
|
41
|
-
const INLINE_EXTRACTABLE = {
|
30
|
+
key: !0,
|
31
|
+
style: !0,
|
32
|
+
className: !0
|
33
|
+
}, INLINE_EXTRACTABLE = {
|
42
34
|
ref: "ref",
|
43
35
|
key: "key",
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
useTheme: true
|
55
|
-
};
|
56
|
-
const createTernary = (x) => x;
|
57
|
-
let hasLoggedBaseInfo = false;
|
36
|
+
onPress: "onClick",
|
37
|
+
onHoverIn: "onMouseEnter",
|
38
|
+
onHoverOut: "onMouseLeave",
|
39
|
+
onPressIn: "onMouseDown",
|
40
|
+
onPressOut: "onMouseUp"
|
41
|
+
}, validHooks = {
|
42
|
+
useMedia: !0,
|
43
|
+
useTheme: !0
|
44
|
+
}, createTernary = (x) => x;
|
45
|
+
let hasLoggedBaseInfo = !1;
|
58
46
|
function isFullyDisabled(props) {
|
59
47
|
return props.disableExtraction && props.disableDebugAttr;
|
60
48
|
}
|
61
49
|
function createExtractor({ logger = console } = { logger: console }) {
|
62
|
-
if (!process.env.TAMAGUI_TARGET) {
|
63
|
-
console.warn('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either "web" or "native"');
|
64
|
-
process.exit(1);
|
65
|
-
}
|
66
50
|
const componentState = {
|
67
|
-
focus:
|
68
|
-
hover:
|
69
|
-
unmounted:
|
70
|
-
press:
|
71
|
-
pressIn:
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
};
|
78
|
-
const shouldAddDebugProp = (
|
51
|
+
focus: !1,
|
52
|
+
hover: !1,
|
53
|
+
unmounted: !0,
|
54
|
+
press: !1,
|
55
|
+
pressIn: !1
|
56
|
+
}, styleProps = {
|
57
|
+
resolveVariablesAs: "variable",
|
58
|
+
noClassNames: !1,
|
59
|
+
isAnimated: !1
|
60
|
+
}, shouldAddDebugProp = (
|
79
61
|
// really basic disable this for next.js because it messes with ssr
|
80
|
-
!process.env.npm_package_dependencies_next &&
|
62
|
+
!process.env.npm_package_dependencies_next && !0 && process.env.IDENTIFY_TAGS !== "false" && (process.env.NODE_ENV === "development" || process.env.DEBUG || process.env.IDENTIFY_TAGS)
|
81
63
|
);
|
82
64
|
let projectInfo = null;
|
83
65
|
function loadSync(props) {
|
84
|
-
|
85
|
-
return null;
|
86
|
-
}
|
87
|
-
return projectInfo ||= loadTamaguiSync(props);
|
66
|
+
return isFullyDisabled(props) ? null : projectInfo ||= loadTamaguiSync(props);
|
88
67
|
}
|
89
68
|
async function load(props) {
|
90
|
-
|
91
|
-
return null;
|
92
|
-
}
|
93
|
-
return projectInfo ||= await loadTamagui(props);
|
69
|
+
return isFullyDisabled(props) ? null : projectInfo ||= await loadTamagui(props);
|
94
70
|
}
|
95
71
|
return {
|
96
72
|
options: {
|
@@ -100,7 +76,7 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
100
76
|
loadTamagui: load,
|
101
77
|
loadTamaguiSync: loadSync,
|
102
78
|
getTamagui() {
|
103
|
-
return projectInfo
|
79
|
+
return projectInfo?.tamaguiConfig;
|
104
80
|
},
|
105
81
|
parseSync: (f, props) => {
|
106
82
|
const projectInfo2 = loadSync(props);
|
@@ -112,11 +88,10 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
112
88
|
}
|
113
89
|
};
|
114
90
|
function parseWithConfig({ components, tamaguiConfig }, fileOrPath, options) {
|
115
|
-
var _a;
|
116
91
|
const {
|
117
92
|
config = "tamagui.config.ts",
|
118
93
|
importsWhitelist = ["constants.js"],
|
119
|
-
evaluateVars =
|
94
|
+
evaluateVars = !0,
|
120
95
|
sourcePath = "",
|
121
96
|
onExtractTag,
|
122
97
|
onStyleRule,
|
@@ -128,183 +103,111 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
128
103
|
disableDebugAttr,
|
129
104
|
disableExtractFoundComponents,
|
130
105
|
includeExtensions = [".ts", ".tsx", ".jsx"],
|
131
|
-
extractStyledDefinitions =
|
106
|
+
extractStyledDefinitions = !1,
|
132
107
|
prefixLogs,
|
133
108
|
excludeProps,
|
134
109
|
target,
|
135
110
|
...restProps
|
136
|
-
} = options
|
137
|
-
|
138
|
-
|
111
|
+
} = options, {
|
112
|
+
expandStylesAndRemoveNullishValues,
|
113
|
+
getSplitStyles,
|
114
|
+
mediaQueryConfig,
|
115
|
+
propMapper,
|
116
|
+
proxyThemeVariables,
|
117
|
+
pseudoDescriptors
|
118
|
+
} = requireTamaguiCore(target === "html" ? "web" : "native");
|
119
|
+
let shouldPrintDebug = options.shouldPrintDebug || !1;
|
120
|
+
if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath))
|
139
121
|
return null;
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
logger.info(
|
149
|
-
`Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(
|
150
|
-
", "
|
151
|
-
)}`
|
152
|
-
);
|
153
|
-
}
|
154
|
-
return null;
|
155
|
-
}
|
122
|
+
if (!isFullyDisabled(options) && !components)
|
123
|
+
throw new Error("Must provide components");
|
124
|
+
if (sourcePath && includeExtensions && !includeExtensions.some((ext) => sourcePath.endsWith(ext)))
|
125
|
+
return shouldPrintDebug && logger.info(
|
126
|
+
`Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(
|
127
|
+
", "
|
128
|
+
)}`
|
129
|
+
), null;
|
156
130
|
function isValidStyleKey(name, staticConfig) {
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if (target === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)]) {
|
162
|
-
return false;
|
163
|
-
}
|
164
|
-
return !!(((_a2 = staticConfig.validStyles) == null ? void 0 : _a2[name]) || pseudoDescriptors[name] || // dont disable variants or else you lose many things flattening
|
165
|
-
((_b = staticConfig.variants) == null ? void 0 : _b[name]) || ((_c = projectInfo == null ? void 0 : projectInfo.tamaguiConfig) == null ? void 0 : _c.shorthands[name]) || (name[0] === "$" ? !!mediaQueryConfig[name.slice(1)] : false));
|
131
|
+
if (!projectInfo)
|
132
|
+
throw new Error("Tamagui extractor not loaded yet");
|
133
|
+
return target === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!(staticConfig.validStyles?.[name] || pseudoDescriptors[name] || // dont disable variants or else you lose many things flattening
|
134
|
+
staticConfig.variants?.[name] || projectInfo?.tamaguiConfig?.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
|
166
135
|
}
|
167
|
-
const isTargetingHTML = target === "html"
|
168
|
-
const ogDebug = shouldPrintDebug;
|
169
|
-
const tm = timer();
|
170
|
-
const propsWithFileInfo = {
|
136
|
+
const isTargetingHTML = target === "html", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo = {
|
171
137
|
...options,
|
172
138
|
sourcePath,
|
173
139
|
allLoadedComponents: components ? [...components] : []
|
174
140
|
};
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
)
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
}
|
193
|
-
}
|
194
|
-
tm.mark("load-tamagui", !!shouldPrintDebug);
|
195
|
-
if (!isFullyDisabled(options)) {
|
196
|
-
if (!(tamaguiConfig == null ? void 0 : tamaguiConfig.themes)) {
|
197
|
-
console.error(
|
198
|
-
`\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file, this may be due to duplicated dependency versions. Try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches, or search your lockfile.`
|
199
|
-
);
|
200
|
-
console.log(` Got config:`, tamaguiConfig);
|
201
|
-
process.exit(0);
|
202
|
-
}
|
203
|
-
}
|
204
|
-
const firstThemeName = Object.keys((tamaguiConfig == null ? void 0 : tamaguiConfig.themes) || {})[0];
|
205
|
-
const firstTheme = (tamaguiConfig == null ? void 0 : tamaguiConfig.themes[firstThemeName]) || {};
|
206
|
-
if (!firstTheme || typeof firstTheme !== "object") {
|
207
|
-
console.error(`Missing theme, an error occurred when importing your config`);
|
208
|
-
console.log(`Got config:`, tamaguiConfig);
|
209
|
-
console.log(`Looking for theme:`, firstThemeName);
|
210
|
-
process.exit(0);
|
211
|
-
}
|
212
|
-
const proxiedTheme = proxyThemeVariables(firstTheme);
|
213
|
-
const themeAccessListeners = /* @__PURE__ */ new Set();
|
214
|
-
const defaultTheme = new Proxy(proxiedTheme, {
|
141
|
+
hasLoggedBaseInfo || (hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info(
|
142
|
+
[
|
143
|
+
"loaded components:",
|
144
|
+
propsWithFileInfo.allLoadedComponents.map((comp) => Object.keys(comp.nameToInfo).join(", ")).join(", ")
|
145
|
+
].join(" ")
|
146
|
+
), process.env.DEBUG?.startsWith("tamagui") && logger.info(
|
147
|
+
[
|
148
|
+
"loaded:",
|
149
|
+
JSON.stringify(propsWithFileInfo.allLoadedComponents, null, 2)
|
150
|
+
].join(`
|
151
|
+
`)
|
152
|
+
)), tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig?.themes || (console.error(
|
153
|
+
'\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file, this may be due to duplicated dependency versions. Try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches, or search your lockfile.'
|
154
|
+
), console.log(" Got config:", tamaguiConfig), process.exit(0));
|
155
|
+
const firstThemeName = Object.keys(tamaguiConfig?.themes || {})[0], firstTheme = tamaguiConfig?.themes[firstThemeName] || {};
|
156
|
+
(!firstTheme || typeof firstTheme != "object") && (console.error("Missing theme, an error occurred when importing your config"), console.log("Got config:", tamaguiConfig), console.log("Looking for theme:", firstThemeName), process.exit(0));
|
157
|
+
const proxiedTheme = proxyThemeVariables(firstTheme), themeAccessListeners = /* @__PURE__ */ new Set(), defaultTheme = new Proxy(proxiedTheme, {
|
215
158
|
get(target2, key) {
|
216
|
-
|
217
|
-
themeAccessListeners.forEach((cb) => cb(String(key)));
|
218
|
-
}
|
219
|
-
return Reflect.get(target2, key);
|
220
|
-
}
|
221
|
-
});
|
222
|
-
const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
223
|
-
if (!isFullyDisabled(options)) {
|
224
|
-
if (Object.keys(components || []).length === 0) {
|
225
|
-
console.warn(
|
226
|
-
`Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)`
|
227
|
-
);
|
228
|
-
if (process.env.DEBUG === "tamagui") {
|
229
|
-
console.log(`components`, Object.keys(components || []), components);
|
230
|
-
}
|
159
|
+
return Reflect.has(target2, key) && themeAccessListeners.forEach((cb) => cb(String(key))), Reflect.get(target2, key);
|
231
160
|
}
|
232
|
-
}
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
)
|
237
|
-
|
238
|
-
let doesUseValidImport =
|
239
|
-
let hasImportedTheme = false;
|
161
|
+
}), body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
162
|
+
isFullyDisabled(options) || Object.keys(components || []).length === 0 && (console.warn(
|
163
|
+
"Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)"
|
164
|
+
), process.env.DEBUG === "tamagui" && console.log("components", Object.keys(components || []), components)), shouldPrintDebug === "verbose" && logger.info(
|
165
|
+
`allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents.map((k) => k.moduleName).join(", ")}`
|
166
|
+
);
|
167
|
+
let doesUseValidImport = !1, hasImportedTheme = !1;
|
240
168
|
const importDeclarations = [];
|
241
169
|
for (const bodyPath of body) {
|
242
170
|
if (bodyPath.type !== "ImportDeclaration")
|
243
171
|
continue;
|
244
|
-
const node = "node" in bodyPath ? bodyPath.node : bodyPath;
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
importDeclarations.push(node);
|
249
|
-
}
|
250
|
-
if (extractStyledDefinitions) {
|
251
|
-
if (valid) {
|
252
|
-
if (node.specifiers.some((specifier) => specifier.local.name === "styled")) {
|
253
|
-
doesUseValidImport = true;
|
254
|
-
break;
|
255
|
-
}
|
256
|
-
}
|
172
|
+
const node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = isValidImport(propsWithFileInfo, moduleName);
|
173
|
+
if (valid && importDeclarations.push(node), extractStyledDefinitions && valid && node.specifiers.some((specifier) => specifier.local.name === "styled")) {
|
174
|
+
doesUseValidImport = !0;
|
175
|
+
break;
|
257
176
|
}
|
258
177
|
if (valid) {
|
259
|
-
const names = node.specifiers.map((specifier) => specifier.local.name)
|
260
|
-
|
261
|
-
(name) => Boolean(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name])
|
178
|
+
const names = node.specifiers.map((specifier) => specifier.local.name), isValidComponent = names.some(
|
179
|
+
(name) => !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name])
|
262
180
|
);
|
263
|
-
if (shouldPrintDebug === "verbose"
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
)
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
}
|
272
|
-
if (isValidComponent) {
|
273
|
-
doesUseValidImport = true;
|
181
|
+
if (shouldPrintDebug === "verbose" && logger.info(
|
182
|
+
` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(
|
183
|
+
", "
|
184
|
+
)} from '${moduleName}' - (valid: ${JSON.stringify(
|
185
|
+
getValidComponentsPaths(propsWithFileInfo)
|
186
|
+
)})`
|
187
|
+
), isValidComponent) {
|
188
|
+
doesUseValidImport = !0;
|
274
189
|
break;
|
275
190
|
}
|
276
191
|
}
|
277
192
|
}
|
278
|
-
if (shouldPrintDebug
|
279
|
-
|
280
|
-
`${JSON.stringify({ doesUseValidImport, hasImportedTheme }, null, 2)}
|
193
|
+
if (shouldPrintDebug && logger.info(
|
194
|
+
`${JSON.stringify({ doesUseValidImport, hasImportedTheme }, null, 2)}
|
281
195
|
`
|
282
|
-
|
283
|
-
}
|
284
|
-
if (!doesUseValidImport) {
|
196
|
+
), !doesUseValidImport)
|
285
197
|
return null;
|
286
|
-
}
|
287
198
|
function getValidImportedComponent(componentName) {
|
288
199
|
const importDeclaration = importDeclarations.find(
|
289
200
|
(dec) => dec.specifiers.some((spec) => spec.local.name === componentName)
|
290
201
|
);
|
291
|
-
|
292
|
-
return null;
|
293
|
-
}
|
294
|
-
return getValidImport(
|
202
|
+
return importDeclaration ? getValidImport(
|
295
203
|
propsWithFileInfo,
|
296
204
|
importDeclaration.source.value,
|
297
205
|
componentName
|
298
|
-
);
|
206
|
+
) : null;
|
299
207
|
}
|
300
208
|
tm.mark("import-check", !!shouldPrintDebug);
|
301
|
-
let couldntParse =
|
302
|
-
const modifiedComponents = /* @__PURE__ */ new Set();
|
303
|
-
const bindingCache = {};
|
304
|
-
const callTraverse = (a) => {
|
305
|
-
return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
|
306
|
-
};
|
307
|
-
const shouldDisableExtraction = disableExtraction === true || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath);
|
209
|
+
let couldntParse = !1;
|
210
|
+
const modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = (a) => fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a), shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath);
|
308
211
|
let programPath = null;
|
309
212
|
const res = {
|
310
213
|
styled: 0,
|
@@ -313,7 +216,7 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
313
216
|
modified: 0,
|
314
217
|
found: 0
|
315
218
|
};
|
316
|
-
callTraverse({
|
219
|
+
if (callTraverse({
|
317
220
|
// @ts-ignore
|
318
221
|
Program: {
|
319
222
|
enter(path) {
|
@@ -322,28 +225,17 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
322
225
|
},
|
323
226
|
// styled() calls
|
324
227
|
CallExpression(path) {
|
325
|
-
|
326
|
-
if (disable || shouldDisableExtraction || extractStyledDefinitions === false) {
|
228
|
+
if (disable || shouldDisableExtraction || extractStyledDefinitions === !1 || !t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled")
|
327
229
|
return;
|
328
|
-
|
329
|
-
if (!t.isIdentifier(
|
230
|
+
const variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown", parentNode = path.node.arguments[0];
|
231
|
+
if (!t.isIdentifier(parentNode))
|
330
232
|
return;
|
331
|
-
|
332
|
-
|
333
|
-
const parentNode = path.node.arguments[0];
|
334
|
-
if (!t.isIdentifier(parentNode)) {
|
233
|
+
const parentName = parentNode.name, definition = path.node.arguments[1];
|
234
|
+
if (!parentName || !definition || !t.isObjectExpression(definition))
|
335
235
|
return;
|
336
|
-
}
|
337
|
-
const parentName = parentNode.name;
|
338
|
-
const definition = path.node.arguments[1];
|
339
|
-
if (!parentName || !definition || !t.isObjectExpression(definition)) {
|
340
|
-
return;
|
341
|
-
}
|
342
236
|
const Component = getValidImportedComponent(parentName);
|
343
237
|
if (!Component) {
|
344
|
-
|
345
|
-
logger.info(` No component found`);
|
346
|
-
}
|
238
|
+
shouldPrintDebug && logger.info(" No component found");
|
347
239
|
return;
|
348
240
|
}
|
349
241
|
const componentSkipProps = /* @__PURE__ */ new Set([
|
@@ -359,37 +251,28 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
359
251
|
"focusStyle",
|
360
252
|
"hoverStyle",
|
361
253
|
"pressStyle"
|
362
|
-
])
|
363
|
-
const skipped = /* @__PURE__ */ new Set();
|
364
|
-
const styles = {};
|
365
|
-
const staticNamespace = getStaticBindingsForScope(
|
254
|
+
]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = getStaticBindingsForScope(
|
366
255
|
path.scope,
|
367
256
|
importsWhitelist,
|
368
257
|
sourcePath,
|
369
258
|
bindingCache,
|
370
259
|
shouldPrintDebug
|
371
|
-
)
|
372
|
-
const attemptEval = !evaluateVars ? evaluateAstNode : createEvaluator({
|
260
|
+
), attemptEval = evaluateVars ? createEvaluator({
|
373
261
|
props: propsWithFileInfo,
|
374
262
|
staticNamespace,
|
375
263
|
sourcePath,
|
376
264
|
shouldPrintDebug
|
377
|
-
});
|
378
|
-
const attemptEvalSafe = createSafeEvaluator(attemptEval);
|
265
|
+
}) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
|
379
266
|
for (const property of definition.properties) {
|
380
267
|
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || // TODO make pseudos and variants work
|
381
268
|
// skip pseudos
|
382
269
|
pseudoDescriptors[property.key.name] || // skip variants
|
383
|
-
|
270
|
+
Component.staticConfig.variants?.[property.key.name] || componentSkipProps.has(property.key.name)) {
|
384
271
|
skipped.add(property);
|
385
272
|
continue;
|
386
273
|
}
|
387
274
|
const out2 = attemptEvalSafe(property.value);
|
388
|
-
|
389
|
-
skipped.add(property);
|
390
|
-
} else {
|
391
|
-
styles[property.key.name] = out2;
|
392
|
-
}
|
275
|
+
out2 === FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out2;
|
393
276
|
}
|
394
277
|
const out = getSplitStyles(
|
395
278
|
styles,
|
@@ -402,134 +285,82 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
402
285
|
void 0,
|
403
286
|
void 0,
|
404
287
|
shouldPrintDebug
|
405
|
-
)
|
406
|
-
const classNames = {
|
288
|
+
), classNames = {
|
407
289
|
...out.classNames
|
408
290
|
};
|
409
|
-
if (shouldPrintDebug
|
410
|
-
|
411
|
-
|
412
|
-
`Extracted styled(${variableName})
|
291
|
+
if (shouldPrintDebug && logger.info(
|
292
|
+
[
|
293
|
+
`Extracted styled(${variableName})
|
413
294
|
`,
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
295
|
+
JSON.stringify(styles, null, 2),
|
296
|
+
`
|
297
|
+
classNames:`,
|
298
|
+
JSON.stringify(classNames, null, 2),
|
299
|
+
`
|
300
|
+
rulesToInsert:`,
|
301
|
+
out.rulesToInsert.flatMap((rule) => rule.rules).join(`
|
302
|
+
`)
|
303
|
+
].join(" ")
|
304
|
+
), definition.properties = definition.properties.map((prop) => {
|
305
|
+
if (skipped.has(prop) || !t.isObjectProperty(prop) || !t.isIdentifier(prop.key))
|
424
306
|
return prop;
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
return prop;
|
432
|
-
});
|
433
|
-
if (out.rulesToInsert) {
|
434
|
-
for (const { identifier, rules } of out.rulesToInsert) {
|
435
|
-
onStyleRule == null ? void 0 : onStyleRule(identifier, rules);
|
436
|
-
}
|
437
|
-
}
|
438
|
-
res.styled++;
|
439
|
-
if (shouldPrintDebug) {
|
440
|
-
logger.info(`Extracted styled(${variableName})`);
|
441
|
-
}
|
307
|
+
const key = prop.key.name, value = classNames[key];
|
308
|
+
return value ? t.objectProperty(t.stringLiteral(key), t.stringLiteral(value)) : prop;
|
309
|
+
}), out.rulesToInsert)
|
310
|
+
for (const { identifier, rules } of out.rulesToInsert)
|
311
|
+
onStyleRule?.(identifier, rules);
|
312
|
+
res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
|
442
313
|
},
|
443
314
|
JSXElement(traversePath) {
|
444
|
-
var _a2;
|
445
315
|
tm.mark("jsx-element", !!shouldPrintDebug);
|
446
|
-
const node = traversePath.node.openingElement;
|
447
|
-
|
448
|
-
const componentName = findComponentName(traversePath.scope);
|
449
|
-
const closingElement = traversePath.node.closingElement;
|
450
|
-
if (t.isJSXMemberExpression(closingElement == null ? void 0 : closingElement.name) || !t.isJSXIdentifier(node.name)) {
|
316
|
+
const node = traversePath.node.openingElement, ogAttributes = node.attributes.map((attr) => ({ ...attr })), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
|
317
|
+
if (t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name))
|
451
318
|
return;
|
452
|
-
}
|
453
319
|
const binding = traversePath.scope.getBinding(node.name.name);
|
454
320
|
let modulePath = "";
|
455
321
|
if (binding) {
|
456
322
|
if (!t.isImportDeclaration(binding.path.parent)) {
|
457
|
-
|
458
|
-
logger.info(` - Binding not import declaration, skip`);
|
459
|
-
}
|
323
|
+
shouldPrintDebug && logger.info(" - Binding not import declaration, skip");
|
460
324
|
return;
|
461
325
|
}
|
462
|
-
modulePath = binding.path.parent.source.value
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
` - Binding for ${componentName} not internal import or from components ${binding.identifier.name} in ${modulePath}`
|
467
|
-
);
|
468
|
-
}
|
326
|
+
if (modulePath = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, modulePath, binding.identifier.name)) {
|
327
|
+
shouldPrintDebug && logger.info(
|
328
|
+
` - Binding for ${componentName} not internal import or from components ${binding.identifier.name} in ${modulePath}`
|
329
|
+
);
|
469
330
|
return;
|
470
331
|
}
|
471
332
|
}
|
472
333
|
const component = getValidComponent(propsWithFileInfo, modulePath, node.name.name);
|
473
334
|
if (!component || !component.staticConfig) {
|
474
|
-
|
475
|
-
logger.info(` - No Tamagui conf on this: ${node.name.name}`);
|
476
|
-
}
|
335
|
+
shouldPrintDebug && logger.info(` - No Tamagui conf on this: ${node.name.name}`);
|
477
336
|
return;
|
478
337
|
}
|
479
338
|
const originalNodeName = node.name.name;
|
480
339
|
res.found++;
|
481
|
-
const filePath = `./${relative(process.cwd(), sourcePath)}
|
482
|
-
const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
483
|
-
const codePosition = `${filePath}:${lineNumbers}`;
|
484
|
-
const debugPropValue = node.attributes.filter(
|
340
|
+
const filePath = `./${relative(process.cwd(), sourcePath)}`, lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "", codePosition = `${filePath}:${lineNumbers}`, debugPropValue = node.attributes.filter(
|
485
341
|
(n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug"
|
486
|
-
).map((n) =>
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
);
|
501
|
-
logger.info(["\x1B[1m", "\x1B[32m", `<${originalNodeName} />`, disableDebugAttr ? "" : "\u{1F41B}"].join(" "));
|
502
|
-
}
|
503
|
-
if (shouldAddDebugProp && !disableDebugAttr) {
|
504
|
-
res.modified++;
|
505
|
-
node.attributes.unshift(
|
506
|
-
t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(node.name.name))
|
507
|
-
);
|
508
|
-
if (componentName) {
|
509
|
-
node.attributes.unshift(
|
510
|
-
t.jsxAttribute(t.jsxIdentifier("data-in"), t.stringLiteral(componentName))
|
511
|
-
);
|
512
|
-
}
|
513
|
-
node.attributes.unshift(
|
514
|
-
t.jsxAttribute(
|
515
|
-
t.jsxIdentifier("data-at"),
|
516
|
-
t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)
|
517
|
-
)
|
518
|
-
);
|
519
|
-
}
|
520
|
-
if (shouldDisableExtraction) {
|
521
|
-
if (shouldPrintDebug === "verbose") {
|
522
|
-
console.log(` Extraction disabled`);
|
523
|
-
}
|
342
|
+
).map((n) => n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1)[0];
|
343
|
+
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`
|
344
|
+
`), logger.info(
|
345
|
+
`\x1B[33m%s\x1B[0m ${componentName} | ${codePosition} -------------------`
|
346
|
+
), logger.info(["\x1B[1m", "\x1B[32m", `<${originalNodeName} />`, disableDebugAttr ? "" : "\u{1F41B}"].join(" "))), shouldAddDebugProp && !disableDebugAttr && (res.modified++, node.attributes.unshift(
|
347
|
+
t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(node.name.name))
|
348
|
+
), componentName && node.attributes.unshift(
|
349
|
+
t.jsxAttribute(t.jsxIdentifier("data-in"), t.stringLiteral(componentName))
|
350
|
+
), node.attributes.unshift(
|
351
|
+
t.jsxAttribute(
|
352
|
+
t.jsxIdentifier("data-at"),
|
353
|
+
t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)
|
354
|
+
)
|
355
|
+
)), shouldDisableExtraction) {
|
356
|
+
shouldPrintDebug === "verbose" && console.log(" Extraction disabled");
|
524
357
|
return;
|
525
358
|
}
|
526
359
|
try {
|
527
|
-
let
|
528
|
-
const attribute = path.node;
|
529
|
-
const attr = { type: "attr", value: attribute };
|
360
|
+
let evaluateAttribute = function(path) {
|
361
|
+
const attribute = path.node, attr = { type: "attr", value: attribute };
|
530
362
|
if (t.isJSXSpreadAttribute(attribute)) {
|
531
|
-
const arg = attribute.argument
|
532
|
-
const conditional = t.isConditionalExpression(arg) ? (
|
363
|
+
const arg = attribute.argument, conditional = t.isConditionalExpression(arg) ? (
|
533
364
|
// <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
|
534
365
|
[arg.test, arg.consequent, arg.alternate]
|
535
366
|
) : t.isLogicalExpression(arg) && arg.operator === "&&" ? (
|
@@ -539,16 +370,10 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
539
370
|
if (conditional) {
|
540
371
|
const [test, alt, cons] = conditional;
|
541
372
|
if (!test)
|
542
|
-
throw new Error(
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
}
|
547
|
-
return attr;
|
548
|
-
}
|
549
|
-
return [
|
550
|
-
...createTernariesFromObjectProperties2(test, alt) || [],
|
551
|
-
...cons && createTernariesFromObjectProperties2(
|
373
|
+
throw new Error("no test");
|
374
|
+
return [alt, cons].some((side) => side && !isStaticObject(side)) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr) : [
|
375
|
+
...createTernariesFromObjectProperties(test, alt) || [],
|
376
|
+
...cons && createTernariesFromObjectProperties(
|
552
377
|
t.unaryExpression("!", test),
|
553
378
|
cons
|
554
379
|
) || []
|
@@ -558,209 +383,92 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
558
383
|
}));
|
559
384
|
}
|
560
385
|
}
|
561
|
-
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name
|
562
|
-
|
563
|
-
logger.info(" ! inlining, spread attr");
|
564
|
-
}
|
565
|
-
inlined.set(`${Math.random()}`, "spread");
|
566
|
-
return attr;
|
567
|
-
}
|
386
|
+
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string")
|
387
|
+
return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr;
|
568
388
|
const name = attribute.name.name;
|
569
|
-
if (excludeProps
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
if (
|
576
|
-
inlined.set(name, name);
|
577
|
-
if (shouldPrintDebug) {
|
578
|
-
logger.info([" ! inlining, inline prop", name].join(" "));
|
579
|
-
}
|
580
|
-
return attr;
|
581
|
-
}
|
582
|
-
if (deoptProps.has(name)) {
|
583
|
-
shouldDeopt = true;
|
584
|
-
inlined.set(name, name);
|
585
|
-
if (shouldPrintDebug) {
|
586
|
-
logger.info([" ! inlining, deopted prop", name].join(" "));
|
587
|
-
}
|
389
|
+
if (excludeProps?.has(name))
|
390
|
+
return shouldPrintDebug && logger.info([" excluding prop", name].join(" ")), null;
|
391
|
+
if (inlineProps.has(name))
|
392
|
+
return inlined.set(name, name), shouldPrintDebug && logger.info([" ! inlining, inline prop", name].join(" ")), attr;
|
393
|
+
if (deoptProps.has(name))
|
394
|
+
return shouldDeopt = !0, inlined.set(name, name), shouldPrintDebug && logger.info([" ! inlining, deopted prop", name].join(" ")), attr;
|
395
|
+
if (UNTOUCHED_PROPS[name])
|
588
396
|
return attr;
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
}
|
593
|
-
if (INLINE_EXTRACTABLE[name]) {
|
594
|
-
inlined.set(name, INLINE_EXTRACTABLE[name]);
|
397
|
+
if (INLINE_EXTRACTABLE[name])
|
398
|
+
return inlined.set(name, INLINE_EXTRACTABLE[name]), attr;
|
399
|
+
if (name.startsWith("data-"))
|
595
400
|
return attr;
|
596
|
-
|
597
|
-
if (name.startsWith("data-")) {
|
598
|
-
return attr;
|
599
|
-
}
|
600
|
-
if (name[0] === "$" && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
|
401
|
+
if (name[0] === "$" && t.isJSXExpressionContainer(attribute?.value)) {
|
601
402
|
const shortname = name.slice(1);
|
602
403
|
if (mediaQueryConfig[shortname]) {
|
603
|
-
if (target === "native")
|
604
|
-
shouldDeopt = true;
|
605
|
-
}
|
606
|
-
if (disableExtractInlineMedia) {
|
404
|
+
if (target === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
|
607
405
|
return attr;
|
608
|
-
}
|
609
406
|
const expression = attribute.value.expression;
|
610
407
|
if (!t.isJSXEmptyExpression(expression)) {
|
611
|
-
const ternaries2 =
|
408
|
+
const ternaries2 = createTernariesFromObjectProperties(
|
612
409
|
t.stringLiteral(shortname),
|
613
410
|
expression,
|
614
411
|
{
|
615
412
|
inlineMediaQuery: shortname
|
616
413
|
}
|
617
414
|
);
|
618
|
-
if (ternaries2)
|
415
|
+
if (ternaries2)
|
619
416
|
return ternaries2.map((value2) => ({
|
620
417
|
type: "ternary",
|
621
418
|
value: value2
|
622
419
|
}));
|
623
|
-
}
|
624
420
|
}
|
625
421
|
}
|
626
422
|
}
|
627
|
-
const [value, valuePath] = (() => {
|
628
|
-
if (t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
|
629
|
-
return [attribute.value.expression, path.get("value")];
|
630
|
-
} else {
|
631
|
-
return [attribute.value, path.get("value")];
|
632
|
-
}
|
633
|
-
})();
|
634
|
-
const remove = () => {
|
423
|
+
const [value, valuePath] = (() => t.isJSXExpressionContainer(attribute?.value) ? [attribute.value.expression, path.get("value")] : [attribute.value, path.get("value")])(), remove = () => {
|
635
424
|
Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
|
636
425
|
};
|
637
|
-
if (name === "ref")
|
638
|
-
|
639
|
-
|
640
|
-
}
|
641
|
-
inlined.set("ref", "ref");
|
642
|
-
return attr;
|
643
|
-
}
|
644
|
-
if (name === "tag") {
|
426
|
+
if (name === "ref")
|
427
|
+
return shouldPrintDebug && logger.info([" ! inlining, ref", name].join(" ")), inlined.set("ref", "ref"), attr;
|
428
|
+
if (name === "tag")
|
645
429
|
return {
|
646
430
|
type: "attr",
|
647
431
|
value: path.node
|
648
432
|
};
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
].join(" ")
|
659
|
-
);
|
660
|
-
}
|
661
|
-
inlined.set(name, true);
|
662
|
-
return attr;
|
663
|
-
}
|
664
|
-
}
|
665
|
-
}
|
666
|
-
if (name === "theme") {
|
667
|
-
inlined.set("theme", attr.value);
|
668
|
-
return attr;
|
669
|
-
}
|
433
|
+
if (disableExtractVariables === !0 && value && value.type === "StringLiteral" && value.value[0] === "$")
|
434
|
+
return shouldPrintDebug && logger.info(
|
435
|
+
[
|
436
|
+
` ! inlining, native disable extract: ${name} =`,
|
437
|
+
value.value
|
438
|
+
].join(" ")
|
439
|
+
), inlined.set(name, !0), attr;
|
440
|
+
if (name === "theme")
|
441
|
+
return inlined.set("theme", attr.value), attr;
|
670
442
|
const styleValue = attemptEvalSafe(value);
|
671
443
|
if (!variants[name] && !isValidStyleKey(name, staticConfig)) {
|
672
|
-
let keys = [name];
|
673
|
-
|
674
|
-
|
675
|
-
if (out) {
|
676
|
-
if (!Array.isArray(out)) {
|
677
|
-
logger.warn(`Error expected array but got`, out);
|
678
|
-
couldntParse = true;
|
679
|
-
shouldDeopt = true;
|
680
|
-
} else {
|
681
|
-
out = Object.fromEntries(out);
|
682
|
-
keys = Object.keys(out);
|
683
|
-
}
|
684
|
-
}
|
685
|
-
if (out) {
|
686
|
-
if (isTargetingHTML) {
|
687
|
-
out = createDOMProps(isTextView ? "span" : "div", out);
|
688
|
-
delete out.className;
|
689
|
-
}
|
690
|
-
keys = Object.keys(out);
|
691
|
-
}
|
692
|
-
let didInline = false;
|
444
|
+
let keys = [name], out = null;
|
445
|
+
out = propMapper(name, styleValue, propMapperStyleState), out && (Array.isArray(out) ? (out = Object.fromEntries(out), keys = Object.keys(out)) : (logger.warn("Error expected array but got", out), couldntParse = !0, shouldDeopt = !0)), out && (isTargetingHTML && (out = createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
|
446
|
+
let didInline = !1;
|
693
447
|
const attributes = keys.map((key) => {
|
694
448
|
const val = out[key];
|
695
|
-
|
696
|
-
if (isStyle) {
|
697
|
-
return {
|
698
|
-
type: "style",
|
699
|
-
value: { [key]: styleValue },
|
700
|
-
name: key,
|
701
|
-
attr: path.node
|
702
|
-
};
|
703
|
-
}
|
704
|
-
if (validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
|
705
|
-
key === "__source" || key === "__self") {
|
706
|
-
return attr;
|
707
|
-
}
|
708
|
-
if (shouldPrintDebug) {
|
709
|
-
logger.info(" ! inlining, non-static " + key);
|
710
|
-
}
|
711
|
-
didInline = true;
|
712
|
-
inlined.set(key, val);
|
713
|
-
return val;
|
714
|
-
});
|
715
|
-
if (didInline) {
|
716
|
-
if (shouldPrintDebug) {
|
717
|
-
logger.info(` bailing flattening due to attributes ${attributes}`);
|
718
|
-
}
|
719
|
-
return attr;
|
720
|
-
}
|
721
|
-
return attributes;
|
722
|
-
}
|
723
|
-
if (styleValue !== FAILED_EVAL) {
|
724
|
-
if (inlineWhenUnflattened.has(name)) {
|
725
|
-
inlineWhenUnflattenedOGVals[name] = { styleValue, attr };
|
726
|
-
}
|
727
|
-
if (isValidStyleKey(name, staticConfig)) {
|
728
|
-
if (shouldPrintDebug) {
|
729
|
-
logger.info(` style: ${name} = ${styleValue}`);
|
730
|
-
}
|
731
|
-
if (!(name in defaultProps)) {
|
732
|
-
if (!hasSetOptimized) {
|
733
|
-
res.optimized++;
|
734
|
-
hasSetOptimized = true;
|
735
|
-
}
|
736
|
-
}
|
737
|
-
return {
|
449
|
+
return isValidStyleKey(key, staticConfig) ? {
|
738
450
|
type: "style",
|
739
|
-
value: { [
|
740
|
-
name,
|
451
|
+
value: { [key]: styleValue },
|
452
|
+
name: key,
|
741
453
|
attr: path.node
|
742
|
-
}
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
}
|
747
|
-
inlined.set(name, true);
|
748
|
-
return attr;
|
749
|
-
}
|
454
|
+
} : validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
|
455
|
+
key === "__source" || key === "__self" ? attr : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key), didInline = !0, inlined.set(key, val), val);
|
456
|
+
});
|
457
|
+
return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes}`), attr) : attributes;
|
750
458
|
}
|
459
|
+
if (styleValue !== FAILED_EVAL)
|
460
|
+
return inlineWhenUnflattened.has(name) && (inlineWhenUnflattenedOGVals[name] = { styleValue, attr }), isValidStyleKey(name, staticConfig) ? (shouldPrintDebug && logger.info(` style: ${name} = ${styleValue}`), name in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
|
461
|
+
type: "style",
|
462
|
+
value: { [name]: styleValue },
|
463
|
+
name,
|
464
|
+
attr: path.node
|
465
|
+
}) : (variants[name] && variantValues.set(name, styleValue), inlined.set(name, !0), attr);
|
751
466
|
if (t.isBinaryExpression(value)) {
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
const rVal = attemptEvalSafe(right);
|
758
|
-
if (shouldPrintDebug) {
|
759
|
-
logger.info(
|
760
|
-
` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`
|
761
|
-
);
|
762
|
-
}
|
763
|
-
if (lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
|
467
|
+
shouldPrintDebug && logger.info(` binary expression ${name} = ${value}`);
|
468
|
+
const { operator, left, right } = value, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
|
469
|
+
if (shouldPrintDebug && logger.info(
|
470
|
+
` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`
|
471
|
+
), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
|
764
472
|
const ternary = addBinaryConditional(operator, left, right);
|
765
473
|
if (ternary)
|
766
474
|
return ternary;
|
@@ -770,43 +478,23 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
770
478
|
if (ternary)
|
771
479
|
return ternary;
|
772
480
|
}
|
773
|
-
|
774
|
-
logger.info(` evalBinaryExpression cant extract`);
|
775
|
-
}
|
776
|
-
inlined.set(name, true);
|
777
|
-
return attr;
|
481
|
+
return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name, !0), attr;
|
778
482
|
}
|
779
483
|
const staticConditional = getStaticConditional(value);
|
780
|
-
if (staticConditional)
|
781
|
-
|
782
|
-
logger.info(` static conditional ${name} ${value}`);
|
783
|
-
}
|
784
|
-
return { type: "ternary", value: staticConditional };
|
785
|
-
}
|
484
|
+
if (staticConditional)
|
485
|
+
return shouldPrintDebug === "verbose" && logger.info(` static conditional ${name} ${value}`), { type: "ternary", value: staticConditional };
|
786
486
|
const staticLogical = getStaticLogical(value);
|
787
|
-
if (staticLogical)
|
788
|
-
|
789
|
-
|
790
|
-
}
|
791
|
-
return { type: "ternary", value: staticLogical };
|
792
|
-
}
|
793
|
-
inlined.set(name, true);
|
794
|
-
if (shouldPrintDebug) {
|
795
|
-
logger.info(` ! inline no match ${name} ${value}`);
|
796
|
-
}
|
797
|
-
return attr;
|
487
|
+
if (staticLogical)
|
488
|
+
return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name} = ${value}`), { type: "ternary", value: staticLogical };
|
489
|
+
return inlined.set(name, !0), shouldPrintDebug && logger.info(` ! inline no match ${name} ${value}`), attr;
|
798
490
|
function addBinaryConditional(operator, staticExpr, cond) {
|
799
491
|
if (getStaticConditional(cond)) {
|
800
492
|
const alt = attemptEval(
|
801
493
|
t.binaryExpression(operator, staticExpr, cond.alternate)
|
802
|
-
)
|
803
|
-
const cons = attemptEval(
|
494
|
+
), cons = attemptEval(
|
804
495
|
t.binaryExpression(operator, staticExpr, cond.consequent)
|
805
496
|
);
|
806
|
-
|
807
|
-
logger.info([" binaryConditional", cond.test, cons, alt].join(" "));
|
808
|
-
}
|
809
|
-
return {
|
497
|
+
return shouldPrintDebug && logger.info([" binaryConditional", cond.test, cons, alt].join(" ")), {
|
810
498
|
type: "ternary",
|
811
499
|
value: {
|
812
500
|
test: cond.test,
|
@@ -819,10 +507,9 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
819
507
|
return null;
|
820
508
|
}
|
821
509
|
function getStaticConditional(value2) {
|
822
|
-
if (t.isConditionalExpression(value2))
|
510
|
+
if (t.isConditionalExpression(value2))
|
823
511
|
try {
|
824
|
-
const aVal = attemptEval(value2.alternate);
|
825
|
-
const cVal = attemptEval(value2.consequent);
|
512
|
+
const aVal = attemptEval(value2.alternate), cVal = attemptEval(value2.consequent);
|
826
513
|
if (shouldPrintDebug) {
|
827
514
|
const type = value2.test.type;
|
828
515
|
logger.info([" static ternary", type, cVal, aVal].join(" "));
|
@@ -834,89 +521,61 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
834
521
|
alternate: { [name]: aVal }
|
835
522
|
};
|
836
523
|
} catch (err) {
|
837
|
-
|
838
|
-
logger.info([" cant eval ternary", err.message].join(" "));
|
839
|
-
}
|
524
|
+
shouldPrintDebug && logger.info([" cant eval ternary", err.message].join(" "));
|
840
525
|
}
|
841
|
-
}
|
842
526
|
return null;
|
843
527
|
}
|
844
528
|
function getStaticLogical(value2) {
|
845
|
-
if (t.isLogicalExpression(value2))
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
}
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
alternate: null
|
857
|
-
};
|
858
|
-
} catch (err) {
|
859
|
-
if (shouldPrintDebug) {
|
860
|
-
logger.info([" cant static eval logical", err].join(" "));
|
861
|
-
}
|
862
|
-
}
|
529
|
+
if (t.isLogicalExpression(value2) && value2.operator === "&&")
|
530
|
+
try {
|
531
|
+
const val = attemptEval(value2.right);
|
532
|
+
return shouldPrintDebug && logger.info([" staticLogical", value2.left, name, val].join(" ")), {
|
533
|
+
test: value2.left,
|
534
|
+
remove,
|
535
|
+
consequent: { [name]: val },
|
536
|
+
alternate: null
|
537
|
+
};
|
538
|
+
} catch (err) {
|
539
|
+
shouldPrintDebug && logger.info([" cant static eval logical", err].join(" "));
|
863
540
|
}
|
864
|
-
}
|
865
541
|
return null;
|
866
542
|
}
|
867
|
-
},
|
543
|
+
}, isStaticObject = function(obj) {
|
868
544
|
return t.isObjectExpression(obj) && obj.properties.every((prop) => {
|
869
|
-
if (!t.isObjectProperty(prop))
|
870
|
-
logger.info(["not object prop", prop].join(" "));
|
871
|
-
|
872
|
-
|
873
|
-
const propName = prop.key["name"];
|
874
|
-
if (!isValidStyleKey(propName, staticConfig) && propName !== "tag") {
|
875
|
-
if (shouldPrintDebug) {
|
876
|
-
logger.info([" not a valid style prop!", propName].join(" "));
|
877
|
-
}
|
878
|
-
return false;
|
879
|
-
}
|
880
|
-
return true;
|
545
|
+
if (!t.isObjectProperty(prop))
|
546
|
+
return logger.info(["not object prop", prop].join(" ")), !1;
|
547
|
+
const propName = prop.key.name;
|
548
|
+
return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([" not a valid style prop!", propName].join(" ")), !1) : !0;
|
881
549
|
});
|
882
|
-
},
|
883
|
-
if (!side)
|
550
|
+
}, createTernariesFromObjectProperties = function(test, side, ternaryPartial = {}) {
|
551
|
+
if (!side)
|
884
552
|
return null;
|
885
|
-
|
886
|
-
if (!isStaticObject2(side)) {
|
553
|
+
if (!isStaticObject(side))
|
887
554
|
throw new Error("not extractable");
|
888
|
-
}
|
889
555
|
return side.properties.flatMap((property) => {
|
890
|
-
if (!t.isObjectProperty(property))
|
556
|
+
if (!t.isObjectProperty(property))
|
891
557
|
throw new Error("expected object property");
|
892
|
-
}
|
893
558
|
if (t.isIdentifier(property.key)) {
|
894
|
-
const key = property.key.name;
|
895
|
-
|
896
|
-
const isMediaQuery = key[0] === "$" && mediaQueryConfig[mediaQueryKey];
|
897
|
-
if (isMediaQuery) {
|
559
|
+
const key = property.key.name, mediaQueryKey = key.slice(1);
|
560
|
+
if (key[0] === "$" && mediaQueryConfig[mediaQueryKey])
|
898
561
|
if (t.isExpression(property.value)) {
|
899
|
-
const ternaries2 =
|
562
|
+
const ternaries2 = createTernariesFromObjectProperties(
|
900
563
|
t.stringLiteral(mediaQueryKey),
|
901
564
|
property.value,
|
902
565
|
{
|
903
566
|
inlineMediaQuery: mediaQueryKey
|
904
567
|
}
|
905
568
|
);
|
906
|
-
if (ternaries2)
|
569
|
+
if (ternaries2)
|
907
570
|
return ternaries2.map((value) => ({
|
908
571
|
...ternaryPartial,
|
909
572
|
...value,
|
910
573
|
// ensure media query test stays on left side (see getMediaQueryTernary)
|
911
574
|
test: t.logicalExpression("&&", value.test, test)
|
912
575
|
}));
|
913
|
-
|
914
|
-
|
915
|
-
}
|
916
|
-
} else {
|
576
|
+
logger.info(["\u26A0\uFE0F no ternaries?", property].join(" "));
|
577
|
+
} else
|
917
578
|
logger.info(["\u26A0\uFE0F not expression", property].join(" "));
|
918
|
-
}
|
919
|
-
}
|
920
579
|
}
|
921
580
|
if (t.isConditionalExpression(property.value)) {
|
922
581
|
const [truthy, falsy] = [
|
@@ -952,8 +611,7 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
952
611
|
}
|
953
612
|
const obj = t.objectExpression([
|
954
613
|
t.objectProperty(property.key, property.value)
|
955
|
-
]);
|
956
|
-
const consequent = attemptEval(obj);
|
614
|
+
]), consequent = attemptEval(obj);
|
957
615
|
return createTernary({
|
958
616
|
remove() {
|
959
617
|
},
|
@@ -963,103 +621,67 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
963
621
|
alternate: null
|
964
622
|
});
|
965
623
|
});
|
966
|
-
},
|
967
|
-
|
968
|
-
|
969
|
-
}
|
970
|
-
obj[key] = val;
|
971
|
-
}, expandStylesAndRemoveNullishValuesWithoutVariants2 = function(style) {
|
624
|
+
}, mergeToEnd = function(obj, key, val) {
|
625
|
+
key in obj && delete obj[key], obj[key] = val;
|
626
|
+
}, expandStylesAndRemoveNullishValuesWithoutVariants = function(style) {
|
972
627
|
let res2 = {};
|
973
|
-
for (const key in style)
|
974
|
-
if (staticConfig.variants && key in staticConfig.variants)
|
975
|
-
|
976
|
-
|
628
|
+
for (const key in style)
|
629
|
+
if (staticConfig.variants && key in staticConfig.variants)
|
630
|
+
mergeToEnd(res2, key, style[key]);
|
631
|
+
else {
|
977
632
|
const expanded = expandStylesAndRemoveNullishValues({ [key]: style[key] });
|
978
|
-
for (const key2 in expanded)
|
979
|
-
|
980
|
-
}
|
633
|
+
for (const key2 in expanded)
|
634
|
+
mergeToEnd(res2, key2, expanded[key2]);
|
981
635
|
}
|
982
|
-
}
|
983
636
|
return res2;
|
984
|
-
},
|
985
|
-
for (const key in next)
|
986
|
-
|
987
|
-
prev2[key] = prev2[key] || {};
|
988
|
-
Object.assign(prev2[key], next[key]);
|
989
|
-
} else {
|
990
|
-
mergeToEnd2(prev2, key, next[key]);
|
991
|
-
}
|
992
|
-
}
|
637
|
+
}, mergeStyles = function(prev2, next) {
|
638
|
+
for (const key in next)
|
639
|
+
pseudoDescriptors[key] ? (prev2[key] = prev2[key] || {}, Object.assign(prev2[key], next[key])) : mergeToEnd(prev2, key, next[key]);
|
993
640
|
};
|
994
|
-
|
995
|
-
const { staticConfig } = component;
|
996
|
-
const defaultProps = { ...staticConfig.defaultProps || {} };
|
997
|
-
const variants = staticConfig.variants || {};
|
998
|
-
const isTextView = staticConfig.isText || false;
|
999
|
-
const validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
|
641
|
+
const { staticConfig } = component, defaultProps = { ...staticConfig.defaultProps || {} }, variants = staticConfig.variants || {}, isTextView = staticConfig.isText || !1, validStyles = staticConfig?.validStyles ?? {};
|
1000
642
|
let tagName = defaultProps.tag ?? (isTextView ? "span" : "div");
|
1001
643
|
traversePath.get("openingElement").get("attributes").forEach((path) => {
|
1002
644
|
const attr = path.node;
|
1003
|
-
if (t.isJSXSpreadAttribute(attr))
|
1004
|
-
return;
|
1005
|
-
if (attr.name.name !== "tag")
|
645
|
+
if (t.isJSXSpreadAttribute(attr) || attr.name.name !== "tag")
|
1006
646
|
return;
|
1007
647
|
const val = attr.value;
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
});
|
1012
|
-
if (shouldPrintDebug === "verbose") {
|
1013
|
-
console.log(` Start tag ${tagName}`);
|
1014
|
-
}
|
1015
|
-
const flatNode = getFlattenedNode == null ? void 0 : getFlattenedNode({ isTextView, tag: tagName });
|
1016
|
-
const inlineProps = /* @__PURE__ */ new Set([
|
648
|
+
t.isStringLiteral(val) && (tagName = val.value);
|
649
|
+
}), shouldPrintDebug === "verbose" && console.log(` Start tag ${tagName}`);
|
650
|
+
const flatNode = getFlattenedNode?.({ isTextView, tag: tagName }), inlineProps = /* @__PURE__ */ new Set([
|
1017
651
|
// adding some always inline props
|
1018
652
|
"dataSet",
|
1019
653
|
...restProps.inlineProps || [],
|
1020
654
|
...staticConfig.inlineProps || []
|
1021
|
-
])
|
1022
|
-
const deoptProps = /* @__PURE__ */ new Set([
|
655
|
+
]), deoptProps = /* @__PURE__ */ new Set([
|
1023
656
|
// always de-opt animation these
|
1024
657
|
"animation",
|
1025
658
|
"disableOptimization",
|
1026
659
|
// when using a non-CSS driver, de-opt on enterStyle/exitStyle
|
1027
|
-
...
|
660
|
+
...tamaguiConfig?.animations.isReactNative ? ["enterStyle", "exitStyle"] : [],
|
1028
661
|
...restProps.deoptProps || [],
|
1029
662
|
...staticConfig.deoptProps || []
|
1030
|
-
])
|
1031
|
-
const inlineWhenUnflattened = /* @__PURE__ */ new Set([
|
663
|
+
]), inlineWhenUnflattened = /* @__PURE__ */ new Set([
|
1032
664
|
...staticConfig.inlineWhenUnflattened || []
|
1033
|
-
])
|
1034
|
-
const staticNamespace = getStaticBindingsForScope(
|
665
|
+
]), staticNamespace = getStaticBindingsForScope(
|
1035
666
|
traversePath.scope,
|
1036
667
|
importsWhitelist,
|
1037
668
|
sourcePath,
|
1038
669
|
bindingCache,
|
1039
670
|
shouldPrintDebug
|
1040
|
-
)
|
1041
|
-
const attemptEval = !evaluateVars ? evaluateAstNode : createEvaluator({
|
671
|
+
), attemptEval = evaluateVars ? createEvaluator({
|
1042
672
|
props: propsWithFileInfo,
|
1043
673
|
staticNamespace,
|
1044
674
|
sourcePath,
|
1045
675
|
traversePath,
|
1046
676
|
shouldPrintDebug
|
1047
|
-
});
|
1048
|
-
|
1049
|
-
if (shouldPrintDebug) {
|
1050
|
-
logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`);
|
1051
|
-
}
|
1052
|
-
if (couldntParse) {
|
677
|
+
}) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
|
678
|
+
if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse)
|
1053
679
|
return;
|
1054
|
-
}
|
1055
680
|
tm.mark("jsx-element-flattened", !!shouldPrintDebug);
|
1056
|
-
let attrs = [];
|
1057
|
-
|
1058
|
-
|
1059
|
-
const
|
1060
|
-
let hasSetOptimized = false;
|
1061
|
-
const inlineWhenUnflattenedOGVals = {};
|
1062
|
-
const propMapperStyleState = {
|
681
|
+
let attrs = [], shouldDeopt = !1;
|
682
|
+
const inlined = /* @__PURE__ */ new Map(), variantValues = /* @__PURE__ */ new Map();
|
683
|
+
let hasSetOptimized = !1;
|
684
|
+
const inlineWhenUnflattenedOGVals = {}, propMapperStyleState = {
|
1063
685
|
staticConfig,
|
1064
686
|
usedKeys: {},
|
1065
687
|
classNames: {},
|
@@ -1076,340 +698,215 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
1076
698
|
},
|
1077
699
|
debug: shouldPrintDebug
|
1078
700
|
};
|
1079
|
-
attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
1080
|
-
var _a3;
|
701
|
+
if (attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
1081
702
|
try {
|
1082
|
-
const res2 =
|
1083
|
-
tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug);
|
1084
|
-
if (!res2) {
|
1085
|
-
path.remove();
|
1086
|
-
}
|
1087
|
-
return res2;
|
703
|
+
const res2 = evaluateAttribute(path);
|
704
|
+
return tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug), res2 || path.remove(), res2;
|
1088
705
|
} catch (err) {
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
);
|
1097
|
-
if (shouldPrintDebug === "verbose") {
|
1098
|
-
logger.info(`node ${(_a3 = path.node) == null ? void 0 : _a3.type}`);
|
1099
|
-
}
|
1100
|
-
}
|
1101
|
-
inlined.set(`${Math.random()}`, "spread");
|
1102
|
-
return {
|
706
|
+
return shouldPrintDebug && (logger.info(
|
707
|
+
[
|
708
|
+
"Recoverable error extracting attribute",
|
709
|
+
err.message,
|
710
|
+
shouldPrintDebug === "verbose" ? err.stack : ""
|
711
|
+
].join(" ")
|
712
|
+
), shouldPrintDebug === "verbose" && logger.info(`node ${path.node?.type}`)), inlined.set(`${Math.random()}`, "spread"), {
|
1103
713
|
type: "attr",
|
1104
714
|
value: path.node
|
1105
715
|
};
|
1106
716
|
}
|
1107
|
-
}).flat(4).filter(isPresent)
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
if (shouldPrintDebug) {
|
1115
|
-
logger.info(
|
1116
|
-
[` avoid optimizing:`, { couldntParse, shouldDeopt }].join(" ")
|
1117
|
-
);
|
1118
|
-
}
|
1119
|
-
node.attributes = ogAttributes;
|
717
|
+
}).flat(4).filter(isPresent), shouldPrintDebug && logger.info(
|
718
|
+
[` - attrs (before):
|
719
|
+
`, logLines(attrs.map(attrStr).join(", "))].join(" ")
|
720
|
+
), couldntParse || shouldDeopt) {
|
721
|
+
shouldPrintDebug && logger.info(
|
722
|
+
[" avoid optimizing:", { couldntParse, shouldDeopt }].join(" ")
|
723
|
+
), node.attributes = ogAttributes;
|
1120
724
|
return;
|
1121
725
|
}
|
1122
726
|
const parentFn = findTopmostFunction(traversePath);
|
1123
|
-
|
1124
|
-
modifiedComponents.add(parentFn);
|
1125
|
-
}
|
727
|
+
parentFn && modifiedComponents.add(parentFn);
|
1126
728
|
let ternaries = [];
|
1127
729
|
attrs = attrs.reduce((out, cur) => {
|
1128
730
|
const next = attrs[attrs.indexOf(cur) + 1];
|
1129
|
-
if (cur.type === "ternary") {
|
1130
|
-
ternaries.push(cur.value);
|
1131
|
-
}
|
1132
|
-
if ((!next || next.type !== "ternary") && ternaries.length) {
|
731
|
+
if (cur.type === "ternary" && ternaries.push(cur.value), (!next || next.type !== "ternary") && ternaries.length) {
|
1133
732
|
const normalized = normalizeTernaries(ternaries).map(
|
1134
|
-
({ alternate, consequent, ...rest }) => {
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
};
|
1143
|
-
}
|
733
|
+
({ alternate, consequent, ...rest }) => ({
|
734
|
+
type: "ternary",
|
735
|
+
value: {
|
736
|
+
...rest,
|
737
|
+
alternate: alternate || null,
|
738
|
+
consequent: consequent || null
|
739
|
+
}
|
740
|
+
})
|
1144
741
|
);
|
1145
742
|
try {
|
1146
743
|
return [...out, ...normalized];
|
1147
744
|
} finally {
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
);
|
1152
|
-
}
|
1153
|
-
ternaries = [];
|
745
|
+
shouldPrintDebug && logger.info(
|
746
|
+
` normalizeTernaries (${ternaries.length} => ${normalized.length})`
|
747
|
+
), ternaries = [];
|
1154
748
|
}
|
1155
749
|
}
|
1156
|
-
|
1157
|
-
return out;
|
1158
|
-
}
|
1159
|
-
out.push(cur);
|
1160
|
-
return out;
|
750
|
+
return cur.type === "ternary" || out.push(cur), out;
|
1161
751
|
}, []).flat();
|
1162
752
|
const hasSpread = attrs.some(
|
1163
753
|
(x) => x.type === "attr" && t.isJSXSpreadAttribute(x.value)
|
1164
|
-
);
|
1165
|
-
|
1166
|
-
const themeVal = inlined.get("theme");
|
1167
|
-
if (target !== "native") {
|
1168
|
-
inlined.delete("theme");
|
1169
|
-
}
|
754
|
+
), hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText")), themeVal = inlined.get("theme");
|
755
|
+
target !== "native" && inlined.delete("theme");
|
1170
756
|
for (const [key] of [...inlined]) {
|
1171
|
-
const isStaticObjectVariant =
|
1172
|
-
|
1173
|
-
inlined.delete(key);
|
1174
|
-
}
|
757
|
+
const isStaticObjectVariant = staticConfig.variants?.[key] && variantValues.has(key);
|
758
|
+
(INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
|
1175
759
|
}
|
1176
760
|
const canFlattenProps = inlined.size === 0;
|
1177
|
-
let shouldFlatten =
|
1178
|
-
|
1179
|
-
)
|
1180
|
-
|
1181
|
-
|
1182
|
-
if (disableExtractVariables) {
|
1183
|
-
themeAccessListeners.add((key) => {
|
1184
|
-
shouldFlatten = false;
|
1185
|
-
usedThemeKeys.add(key);
|
1186
|
-
if (shouldPrintDebug === "verbose") {
|
1187
|
-
logger.info([" ! accessing theme key, avoid flatten", key].join(" "));
|
1188
|
-
}
|
1189
|
-
});
|
1190
|
-
}
|
1191
|
-
if (shouldPrintDebug) {
|
761
|
+
let shouldFlatten = !!(flatNode && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren));
|
762
|
+
const shouldWrapTheme = shouldFlatten && themeVal, usedThemeKeys = /* @__PURE__ */ new Set();
|
763
|
+
if (disableExtractVariables && themeAccessListeners.add((key) => {
|
764
|
+
shouldFlatten = !1, usedThemeKeys.add(key), shouldPrintDebug === "verbose" && logger.info([" ! accessing theme key, avoid flatten", key].join(" "));
|
765
|
+
}), shouldPrintDebug)
|
1192
766
|
try {
|
1193
767
|
logger.info([" flatten?", shouldFlatten, objToStr({ hasSpread, shouldDeopt, canFlattenProps, shouldWrapTheme, hasOnlyStringChildren }), "inlined", inlined.size, [...inlined]].join(" "));
|
1194
768
|
} catch {
|
1195
769
|
}
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
logger.info([" - wrapping theme", themeVal].join(" "));
|
1205
|
-
}
|
1206
|
-
attrs = attrs.filter(
|
1207
|
-
(x) => x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme" ? false : true
|
1208
|
-
);
|
1209
|
-
if (!hasImportedTheme) {
|
1210
|
-
hasImportedTheme = true;
|
1211
|
-
programPath.node.body.push(
|
1212
|
-
t.importDeclaration(
|
1213
|
-
[
|
1214
|
-
t.importSpecifier(
|
1215
|
-
t.identifier("_TamaguiTheme"),
|
1216
|
-
t.identifier("Theme")
|
1217
|
-
)
|
1218
|
-
],
|
1219
|
-
t.stringLiteral("@tamagui/core")
|
1220
|
-
)
|
1221
|
-
);
|
1222
|
-
}
|
1223
|
-
traversePath.replaceWith(
|
1224
|
-
t.jsxElement(
|
1225
|
-
t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
|
1226
|
-
t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
|
1227
|
-
]),
|
1228
|
-
t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")),
|
1229
|
-
[traversePath.node]
|
770
|
+
if (shouldFlatten && shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([" - wrapping theme", themeVal].join(" ")), attrs = attrs.filter(
|
771
|
+
(x) => !(x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme")
|
772
|
+
), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(
|
773
|
+
t.importDeclaration(
|
774
|
+
[
|
775
|
+
t.importSpecifier(
|
776
|
+
t.identifier("_TamaguiTheme"),
|
777
|
+
t.identifier("Theme")
|
1230
778
|
)
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
779
|
+
],
|
780
|
+
t.stringLiteral("@tamagui/web")
|
781
|
+
)
|
782
|
+
)), traversePath.replaceWith(
|
783
|
+
t.jsxElement(
|
784
|
+
t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
|
785
|
+
t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
|
786
|
+
]),
|
787
|
+
t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")),
|
788
|
+
[traversePath.node]
|
789
|
+
)
|
790
|
+
)) : console.warn(
|
791
|
+
`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`
|
792
|
+
)), shouldFlatten) {
|
1235
793
|
const defaultStyleAttrs = Object.keys(defaultProps).flatMap((key) => {
|
1236
|
-
if (!isValidStyleKey(key, staticConfig))
|
794
|
+
if (!isValidStyleKey(key, staticConfig))
|
1237
795
|
return [];
|
1238
|
-
|
1239
|
-
const value = defaultProps[key];
|
1240
|
-
const name = (tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[key]) || key;
|
796
|
+
const value = defaultProps[key], name = tamaguiConfig?.shorthands[key] || key;
|
1241
797
|
if (value === void 0) {
|
1242
798
|
logger.warn(
|
1243
799
|
`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`
|
1244
|
-
);
|
1245
|
-
shouldDeopt = true;
|
800
|
+
), shouldDeopt = !0;
|
1246
801
|
return;
|
1247
802
|
}
|
1248
|
-
|
803
|
+
return {
|
1249
804
|
type: "style",
|
1250
805
|
name,
|
1251
806
|
value: { [name]: value }
|
1252
807
|
};
|
1253
|
-
return attr;
|
1254
808
|
});
|
1255
|
-
|
1256
|
-
attrs = [...defaultStyleAttrs, ...attrs];
|
1257
|
-
}
|
809
|
+
defaultStyleAttrs.length && (attrs = [...defaultStyleAttrs, ...attrs]);
|
1258
810
|
}
|
1259
811
|
if (shouldDeopt || !shouldFlatten) {
|
1260
|
-
|
1261
|
-
logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`);
|
1262
|
-
}
|
1263
|
-
node.attributes = ogAttributes;
|
812
|
+
shouldPrintDebug && logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`), node.attributes = ogAttributes;
|
1264
813
|
return;
|
1265
814
|
}
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
}
|
815
|
+
shouldPrintDebug && logger.info(
|
816
|
+
[` - attrs (flattened):
|
817
|
+
`, logLines(attrs.map(attrStr).join(", "))].join(
|
818
|
+
" "
|
819
|
+
)
|
820
|
+
);
|
1273
821
|
let foundStaticProps = {};
|
1274
822
|
for (const key in attrs) {
|
1275
823
|
const cur = attrs[key];
|
1276
824
|
if (cur.type === "style") {
|
1277
|
-
const expanded =
|
825
|
+
const expanded = expandStylesAndRemoveNullishValuesWithoutVariants(
|
1278
826
|
cur.value
|
1279
827
|
);
|
1280
|
-
for (const key2 in expanded)
|
1281
|
-
|
1282
|
-
}
|
828
|
+
for (const key2 in expanded)
|
829
|
+
mergeToEnd(foundStaticProps, key2, expanded[key2]);
|
1283
830
|
continue;
|
1284
831
|
}
|
1285
832
|
if (cur.type === "attr") {
|
1286
|
-
if (t.isJSXSpreadAttribute(cur.value))
|
1287
|
-
continue;
|
1288
|
-
}
|
1289
|
-
if (!t.isJSXIdentifier(cur.value.name)) {
|
833
|
+
if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name))
|
1290
834
|
continue;
|
1291
|
-
|
1292
|
-
|
1293
|
-
const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
|
1294
|
-
if (value !== FAILED_EVAL) {
|
1295
|
-
mergeToEnd2(foundStaticProps, key2, value);
|
1296
|
-
}
|
835
|
+
const key2 = cur.value.name.name, value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
|
836
|
+
value !== FAILED_EVAL && mergeToEnd(foundStaticProps, key2, value);
|
1297
837
|
}
|
1298
838
|
}
|
1299
839
|
const completeProps = {};
|
1300
|
-
for (const key in defaultProps)
|
1301
|
-
|
1302
|
-
|
1303
|
-
}
|
1304
|
-
}
|
1305
|
-
for (const key in foundStaticProps) {
|
840
|
+
for (const key in defaultProps)
|
841
|
+
key in foundStaticProps || (completeProps[key] = defaultProps[key]);
|
842
|
+
for (const key in foundStaticProps)
|
1306
843
|
completeProps[key] = foundStaticProps[key];
|
1307
|
-
}
|
1308
844
|
attrs = attrs.reduce((acc, cur) => {
|
1309
845
|
if (!cur)
|
1310
846
|
return acc;
|
1311
|
-
if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value)) {
|
1312
|
-
|
1313
|
-
|
1314
|
-
if (
|
1315
|
-
|
1316
|
-
|
847
|
+
if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value) && shouldFlatten) {
|
848
|
+
const name = cur.value.name.name;
|
849
|
+
if (typeof name == "string") {
|
850
|
+
if (name === "tag")
|
851
|
+
return acc;
|
852
|
+
if (variants[name] && variantValues.has(name)) {
|
853
|
+
const styleState = {
|
854
|
+
...propMapperStyleState,
|
855
|
+
props: completeProps,
|
856
|
+
curProps: completeProps
|
857
|
+
};
|
858
|
+
let out = Object.fromEntries(
|
859
|
+
propMapper(name, variantValues.get(name), styleState) || []
|
860
|
+
);
|
861
|
+
if (out && isTargetingHTML) {
|
862
|
+
const cn = out.className;
|
863
|
+
out = createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
|
1317
864
|
}
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
)
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
}
|
1335
|
-
for (const key2 in out) {
|
1336
|
-
const value2 = out[key2];
|
1337
|
-
if (isValidStyleKey(key2, staticConfig)) {
|
1338
|
-
acc.push({
|
1339
|
-
type: "style",
|
1340
|
-
value: { [key2]: value2 },
|
1341
|
-
name: key2,
|
1342
|
-
attr: cur.value
|
1343
|
-
});
|
1344
|
-
} else {
|
1345
|
-
acc.push({
|
1346
|
-
type: "attr",
|
1347
|
-
value: t.jsxAttribute(
|
1348
|
-
t.jsxIdentifier(key2),
|
1349
|
-
t.jsxExpressionContainer(
|
1350
|
-
typeof value2 === "string" ? t.stringLiteral(value2) : literalToAst(value2)
|
1351
|
-
)
|
1352
|
-
)
|
1353
|
-
});
|
1354
|
-
}
|
1355
|
-
}
|
865
|
+
shouldPrintDebug && logger.info([" - expanded variant", name, out].join(" "));
|
866
|
+
for (const key2 in out) {
|
867
|
+
const value2 = out[key2];
|
868
|
+
isValidStyleKey(key2, staticConfig) ? acc.push({
|
869
|
+
type: "style",
|
870
|
+
value: { [key2]: value2 },
|
871
|
+
name: key2,
|
872
|
+
attr: cur.value
|
873
|
+
}) : acc.push({
|
874
|
+
type: "attr",
|
875
|
+
value: t.jsxAttribute(
|
876
|
+
t.jsxIdentifier(key2),
|
877
|
+
t.jsxExpressionContainer(
|
878
|
+
typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)
|
879
|
+
)
|
880
|
+
)
|
881
|
+
});
|
1356
882
|
}
|
1357
883
|
}
|
1358
884
|
}
|
1359
885
|
}
|
1360
|
-
if (cur.type !== "style")
|
1361
|
-
acc.push(cur);
|
1362
|
-
return acc;
|
1363
|
-
}
|
886
|
+
if (cur.type !== "style")
|
887
|
+
return acc.push(cur), acc;
|
1364
888
|
let key = Object.keys(cur.value)[0];
|
1365
|
-
const value = cur.value[key];
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
if (disableExtractVariables) {
|
1372
|
-
if (value[0] === "$" && (usedThemeKeys.has(key) || usedThemeKeys.has(fullKey))) {
|
1373
|
-
if (shouldPrintDebug) {
|
1374
|
-
logger.info([` keeping variable inline: ${key} =`, value].join(" "));
|
1375
|
-
}
|
1376
|
-
acc.push({
|
1377
|
-
type: "attr",
|
1378
|
-
value: t.jsxAttribute(
|
1379
|
-
t.jsxIdentifier(key),
|
1380
|
-
t.jsxExpressionContainer(t.stringLiteral(value))
|
1381
|
-
)
|
1382
|
-
});
|
1383
|
-
return acc;
|
1384
|
-
}
|
1385
|
-
}
|
1386
|
-
acc.push(cur);
|
1387
|
-
return acc;
|
1388
|
-
}, []);
|
1389
|
-
tm.mark("jsx-element-expanded", !!shouldPrintDebug);
|
1390
|
-
if (shouldPrintDebug) {
|
1391
|
-
logger.info(
|
1392
|
-
[" - attrs (expanded): \n", logLines(attrs.map(attrStr).join(", "))].join(
|
1393
|
-
" "
|
889
|
+
const value = cur.value[key], fullKey = tamaguiConfig?.shorthands[key];
|
890
|
+
return fullKey && (cur.value = { [fullKey]: value }, key = fullKey), disableExtractVariables && value[0] === "$" && (usedThemeKeys.has(key) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([` keeping variable inline: ${key} =`, value].join(" ")), acc.push({
|
891
|
+
type: "attr",
|
892
|
+
value: t.jsxAttribute(
|
893
|
+
t.jsxIdentifier(key),
|
894
|
+
t.jsxExpressionContainer(t.stringLiteral(value))
|
1394
895
|
)
|
1395
|
-
);
|
1396
|
-
}
|
896
|
+
}), acc) : (acc.push(cur), acc);
|
897
|
+
}, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info(
|
898
|
+
[` - attrs (expanded):
|
899
|
+
`, logLines(attrs.map(attrStr).join(", "))].join(
|
900
|
+
" "
|
901
|
+
)
|
902
|
+
);
|
1397
903
|
let prev = null;
|
1398
|
-
const getProps = (props, includeProps =
|
1399
|
-
if (!props)
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
if (excludeProps == null ? void 0 : excludeProps.size) {
|
1405
|
-
for (const key in props) {
|
1406
|
-
if (excludeProps.has(key)) {
|
1407
|
-
if (shouldPrintDebug)
|
1408
|
-
logger.info([" delete excluded", key].join(" "));
|
1409
|
-
delete props[key];
|
1410
|
-
}
|
1411
|
-
}
|
1412
|
-
}
|
904
|
+
const getProps = (props, includeProps = !1, debugName = "") => {
|
905
|
+
if (!props)
|
906
|
+
return shouldPrintDebug && logger.info([" getProps() no props"].join(" ")), {};
|
907
|
+
if (excludeProps?.size)
|
908
|
+
for (const key in props)
|
909
|
+
excludeProps.has(key) && (shouldPrintDebug && logger.info([" delete excluded", key].join(" ")), delete props[key]);
|
1413
910
|
try {
|
1414
911
|
const out = getSplitStyles(
|
1415
912
|
props,
|
@@ -1419,226 +916,124 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
1419
916
|
componentState,
|
1420
917
|
{
|
1421
918
|
...styleProps,
|
919
|
+
noClassNames: !0,
|
1422
920
|
fallbackProps: completeProps
|
1423
921
|
},
|
1424
922
|
void 0,
|
1425
923
|
void 0,
|
1426
924
|
void 0,
|
1427
925
|
debugPropValue || shouldPrintDebug
|
1428
|
-
)
|
1429
|
-
const outProps = {
|
926
|
+
), outProps = {
|
1430
927
|
...includeProps ? out.viewProps : {},
|
1431
928
|
...out.style,
|
1432
929
|
...out.pseudos
|
1433
930
|
};
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
logger.info(`
|
1439
|
-
getProps (outProps): ${logLines(objToStr(outProps))}`);
|
1440
|
-
}
|
1441
|
-
if (out.fontFamily) {
|
1442
|
-
setPropsToFontFamily(outProps, out.fontFamily);
|
1443
|
-
if (shouldPrintDebug) {
|
1444
|
-
logger.info(`
|
1445
|
-
\u{1F4AC} new font fam: ${out.fontFamily}`);
|
1446
|
-
}
|
1447
|
-
}
|
1448
|
-
return outProps;
|
931
|
+
return shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
|
932
|
+
getProps (props in): ${logLines(objToStr(props))}`), logger.info(`
|
933
|
+
getProps (outProps): ${logLines(objToStr(outProps))}`)), out.fontFamily && (setPropsToFontFamily(outProps, out.fontFamily), shouldPrintDebug && logger.info(`
|
934
|
+
\u{1F4AC} new font fam: ${out.fontFamily}`)), outProps;
|
1449
935
|
} catch (err) {
|
1450
|
-
logger.info(["error", err.message, err.stack].join(" "));
|
1451
|
-
return {};
|
936
|
+
return logger.info(["error", err.message, err.stack].join(" ")), {};
|
1452
937
|
}
|
1453
938
|
};
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
});
|
1459
|
-
}
|
1460
|
-
attrs = attrs.reduce((acc, cur) => {
|
939
|
+
shouldFlatten && attrs.unshift({
|
940
|
+
type: "style",
|
941
|
+
value: defaultProps
|
942
|
+
}), attrs = attrs.reduce((acc, cur) => {
|
1461
943
|
if (cur.type === "style") {
|
1462
|
-
const key = Object.keys(cur.value)[0];
|
1463
|
-
|
1464
|
-
const shouldKeepOriginalAttr = (
|
944
|
+
const key = Object.keys(cur.value)[0], value = cur.value[key];
|
945
|
+
if (
|
1465
946
|
// !isStyleAndAttr[key] &&
|
1466
947
|
!shouldFlatten && // de-opt if non-style
|
1467
948
|
!validStyles[key] && !pseudoDescriptors[key] && !(key.startsWith("data-") || key.startsWith("aria-"))
|
1468
|
-
)
|
1469
|
-
|
1470
|
-
if (shouldPrintDebug) {
|
1471
|
-
logger.info([" - keeping as non-style", key].join(" "));
|
1472
|
-
}
|
1473
|
-
prev = cur;
|
1474
|
-
acc.push({
|
949
|
+
)
|
950
|
+
return shouldPrintDebug && logger.info([" - keeping as non-style", key].join(" ")), prev = cur, acc.push({
|
1475
951
|
type: "attr",
|
1476
952
|
value: t.jsxAttribute(
|
1477
953
|
t.jsxIdentifier(key),
|
1478
954
|
t.jsxExpressionContainer(
|
1479
|
-
typeof value
|
955
|
+
typeof value == "string" ? t.stringLiteral(value) : literalToAst(value)
|
1480
956
|
)
|
1481
957
|
)
|
1482
|
-
});
|
1483
|
-
|
1484
|
-
return acc;
|
1485
|
-
}
|
1486
|
-
if ((prev == null ? void 0 : prev.type) === "style") {
|
1487
|
-
mergeStyles2(prev.value, cur.value);
|
1488
|
-
return acc;
|
1489
|
-
}
|
958
|
+
}), acc.push(cur), acc;
|
959
|
+
if (prev?.type === "style")
|
960
|
+
return mergeStyles(prev.value, cur.value), acc;
|
1490
961
|
}
|
1491
|
-
prev = cur;
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
logLines(attrs.map(attrStr).join(", "))
|
1500
|
-
].join(" ")
|
1501
|
-
);
|
1502
|
-
}
|
962
|
+
return prev = cur, acc.push(cur), acc;
|
963
|
+
}, []), shouldPrintDebug && logger.info(
|
964
|
+
[
|
965
|
+
` - attrs (combined \u{1F500}):
|
966
|
+
`,
|
967
|
+
logLines(attrs.map(attrStr).join(", "))
|
968
|
+
].join(" ")
|
969
|
+
);
|
1503
970
|
let getStyleError = null;
|
1504
|
-
for (const attr of attrs)
|
971
|
+
for (const attr of attrs)
|
1505
972
|
try {
|
1506
|
-
|
1507
|
-
console.log(` Processing ${attr.type}:`);
|
1508
|
-
}
|
1509
|
-
switch (attr.type) {
|
973
|
+
switch (shouldPrintDebug && console.log(` Processing ${attr.type}:`), attr.type) {
|
1510
974
|
case "ternary": {
|
1511
|
-
const a = getProps(attr.value.alternate,
|
1512
|
-
|
1513
|
-
if (a)
|
1514
|
-
attr.value.alternate = a;
|
1515
|
-
if (c)
|
1516
|
-
attr.value.consequent = c;
|
1517
|
-
if (shouldPrintDebug)
|
1518
|
-
logger.info([" => tern ", attrStr(attr)].join(" "));
|
975
|
+
const a = getProps(attr.value.alternate, !1, "ternary.alternate"), c = getProps(attr.value.consequent, !1, "ternary.consequent");
|
976
|
+
a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", attrStr(attr)].join(" "));
|
1519
977
|
continue;
|
1520
978
|
}
|
1521
979
|
case "style": {
|
1522
|
-
const styles = getProps(attr.value,
|
1523
|
-
|
1524
|
-
attr.value = styles;
|
1525
|
-
}
|
1526
|
-
if (shouldPrintDebug)
|
1527
|
-
logger.info([" * styles (in)", logLines(objToStr(attr.value))].join(" "));
|
1528
|
-
if (shouldPrintDebug)
|
1529
|
-
logger.info([" * styles (out)", logLines(objToStr(styles))].join(" "));
|
980
|
+
const styles = getProps(attr.value, !1, "style");
|
981
|
+
styles && (attr.value = styles), shouldPrintDebug && logger.info([" * styles (in)", logLines(objToStr(attr.value))].join(" ")), shouldPrintDebug && logger.info([" * styles (out)", logLines(objToStr(styles))].join(" "));
|
1530
982
|
continue;
|
1531
983
|
}
|
1532
|
-
case "attr":
|
984
|
+
case "attr":
|
1533
985
|
if (shouldFlatten && t.isJSXAttribute(attr.value)) {
|
1534
986
|
const key = attr.value.name.name;
|
1535
|
-
if (key === "style" || key === "className" || key === "tag")
|
987
|
+
if (key === "style" || key === "className" || key === "tag")
|
1536
988
|
continue;
|
1537
|
-
}
|
1538
989
|
const value = attemptEvalSafe(
|
1539
|
-
attr.value.value || t.booleanLiteral(
|
990
|
+
attr.value.value || t.booleanLiteral(!0)
|
1540
991
|
);
|
1541
992
|
if (value !== FAILED_EVAL) {
|
1542
|
-
const outProps = getProps({ [key]: value },
|
1543
|
-
const outKey = Object.keys(outProps)[0];
|
993
|
+
const outProps = getProps({ [key]: value }, !0, `attr.${key}`), outKey = Object.keys(outProps)[0];
|
1544
994
|
if (outKey) {
|
1545
995
|
const outVal = outProps[outKey];
|
1546
996
|
attr.value = t.jsxAttribute(
|
1547
997
|
t.jsxIdentifier(outKey),
|
1548
998
|
t.jsxExpressionContainer(
|
1549
|
-
typeof outVal
|
999
|
+
typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)
|
1550
1000
|
)
|
1551
1001
|
);
|
1552
1002
|
}
|
1553
1003
|
}
|
1554
1004
|
}
|
1555
|
-
}
|
1556
1005
|
}
|
1557
1006
|
} catch (err) {
|
1558
1007
|
getStyleError = err;
|
1559
1008
|
}
|
1560
|
-
|
1561
|
-
|
1562
|
-
logger.info(["
|
1563
|
-
}
|
1564
|
-
tm.mark("jsx-element-styles", !!shouldPrintDebug);
|
1565
|
-
if (getStyleError) {
|
1566
|
-
logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" "));
|
1567
|
-
node.attributes = ogAttributes;
|
1568
|
-
return null;
|
1569
|
-
}
|
1009
|
+
if (shouldPrintDebug && logger.info([` - attrs (ternaries/combined):
|
1010
|
+
`, logLines(attrs.map(attrStr).join(", "))].join(" ")), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError)
|
1011
|
+
return logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" ")), node.attributes = ogAttributes, null;
|
1570
1012
|
const existingStyleKeys = /* @__PURE__ */ new Set();
|
1571
1013
|
for (let i = attrs.length - 1; i >= 0; i--) {
|
1572
1014
|
const attr = attrs[i];
|
1573
|
-
if (shouldFlatten) {
|
1574
|
-
|
1575
|
-
|
1576
|
-
if (t.isJSXIdentifier(attr.value.name)) {
|
1577
|
-
const name = attr.value.name.name;
|
1578
|
-
if (INLINE_EXTRACTABLE[name]) {
|
1579
|
-
attr.value.name.name = INLINE_EXTRACTABLE[name];
|
1580
|
-
}
|
1581
|
-
}
|
1582
|
-
}
|
1583
|
-
}
|
1584
|
-
}
|
1585
|
-
if (attr.type === "style") {
|
1586
|
-
for (const key in attr.value) {
|
1587
|
-
if (existingStyleKeys.has(key)) {
|
1588
|
-
if (shouldPrintDebug) {
|
1589
|
-
logger.info([` >> delete existing ${key}`].join(" "));
|
1590
|
-
}
|
1591
|
-
delete attr.value[key];
|
1592
|
-
} else {
|
1593
|
-
existingStyleKeys.add(key);
|
1594
|
-
}
|
1595
|
-
}
|
1015
|
+
if (shouldFlatten && attr.type === "attr" && t.isJSXAttribute(attr.value) && t.isJSXIdentifier(attr.value.name)) {
|
1016
|
+
const name = attr.value.name.name;
|
1017
|
+
INLINE_EXTRACTABLE[name] && (attr.value.name.name = INLINE_EXTRACTABLE[name]);
|
1596
1018
|
}
|
1019
|
+
if (attr.type === "style")
|
1020
|
+
for (const key in attr.value)
|
1021
|
+
existingStyleKeys.has(key) ? (shouldPrintDebug && logger.info([` >> delete existing ${key}`].join(" ")), delete attr.value[key]) : existingStyleKeys.add(key);
|
1597
1022
|
}
|
1598
|
-
if (!shouldFlatten) {
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
if (val) {
|
1607
|
-
delete attr.value[key];
|
1608
|
-
attrs.splice(index - 1, 0, val.attr);
|
1609
|
-
} else {
|
1610
|
-
delete attr.value[key];
|
1611
|
-
}
|
1612
|
-
}
|
1023
|
+
if (!shouldFlatten && inlineWhenUnflattened.size) {
|
1024
|
+
for (const [index, attr] of attrs.entries())
|
1025
|
+
if (attr.type === "style")
|
1026
|
+
for (const key in attr.value) {
|
1027
|
+
if (!inlineWhenUnflattened.has(key))
|
1028
|
+
continue;
|
1029
|
+
const val = inlineWhenUnflattenedOGVals[key];
|
1030
|
+
val ? (delete attr.value[key], attrs.splice(index - 1, 0, val.attr)) : delete attr.value[key];
|
1613
1031
|
}
|
1614
|
-
}
|
1615
|
-
}
|
1616
|
-
}
|
1617
|
-
if (shouldFlatten) {
|
1618
|
-
if (shouldPrintDebug) {
|
1619
|
-
logger.info([" [\u2705] flattening", originalNodeName, flatNode].join(" "));
|
1620
|
-
}
|
1621
|
-
node.name.name = flatNode;
|
1622
|
-
res.flattened++;
|
1623
|
-
if (closingElement) {
|
1624
|
-
closingElement.name.name = flatNode;
|
1625
|
-
}
|
1626
|
-
}
|
1627
|
-
const isNativeNotFlat = !shouldFlatten && target === "native";
|
1628
|
-
if (isNativeNotFlat) {
|
1629
|
-
if (shouldPrintDebug) {
|
1630
|
-
logger.info(`Disabled flattening except for simple cases on native for now`);
|
1631
|
-
}
|
1632
|
-
node.attributes = ogAttributes;
|
1633
|
-
return null;
|
1634
|
-
}
|
1635
|
-
if (shouldPrintDebug) {
|
1636
|
-
logger.info([` - inlined props (${inlined.size}):`, shouldDeopt ? " deopted" : "", hasSpread ? " has spread" : "", staticConfig.neverFlatten ? "neverFlatten" : ""].join(" "));
|
1637
|
-
logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`);
|
1638
|
-
logger.info(` - attrs (end):
|
1639
|
-
${logLines(attrs.map(attrStr).join(", "))}`);
|
1640
1032
|
}
|
1641
|
-
|
1033
|
+
if (shouldFlatten && (shouldPrintDebug && logger.info([" [\u2705] flattening", originalNodeName, flatNode].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode)), !shouldFlatten && target === "native")
|
1034
|
+
return shouldPrintDebug && logger.info("Disabled flattening except for simple cases on native for now"), node.attributes = ogAttributes, null;
|
1035
|
+
shouldPrintDebug && (logger.info([` - inlined props (${inlined.size}):`, shouldDeopt ? " deopted" : "", hasSpread ? " has spread" : "", staticConfig.neverFlatten ? "neverFlatten" : ""].join(" ")), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
|
1036
|
+
${logLines(attrs.map(attrStr).join(", "))}`)), onExtractTag({
|
1642
1037
|
parserProps: propsWithFileInfo,
|
1643
1038
|
attrs,
|
1644
1039
|
node,
|
@@ -1654,27 +1049,18 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
1654
1049
|
staticConfig
|
1655
1050
|
});
|
1656
1051
|
} catch (err) {
|
1657
|
-
node.attributes = ogAttributes;
|
1658
|
-
console.error(`@tamagui/static Error: ${err.message} ${err.stack}`);
|
1052
|
+
node.attributes = ogAttributes, console.error(`@tamagui/static Error: ${err.message} ${err.stack}`);
|
1659
1053
|
} finally {
|
1660
|
-
|
1661
|
-
shouldPrintDebug = ogDebug;
|
1662
|
-
}
|
1054
|
+
debugPropValue && (shouldPrintDebug = ogDebug);
|
1663
1055
|
}
|
1664
1056
|
}
|
1665
|
-
})
|
1666
|
-
tm.mark("jsx-done", !!shouldPrintDebug);
|
1667
|
-
if (modifiedComponents.size) {
|
1057
|
+
}), tm.mark("jsx-done", !!shouldPrintDebug), modifiedComponents.size) {
|
1668
1058
|
const all = Array.from(modifiedComponents);
|
1669
|
-
|
1670
|
-
|
1671
|
-
}
|
1672
|
-
for (const comp of all) {
|
1059
|
+
shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
|
1060
|
+
for (const comp of all)
|
1673
1061
|
removeUnusedHooks(comp, shouldPrintDebug);
|
1674
|
-
}
|
1675
1062
|
}
|
1676
|
-
tm.done(shouldPrintDebug === "verbose");
|
1677
|
-
return res;
|
1063
|
+
return tm.done(shouldPrintDebug === "verbose"), res;
|
1678
1064
|
}
|
1679
1065
|
}
|
1680
1066
|
export {
|