@tamagui/static 1.0.0-alpha.4 → 1.0.0-alpha.40

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 (206) hide show
  1. package/dist/cjs/constants.js +43 -0
  2. package/dist/cjs/constants.js.map +7 -0
  3. package/dist/cjs/extractor/accessSafe.js +39 -0
  4. package/dist/cjs/extractor/accessSafe.js.map +7 -0
  5. package/dist/cjs/extractor/babelParse.js +58 -0
  6. package/dist/cjs/extractor/babelParse.js.map +7 -0
  7. package/dist/cjs/extractor/buildClassName.js +68 -0
  8. package/dist/cjs/extractor/buildClassName.js.map +7 -0
  9. package/dist/cjs/extractor/createEvaluator.js +79 -0
  10. package/dist/cjs/extractor/createEvaluator.js.map +7 -0
  11. package/dist/cjs/extractor/createExtractor.js +907 -0
  12. package/dist/cjs/extractor/createExtractor.js.map +7 -0
  13. package/dist/cjs/extractor/ensureImportingConcat.js +52 -0
  14. package/dist/cjs/extractor/ensureImportingConcat.js.map +7 -0
  15. package/dist/cjs/extractor/evaluateAstNode.js +122 -0
  16. package/dist/cjs/extractor/evaluateAstNode.js.map +7 -0
  17. package/dist/cjs/extractor/extractHelpers.js +124 -0
  18. package/dist/cjs/extractor/extractHelpers.js.map +7 -0
  19. package/dist/cjs/extractor/extractMediaStyle.js +193 -0
  20. package/dist/cjs/extractor/extractMediaStyle.js.map +7 -0
  21. package/dist/cjs/extractor/extractToClassNames.js +284 -0
  22. package/dist/cjs/extractor/extractToClassNames.js.map +7 -0
  23. package/dist/cjs/extractor/findTopmostFunction.js +46 -0
  24. package/dist/cjs/extractor/findTopmostFunction.js.map +7 -0
  25. package/dist/cjs/extractor/generatedUid.js +56 -0
  26. package/dist/cjs/extractor/generatedUid.js.map +7 -0
  27. package/dist/cjs/extractor/getPropValueFromAttributes.js +77 -0
  28. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +7 -0
  29. package/dist/cjs/extractor/getSourceModule.js +97 -0
  30. package/dist/cjs/extractor/getSourceModule.js.map +7 -0
  31. package/dist/cjs/extractor/getStaticBindingsForScope.js +156 -0
  32. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +7 -0
  33. package/dist/cjs/extractor/hoistClassNames.js +72 -0
  34. package/dist/cjs/extractor/hoistClassNames.js.map +7 -0
  35. package/dist/cjs/extractor/literalToAst.js +62 -0
  36. package/dist/cjs/extractor/literalToAst.js.map +7 -0
  37. package/dist/cjs/extractor/loadTamagui.js +64 -0
  38. package/dist/cjs/extractor/loadTamagui.js.map +7 -0
  39. package/dist/cjs/extractor/logLines.js +40 -0
  40. package/dist/cjs/extractor/logLines.js.map +7 -0
  41. package/dist/cjs/extractor/normalizeTernaries.js +108 -0
  42. package/dist/cjs/extractor/normalizeTernaries.js.map +7 -0
  43. package/dist/cjs/extractor/removeUnusedHooks.js +107 -0
  44. package/dist/cjs/extractor/removeUnusedHooks.js.map +7 -0
  45. package/dist/cjs/index.js +38 -0
  46. package/dist/cjs/index.js.map +7 -0
  47. package/dist/cjs/patchReactNativeWeb.js +135 -0
  48. package/dist/cjs/patchReactNativeWeb.js.map +7 -0
  49. package/dist/cjs/types.js +21 -0
  50. package/dist/cjs/types.js.map +7 -0
  51. package/dist/{constants.js → esm/constants.js} +4 -0
  52. package/dist/{constants.js.map → esm/constants.js.map} +3 -3
  53. package/dist/{extractor → esm/extractor}/accessSafe.js +0 -0
  54. package/dist/{extractor → esm/extractor}/accessSafe.js.map +1 -1
  55. package/dist/{extractor → esm/extractor}/babelParse.js +0 -0
  56. package/dist/{extractor → esm/extractor}/babelParse.js.map +1 -1
  57. package/dist/{extractor → esm/extractor}/buildClassName.js +0 -0
  58. package/dist/{extractor → esm/extractor}/buildClassName.js.map +1 -1
  59. package/dist/{extractor → esm/extractor}/createEvaluator.js +1 -1
  60. package/dist/esm/extractor/createEvaluator.js.map +7 -0
  61. package/dist/{extractor → esm/extractor}/createExtractor.js +113 -73
  62. package/dist/esm/extractor/createExtractor.js.map +7 -0
  63. package/dist/{extractor → esm/extractor}/ensureImportingConcat.js +1 -1
  64. package/dist/esm/extractor/ensureImportingConcat.js.map +7 -0
  65. package/dist/{extractor → esm/extractor}/evaluateAstNode.js +0 -0
  66. package/dist/{extractor → esm/extractor}/evaluateAstNode.js.map +1 -1
  67. package/dist/{extractor → esm/extractor}/extractHelpers.js +6 -4
  68. package/dist/{extractor → esm/extractor}/extractHelpers.js.map +3 -3
  69. package/dist/{extractor → esm/extractor}/extractMediaStyle.js +3 -2
  70. package/dist/{extractor → esm/extractor}/extractMediaStyle.js.map +2 -2
  71. package/dist/{extractor → esm/extractor}/extractToClassNames.js +27 -29
  72. package/dist/esm/extractor/extractToClassNames.js.map +7 -0
  73. package/dist/{extractor → esm/extractor}/findTopmostFunction.js +0 -0
  74. package/dist/{extractor → esm/extractor}/findTopmostFunction.js.map +1 -1
  75. package/dist/{extractor → esm/extractor}/generatedUid.js +0 -0
  76. package/dist/{extractor → esm/extractor}/generatedUid.js.map +1 -1
  77. package/dist/{extractor → esm/extractor}/getPropValueFromAttributes.js +0 -0
  78. package/dist/{extractor → esm/extractor}/getPropValueFromAttributes.js.map +1 -1
  79. package/dist/{extractor → esm/extractor}/getSourceModule.js +0 -0
  80. package/dist/{extractor → esm/extractor}/getSourceModule.js.map +1 -1
  81. package/dist/{extractor → esm/extractor}/getStaticBindingsForScope.js +0 -0
  82. package/dist/{extractor → esm/extractor}/getStaticBindingsForScope.js.map +1 -1
  83. package/dist/{extractor → esm/extractor}/hoistClassNames.js +0 -0
  84. package/dist/{extractor → esm/extractor}/hoistClassNames.js.map +1 -1
  85. package/dist/{extractor → esm/extractor}/literalToAst.js +0 -0
  86. package/dist/{extractor → esm/extractor}/literalToAst.js.map +1 -1
  87. package/dist/{extractor → esm/extractor}/loadTamagui.js +0 -0
  88. package/dist/{extractor → esm/extractor}/loadTamagui.js.map +3 -3
  89. package/dist/esm/extractor/logLines.js +17 -0
  90. package/dist/esm/extractor/logLines.js.map +7 -0
  91. package/dist/{extractor → esm/extractor}/normalizeTernaries.js +3 -2
  92. package/dist/{extractor → esm/extractor}/normalizeTernaries.js.map +2 -2
  93. package/dist/{extractor → esm/extractor}/removeUnusedHooks.js +5 -3
  94. package/dist/{extractor → esm/extractor}/removeUnusedHooks.js.map +2 -2
  95. package/dist/{index.js → esm/index.js} +0 -0
  96. package/dist/{index.js.map → esm/index.js.map} +1 -1
  97. package/dist/{patchReactNativeWeb.js → esm/patchReactNativeWeb.js} +18 -3
  98. package/dist/esm/patchReactNativeWeb.js.map +7 -0
  99. package/dist/{types.js → esm/types.js} +0 -0
  100. package/dist/{types.js.map → esm/types.js.map} +0 -0
  101. package/dist/jsx/constants.js +13 -0
  102. package/dist/jsx/extractor/accessSafe.js +10 -0
  103. package/dist/jsx/extractor/babelParse.js +29 -0
  104. package/dist/jsx/extractor/buildClassName.js +39 -0
  105. package/dist/jsx/extractor/createEvaluator.js +50 -0
  106. package/dist/jsx/extractor/createExtractor.js +844 -0
  107. package/dist/jsx/extractor/ensureImportingConcat.js +23 -0
  108. package/dist/jsx/extractor/evaluateAstNode.js +93 -0
  109. package/dist/jsx/extractor/extractHelpers.js +95 -0
  110. package/dist/jsx/extractor/extractMediaStyle.js +151 -0
  111. package/dist/jsx/extractor/extractToClassNames.js +240 -0
  112. package/dist/jsx/extractor/findTopmostFunction.js +22 -0
  113. package/dist/jsx/extractor/generatedUid.js +27 -0
  114. package/dist/jsx/extractor/getPropValueFromAttributes.js +48 -0
  115. package/dist/jsx/extractor/getSourceModule.js +68 -0
  116. package/dist/jsx/extractor/getStaticBindingsForScope.js +127 -0
  117. package/dist/jsx/extractor/hoistClassNames.js +43 -0
  118. package/dist/jsx/extractor/literalToAst.js +33 -0
  119. package/dist/jsx/extractor/loadTamagui.js +40 -0
  120. package/dist/jsx/extractor/logLines.js +16 -0
  121. package/dist/jsx/extractor/normalizeTernaries.js +52 -0
  122. package/dist/jsx/extractor/removeUnusedHooks.js +79 -0
  123. package/dist/jsx/index.js +13 -0
  124. package/{src/patchReactNativeWeb.ts → dist/jsx/patchReactNativeWeb.js} +44 -45
  125. package/dist/jsx/types.js +0 -0
  126. package/package.json +20 -17
  127. package/types/constants.d.ts +6 -0
  128. package/types/constants.d.ts.map +1 -0
  129. package/types/extractor/accessSafe.d.ts +3 -0
  130. package/types/extractor/accessSafe.d.ts.map +1 -0
  131. package/types/extractor/babelParse.d.ts +5 -0
  132. package/types/extractor/babelParse.d.ts.map +1 -0
  133. package/types/extractor/buildClassName.d.ts +4 -0
  134. package/types/extractor/buildClassName.d.ts.map +1 -0
  135. package/types/extractor/createEvaluator.d.ts +12 -0
  136. package/types/extractor/createEvaluator.d.ts.map +1 -0
  137. package/types/extractor/createExtractor.d.ts +33 -0
  138. package/types/extractor/createExtractor.d.ts.map +1 -0
  139. package/types/extractor/ensureImportingConcat.d.ts +4 -0
  140. package/types/extractor/ensureImportingConcat.d.ts.map +1 -0
  141. package/types/extractor/evaluateAstNode.d.ts +3 -0
  142. package/types/extractor/evaluateAstNode.d.ts.map +1 -0
  143. package/types/extractor/extractHelpers.d.ts +12 -0
  144. package/types/extractor/extractHelpers.d.ts.map +1 -0
  145. package/types/extractor/extractMediaStyle.d.ts +10 -0
  146. package/types/extractor/extractMediaStyle.d.ts.map +1 -0
  147. package/types/extractor/extractToClassNames.d.ts +21 -0
  148. package/types/extractor/extractToClassNames.d.ts.map +1 -0
  149. package/types/extractor/findTopmostFunction.d.ts +4 -0
  150. package/types/extractor/findTopmostFunction.d.ts.map +1 -0
  151. package/types/extractor/generatedUid.d.ts +5 -0
  152. package/types/extractor/generatedUid.d.ts.map +1 -0
  153. package/types/extractor/getPropValueFromAttributes.d.ts +3 -0
  154. package/types/extractor/getPropValueFromAttributes.d.ts.map +1 -0
  155. package/types/extractor/getSourceModule.d.ts +16 -0
  156. package/types/extractor/getSourceModule.d.ts.map +1 -0
  157. package/types/extractor/getStaticBindingsForScope.d.ts +4 -0
  158. package/types/extractor/getStaticBindingsForScope.d.ts.map +1 -0
  159. package/types/extractor/hoistClassNames.d.ts +6 -0
  160. package/types/extractor/hoistClassNames.d.ts.map +1 -0
  161. package/types/extractor/literalToAst.d.ts +3 -0
  162. package/types/extractor/literalToAst.d.ts.map +1 -0
  163. package/types/extractor/loadTamagui.d.ts +9 -0
  164. package/types/extractor/loadTamagui.d.ts.map +1 -0
  165. package/types/extractor/logLines.d.ts +2 -0
  166. package/types/extractor/logLines.d.ts.map +1 -0
  167. package/types/extractor/normalizeTernaries.d.ts +3 -0
  168. package/types/extractor/normalizeTernaries.d.ts.map +1 -0
  169. package/types/extractor/removeUnusedHooks.d.ts +3 -0
  170. package/types/extractor/removeUnusedHooks.d.ts.map +1 -0
  171. package/types/index.d.ts +8 -0
  172. package/types/index.d.ts.map +1 -0
  173. package/types/patchReactNativeWeb.d.ts +2 -0
  174. package/types/patchReactNativeWeb.d.ts.map +1 -0
  175. package/types/types.d.ts +79 -0
  176. package/types/types.d.ts.map +1 -0
  177. package/dist/extractor/createEvaluator.js.map +0 -7
  178. package/dist/extractor/createExtractor.js.map +0 -7
  179. package/dist/extractor/ensureImportingConcat.js.map +0 -7
  180. package/dist/extractor/extractToClassNames.js.map +0 -7
  181. package/dist/index.cjs +0 -2085
  182. package/dist/index.cjs.map +0 -7
  183. package/dist/patchReactNativeWeb.js.map +0 -7
  184. package/src/constants.ts +0 -10
  185. package/src/extractor/accessSafe.ts +0 -18
  186. package/src/extractor/babelParse.ts +0 -27
  187. package/src/extractor/buildClassName.ts +0 -61
  188. package/src/extractor/createEvaluator.ts +0 -68
  189. package/src/extractor/createExtractor.ts +0 -1116
  190. package/src/extractor/ensureImportingConcat.ts +0 -33
  191. package/src/extractor/evaluateAstNode.ts +0 -121
  192. package/src/extractor/extractHelpers.ts +0 -102
  193. package/src/extractor/extractMediaStyle.ts +0 -191
  194. package/src/extractor/extractToClassNames.ts +0 -337
  195. package/src/extractor/findTopmostFunction.ts +0 -22
  196. package/src/extractor/generatedUid.ts +0 -43
  197. package/src/extractor/getPropValueFromAttributes.ts +0 -92
  198. package/src/extractor/getSourceModule.ts +0 -101
  199. package/src/extractor/getStaticBindingsForScope.ts +0 -173
  200. package/src/extractor/hoistClassNames.ts +0 -45
  201. package/src/extractor/literalToAst.ts +0 -32
  202. package/src/extractor/loadTamagui.ts +0 -61
  203. package/src/extractor/normalizeTernaries.ts +0 -60
  204. package/src/extractor/removeUnusedHooks.ts +0 -76
  205. package/src/index.ts +0 -9
  206. package/src/types.ts +0 -80
@@ -0,0 +1,844 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import traverse from "@babel/traverse";
4
+ import * as t from "@babel/types";
5
+ import { mediaQueryConfig, postProcessStyles, pseudos } from "@tamagui/core-node";
6
+ import { stylePropsTransform } from "@tamagui/helpers";
7
+ import { difference, pick } from "lodash";
8
+ import { FAILED_EVAL } from "../constants";
9
+ import { createEvaluator, createSafeEvaluator } from "./createEvaluator";
10
+ import { evaluateAstNode } from "./evaluateAstNode";
11
+ import { attrStr, findComponentName, isInsideTamagui, isPresent, objToStr } from "./extractHelpers";
12
+ import { findTopmostFunction } from "./findTopmostFunction";
13
+ import { getStaticBindingsForScope } from "./getStaticBindingsForScope";
14
+ import { literalToAst } from "./literalToAst";
15
+ import { loadTamagui } from "./loadTamagui";
16
+ import { logLines } from "./logLines";
17
+ import { normalizeTernaries } from "./normalizeTernaries";
18
+ import { removeUnusedHooks } from "./removeUnusedHooks";
19
+ const UNTOUCHED_PROPS = {
20
+ key: true,
21
+ style: true,
22
+ className: true
23
+ };
24
+ const isAttr = /* @__PURE__ */ __name((x) => x.type === "attr", "isAttr");
25
+ const validHooks = {
26
+ useMedia: true,
27
+ useTheme: true
28
+ };
29
+ const createTernary = /* @__PURE__ */ __name((x) => x, "createTernary");
30
+ function createExtractor() {
31
+ const shouldAddDebugProp = !process.env.npm_package_dependencies_next && process.env.TAMAGUI_TARGET !== "native" && process.env.IDENTIFY_TAGS !== "false" && (process.env.NODE_ENV === "development" || process.env.DEBUG || process.env.IDENTIFY_TAGS);
32
+ require("esbuild-register/dist/node").register({
33
+ target: "es2019",
34
+ format: "cjs"
35
+ });
36
+ let loadedTamaguiConfig;
37
+ let hasLogged = false;
38
+ return {
39
+ getTamagui() {
40
+ return loadedTamaguiConfig;
41
+ },
42
+ parse: (fileOrPath, {
43
+ config = "tamagui.config.ts",
44
+ importsWhitelist = ["constants.js"],
45
+ evaluateVars = true,
46
+ shouldPrintDebug = false,
47
+ sourcePath = "",
48
+ onExtractTag,
49
+ getFlattenedNode,
50
+ disableExtraction,
51
+ disableExtractInlineMedia,
52
+ disableExtractVariables,
53
+ disableDebugAttr,
54
+ ...props
55
+ }) => {
56
+ if (sourcePath === "") {
57
+ throw new Error(`Must provide a source file name`);
58
+ }
59
+ if (!Array.isArray(props.components)) {
60
+ throw new Error(`Must provide components array with list of Tamagui component modules`);
61
+ }
62
+ const { components, tamaguiConfig } = loadTamagui({
63
+ config,
64
+ components: props.components || ["tamagui"]
65
+ });
66
+ loadedTamaguiConfig = tamaguiConfig;
67
+ const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]];
68
+ const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
69
+ const isInternalImport = /* @__PURE__ */ __name((importStr) => {
70
+ return isInsideTamagui(sourcePath) && importStr[0] === ".";
71
+ }, "isInternalImport");
72
+ const validComponents = Object.keys(components).filter((key) => {
73
+ var _a;
74
+ return key[0].toUpperCase() === key[0] && !!((_a = components[key]) == null ? void 0 : _a.staticConfig);
75
+ }).reduce((obj, name) => {
76
+ obj[name] = components[name];
77
+ return obj;
78
+ }, {});
79
+ let doesUseValidImport = false;
80
+ for (const bodyPath of body) {
81
+ if (bodyPath.type !== "ImportDeclaration")
82
+ continue;
83
+ const node = "node" in bodyPath ? bodyPath.node : bodyPath;
84
+ const from = node.source.value;
85
+ if (props.components.includes(from) || isInternalImport(from)) {
86
+ if (node.specifiers.some((specifier) => {
87
+ const name = specifier.local.name;
88
+ return validComponents[name] || validHooks[name];
89
+ })) {
90
+ doesUseValidImport = true;
91
+ break;
92
+ }
93
+ }
94
+ }
95
+ if (shouldPrintDebug) {
96
+ console.log(sourcePath, { doesUseValidImport });
97
+ }
98
+ if (!doesUseValidImport) {
99
+ return null;
100
+ }
101
+ let couldntParse = false;
102
+ const modifiedComponents = /* @__PURE__ */ new Set();
103
+ const bindingCache = {};
104
+ const callTraverse = /* @__PURE__ */ __name((a) => {
105
+ return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
106
+ }, "callTraverse");
107
+ let programPath;
108
+ const res = {
109
+ flattened: 0,
110
+ optimized: 0,
111
+ modified: 0
112
+ };
113
+ callTraverse({
114
+ Program: {
115
+ enter(path) {
116
+ programPath = path;
117
+ }
118
+ },
119
+ JSXElement(traversePath) {
120
+ var _a, _b, _c, _d, _e, _f, _g;
121
+ const node = traversePath.node.openingElement;
122
+ const ogAttributes = node.attributes;
123
+ const componentName = findComponentName(traversePath.scope);
124
+ const closingElement = traversePath.node.closingElement;
125
+ if (t.isJSXMemberExpression(closingElement == null ? void 0 : closingElement.name) || !t.isJSXIdentifier(node.name)) {
126
+ return;
127
+ }
128
+ const binding = traversePath.scope.getBinding(node.name.name);
129
+ if (binding) {
130
+ if (!t.isImportDeclaration(binding.path.parent)) {
131
+ return;
132
+ }
133
+ const source = binding.path.parent.source;
134
+ if (!props.components.includes(source.value) && !isInternalImport(source.value)) {
135
+ return;
136
+ }
137
+ if (!validComponents[binding.identifier.name]) {
138
+ return;
139
+ }
140
+ }
141
+ const component = validComponents[node.name.name];
142
+ if (!component || !component.staticConfig) {
143
+ return;
144
+ }
145
+ const originalNodeName = node.name.name;
146
+ if (shouldPrintDebug) {
147
+ console.log(`
148
+ <${originalNodeName} />`);
149
+ }
150
+ const filePath = sourcePath.replace(process.cwd(), ".");
151
+ const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
152
+ if (shouldAddDebugProp && !disableDebugAttr) {
153
+ const preName = componentName ? `${componentName}:` : "";
154
+ res.modified++;
155
+ node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(` ${preName}${node.name.name} ${filePath.replace("./", "")}:${lineNumbers} `)));
156
+ }
157
+ if (disableExtraction) {
158
+ if (!hasLogged) {
159
+ console.log("\u{1F95A} Tamagui disableExtraction set: no CSS or optimizations will be run");
160
+ hasLogged = true;
161
+ }
162
+ return;
163
+ }
164
+ const { staticConfig } = component;
165
+ const isTextView = staticConfig.isText || false;
166
+ const validStyles = (_a = staticConfig == null ? void 0 : staticConfig.validStyles) != null ? _a : {};
167
+ let tagName = (_c = (_b = staticConfig.defaultProps) == null ? void 0 : _b.tag) != null ? _c : isTextView ? "span" : "div";
168
+ traversePath.get("openingElement").get("attributes").forEach((path) => {
169
+ const attr = path.node;
170
+ if (t.isJSXSpreadAttribute(attr))
171
+ return;
172
+ if (attr.name.name !== "tag")
173
+ return;
174
+ const val = attr.value;
175
+ if (!t.isStringLiteral(val))
176
+ return;
177
+ tagName = val.value;
178
+ });
179
+ const flatNode = getFlattenedNode({ isTextView, tag: tagName });
180
+ const deoptProps = /* @__PURE__ */ new Set([
181
+ ...(_d = props.deoptProps) != null ? _d : [],
182
+ ...(_e = staticConfig.deoptProps) != null ? _e : []
183
+ ]);
184
+ const excludeProps = new Set((_f = props.excludeProps) != null ? _f : []);
185
+ const isExcludedProp = /* @__PURE__ */ __name((name) => {
186
+ const res2 = excludeProps.has(name);
187
+ if (res2 && shouldPrintDebug)
188
+ console.log(` excluding ${name}`);
189
+ return res2;
190
+ }, "isExcludedProp");
191
+ const isDeoptedProp = /* @__PURE__ */ __name((name) => {
192
+ const res2 = deoptProps.has(name);
193
+ if (res2 && shouldPrintDebug)
194
+ console.log(` deopting ${name}`);
195
+ return res2;
196
+ }, "isDeoptedProp");
197
+ const staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
198
+ const attemptEval = !evaluateVars ? evaluateAstNode : createEvaluator({
199
+ tamaguiConfig,
200
+ staticNamespace,
201
+ sourcePath,
202
+ traversePath,
203
+ shouldPrintDebug
204
+ });
205
+ const attemptEvalSafe = createSafeEvaluator(attemptEval);
206
+ if (shouldPrintDebug) {
207
+ console.log(" staticNamespace", Object.keys(staticNamespace).join(", "));
208
+ }
209
+ const hasDeopt = /* @__PURE__ */ __name((obj) => {
210
+ return Object.keys(obj).some(isDeoptedProp);
211
+ }, "hasDeopt");
212
+ const flattenedAttrs = [];
213
+ traversePath.get("openingElement").get("attributes").forEach((path) => {
214
+ const attr = path.node;
215
+ if (!t.isJSXSpreadAttribute(attr)) {
216
+ flattenedAttrs.push(attr);
217
+ return;
218
+ }
219
+ let arg;
220
+ try {
221
+ arg = attemptEval(attr.argument);
222
+ } catch (e) {
223
+ if (shouldPrintDebug) {
224
+ console.log(" couldnt parse spread", e.message);
225
+ }
226
+ flattenedAttrs.push(attr);
227
+ return;
228
+ }
229
+ if (typeof arg !== "undefined") {
230
+ try {
231
+ if (typeof arg !== "object" || arg == null) {
232
+ if (shouldPrintDebug) {
233
+ console.log(" non object or null arg", arg);
234
+ }
235
+ flattenedAttrs.push(attr);
236
+ } else {
237
+ for (const k in arg) {
238
+ const value = arg[k];
239
+ if (!value && typeof value === "object") {
240
+ console.log("shouldnt we handle this?", k, value, arg);
241
+ continue;
242
+ }
243
+ flattenedAttrs.push(t.jsxAttribute(t.jsxIdentifier(k), t.jsxExpressionContainer(literalToAst(value))));
244
+ }
245
+ }
246
+ } catch (err) {
247
+ console.warn("cant parse spread, caught err", err);
248
+ couldntParse = true;
249
+ }
250
+ }
251
+ });
252
+ if (couldntParse) {
253
+ return;
254
+ }
255
+ node.attributes = flattenedAttrs;
256
+ if (staticConfig.defaultProps) {
257
+ for (const key in staticConfig.defaultProps) {
258
+ const serialize = require("babel-literal-to-ast");
259
+ const val = staticConfig.defaultProps[key];
260
+ node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier(key), typeof val === "string" ? t.stringLiteral(val) : t.jsxExpressionContainer(serialize(val))));
261
+ }
262
+ }
263
+ let attrs = [];
264
+ let shouldDeopt = false;
265
+ let inlinePropCount = 0;
266
+ let isFlattened = false;
267
+ attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
268
+ try {
269
+ const res2 = evaluateAttribute(path);
270
+ if (!res2) {
271
+ path.remove();
272
+ }
273
+ return res2;
274
+ } catch (err) {
275
+ console.log("Error extracting attribute", err.message, err.stack);
276
+ console.log("node", path.node);
277
+ return {
278
+ type: "attr",
279
+ value: path.node
280
+ };
281
+ }
282
+ }).flat(4).filter(isPresent);
283
+ if (shouldPrintDebug) {
284
+ console.log(" - attrs (before):\n", logLines(attrs.map(attrStr).join(", ")));
285
+ }
286
+ function isStaticAttributeName(name) {
287
+ var _a2, _b2;
288
+ return !!(!!validStyles[name] || ((_a2 = staticConfig.validPropsExtra) == null ? void 0 : _a2[name]) || !!pseudos[name] || ((_b2 = staticConfig.variants) == null ? void 0 : _b2[name]) || tamaguiConfig.shorthands[name] || (name[0] === "$" ? !!mediaQueryConfig[name.slice(1)] : false));
289
+ }
290
+ __name(isStaticAttributeName, "isStaticAttributeName");
291
+ function isExtractable(obj) {
292
+ return t.isObjectExpression(obj) && obj.properties.every((prop) => {
293
+ if (!t.isObjectProperty(prop)) {
294
+ console.log("not object prop", prop);
295
+ return false;
296
+ }
297
+ const propName = prop.key["name"];
298
+ if (!isStaticAttributeName(propName) && propName !== "tag") {
299
+ if (shouldPrintDebug) {
300
+ console.log(" not a valid style prop!", propName);
301
+ }
302
+ return false;
303
+ }
304
+ return true;
305
+ });
306
+ }
307
+ __name(isExtractable, "isExtractable");
308
+ function createTernariesFromObjectProperties(test, side, ternaryPartial = {}) {
309
+ if (!side) {
310
+ return null;
311
+ }
312
+ if (!isExtractable(side)) {
313
+ throw new Error("not extractable");
314
+ }
315
+ return side.properties.flatMap((property) => {
316
+ if (!t.isObjectProperty(property)) {
317
+ throw new Error("expected object property");
318
+ }
319
+ if (t.isConditionalExpression(property.value)) {
320
+ const [truthy, falsy] = [
321
+ t.objectExpression([t.objectProperty(property.key, property.value.consequent)]),
322
+ t.objectExpression([t.objectProperty(property.key, property.value.alternate)])
323
+ ].map((x) => attemptEval(x));
324
+ return [
325
+ createTernary({
326
+ remove() {
327
+ },
328
+ ...ternaryPartial,
329
+ test: t.logicalExpression("&&", test, property.value.test),
330
+ consequent: truthy,
331
+ alternate: null
332
+ }),
333
+ createTernary({
334
+ ...ternaryPartial,
335
+ test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
336
+ consequent: falsy,
337
+ alternate: null,
338
+ remove() {
339
+ }
340
+ })
341
+ ];
342
+ }
343
+ const obj = t.objectExpression([t.objectProperty(property.key, property.value)]);
344
+ const consequent = attemptEval(obj);
345
+ return createTernary({
346
+ remove() {
347
+ },
348
+ ...ternaryPartial,
349
+ test,
350
+ consequent,
351
+ alternate: null
352
+ });
353
+ });
354
+ }
355
+ __name(createTernariesFromObjectProperties, "createTernariesFromObjectProperties");
356
+ function evaluateAttribute(path) {
357
+ const attribute = path.node;
358
+ const attr = { type: "attr", value: attribute };
359
+ if (t.isJSXSpreadAttribute(attribute)) {
360
+ const arg = attribute.argument;
361
+ const conditional = t.isConditionalExpression(arg) ? [arg.test, arg.consequent, arg.alternate] : t.isLogicalExpression(arg) && arg.operator === "&&" ? [arg.left, arg.right, null] : null;
362
+ if (conditional) {
363
+ const [test, alt, cons] = conditional;
364
+ if (!test)
365
+ throw new Error(`no test`);
366
+ if ([alt, cons].some((side) => side && !isExtractable(side))) {
367
+ if (shouldPrintDebug) {
368
+ console.log("not extractable", alt, cons);
369
+ }
370
+ return attr;
371
+ }
372
+ return [
373
+ ...createTernariesFromObjectProperties(test, alt) || [],
374
+ ...cons && createTernariesFromObjectProperties(t.unaryExpression("!", test), cons) || []
375
+ ].map((ternary) => ({
376
+ type: "ternary",
377
+ value: ternary
378
+ }));
379
+ }
380
+ }
381
+ if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name !== "string") {
382
+ inlinePropCount++;
383
+ return attr;
384
+ }
385
+ const name = attribute.name.name;
386
+ if (isExcludedProp(name)) {
387
+ return null;
388
+ }
389
+ if (isDeoptedProp(name)) {
390
+ if (shouldPrintDebug) {
391
+ console.log(" ! inlining, deopt prop", name);
392
+ }
393
+ inlinePropCount++;
394
+ return attr;
395
+ }
396
+ if (UNTOUCHED_PROPS[name]) {
397
+ return attr;
398
+ }
399
+ if (name[0] === "$" && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
400
+ if (disableExtractInlineMedia) {
401
+ return attr;
402
+ }
403
+ const shortname = name.slice(1);
404
+ if (mediaQueryConfig[shortname]) {
405
+ const expression = attribute.value.expression;
406
+ if (!t.isJSXEmptyExpression(expression)) {
407
+ const ternaries2 = createTernariesFromObjectProperties(t.stringLiteral(shortname), expression, {
408
+ inlineMediaQuery: shortname
409
+ });
410
+ if (ternaries2) {
411
+ return ternaries2.map((value2) => ({
412
+ type: "ternary",
413
+ value: value2
414
+ }));
415
+ }
416
+ }
417
+ }
418
+ }
419
+ const [value, valuePath] = (() => {
420
+ if (t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
421
+ return [attribute.value.expression, path.get("value")];
422
+ } else {
423
+ return [attribute.value, path.get("value")];
424
+ }
425
+ })();
426
+ const remove = /* @__PURE__ */ __name(() => {
427
+ Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
428
+ }, "remove");
429
+ if (name === "ref") {
430
+ if (shouldPrintDebug) {
431
+ console.log(" ! inlining, ref", name);
432
+ }
433
+ inlinePropCount++;
434
+ return attr;
435
+ }
436
+ if (name === "tag") {
437
+ return {
438
+ type: "attr",
439
+ value: path.node
440
+ };
441
+ }
442
+ if (disableExtractVariables) {
443
+ if (value) {
444
+ if (value.type === "StringLiteral" && value.value[0] === "$") {
445
+ if (shouldPrintDebug) {
446
+ console.log(" native, disable extract var", value.value);
447
+ }
448
+ inlinePropCount++;
449
+ return attr;
450
+ }
451
+ }
452
+ }
453
+ const styleValue = attemptEvalSafe(value);
454
+ if (!isStaticAttributeName(name)) {
455
+ let keys = [name];
456
+ if (staticConfig.propMapper) {
457
+ const out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps);
458
+ if (out) {
459
+ keys = Object.keys(out);
460
+ }
461
+ }
462
+ if (keys.some((k) => !isStaticAttributeName(k) && k !== "tag")) {
463
+ if (shouldPrintDebug) {
464
+ console.log(" ! inlining, not static attribute name", name);
465
+ }
466
+ inlinePropCount++;
467
+ return attr;
468
+ }
469
+ }
470
+ if (styleValue !== FAILED_EVAL) {
471
+ return {
472
+ type: "style",
473
+ value: { [name]: styleValue },
474
+ name,
475
+ attr: path.node
476
+ };
477
+ }
478
+ if (t.isBinaryExpression(value)) {
479
+ const { operator, left, right } = value;
480
+ const lVal = attemptEvalSafe(left);
481
+ const rVal = attemptEvalSafe(right);
482
+ if (shouldPrintDebug) {
483
+ console.log(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`);
484
+ }
485
+ if (lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
486
+ const ternary = addBinaryConditional(operator, left, right);
487
+ if (ternary)
488
+ return ternary;
489
+ }
490
+ if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
491
+ const ternary = addBinaryConditional(operator, right, left);
492
+ if (ternary)
493
+ return ternary;
494
+ }
495
+ if (shouldPrintDebug) {
496
+ console.log(` evalBinaryExpression cant extract`);
497
+ }
498
+ inlinePropCount++;
499
+ return attr;
500
+ }
501
+ const staticConditional = getStaticConditional(value);
502
+ if (staticConditional) {
503
+ return { type: "ternary", value: staticConditional };
504
+ }
505
+ const staticLogical = getStaticLogical(value);
506
+ if (staticLogical) {
507
+ return { type: "ternary", value: staticLogical };
508
+ }
509
+ if (shouldPrintDebug) {
510
+ console.log(" ! inline prop via no match", name, value.type);
511
+ }
512
+ inlinePropCount++;
513
+ return attr;
514
+ function addBinaryConditional(operator, staticExpr, cond) {
515
+ if (getStaticConditional(cond)) {
516
+ const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate));
517
+ const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent));
518
+ if (shouldPrintDebug) {
519
+ console.log(" binaryConditional", cond.test, cons, alt);
520
+ }
521
+ return {
522
+ type: "ternary",
523
+ value: {
524
+ test: cond.test,
525
+ remove,
526
+ alternate: { [name]: alt },
527
+ consequent: { [name]: cons }
528
+ }
529
+ };
530
+ }
531
+ return null;
532
+ }
533
+ __name(addBinaryConditional, "addBinaryConditional");
534
+ function getStaticConditional(value2) {
535
+ if (t.isConditionalExpression(value2)) {
536
+ try {
537
+ if (shouldPrintDebug) {
538
+ console.log("attempt", value2.alternate, value2.consequent);
539
+ }
540
+ const aVal = attemptEval(value2.alternate);
541
+ const cVal = attemptEval(value2.consequent);
542
+ if (shouldPrintDebug) {
543
+ const type = value2.test.type;
544
+ console.log(" static ternary", type, cVal, aVal);
545
+ }
546
+ return {
547
+ test: value2.test,
548
+ remove,
549
+ consequent: { [name]: cVal },
550
+ alternate: { [name]: aVal }
551
+ };
552
+ } catch (err) {
553
+ if (shouldPrintDebug) {
554
+ console.log(" cant eval ternary", err.message);
555
+ }
556
+ }
557
+ }
558
+ return null;
559
+ }
560
+ __name(getStaticConditional, "getStaticConditional");
561
+ function getStaticLogical(value2) {
562
+ if (t.isLogicalExpression(value2)) {
563
+ if (value2.operator === "&&") {
564
+ try {
565
+ const val = attemptEval(value2.right);
566
+ if (shouldPrintDebug) {
567
+ console.log(" staticLogical", value2.left, name, val);
568
+ }
569
+ return {
570
+ test: value2.left,
571
+ remove,
572
+ consequent: { [name]: val },
573
+ alternate: null
574
+ };
575
+ } catch (err) {
576
+ if (shouldPrintDebug) {
577
+ console.log(" cant static eval logical", err);
578
+ }
579
+ }
580
+ }
581
+ }
582
+ return null;
583
+ }
584
+ __name(getStaticLogical, "getStaticLogical");
585
+ }
586
+ __name(evaluateAttribute, "evaluateAttribute");
587
+ node.attributes = attrs.filter(isAttr).map((x) => x.value);
588
+ if (couldntParse) {
589
+ if (shouldPrintDebug) {
590
+ console.log(` cancel:`, { couldntParse, shouldDeopt });
591
+ }
592
+ node.attributes = ogAttributes;
593
+ return;
594
+ }
595
+ const parentFn = findTopmostFunction(traversePath);
596
+ if (parentFn) {
597
+ modifiedComponents.add(parentFn);
598
+ }
599
+ let ternaries = [];
600
+ attrs = attrs.reduce((out, cur) => {
601
+ const next = attrs[attrs.indexOf(cur) + 1];
602
+ if (cur.type === "ternary") {
603
+ ternaries.push(cur.value);
604
+ }
605
+ if ((!next || next.type !== "ternary") && ternaries.length) {
606
+ const normalized = normalizeTernaries(ternaries).map(({ alternate, consequent, ...rest }) => {
607
+ return {
608
+ type: "ternary",
609
+ value: {
610
+ ...rest,
611
+ alternate: alternate || null,
612
+ consequent: consequent || null
613
+ }
614
+ };
615
+ });
616
+ try {
617
+ return [...out, ...normalized];
618
+ } finally {
619
+ if (shouldPrintDebug) {
620
+ console.log(` normalizeTernaries (${ternaries.length} => ${normalized.length})`);
621
+ }
622
+ ternaries = [];
623
+ }
624
+ }
625
+ if (cur.type === "ternary") {
626
+ return out;
627
+ }
628
+ out.push(cur);
629
+ return out;
630
+ }, []).flat();
631
+ const completeStaticProps = {
632
+ ...Object.keys(attrs).reduce((acc, index) => {
633
+ const cur = attrs[index];
634
+ if (cur.type === "style") {
635
+ Object.assign(acc, cur.value);
636
+ }
637
+ if (cur.type === "attr") {
638
+ if (t.isJSXSpreadAttribute(cur.value)) {
639
+ return acc;
640
+ }
641
+ if (!t.isJSXIdentifier(cur.value.name)) {
642
+ return acc;
643
+ }
644
+ const key = cur.value.name.name;
645
+ const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
646
+ if (value === FAILED_EVAL) {
647
+ return acc;
648
+ }
649
+ acc[key] = value;
650
+ }
651
+ return acc;
652
+ }, {})
653
+ };
654
+ const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x));
655
+ const hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
656
+ const shouldFlatten = !shouldDeopt && inlinePropCount === 0 && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
657
+ if (!shouldFlatten) {
658
+ attrs = attrs.reduce((acc, cur) => {
659
+ var _a2, _b2;
660
+ if (cur.type === "style") {
661
+ for (const key in cur.value) {
662
+ const shouldEnsureOverridden = !!((_a2 = staticConfig.ensureOverriddenProp) == null ? void 0 : _a2[key]);
663
+ const isSetInAttrsAlready = attrs.some((x) => x.type === "attr" && x.value.type === "JSXAttribute" && x.value.name.name === key);
664
+ if (!isSetInAttrsAlready) {
665
+ const isVariant = !!((_b2 = staticConfig.variants) == null ? void 0 : _b2[cur.name || ""]);
666
+ if (isVariant || shouldEnsureOverridden) {
667
+ acc.push({
668
+ type: "attr",
669
+ value: cur.attr || t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.nullLiteral()))
670
+ });
671
+ }
672
+ }
673
+ }
674
+ }
675
+ acc.push(cur);
676
+ return acc;
677
+ }, []);
678
+ }
679
+ if (shouldPrintDebug) {
680
+ console.log(" - attrs (flattened): \n", logLines(attrs.map(attrStr).join(", ")));
681
+ }
682
+ attrs = attrs.reduce((acc, cur) => {
683
+ if (cur.type !== "attr" || !t.isJSXAttribute(cur.value) || typeof cur.value.name.name !== "string") {
684
+ if (cur.type === "style") {
685
+ let key = Object.keys(cur.value)[0];
686
+ if (!validStyles[key] && !pseudos[key]) {
687
+ if (shouldPrintDebug) {
688
+ console.log(" - ignoring (expanded already):", key);
689
+ }
690
+ return acc;
691
+ }
692
+ }
693
+ }
694
+ acc.push(cur);
695
+ return acc;
696
+ }, []);
697
+ if (shouldPrintDebug) {
698
+ console.log(" - attrs (evaluated styles): \n", logLines(attrs.map(attrStr).join(", ")));
699
+ }
700
+ let prev = null;
701
+ attrs = attrs.reduce((acc, cur) => {
702
+ if (cur.type === "style") {
703
+ if ((prev == null ? void 0 : prev.type) === "style") {
704
+ Object.assign(prev.value, cur.value);
705
+ return acc;
706
+ }
707
+ }
708
+ acc.push(cur);
709
+ prev = cur;
710
+ return acc;
711
+ }, []);
712
+ if (shouldPrintDebug) {
713
+ console.log(" - attrs (combined \u{1F500}): \n", logLines(attrs.map(attrStr).join(", ")));
714
+ }
715
+ const getStyles = /* @__PURE__ */ __name((props2) => {
716
+ var _a2;
717
+ if (!props2)
718
+ return;
719
+ if (!!excludeProps.size) {
720
+ for (const key in props2) {
721
+ if (isExcludedProp(key))
722
+ delete props2[key];
723
+ }
724
+ }
725
+ const out = postProcessStyles(props2, staticConfig, defaultTheme);
726
+ const next = (_a2 = out == null ? void 0 : out.style) != null ? _a2 : props2;
727
+ if (shouldPrintDebug) {
728
+ console.log(" getStyles props >>\n", logLines(objToStr(props2)));
729
+ console.log(" getStyles next >>\n", logLines(objToStr(next)));
730
+ console.log(" getStyles style >>\n", logLines(objToStr(out.style)));
731
+ console.log(" getStyles viewp >>\n", logLines(objToStr(out.viewProps)));
732
+ }
733
+ if (staticConfig.validStyles) {
734
+ for (const key in next) {
735
+ if (!staticConfig.validStyles[key] && !pseudos[key]) {
736
+ delete next[key];
737
+ }
738
+ }
739
+ }
740
+ return next;
741
+ }, "getStyles");
742
+ const completeStylesProcessed = getStyles({
743
+ ...staticConfig.defaultProps,
744
+ ...completeStaticProps
745
+ });
746
+ const stylesToAddToInitialGroup = difference(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps));
747
+ if (stylesToAddToInitialGroup.length) {
748
+ const toAdd = pick(completeStylesProcessed, ...stylesToAddToInitialGroup);
749
+ const firstGroup = attrs.find((x) => x.type === "style");
750
+ if (shouldPrintDebug) {
751
+ console.log(" stylesToAddToInitialGroup", stylesToAddToInitialGroup.join(", "));
752
+ console.log(" toAdd", objToStr(toAdd));
753
+ }
754
+ if (!firstGroup) {
755
+ attrs.unshift({ type: "style", value: toAdd });
756
+ } else {
757
+ Object.assign(firstGroup.value, toAdd);
758
+ }
759
+ }
760
+ if (shouldPrintDebug) {
761
+ console.log(" completeStaticProps\n", logLines(objToStr(completeStaticProps)));
762
+ console.log(" completeStylesProcessed\n", logLines(objToStr(completeStylesProcessed)));
763
+ }
764
+ for (const attr of attrs) {
765
+ try {
766
+ switch (attr.type) {
767
+ case "ternary":
768
+ const a = getStyles(attr.value.alternate);
769
+ const c = getStyles(attr.value.consequent);
770
+ attr.value.alternate = a;
771
+ attr.value.consequent = c;
772
+ if (shouldPrintDebug) {
773
+ console.log(" => tern ", attrStr(attr));
774
+ }
775
+ break;
776
+ case "style":
777
+ const next = {};
778
+ for (const key in attr.value) {
779
+ if (key in stylePropsTransform) {
780
+ next["transform"] = completeStylesProcessed["transform"];
781
+ } else {
782
+ next[key] = (_g = completeStylesProcessed[key]) != null ? _g : attr.value[key];
783
+ }
784
+ }
785
+ attr.value = next;
786
+ break;
787
+ }
788
+ } catch (err) {
789
+ if (shouldPrintDebug) {
790
+ console.log(" postprocessing error, deopt", err);
791
+ node.attributes = ogAttributes;
792
+ return node;
793
+ }
794
+ }
795
+ }
796
+ if (shouldPrintDebug) {
797
+ console.log(" - attrs (after):\n", logLines(attrs.map(attrStr).join(", ")));
798
+ }
799
+ if (shouldFlatten) {
800
+ if (shouldPrintDebug) {
801
+ console.log(" [\u2705] flattening", originalNodeName, flatNode);
802
+ }
803
+ isFlattened = true;
804
+ node.name.name = flatNode;
805
+ res.flattened++;
806
+ if (closingElement) {
807
+ closingElement.name.name = flatNode;
808
+ }
809
+ }
810
+ if (shouldPrintDebug) {
811
+ console.log(" [\u274A] inline props ", inlinePropCount, shouldDeopt ? " deopted" : "", hasSpread ? " spread" : "", "!flatten", staticConfig.neverFlatten);
812
+ console.log(" - attrs (end):\n", logLines(attrs.map(attrStr).join(", ")));
813
+ }
814
+ res.optimized++;
815
+ onExtractTag({
816
+ attrs,
817
+ node,
818
+ lineNumbers,
819
+ filePath,
820
+ attemptEval,
821
+ jsxPath: traversePath,
822
+ originalNodeName,
823
+ isFlattened,
824
+ programPath
825
+ });
826
+ }
827
+ });
828
+ if (modifiedComponents.size) {
829
+ const all = Array.from(modifiedComponents);
830
+ if (shouldPrintDebug) {
831
+ console.log(" [\u{1FA9D}] hook check", all.length);
832
+ }
833
+ for (const comp of all) {
834
+ removeUnusedHooks(comp, shouldPrintDebug);
835
+ }
836
+ }
837
+ return res;
838
+ }
839
+ };
840
+ }
841
+ __name(createExtractor, "createExtractor");
842
+ export {
843
+ createExtractor
844
+ };