@tamagui/static 1.0.0-alpha.7 → 1.0.0-beta.0

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 (242) hide show
  1. package/README.md +3 -19
  2. package/dist/cjs/constants.js +44 -0
  3. package/dist/cjs/constants.js.map +7 -0
  4. package/dist/cjs/extractor/accessSafe.js +36 -0
  5. package/dist/cjs/extractor/accessSafe.js.map +7 -0
  6. package/dist/cjs/extractor/babelParse.js +56 -0
  7. package/dist/cjs/extractor/babelParse.js.map +7 -0
  8. package/dist/cjs/extractor/buildClassName.js +65 -0
  9. package/dist/cjs/extractor/buildClassName.js.map +7 -0
  10. package/dist/cjs/extractor/createEvaluator.js +78 -0
  11. package/dist/cjs/extractor/createEvaluator.js.map +7 -0
  12. package/dist/cjs/extractor/createExtractor.js +1221 -0
  13. package/dist/cjs/extractor/createExtractor.js.map +7 -0
  14. package/dist/cjs/extractor/ensureImportingConcat.js +49 -0
  15. package/dist/cjs/extractor/ensureImportingConcat.js.map +7 -0
  16. package/dist/cjs/extractor/evaluateAstNode.js +119 -0
  17. package/dist/cjs/extractor/evaluateAstNode.js.map +7 -0
  18. package/dist/cjs/extractor/extractHelpers.js +135 -0
  19. package/dist/cjs/extractor/extractHelpers.js.map +7 -0
  20. package/dist/cjs/extractor/extractMediaStyle.js +191 -0
  21. package/dist/cjs/extractor/extractMediaStyle.js.map +7 -0
  22. package/dist/cjs/extractor/extractToClassNames.js +333 -0
  23. package/dist/cjs/extractor/extractToClassNames.js.map +7 -0
  24. package/dist/cjs/extractor/findTopmostFunction.js +45 -0
  25. package/dist/cjs/extractor/findTopmostFunction.js.map +7 -0
  26. package/dist/cjs/extractor/generatedUid.js +53 -0
  27. package/dist/cjs/extractor/generatedUid.js.map +7 -0
  28. package/dist/cjs/extractor/getPrefixLogs.js +33 -0
  29. package/dist/cjs/extractor/getPrefixLogs.js.map +7 -0
  30. package/dist/cjs/extractor/getPropValueFromAttributes.js +74 -0
  31. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +7 -0
  32. package/dist/cjs/extractor/getSourceModule.js +94 -0
  33. package/dist/cjs/extractor/getSourceModule.js.map +7 -0
  34. package/dist/cjs/extractor/getStaticBindingsForScope.js +162 -0
  35. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +7 -0
  36. package/dist/cjs/extractor/hoistClassNames.js +69 -0
  37. package/dist/cjs/extractor/hoistClassNames.js.map +7 -0
  38. package/dist/cjs/extractor/literalToAst.js +119 -0
  39. package/dist/cjs/extractor/literalToAst.js.map +7 -0
  40. package/dist/cjs/extractor/loadTamagui.js +103 -0
  41. package/dist/cjs/extractor/loadTamagui.js.map +7 -0
  42. package/dist/cjs/extractor/logLines.js +44 -0
  43. package/dist/cjs/extractor/logLines.js.map +7 -0
  44. package/dist/cjs/extractor/normalizeTernaries.js +105 -0
  45. package/dist/cjs/extractor/normalizeTernaries.js.map +7 -0
  46. package/dist/cjs/extractor/removeUnusedHooks.js +104 -0
  47. package/dist/cjs/extractor/removeUnusedHooks.js.map +7 -0
  48. package/dist/cjs/extractor/timer.js +46 -0
  49. package/dist/cjs/extractor/timer.js.map +7 -0
  50. package/dist/cjs/extractor/validHTMLAttributes.js +75 -0
  51. package/dist/cjs/extractor/validHTMLAttributes.js.map +7 -0
  52. package/dist/cjs/index.js +40 -0
  53. package/dist/cjs/index.js.map +7 -0
  54. package/dist/cjs/patchReactNativeWeb.js +167 -0
  55. package/dist/cjs/patchReactNativeWeb.js.map +7 -0
  56. package/dist/cjs/types.js +16 -0
  57. package/dist/cjs/types.js.map +7 -0
  58. package/dist/{constants.js → esm/constants.js} +4 -0
  59. package/dist/{constants.js.map → esm/constants.js.map} +3 -3
  60. package/dist/{extractor → esm/extractor}/accessSafe.js +0 -0
  61. package/dist/{extractor → esm/extractor}/accessSafe.js.map +2 -2
  62. package/dist/{extractor → esm/extractor}/babelParse.js +0 -0
  63. package/dist/{extractor → esm/extractor}/babelParse.js.map +3 -3
  64. package/dist/{extractor → esm/extractor}/buildClassName.js +0 -0
  65. package/dist/{extractor → esm/extractor}/buildClassName.js.map +2 -2
  66. package/dist/{extractor → esm/extractor}/createEvaluator.js +3 -2
  67. package/dist/esm/extractor/createEvaluator.js.map +7 -0
  68. package/dist/esm/extractor/createExtractor.js +1169 -0
  69. package/dist/esm/extractor/createExtractor.js.map +7 -0
  70. package/dist/{extractor → esm/extractor}/ensureImportingConcat.js +1 -1
  71. package/dist/esm/extractor/ensureImportingConcat.js.map +7 -0
  72. package/dist/{extractor → esm/extractor}/evaluateAstNode.js +0 -0
  73. package/dist/esm/extractor/evaluateAstNode.js.map +7 -0
  74. package/dist/{extractor → esm/extractor}/extractHelpers.js +20 -11
  75. package/dist/esm/extractor/extractHelpers.js.map +7 -0
  76. package/dist/{extractor → esm/extractor}/extractMediaStyle.js +5 -4
  77. package/dist/esm/extractor/extractMediaStyle.js.map +7 -0
  78. package/dist/{extractor → esm/extractor}/extractToClassNames.js +108 -50
  79. package/dist/esm/extractor/extractToClassNames.js.map +7 -0
  80. package/dist/{extractor → esm/extractor}/findTopmostFunction.js +0 -0
  81. package/dist/{extractor → esm/extractor}/findTopmostFunction.js.map +2 -2
  82. package/dist/{extractor → esm/extractor}/generatedUid.js +0 -0
  83. package/dist/{extractor → esm/extractor}/generatedUid.js.map +2 -2
  84. package/dist/esm/extractor/getPrefixLogs.js +12 -0
  85. package/dist/esm/extractor/getPrefixLogs.js.map +7 -0
  86. package/dist/{extractor → esm/extractor}/getPropValueFromAttributes.js +0 -0
  87. package/dist/{extractor → esm/extractor}/getPropValueFromAttributes.js.map +2 -2
  88. package/dist/{extractor → esm/extractor}/getSourceModule.js +0 -0
  89. package/dist/{extractor → esm/extractor}/getSourceModule.js.map +2 -2
  90. package/dist/{extractor → esm/extractor}/getStaticBindingsForScope.js +10 -1
  91. package/dist/esm/extractor/getStaticBindingsForScope.js.map +7 -0
  92. package/dist/{extractor → esm/extractor}/hoistClassNames.js +0 -0
  93. package/dist/{extractor → esm/extractor}/hoistClassNames.js.map +2 -2
  94. package/dist/esm/extractor/literalToAst.js +80 -0
  95. package/dist/esm/extractor/literalToAst.js.map +7 -0
  96. package/dist/esm/extractor/loadTamagui.js +81 -0
  97. package/dist/esm/extractor/loadTamagui.js.map +7 -0
  98. package/dist/esm/extractor/logLines.js +22 -0
  99. package/dist/esm/extractor/logLines.js.map +7 -0
  100. package/dist/{extractor → esm/extractor}/normalizeTernaries.js +3 -2
  101. package/dist/esm/extractor/normalizeTernaries.js.map +7 -0
  102. package/dist/{extractor → esm/extractor}/removeUnusedHooks.js +5 -3
  103. package/dist/esm/extractor/removeUnusedHooks.js.map +7 -0
  104. package/dist/esm/extractor/timer.js +24 -0
  105. package/dist/esm/extractor/timer.js.map +7 -0
  106. package/dist/esm/extractor/validHTMLAttributes.js +52 -0
  107. package/dist/esm/extractor/validHTMLAttributes.js.map +7 -0
  108. package/dist/{index.js → esm/index.js} +0 -0
  109. package/dist/{index.js.map → esm/index.js.map} +1 -1
  110. package/dist/{patchReactNativeWeb.js → esm/patchReactNativeWeb.js} +49 -14
  111. package/dist/esm/patchReactNativeWeb.js.map +7 -0
  112. package/dist/{types.js → esm/types.js} +0 -0
  113. package/dist/{types.js.map → esm/types.js.map} +0 -0
  114. package/dist/jsx/constants.js +13 -0
  115. package/dist/jsx/extractor/accessSafe.js +10 -0
  116. package/dist/jsx/extractor/babelParse.js +29 -0
  117. package/dist/jsx/extractor/buildClassName.js +39 -0
  118. package/dist/jsx/extractor/createEvaluator.js +51 -0
  119. package/dist/jsx/extractor/createExtractor.js +1168 -0
  120. package/dist/jsx/extractor/ensureImportingConcat.js +23 -0
  121. package/dist/jsx/extractor/evaluateAstNode.js +93 -0
  122. package/dist/jsx/extractor/extractHelpers.js +102 -0
  123. package/dist/jsx/extractor/extractMediaStyle.js +151 -0
  124. package/dist/jsx/extractor/extractToClassNames.js +292 -0
  125. package/dist/jsx/extractor/findTopmostFunction.js +22 -0
  126. package/dist/jsx/extractor/generatedUid.js +27 -0
  127. package/dist/jsx/extractor/getPrefixLogs.js +11 -0
  128. package/dist/jsx/extractor/getPropValueFromAttributes.js +48 -0
  129. package/dist/jsx/extractor/getSourceModule.js +68 -0
  130. package/dist/jsx/extractor/getStaticBindingsForScope.js +136 -0
  131. package/dist/jsx/extractor/hoistClassNames.js +43 -0
  132. package/dist/jsx/extractor/literalToAst.js +79 -0
  133. package/dist/jsx/extractor/loadTamagui.js +80 -0
  134. package/dist/jsx/extractor/logLines.js +21 -0
  135. package/dist/jsx/extractor/normalizeTernaries.js +52 -0
  136. package/dist/jsx/extractor/removeUnusedHooks.js +79 -0
  137. package/dist/jsx/extractor/timer.js +23 -0
  138. package/dist/jsx/extractor/validHTMLAttributes.js +51 -0
  139. package/dist/jsx/index.js +13 -0
  140. package/dist/jsx/patchReactNativeWeb.js +141 -0
  141. package/dist/jsx/types.js +0 -0
  142. package/package.json +40 -36
  143. package/types/constants.d.ts +6 -0
  144. package/types/constants.d.ts.map +1 -0
  145. package/types/extractor/accessSafe.d.ts +3 -0
  146. package/types/extractor/accessSafe.d.ts.map +1 -0
  147. package/types/extractor/babelParse.d.ts +5 -0
  148. package/types/extractor/babelParse.d.ts.map +1 -0
  149. package/types/extractor/buildClassName.d.ts +4 -0
  150. package/types/extractor/buildClassName.d.ts.map +1 -0
  151. package/types/extractor/createEvaluator.d.ts +12 -0
  152. package/types/extractor/createEvaluator.d.ts.map +1 -0
  153. package/types/extractor/createExtractor.d.ts +29 -0
  154. package/types/extractor/createExtractor.d.ts.map +1 -0
  155. package/types/extractor/ensureImportingConcat.d.ts +4 -0
  156. package/types/extractor/ensureImportingConcat.d.ts.map +1 -0
  157. package/types/extractor/evaluateAstNode.d.ts +3 -0
  158. package/types/extractor/evaluateAstNode.d.ts.map +1 -0
  159. package/types/extractor/extractHelpers.d.ts +12 -0
  160. package/types/extractor/extractHelpers.d.ts.map +1 -0
  161. package/types/extractor/extractMediaStyle.d.ts +10 -0
  162. package/types/extractor/extractMediaStyle.d.ts.map +1 -0
  163. package/types/extractor/extractToClassNames.d.ts +24 -0
  164. package/types/extractor/extractToClassNames.d.ts.map +1 -0
  165. package/types/extractor/findTopmostFunction.d.ts +4 -0
  166. package/types/extractor/findTopmostFunction.d.ts.map +1 -0
  167. package/types/extractor/generatedUid.d.ts +5 -0
  168. package/types/extractor/generatedUid.d.ts.map +1 -0
  169. package/types/extractor/getPrefixLogs.d.ts +3 -0
  170. package/types/extractor/getPrefixLogs.d.ts.map +1 -0
  171. package/types/extractor/getPropValueFromAttributes.d.ts +3 -0
  172. package/types/extractor/getPropValueFromAttributes.d.ts.map +1 -0
  173. package/types/extractor/getSourceModule.d.ts +16 -0
  174. package/types/extractor/getSourceModule.d.ts.map +1 -0
  175. package/types/extractor/getStaticBindingsForScope.d.ts +4 -0
  176. package/types/extractor/getStaticBindingsForScope.d.ts.map +1 -0
  177. package/types/extractor/hoistClassNames.d.ts +6 -0
  178. package/types/extractor/hoistClassNames.d.ts.map +1 -0
  179. package/types/extractor/literalToAst.d.ts +4 -0
  180. package/types/extractor/literalToAst.d.ts.map +1 -0
  181. package/types/extractor/loadTamagui.d.ts +9 -0
  182. package/types/extractor/loadTamagui.d.ts.map +1 -0
  183. package/types/extractor/logLines.d.ts +2 -0
  184. package/types/extractor/logLines.d.ts.map +1 -0
  185. package/types/extractor/normalizeTernaries.d.ts +3 -0
  186. package/types/extractor/normalizeTernaries.d.ts.map +1 -0
  187. package/types/extractor/removeUnusedHooks.d.ts +3 -0
  188. package/types/extractor/removeUnusedHooks.d.ts.map +1 -0
  189. package/types/extractor/timer.d.ts +5 -0
  190. package/types/extractor/timer.d.ts.map +1 -0
  191. package/types/extractor/validHTMLAttributes.d.ts +49 -0
  192. package/types/extractor/validHTMLAttributes.d.ts.map +1 -0
  193. package/types/index.d.ts +8 -0
  194. package/types/index.d.ts.map +1 -0
  195. package/types/patchReactNativeWeb.d.ts +2 -0
  196. package/types/patchReactNativeWeb.d.ts.map +1 -0
  197. package/types/types.d.ts +85 -0
  198. package/types/types.d.ts.map +1 -0
  199. package/LICENSE +0 -21
  200. package/dist/extractor/createEvaluator.js.map +0 -7
  201. package/dist/extractor/createExtractor.js +0 -820
  202. package/dist/extractor/createExtractor.js.map +0 -7
  203. package/dist/extractor/ensureImportingConcat.js.map +0 -7
  204. package/dist/extractor/evaluateAstNode.js.map +0 -7
  205. package/dist/extractor/extractHelpers.js.map +0 -7
  206. package/dist/extractor/extractMediaStyle.js.map +0 -7
  207. package/dist/extractor/extractToClassNames.js.map +0 -7
  208. package/dist/extractor/getStaticBindingsForScope.js.map +0 -7
  209. package/dist/extractor/literalToAst.js +0 -34
  210. package/dist/extractor/literalToAst.js.map +0 -7
  211. package/dist/extractor/loadTamagui.js +0 -41
  212. package/dist/extractor/loadTamagui.js.map +0 -7
  213. package/dist/extractor/normalizeTernaries.js.map +0 -7
  214. package/dist/extractor/removeUnusedHooks.js.map +0 -7
  215. package/dist/index.cjs +0 -2109
  216. package/dist/index.cjs.map +0 -7
  217. package/dist/patchReactNativeWeb.js.map +0 -7
  218. package/src/constants.ts +0 -10
  219. package/src/extractor/accessSafe.ts +0 -18
  220. package/src/extractor/babelParse.ts +0 -27
  221. package/src/extractor/buildClassName.ts +0 -61
  222. package/src/extractor/createEvaluator.ts +0 -68
  223. package/src/extractor/createExtractor.ts +0 -1139
  224. package/src/extractor/ensureImportingConcat.ts +0 -33
  225. package/src/extractor/evaluateAstNode.ts +0 -121
  226. package/src/extractor/extractHelpers.ts +0 -102
  227. package/src/extractor/extractMediaStyle.ts +0 -191
  228. package/src/extractor/extractToClassNames.ts +0 -326
  229. package/src/extractor/findTopmostFunction.ts +0 -22
  230. package/src/extractor/generatedUid.ts +0 -43
  231. package/src/extractor/getPropValueFromAttributes.ts +0 -92
  232. package/src/extractor/getSourceModule.ts +0 -101
  233. package/src/extractor/getStaticBindingsForScope.ts +0 -173
  234. package/src/extractor/hoistClassNames.ts +0 -45
  235. package/src/extractor/literalToAst.ts +0 -32
  236. package/src/extractor/loadTamagui.ts +0 -61
  237. package/src/extractor/normalizeTernaries.ts +0 -60
  238. package/src/extractor/removeUnusedHooks.ts +0 -76
  239. package/src/index.ts +0 -9
  240. package/src/patchReactNativeWeb.ts +0 -123
  241. package/src/types.ts +0 -84
  242. package/types.d.ts +0 -217
@@ -0,0 +1,53 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var generatedUid_exports = {};
23
+ __export(generatedUid_exports, {
24
+ generateUid: () => generateUid
25
+ });
26
+ module.exports = __toCommonJS(generatedUid_exports);
27
+ var t = __toESM(require("@babel/types"));
28
+ var import_invariant = __toESM(require("invariant"));
29
+ function generateUid(scope, name) {
30
+ (0, import_invariant.default)(typeof scope === "object", "generateUid expects a scope object as its first parameter");
31
+ (0, import_invariant.default)(typeof name === "string" && name !== "", "generateUid expects a valid name as its second parameter");
32
+ name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
33
+ let uid;
34
+ let i = 0;
35
+ do {
36
+ if (i > 1) {
37
+ uid = name + i;
38
+ } else {
39
+ uid = name;
40
+ }
41
+ i++;
42
+ } while (scope.hasLabel(uid) || scope.hasBinding(uid) || scope.hasGlobal(uid) || scope.hasReference(uid));
43
+ const program = scope.getProgramParent();
44
+ program.references[uid] = true;
45
+ program.uids[uid] = true;
46
+ return uid;
47
+ }
48
+ __name(generateUid, "generateUid");
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ generateUid
52
+ });
53
+ //# sourceMappingURL=generatedUid.js.map
@@ -0,0 +1,7 @@
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;AAAA;AAAA;AAAA;AAAA;AAAA,QAAmB;AACnB,uBAAsB;AAQf,qBAAqB,OAAY,MAAsB;AAC5D,gCAAU,OAAO,UAAU,UAAU,2DAA2D;AAChG,gCACE,OAAO,SAAS,YAAY,SAAS,IACrC,0DACF;AAEA,SAAO,EACJ,aAAa,IAAI,EACjB,QAAQ,OAAO,EAAE,EACjB,QAAQ,YAAY,EAAE;AAEzB,MAAI;AACJ,MAAI,IAAI;AACR,KAAG;AACD,QAAI,IAAI,GAAG;AACT,YAAM,OAAO;AAAA,IACf,OAAO;AACL,YAAM;AAAA,IACR;AACA;AAAA,EACF,SACE,MAAM,SAAS,GAAG,KAClB,MAAM,WAAW,GAAG,KACpB,MAAM,UAAU,GAAG,KACnB,MAAM,aAAa,GAAG;AAGxB,QAAM,UAAU,MAAM,iBAAiB;AACvC,UAAQ,WAAW,OAAO;AAC1B,UAAQ,KAAK,OAAO;AAEpB,SAAO;AACT;AAjCgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var getPrefixLogs_exports = {};
20
+ __export(getPrefixLogs_exports, {
21
+ getPrefixLogs: () => getPrefixLogs
22
+ });
23
+ module.exports = __toCommonJS(getPrefixLogs_exports);
24
+ function getPrefixLogs(options) {
25
+ const { TAMAGUI_TARGET } = process.env;
26
+ return (options == null ? void 0 : options.prefixLogs) ?? ` ${TAMAGUI_TARGET} | `;
27
+ }
28
+ __name(getPrefixLogs, "getPrefixLogs");
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ getPrefixLogs
32
+ });
33
+ //# sourceMappingURL=getPrefixLogs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extractor/getPrefixLogs.ts"],
4
+ "sourcesContent": ["import { TamaguiOptions } from '../types'\n\nexport function getPrefixLogs(options?: TamaguiOptions) {\n const { TAMAGUI_TARGET } = process.env\n return options?.prefixLogs ?? ` ${TAMAGUI_TARGET} | `\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,uBAAuB,SAA0B;AACtD,QAAM,EAAE,mBAAmB,QAAQ;AACnC,SAAO,oCAAS,eAAc,IAAI;AACpC;AAHgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,74 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var getPropValueFromAttributes_exports = {};
23
+ __export(getPropValueFromAttributes_exports, {
24
+ getPropValueFromAttributes: () => getPropValueFromAttributes
25
+ });
26
+ module.exports = __toCommonJS(getPropValueFromAttributes_exports);
27
+ var import_generator = __toESM(require("@babel/generator"));
28
+ var t = __toESM(require("@babel/types"));
29
+ var import_accessSafe = require("./accessSafe");
30
+ function getPropValueFromAttributes(propName, attrs) {
31
+ let propIndex = -1;
32
+ let jsxAttr = null;
33
+ for (let idx = -1, len = attrs.length; ++idx < len; ) {
34
+ const attr = attrs[idx];
35
+ if (t.isJSXAttribute(attr) && attr.name && attr.name.name === propName) {
36
+ propIndex = idx;
37
+ jsxAttr = attr;
38
+ break;
39
+ }
40
+ }
41
+ if (!jsxAttr || jsxAttr.value == null) {
42
+ return null;
43
+ }
44
+ let propValue = jsxAttr.value;
45
+ if (t.isJSXExpressionContainer(propValue)) {
46
+ propValue = propValue.expression;
47
+ }
48
+ if (t.isJSXEmptyExpression(propValue)) {
49
+ console.error("encountered JSXEmptyExpression");
50
+ return null;
51
+ }
52
+ const applicableSpreads = attrs.filter((attr, idx) => {
53
+ if (t.isJSXSpreadAttribute(attr)) {
54
+ if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) {
55
+ return idx > propIndex;
56
+ }
57
+ if (t.isLogicalExpression(attr.argument)) {
58
+ return false;
59
+ }
60
+ throw new Error(`unsupported spread of type "${attr.argument.type}": ${(0, import_generator.default)(attr).code}`);
61
+ }
62
+ return false;
63
+ }).map((attr) => attr.argument);
64
+ if (applicableSpreads.length > 0) {
65
+ propValue = applicableSpreads.reduce((acc, val) => t.logicalExpression("||", (0, import_accessSafe.accessSafe)(val, propName), acc), propValue);
66
+ }
67
+ return propValue;
68
+ }
69
+ __name(getPropValueFromAttributes, "getPropValueFromAttributes");
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ getPropValueFromAttributes
73
+ });
74
+ //# sourceMappingURL=getPropValueFromAttributes.js.map
@@ -0,0 +1,7 @@
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;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqB;AACrB,QAAmB;AAEnB,wBAA2B;AAkBpB,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,IAAI,KAAK,KAAK,QAAQ,KAAK,KAAK,SAAS,UAAU;AACtE,kBAAY;AACZ,gBAAU;AACV;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,QAAQ,SAAS,MAAM;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,YAMe,QAAQ;AAE3B,MAAI,EAAE,yBAAyB,SAAS,GAAG;AACzC,gBAAY,UAAU;AAAA,EACxB;AAGA,MAAI,EAAE,qBAAqB,SAAS,GAAG;AACrC,YAAQ,MAAM,gCAAgC;AAC9C,WAAO;AAAA,EACT;AAGA,QAAM,oBAAoB,MACvB,OAGC,CAAC,MAAM,QAAsC;AAC3C,QAAI,EAAE,qBAAqB,IAAI,GAAG;AAChC,UAAI,EAAE,aAAa,KAAK,QAAQ,KAAK,EAAE,mBAAmB,KAAK,QAAQ,GAAG;AACxE,eAAO,MAAM;AAAA,MACf;AACA,UAAI,EAAE,oBAAoB,KAAK,QAAQ,GAAG;AACxC,eAAO;AAAA,MACT;AACA,YAAM,IAAI,MACR,+BAA+B,KAAK,SAAS,UAAU,8BAAS,IAAI,EAAE,MACxE;AAAA,IACF;AACA,WAAO;AAAA,EACT,CACF,EACC,IAAI,CAAC,SAAS,KAAK,QAAQ;AAK9B,MAAI,kBAAkB,SAAS,GAAG;AAChC,gBAAY,kBAAkB,OAC5B,CAAC,KAAK,QAAQ,EAAE,kBAAkB,MAAM,kCAAW,KAAK,QAAQ,GAAG,GAAG,GACtE,SACF;AAAA,EACF;AAEA,SAAO;AACT;AAtEgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,94 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var getSourceModule_exports = {};
23
+ __export(getSourceModule_exports, {
24
+ getSourceModule: () => getSourceModule
25
+ });
26
+ module.exports = __toCommonJS(getSourceModule_exports);
27
+ var t = __toESM(require("@babel/types"));
28
+ function getSourceModule(itemName, itemBinding) {
29
+ if (!itemBinding.constant) {
30
+ return null;
31
+ }
32
+ let sourceModule;
33
+ let imported;
34
+ let local;
35
+ let destructured;
36
+ let usesImportSyntax = false;
37
+ const itemNode = itemBinding.path.node;
38
+ if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) {
39
+ if (t.isImportDeclaration(itemBinding.path.parent)) {
40
+ sourceModule = itemBinding.path.parent.source.value;
41
+ local = itemNode.local.name;
42
+ usesImportSyntax = true;
43
+ if (t.isImportSpecifier(itemNode)) {
44
+ imported = itemNode.imported["name"];
45
+ destructured = true;
46
+ } else {
47
+ imported = itemNode.local.name;
48
+ destructured = false;
49
+ }
50
+ }
51
+ } 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) {
52
+ const firstArg = itemNode.init.arguments[0];
53
+ if (!t.isStringLiteral(firstArg)) {
54
+ return null;
55
+ }
56
+ sourceModule = firstArg.value;
57
+ if (t.isIdentifier(itemNode.id)) {
58
+ local = itemNode.id.name;
59
+ imported = itemNode.id.name;
60
+ destructured = false;
61
+ } else if (t.isObjectPattern(itemNode.id)) {
62
+ for (const objProp of itemNode.id.properties) {
63
+ if (t.isObjectProperty(objProp) && t.isIdentifier(objProp.value) && objProp.value.name === itemName) {
64
+ local = objProp.value.name;
65
+ imported = objProp.key.name;
66
+ destructured = true;
67
+ break;
68
+ }
69
+ }
70
+ if (!local || !imported) {
71
+ console.error("could not find prop with value `%s`", itemName);
72
+ return null;
73
+ }
74
+ } else {
75
+ console.error("Unhandled id type: %s", itemNode.id.type);
76
+ return null;
77
+ }
78
+ } else {
79
+ return null;
80
+ }
81
+ return {
82
+ destructured,
83
+ imported,
84
+ local,
85
+ sourceModule,
86
+ usesImportSyntax
87
+ };
88
+ }
89
+ __name(getSourceModule, "getSourceModule");
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ getSourceModule
93
+ });
94
+ //# sourceMappingURL=getSourceModule.js.map
@@ -0,0 +1,7 @@
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;AAAA;AAAA;AAAA;AAAA;AAAA,QAAmB;AAUZ,yBACL,UACA,aAIqB;AAErB,MAAI,CAAC,YAAY,UAAU;AACzB,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,mBAAmB;AAEvB,QAAM,WAAW,YAAY,KAAK;AAElC,MAEE,EAAE,yBAAyB,QAAQ,KAEnC,EAAE,kBAAkB,QAAQ,GAC5B;AACA,QAAI,EAAE,oBAAoB,YAAY,KAAK,MAAM,GAAG;AAClD,qBAAe,YAAY,KAAK,OAAO,OAAO;AAC9C,cAAQ,SAAS,MAAM;AACvB,yBAAmB;AACnB,UAAI,EAAE,kBAAkB,QAAQ,GAAG;AACjC,mBAAW,SAAS,SAAS;AAC7B,uBAAe;AAAA,MACjB,OAAO;AACL,mBAAW,SAAS,MAAM;AAC1B,uBAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF,WACE,EAAE,qBAAqB,QAAQ,KAC/B,SAAS,QAAQ,QACjB,EAAE,iBAAiB,SAAS,IAAI,KAChC,EAAE,aAAa,SAAS,KAAK,MAAM,KACnC,SAAS,KAAK,OAAO,SAAS,aAC9B,SAAS,KAAK,UAAU,WAAW,GACnC;AACA,UAAM,WAAW,SAAS,KAAK,UAAU;AACzC,QAAI,CAAC,EAAE,gBAAgB,QAAQ,GAAG;AAChC,aAAO;AAAA,IACT;AACA,mBAAe,SAAS;AAExB,QAAI,EAAE,aAAa,SAAS,EAAE,GAAG;AAC/B,cAAQ,SAAS,GAAG;AACpB,iBAAW,SAAS,GAAG;AACvB,qBAAe;AAAA,IACjB,WAAW,EAAE,gBAAgB,SAAS,EAAE,GAAG;AACzC,iBAAW,WAAW,SAAS,GAAG,YAAY;AAC5C,YACE,EAAE,iBAAiB,OAAO,KAC1B,EAAE,aAAa,QAAQ,KAAK,KAC5B,QAAQ,MAAM,SAAS,UACvB;AACA,kBAAQ,QAAQ,MAAM;AAEtB,qBAAW,QAAQ,IAAI;AACvB,yBAAe;AACf;AAAA,QACF;AAAA,MACF;AAEA,UAAI,CAAC,SAAS,CAAC,UAAU;AACvB,gBAAQ,MAAM,uCAAuC,QAAQ;AAC7D,eAAO;AAAA,MACT;AAAA,IACF,OAAO;AACL,cAAQ,MAAM,yBAAyB,SAAS,GAAG,IAAI;AACvD,aAAO;AAAA,IACT;AAAA,EACF,OAAO;AACL,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AA1FgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,162 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var getStaticBindingsForScope_exports = {};
23
+ __export(getStaticBindingsForScope_exports, {
24
+ getStaticBindingsForScope: () => getStaticBindingsForScope
25
+ });
26
+ module.exports = __toCommonJS(getStaticBindingsForScope_exports);
27
+ var import_path = require("path");
28
+ var t = __toESM(require("@babel/types"));
29
+ var import_fs_extra = require("fs-extra");
30
+ var import_evaluateAstNode = require("./evaluateAstNode");
31
+ var import_getSourceModule = require("./getSourceModule");
32
+ const isLocalImport = /* @__PURE__ */ __name((path) => path.startsWith(".") || path.startsWith("/"), "isLocalImport");
33
+ function resolveImportPath(sourcePath, path) {
34
+ const sourceDir = (0, import_path.dirname)(sourcePath);
35
+ if (isLocalImport(path)) {
36
+ if ((0, import_path.extname)(path) === "") {
37
+ path += ".js";
38
+ }
39
+ return (0, import_path.resolve)(sourceDir, path);
40
+ }
41
+ return path;
42
+ }
43
+ __name(resolveImportPath, "resolveImportPath");
44
+ function importModule(path) {
45
+ const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
46
+ for (const file of filenames) {
47
+ if ((0, import_fs_extra.existsSync)(file)) {
48
+ const { unregister } = require("esbuild-register/dist/node").register({
49
+ target: "es2019",
50
+ format: "cjs"
51
+ });
52
+ try {
53
+ return require(file);
54
+ } catch {
55
+ } finally {
56
+ unregister();
57
+ }
58
+ }
59
+ }
60
+ return null;
61
+ }
62
+ __name(importModule, "importModule");
63
+ function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
64
+ const bindings = scope.getAllBindings();
65
+ const ret = {};
66
+ if (shouldPrintDebug) {
67
+ console.log(" ", Object.keys(bindings).length, "variables in scope");
68
+ }
69
+ const program = scope.getProgramParent().block;
70
+ for (const node of program.body) {
71
+ if (t.isImportDeclaration(node)) {
72
+ const importPath = node.source.value;
73
+ if (!node.specifiers.length)
74
+ continue;
75
+ if (!isLocalImport(importPath)) {
76
+ continue;
77
+ }
78
+ const moduleName = resolveImportPath(sourcePath, importPath);
79
+ const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
80
+ if (!isOnWhitelist)
81
+ continue;
82
+ const src = importModule(moduleName);
83
+ if (!src)
84
+ continue;
85
+ for (const specifier of node.specifiers) {
86
+ if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
87
+ if (typeof src[specifier.imported.name] !== "undefined") {
88
+ const val = src[specifier.local.name];
89
+ ret[specifier.local.name] = val;
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ if (!bindingCache) {
96
+ throw new Error("bindingCache is a required param");
97
+ }
98
+ for (const k in bindings) {
99
+ const binding = bindings[k];
100
+ const sourceModule = (0, import_getSourceModule.getSourceModule)(k, binding);
101
+ if (sourceModule) {
102
+ if (!sourceModule.sourceModule) {
103
+ continue;
104
+ }
105
+ const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule);
106
+ const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
107
+ if (isOnWhitelist) {
108
+ const src = importModule(moduleName);
109
+ if (!src) {
110
+ console.log(`\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`);
111
+ return {};
112
+ }
113
+ if (sourceModule.destructured) {
114
+ if (sourceModule.imported) {
115
+ ret[k] = src[sourceModule.imported];
116
+ }
117
+ } else {
118
+ ret[k] = src;
119
+ }
120
+ }
121
+ continue;
122
+ }
123
+ const { parent, parentPath } = binding.path;
124
+ if (!t.isVariableDeclaration(parent) || parent.kind !== "const") {
125
+ continue;
126
+ }
127
+ const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k);
128
+ if (!dec || !dec.init) {
129
+ continue;
130
+ }
131
+ if (typeof dec.id.start !== "number" || typeof dec.id.end !== "number") {
132
+ console.error("dec.id.start/end is not a number");
133
+ continue;
134
+ }
135
+ if (!t.isIdentifier(dec.id)) {
136
+ console.error("dec is not an identifier");
137
+ continue;
138
+ }
139
+ const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`;
140
+ if (bindingCache.hasOwnProperty(cacheKey)) {
141
+ ret[k] = bindingCache[cacheKey];
142
+ continue;
143
+ }
144
+ if (bindingCache.hasOwnProperty(cacheKey)) {
145
+ ret[k] = bindingCache[cacheKey];
146
+ continue;
147
+ }
148
+ try {
149
+ ret[k] = (0, import_evaluateAstNode.evaluateAstNode)(dec.init, void 0, shouldPrintDebug);
150
+ bindingCache[cacheKey] = ret[k];
151
+ continue;
152
+ } catch (e) {
153
+ }
154
+ }
155
+ return ret;
156
+ }
157
+ __name(getStaticBindingsForScope, "getStaticBindingsForScope");
158
+ // Annotate the CommonJS export names for ESM import in node:
159
+ 0 && (module.exports = {
160
+ getStaticBindingsForScope
161
+ });
162
+ //# sourceMappingURL=getStaticBindingsForScope.js.map
@@ -0,0 +1,7 @@
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 const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n try {\n // TODO we can clear this when we see updates on it later on\n return require(file)\n } catch {\n // doesn't exists\n } finally {\n unregister()\n }\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 | 'verbose'\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": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,69 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var hoistClassNames_exports = {};
23
+ __export(hoistClassNames_exports, {
24
+ hoistClassNames: () => hoistClassNames
25
+ });
26
+ module.exports = __toCommonJS(hoistClassNames_exports);
27
+ var t = __toESM(require("@babel/types"));
28
+ function hoistClassNames(path, existing, expr) {
29
+ const hoist = hoistClassNames.bind(null, path, existing);
30
+ if (t.isStringLiteral(expr)) {
31
+ if (expr.value.trim() === "") {
32
+ return expr;
33
+ }
34
+ if (existing[expr.value]) {
35
+ return existing[expr.value];
36
+ }
37
+ const identifier = replaceStringWithVariable(expr);
38
+ existing[expr.value] = identifier;
39
+ return identifier;
40
+ }
41
+ if (t.isBinaryExpression(expr)) {
42
+ return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
43
+ }
44
+ if (t.isLogicalExpression(expr)) {
45
+ return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
46
+ }
47
+ if (t.isConditionalExpression(expr)) {
48
+ return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
49
+ }
50
+ return expr;
51
+ function replaceStringWithVariable(str) {
52
+ const uid = path.scope.generateUidIdentifier("cn");
53
+ const parent = path.findParent((path2) => path2.isProgram());
54
+ if (!parent)
55
+ throw new Error(`no program?`);
56
+ const variable = t.variableDeclaration("const", [
57
+ t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))
58
+ ]);
59
+ parent.unshiftContainer("body", variable);
60
+ return uid;
61
+ }
62
+ __name(replaceStringWithVariable, "replaceStringWithVariable");
63
+ }
64
+ __name(hoistClassNames, "hoistClassNames");
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ hoistClassNames
68
+ });
69
+ //# sourceMappingURL=hoistClassNames.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extractor/hoistClassNames.ts"],
4
+ "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nexport function hoistClassNames(\n path: NodePath<t.JSXElement>,\n existing: { [key: string]: t.Identifier },\n expr: t.Expression\n) {\n const hoist = hoistClassNames.bind(null, path, existing)\n if (t.isStringLiteral(expr)) {\n if (expr.value.trim() === '') {\n return expr\n }\n if (existing[expr.value]) {\n return existing[expr.value]\n }\n const identifier = replaceStringWithVariable(expr)\n existing[expr.value] = identifier\n return identifier\n }\n if (t.isBinaryExpression(expr)) {\n return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right))\n }\n if (t.isLogicalExpression(expr)) {\n return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right))\n }\n if (t.isConditionalExpression(expr)) {\n return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate))\n }\n return expr\n\n function replaceStringWithVariable(str: t.StringLiteral): t.Identifier {\n // hoist outside fn!\n const uid = path.scope.generateUidIdentifier('cn')\n const parent = path.findParent((path) => path.isProgram())\n if (!parent) throw new Error(`no program?`)\n const variable = t.variableDeclaration('const', [\n // adding a space for extra safety\n t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`)),\n ])\n // @ts-ignore\n parent.unshiftContainer('body', variable)\n return uid\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,QAAmB;AAEZ,yBACL,MACA,UACA,MACA;AACA,QAAM,QAAQ,gBAAgB,KAAK,MAAM,MAAM,QAAQ;AACvD,MAAI,EAAE,gBAAgB,IAAI,GAAG;AAC3B,QAAI,KAAK,MAAM,KAAK,MAAM,IAAI;AAC5B,aAAO;AAAA,IACT;AACA,QAAI,SAAS,KAAK,QAAQ;AACxB,aAAO,SAAS,KAAK;AAAA,IACvB;AACA,UAAM,aAAa,0BAA0B,IAAI;AACjD,aAAS,KAAK,SAAS;AACvB,WAAO;AAAA,EACT;AACA,MAAI,EAAE,mBAAmB,IAAI,GAAG;AAC9B,WAAO,EAAE,iBAAiB,KAAK,UAAU,MAAM,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;AAAA,EAC9E;AACA,MAAI,EAAE,oBAAoB,IAAI,GAAG;AAC/B,WAAO,EAAE,kBAAkB,KAAK,UAAU,MAAM,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;AAAA,EAC/E;AACA,MAAI,EAAE,wBAAwB,IAAI,GAAG;AACnC,WAAO,EAAE,sBAAsB,KAAK,MAAM,MAAM,KAAK,UAAU,GAAG,MAAM,KAAK,SAAS,CAAC;AAAA,EACzF;AACA,SAAO;AAEP,qCAAmC,KAAoC;AAErE,UAAM,MAAM,KAAK,MAAM,sBAAsB,IAAI;AACjD,UAAM,SAAS,KAAK,WAAW,CAAC,UAAS,MAAK,UAAU,CAAC;AACzD,QAAI,CAAC;AAAQ,YAAM,IAAI,MAAM,aAAa;AAC1C,UAAM,WAAW,EAAE,oBAAoB,SAAS;AAAA,MAE9C,EAAE,mBAAmB,KAAK,EAAE,cAAc,IAAI,IAAI,OAAO,CAAC;AAAA,IAC5D,CAAC;AAED,WAAO,iBAAiB,QAAQ,QAAQ;AACxC,WAAO;AAAA,EACT;AAZS;AAaX;AAzCgB;",
6
+ "names": []
7
+ }