@tamagui/static 1.111.7 → 1.111.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/cjs/extractor/loadTamagui.js.map +1 -1
  2. package/dist/cjs/extractor/loadTamagui.native.js.map +2 -2
  3. package/dist/esm/checkDeps.native.js +3 -6
  4. package/dist/esm/checkDeps.native.js.map +1 -6
  5. package/dist/esm/constants.native.js +11 -12
  6. package/dist/esm/constants.native.js.map +1 -6
  7. package/dist/esm/exports.native.js +16 -19
  8. package/dist/esm/exports.native.js.map +1 -6
  9. package/dist/esm/extractor/accessSafe.native.js +9 -16
  10. package/dist/esm/extractor/accessSafe.native.js.map +1 -6
  11. package/dist/esm/extractor/babelParse.native.js +8 -22
  12. package/dist/esm/extractor/babelParse.native.js.map +1 -6
  13. package/dist/esm/extractor/buildClassName.native.js +26 -34
  14. package/dist/esm/extractor/buildClassName.native.js.map +1 -6
  15. package/dist/esm/extractor/bundle.native.js +74 -82
  16. package/dist/esm/extractor/bundle.native.js.map +1 -6
  17. package/dist/esm/extractor/bundleConfig.native.js +110 -123
  18. package/dist/esm/extractor/bundleConfig.native.js.map +1 -6
  19. package/dist/esm/extractor/createEvaluator.native.js +22 -17
  20. package/dist/esm/extractor/createEvaluator.native.js.map +1 -6
  21. package/dist/esm/extractor/createExtractor.native.js +678 -819
  22. package/dist/esm/extractor/createExtractor.native.js.map +1 -6
  23. package/dist/esm/extractor/createLogger.native.js +18 -8
  24. package/dist/esm/extractor/createLogger.native.js.map +1 -6
  25. package/dist/esm/extractor/ensureImportingConcat.native.js +12 -13
  26. package/dist/esm/extractor/ensureImportingConcat.native.js.map +1 -6
  27. package/dist/esm/extractor/esbuildAliasPlugin.native.js +7 -9
  28. package/dist/esm/extractor/esbuildAliasPlugin.native.js.map +1 -6
  29. package/dist/esm/extractor/evaluateAstNode.native.js +23 -43
  30. package/dist/esm/extractor/evaluateAstNode.native.js.map +1 -6
  31. package/dist/esm/extractor/extractHelpers.native.js +73 -96
  32. package/dist/esm/extractor/extractHelpers.native.js.map +1 -6
  33. package/dist/esm/extractor/extractMediaStyle.native.js +75 -61
  34. package/dist/esm/extractor/extractMediaStyle.native.js.map +1 -6
  35. package/dist/esm/extractor/extractToClassNames.native.js +260 -236
  36. package/dist/esm/extractor/extractToClassNames.native.js.map +1 -6
  37. package/dist/esm/extractor/extractToNative.native.js +129 -133
  38. package/dist/esm/extractor/extractToNative.native.js.map +1 -6
  39. package/dist/esm/extractor/findTopmostFunction.native.js +6 -11
  40. package/dist/esm/extractor/findTopmostFunction.native.js.map +1 -6
  41. package/dist/esm/extractor/generateTamaguiStudioConfig.native.js +64 -49
  42. package/dist/esm/extractor/generateTamaguiStudioConfig.native.js.map +1 -6
  43. package/dist/esm/extractor/generatedUid.native.js +5 -8
  44. package/dist/esm/extractor/generatedUid.native.js.map +1 -6
  45. package/dist/esm/extractor/getPrefixLogs.native.js +2 -4
  46. package/dist/esm/extractor/getPrefixLogs.native.js.map +1 -6
  47. package/dist/esm/extractor/getPropValueFromAttributes.native.js +18 -24
  48. package/dist/esm/extractor/getPropValueFromAttributes.native.js.map +1 -6
  49. package/dist/esm/extractor/getSourceModule.native.js +22 -27
  50. package/dist/esm/extractor/getSourceModule.native.js.map +1 -6
  51. package/dist/esm/extractor/getStaticBindingsForScope.native.js +92 -90
  52. package/dist/esm/extractor/getStaticBindingsForScope.native.js.map +1 -6
  53. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js +2 -4
  54. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +1 -6
  55. package/dist/esm/extractor/hoistClassNames.native.js +13 -20
  56. package/dist/esm/extractor/hoistClassNames.native.js.map +1 -6
  57. package/dist/esm/extractor/literalToAst.native.js +23 -44
  58. package/dist/esm/extractor/literalToAst.native.js.map +1 -6
  59. package/dist/esm/extractor/loadFile.native.js +7 -7
  60. package/dist/esm/extractor/loadFile.native.js.map +1 -6
  61. package/dist/esm/extractor/loadTamagui.js.map +1 -1
  62. package/dist/esm/extractor/loadTamagui.mjs.map +1 -1
  63. package/dist/esm/extractor/loadTamagui.native.js +115 -107
  64. package/dist/esm/extractor/loadTamagui.native.js.map +1 -6
  65. package/dist/esm/extractor/logLines.native.js +26 -27
  66. package/dist/esm/extractor/logLines.native.js.map +1 -6
  67. package/dist/esm/extractor/normalizeTernaries.native.js +17 -10
  68. package/dist/esm/extractor/normalizeTernaries.native.js.map +1 -6
  69. package/dist/esm/extractor/propsToFontFamilyCache.native.js +4 -9
  70. package/dist/esm/extractor/propsToFontFamilyCache.native.js.map +1 -6
  71. package/dist/esm/extractor/removeUnusedHooks.native.js +56 -56
  72. package/dist/esm/extractor/removeUnusedHooks.native.js.map +1 -6
  73. package/dist/esm/extractor/timer.native.js +7 -8
  74. package/dist/esm/extractor/timer.native.js.map +1 -6
  75. package/dist/esm/extractor/validHTMLAttributes.native.js +2 -4
  76. package/dist/esm/extractor/validHTMLAttributes.native.js.map +1 -6
  77. package/dist/esm/extractor/watchTamaguiConfig.native.js +19 -22
  78. package/dist/esm/extractor/watchTamaguiConfig.native.js.map +1 -6
  79. package/dist/esm/getPragmaOptions.native.js +18 -8
  80. package/dist/esm/getPragmaOptions.native.js.map +1 -6
  81. package/dist/esm/helpers/memoize.native.js +8 -12
  82. package/dist/esm/helpers/memoize.native.js.map +1 -6
  83. package/dist/esm/helpers/requireTamaguiCore.native.js +8 -8
  84. package/dist/esm/helpers/requireTamaguiCore.native.js.map +1 -6
  85. package/dist/esm/index.native.js +4 -6
  86. package/dist/esm/index.native.js.map +1 -6
  87. package/dist/esm/minifyCSS.native.js +6 -5
  88. package/dist/esm/minifyCSS.native.js.map +1 -6
  89. package/dist/esm/registerRequire.native.js +56 -62
  90. package/dist/esm/registerRequire.native.js.map +1 -6
  91. package/dist/esm/server.native.js +19 -16
  92. package/dist/esm/server.native.js.map +1 -6
  93. package/dist/esm/setup.native.js +2 -1
  94. package/dist/esm/setup.native.js.map +1 -6
  95. package/dist/esm/types.native.js +2 -1
  96. package/dist/esm/types.native.js.map +1 -6
  97. package/package.json +15 -15
  98. package/src/extractor/loadTamagui.ts +2 -0
  99. package/types/extractor/loadTamagui.d.ts.map +1 -1
  100. package/dist/esm/checkDeps.native.mjs +0 -10
  101. package/dist/esm/checkDeps.native.mjs.map +0 -1
  102. package/dist/esm/constants.native.mjs +0 -12
  103. package/dist/esm/constants.native.mjs.map +0 -1
  104. package/dist/esm/exports.native.mjs +0 -16
  105. package/dist/esm/exports.native.mjs.map +0 -1
  106. package/dist/esm/extractor/accessSafe.native.mjs +0 -12
  107. package/dist/esm/extractor/accessSafe.native.mjs.map +0 -1
  108. package/dist/esm/extractor/babelParse.native.mjs +0 -19
  109. package/dist/esm/extractor/babelParse.native.mjs.map +0 -1
  110. package/dist/esm/extractor/buildClassName.native.mjs +0 -30
  111. package/dist/esm/extractor/buildClassName.native.mjs.map +0 -1
  112. package/dist/esm/extractor/bundle.native.mjs +0 -132
  113. package/dist/esm/extractor/bundle.native.mjs.map +0 -1
  114. package/dist/esm/extractor/bundleConfig.native.mjs +0 -322
  115. package/dist/esm/extractor/bundleConfig.native.mjs.map +0 -1
  116. package/dist/esm/extractor/createEvaluator.native.mjs +0 -38
  117. package/dist/esm/extractor/createEvaluator.native.mjs.map +0 -1
  118. package/dist/esm/extractor/createExtractor.native.mjs +0 -1140
  119. package/dist/esm/extractor/createExtractor.native.mjs.map +0 -1
  120. package/dist/esm/extractor/createLogger.native.mjs +0 -25
  121. package/dist/esm/extractor/createLogger.native.mjs.map +0 -1
  122. package/dist/esm/extractor/ensureImportingConcat.native.mjs +0 -20
  123. package/dist/esm/extractor/ensureImportingConcat.native.mjs.map +0 -1
  124. package/dist/esm/extractor/esbuildAliasPlugin.native.mjs +0 -29
  125. package/dist/esm/extractor/esbuildAliasPlugin.native.mjs.map +0 -1
  126. package/dist/esm/extractor/evaluateAstNode.native.mjs +0 -49
  127. package/dist/esm/extractor/evaluateAstNode.native.mjs.map +0 -1
  128. package/dist/esm/extractor/extractHelpers.native.mjs +0 -122
  129. package/dist/esm/extractor/extractHelpers.native.mjs.map +0 -1
  130. package/dist/esm/extractor/extractMediaStyle.native.mjs +0 -125
  131. package/dist/esm/extractor/extractMediaStyle.native.mjs.map +0 -1
  132. package/dist/esm/extractor/extractToClassNames.native.mjs +0 -315
  133. package/dist/esm/extractor/extractToClassNames.native.mjs.map +0 -1
  134. package/dist/esm/extractor/extractToNative.native.mjs +0 -268
  135. package/dist/esm/extractor/extractToNative.native.mjs.map +0 -1
  136. package/dist/esm/extractor/findTopmostFunction.native.mjs +0 -11
  137. package/dist/esm/extractor/findTopmostFunction.native.mjs.map +0 -1
  138. package/dist/esm/extractor/generateTamaguiStudioConfig.native.mjs +0 -139
  139. package/dist/esm/extractor/generateTamaguiStudioConfig.native.mjs.map +0 -1
  140. package/dist/esm/extractor/generatedUid.native.mjs +0 -13
  141. package/dist/esm/extractor/generatedUid.native.mjs.map +0 -1
  142. package/dist/esm/extractor/getPrefixLogs.native.mjs +0 -6
  143. package/dist/esm/extractor/getPrefixLogs.native.mjs.map +0 -1
  144. package/dist/esm/extractor/getPropValueFromAttributes.native.mjs +0 -35
  145. package/dist/esm/extractor/getPropValueFromAttributes.native.mjs.map +0 -1
  146. package/dist/esm/extractor/getSourceModule.native.mjs +0 -50
  147. package/dist/esm/extractor/getSourceModule.native.mjs.map +0 -1
  148. package/dist/esm/extractor/getStaticBindingsForScope.native.mjs +0 -159
  149. package/dist/esm/extractor/getStaticBindingsForScope.native.mjs.map +0 -1
  150. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.mjs +0 -6
  151. package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.mjs.map +0 -1
  152. package/dist/esm/extractor/hoistClassNames.native.mjs +0 -30
  153. package/dist/esm/extractor/hoistClassNames.native.mjs.map +0 -1
  154. package/dist/esm/extractor/literalToAst.native.mjs +0 -55
  155. package/dist/esm/extractor/literalToAst.native.mjs.map +0 -1
  156. package/dist/esm/extractor/loadFile.native.mjs +0 -20
  157. package/dist/esm/extractor/loadFile.native.mjs.map +0 -1
  158. package/dist/esm/extractor/loadTamagui.native.mjs +0 -284
  159. package/dist/esm/extractor/loadTamagui.native.mjs.map +0 -1
  160. package/dist/esm/extractor/logLines.native.mjs +0 -31
  161. package/dist/esm/extractor/logLines.native.mjs.map +0 -1
  162. package/dist/esm/extractor/normalizeTernaries.native.mjs +0 -38
  163. package/dist/esm/extractor/normalizeTernaries.native.mjs.map +0 -1
  164. package/dist/esm/extractor/propsToFontFamilyCache.native.mjs +0 -13
  165. package/dist/esm/extractor/propsToFontFamilyCache.native.mjs.map +0 -1
  166. package/dist/esm/extractor/removeUnusedHooks.native.mjs +0 -83
  167. package/dist/esm/extractor/removeUnusedHooks.native.mjs.map +0 -1
  168. package/dist/esm/extractor/timer.native.mjs +0 -22
  169. package/dist/esm/extractor/timer.native.mjs.map +0 -1
  170. package/dist/esm/extractor/validHTMLAttributes.native.mjs +0 -50
  171. package/dist/esm/extractor/validHTMLAttributes.native.mjs.map +0 -1
  172. package/dist/esm/extractor/watchTamaguiConfig.native.mjs +0 -33
  173. package/dist/esm/extractor/watchTamaguiConfig.native.mjs.map +0 -1
  174. package/dist/esm/getPragmaOptions.native.mjs +0 -51
  175. package/dist/esm/getPragmaOptions.native.mjs.map +0 -1
  176. package/dist/esm/helpers/memoize.native.mjs +0 -15
  177. package/dist/esm/helpers/memoize.native.mjs.map +0 -1
  178. package/dist/esm/helpers/requireTamaguiCore.native.mjs +0 -13
  179. package/dist/esm/helpers/requireTamaguiCore.native.mjs.map +0 -1
  180. package/dist/esm/index.native.mjs +0 -5
  181. package/dist/esm/index.native.mjs.map +0 -1
  182. package/dist/esm/minifyCSS.native.mjs +0 -16
  183. package/dist/esm/minifyCSS.native.mjs.map +0 -1
  184. package/dist/esm/registerRequire.native.mjs +0 -86
  185. package/dist/esm/registerRequire.native.mjs.map +0 -1
  186. package/dist/esm/server.native.mjs +0 -44
  187. package/dist/esm/server.native.mjs.map +0 -1
  188. package/dist/esm/setup.native.mjs +0 -2
  189. package/dist/esm/setup.native.mjs.map +0 -1
  190. package/dist/esm/types.native.mjs +0 -2
  191. package/dist/esm/types.native.mjs.map +0 -1
@@ -4,60 +4,69 @@ import { Color, colorLog } from "@tamagui/cli-color";
4
4
  import { StyleObjectIdentifier, StyleObjectRules } from "@tamagui/web";
5
5
  import { basename, relative } from "node:path";
6
6
  import * as reactNativeWebInternals from "react-native-web-internals";
7
- import { FAILED_EVAL } from "../constants";
8
- import { requireTamaguiCore } from "../helpers/requireTamaguiCore";
9
- import { createEvaluator, createSafeEvaluator } from "./createEvaluator";
10
- import { evaluateAstNode } from "./evaluateAstNode";
11
- import { attrStr, findComponentName, getValidComponent, getValidComponentsPaths, getValidImport, isPresent, isValidImport, objToStr } from "./extractHelpers";
12
- import { findTopmostFunction } from "./findTopmostFunction";
13
- import { cleanupBeforeExit, getStaticBindingsForScope } from "./getStaticBindingsForScope";
14
- import { literalToAst } from "./literalToAst";
15
- import { loadTamagui, loadTamaguiSync } from "./loadTamagui";
16
- import { logLines } from "./logLines";
17
- import { normalizeTernaries } from "./normalizeTernaries";
18
- import { setPropsToFontFamily } from "./propsToFontFamilyCache";
19
- import { removeUnusedHooks } from "./removeUnusedHooks";
20
- import { timer } from "./timer";
21
- import { validHTMLAttributes } from "./validHTMLAttributes";
7
+ import { FAILED_EVAL } from "../constants.native.js";
8
+ import { requireTamaguiCore } from "../helpers/requireTamaguiCore.native.js";
9
+ import { createEvaluator, createSafeEvaluator } from "./createEvaluator.native.js";
10
+ import { evaluateAstNode } from "./evaluateAstNode.native.js";
11
+ import { attrStr, findComponentName, getValidComponent, getValidComponentsPaths, getValidImport, isPresent, isValidImport, objToStr } from "./extractHelpers.native.js";
12
+ import { findTopmostFunction } from "./findTopmostFunction.native.js";
13
+ import { cleanupBeforeExit, getStaticBindingsForScope } from "./getStaticBindingsForScope.native.js";
14
+ import { literalToAst } from "./literalToAst.native.js";
15
+ import { loadTamagui, loadTamaguiSync } from "./loadTamagui.native.js";
16
+ import { logLines } from "./logLines.native.js";
17
+ import { normalizeTernaries } from "./normalizeTernaries.native.js";
18
+ import { setPropsToFontFamily } from "./propsToFontFamilyCache.native.js";
19
+ import { removeUnusedHooks } from "./removeUnusedHooks.native.js";
20
+ import { timer } from "./timer.native.js";
21
+ import { validHTMLAttributes } from "./validHTMLAttributes.native.js";
22
22
  var UNTOUCHED_PROPS = {
23
- key: !0,
24
- style: !0,
25
- className: !0
26
- }, createTernary = function(x) {
27
- return x;
28
- }, hasLoggedBaseInfo = !1;
23
+ key: !0,
24
+ style: !0,
25
+ className: !0
26
+ },
27
+ createTernary = function (x) {
28
+ return x;
29
+ },
30
+ hasLoggedBaseInfo = !1;
29
31
  function isFullyDisabled(props) {
30
32
  return props.disableExtraction && props.disableDebugAttr;
31
33
  }
32
34
  function createExtractor() {
33
- var { logger = console, platform = "web" } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
34
- logger: console
35
- }, INLINE_EXTRACTABLE = {
36
- ref: "ref",
37
- key: "key",
38
- ...platform === "web" && {
39
- onPress: "onClick",
40
- onHoverIn: "onMouseEnter",
41
- onHoverOut: "onMouseLeave",
42
- onPressIn: "onMouseDown",
43
- onPressOut: "onMouseUp"
44
- }
45
- }, componentState = {
46
- focus: !1,
47
- focusVisible: !1,
48
- hover: !1,
49
- unmounted: !0,
50
- press: !1,
51
- pressIn: !1,
52
- disabled: !1
53
- }, styleProps = {
54
- resolveValues: "value",
55
- noClassNames: !1,
56
- isAnimated: !1
57
- }, shouldAddDebugProp = (
35
+ var {
36
+ logger = console,
37
+ platform = "web"
38
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
39
+ logger: console
40
+ },
41
+ INLINE_EXTRACTABLE = {
42
+ ref: "ref",
43
+ key: "key",
44
+ ...(platform === "web" && {
45
+ onPress: "onClick",
46
+ onHoverIn: "onMouseEnter",
47
+ onHoverOut: "onMouseLeave",
48
+ onPressIn: "onMouseDown",
49
+ onPressOut: "onMouseUp"
50
+ })
51
+ },
52
+ componentState = {
53
+ focus: !1,
54
+ focusVisible: !1,
55
+ hover: !1,
56
+ unmounted: !0,
57
+ press: !1,
58
+ pressIn: !1,
59
+ disabled: !1
60
+ },
61
+ styleProps = {
62
+ resolveValues: "value",
63
+ noClassNames: !1,
64
+ isAnimated: !1
65
+ },
66
+ shouldAddDebugProp =
58
67
  // really basic disable this for next.js because it messes with ssr
59
- !process.env.npm_package_dependencies_next && !1
60
- ), projectInfo = null;
68
+ !process.env.npm_package_dependencies_next && !1,
69
+ projectInfo = null;
61
70
  function loadSync(props) {
62
71
  return isFullyDisabled(props) ? null : projectInfo || (projectInfo = loadTamaguiSync(props));
63
72
  }
@@ -74,63 +83,81 @@ function createExtractor() {
74
83
  getTamagui() {
75
84
  return projectInfo?.tamaguiConfig;
76
85
  },
77
- parseSync: function(f, props) {
86
+ parseSync: function (f, props) {
78
87
  var projectInfo2 = loadSync(props);
79
88
  return parseWithConfig(projectInfo2 || {}, f, props);
80
89
  },
81
- parse: async function(f, props) {
90
+ parse: async function (f, props) {
82
91
  var projectInfo2 = await load(props);
83
92
  return parseWithConfig(projectInfo2 || {}, f, props);
84
93
  }
85
94
  };
86
95
  function parseWithConfig(param, fileOrPath, options) {
87
- var { components, tamaguiConfig } = param, { config = "tamagui.config.ts", importsWhitelist = [
88
- "constants.js"
89
- ], evaluateVars = !0, sourcePath = "", onExtractTag, onStyleRule, getFlattenedNode, disable, disableExtraction, disableExtractInlineMedia, disableExtractVariables, disableDebugAttr, enableDynamicEvaluation = !1, disableOptimizeHooks, includeExtensions = [
90
- ".ts",
91
- ".tsx",
92
- ".jsx"
93
- ], extractStyledDefinitions = !1, prefixLogs, excludeProps, platform: platform2, ...restProps } = options, validHooks = disableOptimizeHooks ? {} : {
94
- useMedia: !0,
95
- useTheme: !0
96
- };
97
- if (sourcePath.includes(".tamagui-dynamic-eval"))
98
- return null;
99
- var { normalizeStyle, getSplitStyles, mediaQueryConfig, propMapper, proxyThemeVariables, pseudoDescriptors } = requireTamaguiCore(platform2), shouldPrintDebug = options.shouldPrintDebug || !1;
100
- if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath))
101
- return null;
102
- if (!isFullyDisabled(options) && !components)
103
- throw new Error("Must provide components");
104
- if (sourcePath && includeExtensions && !includeExtensions.some(function(ext) {
96
+ var {
97
+ components,
98
+ tamaguiConfig
99
+ } = param,
100
+ {
101
+ config = "tamagui.config.ts",
102
+ importsWhitelist = ["constants.js"],
103
+ evaluateVars = !0,
104
+ sourcePath = "",
105
+ onExtractTag,
106
+ onStyleRule,
107
+ getFlattenedNode,
108
+ disable,
109
+ disableExtraction,
110
+ disableExtractInlineMedia,
111
+ disableExtractVariables,
112
+ disableDebugAttr,
113
+ enableDynamicEvaluation = !1,
114
+ disableOptimizeHooks,
115
+ includeExtensions = [".ts", ".tsx", ".jsx"],
116
+ extractStyledDefinitions = !1,
117
+ prefixLogs,
118
+ excludeProps,
119
+ platform: platform2,
120
+ ...restProps
121
+ } = options,
122
+ validHooks = disableOptimizeHooks ? {} : {
123
+ useMedia: !0,
124
+ useTheme: !0
125
+ };
126
+ if (sourcePath.includes(".tamagui-dynamic-eval")) return null;
127
+ var {
128
+ normalizeStyle,
129
+ getSplitStyles,
130
+ mediaQueryConfig,
131
+ propMapper,
132
+ proxyThemeVariables,
133
+ pseudoDescriptors
134
+ } = requireTamaguiCore(platform2),
135
+ shouldPrintDebug = options.shouldPrintDebug || !1;
136
+ if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath)) return null;
137
+ if (!isFullyDisabled(options) && !components) throw new Error("Must provide components");
138
+ if (sourcePath && includeExtensions && !includeExtensions.some(function (ext) {
105
139
  return sourcePath.endsWith(ext);
106
- }))
107
- return shouldPrintDebug && logger.info(`Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(", ")}`), null;
140
+ })) return shouldPrintDebug && logger.info(`Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(", ")}`), null;
108
141
  function isValidStyleKey(name, staticConfig) {
109
142
  var _staticConfig_validStyles, _staticConfig_variants, _projectInfo_tamaguiConfig;
110
- if (!projectInfo)
111
- throw new Error("Tamagui extractor not loaded yet");
143
+ if (!projectInfo) throw new Error("Tamagui extractor not loaded yet");
112
144
  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)]);
113
145
  }
114
- var isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo = {
115
- ...options,
116
- sourcePath,
117
- allLoadedComponents: components ? [
118
- ...components
119
- ] : []
120
- };
146
+ var isTargetingHTML = platform2 === "web",
147
+ ogDebug = shouldPrintDebug,
148
+ tm = timer(),
149
+ propsWithFileInfo = {
150
+ ...options,
151
+ sourcePath,
152
+ allLoadedComponents: components ? [...components] : []
153
+ };
121
154
  if (!hasLoggedBaseInfo) {
122
155
  var _process_env_DEBUG;
123
- hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info([
124
- "loaded components:",
125
- propsWithFileInfo.allLoadedComponents.map(function(comp2) {
126
- return Object.keys(comp2.nameToInfo).join(", ");
127
- }).join(", ")
128
- ].join(" ")), !((_process_env_DEBUG = process.env.DEBUG) === null || _process_env_DEBUG === void 0) && _process_env_DEBUG.startsWith("tamagui") && logger.info([
129
- "loaded:",
130
- propsWithFileInfo.allLoadedComponents.map(function(x) {
131
- return x.moduleName;
132
- })
133
- ].join(`
156
+ hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info(["loaded components:", propsWithFileInfo.allLoadedComponents.map(function (comp2) {
157
+ return Object.keys(comp2.nameToInfo).join(", ");
158
+ }).join(", ")].join(" ")), !((_process_env_DEBUG = process.env.DEBUG) === null || _process_env_DEBUG === void 0) && _process_env_DEBUG.startsWith("tamagui") && logger.info(["loaded:", propsWithFileInfo.allLoadedComponents.map(function (x) {
159
+ return x.moduleName;
160
+ })].join(`
134
161
  `));
135
162
  }
136
163
  tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig?.themes || (console.error(`\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file:
@@ -143,41 +170,51 @@ function createExtractor() {
143
170
  - try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches.
144
171
  - or search your lockfile for mis-matches.
145
172
  `), console.info(" Got config:", tamaguiConfig), process.exit(0));
146
- var firstThemeName = Object.keys(tamaguiConfig?.themes || {})[0], firstTheme = tamaguiConfig?.themes[firstThemeName] || {};
173
+ var firstThemeName = Object.keys(tamaguiConfig?.themes || {})[0],
174
+ firstTheme = tamaguiConfig?.themes[firstThemeName] || {};
147
175
  if (!firstTheme || typeof firstTheme != "object") {
148
176
  var _$err = `Missing theme ${firstThemeName}, an error occurred when importing your config`;
149
177
  throw console.info(_$err, "Got config:", tamaguiConfig), console.info("Looking for theme:", firstThemeName), new Error(_$err);
150
178
  }
151
- var proxiedTheme = proxyThemeVariables(firstTheme), themeAccessListeners = /* @__PURE__ */ new Set(), defaultTheme = new Proxy(proxiedTheme, {
152
- get(target, key) {
153
- return Reflect.has(target, key) && themeAccessListeners.forEach(function(cb) {
154
- return cb(String(key));
155
- }), Reflect.get(target, key);
156
- }
157
- }), body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
158
- 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 ${propsWithFileInfo.allLoadedComponents.map(function(k) {
179
+ var proxiedTheme = proxyThemeVariables(firstTheme),
180
+ themeAccessListeners = /* @__PURE__ */new Set(),
181
+ defaultTheme = new Proxy(proxiedTheme, {
182
+ get(target, key) {
183
+ return Reflect.has(target, key) && themeAccessListeners.forEach(function (cb) {
184
+ return cb(String(key));
185
+ }), Reflect.get(target, key);
186
+ }
187
+ }),
188
+ body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
189
+ 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 ${propsWithFileInfo.allLoadedComponents.map(function (k) {
159
190
  return k.moduleName;
160
191
  }).join(", ")}`), logger.info(`valid import paths: ${JSON.stringify(getValidComponentsPaths(propsWithFileInfo))}`));
161
- var doesUseValidImport = !1, hasImportedTheme = !1, importDeclarations = [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
192
+ var doesUseValidImport = !1,
193
+ hasImportedTheme = !1,
194
+ importDeclarations = [],
195
+ _iteratorNormalCompletion = !0,
196
+ _didIteratorError = !1,
197
+ _iteratorError = void 0;
162
198
  try {
163
- for (var _loop = function() {
164
- var bodyPath = _step.value;
165
- if (bodyPath.type !== "ImportDeclaration") return "continue";
166
- var node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = isValidImport(propsWithFileInfo, moduleName);
167
- if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some(function(specifier) {
168
- return specifier.local.name === "styled";
169
- }))
170
- return doesUseValidImport = !0, "break";
171
- if (valid) {
172
- var names = node.specifiers.map(function(specifier) {
173
- return specifier.local.name;
174
- }), isValidComponent = names.some(function(name) {
175
- return !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name]);
176
- });
177
- if (shouldPrintDebug === "verbose" && logger.info(` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(", ")} from '${moduleName}' - (valid: ${JSON.stringify(getValidComponentsPaths(propsWithFileInfo))})`), isValidComponent)
178
- return doesUseValidImport = !0, "break";
179
- }
180
- }, _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
199
+ for (var _loop = function () {
200
+ var bodyPath = _step.value;
201
+ if (bodyPath.type !== "ImportDeclaration") return "continue";
202
+ var node = "node" in bodyPath ? bodyPath.node : bodyPath,
203
+ moduleName = node.source.value,
204
+ valid = isValidImport(propsWithFileInfo, moduleName);
205
+ if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some(function (specifier) {
206
+ return specifier.local.name === "styled";
207
+ })) return doesUseValidImport = !0, "break";
208
+ if (valid) {
209
+ var names = node.specifiers.map(function (specifier) {
210
+ return specifier.local.name;
211
+ }),
212
+ isValidComponent = names.some(function (name) {
213
+ return !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name]);
214
+ });
215
+ if (shouldPrintDebug === "verbose" && logger.info(` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(", ")} from '${moduleName}' - (valid: ${JSON.stringify(getValidComponentsPaths(propsWithFileInfo))})`), isValidComponent) return doesUseValidImport = !0, "break";
216
+ }
217
+ }, _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
181
218
  var _ret = _loop();
182
219
  if (_ret === "break") break;
183
220
  }
@@ -187,34 +224,39 @@ function createExtractor() {
187
224
  try {
188
225
  !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
189
226
  } finally {
190
- if (_didIteratorError)
191
- throw _iteratorError;
227
+ if (_didIteratorError) throw _iteratorError;
192
228
  }
193
229
  }
194
230
  if (shouldPrintDebug && logger.info(`${JSON.stringify({
195
231
  doesUseValidImport,
196
232
  hasImportedTheme
197
233
  }, null, 2)}
198
- `), !doesUseValidImport)
199
- return null;
234
+ `), !doesUseValidImport) return null;
200
235
  function getValidImportedComponent(componentName) {
201
- var importDeclaration = importDeclarations.find(function(dec) {
202
- return dec.specifiers.some(function(spec) {
236
+ var importDeclaration = importDeclarations.find(function (dec) {
237
+ return dec.specifiers.some(function (spec) {
203
238
  return spec.local.name === componentName;
204
239
  });
205
240
  });
206
241
  return importDeclaration ? getValidImport(propsWithFileInfo, importDeclaration.source.value, componentName) : null;
207
242
  }
208
243
  tm.mark("import-check", !!shouldPrintDebug);
209
- var couldntParse = !1, modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = function(a) {
210
- return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
211
- }, shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath), programPath = null, res = {
212
- styled: 0,
213
- flattened: 0,
214
- optimized: 0,
215
- modified: 0,
216
- found: 0
217
- }, version = `${Math.random()}`;
244
+ var couldntParse = !1,
245
+ modifiedComponents = /* @__PURE__ */new Set(),
246
+ bindingCache = {},
247
+ callTraverse = function (a) {
248
+ return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
249
+ },
250
+ shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath),
251
+ programPath = null,
252
+ res = {
253
+ styled: 0,
254
+ flattened: 0,
255
+ optimized: 0,
256
+ modified: 0,
257
+ found: 0
258
+ },
259
+ version = `${Math.random()}`;
218
260
  if (callTraverse({
219
261
  // @ts-ignore
220
262
  Program: {
@@ -225,37 +267,34 @@ function createExtractor() {
225
267
  // styled() calls
226
268
  CallExpression(path) {
227
269
  if (!(disable || shouldDisableExtraction || extractStyledDefinitions === !1) && !(!t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled")) {
228
- var variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown", parentNode = path.node.arguments[0];
270
+ var variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown",
271
+ parentNode = path.node.arguments[0];
229
272
  if (t.isIdentifier(parentNode)) {
230
- var parentName = parentNode.name, definition = path.node.arguments[1];
273
+ var parentName = parentNode.name,
274
+ definition = path.node.arguments[1];
231
275
  if (!(!parentName || !definition || !t.isObjectExpression(definition))) {
232
276
  var Component = getValidImportedComponent(variableName);
233
277
  if (!Component) {
234
- if (enableDynamicEvaluation !== !0)
235
- return;
278
+ if (enableDynamicEvaluation !== !0) return;
236
279
  try {
237
280
  shouldPrintDebug && logger.info(`Unknown component: ${variableName} = styled(${parentName}) attempting dynamic load: ${sourcePath}`);
238
281
  var out = loadTamaguiSync({
239
282
  forceExports: !0,
240
- components: [
241
- sourcePath
242
- ],
283
+ components: [sourcePath],
243
284
  cacheKey: version
244
285
  });
245
286
  if (!out?.components) {
246
287
  shouldPrintDebug && logger.info(`Couldn't load, got ${out}`);
247
288
  return;
248
289
  }
249
- if (propsWithFileInfo.allLoadedComponents = [
250
- ...propsWithFileInfo.allLoadedComponents,
251
- ...out.components
252
- ], Component = out.components.flatMap(function(x) {
290
+ if (propsWithFileInfo.allLoadedComponents = [...propsWithFileInfo.allLoadedComponents, ...out.components], Component = out.components.flatMap(function (x) {
253
291
  var _x_nameToInfo_variableName;
254
292
  return (_x_nameToInfo_variableName = x.nameToInfo[variableName]) !== null && _x_nameToInfo_variableName !== void 0 ? _x_nameToInfo_variableName : [];
255
293
  })[0], !out.cached) {
256
- var _out_components, foundNames = (_out_components = out.components) === null || _out_components === void 0 ? void 0 : _out_components.map(function(x) {
257
- return Object.keys(x.nameToInfo).join(", ");
258
- }).join(", ").trim();
294
+ var _out_components,
295
+ foundNames = (_out_components = out.components) === null || _out_components === void 0 ? void 0 : _out_components.map(function (x) {
296
+ return Object.keys(x.nameToInfo).join(", ");
297
+ }).join(", ").trim();
259
298
  foundNames && colorLog(Color.FgYellow, ` | Tamagui found dynamic components: ${foundNames}`);
260
299
  }
261
300
  } catch {
@@ -266,30 +305,30 @@ function createExtractor() {
266
305
  shouldPrintDebug && logger.info(" No component found");
267
306
  return;
268
307
  }
269
- var componentSkipProps = /* @__PURE__ */ new Set([
270
- ...Component.staticConfig.inlineWhenUnflattened || [],
271
- ...Component.staticConfig.inlineProps || [],
308
+ var componentSkipProps = /* @__PURE__ */new Set([...(Component.staticConfig.inlineWhenUnflattened || []), ...(Component.staticConfig.inlineProps || []),
272
309
  // for now skip variants, will return to them
273
- "variants",
274
- "defaultVariants",
310
+ "variants", "defaultVariants",
275
311
  // skip fontFamily its basically a "variant", important for theme use to be value always
276
- "fontFamily",
277
- "name",
278
- "focusStyle",
279
- "focusVisibleStyle",
280
- "disabledStyle",
281
- "hoverStyle",
282
- "pressStyle"
283
- ]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = getStaticBindingsForScope(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug), attemptEval = evaluateVars ? createEvaluator({
284
- props: propsWithFileInfo,
285
- staticNamespace,
286
- sourcePath,
287
- shouldPrintDebug
288
- }) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval), _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
312
+ "fontFamily", "name", "focusStyle", "focusVisibleStyle", "disabledStyle", "hoverStyle", "pressStyle"]),
313
+ skipped = /* @__PURE__ */new Set(),
314
+ styles = {},
315
+ staticNamespace = getStaticBindingsForScope(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug),
316
+ attemptEval = evaluateVars ? createEvaluator({
317
+ props: propsWithFileInfo,
318
+ staticNamespace,
319
+ sourcePath,
320
+ shouldPrintDebug
321
+ }) : evaluateAstNode,
322
+ attemptEvalSafe = createSafeEvaluator(attemptEval),
323
+ _iteratorNormalCompletion2 = !0,
324
+ _didIteratorError2 = !1,
325
+ _iteratorError2 = void 0;
289
326
  try {
290
327
  for (var _iterator2 = definition.properties[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
291
- var property = _step2.value, _Component_staticConfig_variants;
292
- if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || // TODO make pseudos and variants work
328
+ var property = _step2.value,
329
+ _Component_staticConfig_variants;
330
+ if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) ||
331
+ // TODO make pseudos and variants work
293
332
  // skip pseudos
294
333
  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)) {
295
334
  skipped.add(property);
@@ -304,33 +343,25 @@ function createExtractor() {
304
343
  try {
305
344
  !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
306
345
  } finally {
307
- if (_didIteratorError2)
308
- throw _iteratorError2;
346
+ if (_didIteratorError2) throw _iteratorError2;
309
347
  }
310
348
  }
311
- var out2 = getSplitStyles(styles, Component.staticConfig, defaultTheme, "", componentState, styleProps, void 0, void 0, void 0, shouldPrintDebug), classNames = {
312
- ...out2.classNames
313
- };
314
- if (shouldPrintDebug && logger.info([
315
- `Extracted styled(${variableName})
316
- `,
317
- JSON.stringify(styles, null, 2),
318
- `
319
- classNames:`,
320
- JSON.stringify(classNames, null, 2),
321
- `
322
- rulesToInsert:`,
323
- out2.rulesToInsert
324
- ].join(" ")), definition.properties = definition.properties.map(function(prop) {
325
- if (skipped.has(prop) || !t.isObjectProperty(prop) || !t.isIdentifier(prop.key))
326
- return prop;
327
- var key2 = prop.key.name, value = classNames[key2];
349
+ var out2 = getSplitStyles(styles, Component.staticConfig, defaultTheme, "", componentState, styleProps, void 0, void 0, void 0, shouldPrintDebug),
350
+ classNames = {
351
+ ...out2.classNames
352
+ };
353
+ if (shouldPrintDebug && logger.info([`Extracted styled(${variableName})
354
+ `, JSON.stringify(styles, null, 2), `
355
+ classNames:`, JSON.stringify(classNames, null, 2), `
356
+ rulesToInsert:`, out2.rulesToInsert].join(" ")), definition.properties = definition.properties.map(function (prop) {
357
+ if (skipped.has(prop) || !t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) return prop;
358
+ var key2 = prop.key.name,
359
+ value = classNames[key2];
328
360
  return value ? t.objectProperty(t.stringLiteral(key2), t.stringLiteral(value)) : prop;
329
- }), out2.rulesToInsert)
330
- for (var key in out2.rulesToInsert) {
331
- var styleObject = out2.rulesToInsert[key];
332
- onStyleRule?.(styleObject[StyleObjectIdentifier], styleObject[StyleObjectRules]);
333
- }
361
+ }), out2.rulesToInsert) for (var key in out2.rulesToInsert) {
362
+ var styleObject = out2.rulesToInsert[key];
363
+ onStyleRule?.(styleObject[StyleObjectIdentifier], styleObject[StyleObjectRules]);
364
+ }
334
365
  res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
335
366
  }
336
367
  }
@@ -338,16 +369,20 @@ function createExtractor() {
338
369
  },
339
370
  JSXElement(traversePath) {
340
371
  tm.mark("jsx-element", !!shouldPrintDebug);
341
- var node = traversePath.node.openingElement, ogAttributes = node.attributes.map(function(attr3) {
342
- return {
343
- ...attr3
344
- };
345
- }), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
372
+ var node = traversePath.node.openingElement,
373
+ ogAttributes = node.attributes.map(function (attr3) {
374
+ return {
375
+ ...attr3
376
+ };
377
+ }),
378
+ componentName = findComponentName(traversePath.scope),
379
+ closingElement = traversePath.node.closingElement;
346
380
  if (closingElement && t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name)) {
347
381
  shouldPrintDebug && logger.info(" skip non-identifier element");
348
382
  return;
349
383
  }
350
- var binding = traversePath.scope.getBinding(node.name.name), moduleName = "";
384
+ var binding = traversePath.scope.getBinding(node.name.name),
385
+ moduleName = "";
351
386
  if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, moduleName, binding.identifier.name))) {
352
387
  shouldPrintDebug && logger.info(` - Binding in component ${componentName} not valid import: "${binding.identifier.name}" isn't in ${moduleName}
353
388
  `);
@@ -362,157 +397,112 @@ function createExtractor() {
362
397
  }
363
398
  var originalNodeName = node.name.name;
364
399
  res.found++;
365
- var 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(function(n) {
366
- return t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug";
367
- }).map(function(n) {
368
- return n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1;
369
- })[0];
370
- if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`\x1B[33m\x1B[0m ${componentName} | ${codePosition} -------------------`), logger.info([
371
- "\x1B[1m",
372
- "\x1B[32m",
373
- `<${originalNodeName} />`,
374
- disableDebugAttr ? "" : "\u{1F41B}"
375
- ].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(`${basename(filePath)}:${lineNumbers}`)))), shouldDisableExtraction) {
400
+ var filePath = `./${relative(process.cwd(), sourcePath)}`,
401
+ lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "",
402
+ codePosition = `${filePath}:${lineNumbers}`,
403
+ debugPropValue = node.attributes.filter(function (n) {
404
+ return t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug";
405
+ }).map(function (n) {
406
+ return n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1;
407
+ })[0];
408
+ if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`\x1B[33m\x1B[0m ${componentName} | ${codePosition} -------------------`), logger.info(["\x1B[1m", "\x1B[32m", `<${originalNodeName} />`, disableDebugAttr ? "" : "\u{1F41B}"].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(`${basename(filePath)}:${lineNumbers}`)))), shouldDisableExtraction) {
376
409
  shouldPrintDebug === "verbose" && logger.info(` \u274C Extraction disabled: ${JSON.stringify(disableExtraction)}
377
410
  `);
378
411
  return;
379
412
  }
380
413
  try {
381
- let evaluateAttribute2 = function(path) {
382
- var attribute = path.node, attr3 = {
383
- type: "attr",
384
- value: attribute
385
- };
386
- if (t.isJSXSpreadAttribute(attribute)) {
387
- var arg = attribute.argument, conditional = t.isConditionalExpression(arg) ? (
388
- // <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
389
- [
390
- arg.test,
391
- arg.consequent,
392
- arg.alternate
393
- ]
394
- ) : t.isLogicalExpression(arg) && arg.operator === "&&" ? (
395
- // <YStack {...isSmall && { color: 'red }}
396
- [
397
- arg.left,
398
- arg.right,
399
- null
400
- ]
401
- ) : null;
402
- if (conditional) {
403
- var [test, alt, cons] = conditional;
404
- if (!test) throw new Error("no test");
405
- return [
406
- alt,
407
- cons
408
- ].some(function(side) {
409
- return side && !isStaticObject2(side);
410
- }) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr3) : [
411
- ...createTernariesFromObjectProperties2(test, alt) || [],
412
- ...cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || []
413
- ].map(function(ternary2) {
414
- return {
415
- type: "ternary",
416
- value: ternary2
417
- };
418
- });
419
- }
420
- }
421
- if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string")
422
- return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr3;
423
- var name2 = attribute.name.name;
424
- if (excludeProps?.has(name2))
425
- return shouldPrintDebug && logger.info([
426
- " excluding prop",
427
- name2
428
- ].join(" ")), null;
429
- if (inlineProps.has(name2))
430
- return inlined.set(name2, name2), shouldPrintDebug && logger.info([
431
- " ! inlining, inline prop",
432
- name2
433
- ].join(" ")), attr3;
434
- if (UNTOUCHED_PROPS[name2])
435
- return attr3;
436
- if (INLINE_EXTRACTABLE[name2])
437
- return inlined.set(name2, INLINE_EXTRACTABLE[name2]), attr3;
438
- if (name2.startsWith("data-"))
439
- return attr3;
440
- if ((name2 === "enterStyle" || name2 === "exitStyle") && t.isJSXExpressionContainer(attribute?.value))
441
- return shouldDeopt = !0, attr3;
442
- if (name2[0] === "$" && t.isJSXExpressionContainer(attribute?.value)) {
443
- var shortname = name2.slice(1);
444
- if (mediaQueryConfig[shortname]) {
445
- if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
446
- return attr3;
447
- var expression = attribute.value.expression;
448
- if (!t.isJSXEmptyExpression(expression)) {
449
- var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
450
- inlineMediaQuery: shortname
414
+ let evaluateAttribute2 = function (path) {
415
+ var attribute = path.node,
416
+ attr3 = {
417
+ type: "attr",
418
+ value: attribute
419
+ };
420
+ if (t.isJSXSpreadAttribute(attribute)) {
421
+ var arg = attribute.argument,
422
+ conditional = t.isConditionalExpression(arg) ?
423
+ // <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
424
+ [arg.test, arg.consequent, arg.alternate] : t.isLogicalExpression(arg) && arg.operator === "&&" ?
425
+ // <YStack {...isSmall && { color: 'red }}
426
+ [arg.left, arg.right, null] : null;
427
+ if (conditional) {
428
+ var [test, alt, cons] = conditional;
429
+ if (!test) throw new Error("no test");
430
+ return [alt, cons].some(function (side) {
431
+ return side && !isStaticObject2(side);
432
+ }) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr3) : [...(createTernariesFromObjectProperties2(test, alt) || []), ...(cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || [])].map(function (ternary2) {
433
+ return {
434
+ type: "ternary",
435
+ value: ternary2
436
+ };
451
437
  });
452
- if (ternaries2)
453
- return ternaries2.map(function(value3) {
438
+ }
439
+ }
440
+ if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string") return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr3;
441
+ var name2 = attribute.name.name;
442
+ if (excludeProps?.has(name2)) return shouldPrintDebug && logger.info([" excluding prop", name2].join(" ")), null;
443
+ if (inlineProps.has(name2)) return inlined.set(name2, name2), shouldPrintDebug && logger.info([" ! inlining, inline prop", name2].join(" ")), attr3;
444
+ if (UNTOUCHED_PROPS[name2]) return attr3;
445
+ if (INLINE_EXTRACTABLE[name2]) return inlined.set(name2, INLINE_EXTRACTABLE[name2]), attr3;
446
+ if (name2.startsWith("data-")) return attr3;
447
+ if ((name2 === "enterStyle" || name2 === "exitStyle") && t.isJSXExpressionContainer(attribute?.value)) return shouldDeopt = !0, attr3;
448
+ if (name2[0] === "$" && t.isJSXExpressionContainer(attribute?.value)) {
449
+ var shortname = name2.slice(1);
450
+ if (mediaQueryConfig[shortname]) {
451
+ if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia) return attr3;
452
+ var expression = attribute.value.expression;
453
+ if (!t.isJSXEmptyExpression(expression)) {
454
+ var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
455
+ inlineMediaQuery: shortname
456
+ });
457
+ if (ternaries2) return ternaries2.map(function (value3) {
454
458
  return {
455
459
  type: "ternary",
456
460
  value: value3
457
461
  };
458
462
  });
463
+ }
459
464
  }
460
465
  }
461
- }
462
- var [value2, valuePath] = function() {
463
- return t.isJSXExpressionContainer(attribute?.value) ? [
464
- attribute.value.expression,
465
- path.get("value")
466
- ] : [
467
- attribute.value,
468
- path.get("value")
469
- ];
470
- }(), remove = function() {
471
- Array.isArray(valuePath) ? valuePath.map(function(p) {
472
- return p.remove();
473
- }) : valuePath.remove();
474
- };
475
- if (name2 === "ref")
476
- return shouldPrintDebug && logger.info([
477
- " ! inlining, ref",
478
- name2
479
- ].join(" ")), inlined.set("ref", "ref"), attr3;
480
- if (name2 === "tag")
481
- return {
466
+ var [value2, valuePath] = function () {
467
+ return t.isJSXExpressionContainer(attribute?.value) ? [attribute.value.expression, path.get("value")] : [attribute.value, path.get("value")];
468
+ }(),
469
+ remove = function () {
470
+ Array.isArray(valuePath) ? valuePath.map(function (p) {
471
+ return p.remove();
472
+ }) : valuePath.remove();
473
+ };
474
+ if (name2 === "ref") return shouldPrintDebug && logger.info([" ! inlining, ref", name2].join(" ")), inlined.set("ref", "ref"), attr3;
475
+ if (name2 === "tag") return {
482
476
  type: "attr",
483
477
  value: path.node
484
478
  };
485
- if (disableExtractVariables === !0 && value2 && value2.type === "StringLiteral" && value2.value[0] === "$")
486
- return shouldPrintDebug && logger.info([
487
- ` ! inlining, native disable extract: ${name2} =`,
488
- value2.value
489
- ].join(" ")), inlined.set(name2, !0), attr3;
490
- if (name2 === "theme")
491
- return inlined.set("theme", attr3.value), attr3;
492
- var styleValue = attemptEvalSafe(value2);
493
- if (!variants[name2] && !isValidStyleKey(name2, staticConfig)) {
494
- var keys = [
495
- name2
496
- ], out = null;
497
- 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 = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
498
- var didInline = !1, attributes = keys.map(function(key9) {
499
- var val2 = out[key9], isStyle = isValidStyleKey(key9, staticConfig);
500
- return isStyle ? {
501
- type: "style",
502
- value: {
503
- [key9]: styleValue
504
- },
505
- name: key9,
506
- attr: path.node
507
- } : validHTMLAttributes[key9] || key9.startsWith("aria-") || key9.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
508
- key9 === "__source" || key9 === "__self" ? attr3 : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key9), didInline = !0, inlined.set(key9, val2), val2);
509
- });
510
- return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes.map(function(x) {
511
- return x.toString();
512
- })}`), attr3) : attributes;
513
- }
514
- if (styleValue !== FAILED_EVAL)
515
- return inlineWhenUnflattened.has(name2) && (inlineWhenUnflattenedOGVals[name2] = {
479
+ if (disableExtractVariables === !0 && value2 && value2.type === "StringLiteral" && value2.value[0] === "$") return shouldPrintDebug && logger.info([` ! inlining, native disable extract: ${name2} =`, value2.value].join(" ")), inlined.set(name2, !0), attr3;
480
+ if (name2 === "theme") return inlined.set("theme", attr3.value), attr3;
481
+ var styleValue = attemptEvalSafe(value2);
482
+ if (!variants[name2] && !isValidStyleKey(name2, staticConfig)) {
483
+ var keys = [name2],
484
+ out = null;
485
+ 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 = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
486
+ var didInline = !1,
487
+ attributes = keys.map(function (key9) {
488
+ var val2 = out[key9],
489
+ isStyle = isValidStyleKey(key9, staticConfig);
490
+ return isStyle ? {
491
+ type: "style",
492
+ value: {
493
+ [key9]: styleValue
494
+ },
495
+ name: key9,
496
+ attr: path.node
497
+ } : validHTMLAttributes[key9] || key9.startsWith("aria-") || key9.startsWith("data-") ||
498
+ // this is debug stuff added by vite / new jsx transform
499
+ key9 === "__source" || key9 === "__self" ? attr3 : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key9), didInline = !0, inlined.set(key9, val2), val2);
500
+ });
501
+ return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes.map(function (x) {
502
+ return x.toString();
503
+ })}`), attr3) : attributes;
504
+ }
505
+ if (styleValue !== FAILED_EVAL) return inlineWhenUnflattened.has(name2) && (inlineWhenUnflattenedOGVals[name2] = {
516
506
  styleValue,
517
507
  attr: attr3
518
508
  }), isValidStyleKey(name2, staticConfig) ? (shouldPrintDebug && logger.info(` style: ${name2} = ${styleValue}`), name2 in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
@@ -523,74 +513,68 @@ function createExtractor() {
523
513
  name: name2,
524
514
  attr: path.node
525
515
  }) : (variants[name2] && variantValues.set(name2, styleValue), inlined.set(name2, !0), attr3);
526
- if (t.isBinaryExpression(value2)) {
527
- shouldPrintDebug && logger.info(` binary expression ${name2} = ${value2}`);
528
- var { operator, left, right } = value2, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
529
- if (shouldPrintDebug && logger.info(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
530
- var ternary = addBinaryConditional(operator, left, right);
531
- if (ternary) return ternary;
532
- }
533
- if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
534
- var ternary1 = addBinaryConditional(operator, right, left);
535
- if (ternary1) return ternary1;
516
+ if (t.isBinaryExpression(value2)) {
517
+ shouldPrintDebug && logger.info(` binary expression ${name2} = ${value2}`);
518
+ var {
519
+ operator,
520
+ left,
521
+ right
522
+ } = value2,
523
+ lVal = attemptEvalSafe(left),
524
+ rVal = attemptEvalSafe(right);
525
+ if (shouldPrintDebug && logger.info(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
526
+ var ternary = addBinaryConditional(operator, left, right);
527
+ if (ternary) return ternary;
528
+ }
529
+ if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
530
+ var ternary1 = addBinaryConditional(operator, right, left);
531
+ if (ternary1) return ternary1;
532
+ }
533
+ return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name2, !0), attr3;
536
534
  }
537
- return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name2, !0), attr3;
538
- }
539
- var staticConditional = getStaticConditional(value2);
540
- if (staticConditional)
541
- return shouldPrintDebug === "verbose" && logger.info(` static conditional ${name2} ${value2}`), {
535
+ var staticConditional = getStaticConditional(value2);
536
+ if (staticConditional) return shouldPrintDebug === "verbose" && logger.info(` static conditional ${name2} ${value2}`), {
542
537
  type: "ternary",
543
538
  value: staticConditional
544
539
  };
545
- var staticLogical = getStaticLogical(value2);
546
- if (staticLogical)
547
- return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name2} = ${value2}`), {
540
+ var staticLogical = getStaticLogical(value2);
541
+ if (staticLogical) return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name2} = ${value2}`), {
548
542
  type: "ternary",
549
543
  value: staticLogical
550
544
  };
551
- if (options.experimentalFlattenDynamicValues && isValidStyleKey(name2, staticConfig))
552
- return {
545
+ if (options.experimentalFlattenDynamicValues && isValidStyleKey(name2, staticConfig)) return {
553
546
  type: "dynamic-style",
554
547
  value: value2,
555
548
  name: tamaguiConfig?.shorthands[name2] || name2
556
549
  };
557
- return inlined.set(name2, !0), shouldPrintDebug && logger.info(` ! inline no match ${name2} ${value2}`), attr3;
558
- function addBinaryConditional(operator2, staticExpr, cond) {
559
- if (getStaticConditional(cond)) {
560
- var alt2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.alternate)), cons2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.consequent));
561
- return shouldPrintDebug && logger.info([
562
- " binaryConditional",
563
- cond.test,
564
- cons2,
565
- alt2
566
- ].join(" ")), {
567
- type: "ternary",
568
- value: {
569
- test: cond.test,
570
- remove,
571
- alternate: {
572
- [name2]: alt2
573
- },
574
- consequent: {
575
- [name2]: cons2
550
+ return inlined.set(name2, !0), shouldPrintDebug && logger.info(` ! inline no match ${name2} ${value2}`), attr3;
551
+ function addBinaryConditional(operator2, staticExpr, cond) {
552
+ if (getStaticConditional(cond)) {
553
+ var alt2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.alternate)),
554
+ cons2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.consequent));
555
+ return shouldPrintDebug && logger.info([" binaryConditional", cond.test, cons2, alt2].join(" ")), {
556
+ type: "ternary",
557
+ value: {
558
+ test: cond.test,
559
+ remove,
560
+ alternate: {
561
+ [name2]: alt2
562
+ },
563
+ consequent: {
564
+ [name2]: cons2
565
+ }
576
566
  }
577
- }
578
- };
567
+ };
568
+ }
569
+ return null;
579
570
  }
580
- return null;
581
- }
582
- function getStaticConditional(value3) {
583
- if (t.isConditionalExpression(value3))
584
- try {
585
- var aVal = attemptEval(value3.alternate), cVal = attemptEval(value3.consequent);
571
+ function getStaticConditional(value3) {
572
+ if (t.isConditionalExpression(value3)) try {
573
+ var aVal = attemptEval(value3.alternate),
574
+ cVal = attemptEval(value3.consequent);
586
575
  if (shouldPrintDebug) {
587
576
  var type = value3.test.type;
588
- logger.info([
589
- " static ternary",
590
- type,
591
- cVal,
592
- aVal
593
- ].join(" "));
577
+ logger.info([" static ternary", type, cVal, aVal].join(" "));
594
578
  }
595
579
  return {
596
580
  test: value3.test,
@@ -603,23 +587,14 @@ function createExtractor() {
603
587
  }
604
588
  };
605
589
  } catch (err) {
606
- shouldPrintDebug && logger.info([
607
- " cant eval ternary",
608
- err.message
609
- ].join(" "));
590
+ shouldPrintDebug && logger.info([" cant eval ternary", err.message].join(" "));
610
591
  }
611
- return null;
612
- }
613
- function getStaticLogical(value3) {
614
- if (t.isLogicalExpression(value3) && value3.operator === "&&")
615
- try {
592
+ return null;
593
+ }
594
+ function getStaticLogical(value3) {
595
+ if (t.isLogicalExpression(value3) && value3.operator === "&&") try {
616
596
  var val2 = attemptEval(value3.right);
617
- return shouldPrintDebug && logger.info([
618
- " staticLogical",
619
- value3.left,
620
- name2,
621
- val2
622
- ].join(" ")), {
597
+ return shouldPrintDebug && logger.info([" staticLogical", value3.left, name2, val2].join(" ")), {
623
598
  test: value3.left,
624
599
  remove,
625
600
  consequent: {
@@ -628,126 +603,107 @@ function createExtractor() {
628
603
  alternate: null
629
604
  };
630
605
  } catch (err) {
631
- shouldPrintDebug && logger.info([
632
- " cant static eval logical",
633
- err
634
- ].join(" "));
606
+ shouldPrintDebug && logger.info([" cant static eval logical", err].join(" "));
635
607
  }
636
- return null;
637
- }
638
- }, isStaticObject2 = function(obj) {
639
- return t.isObjectExpression(obj) && obj.properties.every(function(prop) {
640
- if (!t.isObjectProperty(prop))
641
- return logger.info([
642
- "not object prop",
643
- prop
644
- ].join(" ")), !1;
645
- var propName = prop.key.name;
646
- return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([
647
- " not a valid style prop!",
648
- propName
649
- ].join(" ")), !1) : !0;
650
- });
651
- }, createTernariesFromObjectProperties2 = function(test, side) {
652
- var ternaryPartial = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
653
- if (!side)
654
- return null;
655
- if (!isStaticObject2(side))
656
- throw new Error("not extractable");
657
- return side.properties.flatMap(function(property) {
658
- if (!t.isObjectProperty(property))
659
- throw new Error("expected object property");
660
- if (t.isIdentifier(property.key)) {
661
- var key9 = property.key.name, mediaQueryKey = key9.slice(1), isMediaQuery = key9[0] === "$" && mediaQueryConfig[mediaQueryKey];
662
- if (isMediaQuery)
663
- if (t.isExpression(property.value)) {
608
+ return null;
609
+ }
610
+ },
611
+ isStaticObject2 = function (obj) {
612
+ return t.isObjectExpression(obj) && obj.properties.every(function (prop) {
613
+ if (!t.isObjectProperty(prop)) return logger.info(["not object prop", prop].join(" ")), !1;
614
+ var propName = prop.key.name;
615
+ return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([" not a valid style prop!", propName].join(" ")), !1) : !0;
616
+ });
617
+ },
618
+ createTernariesFromObjectProperties2 = function (test, side) {
619
+ var ternaryPartial = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
620
+ if (!side) return null;
621
+ if (!isStaticObject2(side)) throw new Error("not extractable");
622
+ return side.properties.flatMap(function (property) {
623
+ if (!t.isObjectProperty(property)) throw new Error("expected object property");
624
+ if (t.isIdentifier(property.key)) {
625
+ var key9 = property.key.name,
626
+ mediaQueryKey = key9.slice(1),
627
+ isMediaQuery = key9[0] === "$" && mediaQueryConfig[mediaQueryKey];
628
+ if (isMediaQuery) if (t.isExpression(property.value)) {
664
629
  var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(mediaQueryKey), property.value, {
665
630
  inlineMediaQuery: mediaQueryKey
666
631
  });
667
- if (ternaries2)
668
- return ternaries2.map(function(value2) {
669
- return {
670
- ...ternaryPartial,
671
- ...value2,
672
- // ensure media query test stays on left side (see getMediaQueryTernary)
673
- test: t.logicalExpression("&&", value2.test, test)
674
- };
675
- });
676
- logger.info([
677
- "\u26A0\uFE0F no ternaries?",
678
- property
679
- ].join(" "));
680
- } else
681
- logger.info([
682
- "\u26A0\uFE0F not expression",
683
- property
684
- ].join(" "));
685
- }
686
- if (t.isConditionalExpression(property.value)) {
687
- var [truthy, falsy] = [
688
- t.objectExpression([
689
- t.objectProperty(property.key, property.value.consequent)
690
- ]),
691
- t.objectExpression([
692
- t.objectProperty(property.key, property.value.alternate)
693
- ])
694
- ].map(function(x) {
695
- return attemptEval(x);
696
- });
697
- return [
698
- createTernary({
699
- remove() {
700
- },
632
+ if (ternaries2) return ternaries2.map(function (value2) {
633
+ return {
634
+ ...ternaryPartial,
635
+ ...value2,
636
+ // ensure media query test stays on left side (see getMediaQueryTernary)
637
+ test: t.logicalExpression("&&", value2.test, test)
638
+ };
639
+ });
640
+ logger.info(["\u26A0\uFE0F no ternaries?", property].join(" "));
641
+ } else logger.info(["\u26A0\uFE0F not expression", property].join(" "));
642
+ }
643
+ if (t.isConditionalExpression(property.value)) {
644
+ var [truthy, falsy] = [t.objectExpression([t.objectProperty(property.key, property.value.consequent)]), t.objectExpression([t.objectProperty(property.key, property.value.alternate)])].map(function (x) {
645
+ return attemptEval(x);
646
+ });
647
+ return [createTernary({
648
+ remove() {},
701
649
  ...ternaryPartial,
702
650
  test: t.logicalExpression("&&", test, property.value.test),
703
651
  consequent: truthy,
704
652
  alternate: null
705
- }),
706
- createTernary({
653
+ }), createTernary({
707
654
  ...ternaryPartial,
708
655
  test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
709
656
  consequent: falsy,
710
657
  alternate: null,
711
- remove() {
712
- }
713
- })
714
- ];
715
- }
716
- var obj = t.objectExpression([
717
- t.objectProperty(property.key, property.value)
718
- ]), consequent = attemptEval(obj);
719
- return createTernary({
720
- remove() {
721
- },
722
- ...ternaryPartial,
723
- test,
724
- consequent,
725
- alternate: null
658
+ remove() {}
659
+ })];
660
+ }
661
+ var obj = t.objectExpression([t.objectProperty(property.key, property.value)]),
662
+ consequent = attemptEval(obj);
663
+ return createTernary({
664
+ remove() {},
665
+ ...ternaryPartial,
666
+ test,
667
+ consequent,
668
+ alternate: null
669
+ });
726
670
  });
727
- });
728
- }, mergeToEnd2 = function(obj, key9, val2) {
729
- key9 in obj && delete obj[key9], obj[key9] = val2;
730
- }, normalizeStyleWithoutVariants2 = function(style) {
731
- var res2 = {};
732
- for (var key9 in style)
733
- if (staticConfig.variants && key9 in staticConfig.variants)
734
- mergeToEnd2(res2, key9, style[key9]);
735
- else {
671
+ },
672
+ mergeToEnd2 = function (obj, key9, val2) {
673
+ key9 in obj && delete obj[key9], obj[key9] = val2;
674
+ },
675
+ normalizeStyleWithoutVariants2 = function (style) {
676
+ var res2 = {};
677
+ for (var key9 in style) if (staticConfig.variants && key9 in staticConfig.variants) mergeToEnd2(res2, key9, style[key9]);else {
736
678
  var expanded2 = normalizeStyle({
737
679
  [key9]: style[key9]
738
680
  }, !0);
739
- for (var key12 in expanded2)
740
- mergeToEnd2(res2, key12, expanded2[key12]);
681
+ for (var key12 in expanded2) mergeToEnd2(res2, key12, expanded2[key12]);
741
682
  }
742
- return res2;
743
- }, mergeStyles2 = function(prev2, next) {
744
- for (var key9 in next)
745
- pseudoDescriptors[key9] ? (prev2[key9] = prev2[key9] || {}, Object.assign(prev2[key9], next[key9])) : mergeToEnd2(prev2, key9, next[key9]);
746
- };
747
- var evaluateAttribute = evaluateAttribute2, isStaticObject = isStaticObject2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, mergeToEnd = mergeToEnd2, normalizeStyleWithoutVariants = normalizeStyleWithoutVariants2, mergeStyles = mergeStyles2, { staticConfig } = component, defaultProps = {
748
- ...staticConfig.defaultProps || {}
749
- }, variants = staticConfig.variants || {}, isTextView = staticConfig.isText || !1, _staticConfig_validStyles, validStyles = (_staticConfig_validStyles = 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";
750
- traversePath.get("openingElement").get("attributes").forEach(function(path) {
683
+ return res2;
684
+ },
685
+ mergeStyles2 = function (prev2, next) {
686
+ for (var key9 in next) pseudoDescriptors[key9] ? (prev2[key9] = prev2[key9] || {}, Object.assign(prev2[key9], next[key9])) : mergeToEnd2(prev2, key9, next[key9]);
687
+ };
688
+ var evaluateAttribute = evaluateAttribute2,
689
+ isStaticObject = isStaticObject2,
690
+ createTernariesFromObjectProperties = createTernariesFromObjectProperties2,
691
+ mergeToEnd = mergeToEnd2,
692
+ normalizeStyleWithoutVariants = normalizeStyleWithoutVariants2,
693
+ mergeStyles = mergeStyles2,
694
+ {
695
+ staticConfig
696
+ } = component,
697
+ defaultProps = {
698
+ ...(staticConfig.defaultProps || {})
699
+ },
700
+ variants = staticConfig.variants || {},
701
+ isTextView = staticConfig.isText || !1,
702
+ _staticConfig_validStyles,
703
+ validStyles = (_staticConfig_validStyles = staticConfig?.validStyles) !== null && _staticConfig_validStyles !== void 0 ? _staticConfig_validStyles : {},
704
+ _defaultProps_tag,
705
+ tagName = (_defaultProps_tag = defaultProps.tag) !== null && _defaultProps_tag !== void 0 ? _defaultProps_tag : isTextView ? "span" : "div";
706
+ traversePath.get("openingElement").get("attributes").forEach(function (path) {
751
707
  var attr3 = path.node;
752
708
  if (!t.isJSXSpreadAttribute(attr3) && attr3.name.name === "tag") {
753
709
  var val2 = attr3.value;
@@ -755,68 +711,57 @@ function createExtractor() {
755
711
  }
756
712
  }), shouldPrintDebug === "verbose" && console.info(` Start tag ${tagName}`);
757
713
  var flatNode = getFlattenedNode?.({
758
- isTextView,
759
- tag: tagName
760
- }), inlineProps = /* @__PURE__ */ new Set([
714
+ isTextView,
715
+ tag: tagName
716
+ }),
717
+ inlineProps = /* @__PURE__ */new Set([
761
718
  // adding some always inline props
762
- "dataSet",
763
- ...restProps.inlineProps || [],
764
- ...staticConfig.inlineProps || []
765
- ]), deoptProps = /* @__PURE__ */ new Set([
719
+ "dataSet", ...(restProps.inlineProps || []), ...(staticConfig.inlineProps || [])]),
720
+ deoptProps = /* @__PURE__ */new Set([
766
721
  // always de-opt animation these
767
- "animation",
768
- "animateOnly",
769
- "animatePresence",
770
- "disableOptimization",
771
- ...isTargetingHTML ? [] : [
772
- "pressStyle",
773
- "focusStyle",
774
- "focusVisibleStyle",
775
- "disabledStyle"
776
- ],
722
+ "animation", "animateOnly", "animatePresence", "disableOptimization", ...(isTargetingHTML ? [] : ["pressStyle", "focusStyle", "focusVisibleStyle", "disabledStyle"]),
777
723
  // when using a non-CSS driver, de-opt on enterStyle/exitStyle
778
- ...tamaguiConfig?.animations.isReactNative ? [
779
- "enterStyle",
780
- "exitStyle"
781
- ] : []
782
- ]), inlineWhenUnflattened = /* @__PURE__ */ new Set([
783
- ...staticConfig.inlineWhenUnflattened || []
784
- ]), staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug), attemptEval = evaluateVars ? createEvaluator({
785
- props: propsWithFileInfo,
786
- staticNamespace,
787
- sourcePath,
788
- traversePath,
789
- shouldPrintDebug
790
- }) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
791
- if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse)
792
- return;
724
+ ...(tamaguiConfig?.animations.isReactNative ? ["enterStyle", "exitStyle"] : [])]),
725
+ inlineWhenUnflattened = /* @__PURE__ */new Set([...(staticConfig.inlineWhenUnflattened || [])]),
726
+ staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug),
727
+ attemptEval = evaluateVars ? createEvaluator({
728
+ props: propsWithFileInfo,
729
+ staticNamespace,
730
+ sourcePath,
731
+ traversePath,
732
+ shouldPrintDebug
733
+ }) : evaluateAstNode,
734
+ attemptEvalSafe = createSafeEvaluator(attemptEval);
735
+ if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse) return;
793
736
  tm.mark("jsx-element-flattened", !!shouldPrintDebug);
794
- var attrs = [], shouldDeopt = !1, inlined = /* @__PURE__ */ new Map(), variantValues = /* @__PURE__ */ new Map(), hasSetOptimized = !1, inlineWhenUnflattenedOGVals = {}, propMapperStyleState = {
795
- staticConfig,
796
- usedKeys: {},
797
- classNames: {},
798
- style: {},
799
- theme: defaultTheme,
800
- viewProps: defaultProps,
801
- conf: tamaguiConfig,
802
- props: defaultProps,
803
- componentState,
804
- styleProps: {
805
- ...styleProps,
806
- resolveValues: "auto"
807
- },
808
- debug: shouldPrintDebug
809
- };
810
- if (attrs = traversePath.get("openingElement").get("attributes").flatMap(function(path) {
737
+ var attrs = [],
738
+ shouldDeopt = !1,
739
+ inlined = /* @__PURE__ */new Map(),
740
+ variantValues = /* @__PURE__ */new Map(),
741
+ hasSetOptimized = !1,
742
+ inlineWhenUnflattenedOGVals = {},
743
+ propMapperStyleState = {
744
+ staticConfig,
745
+ usedKeys: {},
746
+ classNames: {},
747
+ style: {},
748
+ theme: defaultTheme,
749
+ viewProps: defaultProps,
750
+ conf: tamaguiConfig,
751
+ props: defaultProps,
752
+ componentState,
753
+ styleProps: {
754
+ ...styleProps,
755
+ resolveValues: "auto"
756
+ },
757
+ debug: shouldPrintDebug
758
+ };
759
+ if (attrs = traversePath.get("openingElement").get("attributes").flatMap(function (path) {
811
760
  try {
812
761
  var res2 = evaluateAttribute2(path);
813
762
  return tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug), res2 || path.remove(), res2;
814
763
  } catch (err) {
815
- if (shouldPrintDebug && (logger.info([
816
- "Recoverable error extracting attribute",
817
- err.message,
818
- shouldPrintDebug === "verbose" ? err.stack : ""
819
- ].join(" ")), shouldPrintDebug === "verbose")) {
764
+ if (shouldPrintDebug && (logger.info(["Recoverable error extracting attribute", err.message, shouldPrintDebug === "verbose" ? err.stack : ""].join(" ")), shouldPrintDebug === "verbose")) {
820
765
  var _path_node;
821
766
  logger.info(`node ${(_path_node = path.node) === null || _path_node === void 0 ? void 0 : _path_node.type}`);
822
767
  }
@@ -825,85 +770,79 @@ function createExtractor() {
825
770
  value: path.node
826
771
  };
827
772
  }
828
- }).flat(4).filter(isPresent), shouldPrintDebug && logger.info([
829
- ` - attrs (before):
830
- `,
831
- logLines(attrs.map(attrStr).join(", "))
832
- ].join(" ")), couldntParse || shouldDeopt) {
833
- shouldPrintDebug && logger.info([
834
- " avoid optimizing:",
835
- {
836
- couldntParse,
837
- shouldDeopt
838
- }
839
- ].join(" ")), node.attributes = ogAttributes;
773
+ }).flat(4).filter(isPresent), shouldPrintDebug && logger.info([` - attrs (before):
774
+ `, logLines(attrs.map(attrStr).join(", "))].join(" ")), couldntParse || shouldDeopt) {
775
+ shouldPrintDebug && logger.info([" avoid optimizing:", {
776
+ couldntParse,
777
+ shouldDeopt
778
+ }].join(" ")), node.attributes = ogAttributes;
840
779
  return;
841
780
  }
842
781
  var parentFn = findTopmostFunction(traversePath);
843
782
  parentFn && modifiedComponents.add(parentFn);
844
- var hasSpread = attrs.some(function(x) {
845
- return x.type === "attr" && t.isJSXSpreadAttribute(x.value);
846
- }), hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every(function(x) {
847
- return x.type === "JSXText";
848
- })), themeVal = inlined.get("theme");
783
+ var hasSpread = attrs.some(function (x) {
784
+ return x.type === "attr" && t.isJSXSpreadAttribute(x.value);
785
+ }),
786
+ hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every(function (x) {
787
+ return x.type === "JSXText";
788
+ })),
789
+ themeVal = inlined.get("theme");
849
790
  platform2 !== "native" && inlined.delete("theme");
850
- for (var _i = 0, _iter = [
851
- ...inlined
852
- ]; _i < _iter.length; _i++) {
853
- var [key] = _iter[_i], _staticConfig_variants, isStaticObjectVariant = ((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0 ? void 0 : _staticConfig_variants[key]) && variantValues.has(key);
791
+ for (var _i = 0, _iter = [...inlined]; _i < _iter.length; _i++) {
792
+ var [key] = _iter[_i],
793
+ _staticConfig_variants,
794
+ isStaticObjectVariant = ((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0 ? void 0 : _staticConfig_variants[key]) && variantValues.has(key);
854
795
  (INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
855
796
  }
856
- 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();
857
- if (themeAccessListeners.add(function(key9) {
858
- disableExtractVariables && (usedThemeKeys.add(key9), shouldFlatten = !1, shouldPrintDebug === "verbose" && logger.info([
859
- " ! accessing theme key, avoid flatten",
860
- key9
861
- ].join(" ")));
797
+ var canFlattenProps = inlined.size === 0,
798
+ shouldFlatten = !!(flatNode && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren)),
799
+ usedThemeKeys = /* @__PURE__ */new Set();
800
+ if (themeAccessListeners.add(function (key9) {
801
+ disableExtractVariables && (usedThemeKeys.add(key9), shouldFlatten = !1, shouldPrintDebug === "verbose" && logger.info([" ! accessing theme key, avoid flatten", key9].join(" ")));
862
802
  }), shouldFlatten) {
863
- var skipMap = !1, defaultStyleAttrs = Object.keys(defaultProps).flatMap(function(key9) {
864
- if (skipMap) return [];
865
- var value2 = defaultProps[key9];
866
- if (key9 === "theme" && !themeVal)
867
- return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", {
803
+ var skipMap = !1,
804
+ defaultStyleAttrs = Object.keys(defaultProps).flatMap(function (key9) {
805
+ if (skipMap) return [];
806
+ var value2 = defaultProps[key9];
807
+ if (key9 === "theme" && !themeVal) return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", {
868
808
  value: t.stringLiteral(value2)
869
809
  })), themeVal = {
870
810
  value: t.stringLiteral(value2)
871
811
  }, [];
872
- if (!isValidStyleKey(key9, staticConfig))
873
- return [];
874
- var name2 = tamaguiConfig?.shorthands[key9] || key9;
875
- if (value2 === void 0) {
876
- logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key9} ${value2}`), shouldDeopt = !0;
877
- return;
878
- }
879
- if (name2[0] === "$" && mediaQueryConfig[name2.slice(1)])
880
- return defaultProps[key9] = void 0, evaluateAttribute2({
881
- node: t.jsxAttribute(t.jsxIdentifier(name2), t.jsxExpressionContainer(t.objectExpression(Object.keys(value2).filter(function(k) {
812
+ if (!isValidStyleKey(key9, staticConfig)) return [];
813
+ var name2 = tamaguiConfig?.shorthands[key9] || key9;
814
+ if (value2 === void 0) {
815
+ logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key9} ${value2}`), shouldDeopt = !0;
816
+ return;
817
+ }
818
+ if (name2[0] === "$" && mediaQueryConfig[name2.slice(1)]) return defaultProps[key9] = void 0, evaluateAttribute2({
819
+ node: t.jsxAttribute(t.jsxIdentifier(name2), t.jsxExpressionContainer(t.objectExpression(Object.keys(value2).filter(function (k) {
882
820
  return typeof value2[k] < "u";
883
- }).map(function(k) {
821
+ }).map(function (k) {
884
822
  return t.objectProperty(t.identifier(k), literalToAst(value2[k]));
885
823
  }))))
886
824
  });
887
- var attr3 = {
888
- type: "style",
889
- name: name2,
890
- value: {
891
- [name2]: value2
892
- }
893
- };
894
- return attr3;
895
- });
896
- skipMap || defaultStyleAttrs.length && (attrs = [
897
- ...defaultStyleAttrs,
898
- ...attrs
899
- ]);
825
+ var attr3 = {
826
+ type: "style",
827
+ name: name2,
828
+ value: {
829
+ [name2]: value2
830
+ }
831
+ };
832
+ return attr3;
833
+ });
834
+ skipMap || defaultStyleAttrs.length && (attrs = [...defaultStyleAttrs, ...attrs]);
900
835
  }
901
836
  var ternaries = [];
902
- attrs = attrs.reduce(function(out, cur2) {
837
+ attrs = attrs.reduce(function (out, cur2) {
903
838
  var next = attrs[attrs.indexOf(cur2) + 1];
904
839
  if (cur2.type === "ternary" && ternaries.push(cur2.value), (!next || next.type !== "ternary") && ternaries.length) {
905
- var normalized = normalizeTernaries(ternaries).map(function(param2) {
906
- var { alternate, consequent, ...rest } = param2;
840
+ var normalized = normalizeTernaries(ternaries).map(function (param2) {
841
+ var {
842
+ alternate,
843
+ consequent,
844
+ ...rest
845
+ } = param2;
907
846
  return {
908
847
  type: "ternary",
909
848
  value: {
@@ -914,10 +853,7 @@ function createExtractor() {
914
853
  };
915
854
  });
916
855
  try {
917
- return [
918
- ...out,
919
- ...normalized
920
- ];
856
+ return [...out, ...normalized];
921
857
  } finally {
922
858
  shouldPrintDebug && logger.info(` normalizeTernaries (${ternaries.length} => ${normalized.length})`), ternaries = [];
923
859
  }
@@ -925,88 +861,58 @@ function createExtractor() {
925
861
  return cur2.type === "ternary" || out.push(cur2), out;
926
862
  }, []).flat();
927
863
  var shouldWrapTheme = shouldFlatten && themeVal;
928
- if (shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([
929
- " - wrapping theme",
930
- themeVal
931
- ].join(" ")), attrs = attrs.filter(function(x) {
864
+ if (shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([" - wrapping theme", themeVal].join(" ")), attrs = attrs.filter(function (x) {
932
865
  return !(x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme");
933
- }), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(t.importDeclaration([
934
- t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))
935
- ], t.stringLiteral("@tamagui/web")))), traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
936
- t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
937
- ]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [
938
- traversePath.node
939
- ]))) : console.warn(`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`)), shouldPrintDebug)
940
- try {
941
- logger.info([
942
- " flatten?",
943
- shouldFlatten,
944
- objToStr({
945
- hasSpread,
946
- shouldDeopt,
947
- canFlattenProps,
948
- shouldWrapTheme,
949
- hasOnlyStringChildren
950
- }),
951
- "inlined",
952
- inlined.size,
953
- [
954
- ...inlined
955
- ]
956
- ].join(" "));
957
- } catch {
958
- }
866
+ }), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/web")))), traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]))) : console.warn(`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`)), shouldPrintDebug) try {
867
+ logger.info([" flatten?", shouldFlatten, objToStr({
868
+ hasSpread,
869
+ shouldDeopt,
870
+ canFlattenProps,
871
+ shouldWrapTheme,
872
+ hasOnlyStringChildren
873
+ }), "inlined", inlined.size, [...inlined]].join(" "));
874
+ } catch {}
959
875
  if (shouldDeopt || !shouldFlatten) {
960
876
  shouldPrintDebug && logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`), node.attributes = ogAttributes;
961
877
  return;
962
878
  }
963
- shouldPrintDebug && logger.info([
964
- ` - attrs (flattened):
965
- `,
966
- logLines(attrs.map(attrStr).join(", "))
967
- ].join(" "));
879
+ shouldPrintDebug && logger.info([` - attrs (flattened):
880
+ `, logLines(attrs.map(attrStr).join(", "))].join(" "));
968
881
  var foundStaticProps = {};
969
882
  for (var key1 in attrs) {
970
883
  var cur = attrs[key1];
971
884
  if (cur.type === "style") {
972
885
  var expanded = normalizeStyleWithoutVariants2(cur.value);
973
- for (var key2 in expanded)
974
- mergeToEnd2(foundStaticProps, key2, expanded[key2]);
886
+ for (var key2 in expanded) mergeToEnd2(foundStaticProps, key2, expanded[key2]);
975
887
  continue;
976
888
  }
977
889
  if (cur.type === "attr") {
978
- if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name))
979
- continue;
980
- var key3 = cur.value.name.name, value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
890
+ if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name)) continue;
891
+ var key3 = cur.value.name.name,
892
+ value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
981
893
  value !== FAILED_EVAL && mergeToEnd2(foundStaticProps, key3, value);
982
894
  }
983
895
  }
984
896
  var completeProps = {};
985
- for (var key4 in defaultProps)
986
- key4 in foundStaticProps || (completeProps[key4] = defaultProps[key4]);
987
- for (var key5 in foundStaticProps)
988
- completeProps[key5] = foundStaticProps[key5];
989
- attrs = attrs.reduce(function(acc, cur2) {
897
+ for (var key4 in defaultProps) key4 in foundStaticProps || (completeProps[key4] = defaultProps[key4]);
898
+ for (var key5 in foundStaticProps) completeProps[key5] = foundStaticProps[key5];
899
+ attrs = attrs.reduce(function (acc, cur2) {
990
900
  if (!cur2) return acc;
991
901
  if (cur2.type === "attr" && !t.isJSXSpreadAttribute(cur2.value) && shouldFlatten) {
992
902
  var name2 = cur2.value.name.name;
993
903
  if (typeof name2 == "string") {
994
- if (name2 === "tag")
995
- return acc;
904
+ if (name2 === "tag") return acc;
996
905
  if (variants[name2] && variantValues.has(name2)) {
997
906
  var styleState = {
998
- ...propMapperStyleState,
999
- props: completeProps
1000
- }, out = Object.fromEntries(propMapper(name2, variantValues.get(name2), styleState) || []);
907
+ ...propMapperStyleState,
908
+ props: completeProps
909
+ },
910
+ out = Object.fromEntries(propMapper(name2, variantValues.get(name2), styleState) || []);
1001
911
  if (out && isTargetingHTML) {
1002
912
  var cn = out.className;
1003
913
  out = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
1004
914
  }
1005
- shouldPrintDebug && logger.info([
1006
- " - expanded variant",
1007
- name2,
1008
- out
1009
- ].join(" "));
915
+ shouldPrintDebug && logger.info([" - expanded variant", name2, out].join(" "));
1010
916
  for (var key9 in out) {
1011
917
  var value2 = out[key9];
1012
918
  isValidStyleKey(key9, staticConfig) ? acc.push({
@@ -1024,121 +930,97 @@ function createExtractor() {
1024
930
  }
1025
931
  }
1026
932
  }
1027
- if (cur2.type !== "style")
1028
- return acc.push(cur2), acc;
1029
- var key12 = Object.keys(cur2.value)[0], value12 = cur2.value[key12], fullKey = tamaguiConfig?.shorthands[key12];
933
+ if (cur2.type !== "style") return acc.push(cur2), acc;
934
+ var key12 = Object.keys(cur2.value)[0],
935
+ value12 = cur2.value[key12],
936
+ fullKey = tamaguiConfig?.shorthands[key12];
1030
937
  return fullKey && (cur2.value = {
1031
938
  [fullKey]: value12
1032
- }, key12 = fullKey), disableExtractVariables && value12[0] === "$" && (usedThemeKeys.has(key12) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([
1033
- ` keeping variable inline: ${key12} =`,
1034
- value12
1035
- ].join(" ")), acc.push({
939
+ }, key12 = fullKey), disableExtractVariables && value12[0] === "$" && (usedThemeKeys.has(key12) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([` keeping variable inline: ${key12} =`, value12].join(" ")), acc.push({
1036
940
  type: "attr",
1037
941
  value: t.jsxAttribute(t.jsxIdentifier(key12), t.jsxExpressionContainer(t.stringLiteral(value12)))
1038
942
  }), acc) : (acc.push(cur2), acc);
1039
- }, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info([
1040
- ` - attrs (expanded):
1041
- `,
1042
- logLines(attrs.map(attrStr).join(", "))
1043
- ].join(" "));
1044
- var prev = null, getProps = function(props) {
1045
- var includeProps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, debugName = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
1046
- if (!props)
1047
- return shouldPrintDebug && logger.info([
1048
- " getProps() no props"
1049
- ].join(" ")), {};
1050
- if (excludeProps?.size)
1051
- for (var key9 in props)
1052
- excludeProps.has(key9) && (shouldPrintDebug && logger.info([
1053
- " delete excluded",
1054
- key9
1055
- ].join(" ")), delete props[key9]);
1056
- try {
1057
- var out = getSplitStyles(props, staticConfig, defaultTheme, "", componentState, {
1058
- ...styleProps,
1059
- noClassNames: !0,
1060
- fallbackProps: completeProps
1061
- }, void 0, void 0, void 0, debugPropValue || shouldPrintDebug, options.experimentalFlattenThemesOnNative), outProps2 = {
1062
- ...includeProps ? out.viewProps : {},
1063
- ...out.style,
1064
- ...out.pseudos
1065
- };
1066
- for (var key12 in outProps2)
1067
- deoptProps.has(key12) && (shouldFlatten = !1);
1068
- return shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
943
+ }, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info([` - attrs (expanded):
944
+ `, logLines(attrs.map(attrStr).join(", "))].join(" "));
945
+ var prev = null,
946
+ getProps = function (props) {
947
+ var includeProps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1,
948
+ debugName = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
949
+ if (!props) return shouldPrintDebug && logger.info([" getProps() no props"].join(" ")), {};
950
+ if (excludeProps?.size) for (var key9 in props) excludeProps.has(key9) && (shouldPrintDebug && logger.info([" delete excluded", key9].join(" ")), delete props[key9]);
951
+ try {
952
+ var out = getSplitStyles(props, staticConfig, defaultTheme, "", componentState, {
953
+ ...styleProps,
954
+ noClassNames: !0,
955
+ fallbackProps: completeProps
956
+ }, void 0, void 0, void 0, debugPropValue || shouldPrintDebug, options.experimentalFlattenThemesOnNative),
957
+ outProps2 = {
958
+ ...(includeProps ? out.viewProps : {}),
959
+ ...out.style,
960
+ ...out.pseudos
961
+ };
962
+ for (var key12 in outProps2) deoptProps.has(key12) && (shouldFlatten = !1);
963
+ return shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
1069
964
  getProps (props in): ${logLines(objToStr(props))}`), logger.info(`
1070
965
  getProps (outProps): ${logLines(objToStr(outProps2))}`)), out.fontFamily && (setPropsToFontFamily(outProps2, out.fontFamily), shouldPrintDebug && logger.info(`
1071
966
  \u{1F4AC} new font fam: ${out.fontFamily}`)), outProps2;
1072
- } catch (err) {
1073
- return logger.info([
1074
- "error",
1075
- err.message,
1076
- err.stack
1077
- ].join(" ")), {};
1078
- }
1079
- };
967
+ } catch (err) {
968
+ return logger.info(["error", err.message, err.stack].join(" ")), {};
969
+ }
970
+ };
1080
971
  shouldFlatten && attrs.unshift({
1081
972
  type: "style",
1082
973
  value: defaultProps
1083
- }), attrs = attrs.reduce(function(acc, cur2) {
974
+ }), attrs = attrs.reduce(function (acc, cur2) {
1084
975
  if (cur2.type === "style") {
1085
- var key9 = Object.keys(cur2.value)[0], value2 = cur2.value[key9], shouldKeepOriginalAttr = (
976
+ var key9 = Object.keys(cur2.value)[0],
977
+ value2 = cur2.value[key9],
978
+ shouldKeepOriginalAttr =
1086
979
  // !isStyleAndAttr[key] &&
1087
- !shouldFlatten && // de-opt if non-style
1088
- !validStyles[key9] && !pseudoDescriptors[key9] && !(key9.startsWith("data-") || key9.startsWith("aria-"))
1089
- );
1090
- if (shouldKeepOriginalAttr)
1091
- return shouldPrintDebug && logger.info([
1092
- " - keeping as non-style",
1093
- key9
1094
- ].join(" ")), prev = cur2, acc.push({
1095
- type: "attr",
1096
- value: t.jsxAttribute(t.jsxIdentifier(key9), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)))
1097
- }), acc.push(cur2), acc;
1098
- if (prev?.type === "style")
1099
- return mergeStyles2(prev.value, cur2.value), acc;
980
+ !shouldFlatten &&
981
+ // de-opt if non-style
982
+ !validStyles[key9] && !pseudoDescriptors[key9] && !(key9.startsWith("data-") || key9.startsWith("aria-"));
983
+ if (shouldKeepOriginalAttr) return shouldPrintDebug && logger.info([" - keeping as non-style", key9].join(" ")), prev = cur2, acc.push({
984
+ type: "attr",
985
+ value: t.jsxAttribute(t.jsxIdentifier(key9), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)))
986
+ }), acc.push(cur2), acc;
987
+ if (prev?.type === "style") return mergeStyles2(prev.value, cur2.value), acc;
1100
988
  }
1101
989
  return cur2.type === "style" && (prev = cur2), acc.push(cur2), acc;
1102
- }, []), shouldPrintDebug && logger.info([
1103
- ` - attrs (combined \u{1F500}):
1104
- `,
1105
- logLines(attrs.map(attrStr).join(", "))
1106
- ].join(" "));
1107
- var getStyleError = null, _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
990
+ }, []), shouldPrintDebug && logger.info([` - attrs (combined \u{1F500}):
991
+ `, logLines(attrs.map(attrStr).join(", "))].join(" "));
992
+ var getStyleError = null,
993
+ _iteratorNormalCompletion2 = !0,
994
+ _didIteratorError2 = !1,
995
+ _iteratorError2 = void 0;
1108
996
  try {
1109
997
  for (var _iterator2 = attrs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
1110
998
  var attr = _step2.value;
1111
999
  try {
1112
1000
  switch (shouldPrintDebug && console.info(` Processing ${attr.type}:`), attr.type) {
1113
- case "ternary": {
1114
- var a = getProps(attr.value.alternate, !1, "ternary.alternate"), c = getProps(attr.value.consequent, !1, "ternary.consequent");
1115
- a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([
1116
- " => tern ",
1117
- attrStr(attr)
1118
- ].join(" "));
1119
- continue;
1120
- }
1121
- case "style": {
1122
- var styles = getProps(attr.value, !1, "style");
1123
- styles && (attr.value = styles), shouldPrintDebug && logger.info([
1124
- " * styles (in)",
1125
- logLines(objToStr(attr.value))
1126
- ].join(" ")), shouldPrintDebug && logger.info([
1127
- " * styles (out)",
1128
- logLines(objToStr(styles))
1129
- ].join(" "));
1130
- continue;
1131
- }
1001
+ case "ternary":
1002
+ {
1003
+ var a = getProps(attr.value.alternate, !1, "ternary.alternate"),
1004
+ c = getProps(attr.value.consequent, !1, "ternary.consequent");
1005
+ a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", attrStr(attr)].join(" "));
1006
+ continue;
1007
+ }
1008
+ case "style":
1009
+ {
1010
+ var styles = getProps(attr.value, !1, "style");
1011
+ styles && (attr.value = styles), shouldPrintDebug && logger.info([" * styles (in)", logLines(objToStr(attr.value))].join(" ")), shouldPrintDebug && logger.info([" * styles (out)", logLines(objToStr(styles))].join(" "));
1012
+ continue;
1013
+ }
1132
1014
  case "attr":
1133
1015
  if (shouldFlatten && t.isJSXAttribute(attr.value)) {
1134
1016
  var key6 = attr.value.name.name;
1135
- if (key6 === "style" || key6 === "className" || key6 === "tag")
1136
- continue;
1017
+ if (key6 === "style" || key6 === "className" || key6 === "tag") continue;
1137
1018
  var value1 = attemptEvalSafe(attr.value.value || t.booleanLiteral(!0));
1138
1019
  if (value1 !== FAILED_EVAL) {
1139
1020
  var outProps = getProps({
1140
- [key6]: value1
1141
- }, !0, `attr.${key6}`), outKey = Object.keys(outProps)[0];
1021
+ [key6]: value1
1022
+ }, !0, `attr.${key6}`),
1023
+ outKey = Object.keys(outProps)[0];
1142
1024
  if (outKey) {
1143
1025
  var outVal = outProps[outKey];
1144
1026
  attr.value = t.jsxAttribute(t.jsxIdentifier(outKey), t.jsxExpressionContainer(typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)));
@@ -1156,43 +1038,32 @@ function createExtractor() {
1156
1038
  try {
1157
1039
  !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
1158
1040
  } finally {
1159
- if (_didIteratorError2)
1160
- throw _iteratorError2;
1041
+ if (_didIteratorError2) throw _iteratorError2;
1161
1042
  }
1162
1043
  }
1163
- if (shouldPrintDebug && logger.info([
1164
- ` - attrs (ternaries/combined):
1165
- `,
1166
- logLines(attrs.map(attrStr).join(", "))
1167
- ].join(" ")), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError)
1168
- return logger.info([
1169
- " \u26A0\uFE0F postprocessing error, deopt",
1170
- getStyleError
1171
- ].join(" ")), node.attributes = ogAttributes, null;
1172
- for (var existingStyleKeys = /* @__PURE__ */ new Set(), i = attrs.length - 1; i >= 0; i--) {
1044
+ if (shouldPrintDebug && logger.info([` - attrs (ternaries/combined):
1045
+ `, logLines(attrs.map(attrStr).join(", "))].join(" ")), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError) return logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" ")), node.attributes = ogAttributes, null;
1046
+ for (var existingStyleKeys = /* @__PURE__ */new Set(), i = attrs.length - 1; i >= 0; i--) {
1173
1047
  var attr1 = attrs[i];
1174
1048
  if (shouldFlatten && attr1.type === "attr" && t.isJSXAttribute(attr1.value) && t.isJSXIdentifier(attr1.value.name)) {
1175
1049
  var name = attr1.value.name.name;
1176
1050
  INLINE_EXTRACTABLE[name] && (attr1.value.name.name = INLINE_EXTRACTABLE[name]);
1177
1051
  }
1178
- if (attr1.type === "style")
1179
- for (var key7 in attr1.value)
1180
- existingStyleKeys.has(key7) ? (shouldPrintDebug && logger.info([
1181
- ` >> delete existing ${key7}`
1182
- ].join(" ")), delete attr1.value[key7]) : existingStyleKeys.add(key7);
1052
+ if (attr1.type === "style") for (var key7 in attr1.value) existingStyleKeys.has(key7) ? (shouldPrintDebug && logger.info([` >> delete existing ${key7}`].join(" ")), delete attr1.value[key7]) : existingStyleKeys.add(key7);
1183
1053
  attr1.type === "dynamic-style" && (existingStyleKeys.has(attr1.name) ? attrs[i] = void 0 : existingStyleKeys.add(attr1.name));
1184
1054
  }
1185
1055
  if (options.experimentalFlattenThemesOnNative && (attrs = attrs.filter(Boolean)), !shouldFlatten && inlineWhenUnflattened.size) {
1186
- var _iteratorNormalCompletion12 = !0, _didIteratorError12 = !1, _iteratorError12 = void 0;
1056
+ var _iteratorNormalCompletion12 = !0,
1057
+ _didIteratorError12 = !1,
1058
+ _iteratorError12 = void 0;
1187
1059
  try {
1188
1060
  for (var _iterator12 = attrs.entries()[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = !0) {
1189
1061
  var [index, attr2] = _step12.value;
1190
1062
  if (attr2.type === "style") {
1191
- for (var key8 in attr2.value)
1192
- if (inlineWhenUnflattened.has(key8)) {
1193
- var val = inlineWhenUnflattenedOGVals[key8];
1194
- val ? (delete attr2.value[key8], attrs.splice(index - 1, 0, val.attr)) : delete attr2.value[key8];
1195
- }
1063
+ for (var key8 in attr2.value) if (inlineWhenUnflattened.has(key8)) {
1064
+ var val = inlineWhenUnflattenedOGVals[key8];
1065
+ val ? (delete attr2.value[key8], attrs.splice(index - 1, 0, val.attr)) : delete attr2.value[key8];
1066
+ }
1196
1067
  }
1197
1068
  }
1198
1069
  } catch (err) {
@@ -1201,36 +1072,25 @@ function createExtractor() {
1201
1072
  try {
1202
1073
  !_iteratorNormalCompletion12 && _iterator12.return != null && _iterator12.return();
1203
1074
  } finally {
1204
- if (_didIteratorError12)
1205
- throw _iteratorError12;
1075
+ if (_didIteratorError12) throw _iteratorError12;
1206
1076
  }
1207
1077
  }
1208
1078
  }
1209
- attrs = attrs.filter(function(x) {
1079
+ attrs = attrs.filter(function (x) {
1210
1080
  return !((x.type === "style" || x.type === "dynamic-style") && Object.keys(x.value).length === 0);
1211
- }), shouldFlatten && (shouldPrintDebug && logger.info([
1212
- " [\u2705] flattening",
1213
- originalNodeName,
1214
- flatNode
1215
- ].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode));
1081
+ }), shouldFlatten && (shouldPrintDebug && logger.info([" [\u2705] flattening", originalNodeName, flatNode].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode));
1216
1082
  var isNativeNotFlat = !shouldFlatten && platform2 === "native";
1217
- if (isNativeNotFlat)
1218
- return shouldPrintDebug && logger.info(`Disabled flattening except for simple cases on native for now: ${JSON.stringify({
1219
- flatNode,
1220
- shouldDeopt,
1221
- canFlattenProps,
1222
- hasSpread,
1223
- "staticConfig.isStyledHOC": staticConfig.isStyledHOC,
1224
- "!staticConfig.isHOC": !staticConfig.isHOC,
1225
- "staticConfig.isReactNative": staticConfig.isReactNative,
1226
- "staticConfig.neverFlatten": staticConfig.neverFlatten
1227
- }, null, 2)}`), node.attributes = ogAttributes, null;
1228
- shouldPrintDebug && (logger.info([
1229
- ` - inlined props (${inlined.size}):`,
1230
- shouldDeopt ? " deopted" : "",
1231
- hasSpread ? " has spread" : "",
1232
- staticConfig.neverFlatten ? "neverFlatten" : ""
1233
- ].join(" ")), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
1083
+ if (isNativeNotFlat) return shouldPrintDebug && logger.info(`Disabled flattening except for simple cases on native for now: ${JSON.stringify({
1084
+ flatNode,
1085
+ shouldDeopt,
1086
+ canFlattenProps,
1087
+ hasSpread,
1088
+ "staticConfig.isStyledHOC": staticConfig.isStyledHOC,
1089
+ "!staticConfig.isHOC": !staticConfig.isHOC,
1090
+ "staticConfig.isReactNative": staticConfig.isReactNative,
1091
+ "staticConfig.neverFlatten": staticConfig.neverFlatten
1092
+ }, null, 2)}`), node.attributes = ogAttributes, null;
1093
+ shouldPrintDebug && (logger.info([` - inlined props (${inlined.size}):`, shouldDeopt ? " deopted" : "", hasSpread ? " has spread" : "", staticConfig.neverFlatten ? "neverFlatten" : ""].join(" ")), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
1234
1094
  ${logLines(attrs.map(attrStr).join(", "))}`)), onExtractTag({
1235
1095
  parserProps: propsWithFileInfo,
1236
1096
  attrs,
@@ -1255,7 +1115,9 @@ function createExtractor() {
1255
1115
  }), tm.mark("jsx-done", !!shouldPrintDebug), modifiedComponents.size) {
1256
1116
  var all = Array.from(modifiedComponents);
1257
1117
  shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
1258
- var _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
1118
+ var _iteratorNormalCompletion1 = !0,
1119
+ _didIteratorError1 = !1,
1120
+ _iteratorError1 = void 0;
1259
1121
  try {
1260
1122
  for (var _iterator1 = all[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
1261
1123
  var comp = _step1.value;
@@ -1267,15 +1129,12 @@ function createExtractor() {
1267
1129
  try {
1268
1130
  !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
1269
1131
  } finally {
1270
- if (_didIteratorError1)
1271
- throw _iteratorError1;
1132
+ if (_didIteratorError1) throw _iteratorError1;
1272
1133
  }
1273
1134
  }
1274
1135
  }
1275
1136
  return tm.done(shouldPrintDebug === "verbose"), res;
1276
1137
  }
1277
1138
  }
1278
- export {
1279
- createExtractor
1280
- };
1281
- //# sourceMappingURL=createExtractor.js.map
1139
+ export { createExtractor };
1140
+ //# sourceMappingURL=createExtractor.native.js.map