@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
@@ -7,16 +7,7 @@ import { FAILED_EVAL } from "../constants";
7
7
  import { requireTamaguiCore } from "../helpers/requireTamaguiCore";
8
8
  import { createEvaluator, createSafeEvaluator } from "./createEvaluator";
9
9
  import { evaluateAstNode } from "./evaluateAstNode";
10
- import {
11
- attrStr,
12
- findComponentName,
13
- getValidComponent,
14
- getValidComponentsPaths,
15
- getValidImport,
16
- isPresent,
17
- isValidImport,
18
- objToStr
19
- } from "./extractHelpers";
10
+ import { attrStr, findComponentName, getValidComponent, getValidComponentsPaths, getValidImport, isPresent, isValidImport, objToStr } from "./extractHelpers";
20
11
  import { findTopmostFunction } from "./findTopmostFunction";
21
12
  import { cleanupBeforeExit, getStaticBindingsForScope } from "./getStaticBindingsForScope";
22
13
  import { literalToAst } from "./literalToAst";
@@ -27,30 +18,261 @@ import { setPropsToFontFamily } from "./propsToFontFamilyCache";
27
18
  import { removeUnusedHooks } from "./removeUnusedHooks";
28
19
  import { timer } from "./timer";
29
20
  import { validHTMLAttributes } from "./validHTMLAttributes";
30
- const UNTOUCHED_PROPS = {
21
+ function _array_like_to_array(arr, len) {
22
+ (len == null || len > arr.length) && (len = arr.length);
23
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
24
+ arr2[i] = arr[i];
25
+ return arr2;
26
+ }
27
+ function _array_with_holes(arr) {
28
+ if (Array.isArray(arr))
29
+ return arr;
30
+ }
31
+ function _array_without_holes(arr) {
32
+ if (Array.isArray(arr))
33
+ return _array_like_to_array(arr);
34
+ }
35
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
36
+ try {
37
+ var info = gen[key](arg), value = info.value;
38
+ } catch (error) {
39
+ reject(error);
40
+ return;
41
+ }
42
+ info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
43
+ }
44
+ function _async_to_generator(fn) {
45
+ return function() {
46
+ var self = this, args = arguments;
47
+ return new Promise(function(resolve, reject) {
48
+ var gen = fn.apply(self, args);
49
+ function _next(value) {
50
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
51
+ }
52
+ function _throw(err) {
53
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
54
+ }
55
+ _next(void 0);
56
+ });
57
+ };
58
+ }
59
+ function _define_property(obj, key, value) {
60
+ return key in obj ? Object.defineProperty(obj, key, {
61
+ value,
62
+ enumerable: !0,
63
+ configurable: !0,
64
+ writable: !0
65
+ }) : obj[key] = value, obj;
66
+ }
67
+ function _iterable_to_array(iter) {
68
+ if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
69
+ return Array.from(iter);
70
+ }
71
+ function _iterable_to_array_limit(arr, i) {
72
+ var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
73
+ if (_i != null) {
74
+ var _arr = [], _n = !0, _d = !1, _s, _e;
75
+ try {
76
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
77
+ ;
78
+ } catch (err) {
79
+ _d = !0, _e = err;
80
+ } finally {
81
+ try {
82
+ !_n && _i.return != null && _i.return();
83
+ } finally {
84
+ if (_d)
85
+ throw _e;
86
+ }
87
+ }
88
+ return _arr;
89
+ }
90
+ }
91
+ function _non_iterable_rest() {
92
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
93
+ }
94
+ function _non_iterable_spread() {
95
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
96
+ }
97
+ function _object_spread(target) {
98
+ for (var i = 1; i < arguments.length; i++) {
99
+ var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
100
+ typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
101
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
102
+ }))), ownKeys2.forEach(function(key) {
103
+ _define_property(target, key, source[key]);
104
+ });
105
+ }
106
+ return target;
107
+ }
108
+ function ownKeys(object, enumerableOnly) {
109
+ var keys = Object.keys(object);
110
+ if (Object.getOwnPropertySymbols) {
111
+ var symbols = Object.getOwnPropertySymbols(object);
112
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
113
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
114
+ })), keys.push.apply(keys, symbols);
115
+ }
116
+ return keys;
117
+ }
118
+ function _object_spread_props(target, source) {
119
+ return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
120
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
121
+ }), target;
122
+ }
123
+ function _object_without_properties(source, excluded) {
124
+ if (source == null)
125
+ return {};
126
+ var target = _object_without_properties_loose(source, excluded), key, i;
127
+ if (Object.getOwnPropertySymbols) {
128
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
129
+ for (i = 0; i < sourceSymbolKeys.length; i++)
130
+ key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
131
+ }
132
+ return target;
133
+ }
134
+ function _object_without_properties_loose(source, excluded) {
135
+ if (source == null)
136
+ return {};
137
+ var target = {}, sourceKeys = Object.keys(source), key, i;
138
+ for (i = 0; i < sourceKeys.length; i++)
139
+ key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
140
+ return target;
141
+ }
142
+ function _sliced_to_array(arr, i) {
143
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
144
+ }
145
+ function _to_consumable_array(arr) {
146
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
147
+ }
148
+ function _unsupported_iterable_to_array(o, minLen) {
149
+ if (o) {
150
+ if (typeof o == "string")
151
+ return _array_like_to_array(o, minLen);
152
+ var n = Object.prototype.toString.call(o).slice(8, -1);
153
+ if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
154
+ return Array.from(n);
155
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
156
+ return _array_like_to_array(o, minLen);
157
+ }
158
+ }
159
+ function _ts_generator(thisArg, body) {
160
+ var f, y, t2, g, _ = {
161
+ label: 0,
162
+ sent: function() {
163
+ if (t2[0] & 1)
164
+ throw t2[1];
165
+ return t2[1];
166
+ },
167
+ trys: [],
168
+ ops: []
169
+ };
170
+ return g = {
171
+ next: verb(0),
172
+ throw: verb(1),
173
+ return: verb(2)
174
+ }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
175
+ return this;
176
+ }), g;
177
+ function verb(n) {
178
+ return function(v) {
179
+ return step([
180
+ n,
181
+ v
182
+ ]);
183
+ };
184
+ }
185
+ function step(op) {
186
+ if (f)
187
+ throw new TypeError("Generator is already executing.");
188
+ for (; _; )
189
+ try {
190
+ 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)
191
+ return t2;
192
+ switch (y = 0, t2 && (op = [
193
+ op[0] & 2,
194
+ t2.value
195
+ ]), op[0]) {
196
+ case 0:
197
+ case 1:
198
+ t2 = op;
199
+ break;
200
+ case 4:
201
+ return _.label++, {
202
+ value: op[1],
203
+ done: !1
204
+ };
205
+ case 5:
206
+ _.label++, y = op[1], op = [
207
+ 0
208
+ ];
209
+ continue;
210
+ case 7:
211
+ op = _.ops.pop(), _.trys.pop();
212
+ continue;
213
+ default:
214
+ if (t2 = _.trys, !(t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
215
+ _ = 0;
216
+ continue;
217
+ }
218
+ if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
219
+ _.label = op[1];
220
+ break;
221
+ }
222
+ if (op[0] === 6 && _.label < t2[1]) {
223
+ _.label = t2[1], t2 = op;
224
+ break;
225
+ }
226
+ if (t2 && _.label < t2[2]) {
227
+ _.label = t2[2], _.ops.push(op);
228
+ break;
229
+ }
230
+ t2[2] && _.ops.pop(), _.trys.pop();
231
+ continue;
232
+ }
233
+ op = body.call(thisArg, _);
234
+ } catch (e) {
235
+ op = [
236
+ 6,
237
+ e
238
+ ], y = 0;
239
+ } finally {
240
+ f = t2 = 0;
241
+ }
242
+ if (op[0] & 5)
243
+ throw op[1];
244
+ return {
245
+ value: op[0] ? op[1] : void 0,
246
+ done: !0
247
+ };
248
+ }
249
+ }
250
+ var UNTOUCHED_PROPS = {
31
251
  key: !0,
32
252
  style: !0,
33
253
  className: !0
34
254
  }, validHooks = {
35
255
  useMedia: !0,
36
256
  useTheme: !0
37
- }, createTernary = (x) => x;
38
- let hasLoggedBaseInfo = !1;
257
+ }, createTernary = function(x) {
258
+ return x;
259
+ }, hasLoggedBaseInfo = !1;
39
260
  function isFullyDisabled(props) {
40
261
  return props.disableExtraction && props.disableDebugAttr;
41
262
  }
42
- function createExtractor({ logger = console, platform = "web" } = { logger: console }) {
43
- const INLINE_EXTRACTABLE = {
263
+ function createExtractor() {
264
+ var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
265
+ logger: console
266
+ }, _ref_logger = _ref.logger, logger = _ref_logger === void 0 ? console : _ref_logger, _ref_platform = _ref.platform, platform = _ref_platform === void 0 ? "web" : _ref_platform, INLINE_EXTRACTABLE = _object_spread({
44
267
  ref: "ref",
45
- key: "key",
46
- ...platform === "web" && {
47
- onPress: "onClick",
48
- onHoverIn: "onMouseEnter",
49
- onHoverOut: "onMouseLeave",
50
- onPressIn: "onMouseDown",
51
- onPressOut: "onMouseUp"
52
- }
53
- }, componentState = {
268
+ key: "key"
269
+ }, platform === "web" && {
270
+ onPress: "onClick",
271
+ onHoverIn: "onMouseEnter",
272
+ onHoverOut: "onMouseLeave",
273
+ onPressIn: "onMouseDown",
274
+ onPressOut: "onMouseUp"
275
+ }), componentState = {
54
276
  focus: !1,
55
277
  hover: !1,
56
278
  unmounted: !0,
@@ -63,13 +285,39 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
63
285
  }, shouldAddDebugProp = (
64
286
  // really basic disable this for next.js because it messes with ssr
65
287
  !process.env.npm_package_dependencies_next && !1
66
- );
67
- let projectInfo = null;
288
+ ), projectInfo = null;
68
289
  function loadSync(props) {
69
290
  return isFullyDisabled(props) ? null : projectInfo || (projectInfo = loadTamaguiSync(props));
70
291
  }
71
- async function load(props) {
72
- return isFullyDisabled(props) ? null : projectInfo || (projectInfo = await loadTamagui(props));
292
+ function load(props) {
293
+ return _load.apply(this, arguments);
294
+ }
295
+ function _load() {
296
+ return _load = _async_to_generator(function(props) {
297
+ var _tmp;
298
+ return _ts_generator(this, function(_state) {
299
+ switch (_state.label) {
300
+ case 0:
301
+ return isFullyDisabled(props) ? [
302
+ 2,
303
+ null
304
+ ] : (_tmp = projectInfo, _tmp ? [
305
+ 3,
306
+ 2
307
+ ] : [
308
+ 4,
309
+ loadTamagui(props)
310
+ ]);
311
+ case 1:
312
+ _tmp = projectInfo = _state.sent(), _state.label = 2;
313
+ case 2:
314
+ return [
315
+ 2,
316
+ _tmp
317
+ ];
318
+ }
319
+ });
320
+ }), _load.apply(this, arguments);
73
321
  }
74
322
  return {
75
323
  options: {
@@ -78,666 +326,720 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
78
326
  cleanupBeforeExit,
79
327
  loadTamagui: load,
80
328
  loadTamaguiSync: loadSync,
81
- getTamagui() {
329
+ getTamagui: function() {
82
330
  return projectInfo == null ? void 0 : projectInfo.tamaguiConfig;
83
331
  },
84
- parseSync: (f, props) => {
85
- const projectInfo2 = loadSync(props);
332
+ parseSync: function(f, props) {
333
+ var projectInfo2 = loadSync(props);
86
334
  return parseWithConfig(projectInfo2 || {}, f, props);
87
335
  },
88
- parse: async (f, props) => {
89
- const projectInfo2 = await load(props);
90
- return parseWithConfig(projectInfo2 || {}, f, props);
91
- }
336
+ parse: function() {
337
+ var _ref2 = _async_to_generator(function(f, props) {
338
+ var projectInfo2;
339
+ return _ts_generator(this, function(_state) {
340
+ switch (_state.label) {
341
+ case 0:
342
+ return [
343
+ 4,
344
+ load(props)
345
+ ];
346
+ case 1:
347
+ return projectInfo2 = _state.sent(), [
348
+ 2,
349
+ parseWithConfig(projectInfo2 || {}, f, props)
350
+ ];
351
+ }
352
+ });
353
+ });
354
+ return function(f, props) {
355
+ return _ref2.apply(this, arguments);
356
+ };
357
+ }()
92
358
  };
93
- function parseWithConfig({ components, tamaguiConfig }, fileOrPath, options) {
94
- var _a;
95
- const {
96
- config = "tamagui.config.ts",
97
- importsWhitelist = ["constants.js"],
98
- evaluateVars = !0,
99
- sourcePath = "",
100
- onExtractTag,
101
- onStyleRule,
102
- getFlattenedNode,
103
- disable,
104
- disableExtraction,
105
- disableExtractInlineMedia,
106
- disableExtractVariables,
107
- disableDebugAttr,
108
- enableDynamicEvaluation = !1,
109
- includeExtensions = [".ts", ".tsx", ".jsx"],
110
- extractStyledDefinitions = !1,
111
- prefixLogs,
112
- excludeProps,
113
- platform: platform2,
114
- ...restProps
115
- } = options;
359
+ function parseWithConfig(param, fileOrPath, options) {
360
+ var components = param.components, tamaguiConfig = param.tamaguiConfig, _options_config = options.config, config = _options_config === void 0 ? "tamagui.config.ts" : _options_config, _options_importsWhitelist = options.importsWhitelist, importsWhitelist = _options_importsWhitelist === void 0 ? [
361
+ "constants.js"
362
+ ] : _options_importsWhitelist, _options_evaluateVars = options.evaluateVars, evaluateVars = _options_evaluateVars === void 0 ? !0 : _options_evaluateVars, _options_sourcePath = options.sourcePath, sourcePath = _options_sourcePath === void 0 ? "" : _options_sourcePath, onExtractTag = options.onExtractTag, onStyleRule = options.onStyleRule, getFlattenedNode = options.getFlattenedNode, disable = options.disable, disableExtraction = options.disableExtraction, disableExtractInlineMedia = options.disableExtractInlineMedia, disableExtractVariables = options.disableExtractVariables, disableDebugAttr = options.disableDebugAttr, _options_enableDynamicEvaluation = options.enableDynamicEvaluation, enableDynamicEvaluation = _options_enableDynamicEvaluation === void 0 ? !1 : _options_enableDynamicEvaluation, _options_includeExtensions = options.includeExtensions, includeExtensions = _options_includeExtensions === void 0 ? [
363
+ ".ts",
364
+ ".tsx",
365
+ ".jsx"
366
+ ] : _options_includeExtensions, _options_extractStyledDefinitions = options.extractStyledDefinitions, extractStyledDefinitions = _options_extractStyledDefinitions === void 0 ? !1 : _options_extractStyledDefinitions, prefixLogs = options.prefixLogs, excludeProps = options.excludeProps, platform2 = options.platform, restProps = _object_without_properties(options, [
367
+ "config",
368
+ "importsWhitelist",
369
+ "evaluateVars",
370
+ "sourcePath",
371
+ "onExtractTag",
372
+ "onStyleRule",
373
+ "getFlattenedNode",
374
+ "disable",
375
+ "disableExtraction",
376
+ "disableExtractInlineMedia",
377
+ "disableExtractVariables",
378
+ "disableDebugAttr",
379
+ "enableDynamicEvaluation",
380
+ "includeExtensions",
381
+ "extractStyledDefinitions",
382
+ "prefixLogs",
383
+ "excludeProps",
384
+ "platform"
385
+ ]);
116
386
  if (sourcePath.includes(".tamagui-dynamic-eval"))
117
387
  return null;
118
- const {
119
- normalizeStyle,
120
- getSplitStyles,
121
- mediaQueryConfig,
122
- propMapper,
123
- proxyThemeVariables,
124
- pseudoDescriptors
125
- } = requireTamaguiCore(platform2);
126
- let shouldPrintDebug = options.shouldPrintDebug || !1;
388
+ var _requireTamaguiCore = requireTamaguiCore(platform2), normalizeStyle = _requireTamaguiCore.normalizeStyle, getSplitStyles = _requireTamaguiCore.getSplitStyles, mediaQueryConfig = _requireTamaguiCore.mediaQueryConfig, propMapper = _requireTamaguiCore.propMapper, proxyThemeVariables = _requireTamaguiCore.proxyThemeVariables, pseudoDescriptors = _requireTamaguiCore.pseudoDescriptors, shouldPrintDebug = options.shouldPrintDebug || !1;
127
389
  if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath))
128
390
  return null;
129
391
  if (!isFullyDisabled(options) && !components)
130
392
  throw new Error("Must provide components");
131
- if (sourcePath && includeExtensions && !includeExtensions.some((ext) => sourcePath.endsWith(ext)))
132
- return shouldPrintDebug && logger.info(
133
- `Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(
134
- ", "
135
- )}`
136
- ), null;
393
+ if (sourcePath && includeExtensions && !includeExtensions.some(function(ext) {
394
+ return sourcePath.endsWith(ext);
395
+ }))
396
+ return shouldPrintDebug && logger.info("Ignoring file due to includeExtensions: ".concat(sourcePath, ", includeExtensions: ").concat(includeExtensions.join(", "))), null;
137
397
  function isValidStyleKey(name, staticConfig) {
138
- var _a2, _b, _c;
398
+ var _staticConfig_validStyles, _staticConfig_variants, _projectInfo_tamaguiConfig;
139
399
  if (!projectInfo)
140
400
  throw new Error("Tamagui extractor not loaded yet");
141
- return platform2 === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!((_a2 = staticConfig.validStyles) != null && _a2[name] || pseudoDescriptors[name] || // dont disable variants or else you lose many things flattening
142
- (_b = staticConfig.variants) != null && _b[name] || (_c = projectInfo == null ? void 0 : projectInfo.tamaguiConfig) != null && _c.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
401
+ return platform2 === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!(!((_staticConfig_validStyles = staticConfig.validStyles) === null || _staticConfig_validStyles === void 0) && _staticConfig_validStyles[name] || pseudoDescriptors[name] || !((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0) && _staticConfig_variants[name] || !(projectInfo == null || (_projectInfo_tamaguiConfig = projectInfo.tamaguiConfig) === null || _projectInfo_tamaguiConfig === void 0) && _projectInfo_tamaguiConfig.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
143
402
  }
144
- const isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo = {
145
- ...options,
403
+ var isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo = _object_spread_props(_object_spread({}, options), {
146
404
  sourcePath,
147
- allLoadedComponents: components ? [...components] : []
148
- };
149
- hasLoggedBaseInfo || (hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info(
150
- [
405
+ allLoadedComponents: components ? _to_consumable_array(components) : []
406
+ });
407
+ if (!hasLoggedBaseInfo) {
408
+ var _process_env_DEBUG;
409
+ hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info([
151
410
  "loaded components:",
152
- propsWithFileInfo.allLoadedComponents.map((comp) => Object.keys(comp.nameToInfo).join(", ")).join(", ")
153
- ].join(" ")
154
- ), (_a = process.env.DEBUG) != null && _a.startsWith("tamagui") && logger.info(
155
- [
411
+ propsWithFileInfo.allLoadedComponents.map(function(comp2) {
412
+ return Object.keys(comp2.nameToInfo).join(", ");
413
+ }).join(", ")
414
+ ].join(" ")), !((_process_env_DEBUG = process.env.DEBUG) === null || _process_env_DEBUG === void 0) && _process_env_DEBUG.startsWith("tamagui") && logger.info([
156
415
  "loaded:",
157
- propsWithFileInfo.allLoadedComponents.map((x) => x.moduleName)
416
+ propsWithFileInfo.allLoadedComponents.map(function(x) {
417
+ return x.moduleName;
418
+ })
158
419
  ].join(`
159
- `)
160
- )), tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig != null && tamaguiConfig.themes || (console.error(
161
- '\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file, this may be due to duplicated dependency versions. Try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches, or search your lockfile.'
162
- ), console.info(" Got config:", tamaguiConfig), process.exit(0));
163
- const firstThemeName = Object.keys((tamaguiConfig == null ? void 0 : tamaguiConfig.themes) || {})[0], firstTheme = (tamaguiConfig == null ? void 0 : tamaguiConfig.themes[firstThemeName]) || {};
420
+ `));
421
+ }
422
+ tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig != null && tamaguiConfig.themes || (console.error('\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file, this may be due to duplicated dependency versions. Try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches, or search your lockfile.'), console.info(" Got config:", tamaguiConfig), process.exit(0));
423
+ var firstThemeName = Object.keys((tamaguiConfig == null ? void 0 : tamaguiConfig.themes) || {})[0], firstTheme = (tamaguiConfig == null ? void 0 : tamaguiConfig.themes[firstThemeName]) || {};
164
424
  (!firstTheme || typeof firstTheme != "object") && (console.error("Missing theme, an error occurred when importing your config"), console.info("Got config:", tamaguiConfig), console.info("Looking for theme:", firstThemeName), process.exit(0));
165
- const proxiedTheme = proxyThemeVariables(firstTheme), themeAccessListeners = /* @__PURE__ */ new Set(), defaultTheme = new Proxy(proxiedTheme, {
166
- get(target, key) {
167
- return Reflect.has(target, key) && themeAccessListeners.forEach((cb) => cb(String(key))), Reflect.get(target, key);
425
+ var proxiedTheme = proxyThemeVariables(firstTheme), themeAccessListeners = /* @__PURE__ */ new Set(), defaultTheme = new Proxy(proxiedTheme, {
426
+ get: function(target, key) {
427
+ return Reflect.has(target, key) && themeAccessListeners.forEach(function(cb) {
428
+ return cb(String(key));
429
+ }), Reflect.get(target, key);
168
430
  }
169
431
  }), body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
170
- isFullyDisabled(options) || Object.keys(components || []).length === 0 && (console.warn(
171
- "Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)"
172
- ), process.env.DEBUG === "tamagui" && console.info("components", Object.keys(components || []), components)), shouldPrintDebug === "verbose" && (logger.info(
173
- `allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents.map((k) => k.moduleName).join(", ")}`
174
- ), logger.info(
175
- `valid import paths: ${JSON.stringify(
176
- getValidComponentsPaths(propsWithFileInfo)
177
- )}`
178
- ));
179
- let doesUseValidImport = !1, hasImportedTheme = !1;
180
- const importDeclarations = [];
181
- for (const bodyPath of body) {
182
- if (bodyPath.type !== "ImportDeclaration")
183
- continue;
184
- const node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = isValidImport(propsWithFileInfo, moduleName);
185
- if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some((specifier) => specifier.local.name === "styled")) {
186
- doesUseValidImport = !0;
187
- break;
188
- }
189
- if (valid) {
190
- const names = node.specifiers.map((specifier) => specifier.local.name), isValidComponent = names.some(
191
- (name) => !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name])
192
- );
193
- if (shouldPrintDebug === "verbose" && logger.info(
194
- ` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(
195
- ", "
196
- )} from '${moduleName}' - (valid: ${JSON.stringify(
197
- getValidComponentsPaths(propsWithFileInfo)
198
- )})`
199
- ), isValidComponent) {
200
- doesUseValidImport = !0;
201
- break;
432
+ isFullyDisabled(options) || Object.keys(components || []).length === 0 && (console.warn("Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)"), process.env.DEBUG === "tamagui" && console.info("components", Object.keys(components || []), components)), shouldPrintDebug === "verbose" && (logger.info("allLoadedComponent modules ".concat(propsWithFileInfo.allLoadedComponents.map(function(k) {
433
+ return k.moduleName;
434
+ }).join(", "))), logger.info("valid import paths: ".concat(JSON.stringify(getValidComponentsPaths(propsWithFileInfo)))));
435
+ var doesUseValidImport = !1, hasImportedTheme = !1, importDeclarations = [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
436
+ try {
437
+ for (var _loop = function() {
438
+ var bodyPath = _step.value;
439
+ if (bodyPath.type !== "ImportDeclaration")
440
+ return "continue";
441
+ var node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = isValidImport(propsWithFileInfo, moduleName);
442
+ if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(" - import ".concat(moduleName, " ").concat(valid)), extractStyledDefinitions && valid && node.specifiers.some(function(specifier) {
443
+ return specifier.local.name === "styled";
444
+ }))
445
+ return doesUseValidImport = !0, "break";
446
+ if (valid) {
447
+ var names = node.specifiers.map(function(specifier) {
448
+ return specifier.local.name;
449
+ }), isValidComponent = names.some(function(name) {
450
+ return !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name]);
451
+ });
452
+ if (shouldPrintDebug === "verbose" && logger.info(" - import ".concat(isValidComponent ? "\u2705" : "\u21E3", " - ").concat(names.join(", "), " from '").concat(moduleName, "' - (valid: ").concat(JSON.stringify(getValidComponentsPaths(propsWithFileInfo)), ")")), isValidComponent)
453
+ return doesUseValidImport = !0, "break";
202
454
  }
455
+ }, _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
456
+ var _ret = _loop();
457
+ if (_ret === "break")
458
+ break;
459
+ }
460
+ } catch (err) {
461
+ _didIteratorError = !0, _iteratorError = err;
462
+ } finally {
463
+ try {
464
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
465
+ } finally {
466
+ if (_didIteratorError)
467
+ throw _iteratorError;
203
468
  }
204
469
  }
205
- if (shouldPrintDebug && logger.info(
206
- `${JSON.stringify({ doesUseValidImport, hasImportedTheme }, null, 2)}
207
- `
208
- ), !doesUseValidImport)
470
+ if (shouldPrintDebug && logger.info("".concat(JSON.stringify({
471
+ doesUseValidImport,
472
+ hasImportedTheme
473
+ }, null, 2), `
474
+ `)), !doesUseValidImport)
209
475
  return null;
210
476
  function getValidImportedComponent(componentName) {
211
- const importDeclaration = importDeclarations.find(
212
- (dec) => dec.specifiers.some((spec) => spec.local.name === componentName)
213
- );
214
- return importDeclaration ? getValidImport(
215
- propsWithFileInfo,
216
- importDeclaration.source.value,
217
- componentName
218
- ) : null;
477
+ var importDeclaration = importDeclarations.find(function(dec) {
478
+ return dec.specifiers.some(function(spec) {
479
+ return spec.local.name === componentName;
480
+ });
481
+ });
482
+ return importDeclaration ? getValidImport(propsWithFileInfo, importDeclaration.source.value, componentName) : null;
219
483
  }
220
484
  tm.mark("import-check", !!shouldPrintDebug);
221
- let couldntParse = !1;
222
- const modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = (a) => fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a), shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath);
223
- let programPath = null;
224
- const res = {
485
+ var couldntParse = !1, modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = function(a) {
486
+ return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
487
+ }, shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath), programPath = null, res = {
225
488
  styled: 0,
226
489
  flattened: 0,
227
490
  optimized: 0,
228
491
  modified: 0,
229
492
  found: 0
230
- }, version = `${Math.random()}`;
493
+ }, version = "".concat(Math.random());
231
494
  if (callTraverse({
232
495
  // @ts-ignore
233
496
  Program: {
234
- enter(path) {
497
+ enter: function(path) {
235
498
  programPath = path;
236
499
  }
237
500
  },
238
501
  // styled() calls
239
- CallExpression(path) {
240
- var _a2, _b;
241
- if (disable || shouldDisableExtraction || extractStyledDefinitions === !1 || !t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled")
242
- return;
243
- const variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown", parentNode = path.node.arguments[0];
244
- if (!t.isIdentifier(parentNode))
245
- return;
246
- const parentName = parentNode.name, definition = path.node.arguments[1];
247
- if (!parentName || !definition || !t.isObjectExpression(definition))
248
- return;
249
- let Component = getValidImportedComponent(variableName);
250
- if (!Component) {
251
- if (enableDynamicEvaluation !== !0)
252
- return;
253
- try {
254
- shouldPrintDebug && logger.info(
255
- `Unknown component: ${variableName} = styled(${parentName}) attempting dynamic load: ${sourcePath}`
256
- );
257
- const out2 = loadTamaguiSync({
258
- forceExports: !0,
259
- components: [sourcePath],
260
- cacheKey: version
261
- });
262
- if (!(out2 != null && out2.components)) {
263
- shouldPrintDebug && logger.info(`Couldn't load, got ${out2}`);
264
- return;
265
- }
266
- if (propsWithFileInfo.allLoadedComponents = [
267
- ...propsWithFileInfo.allLoadedComponents,
268
- ...out2.components
269
- ], Component = out2.components.flatMap((x) => x.nameToInfo[variableName] ?? [])[0], !out2.cached) {
270
- const foundNames = (_a2 = out2.components) == null ? void 0 : _a2.map((x) => Object.keys(x.nameToInfo).join(", ")).join(", ").trim();
271
- foundNames && colorLog(
272
- Color.FgYellow,
273
- ` | Tamagui found dynamic components: ${foundNames}`
274
- );
275
- }
276
- } catch {
277
- shouldPrintDebug && logger.info(
278
- `skip optimize styled(${variableName}), unable to pre-process (DEBUG=tamagui for more)`
279
- );
280
- }
281
- }
282
- if (!Component) {
283
- shouldPrintDebug && logger.info(" No component found");
284
- return;
285
- }
286
- const componentSkipProps = /* @__PURE__ */ new Set([
287
- ...Component.staticConfig.inlineWhenUnflattened || [],
288
- ...Component.staticConfig.inlineProps || [],
289
- // for now skip variants, will return to them
290
- "variants",
291
- "defaultVariants",
292
- // skip fontFamily its basically a "variant", important for theme use to be value always
293
- "fontFamily",
294
- "name",
295
- "focusStyle",
296
- "hoverStyle",
297
- "pressStyle"
298
- ]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = getStaticBindingsForScope(
299
- path.scope,
300
- importsWhitelist,
301
- sourcePath,
302
- bindingCache,
303
- shouldPrintDebug
304
- ), attemptEval = evaluateVars ? createEvaluator({
305
- props: propsWithFileInfo,
306
- staticNamespace,
307
- sourcePath,
308
- shouldPrintDebug
309
- }) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
310
- for (const property of definition.properties) {
311
- if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || // TODO make pseudos and variants work
312
- // skip pseudos
313
- pseudoDescriptors[property.key.name] || // skip variants
314
- (_b = Component.staticConfig.variants) != null && _b[property.key.name] || componentSkipProps.has(property.key.name)) {
315
- skipped.add(property);
316
- continue;
317
- }
318
- const out2 = attemptEvalSafe(property.value);
319
- out2 === FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out2;
320
- }
321
- const out = getSplitStyles(
322
- styles,
323
- Component.staticConfig,
324
- defaultTheme,
325
- "",
326
- componentState,
327
- styleProps,
328
- void 0,
329
- void 0,
330
- void 0,
331
- shouldPrintDebug
332
- ), classNames = {
333
- ...out.classNames
334
- };
335
- if (shouldPrintDebug && logger.info(
336
- [
337
- `Extracted styled(${variableName})
338
- `,
339
- JSON.stringify(styles, null, 2),
340
- `
502
+ CallExpression: function(path) {
503
+ if (!(disable || shouldDisableExtraction || extractStyledDefinitions === !1) && !(!t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled")) {
504
+ var variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown", parentNode = path.node.arguments[0];
505
+ if (t.isIdentifier(parentNode)) {
506
+ var parentName = parentNode.name, definition = path.node.arguments[1];
507
+ if (!(!parentName || !definition || !t.isObjectExpression(definition))) {
508
+ var Component = getValidImportedComponent(variableName);
509
+ if (!Component) {
510
+ if (enableDynamicEvaluation !== !0)
511
+ return;
512
+ try {
513
+ shouldPrintDebug && logger.info("Unknown component: ".concat(variableName, " = styled(").concat(parentName, ") attempting dynamic load: ").concat(sourcePath));
514
+ var out = loadTamaguiSync({
515
+ forceExports: !0,
516
+ components: [
517
+ sourcePath
518
+ ],
519
+ cacheKey: version
520
+ });
521
+ if (!(out != null && out.components)) {
522
+ shouldPrintDebug && logger.info("Couldn't load, got ".concat(out));
523
+ return;
524
+ }
525
+ if (propsWithFileInfo.allLoadedComponents = _to_consumable_array(propsWithFileInfo.allLoadedComponents).concat(_to_consumable_array(out.components)), Component = out.components.flatMap(function(x) {
526
+ var _x_nameToInfo_variableName;
527
+ return (_x_nameToInfo_variableName = x.nameToInfo[variableName]) !== null && _x_nameToInfo_variableName !== void 0 ? _x_nameToInfo_variableName : [];
528
+ })[0], !out.cached) {
529
+ var _out_components, foundNames = (_out_components = out.components) === null || _out_components === void 0 ? void 0 : _out_components.map(function(x) {
530
+ return Object.keys(x.nameToInfo).join(", ");
531
+ }).join(", ").trim();
532
+ foundNames && colorLog(Color.FgYellow, " | Tamagui found dynamic components: ".concat(foundNames));
533
+ }
534
+ } catch {
535
+ shouldPrintDebug && logger.info("skip optimize styled(".concat(variableName, "), unable to pre-process (DEBUG=tamagui for more)"));
536
+ }
537
+ }
538
+ if (!Component) {
539
+ shouldPrintDebug && logger.info(" No component found");
540
+ return;
541
+ }
542
+ var componentSkipProps = new Set(_to_consumable_array(Component.staticConfig.inlineWhenUnflattened || []).concat(_to_consumable_array(Component.staticConfig.inlineProps || []), [
543
+ // for now skip variants, will return to them
544
+ "variants",
545
+ "defaultVariants",
546
+ // skip fontFamily its basically a "variant", important for theme use to be value always
547
+ "fontFamily",
548
+ "name",
549
+ "focusStyle",
550
+ "hoverStyle",
551
+ "pressStyle"
552
+ ])), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = getStaticBindingsForScope(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug), attemptEval = evaluateVars ? createEvaluator({
553
+ props: propsWithFileInfo,
554
+ staticNamespace,
555
+ sourcePath,
556
+ shouldPrintDebug
557
+ }) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval), _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
558
+ try {
559
+ for (var _iterator2 = definition.properties[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
560
+ var property = _step2.value, _Component_staticConfig_variants;
561
+ if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || // TODO make pseudos and variants work
562
+ // skip pseudos
563
+ pseudoDescriptors[property.key.name] || !((_Component_staticConfig_variants = Component.staticConfig.variants) === null || _Component_staticConfig_variants === void 0) && _Component_staticConfig_variants[property.key.name] || componentSkipProps.has(property.key.name)) {
564
+ skipped.add(property);
565
+ continue;
566
+ }
567
+ var out1 = attemptEvalSafe(property.value);
568
+ out1 === FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out1;
569
+ }
570
+ } catch (err) {
571
+ _didIteratorError2 = !0, _iteratorError2 = err;
572
+ } finally {
573
+ try {
574
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
575
+ } finally {
576
+ if (_didIteratorError2)
577
+ throw _iteratorError2;
578
+ }
579
+ }
580
+ var out2 = getSplitStyles(styles, Component.staticConfig, defaultTheme, "", componentState, styleProps, void 0, void 0, void 0, shouldPrintDebug), classNames = _object_spread({}, out2.classNames);
581
+ if (shouldPrintDebug && logger.info([
582
+ "Extracted styled(".concat(variableName, `)
583
+ `),
584
+ JSON.stringify(styles, null, 2),
585
+ `
341
586
  classNames:`,
342
- JSON.stringify(classNames, null, 2),
343
- `
587
+ JSON.stringify(classNames, null, 2),
588
+ `
344
589
  rulesToInsert:`,
345
- out.rulesToInsert.flatMap((rule) => rule.rules).join(`
590
+ out2.rulesToInsert.flatMap(function(rule) {
591
+ return rule.rules;
592
+ }).join(`
346
593
  `)
347
- ].join(" ")
348
- ), definition.properties = definition.properties.map((prop) => {
349
- if (skipped.has(prop) || !t.isObjectProperty(prop) || !t.isIdentifier(prop.key))
350
- return prop;
351
- const key = prop.key.name, value = classNames[key];
352
- return value ? t.objectProperty(t.stringLiteral(key), t.stringLiteral(value)) : prop;
353
- }), out.rulesToInsert)
354
- for (const { identifier, rules } of out.rulesToInsert)
355
- onStyleRule == null || onStyleRule(identifier, rules);
356
- res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
594
+ ].join(" ")), definition.properties = definition.properties.map(function(prop) {
595
+ if (skipped.has(prop) || !t.isObjectProperty(prop) || !t.isIdentifier(prop.key))
596
+ return prop;
597
+ var key = prop.key.name, value = classNames[key];
598
+ return value ? t.objectProperty(t.stringLiteral(key), t.stringLiteral(value)) : prop;
599
+ }), out2.rulesToInsert) {
600
+ var _iteratorNormalCompletion12 = !0, _didIteratorError12 = !1, _iteratorError12 = void 0;
601
+ try {
602
+ for (var _iterator12 = out2.rulesToInsert[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = !0) {
603
+ var _step_value = _step12.value, identifier = _step_value.identifier, rules = _step_value.rules;
604
+ onStyleRule == null || onStyleRule(identifier, rules);
605
+ }
606
+ } catch (err) {
607
+ _didIteratorError12 = !0, _iteratorError12 = err;
608
+ } finally {
609
+ try {
610
+ !_iteratorNormalCompletion12 && _iterator12.return != null && _iterator12.return();
611
+ } finally {
612
+ if (_didIteratorError12)
613
+ throw _iteratorError12;
614
+ }
615
+ }
616
+ }
617
+ res.styled++, shouldPrintDebug && logger.info("Extracted styled(".concat(variableName, ")"));
618
+ }
619
+ }
620
+ }
357
621
  },
358
- JSXElement(traversePath) {
359
- var _a2;
622
+ JSXElement: function(traversePath) {
360
623
  tm.mark("jsx-element", !!shouldPrintDebug);
361
- const node = traversePath.node.openingElement, ogAttributes = node.attributes.map((attr) => ({ ...attr })), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
362
- if (shouldPrintDebug && logger.info(` start ${node.name}`), closingElement && t.isJSXMemberExpression(closingElement == null ? void 0 : closingElement.name) || !t.isJSXIdentifier(node.name)) {
624
+ var node = traversePath.node.openingElement, ogAttributes = node.attributes.map(function(attr3) {
625
+ return _object_spread({}, attr3);
626
+ }), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
627
+ if (shouldPrintDebug && logger.info(" start ".concat(node.name)), closingElement && t.isJSXMemberExpression(closingElement == null ? void 0 : closingElement.name) || !t.isJSXIdentifier(node.name)) {
363
628
  shouldPrintDebug && logger.info(" skip non-identifier element");
364
629
  return;
365
630
  }
366
- const binding = traversePath.scope.getBinding(node.name.name);
367
- let moduleName = "";
631
+ var binding = traversePath.scope.getBinding(node.name.name), moduleName = "";
368
632
  if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, moduleName, binding.identifier.name))) {
369
- shouldPrintDebug && logger.info(
370
- ` - Binding for ${componentName} not internal import or from components ${binding.identifier.name} in ${moduleName}`
371
- );
633
+ shouldPrintDebug && logger.info(" - Binding for ".concat(componentName, " not internal import or from components ").concat(binding.identifier.name, " in ").concat(moduleName));
372
634
  return;
373
635
  }
374
- const component = getValidComponent(propsWithFileInfo, moduleName, node.name.name);
636
+ var component = getValidComponent(propsWithFileInfo, moduleName, node.name.name);
375
637
  if (!component || !component.staticConfig) {
376
- shouldPrintDebug && logger.info(` - No Tamagui conf on this: ${node.name.name}`);
638
+ shouldPrintDebug && logger.info(" - No Tamagui conf on this: ".concat(node.name.name));
377
639
  return;
378
640
  }
379
- const originalNodeName = node.name.name;
641
+ var originalNodeName = node.name.name;
380
642
  res.found++;
381
- const filePath = `./${relative(process.cwd(), sourcePath)}`, lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "", codePosition = `${filePath}:${lineNumbers}`, debugPropValue = node.attributes.filter(
382
- (n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug"
383
- ).map((n) => n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1)[0];
643
+ var filePath = "./".concat(relative(process.cwd(), sourcePath)), lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? "-".concat(node.loc.end.line) : "") : "", codePosition = "".concat(filePath, ":").concat(lineNumbers), debugPropValue = node.attributes.filter(function(n) {
644
+ return t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug";
645
+ }).map(function(n) {
646
+ return n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1;
647
+ })[0];
384
648
  if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`
385
- `), logger.info(
386
- `\x1B[33m%s\x1B[0m ${componentName} | ${codePosition} -------------------`
387
- ), logger.info(
388
- [
389
- "\x1B[1m",
390
- "\x1B[32m",
391
- `<${originalNodeName} />`,
392
- disableDebugAttr ? "" : "\u{1F41B}"
393
- ].join(" ")
394
- )), shouldAddDebugProp && !disableDebugAttr && (res.modified++, node.attributes.unshift(
395
- t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(node.name.name))
396
- ), componentName && node.attributes.unshift(
397
- t.jsxAttribute(t.jsxIdentifier("data-in"), t.stringLiteral(componentName))
398
- ), node.attributes.unshift(
399
- t.jsxAttribute(
400
- t.jsxIdentifier("data-at"),
401
- t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)
402
- )
403
- )), shouldDisableExtraction) {
649
+ `), logger.info("\x1B[33m%s\x1B[0m " + "".concat(componentName, " | ").concat(codePosition, " -------------------")), logger.info([
650
+ "\x1B[1m",
651
+ "\x1B[32m",
652
+ "<".concat(originalNodeName, " />"),
653
+ disableDebugAttr ? "" : "\u{1F41B}"
654
+ ].join(" "))), shouldAddDebugProp && !disableDebugAttr && (res.modified++, node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(node.name.name))), componentName && node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-in"), t.stringLiteral(componentName))), node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-at"), t.stringLiteral("".concat(basename(filePath), ":").concat(lineNumbers))))), shouldDisableExtraction) {
404
655
  shouldPrintDebug === "verbose" && console.info(" Extraction disabled");
405
656
  return;
406
657
  }
407
658
  try {
408
- let evaluateAttribute2 = function(path) {
409
- const attribute = path.node, attr = { type: "attr", value: attribute };
410
- if (t.isJSXSpreadAttribute(attribute)) {
411
- const arg = attribute.argument, conditional = t.isConditionalExpression(arg) ? (
412
- // <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
413
- [arg.test, arg.consequent, arg.alternate]
414
- ) : t.isLogicalExpression(arg) && arg.operator === "&&" ? (
415
- // <YStack {...isSmall && { color: 'red }}
416
- [arg.left, arg.right, null]
417
- ) : null;
418
- if (conditional) {
419
- const [test, alt, cons] = conditional;
420
- if (!test)
421
- throw new Error("no test");
422
- return [alt, cons].some((side) => side && !isStaticObject2(side)) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr) : [
423
- ...createTernariesFromObjectProperties2(test, alt) || [],
424
- ...cons && createTernariesFromObjectProperties2(
425
- t.unaryExpression("!", test),
426
- cons
427
- ) || []
428
- ].map((ternary) => ({
429
- type: "ternary",
430
- value: ternary
431
- }));
432
- }
433
- }
434
- if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string")
435
- return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr;
436
- const name = attribute.name.name;
437
- if (excludeProps != null && excludeProps.has(name))
438
- return shouldPrintDebug && logger.info([" excluding prop", name].join(" ")), null;
439
- if (inlineProps.has(name))
440
- return inlined.set(name, name), shouldPrintDebug && logger.info([" ! inlining, inline prop", name].join(" ")), attr;
441
- if (UNTOUCHED_PROPS[name])
442
- return attr;
443
- if (INLINE_EXTRACTABLE[name])
444
- return inlined.set(name, INLINE_EXTRACTABLE[name]), attr;
445
- if (name.startsWith("data-"))
446
- return attr;
447
- if (name[0] === "$" && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
448
- const shortname = name.slice(1);
449
- if (mediaQueryConfig[shortname]) {
450
- if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
451
- return attr;
452
- const expression = attribute.value.expression;
453
- if (!t.isJSXEmptyExpression(expression)) {
454
- const ternaries2 = createTernariesFromObjectProperties2(
455
- t.stringLiteral(shortname),
456
- expression,
457
- {
458
- inlineMediaQuery: shortname
459
- }
460
- );
461
- if (ternaries2)
462
- return ternaries2.map((value2) => ({
463
- type: "ternary",
464
- value: value2
465
- }));
466
- }
467
- }
468
- }
469
- const [value, valuePath] = t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value) ? [attribute.value.expression, path.get("value")] : [attribute.value, path.get("value")], remove = () => {
470
- Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
471
- };
472
- if (name === "ref")
473
- return shouldPrintDebug && logger.info([" ! inlining, ref", name].join(" ")), inlined.set("ref", "ref"), attr;
474
- if (name === "tag")
475
- return {
476
- type: "attr",
477
- value: path.node
478
- };
479
- if (disableExtractVariables === !0 && value && value.type === "StringLiteral" && value.value[0] === "$")
480
- return shouldPrintDebug && logger.info(
481
- [
482
- ` ! inlining, native disable extract: ${name} =`,
483
- value.value
484
- ].join(" ")
485
- ), inlined.set(name, !0), attr;
486
- if (name === "theme")
487
- return inlined.set("theme", attr.value), attr;
488
- const styleValue = attemptEvalSafe(value);
489
- if (!variants[name] && !isValidStyleKey(name, staticConfig)) {
490
- let keys = [name], out = null;
491
- out = propMapper(name, styleValue, propMapperStyleState), out && (Array.isArray(out) ? (out = Object.fromEntries(out), keys = Object.keys(out)) : (logger.warn("Error expected array but got", out), couldntParse = !0, shouldDeopt = !0)), out && (isTargetingHTML && (out = createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
492
- let didInline = !1;
493
- const attributes = keys.map((key) => {
494
- const val = out[key];
495
- return isValidStyleKey(key, staticConfig) ? {
496
- type: "style",
497
- value: { [key]: styleValue },
498
- name: key,
499
- attr: path.node
500
- } : validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
501
- key === "__source" || key === "__self" ? attr : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key), didInline = !0, inlined.set(key, val), val);
502
- });
503
- return didInline ? (shouldPrintDebug && logger.info(
504
- ` bailing flattening due to attributes ${attributes.map(
505
- (x) => x.toString()
506
- )}`
507
- ), attr) : attributes;
508
- }
509
- if (styleValue !== FAILED_EVAL)
510
- return inlineWhenUnflattened.has(name) && (inlineWhenUnflattenedOGVals[name] = { styleValue, attr }), isValidStyleKey(name, staticConfig) ? (shouldPrintDebug && logger.info(` style: ${name} = ${styleValue}`), name in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
511
- type: "style",
512
- value: { [name]: styleValue },
513
- name,
514
- attr: path.node
515
- }) : (variants[name] && variantValues.set(name, styleValue), inlined.set(name, !0), attr);
516
- if (t.isBinaryExpression(value)) {
517
- shouldPrintDebug && logger.info(` binary expression ${name} = ${value}`);
518
- const { operator, left, right } = value, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
519
- if (shouldPrintDebug && logger.info(
520
- ` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`
521
- ), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
522
- const ternary = addBinaryConditional(operator, left, right);
523
- if (ternary)
524
- return ternary;
525
- }
526
- if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
527
- const ternary = addBinaryConditional(operator, right, left);
528
- if (ternary)
529
- return ternary;
530
- }
531
- return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name, !0), attr;
532
- }
533
- const staticConditional = getStaticConditional(value);
534
- if (staticConditional)
535
- return shouldPrintDebug === "verbose" && logger.info(` static conditional ${name} ${value}`), { type: "ternary", value: staticConditional };
536
- const staticLogical = getStaticLogical(value);
537
- if (staticLogical)
538
- return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name} = ${value}`), { type: "ternary", value: staticLogical };
539
- if (options.experimentalFlattenDynamicValues && isValidStyleKey(name, staticConfig))
540
- return {
541
- type: "dynamic-style",
542
- value,
543
- name: (tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[name]) || name
544
- };
545
- return inlined.set(name, !0), shouldPrintDebug && logger.info(` ! inline no match ${name} ${value}`), attr;
546
- function addBinaryConditional(operator, staticExpr, cond) {
547
- if (getStaticConditional(cond)) {
548
- const alt = attemptEval(
549
- t.binaryExpression(operator, staticExpr, cond.alternate)
550
- ), cons = attemptEval(
551
- t.binaryExpression(operator, staticExpr, cond.consequent)
552
- );
553
- return shouldPrintDebug && logger.info([" binaryConditional", cond.test, cons, alt].join(" ")), {
554
- type: "ternary",
555
- value: {
556
- test: cond.test,
557
- remove,
558
- alternate: { [name]: alt },
559
- consequent: { [name]: cons }
560
- }
561
- };
562
- }
563
- return null;
564
- }
565
- function getStaticConditional(value2) {
566
- if (t.isConditionalExpression(value2))
567
- try {
568
- const aVal = attemptEval(value2.alternate), cVal = attemptEval(value2.consequent);
569
- if (shouldPrintDebug) {
570
- const type = value2.test.type;
571
- logger.info([" static ternary", type, cVal, aVal].join(" "));
572
- }
573
- return {
574
- test: value2.test,
575
- remove,
576
- consequent: { [name]: cVal },
577
- alternate: { [name]: aVal }
578
- };
579
- } catch (err) {
580
- shouldPrintDebug && logger.info([" cant eval ternary", err.message].join(" "));
581
- }
582
- return null;
583
- }
584
- function getStaticLogical(value2) {
585
- if (t.isLogicalExpression(value2) && value2.operator === "&&")
586
- try {
587
- const val = attemptEval(value2.right);
588
- return shouldPrintDebug && logger.info([" staticLogical", value2.left, name, val].join(" ")), {
589
- test: value2.left,
590
- remove,
591
- consequent: { [name]: val },
592
- alternate: null
593
- };
594
- } catch (err) {
595
- shouldPrintDebug && logger.info([" cant static eval logical", err].join(" "));
596
- }
597
- return null;
598
- }
599
- }, isStaticObject2 = function(obj) {
600
- return t.isObjectExpression(obj) && obj.properties.every((prop) => {
601
- if (!t.isObjectProperty(prop))
602
- return logger.info(["not object prop", prop].join(" ")), !1;
603
- const propName = prop.key.name;
604
- return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([" not a valid style prop!", propName].join(" ")), !1) : !0;
605
- });
606
- }, createTernariesFromObjectProperties2 = function(test, side, ternaryPartial = {}) {
659
+ let createTernariesFromObjectProperties2 = function(test, side) {
660
+ var ternaryPartial = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
607
661
  if (!side)
608
662
  return null;
609
- if (!isStaticObject2(side))
663
+ if (!isStaticObject(side))
610
664
  throw new Error("not extractable");
611
- return side.properties.flatMap((property) => {
665
+ return side.properties.flatMap(function(property) {
612
666
  if (!t.isObjectProperty(property))
613
667
  throw new Error("expected object property");
614
668
  if (t.isIdentifier(property.key)) {
615
- const key = property.key.name, mediaQueryKey = key.slice(1);
616
- if (key[0] === "$" && mediaQueryConfig[mediaQueryKey])
669
+ var key9 = property.key.name, mediaQueryKey = key9.slice(1), isMediaQuery = key9[0] === "$" && mediaQueryConfig[mediaQueryKey];
670
+ if (isMediaQuery)
617
671
  if (t.isExpression(property.value)) {
618
- const ternaries2 = createTernariesFromObjectProperties2(
619
- t.stringLiteral(mediaQueryKey),
620
- property.value,
621
- {
622
- inlineMediaQuery: mediaQueryKey
623
- }
624
- );
672
+ var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(mediaQueryKey), property.value, {
673
+ inlineMediaQuery: mediaQueryKey
674
+ });
625
675
  if (ternaries2)
626
- return ternaries2.map((value) => ({
627
- ...ternaryPartial,
628
- ...value,
629
- // ensure media query test stays on left side (see getMediaQueryTernary)
630
- test: t.logicalExpression("&&", value.test, test)
631
- }));
632
- logger.info(["\u26A0\uFE0F no ternaries?", property].join(" "));
676
+ return ternaries2.map(function(value2) {
677
+ return _object_spread_props(_object_spread({}, ternaryPartial, value2), {
678
+ // ensure media query test stays on left side (see getMediaQueryTernary)
679
+ test: t.logicalExpression("&&", value2.test, test)
680
+ });
681
+ });
682
+ logger.info([
683
+ "\u26A0\uFE0F no ternaries?",
684
+ property
685
+ ].join(" "));
633
686
  } else
634
- logger.info(["\u26A0\uFE0F not expression", property].join(" "));
687
+ logger.info([
688
+ "\u26A0\uFE0F not expression",
689
+ property
690
+ ].join(" "));
635
691
  }
636
692
  if (t.isConditionalExpression(property.value)) {
637
- const [truthy, falsy] = [
693
+ var _map = _sliced_to_array([
638
694
  t.objectExpression([
639
695
  t.objectProperty(property.key, property.value.consequent)
640
696
  ]),
641
697
  t.objectExpression([
642
698
  t.objectProperty(property.key, property.value.alternate)
643
699
  ])
644
- ].map((x) => attemptEval(x));
700
+ ].map(function(x) {
701
+ return attemptEval(x);
702
+ }), 2), truthy = _map[0], falsy = _map[1];
645
703
  return [
646
- createTernary({
647
- remove() {
648
- },
649
- ...ternaryPartial,
704
+ createTernary(_object_spread_props(_object_spread({
705
+ remove: function() {
706
+ }
707
+ }, ternaryPartial), {
650
708
  test: t.logicalExpression("&&", test, property.value.test),
651
709
  consequent: truthy,
652
710
  alternate: null
653
- }),
654
- createTernary({
655
- ...ternaryPartial,
656
- test: t.logicalExpression(
657
- "&&",
658
- test,
659
- t.unaryExpression("!", property.value.test)
660
- ),
711
+ })),
712
+ createTernary(_object_spread_props(_object_spread({}, ternaryPartial), {
713
+ test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
661
714
  consequent: falsy,
662
715
  alternate: null,
663
- remove() {
716
+ remove: function() {
664
717
  }
665
- })
718
+ }))
666
719
  ];
667
720
  }
668
- const obj = t.objectExpression([
721
+ var obj = t.objectExpression([
669
722
  t.objectProperty(property.key, property.value)
670
723
  ]), consequent = attemptEval(obj);
671
- return createTernary({
672
- remove() {
673
- },
674
- ...ternaryPartial,
724
+ return createTernary(_object_spread_props(_object_spread({
725
+ remove: function() {
726
+ }
727
+ }, ternaryPartial), {
675
728
  test,
676
729
  consequent,
677
730
  alternate: null
678
- });
731
+ }));
679
732
  });
680
- }, mergeToEnd2 = function(obj, key, val) {
681
- key in obj && delete obj[key], obj[key] = val;
682
- }, normalizeStyleWithoutVariants2 = function(style) {
683
- let res2 = {};
684
- for (const key in style)
685
- if (staticConfig.variants && key in staticConfig.variants)
686
- mergeToEnd2(res2, key, style[key]);
687
- else {
688
- const expanded = normalizeStyle({ [key]: style[key] }, !0);
689
- for (const key2 in expanded)
690
- mergeToEnd2(res2, key2, expanded[key2]);
691
- }
692
- return res2;
693
- }, mergeStyles2 = function(prev2, next) {
694
- for (const key in next)
695
- pseudoDescriptors[key] ? (prev2[key] = prev2[key] || {}, Object.assign(prev2[key], next[key])) : mergeToEnd2(prev2, key, next[key]);
696
733
  };
697
- var evaluateAttribute = evaluateAttribute2, isStaticObject = isStaticObject2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, mergeToEnd = mergeToEnd2, normalizeStyleWithoutVariants = normalizeStyleWithoutVariants2, mergeStyles = mergeStyles2;
698
- const { staticConfig } = component, defaultProps = { ...staticConfig.defaultProps || {} }, variants = staticConfig.variants || {}, isTextView = staticConfig.isText || !1, validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
699
- let tagName = defaultProps.tag ?? (isTextView ? "span" : "div");
700
- traversePath.get("openingElement").get("attributes").forEach((path) => {
701
- const attr = path.node;
702
- if (t.isJSXSpreadAttribute(attr) || attr.name.name !== "tag")
703
- return;
704
- const val = attr.value;
705
- t.isStringLiteral(val) && (tagName = val.value);
706
- }), shouldPrintDebug === "verbose" && console.info(` Start tag ${tagName}`);
707
- const flatNode = getFlattenedNode == null ? void 0 : getFlattenedNode({ isTextView, tag: tagName }), inlineProps = /* @__PURE__ */ new Set([
734
+ var createTernariesFromObjectProperties = createTernariesFromObjectProperties2, evaluateAttribute = (
735
+ // START function evaluateAttribute
736
+ function(path) {
737
+ var attribute = path.node, attr3 = {
738
+ type: "attr",
739
+ value: attribute
740
+ };
741
+ if (t.isJSXSpreadAttribute(attribute)) {
742
+ var arg = attribute.argument, conditional = t.isConditionalExpression(arg) ? [
743
+ arg.test,
744
+ arg.consequent,
745
+ arg.alternate
746
+ ] : t.isLogicalExpression(arg) && arg.operator === "&&" ? [
747
+ arg.left,
748
+ arg.right,
749
+ null
750
+ ] : null;
751
+ if (conditional) {
752
+ var _conditional = _sliced_to_array(conditional, 3), test = _conditional[0], alt = _conditional[1], cons = _conditional[2];
753
+ if (!test)
754
+ throw new Error("no test");
755
+ return [
756
+ alt,
757
+ cons
758
+ ].some(function(side) {
759
+ return side && !isStaticObject(side);
760
+ }) ? (shouldPrintDebug && logger.info("not extractable ".concat(alt, " ").concat(cons)), attr3) : _to_consumable_array(createTernariesFromObjectProperties2(test, alt) || []).concat(_to_consumable_array(cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || [])).map(function(ternary2) {
761
+ return {
762
+ type: "ternary",
763
+ value: ternary2
764
+ };
765
+ });
766
+ }
767
+ }
768
+ if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string")
769
+ return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set("".concat(Math.random()), "spread"), attr3;
770
+ var name2 = attribute.name.name;
771
+ if (excludeProps != null && excludeProps.has(name2))
772
+ return shouldPrintDebug && logger.info([
773
+ " excluding prop",
774
+ name2
775
+ ].join(" ")), null;
776
+ if (inlineProps.has(name2))
777
+ return inlined.set(name2, name2), shouldPrintDebug && logger.info([
778
+ " ! inlining, inline prop",
779
+ name2
780
+ ].join(" ")), attr3;
781
+ if (UNTOUCHED_PROPS[name2])
782
+ return attr3;
783
+ if (INLINE_EXTRACTABLE[name2])
784
+ return inlined.set(name2, INLINE_EXTRACTABLE[name2]), attr3;
785
+ if (name2.startsWith("data-"))
786
+ return attr3;
787
+ if (name2[0] === "$" && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
788
+ var shortname = name2.slice(1);
789
+ if (mediaQueryConfig[shortname]) {
790
+ if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
791
+ return attr3;
792
+ var expression = attribute.value.expression;
793
+ if (!t.isJSXEmptyExpression(expression)) {
794
+ var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
795
+ inlineMediaQuery: shortname
796
+ });
797
+ if (ternaries2)
798
+ return ternaries2.map(function(value3) {
799
+ return {
800
+ type: "ternary",
801
+ value: value3
802
+ };
803
+ });
804
+ }
805
+ }
806
+ }
807
+ var _ref2 = _sliced_to_array(function() {
808
+ return t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value) ? [
809
+ attribute.value.expression,
810
+ path.get("value")
811
+ ] : [
812
+ attribute.value,
813
+ path.get("value")
814
+ ];
815
+ }(), 2), value2 = _ref2[0], valuePath = _ref2[1], remove = function() {
816
+ Array.isArray(valuePath) ? valuePath.map(function(p) {
817
+ return p.remove();
818
+ }) : valuePath.remove();
819
+ };
820
+ if (name2 === "ref")
821
+ return shouldPrintDebug && logger.info([
822
+ " ! inlining, ref",
823
+ name2
824
+ ].join(" ")), inlined.set("ref", "ref"), attr3;
825
+ if (name2 === "tag")
826
+ return {
827
+ type: "attr",
828
+ value: path.node
829
+ };
830
+ if (disableExtractVariables === !0 && value2 && value2.type === "StringLiteral" && value2.value[0] === "$")
831
+ return shouldPrintDebug && logger.info([
832
+ " ! inlining, native disable extract: ".concat(name2, " ="),
833
+ value2.value
834
+ ].join(" ")), inlined.set(name2, !0), attr3;
835
+ if (name2 === "theme")
836
+ return inlined.set("theme", attr3.value), attr3;
837
+ var styleValue = attemptEvalSafe(value2);
838
+ if (!variants[name2] && !isValidStyleKey(name2, staticConfig)) {
839
+ var keys = [
840
+ name2
841
+ ], out = null;
842
+ out = propMapper(name2, styleValue, propMapperStyleState), out && (Array.isArray(out) ? (out = Object.fromEntries(out), keys = Object.keys(out)) : (logger.warn("Error expected array but got", out), couldntParse = !0, shouldDeopt = !0)), out && (isTargetingHTML && (out = createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
843
+ var didInline = !1, attributes = keys.map(function(key9) {
844
+ var val2 = out[key9], isStyle = isValidStyleKey(key9, staticConfig);
845
+ return isStyle ? {
846
+ type: "style",
847
+ value: _define_property({}, key9, styleValue),
848
+ name: key9,
849
+ attr: path.node
850
+ } : validHTMLAttributes[key9] || key9.startsWith("aria-") || key9.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
851
+ key9 === "__source" || key9 === "__self" ? attr3 : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key9), didInline = !0, inlined.set(key9, val2), val2);
852
+ });
853
+ return didInline ? (shouldPrintDebug && logger.info(" bailing flattening due to attributes ".concat(attributes.map(function(x) {
854
+ return x.toString();
855
+ }))), attr3) : attributes;
856
+ }
857
+ if (styleValue !== FAILED_EVAL)
858
+ return inlineWhenUnflattened.has(name2) && (inlineWhenUnflattenedOGVals[name2] = {
859
+ styleValue,
860
+ attr: attr3
861
+ }), isValidStyleKey(name2, staticConfig) ? (shouldPrintDebug && logger.info(" style: ".concat(name2, " = ").concat(styleValue)), name2 in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
862
+ type: "style",
863
+ value: _define_property({}, name2, styleValue),
864
+ name: name2,
865
+ attr: path.node
866
+ }) : (variants[name2] && variantValues.set(name2, styleValue), inlined.set(name2, !0), attr3);
867
+ if (t.isBinaryExpression(value2)) {
868
+ shouldPrintDebug && logger.info(" binary expression ".concat(name2, " = ").concat(value2));
869
+ var operator = value2.operator, left = value2.left, right = value2.right, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
870
+ if (shouldPrintDebug && logger.info(" evalBinaryExpression lVal ".concat(String(lVal), ", rVal ").concat(String(rVal))), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
871
+ var ternary = addBinaryConditional(operator, left, right);
872
+ if (ternary)
873
+ return ternary;
874
+ }
875
+ if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
876
+ var ternary1 = addBinaryConditional(operator, right, left);
877
+ if (ternary1)
878
+ return ternary1;
879
+ }
880
+ return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name2, !0), attr3;
881
+ }
882
+ var staticConditional = getStaticConditional(value2);
883
+ if (staticConditional)
884
+ return shouldPrintDebug === "verbose" && logger.info(" static conditional ".concat(name2, " ").concat(value2)), {
885
+ type: "ternary",
886
+ value: staticConditional
887
+ };
888
+ var staticLogical = getStaticLogical(value2);
889
+ if (staticLogical)
890
+ return shouldPrintDebug === "verbose" && logger.info(" static ternary ".concat(name2, " = ").concat(value2)), {
891
+ type: "ternary",
892
+ value: staticLogical
893
+ };
894
+ if (options.experimentalFlattenDynamicValues && isValidStyleKey(name2, staticConfig))
895
+ return {
896
+ type: "dynamic-style",
897
+ value: value2,
898
+ name: (tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[name2]) || name2
899
+ };
900
+ return inlined.set(name2, !0), shouldPrintDebug && logger.info(" ! inline no match ".concat(name2, " ").concat(value2)), attr3;
901
+ function addBinaryConditional(operator2, staticExpr, cond) {
902
+ if (getStaticConditional(cond)) {
903
+ var alt2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.alternate)), cons2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.consequent));
904
+ return shouldPrintDebug && logger.info([
905
+ " binaryConditional",
906
+ cond.test,
907
+ cons2,
908
+ alt2
909
+ ].join(" ")), {
910
+ type: "ternary",
911
+ value: {
912
+ test: cond.test,
913
+ remove,
914
+ alternate: _define_property({}, name2, alt2),
915
+ consequent: _define_property({}, name2, cons2)
916
+ }
917
+ };
918
+ }
919
+ return null;
920
+ }
921
+ function getStaticConditional(value3) {
922
+ if (t.isConditionalExpression(value3))
923
+ try {
924
+ var aVal = attemptEval(value3.alternate), cVal = attemptEval(value3.consequent);
925
+ if (shouldPrintDebug) {
926
+ var type = value3.test.type;
927
+ logger.info([
928
+ " static ternary",
929
+ type,
930
+ cVal,
931
+ aVal
932
+ ].join(" "));
933
+ }
934
+ return {
935
+ test: value3.test,
936
+ remove,
937
+ consequent: _define_property({}, name2, cVal),
938
+ alternate: _define_property({}, name2, aVal)
939
+ };
940
+ } catch (err) {
941
+ shouldPrintDebug && logger.info([
942
+ " cant eval ternary",
943
+ err.message
944
+ ].join(" "));
945
+ }
946
+ return null;
947
+ }
948
+ function getStaticLogical(value3) {
949
+ if (t.isLogicalExpression(value3) && value3.operator === "&&")
950
+ try {
951
+ var val2 = attemptEval(value3.right);
952
+ return shouldPrintDebug && logger.info([
953
+ " staticLogical",
954
+ value3.left,
955
+ name2,
956
+ val2
957
+ ].join(" ")), {
958
+ test: value3.left,
959
+ remove,
960
+ consequent: _define_property({}, name2, val2),
961
+ alternate: null
962
+ };
963
+ } catch (err) {
964
+ shouldPrintDebug && logger.info([
965
+ " cant static eval logical",
966
+ err
967
+ ].join(" "));
968
+ }
969
+ return null;
970
+ }
971
+ }
972
+ ), isStaticObject = function(obj) {
973
+ return t.isObjectExpression(obj) && obj.properties.every(function(prop) {
974
+ if (!t.isObjectProperty(prop))
975
+ return logger.info([
976
+ "not object prop",
977
+ prop
978
+ ].join(" ")), !1;
979
+ var propName = prop.key.name;
980
+ return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([
981
+ " not a valid style prop!",
982
+ propName
983
+ ].join(" ")), !1) : !0;
984
+ });
985
+ }, mergeToEnd = function(obj, key9, val2) {
986
+ key9 in obj && delete obj[key9], obj[key9] = val2;
987
+ }, normalizeStyleWithoutVariants = (
988
+ // preserves order
989
+ function(style) {
990
+ var res2 = {};
991
+ for (var key9 in style)
992
+ if (staticConfig.variants && key9 in staticConfig.variants)
993
+ mergeToEnd(res2, key9, style[key9]);
994
+ else {
995
+ var expanded2 = normalizeStyle(_define_property({}, key9, style[key9]), !0);
996
+ for (var key12 in expanded2)
997
+ mergeToEnd(res2, key12, expanded2[key12]);
998
+ }
999
+ return res2;
1000
+ }
1001
+ ), mergeStyles = function(prev2, next) {
1002
+ for (var key9 in next)
1003
+ pseudoDescriptors[key9] ? (prev2[key9] = prev2[key9] || {}, Object.assign(prev2[key9], next[key9])) : mergeToEnd(prev2, key9, next[key9]);
1004
+ }, staticConfig = component.staticConfig, defaultProps = _object_spread({}, staticConfig.defaultProps || {}), variants = staticConfig.variants || {}, isTextView = staticConfig.isText || !1, _staticConfig_validStyles, validStyles = (_staticConfig_validStyles = staticConfig == null ? void 0 : staticConfig.validStyles) !== null && _staticConfig_validStyles !== void 0 ? _staticConfig_validStyles : {}, _defaultProps_tag, tagName = (_defaultProps_tag = defaultProps.tag) !== null && _defaultProps_tag !== void 0 ? _defaultProps_tag : isTextView ? "span" : "div";
1005
+ traversePath.get("openingElement").get("attributes").forEach(function(path) {
1006
+ var attr3 = path.node;
1007
+ if (!t.isJSXSpreadAttribute(attr3) && attr3.name.name === "tag") {
1008
+ var val2 = attr3.value;
1009
+ t.isStringLiteral(val2) && (tagName = val2.value);
1010
+ }
1011
+ }), shouldPrintDebug === "verbose" && console.info(" Start tag ".concat(tagName));
1012
+ var flatNode = getFlattenedNode == null ? void 0 : getFlattenedNode({
1013
+ isTextView,
1014
+ tag: tagName
1015
+ }), inlineProps = new Set([
708
1016
  // adding some always inline props
709
- "dataSet",
710
- ...restProps.inlineProps || [],
711
- ...staticConfig.inlineProps || []
712
- ]), deoptProps = /* @__PURE__ */ new Set([
1017
+ "dataSet"
1018
+ ].concat(_to_consumable_array(restProps.inlineProps || []), _to_consumable_array(staticConfig.inlineProps || []))), deoptProps = new Set([
713
1019
  // always de-opt animation these
714
1020
  "animation",
715
- "disableOptimization",
716
- ...isTargetingHTML ? [] : ["pressStyle", "focusStyle"],
1021
+ "disableOptimization"
1022
+ ].concat(
1023
+ _to_consumable_array(isTargetingHTML ? [] : [
1024
+ "pressStyle",
1025
+ "focusStyle"
1026
+ ]),
717
1027
  // when using a non-CSS driver, de-opt on enterStyle/exitStyle
718
- ...tamaguiConfig != null && tamaguiConfig.animations.isReactNative ? ["enterStyle", "exitStyle"] : []
719
- ]), inlineWhenUnflattened = /* @__PURE__ */ new Set([
720
- ...staticConfig.inlineWhenUnflattened || []
721
- ]), staticNamespace = getStaticBindingsForScope(
722
- traversePath.scope,
723
- importsWhitelist,
724
- sourcePath,
725
- bindingCache,
726
- shouldPrintDebug
727
- ), attemptEval = evaluateVars ? createEvaluator({
1028
+ _to_consumable_array(tamaguiConfig != null && tamaguiConfig.animations.isReactNative ? [
1029
+ "enterStyle",
1030
+ "exitStyle"
1031
+ ] : [])
1032
+ )), inlineWhenUnflattened = new Set(_to_consumable_array(staticConfig.inlineWhenUnflattened || [])), staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug), attemptEval = evaluateVars ? createEvaluator({
728
1033
  props: propsWithFileInfo,
729
1034
  staticNamespace,
730
1035
  sourcePath,
731
1036
  traversePath,
732
1037
  shouldPrintDebug
733
1038
  }) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
734
- if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse)
1039
+ if (shouldPrintDebug && logger.info(" staticNamespace ".concat(Object.keys(staticNamespace).join(", "))), couldntParse)
735
1040
  return;
736
1041
  tm.mark("jsx-element-flattened", !!shouldPrintDebug);
737
- let attrs = [], shouldDeopt = !1;
738
- const inlined = /* @__PURE__ */ new Map(), variantValues = /* @__PURE__ */ new Map();
739
- let hasSetOptimized = !1;
740
- const inlineWhenUnflattenedOGVals = {}, propMapperStyleState = {
1042
+ var attrs = [], shouldDeopt = !1, inlined = /* @__PURE__ */ new Map(), variantValues = /* @__PURE__ */ new Map(), hasSetOptimized = !1, inlineWhenUnflattenedOGVals = {}, propMapperStyleState = {
741
1043
  staticConfig,
742
1044
  usedKeys: {},
743
1045
  classNames: {},
@@ -748,421 +1050,432 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
748
1050
  curProps: defaultProps,
749
1051
  props: defaultProps,
750
1052
  componentState,
751
- styleProps: {
752
- ...styleProps,
1053
+ styleProps: _object_spread_props(_object_spread({}, styleProps), {
753
1054
  resolveValues: "auto"
754
- },
1055
+ }),
755
1056
  debug: shouldPrintDebug
756
1057
  };
757
- if (attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
758
- var _a3;
1058
+ if (attrs = traversePath.get("openingElement").get("attributes").flatMap(function(path) {
759
1059
  try {
760
- const res2 = evaluateAttribute2(path);
1060
+ var res2 = evaluateAttribute(path);
761
1061
  return tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug), res2 || path.remove(), res2;
762
1062
  } catch (err) {
763
- return shouldPrintDebug && (logger.info(
764
- [
765
- "Recoverable error extracting attribute",
766
- err.message,
767
- shouldPrintDebug === "verbose" ? err.stack : ""
768
- ].join(" ")
769
- ), shouldPrintDebug === "verbose" && logger.info(`node ${(_a3 = path.node) == null ? void 0 : _a3.type}`)), inlined.set(`${Math.random()}`, "spread"), {
1063
+ if (shouldPrintDebug && (logger.info([
1064
+ "Recoverable error extracting attribute",
1065
+ err.message,
1066
+ shouldPrintDebug === "verbose" ? err.stack : ""
1067
+ ].join(" ")), shouldPrintDebug === "verbose")) {
1068
+ var _path_node;
1069
+ logger.info("node ".concat((_path_node = path.node) === null || _path_node === void 0 ? void 0 : _path_node.type));
1070
+ }
1071
+ return inlined.set("".concat(Math.random()), "spread"), {
770
1072
  type: "attr",
771
1073
  value: path.node
772
1074
  };
773
1075
  }
774
- }).flat(4).filter(isPresent), shouldPrintDebug && logger.info(
775
- [` - attrs (before):
776
- `, logLines(attrs.map(attrStr).join(", "))].join(" ")
777
- ), couldntParse || shouldDeopt) {
778
- shouldPrintDebug && logger.info(
779
- [" avoid optimizing:", { couldntParse, shouldDeopt }].join(" ")
780
- ), node.attributes = ogAttributes;
1076
+ }).flat(4).filter(isPresent), shouldPrintDebug && logger.info([
1077
+ ` - attrs (before):
1078
+ `,
1079
+ logLines(attrs.map(attrStr).join(", "))
1080
+ ].join(" ")), couldntParse || shouldDeopt) {
1081
+ shouldPrintDebug && logger.info([
1082
+ " avoid optimizing:",
1083
+ {
1084
+ couldntParse,
1085
+ shouldDeopt
1086
+ }
1087
+ ].join(" ")), node.attributes = ogAttributes;
781
1088
  return;
782
1089
  }
783
- const parentFn = findTopmostFunction(traversePath);
1090
+ var parentFn = findTopmostFunction(traversePath);
784
1091
  parentFn && modifiedComponents.add(parentFn);
785
- const hasSpread = attrs.some(
786
- (x) => x.type === "attr" && t.isJSXSpreadAttribute(x.value)
787
- ), hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
788
- let themeVal = inlined.get("theme");
1092
+ var hasSpread = attrs.some(function(x) {
1093
+ return x.type === "attr" && t.isJSXSpreadAttribute(x.value);
1094
+ }), hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every(function(x) {
1095
+ return x.type === "JSXText";
1096
+ })), themeVal = inlined.get("theme");
789
1097
  platform2 !== "native" && inlined.delete("theme");
790
- for (const [key] of [...inlined]) {
791
- const isStaticObjectVariant = ((_a2 = staticConfig.variants) == null ? void 0 : _a2[key]) && variantValues.has(key);
792
- (INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
1098
+ var _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
1099
+ try {
1100
+ for (var _iterator2 = _to_consumable_array(inlined)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
1101
+ var _step_value = _sliced_to_array(_step2.value, 1), key = _step_value[0], _staticConfig_variants, isStaticObjectVariant = ((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0 ? void 0 : _staticConfig_variants[key]) && variantValues.has(key);
1102
+ (INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
1103
+ }
1104
+ } catch (err) {
1105
+ _didIteratorError2 = !0, _iteratorError2 = err;
1106
+ } finally {
1107
+ try {
1108
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
1109
+ } finally {
1110
+ if (_didIteratorError2)
1111
+ throw _iteratorError2;
1112
+ }
793
1113
  }
794
- const canFlattenProps = inlined.size === 0;
795
- let shouldFlatten = !!(flatNode && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren));
796
- const usedThemeKeys = /* @__PURE__ */ new Set();
797
- if (themeAccessListeners.add((key) => {
798
- options.experimentalFlattenThemesOnNative && usedThemeKeys.add(key), disableExtractVariables && (usedThemeKeys.add(key), shouldFlatten = !1, shouldPrintDebug === "verbose" && logger.info([" ! accessing theme key, avoid flatten", key].join(" ")));
1114
+ var canFlattenProps = inlined.size === 0, shouldFlatten = !!(flatNode && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren)), usedThemeKeys = /* @__PURE__ */ new Set();
1115
+ if (themeAccessListeners.add(function(key9) {
1116
+ options.experimentalFlattenThemesOnNative && usedThemeKeys.add(key9), disableExtractVariables && (usedThemeKeys.add(key9), shouldFlatten = !1, shouldPrintDebug === "verbose" && logger.info([
1117
+ " ! accessing theme key, avoid flatten",
1118
+ key9
1119
+ ].join(" ")));
799
1120
  }), shouldFlatten) {
800
- let skipMap = !1;
801
- const defaultStyleAttrs = Object.keys(defaultProps).flatMap((key) => {
1121
+ var skipMap = !1, defaultStyleAttrs = Object.keys(defaultProps).flatMap(function(key9) {
802
1122
  if (skipMap)
803
1123
  return [];
804
- const value = defaultProps[key];
805
- if (key === "theme" && !themeVal)
806
- return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", { value: t.stringLiteral(value) })), themeVal = { value: t.stringLiteral(value) }, [];
807
- if (!isValidStyleKey(key, staticConfig))
1124
+ var value2 = defaultProps[key9];
1125
+ if (key9 === "theme" && !themeVal)
1126
+ return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", {
1127
+ value: t.stringLiteral(value2)
1128
+ })), themeVal = {
1129
+ value: t.stringLiteral(value2)
1130
+ }, [];
1131
+ if (!isValidStyleKey(key9, staticConfig))
808
1132
  return [];
809
- const name = (tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[key]) || key;
810
- if (value === void 0) {
811
- logger.warn(
812
- `\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`
813
- ), shouldDeopt = !0;
1133
+ var name2 = (tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[key9]) || key9;
1134
+ if (value2 === void 0) {
1135
+ logger.warn("\u26A0\uFE0F Error evaluating default style for component, prop ".concat(key9, " ").concat(value2)), shouldDeopt = !0;
814
1136
  return;
815
1137
  }
816
- return name[0] === "$" && mediaQueryConfig[name.slice(1)] ? (defaultProps[key] = void 0, evaluateAttribute2({
817
- node: t.jsxAttribute(
818
- t.jsxIdentifier(name),
819
- t.jsxExpressionContainer(
820
- t.objectExpression(
821
- Object.keys(value).filter((k) => typeof value[k] < "u").map((k) => t.objectProperty(
822
- t.identifier(k),
823
- literalToAst(value[k])
824
- ))
825
- )
826
- )
827
- )
828
- })) : {
1138
+ if (name2[0] === "$" && mediaQueryConfig[name2.slice(1)])
1139
+ return defaultProps[key9] = void 0, evaluateAttribute({
1140
+ node: t.jsxAttribute(t.jsxIdentifier(name2), t.jsxExpressionContainer(t.objectExpression(Object.keys(value2).filter(function(k) {
1141
+ return typeof value2[k] < "u";
1142
+ }).map(function(k) {
1143
+ return t.objectProperty(t.identifier(k), literalToAst(value2[k]));
1144
+ }))))
1145
+ });
1146
+ var attr3 = {
829
1147
  type: "style",
830
- name,
831
- value: { [name]: value }
1148
+ name: name2,
1149
+ value: _define_property({}, name2, value2)
832
1150
  };
1151
+ return attr3;
833
1152
  });
834
- skipMap || defaultStyleAttrs.length && (attrs = [...defaultStyleAttrs, ...attrs]);
1153
+ skipMap || defaultStyleAttrs.length && (attrs = _to_consumable_array(defaultStyleAttrs).concat(_to_consumable_array(attrs)));
835
1154
  }
836
- let ternaries = [];
837
- attrs = attrs.reduce((out, cur) => {
838
- const next = attrs[attrs.indexOf(cur) + 1];
839
- if (cur.type === "ternary" && ternaries.push(cur.value), (!next || next.type !== "ternary") && ternaries.length) {
840
- const normalized = normalizeTernaries(ternaries).map(
841
- ({ alternate, consequent, ...rest }) => ({
1155
+ var ternaries = [];
1156
+ attrs = attrs.reduce(function(out, cur2) {
1157
+ var next = attrs[attrs.indexOf(cur2) + 1];
1158
+ if (cur2.type === "ternary" && ternaries.push(cur2.value), (!next || next.type !== "ternary") && ternaries.length) {
1159
+ var normalized = normalizeTernaries(ternaries).map(function(_param) {
1160
+ var alternate = _param.alternate, consequent = _param.consequent, rest = _object_without_properties(_param, [
1161
+ "alternate",
1162
+ "consequent"
1163
+ ]);
1164
+ return {
842
1165
  type: "ternary",
843
- value: {
844
- ...rest,
1166
+ value: _object_spread_props(_object_spread({}, rest), {
845
1167
  alternate: alternate || null,
846
1168
  consequent: consequent || null
847
- }
848
- })
849
- );
1169
+ })
1170
+ };
1171
+ });
850
1172
  try {
851
- return [...out, ...normalized];
1173
+ return _to_consumable_array(out).concat(_to_consumable_array(normalized));
852
1174
  } finally {
853
- shouldPrintDebug && logger.info(
854
- ` normalizeTernaries (${ternaries.length} => ${normalized.length})`
855
- ), ternaries = [];
1175
+ shouldPrintDebug && logger.info(" normalizeTernaries (".concat(ternaries.length, " => ").concat(normalized.length, ")")), ternaries = [];
856
1176
  }
857
1177
  }
858
- return cur.type === "ternary" || out.push(cur), out;
1178
+ return cur2.type === "ternary" || out.push(cur2), out;
859
1179
  }, []).flat();
860
- const shouldWrapTheme = shouldFlatten && themeVal;
861
- if (shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([" - wrapping theme", themeVal].join(" ")), attrs = attrs.filter(
862
- (x) => !(x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme")
863
- ), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(
864
- t.importDeclaration(
865
- [
866
- t.importSpecifier(
867
- t.identifier("_TamaguiTheme"),
868
- t.identifier("Theme")
869
- )
870
- ],
871
- t.stringLiteral("@tamagui/web")
872
- )
873
- )), traversePath.replaceWith(
874
- t.jsxElement(
875
- t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
876
- t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
877
- ]),
878
- t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")),
879
- [traversePath.node]
880
- )
881
- )) : console.warn(
882
- `No program path found, avoiding importing flattening / importing theme in ${sourcePath}`
883
- )), shouldPrintDebug)
1180
+ var shouldWrapTheme = shouldFlatten && themeVal;
1181
+ if (shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([
1182
+ " - wrapping theme",
1183
+ themeVal
1184
+ ].join(" ")), attrs = attrs.filter(function(x) {
1185
+ return !(x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme");
1186
+ }), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(t.importDeclaration([
1187
+ t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))
1188
+ ], t.stringLiteral("@tamagui/web")))), traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
1189
+ t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
1190
+ ]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [
1191
+ traversePath.node
1192
+ ]))) : console.warn("No program path found, avoiding importing flattening / importing theme in ".concat(sourcePath))), shouldPrintDebug)
884
1193
  try {
885
- logger.info(
886
- [
887
- " flatten?",
888
- shouldFlatten,
889
- objToStr({
890
- hasSpread,
891
- shouldDeopt,
892
- canFlattenProps,
893
- shouldWrapTheme,
894
- hasOnlyStringChildren
895
- }),
896
- "inlined",
897
- inlined.size,
898
- [...inlined]
899
- ].join(" ")
900
- );
1194
+ logger.info([
1195
+ " flatten?",
1196
+ shouldFlatten,
1197
+ objToStr({
1198
+ hasSpread,
1199
+ shouldDeopt,
1200
+ canFlattenProps,
1201
+ shouldWrapTheme,
1202
+ hasOnlyStringChildren
1203
+ }),
1204
+ "inlined",
1205
+ inlined.size,
1206
+ _to_consumable_array(inlined)
1207
+ ].join(" "));
901
1208
  } catch {
902
1209
  }
903
1210
  if (shouldDeopt || !shouldFlatten) {
904
- shouldPrintDebug && logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`), node.attributes = ogAttributes;
1211
+ shouldPrintDebug && logger.info("Deopting ".concat(shouldDeopt, " ").concat(shouldFlatten)), node.attributes = ogAttributes;
905
1212
  return;
906
1213
  }
907
- shouldPrintDebug && logger.info(
908
- [` - attrs (flattened):
909
- `, logLines(attrs.map(attrStr).join(", "))].join(
910
- " "
911
- )
912
- );
913
- let foundStaticProps = {};
914
- for (const key in attrs) {
915
- const cur = attrs[key];
1214
+ shouldPrintDebug && logger.info([
1215
+ ` - attrs (flattened):
1216
+ `,
1217
+ logLines(attrs.map(attrStr).join(", "))
1218
+ ].join(" "));
1219
+ var foundStaticProps = {};
1220
+ for (var key1 in attrs) {
1221
+ var cur = attrs[key1];
916
1222
  if (cur.type === "style") {
917
- const expanded = normalizeStyleWithoutVariants2(cur.value);
918
- for (const key2 in expanded)
919
- mergeToEnd2(foundStaticProps, key2, expanded[key2]);
1223
+ var expanded = normalizeStyleWithoutVariants(cur.value);
1224
+ for (var key2 in expanded)
1225
+ mergeToEnd(foundStaticProps, key2, expanded[key2]);
920
1226
  continue;
921
1227
  }
922
1228
  if (cur.type === "attr") {
923
1229
  if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name))
924
1230
  continue;
925
- const key2 = cur.value.name.name, value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
926
- value !== FAILED_EVAL && mergeToEnd2(foundStaticProps, key2, value);
1231
+ var key3 = cur.value.name.name, value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
1232
+ value !== FAILED_EVAL && mergeToEnd(foundStaticProps, key3, value);
927
1233
  }
928
1234
  }
929
- const completeProps = {};
930
- for (const key in defaultProps)
931
- key in foundStaticProps || (completeProps[key] = defaultProps[key]);
932
- for (const key in foundStaticProps)
933
- completeProps[key] = foundStaticProps[key];
934
- attrs = attrs.reduce((acc, cur) => {
935
- if (!cur)
1235
+ var completeProps = {};
1236
+ for (var key4 in defaultProps)
1237
+ key4 in foundStaticProps || (completeProps[key4] = defaultProps[key4]);
1238
+ for (var key5 in foundStaticProps)
1239
+ completeProps[key5] = foundStaticProps[key5];
1240
+ attrs = attrs.reduce(function(acc, cur2) {
1241
+ if (!cur2)
936
1242
  return acc;
937
- if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value) && shouldFlatten) {
938
- const name = cur.value.name.name;
939
- if (typeof name == "string") {
940
- if (name === "tag")
1243
+ if (cur2.type === "attr" && !t.isJSXSpreadAttribute(cur2.value) && shouldFlatten) {
1244
+ var name2 = cur2.value.name.name;
1245
+ if (typeof name2 == "string") {
1246
+ if (name2 === "tag")
941
1247
  return acc;
942
- if (variants[name] && variantValues.has(name)) {
943
- const styleState = {
944
- ...propMapperStyleState,
1248
+ if (variants[name2] && variantValues.has(name2)) {
1249
+ var styleState = _object_spread_props(_object_spread({}, propMapperStyleState), {
945
1250
  props: completeProps,
946
1251
  curProps: completeProps
947
- };
948
- let out = Object.fromEntries(
949
- propMapper(name, variantValues.get(name), styleState) || []
950
- );
1252
+ }), out = Object.fromEntries(propMapper(name2, variantValues.get(name2), styleState) || []);
951
1253
  if (out && isTargetingHTML) {
952
- const cn = out.className;
1254
+ var cn = out.className;
953
1255
  out = createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
954
1256
  }
955
- shouldPrintDebug && logger.info([" - expanded variant", name, out].join(" "));
956
- for (const key2 in out) {
957
- const value2 = out[key2];
958
- isValidStyleKey(key2, staticConfig) ? acc.push({
1257
+ shouldPrintDebug && logger.info([
1258
+ " - expanded variant",
1259
+ name2,
1260
+ out
1261
+ ].join(" "));
1262
+ for (var key9 in out) {
1263
+ var value2 = out[key9];
1264
+ isValidStyleKey(key9, staticConfig) ? acc.push({
959
1265
  type: "style",
960
- value: { [key2]: value2 },
961
- name: key2,
962
- attr: cur.value
1266
+ value: _define_property({}, key9, value2),
1267
+ name: key9,
1268
+ attr: cur2.value
963
1269
  }) : acc.push({
964
1270
  type: "attr",
965
- value: t.jsxAttribute(
966
- t.jsxIdentifier(key2),
967
- t.jsxExpressionContainer(
968
- typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)
969
- )
970
- )
1271
+ value: t.jsxAttribute(t.jsxIdentifier(key9), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)))
971
1272
  });
972
1273
  }
973
1274
  }
974
1275
  }
975
1276
  }
976
- if (cur.type !== "style")
977
- return acc.push(cur), acc;
978
- let key = Object.keys(cur.value)[0];
979
- const value = cur.value[key], fullKey = tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[key];
980
- return fullKey && (cur.value = { [fullKey]: value }, key = fullKey), disableExtractVariables && value[0] === "$" && (usedThemeKeys.has(key) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([` keeping variable inline: ${key} =`, value].join(" ")), acc.push({
1277
+ if (cur2.type !== "style")
1278
+ return acc.push(cur2), acc;
1279
+ var key12 = Object.keys(cur2.value)[0], value12 = cur2.value[key12], fullKey = tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[key12];
1280
+ return fullKey && (cur2.value = _define_property({}, fullKey, value12), key12 = fullKey), disableExtractVariables && value12[0] === "$" && (usedThemeKeys.has(key12) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([
1281
+ " keeping variable inline: ".concat(key12, " ="),
1282
+ value12
1283
+ ].join(" ")), acc.push({
981
1284
  type: "attr",
982
- value: t.jsxAttribute(
983
- t.jsxIdentifier(key),
984
- t.jsxExpressionContainer(t.stringLiteral(value))
985
- )
986
- }), acc) : (acc.push(cur), acc);
987
- }, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info(
988
- [` - attrs (expanded):
989
- `, logLines(attrs.map(attrStr).join(", "))].join(
990
- " "
991
- )
992
- );
993
- let prev = null;
994
- const getProps = (props, includeProps = !1, debugName = "") => {
1285
+ value: t.jsxAttribute(t.jsxIdentifier(key12), t.jsxExpressionContainer(t.stringLiteral(value12)))
1286
+ }), acc) : (acc.push(cur2), acc);
1287
+ }, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info([
1288
+ ` - attrs (expanded):
1289
+ `,
1290
+ logLines(attrs.map(attrStr).join(", "))
1291
+ ].join(" "));
1292
+ var prev = null, getProps = function(props) {
1293
+ var includeProps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, debugName = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
995
1294
  if (!props)
996
- return shouldPrintDebug && logger.info([" getProps() no props"].join(" ")), {};
1295
+ return shouldPrintDebug && logger.info([
1296
+ " getProps() no props"
1297
+ ].join(" ")), {};
997
1298
  if (excludeProps != null && excludeProps.size)
998
- for (const key in props)
999
- excludeProps.has(key) && (shouldPrintDebug && logger.info([" delete excluded", key].join(" ")), delete props[key]);
1299
+ for (var key9 in props)
1300
+ excludeProps.has(key9) && (shouldPrintDebug && logger.info([
1301
+ " delete excluded",
1302
+ key9
1303
+ ].join(" ")), delete props[key9]);
1000
1304
  try {
1001
- const beforeProcessUsedThemeKeys = usedThemeKeys.size, out = getSplitStyles(
1002
- props,
1003
- staticConfig,
1004
- defaultTheme,
1005
- "",
1006
- componentState,
1007
- {
1008
- ...styleProps,
1009
- noClassNames: !0,
1010
- fallbackProps: completeProps
1011
- },
1012
- void 0,
1013
- void 0,
1014
- void 0,
1015
- debugPropValue || shouldPrintDebug
1016
- );
1017
- let outProps = {
1018
- ...includeProps ? out.viewProps : {},
1019
- ...out.style,
1020
- ...out.pseudos
1021
- };
1022
- for (const key in outProps)
1023
- deoptProps.has(key) && (shouldFlatten = !1);
1024
- return options.experimentalFlattenThemesOnNative && beforeProcessUsedThemeKeys < usedThemeKeys.size && Object.entries(props).forEach(([key, value]) => {
1025
- usedThemeKeys.has(value) && (outProps[key] = value);
1026
- }), shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
1027
- getProps (props in): ${logLines(objToStr(props))}`), logger.info(
1028
- `
1029
- getProps (outProps): ${logLines(objToStr(outProps))}`
1030
- )), out.fontFamily && (setPropsToFontFamily(outProps, out.fontFamily), shouldPrintDebug && logger.info(`
1031
- \u{1F4AC} new font fam: ${out.fontFamily}`)), outProps;
1305
+ var beforeProcessUsedThemeKeys = usedThemeKeys.size, out = getSplitStyles(props, staticConfig, defaultTheme, "", componentState, _object_spread_props(_object_spread({}, styleProps), {
1306
+ noClassNames: !0,
1307
+ fallbackProps: completeProps
1308
+ }), void 0, void 0, void 0, debugPropValue || shouldPrintDebug), outProps2 = _object_spread({}, includeProps ? out.viewProps : {}, out.style, out.pseudos);
1309
+ for (var key12 in outProps2)
1310
+ deoptProps.has(key12) && (shouldFlatten = !1);
1311
+ return options.experimentalFlattenThemesOnNative && beforeProcessUsedThemeKeys < usedThemeKeys.size && Object.entries(props).forEach(function(param2) {
1312
+ var _param = _sliced_to_array(param2, 2), key10 = _param[0], value2 = _param[1];
1313
+ usedThemeKeys.has(value2) && (outProps2[key10] = value2);
1314
+ }), shouldPrintDebug && (logger.info("(".concat(debugName, ")")), logger.info(`
1315
+ getProps (props in): `.concat(logLines(objToStr(props)))), logger.info(`
1316
+ getProps (outProps): `.concat(logLines(objToStr(outProps2))))), out.fontFamily && (setPropsToFontFamily(outProps2, out.fontFamily), shouldPrintDebug && logger.info(`
1317
+ \u{1F4AC} new font fam: `.concat(out.fontFamily))), outProps2;
1032
1318
  } catch (err) {
1033
- return logger.info(["error", err.message, err.stack].join(" ")), {};
1319
+ return logger.info([
1320
+ "error",
1321
+ err.message,
1322
+ err.stack
1323
+ ].join(" ")), {};
1034
1324
  }
1035
1325
  };
1036
1326
  shouldFlatten && attrs.unshift({
1037
1327
  type: "style",
1038
1328
  value: defaultProps
1039
- }), attrs = attrs.reduce((acc, cur) => {
1040
- if (cur.type === "style") {
1041
- const key = Object.keys(cur.value)[0], value = cur.value[key];
1042
- if (
1329
+ }), attrs = attrs.reduce(function(acc, cur2) {
1330
+ if (cur2.type === "style") {
1331
+ var key9 = Object.keys(cur2.value)[0], value2 = cur2.value[key9], shouldKeepOriginalAttr = (
1043
1332
  // !isStyleAndAttr[key] &&
1044
1333
  !shouldFlatten && // de-opt if non-style
1045
- !validStyles[key] && !pseudoDescriptors[key] && !(key.startsWith("data-") || key.startsWith("aria-"))
1046
- )
1047
- return shouldPrintDebug && logger.info([" - keeping as non-style", key].join(" ")), prev = cur, acc.push({
1334
+ !validStyles[key9] && !pseudoDescriptors[key9] && !(key9.startsWith("data-") || key9.startsWith("aria-"))
1335
+ );
1336
+ if (shouldKeepOriginalAttr)
1337
+ return shouldPrintDebug && logger.info([
1338
+ " - keeping as non-style",
1339
+ key9
1340
+ ].join(" ")), prev = cur2, acc.push({
1048
1341
  type: "attr",
1049
- value: t.jsxAttribute(
1050
- t.jsxIdentifier(key),
1051
- t.jsxExpressionContainer(
1052
- typeof value == "string" ? t.stringLiteral(value) : literalToAst(value)
1053
- )
1054
- )
1055
- }), acc.push(cur), acc;
1342
+ value: t.jsxAttribute(t.jsxIdentifier(key9), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)))
1343
+ }), acc.push(cur2), acc;
1056
1344
  if ((prev == null ? void 0 : prev.type) === "style")
1057
- return mergeStyles2(prev.value, cur.value), acc;
1345
+ return mergeStyles(prev.value, cur2.value), acc;
1058
1346
  }
1059
- return prev = cur, acc.push(cur), acc;
1060
- }, []), shouldPrintDebug && logger.info(
1061
- [
1062
- ` - attrs (combined \u{1F500}):
1347
+ return prev = cur2, acc.push(cur2), acc;
1348
+ }, []), shouldPrintDebug && logger.info([
1349
+ ` - attrs (combined \u{1F500}):
1063
1350
  `,
1064
- logLines(attrs.map(attrStr).join(", "))
1065
- ].join(" ")
1066
- );
1067
- let getStyleError = null;
1068
- for (const attr of attrs)
1069
- try {
1070
- switch (shouldPrintDebug && console.info(` Processing ${attr.type}:`), attr.type) {
1071
- case "ternary": {
1072
- const a = getProps(attr.value.alternate, !1, "ternary.alternate"), c = getProps(attr.value.consequent, !1, "ternary.consequent");
1073
- a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", attrStr(attr)].join(" "));
1074
- continue;
1075
- }
1076
- case "style": {
1077
- const styles = getProps(attr.value, !1, "style");
1078
- styles && (attr.value = styles), shouldPrintDebug && logger.info(
1079
- [" * styles (in)", logLines(objToStr(attr.value))].join(" ")
1080
- ), shouldPrintDebug && logger.info(
1081
- [" * styles (out)", logLines(objToStr(styles))].join(" ")
1082
- );
1083
- continue;
1084
- }
1085
- case "attr":
1086
- if (shouldFlatten && t.isJSXAttribute(attr.value)) {
1087
- const key = attr.value.name.name;
1088
- if (key === "style" || key === "className" || key === "tag")
1089
- continue;
1090
- const value = attemptEvalSafe(
1091
- attr.value.value || t.booleanLiteral(!0)
1092
- );
1093
- if (value !== FAILED_EVAL) {
1094
- const outProps = getProps({ [key]: value }, !0, `attr.${key}`), outKey = Object.keys(outProps)[0];
1095
- if (outKey) {
1096
- const outVal = outProps[outKey];
1097
- attr.value = t.jsxAttribute(
1098
- t.jsxIdentifier(outKey),
1099
- t.jsxExpressionContainer(
1100
- typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)
1101
- )
1102
- );
1351
+ logLines(attrs.map(attrStr).join(", "))
1352
+ ].join(" "));
1353
+ var getStyleError = null, _iteratorNormalCompletion12 = !0, _didIteratorError12 = !1, _iteratorError12 = void 0;
1354
+ try {
1355
+ for (var _iterator12 = attrs[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = !0) {
1356
+ var attr = _step12.value;
1357
+ try {
1358
+ switch (shouldPrintDebug && console.info(" Processing ".concat(attr.type, ":")), attr.type) {
1359
+ case "ternary": {
1360
+ var a = getProps(attr.value.alternate, !1, "ternary.alternate"), c = getProps(attr.value.consequent, !1, "ternary.consequent");
1361
+ a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([
1362
+ " => tern ",
1363
+ attrStr(attr)
1364
+ ].join(" "));
1365
+ continue;
1366
+ }
1367
+ case "style": {
1368
+ var styles = getProps(attr.value, !1, "style");
1369
+ styles && (attr.value = styles), shouldPrintDebug && logger.info([
1370
+ " * styles (in)",
1371
+ logLines(objToStr(attr.value))
1372
+ ].join(" ")), shouldPrintDebug && logger.info([
1373
+ " * styles (out)",
1374
+ logLines(objToStr(styles))
1375
+ ].join(" "));
1376
+ continue;
1377
+ }
1378
+ case "attr":
1379
+ if (shouldFlatten && t.isJSXAttribute(attr.value)) {
1380
+ var key6 = attr.value.name.name;
1381
+ if (key6 === "style" || key6 === "className" || key6 === "tag")
1382
+ continue;
1383
+ var value1 = attemptEvalSafe(attr.value.value || t.booleanLiteral(!0));
1384
+ if (value1 !== FAILED_EVAL) {
1385
+ var outProps = getProps(_define_property({}, key6, value1), !0, "attr.".concat(key6)), outKey = Object.keys(outProps)[0];
1386
+ if (outKey) {
1387
+ var outVal = outProps[outKey];
1388
+ attr.value = t.jsxAttribute(t.jsxIdentifier(outKey), t.jsxExpressionContainer(typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)));
1389
+ }
1103
1390
  }
1104
1391
  }
1105
- }
1392
+ }
1393
+ } catch (err) {
1394
+ getStyleError = err;
1106
1395
  }
1107
- } catch (err) {
1108
- getStyleError = err;
1109
1396
  }
1110
- if (shouldPrintDebug && logger.info(
1111
- [
1112
- ` - attrs (ternaries/combined):
1397
+ } catch (err) {
1398
+ _didIteratorError12 = !0, _iteratorError12 = err;
1399
+ } finally {
1400
+ try {
1401
+ !_iteratorNormalCompletion12 && _iterator12.return != null && _iterator12.return();
1402
+ } finally {
1403
+ if (_didIteratorError12)
1404
+ throw _iteratorError12;
1405
+ }
1406
+ }
1407
+ if (shouldPrintDebug && logger.info([
1408
+ ` - attrs (ternaries/combined):
1113
1409
  `,
1114
- logLines(attrs.map(attrStr).join(", "))
1115
- ].join(" ")
1116
- ), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError)
1117
- return logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" ")), node.attributes = ogAttributes, null;
1118
- const existingStyleKeys = /* @__PURE__ */ new Set();
1119
- for (let i = attrs.length - 1; i >= 0; i--) {
1120
- const attr = attrs[i];
1121
- if (shouldFlatten && attr.type === "attr" && t.isJSXAttribute(attr.value) && t.isJSXIdentifier(attr.value.name)) {
1122
- const name = attr.value.name.name;
1123
- INLINE_EXTRACTABLE[name] && (attr.value.name.name = INLINE_EXTRACTABLE[name]);
1410
+ logLines(attrs.map(attrStr).join(", "))
1411
+ ].join(" ")), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError)
1412
+ return logger.info([
1413
+ " \u26A0\uFE0F postprocessing error, deopt",
1414
+ getStyleError
1415
+ ].join(" ")), node.attributes = ogAttributes, null;
1416
+ for (var existingStyleKeys = /* @__PURE__ */ new Set(), i = attrs.length - 1; i >= 0; i--) {
1417
+ var attr1 = attrs[i];
1418
+ if (shouldFlatten && attr1.type === "attr" && t.isJSXAttribute(attr1.value) && t.isJSXIdentifier(attr1.value.name)) {
1419
+ var name = attr1.value.name.name;
1420
+ INLINE_EXTRACTABLE[name] && (attr1.value.name.name = INLINE_EXTRACTABLE[name]);
1124
1421
  }
1125
- if (attr.type === "style")
1126
- for (const key in attr.value)
1127
- existingStyleKeys.has(key) ? (shouldPrintDebug && logger.info([` >> delete existing ${key}`].join(" ")), delete attr.value[key]) : existingStyleKeys.add(key);
1128
- attr.type === "dynamic-style" && (existingStyleKeys.has(attr.name) ? attrs[i] = void 0 : existingStyleKeys.add(attr.name));
1422
+ if (attr1.type === "style")
1423
+ for (var key7 in attr1.value)
1424
+ existingStyleKeys.has(key7) ? (shouldPrintDebug && logger.info([
1425
+ " >> delete existing ".concat(key7)
1426
+ ].join(" ")), delete attr1.value[key7]) : existingStyleKeys.add(key7);
1427
+ attr1.type === "dynamic-style" && (existingStyleKeys.has(attr1.name) ? attrs[i] = void 0 : existingStyleKeys.add(attr1.name));
1129
1428
  }
1130
1429
  if (options.experimentalFlattenThemesOnNative && (attrs = attrs.filter(Boolean)), !shouldFlatten && inlineWhenUnflattened.size) {
1131
- for (const [index, attr] of attrs.entries())
1132
- if (attr.type === "style")
1133
- for (const key in attr.value) {
1134
- if (!inlineWhenUnflattened.has(key))
1135
- continue;
1136
- const val = inlineWhenUnflattenedOGVals[key];
1137
- val ? (delete attr.value[key], attrs.splice(index - 1, 0, val.attr)) : delete attr.value[key];
1430
+ var _iteratorNormalCompletion22 = !0, _didIteratorError22 = !1, _iteratorError22 = void 0;
1431
+ try {
1432
+ for (var _iterator22 = attrs.entries()[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = !0) {
1433
+ var _step_value1 = _sliced_to_array(_step22.value, 2), index = _step_value1[0], attr2 = _step_value1[1];
1434
+ if (attr2.type === "style") {
1435
+ for (var key8 in attr2.value)
1436
+ if (inlineWhenUnflattened.has(key8)) {
1437
+ var val = inlineWhenUnflattenedOGVals[key8];
1438
+ val ? (delete attr2.value[key8], attrs.splice(index - 1, 0, val.attr)) : delete attr2.value[key8];
1439
+ }
1138
1440
  }
1441
+ }
1442
+ } catch (err) {
1443
+ _didIteratorError22 = !0, _iteratorError22 = err;
1444
+ } finally {
1445
+ try {
1446
+ !_iteratorNormalCompletion22 && _iterator22.return != null && _iterator22.return();
1447
+ } finally {
1448
+ if (_didIteratorError22)
1449
+ throw _iteratorError22;
1450
+ }
1451
+ }
1139
1452
  }
1140
- if (attrs = attrs.filter((x) => !(x.type === "style" && Object.keys(x.value).length === 0)), shouldFlatten && (shouldPrintDebug && logger.info([" [\u2705] flattening", originalNodeName, flatNode].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode)), !shouldFlatten && platform2 === "native")
1141
- return shouldPrintDebug && logger.info(
1142
- `Disabled flattening except for simple cases on native for now: ${JSON.stringify(
1143
- {
1144
- flatNode,
1145
- shouldDeopt,
1146
- canFlattenProps,
1147
- hasSpread,
1148
- "staticConfig.isStyledHOC": staticConfig.isStyledHOC,
1149
- "!staticConfig.isHOC": !staticConfig.isHOC,
1150
- "staticConfig.isReactNative": staticConfig.isReactNative,
1151
- "staticConfig.neverFlatten": staticConfig.neverFlatten
1152
- },
1153
- null,
1154
- 2
1155
- )}`
1156
- ), node.attributes = ogAttributes, null;
1157
- shouldPrintDebug && (logger.info(
1158
- [
1159
- ` - inlined props (${inlined.size}):`,
1160
- shouldDeopt ? " deopted" : "",
1161
- hasSpread ? " has spread" : "",
1162
- staticConfig.neverFlatten ? "neverFlatten" : ""
1163
- ].join(" ")
1164
- ), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
1165
- ${logLines(attrs.map(attrStr).join(", "))}`)), onExtractTag({
1453
+ attrs = attrs.filter(function(x) {
1454
+ return !(x.type === "style" && Object.keys(x.value).length === 0);
1455
+ }), shouldFlatten && (shouldPrintDebug && logger.info([
1456
+ " [\u2705] flattening",
1457
+ originalNodeName,
1458
+ flatNode
1459
+ ].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode));
1460
+ var isNativeNotFlat = !shouldFlatten && platform2 === "native";
1461
+ if (isNativeNotFlat)
1462
+ return shouldPrintDebug && logger.info("Disabled flattening except for simple cases on native for now: ".concat(JSON.stringify({
1463
+ flatNode,
1464
+ shouldDeopt,
1465
+ canFlattenProps,
1466
+ hasSpread,
1467
+ "staticConfig.isStyledHOC": staticConfig.isStyledHOC,
1468
+ "!staticConfig.isHOC": !staticConfig.isHOC,
1469
+ "staticConfig.isReactNative": staticConfig.isReactNative,
1470
+ "staticConfig.neverFlatten": staticConfig.neverFlatten
1471
+ }, null, 2))), node.attributes = ogAttributes, null;
1472
+ shouldPrintDebug && (logger.info([
1473
+ " - inlined props (".concat(inlined.size, "):"),
1474
+ shouldDeopt ? " deopted" : "",
1475
+ hasSpread ? " has spread" : "",
1476
+ staticConfig.neverFlatten ? "neverFlatten" : ""
1477
+ ].join(" ")), logger.info(" - shouldFlatten/isFlattened: ".concat(shouldFlatten)), logger.info(` - attrs (end):
1478
+ `.concat(logLines(attrs.map(attrStr).join(", "))))), onExtractTag({
1166
1479
  parserProps: propsWithFileInfo,
1167
1480
  attrs,
1168
1481
  node,
@@ -1178,18 +1491,30 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
1178
1491
  staticConfig
1179
1492
  });
1180
1493
  } catch (err) {
1181
- node.attributes = ogAttributes, console.error(
1182
- `@tamagui/static error, reverting optimization. In ${filePath} ${lineNumbers} on ${originalNodeName}: ${err.message}. For stack trace set environment TAMAGUI_DEBUG=1`
1183
- ), process.env.TAMAGUI_DEBUG === "1" && console.error(err.stack);
1494
+ node.attributes = ogAttributes, console.error("@tamagui/static error, reverting optimization. In ".concat(filePath, " ").concat(lineNumbers, " on ").concat(originalNodeName, ": ").concat(err.message, ". For stack trace set environment TAMAGUI_DEBUG=1")), process.env.TAMAGUI_DEBUG === "1" && console.error(err.stack);
1184
1495
  } finally {
1185
1496
  debugPropValue && (shouldPrintDebug = ogDebug);
1186
1497
  }
1187
1498
  }
1188
1499
  }), tm.mark("jsx-done", !!shouldPrintDebug), modifiedComponents.size) {
1189
- const all = Array.from(modifiedComponents);
1190
- shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
1191
- for (const comp of all)
1192
- removeUnusedHooks(comp, shouldPrintDebug);
1500
+ var all = Array.from(modifiedComponents);
1501
+ shouldPrintDebug && logger.info(" [\u{1FA9D}] hook check ".concat(all.length));
1502
+ var _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
1503
+ try {
1504
+ for (var _iterator1 = all[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
1505
+ var comp = _step1.value;
1506
+ removeUnusedHooks(comp, shouldPrintDebug);
1507
+ }
1508
+ } catch (err) {
1509
+ _didIteratorError1 = !0, _iteratorError1 = err;
1510
+ } finally {
1511
+ try {
1512
+ !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
1513
+ } finally {
1514
+ if (_didIteratorError1)
1515
+ throw _iteratorError1;
1516
+ }
1517
+ }
1193
1518
  }
1194
1519
  return tm.done(shouldPrintDebug === "verbose"), res;
1195
1520
  }