@tamagui/static 1.0.0-beta.8 → 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 (244) hide show
  1. package/dist/cjs/extractor/accessSafe.js +0 -2
  2. package/dist/cjs/extractor/accessSafe.js.map +1 -1
  3. package/dist/cjs/extractor/babelParse.js +15 -16
  4. package/dist/cjs/extractor/babelParse.js.map +2 -2
  5. package/dist/cjs/extractor/buildClassName.js +0 -2
  6. package/dist/cjs/extractor/buildClassName.js.map +1 -1
  7. package/dist/cjs/extractor/createEvaluator.js +9 -7
  8. package/dist/cjs/extractor/createEvaluator.js.map +2 -2
  9. package/dist/cjs/extractor/createExtractor.js +318 -145
  10. package/dist/cjs/extractor/createExtractor.js.map +2 -2
  11. package/dist/cjs/extractor/ensureImportingConcat.js +0 -2
  12. package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -1
  13. package/dist/cjs/extractor/evaluateAstNode.js +0 -2
  14. package/dist/cjs/extractor/evaluateAstNode.js.map +1 -1
  15. package/dist/cjs/extractor/extractHelpers.js +11 -16
  16. package/dist/cjs/extractor/extractHelpers.js.map +1 -1
  17. package/dist/cjs/extractor/extractMediaStyle.js +3 -8
  18. package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
  19. package/dist/cjs/extractor/extractToClassNames.js +27 -42
  20. package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
  21. package/dist/cjs/extractor/findTopmostFunction.js +1 -3
  22. package/dist/cjs/extractor/findTopmostFunction.js.map +1 -1
  23. package/dist/cjs/extractor/generatedUid.js +0 -2
  24. package/dist/cjs/extractor/generatedUid.js.map +1 -1
  25. package/dist/cjs/extractor/getPrefixLogs.js +0 -2
  26. package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
  27. package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -2
  28. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -1
  29. package/dist/cjs/extractor/getSourceModule.js +0 -2
  30. package/dist/cjs/extractor/getSourceModule.js.map +1 -1
  31. package/dist/cjs/extractor/getStaticBindingsForScope.js +1 -5
  32. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -1
  33. package/dist/cjs/extractor/hoistClassNames.js +0 -3
  34. package/dist/cjs/extractor/hoistClassNames.js.map +1 -1
  35. package/dist/cjs/extractor/literalToAst.js +0 -4
  36. package/dist/cjs/extractor/literalToAst.js.map +1 -1
  37. package/dist/cjs/extractor/loadTamagui.js +43 -10
  38. package/dist/cjs/extractor/loadTamagui.js.map +2 -2
  39. package/dist/cjs/extractor/logLines.js +2 -3
  40. package/dist/cjs/extractor/logLines.js.map +1 -1
  41. package/dist/cjs/extractor/normalizeTernaries.js +0 -2
  42. package/dist/cjs/extractor/normalizeTernaries.js.map +1 -1
  43. package/dist/cjs/extractor/removeUnusedHooks.js +2 -4
  44. package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
  45. package/dist/cjs/extractor/timer.js +2 -3
  46. package/dist/cjs/extractor/timer.js.map +1 -1
  47. package/dist/cjs/extractor/validHTMLAttributes.js +51 -0
  48. package/dist/cjs/extractor/validHTMLAttributes.js.map +2 -2
  49. package/dist/cjs/index.js +2 -1
  50. package/dist/cjs/index.js.map +2 -2
  51. package/dist/cjs/types.js.map +1 -1
  52. package/dist/esm/extractor/accessSafe.js +0 -3
  53. package/dist/esm/extractor/accessSafe.js.map +1 -1
  54. package/dist/esm/extractor/babelParse.js +15 -17
  55. package/dist/esm/extractor/babelParse.js.map +2 -2
  56. package/dist/esm/extractor/buildClassName.js +0 -3
  57. package/dist/esm/extractor/buildClassName.js.map +1 -1
  58. package/dist/esm/extractor/createEvaluator.js +9 -8
  59. package/dist/esm/extractor/createEvaluator.js.map +2 -2
  60. package/dist/esm/extractor/createExtractor.js +405 -195
  61. package/dist/esm/extractor/createExtractor.js.map +2 -2
  62. package/dist/esm/extractor/ensureImportingConcat.js +0 -3
  63. package/dist/esm/extractor/ensureImportingConcat.js.map +1 -1
  64. package/dist/esm/extractor/evaluateAstNode.js +0 -3
  65. package/dist/esm/extractor/evaluateAstNode.js.map +1 -1
  66. package/dist/esm/extractor/extractHelpers.js +11 -17
  67. package/dist/esm/extractor/extractHelpers.js.map +1 -1
  68. package/dist/esm/extractor/extractMediaStyle.js +29 -20
  69. package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
  70. package/dist/esm/extractor/extractToClassNames.js +53 -52
  71. package/dist/esm/extractor/extractToClassNames.js.map +2 -2
  72. package/dist/esm/extractor/findTopmostFunction.js +1 -4
  73. package/dist/esm/extractor/findTopmostFunction.js.map +1 -1
  74. package/dist/esm/extractor/generatedUid.js +0 -3
  75. package/dist/esm/extractor/generatedUid.js.map +1 -1
  76. package/dist/esm/extractor/getPrefixLogs.js +1 -5
  77. package/dist/esm/extractor/getPrefixLogs.js.map +1 -1
  78. package/dist/esm/extractor/getPropValueFromAttributes.js +0 -3
  79. package/dist/esm/extractor/getPropValueFromAttributes.js.map +1 -1
  80. package/dist/esm/extractor/getSourceModule.js +0 -3
  81. package/dist/esm/extractor/getSourceModule.js.map +1 -1
  82. package/dist/esm/extractor/getStaticBindingsForScope.js +1 -6
  83. package/dist/esm/extractor/getStaticBindingsForScope.js.map +1 -1
  84. package/dist/esm/extractor/hoistClassNames.js +0 -4
  85. package/dist/esm/extractor/hoistClassNames.js.map +1 -1
  86. package/dist/esm/extractor/literalToAst.js +21 -11
  87. package/dist/esm/extractor/literalToAst.js.map +1 -1
  88. package/dist/esm/extractor/loadTamagui.js +44 -11
  89. package/dist/esm/extractor/loadTamagui.js.map +2 -2
  90. package/dist/esm/extractor/logLines.js +2 -4
  91. package/dist/esm/extractor/logLines.js.map +1 -1
  92. package/dist/esm/extractor/normalizeTernaries.js +35 -9
  93. package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
  94. package/dist/esm/extractor/removeUnusedHooks.js +5 -9
  95. package/dist/esm/extractor/removeUnusedHooks.js.map +1 -1
  96. package/dist/esm/extractor/timer.js +2 -4
  97. package/dist/esm/extractor/timer.js.map +1 -1
  98. package/dist/esm/extractor/validHTMLAttributes.js +50 -0
  99. package/dist/esm/extractor/validHTMLAttributes.js.map +2 -2
  100. package/dist/esm/index.js +2 -1
  101. package/dist/esm/index.js.map +2 -2
  102. package/dist/jsx/constants.js +1 -0
  103. package/dist/jsx/constants.js.map +7 -0
  104. package/dist/jsx/extractor/accessSafe.js +1 -3
  105. package/dist/jsx/extractor/accessSafe.js.map +7 -0
  106. package/dist/jsx/extractor/babelParse.js +16 -17
  107. package/dist/jsx/extractor/babelParse.js.map +7 -0
  108. package/dist/jsx/extractor/buildClassName.js +1 -3
  109. package/dist/jsx/extractor/buildClassName.js.map +7 -0
  110. package/dist/jsx/extractor/createEvaluator.js +10 -8
  111. package/dist/jsx/extractor/createEvaluator.js.map +7 -0
  112. package/dist/jsx/extractor/createExtractor.js +325 -150
  113. package/dist/jsx/extractor/createExtractor.js.map +7 -0
  114. package/dist/jsx/extractor/ensureImportingConcat.js +1 -3
  115. package/dist/jsx/extractor/ensureImportingConcat.js.map +7 -0
  116. package/dist/jsx/extractor/evaluateAstNode.js +1 -3
  117. package/dist/jsx/extractor/evaluateAstNode.js.map +7 -0
  118. package/dist/jsx/extractor/extractHelpers.js +12 -17
  119. package/dist/jsx/extractor/extractHelpers.js.map +7 -0
  120. package/dist/jsx/extractor/extractMediaStyle.js +4 -9
  121. package/dist/jsx/extractor/extractMediaStyle.js.map +7 -0
  122. package/dist/jsx/extractor/extractToClassNames.js +31 -43
  123. package/dist/jsx/extractor/extractToClassNames.js.map +7 -0
  124. package/dist/jsx/extractor/findTopmostFunction.js +2 -4
  125. package/dist/jsx/extractor/findTopmostFunction.js.map +7 -0
  126. package/dist/jsx/extractor/generatedUid.js +1 -3
  127. package/dist/jsx/extractor/generatedUid.js.map +7 -0
  128. package/dist/jsx/extractor/getPrefixLogs.js +1 -3
  129. package/dist/jsx/extractor/getPrefixLogs.js.map +7 -0
  130. package/dist/jsx/extractor/getPropValueFromAttributes.js +1 -3
  131. package/dist/jsx/extractor/getPropValueFromAttributes.js.map +7 -0
  132. package/dist/jsx/extractor/getSourceModule.js +1 -3
  133. package/dist/jsx/extractor/getSourceModule.js.map +7 -0
  134. package/dist/jsx/extractor/getStaticBindingsForScope.js +2 -6
  135. package/dist/jsx/extractor/getStaticBindingsForScope.js.map +7 -0
  136. package/dist/jsx/extractor/hoistClassNames.js +1 -4
  137. package/dist/jsx/extractor/hoistClassNames.js.map +7 -0
  138. package/dist/jsx/extractor/literalToAst.js +1 -5
  139. package/dist/jsx/extractor/literalToAst.js.map +7 -0
  140. package/dist/jsx/extractor/loadTamagui.js +30 -11
  141. package/dist/jsx/extractor/loadTamagui.js.map +7 -0
  142. package/dist/jsx/extractor/logLines.js +3 -4
  143. package/dist/jsx/extractor/logLines.js.map +7 -0
  144. package/dist/jsx/extractor/normalizeTernaries.js +1 -3
  145. package/dist/jsx/extractor/normalizeTernaries.js.map +7 -0
  146. package/dist/jsx/extractor/removeUnusedHooks.js +3 -5
  147. package/dist/jsx/extractor/removeUnusedHooks.js.map +7 -0
  148. package/dist/jsx/extractor/timer.js +3 -4
  149. package/dist/jsx/extractor/timer.js.map +7 -0
  150. package/dist/jsx/extractor/validHTMLAttributes.js +51 -0
  151. package/dist/jsx/extractor/validHTMLAttributes.js.map +7 -0
  152. package/dist/jsx/index.js +3 -1
  153. package/dist/jsx/index.js.map +7 -0
  154. package/dist/jsx/types.js +1 -0
  155. package/dist/jsx/types.js.map +7 -0
  156. package/package.json +27 -19
  157. package/src/constants.ts +13 -0
  158. package/src/extractor/accessSafe.ts +18 -0
  159. package/src/extractor/babelParse.ts +27 -0
  160. package/src/extractor/buildClassName.ts +61 -0
  161. package/src/extractor/createEvaluator.ts +75 -0
  162. package/src/extractor/createExtractor.ts +1928 -0
  163. package/src/extractor/ensureImportingConcat.ts +39 -0
  164. package/src/extractor/evaluateAstNode.ts +121 -0
  165. package/src/extractor/extractHelpers.ts +119 -0
  166. package/src/extractor/extractMediaStyle.ts +192 -0
  167. package/src/extractor/extractToClassNames.ts +393 -0
  168. package/src/extractor/findTopmostFunction.ts +22 -0
  169. package/src/extractor/generatedUid.ts +43 -0
  170. package/src/extractor/getPrefixLogs.ts +6 -0
  171. package/src/extractor/getPropValueFromAttributes.ts +92 -0
  172. package/src/extractor/getSourceModule.ts +101 -0
  173. package/src/extractor/getStaticBindingsForScope.ts +183 -0
  174. package/src/extractor/hoistClassNames.ts +45 -0
  175. package/src/extractor/literalToAst.ts +84 -0
  176. package/src/extractor/loadTamagui.ts +145 -0
  177. package/src/extractor/logLines.ts +16 -0
  178. package/src/extractor/normalizeTernaries.ts +63 -0
  179. package/src/extractor/removeUnusedHooks.ts +76 -0
  180. package/src/extractor/timer.ts +18 -0
  181. package/src/extractor/validHTMLAttributes.ts +99 -0
  182. package/src/index.ts +10 -0
  183. package/src/types.ts +96 -0
  184. package/types/extractor/buildClassName.d.ts +0 -0
  185. package/types/extractor/buildClassName.d.ts.map +0 -0
  186. package/types/extractor/createEvaluator.d.ts +1 -1
  187. package/types/extractor/createEvaluator.d.ts.map +1 -1
  188. package/types/extractor/createExtractor.d.ts +3 -4
  189. package/types/extractor/createExtractor.d.ts.map +1 -1
  190. package/types/extractor/extractHelpers.d.ts +1 -1
  191. package/types/extractor/extractHelpers.d.ts.map +1 -1
  192. package/types/extractor/extractMediaStyle.d.ts +0 -0
  193. package/types/extractor/extractMediaStyle.d.ts.map +1 -1
  194. package/types/extractor/extractToClassNames.d.ts +1 -6
  195. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  196. package/types/extractor/getPrefixLogs.d.ts +0 -0
  197. package/types/extractor/getPrefixLogs.d.ts.map +0 -0
  198. package/types/extractor/loadTamagui.d.ts +10 -4
  199. package/types/extractor/loadTamagui.d.ts.map +1 -1
  200. package/types/extractor/normalizeTernaries.d.ts +0 -0
  201. package/types/extractor/normalizeTernaries.d.ts.map +0 -0
  202. package/types/index.d.ts +2 -1
  203. package/types/index.d.ts.map +1 -1
  204. package/types/types.d.ts +6 -7
  205. package/types/types.d.ts.map +1 -1
  206. package/dist/cjs/patchReactNativeWeb.js +0 -167
  207. package/dist/cjs/patchReactNativeWeb.js.map +0 -7
  208. package/dist/esm/patchReactNativeWeb.js +0 -142
  209. package/dist/esm/patchReactNativeWeb.js.map +0 -7
  210. package/dist/jsx/patchReactNativeWeb.js +0 -141
  211. package/types/constants.d.ts +0 -6
  212. package/types/constants.d.ts.map +0 -1
  213. package/types/extractor/accessSafe.d.ts +0 -3
  214. package/types/extractor/accessSafe.d.ts.map +0 -1
  215. package/types/extractor/babelParse.d.ts +0 -5
  216. package/types/extractor/babelParse.d.ts.map +0 -1
  217. package/types/extractor/ensureImportingConcat.d.ts +0 -4
  218. package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
  219. package/types/extractor/evaluateAstNode.d.ts +0 -3
  220. package/types/extractor/evaluateAstNode.d.ts.map +0 -1
  221. package/types/extractor/findTopmostFunction.d.ts +0 -4
  222. package/types/extractor/findTopmostFunction.d.ts.map +0 -1
  223. package/types/extractor/generatedUid.d.ts +0 -5
  224. package/types/extractor/generatedUid.d.ts.map +0 -1
  225. package/types/extractor/getPropValueFromAttributes.d.ts +0 -3
  226. package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
  227. package/types/extractor/getSourceModule.d.ts +0 -16
  228. package/types/extractor/getSourceModule.d.ts.map +0 -1
  229. package/types/extractor/getStaticBindingsForScope.d.ts +0 -4
  230. package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
  231. package/types/extractor/hoistClassNames.d.ts +0 -6
  232. package/types/extractor/hoistClassNames.d.ts.map +0 -1
  233. package/types/extractor/literalToAst.d.ts +0 -4
  234. package/types/extractor/literalToAst.d.ts.map +0 -1
  235. package/types/extractor/logLines.d.ts +0 -2
  236. package/types/extractor/logLines.d.ts.map +0 -1
  237. package/types/extractor/removeUnusedHooks.d.ts +0 -3
  238. package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
  239. package/types/extractor/timer.d.ts +0 -5
  240. package/types/extractor/timer.d.ts.map +0 -1
  241. package/types/extractor/validHTMLAttributes.d.ts +0 -49
  242. package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
  243. package/types/patchReactNativeWeb.d.ts +0 -2
  244. package/types/patchReactNativeWeb.d.ts.map +0 -1
@@ -1,15 +1,15 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  import { relative } from "path";
4
2
  import traverse from "@babel/traverse";
5
3
  import * as t from "@babel/types";
6
4
  import {
5
+ createDOMProps,
6
+ expandStyles,
7
7
  getSplitStyles,
8
+ getStylesAtomic,
8
9
  mediaQueryConfig,
9
- normalizeStyleObject,
10
10
  proxyThemeVariables,
11
- pseudos,
12
- rnw
11
+ pseudoDescriptors,
12
+ stylePropsTransform
13
13
  } from "@tamagui/core-node";
14
14
  import { difference, pick } from "lodash";
15
15
  import { FAILED_EVAL } from "../constants";
@@ -39,12 +39,12 @@ const INLINE_EXTRACTABLE = {
39
39
  onPressIn: "onMouseDown",
40
40
  onPressOut: "onMouseUp"
41
41
  };
42
- const isAttr = /* @__PURE__ */ __name((x) => x.type === "attr", "isAttr");
42
+ const isAttr = (x) => x.type === "attr";
43
43
  const validHooks = {
44
44
  useMedia: true,
45
45
  useTheme: true
46
46
  };
47
- const createTernary = /* @__PURE__ */ __name((x) => x, "createTernary");
47
+ const createTernary = (x) => x;
48
48
  function createExtractor() {
49
49
  if (!process.env.TAMAGUI_TARGET) {
50
50
  console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either "web" or "native"');
@@ -53,6 +53,10 @@ function createExtractor() {
53
53
  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);
54
54
  let loadedTamaguiConfig;
55
55
  let hasLogged = false;
56
+ function isValidStyleKey(name, staticConfig) {
57
+ var _a, _b;
58
+ return !!(!!((_a = staticConfig.validStyles) == null ? void 0 : _a[name]) || !!pseudoDescriptors[name] || ((_b = staticConfig.variants) == null ? void 0 : _b[name]) || loadedTamaguiConfig.shorthands[name] || (name[0] === "$" ? !!mediaQueryConfig[name.slice(1)] : false));
59
+ }
56
60
  return {
57
61
  getTamagui() {
58
62
  return loadedTamaguiConfig;
@@ -64,14 +68,17 @@ function createExtractor() {
64
68
  shouldPrintDebug = false,
65
69
  sourcePath = "",
66
70
  onExtractTag,
71
+ onStyleRule,
67
72
  getFlattenedNode,
68
73
  disable,
69
74
  disableExtraction,
70
75
  disableExtractInlineMedia,
71
76
  disableExtractVariables,
72
77
  disableDebugAttr,
78
+ extractStyledDefinitions = false,
73
79
  prefixLogs,
74
80
  excludeProps,
81
+ target,
75
82
  ...props
76
83
  }) => {
77
84
  if (disable) {
@@ -83,6 +90,7 @@ function createExtractor() {
83
90
  if (!Array.isArray(props.components)) {
84
91
  throw new Error(`Must provide components array with list of Tamagui component modules`);
85
92
  }
93
+ const isTargetingHTML = target === "html";
86
94
  const ogDebug = shouldPrintDebug;
87
95
  const tm = timer();
88
96
  const { components, tamaguiConfig } = loadTamagui({
@@ -94,11 +102,20 @@ function createExtractor() {
94
102
  }
95
103
  tm.mark("load-tamagui", shouldPrintDebug === "verbose");
96
104
  loadedTamaguiConfig = tamaguiConfig;
97
- const defaultTheme = proxyThemeVariables(tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]);
105
+ const proxiedTheme = proxyThemeVariables(tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]);
106
+ const themeAccessListeners = /* @__PURE__ */ new Set();
107
+ const defaultTheme = new Proxy(proxiedTheme, {
108
+ get(target2, key) {
109
+ if (key[0] === "$") {
110
+ themeAccessListeners.forEach((cb) => cb(String(key)));
111
+ }
112
+ return Reflect.get(target2, key);
113
+ }
114
+ });
98
115
  const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
99
- const isInternalImport = /* @__PURE__ */ __name((importStr) => {
116
+ const isInternalImport = (importStr) => {
100
117
  return isInsideTamagui(sourcePath) && importStr[0] === ".";
101
- }, "isInternalImport");
118
+ };
102
119
  const validComponents = Object.keys(components).filter((key) => {
103
120
  var _a;
104
121
  return key[0].toUpperCase() === key[0] && !!((_a = components[key]) == null ? void 0 : _a.staticConfig);
@@ -116,11 +133,21 @@ function createExtractor() {
116
133
  continue;
117
134
  const node = "node" in bodyPath ? bodyPath.node : bodyPath;
118
135
  const from = node.source.value;
136
+ if (extractStyledDefinitions) {
137
+ if (from === "@tamagui/core" || from === "tamagui") {
138
+ if (node.specifiers.some((specifier) => {
139
+ return specifier.local.name === "styled";
140
+ })) {
141
+ doesUseValidImport = true;
142
+ break;
143
+ }
144
+ }
145
+ }
119
146
  const isValidImport = props.components.includes(from) || isInternalImport(from);
120
147
  if (isValidImport) {
121
148
  const isValidComponent = node.specifiers.some((specifier) => {
122
149
  const name = specifier.local.name;
123
- return validComponents[name] || validHooks[name];
150
+ return !!(validComponents[name] || validHooks[name]);
124
151
  });
125
152
  if (shouldPrintDebug === "verbose") {
126
153
  console.log("import from", from, { isValidComponent });
@@ -141,11 +168,12 @@ function createExtractor() {
141
168
  let couldntParse = false;
142
169
  const modifiedComponents = /* @__PURE__ */ new Set();
143
170
  const bindingCache = {};
144
- const callTraverse = /* @__PURE__ */ __name((a) => {
171
+ const callTraverse = (a) => {
145
172
  return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
146
- }, "callTraverse");
173
+ };
147
174
  let programPath;
148
175
  const res = {
176
+ styled: 0,
149
177
  flattened: 0,
150
178
  optimized: 0,
151
179
  modified: 0,
@@ -157,8 +185,99 @@ function createExtractor() {
157
185
  programPath = path;
158
186
  }
159
187
  },
188
+ CallExpression(path) {
189
+ var _a;
190
+ if (disable || disableExtraction || extractStyledDefinitions === false) {
191
+ return;
192
+ }
193
+ if (!t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled") {
194
+ return;
195
+ }
196
+ const name = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown";
197
+ const definition = path.node.arguments[1];
198
+ if (!name || !definition || !t.isObjectExpression(definition)) {
199
+ return;
200
+ }
201
+ const Component = validComponents[name];
202
+ if (!Component) {
203
+ if (shouldPrintDebug) {
204
+ console.log(`Didn't recognize styled(${name}), ${name} isn't in design system provided to tamagui.config.ts`);
205
+ }
206
+ return;
207
+ }
208
+ const componentSkipProps = /* @__PURE__ */ new Set([
209
+ ...Component.staticConfig.inlineWhenUnflattened || [],
210
+ ...Component.staticConfig.inlineProps || [],
211
+ ...Component.staticConfig.deoptProps || [],
212
+ "variants",
213
+ "defaultVariants",
214
+ "fontFamily",
215
+ "name"
216
+ ]);
217
+ const skipped = [];
218
+ const styles = {};
219
+ const staticNamespace = getStaticBindingsForScope(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
220
+ const attemptEval = !evaluateVars ? evaluateAstNode : createEvaluator({
221
+ tamaguiConfig,
222
+ staticNamespace,
223
+ sourcePath,
224
+ shouldPrintDebug
225
+ });
226
+ const attemptEvalSafe = createSafeEvaluator(attemptEval);
227
+ for (const property of definition.properties) {
228
+ if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || ((_a = Component.staticConfig.variants) == null ? void 0 : _a[property.key.name]) || componentSkipProps.has(property.key.name)) {
229
+ skipped.push(property);
230
+ continue;
231
+ }
232
+ const out2 = attemptEvalSafe(property.value);
233
+ if (out2 === FAILED_EVAL) {
234
+ skipped.push(property);
235
+ } else {
236
+ styles[property.key.name] = out2;
237
+ }
238
+ }
239
+ const out = getSplitStyles(styles, Component.staticConfig, defaultTheme, {
240
+ focus: false,
241
+ hover: false,
242
+ mounted: false,
243
+ press: false,
244
+ pressIn: false,
245
+ resolveVariablesAs: "variable"
246
+ });
247
+ const classNames = {
248
+ ...out.classNames
249
+ };
250
+ const atomics = getStylesAtomic(out.style);
251
+ if (shouldPrintDebug) {
252
+ console.log("Exctacting styled()", styles, out, "to", atomics);
253
+ }
254
+ for (const atomic of atomics) {
255
+ for (const rule of atomic.rules) {
256
+ out.rulesToInsert = out.rulesToInsert || [];
257
+ out.rulesToInsert.push([atomic.identifier, rule]);
258
+ }
259
+ classNames[atomic.property] = atomic.identifier;
260
+ }
261
+ definition.properties = skipped;
262
+ for (const cn in classNames) {
263
+ if (componentSkipProps.has(cn)) {
264
+ continue;
265
+ }
266
+ const val = classNames[cn];
267
+ definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)));
268
+ }
269
+ if (out.rulesToInsert) {
270
+ for (const [identifier, rule] of out.rulesToInsert) {
271
+ onStyleRule == null ? void 0 : onStyleRule(identifier, [rule]);
272
+ }
273
+ }
274
+ res.styled++;
275
+ if (shouldPrintDebug) {
276
+ console.log(`Extracted styled(${name}) props:`, styles);
277
+ }
278
+ },
160
279
  JSXElement(traversePath) {
161
- var _a, _b, _c, _d, _e;
280
+ var _a, _b, _c, _d, _e, _f;
162
281
  tm.mark("jsx-element", shouldPrintDebug === "verbose");
163
282
  const node = traversePath.node.openingElement;
164
283
  const ogAttributes = node.attributes;
@@ -200,10 +319,7 @@ function createExtractor() {
200
319
  shouldPrintDebug = debugPropValue;
201
320
  }
202
321
  try {
203
- let isValidStyleKey = function(name) {
204
- var _a2;
205
- return !!(!!validStyles[name] || !!pseudos[name] || ((_a2 = staticConfig.variants) == null ? void 0 : _a2[name]) || tamaguiConfig.shorthands[name] || (name[0] === "$" ? !!mediaQueryConfig[name.slice(1)] : false));
206
- }, evaluateAttribute = function(path) {
322
+ let evaluateAttribute = function(path) {
207
323
  const attribute = path.node;
208
324
  const attr = { type: "attr", value: attribute };
209
325
  if (t.isJSXSpreadAttribute(attribute)) {
@@ -294,9 +410,9 @@ function createExtractor() {
294
410
  return [attribute.value, path.get("value")];
295
411
  }
296
412
  })();
297
- const remove = /* @__PURE__ */ __name(() => {
413
+ const remove = () => {
298
414
  Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
299
- }, "remove");
415
+ };
300
416
  if (name === "ref") {
301
417
  if (shouldPrintDebug) {
302
418
  console.log(" ! inlining, ref", name);
@@ -326,29 +442,39 @@ function createExtractor() {
326
442
  return attr;
327
443
  }
328
444
  const styleValue = attemptEvalSafe(value);
329
- if (!isValidStyleKey(name)) {
445
+ if (!variants[name] && !isValidStyleKey(name, staticConfig)) {
330
446
  let keys = [name];
331
447
  let out = null;
332
- if (staticConfig.propMapper) {
333
- out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, "auto");
334
- if (out) {
335
- out = rnw.createDOMProps(isTextView ? "span" : "div", out);
336
- delete out.className;
448
+ out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, { resolveVariablesAs: "auto" }, void 0, shouldPrintDebug);
449
+ if (out) {
450
+ if (!Array.isArray(out)) {
451
+ console.warn(`Error expected array but got`, out);
452
+ couldntParse = true;
453
+ shouldDeopt = true;
454
+ } else {
455
+ out = Object.fromEntries(out);
337
456
  keys = Object.keys(out);
338
457
  }
339
458
  }
459
+ if (out) {
460
+ if (isTargetingHTML) {
461
+ out = createDOMProps(isTextView ? "span" : "div", out);
462
+ delete out.className;
463
+ }
464
+ keys = Object.keys(out);
465
+ }
340
466
  let didInline = false;
341
467
  const attributes = keys.map((key) => {
342
468
  const val = out[key];
343
- if (isValidStyleKey(key)) {
469
+ if (isValidStyleKey(key, staticConfig)) {
344
470
  return {
345
471
  type: "style",
346
- value: { [name]: styleValue },
347
- name,
472
+ value: { [key]: styleValue },
473
+ name: key,
348
474
  attr: path.node
349
475
  };
350
476
  }
351
- if (validHTMLAttributes[key]) {
477
+ if (validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-")) {
352
478
  return attr;
353
479
  }
354
480
  if (shouldPrintDebug) {
@@ -367,7 +493,10 @@ function createExtractor() {
367
493
  return attributes;
368
494
  }
369
495
  if (styleValue !== FAILED_EVAL) {
370
- if (isValidStyleKey(name)) {
496
+ if (inlineWhenUnflattened.has(name)) {
497
+ inlineWhenUnflattenedOGVals[name] = { styleValue, attr };
498
+ }
499
+ if (isValidStyleKey(name, staticConfig)) {
371
500
  if (shouldPrintDebug) {
372
501
  console.log(` style: ${name} =`, styleValue);
373
502
  }
@@ -384,6 +513,9 @@ function createExtractor() {
384
513
  attr: path.node
385
514
  };
386
515
  } else {
516
+ if (variants[name]) {
517
+ variantValues.set(name, styleValue);
518
+ }
387
519
  inlined.set(name, true);
388
520
  return attr;
389
521
  }
@@ -452,7 +584,6 @@ function createExtractor() {
452
584
  }
453
585
  return null;
454
586
  }
455
- __name(addBinaryConditional, "addBinaryConditional");
456
587
  function getStaticConditional(value2) {
457
588
  if (t.isConditionalExpression(value2)) {
458
589
  try {
@@ -476,7 +607,6 @@ function createExtractor() {
476
607
  }
477
608
  return null;
478
609
  }
479
- __name(getStaticConditional, "getStaticConditional");
480
610
  function getStaticLogical(value2) {
481
611
  if (t.isLogicalExpression(value2)) {
482
612
  if (value2.operator === "&&") {
@@ -500,7 +630,6 @@ function createExtractor() {
500
630
  }
501
631
  return null;
502
632
  }
503
- __name(getStaticLogical, "getStaticLogical");
504
633
  }, isExtractable = function(obj) {
505
634
  return t.isObjectExpression(obj) && obj.properties.every((prop) => {
506
635
  if (!t.isObjectProperty(prop)) {
@@ -508,7 +637,7 @@ function createExtractor() {
508
637
  return false;
509
638
  }
510
639
  const propName = prop.key["name"];
511
- if (!isValidStyleKey(propName) && propName !== "tag") {
640
+ if (!isValidStyleKey(propName, staticConfig) && propName !== "tag") {
512
641
  if (shouldPrintDebug) {
513
642
  console.log(" not a valid style prop!", propName);
514
643
  }
@@ -585,10 +714,10 @@ function createExtractor() {
585
714
  alternate: null
586
715
  });
587
716
  });
588
- }, mergeStyles = function(prev2, next) {
589
- normalizeStyleObject(next);
717
+ }, mergeStyles = function(prev2, nextIn) {
718
+ const next = expandStyles(nextIn);
590
719
  for (const key in next) {
591
- if (pseudos[key]) {
720
+ if (pseudoDescriptors[key]) {
592
721
  prev2[key] = prev2[key] || {};
593
722
  if (shouldPrintDebug) {
594
723
  if (!next[key] || !prev2[key]) {
@@ -600,12 +729,17 @@ function createExtractor() {
600
729
  prev2[key] = next[key];
601
730
  }
602
731
  }
732
+ }, omitInvalidStyles = function(style) {
733
+ if (staticConfig.validStyles) {
734
+ for (const key in style) {
735
+ if (stylePropsTransform[key] || !staticConfig.validStyles[key] && !pseudoDescriptors[key] && !/(hoverStyle|focusStyle|pressStyle)$/.test(key)) {
736
+ if (shouldPrintDebug)
737
+ console.log(" delete invalid style", key);
738
+ delete style[key];
739
+ }
740
+ }
741
+ }
603
742
  };
604
- __name(isValidStyleKey, "isValidStyleKey");
605
- __name(evaluateAttribute, "evaluateAttribute");
606
- __name(isExtractable, "isExtractable");
607
- __name(createTernariesFromObjectProperties, "createTernariesFromObjectProperties");
608
- __name(mergeStyles, "mergeStyles");
609
743
  node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
610
744
  if (shouldPrintDebug) {
611
745
  console.log("\n");
@@ -618,17 +752,19 @@ function createExtractor() {
618
752
  }
619
753
  const shouldLog = !hasLogged;
620
754
  if (shouldLog) {
755
+ console.log(` 1\uFE0F\u20E3 Inline optimized 2\uFE0F\u20E3 Inline flattened 3\uFE0F\u20E3 styled() extracted`);
621
756
  const prefix = " |";
622
- console.log(prefixLogs || prefix, " total \xB7 optimized \xB7 flattened ");
757
+ console.log(prefixLogs || prefix, " total \xB7 1\uFE0F\u20E3 \xB7 2\uFE0F\u20E3 \xB7 3\uFE0F\u20E3");
623
758
  hasLogged = true;
624
759
  }
625
760
  if (disableExtraction) {
626
761
  return;
627
762
  }
628
763
  const { staticConfig } = component;
764
+ const variants = staticConfig.variants || {};
629
765
  const isTextView = staticConfig.isText || false;
630
766
  const validStyles = (_a = staticConfig == null ? void 0 : staticConfig.validStyles) != null ? _a : {};
631
- let tagName = (_c = (_b = staticConfig.defaultProps) == null ? void 0 : _b.tag) != null ? _c : isTextView ? "span" : "div";
767
+ let tagName = (_b = staticConfig.defaultProps.tag) != null ? _b : isTextView ? "span" : "div";
632
768
  traversePath.get("openingElement").get("attributes").forEach((path) => {
633
769
  const attr = path.node;
634
770
  if (t.isJSXSpreadAttribute(attr))
@@ -650,6 +786,7 @@ function createExtractor() {
650
786
  ...props.deoptProps || [],
651
787
  ...staticConfig.deoptProps || []
652
788
  ]);
789
+ const inlineWhenUnflattened = /* @__PURE__ */ new Set([...staticConfig.inlineWhenUnflattened || []]);
653
790
  const staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
654
791
  const attemptEval = !evaluateVars ? evaluateAstNode : createEvaluator({
655
792
  tamaguiConfig,
@@ -707,27 +844,12 @@ function createExtractor() {
707
844
  }
708
845
  tm.mark("jsx-element-flattened", shouldPrintDebug === "verbose");
709
846
  node.attributes = flattenedAttrs;
710
- if (staticConfig.defaultProps) {
711
- for (const key in staticConfig.defaultProps) {
712
- if (isValidStyleKey(key)) {
713
- continue;
714
- }
715
- const serialize = require("babel-literal-to-ast");
716
- const val = staticConfig.defaultProps[key];
717
- try {
718
- const serializedDefaultProp = serialize(val);
719
- node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier(key), typeof val === "string" ? t.stringLiteral(val) : t.jsxExpressionContainer(serializedDefaultProp)));
720
- } catch (err) {
721
- console.warn(`\u26A0\uFE0F Error evaluating default prop for component ${node.name.name}, prop ${key}
722
- error: ${err}
723
- value:`, val, "\n defaultProps:", staticConfig.defaultProps);
724
- }
725
- }
726
- }
727
847
  let attrs = [];
728
848
  let shouldDeopt = false;
729
849
  const inlined = /* @__PURE__ */ new Map();
850
+ const variantValues = /* @__PURE__ */ new Map();
730
851
  let hasSetOptimized = false;
852
+ const inlineWhenUnflattenedOGVals = {};
731
853
  attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
732
854
  try {
733
855
  const res2 = evaluateAttribute(path);
@@ -741,6 +863,7 @@ function createExtractor() {
741
863
  console.log("Error extracting attribute", err.message, err.stack);
742
864
  console.log("node", path.node);
743
865
  }
866
+ inlined.set(`${Math.random()}`, "spread");
744
867
  return {
745
868
  type: "attr",
746
869
  value: path.node
@@ -796,18 +919,30 @@ function createExtractor() {
796
919
  }, []).flat();
797
920
  const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x));
798
921
  const hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
799
- let themeVal = inlined.get("theme");
922
+ const themeVal = inlined.get("theme");
800
923
  inlined.delete("theme");
801
- const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k]);
802
- const shouldWrapThme = allOtherPropsExtractable && !!themeVal;
803
- const canFlattenProps = inlined.size === 0 || shouldWrapThme || allOtherPropsExtractable;
924
+ for (const [key] of [...inlined]) {
925
+ if (INLINE_EXTRACTABLE[key] || ((_c = staticConfig.variants) == null ? void 0 : _c[key])) {
926
+ inlined.delete(key);
927
+ }
928
+ }
929
+ const canFlattenProps = inlined.size === 0;
804
930
  let shouldFlatten = !shouldDeopt && canFlattenProps && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
931
+ const shouldWrapTheme = shouldFlatten && themeVal;
932
+ if (disableExtractVariables) {
933
+ themeAccessListeners.add((key) => {
934
+ shouldFlatten = false;
935
+ if (shouldPrintDebug) {
936
+ console.log(" ! accessing theme key, avoid flatten", key);
937
+ }
938
+ });
939
+ }
805
940
  if (shouldPrintDebug) {
806
- console.log(" - flatten?", objToStr({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapThme, allOtherPropsExtractable, hasOnlyStringChildren }));
941
+ console.log(" - flatten?", objToStr({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapTheme, hasOnlyStringChildren }), "inlined", [...inlined]);
807
942
  }
808
- if (shouldFlatten && shouldWrapThme) {
943
+ if (shouldFlatten && shouldWrapTheme) {
809
944
  if (shouldPrintDebug) {
810
- console.log(" - wrapping theme", allOtherPropsExtractable, themeVal);
945
+ console.log(" - wrapping theme", themeVal);
811
946
  }
812
947
  attrs = attrs.filter((x) => x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme" ? false : true);
813
948
  if (!hasImportedTheme) {
@@ -818,9 +953,9 @@ function createExtractor() {
818
953
  t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
819
954
  ]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]));
820
955
  }
821
- if (shouldFlatten && staticConfig.defaultProps) {
956
+ if (shouldFlatten) {
822
957
  const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {
823
- if (!isValidStyleKey(key)) {
958
+ if (!isValidStyleKey(key, staticConfig)) {
824
959
  return [];
825
960
  }
826
961
  const value = staticConfig.defaultProps[key];
@@ -866,14 +1001,87 @@ function createExtractor() {
866
1001
  console.log(" - attrs (flattened): \n", logLines(attrs.map(attrStr).join(", ")));
867
1002
  console.log(" - ensureOverriden:", Object.keys(ensureOverridden).join(", "));
868
1003
  }
1004
+ const state = {
1005
+ noClassNames: false,
1006
+ focus: false,
1007
+ hover: false,
1008
+ mounted: true,
1009
+ press: false,
1010
+ pressIn: false
1011
+ };
1012
+ let foundStaticProps = {};
1013
+ for (const key in attrs) {
1014
+ const cur = attrs[key];
1015
+ if (cur.type === "style") {
1016
+ foundStaticProps = {
1017
+ ...foundStaticProps,
1018
+ ...expandStyles(cur.value)
1019
+ };
1020
+ continue;
1021
+ }
1022
+ if (cur.type === "attr") {
1023
+ if (t.isJSXSpreadAttribute(cur.value)) {
1024
+ continue;
1025
+ }
1026
+ if (!t.isJSXIdentifier(cur.value.name)) {
1027
+ continue;
1028
+ }
1029
+ const key2 = cur.value.name.name;
1030
+ const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
1031
+ if (value !== FAILED_EVAL) {
1032
+ foundStaticProps = {
1033
+ ...foundStaticProps,
1034
+ [key2]: value
1035
+ };
1036
+ }
1037
+ }
1038
+ }
1039
+ const completeProps = {};
1040
+ for (const key in staticConfig.defaultProps) {
1041
+ if (!(key in foundStaticProps)) {
1042
+ completeProps[key] = staticConfig.defaultProps[key];
1043
+ }
1044
+ }
1045
+ for (const key in foundStaticProps) {
1046
+ completeProps[key] = foundStaticProps[key];
1047
+ }
869
1048
  attrs = attrs.reduce((acc, cur) => {
870
- if (!cur) {
1049
+ if (!cur)
871
1050
  return acc;
872
- }
873
1051
  if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value)) {
874
1052
  if (shouldFlatten) {
875
- if (cur.value.name.name === "tag") {
876
- return acc;
1053
+ const name = cur.value.name.name;
1054
+ if (typeof name === "string") {
1055
+ if (name === "tag") {
1056
+ return acc;
1057
+ }
1058
+ if (variants[name] && variantValues.has(name)) {
1059
+ let out = Object.fromEntries(staticConfig.propMapper(name, variantValues.get(name), defaultTheme, completeProps, { ...state, resolveVariablesAs: "auto" }, void 0, shouldPrintDebug) || []);
1060
+ if (out && isTargetingHTML) {
1061
+ const cn = out.className;
1062
+ out = createDOMProps(isTextView ? "span" : "div", out);
1063
+ out.className = cn;
1064
+ }
1065
+ if (shouldPrintDebug) {
1066
+ console.log(" - expanded variant", name, out);
1067
+ }
1068
+ for (const key2 in out) {
1069
+ const value2 = out[key2];
1070
+ if (isValidStyleKey(key2, staticConfig)) {
1071
+ acc.push({
1072
+ type: "style",
1073
+ value: { [key2]: value2 },
1074
+ name: key2,
1075
+ attr: cur.value
1076
+ });
1077
+ } else {
1078
+ acc.push({
1079
+ type: "attr",
1080
+ value: t.jsxAttribute(t.jsxIdentifier(key2), t.jsxExpressionContainer(typeof value2 === "string" ? t.stringLiteral(value2) : literalToAst(value2)))
1081
+ });
1082
+ }
1083
+ }
1084
+ }
877
1085
  }
878
1086
  }
879
1087
  }
@@ -912,7 +1120,7 @@ function createExtractor() {
912
1120
  if (cur.type === "style") {
913
1121
  const key = Object.keys(cur.value)[0];
914
1122
  const value = cur.value[key];
915
- const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !pseudos[key] && !key.startsWith("data-");
1123
+ const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !pseudoDescriptors[key] && !key.startsWith("data-");
916
1124
  if (shouldKeepOriginalAttr) {
917
1125
  if (shouldPrintDebug) {
918
1126
  console.log(" - keeping as non-style", key);
@@ -940,46 +1148,13 @@ function createExtractor() {
940
1148
  acc.push(cur);
941
1149
  return acc;
942
1150
  }, []);
943
- const state = {
944
- noClassNames: true,
945
- focus: false,
946
- hover: false,
947
- mounted: true,
948
- press: false,
949
- pressIn: false
950
- };
951
- const completeStaticProps = Object.keys(attrs).reduce((acc, index) => {
952
- const cur = attrs[index];
953
- if (cur.type === "style") {
954
- normalizeStyleObject(cur.value);
955
- Object.assign(acc, cur.value);
956
- }
957
- if (cur.type === "attr") {
958
- if (t.isJSXSpreadAttribute(cur.value)) {
959
- return acc;
960
- }
961
- if (!t.isJSXIdentifier(cur.value.name)) {
962
- return acc;
963
- }
964
- const key = cur.value.name.name;
965
- const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
966
- if (value === FAILED_EVAL) {
967
- return acc;
968
- }
969
- acc[key] = value;
970
- }
971
- return acc;
972
- }, {});
973
- const completeProps = {
974
- ...staticConfig.defaultProps,
975
- ...completeStaticProps
976
- };
977
1151
  if (shouldPrintDebug) {
978
1152
  console.log(" - attrs (combined \u{1F500}): \n", logLines(attrs.map(attrStr).join(", ")));
979
1153
  console.log(" - defaultProps: \n", logLines(objToStr(staticConfig.defaultProps)));
980
- console.log(" - completeStaticProps: \n", logLines(objToStr(completeStaticProps)));
1154
+ console.log(" - foundStaticProps: \n", logLines(objToStr(foundStaticProps)));
1155
+ console.log(" - completeProps: \n", logLines(objToStr(completeProps)));
981
1156
  }
982
- const getStyles = /* @__PURE__ */ __name((props2, debugName = "") => {
1157
+ const getStyles = (props2, debugName = "") => {
983
1158
  if (!props2 || !Object.keys(props2).length) {
984
1159
  if (shouldPrintDebug)
985
1160
  console.log(" getStyles() no props");
@@ -998,41 +1173,24 @@ function createExtractor() {
998
1173
  const out = getSplitStyles(props2, staticConfig, defaultTheme, {
999
1174
  ...state,
1000
1175
  fallbackProps: completeProps
1001
- });
1176
+ }, void 0, props2["debug"]);
1002
1177
  const outStyle = {
1003
1178
  ...out.style,
1004
1179
  ...out.pseudos
1005
1180
  };
1006
- if (staticConfig.validStyles) {
1007
- for (const key in outStyle) {
1008
- if (!staticConfig.validStyles[key] && !pseudos[key] && !/(hover|focus|press)Style$/.test(key)) {
1009
- if (shouldPrintDebug)
1010
- console.log(" delete invalid style", key);
1011
- delete outStyle[key];
1012
- }
1013
- }
1014
- }
1015
- if (shouldPrintDebug) {
1016
- console.log(` getStyles ${debugName} (props):
1017
- `, logLines(objToStr(props2)));
1018
- console.log(` getStyles ${debugName} (out.viewProps):
1019
- `, logLines(objToStr(out.viewProps)));
1020
- console.log(` getStyles ${debugName} (out.style):
1021
- `, logLines(objToStr(outStyle || {}), true));
1022
- }
1023
1181
  return outStyle;
1024
1182
  } catch (err) {
1025
1183
  console.log("error", err.message, err.stack);
1026
1184
  return {};
1027
1185
  }
1028
- }, "getStyles");
1029
- const completeStylesProcessed = getStyles(completeProps, "completeStylesProcessed");
1030
- if (!completeStylesProcessed) {
1186
+ };
1187
+ const completeStyles = getStyles(completeProps, "completeStyles");
1188
+ if (!completeStyles) {
1031
1189
  throw new Error(`Impossible, no styles`);
1032
1190
  }
1033
- const stylesToAddToInitialGroup = shouldFlatten ? difference(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps)) : [];
1034
- if (stylesToAddToInitialGroup.length) {
1035
- const toAdd = pick(completeStylesProcessed, ...stylesToAddToInitialGroup);
1191
+ const addInitialStyleKeys = shouldFlatten ? difference(Object.keys(completeStyles), Object.keys(foundStaticProps)) : [];
1192
+ if (addInitialStyleKeys.length) {
1193
+ const toAdd = pick(completeStyles, ...addInitialStyleKeys);
1036
1194
  const firstGroup = attrs.find((x) => x.type === "style");
1037
1195
  if (shouldPrintDebug) {
1038
1196
  console.log(" toAdd", objToStr(toAdd));
@@ -1040,19 +1198,17 @@ function createExtractor() {
1040
1198
  if (!firstGroup) {
1041
1199
  attrs.unshift({ type: "style", value: toAdd });
1042
1200
  } else {
1201
+ omitInvalidStyles(firstGroup.value);
1043
1202
  Object.assign(firstGroup.value, toAdd);
1044
1203
  }
1045
1204
  }
1046
1205
  if (shouldPrintDebug) {
1047
- console.log(" -- stylesToAddToInitialGroup", stylesToAddToInitialGroup.join(", "), { shouldFlatten });
1048
- console.log(" -- completeStaticProps:\n", logLines(objToStr(completeStaticProps)));
1049
- console.log(" -- completeStylesProcessed:\n", logLines(objToStr(completeStylesProcessed)));
1206
+ if (shouldFlatten)
1207
+ console.log(" -- addInitialStyleKeys", addInitialStyleKeys.join(", "));
1050
1208
  }
1051
1209
  let getStyleError = null;
1052
1210
  for (const attr of attrs) {
1053
1211
  try {
1054
- if (shouldPrintDebug)
1055
- console.log(" *", attrStr(attr));
1056
1212
  switch (attr.type) {
1057
1213
  case "ternary":
1058
1214
  const a = getStyles(attr.value.alternate, "ternary.alternate");
@@ -1065,20 +1221,23 @@ function createExtractor() {
1065
1221
  console.log(" => tern ", attrStr(attr));
1066
1222
  continue;
1067
1223
  case "style":
1068
- if (shouldPrintDebug)
1069
- console.log(" * styles in", logLines(objToStr(attr.value)));
1070
1224
  const styles = getStyles(attr.value, "style");
1071
- if (shouldPrintDebug)
1072
- console.log(" * styles out", logLines(objToStr(styles)));
1073
1225
  if (styles) {
1074
- attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStylesProcessed[k]]));
1226
+ attr.value = styles;
1075
1227
  }
1228
+ if (shouldPrintDebug)
1229
+ console.log(" * styles (in)", logLines(objToStr(attr.value)));
1230
+ if (shouldPrintDebug)
1231
+ console.log(" * styles (out)", logLines(objToStr(styles)));
1076
1232
  continue;
1077
1233
  }
1078
1234
  } catch (err) {
1079
1235
  getStyleError = err;
1080
1236
  }
1081
1237
  }
1238
+ if (shouldPrintDebug) {
1239
+ console.log(" - attrs (ternaries/combined):\n", logLines(attrs.map(attrStr).join(", ")));
1240
+ }
1082
1241
  tm.mark("jsx-element-styles", shouldPrintDebug === "verbose");
1083
1242
  if (getStyleError) {
1084
1243
  console.log(" \u26A0\uFE0F postprocessing error, deopt", getStyleError);
@@ -1088,7 +1247,7 @@ function createExtractor() {
1088
1247
  const existingStyleKeys = /* @__PURE__ */ new Set();
1089
1248
  for (let i = attrs.length - 1; i >= 0; i--) {
1090
1249
  const attr = attrs[i];
1091
- if (shouldFlatten && canFlattenProps) {
1250
+ if (shouldFlatten) {
1092
1251
  if (attr.type === "attr") {
1093
1252
  if (t.isJSXAttribute(attr.value)) {
1094
1253
  if (t.isJSXIdentifier(attr.value.name)) {
@@ -1096,6 +1255,9 @@ function createExtractor() {
1096
1255
  if (INLINE_EXTRACTABLE[name]) {
1097
1256
  attr.value.name.name = INLINE_EXTRACTABLE[name];
1098
1257
  }
1258
+ if ((_f = staticConfig.variants) == null ? void 0 : _f[name]) {
1259
+ const expanded = getStyles({});
1260
+ }
1099
1261
  }
1100
1262
  }
1101
1263
  }
@@ -1113,6 +1275,21 @@ function createExtractor() {
1113
1275
  }
1114
1276
  }
1115
1277
  }
1278
+ if (!shouldFlatten) {
1279
+ if (Object.keys(inlineWhenUnflattenedOGVals).length) {
1280
+ for (const [index, attr] of attrs.entries()) {
1281
+ if (attr.type === "style") {
1282
+ for (const key in attr.value) {
1283
+ const val = inlineWhenUnflattenedOGVals[key];
1284
+ if (val) {
1285
+ delete attr.value[key];
1286
+ attrs.splice(index - 1, 0, val.attr);
1287
+ }
1288
+ }
1289
+ }
1290
+ }
1291
+ }
1292
+ }
1116
1293
  if (shouldFlatten) {
1117
1294
  if (shouldPrintDebug) {
1118
1295
  console.log(" [\u2705] flattening", originalNodeName, flatNode);
@@ -1138,8 +1315,6 @@ function createExtractor() {
1138
1315
  isFlattened: shouldFlatten,
1139
1316
  programPath
1140
1317
  });
1141
- } catch (err) {
1142
- throw err;
1143
1318
  } finally {
1144
1319
  if (debugPropValue) {
1145
1320
  shouldPrintDebug = ogDebug;
@@ -1162,7 +1337,7 @@ function createExtractor() {
1162
1337
  }
1163
1338
  };
1164
1339
  }
1165
- __name(createExtractor, "createExtractor");
1166
1340
  export {
1167
1341
  createExtractor
1168
1342
  };
1343
+ //# sourceMappingURL=createExtractor.js.map