@tamagui/static 1.0.0-alpha.37 → 1.0.0-alpha.38

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 (173) hide show
  1. package/dist/.buildinfo +1 -0
  2. package/dist/extractor/createEvaluator.js.map +2 -2
  3. package/dist/extractor/createExtractor.js +86 -105
  4. package/dist/extractor/createExtractor.js.map +2 -2
  5. package/dist/extractor/extractHelpers.js +1 -3
  6. package/dist/extractor/extractHelpers.js.map +2 -2
  7. package/dist/extractor/extractMediaStyle.js +8 -10
  8. package/dist/extractor/extractMediaStyle.js.map +2 -2
  9. package/dist/extractor/extractToClassNames.js +20 -10
  10. package/dist/extractor/extractToClassNames.js.map +2 -2
  11. package/dist/extractor/getStaticBindingsForScope.js +7 -0
  12. package/dist/extractor/getStaticBindingsForScope.js.map +2 -2
  13. package/dist/forwardPropsList.js +140 -0
  14. package/dist/forwardPropsList.js.map +7 -0
  15. package/dist/index.cjs +133 -205
  16. package/dist/index.cjs.map +3 -3
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/patchReactNativeWeb.js +3 -30
  20. package/dist/patchReactNativeWeb.js.map +2 -2
  21. package/package.json +7 -7
  22. package/dist/cjs/constants.js +0 -33
  23. package/dist/cjs/constants.js.map +0 -7
  24. package/dist/cjs/extractor/accessSafe.js +0 -33
  25. package/dist/cjs/extractor/accessSafe.js.map +0 -7
  26. package/dist/cjs/extractor/babelParse.js +0 -52
  27. package/dist/cjs/extractor/babelParse.js.map +0 -7
  28. package/dist/cjs/extractor/buildClassName.js +0 -62
  29. package/dist/cjs/extractor/buildClassName.js.map +0 -7
  30. package/dist/cjs/extractor/createEvaluator.js +0 -73
  31. package/dist/cjs/extractor/createEvaluator.js.map +0 -7
  32. package/dist/cjs/extractor/createExtractor.js +0 -903
  33. package/dist/cjs/extractor/createExtractor.js.map +0 -7
  34. package/dist/cjs/extractor/ensureImportingConcat.js +0 -46
  35. package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
  36. package/dist/cjs/extractor/evaluateAstNode.js +0 -116
  37. package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
  38. package/dist/cjs/extractor/extractHelpers.js +0 -118
  39. package/dist/cjs/extractor/extractHelpers.js.map +0 -7
  40. package/dist/cjs/extractor/extractMediaStyle.js +0 -187
  41. package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
  42. package/dist/cjs/extractor/extractToClassNames.js +0 -279
  43. package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
  44. package/dist/cjs/extractor/findTopmostFunction.js +0 -29
  45. package/dist/cjs/extractor/findTopmostFunction.js.map +0 -7
  46. package/dist/cjs/extractor/generatedUid.js +0 -50
  47. package/dist/cjs/extractor/generatedUid.js.map +0 -7
  48. package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -71
  49. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
  50. package/dist/cjs/extractor/getSourceModule.js +0 -91
  51. package/dist/cjs/extractor/getSourceModule.js.map +0 -7
  52. package/dist/cjs/extractor/getStaticBindingsForScope.js +0 -150
  53. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
  54. package/dist/cjs/extractor/hoistClassNames.js +0 -66
  55. package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
  56. package/dist/cjs/extractor/literalToAst.js +0 -56
  57. package/dist/cjs/extractor/literalToAst.js.map +0 -7
  58. package/dist/cjs/extractor/loadTamagui.js +0 -63
  59. package/dist/cjs/extractor/loadTamagui.js.map +0 -7
  60. package/dist/cjs/extractor/logLines.js +0 -23
  61. package/dist/cjs/extractor/logLines.js.map +0 -7
  62. package/dist/cjs/extractor/normalizeTernaries.js +0 -102
  63. package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
  64. package/dist/cjs/extractor/removeUnusedHooks.js +0 -101
  65. package/dist/cjs/extractor/removeUnusedHooks.js.map +0 -7
  66. package/dist/cjs/index.js +0 -37
  67. package/dist/cjs/index.js.map +0 -7
  68. package/dist/cjs/patchReactNativeWeb.js +0 -129
  69. package/dist/cjs/patchReactNativeWeb.js.map +0 -7
  70. package/dist/cjs/types.js +0 -4
  71. package/dist/cjs/types.js.map +0 -7
  72. package/dist/esm/constants.js +0 -10
  73. package/dist/esm/constants.js.map +0 -7
  74. package/dist/esm/extractor/accessSafe.js +0 -11
  75. package/dist/esm/extractor/accessSafe.js.map +0 -7
  76. package/dist/esm/extractor/babelParse.js +0 -30
  77. package/dist/esm/extractor/babelParse.js.map +0 -7
  78. package/dist/esm/extractor/buildClassName.js +0 -40
  79. package/dist/esm/extractor/buildClassName.js.map +0 -7
  80. package/dist/esm/extractor/createEvaluator.js +0 -51
  81. package/dist/esm/extractor/createEvaluator.js.map +0 -7
  82. package/dist/esm/extractor/createExtractor.js +0 -847
  83. package/dist/esm/extractor/createExtractor.js.map +0 -7
  84. package/dist/esm/extractor/ensureImportingConcat.js +0 -24
  85. package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
  86. package/dist/esm/extractor/evaluateAstNode.js +0 -94
  87. package/dist/esm/extractor/evaluateAstNode.js.map +0 -7
  88. package/dist/esm/extractor/extractHelpers.js +0 -96
  89. package/dist/esm/extractor/extractHelpers.js.map +0 -7
  90. package/dist/esm/extractor/extractMediaStyle.js +0 -152
  91. package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
  92. package/dist/esm/extractor/extractToClassNames.js +0 -242
  93. package/dist/esm/extractor/extractToClassNames.js.map +0 -7
  94. package/dist/esm/extractor/findTopmostFunction.js +0 -23
  95. package/dist/esm/extractor/findTopmostFunction.js.map +0 -7
  96. package/dist/esm/extractor/generatedUid.js +0 -28
  97. package/dist/esm/extractor/generatedUid.js.map +0 -7
  98. package/dist/esm/extractor/getPropValueFromAttributes.js +0 -49
  99. package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
  100. package/dist/esm/extractor/getSourceModule.js +0 -69
  101. package/dist/esm/extractor/getSourceModule.js.map +0 -7
  102. package/dist/esm/extractor/getStaticBindingsForScope.js +0 -128
  103. package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
  104. package/dist/esm/extractor/hoistClassNames.js +0 -44
  105. package/dist/esm/extractor/hoistClassNames.js.map +0 -7
  106. package/dist/esm/extractor/literalToAst.js +0 -34
  107. package/dist/esm/extractor/literalToAst.js.map +0 -7
  108. package/dist/esm/extractor/loadTamagui.js +0 -41
  109. package/dist/esm/extractor/loadTamagui.js.map +0 -7
  110. package/dist/esm/extractor/logLines.js +0 -17
  111. package/dist/esm/extractor/logLines.js.map +0 -7
  112. package/dist/esm/extractor/normalizeTernaries.js +0 -53
  113. package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
  114. package/dist/esm/extractor/removeUnusedHooks.js +0 -80
  115. package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
  116. package/dist/esm/index.js +0 -14
  117. package/dist/esm/index.js.map +0 -7
  118. package/dist/esm/patchReactNativeWeb.js +0 -107
  119. package/dist/esm/patchReactNativeWeb.js.map +0 -7
  120. package/dist/esm/types.js +0 -1
  121. package/dist/esm/types.js.map +0 -7
  122. package/dist/extractor/loadTamagui.js +0 -41
  123. package/dist/extractor/loadTamagui.js.map +0 -7
  124. package/dist/jsx/constants.js +0 -9
  125. package/dist/jsx/extractor/accessSafe.js +0 -10
  126. package/dist/jsx/extractor/babelParse.js +0 -29
  127. package/dist/jsx/extractor/buildClassName.js +0 -39
  128. package/dist/jsx/extractor/createEvaluator.js +0 -50
  129. package/dist/jsx/extractor/createExtractor.js +0 -846
  130. package/dist/jsx/extractor/ensureImportingConcat.js +0 -23
  131. package/dist/jsx/extractor/evaluateAstNode.js +0 -93
  132. package/dist/jsx/extractor/extractHelpers.js +0 -95
  133. package/dist/jsx/extractor/extractMediaStyle.js +0 -151
  134. package/dist/jsx/extractor/extractToClassNames.js +0 -241
  135. package/dist/jsx/extractor/findTopmostFunction.js +0 -22
  136. package/dist/jsx/extractor/generatedUid.js +0 -27
  137. package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -48
  138. package/dist/jsx/extractor/getSourceModule.js +0 -68
  139. package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -127
  140. package/dist/jsx/extractor/hoistClassNames.js +0 -43
  141. package/dist/jsx/extractor/literalToAst.js +0 -33
  142. package/dist/jsx/extractor/loadTamagui.js +0 -40
  143. package/dist/jsx/extractor/logLines.js +0 -16
  144. package/dist/jsx/extractor/normalizeTernaries.js +0 -52
  145. package/dist/jsx/extractor/removeUnusedHooks.js +0 -79
  146. package/dist/jsx/index.js +0 -13
  147. package/dist/jsx/patchReactNativeWeb.js +0 -106
  148. package/dist/jsx/types.js +0 -0
  149. package/types/constants.d.ts.map +0 -1
  150. package/types/extractor/accessSafe.d.ts.map +0 -1
  151. package/types/extractor/babelParse.d.ts.map +0 -1
  152. package/types/extractor/buildClassName.d.ts.map +0 -1
  153. package/types/extractor/createEvaluator.d.ts.map +0 -1
  154. package/types/extractor/createExtractor.d.ts.map +0 -1
  155. package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
  156. package/types/extractor/evaluateAstNode.d.ts.map +0 -1
  157. package/types/extractor/extractHelpers.d.ts.map +0 -1
  158. package/types/extractor/extractMediaStyle.d.ts.map +0 -1
  159. package/types/extractor/extractToClassNames.d.ts.map +0 -1
  160. package/types/extractor/findTopmostFunction.d.ts.map +0 -1
  161. package/types/extractor/generatedUid.d.ts.map +0 -1
  162. package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
  163. package/types/extractor/getSourceModule.d.ts.map +0 -1
  164. package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
  165. package/types/extractor/hoistClassNames.d.ts.map +0 -1
  166. package/types/extractor/literalToAst.d.ts.map +0 -1
  167. package/types/extractor/loadTamagui.d.ts.map +0 -1
  168. package/types/extractor/logLines.d.ts.map +0 -1
  169. package/types/extractor/normalizeTernaries.d.ts.map +0 -1
  170. package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
  171. package/types/index.d.ts.map +0 -1
  172. package/types/patchReactNativeWeb.d.ts.map +0 -1
  173. package/types/types.d.ts.map +0 -1
@@ -1,242 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as path from "path";
4
- import { basename } from "path";
5
- import * as util from "util";
6
- import generate from "@babel/generator";
7
- import * as t from "@babel/types";
8
- import { getStylesAtomic } from "@tamagui/core-node";
9
- import { concatClassName } from "@tamagui/helpers";
10
- import invariant from "invariant";
11
- import { getRemainingRequest } from "loader-utils";
12
- import { babelParse } from "./babelParse";
13
- import { buildClassName } from "./buildClassName";
14
- import { ensureImportingConcat } from "./ensureImportingConcat";
15
- import { isSimpleSpread } from "./extractHelpers";
16
- import { extractMediaStyle } from "./extractMediaStyle";
17
- import { hoistClassNames } from "./hoistClassNames";
18
- import { logLines } from "./logLines";
19
- const CONCAT_CLASSNAME_IMPORT = "concatClassName";
20
- const mergeStyleGroups = {
21
- shadowOpacity: true,
22
- shadowRadius: true,
23
- shadowColor: true,
24
- shadowOffset: true
25
- };
26
- function extractToClassNames({
27
- loader,
28
- extractor,
29
- source,
30
- sourcePath,
31
- options,
32
- shouldPrintDebug,
33
- threaded,
34
- cssPath
35
- }) {
36
- var _a;
37
- if (typeof source !== "string") {
38
- throw new Error("`source` must be a string of javascript");
39
- }
40
- invariant(typeof sourcePath === "string" && path.isAbsolute(sourcePath), "`sourcePath` must be an absolute path to a .js file");
41
- const shouldLogTiming = (_a = options.logTimings) != null ? _a : true;
42
- const start = Date.now();
43
- const mem = shouldLogTiming ? process.memoryUsage() : null;
44
- let ast;
45
- try {
46
- ast = babelParse(source);
47
- } catch (err) {
48
- console.error("babel parse error:", sourcePath);
49
- throw err;
50
- }
51
- const cssMap = new Map();
52
- const existingHoists = {};
53
- const res = extractor.parse(ast, {
54
- sourcePath,
55
- shouldPrintDebug,
56
- ...options,
57
- getFlattenedNode: ({ tag }) => tag,
58
- onExtractTag: ({
59
- attrs,
60
- node,
61
- attemptEval,
62
- jsxPath,
63
- originalNodeName,
64
- filePath,
65
- lineNumbers,
66
- programPath
67
- }) => {
68
- let finalClassNames = [];
69
- let finalAttrs = [];
70
- let finalStyles = [];
71
- const viewStyles = {};
72
- for (const attr of attrs) {
73
- if (attr.type === "style") {
74
- Object.assign(viewStyles, attr.value);
75
- }
76
- }
77
- const ensureNeededPrevStyle = /* @__PURE__ */ __name((style) => {
78
- var _a2;
79
- const keys = Object.keys(style);
80
- if (!keys.some((key) => mergeStyleGroups[key])) {
81
- return style;
82
- }
83
- for (const k in mergeStyleGroups) {
84
- if (k in viewStyles) {
85
- style[k] = (_a2 = style[k]) != null ? _a2 : viewStyles[k];
86
- }
87
- }
88
- return style;
89
- }, "ensureNeededPrevStyle");
90
- const addStyles = /* @__PURE__ */ __name((style) => {
91
- if (!style)
92
- return [];
93
- const styleWithPrev = ensureNeededPrevStyle(style);
94
- const res2 = getStylesAtomic(styleWithPrev);
95
- if (res2.length) {
96
- finalStyles = [...finalStyles, ...res2];
97
- }
98
- return res2;
99
- }, "addStyles");
100
- let lastMediaImportance = 1;
101
- for (const attr of attrs) {
102
- switch (attr.type) {
103
- case "style":
104
- const styles2 = addStyles(attr.value);
105
- const newClassNames = concatClassName(styles2.map((x) => x.identifier).join(" "));
106
- const existing = finalClassNames.find((x) => x.type == "StringLiteral");
107
- if (existing) {
108
- existing.value = `${existing.value} ${newClassNames}`;
109
- } else {
110
- finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)];
111
- }
112
- if (shouldPrintDebug) {
113
- console.log(" classnames (after)\n", logLines(finalClassNames.map((x) => x["value"]).join(" ")));
114
- }
115
- break;
116
- case "attr":
117
- const val = attr.value;
118
- if (t.isJSXSpreadAttribute(val)) {
119
- if (isSimpleSpread(val)) {
120
- finalClassNames.push(t.logicalExpression("&&", val.argument, t.memberExpression(val.argument, t.identifier("className"))));
121
- }
122
- } else if (val.name.name === "className") {
123
- const value = val.value;
124
- if (value) {
125
- try {
126
- const evaluatedValue = attemptEval(value);
127
- finalClassNames.push(t.stringLiteral(evaluatedValue));
128
- } catch (e) {
129
- finalClassNames.push(value["expression"]);
130
- }
131
- }
132
- continue;
133
- }
134
- finalAttrs.push(val);
135
- break;
136
- case "ternary":
137
- const mediaExtraction = extractMediaStyle(attr.value, jsxPath, extractor.getTamagui(), sourcePath, lastMediaImportance, shouldPrintDebug);
138
- if (mediaExtraction) {
139
- lastMediaImportance++;
140
- finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles];
141
- finalClassNames = [
142
- ...finalClassNames,
143
- ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier))
144
- ];
145
- if (!mediaExtraction.ternaryWithoutMedia) {
146
- continue;
147
- }
148
- }
149
- const ternary = (mediaExtraction == null ? void 0 : mediaExtraction.ternaryWithoutMedia) || attr.value;
150
- const consInfo = addStyles(ternary.consequent);
151
- const altInfo = addStyles(ternary.alternate);
152
- const cCN = consInfo.map((x) => x.identifier).join(" ");
153
- const aCN = altInfo.map((x) => x.identifier).join(" ");
154
- if (consInfo.length && altInfo.length) {
155
- finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN)));
156
- } else {
157
- finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(" " + cCN), t.stringLiteral(" " + aCN)));
158
- }
159
- break;
160
- }
161
- }
162
- node.attributes = finalAttrs;
163
- if (finalClassNames.length) {
164
- const names = buildClassName(finalClassNames);
165
- const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null;
166
- let expr = nameExpr;
167
- if (nameExpr && !t.isIdentifier(nameExpr)) {
168
- ensureImportingConcat(programPath);
169
- const simpleSpreads = attrs.filter((x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value));
170
- expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [
171
- expr,
172
- ...simpleSpreads.map((val) => val.value["argument"])
173
- ]);
174
- }
175
- node.attributes.push(t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr)));
176
- }
177
- const comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName);
178
- for (const { className, rules } of finalStyles) {
179
- if (cssMap.has(className)) {
180
- if (comment) {
181
- const val = cssMap.get(className);
182
- val.commentTexts.push(comment);
183
- cssMap.set(className, val);
184
- }
185
- } else if (rules.length) {
186
- if (rules.length > 1) {
187
- console.log(" rules error", { rules });
188
- throw new Error(`Shouldn't have more than one rule`);
189
- }
190
- cssMap.set(className, {
191
- css: rules[0],
192
- commentTexts: [comment]
193
- });
194
- }
195
- }
196
- }
197
- });
198
- if (!res || !res.modified && !res.optimized && !res.flattened) {
199
- if (shouldPrintDebug) {
200
- console.log("no res or none modified", res);
201
- }
202
- return null;
203
- }
204
- const styles = Array.from(cssMap.values()).map((x) => x.css).join("\n").trim();
205
- if (styles) {
206
- const cssQuery = threaded ? `cssData=${Buffer.from(styles).toString("base64")}` : `cssPath=${cssPath}`;
207
- const remReq = getRemainingRequest(loader);
208
- const importPath = `${cssPath}!=!tamagui-loader?${cssQuery}!${remReq}`;
209
- ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)));
210
- }
211
- const result = generate(ast, {
212
- concise: false,
213
- filename: sourcePath,
214
- retainLines: false,
215
- sourceFileName: sourcePath,
216
- sourceMaps: true
217
- }, source);
218
- if (shouldPrintDebug) {
219
- console.log("\n -------- output code ------- \n\n", result.code.split("\n").filter((x) => !x.startsWith("//")).join("\n"));
220
- console.log("\n -------- output style -------- \n\n", styles);
221
- }
222
- if (shouldLogTiming) {
223
- const memUsed = mem ? Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10 : 0;
224
- const timing = `${Date.now() - start}`.padStart(3);
225
- const path2 = basename(sourcePath).padStart(40);
226
- const numOptimized = `${res.optimized}`.padStart(4);
227
- const memory = memUsed > 10 ? `used ${memUsed}MB` : "";
228
- console.log(` \u{1F95A} ${path2} ${timing}ms \u05C1\xB7 ${numOptimized} optimized \xB7 ${res.flattened} flattened ${memory}`);
229
- }
230
- return {
231
- ast,
232
- styles,
233
- js: result.code,
234
- map: result.map
235
- };
236
- }
237
- __name(extractToClassNames, "extractToClassNames");
238
- export {
239
- CONCAT_CLASSNAME_IMPORT,
240
- extractToClassNames
241
- };
242
- //# sourceMappingURL=extractToClassNames.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/extractToClassNames.ts"],
4
- "sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { getRemainingRequest } from 'loader-utils'\nimport { ViewStyle } from 'react-native'\n\nimport { ClassNameObject, StyleObject, TamaguiOptions } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { hoistClassNames } from './hoistClassNames'\nimport { logLines } from './logLines'\n\nexport const CONCAT_CLASSNAME_IMPORT = 'concatClassName'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport function extractToClassNames({\n loader,\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n threaded,\n cssPath,\n}: {\n loader: any\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean\n cssPath: string\n threaded?: boolean\n}): null | {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n} {\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n // @ts-ignore\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n getFlattenedNode: ({ tag }) => tag,\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n }) => {\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n const viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n Object.assign(viewStyles, attr.value)\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null) => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n // prettier-ignore\n const existing = finalClassNames.find((x) => x.type == 'StringLiteral') as t.StringLiteral | null\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' classnames (after)\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (mediaExtraction) {\n lastMediaImportance++\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n if (!mediaExtraction.ternaryWithoutMedia) {\n continue\n }\n }\n const ternary = mediaExtraction?.ternaryWithoutMedia || attr.value\n const consInfo = addStyles(ternary.consequent)\n const altInfo = addStyles(ternary.alternate)\n const cCN = consInfo.map((x) => x.identifier).join(' ')\n const aCN = altInfo.map((x) => x.identifier).join(' ')\n if (consInfo.length && altInfo.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n break\n }\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { className, rules } of finalStyles) {\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n if (styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = getRemainingRequest(loader)\n const importPath = `${cssPath}!=!tamagui-loader?${cssQuery}!${remReq}`\n ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)))\n }\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const timing = `${Date.now() - start}`.padStart(3)\n const path = basename(sourcePath).padStart(40)\n const numOptimized = `${res.optimized}`.padStart(4)\n const memory = memUsed > 10 ? `used ${memUsed}MB` : ''\n console.log(\n ` \uD83E\uDD5A ${path} ${timing}ms \u05C1\u00B7 ${numOptimized} optimized \u00B7 ${res.flattened} flattened ${memory}`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
5
- "mappings": ";;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAM,0BAA0B;AAEvC,MAAM,mBAAmB;AAAA,EACvB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAAA;AAGT,6BAA6B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAgBA;AAvDF;AAwDE,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI,MAAM;AAAA;AAElB,YACE,OAAO,eAAe,YAAY,KAAK,WAAW,aAClD;AAGF,QAAM,kBAAkB,cAAQ,eAAR,YAAsB;AAC9C,QAAM,QAAQ,KAAK;AACnB,QAAM,MAAM,kBAAkB,QAAQ,gBAAgB;AAGtD,MAAI;AAEJ,MAAI;AAEF,UAAM,WAAW;AAAA,WACV,KAAP;AACA,YAAQ,MAAM,sBAAsB;AACpC,UAAM;AAAA;AAGR,QAAM,SAAS,IAAI;AACnB,QAAM,iBAAkD;AAExD,QAAM,MAAM,UAAU,MAAM,KAAK;AAAA,IAC/B;AAAA,IACA;AAAA,OACG;AAAA,IACH,kBAAkB,CAAC,EAAE,UAAU;AAAA,IAC/B,cAAc,CAAC;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;A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ACnC,UAAM,aAAa,GAAG,4BAA4B,YAAY;AAC9D,QAAI,QAAQ,KAAK,QAAQ,EAAE,kBAAkB,IAAI,EAAE,cAAc;AAAA;AAGnE,QAAM,SAAS,SACb,KACA;AAAA,IACE,SAAS;AAAA,IACT,UAAU;AAAA,IACV,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,YAAY;AAAA,KAEd;AAGF,MAAI,kBAAkB;AACpB,YAAQ,IACN,wCACA,OAAO,KACJ,MAAM,MACN,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,OAC5B,KAAK;AAEV,YAAQ,IAAI,0CAA0C;AAAA;AAGxD,MAAI,iBAAiB;AACnB,UAAM,UAAU,MACZ,KAAK,MAAQ,SAAQ,cAAc,WAAW,IAAI,YAAY,OAAO,OAAQ,MAAM,KACnF;AACJ,UAAM,SAAS,GAAG,KAAK,QAAQ,QAAQ,SAAS;AAChD,UAAM,QAAO,SAAS,YAAY,SAAS;AAC3C,UAAM,eAAe,GAAG,IAAI,YAAY,SAAS;AACjD,UAAM,SAAS,UAAU,KAAK,QAAQ,cAAc;AACpD,YAAQ,IACN,eAAQ,SAAQ,uBAAe,+BAA4B,IAAI,uBAAuB;AAAA;AAI1F,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,KAAK,OAAO;AAAA;AAAA;AAzSA;",
6
- "names": []
7
- }
@@ -1,23 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- function findTopmostFunction(jsxPath) {
4
- const isFunction = /* @__PURE__ */ __name((path) => path.isArrowFunctionExpression() || path.isFunctionDeclaration() || path.isFunctionExpression(), "isFunction");
5
- let compFn = jsxPath.findParent(isFunction);
6
- while (compFn) {
7
- const parent = compFn.findParent(isFunction);
8
- if (parent) {
9
- compFn = parent;
10
- } else {
11
- break;
12
- }
13
- }
14
- if (!compFn) {
15
- return null;
16
- }
17
- return compFn;
18
- }
19
- __name(findTopmostFunction, "findTopmostFunction");
20
- export {
21
- findTopmostFunction
22
- };
23
- //# sourceMappingURL=findTopmostFunction.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/findTopmostFunction.ts"],
4
- "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nexport function findTopmostFunction(jsxPath: NodePath<t.JSXElement>) {\n // get topmost fn\n const isFunction = (path: NodePath<any>) =>\n path.isArrowFunctionExpression() || path.isFunctionDeclaration() || path.isFunctionExpression()\n let compFn: NodePath<any> | null = jsxPath.findParent(isFunction)\n while (compFn) {\n const parent = compFn.findParent(isFunction)\n if (parent) {\n compFn = parent\n } else {\n break\n }\n }\n if (!compFn) {\n // console.error(`Couldn't find a topmost function for media query extraction`)\n return null\n }\n return compFn\n}\n"],
5
- "mappings": ";;AAGO,6BAA6B,SAAiC;AAEnE,QAAM,aAAa,wBAAC,SAClB,KAAK,+BAA+B,KAAK,2BAA2B,KAAK,wBADxD;AAEnB,MAAI,SAA+B,QAAQ,WAAW;AACtD,SAAO,QAAQ;AACb,UAAM,SAAS,OAAO,WAAW;AACjC,QAAI,QAAQ;AACV,eAAS;AAAA,WACJ;AACL;AAAA;AAAA;AAGJ,MAAI,CAAC,QAAQ;AAEX,WAAO;AAAA;AAET,SAAO;AAAA;AAjBO;",
6
- "names": []
7
- }
@@ -1,28 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as t from "@babel/types";
4
- import invariant from "invariant";
5
- function generateUid(scope, name) {
6
- invariant(typeof scope === "object", "generateUid expects a scope object as its first parameter");
7
- invariant(typeof name === "string" && name !== "", "generateUid expects a valid name as its second parameter");
8
- name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
9
- let uid;
10
- let i = 0;
11
- do {
12
- if (i > 1) {
13
- uid = name + i;
14
- } else {
15
- uid = name;
16
- }
17
- i++;
18
- } while (scope.hasLabel(uid) || scope.hasBinding(uid) || scope.hasGlobal(uid) || scope.hasReference(uid));
19
- const program = scope.getProgramParent();
20
- program.references[uid] = true;
21
- program.uids[uid] = true;
22
- return uid;
23
- }
24
- __name(generateUid, "generateUid");
25
- export {
26
- generateUid
27
- };
28
- //# sourceMappingURL=generatedUid.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/generatedUid.ts"],
4
- "sourcesContent": ["import * as t from '@babel/types'\nimport invariant from 'invariant'\n\n// TODO: open a PR upstream\ndeclare module '@babel/types' {\n export function toIdentifier(input: string): string\n}\n\n// A clone of path.scope.generateUid that doesn't prepend underscores\nexport function generateUid(scope: any, name: string): string {\n invariant(typeof scope === 'object', 'generateUid expects a scope object as its first parameter')\n invariant(\n typeof name === 'string' && name !== '',\n 'generateUid expects a valid name as its second parameter'\n )\n\n name = t\n .toIdentifier(name)\n .replace(/^_+/, '')\n .replace(/[0-9]+$/g, '')\n\n let uid\n let i = 0\n do {\n if (i > 1) {\n uid = name + i\n } else {\n uid = name\n }\n i++\n } while (\n scope.hasLabel(uid) ||\n scope.hasBinding(uid) ||\n scope.hasGlobal(uid) ||\n scope.hasReference(uid)\n )\n\n const program = scope.getProgramParent()\n program.references[uid] = true\n program.uids[uid] = true\n\n return uid\n}\n"],
5
- "mappings": ";;AAAA;AACA;AAQO,qBAAqB,OAAY,MAAsB;AAC5D,YAAU,OAAO,UAAU,UAAU;AACrC,YACE,OAAO,SAAS,YAAY,SAAS,IACrC;AAGF,SAAO,EACJ,aAAa,MACb,QAAQ,OAAO,IACf,QAAQ,YAAY;AAEvB,MAAI;AACJ,MAAI,IAAI;AACR,KAAG;AACD,QAAI,IAAI,GAAG;AACT,YAAM,OAAO;AAAA,WACR;AACL,YAAM;AAAA;AAER;AAAA,WAEA,MAAM,SAAS,QACf,MAAM,WAAW,QACjB,MAAM,UAAU,QAChB,MAAM,aAAa;AAGrB,QAAM,UAAU,MAAM;AACtB,UAAQ,WAAW,OAAO;AAC1B,UAAQ,KAAK,OAAO;AAEpB,SAAO;AAAA;AAhCO;",
6
- "names": []
7
- }
@@ -1,49 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import generate from "@babel/generator";
4
- import * as t from "@babel/types";
5
- import { accessSafe } from "./accessSafe";
6
- function getPropValueFromAttributes(propName, attrs) {
7
- let propIndex = -1;
8
- let jsxAttr = null;
9
- for (let idx = -1, len = attrs.length; ++idx < len; ) {
10
- const attr = attrs[idx];
11
- if (t.isJSXAttribute(attr) && attr.name && attr.name.name === propName) {
12
- propIndex = idx;
13
- jsxAttr = attr;
14
- break;
15
- }
16
- }
17
- if (!jsxAttr || jsxAttr.value == null) {
18
- return null;
19
- }
20
- let propValue = jsxAttr.value;
21
- if (t.isJSXExpressionContainer(propValue)) {
22
- propValue = propValue.expression;
23
- }
24
- if (t.isJSXEmptyExpression(propValue)) {
25
- console.error("encountered JSXEmptyExpression");
26
- return null;
27
- }
28
- const applicableSpreads = attrs.filter((attr, idx) => {
29
- if (t.isJSXSpreadAttribute(attr)) {
30
- if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) {
31
- return idx > propIndex;
32
- }
33
- if (t.isLogicalExpression(attr.argument)) {
34
- return false;
35
- }
36
- throw new Error(`unsupported spread of type "${attr.argument.type}": ${generate(attr).code}`);
37
- }
38
- return false;
39
- }).map((attr) => attr.argument);
40
- if (applicableSpreads.length > 0) {
41
- propValue = applicableSpreads.reduce((acc, val) => t.logicalExpression("||", accessSafe(val, propName), acc), propValue);
42
- }
43
- return propValue;
44
- }
45
- __name(getPropValueFromAttributes, "getPropValueFromAttributes");
46
- export {
47
- getPropValueFromAttributes
48
- };
49
- //# sourceMappingURL=getPropValueFromAttributes.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/getPropValueFromAttributes.ts"],
4
- "sourcesContent": ["import generate from '@babel/generator'\nimport * as t from '@babel/types'\n\nimport { accessSafe } from './accessSafe'\n\n/**\n * getPropValueFromAttributes gets a prop by name from a list of attributes and accounts for potential spread operators.\n * Here's an example. Given this component:\n * ```\n * <Block coolProp=\"wow\" {...spread1} neatProp=\"ok\" {...spread2} />```\n * getPropValueFromAttributes will return the following:\n * - for propName `coolProp`:\n * ```\n * accessSafe(spread1, 'coolProp') || accessSafe(spread2, 'coolProp') || 'wow'```\n * - for propName `neatProp`:\n * ```\n * accessSafe(spread2, 'neatProp') || 'ok'```\n * - for propName `notPresent`: `null`\n *\n * The returned value should (obviously) be placed after spread operators.\n */\nexport function getPropValueFromAttributes(\n propName: string,\n attrs: (t.JSXAttribute | t.JSXSpreadAttribute)[]\n): t.Expression | null {\n let propIndex: number = -1\n let jsxAttr: t.JSXAttribute | null = null\n for (let idx = -1, len = attrs.length; ++idx < len; ) {\n const attr = attrs[idx]\n if (t.isJSXAttribute(attr) && attr.name && attr.name.name === propName) {\n propIndex = idx\n jsxAttr = attr\n break\n }\n }\n\n if (!jsxAttr || jsxAttr.value == null) {\n return null\n }\n\n let propValue:\n | t.JSXElement\n | t.JSXFragment\n | t.StringLiteral\n | t.JSXExpressionContainer\n | t.JSXEmptyExpression\n | t.Expression = jsxAttr.value\n\n if (t.isJSXExpressionContainer(propValue)) {\n propValue = propValue.expression\n }\n\n // TODO how to handle this??\n if (t.isJSXEmptyExpression(propValue)) {\n console.error('encountered JSXEmptyExpression')\n return null\n }\n\n // filter out spread props that occur before propValue\n const applicableSpreads = attrs\n .filter(\n // 1. idx is greater than propValue prop index\n // 2. attr is a spread operator\n (attr, idx): attr is t.JSXSpreadAttribute => {\n if (t.isJSXSpreadAttribute(attr)) {\n if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) {\n return idx > propIndex\n }\n if (t.isLogicalExpression(attr.argument)) {\n return false\n }\n throw new Error(\n `unsupported spread of type \"${attr.argument.type}\": ${generate(attr).code}`\n )\n }\n return false\n }\n )\n .map((attr) => attr.argument)\n\n // if spread operators occur after propValue, create a binary expression for each operator\n // i.e. before1.propValue || before2.propValue || propValue\n // TODO: figure out how to do this without all the extra parens\n if (applicableSpreads.length > 0) {\n propValue = applicableSpreads.reduce<t.Expression>(\n (acc, val) => t.logicalExpression('||', accessSafe(val, propName), acc),\n propValue\n )\n }\n\n return propValue\n}\n"],
5
- "mappings": ";;AAAA;AACA;AAEA;AAkBO,oCACL,UACA,OACqB;AACrB,MAAI,YAAoB;AACxB,MAAI,UAAiC;AACrC,WAAS,MAAM,IAAI,MAAM,MAAM,QAAQ,EAAE,MAAM,OAAO;AACpD,UAAM,OAAO,MAAM;AACnB,QAAI,EAAE,eAAe,SAAS,KAAK,QAAQ,KAAK,KAAK,SAAS,UAAU;AACtE,kBAAY;AACZ,gBAAU;AACV;AAAA;AAAA;AAIJ,MAAI,CAAC,WAAW,QAAQ,SAAS,MAAM;AACrC,WAAO;AAAA;AAGT,MAAI,YAMe,QAAQ;AAE3B,MAAI,EAAE,yBAAyB,YAAY;AACzC,gBAAY,UAAU;AAAA;AAIxB,MAAI,EAAE,qBAAqB,YAAY;AACrC,YAAQ,MAAM;AACd,WAAO;AAAA;AAIT,QAAM,oBAAoB,MACvB,OAGC,CAAC,MAAM,QAAsC;AAC3C,QAAI,EAAE,qBAAqB,OAAO;AAChC,UAAI,EAAE,aAAa,KAAK,aAAa,EAAE,mBAAmB,KAAK,WAAW;AACxE,eAAO,MAAM;AAAA;AAEf,UAAI,EAAE,oBAAoB,KAAK,WAAW;AACxC,eAAO;AAAA;AAET,YAAM,IAAI,MACR,+BAA+B,KAAK,SAAS,UAAU,SAAS,MAAM;AAAA;AAG1E,WAAO;AAAA,KAGV,IAAI,CAAC,SAAS,KAAK;AAKtB,MAAI,kBAAkB,SAAS,GAAG;AAChC,gBAAY,kBAAkB,OAC5B,CAAC,KAAK,QAAQ,EAAE,kBAAkB,MAAM,WAAW,KAAK,WAAW,MACnE;AAAA;AAIJ,SAAO;AAAA;AArEO;",
6
- "names": []
7
- }
@@ -1,69 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as t from "@babel/types";
4
- function getSourceModule(itemName, itemBinding) {
5
- if (!itemBinding.constant) {
6
- return null;
7
- }
8
- let sourceModule;
9
- let imported;
10
- let local;
11
- let destructured;
12
- let usesImportSyntax = false;
13
- const itemNode = itemBinding.path.node;
14
- if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) {
15
- if (t.isImportDeclaration(itemBinding.path.parent)) {
16
- sourceModule = itemBinding.path.parent.source.value;
17
- local = itemNode.local.name;
18
- usesImportSyntax = true;
19
- if (t.isImportSpecifier(itemNode)) {
20
- imported = itemNode.imported["name"];
21
- destructured = true;
22
- } else {
23
- imported = itemNode.local.name;
24
- destructured = false;
25
- }
26
- }
27
- } else if (t.isVariableDeclarator(itemNode) && itemNode.init != null && t.isCallExpression(itemNode.init) && t.isIdentifier(itemNode.init.callee) && itemNode.init.callee.name === "require" && itemNode.init.arguments.length === 1) {
28
- const firstArg = itemNode.init.arguments[0];
29
- if (!t.isStringLiteral(firstArg)) {
30
- return null;
31
- }
32
- sourceModule = firstArg.value;
33
- if (t.isIdentifier(itemNode.id)) {
34
- local = itemNode.id.name;
35
- imported = itemNode.id.name;
36
- destructured = false;
37
- } else if (t.isObjectPattern(itemNode.id)) {
38
- for (const objProp of itemNode.id.properties) {
39
- if (t.isObjectProperty(objProp) && t.isIdentifier(objProp.value) && objProp.value.name === itemName) {
40
- local = objProp.value.name;
41
- imported = objProp.key.name;
42
- destructured = true;
43
- break;
44
- }
45
- }
46
- if (!local || !imported) {
47
- console.error("could not find prop with value `%s`", itemName);
48
- return null;
49
- }
50
- } else {
51
- console.error("Unhandled id type: %s", itemNode.id.type);
52
- return null;
53
- }
54
- } else {
55
- return null;
56
- }
57
- return {
58
- destructured,
59
- imported,
60
- local,
61
- sourceModule,
62
- usesImportSyntax
63
- };
64
- }
65
- __name(getSourceModule, "getSourceModule");
66
- export {
67
- getSourceModule
68
- };
69
- //# sourceMappingURL=getSourceModule.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/getSourceModule.ts"],
4
- "sourcesContent": ["import * as t from '@babel/types'\n\nexport interface SourceModule {\n sourceModule?: string\n imported?: string\n local?: string\n destructured?: boolean\n usesImportSyntax: boolean\n}\n\nexport function getSourceModule(\n itemName: string,\n itemBinding: {\n constant?: boolean\n path: { node: t.Node; parent: any }\n }\n): SourceModule | null {\n // TODO: deal with reassignment\n if (!itemBinding.constant) {\n return null\n }\n\n let sourceModule: string | undefined\n let imported: string | undefined\n let local: string | undefined\n let destructured: boolean | undefined\n let usesImportSyntax = false\n\n const itemNode = itemBinding.path.node\n\n if (\n // import x from 'y';\n t.isImportDefaultSpecifier(itemNode) ||\n // import {x} from 'y';\n t.isImportSpecifier(itemNode)\n ) {\n if (t.isImportDeclaration(itemBinding.path.parent)) {\n sourceModule = itemBinding.path.parent.source.value\n local = itemNode.local.name\n usesImportSyntax = true\n if (t.isImportSpecifier(itemNode)) {\n imported = itemNode.imported['name']\n destructured = true\n } else {\n imported = itemNode.local.name\n destructured = false\n }\n }\n } else if (\n t.isVariableDeclarator(itemNode) &&\n itemNode.init != null &&\n t.isCallExpression(itemNode.init) &&\n t.isIdentifier(itemNode.init.callee) &&\n itemNode.init.callee.name === 'require' &&\n itemNode.init.arguments.length === 1\n ) {\n const firstArg = itemNode.init.arguments[0]\n if (!t.isStringLiteral(firstArg)) {\n return null\n }\n sourceModule = firstArg.value\n\n if (t.isIdentifier(itemNode.id)) {\n local = itemNode.id.name\n imported = itemNode.id.name\n destructured = false\n } else if (t.isObjectPattern(itemNode.id)) {\n for (const objProp of itemNode.id.properties) {\n if (\n t.isObjectProperty(objProp) &&\n t.isIdentifier(objProp.value) &&\n objProp.value.name === itemName\n ) {\n local = objProp.value.name\n // @ts-ignore TODO remove this is only an issue on CI\n imported = objProp.key.name\n destructured = true\n break\n }\n }\n\n if (!local || !imported) {\n console.error('could not find prop with value `%s`', itemName)\n return null\n }\n } else {\n console.error('Unhandled id type: %s', itemNode.id.type)\n return null\n }\n } else {\n return null\n }\n\n return {\n destructured,\n imported,\n local,\n sourceModule,\n usesImportSyntax,\n }\n}\n"],
5
- "mappings": ";;AAAA;AAUO,yBACL,UACA,aAIqB;AAErB,MAAI,CAAC,YAAY,UAAU;AACzB,WAAO;AAAA;AAGT,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,mBAAmB;AAEvB,QAAM,WAAW,YAAY,KAAK;AAElC,MAEE,EAAE,yBAAyB,aAE3B,EAAE,kBAAkB,WACpB;AACA,QAAI,EAAE,oBAAoB,YAAY,KAAK,SAAS;AAClD,qBAAe,YAAY,KAAK,OAAO,OAAO;AAC9C,cAAQ,SAAS,MAAM;AACvB,yBAAmB;AACnB,UAAI,EAAE,kBAAkB,WAAW;AACjC,mBAAW,SAAS,SAAS;AAC7B,uBAAe;AAAA,aACV;AACL,mBAAW,SAAS,MAAM;AAC1B,uBAAe;AAAA;AAAA;AAAA,aAInB,EAAE,qBAAqB,aACvB,SAAS,QAAQ,QACjB,EAAE,iBAAiB,SAAS,SAC5B,EAAE,aAAa,SAAS,KAAK,WAC7B,SAAS,KAAK,OAAO,SAAS,aAC9B,SAAS,KAAK,UAAU,WAAW,GACnC;AACA,UAAM,WAAW,SAAS,KAAK,UAAU;AACzC,QAAI,CAAC,EAAE,gBAAgB,WAAW;AAChC,aAAO;AAAA;AAET,mBAAe,SAAS;AAExB,QAAI,EAAE,aAAa,SAAS,KAAK;AAC/B,cAAQ,SAAS,GAAG;AACpB,iBAAW,SAAS,GAAG;AACvB,qBAAe;AAAA,eACN,EAAE,gBAAgB,SAAS,KAAK;AACzC,iBAAW,WAAW,SAAS,GAAG,YAAY;AAC5C,YACE,EAAE,iBAAiB,YACnB,EAAE,aAAa,QAAQ,UACvB,QAAQ,MAAM,SAAS,UACvB;AACA,kBAAQ,QAAQ,MAAM;AAEtB,qBAAW,QAAQ,IAAI;AACvB,yBAAe;AACf;AAAA;AAAA;AAIJ,UAAI,CAAC,SAAS,CAAC,UAAU;AACvB,gBAAQ,MAAM,uCAAuC;AACrD,eAAO;AAAA;AAAA,WAEJ;AACL,cAAQ,MAAM,yBAAyB,SAAS,GAAG;AACnD,aAAO;AAAA;AAAA,SAEJ;AACL,WAAO;AAAA;AAGT,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAxFY;",
6
- "names": []
7
- }
@@ -1,128 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { dirname, extname, resolve } from "path";
4
- import * as t from "@babel/types";
5
- import { existsSync } from "fs-extra";
6
- import { evaluateAstNode } from "./evaluateAstNode";
7
- import { getSourceModule } from "./getSourceModule";
8
- const isLocalImport = /* @__PURE__ */ __name((path) => path.startsWith(".") || path.startsWith("/"), "isLocalImport");
9
- function resolveImportPath(sourcePath, path) {
10
- const sourceDir = dirname(sourcePath);
11
- if (isLocalImport(path)) {
12
- if (extname(path) === "") {
13
- path += ".js";
14
- }
15
- return resolve(sourceDir, path);
16
- }
17
- return path;
18
- }
19
- __name(resolveImportPath, "resolveImportPath");
20
- function importModule(path) {
21
- const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
22
- for (const file of filenames) {
23
- if (existsSync(file)) {
24
- return require(file);
25
- }
26
- }
27
- return null;
28
- }
29
- __name(importModule, "importModule");
30
- function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
31
- const bindings = scope.getAllBindings();
32
- const ret = {};
33
- if (shouldPrintDebug) {
34
- console.log(" ", Object.keys(bindings).length, "variables in scope");
35
- }
36
- const program = scope.getProgramParent().block;
37
- for (const node of program.body) {
38
- if (t.isImportDeclaration(node)) {
39
- const importPath = node.source.value;
40
- if (!node.specifiers.length)
41
- continue;
42
- if (!isLocalImport(importPath)) {
43
- continue;
44
- }
45
- const moduleName = resolveImportPath(sourcePath, importPath);
46
- const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
47
- if (!isOnWhitelist)
48
- continue;
49
- const src = importModule(moduleName);
50
- if (!src)
51
- continue;
52
- for (const specifier of node.specifiers) {
53
- if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
54
- if (typeof src[specifier.imported.name] !== "undefined") {
55
- const val = src[specifier.local.name];
56
- ret[specifier.local.name] = val;
57
- }
58
- }
59
- }
60
- }
61
- }
62
- if (!bindingCache) {
63
- throw new Error("bindingCache is a required param");
64
- }
65
- for (const k in bindings) {
66
- const binding = bindings[k];
67
- const sourceModule = getSourceModule(k, binding);
68
- if (sourceModule) {
69
- if (!sourceModule.sourceModule) {
70
- continue;
71
- }
72
- const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule);
73
- const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
74
- if (isOnWhitelist) {
75
- const src = importModule(moduleName);
76
- if (!src) {
77
- console.log(`\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`);
78
- return {};
79
- }
80
- if (sourceModule.destructured) {
81
- if (sourceModule.imported) {
82
- ret[k] = src[sourceModule.imported];
83
- }
84
- } else {
85
- ret[k] = src;
86
- }
87
- }
88
- continue;
89
- }
90
- const { parent, parentPath } = binding.path;
91
- if (!t.isVariableDeclaration(parent) || parent.kind !== "const") {
92
- continue;
93
- }
94
- const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k);
95
- if (!dec || !dec.init) {
96
- continue;
97
- }
98
- if (typeof dec.id.start !== "number" || typeof dec.id.end !== "number") {
99
- console.error("dec.id.start/end is not a number");
100
- continue;
101
- }
102
- if (!t.isIdentifier(dec.id)) {
103
- console.error("dec is not an identifier");
104
- continue;
105
- }
106
- const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`;
107
- if (bindingCache.hasOwnProperty(cacheKey)) {
108
- ret[k] = bindingCache[cacheKey];
109
- continue;
110
- }
111
- if (bindingCache.hasOwnProperty(cacheKey)) {
112
- ret[k] = bindingCache[cacheKey];
113
- continue;
114
- }
115
- try {
116
- ret[k] = evaluateAstNode(dec.init, void 0, shouldPrintDebug);
117
- bindingCache[cacheKey] = ret[k];
118
- continue;
119
- } catch (e) {
120
- }
121
- }
122
- return ret;
123
- }
124
- __name(getStaticBindingsForScope, "getStaticBindingsForScope");
125
- export {
126
- getStaticBindingsForScope
127
- };
128
- //# sourceMappingURL=getStaticBindingsForScope.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/getStaticBindingsForScope.ts"],
4
- "sourcesContent": ["import { dirname, extname, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nfunction importModule(path: string) {\n const filenames = [path.replace('.js', '.tsx'), path.replace('.js', '.ts'), path]\n for (const file of filenames) {\n if (existsSync(file)) {\n // TODO we can clear this when we see updates on it later on\n return require(file)\n }\n }\n return null\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
5
- "mappings": ";;AAAA;AAGA;AACA;AAEA;AACA;AAEA,MAAM,gBAAgB,wBAAC,SAAiB,KAAK,WAAW,QAAQ,KAAK,WAAW,MAA1D;AAEtB,2BAA2B,YAAoB,MAAc;AAC3D,QAAM,YAAY,QAAQ;AAC1B,MAAI,cAAc,OAAO;AACvB,QAAI,QAAQ,UAAU,IAAI;AACxB,cAAQ;AAAA;AAEV,WAAO,QAAQ,WAAW;AAAA;AAE5B,SAAO;AAAA;AARA;AAWT,sBAAsB,MAAc;AAClC,QAAM,YAAY,CAAC,KAAK,QAAQ,OAAO,SAAS,KAAK,QAAQ,OAAO,QAAQ;AAC5E,aAAW,QAAQ,WAAW;AAC5B,QAAI,WAAW,OAAO;AAEpB,aAAO,QAAQ;AAAA;AAAA;AAGnB,SAAO;AAAA;AARA;AAWF,mCACL,OACA,YAAsB,IACtB,YACA,cACA,kBACqB;AACrB,QAAM,WAAoC,MAAM;AAChD,QAAM,MAA2B;AAEjC,MAAI,kBAAkB;AAEpB,YAAQ,IAAI,MAAM,OAAO,KAAK,U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