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

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 -1
  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 +20 -6
  8. package/dist/extractor/buildClassName.js.map +7 -0
  9. package/dist/{cjs/extractor → extractor}/createEvaluator.js +17 -12
  10. package/dist/extractor/createEvaluator.js.map +7 -0
  11. package/dist/extractor/createExtractor.js +1560 -0
  12. package/dist/extractor/createExtractor.js.map +7 -0
  13. package/dist/{cjs/extractor → extractor}/ensureImportingConcat.js +22 -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 +20 -19
  18. package/dist/extractor/extractHelpers.js.map +7 -0
  19. package/dist/{cjs/extractor → extractor}/extractMediaStyle.js +38 -39
  20. package/dist/extractor/extractMediaStyle.js.map +7 -0
  21. package/dist/{cjs/extractor → extractor}/extractToClassNames.js +164 -101
  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 +44 -35
  64. package/src/constants.ts +15 -0
  65. package/src/extractor/accessSafe.ts +18 -0
  66. package/src/extractor/babelParse.ts +27 -0
  67. package/src/extractor/buildClassName.ts +61 -0
  68. package/src/extractor/createEvaluator.ts +73 -0
  69. package/src/extractor/createExtractor.ts +2032 -0
  70. package/src/extractor/ensureImportingConcat.ts +39 -0
  71. package/src/extractor/evaluateAstNode.ts +121 -0
  72. package/src/extractor/extractHelpers.ts +120 -0
  73. package/src/extractor/extractMediaStyle.ts +192 -0
  74. package/src/extractor/extractToClassNames.ts +456 -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 +91 -0
  94. package/src/webpackPlugin.ts +9 -0
  95. package/tamagui.tsconfig.json +5 -0
  96. package/types/constants.d.ts +1 -0
  97. package/types/extractor/buildClassName.d.ts +1 -1
  98. package/types/extractor/createEvaluator.d.ts +2 -2
  99. package/types/extractor/createExtractor.d.ts +25 -10
  100. package/types/extractor/extractHelpers.d.ts +2 -2
  101. package/types/extractor/extractMediaStyle.d.ts +1 -1
  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 +25 -30
  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,8 +30,8 @@ __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");
33
+ var import_constants = require("../constants.js");
34
+ var import_extractHelpers = require("./extractHelpers.js");
49
35
  function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importance = 0, shouldPrintDebug = false) {
50
36
  const mt = getMediaQueryTernary(ternary, jsxPath, sourcePath);
51
37
  if (!mt) {
@@ -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,27 +96,38 @@ 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
99
  function getMediaQueryTernary(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
+ ternary.test.left,
103
+ jsxPath,
104
+ sourcePath,
105
+ ternary.inlineMediaQuery
106
+ );
113
107
  if (mediaLeft) {
114
- return __spreadProps(__spreadValues({}, mediaLeft), {
115
- ternaryWithoutMedia: __spreadProps(__spreadValues({}, ternary), {
108
+ return {
109
+ ...mediaLeft,
110
+ ternaryWithoutMedia: {
111
+ ...ternary,
116
112
  test: ternary.test.right
117
- })
118
- });
113
+ }
114
+ };
119
115
  }
120
116
  }
121
- const result = getMediaInfoFromExpression(ternary.test, jsxPath, sourcePath, ternary.inlineMediaQuery);
117
+ const result = getMediaInfoFromExpression(
118
+ ternary.test,
119
+ jsxPath,
120
+ sourcePath,
121
+ ternary.inlineMediaQuery
122
+ );
122
123
  if (result) {
123
- return __spreadProps(__spreadValues({}, result), {
124
+ return {
125
+ ...result,
124
126
  ternaryWithoutMedia: null
125
- });
127
+ };
126
128
  }
127
129
  return null;
128
130
  }
129
- __name(getMediaQueryTernary, "getMediaQueryTernary");
130
131
  function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery) {
131
132
  var _a, _b, _c;
132
133
  if (inlineMediaQuery) {
@@ -160,7 +161,6 @@ function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery)
160
161
  }
161
162
  return null;
162
163
  }
163
- __name(getMediaInfoFromExpression, "getMediaInfoFromExpression");
164
164
  function isValidMediaCall(jsxPath, init, sourcePath) {
165
165
  if (!t.isCallExpression(init))
166
166
  return false;
@@ -182,7 +182,6 @@ function isValidMediaCall(jsxPath, init, sourcePath) {
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 { ViewStyle } from 'react-native'\n\nimport { MEDIA_SEP } from '../constants.js'\nimport type { StyleObject, Ternary } from '../types.js'\nimport { isInsideTamagui, isPresent } from './extractHelpers.js'\n\nexport function extractMediaStyle(\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(ternary, jsxPath, sourcePath)\n if (!mt) {\n return null\n }\n const { key } = mt\n const mq = tamaguiConfig.media[key]\n if (!mq) {\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 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 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 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 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 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 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(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(jsxPath, node.init, sourcePath)) return false\n return { key, bindingName: key }\n }\n return null\n}\n\nexport function isValidMediaCall(\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 (useMediaImport.source.value !== 'tamagui') {\n if (!isInsideTamagui(sourcePath)) {\n return false\n }\n }\n return true\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,QAAmB;AACnB,uBAA4E;AAG5E,uBAA0B;AAE1B,4BAA2C;AAEpC,SAAS,kBACd,SACA,SACA,eACA,YACA,aAAa,GACb,mBAAwC,OACxC;AACA,QAAM,KAAK,qBAAqB,SAAS,SAAS,UAAU;AAC5D,MAAI,CAAC,IAAI;AACP,WAAO;AAAA,EACT;AACA,QAAM,EAAE,IAAI,IAAI;AAChB,QAAM,KAAK,cAAc,MAAM;AAC/B,MAAI,CAAC,IAAI;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gB,UAAU,GAAG;AAChC,aAAO;AAAA,IACT;AAAA,EACF;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,38 @@ 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_constants = require("../constants.js");
39
+ var import_babelParse = require("./babelParse.js");
40
+ var import_buildClassName = require("./buildClassName.js");
41
+ var import_ensureImportingConcat = require("./ensureImportingConcat.js");
42
+ var import_extractHelpers = require("./extractHelpers.js");
43
+ var import_extractMediaStyle = require("./extractMediaStyle.js");
44
+ var import_getPrefixLogs = require("./getPrefixLogs.js");
45
+ var import_hoistClassNames = require("./hoistClassNames.js");
46
+ var import_logLines = require("./logLines.js");
47
+ var import_timer = require("./timer.js");
63
48
  const mergeStyleGroups = {
64
49
  shadowOpacity: true,
65
50
  shadowRadius: true,
66
51
  shadowColor: true,
67
52
  shadowOffset: true
68
53
  };
69
- function extractToClassNames({
70
- loader,
54
+ async function extractToClassNames({
71
55
  extractor,
72
56
  source,
73
57
  sourcePath,
74
58
  options,
75
- shouldPrintDebug,
76
- cssLoaderPath,
77
- threaded,
78
- cssPath
59
+ shouldPrintDebug
79
60
  }) {
80
61
  const tm = (0, import_timer.timer)();
81
62
  if (typeof source !== "string") {
82
63
  throw new Error("`source` must be a string of javascript");
83
64
  }
84
- (0, import_invariant.default)(typeof sourcePath === "string" && path.isAbsolute(sourcePath), "`sourcePath` must be an absolute path to a .js file");
65
+ (0, import_invariant.default)(
66
+ typeof sourcePath === "string" && path.isAbsolute(sourcePath),
67
+ "`sourcePath` must be an absolute path to a .js file"
68
+ );
69
+ await extractor.loadTamagui(options);
85
70
  const shouldLogTiming = options.logTimings ?? true;
86
71
  const start = Date.now();
87
72
  const mem = shouldLogTiming ? process.memoryUsage() : null;
@@ -96,10 +81,15 @@ function extractToClassNames({
96
81
  const cssMap = /* @__PURE__ */ new Map();
97
82
  const existingHoists = {};
98
83
  let hasFlattened = false;
99
- const res = extractor.parse(ast, __spreadProps(__spreadValues({
84
+ const res = await extractor.parse(ast, {
100
85
  sourcePath,
101
- shouldPrintDebug
102
- }, options), {
86
+ shouldPrintDebug,
87
+ ...options,
88
+ target: "html",
89
+ extractStyledDefinitions: true,
90
+ onStyleRule(identifier, rules) {
91
+ cssMap.set(`.${identifier}`, { css: rules.join(";"), commentTexts: [] });
92
+ },
103
93
  getFlattenedNode: ({ tag }) => {
104
94
  hasFlattened = true;
105
95
  return tag;
@@ -113,19 +103,32 @@ function extractToClassNames({
113
103
  filePath,
114
104
  lineNumbers,
115
105
  programPath,
116
- isFlattened
106
+ isFlattened,
107
+ completeProps,
108
+ staticConfig
117
109
  }) => {
118
110
  var _a;
111
+ if (staticConfig.acceptsClassName === false) {
112
+ if (shouldPrintDebug) {
113
+ console.log(`bail, acceptsClassName is false`);
114
+ }
115
+ return;
116
+ }
117
+ const didFlattenThisTag = hasFlattened;
118
+ hasFlattened = false;
119
119
  let finalClassNames = [];
120
- let finalAttrs = [];
120
+ const finalAttrs = [];
121
121
  let finalStyles = [];
122
- const viewStyles = {};
122
+ let viewStyles = {};
123
123
  for (const attr of attrs) {
124
124
  if (attr.type === "style") {
125
- Object.assign(viewStyles, attr.value);
125
+ viewStyles = {
126
+ ...viewStyles,
127
+ ...attr.value
128
+ };
126
129
  }
127
130
  }
128
- const ensureNeededPrevStyle = /* @__PURE__ */ __name((style) => {
131
+ const ensureNeededPrevStyle = (style) => {
129
132
  const keys = Object.keys(style);
130
133
  if (!keys.some((key) => mergeStyleGroups[key])) {
131
134
  return style;
@@ -136,8 +139,8 @@ function extractToClassNames({
136
139
  }
137
140
  }
138
141
  return style;
139
- }, "ensureNeededPrevStyle");
140
- const addStyles = /* @__PURE__ */ __name((style) => {
142
+ };
143
+ const addStyles = (style) => {
141
144
  if (!style)
142
145
  return [];
143
146
  const styleWithPrev = ensureNeededPrevStyle(style);
@@ -146,34 +149,26 @@ function extractToClassNames({
146
149
  finalStyles = [...finalStyles, ...res2];
147
150
  }
148
151
  return res2;
149
- }, "addStyles");
152
+ };
150
153
  let lastMediaImportance = 1;
151
154
  for (const attr of attrs) {
152
155
  switch (attr.type) {
153
- case "style":
156
+ case "style": {
154
157
  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
- });
158
+ const styles2 = (0, import_core_node.getStylesAtomic)(attr.value);
164
159
  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
160
  for (const style of styles2) {
171
- finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(style.property), t.stringLiteral(style.identifier)));
161
+ const prop = style.pseudo ? `${style.property}-${style.pseudo}` : style.property;
162
+ finalAttrs.push(
163
+ t.jsxAttribute(t.jsxIdentifier(prop), t.stringLiteral(style.identifier))
164
+ );
172
165
  }
173
166
  } else {
174
167
  const styles2 = addStyles(attr.value);
175
168
  const newClassNames = (0, import_helpers.concatClassName)(styles2.map((x) => x.identifier).join(" "));
176
- const existing = finalClassNames.find((x) => x.type == "StringLiteral");
169
+ const existing = finalClassNames.find(
170
+ (x) => x.type == "StringLiteral"
171
+ );
177
172
  if (existing) {
178
173
  existing.value = `${existing.value} ${newClassNames}`;
179
174
  } else {
@@ -181,11 +176,18 @@ function extractToClassNames({
181
176
  }
182
177
  }
183
178
  break;
184
- case "attr":
179
+ }
180
+ case "attr": {
185
181
  const val = attr.value;
186
182
  if (t.isJSXSpreadAttribute(val)) {
187
183
  if ((0, import_extractHelpers.isSimpleSpread)(val)) {
188
- finalClassNames.push(t.logicalExpression("&&", val.argument, t.memberExpression(val.argument, t.identifier("className"))));
184
+ finalClassNames.push(
185
+ t.logicalExpression(
186
+ "&&",
187
+ val.argument,
188
+ t.memberExpression(val.argument, t.identifier("className"))
189
+ )
190
+ );
189
191
  }
190
192
  } else if (val.name.name === "className") {
191
193
  const value = val.value;
@@ -201,15 +203,31 @@ function extractToClassNames({
201
203
  }
202
204
  finalAttrs.push(val);
203
205
  break;
204
- case "ternary":
205
- const mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(attr.value, jsxPath, extractor.getTamagui(), sourcePath, lastMediaImportance, shouldPrintDebug);
206
+ }
207
+ case "ternary": {
208
+ const mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(
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,85 @@ 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) {
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
+ })();
245
294
  let names = (0, import_buildClassName.buildClassName)(finalClassNames);
246
- if (t.isStringLiteral(names)) {
247
- names.value = (0, import_helpers.concatClassName)(names.value);
295
+ if (names) {
296
+ if (t.isStringLiteral(names)) {
297
+ names.value = (0, import_helpers.concatClassName)(names.value);
298
+ names.value = `${extraClassNames} ${names.value}`;
299
+ } else {
300
+ names = t.binaryExpression("+", t.stringLiteral(extraClassNames), names);
301
+ }
248
302
  }
249
303
  const nameExpr = names ? (0, import_hoistClassNames.hoistClassNames)(jsxPath, existingHoists, names) : null;
250
304
  let expr = nameExpr;
251
305
  if (nameExpr && !t.isIdentifier(nameExpr)) {
252
- if (!hasFlattened) {
306
+ if (!didFlattenThisTag) {
253
307
  } else {
254
308
  (0, import_ensureImportingConcat.ensureImportingConcat)(programPath);
255
- const simpleSpreads = attrs.filter((x) => t.isJSXSpreadAttribute(x.value) && (0, import_extractHelpers.isSimpleSpread)(x.value));
309
+ const simpleSpreads = attrs.filter(
310
+ (x) => t.isJSXSpreadAttribute(x.value) && (0, import_extractHelpers.isSimpleSpread)(x.value)
311
+ );
256
312
  expr = t.callExpression(t.identifier(import_constants.CONCAT_CLASSNAME_IMPORT), [
257
313
  expr,
258
314
  ...simpleSpreads.map((val) => val.value["argument"])
259
315
  ]);
260
316
  }
261
317
  }
262
- node.attributes.push(t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr)));
318
+ node.attributes.push(
319
+ t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr))
320
+ );
263
321
  }
264
322
  const comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName);
265
- for (const { className, rules, identifier, value } of finalStyles) {
323
+ for (const { identifier, rules } of finalStyles) {
324
+ const className = `.${identifier}`;
266
325
  if (cssMap.has(className)) {
267
326
  if (comment) {
268
327
  const val = cssMap.get(className);
@@ -281,42 +340,47 @@ function extractToClassNames({
281
340
  }
282
341
  }
283
342
  }
284
- }));
285
- if (!res || !res.modified && !res.optimized && !res.flattened) {
343
+ });
344
+ if (!res || !res.modified && !res.optimized && !res.flattened && !res.styled) {
286
345
  if (shouldPrintDebug) {
287
346
  console.log("no res or none modified", res);
288
347
  }
289
348
  return null;
290
349
  }
291
350
  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);
351
+ const result = (0, import_generator.default)(
352
+ ast,
353
+ {
354
+ concise: false,
355
+ filename: sourcePath,
356
+ retainLines: false,
357
+ sourceFileName: sourcePath,
358
+ sourceMaps: true
359
+ },
360
+ source
361
+ );
305
362
  if (shouldPrintDebug) {
306
- console.log("\n -------- output code ------- \n\n", result.code.split("\n").filter((x) => !x.startsWith("//")).join("\n"));
363
+ console.log(
364
+ "\n -------- output code ------- \n\n",
365
+ result.code.split("\n").filter((x) => !x.startsWith("//")).join("\n")
366
+ );
307
367
  console.log("\n -------- output style -------- \n\n", styles);
308
368
  }
309
369
  if (shouldLogTiming) {
310
370
  const memUsed = mem ? Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10 : 0;
311
371
  const path2 = (0, import_path.basename)(sourcePath).replace(/\.[jt]sx?$/, "").slice(0, 22).trim().padStart(24);
372
+ const numStyled = `${res.styled}`.padStart(3);
312
373
  const numOptimized = `${res.optimized}`.padStart(3);
313
374
  const numFound = `${res.found}`.padStart(3);
314
375
  const numFlattened = `${res.flattened}`.padStart(3);
315
376
  const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : "";
316
377
  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})` : ""}`);
378
+ const timingStr = `${timing}ms`.padStart(6);
379
+ const pre = (0, import_getPrefixLogs.getPrefixLogs)(options);
380
+ const memStr = memory ? `(${memory})` : "";
381
+ console.log(
382
+ `${pre} ${path2} ${numFound} \xB7 ${numOptimized} \xB7 ${numFlattened} \xB7 ${numStyled} ${timingStr} ${memStr}`
383
+ );
320
384
  }
321
385
  return {
322
386
  ast,
@@ -325,7 +389,6 @@ function extractToClassNames({
325
389
  map: result.map
326
390
  };
327
391
  }
328
- __name(extractToClassNames, "extractToClassNames");
329
392
  // Annotate the CommonJS export names for ESM import in node:
330
393
  0 && (module.exports = {
331
394
  extractToClassNames