@tamagui/static 1.135.4 → 1.135.5

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