@wyw-in-js/transform 1.1.0 → 2.0.0-alpha.1

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 (801) hide show
  1. package/esm/cache.js +433 -289
  2. package/esm/cache.js.map +1 -1
  3. package/esm/debug/fileReporter.js +171 -134
  4. package/esm/debug/fileReporter.js.map +1 -1
  5. package/esm/eval/broker.js +2275 -0
  6. package/esm/eval/broker.js.map +1 -0
  7. package/esm/eval/lru.js +36 -0
  8. package/esm/eval/lru.js.map +1 -0
  9. package/esm/eval/prepareModuleOnDemand.js +21 -0
  10. package/esm/eval/prepareModuleOnDemand.js.map +1 -0
  11. package/esm/eval/protocol.js +2 -0
  12. package/esm/eval/protocol.js.map +1 -0
  13. package/esm/eval/runner.js +1878 -0
  14. package/esm/eval/runner.js.map +1 -0
  15. package/esm/eval/serialize.js +333 -0
  16. package/esm/eval/serialize.js.map +1 -0
  17. package/esm/eval/writeQueue.js +81 -0
  18. package/esm/eval/writeQueue.js.map +1 -0
  19. package/esm/evaluators/index.js +11 -12
  20. package/esm/evaluators/index.js.map +1 -1
  21. package/esm/index.js +25 -29
  22. package/esm/index.js.map +1 -1
  23. package/esm/module.js +923 -520
  24. package/esm/module.js.map +1 -1
  25. package/esm/shaker.js +14 -80
  26. package/esm/shaker.js.map +1 -1
  27. package/esm/transform/BaseEntrypoint.js +162 -164
  28. package/esm/transform/BaseEntrypoint.js.map +1 -1
  29. package/esm/transform/Entrypoint.helpers.js +96 -253
  30. package/esm/transform/Entrypoint.helpers.js.map +1 -1
  31. package/esm/transform/Entrypoint.js +336 -270
  32. package/esm/transform/Entrypoint.js.map +1 -1
  33. package/esm/transform/Entrypoint.types.js +1 -1
  34. package/esm/transform/Entrypoint.types.js.map +1 -1
  35. package/esm/transform/EvaluatedEntrypoint.js +10 -4
  36. package/esm/transform/EvaluatedEntrypoint.js.map +1 -1
  37. package/esm/transform/actions/AbortError.js +6 -6
  38. package/esm/transform/actions/AbortError.js.map +1 -1
  39. package/esm/transform/actions/BaseAction.js +140 -136
  40. package/esm/transform/actions/BaseAction.js.map +1 -1
  41. package/esm/transform/actions/UnprocessedEntrypointError.js +6 -6
  42. package/esm/transform/actions/UnprocessedEntrypointError.js.map +1 -1
  43. package/esm/transform/actions/actionRunner.js +63 -66
  44. package/esm/transform/actions/actionRunner.js.map +1 -1
  45. package/esm/transform/actions/types.js +1 -1
  46. package/esm/transform/actions/types.js.map +1 -1
  47. package/esm/transform/barrelManifest.types.js +2 -0
  48. package/esm/transform/barrelManifest.types.js.map +1 -0
  49. package/esm/transform/generators/baseProcessingHandlers.js +15 -17
  50. package/esm/transform/generators/baseProcessingHandlers.js.map +1 -1
  51. package/esm/transform/generators/collect.js +27 -55
  52. package/esm/transform/generators/collect.js.map +1 -1
  53. package/esm/transform/generators/createStylisPreprocessor.js +353 -321
  54. package/esm/transform/generators/createStylisPreprocessor.js.map +1 -1
  55. package/esm/transform/generators/evalFile.js +48 -47
  56. package/esm/transform/generators/evalFile.js.map +1 -1
  57. package/esm/transform/generators/extract.js +78 -90
  58. package/esm/transform/generators/extract.js.map +1 -1
  59. package/esm/transform/generators/getExports.js +57 -74
  60. package/esm/transform/generators/getExports.js.map +1 -1
  61. package/esm/transform/generators/index.js +11 -11
  62. package/esm/transform/generators/index.js.map +1 -1
  63. package/esm/transform/generators/processEntrypoint.js +93 -67
  64. package/esm/transform/generators/processEntrypoint.js.map +1 -1
  65. package/esm/transform/generators/processImports.js +102 -67
  66. package/esm/transform/generators/processImports.js.map +1 -1
  67. package/esm/transform/generators/resolveImports.js +212 -197
  68. package/esm/transform/generators/resolveImports.js.map +1 -1
  69. package/esm/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  70. package/esm/transform/generators/resolveStaticOxcValues/cache.js.map +1 -0
  71. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js +146 -0
  72. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js.map +1 -0
  73. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js +33 -0
  74. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js.map +1 -0
  75. package/esm/transform/generators/resolveStaticOxcValues/environment.js +29 -0
  76. package/esm/transform/generators/resolveStaticOxcValues/environment.js.map +1 -0
  77. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js +351 -0
  78. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js.map +1 -0
  79. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js +253 -0
  80. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js.map +1 -0
  81. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js +310 -0
  82. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js.map +1 -0
  83. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +74 -0
  84. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js.map +1 -0
  85. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +229 -0
  86. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js.map +1 -0
  87. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js +172 -0
  88. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js.map +1 -0
  89. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js +476 -0
  90. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js.map +1 -0
  91. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js +55 -0
  92. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js.map +1 -0
  93. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js +123 -0
  94. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js.map +1 -0
  95. package/esm/transform/generators/resolveStaticOxcValues/prune.js +186 -0
  96. package/esm/transform/generators/resolveStaticOxcValues/prune.js.map +1 -0
  97. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +183 -0
  98. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js.map +1 -0
  99. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js +298 -0
  100. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js.map +1 -0
  101. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +298 -0
  102. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js.map +1 -0
  103. package/esm/transform/generators/resolveStaticOxcValues/types.js +3 -0
  104. package/esm/transform/generators/resolveStaticOxcValues/types.js.map +1 -0
  105. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +59 -0
  106. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js.map +1 -0
  107. package/esm/transform/generators/resolveStaticOxcValues.js +2 -0
  108. package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -0
  109. package/esm/transform/generators/rewriteOxcBarrelImports.js +822 -0
  110. package/esm/transform/generators/rewriteOxcBarrelImports.js.map +1 -0
  111. package/esm/transform/generators/transform.js +251 -248
  112. package/esm/transform/generators/transform.js.map +1 -1
  113. package/esm/transform/generators/workflow.js +87 -90
  114. package/esm/transform/generators/workflow.js.map +1 -1
  115. package/esm/transform/helpers/loadWywOptions.js +183 -74
  116. package/esm/transform/helpers/loadWywOptions.js.map +1 -1
  117. package/esm/transform/helpers/withDefaultServices.js +13 -22
  118. package/esm/transform/helpers/withDefaultServices.js.map +1 -1
  119. package/esm/transform/isStaticallyEvaluatableModule.js +140 -152
  120. package/esm/transform/isStaticallyEvaluatableModule.js.map +1 -1
  121. package/esm/transform/oxcBarrelManifest.js +349 -0
  122. package/esm/transform/oxcBarrelManifest.js.map +1 -0
  123. package/esm/transform/rootLog.js +3 -3
  124. package/esm/transform/rootLog.js.map +1 -1
  125. package/esm/transform/syntax.js +2 -0
  126. package/esm/transform/syntax.js.map +1 -0
  127. package/esm/transform/types.js +2 -2
  128. package/esm/transform/types.js.map +1 -1
  129. package/esm/transform.js +125 -147
  130. package/esm/transform.js.map +1 -1
  131. package/esm/types.js +4 -1
  132. package/esm/types.js.map +1 -1
  133. package/esm/utils/EventEmitter.js +79 -48
  134. package/esm/utils/EventEmitter.js.map +1 -1
  135. package/esm/utils/ShakerMetadata.js +2 -2
  136. package/esm/utils/ShakerMetadata.js.map +1 -1
  137. package/esm/utils/TransformDiagnostics.js +9 -9
  138. package/esm/utils/TransformDiagnostics.js.map +1 -1
  139. package/esm/utils/TransformMetadata.js +24 -26
  140. package/esm/utils/TransformMetadata.js.map +1 -1
  141. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js +160 -0
  142. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js.map +1 -0
  143. package/esm/utils/applyOxcProcessors/cleanupBindings.js +157 -0
  144. package/esm/utils/applyOxcProcessors/cleanupBindings.js.map +1 -0
  145. package/esm/utils/applyOxcProcessors/cleanupRemovals.js +431 -0
  146. package/esm/utils/applyOxcProcessors/cleanupRemovals.js.map +1 -0
  147. package/esm/utils/applyOxcProcessors/displayName.js +93 -0
  148. package/esm/utils/applyOxcProcessors/displayName.js.map +1 -0
  149. package/esm/utils/applyOxcProcessors/expressionValues.js +152 -0
  150. package/esm/utils/applyOxcProcessors/expressionValues.js.map +1 -0
  151. package/esm/utils/applyOxcProcessors/processorFactory.js +62 -0
  152. package/esm/utils/applyOxcProcessors/processorFactory.js.map +1 -0
  153. package/esm/utils/applyOxcProcessors/processorUsages.js +143 -0
  154. package/esm/utils/applyOxcProcessors/processorUsages.js.map +1 -0
  155. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js +207 -0
  156. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js.map +1 -0
  157. package/esm/utils/applyOxcProcessors/shared.js +29 -0
  158. package/esm/utils/applyOxcProcessors/shared.js.map +1 -0
  159. package/esm/utils/applyOxcProcessors/types.js +2 -0
  160. package/esm/utils/applyOxcProcessors/types.js.map +1 -0
  161. package/esm/utils/applyOxcProcessors.js +2 -0
  162. package/esm/utils/applyOxcProcessors.js.map +1 -0
  163. package/esm/utils/collectOxcExportsAndImports.js +934 -0
  164. package/esm/utils/collectOxcExportsAndImports.js.map +1 -0
  165. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js +157 -0
  166. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js.map +1 -0
  167. package/esm/utils/collectOxcRuntime/sourceMap.js +36 -0
  168. package/esm/utils/collectOxcRuntime/sourceMap.js.map +1 -0
  169. package/esm/utils/collectOxcRuntime/types.js +2 -0
  170. package/esm/utils/collectOxcRuntime/types.js.map +1 -0
  171. package/esm/utils/collectOxcRuntime.js +32 -0
  172. package/esm/utils/collectOxcRuntime.js.map +1 -0
  173. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js +496 -0
  174. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js.map +1 -0
  175. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js +113 -0
  176. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js.map +1 -0
  177. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js +387 -0
  178. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js.map +1 -0
  179. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js +17 -0
  180. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js.map +1 -0
  181. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js +540 -0
  182. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js.map +1 -0
  183. package/esm/utils/collectOxcTemplateDependencies/types.js +2 -0
  184. package/esm/utils/collectOxcTemplateDependencies/types.js.map +1 -0
  185. package/esm/utils/collectOxcTemplateDependencies.js +4 -0
  186. package/esm/utils/collectOxcTemplateDependencies.js.map +1 -0
  187. package/esm/utils/dispose-polyfill.js +3 -4
  188. package/esm/utils/dispose-polyfill.js.map +1 -1
  189. package/esm/utils/getFileIdx.js +6 -6
  190. package/esm/utils/getFileIdx.js.map +1 -1
  191. package/esm/utils/getPluginKey.js +12 -12
  192. package/esm/utils/getPluginKey.js.map +1 -1
  193. package/esm/utils/getVisitorKeys.js +9 -3
  194. package/esm/utils/getVisitorKeys.js.map +1 -1
  195. package/esm/utils/hasCachedWywPrevalExport.js +23 -0
  196. package/esm/utils/hasCachedWywPrevalExport.js.map +1 -0
  197. package/esm/utils/hasWywPreval.js +5 -5
  198. package/esm/utils/hasWywPreval.js.map +1 -1
  199. package/esm/utils/importOverrides.js +75 -90
  200. package/esm/utils/importOverrides.js.map +1 -1
  201. package/esm/utils/isNode.js +2 -2
  202. package/esm/utils/isNode.js.map +1 -1
  203. package/esm/utils/isNotNull.js +2 -2
  204. package/esm/utils/isNotNull.js.map +1 -1
  205. package/esm/utils/isSerializable.js +11 -11
  206. package/esm/utils/isSerializable.js.map +1 -1
  207. package/esm/utils/nativeResolver.js +93 -0
  208. package/esm/utils/nativeResolver.js.map +1 -0
  209. package/esm/utils/oxc/ast.js +28 -0
  210. package/esm/utils/oxc/ast.js.map +1 -0
  211. package/esm/utils/oxc/parse.js +3 -0
  212. package/esm/utils/oxc/parse.js.map +1 -0
  213. package/esm/utils/oxc/replacements.js +14 -0
  214. package/esm/utils/oxc/replacements.js.map +1 -0
  215. package/esm/utils/oxc/sourceLocations.js +59 -0
  216. package/esm/utils/oxc/sourceLocations.js.map +1 -0
  217. package/esm/utils/oxcAstService.js +121 -0
  218. package/esm/utils/oxcAstService.js.map +1 -0
  219. package/esm/utils/oxcEmit.js +447 -0
  220. package/esm/utils/oxcEmit.js.map +1 -0
  221. package/esm/utils/oxcPreevalStage/evalStrategy.js +3 -0
  222. package/esm/utils/oxcPreevalStage/evalStrategy.js.map +1 -0
  223. package/esm/utils/oxcPreevalStage/prepareCode.js +21 -0
  224. package/esm/utils/oxcPreevalStage/prepareCode.js.map +1 -0
  225. package/esm/utils/oxcPreevalStage/prevalExport.js +23 -0
  226. package/esm/utils/oxcPreevalStage/prevalExport.js.map +1 -0
  227. package/esm/utils/oxcPreevalStage/processors.js +17 -0
  228. package/esm/utils/oxcPreevalStage/processors.js.map +1 -0
  229. package/esm/utils/oxcPreevalStage/staticOverlay.js +18 -0
  230. package/esm/utils/oxcPreevalStage/staticOverlay.js.map +1 -0
  231. package/esm/utils/oxcPreevalStage/types.js +2 -0
  232. package/esm/utils/oxcPreevalStage/types.js.map +1 -0
  233. package/esm/utils/oxcPreevalStage.js +41 -0
  234. package/esm/utils/oxcPreevalStage.js.map +1 -0
  235. package/esm/utils/oxcPreevalTransforms.js +1065 -0
  236. package/esm/utils/oxcPreevalTransforms.js.map +1 -0
  237. package/esm/utils/oxcShaker.js +662 -0
  238. package/esm/utils/oxcShaker.js.map +1 -0
  239. package/esm/utils/parseOxc.js +37 -0
  240. package/esm/utils/parseOxc.js.map +1 -0
  241. package/esm/utils/parseRequest.js +27 -27
  242. package/esm/utils/parseRequest.js.map +1 -1
  243. package/esm/utils/peek.js +1 -1
  244. package/esm/utils/peek.js.map +1 -1
  245. package/esm/utils/processorLookup.js +125 -0
  246. package/esm/utils/processorLookup.js.map +1 -0
  247. package/esm/utils/processorStaticSemantics.js +157 -0
  248. package/esm/utils/processorStaticSemantics.js.map +1 -0
  249. package/esm/utils/resolveWithConditions.js +99 -0
  250. package/esm/utils/resolveWithConditions.js.map +1 -0
  251. package/esm/vm/createVmContext.js +140 -141
  252. package/esm/vm/createVmContext.js.map +1 -1
  253. package/esm/vm/process.js +11 -13
  254. package/esm/vm/process.js.map +1 -1
  255. package/package.json +19 -26
  256. package/types/cache.d.ts +17 -8
  257. package/types/cache.js +245 -95
  258. package/types/debug/fileReporter.js +68 -23
  259. package/types/eval/broker.d.ts +92 -0
  260. package/types/eval/broker.js +2411 -0
  261. package/types/eval/lru.d.ts +10 -0
  262. package/types/eval/lru.js +36 -0
  263. package/types/eval/prepareModuleOnDemand.d.ts +7 -0
  264. package/types/eval/prepareModuleOnDemand.js +24 -0
  265. package/types/eval/protocol.d.ts +111 -0
  266. package/types/eval/protocol.js +1 -0
  267. package/types/eval/serialize.d.ts +78 -0
  268. package/types/eval/serialize.js +357 -0
  269. package/types/eval/writeQueue.d.ts +13 -0
  270. package/types/eval/writeQueue.js +80 -0
  271. package/types/evaluators/index.d.ts +2 -2
  272. package/types/evaluators/index.js +6 -9
  273. package/types/index.d.ts +3 -6
  274. package/types/index.js +24 -82
  275. package/types/module.d.ts +38 -7
  276. package/types/module.js +613 -192
  277. package/types/shaker.d.ts +2 -10
  278. package/types/shaker.js +10 -100
  279. package/types/transform/BaseEntrypoint.js +6 -11
  280. package/types/transform/Entrypoint.d.ts +15 -15
  281. package/types/transform/Entrypoint.helpers.d.ts +2 -5
  282. package/types/transform/Entrypoint.helpers.js +43 -203
  283. package/types/transform/Entrypoint.js +130 -53
  284. package/types/transform/Entrypoint.types.d.ts +31 -6
  285. package/types/transform/Entrypoint.types.js +1 -2
  286. package/types/transform/EvaluatedEntrypoint.d.ts +13 -2
  287. package/types/transform/EvaluatedEntrypoint.js +7 -6
  288. package/types/transform/actions/AbortError.js +2 -7
  289. package/types/transform/actions/BaseAction.js +4 -8
  290. package/types/transform/actions/UnprocessedEntrypointError.js +2 -7
  291. package/types/transform/actions/actionRunner.js +8 -12
  292. package/types/transform/actions/types.d.ts +2 -2
  293. package/types/transform/actions/types.js +1 -2
  294. package/types/transform/{barrelManifest.d.ts → barrelManifest.types.d.ts} +0 -2
  295. package/types/transform/barrelManifest.types.js +1 -0
  296. package/types/transform/generators/baseProcessingHandlers.d.ts +4 -5
  297. package/types/transform/generators/baseProcessingHandlers.js +10 -14
  298. package/types/transform/generators/collect.js +13 -39
  299. package/types/transform/generators/createStylisPreprocessor.js +19 -60
  300. package/types/transform/generators/evalFile.d.ts +2 -2
  301. package/types/transform/generators/evalFile.js +26 -28
  302. package/types/transform/generators/extract.js +5 -8
  303. package/types/transform/generators/getExports.js +23 -30
  304. package/types/transform/generators/index.d.ts +2 -2
  305. package/types/transform/generators/index.js +11 -14
  306. package/types/transform/generators/processEntrypoint.d.ts +2 -2
  307. package/types/transform/generators/processEntrypoint.js +60 -26
  308. package/types/transform/generators/processImports.d.ts +0 -3
  309. package/types/transform/generators/processImports.js +60 -20
  310. package/types/transform/generators/resolveImports.d.ts +3 -1
  311. package/types/transform/generators/resolveImports.js +66 -23
  312. package/types/transform/generators/resolveStaticOxcValues/cache.d.ts +25 -0
  313. package/types/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  314. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.d.ts +5 -0
  315. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.js +149 -0
  316. package/types/transform/generators/resolveStaticOxcValues/dependencies.d.ts +6 -0
  317. package/types/transform/generators/resolveStaticOxcValues/dependencies.js +37 -0
  318. package/types/transform/generators/resolveStaticOxcValues/environment.d.ts +12 -0
  319. package/types/transform/generators/resolveStaticOxcValues/environment.js +32 -0
  320. package/types/transform/generators/resolveStaticOxcValues/exportResolver.d.ts +4 -0
  321. package/types/transform/generators/resolveStaticOxcValues/exportResolver.js +358 -0
  322. package/types/transform/generators/resolveStaticOxcValues/exportTargets.d.ts +20 -0
  323. package/types/transform/generators/resolveStaticOxcValues/exportTargets.js +285 -0
  324. package/types/transform/generators/resolveStaticOxcValues/objectAssign.d.ts +41 -0
  325. package/types/transform/generators/resolveStaticOxcValues/objectAssign.js +352 -0
  326. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.d.ts +6 -0
  327. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +88 -0
  328. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.d.ts +13 -0
  329. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +263 -0
  330. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.d.ts +4 -0
  331. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.js +191 -0
  332. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.d.ts +40 -0
  333. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.js +516 -0
  334. package/types/transform/generators/resolveStaticOxcValues/processorTarget.d.ts +5 -0
  335. package/types/transform/generators/resolveStaticOxcValues/processorTarget.js +62 -0
  336. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.d.ts +11 -0
  337. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.js +133 -0
  338. package/types/transform/generators/resolveStaticOxcValues/prune.d.ts +15 -0
  339. package/types/transform/generators/resolveStaticOxcValues/prune.js +220 -0
  340. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.d.ts +2 -0
  341. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +197 -0
  342. package/types/transform/generators/resolveStaticOxcValues/staticExpression.d.ts +25 -0
  343. package/types/transform/generators/resolveStaticOxcValues/staticExpression.js +391 -0
  344. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.d.ts +14 -0
  345. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +304 -0
  346. package/types/transform/generators/resolveStaticOxcValues/types.d.ts +99 -0
  347. package/types/transform/generators/resolveStaticOxcValues/types.js +2 -0
  348. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.d.ts +7 -0
  349. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +64 -0
  350. package/types/transform/generators/resolveStaticOxcValues.d.ts +1 -0
  351. package/types/transform/generators/resolveStaticOxcValues.js +1 -0
  352. package/types/transform/generators/{rewriteBarrelImports.d.ts → rewriteOxcBarrelImports.d.ts} +2 -3
  353. package/types/transform/generators/{rewriteBarrelImports.js → rewriteOxcBarrelImports.js} +282 -225
  354. package/types/transform/generators/transform.d.ts +3 -7
  355. package/types/transform/generators/transform.js +217 -199
  356. package/types/transform/generators/workflow.js +62 -45
  357. package/types/transform/helpers/loadWywOptions.js +115 -21
  358. package/types/transform/helpers/withDefaultServices.d.ts +1 -1
  359. package/types/transform/helpers/withDefaultServices.js +6 -44
  360. package/types/transform/isStaticallyEvaluatableModule.d.ts +1 -2
  361. package/types/transform/isStaticallyEvaluatableModule.js +125 -126
  362. package/types/transform/oxcBarrelManifest.d.ts +2 -0
  363. package/types/transform/{barrelManifest.js → oxcBarrelManifest.js} +156 -97
  364. package/types/transform/rootLog.js +2 -5
  365. package/types/transform/syntax.d.ts +38 -0
  366. package/types/transform/syntax.js +1 -0
  367. package/types/transform/types.d.ts +9 -6
  368. package/types/transform/types.js +1 -4
  369. package/types/transform.d.ts +2 -2
  370. package/types/transform.js +90 -101
  371. package/types/types.d.ts +0 -23
  372. package/types/types.js +1 -2
  373. package/types/utils/EventEmitter.d.ts +16 -1
  374. package/types/utils/EventEmitter.js +47 -18
  375. package/types/utils/ShakerMetadata.js +1 -5
  376. package/types/utils/TransformDiagnostics.js +3 -7
  377. package/types/utils/TransformMetadata.js +8 -16
  378. package/types/utils/applyOxcProcessors/applyOxcProcessors.d.ts +8 -0
  379. package/types/utils/applyOxcProcessors/applyOxcProcessors.js +167 -0
  380. package/types/utils/applyOxcProcessors/cleanupBindings.d.ts +12 -0
  381. package/types/utils/applyOxcProcessors/cleanupBindings.js +189 -0
  382. package/types/utils/applyOxcProcessors/cleanupRemovals.d.ts +16 -0
  383. package/types/utils/applyOxcProcessors/cleanupRemovals.js +482 -0
  384. package/types/utils/applyOxcProcessors/displayName.d.ts +9 -0
  385. package/types/utils/applyOxcProcessors/displayName.js +113 -0
  386. package/types/utils/applyOxcProcessors/expressionValues.d.ts +11 -0
  387. package/types/utils/applyOxcProcessors/expressionValues.js +170 -0
  388. package/types/utils/applyOxcProcessors/processorFactory.d.ts +7 -0
  389. package/types/utils/applyOxcProcessors/processorFactory.js +70 -0
  390. package/types/utils/applyOxcProcessors/processorUsages.d.ts +16 -0
  391. package/types/utils/applyOxcProcessors/processorUsages.js +163 -0
  392. package/types/utils/applyOxcProcessors/sameFileStaticValues.d.ts +23 -0
  393. package/types/utils/applyOxcProcessors/sameFileStaticValues.js +211 -0
  394. package/types/utils/applyOxcProcessors/shared.d.ts +10 -0
  395. package/types/utils/applyOxcProcessors/shared.js +37 -0
  396. package/types/utils/applyOxcProcessors/types.d.ts +88 -0
  397. package/types/utils/applyOxcProcessors/types.js +1 -0
  398. package/types/utils/applyOxcProcessors.d.ts +1 -0
  399. package/types/utils/applyOxcProcessors.js +1 -0
  400. package/types/utils/collectOxcExportsAndImports.d.ts +35 -0
  401. package/types/utils/collectOxcExportsAndImports.js +957 -0
  402. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.d.ts +1 -0
  403. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.js +185 -0
  404. package/types/utils/collectOxcRuntime/sourceMap.d.ts +2 -0
  405. package/types/utils/collectOxcRuntime/sourceMap.js +37 -0
  406. package/types/utils/collectOxcRuntime/types.d.ts +16 -0
  407. package/types/utils/collectOxcRuntime/types.js +1 -0
  408. package/types/utils/collectOxcRuntime.d.ts +4 -0
  409. package/types/utils/collectOxcRuntime.js +31 -0
  410. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.d.ts +6 -0
  411. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.js +550 -0
  412. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.d.ts +11 -0
  413. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.js +131 -0
  414. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.d.ts +20 -0
  415. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.js +434 -0
  416. package/types/utils/collectOxcTemplateDependencies/staticBindings.d.ts +7 -0
  417. package/types/utils/collectOxcTemplateDependencies/staticBindings.js +13 -0
  418. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.d.ts +13 -0
  419. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.js +626 -0
  420. package/types/utils/collectOxcTemplateDependencies/types.d.ts +116 -0
  421. package/types/utils/collectOxcTemplateDependencies/types.js +1 -0
  422. package/types/utils/collectOxcTemplateDependencies.d.ts +4 -0
  423. package/types/utils/collectOxcTemplateDependencies.js +3 -0
  424. package/types/utils/getFileIdx.js +1 -4
  425. package/types/utils/getPluginKey.d.ts +5 -2
  426. package/types/utils/getPluginKey.js +2 -6
  427. package/types/utils/getVisitorKeys.d.ts +4 -4
  428. package/types/utils/getVisitorKeys.js +9 -6
  429. package/types/utils/hasCachedWywPrevalExport.d.ts +14 -0
  430. package/types/utils/hasCachedWywPrevalExport.js +30 -0
  431. package/types/utils/hasWywPreval.js +1 -4
  432. package/types/utils/importOverrides.js +17 -27
  433. package/types/utils/isNode.d.ts +2 -2
  434. package/types/utils/isNode.js +2 -6
  435. package/types/utils/isNotNull.js +1 -4
  436. package/types/utils/isSerializable.js +3 -6
  437. package/types/utils/nativeResolver.d.ts +13 -0
  438. package/types/utils/nativeResolver.js +91 -0
  439. package/types/utils/oxc/ast.d.ts +4 -0
  440. package/types/utils/oxc/ast.js +37 -0
  441. package/types/utils/oxc/parse.d.ts +3 -0
  442. package/types/utils/oxc/parse.js +2 -0
  443. package/types/utils/oxc/replacements.d.ts +12 -0
  444. package/types/utils/oxc/replacements.js +18 -0
  445. package/types/utils/oxc/sourceLocations.d.ts +5 -0
  446. package/types/utils/oxc/sourceLocations.js +63 -0
  447. package/types/utils/oxcAstService.d.ts +11 -0
  448. package/types/utils/oxcAstService.js +79 -0
  449. package/types/utils/oxcEmit.d.ts +19 -0
  450. package/types/utils/oxcEmit.js +506 -0
  451. package/types/utils/oxcPreevalStage/evalStrategy.d.ts +3 -0
  452. package/types/utils/oxcPreevalStage/evalStrategy.js +2 -0
  453. package/types/utils/oxcPreevalStage/prepareCode.d.ts +3 -0
  454. package/types/utils/oxcPreevalStage/prepareCode.js +20 -0
  455. package/types/utils/oxcPreevalStage/prevalExport.d.ts +1 -0
  456. package/types/utils/oxcPreevalStage/prevalExport.js +22 -0
  457. package/types/utils/oxcPreevalStage/processors.d.ts +10 -0
  458. package/types/utils/oxcPreevalStage/processors.js +16 -0
  459. package/types/utils/oxcPreevalStage/staticOverlay.d.ts +3 -0
  460. package/types/utils/oxcPreevalStage/staticOverlay.js +23 -0
  461. package/types/utils/oxcPreevalStage/types.d.ts +22 -0
  462. package/types/utils/oxcPreevalStage/types.js +1 -0
  463. package/types/utils/oxcPreevalStage.d.ts +4 -0
  464. package/types/utils/oxcPreevalStage.js +40 -0
  465. package/types/utils/oxcPreevalTransforms.d.ts +13 -0
  466. package/types/utils/oxcPreevalTransforms.js +1192 -0
  467. package/types/utils/oxcShaker.d.ts +13 -0
  468. package/types/utils/oxcShaker.js +751 -0
  469. package/types/utils/parseOxc.d.ts +11 -0
  470. package/types/utils/parseOxc.js +38 -0
  471. package/types/utils/parseRequest.js +2 -7
  472. package/types/utils/peek.js +1 -5
  473. package/types/utils/processorLookup.d.ts +8 -0
  474. package/types/utils/processorLookup.js +135 -0
  475. package/types/utils/processorStaticSemantics.d.ts +13 -0
  476. package/types/utils/processorStaticSemantics.js +191 -0
  477. package/types/utils/resolveWithConditions.d.ts +12 -0
  478. package/types/utils/resolveWithConditions.js +103 -0
  479. package/types/vm/createVmContext.d.ts +2 -2
  480. package/types/vm/createVmContext.js +25 -62
  481. package/types/vm/process.js +20 -26
  482. package/esm/babel.js +0 -2
  483. package/esm/babel.js.map +0 -1
  484. package/esm/options/buildOptions.js +0 -168
  485. package/esm/options/buildOptions.js.map +0 -1
  486. package/esm/options/buildOptions.test.js +0 -138
  487. package/esm/options/buildOptions.test.js.map +0 -1
  488. package/esm/options/loadBabelOptions.js +0 -24
  489. package/esm/options/loadBabelOptions.js.map +0 -1
  490. package/esm/plugins/babel-transform.js +0 -53
  491. package/esm/plugins/babel-transform.js.map +0 -1
  492. package/esm/plugins/collector.js +0 -60
  493. package/esm/plugins/collector.js.map +0 -1
  494. package/esm/plugins/dynamic-import.js +0 -56
  495. package/esm/plugins/dynamic-import.js.map +0 -1
  496. package/esm/plugins/preeval.js +0 -73
  497. package/esm/plugins/preeval.js.map +0 -1
  498. package/esm/plugins/shaker.js +0 -680
  499. package/esm/plugins/shaker.js.map +0 -1
  500. package/esm/transform/barrelManifest.js +0 -291
  501. package/esm/transform/barrelManifest.js.map +0 -1
  502. package/esm/transform/generators/explodeReexports.js +0 -64
  503. package/esm/transform/generators/explodeReexports.js.map +0 -1
  504. package/esm/transform/generators/rewriteBarrelImports.js +0 -733
  505. package/esm/transform/generators/rewriteBarrelImports.js.map +0 -1
  506. package/esm/utils/addIdentifierToWywPreval.js +0 -68
  507. package/esm/utils/addIdentifierToWywPreval.js.map +0 -1
  508. package/esm/utils/collectExportsAndImports.js +0 -1157
  509. package/esm/utils/collectExportsAndImports.js.map +0 -1
  510. package/esm/utils/collectTemplateDependencies.js +0 -228
  511. package/esm/utils/collectTemplateDependencies.js.map +0 -1
  512. package/esm/utils/createId.js +0 -6
  513. package/esm/utils/createId.js.map +0 -1
  514. package/esm/utils/findIdentifiers.js +0 -62
  515. package/esm/utils/findIdentifiers.js.map +0 -1
  516. package/esm/utils/getConstantStringValue.js +0 -58
  517. package/esm/utils/getConstantStringValue.js.map +0 -1
  518. package/esm/utils/getMemberExpressionPropertyName.js +0 -11
  519. package/esm/utils/getMemberExpressionPropertyName.js.map +0 -1
  520. package/esm/utils/getScope.js +0 -6
  521. package/esm/utils/getScope.js.map +0 -1
  522. package/esm/utils/getSource.js +0 -15
  523. package/esm/utils/getSource.js.map +0 -1
  524. package/esm/utils/getTagProcessor.js +0 -404
  525. package/esm/utils/getTagProcessor.js.map +0 -1
  526. package/esm/utils/isExports.js +0 -22
  527. package/esm/utils/isExports.js.map +0 -1
  528. package/esm/utils/isGlobal.js +0 -6
  529. package/esm/utils/isGlobal.js.map +0 -1
  530. package/esm/utils/isNodePath.js +0 -4
  531. package/esm/utils/isNodePath.js.map +0 -1
  532. package/esm/utils/isRemoved.js +0 -46
  533. package/esm/utils/isRemoved.js.map +0 -1
  534. package/esm/utils/isRequire.js +0 -13
  535. package/esm/utils/isRequire.js.map +0 -1
  536. package/esm/utils/isTypedNode.js +0 -6
  537. package/esm/utils/isTypedNode.js.map +0 -1
  538. package/esm/utils/isUnnecessaryReactCall.js +0 -72
  539. package/esm/utils/isUnnecessaryReactCall.js.map +0 -1
  540. package/esm/utils/removeDangerousCode.js +0 -276
  541. package/esm/utils/removeDangerousCode.js.map +0 -1
  542. package/esm/utils/replaceImportMetaEnv.js +0 -44
  543. package/esm/utils/replaceImportMetaEnv.js.map +0 -1
  544. package/esm/utils/scopeHelpers.js +0 -527
  545. package/esm/utils/scopeHelpers.js.map +0 -1
  546. package/esm/utils/traversalCache.js +0 -23
  547. package/esm/utils/traversalCache.js.map +0 -1
  548. package/esm/utils/unwrapExpression.js +0 -18
  549. package/esm/utils/unwrapExpression.js.map +0 -1
  550. package/esm/utils/unwrapSequence.js +0 -14
  551. package/esm/utils/unwrapSequence.js.map +0 -1
  552. package/esm/utils/valueToLiteral.js +0 -59
  553. package/esm/utils/valueToLiteral.js.map +0 -1
  554. package/esm/utils/visitors/JSXElementsRemover.js +0 -51
  555. package/esm/utils/visitors/JSXElementsRemover.js.map +0 -1
  556. package/lib/babel.js +0 -2
  557. package/lib/babel.js.map +0 -1
  558. package/lib/cache.js +0 -308
  559. package/lib/cache.js.map +0 -1
  560. package/lib/debug/fileReporter.js +0 -153
  561. package/lib/debug/fileReporter.js.map +0 -1
  562. package/lib/evaluators/index.js +0 -20
  563. package/lib/evaluators/index.js.map +0 -1
  564. package/lib/index.js +0 -286
  565. package/lib/index.js.map +0 -1
  566. package/lib/module.js +0 -552
  567. package/lib/module.js.map +0 -1
  568. package/lib/options/buildOptions.js +0 -176
  569. package/lib/options/buildOptions.js.map +0 -1
  570. package/lib/options/buildOptions.test.js +0 -141
  571. package/lib/options/buildOptions.test.js.map +0 -1
  572. package/lib/options/loadBabelOptions.js +0 -31
  573. package/lib/options/loadBabelOptions.js.map +0 -1
  574. package/lib/plugins/babel-transform.js +0 -60
  575. package/lib/plugins/babel-transform.js.map +0 -1
  576. package/lib/plugins/collector.js +0 -70
  577. package/lib/plugins/collector.js.map +0 -1
  578. package/lib/plugins/dynamic-import.js +0 -61
  579. package/lib/plugins/dynamic-import.js.map +0 -1
  580. package/lib/plugins/preeval.js +0 -81
  581. package/lib/plugins/preeval.js.map +0 -1
  582. package/lib/plugins/shaker.js +0 -691
  583. package/lib/plugins/shaker.js.map +0 -1
  584. package/lib/shaker.js +0 -95
  585. package/lib/shaker.js.map +0 -1
  586. package/lib/transform/BaseEntrypoint.js +0 -179
  587. package/lib/transform/BaseEntrypoint.js.map +0 -1
  588. package/lib/transform/Entrypoint.helpers.js +0 -279
  589. package/lib/transform/Entrypoint.helpers.js.map +0 -1
  590. package/lib/transform/Entrypoint.js +0 -289
  591. package/lib/transform/Entrypoint.js.map +0 -1
  592. package/lib/transform/Entrypoint.types.js +0 -2
  593. package/lib/transform/Entrypoint.types.js.map +0 -1
  594. package/lib/transform/EvaluatedEntrypoint.js +0 -13
  595. package/lib/transform/EvaluatedEntrypoint.js.map +0 -1
  596. package/lib/transform/actions/AbortError.js +0 -16
  597. package/lib/transform/actions/AbortError.js.map +0 -1
  598. package/lib/transform/actions/BaseAction.js +0 -150
  599. package/lib/transform/actions/BaseAction.js.map +0 -1
  600. package/lib/transform/actions/UnprocessedEntrypointError.js +0 -16
  601. package/lib/transform/actions/UnprocessedEntrypointError.js.map +0 -1
  602. package/lib/transform/actions/actionRunner.js +0 -82
  603. package/lib/transform/actions/actionRunner.js.map +0 -1
  604. package/lib/transform/actions/types.js +0 -2
  605. package/lib/transform/actions/types.js.map +0 -1
  606. package/lib/transform/barrelManifest.js +0 -300
  607. package/lib/transform/barrelManifest.js.map +0 -1
  608. package/lib/transform/generators/baseProcessingHandlers.js +0 -27
  609. package/lib/transform/generators/baseProcessingHandlers.js.map +0 -1
  610. package/lib/transform/generators/collect.js +0 -66
  611. package/lib/transform/generators/collect.js.map +0 -1
  612. package/lib/transform/generators/createStylisPreprocessor.js +0 -372
  613. package/lib/transform/generators/createStylisPreprocessor.js.map +0 -1
  614. package/lib/transform/generators/evalFile.js +0 -57
  615. package/lib/transform/generators/evalFile.js.map +0 -1
  616. package/lib/transform/generators/explodeReexports.js +0 -71
  617. package/lib/transform/generators/explodeReexports.js.map +0 -1
  618. package/lib/transform/generators/extract.js +0 -102
  619. package/lib/transform/generators/extract.js.map +0 -1
  620. package/lib/transform/generators/getExports.js +0 -85
  621. package/lib/transform/generators/getExports.js.map +0 -1
  622. package/lib/transform/generators/index.js +0 -19
  623. package/lib/transform/generators/index.js.map +0 -1
  624. package/lib/transform/generators/processEntrypoint.js +0 -76
  625. package/lib/transform/generators/processEntrypoint.js.map +0 -1
  626. package/lib/transform/generators/processImports.js +0 -82
  627. package/lib/transform/generators/processImports.js.map +0 -1
  628. package/lib/transform/generators/resolveImports.js +0 -221
  629. package/lib/transform/generators/resolveImports.js.map +0 -1
  630. package/lib/transform/generators/rewriteBarrelImports.js +0 -743
  631. package/lib/transform/generators/rewriteBarrelImports.js.map +0 -1
  632. package/lib/transform/generators/transform.js +0 -272
  633. package/lib/transform/generators/transform.js.map +0 -1
  634. package/lib/transform/generators/workflow.js +0 -100
  635. package/lib/transform/generators/workflow.js.map +0 -1
  636. package/lib/transform/helpers/loadWywOptions.js +0 -88
  637. package/lib/transform/helpers/loadWywOptions.js.map +0 -1
  638. package/lib/transform/helpers/withDefaultServices.js +0 -31
  639. package/lib/transform/helpers/withDefaultServices.js.map +0 -1
  640. package/lib/transform/isStaticallyEvaluatableModule.js +0 -159
  641. package/lib/transform/isStaticallyEvaluatableModule.js.map +0 -1
  642. package/lib/transform/rootLog.js +0 -9
  643. package/lib/transform/rootLog.js.map +0 -1
  644. package/lib/transform/types.js +0 -8
  645. package/lib/transform/types.js.map +0 -1
  646. package/lib/transform.js +0 -160
  647. package/lib/transform.js.map +0 -1
  648. package/lib/types.js +0 -2
  649. package/lib/types.js.map +0 -1
  650. package/lib/utils/EventEmitter.js +0 -61
  651. package/lib/utils/EventEmitter.js.map +0 -1
  652. package/lib/utils/ShakerMetadata.js +0 -9
  653. package/lib/utils/ShakerMetadata.js.map +0 -1
  654. package/lib/utils/TransformDiagnostics.js +0 -20
  655. package/lib/utils/TransformDiagnostics.js.map +0 -1
  656. package/lib/utils/TransformMetadata.js +0 -45
  657. package/lib/utils/TransformMetadata.js.map +0 -1
  658. package/lib/utils/addIdentifierToWywPreval.js +0 -75
  659. package/lib/utils/addIdentifierToWywPreval.js.map +0 -1
  660. package/lib/utils/collectExportsAndImports.js +0 -1173
  661. package/lib/utils/collectExportsAndImports.js.map +0 -1
  662. package/lib/utils/collectTemplateDependencies.js +0 -242
  663. package/lib/utils/collectTemplateDependencies.js.map +0 -1
  664. package/lib/utils/createId.js +0 -13
  665. package/lib/utils/createId.js.map +0 -1
  666. package/lib/utils/dispose-polyfill.js +0 -9
  667. package/lib/utils/dispose-polyfill.js.map +0 -1
  668. package/lib/utils/findIdentifiers.js +0 -73
  669. package/lib/utils/findIdentifiers.js.map +0 -1
  670. package/lib/utils/getConstantStringValue.js +0 -66
  671. package/lib/utils/getConstantStringValue.js.map +0 -1
  672. package/lib/utils/getFileIdx.js +0 -16
  673. package/lib/utils/getFileIdx.js.map +0 -1
  674. package/lib/utils/getMemberExpressionPropertyName.js +0 -18
  675. package/lib/utils/getMemberExpressionPropertyName.js.map +0 -1
  676. package/lib/utils/getPluginKey.js +0 -21
  677. package/lib/utils/getPluginKey.js.map +0 -1
  678. package/lib/utils/getScope.js +0 -12
  679. package/lib/utils/getScope.js.map +0 -1
  680. package/lib/utils/getSource.js +0 -24
  681. package/lib/utils/getSource.js.map +0 -1
  682. package/lib/utils/getTagProcessor.js +0 -424
  683. package/lib/utils/getTagProcessor.js.map +0 -1
  684. package/lib/utils/getVisitorKeys.js +0 -11
  685. package/lib/utils/getVisitorKeys.js.map +0 -1
  686. package/lib/utils/hasWywPreval.js +0 -13
  687. package/lib/utils/hasWywPreval.js.map +0 -1
  688. package/lib/utils/importOverrides.js +0 -119
  689. package/lib/utils/importOverrides.js.map +0 -1
  690. package/lib/utils/isExports.js +0 -27
  691. package/lib/utils/isExports.js.map +0 -1
  692. package/lib/utils/isGlobal.js +0 -13
  693. package/lib/utils/isGlobal.js.map +0 -1
  694. package/lib/utils/isNode.js +0 -9
  695. package/lib/utils/isNode.js.map +0 -1
  696. package/lib/utils/isNodePath.js +0 -10
  697. package/lib/utils/isNodePath.js.map +0 -1
  698. package/lib/utils/isNotNull.js +0 -10
  699. package/lib/utils/isNotNull.js.map +0 -1
  700. package/lib/utils/isRemoved.js +0 -52
  701. package/lib/utils/isRemoved.js.map +0 -1
  702. package/lib/utils/isRequire.js +0 -18
  703. package/lib/utils/isRequire.js.map +0 -1
  704. package/lib/utils/isSerializable.js +0 -19
  705. package/lib/utils/isSerializable.js.map +0 -1
  706. package/lib/utils/isTypedNode.js +0 -13
  707. package/lib/utils/isTypedNode.js.map +0 -1
  708. package/lib/utils/isUnnecessaryReactCall.js +0 -81
  709. package/lib/utils/isUnnecessaryReactCall.js.map +0 -1
  710. package/lib/utils/parseRequest.js +0 -37
  711. package/lib/utils/parseRequest.js.map +0 -1
  712. package/lib/utils/peek.js +0 -9
  713. package/lib/utils/peek.js.map +0 -1
  714. package/lib/utils/removeDangerousCode.js +0 -284
  715. package/lib/utils/removeDangerousCode.js.map +0 -1
  716. package/lib/utils/replaceImportMetaEnv.js +0 -50
  717. package/lib/utils/replaceImportMetaEnv.js.map +0 -1
  718. package/lib/utils/scopeHelpers.js +0 -557
  719. package/lib/utils/scopeHelpers.js.map +0 -1
  720. package/lib/utils/traversalCache.js +0 -31
  721. package/lib/utils/traversalCache.js.map +0 -1
  722. package/lib/utils/unwrapExpression.js +0 -25
  723. package/lib/utils/unwrapExpression.js.map +0 -1
  724. package/lib/utils/unwrapSequence.js +0 -20
  725. package/lib/utils/unwrapSequence.js.map +0 -1
  726. package/lib/utils/valueToLiteral.js +0 -65
  727. package/lib/utils/valueToLiteral.js.map +0 -1
  728. package/lib/utils/visitors/JSXElementsRemover.js +0 -57
  729. package/lib/utils/visitors/JSXElementsRemover.js.map +0 -1
  730. package/lib/vm/createVmContext.js +0 -166
  731. package/lib/vm/createVmContext.js.map +0 -1
  732. package/lib/vm/process.js +0 -38
  733. package/lib/vm/process.js.map +0 -1
  734. package/types/babel.d.ts +0 -2
  735. package/types/babel.js +0 -2
  736. package/types/options/buildOptions.d.ts +0 -6
  737. package/types/options/buildOptions.js +0 -178
  738. package/types/options/loadBabelOptions.d.ts +0 -3
  739. package/types/options/loadBabelOptions.js +0 -26
  740. package/types/plugins/babel-transform.d.ts +0 -4
  741. package/types/plugins/babel-transform.js +0 -49
  742. package/types/plugins/collector.d.ts +0 -23
  743. package/types/plugins/collector.js +0 -62
  744. package/types/plugins/dynamic-import.d.ts +0 -6
  745. package/types/plugins/dynamic-import.js +0 -60
  746. package/types/plugins/preeval.d.ts +0 -16
  747. package/types/plugins/preeval.js +0 -69
  748. package/types/plugins/shaker.d.ts +0 -14
  749. package/types/plugins/shaker.js +0 -724
  750. package/types/transform/generators/explodeReexports.d.ts +0 -7
  751. package/types/transform/generators/explodeReexports.js +0 -65
  752. package/types/utils/addIdentifierToWywPreval.d.ts +0 -4
  753. package/types/utils/addIdentifierToWywPreval.js +0 -74
  754. package/types/utils/collectExportsAndImports.d.ts +0 -31
  755. package/types/utils/collectExportsAndImports.js +0 -1147
  756. package/types/utils/collectTemplateDependencies.d.ts +0 -17
  757. package/types/utils/collectTemplateDependencies.js +0 -220
  758. package/types/utils/createId.d.ts +0 -2
  759. package/types/utils/createId.js +0 -9
  760. package/types/utils/findIdentifiers.d.ts +0 -6
  761. package/types/utils/findIdentifiers.js +0 -67
  762. package/types/utils/getConstantStringValue.d.ts +0 -2
  763. package/types/utils/getConstantStringValue.js +0 -94
  764. package/types/utils/getMemberExpressionPropertyName.d.ts +0 -2
  765. package/types/utils/getMemberExpressionPropertyName.js +0 -46
  766. package/types/utils/getScope.d.ts +0 -2
  767. package/types/utils/getScope.js +0 -10
  768. package/types/utils/getSource.d.ts +0 -2
  769. package/types/utils/getSource.js +0 -22
  770. package/types/utils/getTagProcessor.d.ts +0 -13
  771. package/types/utils/getTagProcessor.js +0 -411
  772. package/types/utils/isExports.d.ts +0 -6
  773. package/types/utils/isExports.js +0 -19
  774. package/types/utils/isGlobal.d.ts +0 -2
  775. package/types/utils/isGlobal.js +0 -9
  776. package/types/utils/isNodePath.d.ts +0 -3
  777. package/types/utils/isNodePath.js +0 -6
  778. package/types/utils/isRemoved.d.ts +0 -5
  779. package/types/utils/isRemoved.js +0 -41
  780. package/types/utils/isRequire.d.ts +0 -6
  781. package/types/utils/isRequire.js +0 -14
  782. package/types/utils/isTypedNode.d.ts +0 -5
  783. package/types/utils/isTypedNode.js +0 -9
  784. package/types/utils/isUnnecessaryReactCall.d.ts +0 -3
  785. package/types/utils/isUnnecessaryReactCall.js +0 -75
  786. package/types/utils/removeDangerousCode.d.ts +0 -4
  787. package/types/utils/removeDangerousCode.js +0 -326
  788. package/types/utils/replaceImportMetaEnv.d.ts +0 -3
  789. package/types/utils/replaceImportMetaEnv.js +0 -39
  790. package/types/utils/scopeHelpers.d.ts +0 -12
  791. package/types/utils/scopeHelpers.js +0 -580
  792. package/types/utils/traversalCache.d.ts +0 -4
  793. package/types/utils/traversalCache.js +0 -27
  794. package/types/utils/unwrapExpression.d.ts +0 -2
  795. package/types/utils/unwrapExpression.js +0 -57
  796. package/types/utils/unwrapSequence.d.ts +0 -8
  797. package/types/utils/unwrapSequence.js +0 -16
  798. package/types/utils/valueToLiteral.d.ts +0 -3
  799. package/types/utils/valueToLiteral.js +0 -63
  800. package/types/utils/visitors/JSXElementsRemover.d.ts +0 -3
  801. package/types/utils/visitors/JSXElementsRemover.js +0 -51
@@ -0,0 +1,182 @@
1
+ /* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */
2
+ import { createHash } from "crypto";
3
+ import { readFileSync, statSync } from "fs";
4
+ import { isAbsolute } from "path";
5
+ import { oxcShaker } from "../../../shaker.js";
6
+ import { runOxcPreevalStage } from "../../../utils/oxcPreevalStage.js";
7
+ import { stripQueryAndHash } from "../../../utils/parseRequest.js";
8
+ import { isEnvDisabled, parseProgram } from "./environment.js";
9
+ import { STATIC_EXPORT_MAX_NULL_ATTEMPTS } from "./types.js";
10
+ export const staticFileAnalysisCaches = new WeakMap();
11
+ export const staticFileHashCaches = new WeakMap();
12
+ export const staticExportResultCaches = new WeakMap();
13
+ export const staticMetadataPreevalCaches = new WeakMap();
14
+ export const hashStaticContent = (content) => createHash("sha256").update(content).digest("hex");
15
+ export const getWeakCacheMap = (caches, key) => {
16
+ let cache = caches.get(key);
17
+ if (!cache) {
18
+ cache = new Map();
19
+ caches.set(key, cache);
20
+ }
21
+ return cache;
22
+ };
23
+ export const isStaticResolveCacheEnabled = () => {
24
+ const envValue = process.env.WYW_STATIC_RESOLVE_CACHE?.trim().toLowerCase();
25
+ if (envValue) {
26
+ return !isEnvDisabled(envValue);
27
+ }
28
+ return true;
29
+ };
30
+ export const staticCachePrefix = (action) => `${action.services.cache.getKeySalt() ?? ""}\0${action.services.options.root ?? ""}`;
31
+ export const staticFileAnalysisCache = (action) => getWeakCacheMap(staticFileAnalysisCaches, action.services.cache);
32
+ export const staticFileHashCache = (action) => getWeakCacheMap(staticFileHashCaches, action.services.cache);
33
+ export const staticExportResultCache = (action) => getWeakCacheMap(staticExportResultCaches, action.services.cache);
34
+ export const staticMetadataPreevalCache = (action) => getWeakCacheMap(staticMetadataPreevalCaches, action.services.cache);
35
+ export const staticFileAnalysisCacheKey = (action, filename, codeHash) => `${staticCachePrefix(action)}\0${filename}\0${codeHash}`;
36
+ export const staticExportCacheKey = (action, filename, exportedName, codeHash) => `${staticCachePrefix(action)}\0${filename}\0${exportedName}\0${codeHash}`;
37
+ export const staticMetadataPreevalCacheKey = (action, filename, codeHash) => `${staticCachePrefix(action)}\0${filename}\0${codeHash}`;
38
+ export const getStaticFileContentHash = (action, dependency) => {
39
+ const filename = stripQueryAndHash(dependency);
40
+ if (!isAbsolute(filename)) {
41
+ return null;
42
+ }
43
+ let stat;
44
+ try {
45
+ stat = statSync(filename);
46
+ } catch {
47
+ return null;
48
+ }
49
+ if (!stat.isFile()) {
50
+ return null;
51
+ }
52
+ const cache = staticFileHashCache(action);
53
+ const cached = cache.get(filename);
54
+ if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {
55
+ return cached.hash;
56
+ }
57
+ let hash;
58
+ try {
59
+ hash = hashStaticContent(readFileSync(filename));
60
+ } catch {
61
+ return null;
62
+ }
63
+ cache.set(filename, {
64
+ hash,
65
+ mtimeMs: stat.mtimeMs,
66
+ size: stat.size
67
+ });
68
+ return hash;
69
+ };
70
+ export const collectStaticDependencyHashes = (action, dependencies) => {
71
+ const hashes = new Map();
72
+ for (const dependency of dependencies) {
73
+ const hash = getStaticFileContentHash(action, dependency);
74
+ if (!hash) {
75
+ return null;
76
+ }
77
+ hashes.set(stripQueryAndHash(dependency), hash);
78
+ }
79
+ return hashes;
80
+ };
81
+ export const areStaticDependencyHashesCurrent = (action, dependencyHashes) => {
82
+ for (const [dependency, expectedHash] of dependencyHashes) {
83
+ if (getStaticFileContentHash(action, dependency) !== expectedHash) {
84
+ return false;
85
+ }
86
+ }
87
+ return true;
88
+ };
89
+ export const getStaticExportCachedResult = (action, filename, exportedName, codeHash) => {
90
+ if (!isStaticResolveCacheEnabled()) {
91
+ return undefined;
92
+ }
93
+ const cache = staticExportResultCache(action);
94
+ const cacheKey = staticExportCacheKey(action, filename, exportedName, codeHash);
95
+ const cached = cache.get(cacheKey);
96
+ if (!cached) {
97
+ return undefined;
98
+ }
99
+ if (cached.result === null) {
100
+ // Bounded retry: until the attempt counter has been bumped enough times
101
+ // that we accept the null as stable, treat it as a cache miss so the
102
+ // caller re-walks. The counter is updated in setStaticExportCachedResult.
103
+ if (cached.attempts < STATIC_EXPORT_MAX_NULL_ATTEMPTS) {
104
+ return undefined;
105
+ }
106
+ return null;
107
+ }
108
+ if (areStaticDependencyHashesCurrent(action, cached.dependencyHashes)) {
109
+ return cached.result;
110
+ }
111
+ cache.delete(cacheKey);
112
+ return undefined;
113
+ };
114
+ export const setStaticExportCachedResult = (action, filename, exportedName, codeHash, result) => {
115
+ if (!isStaticResolveCacheEnabled()) {
116
+ return;
117
+ }
118
+ const cache = staticExportResultCache(action);
119
+ const cacheKey = staticExportCacheKey(action, filename, exportedName, codeHash);
120
+ if (!result) {
121
+ const existing = cache.get(cacheKey);
122
+ const attempts = existing && existing.result === null ? existing.attempts + 1 : 1;
123
+ cache.set(cacheKey, {
124
+ attempts,
125
+ result: null
126
+ });
127
+ return;
128
+ }
129
+ const dependencyHashes = collectStaticDependencyHashes(action, result.dependencies);
130
+ if (!dependencyHashes) {
131
+ return;
132
+ }
133
+ cache.set(cacheKey, {
134
+ dependencyHashes,
135
+ result
136
+ });
137
+ };
138
+ export const getStaticFileAnalysis = (action, filename) => {
139
+ const loadedAndParsed = action.services.loadAndParseFn(action.services, filename, undefined, action.services.log);
140
+ if (loadedAndParsed.evaluator === "ignored" || loadedAndParsed.evaluator !== oxcShaker) {
141
+ return null;
142
+ }
143
+ const { code } = loadedAndParsed;
144
+ const codeHash = hashStaticContent(code);
145
+ const cache = staticFileAnalysisCache(action);
146
+ const cacheKey = staticFileAnalysisCacheKey(action, filename, codeHash);
147
+ const cached = cache.get(cacheKey);
148
+ if (cached) {
149
+ return cached;
150
+ }
151
+ const analysis = {
152
+ code,
153
+ codeHash,
154
+ program: parseProgram(code, filename)
155
+ };
156
+ cache.set(cacheKey, analysis);
157
+ return analysis;
158
+ };
159
+ export const getStaticMetadataPreevalResult = (action, filename, code, codeHash) => {
160
+ const cache = staticMetadataPreevalCache(action);
161
+ const cacheKey = staticMetadataPreevalCacheKey(action, filename, codeHash);
162
+ const cached = cache.get(cacheKey);
163
+ if (cached) {
164
+ return cached.result;
165
+ }
166
+ const root = action.services.options.root ?? process.cwd();
167
+ try {
168
+ const result = action.services.eventEmitter.perf("transform:preeval:staticMetadata", () => runOxcPreevalStage(code, {
169
+ filename,
170
+ root
171
+ }, {
172
+ ...action.services.options.pluginOptions,
173
+ eventEmitter: action.services.eventEmitter
174
+ }));
175
+ cache.set(cacheKey, { result });
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AAM,SAAS,MAAM,IAAI,SAAS;AAClC,KAAI,QAAQ;AACV,SAAO;;CAGT,MAAM,WAAW;EACf;EACA;EACA,SAAS,aAAa,MAAM,SAAS;EACtC;AACD,OAAM,IAAI,UAAU,SAAS;AAC7B,QAAO;;AAGT,OAAO,MAAM,kCACX,QACA,UACA,MACA,aACiD;CACjD,MAAM,QAAQ,2BAA2B,OAAO;CAChD,MAAM,WAAW,8BAA8B,QAAQ,UAAU,SAAS;CAC1E,MAAM,SAAS,MAAM,IAAI,SAAS;AAClC,KAAI,QAAQ;AACV,SAAO,OAAO;;CAGhB,MAAM,OAAO,OAAO,SAAS,QAAQ,QAAQ,QAAQ,KAAK;AAC1D,KAAI;EACF,MAAM,SAAS,OAAO,SAAS,aAAa,KAC1C,0CAEE,mBACE,MACA;GACE;GACA;GACD,EACD;GACE,GAAG,OAAO,SAAS,QAAQ;GAC3B,cAAc,OAAO,SAAS;GAC/B,CACF,CACJ;AACD,QAAM,IAAI,UAAU,EAAE,QAAQ,CAAC;AAC/B,SAAO;SACD;AACN,QAAM,IAAI,UAAU,EAAE,QAAQ,MAAM,CAAC;AACrC,SAAO","names":[],"sources":["../../../../src/transform/generators/resolveStaticOxcValues/cache.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport { createHash } from 'crypto';\nimport { readFileSync, statSync } from 'fs';\nimport { isAbsolute } from 'path';\n\nimport { oxcShaker } from '../../../shaker';\nimport { runOxcPreevalStage } from '../../../utils/oxcPreevalStage';\nimport { stripQueryAndHash } from '../../../utils/parseRequest';\nimport type { ITransformAction } from '../../types';\nimport { isEnvDisabled, parseProgram } from './environment';\nimport type {\n StaticExportCacheEntry,\n StaticExportResult,\n StaticFileAnalysis,\n StaticFileHashCacheEntry,\n StaticMetadataPreevalCacheEntry,\n} from './types';\nimport { STATIC_EXPORT_MAX_NULL_ATTEMPTS } from './types';\n\nexport const staticFileAnalysisCaches = new WeakMap<\n object,\n Map<string, StaticFileAnalysis>\n>();\n\nexport const staticFileHashCaches = new WeakMap<\n object,\n Map<string, StaticFileHashCacheEntry>\n>();\n\nexport const staticExportResultCaches = new WeakMap<\n object,\n Map<string, StaticExportCacheEntry>\n>();\n\nexport const staticMetadataPreevalCaches = new WeakMap<\n object,\n Map<string, StaticMetadataPreevalCacheEntry>\n>();\n\nexport const hashStaticContent = (content: string | Buffer): string =>\n createHash('sha256').update(content).digest('hex');\n\nexport const getWeakCacheMap = <TValue>(\n caches: WeakMap<object, Map<string, TValue>>,\n key: object\n): Map<string, TValue> => {\n let cache = caches.get(key);\n if (!cache) {\n cache = new Map();\n caches.set(key, cache);\n }\n\n return cache;\n};\n\nexport const isStaticResolveCacheEnabled = (): boolean => {\n const envValue = process.env.WYW_STATIC_RESOLVE_CACHE?.trim().toLowerCase();\n if (envValue) {\n return !isEnvDisabled(envValue);\n }\n\n return true;\n};\n\nexport const staticCachePrefix = (action: ITransformAction): string =>\n `${action.services.cache.getKeySalt() ?? ''}\\0${\n action.services.options.root ?? ''\n }`;\n\nexport const staticFileAnalysisCache = (\n action: ITransformAction\n): Map<string, StaticFileAnalysis> =>\n getWeakCacheMap(staticFileAnalysisCaches, action.services.cache);\n\nexport const staticFileHashCache = (\n action: ITransformAction\n): Map<string, StaticFileHashCacheEntry> =>\n getWeakCacheMap(staticFileHashCaches, action.services.cache);\n\nexport const staticExportResultCache = (\n action: ITransformAction\n): Map<string, StaticExportCacheEntry> =>\n getWeakCacheMap(staticExportResultCaches, action.services.cache);\n\nexport const staticMetadataPreevalCache = (\n action: ITransformAction\n): Map<string, StaticMetadataPreevalCacheEntry> =>\n getWeakCacheMap(staticMetadataPreevalCaches, action.services.cache);\n\nexport const staticFileAnalysisCacheKey = (\n action: ITransformAction,\n filename: string,\n codeHash: string\n): string => `${staticCachePrefix(action)}\\0${filename}\\0${codeHash}`;\n\nexport const staticExportCacheKey = (\n action: ITransformAction,\n filename: string,\n exportedName: string,\n codeHash: string\n): string =>\n `${staticCachePrefix(action)}\\0${filename}\\0${exportedName}\\0${codeHash}`;\n\nexport const staticMetadataPreevalCacheKey = (\n action: ITransformAction,\n filename: string,\n codeHash: string\n): string => `${staticCachePrefix(action)}\\0${filename}\\0${codeHash}`;\n\nexport const getStaticFileContentHash = (\n action: ITransformAction,\n dependency: string\n): string | null => {\n const filename = stripQueryAndHash(dependency);\n if (!isAbsolute(filename)) {\n return null;\n }\n\n let stat;\n try {\n stat = statSync(filename);\n } catch {\n return null;\n }\n\n if (!stat.isFile()) {\n return null;\n }\n\n const cache = staticFileHashCache(action);\n const cached = cache.get(filename);\n if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {\n return cached.hash;\n }\n\n let hash: string;\n try {\n hash = hashStaticContent(readFileSync(filename));\n } catch {\n return null;\n }\n\n cache.set(filename, {\n hash,\n mtimeMs: stat.mtimeMs,\n size: stat.size,\n });\n return hash;\n};\n\nexport const collectStaticDependencyHashes = (\n action: ITransformAction,\n dependencies: string[]\n): Map<string, string> | null => {\n const hashes = new Map<string, string>();\n for (const dependency of dependencies) {\n const hash = getStaticFileContentHash(action, dependency);\n if (!hash) {\n return null;\n }\n\n hashes.set(stripQueryAndHash(dependency), hash);\n }\n\n return hashes;\n};\n\nexport const areStaticDependencyHashesCurrent = (\n action: ITransformAction,\n dependencyHashes: Map<string, string>\n): boolean => {\n for (const [dependency, expectedHash] of dependencyHashes) {\n if (getStaticFileContentHash(action, dependency) !== expectedHash) {\n return false;\n }\n }\n\n return true;\n};\n\nexport const getStaticExportCachedResult = (\n action: ITransformAction,\n filename: string,\n exportedName: string,\n codeHash: string\n): StaticExportResult | null | undefined => {\n if (!isStaticResolveCacheEnabled()) {\n return undefined;\n }\n\n const cache = staticExportResultCache(action);\n const cacheKey = staticExportCacheKey(\n action,\n filename,\n exportedName,\n codeHash\n );\n const cached = cache.get(cacheKey);\n if (!cached) {\n return undefined;\n }\n\n if (cached.result === null) {\n // Bounded retry: until the attempt counter has been bumped enough times\n // that we accept the null as stable, treat it as a cache miss so the\n // caller re-walks. The counter is updated in setStaticExportCachedResult.\n if (cached.attempts < STATIC_EXPORT_MAX_NULL_ATTEMPTS) {\n return undefined;\n }\n return null;\n }\n\n if (areStaticDependencyHashesCurrent(action, cached.dependencyHashes)) {\n return cached.result;\n }\n\n cache.delete(cacheKey);\n return undefined;\n};\n\nexport const setStaticExportCachedResult = (\n action: ITransformAction,\n filename: string,\n exportedName: string,\n codeHash: string,\n result: StaticExportResult | null\n): void => {\n if (!isStaticResolveCacheEnabled()) {\n return;\n }\n\n const cache = staticExportResultCache(action);\n const cacheKey = staticExportCacheKey(\n action,\n filename,\n exportedName,\n codeHash\n );\n if (!result) {\n const existing = cache.get(cacheKey);\n const attempts =\n existing && existing.result === null ? existing.attempts + 1 : 1;\n cache.set(cacheKey, { attempts, result: null });\n return;\n }\n\n const dependencyHashes = collectStaticDependencyHashes(\n action,\n result.dependencies\n );\n if (!dependencyHashes) {\n return;\n }\n\n cache.set(cacheKey, {\n dependencyHashes,\n result,\n });\n};\n\nexport const getStaticFileAnalysis = (\n action: ITransformAction,\n filename: string\n): StaticFileAnalysis | null => {\n const loadedAndParsed = action.services.loadAndParseFn(\n action.services,\n filename,\n undefined,\n action.services.log\n );\n if (\n loadedAndParsed.evaluator === 'ignored' ||\n loadedAndParsed.evaluator !== oxcShaker\n ) {\n return null;\n }\n\n const { code } = loadedAndParsed;\n const codeHash = hashStaticContent(code);\n const cache = staticFileAnalysisCache(action);\n const cacheKey = staticFileAnalysisCacheKey(action, filename, codeHash);\n const cached = cache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const analysis = {\n code,\n codeHash,\n program: parseProgram(code, filename),\n };\n cache.set(cacheKey, analysis);\n return analysis;\n};\n\nexport const getStaticMetadataPreevalResult = (\n action: ITransformAction,\n filename: string,\n code: string,\n codeHash: string\n): ReturnType<typeof runOxcPreevalStage> | null => {\n const cache = staticMetadataPreevalCache(action);\n const cacheKey = staticMetadataPreevalCacheKey(action, filename, codeHash);\n const cached = cache.get(cacheKey);\n if (cached) {\n return cached.result;\n }\n\n const root = action.services.options.root ?? process.cwd();\n try {\n const result = action.services.eventEmitter.perf(\n 'transform:preeval:staticMetadata',\n () =>\n runOxcPreevalStage(\n code,\n {\n filename,\n root,\n },\n {\n ...action.services.options.pluginOptions,\n eventEmitter: action.services.eventEmitter,\n }\n )\n );\n cache.set(cacheKey, { result });\n return result;\n } catch {\n cache.set(cacheKey, { result: null });\n return null;\n }\n};\n"],"file":"cache.js"}
@@ -0,0 +1,146 @@
1
+ import { evaluateOxcStaticExpression, isOxcStaticSerializableValue, lookupStaticBinding } from "../../../utils/collectOxcTemplateDependencies.js";
2
+ import { resolveDependency } from "./dependencies.js";
3
+ import { debugStaticResolve, getStaticBindings } from "./environment.js";
4
+ import { resolveImportValue } from "./exportResolver.js";
5
+ import { resolveImportAsOpaqueRuntime } from "./opaqueRuntime.js";
6
+ import { bindStaticResolvedValue, isRuntimeCallbackExpression, parseStaticExpressionSource } from "./staticExpression.js";
7
+ export function* resolveCandidateValue(action, candidate, filename, memo) {
8
+ const env = new Map();
9
+ const dependencies = new Set();
10
+ const sideEffectDependencies = new Set();
11
+ const sideEffectImportLocals = new Set();
12
+ let candidateExpression;
13
+ if (candidate.inlineConstants) {
14
+ for (const [name, value] of Object.entries(candidate.inlineConstants)) {
15
+ env.set(name, value);
16
+ }
17
+ }
18
+ const staticBindingsForCandidate = getStaticBindings(action);
19
+ for (const item of candidate.imports) {
20
+ // staticBindings overrides take precedence over actual import
21
+ // resolution: a registered value (or function) replaces whatever
22
+ // the source module would otherwise provide. Useful for prototyping
23
+ // / SSR theming and for opaque utilities like `cx`.
24
+ //
25
+ // Match the override map first by the raw specifier as written
26
+ // (`@linaria/core`, `./flags`, …). If that misses, resolve to an
27
+ // absolute path and try again — this lets the host key by
28
+ // absolute file path so a single entry covers every relative
29
+ // variant of the same module.
30
+ let override = lookupStaticBinding(staticBindingsForCandidate, item.source, item.imported);
31
+ if (!override.found && staticBindingsForCandidate) {
32
+ const dep = yield* resolveDependency(action, filename, item.source, item.imported);
33
+ if (dep?.resolved) {
34
+ override = lookupStaticBinding(staticBindingsForCandidate, dep.resolved, item.imported);
35
+ }
36
+ }
37
+ if (override.found) {
38
+ env.set(item.local, override.value);
39
+ continue;
40
+ }
41
+ const resolved = yield* resolveImportValue(action, filename, item, new Set(), memo);
42
+ if (!resolved) {
43
+ debugStaticResolve(action, {
44
+ candidate: candidate.name,
45
+ filename,
46
+ imported: item.imported,
47
+ phase: "candidate",
48
+ reason: "candidate-import-unresolved",
49
+ source: item.source,
50
+ status: "rejected"
51
+ });
52
+ return null;
53
+ }
54
+ if (resolved.callable === "zero-arg" && candidateExpression === undefined) {
55
+ candidateExpression = parseStaticExpressionSource(candidate.source, filename);
56
+ }
57
+ const expressionForBinding = resolved.callable === "zero-arg" ? candidateExpression : null;
58
+ if (resolved.callable === "zero-arg" && !expressionForBinding || expressionForBinding && !bindStaticResolvedValue(env, expressionForBinding, item.local, resolved)) {
59
+ debugStaticResolve(action, {
60
+ candidate: candidate.name,
61
+ filename,
62
+ imported: item.imported,
63
+ phase: "candidate",
64
+ reason: "candidate-callable-usage-unsupported",
65
+ source: item.source,
66
+ status: "rejected"
67
+ });
68
+ return null;
69
+ }
70
+ if (!expressionForBinding) {
71
+ env.set(item.local, resolved.value);
72
+ }
73
+ resolved.dependencies.forEach((dependency) => dependencies.add(dependency));
74
+ resolved.sideEffectDependencies?.forEach((dependency) => {
75
+ sideEffectDependencies.add(dependency);
76
+ sideEffectImportLocals.add(item.importLocal ?? item.local);
77
+ });
78
+ }
79
+ if (candidateExpression === undefined) {
80
+ candidateExpression = parseStaticExpressionSource(candidate.source, filename);
81
+ }
82
+ const value = evaluateOxcStaticExpression(candidate.source, filename, env, getStaticBindings(action));
83
+ // Function-valued candidates are runtime callbacks (e.g. styled-
84
+ // component dynamic prop interpolations like `${props => ...}`). The
85
+ // value isn't serializable, but the candidate IS resolved — the
86
+ // local `_exp = () => target` arrow already lives in the bundle, so
87
+ // the file does not need evalFile to compute it. Mark the result as
88
+ // runtimeOnly so the helper declaration survives pruning.
89
+ if (typeof value === "function" || value === undefined && isRuntimeCallbackExpression(candidateExpression)) {
90
+ debugStaticResolve(action, {
91
+ candidate: candidate.name,
92
+ filename,
93
+ phase: "candidate",
94
+ reason: "runtime-callback",
95
+ status: "resolved"
96
+ });
97
+ return {
98
+ dependencies: [...dependencies],
99
+ runtimeOnly: true,
100
+ sideEffectDependencies: [...sideEffectDependencies],
101
+ sideEffectImportLocals: [...sideEffectImportLocals],
102
+ value
103
+ };
104
+ }
105
+ if (!isOxcStaticSerializableValue(value)) {
106
+ debugStaticResolve(action, {
107
+ candidate: candidate.name,
108
+ filename,
109
+ phase: "candidate",
110
+ reason: "candidate-expression-non-serializable",
111
+ status: "rejected"
112
+ });
113
+ return null;
114
+ }
115
+ debugStaticResolve(action, {
116
+ candidate: candidate.name,
117
+ filename,
118
+ phase: "candidate",
119
+ status: "resolved"
120
+ });
121
+ return {
122
+ dependencies: [...dependencies],
123
+ sideEffectDependencies: [...sideEffectDependencies],
124
+ sideEffectImportLocals: [...sideEffectImportLocals],
125
+ value
126
+ };
127
+ }
128
+ export function* resolveOpaqueRuntimeCandidateValue(action, candidate, filename) {
129
+ if (candidate.imports.length === 0) {
130
+ return null;
131
+ }
132
+ const dependencies = new Set();
133
+ const memo = new Map();
134
+ for (const item of candidate.imports) {
135
+ const proof = yield* resolveImportAsOpaqueRuntime(action, filename, item, new Set(), memo);
136
+ if (!proof) {
137
+ return null;
138
+ }
139
+ proof.dependencies.forEach((dependency) => dependencies.add(dependency));
140
+ }
141
+ return {
142
+ dependencies: [...dependencies],
143
+ value: null
144
+ };
145
+ }
146
+ //# sourceMappingURL=candidateResolver.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAIA,SACE,6BACA,8BACA,2BAEK;AAEP,SAAS,yBAAyB;AAClC,SAAS,oBAAoB,yBAAyB;AACtD,SAAS,0BAA0B;AACnC,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Aa;CACtC,MAAM,OAAO,IAAI,KAA8C;AAE/D,MAAK,MAAM,QAAQ,UAAU,SAAS;EACpC,MAAM,QAAQ,OAAO,6BACnB,QACA,UACA,MACA,IAAI,KAAK,EACT,KACD;AACD,MAAI,CAAC,OAAO;AACV,UAAO;;AAGT,QAAM,aAAa,SAAS,eAAe,aAAa,IAAI,WAAW,CAAC;;AAG1E,QAAO;EACL,cAAc,CAAC,GAAG,aAAa;EAC/B,OAAO;EACR","names":[],"sources":["../../../../src/transform/generators/resolveStaticOxcValues/candidateResolver.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport type { Expression } from 'oxc-parser';\n\nimport {\n evaluateOxcStaticExpression,\n isOxcStaticSerializableValue,\n lookupStaticBinding,\n type OxcStaticValueCandidate,\n} from '../../../utils/collectOxcTemplateDependencies';\nimport type { ITransformAction, SyncScenarioFor } from '../../types';\nimport { resolveDependency } from './dependencies';\nimport { debugStaticResolve, getStaticBindings } from './environment';\nimport { resolveImportValue } from './exportResolver';\nimport { resolveImportAsOpaqueRuntime } from './opaqueRuntime';\nimport {\n bindStaticResolvedValue,\n isRuntimeCallbackExpression,\n parseStaticExpressionSource,\n} from './staticExpression';\nimport type { OpaqueRuntimeImportProof, StaticExportResult } from './types';\n\nexport function* resolveCandidateValue(\n action: ITransformAction,\n candidate: OxcStaticValueCandidate,\n filename: string,\n memo: Map<string, StaticExportResult | null>\n): SyncScenarioFor<StaticExportResult | null> {\n const env = new Map<string, unknown>();\n const dependencies = new Set<string>();\n const sideEffectDependencies = new Set<string>();\n const sideEffectImportLocals = new Set<string>();\n let candidateExpression: Expression | null | undefined;\n\n if (candidate.inlineConstants) {\n for (const [name, value] of Object.entries(candidate.inlineConstants)) {\n env.set(name, value);\n }\n }\n\n const staticBindingsForCandidate = getStaticBindings(action);\n\n for (const item of candidate.imports) {\n // staticBindings overrides take precedence over actual import\n // resolution: a registered value (or function) replaces whatever\n // the source module would otherwise provide. Useful for prototyping\n // / SSR theming and for opaque utilities like `cx`.\n //\n // Match the override map first by the raw specifier as written\n // (`@linaria/core`, `./flags`, …). If that misses, resolve to an\n // absolute path and try again — this lets the host key by\n // absolute file path so a single entry covers every relative\n // variant of the same module.\n let override = lookupStaticBinding(\n staticBindingsForCandidate,\n item.source,\n item.imported\n );\n if (!override.found && staticBindingsForCandidate) {\n const dep = yield* resolveDependency(\n action,\n filename,\n item.source,\n item.imported\n );\n if (dep?.resolved) {\n override = lookupStaticBinding(\n staticBindingsForCandidate,\n dep.resolved,\n item.imported\n );\n }\n }\n if (override.found) {\n env.set(item.local, override.value);\n continue;\n }\n\n const resolved = yield* resolveImportValue(\n action,\n filename,\n item,\n new Set(),\n memo\n );\n if (!resolved) {\n debugStaticResolve(action, {\n candidate: candidate.name,\n filename,\n imported: item.imported,\n phase: 'candidate',\n reason: 'candidate-import-unresolved',\n source: item.source,\n status: 'rejected',\n });\n return null;\n }\n\n if (resolved.callable === 'zero-arg' && candidateExpression === undefined) {\n candidateExpression = parseStaticExpressionSource(\n candidate.source,\n filename\n );\n }\n\n const expressionForBinding =\n resolved.callable === 'zero-arg' ? candidateExpression : null;\n if (\n (resolved.callable === 'zero-arg' && !expressionForBinding) ||\n (expressionForBinding &&\n !bindStaticResolvedValue(\n env,\n expressionForBinding,\n item.local,\n resolved\n ))\n ) {\n debugStaticResolve(action, {\n candidate: candidate.name,\n filename,\n imported: item.imported,\n phase: 'candidate',\n reason: 'candidate-callable-usage-unsupported',\n source: item.source,\n status: 'rejected',\n });\n return null;\n }\n\n if (!expressionForBinding) {\n env.set(item.local, resolved.value);\n }\n\n resolved.dependencies.forEach((dependency) => dependencies.add(dependency));\n resolved.sideEffectDependencies?.forEach((dependency) => {\n sideEffectDependencies.add(dependency);\n sideEffectImportLocals.add(item.importLocal ?? item.local);\n });\n }\n\n if (candidateExpression === undefined) {\n candidateExpression = parseStaticExpressionSource(\n candidate.source,\n filename\n );\n }\n\n const value = evaluateOxcStaticExpression(\n candidate.source,\n filename,\n env,\n getStaticBindings(action)\n );\n // Function-valued candidates are runtime callbacks (e.g. styled-\n // component dynamic prop interpolations like `${props => ...}`). The\n // value isn't serializable, but the candidate IS resolved — the\n // local `_exp = () => target` arrow already lives in the bundle, so\n // the file does not need evalFile to compute it. Mark the result as\n // runtimeOnly so the helper declaration survives pruning.\n if (\n typeof value === 'function' ||\n (value === undefined && isRuntimeCallbackExpression(candidateExpression))\n ) {\n debugStaticResolve(action, {\n candidate: candidate.name,\n filename,\n phase: 'candidate',\n reason: 'runtime-callback',\n status: 'resolved',\n });\n return {\n dependencies: [...dependencies],\n runtimeOnly: true,\n sideEffectDependencies: [...sideEffectDependencies],\n sideEffectImportLocals: [...sideEffectImportLocals],\n value,\n };\n }\n\n if (!isOxcStaticSerializableValue(value)) {\n debugStaticResolve(action, {\n candidate: candidate.name,\n filename,\n phase: 'candidate',\n reason: 'candidate-expression-non-serializable',\n status: 'rejected',\n });\n return null;\n }\n\n debugStaticResolve(action, {\n candidate: candidate.name,\n filename,\n phase: 'candidate',\n status: 'resolved',\n });\n\n return {\n dependencies: [...dependencies],\n sideEffectDependencies: [...sideEffectDependencies],\n sideEffectImportLocals: [...sideEffectImportLocals],\n value,\n };\n}\n\nexport function* resolveOpaqueRuntimeCandidateValue(\n action: ITransformAction,\n candidate: OxcStaticValueCandidate,\n filename: string\n): SyncScenarioFor<StaticExportResult | null> {\n if (candidate.imports.length === 0) {\n return null;\n }\n\n const dependencies = new Set<string>();\n const memo = new Map<string, OpaqueRuntimeImportProof | null>();\n\n for (const item of candidate.imports) {\n const proof = yield* resolveImportAsOpaqueRuntime(\n action,\n filename,\n item,\n new Set(),\n memo\n );\n if (!proof) {\n return null;\n }\n\n proof.dependencies.forEach((dependency) => dependencies.add(dependency));\n }\n\n return {\n dependencies: [...dependencies],\n value: null,\n };\n}\n"],"file":"candidateResolver.js"}
@@ -0,0 +1,33 @@
1
+ /* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */
2
+ import { Entrypoint } from "../../Entrypoint.js";
3
+ import { getWeakCacheMap } from "./cache.js";
4
+ export const isRelativeSource = (source) => source.startsWith("./") || source.startsWith("../") || source === "." || source === "..";
5
+ export const dependencyResolutionCaches = new WeakMap();
6
+ // Bare package and alias resolution can depend on the importer through nested
7
+ // packages, package boundaries, tsconfig paths, or bundler aliases.
8
+ export const dependencyResolutionCacheKey = (importer, source, imported) => `${importer}\0${source}\0${imported}`;
9
+ export function* resolveDependency(action, importer, source, imported) {
10
+ const entrypoint = importer === action.entrypoint.name ? action.entrypoint : Entrypoint.createRoot(action.services, importer, [imported], undefined);
11
+ const imports = new Map([[source, [imported]]]);
12
+ const [resolved] = yield* action.getNext("resolveImports", entrypoint, {
13
+ imports,
14
+ phase: "initial"
15
+ });
16
+ // Non-relative sources (package names, aliases) can still be importer-
17
+ // dependent because of nested packages, tsconfig boundaries, and bundler
18
+ // aliases. Cache only within the same importer context.
19
+ if (!isRelativeSource(source)) {
20
+ const cache = getWeakCacheMap(dependencyResolutionCaches, action.services.cache);
21
+ const cacheKey = dependencyResolutionCacheKey(importer, source, imported);
22
+ if (resolved?.resolved) {
23
+ cache.set(cacheKey, resolved);
24
+ return resolved;
25
+ }
26
+ const cached = cache.get(cacheKey);
27
+ if (cached?.resolved) {
28
+ return cached;
29
+ }
30
+ }
31
+ return resolved ?? null;
32
+ }
33
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";AAEA,SAAS,kBAAkB;AAG3B,SAAS,uBAAuB;AAEhC,OAAO,MAAM,oBAAoB,WAC/B,OAAO,WAAW,KAAK,IACvB,OAAO,WAAW,MAAM,IACxB,WAAW,OACX,WAAW;AAEb,OAAO,MAAM,6BAA6B,IAAI,SAG3C;;;AAIH,OAAO,MAAM,gCACX,UACA,QACA,aACW,GAAG,SAAS,IAAI,OAAO,IAAI;AAExC,OAAO,UAAU,kBACf,QACA,UACA,QACA,UAC+C;CAC/C,MAAM,aACJ,aAAa,OAAO,WAAW,OAC3B,OAAO,aACP,WAAW,WAAW,OAAO,UAAU,UAAU,CAAC,SAAS,EAAE,UAAU;CAC7E,MAAM,UAAU,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;CAC/C,MAAM,CAAC,YAAY,OAAO,OAAO,QAAQ,kBAAkB,YAAY;EACrE;EACA,OAAO;EACR,CAAC;;;;AAKF,KAAI,CAAC,iBAAiB,OAAO,EAAE;EAC7B,MAAM,QAAQ,gBACZ,4BACA,OAAO,SAAS,MACjB;EACD,MAAM,WAAW,6BAA6B,UAAU,QAAQ,SAAS;AACzE,MAAI,UAAU,UAAU;AACtB,SAAM,IAAI,UAAU,SAAS;AAC7B,UAAO;;EAGT,MAAM,SAAS,MAAM,IAAI,SAAS;AAClC,MAAI,QAAQ,UAAU;AACpB,UAAO;;;AAIX,QAAO,YAAY","names":[],"sources":["../../../../src/transform/generators/resolveStaticOxcValues/dependencies.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport { Entrypoint } from '../../Entrypoint';\nimport type { IEntrypointDependency } from '../../Entrypoint.types';\nimport type { ITransformAction, SyncScenarioFor } from '../../types';\nimport { getWeakCacheMap } from './cache';\n\nexport const isRelativeSource = (source: string): boolean =>\n source.startsWith('./') ||\n source.startsWith('../') ||\n source === '.' ||\n source === '..';\n\nexport const dependencyResolutionCaches = new WeakMap<\n object,\n Map<string, IEntrypointDependency>\n>();\n\n// Bare package and alias resolution can depend on the importer through nested\n// packages, package boundaries, tsconfig paths, or bundler aliases.\nexport const dependencyResolutionCacheKey = (\n importer: string,\n source: string,\n imported: string\n): string => `${importer}\\0${source}\\0${imported}`;\n\nexport function* resolveDependency(\n action: ITransformAction,\n importer: string,\n source: string,\n imported: string\n): SyncScenarioFor<IEntrypointDependency | null> {\n const entrypoint =\n importer === action.entrypoint.name\n ? action.entrypoint\n : Entrypoint.createRoot(action.services, importer, [imported], undefined);\n const imports = new Map([[source, [imported]]]);\n const [resolved] = yield* action.getNext('resolveImports', entrypoint, {\n imports,\n phase: 'initial',\n });\n\n // Non-relative sources (package names, aliases) can still be importer-\n // dependent because of nested packages, tsconfig boundaries, and bundler\n // aliases. Cache only within the same importer context.\n if (!isRelativeSource(source)) {\n const cache = getWeakCacheMap(\n dependencyResolutionCaches,\n action.services.cache\n );\n const cacheKey = dependencyResolutionCacheKey(importer, source, imported);\n if (resolved?.resolved) {\n cache.set(cacheKey, resolved);\n return resolved;\n }\n\n const cached = cache.get(cacheKey);\n if (cached?.resolved) {\n return cached;\n }\n }\n\n return resolved ?? null;\n}\n"],"file":"dependencies.js"}
@@ -0,0 +1,29 @@
1
+ /* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */
2
+ import { isAbsolute, relative } from "path";
3
+ import { parseOxcProgram } from "../../../utils/oxc/parse.js";
4
+ import { stripQueryAndHash } from "../../../utils/parseRequest.js";
5
+ export const isInsideRoot = (filename, root) => {
6
+ const relativePath = relative(root, filename);
7
+ return relativePath === "" || !!relativePath && !relativePath.startsWith("..") && !isAbsolute(relativePath);
8
+ };
9
+ export const nodeModulesPattern = /[\\/]node_modules[\\/]/;
10
+ export const isLocalStaticMetadataFile = (filename, root) => {
11
+ const strippedFilename = stripQueryAndHash(filename);
12
+ if (isInsideRoot(strippedFilename, root)) {
13
+ return true;
14
+ }
15
+ return isAbsolute(strippedFilename) && !nodeModulesPattern.test(strippedFilename);
16
+ };
17
+ export const isEnvDisabled = (value) => value === "0" || value === "false" || value === "no" || value === "off";
18
+ export const getEvalStrategy = (action) => action.services.options.pluginOptions.eval?.strategy ?? "execute";
19
+ export const getStaticStrategyFailure = (filename, dependencyNames) => new Error(`[wyw-in-js] eval.strategy: "static" cannot fall back to the build-time evaluator for ${filename}. ` + `Unresolved values: ${[...dependencyNames].join(", ")}.`);
20
+ export const debugStaticResolve = (action, event) => {
21
+ const labels = Object.fromEntries(Object.entries({
22
+ ...event,
23
+ type: "staticResolve"
24
+ }).filter(([, value]) => value !== undefined));
25
+ action.services.eventEmitter.single(labels);
26
+ };
27
+ export const parseProgram = (code, filename) => parseOxcProgram(code, filename, "unambiguous");
28
+ export const getStaticBindings = (action) => action.services.options.pluginOptions?.staticBindings;
29
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";AAEA,SAAS,YAAY,gBAAgB;AAIrC,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAIlC,OAAO,MAAM,gBAAgB,UAAkB,SAA0B;CACvE,MAAM,eAAe,SAAS,MAAM,SAAS;AAC7C,QACE,iBAAiB,MAChB,CAAC,CAAC,gBACD,CAAC,aAAa,WAAW,KAAK,IAC9B,CAAC,WAAW,aAAa;;AAI/B,OAAO,MAAM,qBAAqB;AAElC,OAAO,MAAM,6BACX,UACA,SACY;CACZ,MAAM,mBAAmB,kBAAkB,SAAS;AACpD,KAAI,aAAa,kBAAkB,KAAK,EAAE;AACxC,SAAO;;AAGT,QACE,WAAW,iBAAiB,IAAI,CAAC,mBAAmB,KAAK,iBAAiB;;AAI9E,OAAO,MAAM,iBAAiB,UAC5B,UAAU,OAAO,UAAU,WAAW,UAAU,QAAQ,UAAU;AAEpE,OAAO,MAAM,mBAAmB,WAC9B,OAAO,SAAS,QAAQ,cAAc,MAAM,YAAY;AAE1D,OAAO,MAAM,4BACX,UACA,oBAEA,IAAI,MACF,wFAAwF,SAAS,MAC/F,sBAAsB,CAAC,GAAG,gBAAgB,CAAC,KAAK,KAAK,CAAC,GACzD;AAEH,OAAO,MAAM,sBACX,QACA,UACS;CACT,MAAM,SAAS,OAAO,YACpB,OAAO,QAAQ;EACb,GAAG;EACH,MAAM;EACP,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,UAAU,CAC9C;AAED,QAAO,SAAS,aAAa,OAAO,OAAO;;AAG7C,OAAO,MAAM,gBAAgB,MAAc,aACzC,gBAAgB,MAAM,UAAU,cAAc;AAEhD,OAAO,MAAM,qBACX,WAEA,OAAO,SAAS,QAAQ,eAAe","names":[],"sources":["../../../../src/transform/generators/resolveStaticOxcValues/environment.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport { isAbsolute, relative } from 'path';\n\nimport type { Program } from 'oxc-parser';\n\nimport { parseOxcProgram } from '../../../utils/oxc/parse';\nimport { stripQueryAndHash } from '../../../utils/parseRequest';\nimport type { ITransformAction } from '../../types';\nimport type { StaticResolveDebugEvent } from './types';\n\nexport const isInsideRoot = (filename: string, root: string): boolean => {\n const relativePath = relative(root, filename);\n return (\n relativePath === '' ||\n (!!relativePath &&\n !relativePath.startsWith('..') &&\n !isAbsolute(relativePath))\n );\n};\n\nexport const nodeModulesPattern = /[\\\\/]node_modules[\\\\/]/;\n\nexport const isLocalStaticMetadataFile = (\n filename: string,\n root: string\n): boolean => {\n const strippedFilename = stripQueryAndHash(filename);\n if (isInsideRoot(strippedFilename, root)) {\n return true;\n }\n\n return (\n isAbsolute(strippedFilename) && !nodeModulesPattern.test(strippedFilename)\n );\n};\n\nexport const isEnvDisabled = (value: string): boolean =>\n value === '0' || value === 'false' || value === 'no' || value === 'off';\n\nexport const getEvalStrategy = (action: ITransformAction) =>\n action.services.options.pluginOptions.eval?.strategy ?? 'execute';\n\nexport const getStaticStrategyFailure = (\n filename: string,\n dependencyNames: Iterable<string>\n): Error =>\n new Error(\n `[wyw-in-js] eval.strategy: \"static\" cannot fall back to the build-time evaluator for ${filename}. ` +\n `Unresolved values: ${[...dependencyNames].join(', ')}.`\n );\n\nexport const debugStaticResolve = (\n action: ITransformAction,\n event: StaticResolveDebugEvent\n): void => {\n const labels = Object.fromEntries(\n Object.entries({\n ...event,\n type: 'staticResolve',\n }).filter(([, value]) => value !== undefined)\n );\n\n action.services.eventEmitter.single(labels);\n};\n\nexport const parseProgram = (code: string, filename: string): Program =>\n parseOxcProgram(code, filename, 'unambiguous');\n\nexport const getStaticBindings = (\n action: ITransformAction\n): Record<string, Record<string, unknown>> | undefined =>\n action.services.options.pluginOptions?.staticBindings;\n"],"file":"environment.js"}