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