@tamagui/static 1.111.7 → 1.111.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/cjs/extractor/loadTamagui.js.map +1 -1
  2. package/dist/cjs/extractor/loadTamagui.native.js.map +2 -2
  3. package/dist/esm/checkDeps.native.js +3 -6
  4. package/dist/esm/checkDeps.native.js.map +1 -6
  5. package/dist/esm/constants.native.js +11 -12
  6. package/dist/esm/constants.native.js.map +1 -6
  7. package/dist/esm/exports.native.js +16 -19
  8. package/dist/esm/exports.native.js.map +1 -6
  9. package/dist/esm/extractor/accessSafe.native.js +9 -16
  10. package/dist/esm/extractor/accessSafe.native.js.map +1 -6
  11. package/dist/esm/extractor/babelParse.native.js +8 -22
  12. package/dist/esm/extractor/babelParse.native.js.map +1 -6
  13. package/dist/esm/extractor/buildClassName.native.js +26 -34
  14. package/dist/esm/extractor/buildClassName.native.js.map +1 -6
  15. package/dist/esm/extractor/bundle.native.js +74 -82
  16. package/dist/esm/extractor/bundle.native.js.map +1 -6
  17. package/dist/esm/extractor/bundleConfig.native.js +110 -123
  18. package/dist/esm/extractor/bundleConfig.native.js.map +1 -6
  19. package/dist/esm/extractor/createEvaluator.native.js +22 -17
  20. package/dist/esm/extractor/createEvaluator.native.js.map +1 -6
  21. package/dist/esm/extractor/createExtractor.native.js +678 -819
  22. package/dist/esm/extractor/createExtractor.native.js.map +1 -6
  23. package/dist/esm/extractor/createLogger.native.js +18 -8
  24. package/dist/esm/extractor/createLogger.native.js.map +1 -6
  25. package/dist/esm/extractor/ensureImportingConcat.native.js +12 -13
  26. package/dist/esm/extractor/ensureImportingConcat.native.js.map +1 -6
  27. package/dist/esm/extractor/esbuildAliasPlugin.native.js +7 -9
  28. package/dist/esm/extractor/esbuildAliasPlugin.native.js.map +1 -6
  29. package/dist/esm/extractor/evaluateAstNode.native.js +23 -43
  30. package/dist/esm/extractor/evaluateAstNode.native.js.map +1 -6
  31. package/dist/esm/extractor/extractHelpers.native.js +73 -96
  32. package/dist/esm/extractor/extractHelpers.native.js.map +1 -6
  33. package/dist/esm/extractor/extractMediaStyle.native.js +75 -61
  34. package/dist/esm/extractor/extractMediaStyle.native.js.map +1 -6
  35. package/dist/esm/extractor/extractToClassNames.native.js +260 -236
  36. package/dist/esm/extractor/extractToClassNames.native.js.map +1 -6
  37. package/dist/esm/extractor/extractToNative.native.js +129 -133
  38. package/dist/esm/extractor/extractToNative.native.js.map +1 -6
  39. package/dist/esm/extractor/findTopmostFunction.native.js +6 -11
  40. package/dist/esm/extractor/findTopmostFunction.native.js.map +1 -6
  41. package/dist/esm/extractor/generateTamaguiStudioConfig.native.js +64 -49
  42. package/dist/esm/extractor/generateTamaguiStudioConfig.native.js.map +1 -6
  43. package/dist/esm/extractor/generatedUid.native.js +5 -8
  44. package/dist/esm/extractor/generatedUid.native.js.map +1 -6
  45. package/dist/esm/extractor/getPrefixLogs.native.js +2 -4
  46. package/dist/esm/extractor/getPrefixLogs.native.js.map +1 -6
  47. package/dist/esm/extractor/getPropValueFromAttributes.native.js +18 -24
  48. package/dist/esm/extractor/getPropValueFromAttributes.native.js.map +1 -6
  49. package/dist/esm/extractor/getSourceModule.native.js +22 -27
  50. package/dist/esm/extractor/getSourceModule.native.js.map +1 -6
  51. package/dist/esm/extractor/getStaticBindingsForScope.native.js +92 -90
  52. package/dist/esm/extractor/getStaticBindingsForScope.native.js.map +1 -6
  53. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js +2 -4
  54. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +1 -6
  55. package/dist/esm/extractor/hoistClassNames.native.js +13 -20
  56. package/dist/esm/extractor/hoistClassNames.native.js.map +1 -6
  57. package/dist/esm/extractor/literalToAst.native.js +23 -44
  58. package/dist/esm/extractor/literalToAst.native.js.map +1 -6
  59. package/dist/esm/extractor/loadFile.native.js +7 -7
  60. package/dist/esm/extractor/loadFile.native.js.map +1 -6
  61. package/dist/esm/extractor/loadTamagui.js.map +1 -1
  62. package/dist/esm/extractor/loadTamagui.mjs.map +1 -1
  63. package/dist/esm/extractor/loadTamagui.native.js +115 -107
  64. package/dist/esm/extractor/loadTamagui.native.js.map +1 -6
  65. package/dist/esm/extractor/logLines.native.js +26 -27
  66. package/dist/esm/extractor/logLines.native.js.map +1 -6
  67. package/dist/esm/extractor/normalizeTernaries.native.js +17 -10
  68. package/dist/esm/extractor/normalizeTernaries.native.js.map +1 -6
  69. package/dist/esm/extractor/propsToFontFamilyCache.native.js +4 -9
  70. package/dist/esm/extractor/propsToFontFamilyCache.native.js.map +1 -6
  71. package/dist/esm/extractor/removeUnusedHooks.native.js +56 -56
  72. package/dist/esm/extractor/removeUnusedHooks.native.js.map +1 -6
  73. package/dist/esm/extractor/timer.native.js +7 -8
  74. package/dist/esm/extractor/timer.native.js.map +1 -6
  75. package/dist/esm/extractor/validHTMLAttributes.native.js +2 -4
  76. package/dist/esm/extractor/validHTMLAttributes.native.js.map +1 -6
  77. package/dist/esm/extractor/watchTamaguiConfig.native.js +19 -22
  78. package/dist/esm/extractor/watchTamaguiConfig.native.js.map +1 -6
  79. package/dist/esm/getPragmaOptions.native.js +18 -8
  80. package/dist/esm/getPragmaOptions.native.js.map +1 -6
  81. package/dist/esm/helpers/memoize.native.js +8 -12
  82. package/dist/esm/helpers/memoize.native.js.map +1 -6
  83. package/dist/esm/helpers/requireTamaguiCore.native.js +8 -8
  84. package/dist/esm/helpers/requireTamaguiCore.native.js.map +1 -6
  85. package/dist/esm/index.native.js +4 -6
  86. package/dist/esm/index.native.js.map +1 -6
  87. package/dist/esm/minifyCSS.native.js +6 -5
  88. package/dist/esm/minifyCSS.native.js.map +1 -6
  89. package/dist/esm/registerRequire.native.js +56 -62
  90. package/dist/esm/registerRequire.native.js.map +1 -6
  91. package/dist/esm/server.native.js +19 -16
  92. package/dist/esm/server.native.js.map +1 -6
  93. package/dist/esm/setup.native.js +2 -1
  94. package/dist/esm/setup.native.js.map +1 -6
  95. package/dist/esm/types.native.js +2 -1
  96. package/dist/esm/types.native.js.map +1 -6
  97. package/package.json +15 -15
  98. package/src/extractor/loadTamagui.ts +2 -0
  99. package/types/extractor/loadTamagui.d.ts.map +1 -1
  100. package/dist/esm/checkDeps.native.mjs +0 -10
  101. package/dist/esm/checkDeps.native.mjs.map +0 -1
  102. package/dist/esm/constants.native.mjs +0 -12
  103. package/dist/esm/constants.native.mjs.map +0 -1
  104. package/dist/esm/exports.native.mjs +0 -16
  105. package/dist/esm/exports.native.mjs.map +0 -1
  106. package/dist/esm/extractor/accessSafe.native.mjs +0 -12
  107. package/dist/esm/extractor/accessSafe.native.mjs.map +0 -1
  108. package/dist/esm/extractor/babelParse.native.mjs +0 -19
  109. package/dist/esm/extractor/babelParse.native.mjs.map +0 -1
  110. package/dist/esm/extractor/buildClassName.native.mjs +0 -30
  111. package/dist/esm/extractor/buildClassName.native.mjs.map +0 -1
  112. package/dist/esm/extractor/bundle.native.mjs +0 -132
  113. package/dist/esm/extractor/bundle.native.mjs.map +0 -1
  114. package/dist/esm/extractor/bundleConfig.native.mjs +0 -322
  115. package/dist/esm/extractor/bundleConfig.native.mjs.map +0 -1
  116. package/dist/esm/extractor/createEvaluator.native.mjs +0 -38
  117. package/dist/esm/extractor/createEvaluator.native.mjs.map +0 -1
  118. package/dist/esm/extractor/createExtractor.native.mjs +0 -1140
  119. package/dist/esm/extractor/createExtractor.native.mjs.map +0 -1
  120. package/dist/esm/extractor/createLogger.native.mjs +0 -25
  121. package/dist/esm/extractor/createLogger.native.mjs.map +0 -1
  122. package/dist/esm/extractor/ensureImportingConcat.native.mjs +0 -20
  123. package/dist/esm/extractor/ensureImportingConcat.native.mjs.map +0 -1
  124. package/dist/esm/extractor/esbuildAliasPlugin.native.mjs +0 -29
  125. package/dist/esm/extractor/esbuildAliasPlugin.native.mjs.map +0 -1
  126. package/dist/esm/extractor/evaluateAstNode.native.mjs +0 -49
  127. package/dist/esm/extractor/evaluateAstNode.native.mjs.map +0 -1
  128. package/dist/esm/extractor/extractHelpers.native.mjs +0 -122
  129. package/dist/esm/extractor/extractHelpers.native.mjs.map +0 -1
  130. package/dist/esm/extractor/extractMediaStyle.native.mjs +0 -125
  131. package/dist/esm/extractor/extractMediaStyle.native.mjs.map +0 -1
  132. package/dist/esm/extractor/extractToClassNames.native.mjs +0 -315
  133. package/dist/esm/extractor/extractToClassNames.native.mjs.map +0 -1
  134. package/dist/esm/extractor/extractToNative.native.mjs +0 -268
  135. package/dist/esm/extractor/extractToNative.native.mjs.map +0 -1
  136. package/dist/esm/extractor/findTopmostFunction.native.mjs +0 -11
  137. package/dist/esm/extractor/findTopmostFunction.native.mjs.map +0 -1
  138. package/dist/esm/extractor/generateTamaguiStudioConfig.native.mjs +0 -139
  139. package/dist/esm/extractor/generateTamaguiStudioConfig.native.mjs.map +0 -1
  140. package/dist/esm/extractor/generatedUid.native.mjs +0 -13
  141. package/dist/esm/extractor/generatedUid.native.mjs.map +0 -1
  142. package/dist/esm/extractor/getPrefixLogs.native.mjs +0 -6
  143. package/dist/esm/extractor/getPrefixLogs.native.mjs.map +0 -1
  144. package/dist/esm/extractor/getPropValueFromAttributes.native.mjs +0 -35
  145. package/dist/esm/extractor/getPropValueFromAttributes.native.mjs.map +0 -1
  146. package/dist/esm/extractor/getSourceModule.native.mjs +0 -50
  147. package/dist/esm/extractor/getSourceModule.native.mjs.map +0 -1
  148. package/dist/esm/extractor/getStaticBindingsForScope.native.mjs +0 -159
  149. package/dist/esm/extractor/getStaticBindingsForScope.native.mjs.map +0 -1
  150. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.mjs +0 -6
  151. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.mjs.map +0 -1
  152. package/dist/esm/extractor/hoistClassNames.native.mjs +0 -30
  153. package/dist/esm/extractor/hoistClassNames.native.mjs.map +0 -1
  154. package/dist/esm/extractor/literalToAst.native.mjs +0 -55
  155. package/dist/esm/extractor/literalToAst.native.mjs.map +0 -1
  156. package/dist/esm/extractor/loadFile.native.mjs +0 -20
  157. package/dist/esm/extractor/loadFile.native.mjs.map +0 -1
  158. package/dist/esm/extractor/loadTamagui.native.mjs +0 -284
  159. package/dist/esm/extractor/loadTamagui.native.mjs.map +0 -1
  160. package/dist/esm/extractor/logLines.native.mjs +0 -31
  161. package/dist/esm/extractor/logLines.native.mjs.map +0 -1
  162. package/dist/esm/extractor/normalizeTernaries.native.mjs +0 -38
  163. package/dist/esm/extractor/normalizeTernaries.native.mjs.map +0 -1
  164. package/dist/esm/extractor/propsToFontFamilyCache.native.mjs +0 -13
  165. package/dist/esm/extractor/propsToFontFamilyCache.native.mjs.map +0 -1
  166. package/dist/esm/extractor/removeUnusedHooks.native.mjs +0 -83
  167. package/dist/esm/extractor/removeUnusedHooks.native.mjs.map +0 -1
  168. package/dist/esm/extractor/timer.native.mjs +0 -22
  169. package/dist/esm/extractor/timer.native.mjs.map +0 -1
  170. package/dist/esm/extractor/validHTMLAttributes.native.mjs +0 -50
  171. package/dist/esm/extractor/validHTMLAttributes.native.mjs.map +0 -1
  172. package/dist/esm/extractor/watchTamaguiConfig.native.mjs +0 -33
  173. package/dist/esm/extractor/watchTamaguiConfig.native.mjs.map +0 -1
  174. package/dist/esm/getPragmaOptions.native.mjs +0 -51
  175. package/dist/esm/getPragmaOptions.native.mjs.map +0 -1
  176. package/dist/esm/helpers/memoize.native.mjs +0 -15
  177. package/dist/esm/helpers/memoize.native.mjs.map +0 -1
  178. package/dist/esm/helpers/requireTamaguiCore.native.mjs +0 -13
  179. package/dist/esm/helpers/requireTamaguiCore.native.mjs.map +0 -1
  180. package/dist/esm/index.native.mjs +0 -5
  181. package/dist/esm/index.native.mjs.map +0 -1
  182. package/dist/esm/minifyCSS.native.mjs +0 -16
  183. package/dist/esm/minifyCSS.native.mjs.map +0 -1
  184. package/dist/esm/registerRequire.native.mjs +0 -86
  185. package/dist/esm/registerRequire.native.mjs.map +0 -1
  186. package/dist/esm/server.native.mjs +0 -44
  187. package/dist/esm/server.native.mjs.map +0 -1
  188. package/dist/esm/setup.native.mjs +0 -2
  189. package/dist/esm/setup.native.mjs.map +0 -1
  190. package/dist/esm/types.native.mjs +0 -2
  191. package/dist/esm/types.native.mjs.map +0 -1
@@ -1,1140 +0,0 @@
1
- import traverse from "@babel/traverse";
2
- import * as t from "@babel/types";
3
- import { Color, colorLog } from "@tamagui/cli-color";
4
- import { StyleObjectIdentifier, StyleObjectRules } from "@tamagui/web";
5
- import { basename, relative } from "node:path";
6
- import * as reactNativeWebInternals from "react-native-web-internals";
7
- import { FAILED_EVAL } from "../constants.native.mjs";
8
- import { requireTamaguiCore } from "../helpers/requireTamaguiCore.native.mjs";
9
- import { createEvaluator, createSafeEvaluator } from "./createEvaluator.native.mjs";
10
- import { evaluateAstNode } from "./evaluateAstNode.native.mjs";
11
- import { attrStr, findComponentName, getValidComponent, getValidComponentsPaths, getValidImport, isPresent, isValidImport, objToStr } from "./extractHelpers.native.mjs";
12
- import { findTopmostFunction } from "./findTopmostFunction.native.mjs";
13
- import { cleanupBeforeExit, getStaticBindingsForScope } from "./getStaticBindingsForScope.native.mjs";
14
- import { literalToAst } from "./literalToAst.native.mjs";
15
- import { loadTamagui, loadTamaguiSync } from "./loadTamagui.native.mjs";
16
- import { logLines } from "./logLines.native.mjs";
17
- import { normalizeTernaries } from "./normalizeTernaries.native.mjs";
18
- import { setPropsToFontFamily } from "./propsToFontFamilyCache.native.mjs";
19
- import { removeUnusedHooks } from "./removeUnusedHooks.native.mjs";
20
- import { timer } from "./timer.native.mjs";
21
- import { validHTMLAttributes } from "./validHTMLAttributes.native.mjs";
22
- var UNTOUCHED_PROPS = {
23
- key: !0,
24
- style: !0,
25
- className: !0
26
- },
27
- createTernary = function (x) {
28
- return x;
29
- },
30
- hasLoggedBaseInfo = !1;
31
- function isFullyDisabled(props) {
32
- return props.disableExtraction && props.disableDebugAttr;
33
- }
34
- function createExtractor() {
35
- var {
36
- logger = console,
37
- platform = "web"
38
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
39
- logger: console
40
- },
41
- INLINE_EXTRACTABLE = {
42
- ref: "ref",
43
- key: "key",
44
- ...(platform === "web" && {
45
- onPress: "onClick",
46
- onHoverIn: "onMouseEnter",
47
- onHoverOut: "onMouseLeave",
48
- onPressIn: "onMouseDown",
49
- onPressOut: "onMouseUp"
50
- })
51
- },
52
- componentState = {
53
- focus: !1,
54
- focusVisible: !1,
55
- hover: !1,
56
- unmounted: !0,
57
- press: !1,
58
- pressIn: !1,
59
- disabled: !1
60
- },
61
- styleProps = {
62
- resolveValues: "value",
63
- noClassNames: !1,
64
- isAnimated: !1
65
- },
66
- shouldAddDebugProp =
67
- // really basic disable this for next.js because it messes with ssr
68
- !process.env.npm_package_dependencies_next && !1,
69
- projectInfo = null;
70
- function loadSync(props) {
71
- return isFullyDisabled(props) ? null : projectInfo || (projectInfo = loadTamaguiSync(props));
72
- }
73
- async function load(props) {
74
- return isFullyDisabled(props) ? null : projectInfo || (projectInfo = await loadTamagui(props));
75
- }
76
- return {
77
- options: {
78
- logger
79
- },
80
- cleanupBeforeExit,
81
- loadTamagui: load,
82
- loadTamaguiSync: loadSync,
83
- getTamagui() {
84
- return projectInfo?.tamaguiConfig;
85
- },
86
- parseSync: function (f, props) {
87
- var projectInfo2 = loadSync(props);
88
- return parseWithConfig(projectInfo2 || {}, f, props);
89
- },
90
- parse: async function (f, props) {
91
- var projectInfo2 = await load(props);
92
- return parseWithConfig(projectInfo2 || {}, f, props);
93
- }
94
- };
95
- function parseWithConfig(param, fileOrPath, options) {
96
- var {
97
- components,
98
- tamaguiConfig
99
- } = param,
100
- {
101
- config = "tamagui.config.ts",
102
- importsWhitelist = ["constants.js"],
103
- evaluateVars = !0,
104
- sourcePath = "",
105
- onExtractTag,
106
- onStyleRule,
107
- getFlattenedNode,
108
- disable,
109
- disableExtraction,
110
- disableExtractInlineMedia,
111
- disableExtractVariables,
112
- disableDebugAttr,
113
- enableDynamicEvaluation = !1,
114
- disableOptimizeHooks,
115
- includeExtensions = [".ts", ".tsx", ".jsx"],
116
- extractStyledDefinitions = !1,
117
- prefixLogs,
118
- excludeProps,
119
- platform: platform2,
120
- ...restProps
121
- } = options,
122
- validHooks = disableOptimizeHooks ? {} : {
123
- useMedia: !0,
124
- useTheme: !0
125
- };
126
- if (sourcePath.includes(".tamagui-dynamic-eval")) return null;
127
- var {
128
- normalizeStyle,
129
- getSplitStyles,
130
- mediaQueryConfig,
131
- propMapper,
132
- proxyThemeVariables,
133
- pseudoDescriptors
134
- } = requireTamaguiCore(platform2),
135
- shouldPrintDebug = options.shouldPrintDebug || !1;
136
- if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath)) return null;
137
- if (!isFullyDisabled(options) && !components) throw new Error("Must provide components");
138
- if (sourcePath && includeExtensions && !includeExtensions.some(function (ext) {
139
- return sourcePath.endsWith(ext);
140
- })) return shouldPrintDebug && logger.info(`Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(", ")}`), null;
141
- function isValidStyleKey(name, staticConfig) {
142
- var _staticConfig_validStyles, _staticConfig_variants, _projectInfo_tamaguiConfig;
143
- if (!projectInfo) throw new Error("Tamagui extractor not loaded yet");
144
- return platform2 === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!(!((_staticConfig_validStyles = staticConfig.validStyles) === null || _staticConfig_validStyles === void 0) && _staticConfig_validStyles[name] || pseudoDescriptors[name] || !((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0) && _staticConfig_variants[name] || !(projectInfo == null || (_projectInfo_tamaguiConfig = projectInfo.tamaguiConfig) === null || _projectInfo_tamaguiConfig === void 0) && _projectInfo_tamaguiConfig.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
145
- }
146
- var isTargetingHTML = platform2 === "web",
147
- ogDebug = shouldPrintDebug,
148
- tm = timer(),
149
- propsWithFileInfo = {
150
- ...options,
151
- sourcePath,
152
- allLoadedComponents: components ? [...components] : []
153
- };
154
- if (!hasLoggedBaseInfo) {
155
- var _process_env_DEBUG;
156
- hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info(["loaded components:", propsWithFileInfo.allLoadedComponents.map(function (comp2) {
157
- return Object.keys(comp2.nameToInfo).join(", ");
158
- }).join(", ")].join(" ")), !((_process_env_DEBUG = process.env.DEBUG) === null || _process_env_DEBUG === void 0) && _process_env_DEBUG.startsWith("tamagui") && logger.info(["loaded:", propsWithFileInfo.allLoadedComponents.map(function (x) {
159
- return x.moduleName;
160
- })].join(`
161
- `));
162
- }
163
- tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig?.themes || (console.error(`\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file:
164
-
165
- You may not need the compiler! Remember you can run Tamagui with no configuration at all.
166
-
167
- You may have not "export default" your config (you can also "export const config").
168
-
169
- Or this may be due to duplicated dependency versions:
170
- - try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches.
171
- - or search your lockfile for mis-matches.
172
- `), console.info(" Got config:", tamaguiConfig), process.exit(0));
173
- var firstThemeName = Object.keys(tamaguiConfig?.themes || {})[0],
174
- firstTheme = tamaguiConfig?.themes[firstThemeName] || {};
175
- if (!firstTheme || typeof firstTheme != "object") {
176
- var _$err = `Missing theme ${firstThemeName}, an error occurred when importing your config`;
177
- throw console.info(_$err, "Got config:", tamaguiConfig), console.info("Looking for theme:", firstThemeName), new Error(_$err);
178
- }
179
- var proxiedTheme = proxyThemeVariables(firstTheme),
180
- themeAccessListeners = /* @__PURE__ */new Set(),
181
- defaultTheme = new Proxy(proxiedTheme, {
182
- get(target, key) {
183
- return Reflect.has(target, key) && themeAccessListeners.forEach(function (cb) {
184
- return cb(String(key));
185
- }), Reflect.get(target, key);
186
- }
187
- }),
188
- body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
189
- isFullyDisabled(options) || Object.keys(components || []).length === 0 && (console.warn("Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)"), process.env.DEBUG === "tamagui" && console.info("components", Object.keys(components || []), components)), shouldPrintDebug === "verbose" && (logger.info(`allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents.map(function (k) {
190
- return k.moduleName;
191
- }).join(", ")}`), logger.info(`valid import paths: ${JSON.stringify(getValidComponentsPaths(propsWithFileInfo))}`));
192
- var doesUseValidImport = !1,
193
- hasImportedTheme = !1,
194
- importDeclarations = [],
195
- _iteratorNormalCompletion = !0,
196
- _didIteratorError = !1,
197
- _iteratorError = void 0;
198
- try {
199
- for (var _loop = function () {
200
- var bodyPath = _step.value;
201
- if (bodyPath.type !== "ImportDeclaration") return "continue";
202
- var node = "node" in bodyPath ? bodyPath.node : bodyPath,
203
- moduleName = node.source.value,
204
- valid = isValidImport(propsWithFileInfo, moduleName);
205
- if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some(function (specifier) {
206
- return specifier.local.name === "styled";
207
- })) return doesUseValidImport = !0, "break";
208
- if (valid) {
209
- var names = node.specifiers.map(function (specifier) {
210
- return specifier.local.name;
211
- }),
212
- isValidComponent = names.some(function (name) {
213
- return !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name]);
214
- });
215
- if (shouldPrintDebug === "verbose" && logger.info(` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(", ")} from '${moduleName}' - (valid: ${JSON.stringify(getValidComponentsPaths(propsWithFileInfo))})`), isValidComponent) return doesUseValidImport = !0, "break";
216
- }
217
- }, _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
218
- var _ret = _loop();
219
- if (_ret === "break") break;
220
- }
221
- } catch (err) {
222
- _didIteratorError = !0, _iteratorError = err;
223
- } finally {
224
- try {
225
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
226
- } finally {
227
- if (_didIteratorError) throw _iteratorError;
228
- }
229
- }
230
- if (shouldPrintDebug && logger.info(`${JSON.stringify({
231
- doesUseValidImport,
232
- hasImportedTheme
233
- }, null, 2)}
234
- `), !doesUseValidImport) return null;
235
- function getValidImportedComponent(componentName) {
236
- var importDeclaration = importDeclarations.find(function (dec) {
237
- return dec.specifiers.some(function (spec) {
238
- return spec.local.name === componentName;
239
- });
240
- });
241
- return importDeclaration ? getValidImport(propsWithFileInfo, importDeclaration.source.value, componentName) : null;
242
- }
243
- tm.mark("import-check", !!shouldPrintDebug);
244
- var couldntParse = !1,
245
- modifiedComponents = /* @__PURE__ */new Set(),
246
- bindingCache = {},
247
- callTraverse = function (a) {
248
- return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
249
- },
250
- shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath),
251
- programPath = null,
252
- res = {
253
- styled: 0,
254
- flattened: 0,
255
- optimized: 0,
256
- modified: 0,
257
- found: 0
258
- },
259
- version = `${Math.random()}`;
260
- if (callTraverse({
261
- // @ts-ignore
262
- Program: {
263
- enter(path) {
264
- programPath = path;
265
- }
266
- },
267
- // styled() calls
268
- CallExpression(path) {
269
- if (!(disable || shouldDisableExtraction || extractStyledDefinitions === !1) && !(!t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled")) {
270
- var variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown",
271
- parentNode = path.node.arguments[0];
272
- if (t.isIdentifier(parentNode)) {
273
- var parentName = parentNode.name,
274
- definition = path.node.arguments[1];
275
- if (!(!parentName || !definition || !t.isObjectExpression(definition))) {
276
- var Component = getValidImportedComponent(variableName);
277
- if (!Component) {
278
- if (enableDynamicEvaluation !== !0) return;
279
- try {
280
- shouldPrintDebug && logger.info(`Unknown component: ${variableName} = styled(${parentName}) attempting dynamic load: ${sourcePath}`);
281
- var out = loadTamaguiSync({
282
- forceExports: !0,
283
- components: [sourcePath],
284
- cacheKey: version
285
- });
286
- if (!out?.components) {
287
- shouldPrintDebug && logger.info(`Couldn't load, got ${out}`);
288
- return;
289
- }
290
- if (propsWithFileInfo.allLoadedComponents = [...propsWithFileInfo.allLoadedComponents, ...out.components], Component = out.components.flatMap(function (x) {
291
- var _x_nameToInfo_variableName;
292
- return (_x_nameToInfo_variableName = x.nameToInfo[variableName]) !== null && _x_nameToInfo_variableName !== void 0 ? _x_nameToInfo_variableName : [];
293
- })[0], !out.cached) {
294
- var _out_components,
295
- foundNames = (_out_components = out.components) === null || _out_components === void 0 ? void 0 : _out_components.map(function (x) {
296
- return Object.keys(x.nameToInfo).join(", ");
297
- }).join(", ").trim();
298
- foundNames && colorLog(Color.FgYellow, ` | Tamagui found dynamic components: ${foundNames}`);
299
- }
300
- } catch {
301
- shouldPrintDebug && logger.info(`skip optimize styled(${variableName}), unable to pre-process (DEBUG=tamagui for more)`);
302
- }
303
- }
304
- if (!Component) {
305
- shouldPrintDebug && logger.info(" No component found");
306
- return;
307
- }
308
- var componentSkipProps = /* @__PURE__ */new Set([...(Component.staticConfig.inlineWhenUnflattened || []), ...(Component.staticConfig.inlineProps || []),
309
- // for now skip variants, will return to them
310
- "variants", "defaultVariants",
311
- // skip fontFamily its basically a "variant", important for theme use to be value always
312
- "fontFamily", "name", "focusStyle", "focusVisibleStyle", "disabledStyle", "hoverStyle", "pressStyle"]),
313
- skipped = /* @__PURE__ */new Set(),
314
- styles = {},
315
- staticNamespace = getStaticBindingsForScope(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug),
316
- attemptEval = evaluateVars ? createEvaluator({
317
- props: propsWithFileInfo,
318
- staticNamespace,
319
- sourcePath,
320
- shouldPrintDebug
321
- }) : evaluateAstNode,
322
- attemptEvalSafe = createSafeEvaluator(attemptEval),
323
- _iteratorNormalCompletion2 = !0,
324
- _didIteratorError2 = !1,
325
- _iteratorError2 = void 0;
326
- try {
327
- for (var _iterator2 = definition.properties[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
328
- var property = _step2.value,
329
- _Component_staticConfig_variants;
330
- if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) ||
331
- // TODO make pseudos and variants work
332
- // skip pseudos
333
- pseudoDescriptors[property.key.name] || !((_Component_staticConfig_variants = Component.staticConfig.variants) === null || _Component_staticConfig_variants === void 0) && _Component_staticConfig_variants[property.key.name] || componentSkipProps.has(property.key.name)) {
334
- skipped.add(property);
335
- continue;
336
- }
337
- var out1 = attemptEvalSafe(property.value);
338
- out1 === FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out1;
339
- }
340
- } catch (err) {
341
- _didIteratorError2 = !0, _iteratorError2 = err;
342
- } finally {
343
- try {
344
- !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
345
- } finally {
346
- if (_didIteratorError2) throw _iteratorError2;
347
- }
348
- }
349
- var out2 = getSplitStyles(styles, Component.staticConfig, defaultTheme, "", componentState, styleProps, void 0, void 0, void 0, shouldPrintDebug),
350
- classNames = {
351
- ...out2.classNames
352
- };
353
- if (shouldPrintDebug && logger.info([`Extracted styled(${variableName})
354
- `, JSON.stringify(styles, null, 2), `
355
- classNames:`, JSON.stringify(classNames, null, 2), `
356
- rulesToInsert:`, out2.rulesToInsert].join(" ")), definition.properties = definition.properties.map(function (prop) {
357
- if (skipped.has(prop) || !t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) return prop;
358
- var key2 = prop.key.name,
359
- value = classNames[key2];
360
- return value ? t.objectProperty(t.stringLiteral(key2), t.stringLiteral(value)) : prop;
361
- }), out2.rulesToInsert) for (var key in out2.rulesToInsert) {
362
- var styleObject = out2.rulesToInsert[key];
363
- onStyleRule?.(styleObject[StyleObjectIdentifier], styleObject[StyleObjectRules]);
364
- }
365
- res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
366
- }
367
- }
368
- }
369
- },
370
- JSXElement(traversePath) {
371
- tm.mark("jsx-element", !!shouldPrintDebug);
372
- var node = traversePath.node.openingElement,
373
- ogAttributes = node.attributes.map(function (attr3) {
374
- return {
375
- ...attr3
376
- };
377
- }),
378
- componentName = findComponentName(traversePath.scope),
379
- closingElement = traversePath.node.closingElement;
380
- if (closingElement && t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name)) {
381
- shouldPrintDebug && logger.info(" skip non-identifier element");
382
- return;
383
- }
384
- var binding = traversePath.scope.getBinding(node.name.name),
385
- moduleName = "";
386
- if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, moduleName, binding.identifier.name))) {
387
- shouldPrintDebug && logger.info(` - Binding in component ${componentName} not valid import: "${binding.identifier.name}" isn't in ${moduleName}
388
- `);
389
- return;
390
- }
391
- var component = getValidComponent(propsWithFileInfo, moduleName, node.name.name);
392
- if (!component || !component.staticConfig) {
393
- shouldPrintDebug && logger.info(`
394
- - No Tamagui conf for: ${node.name.name}
395
- `);
396
- return;
397
- }
398
- var originalNodeName = node.name.name;
399
- res.found++;
400
- var filePath = `./${relative(process.cwd(), sourcePath)}`,
401
- lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "",
402
- codePosition = `${filePath}:${lineNumbers}`,
403
- debugPropValue = node.attributes.filter(function (n) {
404
- return t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug";
405
- }).map(function (n) {
406
- return n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1;
407
- })[0];
408
- if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`\x1B[33m\x1B[0m ${componentName} | ${codePosition} -------------------`), logger.info(["\x1B[1m", "\x1B[32m", `<${originalNodeName} />`, disableDebugAttr ? "" : "\u{1F41B}"].join(" "))), shouldAddDebugProp && !disableDebugAttr && (res.modified++, node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(node.name.name))), componentName && node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-in"), t.stringLiteral(componentName))), node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-at"), t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)))), shouldDisableExtraction) {
409
- shouldPrintDebug === "verbose" && logger.info(` \u274C Extraction disabled: ${JSON.stringify(disableExtraction)}
410
- `);
411
- return;
412
- }
413
- try {
414
- let evaluateAttribute2 = function (path) {
415
- var attribute = path.node,
416
- attr3 = {
417
- type: "attr",
418
- value: attribute
419
- };
420
- if (t.isJSXSpreadAttribute(attribute)) {
421
- var arg = attribute.argument,
422
- conditional = t.isConditionalExpression(arg) ?
423
- // <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
424
- [arg.test, arg.consequent, arg.alternate] : t.isLogicalExpression(arg) && arg.operator === "&&" ?
425
- // <YStack {...isSmall && { color: 'red }}
426
- [arg.left, arg.right, null] : null;
427
- if (conditional) {
428
- var [test, alt, cons] = conditional;
429
- if (!test) throw new Error("no test");
430
- return [alt, cons].some(function (side) {
431
- return side && !isStaticObject2(side);
432
- }) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr3) : [...(createTernariesFromObjectProperties2(test, alt) || []), ...(cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || [])].map(function (ternary2) {
433
- return {
434
- type: "ternary",
435
- value: ternary2
436
- };
437
- });
438
- }
439
- }
440
- if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string") return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr3;
441
- var name2 = attribute.name.name;
442
- if (excludeProps?.has(name2)) return shouldPrintDebug && logger.info([" excluding prop", name2].join(" ")), null;
443
- if (inlineProps.has(name2)) return inlined.set(name2, name2), shouldPrintDebug && logger.info([" ! inlining, inline prop", name2].join(" ")), attr3;
444
- if (UNTOUCHED_PROPS[name2]) return attr3;
445
- if (INLINE_EXTRACTABLE[name2]) return inlined.set(name2, INLINE_EXTRACTABLE[name2]), attr3;
446
- if (name2.startsWith("data-")) return attr3;
447
- if ((name2 === "enterStyle" || name2 === "exitStyle") && t.isJSXExpressionContainer(attribute?.value)) return shouldDeopt = !0, attr3;
448
- if (name2[0] === "$" && t.isJSXExpressionContainer(attribute?.value)) {
449
- var shortname = name2.slice(1);
450
- if (mediaQueryConfig[shortname]) {
451
- if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia) return attr3;
452
- var expression = attribute.value.expression;
453
- if (!t.isJSXEmptyExpression(expression)) {
454
- var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
455
- inlineMediaQuery: shortname
456
- });
457
- if (ternaries2) return ternaries2.map(function (value3) {
458
- return {
459
- type: "ternary",
460
- value: value3
461
- };
462
- });
463
- }
464
- }
465
- }
466
- var [value2, valuePath] = function () {
467
- return t.isJSXExpressionContainer(attribute?.value) ? [attribute.value.expression, path.get("value")] : [attribute.value, path.get("value")];
468
- }(),
469
- remove = function () {
470
- Array.isArray(valuePath) ? valuePath.map(function (p) {
471
- return p.remove();
472
- }) : valuePath.remove();
473
- };
474
- if (name2 === "ref") return shouldPrintDebug && logger.info([" ! inlining, ref", name2].join(" ")), inlined.set("ref", "ref"), attr3;
475
- if (name2 === "tag") return {
476
- type: "attr",
477
- value: path.node
478
- };
479
- if (disableExtractVariables === !0 && value2 && value2.type === "StringLiteral" && value2.value[0] === "$") return shouldPrintDebug && logger.info([` ! inlining, native disable extract: ${name2} =`, value2.value].join(" ")), inlined.set(name2, !0), attr3;
480
- if (name2 === "theme") return inlined.set("theme", attr3.value), attr3;
481
- var styleValue = attemptEvalSafe(value2);
482
- if (!variants[name2] && !isValidStyleKey(name2, staticConfig)) {
483
- var keys = [name2],
484
- out = null;
485
- out = propMapper(name2, 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 = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
486
- var didInline = !1,
487
- attributes = keys.map(function (key9) {
488
- var val2 = out[key9],
489
- isStyle = isValidStyleKey(key9, staticConfig);
490
- return isStyle ? {
491
- type: "style",
492
- value: {
493
- [key9]: styleValue
494
- },
495
- name: key9,
496
- attr: path.node
497
- } : validHTMLAttributes[key9] || key9.startsWith("aria-") || key9.startsWith("data-") ||
498
- // this is debug stuff added by vite / new jsx transform
499
- key9 === "__source" || key9 === "__self" ? attr3 : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key9), didInline = !0, inlined.set(key9, val2), val2);
500
- });
501
- return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes.map(function (x) {
502
- return x.toString();
503
- })}`), attr3) : attributes;
504
- }
505
- if (styleValue !== FAILED_EVAL) return inlineWhenUnflattened.has(name2) && (inlineWhenUnflattenedOGVals[name2] = {
506
- styleValue,
507
- attr: attr3
508
- }), isValidStyleKey(name2, staticConfig) ? (shouldPrintDebug && logger.info(` style: ${name2} = ${styleValue}`), name2 in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
509
- type: "style",
510
- value: {
511
- [name2]: styleValue
512
- },
513
- name: name2,
514
- attr: path.node
515
- }) : (variants[name2] && variantValues.set(name2, styleValue), inlined.set(name2, !0), attr3);
516
- if (t.isBinaryExpression(value2)) {
517
- shouldPrintDebug && logger.info(` binary expression ${name2} = ${value2}`);
518
- var {
519
- operator,
520
- left,
521
- right
522
- } = value2,
523
- lVal = attemptEvalSafe(left),
524
- rVal = attemptEvalSafe(right);
525
- if (shouldPrintDebug && logger.info(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
526
- var ternary = addBinaryConditional(operator, left, right);
527
- if (ternary) return ternary;
528
- }
529
- if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
530
- var ternary1 = addBinaryConditional(operator, right, left);
531
- if (ternary1) return ternary1;
532
- }
533
- return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name2, !0), attr3;
534
- }
535
- var staticConditional = getStaticConditional(value2);
536
- if (staticConditional) return shouldPrintDebug === "verbose" && logger.info(` static conditional ${name2} ${value2}`), {
537
- type: "ternary",
538
- value: staticConditional
539
- };
540
- var staticLogical = getStaticLogical(value2);
541
- if (staticLogical) return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name2} = ${value2}`), {
542
- type: "ternary",
543
- value: staticLogical
544
- };
545
- if (options.experimentalFlattenDynamicValues && isValidStyleKey(name2, staticConfig)) return {
546
- type: "dynamic-style",
547
- value: value2,
548
- name: tamaguiConfig?.shorthands[name2] || name2
549
- };
550
- return inlined.set(name2, !0), shouldPrintDebug && logger.info(` ! inline no match ${name2} ${value2}`), attr3;
551
- function addBinaryConditional(operator2, staticExpr, cond) {
552
- if (getStaticConditional(cond)) {
553
- var alt2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.alternate)),
554
- cons2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.consequent));
555
- return shouldPrintDebug && logger.info([" binaryConditional", cond.test, cons2, alt2].join(" ")), {
556
- type: "ternary",
557
- value: {
558
- test: cond.test,
559
- remove,
560
- alternate: {
561
- [name2]: alt2
562
- },
563
- consequent: {
564
- [name2]: cons2
565
- }
566
- }
567
- };
568
- }
569
- return null;
570
- }
571
- function getStaticConditional(value3) {
572
- if (t.isConditionalExpression(value3)) try {
573
- var aVal = attemptEval(value3.alternate),
574
- cVal = attemptEval(value3.consequent);
575
- if (shouldPrintDebug) {
576
- var type = value3.test.type;
577
- logger.info([" static ternary", type, cVal, aVal].join(" "));
578
- }
579
- return {
580
- test: value3.test,
581
- remove,
582
- consequent: {
583
- [name2]: cVal
584
- },
585
- alternate: {
586
- [name2]: aVal
587
- }
588
- };
589
- } catch (err) {
590
- shouldPrintDebug && logger.info([" cant eval ternary", err.message].join(" "));
591
- }
592
- return null;
593
- }
594
- function getStaticLogical(value3) {
595
- if (t.isLogicalExpression(value3) && value3.operator === "&&") try {
596
- var val2 = attemptEval(value3.right);
597
- return shouldPrintDebug && logger.info([" staticLogical", value3.left, name2, val2].join(" ")), {
598
- test: value3.left,
599
- remove,
600
- consequent: {
601
- [name2]: val2
602
- },
603
- alternate: null
604
- };
605
- } catch (err) {
606
- shouldPrintDebug && logger.info([" cant static eval logical", err].join(" "));
607
- }
608
- return null;
609
- }
610
- },
611
- isStaticObject2 = function (obj) {
612
- return t.isObjectExpression(obj) && obj.properties.every(function (prop) {
613
- if (!t.isObjectProperty(prop)) return logger.info(["not object prop", prop].join(" ")), !1;
614
- var propName = prop.key.name;
615
- return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([" not a valid style prop!", propName].join(" ")), !1) : !0;
616
- });
617
- },
618
- createTernariesFromObjectProperties2 = function (test, side) {
619
- var ternaryPartial = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
620
- if (!side) return null;
621
- if (!isStaticObject2(side)) throw new Error("not extractable");
622
- return side.properties.flatMap(function (property) {
623
- if (!t.isObjectProperty(property)) throw new Error("expected object property");
624
- if (t.isIdentifier(property.key)) {
625
- var key9 = property.key.name,
626
- mediaQueryKey = key9.slice(1),
627
- isMediaQuery = key9[0] === "$" && mediaQueryConfig[mediaQueryKey];
628
- if (isMediaQuery) if (t.isExpression(property.value)) {
629
- var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(mediaQueryKey), property.value, {
630
- inlineMediaQuery: mediaQueryKey
631
- });
632
- if (ternaries2) return ternaries2.map(function (value2) {
633
- return {
634
- ...ternaryPartial,
635
- ...value2,
636
- // ensure media query test stays on left side (see getMediaQueryTernary)
637
- test: t.logicalExpression("&&", value2.test, test)
638
- };
639
- });
640
- logger.info(["\u26A0\uFE0F no ternaries?", property].join(" "));
641
- } else logger.info(["\u26A0\uFE0F not expression", property].join(" "));
642
- }
643
- if (t.isConditionalExpression(property.value)) {
644
- var [truthy, falsy] = [t.objectExpression([t.objectProperty(property.key, property.value.consequent)]), t.objectExpression([t.objectProperty(property.key, property.value.alternate)])].map(function (x) {
645
- return attemptEval(x);
646
- });
647
- return [createTernary({
648
- remove() {},
649
- ...ternaryPartial,
650
- test: t.logicalExpression("&&", test, property.value.test),
651
- consequent: truthy,
652
- alternate: null
653
- }), createTernary({
654
- ...ternaryPartial,
655
- test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
656
- consequent: falsy,
657
- alternate: null,
658
- remove() {}
659
- })];
660
- }
661
- var obj = t.objectExpression([t.objectProperty(property.key, property.value)]),
662
- consequent = attemptEval(obj);
663
- return createTernary({
664
- remove() {},
665
- ...ternaryPartial,
666
- test,
667
- consequent,
668
- alternate: null
669
- });
670
- });
671
- },
672
- mergeToEnd2 = function (obj, key9, val2) {
673
- key9 in obj && delete obj[key9], obj[key9] = val2;
674
- },
675
- normalizeStyleWithoutVariants2 = function (style) {
676
- var res2 = {};
677
- for (var key9 in style) if (staticConfig.variants && key9 in staticConfig.variants) mergeToEnd2(res2, key9, style[key9]);else {
678
- var expanded2 = normalizeStyle({
679
- [key9]: style[key9]
680
- }, !0);
681
- for (var key12 in expanded2) mergeToEnd2(res2, key12, expanded2[key12]);
682
- }
683
- return res2;
684
- },
685
- mergeStyles2 = function (prev2, next) {
686
- for (var key9 in next) pseudoDescriptors[key9] ? (prev2[key9] = prev2[key9] || {}, Object.assign(prev2[key9], next[key9])) : mergeToEnd2(prev2, key9, next[key9]);
687
- };
688
- var evaluateAttribute = evaluateAttribute2,
689
- isStaticObject = isStaticObject2,
690
- createTernariesFromObjectProperties = createTernariesFromObjectProperties2,
691
- mergeToEnd = mergeToEnd2,
692
- normalizeStyleWithoutVariants = normalizeStyleWithoutVariants2,
693
- mergeStyles = mergeStyles2,
694
- {
695
- staticConfig
696
- } = component,
697
- defaultProps = {
698
- ...(staticConfig.defaultProps || {})
699
- },
700
- variants = staticConfig.variants || {},
701
- isTextView = staticConfig.isText || !1,
702
- _staticConfig_validStyles,
703
- validStyles = (_staticConfig_validStyles = staticConfig?.validStyles) !== null && _staticConfig_validStyles !== void 0 ? _staticConfig_validStyles : {},
704
- _defaultProps_tag,
705
- tagName = (_defaultProps_tag = defaultProps.tag) !== null && _defaultProps_tag !== void 0 ? _defaultProps_tag : isTextView ? "span" : "div";
706
- traversePath.get("openingElement").get("attributes").forEach(function (path) {
707
- var attr3 = path.node;
708
- if (!t.isJSXSpreadAttribute(attr3) && attr3.name.name === "tag") {
709
- var val2 = attr3.value;
710
- t.isStringLiteral(val2) && (tagName = val2.value);
711
- }
712
- }), shouldPrintDebug === "verbose" && console.info(` Start tag ${tagName}`);
713
- var flatNode = getFlattenedNode?.({
714
- isTextView,
715
- tag: tagName
716
- }),
717
- inlineProps = /* @__PURE__ */new Set([
718
- // adding some always inline props
719
- "dataSet", ...(restProps.inlineProps || []), ...(staticConfig.inlineProps || [])]),
720
- deoptProps = /* @__PURE__ */new Set([
721
- // always de-opt animation these
722
- "animation", "animateOnly", "animatePresence", "disableOptimization", ...(isTargetingHTML ? [] : ["pressStyle", "focusStyle", "focusVisibleStyle", "disabledStyle"]),
723
- // when using a non-CSS driver, de-opt on enterStyle/exitStyle
724
- ...(tamaguiConfig?.animations.isReactNative ? ["enterStyle", "exitStyle"] : [])]),
725
- inlineWhenUnflattened = /* @__PURE__ */new Set([...(staticConfig.inlineWhenUnflattened || [])]),
726
- staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug),
727
- attemptEval = evaluateVars ? createEvaluator({
728
- props: propsWithFileInfo,
729
- staticNamespace,
730
- sourcePath,
731
- traversePath,
732
- shouldPrintDebug
733
- }) : evaluateAstNode,
734
- attemptEvalSafe = createSafeEvaluator(attemptEval);
735
- if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse) return;
736
- tm.mark("jsx-element-flattened", !!shouldPrintDebug);
737
- var attrs = [],
738
- shouldDeopt = !1,
739
- inlined = /* @__PURE__ */new Map(),
740
- variantValues = /* @__PURE__ */new Map(),
741
- hasSetOptimized = !1,
742
- inlineWhenUnflattenedOGVals = {},
743
- propMapperStyleState = {
744
- staticConfig,
745
- usedKeys: {},
746
- classNames: {},
747
- style: {},
748
- theme: defaultTheme,
749
- viewProps: defaultProps,
750
- conf: tamaguiConfig,
751
- props: defaultProps,
752
- componentState,
753
- styleProps: {
754
- ...styleProps,
755
- resolveValues: "auto"
756
- },
757
- debug: shouldPrintDebug
758
- };
759
- if (attrs = traversePath.get("openingElement").get("attributes").flatMap(function (path) {
760
- try {
761
- var res2 = evaluateAttribute2(path);
762
- return tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug), res2 || path.remove(), res2;
763
- } catch (err) {
764
- if (shouldPrintDebug && (logger.info(["Recoverable error extracting attribute", err.message, shouldPrintDebug === "verbose" ? err.stack : ""].join(" ")), shouldPrintDebug === "verbose")) {
765
- var _path_node;
766
- logger.info(`node ${(_path_node = path.node) === null || _path_node === void 0 ? void 0 : _path_node.type}`);
767
- }
768
- return inlined.set(`${Math.random()}`, "spread"), {
769
- type: "attr",
770
- value: path.node
771
- };
772
- }
773
- }).flat(4).filter(isPresent), shouldPrintDebug && logger.info([` - attrs (before):
774
- `, logLines(attrs.map(attrStr).join(", "))].join(" ")), couldntParse || shouldDeopt) {
775
- shouldPrintDebug && logger.info([" avoid optimizing:", {
776
- couldntParse,
777
- shouldDeopt
778
- }].join(" ")), node.attributes = ogAttributes;
779
- return;
780
- }
781
- var parentFn = findTopmostFunction(traversePath);
782
- parentFn && modifiedComponents.add(parentFn);
783
- var hasSpread = attrs.some(function (x) {
784
- return x.type === "attr" && t.isJSXSpreadAttribute(x.value);
785
- }),
786
- hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every(function (x) {
787
- return x.type === "JSXText";
788
- })),
789
- themeVal = inlined.get("theme");
790
- platform2 !== "native" && inlined.delete("theme");
791
- for (var _i = 0, _iter = [...inlined]; _i < _iter.length; _i++) {
792
- var [key] = _iter[_i],
793
- _staticConfig_variants,
794
- isStaticObjectVariant = ((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0 ? void 0 : _staticConfig_variants[key]) && variantValues.has(key);
795
- (INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
796
- }
797
- var canFlattenProps = inlined.size === 0,
798
- shouldFlatten = !!(flatNode && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren)),
799
- usedThemeKeys = /* @__PURE__ */new Set();
800
- if (themeAccessListeners.add(function (key9) {
801
- disableExtractVariables && (usedThemeKeys.add(key9), shouldFlatten = !1, shouldPrintDebug === "verbose" && logger.info([" ! accessing theme key, avoid flatten", key9].join(" ")));
802
- }), shouldFlatten) {
803
- var skipMap = !1,
804
- defaultStyleAttrs = Object.keys(defaultProps).flatMap(function (key9) {
805
- if (skipMap) return [];
806
- var value2 = defaultProps[key9];
807
- if (key9 === "theme" && !themeVal) return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", {
808
- value: t.stringLiteral(value2)
809
- })), themeVal = {
810
- value: t.stringLiteral(value2)
811
- }, [];
812
- if (!isValidStyleKey(key9, staticConfig)) return [];
813
- var name2 = tamaguiConfig?.shorthands[key9] || key9;
814
- if (value2 === void 0) {
815
- logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key9} ${value2}`), shouldDeopt = !0;
816
- return;
817
- }
818
- if (name2[0] === "$" && mediaQueryConfig[name2.slice(1)]) return defaultProps[key9] = void 0, evaluateAttribute2({
819
- node: t.jsxAttribute(t.jsxIdentifier(name2), t.jsxExpressionContainer(t.objectExpression(Object.keys(value2).filter(function (k) {
820
- return typeof value2[k] < "u";
821
- }).map(function (k) {
822
- return t.objectProperty(t.identifier(k), literalToAst(value2[k]));
823
- }))))
824
- });
825
- var attr3 = {
826
- type: "style",
827
- name: name2,
828
- value: {
829
- [name2]: value2
830
- }
831
- };
832
- return attr3;
833
- });
834
- skipMap || defaultStyleAttrs.length && (attrs = [...defaultStyleAttrs, ...attrs]);
835
- }
836
- var ternaries = [];
837
- attrs = attrs.reduce(function (out, cur2) {
838
- var next = attrs[attrs.indexOf(cur2) + 1];
839
- if (cur2.type === "ternary" && ternaries.push(cur2.value), (!next || next.type !== "ternary") && ternaries.length) {
840
- var normalized = normalizeTernaries(ternaries).map(function (param2) {
841
- var {
842
- alternate,
843
- consequent,
844
- ...rest
845
- } = param2;
846
- return {
847
- type: "ternary",
848
- value: {
849
- ...rest,
850
- alternate: alternate || null,
851
- consequent: consequent || null
852
- }
853
- };
854
- });
855
- try {
856
- return [...out, ...normalized];
857
- } finally {
858
- shouldPrintDebug && logger.info(` normalizeTernaries (${ternaries.length} => ${normalized.length})`), ternaries = [];
859
- }
860
- }
861
- return cur2.type === "ternary" || out.push(cur2), out;
862
- }, []).flat();
863
- var shouldWrapTheme = shouldFlatten && themeVal;
864
- if (shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([" - wrapping theme", themeVal].join(" ")), attrs = attrs.filter(function (x) {
865
- return !(x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme");
866
- }), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/web")))), traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]))) : console.warn(`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`)), shouldPrintDebug) try {
867
- logger.info([" flatten?", shouldFlatten, objToStr({
868
- hasSpread,
869
- shouldDeopt,
870
- canFlattenProps,
871
- shouldWrapTheme,
872
- hasOnlyStringChildren
873
- }), "inlined", inlined.size, [...inlined]].join(" "));
874
- } catch {}
875
- if (shouldDeopt || !shouldFlatten) {
876
- shouldPrintDebug && logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`), node.attributes = ogAttributes;
877
- return;
878
- }
879
- shouldPrintDebug && logger.info([` - attrs (flattened):
880
- `, logLines(attrs.map(attrStr).join(", "))].join(" "));
881
- var foundStaticProps = {};
882
- for (var key1 in attrs) {
883
- var cur = attrs[key1];
884
- if (cur.type === "style") {
885
- var expanded = normalizeStyleWithoutVariants2(cur.value);
886
- for (var key2 in expanded) mergeToEnd2(foundStaticProps, key2, expanded[key2]);
887
- continue;
888
- }
889
- if (cur.type === "attr") {
890
- if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name)) continue;
891
- var key3 = cur.value.name.name,
892
- value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
893
- value !== FAILED_EVAL && mergeToEnd2(foundStaticProps, key3, value);
894
- }
895
- }
896
- var completeProps = {};
897
- for (var key4 in defaultProps) key4 in foundStaticProps || (completeProps[key4] = defaultProps[key4]);
898
- for (var key5 in foundStaticProps) completeProps[key5] = foundStaticProps[key5];
899
- attrs = attrs.reduce(function (acc, cur2) {
900
- if (!cur2) return acc;
901
- if (cur2.type === "attr" && !t.isJSXSpreadAttribute(cur2.value) && shouldFlatten) {
902
- var name2 = cur2.value.name.name;
903
- if (typeof name2 == "string") {
904
- if (name2 === "tag") return acc;
905
- if (variants[name2] && variantValues.has(name2)) {
906
- var styleState = {
907
- ...propMapperStyleState,
908
- props: completeProps
909
- },
910
- out = Object.fromEntries(propMapper(name2, variantValues.get(name2), styleState) || []);
911
- if (out && isTargetingHTML) {
912
- var cn = out.className;
913
- out = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
914
- }
915
- shouldPrintDebug && logger.info([" - expanded variant", name2, out].join(" "));
916
- for (var key9 in out) {
917
- var value2 = out[key9];
918
- isValidStyleKey(key9, staticConfig) ? acc.push({
919
- type: "style",
920
- value: {
921
- [key9]: value2
922
- },
923
- name: key9,
924
- attr: cur2.value
925
- }) : acc.push({
926
- type: "attr",
927
- value: t.jsxAttribute(t.jsxIdentifier(key9), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)))
928
- });
929
- }
930
- }
931
- }
932
- }
933
- if (cur2.type !== "style") return acc.push(cur2), acc;
934
- var key12 = Object.keys(cur2.value)[0],
935
- value12 = cur2.value[key12],
936
- fullKey = tamaguiConfig?.shorthands[key12];
937
- return fullKey && (cur2.value = {
938
- [fullKey]: value12
939
- }, key12 = fullKey), disableExtractVariables && value12[0] === "$" && (usedThemeKeys.has(key12) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([` keeping variable inline: ${key12} =`, value12].join(" ")), acc.push({
940
- type: "attr",
941
- value: t.jsxAttribute(t.jsxIdentifier(key12), t.jsxExpressionContainer(t.stringLiteral(value12)))
942
- }), acc) : (acc.push(cur2), acc);
943
- }, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info([` - attrs (expanded):
944
- `, logLines(attrs.map(attrStr).join(", "))].join(" "));
945
- var prev = null,
946
- getProps = function (props) {
947
- var includeProps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1,
948
- debugName = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
949
- if (!props) return shouldPrintDebug && logger.info([" getProps() no props"].join(" ")), {};
950
- if (excludeProps?.size) for (var key9 in props) excludeProps.has(key9) && (shouldPrintDebug && logger.info([" delete excluded", key9].join(" ")), delete props[key9]);
951
- try {
952
- var out = getSplitStyles(props, staticConfig, defaultTheme, "", componentState, {
953
- ...styleProps,
954
- noClassNames: !0,
955
- fallbackProps: completeProps
956
- }, void 0, void 0, void 0, debugPropValue || shouldPrintDebug, options.experimentalFlattenThemesOnNative),
957
- outProps2 = {
958
- ...(includeProps ? out.viewProps : {}),
959
- ...out.style,
960
- ...out.pseudos
961
- };
962
- for (var key12 in outProps2) deoptProps.has(key12) && (shouldFlatten = !1);
963
- return shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
964
- getProps (props in): ${logLines(objToStr(props))}`), logger.info(`
965
- getProps (outProps): ${logLines(objToStr(outProps2))}`)), out.fontFamily && (setPropsToFontFamily(outProps2, out.fontFamily), shouldPrintDebug && logger.info(`
966
- \u{1F4AC} new font fam: ${out.fontFamily}`)), outProps2;
967
- } catch (err) {
968
- return logger.info(["error", err.message, err.stack].join(" ")), {};
969
- }
970
- };
971
- shouldFlatten && attrs.unshift({
972
- type: "style",
973
- value: defaultProps
974
- }), attrs = attrs.reduce(function (acc, cur2) {
975
- if (cur2.type === "style") {
976
- var key9 = Object.keys(cur2.value)[0],
977
- value2 = cur2.value[key9],
978
- shouldKeepOriginalAttr =
979
- // !isStyleAndAttr[key] &&
980
- !shouldFlatten &&
981
- // de-opt if non-style
982
- !validStyles[key9] && !pseudoDescriptors[key9] && !(key9.startsWith("data-") || key9.startsWith("aria-"));
983
- if (shouldKeepOriginalAttr) return shouldPrintDebug && logger.info([" - keeping as non-style", key9].join(" ")), prev = cur2, acc.push({
984
- type: "attr",
985
- value: t.jsxAttribute(t.jsxIdentifier(key9), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)))
986
- }), acc.push(cur2), acc;
987
- if (prev?.type === "style") return mergeStyles2(prev.value, cur2.value), acc;
988
- }
989
- return cur2.type === "style" && (prev = cur2), acc.push(cur2), acc;
990
- }, []), shouldPrintDebug && logger.info([` - attrs (combined \u{1F500}):
991
- `, logLines(attrs.map(attrStr).join(", "))].join(" "));
992
- var getStyleError = null,
993
- _iteratorNormalCompletion2 = !0,
994
- _didIteratorError2 = !1,
995
- _iteratorError2 = void 0;
996
- try {
997
- for (var _iterator2 = attrs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
998
- var attr = _step2.value;
999
- try {
1000
- switch (shouldPrintDebug && console.info(` Processing ${attr.type}:`), attr.type) {
1001
- case "ternary":
1002
- {
1003
- var a = getProps(attr.value.alternate, !1, "ternary.alternate"),
1004
- c = getProps(attr.value.consequent, !1, "ternary.consequent");
1005
- a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", attrStr(attr)].join(" "));
1006
- continue;
1007
- }
1008
- case "style":
1009
- {
1010
- var styles = getProps(attr.value, !1, "style");
1011
- styles && (attr.value = styles), shouldPrintDebug && logger.info([" * styles (in)", logLines(objToStr(attr.value))].join(" ")), shouldPrintDebug && logger.info([" * styles (out)", logLines(objToStr(styles))].join(" "));
1012
- continue;
1013
- }
1014
- case "attr":
1015
- if (shouldFlatten && t.isJSXAttribute(attr.value)) {
1016
- var key6 = attr.value.name.name;
1017
- if (key6 === "style" || key6 === "className" || key6 === "tag") continue;
1018
- var value1 = attemptEvalSafe(attr.value.value || t.booleanLiteral(!0));
1019
- if (value1 !== FAILED_EVAL) {
1020
- var outProps = getProps({
1021
- [key6]: value1
1022
- }, !0, `attr.${key6}`),
1023
- outKey = Object.keys(outProps)[0];
1024
- if (outKey) {
1025
- var outVal = outProps[outKey];
1026
- attr.value = t.jsxAttribute(t.jsxIdentifier(outKey), t.jsxExpressionContainer(typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)));
1027
- }
1028
- }
1029
- }
1030
- }
1031
- } catch (err) {
1032
- getStyleError = err;
1033
- }
1034
- }
1035
- } catch (err) {
1036
- _didIteratorError2 = !0, _iteratorError2 = err;
1037
- } finally {
1038
- try {
1039
- !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
1040
- } finally {
1041
- if (_didIteratorError2) throw _iteratorError2;
1042
- }
1043
- }
1044
- if (shouldPrintDebug && logger.info([` - attrs (ternaries/combined):
1045
- `, logLines(attrs.map(attrStr).join(", "))].join(" ")), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError) return logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" ")), node.attributes = ogAttributes, null;
1046
- for (var existingStyleKeys = /* @__PURE__ */new Set(), i = attrs.length - 1; i >= 0; i--) {
1047
- var attr1 = attrs[i];
1048
- if (shouldFlatten && attr1.type === "attr" && t.isJSXAttribute(attr1.value) && t.isJSXIdentifier(attr1.value.name)) {
1049
- var name = attr1.value.name.name;
1050
- INLINE_EXTRACTABLE[name] && (attr1.value.name.name = INLINE_EXTRACTABLE[name]);
1051
- }
1052
- if (attr1.type === "style") for (var key7 in attr1.value) existingStyleKeys.has(key7) ? (shouldPrintDebug && logger.info([` >> delete existing ${key7}`].join(" ")), delete attr1.value[key7]) : existingStyleKeys.add(key7);
1053
- attr1.type === "dynamic-style" && (existingStyleKeys.has(attr1.name) ? attrs[i] = void 0 : existingStyleKeys.add(attr1.name));
1054
- }
1055
- if (options.experimentalFlattenThemesOnNative && (attrs = attrs.filter(Boolean)), !shouldFlatten && inlineWhenUnflattened.size) {
1056
- var _iteratorNormalCompletion12 = !0,
1057
- _didIteratorError12 = !1,
1058
- _iteratorError12 = void 0;
1059
- try {
1060
- for (var _iterator12 = attrs.entries()[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = !0) {
1061
- var [index, attr2] = _step12.value;
1062
- if (attr2.type === "style") {
1063
- for (var key8 in attr2.value) if (inlineWhenUnflattened.has(key8)) {
1064
- var val = inlineWhenUnflattenedOGVals[key8];
1065
- val ? (delete attr2.value[key8], attrs.splice(index - 1, 0, val.attr)) : delete attr2.value[key8];
1066
- }
1067
- }
1068
- }
1069
- } catch (err) {
1070
- _didIteratorError12 = !0, _iteratorError12 = err;
1071
- } finally {
1072
- try {
1073
- !_iteratorNormalCompletion12 && _iterator12.return != null && _iterator12.return();
1074
- } finally {
1075
- if (_didIteratorError12) throw _iteratorError12;
1076
- }
1077
- }
1078
- }
1079
- attrs = attrs.filter(function (x) {
1080
- return !((x.type === "style" || x.type === "dynamic-style") && Object.keys(x.value).length === 0);
1081
- }), shouldFlatten && (shouldPrintDebug && logger.info([" [\u2705] flattening", originalNodeName, flatNode].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode));
1082
- var isNativeNotFlat = !shouldFlatten && platform2 === "native";
1083
- if (isNativeNotFlat) return shouldPrintDebug && logger.info(`Disabled flattening except for simple cases on native for now: ${JSON.stringify({
1084
- flatNode,
1085
- shouldDeopt,
1086
- canFlattenProps,
1087
- hasSpread,
1088
- "staticConfig.isStyledHOC": staticConfig.isStyledHOC,
1089
- "!staticConfig.isHOC": !staticConfig.isHOC,
1090
- "staticConfig.isReactNative": staticConfig.isReactNative,
1091
- "staticConfig.neverFlatten": staticConfig.neverFlatten
1092
- }, null, 2)}`), node.attributes = ogAttributes, null;
1093
- 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):
1094
- ${logLines(attrs.map(attrStr).join(", "))}`)), onExtractTag({
1095
- parserProps: propsWithFileInfo,
1096
- attrs,
1097
- node,
1098
- lineNumbers,
1099
- filePath,
1100
- config: tamaguiConfig,
1101
- attemptEval,
1102
- jsxPath: traversePath,
1103
- originalNodeName,
1104
- isFlattened: shouldFlatten,
1105
- programPath,
1106
- completeProps,
1107
- staticConfig
1108
- });
1109
- } catch (err) {
1110
- node.attributes = ogAttributes, console.error(`@tamagui/static error, reverting optimization. In ${filePath} ${lineNumbers} on ${originalNodeName}: ${err.message}. For stack trace set environment TAMAGUI_DEBUG=1`), process.env.TAMAGUI_DEBUG === "1" && console.error(err.stack);
1111
- } finally {
1112
- debugPropValue && (shouldPrintDebug = ogDebug);
1113
- }
1114
- }
1115
- }), tm.mark("jsx-done", !!shouldPrintDebug), modifiedComponents.size) {
1116
- var all = Array.from(modifiedComponents);
1117
- shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
1118
- var _iteratorNormalCompletion1 = !0,
1119
- _didIteratorError1 = !1,
1120
- _iteratorError1 = void 0;
1121
- try {
1122
- for (var _iterator1 = all[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
1123
- var comp = _step1.value;
1124
- removeUnusedHooks(comp, shouldPrintDebug);
1125
- }
1126
- } catch (err) {
1127
- _didIteratorError1 = !0, _iteratorError1 = err;
1128
- } finally {
1129
- try {
1130
- !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
1131
- } finally {
1132
- if (_didIteratorError1) throw _iteratorError1;
1133
- }
1134
- }
1135
- }
1136
- return tm.done(shouldPrintDebug === "verbose"), res;
1137
- }
1138
- }
1139
- export { createExtractor };
1140
- //# sourceMappingURL=createExtractor.native.mjs.map