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