@tamagui/static 1.0.1-beta.19 → 1.0.1-beta.191

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 (250) hide show
  1. package/dist/{cjs/constants.js → constants.js} +9 -4
  2. package/dist/constants.js.map +7 -0
  3. package/dist/{cjs/extractor → extractor}/accessSafe.js +14 -4
  4. package/dist/{esm/extractor → extractor}/accessSafe.js.map +2 -2
  5. package/dist/{cjs/extractor → extractor}/babelParse.js +20 -17
  6. package/dist/extractor/babelParse.js.map +7 -0
  7. package/dist/{cjs/extractor → extractor}/buildClassName.js +40 -11
  8. package/dist/extractor/buildClassName.js.map +7 -0
  9. package/dist/{cjs/extractor → extractor}/createEvaluator.js +19 -14
  10. package/dist/extractor/createEvaluator.js.map +7 -0
  11. package/dist/extractor/createExtractor.js +1577 -0
  12. package/dist/extractor/createExtractor.js.map +7 -0
  13. package/dist/{cjs/extractor → extractor}/ensureImportingConcat.js +18 -8
  14. package/dist/extractor/ensureImportingConcat.js.map +7 -0
  15. package/dist/{cjs/extractor → extractor}/evaluateAstNode.js +14 -6
  16. package/dist/{esm/extractor → extractor}/evaluateAstNode.js.map +2 -2
  17. package/dist/{cjs/extractor → extractor}/extractHelpers.js +56 -27
  18. package/dist/extractor/extractHelpers.js.map +7 -0
  19. package/dist/{cjs/extractor → extractor}/extractMediaStyle.js +49 -50
  20. package/dist/extractor/extractMediaStyle.js.map +7 -0
  21. package/dist/{cjs/extractor → extractor}/extractToClassNames.js +160 -109
  22. package/dist/extractor/extractToClassNames.js.map +7 -0
  23. package/dist/{cjs/extractor → extractor}/findTopmostFunction.js +2 -3
  24. package/dist/{esm/extractor → extractor}/findTopmostFunction.js.map +2 -2
  25. package/dist/{cjs/extractor → extractor}/generatedUid.js +9 -4
  26. package/dist/{cjs/extractor → extractor}/generatedUid.js.map +3 -3
  27. package/dist/{cjs/extractor → extractor}/getPrefixLogs.js +1 -2
  28. package/dist/extractor/getPrefixLogs.js.map +7 -0
  29. package/dist/{cjs/extractor → extractor}/getPropValueFromAttributes.js +24 -15
  30. package/dist/extractor/getPropValueFromAttributes.js.map +7 -0
  31. package/dist/{cjs/extractor → extractor}/getSourceModule.js +5 -3
  32. package/dist/{esm/extractor → extractor}/getSourceModule.js.map +2 -2
  33. package/dist/{cjs/extractor → extractor}/getStaticBindingsForScope.js +88 -38
  34. package/dist/extractor/getStaticBindingsForScope.js.map +7 -0
  35. package/dist/{cjs/extractor → extractor}/hoistClassNames.js +5 -4
  36. package/dist/{esm/extractor → extractor}/hoistClassNames.js.map +3 -3
  37. package/dist/{cjs/extractor → extractor}/literalToAst.js +26 -34
  38. package/dist/{cjs/extractor → extractor}/literalToAst.js.map +2 -2
  39. package/dist/extractor/loadFile.js +21 -0
  40. package/dist/extractor/loadFile.js.map +7 -0
  41. package/dist/extractor/loadTamagui.js +327 -0
  42. package/dist/extractor/loadTamagui.js.map +7 -0
  43. package/dist/{cjs/extractor → extractor}/logLines.js +3 -3
  44. package/dist/{cjs/extractor → extractor}/logLines.js.map +2 -2
  45. package/dist/{cjs/extractor → extractor}/normalizeTernaries.js +13 -36
  46. package/dist/extractor/normalizeTernaries.js.map +7 -0
  47. package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js +7 -5
  48. package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js.map +2 -2
  49. package/dist/{cjs/extractor → extractor}/timer.js +11 -4
  50. package/dist/extractor/timer.js.map +7 -0
  51. package/dist/{cjs/extractor → extractor}/validHTMLAttributes.js +52 -0
  52. package/dist/extractor/validHTMLAttributes.js.map +7 -0
  53. package/dist/getPragmaOptions.js +68 -0
  54. package/dist/getPragmaOptions.js.map +7 -0
  55. package/dist/{cjs/index.js → index.js} +11 -7
  56. package/dist/index.js.map +7 -0
  57. package/dist/require.js +95 -0
  58. package/dist/require.js.map +7 -0
  59. package/dist/{cjs/types.js → types.js} +1 -0
  60. package/dist/types.js.map +7 -0
  61. package/dist/webpackPlugin.js +35 -0
  62. package/dist/webpackPlugin.js.map +7 -0
  63. package/package.json +46 -35
  64. package/src/constants.ts +14 -0
  65. package/src/extractor/accessSafe.ts +18 -0
  66. package/src/extractor/babelParse.ts +27 -0
  67. package/src/extractor/buildClassName.ts +77 -0
  68. package/src/extractor/createEvaluator.ts +73 -0
  69. package/src/extractor/createExtractor.ts +2044 -0
  70. package/src/extractor/ensureImportingConcat.ts +32 -0
  71. package/src/extractor/evaluateAstNode.ts +121 -0
  72. package/src/extractor/extractHelpers.ts +154 -0
  73. package/src/extractor/extractMediaStyle.ts +199 -0
  74. package/src/extractor/extractToClassNames.ts +442 -0
  75. package/src/extractor/findTopmostFunction.ts +22 -0
  76. package/src/extractor/generatedUid.ts +43 -0
  77. package/src/extractor/getPrefixLogs.ts +6 -0
  78. package/src/extractor/getPropValueFromAttributes.ts +92 -0
  79. package/src/extractor/getSourceModule.ts +101 -0
  80. package/src/extractor/getStaticBindingsForScope.ts +227 -0
  81. package/src/extractor/hoistClassNames.ts +45 -0
  82. package/src/extractor/literalToAst.ts +84 -0
  83. package/src/extractor/loadFile.ts +17 -0
  84. package/src/extractor/loadTamagui.ts +377 -0
  85. package/src/extractor/logLines.ts +16 -0
  86. package/src/extractor/normalizeTernaries.ts +63 -0
  87. package/src/extractor/removeUnusedHooks.ts +76 -0
  88. package/src/extractor/timer.ts +29 -0
  89. package/src/extractor/validHTMLAttributes.ts +99 -0
  90. package/src/getPragmaOptions.ts +52 -0
  91. package/src/index.ts +12 -0
  92. package/src/require.ts +112 -0
  93. package/src/types.ts +94 -0
  94. package/src/webpackPlugin.ts +9 -0
  95. package/tamagui.tsconfig.json +5 -0
  96. package/types/constants.d.ts +1 -1
  97. package/types/extractor/buildClassName.d.ts +5 -2
  98. package/types/extractor/createEvaluator.d.ts +4 -4
  99. package/types/extractor/createExtractor.d.ts +26 -11
  100. package/types/extractor/extractHelpers.d.ts +6 -4
  101. package/types/extractor/extractMediaStyle.d.ts +3 -3
  102. package/types/extractor/extractToClassNames.d.ts +4 -9
  103. package/types/extractor/findTopmostFunction.d.ts +1 -1
  104. package/types/extractor/getPrefixLogs.d.ts +1 -1
  105. package/types/extractor/getPropValueFromAttributes.d.ts +16 -0
  106. package/types/extractor/getStaticBindingsForScope.d.ts +2 -1
  107. package/types/extractor/loadFile.d.ts +1 -0
  108. package/types/extractor/loadTamagui.d.ts +15 -5
  109. package/types/extractor/normalizeTernaries.d.ts +1 -1
  110. package/types/extractor/validHTMLAttributes.d.ts +49 -0
  111. package/types/getPragmaOptions.d.ts +9 -0
  112. package/types/index.d.ts +10 -7
  113. package/types/require.d.ts +4 -0
  114. package/types/types.d.ts +29 -32
  115. package/types/webpackPlugin.d.ts +4 -0
  116. package/dist/cjs/constants.js.map +0 -7
  117. package/dist/cjs/extractor/accessSafe.js.map +0 -7
  118. package/dist/cjs/extractor/babelParse.js.map +0 -7
  119. package/dist/cjs/extractor/buildClassName.js.map +0 -7
  120. package/dist/cjs/extractor/createEvaluator.js.map +0 -7
  121. package/dist/cjs/extractor/createExtractor.js +0 -1221
  122. package/dist/cjs/extractor/createExtractor.js.map +0 -7
  123. package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
  124. package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
  125. package/dist/cjs/extractor/extractHelpers.js.map +0 -7
  126. package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
  127. package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
  128. package/dist/cjs/extractor/findTopmostFunction.js.map +0 -7
  129. package/dist/cjs/extractor/getPrefixLogs.js.map +0 -7
  130. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
  131. package/dist/cjs/extractor/getSourceModule.js.map +0 -7
  132. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
  133. package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
  134. package/dist/cjs/extractor/loadTamagui.js +0 -106
  135. package/dist/cjs/extractor/loadTamagui.js.map +0 -7
  136. package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
  137. package/dist/cjs/extractor/timer.js.map +0 -7
  138. package/dist/cjs/extractor/validHTMLAttributes.js.map +0 -7
  139. package/dist/cjs/index.js.map +0 -7
  140. package/dist/cjs/patchReactNativeWeb.js +0 -167
  141. package/dist/cjs/patchReactNativeWeb.js.map +0 -7
  142. package/dist/cjs/types.js.map +0 -7
  143. package/dist/esm/constants.js +0 -14
  144. package/dist/esm/constants.js.map +0 -7
  145. package/dist/esm/extractor/accessSafe.js +0 -11
  146. package/dist/esm/extractor/babelParse.js +0 -30
  147. package/dist/esm/extractor/babelParse.js.map +0 -7
  148. package/dist/esm/extractor/buildClassName.js +0 -40
  149. package/dist/esm/extractor/buildClassName.js.map +0 -7
  150. package/dist/esm/extractor/createEvaluator.js +0 -52
  151. package/dist/esm/extractor/createEvaluator.js.map +0 -7
  152. package/dist/esm/extractor/createExtractor.js +0 -1169
  153. package/dist/esm/extractor/createExtractor.js.map +0 -7
  154. package/dist/esm/extractor/ensureImportingConcat.js +0 -24
  155. package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
  156. package/dist/esm/extractor/evaluateAstNode.js +0 -94
  157. package/dist/esm/extractor/extractHelpers.js +0 -103
  158. package/dist/esm/extractor/extractHelpers.js.map +0 -7
  159. package/dist/esm/extractor/extractMediaStyle.js +0 -152
  160. package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
  161. package/dist/esm/extractor/extractToClassNames.js +0 -293
  162. package/dist/esm/extractor/extractToClassNames.js.map +0 -7
  163. package/dist/esm/extractor/findTopmostFunction.js +0 -23
  164. package/dist/esm/extractor/generatedUid.js +0 -28
  165. package/dist/esm/extractor/generatedUid.js.map +0 -7
  166. package/dist/esm/extractor/getPrefixLogs.js +0 -12
  167. package/dist/esm/extractor/getPrefixLogs.js.map +0 -7
  168. package/dist/esm/extractor/getPropValueFromAttributes.js +0 -49
  169. package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
  170. package/dist/esm/extractor/getSourceModule.js +0 -69
  171. package/dist/esm/extractor/getStaticBindingsForScope.js +0 -137
  172. package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
  173. package/dist/esm/extractor/hoistClassNames.js +0 -44
  174. package/dist/esm/extractor/literalToAst.js +0 -80
  175. package/dist/esm/extractor/literalToAst.js.map +0 -7
  176. package/dist/esm/extractor/loadTamagui.js +0 -84
  177. package/dist/esm/extractor/loadTamagui.js.map +0 -7
  178. package/dist/esm/extractor/logLines.js +0 -22
  179. package/dist/esm/extractor/logLines.js.map +0 -7
  180. package/dist/esm/extractor/normalizeTernaries.js +0 -53
  181. package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
  182. package/dist/esm/extractor/removeUnusedHooks.js +0 -80
  183. package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
  184. package/dist/esm/extractor/timer.js +0 -24
  185. package/dist/esm/extractor/timer.js.map +0 -7
  186. package/dist/esm/extractor/validHTMLAttributes.js +0 -52
  187. package/dist/esm/extractor/validHTMLAttributes.js.map +0 -7
  188. package/dist/esm/index.js +0 -14
  189. package/dist/esm/index.js.map +0 -7
  190. package/dist/esm/patchReactNativeWeb.js +0 -142
  191. package/dist/esm/patchReactNativeWeb.js.map +0 -7
  192. package/dist/esm/types.js +0 -1
  193. package/dist/esm/types.js.map +0 -7
  194. package/dist/jsx/constants.js +0 -13
  195. package/dist/jsx/extractor/accessSafe.js +0 -10
  196. package/dist/jsx/extractor/babelParse.js +0 -29
  197. package/dist/jsx/extractor/buildClassName.js +0 -39
  198. package/dist/jsx/extractor/createEvaluator.js +0 -51
  199. package/dist/jsx/extractor/createExtractor.js +0 -1168
  200. package/dist/jsx/extractor/ensureImportingConcat.js +0 -23
  201. package/dist/jsx/extractor/evaluateAstNode.js +0 -93
  202. package/dist/jsx/extractor/extractHelpers.js +0 -102
  203. package/dist/jsx/extractor/extractMediaStyle.js +0 -151
  204. package/dist/jsx/extractor/extractToClassNames.js +0 -292
  205. package/dist/jsx/extractor/findTopmostFunction.js +0 -22
  206. package/dist/jsx/extractor/generatedUid.js +0 -27
  207. package/dist/jsx/extractor/getPrefixLogs.js +0 -11
  208. package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -48
  209. package/dist/jsx/extractor/getSourceModule.js +0 -68
  210. package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -136
  211. package/dist/jsx/extractor/hoistClassNames.js +0 -43
  212. package/dist/jsx/extractor/literalToAst.js +0 -79
  213. package/dist/jsx/extractor/loadTamagui.js +0 -83
  214. package/dist/jsx/extractor/logLines.js +0 -21
  215. package/dist/jsx/extractor/normalizeTernaries.js +0 -52
  216. package/dist/jsx/extractor/removeUnusedHooks.js +0 -79
  217. package/dist/jsx/extractor/timer.js +0 -23
  218. package/dist/jsx/extractor/validHTMLAttributes.js +0 -51
  219. package/dist/jsx/index.js +0 -13
  220. package/dist/jsx/patchReactNativeWeb.js +0 -141
  221. package/dist/jsx/types.js +0 -0
  222. package/types/constants.d.ts.map +0 -1
  223. package/types/extractor/accessSafe.d.ts.map +0 -1
  224. package/types/extractor/babelParse.d.ts.map +0 -1
  225. package/types/extractor/buildClassName.d.ts.map +0 -1
  226. package/types/extractor/createEvaluator.d.ts.map +0 -1
  227. package/types/extractor/createExtractor.d.ts.map +0 -1
  228. package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
  229. package/types/extractor/evaluateAstNode.d.ts.map +0 -1
  230. package/types/extractor/extractHelpers.d.ts.map +0 -1
  231. package/types/extractor/extractMediaStyle.d.ts.map +0 -1
  232. package/types/extractor/extractToClassNames.d.ts.map +0 -1
  233. package/types/extractor/findTopmostFunction.d.ts.map +0 -1
  234. package/types/extractor/generatedUid.d.ts.map +0 -1
  235. package/types/extractor/getPrefixLogs.d.ts.map +0 -1
  236. package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
  237. package/types/extractor/getSourceModule.d.ts.map +0 -1
  238. package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
  239. package/types/extractor/hoistClassNames.d.ts.map +0 -1
  240. package/types/extractor/literalToAst.d.ts.map +0 -1
  241. package/types/extractor/loadTamagui.d.ts.map +0 -1
  242. package/types/extractor/logLines.d.ts.map +0 -1
  243. package/types/extractor/normalizeTernaries.d.ts.map +0 -1
  244. package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
  245. package/types/extractor/timer.d.ts.map +0 -1
  246. package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
  247. package/types/index.d.ts.map +0 -1
  248. package/types/patchReactNativeWeb.d.ts +0 -2
  249. package/types/patchReactNativeWeb.d.ts.map +0 -1
  250. package/types/types.d.ts.map +0 -1
@@ -1,27 +1,10 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
6
  var __getProtoOf = Object.getPrototypeOf;
9
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
8
  var __export = (target, all) => {
26
9
  for (var name in all)
27
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -34,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
34
17
  }
35
18
  return to;
36
19
  };
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
38
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
25
  var extractMediaStyle_exports = {};
40
26
  __export(extractMediaStyle_exports, {
@@ -44,10 +30,10 @@ __export(extractMediaStyle_exports, {
44
30
  module.exports = __toCommonJS(extractMediaStyle_exports);
45
31
  var t = __toESM(require("@babel/types"));
46
32
  var import_core_node = require("@tamagui/core-node");
47
- var import_constants = require("../constants");
48
- var import_extractHelpers = require("./extractHelpers");
49
- function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importance = 0, shouldPrintDebug = false) {
50
- const mt = getMediaQueryTernary(ternary, jsxPath, sourcePath);
33
+ var import_constants = require("../constants.js");
34
+ var import_extractHelpers = require("./extractHelpers.js");
35
+ function extractMediaStyle(props, ternary, jsxPath, tamaguiConfig, sourcePath, importance = 0, shouldPrintDebug = false) {
36
+ const mt = getMediaQueryTernary(props, ternary, jsxPath, sourcePath);
51
37
  if (!mt) {
52
38
  return null;
53
39
  }
@@ -57,9 +43,9 @@ function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importan
57
43
  console.error(`Media query "${key}" not found: ${Object.keys(tamaguiConfig.media)}`);
58
44
  return null;
59
45
  }
60
- const getStyleObj = /* @__PURE__ */ __name((styleObj, negate = false) => {
46
+ const getStyleObj = (styleObj, negate = false) => {
61
47
  return styleObj ? { styleObj, negate } : null;
62
- }, "getStyleObj");
48
+ };
63
49
  const styleOpts = [
64
50
  getStyleObj(ternary.consequent, false),
65
51
  getStyleObj(ternary.alternate, true)
@@ -79,24 +65,28 @@ function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importan
79
65
  const singleMediaStyles = styles.map((style) => {
80
66
  const negKey = negate ? "0" : "";
81
67
  const ogPrefix = style.identifier.slice(0, style.identifier.indexOf("-") + 1);
82
- const identifier = `${style.identifier.replace(ogPrefix, `${ogPrefix}${import_constants.MEDIA_SEP}${key}${negKey}${import_constants.MEDIA_SEP}`)}`;
68
+ const identifier = `${style.identifier.replace(
69
+ ogPrefix,
70
+ `${ogPrefix}${import_constants.MEDIA_SEP}${key}${negKey}${import_constants.MEDIA_SEP}`
71
+ )}`;
83
72
  const className = `.${identifier}`;
84
73
  const mediaSelector = (0, import_core_node.mediaObjectToString)(tamaguiConfig.media[key]);
85
74
  const screenStr = negate ? "not all" : "screen";
86
75
  const mediaQuery = `${screenStr} and ${mediaSelector}`;
87
76
  const precendencePrefix = mediaKeyPrecendence[key];
88
- const styleInner = style.rules[0].replace(style.identifier, identifier);
77
+ const styleInner = style.rules.map((rule) => rule.replace(style.identifier, identifier)).join(";");
89
78
  let styleRule = "";
90
79
  if (styleInner.includes("@media")) {
91
80
  styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
92
81
  } else {
93
82
  styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`;
94
83
  }
95
- return __spreadProps(__spreadValues({}, style), {
84
+ return {
85
+ ...style,
96
86
  identifier,
97
87
  className,
98
88
  rules: [styleRule]
99
- });
89
+ };
100
90
  });
101
91
  if (shouldPrintDebug === "verbose") {
102
92
  console.log(" media styles:", importance, styleObj, singleMediaStyles.map((x) => x.identifier).join(", "));
@@ -106,28 +96,41 @@ function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importan
106
96
  ternary.remove();
107
97
  return { mediaStyles, ternaryWithoutMedia: mt.ternaryWithoutMedia };
108
98
  }
109
- __name(extractMediaStyle, "extractMediaStyle");
110
- function getMediaQueryTernary(ternary, jsxPath, sourcePath) {
99
+ function getMediaQueryTernary(props, ternary, jsxPath, sourcePath) {
111
100
  if (t.isLogicalExpression(ternary.test) && ternary.test.operator === "&&") {
112
- const mediaLeft = getMediaInfoFromExpression(ternary.test.left, jsxPath, sourcePath, ternary.inlineMediaQuery);
101
+ const mediaLeft = getMediaInfoFromExpression(
102
+ props,
103
+ ternary.test.left,
104
+ jsxPath,
105
+ sourcePath,
106
+ ternary.inlineMediaQuery
107
+ );
113
108
  if (mediaLeft) {
114
- return __spreadProps(__spreadValues({}, mediaLeft), {
115
- ternaryWithoutMedia: __spreadProps(__spreadValues({}, ternary), {
109
+ return {
110
+ ...mediaLeft,
111
+ ternaryWithoutMedia: {
112
+ ...ternary,
116
113
  test: ternary.test.right
117
- })
118
- });
114
+ }
115
+ };
119
116
  }
120
117
  }
121
- const result = getMediaInfoFromExpression(ternary.test, jsxPath, sourcePath, ternary.inlineMediaQuery);
118
+ const result = getMediaInfoFromExpression(
119
+ props,
120
+ ternary.test,
121
+ jsxPath,
122
+ sourcePath,
123
+ ternary.inlineMediaQuery
124
+ );
122
125
  if (result) {
123
- return __spreadProps(__spreadValues({}, result), {
126
+ return {
127
+ ...result,
124
128
  ternaryWithoutMedia: null
125
- });
129
+ };
126
130
  }
127
131
  return null;
128
132
  }
129
- __name(getMediaQueryTernary, "getMediaQueryTernary");
130
- function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery) {
133
+ function getMediaInfoFromExpression(props, test, jsxPath, sourcePath, inlineMediaQuery) {
131
134
  var _a, _b, _c;
132
135
  if (inlineMediaQuery) {
133
136
  return {
@@ -145,7 +148,7 @@ function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery)
145
148
  const bindingNode = (_a = binding.path) == null ? void 0 : _a.node;
146
149
  if (!t.isVariableDeclarator(bindingNode) || !bindingNode.init)
147
150
  return false;
148
- if (!isValidMediaCall(jsxPath, bindingNode.init, sourcePath))
151
+ if (!isValidMediaCall(props, jsxPath, bindingNode.init, sourcePath))
149
152
  return false;
150
153
  return { key, bindingName: name };
151
154
  }
@@ -154,14 +157,13 @@ function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery)
154
157
  const node = (_c = (_b = jsxPath.scope.getBinding(test.name)) == null ? void 0 : _b.path) == null ? void 0 : _c.node;
155
158
  if (!t.isVariableDeclarator(node))
156
159
  return false;
157
- if (!node.init || !isValidMediaCall(jsxPath, node.init, sourcePath))
160
+ if (!node.init || !isValidMediaCall(props, jsxPath, node.init, sourcePath))
158
161
  return false;
159
162
  return { key, bindingName: key };
160
163
  }
161
164
  return null;
162
165
  }
163
- __name(getMediaInfoFromExpression, "getMediaInfoFromExpression");
164
- function isValidMediaCall(jsxPath, init, sourcePath) {
166
+ function isValidMediaCall(props, jsxPath, init, sourcePath) {
165
167
  if (!t.isCallExpression(init))
166
168
  return false;
167
169
  if (!t.isIdentifier(init.callee))
@@ -175,14 +177,11 @@ function isValidMediaCall(jsxPath, init, sourcePath) {
175
177
  const useMediaImport = mediaBinding.path.parent;
176
178
  if (!t.isImportDeclaration(useMediaImport))
177
179
  return false;
178
- if (useMediaImport.source.value !== "tamagui") {
179
- if (!(0, import_extractHelpers.isInsideTamagui)(sourcePath)) {
180
- return false;
181
- }
180
+ if (!(0, import_extractHelpers.isValidImport)(props, sourcePath)) {
181
+ return false;
182
182
  }
183
183
  return true;
184
184
  }
185
- __name(isValidMediaCall, "isValidMediaCall");
186
185
  // Annotate the CommonJS export names for ESM import in node:
187
186
  0 && (module.exports = {
188
187
  extractMediaStyle,
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractor/extractMediaStyle.ts"],
4
+ "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { TamaguiInternalConfig, getStylesAtomic, mediaObjectToString } from '@tamagui/core-node'\nimport type { ViewStyle } from 'react-native'\n\nimport { MEDIA_SEP } from '../constants.js'\nimport type { StyleObject, TamaguiOptionsWithFileInfo, Ternary } from '../types.js'\nimport { isPresent, isValidImport } from './extractHelpers.js'\n\nexport function extractMediaStyle(\n props: TamaguiOptionsWithFileInfo,\n ternary: Ternary,\n jsxPath: NodePath<t.JSXElement>,\n tamaguiConfig: TamaguiInternalConfig,\n sourcePath: string,\n importance = 0,\n shouldPrintDebug: boolean | 'verbose' = false\n) {\n const mt = getMediaQueryTernary(props, ternary, jsxPath, sourcePath)\n if (!mt) {\n return null\n }\n const { key } = mt\n const mq = tamaguiConfig.media[key]\n if (!mq) {\n // eslint-disable-next-line no-console\n console.error(`Media query \"${key}\" not found: ${Object.keys(tamaguiConfig.media)}`)\n return null\n }\n const getStyleObj = (styleObj: ViewStyle | null, negate = false) => {\n return styleObj ? { styleObj, negate } : null\n }\n const styleOpts = [\n getStyleObj(ternary.consequent, false),\n getStyleObj(ternary.alternate, true),\n ].filter(isPresent)\n if (shouldPrintDebug && !styleOpts.length) {\n // eslint-disable-next-line no-console\n console.log(' media query, no styles?')\n return null\n }\n // for now order first strongest\n const mediaKeys = Object.keys(tamaguiConfig.media)\n const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {\n acc[cur] = new Array(importance + 1).fill(':root').join('')\n return acc\n }, {})\n let mediaStyles: StyleObject[] = []\n for (const { styleObj, negate } of styleOpts) {\n const styles = getStylesAtomic(styleObj)\n const singleMediaStyles = styles.map((style) => {\n const negKey = negate ? '0' : ''\n const ogPrefix = style.identifier.slice(0, style.identifier.indexOf('-') + 1)\n // adds an extra separator before and after to detect later in concatClassName\n // so it goes from: \"_f-[hash]\"\n // to: \"_f-_sm0_[hash]\" or \"_f-_sm_[hash]\"\n const identifier = `${style.identifier.replace(\n ogPrefix,\n `${ogPrefix}${MEDIA_SEP}${key}${negKey}${MEDIA_SEP}`\n )}`\n const className = `.${identifier}`\n const mediaSelector = mediaObjectToString(tamaguiConfig.media[key])\n const screenStr = negate ? 'not all' : 'screen'\n const mediaQuery = `${screenStr} and ${mediaSelector}`\n const precendencePrefix = mediaKeyPrecendence[key]\n const styleInner = style.rules\n .map((rule) => rule.replace(style.identifier, identifier))\n .join(';')\n // combines media queries if they already exist\n let styleRule = ''\n if (styleInner.includes('@media')) {\n // combine\n styleRule = styleInner.replace('{', ` and ${mediaQuery} {`)\n } else {\n styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`\n }\n return {\n ...style,\n identifier,\n className,\n rules: [styleRule],\n }\n })\n if (shouldPrintDebug === 'verbose') {\n // prettier-ignore\n // eslint-disable-next-line no-console\n console.log(' media styles:', importance, styleObj, singleMediaStyles.map(x => x.identifier).join(', '))\n }\n // add to output\n mediaStyles = [...mediaStyles, ...singleMediaStyles]\n }\n // filter out\n ternary.remove()\n return { mediaStyles, ternaryWithoutMedia: mt.ternaryWithoutMedia }\n}\n\nfunction getMediaQueryTernary(\n props: TamaguiOptionsWithFileInfo,\n ternary: Ternary,\n jsxPath: NodePath<t.JSXElement>,\n sourcePath: string\n): null | {\n key: string\n bindingName: string\n ternaryWithoutMedia: Ternary | null\n} {\n // this handles unwrapping logical && media query ternarys\n // first, unwrap if it has media logicalExpression\n if (t.isLogicalExpression(ternary.test) && ternary.test.operator === '&&') {\n // *should* be normalized to always be on left side\n const mediaLeft = getMediaInfoFromExpression(\n props,\n ternary.test.left,\n jsxPath,\n sourcePath,\n ternary.inlineMediaQuery\n )\n if (mediaLeft) {\n return {\n ...mediaLeft,\n ternaryWithoutMedia: {\n ...ternary,\n test: ternary.test.right,\n },\n }\n }\n }\n // const media = useMedia()\n // ... media.sm\n const result = getMediaInfoFromExpression(\n props,\n ternary.test,\n jsxPath,\n sourcePath,\n ternary.inlineMediaQuery\n )\n if (result) {\n return {\n ...result,\n ternaryWithoutMedia: null,\n }\n }\n return null\n}\n\nfunction getMediaInfoFromExpression(\n props: TamaguiOptionsWithFileInfo,\n test: t.Expression,\n jsxPath: NodePath<t.JSXElement>,\n sourcePath: string,\n inlineMediaQuery?: string\n) {\n if (inlineMediaQuery) {\n return {\n key: inlineMediaQuery,\n bindingName: inlineMediaQuery,\n }\n }\n if (t.isMemberExpression(test) && t.isIdentifier(test.object) && t.isIdentifier(test.property)) {\n const name = test.object['name']\n const key = test.property['name']\n const bindings = jsxPath.scope.getAllBindings()\n const binding = bindings[name]\n if (!binding) return false\n const bindingNode = binding.path?.node\n if (!t.isVariableDeclarator(bindingNode) || !bindingNode.init) return false\n if (!isValidMediaCall(props, jsxPath, bindingNode.init, sourcePath)) return false\n return { key, bindingName: name }\n }\n if (t.isIdentifier(test)) {\n const key = test.name\n const node = jsxPath.scope.getBinding(test.name)?.path?.node\n if (!t.isVariableDeclarator(node)) return false\n if (!node.init || !isValidMediaCall(props, jsxPath, node.init, sourcePath)) return false\n return { key, bindingName: key }\n }\n return null\n}\n\nexport function isValidMediaCall(\n props: TamaguiOptionsWithFileInfo,\n jsxPath: NodePath<t.JSXElement>,\n init: t.Expression,\n sourcePath: string\n) {\n if (!t.isCallExpression(init)) return false\n if (!t.isIdentifier(init.callee)) return false\n // TODO could support renaming useMedia by looking up import first\n if (init.callee.name !== 'useMedia') return false\n const bindings = jsxPath.scope.getAllBindings()\n const mediaBinding = bindings['useMedia']\n if (!mediaBinding) return false\n const useMediaImport = mediaBinding.path.parent\n if (!t.isImportDeclaration(useMediaImport)) return false\n if (!isValidImport(props, sourcePath)) {\n return false\n }\n return true\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,QAAmB;AACnB,uBAA4E;AAG5E,uBAA0B;AAE1B,4BAAyC;AAElC,SAAS,kBACd,OACA,SACA,SACA,eACA,YACA,aAAa,GACb,mBAAwC,OACxC;AACA,QAAM,KAAK,qBAAqB,OAAO,SAAS,SAAS,UAAU;AACnE,MAAI,CAAC,IAAI;AACP,WAAO;AAAA,EACT;AACA,QAAM,EAAE,IAAI,IAAI;AAChB,QAAM,KAAK,cAAc,MAAM;AAC/B,MAAI,CAAC,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nD,MAAI,KAAC,qCAAc,OAAO,UAAU,GAAG;AACrC,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -1,27 +1,10 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
6
  var __getProtoOf = Object.getPrototypeOf;
9
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
8
  var __export = (target, all) => {
26
9
  for (var name in all)
27
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -34,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
34
17
  }
35
18
  return to;
36
19
  };
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
38
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
25
  var extractToClassNames_exports = {};
40
26
  __export(extractToClassNames_exports, {
@@ -49,39 +35,37 @@ var t = __toESM(require("@babel/types"));
49
35
  var import_core_node = require("@tamagui/core-node");
50
36
  var import_helpers = require("@tamagui/helpers");
51
37
  var import_invariant = __toESM(require("invariant"));
52
- var import_constants = require("../constants");
53
- var import_babelParse = require("./babelParse");
54
- var import_buildClassName = require("./buildClassName");
55
- var import_ensureImportingConcat = require("./ensureImportingConcat");
56
- var import_extractHelpers = require("./extractHelpers");
57
- var import_extractMediaStyle = require("./extractMediaStyle");
58
- var import_getPrefixLogs = require("./getPrefixLogs");
59
- var import_hoistClassNames = require("./hoistClassNames");
60
- var import_literalToAst = require("./literalToAst");
61
- var import_logLines = require("./logLines");
62
- var import_timer = require("./timer");
38
+ var import_babelParse = require("./babelParse.js");
39
+ var import_buildClassName = require("./buildClassName.js");
40
+ var import_ensureImportingConcat = require("./ensureImportingConcat.js");
41
+ var import_extractHelpers = require("./extractHelpers.js");
42
+ var import_extractMediaStyle = require("./extractMediaStyle.js");
43
+ var import_getPrefixLogs = require("./getPrefixLogs.js");
44
+ var import_hoistClassNames = require("./hoistClassNames.js");
45
+ var import_logLines = require("./logLines.js");
46
+ var import_timer = require("./timer.js");
63
47
  const mergeStyleGroups = {
64
48
  shadowOpacity: true,
65
49
  shadowRadius: true,
66
50
  shadowColor: true,
67
51
  shadowOffset: true
68
52
  };
69
- function extractToClassNames({
70
- loader,
53
+ async function extractToClassNames({
71
54
  extractor,
72
55
  source,
73
56
  sourcePath,
74
57
  options,
75
- shouldPrintDebug,
76
- cssLoaderPath,
77
- threaded,
78
- cssPath
58
+ shouldPrintDebug
79
59
  }) {
80
60
  const tm = (0, import_timer.timer)();
81
61
  if (typeof source !== "string") {
82
62
  throw new Error("`source` must be a string of javascript");
83
63
  }
84
- (0, import_invariant.default)(typeof sourcePath === "string" && path.isAbsolute(sourcePath), "`sourcePath` must be an absolute path to a .js file");
64
+ (0, import_invariant.default)(
65
+ typeof sourcePath === "string" && path.isAbsolute(sourcePath),
66
+ "`sourcePath` must be an absolute path to a .js file"
67
+ );
68
+ await extractor.loadTamagui(options);
85
69
  const shouldLogTiming = options.logTimings ?? true;
86
70
  const start = Date.now();
87
71
  const mem = shouldLogTiming ? process.memoryUsage() : null;
@@ -96,10 +80,15 @@ function extractToClassNames({
96
80
  const cssMap = /* @__PURE__ */ new Map();
97
81
  const existingHoists = {};
98
82
  let hasFlattened = false;
99
- const res = extractor.parse(ast, __spreadProps(__spreadValues({
83
+ const res = await extractor.parse(ast, {
84
+ shouldPrintDebug,
85
+ ...options,
100
86
  sourcePath,
101
- shouldPrintDebug
102
- }, options), {
87
+ target: "html",
88
+ extractStyledDefinitions: true,
89
+ onStyleRule(identifier, rules) {
90
+ cssMap.set(`.${identifier}`, { css: rules.join(";"), commentTexts: [] });
91
+ },
103
92
  getFlattenedNode: ({ tag }) => {
104
93
  hasFlattened = true;
105
94
  return tag;
@@ -113,19 +102,32 @@ function extractToClassNames({
113
102
  filePath,
114
103
  lineNumbers,
115
104
  programPath,
116
- isFlattened
105
+ isFlattened,
106
+ completeProps,
107
+ staticConfig
117
108
  }) => {
118
109
  var _a;
110
+ if (staticConfig.acceptsClassName === false) {
111
+ if (shouldPrintDebug) {
112
+ console.log(`bail, acceptsClassName is false`);
113
+ }
114
+ return;
115
+ }
116
+ const didFlattenThisTag = hasFlattened;
117
+ hasFlattened = false;
119
118
  let finalClassNames = [];
120
- let finalAttrs = [];
119
+ const finalAttrs = [];
121
120
  let finalStyles = [];
122
- const viewStyles = {};
121
+ let viewStyles = {};
123
122
  for (const attr of attrs) {
124
123
  if (attr.type === "style") {
125
- Object.assign(viewStyles, attr.value);
124
+ viewStyles = {
125
+ ...viewStyles,
126
+ ...attr.value
127
+ };
126
128
  }
127
129
  }
128
- const ensureNeededPrevStyle = /* @__PURE__ */ __name((style) => {
130
+ const ensureNeededPrevStyle = (style) => {
129
131
  const keys = Object.keys(style);
130
132
  if (!keys.some((key) => mergeStyleGroups[key])) {
131
133
  return style;
@@ -136,8 +138,8 @@ function extractToClassNames({
136
138
  }
137
139
  }
138
140
  return style;
139
- }, "ensureNeededPrevStyle");
140
- const addStyles = /* @__PURE__ */ __name((style) => {
141
+ };
142
+ const addStyles = (style) => {
141
143
  if (!style)
142
144
  return [];
143
145
  const styleWithPrev = ensureNeededPrevStyle(style);
@@ -146,34 +148,26 @@ function extractToClassNames({
146
148
  finalStyles = [...finalStyles, ...res2];
147
149
  }
148
150
  return res2;
149
- }, "addStyles");
151
+ };
150
152
  let lastMediaImportance = 1;
151
153
  for (const attr of attrs) {
152
154
  switch (attr.type) {
153
- case "style":
155
+ case "style": {
154
156
  if (!isFlattened) {
155
- const { hoverStyle, pressStyle, focusStyle } = attr.value;
156
- const pseudos = [
157
- ["hoverStyle", hoverStyle],
158
- ["pressStyle", pressStyle],
159
- ["focusStyle", focusStyle]
160
- ];
161
- const styles2 = (0, import_core_node.getStylesAtomic)(attr.value, {
162
- splitTransforms: true
163
- });
157
+ const styles2 = (0, import_core_node.getStylesAtomic)(attr.value);
164
158
  finalStyles = [...finalStyles, ...styles2];
165
- for (const [key, value] of pseudos) {
166
- if (value && Object.keys(value).length) {
167
- finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer((0, import_literalToAst.literalToAst)(value))));
168
- }
169
- }
170
159
  for (const style of styles2) {
171
- finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(style.property), t.stringLiteral(style.identifier)));
160
+ const prop = style.pseudo ? `${style.property}-${style.pseudo}` : style.property;
161
+ finalAttrs.push(
162
+ t.jsxAttribute(t.jsxIdentifier(prop), t.stringLiteral(style.identifier))
163
+ );
172
164
  }
173
165
  } else {
174
166
  const styles2 = addStyles(attr.value);
175
167
  const newClassNames = (0, import_helpers.concatClassName)(styles2.map((x) => x.identifier).join(" "));
176
- const existing = finalClassNames.find((x) => x.type == "StringLiteral");
168
+ const existing = finalClassNames.find(
169
+ (x) => x.type == "StringLiteral"
170
+ );
177
171
  if (existing) {
178
172
  existing.value = `${existing.value} ${newClassNames}`;
179
173
  } else {
@@ -181,11 +175,18 @@ function extractToClassNames({
181
175
  }
182
176
  }
183
177
  break;
184
- case "attr":
178
+ }
179
+ case "attr": {
185
180
  const val = attr.value;
186
181
  if (t.isJSXSpreadAttribute(val)) {
187
182
  if ((0, import_extractHelpers.isSimpleSpread)(val)) {
188
- finalClassNames.push(t.logicalExpression("&&", val.argument, t.memberExpression(val.argument, t.identifier("className"))));
183
+ finalClassNames.push(
184
+ t.logicalExpression(
185
+ "&&",
186
+ val.argument,
187
+ t.memberExpression(val.argument, t.identifier("className"))
188
+ )
189
+ );
189
190
  }
190
191
  } else if (val.name.name === "className") {
191
192
  const value = val.value;
@@ -201,15 +202,32 @@ function extractToClassNames({
201
202
  }
202
203
  finalAttrs.push(val);
203
204
  break;
204
- case "ternary":
205
- const mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(attr.value, jsxPath, extractor.getTamagui(), sourcePath, lastMediaImportance, shouldPrintDebug);
205
+ }
206
+ case "ternary": {
207
+ const mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(
208
+ { ...options, sourcePath },
209
+ attr.value,
210
+ jsxPath,
211
+ extractor.getTamagui(),
212
+ sourcePath,
213
+ lastMediaImportance,
214
+ shouldPrintDebug
215
+ );
206
216
  if (shouldPrintDebug) {
207
217
  if (mediaExtraction) {
208
- console.log("ternary (mediaStyles)", ((_a = mediaExtraction.ternaryWithoutMedia) == null ? void 0 : _a.inlineMediaQuery) ?? "", mediaExtraction.mediaStyles.map((x) => x.identifier).join("."));
218
+ console.log(
219
+ "ternary (mediaStyles)",
220
+ ((_a = mediaExtraction.ternaryWithoutMedia) == null ? void 0 : _a.inlineMediaQuery) ?? "",
221
+ mediaExtraction.mediaStyles.map((x) => x.identifier).join(".")
222
+ );
209
223
  }
210
224
  }
211
225
  if (!mediaExtraction) {
212
- addTernaryStyle(attr.value, addStyles(attr.value.consequent), addStyles(attr.value.alternate));
226
+ addTernaryStyle(
227
+ attr.value,
228
+ addStyles(attr.value.consequent),
229
+ addStyles(attr.value.alternate)
230
+ );
213
231
  continue;
214
232
  }
215
233
  lastMediaImportance++;
@@ -225,44 +243,77 @@ function extractToClassNames({
225
243
  ];
226
244
  }
227
245
  break;
246
+ }
228
247
  }
229
248
  }
230
249
  function addTernaryStyle(ternary, a, b) {
231
250
  const cCN = a.map((x) => x.identifier).join(" ");
232
251
  const aCN = b.map((x) => x.identifier).join(" ");
233
252
  if (a.length && b.length) {
234
- finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN)));
253
+ finalClassNames.push(
254
+ t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))
255
+ );
235
256
  } else {
236
- finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(" " + cCN), t.stringLiteral(" " + aCN)));
257
+ finalClassNames.push(
258
+ t.conditionalExpression(
259
+ ternary.test,
260
+ t.stringLiteral(" " + cCN),
261
+ t.stringLiteral(" " + aCN)
262
+ )
263
+ );
237
264
  }
238
265
  }
239
- __name(addTernaryStyle, "addTernaryStyle");
240
266
  if (shouldPrintDebug) {
241
- console.log(" finalClassNames\n", (0, import_logLines.logLines)(finalClassNames.map((x) => x["value"]).join(" ")));
267
+ console.log(
268
+ " finalClassNames\n",
269
+ (0, import_logLines.logLines)(finalClassNames.map((x) => x["value"]).join(" "))
270
+ );
242
271
  }
243
272
  node.attributes = finalAttrs;
244
273
  if (finalClassNames.length) {
245
- let names = (0, import_buildClassName.buildClassName)(finalClassNames);
246
- if (t.isStringLiteral(names)) {
247
- names.value = (0, import_helpers.concatClassName)(names.value);
248
- }
274
+ const extraClassNames = (() => {
275
+ let value = "";
276
+ if (!isFlattened) {
277
+ return value;
278
+ }
279
+ if (process.env.TAMAGUI_DEBUG_OPTIMIZATIONS) {
280
+ value += `is_tamagui_flattened`;
281
+ }
282
+ if (staticConfig.componentName) {
283
+ value += ` is_${staticConfig.componentName}`;
284
+ }
285
+ if (staticConfig.isText) {
286
+ let family = completeProps.fontFamily;
287
+ if (family[0] === "$") {
288
+ family = family.slice(1);
289
+ }
290
+ value += ` font_${family}`;
291
+ }
292
+ return value;
293
+ })();
294
+ const names = (0, import_buildClassName.buildClassName)(finalClassNames, extraClassNames);
249
295
  const nameExpr = names ? (0, import_hoistClassNames.hoistClassNames)(jsxPath, existingHoists, names) : null;
250
296
  let expr = nameExpr;
251
297
  if (nameExpr && !t.isIdentifier(nameExpr)) {
252
- if (!hasFlattened) {
298
+ if (!didFlattenThisTag) {
253
299
  } else {
254
300
  (0, import_ensureImportingConcat.ensureImportingConcat)(programPath);
255
- const simpleSpreads = attrs.filter((x) => t.isJSXSpreadAttribute(x.value) && (0, import_extractHelpers.isSimpleSpread)(x.value));
256
- expr = t.callExpression(t.identifier(import_constants.CONCAT_CLASSNAME_IMPORT), [
301
+ const simpleSpreads = attrs.filter(
302
+ (x) => t.isJSXSpreadAttribute(x.value) && (0, import_extractHelpers.isSimpleSpread)(x.value)
303
+ );
304
+ expr = t.callExpression(t.identifier("concatClassName"), [
257
305
  expr,
258
306
  ...simpleSpreads.map((val) => val.value["argument"])
259
307
  ]);
260
308
  }
261
309
  }
262
- node.attributes.push(t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr)));
310
+ node.attributes.push(
311
+ t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr))
312
+ );
263
313
  }
264
314
  const comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName);
265
- for (const { className, rules, identifier, value } of finalStyles) {
315
+ for (const { identifier, rules } of finalStyles) {
316
+ const className = `.${identifier}`;
266
317
  if (cssMap.has(className)) {
267
318
  if (comment) {
268
319
  const val = cssMap.get(className);
@@ -270,53 +321,54 @@ function extractToClassNames({
270
321
  cssMap.set(className, val);
271
322
  }
272
323
  } else if (rules.length) {
273
- if (rules.length > 1) {
274
- console.log(" rules error", { rules });
275
- throw new Error(`Shouldn't have more than one rule`);
276
- }
277
324
  cssMap.set(className, {
278
- css: rules[0],
325
+ css: rules.join("\n"),
279
326
  commentTexts: [comment]
280
327
  });
281
328
  }
282
329
  }
283
330
  }
284
- }));
285
- if (!res || !res.modified && !res.optimized && !res.flattened) {
331
+ });
332
+ if (!res || !res.modified && !res.optimized && !res.flattened && !res.styled) {
286
333
  if (shouldPrintDebug) {
287
334
  console.log("no res or none modified", res);
288
335
  }
289
336
  return null;
290
337
  }
291
338
  const styles = Array.from(cssMap.values()).map((x) => x.css).join("\n").trim();
292
- if (styles) {
293
- const cssQuery = threaded ? `cssData=${Buffer.from(styles).toString("base64")}` : `cssPath=${cssPath}`;
294
- const remReq = loader.remainingRequest;
295
- const importPath = `${cssPath}!=!${cssLoaderPath}?${cssQuery}!${remReq}`;
296
- ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)));
297
- }
298
- const result = (0, import_generator.default)(ast, {
299
- concise: false,
300
- filename: sourcePath,
301
- retainLines: false,
302
- sourceFileName: sourcePath,
303
- sourceMaps: true
304
- }, source);
339
+ const result = (0, import_generator.default)(
340
+ ast,
341
+ {
342
+ concise: false,
343
+ filename: sourcePath,
344
+ retainLines: false,
345
+ sourceFileName: sourcePath,
346
+ sourceMaps: true
347
+ },
348
+ source
349
+ );
305
350
  if (shouldPrintDebug) {
306
- console.log("\n -------- output code ------- \n\n", result.code.split("\n").filter((x) => !x.startsWith("//")).join("\n"));
351
+ console.log(
352
+ "\n -------- output code ------- \n\n",
353
+ result.code.split("\n").filter((x) => !x.startsWith("//")).join("\n")
354
+ );
307
355
  console.log("\n -------- output style -------- \n\n", styles);
308
356
  }
309
357
  if (shouldLogTiming) {
310
358
  const memUsed = mem ? Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10 : 0;
311
359
  const path2 = (0, import_path.basename)(sourcePath).replace(/\.[jt]sx?$/, "").slice(0, 22).trim().padStart(24);
360
+ const numStyled = `${res.styled}`.padStart(3);
312
361
  const numOptimized = `${res.optimized}`.padStart(3);
313
362
  const numFound = `${res.found}`.padStart(3);
314
363
  const numFlattened = `${res.flattened}`.padStart(3);
315
364
  const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : "";
316
365
  const timing = Date.now() - start;
317
- const timingWarning = timing > 50 ? "\u26A0\uFE0F" : timing > 150 ? "\u2622\uFE0F" : "";
318
- const timingStr = `${timing}ms${timingWarning}`.padStart(6);
319
- console.log(`${(0, import_getPrefixLogs.getPrefixLogs)(options)} ${path2} ${numFound} \xB7 ${numOptimized} \xB7 ${numFlattened} ${timingStr} ${memory ? `(${memory})` : ""}`);
366
+ const timingStr = `${timing}ms`.padStart(6);
367
+ const pre = (0, import_getPrefixLogs.getPrefixLogs)(options);
368
+ const memStr = memory ? `(${memory})` : "";
369
+ console.log(
370
+ `${pre} ${path2} ${numFound} \xB7 ${numOptimized} \xB7 ${numFlattened} \xB7 ${numStyled} ${timingStr} ${memStr}`
371
+ );
320
372
  }
321
373
  return {
322
374
  ast,
@@ -325,7 +377,6 @@ function extractToClassNames({
325
377
  map: result.map
326
378
  };
327
379
  }
328
- __name(extractToClassNames, "extractToClassNames");
329
380
  // Annotate the CommonJS export names for ESM import in node:
330
381
  0 && (module.exports = {
331
382
  extractToClassNames