@tamagui/static 1.0.0-canary.204 → 1.0.1-beta.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +1 -5
  2. package/dist/cjs/extractor/accessSafe.js +0 -2
  3. package/dist/cjs/extractor/accessSafe.js.map +1 -1
  4. package/dist/cjs/extractor/babelParse.js +15 -16
  5. package/dist/cjs/extractor/babelParse.js.map +2 -2
  6. package/dist/cjs/extractor/buildClassName.js +0 -2
  7. package/dist/cjs/extractor/buildClassName.js.map +1 -1
  8. package/dist/cjs/extractor/createEvaluator.js +9 -7
  9. package/dist/cjs/extractor/createEvaluator.js.map +2 -2
  10. package/dist/cjs/extractor/createExtractor.js +318 -144
  11. package/dist/cjs/extractor/createExtractor.js.map +2 -2
  12. package/dist/cjs/extractor/ensureImportingConcat.js +0 -2
  13. package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -1
  14. package/dist/cjs/extractor/evaluateAstNode.js +0 -2
  15. package/dist/cjs/extractor/evaluateAstNode.js.map +1 -1
  16. package/dist/cjs/extractor/extractHelpers.js +11 -16
  17. package/dist/cjs/extractor/extractHelpers.js.map +1 -1
  18. package/dist/cjs/extractor/extractMediaStyle.js +3 -8
  19. package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
  20. package/dist/cjs/extractor/extractToClassNames.js +27 -42
  21. package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
  22. package/dist/cjs/extractor/findTopmostFunction.js +1 -3
  23. package/dist/cjs/extractor/findTopmostFunction.js.map +1 -1
  24. package/dist/cjs/extractor/generatedUid.js +0 -2
  25. package/dist/cjs/extractor/generatedUid.js.map +1 -1
  26. package/dist/cjs/extractor/getPrefixLogs.js +0 -2
  27. package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
  28. package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -2
  29. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -1
  30. package/dist/cjs/extractor/getSourceModule.js +0 -2
  31. package/dist/cjs/extractor/getSourceModule.js.map +1 -1
  32. package/dist/cjs/extractor/getStaticBindingsForScope.js +11 -6
  33. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +2 -2
  34. package/dist/cjs/extractor/hoistClassNames.js +0 -3
  35. package/dist/cjs/extractor/hoistClassNames.js.map +1 -1
  36. package/dist/cjs/extractor/literalToAst.js +0 -4
  37. package/dist/cjs/extractor/literalToAst.js.map +1 -1
  38. package/dist/cjs/extractor/loadTamagui.js +46 -10
  39. package/dist/cjs/extractor/loadTamagui.js.map +2 -2
  40. package/dist/cjs/extractor/logLines.js +2 -3
  41. package/dist/cjs/extractor/logLines.js.map +1 -1
  42. package/dist/cjs/extractor/normalizeTernaries.js +0 -2
  43. package/dist/cjs/extractor/normalizeTernaries.js.map +1 -1
  44. package/dist/cjs/extractor/removeUnusedHooks.js +2 -4
  45. package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
  46. package/dist/cjs/extractor/timer.js +2 -3
  47. package/dist/cjs/extractor/timer.js.map +1 -1
  48. package/dist/cjs/extractor/validHTMLAttributes.js +51 -0
  49. package/dist/cjs/extractor/validHTMLAttributes.js.map +2 -2
  50. package/dist/cjs/index.js +2 -1
  51. package/dist/cjs/index.js.map +2 -2
  52. package/dist/cjs/types.js.map +1 -1
  53. package/dist/esm/extractor/accessSafe.js +0 -3
  54. package/dist/esm/extractor/accessSafe.js.map +1 -1
  55. package/dist/esm/extractor/babelParse.js +15 -17
  56. package/dist/esm/extractor/babelParse.js.map +2 -2
  57. package/dist/esm/extractor/buildClassName.js +0 -3
  58. package/dist/esm/extractor/buildClassName.js.map +1 -1
  59. package/dist/esm/extractor/createEvaluator.js +9 -8
  60. package/dist/esm/extractor/createEvaluator.js.map +2 -2
  61. package/dist/esm/extractor/createExtractor.js +405 -194
  62. package/dist/esm/extractor/createExtractor.js.map +2 -2
  63. package/dist/esm/extractor/ensureImportingConcat.js +0 -3
  64. package/dist/esm/extractor/ensureImportingConcat.js.map +1 -1
  65. package/dist/esm/extractor/evaluateAstNode.js +0 -3
  66. package/dist/esm/extractor/evaluateAstNode.js.map +1 -1
  67. package/dist/esm/extractor/extractHelpers.js +11 -17
  68. package/dist/esm/extractor/extractHelpers.js.map +1 -1
  69. package/dist/esm/extractor/extractMediaStyle.js +29 -20
  70. package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
  71. package/dist/esm/extractor/extractToClassNames.js +53 -52
  72. package/dist/esm/extractor/extractToClassNames.js.map +2 -2
  73. package/dist/esm/extractor/findTopmostFunction.js +1 -4
  74. package/dist/esm/extractor/findTopmostFunction.js.map +1 -1
  75. package/dist/esm/extractor/generatedUid.js +0 -3
  76. package/dist/esm/extractor/generatedUid.js.map +1 -1
  77. package/dist/esm/extractor/getPrefixLogs.js +1 -5
  78. package/dist/esm/extractor/getPrefixLogs.js.map +1 -1
  79. package/dist/esm/extractor/getPropValueFromAttributes.js +0 -3
  80. package/dist/esm/extractor/getPropValueFromAttributes.js.map +1 -1
  81. package/dist/esm/extractor/getSourceModule.js +0 -3
  82. package/dist/esm/extractor/getSourceModule.js.map +1 -1
  83. package/dist/esm/extractor/getStaticBindingsForScope.js +11 -7
  84. package/dist/esm/extractor/getStaticBindingsForScope.js.map +2 -2
  85. package/dist/esm/extractor/hoistClassNames.js +0 -4
  86. package/dist/esm/extractor/hoistClassNames.js.map +1 -1
  87. package/dist/esm/extractor/literalToAst.js +21 -11
  88. package/dist/esm/extractor/literalToAst.js.map +1 -1
  89. package/dist/esm/extractor/loadTamagui.js +47 -11
  90. package/dist/esm/extractor/loadTamagui.js.map +2 -2
  91. package/dist/esm/extractor/logLines.js +2 -4
  92. package/dist/esm/extractor/logLines.js.map +1 -1
  93. package/dist/esm/extractor/normalizeTernaries.js +35 -9
  94. package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
  95. package/dist/esm/extractor/removeUnusedHooks.js +5 -9
  96. package/dist/esm/extractor/removeUnusedHooks.js.map +1 -1
  97. package/dist/esm/extractor/timer.js +2 -4
  98. package/dist/esm/extractor/timer.js.map +1 -1
  99. package/dist/esm/extractor/validHTMLAttributes.js +50 -0
  100. package/dist/esm/extractor/validHTMLAttributes.js.map +2 -2
  101. package/dist/esm/index.js +2 -1
  102. package/dist/esm/index.js.map +2 -2
  103. package/dist/jsx/constants.js +1 -0
  104. package/dist/jsx/constants.js.map +7 -0
  105. package/dist/jsx/extractor/accessSafe.js +1 -3
  106. package/dist/jsx/extractor/accessSafe.js.map +7 -0
  107. package/dist/jsx/extractor/babelParse.js +16 -17
  108. package/dist/jsx/extractor/babelParse.js.map +7 -0
  109. package/dist/jsx/extractor/buildClassName.js +1 -3
  110. package/dist/jsx/extractor/buildClassName.js.map +7 -0
  111. package/dist/jsx/extractor/createEvaluator.js +10 -8
  112. package/dist/jsx/extractor/createEvaluator.js.map +7 -0
  113. package/dist/jsx/extractor/createExtractor.js +325 -149
  114. package/dist/jsx/extractor/createExtractor.js.map +7 -0
  115. package/dist/jsx/extractor/ensureImportingConcat.js +1 -3
  116. package/dist/jsx/extractor/ensureImportingConcat.js.map +7 -0
  117. package/dist/jsx/extractor/evaluateAstNode.js +1 -3
  118. package/dist/jsx/extractor/evaluateAstNode.js.map +7 -0
  119. package/dist/jsx/extractor/extractHelpers.js +12 -17
  120. package/dist/jsx/extractor/extractHelpers.js.map +7 -0
  121. package/dist/jsx/extractor/extractMediaStyle.js +4 -9
  122. package/dist/jsx/extractor/extractMediaStyle.js.map +7 -0
  123. package/dist/jsx/extractor/extractToClassNames.js +31 -43
  124. package/dist/jsx/extractor/extractToClassNames.js.map +7 -0
  125. package/dist/jsx/extractor/findTopmostFunction.js +2 -4
  126. package/dist/jsx/extractor/findTopmostFunction.js.map +7 -0
  127. package/dist/jsx/extractor/generatedUid.js +1 -3
  128. package/dist/jsx/extractor/generatedUid.js.map +7 -0
  129. package/dist/jsx/extractor/getPrefixLogs.js +1 -3
  130. package/dist/jsx/extractor/getPrefixLogs.js.map +7 -0
  131. package/dist/jsx/extractor/getPropValueFromAttributes.js +1 -3
  132. package/dist/jsx/extractor/getPropValueFromAttributes.js.map +7 -0
  133. package/dist/jsx/extractor/getSourceModule.js +1 -3
  134. package/dist/jsx/extractor/getSourceModule.js.map +7 -0
  135. package/dist/jsx/extractor/getStaticBindingsForScope.js +12 -7
  136. package/dist/jsx/extractor/getStaticBindingsForScope.js.map +7 -0
  137. package/dist/jsx/extractor/hoistClassNames.js +1 -4
  138. package/dist/jsx/extractor/hoistClassNames.js.map +7 -0
  139. package/dist/jsx/extractor/literalToAst.js +1 -5
  140. package/dist/jsx/extractor/literalToAst.js.map +7 -0
  141. package/dist/jsx/extractor/loadTamagui.js +33 -11
  142. package/dist/jsx/extractor/loadTamagui.js.map +7 -0
  143. package/dist/jsx/extractor/logLines.js +3 -4
  144. package/dist/jsx/extractor/logLines.js.map +7 -0
  145. package/dist/jsx/extractor/normalizeTernaries.js +1 -3
  146. package/dist/jsx/extractor/normalizeTernaries.js.map +7 -0
  147. package/dist/jsx/extractor/removeUnusedHooks.js +3 -5
  148. package/dist/jsx/extractor/removeUnusedHooks.js.map +7 -0
  149. package/dist/jsx/extractor/timer.js +3 -4
  150. package/dist/jsx/extractor/timer.js.map +7 -0
  151. package/dist/jsx/extractor/validHTMLAttributes.js +51 -0
  152. package/dist/jsx/extractor/validHTMLAttributes.js.map +7 -0
  153. package/dist/jsx/index.js +3 -1
  154. package/dist/jsx/index.js.map +7 -0
  155. package/dist/jsx/types.js +1 -0
  156. package/dist/jsx/types.js.map +7 -0
  157. package/package.json +28 -20
  158. package/src/constants.ts +13 -0
  159. package/src/extractor/accessSafe.ts +18 -0
  160. package/src/extractor/babelParse.ts +27 -0
  161. package/src/extractor/buildClassName.ts +61 -0
  162. package/src/extractor/createEvaluator.ts +75 -0
  163. package/src/extractor/createExtractor.ts +1928 -0
  164. package/src/extractor/ensureImportingConcat.ts +39 -0
  165. package/src/extractor/evaluateAstNode.ts +121 -0
  166. package/src/extractor/extractHelpers.ts +119 -0
  167. package/src/extractor/extractMediaStyle.ts +192 -0
  168. package/src/extractor/extractToClassNames.ts +393 -0
  169. package/src/extractor/findTopmostFunction.ts +22 -0
  170. package/src/extractor/generatedUid.ts +43 -0
  171. package/src/extractor/getPrefixLogs.ts +6 -0
  172. package/src/extractor/getPropValueFromAttributes.ts +92 -0
  173. package/src/extractor/getSourceModule.ts +101 -0
  174. package/src/extractor/getStaticBindingsForScope.ts +183 -0
  175. package/src/extractor/hoistClassNames.ts +45 -0
  176. package/src/extractor/literalToAst.ts +84 -0
  177. package/src/extractor/loadTamagui.ts +145 -0
  178. package/src/extractor/logLines.ts +16 -0
  179. package/src/extractor/normalizeTernaries.ts +63 -0
  180. package/src/extractor/removeUnusedHooks.ts +76 -0
  181. package/src/extractor/timer.ts +18 -0
  182. package/src/extractor/validHTMLAttributes.ts +99 -0
  183. package/src/index.ts +10 -0
  184. package/src/types.ts +96 -0
  185. package/types/extractor/buildClassName.d.ts +0 -0
  186. package/types/extractor/buildClassName.d.ts.map +0 -0
  187. package/types/extractor/createEvaluator.d.ts +1 -1
  188. package/types/extractor/createEvaluator.d.ts.map +1 -1
  189. package/types/extractor/createExtractor.d.ts +3 -4
  190. package/types/extractor/createExtractor.d.ts.map +1 -1
  191. package/types/extractor/extractHelpers.d.ts +1 -1
  192. package/types/extractor/extractHelpers.d.ts.map +1 -1
  193. package/types/extractor/extractMediaStyle.d.ts +0 -0
  194. package/types/extractor/extractMediaStyle.d.ts.map +1 -1
  195. package/types/extractor/extractToClassNames.d.ts +1 -6
  196. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  197. package/types/extractor/getPrefixLogs.d.ts +0 -0
  198. package/types/extractor/getPrefixLogs.d.ts.map +0 -0
  199. package/types/extractor/loadTamagui.d.ts +10 -4
  200. package/types/extractor/loadTamagui.d.ts.map +1 -1
  201. package/types/extractor/normalizeTernaries.d.ts +0 -0
  202. package/types/extractor/normalizeTernaries.d.ts.map +0 -0
  203. package/types/index.d.ts +2 -1
  204. package/types/index.d.ts.map +1 -1
  205. package/types/types.d.ts +6 -7
  206. package/types/types.d.ts.map +1 -1
  207. package/LICENSE +0 -21
  208. package/dist/cjs/patchReactNativeWeb.js +0 -167
  209. package/dist/cjs/patchReactNativeWeb.js.map +0 -7
  210. package/dist/esm/patchReactNativeWeb.js +0 -142
  211. package/dist/esm/patchReactNativeWeb.js.map +0 -7
  212. package/dist/jsx/patchReactNativeWeb.js +0 -141
  213. package/types/constants.d.ts +0 -6
  214. package/types/constants.d.ts.map +0 -1
  215. package/types/extractor/accessSafe.d.ts +0 -3
  216. package/types/extractor/accessSafe.d.ts.map +0 -1
  217. package/types/extractor/babelParse.d.ts +0 -5
  218. package/types/extractor/babelParse.d.ts.map +0 -1
  219. package/types/extractor/ensureImportingConcat.d.ts +0 -4
  220. package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
  221. package/types/extractor/evaluateAstNode.d.ts +0 -3
  222. package/types/extractor/evaluateAstNode.d.ts.map +0 -1
  223. package/types/extractor/findTopmostFunction.d.ts +0 -4
  224. package/types/extractor/findTopmostFunction.d.ts.map +0 -1
  225. package/types/extractor/generatedUid.d.ts +0 -5
  226. package/types/extractor/generatedUid.d.ts.map +0 -1
  227. package/types/extractor/getPropValueFromAttributes.d.ts +0 -3
  228. package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
  229. package/types/extractor/getSourceModule.d.ts +0 -16
  230. package/types/extractor/getSourceModule.d.ts.map +0 -1
  231. package/types/extractor/getStaticBindingsForScope.d.ts +0 -4
  232. package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
  233. package/types/extractor/hoistClassNames.d.ts +0 -6
  234. package/types/extractor/hoistClassNames.d.ts.map +0 -1
  235. package/types/extractor/literalToAst.d.ts +0 -4
  236. package/types/extractor/literalToAst.d.ts.map +0 -1
  237. package/types/extractor/logLines.d.ts +0 -2
  238. package/types/extractor/logLines.d.ts.map +0 -1
  239. package/types/extractor/removeUnusedHooks.d.ts +0 -3
  240. package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
  241. package/types/extractor/timer.d.ts +0 -5
  242. package/types/extractor/timer.d.ts.map +0 -1
  243. package/types/extractor/validHTMLAttributes.d.ts +0 -49
  244. package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
  245. package/types/patchReactNativeWeb.d.ts +0 -2
  246. package/types/patchReactNativeWeb.d.ts.map +0 -1
@@ -21,7 +21,6 @@ var __spreadValues = (a, b) => {
21
21
  return a;
22
22
  };
23
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
24
  var __objRest = (source, exclude) => {
26
25
  var target = {};
27
26
  for (var prop in source)
@@ -85,12 +84,12 @@ const INLINE_EXTRACTABLE = {
85
84
  onPressIn: "onMouseDown",
86
85
  onPressOut: "onMouseUp"
87
86
  };
88
- const isAttr = /* @__PURE__ */ __name((x) => x.type === "attr", "isAttr");
87
+ const isAttr = (x) => x.type === "attr";
89
88
  const validHooks = {
90
89
  useMedia: true,
91
90
  useTheme: true
92
91
  };
93
- const createTernary = /* @__PURE__ */ __name((x) => x, "createTernary");
92
+ const createTernary = (x) => x;
94
93
  function createExtractor() {
95
94
  if (!process.env.TAMAGUI_TARGET) {
96
95
  console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either "web" or "native"');
@@ -99,6 +98,10 @@ function createExtractor() {
99
98
  const shouldAddDebugProp = !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);
100
99
  let loadedTamaguiConfig;
101
100
  let hasLogged = false;
101
+ function isValidStyleKey(name, staticConfig) {
102
+ var _a, _b;
103
+ return !!(!!((_a = staticConfig.validStyles) == null ? void 0 : _a[name]) || !!import_core_node.pseudoDescriptors[name] || ((_b = staticConfig.variants) == null ? void 0 : _b[name]) || loadedTamaguiConfig.shorthands[name] || (name[0] === "$" ? !!import_core_node.mediaQueryConfig[name.slice(1)] : false));
104
+ }
102
105
  return {
103
106
  getTamagui() {
104
107
  return loadedTamaguiConfig;
@@ -111,14 +114,17 @@ function createExtractor() {
111
114
  shouldPrintDebug = false,
112
115
  sourcePath = "",
113
116
  onExtractTag,
117
+ onStyleRule,
114
118
  getFlattenedNode,
115
119
  disable,
116
120
  disableExtraction,
117
121
  disableExtractInlineMedia,
118
122
  disableExtractVariables,
119
123
  disableDebugAttr,
124
+ extractStyledDefinitions = false,
120
125
  prefixLogs,
121
- excludeProps
126
+ excludeProps,
127
+ target
122
128
  } = _b, props = __objRest(_b, [
123
129
  "config",
124
130
  "importsWhitelist",
@@ -126,14 +132,17 @@ function createExtractor() {
126
132
  "shouldPrintDebug",
127
133
  "sourcePath",
128
134
  "onExtractTag",
135
+ "onStyleRule",
129
136
  "getFlattenedNode",
130
137
  "disable",
131
138
  "disableExtraction",
132
139
  "disableExtractInlineMedia",
133
140
  "disableExtractVariables",
134
141
  "disableDebugAttr",
142
+ "extractStyledDefinitions",
135
143
  "prefixLogs",
136
- "excludeProps"
144
+ "excludeProps",
145
+ "target"
137
146
  ]);
138
147
  if (disable) {
139
148
  return null;
@@ -144,6 +153,7 @@ function createExtractor() {
144
153
  if (!Array.isArray(props.components)) {
145
154
  throw new Error(`Must provide components array with list of Tamagui component modules`);
146
155
  }
156
+ const isTargetingHTML = target === "html";
147
157
  const ogDebug = shouldPrintDebug;
148
158
  const tm = (0, import_timer.timer)();
149
159
  const { components, tamaguiConfig } = (0, import_loadTamagui.loadTamagui)({
@@ -155,11 +165,20 @@ function createExtractor() {
155
165
  }
156
166
  tm.mark("load-tamagui", shouldPrintDebug === "verbose");
157
167
  loadedTamaguiConfig = tamaguiConfig;
158
- const defaultTheme = (0, import_core_node.proxyThemeVariables)(tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]);
168
+ const proxiedTheme = (0, import_core_node.proxyThemeVariables)(tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]);
169
+ const themeAccessListeners = /* @__PURE__ */ new Set();
170
+ const defaultTheme = new Proxy(proxiedTheme, {
171
+ get(target2, key) {
172
+ if (key[0] === "$") {
173
+ themeAccessListeners.forEach((cb) => cb(String(key)));
174
+ }
175
+ return Reflect.get(target2, key);
176
+ }
177
+ });
159
178
  const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
160
- const isInternalImport = /* @__PURE__ */ __name((importStr) => {
179
+ const isInternalImport = (importStr) => {
161
180
  return (0, import_extractHelpers.isInsideTamagui)(sourcePath) && importStr[0] === ".";
162
- }, "isInternalImport");
181
+ };
163
182
  const validComponents = Object.keys(components).filter((key) => {
164
183
  var _a2;
165
184
  return key[0].toUpperCase() === key[0] && !!((_a2 = components[key]) == null ? void 0 : _a2.staticConfig);
@@ -177,11 +196,21 @@ function createExtractor() {
177
196
  continue;
178
197
  const node = "node" in bodyPath ? bodyPath.node : bodyPath;
179
198
  const from = node.source.value;
199
+ if (extractStyledDefinitions) {
200
+ if (from === "@tamagui/core" || from === "tamagui") {
201
+ if (node.specifiers.some((specifier) => {
202
+ return specifier.local.name === "styled";
203
+ })) {
204
+ doesUseValidImport = true;
205
+ break;
206
+ }
207
+ }
208
+ }
180
209
  const isValidImport = props.components.includes(from) || isInternalImport(from);
181
210
  if (isValidImport) {
182
211
  const isValidComponent = node.specifiers.some((specifier) => {
183
212
  const name = specifier.local.name;
184
- return validComponents[name] || validHooks[name];
213
+ return !!(validComponents[name] || validHooks[name]);
185
214
  });
186
215
  if (shouldPrintDebug === "verbose") {
187
216
  console.log("import from", from, { isValidComponent });
@@ -202,11 +231,12 @@ function createExtractor() {
202
231
  let couldntParse = false;
203
232
  const modifiedComponents = /* @__PURE__ */ new Set();
204
233
  const bindingCache = {};
205
- const callTraverse = /* @__PURE__ */ __name((a) => {
234
+ const callTraverse = (a) => {
206
235
  return fileOrPath.type === "File" ? (0, import_traverse.default)(fileOrPath, a) : fileOrPath.traverse(a);
207
- }, "callTraverse");
236
+ };
208
237
  let programPath;
209
238
  const res = {
239
+ styled: 0,
210
240
  flattened: 0,
211
241
  optimized: 0,
212
242
  modified: 0,
@@ -218,8 +248,97 @@ function createExtractor() {
218
248
  programPath = path;
219
249
  }
220
250
  },
251
+ CallExpression(path) {
252
+ var _a2;
253
+ if (disable || disableExtraction || extractStyledDefinitions === false) {
254
+ return;
255
+ }
256
+ if (!t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled") {
257
+ return;
258
+ }
259
+ const name = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown";
260
+ const definition = path.node.arguments[1];
261
+ if (!name || !definition || !t.isObjectExpression(definition)) {
262
+ return;
263
+ }
264
+ const Component = validComponents[name];
265
+ if (!Component) {
266
+ if (shouldPrintDebug) {
267
+ console.log(`Didn't recognize styled(${name}), ${name} isn't in design system provided to tamagui.config.ts`);
268
+ }
269
+ return;
270
+ }
271
+ const componentSkipProps = /* @__PURE__ */ new Set([
272
+ ...Component.staticConfig.inlineWhenUnflattened || [],
273
+ ...Component.staticConfig.inlineProps || [],
274
+ ...Component.staticConfig.deoptProps || [],
275
+ "variants",
276
+ "defaultVariants",
277
+ "fontFamily",
278
+ "name"
279
+ ]);
280
+ const skipped = [];
281
+ const styles = {};
282
+ const staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
283
+ const attemptEval = !evaluateVars ? import_evaluateAstNode.evaluateAstNode : (0, import_createEvaluator.createEvaluator)({
284
+ tamaguiConfig,
285
+ staticNamespace,
286
+ sourcePath,
287
+ shouldPrintDebug
288
+ });
289
+ const attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
290
+ for (const property of definition.properties) {
291
+ if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || ((_a2 = Component.staticConfig.variants) == null ? void 0 : _a2[property.key.name]) || componentSkipProps.has(property.key.name)) {
292
+ skipped.push(property);
293
+ continue;
294
+ }
295
+ const out2 = attemptEvalSafe(property.value);
296
+ if (out2 === import_constants.FAILED_EVAL) {
297
+ skipped.push(property);
298
+ } else {
299
+ styles[property.key.name] = out2;
300
+ }
301
+ }
302
+ const out = (0, import_core_node.getSplitStyles)(styles, Component.staticConfig, defaultTheme, {
303
+ focus: false,
304
+ hover: false,
305
+ mounted: false,
306
+ press: false,
307
+ pressIn: false,
308
+ resolveVariablesAs: "variable"
309
+ });
310
+ const classNames = __spreadValues({}, out.classNames);
311
+ const atomics = (0, import_core_node.getStylesAtomic)(out.style);
312
+ if (shouldPrintDebug) {
313
+ console.log("Exctacting styled()", styles, out, "to", atomics);
314
+ }
315
+ for (const atomic of atomics) {
316
+ for (const rule of atomic.rules) {
317
+ out.rulesToInsert = out.rulesToInsert || [];
318
+ out.rulesToInsert.push([atomic.identifier, rule]);
319
+ }
320
+ classNames[atomic.property] = atomic.identifier;
321
+ }
322
+ definition.properties = skipped;
323
+ for (const cn in classNames) {
324
+ if (componentSkipProps.has(cn)) {
325
+ continue;
326
+ }
327
+ const val = classNames[cn];
328
+ definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)));
329
+ }
330
+ if (out.rulesToInsert) {
331
+ for (const [identifier, rule] of out.rulesToInsert) {
332
+ onStyleRule == null ? void 0 : onStyleRule(identifier, [rule]);
333
+ }
334
+ }
335
+ res.styled++;
336
+ if (shouldPrintDebug) {
337
+ console.log(`Extracted styled(${name}) props:`, styles);
338
+ }
339
+ },
221
340
  JSXElement(traversePath) {
222
- var _a2, _b2, _c;
341
+ var _a2, _b2, _c, _d;
223
342
  tm.mark("jsx-element", shouldPrintDebug === "verbose");
224
343
  const node = traversePath.node.openingElement;
225
344
  const ogAttributes = node.attributes;
@@ -261,10 +380,7 @@ function createExtractor() {
261
380
  shouldPrintDebug = debugPropValue;
262
381
  }
263
382
  try {
264
- let isValidStyleKey = function(name) {
265
- var _a3;
266
- return !!(!!validStyles[name] || !!import_core_node.pseudos[name] || ((_a3 = staticConfig.variants) == null ? void 0 : _a3[name]) || tamaguiConfig.shorthands[name] || (name[0] === "$" ? !!import_core_node.mediaQueryConfig[name.slice(1)] : false));
267
- }, evaluateAttribute = function(path) {
383
+ let evaluateAttribute = function(path) {
268
384
  const attribute = path.node;
269
385
  const attr = { type: "attr", value: attribute };
270
386
  if (t.isJSXSpreadAttribute(attribute)) {
@@ -355,9 +471,9 @@ function createExtractor() {
355
471
  return [attribute.value, path.get("value")];
356
472
  }
357
473
  })();
358
- const remove = /* @__PURE__ */ __name(() => {
474
+ const remove = () => {
359
475
  Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
360
- }, "remove");
476
+ };
361
477
  if (name === "ref") {
362
478
  if (shouldPrintDebug) {
363
479
  console.log(" ! inlining, ref", name);
@@ -387,29 +503,39 @@ function createExtractor() {
387
503
  return attr;
388
504
  }
389
505
  const styleValue = attemptEvalSafe(value);
390
- if (!isValidStyleKey(name)) {
506
+ if (!variants[name] && !isValidStyleKey(name, staticConfig)) {
391
507
  let keys = [name];
392
508
  let out = null;
393
- if (staticConfig.propMapper) {
394
- out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, "auto");
395
- if (out) {
396
- out = import_core_node.rnw.createDOMProps(isTextView ? "span" : "div", out);
397
- delete out.className;
509
+ out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, { resolveVariablesAs: "auto" }, void 0, shouldPrintDebug);
510
+ if (out) {
511
+ if (!Array.isArray(out)) {
512
+ console.warn(`Error expected array but got`, out);
513
+ couldntParse = true;
514
+ shouldDeopt = true;
515
+ } else {
516
+ out = Object.fromEntries(out);
398
517
  keys = Object.keys(out);
399
518
  }
400
519
  }
520
+ if (out) {
521
+ if (isTargetingHTML) {
522
+ out = (0, import_core_node.createDOMProps)(isTextView ? "span" : "div", out);
523
+ delete out.className;
524
+ }
525
+ keys = Object.keys(out);
526
+ }
401
527
  let didInline = false;
402
528
  const attributes = keys.map((key) => {
403
529
  const val = out[key];
404
- if (isValidStyleKey(key)) {
530
+ if (isValidStyleKey(key, staticConfig)) {
405
531
  return {
406
532
  type: "style",
407
- value: { [name]: styleValue },
408
- name,
533
+ value: { [key]: styleValue },
534
+ name: key,
409
535
  attr: path.node
410
536
  };
411
537
  }
412
- if (import_validHTMLAttributes.validHTMLAttributes[key]) {
538
+ if (import_validHTMLAttributes.validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-")) {
413
539
  return attr;
414
540
  }
415
541
  if (shouldPrintDebug) {
@@ -428,7 +554,10 @@ function createExtractor() {
428
554
  return attributes;
429
555
  }
430
556
  if (styleValue !== import_constants.FAILED_EVAL) {
431
- if (isValidStyleKey(name)) {
557
+ if (inlineWhenUnflattened.has(name)) {
558
+ inlineWhenUnflattenedOGVals[name] = { styleValue, attr };
559
+ }
560
+ if (isValidStyleKey(name, staticConfig)) {
432
561
  if (shouldPrintDebug) {
433
562
  console.log(` style: ${name} =`, styleValue);
434
563
  }
@@ -445,6 +574,9 @@ function createExtractor() {
445
574
  attr: path.node
446
575
  };
447
576
  } else {
577
+ if (variants[name]) {
578
+ variantValues.set(name, styleValue);
579
+ }
448
580
  inlined.set(name, true);
449
581
  return attr;
450
582
  }
@@ -513,7 +645,6 @@ function createExtractor() {
513
645
  }
514
646
  return null;
515
647
  }
516
- __name(addBinaryConditional, "addBinaryConditional");
517
648
  function getStaticConditional(value2) {
518
649
  if (t.isConditionalExpression(value2)) {
519
650
  try {
@@ -537,7 +668,6 @@ function createExtractor() {
537
668
  }
538
669
  return null;
539
670
  }
540
- __name(getStaticConditional, "getStaticConditional");
541
671
  function getStaticLogical(value2) {
542
672
  if (t.isLogicalExpression(value2)) {
543
673
  if (value2.operator === "&&") {
@@ -561,7 +691,6 @@ function createExtractor() {
561
691
  }
562
692
  return null;
563
693
  }
564
- __name(getStaticLogical, "getStaticLogical");
565
694
  }, isExtractable = function(obj) {
566
695
  return t.isObjectExpression(obj) && obj.properties.every((prop) => {
567
696
  if (!t.isObjectProperty(prop)) {
@@ -569,7 +698,7 @@ function createExtractor() {
569
698
  return false;
570
699
  }
571
700
  const propName = prop.key["name"];
572
- if (!isValidStyleKey(propName) && propName !== "tag") {
701
+ if (!isValidStyleKey(propName, staticConfig) && propName !== "tag") {
573
702
  if (shouldPrintDebug) {
574
703
  console.log(" not a valid style prop!", propName);
575
704
  }
@@ -643,9 +772,10 @@ function createExtractor() {
643
772
  alternate: null
644
773
  }));
645
774
  });
646
- }, mergeStyles = function(prev2, next) {
775
+ }, mergeStyles = function(prev2, nextIn) {
776
+ const next = (0, import_core_node.expandStyles)(nextIn);
647
777
  for (const key in next) {
648
- if (import_core_node.pseudos[key]) {
778
+ if (import_core_node.pseudoDescriptors[key]) {
649
779
  prev2[key] = prev2[key] || {};
650
780
  if (shouldPrintDebug) {
651
781
  if (!next[key] || !prev2[key]) {
@@ -657,12 +787,17 @@ function createExtractor() {
657
787
  prev2[key] = next[key];
658
788
  }
659
789
  }
790
+ }, omitInvalidStyles = function(style) {
791
+ if (staticConfig.validStyles) {
792
+ for (const key in style) {
793
+ if (import_core_node.stylePropsTransform[key] || !staticConfig.validStyles[key] && !import_core_node.pseudoDescriptors[key] && !/(hoverStyle|focusStyle|pressStyle)$/.test(key)) {
794
+ if (shouldPrintDebug)
795
+ console.log(" delete invalid style", key);
796
+ delete style[key];
797
+ }
798
+ }
799
+ }
660
800
  };
661
- __name(isValidStyleKey, "isValidStyleKey");
662
- __name(evaluateAttribute, "evaluateAttribute");
663
- __name(isExtractable, "isExtractable");
664
- __name(createTernariesFromObjectProperties, "createTernariesFromObjectProperties");
665
- __name(mergeStyles, "mergeStyles");
666
801
  node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
667
802
  if (shouldPrintDebug) {
668
803
  console.log("\n");
@@ -675,17 +810,19 @@ function createExtractor() {
675
810
  }
676
811
  const shouldLog = !hasLogged;
677
812
  if (shouldLog) {
813
+ console.log(` 1\uFE0F\u20E3 Inline optimized 2\uFE0F\u20E3 Inline flattened 3\uFE0F\u20E3 styled() extracted`);
678
814
  const prefix = " |";
679
- console.log(prefixLogs || prefix, " total \xB7 optimized \xB7 flattened ");
815
+ console.log(prefixLogs || prefix, " total \xB7 1\uFE0F\u20E3 \xB7 2\uFE0F\u20E3 \xB7 3\uFE0F\u20E3");
680
816
  hasLogged = true;
681
817
  }
682
818
  if (disableExtraction) {
683
819
  return;
684
820
  }
685
821
  const { staticConfig } = component;
822
+ const variants = staticConfig.variants || {};
686
823
  const isTextView = staticConfig.isText || false;
687
824
  const validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
688
- let tagName = ((_a2 = staticConfig.defaultProps) == null ? void 0 : _a2.tag) ?? (isTextView ? "span" : "div");
825
+ let tagName = staticConfig.defaultProps.tag ?? (isTextView ? "span" : "div");
689
826
  traversePath.get("openingElement").get("attributes").forEach((path) => {
690
827
  const attr = path.node;
691
828
  if (t.isJSXSpreadAttribute(attr))
@@ -707,6 +844,7 @@ function createExtractor() {
707
844
  ...props.deoptProps || [],
708
845
  ...staticConfig.deoptProps || []
709
846
  ]);
847
+ const inlineWhenUnflattened = /* @__PURE__ */ new Set([...staticConfig.inlineWhenUnflattened || []]);
710
848
  const staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
711
849
  const attemptEval = !evaluateVars ? import_evaluateAstNode.evaluateAstNode : (0, import_createEvaluator.createEvaluator)({
712
850
  tamaguiConfig,
@@ -764,27 +902,12 @@ function createExtractor() {
764
902
  }
765
903
  tm.mark("jsx-element-flattened", shouldPrintDebug === "verbose");
766
904
  node.attributes = flattenedAttrs;
767
- if (staticConfig.defaultProps) {
768
- for (const key in staticConfig.defaultProps) {
769
- if (isValidStyleKey(key)) {
770
- continue;
771
- }
772
- const serialize = require("babel-literal-to-ast");
773
- const val = staticConfig.defaultProps[key];
774
- try {
775
- const serializedDefaultProp = serialize(val);
776
- node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier(key), typeof val === "string" ? t.stringLiteral(val) : t.jsxExpressionContainer(serializedDefaultProp)));
777
- } catch (err) {
778
- console.warn(`\u26A0\uFE0F Error evaluating default prop for component ${node.name.name}, prop ${key}
779
- error: ${err}
780
- value:`, val, "\n defaultProps:", staticConfig.defaultProps);
781
- }
782
- }
783
- }
784
905
  let attrs = [];
785
906
  let shouldDeopt = false;
786
907
  const inlined = /* @__PURE__ */ new Map();
908
+ const variantValues = /* @__PURE__ */ new Map();
787
909
  let hasSetOptimized = false;
910
+ const inlineWhenUnflattenedOGVals = {};
788
911
  attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
789
912
  try {
790
913
  const res2 = evaluateAttribute(path);
@@ -798,6 +921,7 @@ function createExtractor() {
798
921
  console.log("Error extracting attribute", err.message, err.stack);
799
922
  console.log("node", path.node);
800
923
  }
924
+ inlined.set(`${Math.random()}`, "spread");
801
925
  return {
802
926
  type: "attr",
803
927
  value: path.node
@@ -853,18 +977,30 @@ function createExtractor() {
853
977
  }, []).flat();
854
978
  const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x));
855
979
  const hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
856
- let themeVal = inlined.get("theme");
980
+ const themeVal = inlined.get("theme");
857
981
  inlined.delete("theme");
858
- const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k]);
859
- const shouldWrapThme = allOtherPropsExtractable && !!themeVal;
860
- const canFlattenProps = inlined.size === 0 || shouldWrapThme || allOtherPropsExtractable;
982
+ for (const [key] of [...inlined]) {
983
+ if (INLINE_EXTRACTABLE[key] || ((_a2 = staticConfig.variants) == null ? void 0 : _a2[key])) {
984
+ inlined.delete(key);
985
+ }
986
+ }
987
+ const canFlattenProps = inlined.size === 0;
861
988
  let shouldFlatten = !shouldDeopt && canFlattenProps && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
989
+ const shouldWrapTheme = shouldFlatten && themeVal;
990
+ if (disableExtractVariables) {
991
+ themeAccessListeners.add((key) => {
992
+ shouldFlatten = false;
993
+ if (shouldPrintDebug) {
994
+ console.log(" ! accessing theme key, avoid flatten", key);
995
+ }
996
+ });
997
+ }
862
998
  if (shouldPrintDebug) {
863
- console.log(" - flatten?", (0, import_extractHelpers.objToStr)({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapThme, allOtherPropsExtractable, hasOnlyStringChildren }));
999
+ console.log(" - flatten?", (0, import_extractHelpers.objToStr)({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapTheme, hasOnlyStringChildren }), "inlined", [...inlined]);
864
1000
  }
865
- if (shouldFlatten && shouldWrapThme) {
1001
+ if (shouldFlatten && shouldWrapTheme) {
866
1002
  if (shouldPrintDebug) {
867
- console.log(" - wrapping theme", allOtherPropsExtractable, themeVal);
1003
+ console.log(" - wrapping theme", themeVal);
868
1004
  }
869
1005
  attrs = attrs.filter((x) => x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme" ? false : true);
870
1006
  if (!hasImportedTheme) {
@@ -875,9 +1011,9 @@ function createExtractor() {
875
1011
  t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
876
1012
  ]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]));
877
1013
  }
878
- if (shouldFlatten && staticConfig.defaultProps) {
1014
+ if (shouldFlatten) {
879
1015
  const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {
880
- if (!isValidStyleKey(key)) {
1016
+ if (!isValidStyleKey(key, staticConfig)) {
881
1017
  return [];
882
1018
  }
883
1019
  const value = staticConfig.defaultProps[key];
@@ -923,14 +1059,83 @@ function createExtractor() {
923
1059
  console.log(" - attrs (flattened): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
924
1060
  console.log(" - ensureOverriden:", Object.keys(ensureOverridden).join(", "));
925
1061
  }
1062
+ const state = {
1063
+ noClassNames: false,
1064
+ focus: false,
1065
+ hover: false,
1066
+ mounted: true,
1067
+ press: false,
1068
+ pressIn: false
1069
+ };
1070
+ let foundStaticProps = {};
1071
+ for (const key in attrs) {
1072
+ const cur = attrs[key];
1073
+ if (cur.type === "style") {
1074
+ foundStaticProps = __spreadValues(__spreadValues({}, foundStaticProps), (0, import_core_node.expandStyles)(cur.value));
1075
+ continue;
1076
+ }
1077
+ if (cur.type === "attr") {
1078
+ if (t.isJSXSpreadAttribute(cur.value)) {
1079
+ continue;
1080
+ }
1081
+ if (!t.isJSXIdentifier(cur.value.name)) {
1082
+ continue;
1083
+ }
1084
+ const key2 = cur.value.name.name;
1085
+ const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
1086
+ if (value !== import_constants.FAILED_EVAL) {
1087
+ foundStaticProps = __spreadProps(__spreadValues({}, foundStaticProps), {
1088
+ [key2]: value
1089
+ });
1090
+ }
1091
+ }
1092
+ }
1093
+ const completeProps = {};
1094
+ for (const key in staticConfig.defaultProps) {
1095
+ if (!(key in foundStaticProps)) {
1096
+ completeProps[key] = staticConfig.defaultProps[key];
1097
+ }
1098
+ }
1099
+ for (const key in foundStaticProps) {
1100
+ completeProps[key] = foundStaticProps[key];
1101
+ }
926
1102
  attrs = attrs.reduce((acc, cur) => {
927
- if (!cur) {
1103
+ if (!cur)
928
1104
  return acc;
929
- }
930
1105
  if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value)) {
931
1106
  if (shouldFlatten) {
932
- if (cur.value.name.name === "tag") {
933
- return acc;
1107
+ const name = cur.value.name.name;
1108
+ if (typeof name === "string") {
1109
+ if (name === "tag") {
1110
+ return acc;
1111
+ }
1112
+ if (variants[name] && variantValues.has(name)) {
1113
+ let out = Object.fromEntries(staticConfig.propMapper(name, variantValues.get(name), defaultTheme, completeProps, __spreadProps(__spreadValues({}, state), { resolveVariablesAs: "auto" }), void 0, shouldPrintDebug) || []);
1114
+ if (out && isTargetingHTML) {
1115
+ const cn = out.className;
1116
+ out = (0, import_core_node.createDOMProps)(isTextView ? "span" : "div", out);
1117
+ out.className = cn;
1118
+ }
1119
+ if (shouldPrintDebug) {
1120
+ console.log(" - expanded variant", name, out);
1121
+ }
1122
+ for (const key2 in out) {
1123
+ const value2 = out[key2];
1124
+ if (isValidStyleKey(key2, staticConfig)) {
1125
+ acc.push({
1126
+ type: "style",
1127
+ value: { [key2]: value2 },
1128
+ name: key2,
1129
+ attr: cur.value
1130
+ });
1131
+ } else {
1132
+ acc.push({
1133
+ type: "attr",
1134
+ value: t.jsxAttribute(t.jsxIdentifier(key2), t.jsxExpressionContainer(typeof value2 === "string" ? t.stringLiteral(value2) : (0, import_literalToAst.literalToAst)(value2)))
1135
+ });
1136
+ }
1137
+ }
1138
+ }
934
1139
  }
935
1140
  }
936
1141
  }
@@ -969,7 +1174,7 @@ function createExtractor() {
969
1174
  if (cur.type === "style") {
970
1175
  const key = Object.keys(cur.value)[0];
971
1176
  const value = cur.value[key];
972
- const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !import_core_node.pseudos[key] && !key.startsWith("data-");
1177
+ const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !import_core_node.pseudoDescriptors[key] && !key.startsWith("data-");
973
1178
  if (shouldKeepOriginalAttr) {
974
1179
  if (shouldPrintDebug) {
975
1180
  console.log(" - keeping as non-style", key);
@@ -997,43 +1202,13 @@ function createExtractor() {
997
1202
  acc.push(cur);
998
1203
  return acc;
999
1204
  }, []);
1000
- const state = {
1001
- noClassNames: true,
1002
- focus: false,
1003
- hover: false,
1004
- mounted: true,
1005
- press: false,
1006
- pressIn: false
1007
- };
1008
- const completeStaticProps = Object.keys(attrs).reduce((acc, index) => {
1009
- const cur = attrs[index];
1010
- if (cur.type === "style") {
1011
- (0, import_core_node.normalizeStyleObject)(cur.value);
1012
- Object.assign(acc, cur.value);
1013
- }
1014
- if (cur.type === "attr") {
1015
- if (t.isJSXSpreadAttribute(cur.value)) {
1016
- return acc;
1017
- }
1018
- if (!t.isJSXIdentifier(cur.value.name)) {
1019
- return acc;
1020
- }
1021
- const key = cur.value.name.name;
1022
- const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
1023
- if (value === import_constants.FAILED_EVAL) {
1024
- return acc;
1025
- }
1026
- acc[key] = value;
1027
- }
1028
- return acc;
1029
- }, {});
1030
- const completeProps = __spreadValues(__spreadValues({}, staticConfig.defaultProps), completeStaticProps);
1031
1205
  if (shouldPrintDebug) {
1032
1206
  console.log(" - attrs (combined \u{1F500}): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
1033
1207
  console.log(" - defaultProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(staticConfig.defaultProps)));
1034
- console.log(" - completeStaticProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeStaticProps)));
1208
+ console.log(" - foundStaticProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(foundStaticProps)));
1209
+ console.log(" - completeProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeProps)));
1035
1210
  }
1036
- const getStyles = /* @__PURE__ */ __name((props2, debugName = "") => {
1211
+ const getStyles = (props2, debugName = "") => {
1037
1212
  if (!props2 || !Object.keys(props2).length) {
1038
1213
  if (shouldPrintDebug)
1039
1214
  console.log(" getStyles() no props");
@@ -1051,38 +1226,21 @@ function createExtractor() {
1051
1226
  try {
1052
1227
  const out = (0, import_core_node.getSplitStyles)(props2, staticConfig, defaultTheme, __spreadProps(__spreadValues({}, state), {
1053
1228
  fallbackProps: completeProps
1054
- }));
1229
+ }), void 0, props2["debug"]);
1055
1230
  const outStyle = __spreadValues(__spreadValues({}, out.style), out.pseudos);
1056
- if (staticConfig.validStyles) {
1057
- for (const key in outStyle) {
1058
- if (!staticConfig.validStyles[key] && !import_core_node.pseudos[key] && !/(hover|focus|press)Style$/.test(key)) {
1059
- if (shouldPrintDebug)
1060
- console.log(" delete invalid style", key);
1061
- delete outStyle[key];
1062
- }
1063
- }
1064
- }
1065
- if (shouldPrintDebug) {
1066
- console.log(` getStyles ${debugName} (props):
1067
- `, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(props2)));
1068
- console.log(` getStyles ${debugName} (out.viewProps):
1069
- `, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(out.viewProps)));
1070
- console.log(` getStyles ${debugName} (out.style):
1071
- `, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(outStyle || {}), true));
1072
- }
1073
1231
  return outStyle;
1074
1232
  } catch (err) {
1075
1233
  console.log("error", err.message, err.stack);
1076
1234
  return {};
1077
1235
  }
1078
- }, "getStyles");
1079
- const completeStylesProcessed = getStyles(completeProps, "completeStylesProcessed");
1080
- if (!completeStylesProcessed) {
1236
+ };
1237
+ const completeStyles = getStyles(completeProps, "completeStyles");
1238
+ if (!completeStyles) {
1081
1239
  throw new Error(`Impossible, no styles`);
1082
1240
  }
1083
- const stylesToAddToInitialGroup = shouldFlatten ? (0, import_lodash.difference)(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps)) : [];
1084
- if (stylesToAddToInitialGroup.length) {
1085
- const toAdd = (0, import_lodash.pick)(completeStylesProcessed, ...stylesToAddToInitialGroup);
1241
+ const addInitialStyleKeys = shouldFlatten ? (0, import_lodash.difference)(Object.keys(completeStyles), Object.keys(foundStaticProps)) : [];
1242
+ if (addInitialStyleKeys.length) {
1243
+ const toAdd = (0, import_lodash.pick)(completeStyles, ...addInitialStyleKeys);
1086
1244
  const firstGroup = attrs.find((x) => x.type === "style");
1087
1245
  if (shouldPrintDebug) {
1088
1246
  console.log(" toAdd", (0, import_extractHelpers.objToStr)(toAdd));
@@ -1090,19 +1248,17 @@ function createExtractor() {
1090
1248
  if (!firstGroup) {
1091
1249
  attrs.unshift({ type: "style", value: toAdd });
1092
1250
  } else {
1251
+ omitInvalidStyles(firstGroup.value);
1093
1252
  Object.assign(firstGroup.value, toAdd);
1094
1253
  }
1095
1254
  }
1096
1255
  if (shouldPrintDebug) {
1097
- console.log(" -- stylesToAddToInitialGroup", stylesToAddToInitialGroup.join(", "), { shouldFlatten });
1098
- console.log(" -- completeStaticProps:\n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeStaticProps)));
1099
- console.log(" -- completeStylesProcessed:\n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeStylesProcessed)));
1256
+ if (shouldFlatten)
1257
+ console.log(" -- addInitialStyleKeys", addInitialStyleKeys.join(", "));
1100
1258
  }
1101
1259
  let getStyleError = null;
1102
1260
  for (const attr of attrs) {
1103
1261
  try {
1104
- if (shouldPrintDebug)
1105
- console.log(" *", (0, import_extractHelpers.attrStr)(attr));
1106
1262
  switch (attr.type) {
1107
1263
  case "ternary":
1108
1264
  const a = getStyles(attr.value.alternate, "ternary.alternate");
@@ -1115,20 +1271,23 @@ function createExtractor() {
1115
1271
  console.log(" => tern ", (0, import_extractHelpers.attrStr)(attr));
1116
1272
  continue;
1117
1273
  case "style":
1118
- if (shouldPrintDebug)
1119
- console.log(" * styles in", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(attr.value)));
1120
1274
  const styles = getStyles(attr.value, "style");
1121
- if (shouldPrintDebug)
1122
- console.log(" * styles out", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(styles)));
1123
1275
  if (styles) {
1124
- attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStylesProcessed[k]]));
1276
+ attr.value = styles;
1125
1277
  }
1278
+ if (shouldPrintDebug)
1279
+ console.log(" * styles (in)", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(attr.value)));
1280
+ if (shouldPrintDebug)
1281
+ console.log(" * styles (out)", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(styles)));
1126
1282
  continue;
1127
1283
  }
1128
1284
  } catch (err) {
1129
1285
  getStyleError = err;
1130
1286
  }
1131
1287
  }
1288
+ if (shouldPrintDebug) {
1289
+ console.log(" - attrs (ternaries/combined):\n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
1290
+ }
1132
1291
  tm.mark("jsx-element-styles", shouldPrintDebug === "verbose");
1133
1292
  if (getStyleError) {
1134
1293
  console.log(" \u26A0\uFE0F postprocessing error, deopt", getStyleError);
@@ -1138,7 +1297,7 @@ function createExtractor() {
1138
1297
  const existingStyleKeys = /* @__PURE__ */ new Set();
1139
1298
  for (let i = attrs.length - 1; i >= 0; i--) {
1140
1299
  const attr = attrs[i];
1141
- if (shouldFlatten && canFlattenProps) {
1300
+ if (shouldFlatten) {
1142
1301
  if (attr.type === "attr") {
1143
1302
  if (t.isJSXAttribute(attr.value)) {
1144
1303
  if (t.isJSXIdentifier(attr.value.name)) {
@@ -1146,6 +1305,9 @@ function createExtractor() {
1146
1305
  if (INLINE_EXTRACTABLE[name]) {
1147
1306
  attr.value.name.name = INLINE_EXTRACTABLE[name];
1148
1307
  }
1308
+ if ((_d = staticConfig.variants) == null ? void 0 : _d[name]) {
1309
+ const expanded = getStyles({});
1310
+ }
1149
1311
  }
1150
1312
  }
1151
1313
  }
@@ -1163,6 +1325,21 @@ function createExtractor() {
1163
1325
  }
1164
1326
  }
1165
1327
  }
1328
+ if (!shouldFlatten) {
1329
+ if (Object.keys(inlineWhenUnflattenedOGVals).length) {
1330
+ for (const [index, attr] of attrs.entries()) {
1331
+ if (attr.type === "style") {
1332
+ for (const key in attr.value) {
1333
+ const val = inlineWhenUnflattenedOGVals[key];
1334
+ if (val) {
1335
+ delete attr.value[key];
1336
+ attrs.splice(index - 1, 0, val.attr);
1337
+ }
1338
+ }
1339
+ }
1340
+ }
1341
+ }
1342
+ }
1166
1343
  if (shouldFlatten) {
1167
1344
  if (shouldPrintDebug) {
1168
1345
  console.log(" [\u2705] flattening", originalNodeName, flatNode);
@@ -1188,8 +1365,6 @@ function createExtractor() {
1188
1365
  isFlattened: shouldFlatten,
1189
1366
  programPath
1190
1367
  });
1191
- } catch (err) {
1192
- throw err;
1193
1368
  } finally {
1194
1369
  if (debugPropValue) {
1195
1370
  shouldPrintDebug = ogDebug;
@@ -1212,7 +1387,6 @@ function createExtractor() {
1212
1387
  }
1213
1388
  };
1214
1389
  }
1215
- __name(createExtractor, "createExtractor");
1216
1390
  // Annotate the CommonJS export names for ESM import in node:
1217
1391
  0 && (module.exports = {
1218
1392
  createExtractor