@wyw-in-js/transform 0.1.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 (480) hide show
  1. package/LICENSE +21 -0
  2. package/esm/babel.js +2 -0
  3. package/esm/babel.js.map +1 -0
  4. package/esm/cache.js +80 -0
  5. package/esm/cache.js.map +1 -0
  6. package/esm/debug/fileReporter.js +144 -0
  7. package/esm/debug/fileReporter.js.map +1 -0
  8. package/esm/evaluators/index.js +14 -0
  9. package/esm/evaluators/index.js.map +1 -0
  10. package/esm/index.js +24 -0
  11. package/esm/index.js.map +1 -0
  12. package/esm/module.js +316 -0
  13. package/esm/module.js.map +1 -0
  14. package/esm/options/babel-merge.d.js +2 -0
  15. package/esm/options/babel-merge.d.js.map +1 -0
  16. package/esm/options/buildOptions.js +28 -0
  17. package/esm/options/buildOptions.js.map +1 -0
  18. package/esm/options/loadBabelOptions.js +24 -0
  19. package/esm/options/loadBabelOptions.js.map +1 -0
  20. package/esm/plugins/babel-transform.js +53 -0
  21. package/esm/plugins/babel-transform.js.map +1 -0
  22. package/esm/plugins/collector.js +66 -0
  23. package/esm/plugins/collector.js.map +1 -0
  24. package/esm/plugins/dynamic-import.js +28 -0
  25. package/esm/plugins/dynamic-import.js.map +1 -0
  26. package/esm/plugins/preeval.js +75 -0
  27. package/esm/plugins/preeval.js.map +1 -0
  28. package/esm/plugins/shaker.js +296 -0
  29. package/esm/plugins/shaker.js.map +1 -0
  30. package/esm/shaker.js +50 -0
  31. package/esm/shaker.js.map +1 -0
  32. package/esm/transform/BaseEntrypoint.js +164 -0
  33. package/esm/transform/BaseEntrypoint.js.map +1 -0
  34. package/esm/transform/Entrypoint.helpers.js +168 -0
  35. package/esm/transform/Entrypoint.helpers.js.map +1 -0
  36. package/esm/transform/Entrypoint.js +212 -0
  37. package/esm/transform/Entrypoint.js.map +1 -0
  38. package/esm/transform/Entrypoint.types.js +2 -0
  39. package/esm/transform/Entrypoint.types.js.map +1 -0
  40. package/esm/transform/EvaluatedEntrypoint.js +6 -0
  41. package/esm/transform/EvaluatedEntrypoint.js.map +1 -0
  42. package/esm/transform/actions/AbortError.js +8 -0
  43. package/esm/transform/actions/AbortError.js.map +1 -0
  44. package/esm/transform/actions/BaseAction.js +134 -0
  45. package/esm/transform/actions/BaseAction.js.map +1 -0
  46. package/esm/transform/actions/UnprocessedEntrypointError.js +8 -0
  47. package/esm/transform/actions/UnprocessedEntrypointError.js.map +1 -0
  48. package/esm/transform/actions/actionRunner.js +73 -0
  49. package/esm/transform/actions/actionRunner.js.map +1 -0
  50. package/esm/transform/actions/types.js +2 -0
  51. package/esm/transform/actions/types.js.map +1 -0
  52. package/esm/transform/generators/baseProcessingHandlers.js +22 -0
  53. package/esm/transform/generators/baseProcessingHandlers.js.map +1 -0
  54. package/esm/transform/generators/collect.js +58 -0
  55. package/esm/transform/generators/collect.js.map +1 -0
  56. package/esm/transform/generators/evalFile.js +50 -0
  57. package/esm/transform/generators/evalFile.js.map +1 -0
  58. package/esm/transform/generators/explodeReexports.js +63 -0
  59. package/esm/transform/generators/explodeReexports.js.map +1 -0
  60. package/esm/transform/generators/extract.js +120 -0
  61. package/esm/transform/generators/extract.js.map +1 -0
  62. package/esm/transform/generators/getExports.js +73 -0
  63. package/esm/transform/generators/getExports.js.map +1 -0
  64. package/esm/transform/generators/index.js +13 -0
  65. package/esm/transform/generators/index.js.map +1 -0
  66. package/esm/transform/generators/processEntrypoint.js +43 -0
  67. package/esm/transform/generators/processEntrypoint.js.map +1 -0
  68. package/esm/transform/generators/processImports.js +23 -0
  69. package/esm/transform/generators/processImports.js.map +1 -0
  70. package/esm/transform/generators/resolveImports.js +148 -0
  71. package/esm/transform/generators/resolveImports.js.map +1 -0
  72. package/esm/transform/generators/transform.js +117 -0
  73. package/esm/transform/generators/transform.js.map +1 -0
  74. package/esm/transform/generators/workflow.js +82 -0
  75. package/esm/transform/generators/workflow.js.map +1 -0
  76. package/esm/transform/helpers/loadLinariaOptions.js +66 -0
  77. package/esm/transform/helpers/loadLinariaOptions.js.map +1 -0
  78. package/esm/transform/helpers/withDefaultServices.js +21 -0
  79. package/esm/transform/helpers/withDefaultServices.js.map +1 -0
  80. package/esm/transform/rootLog.js +3 -0
  81. package/esm/transform/rootLog.js.map +1 -0
  82. package/esm/transform/types.js +2 -0
  83. package/esm/transform/types.js.map +1 -0
  84. package/esm/transform.js +121 -0
  85. package/esm/transform.js.map +1 -0
  86. package/esm/types.js +2 -0
  87. package/esm/types.js.map +1 -0
  88. package/esm/utils/EventEmitter.js +52 -0
  89. package/esm/utils/EventEmitter.js.map +1 -0
  90. package/esm/utils/ShakerMetadata.js +2 -0
  91. package/esm/utils/ShakerMetadata.js.map +1 -0
  92. package/esm/utils/TransformMetadata.js +11 -0
  93. package/esm/utils/TransformMetadata.js.map +1 -0
  94. package/esm/utils/addIdentifierToLinariaPreval.js +68 -0
  95. package/esm/utils/addIdentifierToLinariaPreval.js.map +1 -0
  96. package/esm/utils/collectExportsAndImports.js +974 -0
  97. package/esm/utils/collectExportsAndImports.js.map +1 -0
  98. package/esm/utils/collectTemplateDependencies.js +219 -0
  99. package/esm/utils/collectTemplateDependencies.js.map +1 -0
  100. package/esm/utils/createId.js +6 -0
  101. package/esm/utils/createId.js.map +1 -0
  102. package/esm/utils/dispose-polyfill.js +6 -0
  103. package/esm/utils/dispose-polyfill.js.map +1 -0
  104. package/esm/utils/findIdentifiers.js +62 -0
  105. package/esm/utils/findIdentifiers.js.map +1 -0
  106. package/esm/utils/findPackageJSON.js +22 -0
  107. package/esm/utils/findPackageJSON.js.map +1 -0
  108. package/esm/utils/getFileIdx.js +10 -0
  109. package/esm/utils/getFileIdx.js.map +1 -0
  110. package/esm/utils/getPluginKey.js +13 -0
  111. package/esm/utils/getPluginKey.js.map +1 -0
  112. package/esm/utils/getScope.js +6 -0
  113. package/esm/utils/getScope.js.map +1 -0
  114. package/esm/utils/getSource.js +15 -0
  115. package/esm/utils/getSource.js.map +1 -0
  116. package/esm/utils/getTagProcessor.js +304 -0
  117. package/esm/utils/getTagProcessor.js.map +1 -0
  118. package/esm/utils/getVisitorKeys.js +5 -0
  119. package/esm/utils/getVisitorKeys.js.map +1 -0
  120. package/esm/utils/hasLinariaPreval.js +7 -0
  121. package/esm/utils/hasLinariaPreval.js.map +1 -0
  122. package/esm/utils/isExports.js +22 -0
  123. package/esm/utils/isExports.js.map +1 -0
  124. package/esm/utils/isGlobal.js +6 -0
  125. package/esm/utils/isGlobal.js.map +1 -0
  126. package/esm/utils/isNode.js +2 -0
  127. package/esm/utils/isNode.js.map +1 -0
  128. package/esm/utils/isNodePath.js +4 -0
  129. package/esm/utils/isNodePath.js.map +1 -0
  130. package/esm/utils/isNotNull.js +4 -0
  131. package/esm/utils/isNotNull.js.map +1 -0
  132. package/esm/utils/isRemoved.js +46 -0
  133. package/esm/utils/isRemoved.js.map +1 -0
  134. package/esm/utils/isRequire.js +13 -0
  135. package/esm/utils/isRequire.js.map +1 -0
  136. package/esm/utils/isSerializable.js +13 -0
  137. package/esm/utils/isSerializable.js.map +1 -0
  138. package/esm/utils/isTypedNode.js +6 -0
  139. package/esm/utils/isTypedNode.js.map +1 -0
  140. package/esm/utils/isUnnecessaryReactCall.js +72 -0
  141. package/esm/utils/isUnnecessaryReactCall.js.map +1 -0
  142. package/esm/utils/peek.js +2 -0
  143. package/esm/utils/peek.js.map +1 -0
  144. package/esm/utils/processTemplateExpression.js +11 -0
  145. package/esm/utils/processTemplateExpression.js.map +1 -0
  146. package/esm/utils/removeDangerousCode.js +127 -0
  147. package/esm/utils/removeDangerousCode.js.map +1 -0
  148. package/esm/utils/scopeHelpers.js +514 -0
  149. package/esm/utils/scopeHelpers.js.map +1 -0
  150. package/esm/utils/traversalCache.js +28 -0
  151. package/esm/utils/traversalCache.js.map +1 -0
  152. package/esm/utils/unwrapSequence.js +14 -0
  153. package/esm/utils/unwrapSequence.js.map +1 -0
  154. package/esm/utils/valueToLiteral.js +59 -0
  155. package/esm/utils/valueToLiteral.js.map +1 -0
  156. package/esm/utils/visitors/JSXElementsRemover.js +51 -0
  157. package/esm/utils/visitors/JSXElementsRemover.js.map +1 -0
  158. package/esm/vm/createVmContext.js +72 -0
  159. package/esm/vm/createVmContext.js.map +1 -0
  160. package/esm/vm/process.js +29 -0
  161. package/esm/vm/process.js.map +1 -0
  162. package/lib/babel.js +2 -0
  163. package/lib/babel.js.map +1 -0
  164. package/lib/cache.js +87 -0
  165. package/lib/cache.js.map +1 -0
  166. package/lib/debug/fileReporter.js +153 -0
  167. package/lib/debug/fileReporter.js.map +1 -0
  168. package/lib/evaluators/index.js +20 -0
  169. package/lib/evaluators/index.js.map +1 -0
  170. package/lib/index.js +225 -0
  171. package/lib/index.js.map +1 -0
  172. package/lib/module.js +327 -0
  173. package/lib/module.js.map +1 -0
  174. package/lib/options/babel-merge.d.js +2 -0
  175. package/lib/options/babel-merge.d.js.map +1 -0
  176. package/lib/options/buildOptions.js +35 -0
  177. package/lib/options/buildOptions.js.map +1 -0
  178. package/lib/options/loadBabelOptions.js +31 -0
  179. package/lib/options/loadBabelOptions.js.map +1 -0
  180. package/lib/plugins/babel-transform.js +60 -0
  181. package/lib/plugins/babel-transform.js.map +1 -0
  182. package/lib/plugins/collector.js +76 -0
  183. package/lib/plugins/collector.js.map +1 -0
  184. package/lib/plugins/dynamic-import.js +34 -0
  185. package/lib/plugins/dynamic-import.js.map +1 -0
  186. package/lib/plugins/preeval.js +82 -0
  187. package/lib/plugins/preeval.js.map +1 -0
  188. package/lib/plugins/shaker.js +303 -0
  189. package/lib/plugins/shaker.js.map +1 -0
  190. package/lib/shaker.js +58 -0
  191. package/lib/shaker.js.map +1 -0
  192. package/lib/transform/BaseEntrypoint.js +175 -0
  193. package/lib/transform/BaseEntrypoint.js.map +1 -0
  194. package/lib/transform/Entrypoint.helpers.js +182 -0
  195. package/lib/transform/Entrypoint.helpers.js.map +1 -0
  196. package/lib/transform/Entrypoint.js +226 -0
  197. package/lib/transform/Entrypoint.js.map +1 -0
  198. package/lib/transform/Entrypoint.types.js +2 -0
  199. package/lib/transform/Entrypoint.types.js.map +1 -0
  200. package/lib/transform/EvaluatedEntrypoint.js +13 -0
  201. package/lib/transform/EvaluatedEntrypoint.js.map +1 -0
  202. package/lib/transform/actions/AbortError.js +16 -0
  203. package/lib/transform/actions/AbortError.js.map +1 -0
  204. package/lib/transform/actions/BaseAction.js +144 -0
  205. package/lib/transform/actions/BaseAction.js.map +1 -0
  206. package/lib/transform/actions/UnprocessedEntrypointError.js +16 -0
  207. package/lib/transform/actions/UnprocessedEntrypointError.js.map +1 -0
  208. package/lib/transform/actions/actionRunner.js +82 -0
  209. package/lib/transform/actions/actionRunner.js.map +1 -0
  210. package/lib/transform/actions/types.js +2 -0
  211. package/lib/transform/actions/types.js.map +1 -0
  212. package/lib/transform/generators/baseProcessingHandlers.js +27 -0
  213. package/lib/transform/generators/baseProcessingHandlers.js.map +1 -0
  214. package/lib/transform/generators/collect.js +66 -0
  215. package/lib/transform/generators/collect.js.map +1 -0
  216. package/lib/transform/generators/evalFile.js +57 -0
  217. package/lib/transform/generators/evalFile.js.map +1 -0
  218. package/lib/transform/generators/explodeReexports.js +70 -0
  219. package/lib/transform/generators/explodeReexports.js.map +1 -0
  220. package/lib/transform/generators/extract.js +128 -0
  221. package/lib/transform/generators/extract.js.map +1 -0
  222. package/lib/transform/generators/getExports.js +80 -0
  223. package/lib/transform/generators/getExports.js.map +1 -0
  224. package/lib/transform/generators/index.js +19 -0
  225. package/lib/transform/generators/index.js.map +1 -0
  226. package/lib/transform/generators/processEntrypoint.js +49 -0
  227. package/lib/transform/generators/processEntrypoint.js.map +1 -0
  228. package/lib/transform/generators/processImports.js +29 -0
  229. package/lib/transform/generators/processImports.js.map +1 -0
  230. package/lib/transform/generators/resolveImports.js +158 -0
  231. package/lib/transform/generators/resolveImports.js.map +1 -0
  232. package/lib/transform/generators/transform.js +130 -0
  233. package/lib/transform/generators/transform.js.map +1 -0
  234. package/lib/transform/generators/workflow.js +90 -0
  235. package/lib/transform/generators/workflow.js.map +1 -0
  236. package/lib/transform/helpers/loadLinariaOptions.js +73 -0
  237. package/lib/transform/helpers/loadLinariaOptions.js.map +1 -0
  238. package/lib/transform/helpers/withDefaultServices.js +30 -0
  239. package/lib/transform/helpers/withDefaultServices.js.map +1 -0
  240. package/lib/transform/rootLog.js +9 -0
  241. package/lib/transform/rootLog.js.map +1 -0
  242. package/lib/transform/types.js +8 -0
  243. package/lib/transform/types.js.map +1 -0
  244. package/lib/transform.js +128 -0
  245. package/lib/transform.js.map +1 -0
  246. package/lib/types.js +2 -0
  247. package/lib/types.js.map +1 -0
  248. package/lib/utils/EventEmitter.js +61 -0
  249. package/lib/utils/EventEmitter.js.map +1 -0
  250. package/lib/utils/ShakerMetadata.js +9 -0
  251. package/lib/utils/ShakerMetadata.js.map +1 -0
  252. package/lib/utils/TransformMetadata.js +19 -0
  253. package/lib/utils/TransformMetadata.js.map +1 -0
  254. package/lib/utils/addIdentifierToLinariaPreval.js +75 -0
  255. package/lib/utils/addIdentifierToLinariaPreval.js.map +1 -0
  256. package/lib/utils/collectExportsAndImports.js +990 -0
  257. package/lib/utils/collectExportsAndImports.js.map +1 -0
  258. package/lib/utils/collectTemplateDependencies.js +233 -0
  259. package/lib/utils/collectTemplateDependencies.js.map +1 -0
  260. package/lib/utils/createId.js +13 -0
  261. package/lib/utils/createId.js.map +1 -0
  262. package/lib/utils/dispose-polyfill.js +9 -0
  263. package/lib/utils/dispose-polyfill.js.map +1 -0
  264. package/lib/utils/findIdentifiers.js +73 -0
  265. package/lib/utils/findIdentifiers.js.map +1 -0
  266. package/lib/utils/findPackageJSON.js +29 -0
  267. package/lib/utils/findPackageJSON.js.map +1 -0
  268. package/lib/utils/getFileIdx.js +16 -0
  269. package/lib/utils/getFileIdx.js.map +1 -0
  270. package/lib/utils/getPluginKey.js +21 -0
  271. package/lib/utils/getPluginKey.js.map +1 -0
  272. package/lib/utils/getScope.js +12 -0
  273. package/lib/utils/getScope.js.map +1 -0
  274. package/lib/utils/getSource.js +24 -0
  275. package/lib/utils/getSource.js.map +1 -0
  276. package/lib/utils/getTagProcessor.js +318 -0
  277. package/lib/utils/getTagProcessor.js.map +1 -0
  278. package/lib/utils/getVisitorKeys.js +11 -0
  279. package/lib/utils/getVisitorKeys.js.map +1 -0
  280. package/lib/utils/hasLinariaPreval.js +13 -0
  281. package/lib/utils/hasLinariaPreval.js.map +1 -0
  282. package/lib/utils/isExports.js +27 -0
  283. package/lib/utils/isExports.js.map +1 -0
  284. package/lib/utils/isGlobal.js +13 -0
  285. package/lib/utils/isGlobal.js.map +1 -0
  286. package/lib/utils/isNode.js +9 -0
  287. package/lib/utils/isNode.js.map +1 -0
  288. package/lib/utils/isNodePath.js +10 -0
  289. package/lib/utils/isNodePath.js.map +1 -0
  290. package/lib/utils/isNotNull.js +10 -0
  291. package/lib/utils/isNotNull.js.map +1 -0
  292. package/lib/utils/isRemoved.js +52 -0
  293. package/lib/utils/isRemoved.js.map +1 -0
  294. package/lib/utils/isRequire.js +18 -0
  295. package/lib/utils/isRequire.js.map +1 -0
  296. package/lib/utils/isSerializable.js +19 -0
  297. package/lib/utils/isSerializable.js.map +1 -0
  298. package/lib/utils/isTypedNode.js +13 -0
  299. package/lib/utils/isTypedNode.js.map +1 -0
  300. package/lib/utils/isUnnecessaryReactCall.js +81 -0
  301. package/lib/utils/isUnnecessaryReactCall.js.map +1 -0
  302. package/lib/utils/peek.js +9 -0
  303. package/lib/utils/peek.js.map +1 -0
  304. package/lib/utils/processTemplateExpression.js +18 -0
  305. package/lib/utils/processTemplateExpression.js.map +1 -0
  306. package/lib/utils/removeDangerousCode.js +134 -0
  307. package/lib/utils/removeDangerousCode.js.map +1 -0
  308. package/lib/utils/scopeHelpers.js +544 -0
  309. package/lib/utils/scopeHelpers.js.map +1 -0
  310. package/lib/utils/traversalCache.js +38 -0
  311. package/lib/utils/traversalCache.js.map +1 -0
  312. package/lib/utils/unwrapSequence.js +20 -0
  313. package/lib/utils/unwrapSequence.js.map +1 -0
  314. package/lib/utils/valueToLiteral.js +65 -0
  315. package/lib/utils/valueToLiteral.js.map +1 -0
  316. package/lib/utils/visitors/JSXElementsRemover.js +57 -0
  317. package/lib/utils/visitors/JSXElementsRemover.js.map +1 -0
  318. package/lib/vm/createVmContext.js +80 -0
  319. package/lib/vm/createVmContext.js.map +1 -0
  320. package/lib/vm/process.js +38 -0
  321. package/lib/vm/process.js.map +1 -0
  322. package/package.json +63 -0
  323. package/types/babel.d.ts +2 -0
  324. package/types/babel.js +2 -0
  325. package/types/cache.d.ts +24 -0
  326. package/types/cache.js +85 -0
  327. package/types/debug/fileReporter.d.ts +27 -0
  328. package/types/debug/fileReporter.js +151 -0
  329. package/types/evaluators/index.d.ts +10 -0
  330. package/types/evaluators/index.js +15 -0
  331. package/types/index.d.ts +30 -0
  332. package/types/index.js +69 -0
  333. package/types/module.d.ts +62 -0
  334. package/types/module.js +318 -0
  335. package/types/options/buildOptions.d.ts +7 -0
  336. package/types/options/buildOptions.js +35 -0
  337. package/types/options/loadBabelOptions.d.ts +3 -0
  338. package/types/options/loadBabelOptions.js +27 -0
  339. package/types/plugins/babel-transform.d.ts +4 -0
  340. package/types/plugins/babel-transform.js +49 -0
  341. package/types/plugins/collector.d.ts +16 -0
  342. package/types/plugins/collector.js +67 -0
  343. package/types/plugins/dynamic-import.d.ts +6 -0
  344. package/types/plugins/dynamic-import.js +32 -0
  345. package/types/plugins/preeval.d.ts +16 -0
  346. package/types/plugins/preeval.js +69 -0
  347. package/types/plugins/shaker.d.ts +11 -0
  348. package/types/plugins/shaker.js +299 -0
  349. package/types/shaker.d.ts +3 -0
  350. package/types/shaker.js +64 -0
  351. package/types/transform/BaseEntrypoint.d.ts +23 -0
  352. package/types/transform/BaseEntrypoint.js +182 -0
  353. package/types/transform/Entrypoint.d.ts +50 -0
  354. package/types/transform/Entrypoint.helpers.d.ts +14 -0
  355. package/types/transform/Entrypoint.helpers.js +169 -0
  356. package/types/transform/Entrypoint.js +223 -0
  357. package/types/transform/Entrypoint.types.d.ts +23 -0
  358. package/types/transform/Entrypoint.types.js +2 -0
  359. package/types/transform/EvaluatedEntrypoint.d.ts +16 -0
  360. package/types/transform/EvaluatedEntrypoint.js +9 -0
  361. package/types/transform/actions/AbortError.d.ts +4 -0
  362. package/types/transform/actions/AbortError.js +12 -0
  363. package/types/transform/actions/BaseAction.d.ts +40 -0
  364. package/types/transform/actions/BaseAction.js +149 -0
  365. package/types/transform/actions/UnprocessedEntrypointError.d.ts +6 -0
  366. package/types/transform/actions/UnprocessedEntrypointError.js +13 -0
  367. package/types/transform/actions/actionRunner.d.ts +4 -0
  368. package/types/transform/actions/actionRunner.js +86 -0
  369. package/types/transform/actions/types.d.ts +15 -0
  370. package/types/transform/actions/types.js +2 -0
  371. package/types/transform/generators/baseProcessingHandlers.d.ts +17 -0
  372. package/types/transform/generators/baseProcessingHandlers.js +23 -0
  373. package/types/transform/generators/collect.d.ts +6 -0
  374. package/types/transform/generators/collect.js +57 -0
  375. package/types/transform/generators/evalFile.d.ts +6 -0
  376. package/types/transform/generators/evalFile.js +56 -0
  377. package/types/transform/generators/explodeReexports.d.ts +7 -0
  378. package/types/transform/generators/explodeReexports.js +67 -0
  379. package/types/transform/generators/extract.d.ts +8 -0
  380. package/types/transform/generators/extract.js +116 -0
  381. package/types/transform/generators/getExports.d.ts +8 -0
  382. package/types/transform/generators/getExports.js +65 -0
  383. package/types/transform/generators/index.d.ts +15 -0
  384. package/types/transform/generators/index.js +15 -0
  385. package/types/transform/generators/processEntrypoint.d.ts +9 -0
  386. package/types/transform/generators/processEntrypoint.js +88 -0
  387. package/types/transform/generators/processImports.d.ts +5 -0
  388. package/types/transform/generators/processImports.js +21 -0
  389. package/types/transform/generators/resolveImports.d.ts +9 -0
  390. package/types/transform/generators/resolveImports.js +124 -0
  391. package/types/transform/generators/transform.d.ts +17 -0
  392. package/types/transform/generators/transform.js +115 -0
  393. package/types/transform/generators/workflow.d.ts +7 -0
  394. package/types/transform/generators/workflow.js +77 -0
  395. package/types/transform/helpers/loadLinariaOptions.d.ts +6 -0
  396. package/types/transform/helpers/loadLinariaOptions.js +86 -0
  397. package/types/transform/helpers/withDefaultServices.d.ts +5 -0
  398. package/types/transform/helpers/withDefaultServices.js +40 -0
  399. package/types/transform/rootLog.d.ts +3 -0
  400. package/types/transform/rootLog.js +5 -0
  401. package/types/transform/types.d.ts +137 -0
  402. package/types/transform/types.js +4 -0
  403. package/types/transform.d.ts +20 -0
  404. package/types/transform.js +121 -0
  405. package/types/types.d.ts +72 -0
  406. package/types/types.js +5 -0
  407. package/types/utils/EventEmitter.d.ts +58 -0
  408. package/types/utils/EventEmitter.js +61 -0
  409. package/types/utils/ShakerMetadata.d.ts +7 -0
  410. package/types/utils/ShakerMetadata.js +5 -0
  411. package/types/utils/TransformMetadata.d.ts +13 -0
  412. package/types/utils/TransformMetadata.js +17 -0
  413. package/types/utils/addIdentifierToLinariaPreval.d.ts +4 -0
  414. package/types/utils/addIdentifierToLinariaPreval.js +75 -0
  415. package/types/utils/collectExportsAndImports.d.ts +31 -0
  416. package/types/utils/collectExportsAndImports.js +962 -0
  417. package/types/utils/collectTemplateDependencies.d.ts +17 -0
  418. package/types/utils/collectTemplateDependencies.js +212 -0
  419. package/types/utils/createId.d.ts +2 -0
  420. package/types/utils/createId.js +9 -0
  421. package/types/utils/dispose-polyfill.d.ts +0 -0
  422. package/types/utils/dispose-polyfill.js +5 -0
  423. package/types/utils/findIdentifiers.d.ts +6 -0
  424. package/types/utils/findIdentifiers.js +68 -0
  425. package/types/utils/findPackageJSON.d.ts +1 -0
  426. package/types/utils/findPackageJSON.js +29 -0
  427. package/types/utils/getFileIdx.d.ts +1 -0
  428. package/types/utils/getFileIdx.js +13 -0
  429. package/types/utils/getPluginKey.d.ts +2 -0
  430. package/types/utils/getPluginKey.js +16 -0
  431. package/types/utils/getScope.d.ts +2 -0
  432. package/types/utils/getScope.js +11 -0
  433. package/types/utils/getSource.d.ts +2 -0
  434. package/types/utils/getSource.js +22 -0
  435. package/types/utils/getTagProcessor.d.ts +6 -0
  436. package/types/utils/getTagProcessor.js +315 -0
  437. package/types/utils/getVisitorKeys.d.ts +5 -0
  438. package/types/utils/getVisitorKeys.js +8 -0
  439. package/types/utils/hasLinariaPreval.d.ts +4 -0
  440. package/types/utils/hasLinariaPreval.js +9 -0
  441. package/types/utils/isExports.d.ts +6 -0
  442. package/types/utils/isExports.js +20 -0
  443. package/types/utils/isGlobal.d.ts +2 -0
  444. package/types/utils/isGlobal.js +9 -0
  445. package/types/utils/isNode.d.ts +2 -0
  446. package/types/utils/isNode.js +7 -0
  447. package/types/utils/isNodePath.d.ts +3 -0
  448. package/types/utils/isNodePath.js +7 -0
  449. package/types/utils/isNotNull.d.ts +1 -0
  450. package/types/utils/isNotNull.js +7 -0
  451. package/types/utils/isRemoved.d.ts +5 -0
  452. package/types/utils/isRemoved.js +42 -0
  453. package/types/utils/isRequire.d.ts +6 -0
  454. package/types/utils/isRequire.js +15 -0
  455. package/types/utils/isSerializable.d.ts +2 -0
  456. package/types/utils/isSerializable.js +18 -0
  457. package/types/utils/isTypedNode.d.ts +5 -0
  458. package/types/utils/isTypedNode.js +9 -0
  459. package/types/utils/isUnnecessaryReactCall.d.ts +3 -0
  460. package/types/utils/isUnnecessaryReactCall.js +76 -0
  461. package/types/utils/peek.d.ts +1 -0
  462. package/types/utils/peek.js +5 -0
  463. package/types/utils/processTemplateExpression.d.ts +5 -0
  464. package/types/utils/processTemplateExpression.js +17 -0
  465. package/types/utils/removeDangerousCode.d.ts +3 -0
  466. package/types/utils/removeDangerousCode.js +144 -0
  467. package/types/utils/scopeHelpers.d.ts +12 -0
  468. package/types/utils/scopeHelpers.js +568 -0
  469. package/types/utils/traversalCache.d.ts +5 -0
  470. package/types/utils/traversalCache.js +36 -0
  471. package/types/utils/unwrapSequence.d.ts +8 -0
  472. package/types/utils/unwrapSequence.js +17 -0
  473. package/types/utils/valueToLiteral.d.ts +3 -0
  474. package/types/utils/valueToLiteral.js +64 -0
  475. package/types/utils/visitors/JSXElementsRemover.d.ts +3 -0
  476. package/types/utils/visitors/JSXElementsRemover.js +52 -0
  477. package/types/vm/createVmContext.d.ts +7 -0
  478. package/types/vm/createVmContext.js +92 -0
  479. package/types/vm/process.d.ts +25 -0
  480. package/types/vm/process.js +32 -0
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPluginKey = void 0;
7
+ const getPluginKey = plugin => {
8
+ if (typeof plugin === 'string') {
9
+ return plugin;
10
+ }
11
+ if (Array.isArray(plugin)) {
12
+ return getPluginKey(plugin[0]);
13
+ }
14
+ if (typeof plugin === 'object' && plugin !== null && 'key' in plugin) {
15
+ var _key;
16
+ return (_key = plugin.key) !== null && _key !== void 0 ? _key : null;
17
+ }
18
+ return null;
19
+ };
20
+ exports.getPluginKey = getPluginKey;
21
+ //# sourceMappingURL=getPluginKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPluginKey.js","names":["getPluginKey","plugin","Array","isArray","_key","key","exports"],"sources":["../../src/utils/getPluginKey.ts"],"sourcesContent":["import type { PluginItem } from '@babel/core';\n\nexport const getPluginKey = (plugin: PluginItem): string | null => {\n if (typeof plugin === 'string') {\n return plugin;\n }\n\n if (Array.isArray(plugin)) {\n return getPluginKey(plugin[0]);\n }\n\n if (typeof plugin === 'object' && plugin !== null && 'key' in plugin) {\n return (plugin as { key?: string | null }).key ?? null;\n }\n\n return null;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GAAIC,MAAkB,IAAoB;EACjE,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EAEA,IAAIC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACzB,OAAOD,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;EAChC;EAEA,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,KAAK,IAAI,IAAI,KAAK,IAAIA,MAAM,EAAE;IAAA,IAAAG,IAAA;IACpE,QAAAA,IAAA,GAAQH,MAAM,CAA6BI,GAAG,cAAAD,IAAA,cAAAA,IAAA,GAAI,IAAI;EACxD;EAEA,OAAO,IAAI;AACb,CAAC;AAACE,OAAA,CAAAN,YAAA,GAAAA,YAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getScope = getScope;
7
+ function getScope(path) {
8
+ // In some nodes (like FunctionDeclaration) `scope` for `id` returns
9
+ // local function scope instead of a scope where function is declared.
10
+ return path.key === 'id' && path.parent === path.scope.block ? path.scope.parent : path.scope;
11
+ }
12
+ //# sourceMappingURL=getScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getScope.js","names":["getScope","path","key","parent","scope","block"],"sources":["../../src/utils/getScope.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\n\nexport function getScope(path: NodePath) {\n // In some nodes (like FunctionDeclaration) `scope` for `id` returns\n // local function scope instead of a scope where function is declared.\n return path.key === 'id' && path.parent === path.scope.block\n ? path.scope.parent\n : path.scope;\n}\n"],"mappings":";;;;;;AAEO,SAASA,QAAQA,CAACC,IAAc,EAAE;EACvC;EACA;EACA,OAAOA,IAAI,CAACC,GAAG,KAAK,IAAI,IAAID,IAAI,CAACE,MAAM,KAAKF,IAAI,CAACG,KAAK,CAACC,KAAK,GACxDJ,IAAI,CAACG,KAAK,CAACD,MAAM,GACjBF,IAAI,CAACG,KAAK;AAChB"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSource = void 0;
7
+ var _generator = _interopRequireDefault(require("@babel/generator"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const getSource = (path, force = false) => {
10
+ var _path$node$extra;
11
+ if (path.isIdentifier()) {
12
+ // Fast-lane for identifiers
13
+ return path.node.name;
14
+ }
15
+ let source;
16
+ try {
17
+ source = force ? undefined : path.getSource();
18
+ // eslint-disable-next-line no-empty
19
+ } catch {}
20
+ source = source || (0, _generator.default)(path.node).code;
21
+ return (_path$node$extra = path.node.extra) !== null && _path$node$extra !== void 0 && _path$node$extra.parenthesized ? `(${source})` : source;
22
+ };
23
+ exports.getSource = getSource;
24
+ //# sourceMappingURL=getSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSource.js","names":["_generator","_interopRequireDefault","require","obj","__esModule","default","getSource","path","force","_path$node$extra","isIdentifier","node","name","source","undefined","generator","code","extra","parenthesized","exports"],"sources":["../../src/utils/getSource.ts"],"sourcesContent":["import generator from '@babel/generator';\nimport type { NodePath } from '@babel/traverse';\n\nexport const getSource = (path: NodePath, force = false): string => {\n if (path.isIdentifier()) {\n // Fast-lane for identifiers\n return path.node.name;\n }\n\n let source: string | undefined;\n try {\n source = force ? undefined : path.getSource();\n // eslint-disable-next-line no-empty\n } catch {}\n\n source = source || generator(path.node).code;\n\n return path.node.extra?.parenthesized ? `(${source})` : source;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGlC,MAAMG,SAAS,GAAGA,CAACC,IAAc,EAAEC,KAAK,GAAG,KAAK,KAAa;EAAA,IAAAC,gBAAA;EAClE,IAAIF,IAAI,CAACG,YAAY,CAAC,CAAC,EAAE;IACvB;IACA,OAAOH,IAAI,CAACI,IAAI,CAACC,IAAI;EACvB;EAEA,IAAIC,MAA0B;EAC9B,IAAI;IACFA,MAAM,GAAGL,KAAK,GAAGM,SAAS,GAAGP,IAAI,CAACD,SAAS,CAAC,CAAC;IAC7C;EACF,CAAC,CAAC,MAAM,CAAC;EAETO,MAAM,GAAGA,MAAM,IAAI,IAAAE,kBAAS,EAACR,IAAI,CAACI,IAAI,CAAC,CAACK,IAAI;EAE5C,OAAO,CAAAP,gBAAA,GAAAF,IAAI,CAACI,IAAI,CAACM,KAAK,cAAAR,gBAAA,eAAfA,gBAAA,CAAiBS,aAAa,GAAI,IAAGL,MAAO,GAAE,GAAGA,MAAM;AAChE,CAAC;AAACM,OAAA,CAAAb,SAAA,GAAAA,SAAA"}
@@ -0,0 +1,318 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTagProcessor = getTagProcessor;
7
+ var _fs = require("fs");
8
+ var _path = require("path");
9
+ var _core = require("@babel/core");
10
+ var _helperModuleImports = require("@babel/helper-module-imports");
11
+ var _processorUtils = require("@wyw-in-js/processor-utils");
12
+ var _collectExportsAndImports = require("./collectExportsAndImports");
13
+ var _collectTemplateDependencies = require("./collectTemplateDependencies");
14
+ var _findPackageJSON = require("./findPackageJSON");
15
+ var _getSource = require("./getSource");
16
+ var _isNotNull = require("./isNotNull");
17
+ var _scopeHelpers = require("./scopeHelpers");
18
+ var _traversalCache = require("./traversalCache");
19
+ const last = arr => arr[arr.length - 1];
20
+ function zip(arr1, arr2) {
21
+ const result = [];
22
+ for (let i = 0; i < arr1.length; i++) {
23
+ result.push(arr1[i]);
24
+ if (arr2[i]) result.push(arr2[i]);
25
+ }
26
+ return result;
27
+ }
28
+ function buildCodeFrameError(path, message) {
29
+ try {
30
+ return path.buildCodeFrameError(message);
31
+ } catch {
32
+ return new Error(message);
33
+ }
34
+ }
35
+ const definedTagsCache = new Map();
36
+ const getDefinedTagsFromPackage = (pkgName, filename) => {
37
+ var _packageJSON$wywInJ;
38
+ if (definedTagsCache.has(pkgName)) {
39
+ return definedTagsCache.get(pkgName);
40
+ }
41
+ const packageJSONPath = (0, _findPackageJSON.findPackageJSON)(pkgName, filename);
42
+ if (!packageJSONPath) {
43
+ return undefined;
44
+ }
45
+ const packageDir = (0, _path.dirname)(packageJSONPath);
46
+ const packageJSON = JSON.parse((0, _fs.readFileSync)(packageJSONPath, 'utf8'));
47
+ const definedTags = (_packageJSON$wywInJ = packageJSON['wyw-in-js']) === null || _packageJSON$wywInJ === void 0 ? void 0 : _packageJSON$wywInJ.tags;
48
+ const normalizedTags = definedTags ? Object.entries(definedTags).reduce((acc, [key, value]) => ({
49
+ ...acc,
50
+ [key]: value.startsWith('.') ? (0, _path.join)(packageDir, value) : require.resolve(value, {
51
+ paths: [packageDir]
52
+ })
53
+ }), {}) : undefined;
54
+ definedTagsCache.set(pkgName, normalizedTags);
55
+ return normalizedTags;
56
+ };
57
+ function isValidProcessorClass(module) {
58
+ return module instanceof _processorUtils.BaseProcessor.constructor;
59
+ }
60
+ function getProcessorFromPackage(packageName, tagName, filename) {
61
+ const definedTags = getDefinedTagsFromPackage(packageName, filename);
62
+ const processorPath = definedTags === null || definedTags === void 0 ? void 0 : definedTags[tagName];
63
+ if (!processorPath) {
64
+ return null;
65
+ }
66
+ const Processor = require(processorPath).default;
67
+ if (!isValidProcessorClass(Processor)) {
68
+ return null;
69
+ }
70
+ return Processor;
71
+ }
72
+ function getProcessorFromFile(processorPath) {
73
+ const Processor = require(processorPath).default;
74
+ if (!isValidProcessorClass(Processor)) {
75
+ return null;
76
+ }
77
+ return Processor;
78
+ }
79
+ function getProcessorForIdentifier(path, imports, filename, options) {
80
+ var _options$tagResolver, _relatedImports$map$f;
81
+ const pathBinding = path.scope.getBinding(path.node.name);
82
+ if (!pathBinding) {
83
+ // It's not a binding, so it's not a tag
84
+ return [null, null, null];
85
+ }
86
+ const tagResolver = (_options$tagResolver = options.tagResolver) !== null && _options$tagResolver !== void 0 ? _options$tagResolver : () => null;
87
+
88
+ // FIXME: can be simplified
89
+ const relatedImports = imports.map(i => {
90
+ const {
91
+ local
92
+ } = i;
93
+ if (local === path) {
94
+ return [i, null];
95
+ }
96
+ if (!local.isIdentifier()) {
97
+ if (path.isDescendant(local)) {
98
+ return [i, local];
99
+ }
100
+ return null;
101
+ }
102
+ const binding = local.scope.getBinding(local.node.name);
103
+ if (pathBinding === binding) {
104
+ return [i, path];
105
+ }
106
+ return null;
107
+ }).filter(_isNotNull.isNotNull).filter(i => i[1] === null || i[1].isExpression());
108
+ if (relatedImports.length === 0) {
109
+ return [null, null, null];
110
+ }
111
+ const [Processor = null, tagSource = null, tagPath = null] = (_relatedImports$map$f = relatedImports.map(([{
112
+ imported,
113
+ source
114
+ }, p]) => {
115
+ const customFile = tagResolver(source, imported);
116
+ const processor = customFile ? getProcessorFromFile(customFile) : getProcessorFromPackage(source, imported, filename);
117
+ return [processor, {
118
+ imported,
119
+ source
120
+ }, p];
121
+ }).find(([proc]) => proc)) !== null && _relatedImports$map$f !== void 0 ? _relatedImports$map$f : [];
122
+ return Processor === null || tagSource === null || tagPath === null ? [null, null, null] : [Processor, tagSource, tagPath];
123
+ }
124
+ function getBuilderForIdentifier(path, imports, filename, options) {
125
+ const [Processor, tagSource, tagPath] = getProcessorForIdentifier(path, imports, filename, options);
126
+ if (!Processor || !tagSource || !tagPath) {
127
+ return null;
128
+ }
129
+ const params = [['callee', tagPath.node]];
130
+ let prev = tagPath;
131
+ let current = tagPath.parentPath;
132
+ while (current && current !== path) {
133
+ var _current, _current2, _current3, _current4;
134
+ if ((_current = current) !== null && _current !== void 0 && _current.isSequenceExpression() && last(current.node.expressions) === prev.node) {
135
+ prev = current;
136
+ current = current.parentPath;
137
+ // eslint-disable-next-line no-continue
138
+ continue;
139
+ }
140
+ if ((_current2 = current) !== null && _current2 !== void 0 && _current2.isCallExpression({
141
+ callee: prev.node
142
+ })) {
143
+ const args = current.get('arguments');
144
+ const cookedArgs = args.map(arg => {
145
+ const buildError = arg.buildCodeFrameError.bind(arg);
146
+ if (!arg.isExpression()) {
147
+ throw buildError(`Unexpected type of an argument ${arg.type}`);
148
+ }
149
+ const source = (0, _getSource.getSource)(arg);
150
+ const extracted = (0, _collectTemplateDependencies.extractExpression)(arg, options.evaluate, imports);
151
+ return {
152
+ ...extracted,
153
+ source,
154
+ buildCodeFrameError: buildError
155
+ };
156
+ }).filter(_isNotNull.isNotNull);
157
+ params.push(['call', ...cookedArgs]);
158
+ prev = current;
159
+ current = current.parentPath;
160
+ // eslint-disable-next-line no-continue
161
+ continue;
162
+ }
163
+ if ((_current3 = current) !== null && _current3 !== void 0 && _current3.isMemberExpression({
164
+ object: prev.node
165
+ })) {
166
+ const property = current.get('property');
167
+ if (property.isIdentifier() && !current.node.computed) {
168
+ params.push(['member', property.node.name]);
169
+ } else if (property.isStringLiteral()) {
170
+ params.push(['member', property.node.value]);
171
+ } else {
172
+ throw property.buildCodeFrameError(`Unexpected type of a property`);
173
+ }
174
+ prev = current;
175
+ current = current.parentPath;
176
+ // eslint-disable-next-line no-continue
177
+ continue;
178
+ }
179
+ if ((_current4 = current) !== null && _current4 !== void 0 && _current4.isTaggedTemplateExpression({
180
+ tag: prev.node
181
+ })) {
182
+ const [quasis, expressionValues] = (0, _collectTemplateDependencies.collectTemplateDependencies)(current, options.evaluate);
183
+ params.push(['template', zip(quasis, expressionValues)]);
184
+ prev = current;
185
+ current = current.parentPath;
186
+ // eslint-disable-next-line no-continue
187
+ continue;
188
+ }
189
+ break;
190
+ }
191
+ const replacer = (replacement, isPure) => {
192
+ (0, _scopeHelpers.mutate)(prev, p => {
193
+ p.replaceWith(replacement);
194
+ if (isPure) {
195
+ p.addComment('leading', '#__PURE__');
196
+ }
197
+ });
198
+ };
199
+ const astService = {
200
+ ..._core.types,
201
+ addDefaultImport: (importedSource, nameHint) => (0, _helperModuleImports.addDefault)(path, importedSource, {
202
+ nameHint
203
+ }),
204
+ addNamedImport: (name, importedSource, nameHint = name) => (0, _helperModuleImports.addNamed)(path, name, importedSource, {
205
+ nameHint
206
+ })
207
+ };
208
+ return (...args) => {
209
+ var _tagPath$node$loc;
210
+ return new Processor(params, tagSource, astService, (_tagPath$node$loc = tagPath.node.loc) !== null && _tagPath$node$loc !== void 0 ? _tagPath$node$loc : null, replacer, ...args);
211
+ };
212
+ }
213
+ function getDisplayName(path, idx, filename) {
214
+ let displayName;
215
+ const parent = path.findParent(p => p.isObjectProperty() || p.isJSXOpeningElement() || p.isVariableDeclarator());
216
+ if (parent) {
217
+ if (parent.isObjectProperty()) {
218
+ if ('name' in parent.node.key) {
219
+ displayName = parent.node.key.name;
220
+ } else if ('value' in parent.node.key) {
221
+ displayName = parent.node.key.value.toString();
222
+ } else {
223
+ const keyPath = parent.get('key');
224
+ displayName = (0, _getSource.getSource)(keyPath);
225
+ }
226
+ } else if (parent.isJSXOpeningElement()) {
227
+ const name = parent.get('name');
228
+ if (name.isJSXIdentifier()) {
229
+ displayName = name.node.name;
230
+ }
231
+ } else if (parent.isVariableDeclarator()) {
232
+ const id = parent.get('id');
233
+ if (id.isIdentifier()) {
234
+ displayName = id.node.name;
235
+ }
236
+ }
237
+ }
238
+ if (!displayName) {
239
+ // Try to derive the path from the filename
240
+ displayName = (0, _path.basename)(filename !== null && filename !== void 0 ? filename : 'unknown');
241
+ if (filename && /^index\.[a-z\d]+$/.test(displayName)) {
242
+ // If the file name is 'index', better to get name from parent folder
243
+ displayName = (0, _path.basename)((0, _path.dirname)(filename));
244
+ }
245
+
246
+ // Remove the file extension
247
+ displayName = displayName.replace(/\.[a-z\d]+$/, '');
248
+ if (displayName) {
249
+ displayName += idx;
250
+ } else {
251
+ throw new Error("Couldn't determine a name for the component. Ensure that it's either:\n" + '- Assigned to a variable\n' + '- Is an object property\n' + '- Is a prop in a JSX element\n');
252
+ }
253
+ }
254
+ return displayName;
255
+ }
256
+ function isTagReferenced(path) {
257
+ // Check if the variable is referenced anywhere for basic DCE
258
+ // Only works when it's assigned to a variable
259
+ let isReferenced = true;
260
+ const parent = path.findParent(p => p.isObjectProperty() || p.isJSXOpeningElement() || p.isVariableDeclarator());
261
+ if (parent) {
262
+ if (parent.isVariableDeclarator()) {
263
+ const id = parent.get('id');
264
+ // FIXME: replace with id.isReferencedIdentifier()
265
+ if (id.isIdentifier()) {
266
+ const {
267
+ referencePaths
268
+ } = path.scope.getBinding(id.node.name) || {
269
+ referencePaths: []
270
+ };
271
+ isReferenced = referencePaths.length !== 0;
272
+ }
273
+ }
274
+ }
275
+ return isReferenced;
276
+ }
277
+ const counters = new WeakMap();
278
+ const getNextIndex = state => {
279
+ var _counters$get;
280
+ const counter = (_counters$get = counters.get(state)) !== null && _counters$get !== void 0 ? _counters$get : 0;
281
+ counters.set(state, counter + 1);
282
+ return counter;
283
+ };
284
+ function getTagProcessor(path, fileContext, options) {
285
+ var _cache$get;
286
+ const cache = (0, _traversalCache.getTraversalCache)(path, 'getTagProcessor');
287
+ if (!cache.has(path.node)) {
288
+ const root = path.scope.getProgramParent().path;
289
+ const {
290
+ imports
291
+ } = (0, _collectExportsAndImports.collectExportsAndImports)(root);
292
+ try {
293
+ const builder = getBuilderForIdentifier(path, imports.filter(_collectExportsAndImports.explicitImport), fileContext.filename, options);
294
+ if (builder) {
295
+ // Increment the index of the style we're processing
296
+ // This is used for slug generation to prevent collision
297
+ // Also used for display name if it couldn't be determined
298
+ const idx = getNextIndex(fileContext);
299
+ const displayName = getDisplayName(path, idx, fileContext.filename);
300
+ const processor = builder(displayName, isTagReferenced(path), idx, options, fileContext);
301
+ cache.set(path.node, processor);
302
+ } else {
303
+ cache.set(path.node, null);
304
+ }
305
+ } catch (e) {
306
+ if (e === _processorUtils.BaseProcessor.SKIP) {
307
+ cache.set(path.node, null);
308
+ return null;
309
+ }
310
+ if (e instanceof Error) {
311
+ throw buildCodeFrameError(path, e.message);
312
+ }
313
+ throw e;
314
+ }
315
+ }
316
+ return (_cache$get = cache.get(path.node)) !== null && _cache$get !== void 0 ? _cache$get : null;
317
+ }
318
+ //# sourceMappingURL=getTagProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTagProcessor.js","names":["_fs","require","_path","_core","_helperModuleImports","_processorUtils","_collectExportsAndImports","_collectTemplateDependencies","_findPackageJSON","_getSource","_isNotNull","_scopeHelpers","_traversalCache","last","arr","length","zip","arr1","arr2","result","i","push","buildCodeFrameError","path","message","Error","definedTagsCache","Map","getDefinedTagsFromPackage","pkgName","filename","_packageJSON$wywInJ","has","get","packageJSONPath","findPackageJSON","undefined","packageDir","dirname","packageJSON","JSON","parse","readFileSync","definedTags","tags","normalizedTags","Object","entries","reduce","acc","key","value","startsWith","join","resolve","paths","set","isValidProcessorClass","module","BaseProcessor","constructor","getProcessorFromPackage","packageName","tagName","processorPath","Processor","default","getProcessorFromFile","getProcessorForIdentifier","imports","options","_options$tagResolver","_relatedImports$map$f","pathBinding","scope","getBinding","node","name","tagResolver","relatedImports","map","local","isIdentifier","isDescendant","binding","filter","isNotNull","isExpression","tagSource","tagPath","imported","source","p","customFile","processor","find","proc","getBuilderForIdentifier","params","prev","current","parentPath","_current","_current2","_current3","_current4","isSequenceExpression","expressions","isCallExpression","callee","args","cookedArgs","arg","buildError","bind","type","getSource","extracted","extractExpression","evaluate","isMemberExpression","object","property","computed","isStringLiteral","isTaggedTemplateExpression","tag","quasis","expressionValues","collectTemplateDependencies","replacer","replacement","isPure","mutate","replaceWith","addComment","astService","t","addDefaultImport","importedSource","nameHint","addDefault","addNamedImport","addNamed","_tagPath$node$loc","loc","getDisplayName","idx","displayName","parent","findParent","isObjectProperty","isJSXOpeningElement","isVariableDeclarator","toString","keyPath","isJSXIdentifier","id","basename","test","replace","isTagReferenced","isReferenced","referencePaths","counters","WeakMap","getNextIndex","state","_counters$get","counter","getTagProcessor","fileContext","_cache$get","cache","getTraversalCache","root","getProgramParent","collectExportsAndImports","builder","explicitImport","e","SKIP"],"sources":["../../src/utils/getTagProcessor.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { basename, dirname, join } from 'path';\n\nimport { types as t } from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport type { NodePath } from '@babel/traverse';\nimport type {\n Expression,\n SourceLocation,\n Identifier,\n MemberExpression,\n Program,\n} from '@babel/types';\n\nimport { BaseProcessor } from '@wyw-in-js/processor-utils';\nimport type {\n Param,\n Params,\n IFileContext,\n TagSource,\n} from '@wyw-in-js/processor-utils';\nimport type { ExpressionValue, StrictOptions } from '@wyw-in-js/shared';\n\nimport type { IImport } from './collectExportsAndImports';\nimport {\n collectExportsAndImports,\n explicitImport,\n} from './collectExportsAndImports';\nimport {\n collectTemplateDependencies,\n extractExpression,\n} from './collectTemplateDependencies';\nimport { findPackageJSON } from './findPackageJSON';\nimport { getSource } from './getSource';\nimport { isNotNull } from './isNotNull';\nimport { mutate } from './scopeHelpers';\nimport { getTraversalCache } from './traversalCache';\n\ntype BuilderArgs = ConstructorParameters<typeof BaseProcessor> extends [\n Params,\n TagSource,\n typeof t,\n SourceLocation | null,\n (replacement: Expression, isPure: boolean) => void,\n ...infer T,\n]\n ? T\n : never;\n\ntype Builder = (...args: BuilderArgs) => BaseProcessor;\n\ntype ProcessorClass = new (\n ...args: ConstructorParameters<typeof BaseProcessor>\n) => BaseProcessor;\n\nconst last = <T>(arr: T[]): T | undefined => arr[arr.length - 1];\n\nfunction zip<T1, T2>(arr1: T1[], arr2: T2[]) {\n const result: (T1 | T2)[] = [];\n for (let i = 0; i < arr1.length; i++) {\n result.push(arr1[i]);\n if (arr2[i]) result.push(arr2[i]);\n }\n\n return result;\n}\n\nfunction buildCodeFrameError(path: NodePath, message: string): Error {\n try {\n return path.buildCodeFrameError(message);\n } catch {\n return new Error(message);\n }\n}\n\nconst definedTagsCache = new Map<string, Record<string, string> | undefined>();\nconst getDefinedTagsFromPackage = (\n pkgName: string,\n filename: string | null | undefined\n): Record<string, string> | undefined => {\n if (definedTagsCache.has(pkgName)) {\n return definedTagsCache.get(pkgName);\n }\n\n const packageJSONPath = findPackageJSON(pkgName, filename);\n if (!packageJSONPath) {\n return undefined;\n }\n\n const packageDir = dirname(packageJSONPath);\n const packageJSON = JSON.parse(readFileSync(packageJSONPath, 'utf8'));\n const definedTags: Record<string, string> | undefined =\n packageJSON['wyw-in-js']?.tags;\n\n const normalizedTags = definedTags\n ? Object.entries(definedTags).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: value.startsWith('.')\n ? join(packageDir, value)\n : require.resolve(value, { paths: [packageDir] }),\n }),\n {} as Record<string, string>\n )\n : undefined;\n\n definedTagsCache.set(pkgName, normalizedTags);\n\n return normalizedTags;\n};\n\nfunction isValidProcessorClass(module: unknown): module is ProcessorClass {\n return module instanceof BaseProcessor.constructor;\n}\n\nfunction getProcessorFromPackage(\n packageName: string,\n tagName: string,\n filename: string | null | undefined\n): ProcessorClass | null {\n const definedTags = getDefinedTagsFromPackage(packageName, filename);\n const processorPath = definedTags?.[tagName];\n if (!processorPath) {\n return null;\n }\n\n const Processor = require(processorPath).default;\n if (!isValidProcessorClass(Processor)) {\n return null;\n }\n\n return Processor;\n}\n\nfunction getProcessorFromFile(processorPath: string): ProcessorClass | null {\n const Processor = require(processorPath).default;\n if (!isValidProcessorClass(Processor)) {\n return null;\n }\n\n return Processor;\n}\n\nfunction getProcessorForIdentifier(\n path: NodePath<Identifier>,\n imports: IImport[],\n filename: string | null | undefined,\n options: Pick<\n StrictOptions,\n 'classNameSlug' | 'displayName' | 'evaluate' | 'tagResolver'\n >\n):\n | [ProcessorClass, TagSource, NodePath<Identifier | MemberExpression>]\n | [null, null, null] {\n const pathBinding = path.scope.getBinding(path.node.name);\n if (!pathBinding) {\n // It's not a binding, so it's not a tag\n return [null, null, null];\n }\n\n const tagResolver = options.tagResolver ?? (() => null);\n\n // FIXME: can be simplified\n const relatedImports = imports\n .map(\n (i): [IImport, NodePath<Identifier | MemberExpression> | null] | null => {\n const { local } = i;\n\n if (local === path) {\n return [i, null];\n }\n\n if (!local.isIdentifier()) {\n if (path.isDescendant(local)) {\n return [i, local];\n }\n\n return null;\n }\n\n const binding = local.scope.getBinding(local.node.name);\n if (pathBinding === binding) {\n return [i, path];\n }\n\n return null;\n }\n )\n .filter(isNotNull)\n .filter((i) => i[1] === null || i[1].isExpression());\n\n if (relatedImports.length === 0) {\n return [null, null, null];\n }\n\n const [Processor = null, tagSource = null, tagPath = null] =\n relatedImports\n .map(\n ([{ imported, source }, p]): [\n ProcessorClass | null,\n TagSource,\n NodePath<Identifier | MemberExpression> | null,\n ] => {\n const customFile = tagResolver(source, imported);\n const processor = customFile\n ? getProcessorFromFile(customFile)\n : getProcessorFromPackage(source, imported, filename);\n return [processor, { imported, source }, p];\n }\n )\n .find(([proc]) => proc) ?? [];\n\n return Processor === null || tagSource === null || tagPath === null\n ? [null, null, null]\n : [Processor, tagSource, tagPath];\n}\n\nfunction getBuilderForIdentifier(\n path: NodePath<Identifier>,\n imports: IImport[],\n filename: string | null | undefined,\n options: Pick<\n StrictOptions,\n 'classNameSlug' | 'displayName' | 'evaluate' | 'tagResolver'\n >\n): Builder | null {\n const [Processor, tagSource, tagPath] = getProcessorForIdentifier(\n path,\n imports,\n filename,\n options\n );\n\n if (!Processor || !tagSource || !tagPath) {\n return null;\n }\n\n const params: Param[] = [['callee', tagPath.node]];\n let prev: NodePath = tagPath;\n let current: NodePath | null = tagPath.parentPath;\n while (current && current !== path) {\n if (\n current?.isSequenceExpression() &&\n last(current.node.expressions) === prev.node\n ) {\n prev = current;\n current = current.parentPath;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (current?.isCallExpression({ callee: prev.node })) {\n const args = current.get('arguments');\n const cookedArgs = args\n .map((arg) => {\n const buildError = arg.buildCodeFrameError.bind(arg);\n if (!arg.isExpression()) {\n throw buildError(`Unexpected type of an argument ${arg.type}`);\n }\n const source = getSource(arg);\n const extracted = extractExpression(arg, options.evaluate, imports);\n return {\n ...extracted,\n source,\n buildCodeFrameError: buildError,\n } as ExpressionValue;\n })\n .filter(isNotNull);\n\n params.push(['call', ...cookedArgs]);\n prev = current;\n current = current.parentPath;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (current?.isMemberExpression({ object: prev.node })) {\n const property = current.get('property');\n if (property.isIdentifier() && !current.node.computed) {\n params.push(['member', property.node.name]);\n } else if (property.isStringLiteral()) {\n params.push(['member', property.node.value]);\n } else {\n throw property.buildCodeFrameError(`Unexpected type of a property`);\n }\n\n prev = current;\n current = current.parentPath;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (current?.isTaggedTemplateExpression({ tag: prev.node })) {\n const [quasis, expressionValues] = collectTemplateDependencies(\n current,\n options.evaluate\n );\n params.push(['template', zip(quasis, expressionValues)]);\n\n prev = current;\n current = current.parentPath;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n break;\n }\n\n const replacer = (replacement: Expression, isPure: boolean) => {\n mutate(prev, (p) => {\n p.replaceWith(replacement);\n if (isPure) {\n p.addComment('leading', '#__PURE__');\n }\n });\n };\n\n const astService = {\n ...t,\n addDefaultImport: (importedSource: string, nameHint?: string) =>\n addDefault(path, importedSource, { nameHint }),\n addNamedImport: (\n name: string,\n importedSource: string,\n nameHint: string = name\n ) => addNamed(path, name, importedSource, { nameHint }),\n };\n\n return (...args: BuilderArgs) =>\n new Processor(\n params,\n tagSource,\n astService,\n tagPath.node.loc ?? null,\n replacer,\n ...args\n );\n}\n\nfunction getDisplayName(\n path: NodePath<Identifier>,\n idx: number,\n filename?: string | null\n): string {\n let displayName: string | undefined;\n\n const parent = path.findParent(\n (p) =>\n p.isObjectProperty() ||\n p.isJSXOpeningElement() ||\n p.isVariableDeclarator()\n );\n\n if (parent) {\n if (parent.isObjectProperty()) {\n if ('name' in parent.node.key) {\n displayName = parent.node.key.name;\n } else if ('value' in parent.node.key) {\n displayName = parent.node.key.value.toString();\n } else {\n const keyPath = parent.get('key');\n displayName = getSource(keyPath);\n }\n } else if (parent.isJSXOpeningElement()) {\n const name = parent.get('name');\n if (name.isJSXIdentifier()) {\n displayName = name.node.name;\n }\n } else if (parent.isVariableDeclarator()) {\n const id = parent.get('id');\n if (id.isIdentifier()) {\n displayName = id.node.name;\n }\n }\n }\n\n if (!displayName) {\n // Try to derive the path from the filename\n displayName = basename(filename ?? 'unknown');\n\n if (filename && /^index\\.[a-z\\d]+$/.test(displayName)) {\n // If the file name is 'index', better to get name from parent folder\n displayName = basename(dirname(filename));\n }\n\n // Remove the file extension\n displayName = displayName.replace(/\\.[a-z\\d]+$/, '');\n\n if (displayName) {\n displayName += idx;\n } else {\n throw new Error(\n \"Couldn't determine a name for the component. Ensure that it's either:\\n\" +\n '- Assigned to a variable\\n' +\n '- Is an object property\\n' +\n '- Is a prop in a JSX element\\n'\n );\n }\n }\n\n return displayName;\n}\n\nfunction isTagReferenced(path: NodePath): boolean {\n // Check if the variable is referenced anywhere for basic DCE\n // Only works when it's assigned to a variable\n let isReferenced = true;\n\n const parent = path.findParent(\n (p) =>\n p.isObjectProperty() ||\n p.isJSXOpeningElement() ||\n p.isVariableDeclarator()\n );\n\n if (parent) {\n if (parent.isVariableDeclarator()) {\n const id = parent.get('id');\n // FIXME: replace with id.isReferencedIdentifier()\n if (id.isIdentifier()) {\n const { referencePaths } = path.scope.getBinding(id.node.name) || {\n referencePaths: [],\n };\n\n isReferenced = referencePaths.length !== 0;\n }\n }\n }\n\n return isReferenced;\n}\n\nconst counters = new WeakMap<IFileContext, number>();\nconst getNextIndex = (state: IFileContext) => {\n const counter = counters.get(state) ?? 0;\n counters.set(state, counter + 1);\n return counter;\n};\n\nexport function getTagProcessor(\n path: NodePath<Identifier>,\n fileContext: IFileContext,\n options: Pick<\n StrictOptions,\n 'classNameSlug' | 'displayName' | 'evaluate' | 'tagResolver'\n >\n): BaseProcessor | null {\n const cache = getTraversalCache<BaseProcessor | null, Identifier>(\n path,\n 'getTagProcessor'\n );\n\n if (!cache.has(path.node)) {\n const root = path.scope.getProgramParent().path as NodePath<Program>;\n const { imports } = collectExportsAndImports(root);\n try {\n const builder = getBuilderForIdentifier(\n path,\n imports.filter(explicitImport),\n fileContext.filename,\n options\n );\n if (builder) {\n // Increment the index of the style we're processing\n // This is used for slug generation to prevent collision\n // Also used for display name if it couldn't be determined\n const idx = getNextIndex(fileContext);\n\n const displayName = getDisplayName(path, idx, fileContext.filename);\n\n const processor = builder(\n displayName,\n isTagReferenced(path),\n idx,\n options,\n fileContext\n );\n\n cache.set(path.node, processor);\n } else {\n cache.set(path.node, null);\n }\n } catch (e) {\n if (e === BaseProcessor.SKIP) {\n cache.set(path.node, null);\n return null;\n }\n\n if (e instanceof Error) {\n throw buildCodeFrameError(path, e.message);\n }\n\n throw e;\n }\n }\n\n return cache.get(path.node) ?? null;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AAUA,IAAAI,eAAA,GAAAJ,OAAA;AAUA,IAAAK,yBAAA,GAAAL,OAAA;AAIA,IAAAM,4BAAA,GAAAN,OAAA;AAIA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,aAAA,GAAAV,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AAmBA,MAAMY,IAAI,GAAOC,GAAQ,IAAoBA,GAAG,CAACA,GAAG,CAACC,MAAM,GAAG,CAAC,CAAC;AAEhE,SAASC,GAAGA,CAASC,IAAU,EAAEC,IAAU,EAAE;EAC3C,MAAMC,MAAmB,GAAG,EAAE;EAC9B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,CAACF,MAAM,EAAEK,CAAC,EAAE,EAAE;IACpCD,MAAM,CAACE,IAAI,CAACJ,IAAI,CAACG,CAAC,CAAC,CAAC;IACpB,IAAIF,IAAI,CAACE,CAAC,CAAC,EAAED,MAAM,CAACE,IAAI,CAACH,IAAI,CAACE,CAAC,CAAC,CAAC;EACnC;EAEA,OAAOD,MAAM;AACf;AAEA,SAASG,mBAAmBA,CAACC,IAAc,EAAEC,OAAe,EAAS;EACnE,IAAI;IACF,OAAOD,IAAI,CAACD,mBAAmB,CAAC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BAAmB,CAACC,IAAI,EAAE6J,CAAC,CAAC5J,OAAO,CAAC;MAC5C;MAEA,MAAM4J,CAAC;IACT;EACF;EAEA,QAAAR,UAAA,GAAOC,KAAK,CAAC5I,GAAG,CAACV,IAAI,CAACqD,IAAI,CAAC,cAAAgG,UAAA,cAAAA,UAAA,GAAI,IAAI;AACrC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getVisitorKeys = getVisitorKeys;
7
+ var _core = require("@babel/core");
8
+ function getVisitorKeys(node) {
9
+ return _core.types.VISITOR_KEYS[node.type];
10
+ }
11
+ //# sourceMappingURL=getVisitorKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVisitorKeys.js","names":["_core","require","getVisitorKeys","node","t","VISITOR_KEYS","type"],"sources":["../../src/utils/getVisitorKeys.ts"],"sourcesContent":["import { types as t } from '@babel/core';\nimport type { Node } from '@babel/types';\n\nexport type VisitorKeys<T extends Node> = {\n [K in keyof T]: Exclude<T[K], undefined> extends Node | Node[] | null\n ? K\n : never;\n}[keyof T] &\n string;\n\nexport function getVisitorKeys<TNode extends Node>(\n node: TNode\n): VisitorKeys<TNode>[] {\n return t.VISITOR_KEYS[node.type] as VisitorKeys<TNode>[];\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAUO,SAASC,cAAcA,CAC5BC,IAAW,EACW;EACtB,OAAOC,WAAC,CAACC,YAAY,CAACF,IAAI,CAACG,IAAI,CAAC;AAClC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = hasLinariaPreval;
7
+ function hasLinariaPreval(exports) {
8
+ if (!exports || typeof exports !== 'object') {
9
+ return false;
10
+ }
11
+ return '__linariaPreval' in exports;
12
+ }
13
+ //# sourceMappingURL=hasLinariaPreval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasLinariaPreval.js","names":["hasLinariaPreval","exports"],"sources":["../../src/utils/hasLinariaPreval.ts"],"sourcesContent":["import type { Value } from '@wyw-in-js/processor-utils';\n\nexport default function hasLinariaPreval(exports: unknown): exports is {\n __linariaPreval: Record<string, () => Value> | null | undefined;\n} {\n if (!exports || typeof exports !== 'object') {\n return false;\n }\n\n return '__linariaPreval' in exports;\n}\n"],"mappings":";;;;;;AAEe,SAASA,gBAAgBA,CAACC,OAAgB,EAEvD;EACA,IAAI,CAACA,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC3C,OAAO,KAAK;EACd;EAEA,OAAO,iBAAiB,IAAIA,OAAO;AACrC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isExports = isExports;
7
+ var _isGlobal = require("./isGlobal");
8
+ /**
9
+ * Checks that specified Identifier is a global `exports` or `module.exports`
10
+ * @param node
11
+ */
12
+ function isExports(node) {
13
+ if (node !== null && node !== void 0 && node.isIdentifier({
14
+ name: 'exports'
15
+ })) {
16
+ return (0, _isGlobal.isGlobal)(node, 'exports');
17
+ }
18
+ if (node !== null && node !== void 0 && node.isMemberExpression() && node.get('object').isIdentifier({
19
+ name: 'module'
20
+ }) && node.get('property').isIdentifier({
21
+ name: 'exports'
22
+ })) {
23
+ return (0, _isGlobal.isGlobal)(node, 'module');
24
+ }
25
+ return false;
26
+ }
27
+ //# sourceMappingURL=isExports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isExports.js","names":["_isGlobal","require","isExports","node","isIdentifier","name","isGlobal","isMemberExpression","get"],"sources":["../../src/utils/isExports.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\n\nimport { isGlobal } from './isGlobal';\n\n/**\n * Checks that specified Identifier is a global `exports` or `module.exports`\n * @param node\n */\nexport function isExports(node: NodePath | null | undefined) {\n if (node?.isIdentifier({ name: 'exports' })) {\n return isGlobal(node, 'exports');\n }\n\n if (\n node?.isMemberExpression() &&\n node.get('object').isIdentifier({ name: 'module' }) &&\n node.get('property').isIdentifier({ name: 'exports' })\n ) {\n return isGlobal(node, 'module');\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAACC,IAAiC,EAAE;EAC3D,IAAIA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEC,YAAY,CAAC;IAAEC,IAAI,EAAE;EAAU,CAAC,CAAC,EAAE;IAC3C,OAAO,IAAAC,kBAAQ,EAACH,IAAI,EAAE,SAAS,CAAC;EAClC;EAEA,IACEA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEI,kBAAkB,CAAC,CAAC,IAC1BJ,IAAI,CAACK,GAAG,CAAC,QAAQ,CAAC,CAACJ,YAAY,CAAC;IAAEC,IAAI,EAAE;EAAS,CAAC,CAAC,IACnDF,IAAI,CAACK,GAAG,CAAC,UAAU,CAAC,CAACJ,YAAY,CAAC;IAAEC,IAAI,EAAE;EAAU,CAAC,CAAC,EACtD;IACA,OAAO,IAAAC,kBAAQ,EAACH,IAAI,EAAE,QAAQ,CAAC;EACjC;EAEA,OAAO,KAAK;AACd"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isGlobal = void 0;
7
+ var _getScope = require("./getScope");
8
+ const isGlobal = (node, name) => {
9
+ const scope = (0, _getScope.getScope)(node);
10
+ return scope.getBinding(name) === undefined && scope.hasGlobal(name);
11
+ };
12
+ exports.isGlobal = isGlobal;
13
+ //# sourceMappingURL=isGlobal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGlobal.js","names":["_getScope","require","isGlobal","node","name","scope","getScope","getBinding","undefined","hasGlobal","exports"],"sources":["../../src/utils/isGlobal.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\n\nimport { getScope } from './getScope';\n\nexport const isGlobal = (node: NodePath, name: string) => {\n const scope = getScope(node);\n\n return scope.getBinding(name) === undefined && scope.hasGlobal(name);\n};\n"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAGA,CAACC,IAAc,EAAEC,IAAY,KAAK;EACxD,MAAMC,KAAK,GAAG,IAAAC,kBAAQ,EAACH,IAAI,CAAC;EAE5B,OAAOE,KAAK,CAACE,UAAU,CAACH,IAAI,CAAC,KAAKI,SAAS,IAAIH,KAAK,CAACI,SAAS,CAACL,IAAI,CAAC;AACtE,CAAC;AAACM,OAAA,CAAAR,QAAA,GAAAA,QAAA"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isNode = void 0;
7
+ const isNode = obj => typeof obj === 'object' && obj !== null && (obj === null || obj === void 0 ? void 0 : obj.type) !== undefined;
8
+ exports.isNode = isNode;
9
+ //# sourceMappingURL=isNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNode.js","names":["isNode","obj","type","undefined","exports"],"sources":["../../src/utils/isNode.ts"],"sourcesContent":["import type { Node } from '@babel/types';\n\nexport const isNode = (obj: unknown): obj is Node =>\n typeof obj === 'object' &&\n obj !== null &&\n (obj as { type: unknown })?.type !== undefined;\n"],"mappings":";;;;;;AAEO,MAAMA,MAAM,GAAIC,GAAY,IACjC,OAAOA,GAAG,KAAK,QAAQ,IACvBA,GAAG,KAAK,IAAI,IACZ,CAACA,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAwBC,IAAI,MAAKC,SAAS;AAACC,OAAA,CAAAJ,MAAA,GAAAA,MAAA"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isNodePath = isNodePath;
7
+ function isNodePath(obj) {
8
+ return 'node' in obj && (obj === null || obj === void 0 ? void 0 : obj.node) !== undefined;
9
+ }
10
+ //# sourceMappingURL=isNodePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNodePath.js","names":["isNodePath","obj","node","undefined"],"sources":["../../src/utils/isNodePath.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport type { Node } from '@babel/types';\n\nexport function isNodePath<T extends Node>(\n obj: NodePath<T> | T\n): obj is NodePath<T> {\n return 'node' in obj && obj?.node !== undefined;\n}\n"],"mappings":";;;;;;AAGO,SAASA,UAAUA,CACxBC,GAAoB,EACA;EACpB,OAAO,MAAM,IAAIA,GAAG,IAAI,CAAAA,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEC,IAAI,MAAKC,SAAS;AACjD"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isNotNull = isNotNull;
7
+ function isNotNull(x) {
8
+ return x !== null;
9
+ }
10
+ //# sourceMappingURL=isNotNull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNotNull.js","names":["isNotNull","x"],"sources":["../../src/utils/isNotNull.ts"],"sourcesContent":["export function isNotNull<T>(x: T | null): x is T {\n return x !== null;\n}\n"],"mappings":";;;;;;AAAO,SAASA,SAASA,CAAIC,CAAW,EAAU;EAChD,OAAOA,CAAC,KAAK,IAAI;AACnB"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isRemoved = isRemoved;
7
+ /**
8
+ * Checks if a given path has been removed from the AST.
9
+ */
10
+ function isRemoved(path) {
11
+ // Check if the input path has already been removed
12
+ if (path.removed) {
13
+ return true;
14
+ }
15
+
16
+ // Check if any of the parent paths have been removed
17
+ let currentPath = path;
18
+ while (currentPath) {
19
+ const parent = currentPath.parentPath;
20
+ if (parent) {
21
+ // If the parent path has been removed, return true
22
+ if (parent.removed || parent.node === null) {
23
+ return true;
24
+ }
25
+ const {
26
+ listKey,
27
+ key,
28
+ node
29
+ } = currentPath;
30
+ if (listKey) {
31
+ // If the current path is part of a list and the current node
32
+ // is not presented in this list, return true
33
+ const found = parent.get(listKey).find(p => p.node === node);
34
+ if (!found) {
35
+ return true;
36
+ }
37
+ }
38
+ // If the current path is not part of a list and its node is not the same
39
+ // as the node in the parent object at the same key, return true
40
+ else if (parent.get(key).node !== node) {
41
+ return true;
42
+ }
43
+ }
44
+
45
+ // Set the current path to its parent path and continue the loop
46
+ currentPath = parent;
47
+ }
48
+
49
+ // If the function has not returned true by this point, return false
50
+ return false;
51
+ }
52
+ //# sourceMappingURL=isRemoved.js.map