@tamagui/static 1.89.26 → 1.89.27-1708113113238

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/dist/cjs/constants.native.js +4 -4
  2. package/dist/cjs/constants.native.js.map +3 -3
  3. package/dist/cjs/extractor/accessSafe.native.js +1 -5
  4. package/dist/cjs/extractor/accessSafe.native.js.map +3 -3
  5. package/dist/cjs/extractor/babelParse.native.js +5 -8
  6. package/dist/cjs/extractor/babelParse.native.js.map +3 -3
  7. package/dist/cjs/extractor/buildClassName.native.js +31 -42
  8. package/dist/cjs/extractor/buildClassName.native.js.map +3 -3
  9. package/dist/cjs/extractor/bundle.js +6 -4
  10. package/dist/cjs/extractor/bundle.js.map +1 -1
  11. package/dist/cjs/extractor/bundle.native.js +321 -56
  12. package/dist/cjs/extractor/bundle.native.js.map +3 -3
  13. package/dist/cjs/extractor/bundleConfig.native.js +499 -187
  14. package/dist/cjs/extractor/bundleConfig.native.js.map +3 -3
  15. package/dist/cjs/extractor/createEvaluator.native.js +9 -11
  16. package/dist/cjs/extractor/createEvaluator.native.js.map +3 -3
  17. package/dist/cjs/extractor/createExtractor.native.js +1240 -906
  18. package/dist/cjs/extractor/createExtractor.native.js.map +3 -3
  19. package/dist/cjs/extractor/ensureImportingConcat.native.js +11 -17
  20. package/dist/cjs/extractor/ensureImportingConcat.native.js.map +3 -3
  21. package/dist/cjs/extractor/esbuildAliasPlugin.native.js +22 -11
  22. package/dist/cjs/extractor/esbuildAliasPlugin.native.js.map +3 -3
  23. package/dist/cjs/extractor/evaluateAstNode.native.js +15 -21
  24. package/dist/cjs/extractor/evaluateAstNode.native.js.map +3 -3
  25. package/dist/cjs/extractor/extractHelpers.native.js +146 -38
  26. package/dist/cjs/extractor/extractHelpers.native.js.map +3 -3
  27. package/dist/cjs/extractor/extractMediaStyle.native.js +127 -54
  28. package/dist/cjs/extractor/extractMediaStyle.native.js.map +3 -3
  29. package/dist/cjs/extractor/extractToClassNames.native.js +449 -252
  30. package/dist/cjs/extractor/extractToClassNames.native.js.map +3 -3
  31. package/dist/cjs/extractor/findTopmostFunction.native.js +4 -4
  32. package/dist/cjs/extractor/findTopmostFunction.native.js.map +3 -3
  33. package/dist/cjs/extractor/generateTamaguiStudioConfig.native.js +415 -54
  34. package/dist/cjs/extractor/generateTamaguiStudioConfig.native.js.map +3 -3
  35. package/dist/cjs/extractor/generatedUid.native.js +2 -2
  36. package/dist/cjs/extractor/generatedUid.native.js.map +3 -3
  37. package/dist/cjs/extractor/getPrefixLogs.native.js +2 -1
  38. package/dist/cjs/extractor/getPrefixLogs.native.js.map +3 -3
  39. package/dist/cjs/extractor/getPropValueFromAttributes.native.js +16 -19
  40. package/dist/cjs/extractor/getPropValueFromAttributes.native.js.map +3 -3
  41. package/dist/cjs/extractor/getSourceModule.native.js +20 -7
  42. package/dist/cjs/extractor/getSourceModule.native.js.map +3 -3
  43. package/dist/cjs/extractor/getStaticBindingsForScope.native.js +336 -94
  44. package/dist/cjs/extractor/getStaticBindingsForScope.native.js.map +3 -3
  45. package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +3 -3
  46. package/dist/cjs/extractor/hoistClassNames.native.js +8 -10
  47. package/dist/cjs/extractor/hoistClassNames.native.js.map +3 -3
  48. package/dist/cjs/extractor/literalToAst.native.js +89 -19
  49. package/dist/cjs/extractor/literalToAst.native.js.map +3 -3
  50. package/dist/cjs/extractor/loadFile.native.js +16 -8
  51. package/dist/cjs/extractor/loadFile.native.js.map +3 -3
  52. package/dist/cjs/extractor/loadTamagui.js +3 -3
  53. package/dist/cjs/extractor/loadTamagui.js.map +1 -1
  54. package/dist/cjs/extractor/loadTamagui.native.js +667 -192
  55. package/dist/cjs/extractor/loadTamagui.native.js.map +3 -3
  56. package/dist/cjs/extractor/logLines.native.js +24 -6
  57. package/dist/cjs/extractor/logLines.native.js.map +3 -3
  58. package/dist/cjs/extractor/normalizeTernaries.native.js +71 -20
  59. package/dist/cjs/extractor/normalizeTernaries.native.js.map +3 -3
  60. package/dist/cjs/extractor/propsToFontFamilyCache.native.js +3 -3
  61. package/dist/cjs/extractor/propsToFontFamilyCache.native.js.map +3 -3
  62. package/dist/cjs/extractor/removeUnusedHooks.native.js +69 -36
  63. package/dist/cjs/extractor/removeUnusedHooks.native.js.map +3 -3
  64. package/dist/cjs/extractor/timer.native.js +10 -9
  65. package/dist/cjs/extractor/timer.native.js.map +3 -3
  66. package/dist/cjs/extractor/validHTMLAttributes.native.js +1 -1
  67. package/dist/cjs/extractor/validHTMLAttributes.native.js.map +3 -3
  68. package/dist/cjs/getPragmaOptions.native.js +4 -9
  69. package/dist/cjs/getPragmaOptions.native.js.map +3 -3
  70. package/dist/cjs/helpers/memoize.native.js +5 -3
  71. package/dist/cjs/helpers/memoize.native.js.map +3 -3
  72. package/dist/cjs/helpers/requireTamaguiCore.native.js +2 -1
  73. package/dist/cjs/helpers/requireTamaguiCore.native.js.map +3 -3
  74. package/dist/cjs/index.native.js.map +2 -2
  75. package/dist/cjs/minifyCSS.native.js.map +3 -3
  76. package/dist/cjs/registerRequire.native.js +56 -28
  77. package/dist/cjs/registerRequire.native.js.map +3 -3
  78. package/dist/cjs/server.native.js +175 -21
  79. package/dist/cjs/server.native.js.map +3 -3
  80. package/dist/cjs/setup.native.js.map +3 -3
  81. package/dist/cjs/static.native.js.map +2 -2
  82. package/dist/cjs/types.native.js.map +2 -2
  83. package/dist/cjs/webpackPlugin.native.js +26 -5
  84. package/dist/cjs/webpackPlugin.native.js.map +3 -3
  85. package/dist/esm/constants.native.js +4 -3
  86. package/dist/esm/constants.native.js.map +3 -3
  87. package/dist/esm/extractor/accessSafe.native.js +1 -5
  88. package/dist/esm/extractor/accessSafe.native.js.map +3 -3
  89. package/dist/esm/extractor/babelParse.native.js +5 -7
  90. package/dist/esm/extractor/babelParse.native.js.map +3 -3
  91. package/dist/esm/extractor/buildClassName.native.js +31 -41
  92. package/dist/esm/extractor/buildClassName.native.js.map +3 -3
  93. package/dist/esm/extractor/bundle.js +6 -4
  94. package/dist/esm/extractor/bundle.js.map +1 -1
  95. package/dist/esm/extractor/bundle.mjs +7 -5
  96. package/dist/esm/extractor/bundle.native.js +321 -56
  97. package/dist/esm/extractor/bundle.native.js.map +3 -3
  98. package/dist/esm/extractor/bundleConfig.native.js +499 -187
  99. package/dist/esm/extractor/bundleConfig.native.js.map +3 -3
  100. package/dist/esm/extractor/createEvaluator.native.js +9 -11
  101. package/dist/esm/extractor/createEvaluator.native.js.map +3 -3
  102. package/dist/esm/extractor/createExtractor.native.js +1241 -916
  103. package/dist/esm/extractor/createExtractor.native.js.map +3 -3
  104. package/dist/esm/extractor/ensureImportingConcat.native.js +11 -16
  105. package/dist/esm/extractor/ensureImportingConcat.native.js.map +3 -3
  106. package/dist/esm/extractor/esbuildAliasPlugin.native.js +22 -11
  107. package/dist/esm/extractor/esbuildAliasPlugin.native.js.map +3 -3
  108. package/dist/esm/extractor/evaluateAstNode.native.js +15 -21
  109. package/dist/esm/extractor/evaluateAstNode.native.js.map +3 -3
  110. package/dist/esm/extractor/extractHelpers.native.js +146 -38
  111. package/dist/esm/extractor/extractHelpers.native.js.map +3 -3
  112. package/dist/esm/extractor/extractMediaStyle.native.js +127 -54
  113. package/dist/esm/extractor/extractMediaStyle.native.js.map +3 -3
  114. package/dist/esm/extractor/extractToClassNames.native.js +449 -252
  115. package/dist/esm/extractor/extractToClassNames.native.js.map +3 -3
  116. package/dist/esm/extractor/findTopmostFunction.native.js +4 -4
  117. package/dist/esm/extractor/findTopmostFunction.native.js.map +3 -3
  118. package/dist/esm/extractor/generateTamaguiStudioConfig.native.js +415 -54
  119. package/dist/esm/extractor/generateTamaguiStudioConfig.native.js.map +3 -3
  120. package/dist/esm/extractor/generatedUid.native.js +2 -2
  121. package/dist/esm/extractor/generatedUid.native.js.map +3 -3
  122. package/dist/esm/extractor/getPrefixLogs.native.js +2 -1
  123. package/dist/esm/extractor/getPrefixLogs.native.js.map +3 -3
  124. package/dist/esm/extractor/getPropValueFromAttributes.native.js +16 -19
  125. package/dist/esm/extractor/getPropValueFromAttributes.native.js.map +3 -3
  126. package/dist/esm/extractor/getSourceModule.native.js +20 -7
  127. package/dist/esm/extractor/getSourceModule.native.js.map +3 -3
  128. package/dist/esm/extractor/getStaticBindingsForScope.native.js +336 -94
  129. package/dist/esm/extractor/getStaticBindingsForScope.native.js.map +3 -3
  130. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +3 -3
  131. package/dist/esm/extractor/hoistClassNames.native.js +8 -10
  132. package/dist/esm/extractor/hoistClassNames.native.js.map +3 -3
  133. package/dist/esm/extractor/literalToAst.native.js +89 -19
  134. package/dist/esm/extractor/literalToAst.native.js.map +3 -3
  135. package/dist/esm/extractor/loadFile.native.js +16 -8
  136. package/dist/esm/extractor/loadFile.native.js.map +3 -3
  137. package/dist/esm/extractor/loadTamagui.js +1 -2
  138. package/dist/esm/extractor/loadTamagui.js.map +1 -1
  139. package/dist/esm/extractor/loadTamagui.mjs +5 -3
  140. package/dist/esm/extractor/loadTamagui.native.js +668 -203
  141. package/dist/esm/extractor/loadTamagui.native.js.map +3 -3
  142. package/dist/esm/extractor/logLines.native.js +24 -6
  143. package/dist/esm/extractor/logLines.native.js.map +3 -3
  144. package/dist/esm/extractor/normalizeTernaries.native.js +71 -20
  145. package/dist/esm/extractor/normalizeTernaries.native.js.map +3 -3
  146. package/dist/esm/extractor/propsToFontFamilyCache.native.js +3 -3
  147. package/dist/esm/extractor/propsToFontFamilyCache.native.js.map +3 -3
  148. package/dist/esm/extractor/removeUnusedHooks.native.js +69 -35
  149. package/dist/esm/extractor/removeUnusedHooks.native.js.map +3 -3
  150. package/dist/esm/extractor/timer.native.js +10 -9
  151. package/dist/esm/extractor/timer.native.js.map +3 -3
  152. package/dist/esm/extractor/validHTMLAttributes.native.js +1 -1
  153. package/dist/esm/extractor/validHTMLAttributes.native.js.map +3 -3
  154. package/dist/esm/getPragmaOptions.native.js +4 -9
  155. package/dist/esm/getPragmaOptions.native.js.map +3 -3
  156. package/dist/esm/helpers/memoize.native.js +5 -3
  157. package/dist/esm/helpers/memoize.native.js.map +3 -3
  158. package/dist/esm/helpers/requireTamaguiCore.native.js +2 -1
  159. package/dist/esm/helpers/requireTamaguiCore.native.js.map +3 -3
  160. package/dist/esm/index.native.js.map +1 -1
  161. package/dist/esm/minifyCSS.native.js.map +3 -3
  162. package/dist/esm/registerRequire.native.js +56 -28
  163. package/dist/esm/registerRequire.native.js.map +3 -3
  164. package/dist/esm/server.native.js +175 -21
  165. package/dist/esm/server.native.js.map +3 -3
  166. package/dist/esm/setup.native.js.map +3 -3
  167. package/dist/esm/static.native.js.map +3 -3
  168. package/dist/esm/webpackPlugin.native.js +26 -5
  169. package/dist/esm/webpackPlugin.native.js.map +3 -3
  170. package/package.json +14 -15
  171. package/src/extractor/bundle.ts +5 -2
  172. package/src/extractor/loadTamagui.ts +3 -2
  173. package/types/extractor/bundle.d.ts.map +1 -1
  174. package/types/extractor/loadTamagui.d.ts.map +1 -1
  175. package/tamagui.tsconfig.json +0 -5
@@ -15,273 +15,470 @@ import { hoistClassNames } from "./hoistClassNames";
15
15
  import { logLines } from "./logLines";
16
16
  import { getFontFamilyClassNameFromProps } from "./propsToFontFamilyCache";
17
17
  import { timer } from "./timer";
18
- const mergeStyleGroups = {
19
- shadowOpacity: !0,
20
- shadowRadius: !0,
21
- shadowColor: !0,
22
- shadowOffset: !0
23
- };
24
- async function extractToClassNames({
25
- extractor,
26
- source,
27
- sourcePath,
28
- options,
29
- shouldPrintDebug
30
- }) {
31
- const tm = timer(), { getStylesAtomic } = requireTamaguiCore("web");
32
- if (sourcePath != null && sourcePath.includes("node_modules"))
33
- return null;
34
- if (shouldPrintDebug && console.warn(`--- ${sourcePath} ---
35
-
36
- `), typeof source != "string")
37
- throw new Error("`source` must be a string of javascript");
38
- if (sourcePath && !path.isAbsolute(sourcePath))
39
- throw new Error(
40
- "`sourcePath` must be an absolute path to a .js file, got: " + sourcePath
41
- );
42
- /.[tj]sx?$/i.test(sourcePath || "") || console.warn(`${sourcePath == null ? void 0 : sourcePath.slice(0, 100)} - bad filename.`), !options.disableExtraction && !options._disableLoadTamagui && await extractor.loadTamagui(options);
43
- const shouldLogTiming = options.logTimings ?? !0, start = Date.now(), mem = process.env.TAMAGUI_SHOW_MEMORY_USAGE && shouldLogTiming ? process.memoryUsage() : null;
44
- let ast;
18
+ function _array_like_to_array(arr, len) {
19
+ (len == null || len > arr.length) && (len = arr.length);
20
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
21
+ arr2[i] = arr[i];
22
+ return arr2;
23
+ }
24
+ function _array_without_holes(arr) {
25
+ if (Array.isArray(arr))
26
+ return _array_like_to_array(arr);
27
+ }
28
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
45
29
  try {
46
- ast = babelParse(source, sourcePath);
47
- } catch (err) {
48
- throw console.error("babel parse error:", sourcePath == null ? void 0 : sourcePath.slice(0, 100)), err;
30
+ var info = gen[key](arg), value = info.value;
31
+ } catch (error) {
32
+ reject(error);
33
+ return;
49
34
  }
50
- tm.mark("babel-parse", shouldPrintDebug === "verbose");
51
- const cssMap = /* @__PURE__ */ new Map(), existingHoists = {};
52
- let hasFlattened = !1;
53
- const res = await extractor.parse(ast, {
54
- shouldPrintDebug,
55
- ...options,
56
- sourcePath,
57
- extractStyledDefinitions: !0,
58
- onStyleRule(identifier, rules) {
59
- const css = rules.join(";");
60
- shouldPrintDebug && console.info(`adding styled() rule: .${identifier} ${css}`), cssMap.set(`.${identifier}`, { css, commentTexts: [] });
61
- },
62
- getFlattenedNode: ({ tag }) => (hasFlattened = !0, tag),
63
- onExtractTag: ({
64
- parserProps,
65
- attrs,
66
- node,
67
- attemptEval,
68
- jsxPath,
69
- originalNodeName,
70
- filePath,
71
- lineNumbers,
72
- programPath,
73
- isFlattened,
74
- staticConfig
75
- }) => {
76
- var _a;
77
- if (staticConfig.acceptsClassName === !1) {
78
- shouldPrintDebug && console.info("bail, acceptsClassName is false");
79
- return;
35
+ info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
36
+ }
37
+ function _async_to_generator(fn) {
38
+ return function() {
39
+ var self = this, args = arguments;
40
+ return new Promise(function(resolve, reject) {
41
+ var gen = fn.apply(self, args);
42
+ function _next(value) {
43
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
80
44
  }
81
- const didFlattenThisTag = hasFlattened;
82
- hasFlattened = !1;
83
- let finalClassNames = [];
84
- const finalAttrs = [];
85
- let finalStyles = [], viewStyles = {};
86
- for (const attr of attrs)
87
- attr.type === "style" && (viewStyles = {
88
- ...viewStyles,
89
- ...attr.value
90
- });
91
- const ensureNeededPrevStyle = (style) => {
92
- if (!Object.keys(style).some((key) => mergeStyleGroups[key]))
93
- return style;
94
- for (const k in mergeStyleGroups)
95
- k in viewStyles && (style[k] = style[k] ?? viewStyles[k]);
96
- return style;
97
- }, addStyles = (style) => {
98
- if (!style)
99
- return [];
100
- const styleWithPrev = ensureNeededPrevStyle(style), res2 = getStylesAtomic(styleWithPrev);
101
- return res2.length && (finalStyles = [...finalStyles, ...res2]), res2;
102
- };
103
- let lastMediaImportance = 1;
104
- for (const attr of attrs)
105
- switch (attr.type) {
106
- case "style": {
107
- if (isFlattened) {
108
- const styles2 = addStyles(attr.value), newFontFamily = getFontFamilyClassNameFromProps(attr.value) || "", newClassNames = concatClassName(
109
- styles2.map((x) => x.identifier).join(" ") + newFontFamily
110
- ), existing = finalClassNames.find(
111
- (x) => x.type == "StringLiteral"
112
- );
113
- if (existing) {
114
- let previous = existing.value;
115
- newFontFamily && (shouldPrintDebug && console.info(` newFontFamily: ${newFontFamily}`), previous = previous.replace(/font_[a-z]+/i, "")), existing.value = `${previous} ${newClassNames}`;
116
- } else
117
- finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)];
118
- } else {
119
- const styles2 = getStylesAtomic(attr.value);
120
- finalStyles = [...finalStyles, ...styles2];
121
- for (const style of styles2) {
122
- const prop = style.pseudo ? `${style.property}-${style.pseudo}` : style.property;
123
- finalAttrs.push(
124
- t.jsxAttribute(t.jsxIdentifier(prop), t.stringLiteral(style.identifier))
125
- );
126
- }
127
- }
45
+ function _throw(err) {
46
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
47
+ }
48
+ _next(void 0);
49
+ });
50
+ };
51
+ }
52
+ function _define_property(obj, key, value) {
53
+ return key in obj ? Object.defineProperty(obj, key, {
54
+ value,
55
+ enumerable: !0,
56
+ configurable: !0,
57
+ writable: !0
58
+ }) : obj[key] = value, obj;
59
+ }
60
+ function _iterable_to_array(iter) {
61
+ if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
62
+ return Array.from(iter);
63
+ }
64
+ function _non_iterable_spread() {
65
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
66
+ }
67
+ function _object_spread(target) {
68
+ for (var i = 1; i < arguments.length; i++) {
69
+ var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
70
+ typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
71
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
72
+ }))), ownKeys2.forEach(function(key) {
73
+ _define_property(target, key, source[key]);
74
+ });
75
+ }
76
+ return target;
77
+ }
78
+ function ownKeys(object, enumerableOnly) {
79
+ var keys = Object.keys(object);
80
+ if (Object.getOwnPropertySymbols) {
81
+ var symbols = Object.getOwnPropertySymbols(object);
82
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
83
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
84
+ })), keys.push.apply(keys, symbols);
85
+ }
86
+ return keys;
87
+ }
88
+ function _object_spread_props(target, source) {
89
+ return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
90
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
91
+ }), target;
92
+ }
93
+ function _to_consumable_array(arr) {
94
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
95
+ }
96
+ function _unsupported_iterable_to_array(o, minLen) {
97
+ if (o) {
98
+ if (typeof o == "string")
99
+ return _array_like_to_array(o, minLen);
100
+ var n = Object.prototype.toString.call(o).slice(8, -1);
101
+ if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
102
+ return Array.from(n);
103
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
104
+ return _array_like_to_array(o, minLen);
105
+ }
106
+ }
107
+ function _ts_generator(thisArg, body) {
108
+ var f, y, t2, g, _ = {
109
+ label: 0,
110
+ sent: function() {
111
+ if (t2[0] & 1)
112
+ throw t2[1];
113
+ return t2[1];
114
+ },
115
+ trys: [],
116
+ ops: []
117
+ };
118
+ return g = {
119
+ next: verb(0),
120
+ throw: verb(1),
121
+ return: verb(2)
122
+ }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
123
+ return this;
124
+ }), g;
125
+ function verb(n) {
126
+ return function(v) {
127
+ return step([
128
+ n,
129
+ v
130
+ ]);
131
+ };
132
+ }
133
+ function step(op) {
134
+ if (f)
135
+ throw new TypeError("Generator is already executing.");
136
+ for (; _; )
137
+ try {
138
+ if (f = 1, y && (t2 = op[0] & 2 ? y.return : op[0] ? y.throw || ((t2 = y.return) && t2.call(y), 0) : y.next) && !(t2 = t2.call(y, op[1])).done)
139
+ return t2;
140
+ switch (y = 0, t2 && (op = [
141
+ op[0] & 2,
142
+ t2.value
143
+ ]), op[0]) {
144
+ case 0:
145
+ case 1:
146
+ t2 = op;
128
147
  break;
129
- }
130
- case "attr": {
131
- const val = attr.value;
132
- if (t.isJSXSpreadAttribute(val))
133
- isSimpleSpread(val) && finalClassNames.push(
134
- t.logicalExpression(
135
- "&&",
136
- val.argument,
137
- t.memberExpression(val.argument, t.identifier("className"))
138
- )
139
- );
140
- else if (val.name.name === "className") {
141
- const value = val.value;
142
- if (value)
143
- try {
144
- const evaluatedValue = attemptEval(value);
145
- finalClassNames.push(t.stringLiteral(evaluatedValue));
146
- } catch {
147
- finalClassNames.push(value.expression);
148
- }
148
+ case 4:
149
+ return _.label++, {
150
+ value: op[1],
151
+ done: !1
152
+ };
153
+ case 5:
154
+ _.label++, y = op[1], op = [
155
+ 0
156
+ ];
157
+ continue;
158
+ case 7:
159
+ op = _.ops.pop(), _.trys.pop();
160
+ continue;
161
+ default:
162
+ if (t2 = _.trys, !(t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
163
+ _ = 0;
149
164
  continue;
150
165
  }
151
- finalAttrs.push(val);
152
- break;
153
- }
154
- case "ternary": {
155
- const mediaExtraction = extractMediaStyle(
156
- parserProps,
157
- attr.value,
158
- jsxPath,
159
- extractor.getTamagui(),
160
- sourcePath || "",
161
- lastMediaImportance,
162
- shouldPrintDebug
163
- );
164
- if (shouldPrintDebug && mediaExtraction && console.info(
165
- "ternary (mediaStyles)",
166
- ((_a = mediaExtraction.ternaryWithoutMedia) == null ? void 0 : _a.inlineMediaQuery) ?? "",
167
- mediaExtraction.mediaStyles.map((x) => x.identifier).join(".")
168
- ), !mediaExtraction) {
169
- addTernaryStyle(
170
- attr.value,
171
- addStyles(attr.value.consequent),
172
- addStyles(attr.value.alternate)
173
- );
174
- continue;
166
+ if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
167
+ _.label = op[1];
168
+ break;
175
169
  }
176
- lastMediaImportance++, mediaExtraction.mediaStyles && (finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]), mediaExtraction.ternaryWithoutMedia ? addTernaryStyle(
177
- mediaExtraction.ternaryWithoutMedia,
178
- mediaExtraction.mediaStyles,
179
- []
180
- ) : finalClassNames = [
181
- ...finalClassNames,
182
- ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier))
183
- ];
184
- break;
185
- }
186
- }
187
- function addTernaryStyle(ternary, a, b) {
188
- const cCN = a.map((x) => x.identifier).join(" "), aCN = b.map((x) => x.identifier).join(" ");
189
- a.length && b.length ? finalClassNames.push(
190
- t.conditionalExpression(
191
- ternary.test,
192
- t.stringLiteral(cCN),
193
- t.stringLiteral(aCN)
194
- )
195
- ) : finalClassNames.push(
196
- t.conditionalExpression(
197
- ternary.test,
198
- t.stringLiteral(" " + cCN),
199
- t.stringLiteral(" " + aCN)
200
- )
201
- );
202
- }
203
- if (shouldPrintDebug && console.info(
204
- ` finalClassNames
205
- `,
206
- logLines(finalClassNames.map((x) => x.value).join(" "))
207
- ), node.attributes = finalAttrs, finalClassNames.length) {
208
- const extraClassNames = (() => {
209
- let value = "";
210
- return isFlattened && (process.env.TAMAGUI_DEBUG_OPTIMIZATIONS && (value += "is_tamagui_flattened"), staticConfig.componentName && (value += ` is_${staticConfig.componentName}`)), value;
211
- })(), names = buildClassName(finalClassNames, extraClassNames), nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null;
212
- let expr = nameExpr;
213
- if (nameExpr && !t.isIdentifier(nameExpr) && didFlattenThisTag) {
214
- ensureImportingConcat(programPath);
215
- const simpleSpreads = attrs.filter((x) => x.type === "attr" && t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value));
216
- expr = t.callExpression(t.identifier("concatClassName"), [
217
- expr,
218
- ...simpleSpreads.map((val) => val.value.argument)
219
- ]);
170
+ if (op[0] === 6 && _.label < t2[1]) {
171
+ _.label = t2[1], t2 = op;
172
+ break;
173
+ }
174
+ if (t2 && _.label < t2[2]) {
175
+ _.label = t2[2], _.ops.push(op);
176
+ break;
177
+ }
178
+ t2[2] && _.ops.pop(), _.trys.pop();
179
+ continue;
220
180
  }
221
- node.attributes.push(
222
- t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr))
223
- );
181
+ op = body.call(thisArg, _);
182
+ } catch (e) {
183
+ op = [
184
+ 6,
185
+ e
186
+ ], y = 0;
187
+ } finally {
188
+ f = t2 = 0;
224
189
  }
225
- const comment = util.format(
226
- "/* %s:%s (%s) */",
227
- filePath,
228
- lineNumbers,
229
- originalNodeName
230
- );
231
- for (const { identifier, rules } of finalStyles) {
232
- const className = `.${identifier}`;
233
- if (cssMap.has(className)) {
234
- if (comment) {
235
- const val = cssMap.get(className);
236
- val.commentTexts.push(comment), cssMap.set(className, val);
190
+ if (op[0] & 5)
191
+ throw op[1];
192
+ return {
193
+ value: op[0] ? op[1] : void 0,
194
+ done: !0
195
+ };
196
+ }
197
+ }
198
+ var mergeStyleGroups = {
199
+ shadowOpacity: !0,
200
+ shadowRadius: !0,
201
+ shadowColor: !0,
202
+ shadowOffset: !0
203
+ };
204
+ function extractToClassNames(_) {
205
+ return _extractToClassNames.apply(this, arguments);
206
+ }
207
+ function _extractToClassNames() {
208
+ return _extractToClassNames = _async_to_generator(function(param) {
209
+ var extractor, source, sourcePath, options, shouldPrintDebug, tm, getStylesAtomic, _options_logTimings, shouldLogTiming, start, mem, ast, cssMap, existingHoists, hasFlattened, res, styles, result, memUsed, _$path, numOptimized, numFound, numFlattened, memory, timing, timingStr, pre, memStr;
210
+ return _ts_generator(this, function(_state) {
211
+ switch (_state.label) {
212
+ case 0:
213
+ if (extractor = param.extractor, source = param.source, sourcePath = param.sourcePath, options = param.options, shouldPrintDebug = param.shouldPrintDebug, tm = timer(), getStylesAtomic = requireTamaguiCore("web").getStylesAtomic, sourcePath != null && sourcePath.includes("node_modules"))
214
+ return [
215
+ 2,
216
+ null
217
+ ];
218
+ if (shouldPrintDebug && console.warn("--- ".concat(sourcePath, ` ---
219
+
220
+ `)), typeof source != "string")
221
+ throw new Error("`source` must be a string of javascript");
222
+ if (sourcePath && !path.isAbsolute(sourcePath))
223
+ throw new Error("`sourcePath` must be an absolute path to a .js file, got: " + sourcePath);
224
+ return /.[tj]sx?$/i.test(sourcePath || "") || console.warn("".concat(sourcePath == null ? void 0 : sourcePath.slice(0, 100), " - bad filename.")), !options.disableExtraction && !options._disableLoadTamagui ? [
225
+ 4,
226
+ extractor.loadTamagui(options)
227
+ ] : [
228
+ 3,
229
+ 2
230
+ ];
231
+ case 1:
232
+ _state.sent(), _state.label = 2;
233
+ case 2:
234
+ shouldLogTiming = (_options_logTimings = options.logTimings) !== null && _options_logTimings !== void 0 ? _options_logTimings : !0, start = Date.now(), mem = process.env.TAMAGUI_SHOW_MEMORY_USAGE && shouldLogTiming ? process.memoryUsage() : null;
235
+ try {
236
+ ast = babelParse(source, sourcePath);
237
+ } catch (err) {
238
+ throw console.error("babel parse error:", sourcePath == null ? void 0 : sourcePath.slice(0, 100)), err;
237
239
  }
238
- } else
239
- rules.length && cssMap.set(className, {
240
- css: rules.join(`
240
+ return tm.mark("babel-parse", shouldPrintDebug === "verbose"), cssMap = /* @__PURE__ */ new Map(), existingHoists = {}, hasFlattened = !1, [
241
+ 4,
242
+ extractor.parse(ast, _object_spread_props(_object_spread({
243
+ shouldPrintDebug
244
+ }, options), {
245
+ sourcePath,
246
+ extractStyledDefinitions: !0,
247
+ onStyleRule: function(identifier, rules) {
248
+ var css = rules.join(";");
249
+ shouldPrintDebug && console.info("adding styled() rule: .".concat(identifier, " ").concat(css)), cssMap.set(".".concat(identifier), {
250
+ css,
251
+ commentTexts: []
252
+ });
253
+ },
254
+ getFlattenedNode: function(param2) {
255
+ var tag = param2.tag;
256
+ return hasFlattened = !0, tag;
257
+ },
258
+ onExtractTag: function(param2) {
259
+ var parserProps = param2.parserProps, attrs = param2.attrs, node = param2.node, attemptEval = param2.attemptEval, jsxPath = param2.jsxPath, originalNodeName = param2.originalNodeName, filePath = param2.filePath, lineNumbers = param2.lineNumbers, programPath = param2.programPath, isFlattened = param2.isFlattened, staticConfig = param2.staticConfig, addTernaryStyle = function(ternary, a, b) {
260
+ var cCN = a.map(function(x) {
261
+ return x.identifier;
262
+ }).join(" "), aCN = b.map(function(x) {
263
+ return x.identifier;
264
+ }).join(" ");
265
+ a.length && b.length ? finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))) : finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(" " + cCN), t.stringLiteral(" " + aCN)));
266
+ };
267
+ if (staticConfig.acceptsClassName === !1) {
268
+ shouldPrintDebug && console.info("bail, acceptsClassName is false");
269
+ return;
270
+ }
271
+ var didFlattenThisTag = hasFlattened;
272
+ hasFlattened = !1;
273
+ var finalClassNames = [], finalAttrs = [], finalStyles = [], viewStyles = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
274
+ try {
275
+ for (var _iterator = attrs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
276
+ var attr = _step.value;
277
+ attr.type === "style" && (viewStyles = _object_spread({}, viewStyles, attr.value));
278
+ }
279
+ } catch (err) {
280
+ _didIteratorError = !0, _iteratorError = err;
281
+ } finally {
282
+ try {
283
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
284
+ } finally {
285
+ if (_didIteratorError)
286
+ throw _iteratorError;
287
+ }
288
+ }
289
+ var ensureNeededPrevStyle = function(style2) {
290
+ var keys = Object.keys(style2);
291
+ if (!keys.some(function(key) {
292
+ return mergeStyleGroups[key];
293
+ }))
294
+ return style2;
295
+ for (var k in mergeStyleGroups)
296
+ if (k in viewStyles) {
297
+ var _style_k;
298
+ style2[k] = (_style_k = style2[k]) !== null && _style_k !== void 0 ? _style_k : viewStyles[k];
299
+ }
300
+ return style2;
301
+ }, addStyles = function(style2) {
302
+ if (!style2)
303
+ return [];
304
+ var styleWithPrev = ensureNeededPrevStyle(style2), res2 = getStylesAtomic(styleWithPrev);
305
+ return res2.length && (finalStyles = _to_consumable_array(finalStyles).concat(_to_consumable_array(res2))), res2;
306
+ }, lastMediaImportance = 1, _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
307
+ try {
308
+ for (var _iterator1 = attrs[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
309
+ var attr1 = _step1.value;
310
+ switch (attr1.type) {
311
+ case "style": {
312
+ if (isFlattened) {
313
+ var styles1 = addStyles(attr1.value), newFontFamily = getFontFamilyClassNameFromProps(attr1.value) || "", newClassNames = concatClassName(styles1.map(function(x) {
314
+ return x.identifier;
315
+ }).join(" ") + newFontFamily), existing = finalClassNames.find(function(x) {
316
+ return x.type == "StringLiteral";
317
+ });
318
+ if (existing) {
319
+ var previous = existing.value;
320
+ newFontFamily && (shouldPrintDebug && console.info(" newFontFamily: ".concat(newFontFamily)), previous = previous.replace(/font_[a-z]+/i, "")), existing.value = "".concat(previous, " ").concat(newClassNames);
321
+ } else
322
+ finalClassNames = _to_consumable_array(finalClassNames).concat([
323
+ t.stringLiteral(newClassNames)
324
+ ]);
325
+ } else {
326
+ var styles2 = getStylesAtomic(attr1.value);
327
+ finalStyles = _to_consumable_array(finalStyles).concat(_to_consumable_array(styles2));
328
+ var _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
329
+ try {
330
+ for (var _iterator2 = styles2[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
331
+ var style = _step2.value, prop = style.pseudo ? "".concat(style.property, "-").concat(style.pseudo) : style.property;
332
+ finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(prop), t.stringLiteral(style.identifier)));
333
+ }
334
+ } catch (err) {
335
+ _didIteratorError2 = !0, _iteratorError2 = err;
336
+ } finally {
337
+ try {
338
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
339
+ } finally {
340
+ if (_didIteratorError2)
341
+ throw _iteratorError2;
342
+ }
343
+ }
344
+ }
345
+ break;
346
+ }
347
+ case "attr": {
348
+ var val = attr1.value;
349
+ if (t.isJSXSpreadAttribute(val))
350
+ isSimpleSpread(val) && finalClassNames.push(t.logicalExpression("&&", val.argument, t.memberExpression(val.argument, t.identifier("className"))));
351
+ else if (val.name.name === "className") {
352
+ var value = val.value;
353
+ if (value)
354
+ try {
355
+ var evaluatedValue = attemptEval(value);
356
+ finalClassNames.push(t.stringLiteral(evaluatedValue));
357
+ } catch {
358
+ finalClassNames.push(value.expression);
359
+ }
360
+ continue;
361
+ }
362
+ finalAttrs.push(val);
363
+ break;
364
+ }
365
+ case "ternary": {
366
+ var mediaExtraction = extractMediaStyle(parserProps, attr1.value, jsxPath, extractor.getTamagui(), sourcePath || "", lastMediaImportance, shouldPrintDebug);
367
+ if (shouldPrintDebug && mediaExtraction) {
368
+ var _mediaExtraction_ternaryWithoutMedia, _mediaExtraction_ternaryWithoutMedia_inlineMediaQuery;
369
+ console.info("ternary (mediaStyles)", (_mediaExtraction_ternaryWithoutMedia_inlineMediaQuery = (_mediaExtraction_ternaryWithoutMedia = mediaExtraction.ternaryWithoutMedia) === null || _mediaExtraction_ternaryWithoutMedia === void 0 ? void 0 : _mediaExtraction_ternaryWithoutMedia.inlineMediaQuery) !== null && _mediaExtraction_ternaryWithoutMedia_inlineMediaQuery !== void 0 ? _mediaExtraction_ternaryWithoutMedia_inlineMediaQuery : "", mediaExtraction.mediaStyles.map(function(x) {
370
+ return x.identifier;
371
+ }).join("."));
372
+ }
373
+ if (!mediaExtraction) {
374
+ addTernaryStyle(attr1.value, addStyles(attr1.value.consequent), addStyles(attr1.value.alternate));
375
+ continue;
376
+ }
377
+ lastMediaImportance++, mediaExtraction.mediaStyles && (finalStyles = _to_consumable_array(finalStyles).concat(_to_consumable_array(mediaExtraction.mediaStyles))), mediaExtraction.ternaryWithoutMedia ? addTernaryStyle(mediaExtraction.ternaryWithoutMedia, mediaExtraction.mediaStyles, []) : finalClassNames = _to_consumable_array(finalClassNames).concat(_to_consumable_array(mediaExtraction.mediaStyles.map(function(x) {
378
+ return t.stringLiteral(x.identifier);
379
+ })));
380
+ break;
381
+ }
382
+ }
383
+ }
384
+ } catch (err) {
385
+ _didIteratorError1 = !0, _iteratorError1 = err;
386
+ } finally {
387
+ try {
388
+ !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
389
+ } finally {
390
+ if (_didIteratorError1)
391
+ throw _iteratorError1;
392
+ }
393
+ }
394
+ if (shouldPrintDebug && console.info(` finalClassNames
395
+ `, logLines(finalClassNames.map(function(x) {
396
+ return x.value;
397
+ }).join(" "))), node.attributes = finalAttrs, finalClassNames.length) {
398
+ var extraClassNames = function() {
399
+ var value2 = "";
400
+ return isFlattened && (process.env.TAMAGUI_DEBUG_OPTIMIZATIONS && (value2 += "is_tamagui_flattened"), staticConfig.componentName && (value2 += " is_".concat(staticConfig.componentName))), value2;
401
+ }(), names = buildClassName(finalClassNames, extraClassNames), nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null, expr = nameExpr;
402
+ if (nameExpr && !t.isIdentifier(nameExpr) && didFlattenThisTag) {
403
+ ensureImportingConcat(programPath);
404
+ var simpleSpreads = attrs.filter(function(x) {
405
+ return x.type === "attr" && t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value);
406
+ });
407
+ expr = t.callExpression(t.identifier("concatClassName"), [
408
+ expr
409
+ ].concat(_to_consumable_array(simpleSpreads.map(function(val2) {
410
+ return val2.value.argument;
411
+ }))));
412
+ }
413
+ node.attributes.push(t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr)));
414
+ }
415
+ var comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName), _iteratorNormalCompletion3 = !0, _didIteratorError3 = !1, _iteratorError3 = void 0;
416
+ try {
417
+ for (var _iterator3 = finalStyles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = !0) {
418
+ var _step_value = _step3.value, identifier = _step_value.identifier, rules = _step_value.rules, className = ".".concat(identifier);
419
+ if (cssMap.has(className)) {
420
+ if (comment) {
421
+ var val1 = cssMap.get(className);
422
+ val1.commentTexts.push(comment), cssMap.set(className, val1);
423
+ }
424
+ } else
425
+ rules.length && cssMap.set(className, {
426
+ css: rules.join(`
241
427
  `),
242
- commentTexts: [comment]
243
- });
244
- }
245
- }
246
- });
247
- if (!res || !res.modified && !res.optimized && !res.flattened && !res.styled)
248
- return shouldPrintDebug && console.info("no res or none modified", res), null;
249
- const styles = Array.from(cssMap.values()).map((x) => x.css).join(`
250
- `).trim(), result = generate(
251
- ast,
252
- {
253
- concise: !1,
254
- filename: sourcePath,
255
- // this makes the debug output terrible, and i think sourcemap works already
256
- retainLines: !1,
257
- sourceFileName: sourcePath,
258
- sourceMaps: !0
259
- },
260
- source
261
- );
262
- if (shouldPrintDebug && (console.info(
263
- `
428
+ commentTexts: [
429
+ comment
430
+ ]
431
+ });
432
+ }
433
+ } catch (err) {
434
+ _didIteratorError3 = !0, _iteratorError3 = err;
435
+ } finally {
436
+ try {
437
+ !_iteratorNormalCompletion3 && _iterator3.return != null && _iterator3.return();
438
+ } finally {
439
+ if (_didIteratorError3)
440
+ throw _iteratorError3;
441
+ }
442
+ }
443
+ }
444
+ }))
445
+ ];
446
+ case 3:
447
+ return res = _state.sent(), !res || !res.modified && !res.optimized && !res.flattened && !res.styled ? (shouldPrintDebug && console.info("no res or none modified", res), [
448
+ 2,
449
+ null
450
+ ]) : (styles = Array.from(cssMap.values()).map(function(x) {
451
+ return x.css;
452
+ }).join(`
453
+ `).trim(), result = generate(ast, {
454
+ concise: !1,
455
+ filename: sourcePath,
456
+ // this makes the debug output terrible, and i think sourcemap works already
457
+ retainLines: !1,
458
+ sourceFileName: sourcePath,
459
+ sourceMaps: !0
460
+ }, source), shouldPrintDebug && (console.info(`
264
461
  -------- output code -------
265
462
 
266
- `,
267
- result.code.split(`
268
- `).filter((x) => !x.startsWith("//")).join(`
269
- `)
270
- ), console.info(`
463
+ `, result.code.split(`
464
+ `).filter(function(x) {
465
+ return !x.startsWith("//");
466
+ }).join(`
467
+ `)), console.info(`
271
468
  -------- output style --------
272
469
 
273
- `, styles)), shouldLogTiming) {
274
- const memUsed = mem ? Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10 : 0, path2 = basename(sourcePath || "").replace(/\.[jt]sx?$/, "").slice(0, 22).trim().padStart(24), numOptimized = `${res.optimized + res.styled}`.padStart(3), numFound = `${res.found + res.styled}`.padStart(3), numFlattened = `${res.flattened}`.padStart(3), memory = memUsed ? ` ${memUsed}MB` : "", timingStr = `${Date.now() - start}ms`.padStart(6), pre = getPrefixLogs(options), memStr = memory ? `(${memory})` : "";
275
- console.info(
276
- `${pre} ${path2} \xB7 ${numFound} found \xB7 ${numOptimized} opt \xB7 ${numFlattened} flat ${timingStr} ${memStr}`
277
- );
278
- }
279
- return {
280
- ast,
281
- styles,
282
- js: result.code,
283
- map: result.map
284
- };
470
+ `, styles)), shouldLogTiming && (memUsed = mem ? Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10 : 0, _$path = basename(sourcePath || "").replace(/\.[jt]sx?$/, "").slice(0, 22).trim().padStart(24), numOptimized = "".concat(res.optimized + res.styled).padStart(3), numFound = "".concat(res.found + res.styled).padStart(3), numFlattened = "".concat(res.flattened).padStart(3), memory = memUsed ? " ".concat(memUsed, "MB") : "", timing = Date.now() - start, timingStr = "".concat(timing, "ms").padStart(6), pre = getPrefixLogs(options), memStr = memory ? "(".concat(memory, ")") : "", console.info("".concat(pre, " ").concat(_$path, " \xB7 ").concat(numFound, " found \xB7 ").concat(numOptimized, " opt \xB7 ").concat(numFlattened, " flat ").concat(timingStr, " ").concat(memStr))), [
471
+ 2,
472
+ {
473
+ ast,
474
+ styles,
475
+ js: result.code,
476
+ map: result.map
477
+ }
478
+ ]);
479
+ }
480
+ });
481
+ }), _extractToClassNames.apply(this, arguments);
285
482
  }
286
483
  export {
287
484
  extractToClassNames