@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,540 @@
1
+ import { lookupStaticBinding } from "./staticBindings.js";
2
+ import { resolveBindingAt } from "./scopeAnalysis.js";
3
+ export const literalCode = (value) => {
4
+ if (typeof value === "number") {
5
+ return Number.isFinite(value) ? JSON.stringify(value) : null;
6
+ }
7
+ if (value === null || typeof value === "string" || typeof value === "boolean") {
8
+ return JSON.stringify(value);
9
+ }
10
+ if (Array.isArray(value)) {
11
+ return JSON.stringify(value);
12
+ }
13
+ if (typeof value === "object" && value !== null) {
14
+ return `(${JSON.stringify(value)})`;
15
+ }
16
+ return null;
17
+ };
18
+ export const isStaticSerializableValue = (value) => literalCode(value) !== null;
19
+ export const cloneStaticValue = (value) => {
20
+ if (Array.isArray(value)) {
21
+ return value.map((item) => cloneStaticValue(item));
22
+ }
23
+ if (typeof value === "object" && value !== null) {
24
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cloneStaticValue(item)]));
25
+ }
26
+ return value;
27
+ };
28
+ const INT32_SIZE = 2 ** 32;
29
+ const INT32_SIGN_BIT = 2 ** 31;
30
+ const toInt32 = (value) => {
31
+ if (!Number.isFinite(value) || value === 0) {
32
+ return 0;
33
+ }
34
+ const integer = Math.sign(value) * Math.floor(Math.abs(value));
35
+ const int32bit = (integer % INT32_SIZE + INT32_SIZE) % INT32_SIZE;
36
+ return int32bit >= INT32_SIGN_BIT ? int32bit - INT32_SIZE : int32bit;
37
+ };
38
+ const bitwiseNot = (value) => -toInt32(value) - 1;
39
+ const getObjectMember = (objectValue, property) => {
40
+ if (objectValue === null || objectValue === undefined || typeof objectValue !== "object" && typeof objectValue !== "string" && typeof objectValue !== "number" && typeof objectValue !== "boolean") {
41
+ return undefined;
42
+ }
43
+ return objectValue[property];
44
+ };
45
+ const oxcStaticCallableValue = Symbol("wyw.oxc.staticCallableValue");
46
+ const isOxcStaticCallableValue = (value) => typeof value === "object" && value !== null && oxcStaticCallableValue in value;
47
+ const unwrapOxcStaticCallableValue = (value) => isOxcStaticCallableValue(value) ? value[oxcStaticCallableValue] : value;
48
+ export const createOxcStaticCallableValue = (value) => ({ [oxcStaticCallableValue]: value });
49
+ const assignPatternValue = (pattern, value, ctx, env, stack) => {
50
+ if (pattern.type === "Identifier") {
51
+ env.set(pattern.name, value);
52
+ return true;
53
+ }
54
+ if (pattern.type === "AssignmentPattern") {
55
+ return assignPatternValue(pattern.left, value === undefined ? evaluateStatic(pattern.right, ctx, env, stack) : value, ctx, env, stack);
56
+ }
57
+ if (pattern.type === "ObjectPattern") {
58
+ if (typeof value !== "object" || value === null) {
59
+ return false;
60
+ }
61
+ return pattern.properties.every((property) => {
62
+ if (property.type === "RestElement") {
63
+ return false;
64
+ }
65
+ let key;
66
+ if (property.computed) {
67
+ key = evaluateStatic(property.key, ctx, env, stack);
68
+ } else if (property.key.type === "Identifier") {
69
+ key = property.key.name;
70
+ } else if (property.key.type === "Literal") {
71
+ key = property.key.value;
72
+ }
73
+ if (key === undefined || key === null) {
74
+ return false;
75
+ }
76
+ return assignPatternValue(property.value, getObjectMember(value, key), ctx, env, stack);
77
+ });
78
+ }
79
+ if (pattern.type === "ArrayPattern") {
80
+ if (!Array.isArray(value)) {
81
+ return false;
82
+ }
83
+ return pattern.elements.every((element, index) => element ? assignPatternValue(element, value[index], ctx, env, stack) : true);
84
+ }
85
+ return false;
86
+ };
87
+ const applyRootMutation = (bindingName, baseValue, mutation, ctx, env, stack) => {
88
+ const resolvePath = (node) => {
89
+ if (node.type === "Identifier") {
90
+ return node.name === bindingName ? { path: [] } : null;
91
+ }
92
+ if (node.type !== "MemberExpression") {
93
+ return null;
94
+ }
95
+ const parent = resolvePath(node.object);
96
+ if (!parent) {
97
+ return null;
98
+ }
99
+ let key;
100
+ if (node.computed) {
101
+ key = evaluateStatic(node.property, ctx, env, stack);
102
+ } else if (node.property.type === "Identifier") {
103
+ key = node.property.name;
104
+ }
105
+ if (key === undefined || key === null || typeof key !== "string" && typeof key !== "number") {
106
+ return null;
107
+ }
108
+ return { path: [...parent.path, key] };
109
+ };
110
+ const pathInfo = resolvePath(mutation.type === "AssignmentExpression" ? mutation.left : mutation.argument);
111
+ if (!pathInfo) {
112
+ return undefined;
113
+ }
114
+ const cloned = cloneStaticValue(baseValue);
115
+ if (pathInfo.path.length === 0) {
116
+ if (mutation.type !== "AssignmentExpression") {
117
+ return undefined;
118
+ }
119
+ return evaluateStatic(mutation.right, ctx, env, stack);
120
+ }
121
+ let target = cloned;
122
+ for (let idx = 0; idx < pathInfo.path.length - 1; idx += 1) {
123
+ const key = pathInfo.path[idx];
124
+ const next = target?.[key];
125
+ if (typeof next !== "object" || next === null) {
126
+ return undefined;
127
+ }
128
+ target = next;
129
+ }
130
+ const lastKey = pathInfo.path[pathInfo.path.length - 1];
131
+ if (mutation.type === "AssignmentExpression") {
132
+ const nextValue = evaluateStatic(mutation.right, ctx, env, stack);
133
+ if (nextValue === undefined) {
134
+ return undefined;
135
+ }
136
+ target[lastKey] = nextValue;
137
+ return cloned;
138
+ }
139
+ const currentValue = target[lastKey];
140
+ if (typeof currentValue !== "number") {
141
+ return undefined;
142
+ }
143
+ target[lastKey] = mutation.operator === "++" ? currentValue + 1 : currentValue - 1;
144
+ return cloned;
145
+ };
146
+ const evaluateFunctionCall = (fn, args, ctx, env, stack) => {
147
+ if (fn.async || !fn.body) {
148
+ return undefined;
149
+ }
150
+ const localEnv = new Map(env);
151
+ for (let idx = 0; idx < fn.params.length; idx += 1) {
152
+ if (!assignPatternValue(fn.params[idx], args[idx], ctx, localEnv, stack)) {
153
+ return undefined;
154
+ }
155
+ }
156
+ if (fn.body.type !== "BlockStatement") {
157
+ return evaluateStatic(fn.body, ctx, localEnv, stack);
158
+ }
159
+ for (const statement of fn.body.body) {
160
+ if (statement.type === "VariableDeclaration") {
161
+ for (const declarator of statement.declarations) {
162
+ const value = declarator.init ? evaluateStatic(declarator.init, ctx, localEnv, stack) : undefined;
163
+ if (!assignPatternValue(declarator.id, value, ctx, localEnv, stack)) {
164
+ return undefined;
165
+ }
166
+ }
167
+ continue;
168
+ }
169
+ if (statement.type === "ReturnStatement") {
170
+ if (!statement.argument) {
171
+ return undefined;
172
+ }
173
+ return evaluateStatic(statement.argument, ctx, localEnv, stack);
174
+ }
175
+ return undefined;
176
+ }
177
+ return undefined;
178
+ };
179
+ const isProcessEnvMember = (node) => {
180
+ if (node.type !== "MemberExpression" || node.computed) {
181
+ return false;
182
+ }
183
+ if (node.property.type !== "Identifier" || node.property.name !== "env") {
184
+ return false;
185
+ }
186
+ return node.object.type === "Identifier" && node.object.name === "process";
187
+ };
188
+ const isProcessEnvValueAccess = (expression, env) => expression.type === "MemberExpression" && isProcessEnvMember(expression.object) && !env.has("process");
189
+ const isDeterministicUndefinedExpression = (expression, ctx, env) => {
190
+ if (isProcessEnvValueAccess(expression, env)) {
191
+ return true;
192
+ }
193
+ if (expression.type === "UnaryExpression" && expression.operator === "void") {
194
+ return true;
195
+ }
196
+ return expression.type === "Identifier" && expression.name === "undefined" && !resolveBindingAt(ctx, expression.name, expression.start);
197
+ };
198
+ const evaluateBinary = (expression, ctx, env = new Map(), stack = []) => {
199
+ if (expression.type !== "BinaryExpression") {
200
+ return undefined;
201
+ }
202
+ const left = evaluateStatic(expression.left, ctx, env, stack);
203
+ const right = evaluateStatic(expression.right, ctx, env, stack);
204
+ const leftIsDeterministicUndefined = left === undefined && isDeterministicUndefinedExpression(expression.left, ctx, env);
205
+ const rightIsDeterministicUndefined = right === undefined && isDeterministicUndefinedExpression(expression.right, ctx, env);
206
+ if (left === undefined && !leftIsDeterministicUndefined || right === undefined && !rightIsDeterministicUndefined) {
207
+ return undefined;
208
+ }
209
+ switch (expression.operator) {
210
+ case "===": return left === right;
211
+ case "!==": return left !== right;
212
+ case "==":
213
+ // eslint-disable-next-line eqeqeq
214
+ return left == right;
215
+ case "!=":
216
+ // eslint-disable-next-line eqeqeq
217
+ return left != right;
218
+ default: break;
219
+ }
220
+ if (expression.operator === "+") {
221
+ if (typeof left === "number" && typeof right === "number") {
222
+ return left + right;
223
+ }
224
+ if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number")) {
225
+ return `${left}${right}`;
226
+ }
227
+ }
228
+ if (typeof left === "number" && typeof right === "number") {
229
+ switch (expression.operator) {
230
+ case "<": return left < right;
231
+ case "<=": return left <= right;
232
+ case ">": return left > right;
233
+ case ">=": return left >= right;
234
+ case "-": return left - right;
235
+ case "*": return left * right;
236
+ case "/": return left / right;
237
+ case "%": return left % right;
238
+ case "**": return left ** right;
239
+ default: break;
240
+ }
241
+ }
242
+ return undefined;
243
+ };
244
+ export const evaluateStatic = (expression, ctx, env = new Map(), stack = []) => {
245
+ if (expression.type === "TSAsExpression" || expression.type === "TSSatisfiesExpression" || expression.type === "TSNonNullExpression" || expression.type === "TSInstantiationExpression" || expression.type === "TSTypeAssertion" || expression.type === "ParenthesizedExpression") {
246
+ return evaluateStatic(expression.expression, ctx, env, stack);
247
+ }
248
+ if (expression.type === "Literal") {
249
+ return expression.value;
250
+ }
251
+ if (expression.type === "UnaryExpression") {
252
+ if (expression.operator === "typeof") {
253
+ const argIsProcessEnvAccess = isProcessEnvValueAccess(expression.argument, env);
254
+ // `typeof someIdentifier` is the canonical undeclared-global
255
+ // probe — it returns 'undefined' regardless of whether the
256
+ // symbol is declared. Only fold truly unbound identifiers: declared
257
+ // but dynamic locals still have runtime values we cannot infer.
258
+ const argIsUnboundBareIdentifier = expression.argument.type === "Identifier" && !resolveBindingAt(ctx, expression.argument.name, expression.argument.start);
259
+ const arg = evaluateStatic(expression.argument, ctx, env, stack);
260
+ if (arg === undefined) {
261
+ return argIsProcessEnvAccess || argIsUnboundBareIdentifier ? "undefined" : undefined;
262
+ }
263
+ return typeof arg;
264
+ }
265
+ const arg = evaluateStatic(expression.argument, ctx, env, stack);
266
+ if (arg === undefined) {
267
+ return undefined;
268
+ }
269
+ switch (expression.operator) {
270
+ case "-": return typeof arg === "number" ? -arg : undefined;
271
+ case "+": return typeof arg === "number" ? +arg : undefined;
272
+ case "!": return !arg;
273
+ case "~": return typeof arg === "number" ? bitwiseNot(arg) : undefined;
274
+ case "void": return undefined;
275
+ default: return undefined;
276
+ }
277
+ }
278
+ if (expression.type === "LogicalExpression") {
279
+ const left = evaluateStatic(expression.left, ctx, env, stack);
280
+ // process.env.X access is the only source we trust as "deterministically
281
+ // undefined" — it's a build-time lookup we control. For everything else,
282
+ // undefined means "couldn't evaluate" and we must bail to avoid inlining
283
+ // a wrong fallback when the runtime value isn't actually nullish.
284
+ const leftIsProcessEnvAccess = isProcessEnvValueAccess(expression.left, env);
285
+ if (left === undefined && !leftIsProcessEnvAccess) {
286
+ return undefined;
287
+ }
288
+ if (expression.operator === "||") {
289
+ return left || evaluateStatic(expression.right, ctx, env, stack);
290
+ }
291
+ if (expression.operator === "??") {
292
+ return left ?? evaluateStatic(expression.right, ctx, env, stack);
293
+ }
294
+ if (expression.operator === "&&") {
295
+ return left && evaluateStatic(expression.right, ctx, env, stack);
296
+ }
297
+ return undefined;
298
+ }
299
+ if (expression.type === "ConditionalExpression") {
300
+ const test = evaluateStatic(expression.test, ctx, env, stack);
301
+ if (test === undefined) {
302
+ return undefined;
303
+ }
304
+ return evaluateStatic(test ? expression.consequent : expression.alternate, ctx, env, stack);
305
+ }
306
+ if (expression.type === "TemplateLiteral") {
307
+ let result = "";
308
+ for (let idx = 0; idx < expression.quasis.length; idx += 1) {
309
+ result += expression.quasis[idx]?.value.cooked ?? "";
310
+ const nextExpression = expression.expressions[idx];
311
+ if (!nextExpression) {
312
+ continue;
313
+ }
314
+ const value = evaluateStatic(nextExpression, ctx, env, stack);
315
+ if (value === undefined || typeof value !== "string" && typeof value !== "number") {
316
+ return undefined;
317
+ }
318
+ result += String(value);
319
+ }
320
+ return result;
321
+ }
322
+ if (expression.type === "Identifier") {
323
+ if (env.has(expression.name)) {
324
+ return unwrapOxcStaticCallableValue(env.get(expression.name));
325
+ }
326
+ const binding = resolveBindingAt(ctx, expression.name, expression.start);
327
+ if (binding?.importedFrom) {
328
+ // staticBindings can supply a literal value for an imported name,
329
+ // bypassing whatever the source module would otherwise resolve to.
330
+ // Function values are deferred to the CallExpression branch.
331
+ const override = lookupStaticBinding(ctx.staticBindings, binding.importedFrom, binding.imported);
332
+ if (override.found && typeof override.value !== "function") {
333
+ return override.value;
334
+ }
335
+ return undefined;
336
+ }
337
+ if (!binding) {
338
+ return undefined;
339
+ }
340
+ if (binding.kind === "param") {
341
+ return undefined;
342
+ }
343
+ if (stack.includes(binding.name)) {
344
+ return undefined;
345
+ }
346
+ let value;
347
+ const { declarator } = binding;
348
+ const init = declarator?.init;
349
+ if (init) {
350
+ if (declarator.id.type !== "Identifier") {
351
+ return undefined;
352
+ }
353
+ value = evaluateStatic(init, ctx, env, [...stack, binding.name]);
354
+ } else if (binding.functionNode) {
355
+ value = binding.functionNode;
356
+ }
357
+ if (value !== undefined && binding.isRoot && typeof value === "object" && value !== null && !Array.isArray(value)) {
358
+ const mutations = ctx.rootMutationsByBinding.get(binding.name) ?? [];
359
+ let nextValue = cloneStaticValue(value);
360
+ for (const mutation of mutations) {
361
+ if (mutation.start >= ctx.currentExpressionStart) {
362
+ break;
363
+ }
364
+ const applied = applyRootMutation(binding.name, nextValue, mutation, ctx, env, [...stack, binding.name]);
365
+ if (applied === undefined) {
366
+ return undefined;
367
+ }
368
+ nextValue = applied;
369
+ }
370
+ return nextValue;
371
+ }
372
+ return value;
373
+ }
374
+ if (expression.type === "ObjectExpression") {
375
+ const result = {};
376
+ for (const property of expression.properties) {
377
+ if (property.type === "SpreadElement") {
378
+ const spreadValue = evaluateStatic(property.argument, ctx, env, stack);
379
+ if (typeof spreadValue !== "object" || spreadValue === null) {
380
+ return undefined;
381
+ }
382
+ Object.assign(result, spreadValue);
383
+ continue;
384
+ }
385
+ let key;
386
+ if (property.computed) {
387
+ key = evaluateStatic(property.key, ctx, env, stack);
388
+ } else if (property.key.type === "Identifier") {
389
+ key = property.key.name;
390
+ } else if (property.key.type === "Literal") {
391
+ key = property.key.value;
392
+ }
393
+ if (key === undefined || key === null || typeof key !== "string" && typeof key !== "number") {
394
+ return undefined;
395
+ }
396
+ const value = evaluateStatic(property.value, ctx, env, stack);
397
+ if (value === undefined) {
398
+ return undefined;
399
+ }
400
+ result[key] = value;
401
+ }
402
+ return result;
403
+ }
404
+ if (expression.type === "ArrayExpression") {
405
+ const result = [];
406
+ for (const element of expression.elements) {
407
+ if (!element) {
408
+ return undefined;
409
+ }
410
+ if (element.type === "SpreadElement") {
411
+ const spreadValue = evaluateStatic(element.argument, ctx, env, stack);
412
+ if (!Array.isArray(spreadValue)) {
413
+ return undefined;
414
+ }
415
+ result.push(...spreadValue);
416
+ continue;
417
+ }
418
+ const value = evaluateStatic(element, ctx, env, stack);
419
+ if (value === undefined) {
420
+ return undefined;
421
+ }
422
+ result.push(value);
423
+ }
424
+ return result;
425
+ }
426
+ if (expression.type === "MemberExpression") {
427
+ let key;
428
+ if (expression.computed) {
429
+ key = evaluateStatic(expression.property, ctx, env, stack);
430
+ } else if (expression.property.type === "Identifier") {
431
+ key = expression.property.name;
432
+ }
433
+ if (key === undefined || key === null || typeof key !== "string" && typeof key !== "number") {
434
+ return undefined;
435
+ }
436
+ if (isProcessEnvValueAccess(expression, env) && typeof key === "string") {
437
+ // Treat process.env.X as deterministically undefined at build time.
438
+ // Reading from real process.env would couple the bundle to whatever
439
+ // happens to be set on the build machine; falling back to the
440
+ // ?? / || branch (or a runtime read) is more predictable.
441
+ return undefined;
442
+ }
443
+ const objectValue = evaluateStatic(expression.object, ctx, env, stack);
444
+ if (objectValue === undefined) {
445
+ return undefined;
446
+ }
447
+ return getObjectMember(objectValue, key);
448
+ }
449
+ if (expression.type === "NewExpression") {
450
+ if (expression.callee.type !== "Identifier" || expression.arguments.length !== 1) {
451
+ return undefined;
452
+ }
453
+ const [argument] = expression.arguments;
454
+ if (!argument || argument.type === "SpreadElement") {
455
+ return undefined;
456
+ }
457
+ const value = evaluateStatic(argument, ctx, env, stack);
458
+ if (value === undefined) {
459
+ return undefined;
460
+ }
461
+ if (expression.callee.name === "String") {
462
+ return String(value);
463
+ }
464
+ if (expression.callee.name === "Number") {
465
+ return Number(value);
466
+ }
467
+ if (expression.callee.name === "Boolean") {
468
+ return Boolean(value);
469
+ }
470
+ return undefined;
471
+ }
472
+ if (expression.type === "CallExpression") {
473
+ if (expression.callee.type === "Identifier") {
474
+ const args = expression.arguments.map((arg) => arg.type === "SpreadElement" ? undefined : evaluateStatic(arg, ctx, env, stack));
475
+ if (args.some((value) => value === undefined)) {
476
+ return undefined;
477
+ }
478
+ const staticCallable = env.get(expression.callee.name);
479
+ if (isOxcStaticCallableValue(staticCallable) && expression.arguments.length === 0) {
480
+ return unwrapOxcStaticCallableValue(staticCallable);
481
+ }
482
+ // Plain function in env (e.g. supplied via staticBindings as a
483
+ // pure helper). Invoke with already-evaluated args.
484
+ if (typeof staticCallable === "function") {
485
+ try {
486
+ return staticCallable(...args);
487
+ } catch {
488
+ return undefined;
489
+ }
490
+ }
491
+ if (expression.callee.name === "String" && args.length === 1) {
492
+ return String(args[0]);
493
+ }
494
+ if (expression.callee.name === "Number" && args.length === 1) {
495
+ return Number(args[0]);
496
+ }
497
+ if (expression.callee.name === "Boolean" && args.length === 1) {
498
+ return Boolean(args[0]);
499
+ }
500
+ const binding = resolveBindingAt(ctx, expression.callee.name, expression.callee.start);
501
+ // staticBindings can register a pure helper for an imported name
502
+ // (e.g. linaria's `cx` from '@linaria/core'). When the callee
503
+ // resolves to such an import and every arg evaluated, invoke the
504
+ // helper and return its result as a static value.
505
+ if (binding?.importedFrom) {
506
+ const override = lookupStaticBinding(ctx.staticBindings, binding.importedFrom, binding.imported);
507
+ if (override.found && typeof override.value === "function") {
508
+ try {
509
+ return override.value(...args);
510
+ } catch {
511
+ return undefined;
512
+ }
513
+ }
514
+ }
515
+ const fn = binding?.functionNode ?? binding?.declarator?.init;
516
+ if (fn && (fn.type === "ArrowFunctionExpression" || fn.type === "FunctionDeclaration" || fn.type === "FunctionExpression")) {
517
+ return evaluateFunctionCall(fn, args, ctx, env, [...stack, expression.callee.name]);
518
+ }
519
+ }
520
+ if (expression.callee.type === "MemberExpression") {
521
+ const objectValue = evaluateStatic(expression.callee.object, ctx, env, stack);
522
+ let key;
523
+ if (expression.callee.computed) {
524
+ key = evaluateStatic(expression.callee.property, ctx, env, stack);
525
+ } else if (expression.callee.property.type === "Identifier") {
526
+ key = expression.callee.property.name;
527
+ }
528
+ if (typeof objectValue === "string") {
529
+ if (key === "toLowerCase" && expression.arguments.length === 0) {
530
+ return objectValue.toLowerCase();
531
+ }
532
+ if (key === "toUpperCase" && expression.arguments.length === 0) {
533
+ return objectValue.toUpperCase();
534
+ }
535
+ }
536
+ }
537
+ }
538
+ return evaluateBinary(expression, ctx, env, stack);
539
+ };
540
+ //# sourceMappingURL=staticEvaluator.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AASA,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AAGjC,OAAO,MAAM,eAAe,UAAkC;AAC5D,KAAI,OAAO,UAAU,UAAU;AAC7B,SAAO,OAAO,SAAS,MAAM,GAAG,KAAK,UAAU,MAAM,GAAG;;AAG1D,KACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA,SAAO,KAAK,UAAU,MAAM;;AAG9B,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,SAAO,KAAK,UAAU,MAAM;;AAG9B,KAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,SAAO,IAAI,KAAK,UAAU,MAAM,CAAC;;AAGnC,QAAO;;AAGT,OAAO,MAAM,6BAA6B,UACxC,YAAY,MAAM,KAAK;AAEzB,OAAO,MAAM,oBAAoB,UAA4B;AAC3D,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,SAAO,MAAM,KAAK,SAAS,iBAAiB,KAAK,CAAC;;AAGpD,KAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,SAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,iBAAiB,KAAK,CAAC,CAAC,CAC1E;;AAGH,QAAO;;AAGT,MAAM,aAAa,KAAK;AACxB,MAAM,iBAAiB,KAAK;AAE5B,MAAM,WAAW,UAA0B;AACzC,KAAI,CAAC,OAAO,SAAS,MAAM,IAAI,UAAU,GAAG;AAC1C,SAAO;;CAGT,MAAM,UAAU,KAAK,KAAK,MAAM,GAAG,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC;CA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9D,YAAO,YAAY,aAAa;;AAGlC,QAAI,QAAQ,iBAAiB,WAAW,UAAU,WAAW,GAAG;AAC9D,YAAO,YAAY,aAAa;;;;;AAMxC,QAAO,eAAe,YAAY,KAAK,KAAK,MAAM","names":[],"sources":["../../../src/utils/collectOxcTemplateDependencies/staticEvaluator.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport type {\n AssignmentExpression,\n Expression,\n Node,\n UpdateExpression,\n} from 'oxc-parser';\n\nimport { lookupStaticBinding } from './staticBindings';\nimport { resolveBindingAt } from './scopeAnalysis';\nimport type { ExtractionContext, OxcFunctionLikeNode } from './types';\n\nexport const literalCode = (value: unknown): string | null => {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? JSON.stringify(value) : null;\n }\n\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'boolean'\n ) {\n return JSON.stringify(value);\n }\n\n if (Array.isArray(value)) {\n return JSON.stringify(value);\n }\n\n if (typeof value === 'object' && value !== null) {\n return `(${JSON.stringify(value)})`;\n }\n\n return null;\n};\n\nexport const isStaticSerializableValue = (value: unknown): boolean =>\n literalCode(value) !== null;\n\nexport const cloneStaticValue = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n return value.map((item) => cloneStaticValue(item));\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [key, cloneStaticValue(item)])\n );\n }\n\n return value;\n};\n\nconst INT32_SIZE = 2 ** 32;\nconst INT32_SIGN_BIT = 2 ** 31;\n\nconst toInt32 = (value: number): number => {\n if (!Number.isFinite(value) || value === 0) {\n return 0;\n }\n\n const integer = Math.sign(value) * Math.floor(Math.abs(value));\n const int32bit = ((integer % INT32_SIZE) + INT32_SIZE) % INT32_SIZE;\n\n return int32bit >= INT32_SIGN_BIT ? int32bit - INT32_SIZE : int32bit;\n};\n\nconst bitwiseNot = (value: number): number => -toInt32(value) - 1;\n\nconst getObjectMember = (\n objectValue: unknown,\n property: string | number\n): unknown | undefined => {\n if (\n objectValue === null ||\n objectValue === undefined ||\n (typeof objectValue !== 'object' &&\n typeof objectValue !== 'string' &&\n typeof objectValue !== 'number' &&\n typeof objectValue !== 'boolean')\n ) {\n return undefined;\n }\n\n return (objectValue as Record<string | number, unknown>)[property];\n};\n\ntype EvalEnv = Map<string, unknown>;\n\nconst oxcStaticCallableValue = Symbol('wyw.oxc.staticCallableValue');\n\ntype OxcStaticCallableValue = {\n [oxcStaticCallableValue]: unknown;\n};\n\nconst isOxcStaticCallableValue = (\n value: unknown\n): value is OxcStaticCallableValue =>\n typeof value === 'object' &&\n value !== null &&\n oxcStaticCallableValue in value;\n\nconst unwrapOxcStaticCallableValue = (value: unknown): unknown =>\n isOxcStaticCallableValue(value) ? value[oxcStaticCallableValue] : value;\n\nexport const createOxcStaticCallableValue = (\n value: unknown\n): OxcStaticCallableValue => ({\n [oxcStaticCallableValue]: value,\n});\n\nconst assignPatternValue = (\n pattern: Node,\n value: unknown,\n ctx: ExtractionContext,\n env: EvalEnv,\n stack: string[]\n): boolean => {\n if (pattern.type === 'Identifier') {\n env.set(pattern.name, value);\n return true;\n }\n\n if (pattern.type === 'AssignmentPattern') {\n return assignPatternValue(\n pattern.left,\n value === undefined\n ? evaluateStatic(pattern.right, ctx, env, stack)\n : value,\n ctx,\n env,\n stack\n );\n }\n\n if (pattern.type === 'ObjectPattern') {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n return pattern.properties.every((property) => {\n if (property.type === 'RestElement') {\n return false;\n }\n\n let key: unknown;\n if (property.computed) {\n key = evaluateStatic(property.key as Expression, ctx, env, stack);\n } else if (property.key.type === 'Identifier') {\n key = property.key.name;\n } else if (property.key.type === 'Literal') {\n key = property.key.value;\n }\n if (key === undefined || key === null) {\n return false;\n }\n\n return assignPatternValue(\n property.value,\n getObjectMember(value, key as string | number),\n ctx,\n env,\n stack\n );\n });\n }\n\n if (pattern.type === 'ArrayPattern') {\n if (!Array.isArray(value)) {\n return false;\n }\n\n return pattern.elements.every((element, index) =>\n element\n ? assignPatternValue(element, value[index], ctx, env, stack)\n : true\n );\n }\n\n return false;\n};\n\nconst applyRootMutation = (\n bindingName: string,\n baseValue: unknown,\n mutation: AssignmentExpression | UpdateExpression,\n ctx: ExtractionContext,\n env: EvalEnv,\n stack: string[]\n): unknown | undefined => {\n const resolvePath = (node: Node): { path: Array<string | number> } | null => {\n if (node.type === 'Identifier') {\n return node.name === bindingName ? { path: [] } : null;\n }\n\n if (node.type !== 'MemberExpression') {\n return null;\n }\n\n const parent = resolvePath(node.object);\n if (!parent) {\n return null;\n }\n\n let key: unknown;\n if (node.computed) {\n key = evaluateStatic(node.property as Expression, ctx, env, stack);\n } else if (node.property.type === 'Identifier') {\n key = node.property.name;\n }\n if (\n key === undefined ||\n key === null ||\n (typeof key !== 'string' && typeof key !== 'number')\n ) {\n return null;\n }\n\n return {\n path: [...parent.path, key],\n };\n };\n\n const pathInfo = resolvePath(\n mutation.type === 'AssignmentExpression' ? mutation.left : mutation.argument\n );\n if (!pathInfo) {\n return undefined;\n }\n\n const cloned = cloneStaticValue(baseValue);\n if (pathInfo.path.length === 0) {\n if (mutation.type !== 'AssignmentExpression') {\n return undefined;\n }\n\n return evaluateStatic(mutation.right, ctx, env, stack);\n }\n\n let target = cloned as Record<string | number, unknown>;\n for (let idx = 0; idx < pathInfo.path.length - 1; idx += 1) {\n const key = pathInfo.path[idx];\n const next = target?.[key];\n if (typeof next !== 'object' || next === null) {\n return undefined;\n }\n\n target = next as Record<string | number, unknown>;\n }\n\n const lastKey = pathInfo.path[pathInfo.path.length - 1]!;\n if (mutation.type === 'AssignmentExpression') {\n const nextValue = evaluateStatic(mutation.right, ctx, env, stack);\n if (nextValue === undefined) {\n return undefined;\n }\n\n target[lastKey] = nextValue;\n return cloned;\n }\n\n const currentValue = target[lastKey];\n if (typeof currentValue !== 'number') {\n return undefined;\n }\n\n target[lastKey] =\n mutation.operator === '++' ? currentValue + 1 : currentValue - 1;\n return cloned;\n};\n\nconst evaluateFunctionCall = (\n fn: OxcFunctionLikeNode,\n args: unknown[],\n ctx: ExtractionContext,\n env: EvalEnv,\n stack: string[]\n): unknown | undefined => {\n if (fn.async || !fn.body) {\n return undefined;\n }\n\n const localEnv = new Map(env);\n for (let idx = 0; idx < fn.params.length; idx += 1) {\n if (!assignPatternValue(fn.params[idx], args[idx], ctx, localEnv, stack)) {\n return undefined;\n }\n }\n\n if (fn.body.type !== 'BlockStatement') {\n return evaluateStatic(fn.body as Expression, ctx, localEnv, stack);\n }\n\n for (const statement of fn.body.body) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n const value = declarator.init\n ? evaluateStatic(declarator.init, ctx, localEnv, stack)\n : undefined;\n if (!assignPatternValue(declarator.id, value, ctx, localEnv, stack)) {\n return undefined;\n }\n }\n continue;\n }\n\n if (statement.type === 'ReturnStatement') {\n if (!statement.argument) {\n return undefined;\n }\n\n return evaluateStatic(statement.argument, ctx, localEnv, stack);\n }\n\n return undefined;\n }\n\n return undefined;\n};\n\nconst isProcessEnvMember = (node: Node): boolean => {\n if (node.type !== 'MemberExpression' || node.computed) {\n return false;\n }\n\n if (node.property.type !== 'Identifier' || node.property.name !== 'env') {\n return false;\n }\n\n return node.object.type === 'Identifier' && node.object.name === 'process';\n};\n\nconst isProcessEnvValueAccess = (\n expression: Expression,\n env: EvalEnv\n): boolean =>\n expression.type === 'MemberExpression' &&\n isProcessEnvMember(expression.object) &&\n !env.has('process');\n\nconst isDeterministicUndefinedExpression = (\n expression: Expression,\n ctx: ExtractionContext,\n env: EvalEnv\n): boolean => {\n if (isProcessEnvValueAccess(expression, env)) {\n return true;\n }\n\n if (expression.type === 'UnaryExpression' && expression.operator === 'void') {\n return true;\n }\n\n return (\n expression.type === 'Identifier' &&\n expression.name === 'undefined' &&\n !resolveBindingAt(ctx, expression.name, expression.start)\n );\n};\n\nconst evaluateBinary = (\n expression: Expression,\n ctx: ExtractionContext,\n env: EvalEnv = new Map(),\n stack: string[] = []\n): unknown | undefined => {\n if (expression.type !== 'BinaryExpression') {\n return undefined;\n }\n\n const left = evaluateStatic(expression.left as Expression, ctx, env, stack);\n const right = evaluateStatic(expression.right as Expression, ctx, env, stack);\n\n const leftIsDeterministicUndefined =\n left === undefined &&\n isDeterministicUndefinedExpression(expression.left as Expression, ctx, env);\n const rightIsDeterministicUndefined =\n right === undefined &&\n isDeterministicUndefinedExpression(\n expression.right as Expression,\n ctx,\n env\n );\n\n if (\n (left === undefined && !leftIsDeterministicUndefined) ||\n (right === undefined && !rightIsDeterministicUndefined)\n ) {\n return undefined;\n }\n\n switch (expression.operator) {\n case '===':\n return left === right;\n case '!==':\n return left !== right;\n case '==':\n // eslint-disable-next-line eqeqeq\n return left == right;\n case '!=':\n // eslint-disable-next-line eqeqeq\n return left != right;\n default:\n break;\n }\n\n if (expression.operator === '+') {\n if (typeof left === 'number' && typeof right === 'number') {\n return left + right;\n }\n\n if (\n (typeof left === 'string' || typeof left === 'number') &&\n (typeof right === 'string' || typeof right === 'number')\n ) {\n return `${left}${right}`;\n }\n }\n\n if (typeof left === 'number' && typeof right === 'number') {\n switch (expression.operator) {\n case '<':\n return left < right;\n case '<=':\n return left <= right;\n case '>':\n return left > right;\n case '>=':\n return left >= right;\n case '-':\n return left - right;\n case '*':\n return left * right;\n case '/':\n return left / right;\n case '%':\n return left % right;\n case '**':\n return left ** right;\n default:\n break;\n }\n }\n\n return undefined;\n};\n\nexport const evaluateStatic = (\n expression: Expression,\n ctx: ExtractionContext,\n env: EvalEnv = new Map(),\n stack: string[] = []\n): unknown | undefined => {\n if (\n expression.type === 'TSAsExpression' ||\n expression.type === 'TSSatisfiesExpression' ||\n expression.type === 'TSNonNullExpression' ||\n expression.type === 'TSInstantiationExpression' ||\n expression.type === 'TSTypeAssertion' ||\n expression.type === 'ParenthesizedExpression'\n ) {\n return evaluateStatic(expression.expression as Expression, ctx, env, stack);\n }\n\n if (expression.type === 'Literal') {\n return expression.value;\n }\n\n if (expression.type === 'UnaryExpression') {\n if (expression.operator === 'typeof') {\n const argIsProcessEnvAccess = isProcessEnvValueAccess(\n expression.argument as Expression,\n env\n );\n // `typeof someIdentifier` is the canonical undeclared-global\n // probe — it returns 'undefined' regardless of whether the\n // symbol is declared. Only fold truly unbound identifiers: declared\n // but dynamic locals still have runtime values we cannot infer.\n const argIsUnboundBareIdentifier =\n expression.argument.type === 'Identifier' &&\n !resolveBindingAt(\n ctx,\n expression.argument.name,\n expression.argument.start\n );\n const arg = evaluateStatic(\n expression.argument as Expression,\n ctx,\n env,\n stack\n );\n if (arg === undefined) {\n return argIsProcessEnvAccess || argIsUnboundBareIdentifier\n ? 'undefined'\n : undefined;\n }\n\n return typeof arg;\n }\n\n const arg = evaluateStatic(\n expression.argument as Expression,\n ctx,\n env,\n stack\n );\n if (arg === undefined) {\n return undefined;\n }\n\n switch (expression.operator) {\n case '-':\n return typeof arg === 'number' ? -arg : undefined;\n case '+':\n return typeof arg === 'number' ? +arg : undefined;\n case '!':\n return !arg;\n case '~':\n return typeof arg === 'number' ? bitwiseNot(arg) : undefined;\n case 'void':\n return undefined;\n default:\n return undefined;\n }\n }\n\n if (expression.type === 'LogicalExpression') {\n const left = evaluateStatic(expression.left, ctx, env, stack);\n // process.env.X access is the only source we trust as \"deterministically\n // undefined\" — it's a build-time lookup we control. For everything else,\n // undefined means \"couldn't evaluate\" and we must bail to avoid inlining\n // a wrong fallback when the runtime value isn't actually nullish.\n const leftIsProcessEnvAccess = isProcessEnvValueAccess(\n expression.left,\n env\n );\n\n if (left === undefined && !leftIsProcessEnvAccess) {\n return undefined;\n }\n\n if (expression.operator === '||') {\n return left || evaluateStatic(expression.right, ctx, env, stack);\n }\n\n if (expression.operator === '??') {\n return left ?? evaluateStatic(expression.right, ctx, env, stack);\n }\n\n if (expression.operator === '&&') {\n return left && evaluateStatic(expression.right, ctx, env, stack);\n }\n\n return undefined;\n }\n\n if (expression.type === 'ConditionalExpression') {\n const test = evaluateStatic(expression.test, ctx, env, stack);\n if (test === undefined) {\n return undefined;\n }\n\n return evaluateStatic(\n test ? expression.consequent : expression.alternate,\n ctx,\n env,\n stack\n );\n }\n\n if (expression.type === 'TemplateLiteral') {\n let result = '';\n\n for (let idx = 0; idx < expression.quasis.length; idx += 1) {\n result += expression.quasis[idx]?.value.cooked ?? '';\n\n const nextExpression = expression.expressions[idx];\n if (!nextExpression) {\n continue;\n }\n\n const value = evaluateStatic(nextExpression, ctx, env, stack);\n if (\n value === undefined ||\n (typeof value !== 'string' && typeof value !== 'number')\n ) {\n return undefined;\n }\n\n result += String(value);\n }\n\n return result;\n }\n\n if (expression.type === 'Identifier') {\n if (env.has(expression.name)) {\n return unwrapOxcStaticCallableValue(env.get(expression.name));\n }\n\n const binding = resolveBindingAt(ctx, expression.name, expression.start);\n if (binding?.importedFrom) {\n // staticBindings can supply a literal value for an imported name,\n // bypassing whatever the source module would otherwise resolve to.\n // Function values are deferred to the CallExpression branch.\n const override = lookupStaticBinding(\n ctx.staticBindings,\n binding.importedFrom,\n binding.imported\n );\n if (override.found && typeof override.value !== 'function') {\n return override.value;\n }\n return undefined;\n }\n if (!binding) {\n return undefined;\n }\n\n if (binding.kind === 'param') {\n return undefined;\n }\n\n if (stack.includes(binding.name)) {\n return undefined;\n }\n\n let value: unknown | undefined;\n const { declarator } = binding;\n const init = declarator?.init;\n if (init) {\n if (declarator.id.type !== 'Identifier') {\n return undefined;\n }\n\n value = evaluateStatic(init, ctx, env, [...stack, binding.name]);\n } else if (binding.functionNode) {\n value = binding.functionNode;\n }\n\n if (\n value !== undefined &&\n binding.isRoot &&\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value)\n ) {\n const mutations = ctx.rootMutationsByBinding.get(binding.name) ?? [];\n let nextValue = cloneStaticValue(value);\n for (const mutation of mutations) {\n if (mutation.start >= ctx.currentExpressionStart) {\n break;\n }\n\n const applied = applyRootMutation(\n binding.name,\n nextValue,\n mutation,\n ctx,\n env,\n [...stack, binding.name]\n );\n if (applied === undefined) {\n return undefined;\n }\n\n nextValue = applied;\n }\n\n return nextValue;\n }\n\n return value;\n }\n\n if (expression.type === 'ObjectExpression') {\n const result: Record<string, unknown> = {};\n\n for (const property of expression.properties) {\n if (property.type === 'SpreadElement') {\n const spreadValue = evaluateStatic(property.argument, ctx, env, stack);\n if (typeof spreadValue !== 'object' || spreadValue === null) {\n return undefined;\n }\n\n Object.assign(result, spreadValue);\n continue;\n }\n\n let key: unknown;\n if (property.computed) {\n key = evaluateStatic(property.key as Expression, ctx, env, stack);\n } else if (property.key.type === 'Identifier') {\n key = property.key.name;\n } else if (property.key.type === 'Literal') {\n key = property.key.value;\n }\n if (\n key === undefined ||\n key === null ||\n (typeof key !== 'string' && typeof key !== 'number')\n ) {\n return undefined;\n }\n\n const value = evaluateStatic(property.value, ctx, env, stack);\n if (value === undefined) {\n return undefined;\n }\n\n result[key] = value;\n }\n\n return result;\n }\n\n if (expression.type === 'ArrayExpression') {\n const result: unknown[] = [];\n\n for (const element of expression.elements) {\n if (!element) {\n return undefined;\n }\n\n if (element.type === 'SpreadElement') {\n const spreadValue = evaluateStatic(element.argument, ctx, env, stack);\n if (!Array.isArray(spreadValue)) {\n return undefined;\n }\n\n result.push(...spreadValue);\n continue;\n }\n\n const value = evaluateStatic(element, ctx, env, stack);\n if (value === undefined) {\n return undefined;\n }\n\n result.push(value);\n }\n\n return result;\n }\n\n if (expression.type === 'MemberExpression') {\n let key: unknown;\n if (expression.computed) {\n key = evaluateStatic(expression.property as Expression, ctx, env, stack);\n } else if (expression.property.type === 'Identifier') {\n key = expression.property.name;\n }\n if (\n key === undefined ||\n key === null ||\n (typeof key !== 'string' && typeof key !== 'number')\n ) {\n return undefined;\n }\n\n if (isProcessEnvValueAccess(expression, env) && typeof key === 'string') {\n // Treat process.env.X as deterministically undefined at build time.\n // Reading from real process.env would couple the bundle to whatever\n // happens to be set on the build machine; falling back to the\n // ?? / || branch (or a runtime read) is more predictable.\n return undefined;\n }\n\n const objectValue = evaluateStatic(expression.object, ctx, env, stack);\n if (objectValue === undefined) {\n return undefined;\n }\n\n return getObjectMember(objectValue, key);\n }\n\n if (expression.type === 'NewExpression') {\n if (\n expression.callee.type !== 'Identifier' ||\n expression.arguments.length !== 1\n ) {\n return undefined;\n }\n\n const [argument] = expression.arguments;\n if (!argument || argument.type === 'SpreadElement') {\n return undefined;\n }\n\n const value = evaluateStatic(argument, ctx, env, stack);\n if (value === undefined) {\n return undefined;\n }\n\n if (expression.callee.name === 'String') {\n return String(value);\n }\n\n if (expression.callee.name === 'Number') {\n return Number(value);\n }\n\n if (expression.callee.name === 'Boolean') {\n return Boolean(value);\n }\n\n return undefined;\n }\n\n if (expression.type === 'CallExpression') {\n if (expression.callee.type === 'Identifier') {\n const args = expression.arguments.map((arg) =>\n arg.type === 'SpreadElement'\n ? undefined\n : evaluateStatic(arg, ctx, env, stack)\n );\n if (args.some((value) => value === undefined)) {\n return undefined;\n }\n\n const staticCallable = env.get(expression.callee.name);\n if (\n isOxcStaticCallableValue(staticCallable) &&\n expression.arguments.length === 0\n ) {\n return unwrapOxcStaticCallableValue(staticCallable);\n }\n\n // Plain function in env (e.g. supplied via staticBindings as a\n // pure helper). Invoke with already-evaluated args.\n if (typeof staticCallable === 'function') {\n try {\n return (staticCallable as (...a: unknown[]) => unknown)(...args);\n } catch {\n return undefined;\n }\n }\n\n if (expression.callee.name === 'String' && args.length === 1) {\n return String(args[0]);\n }\n\n if (expression.callee.name === 'Number' && args.length === 1) {\n return Number(args[0]);\n }\n\n if (expression.callee.name === 'Boolean' && args.length === 1) {\n return Boolean(args[0]);\n }\n\n const binding = resolveBindingAt(\n ctx,\n expression.callee.name,\n expression.callee.start\n );\n\n // staticBindings can register a pure helper for an imported name\n // (e.g. linaria's `cx` from '@linaria/core'). When the callee\n // resolves to such an import and every arg evaluated, invoke the\n // helper and return its result as a static value.\n if (binding?.importedFrom) {\n const override = lookupStaticBinding(\n ctx.staticBindings,\n binding.importedFrom,\n binding.imported\n );\n if (override.found && typeof override.value === 'function') {\n try {\n return (override.value as (...a: unknown[]) => unknown)(...args);\n } catch {\n return undefined;\n }\n }\n }\n\n const fn = binding?.functionNode ?? binding?.declarator?.init;\n if (\n fn &&\n (fn.type === 'ArrowFunctionExpression' ||\n fn.type === 'FunctionDeclaration' ||\n fn.type === 'FunctionExpression')\n ) {\n return evaluateFunctionCall(fn, args, ctx, env, [\n ...stack,\n expression.callee.name,\n ]);\n }\n }\n\n if (expression.callee.type === 'MemberExpression') {\n const objectValue = evaluateStatic(\n expression.callee.object,\n ctx,\n env,\n stack\n );\n let key: unknown;\n if (expression.callee.computed) {\n key = evaluateStatic(\n expression.callee.property as Expression,\n ctx,\n env,\n stack\n );\n } else if (expression.callee.property.type === 'Identifier') {\n key = expression.callee.property.name;\n }\n if (typeof objectValue === 'string') {\n if (key === 'toLowerCase' && expression.arguments.length === 0) {\n return objectValue.toLowerCase();\n }\n\n if (key === 'toUpperCase' && expression.arguments.length === 0) {\n return objectValue.toUpperCase();\n }\n }\n }\n }\n\n return evaluateBinary(expression, ctx, env, stack);\n};\n"],"file":"staticEvaluator.js"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../src/utils/collectOxcTemplateDependencies/types.ts"],"version":3,"sourcesContent":["import type { ExpressionValue, ValueType } from '@wyw-in-js/shared';\nimport type {\n AssignmentExpression,\n Expression,\n Node,\n TemplateLiteral,\n UpdateExpression,\n VariableDeclaration,\n VariableDeclarator,\n} from 'oxc-parser';\n\nimport type { OxcValueReplacement } from '../oxc/replacements';\nimport type { OxcLocationLookup } from '../oxc/sourceLocations';\n\nexport type OxcFunctionLikeNode = Node & {\n async: boolean;\n body: Node | null;\n id?: { name: string } | null;\n params: Node[];\n};\nexport type BindingKind = 'function' | 'import' | 'param' | 'variable';\nexport type ScopedDeclarationKind = 'const' | 'let' | 'var';\n\nexport type Binding = {\n declarationKind?: ScopedDeclarationKind;\n declaredAt: number;\n declaration: VariableDeclaration | null;\n declarator: VariableDeclarator | null;\n functionNode?: OxcFunctionLikeNode | null;\n imported?: 'default' | '*' | string;\n importedFrom?: string;\n isRoot: boolean;\n kind: BindingKind;\n name: string;\n scope: Scope;\n};\n\nexport type Replacement = OxcValueReplacement;\n\nexport type SpanLookup = Set<string> | null;\n\nexport type LocationLookup = OxcLocationLookup;\n\nexport type ExpressionSpan = {\n end: number;\n start: number;\n};\n\nexport type Scope = {\n bindings: Map<string, Binding>;\n depth: number;\n end: number;\n functionBoundary: boolean;\n params: Set<string>;\n parent: Scope | null;\n root: boolean;\n start: number;\n};\n\nexport type ReferenceIdentifier = {\n end: number;\n name: string;\n start: number;\n};\n\nexport type OxcStaticImportReference = {\n imported: 'default' | string;\n importLocal?: string;\n local: string;\n source: string;\n};\n\nexport type OxcStaticValue = {\n name: string;\n value: unknown;\n};\n\nexport type OxcStaticValueCandidate = {\n imports: OxcStaticImportReference[];\n inlineConstants?: Record<string, unknown>;\n name: string;\n source: string;\n};\n\nexport type TemplateExtractionResult = {\n code: string;\n dependencyNames: string[];\n expressionValues: Omit<ExpressionValue, 'buildCodeFrameError'>[];\n staticValueCandidates: OxcStaticValueCandidate[];\n staticValues: OxcStaticValue[];\n};\n\nexport type StaticBindings = Record<string, Record<string, unknown>>;\n\nexport type ExtractedExpression = {\n expressionCode: string;\n hasInlinableLocalReference?: boolean;\n importedFrom: string[];\n kind: ValueType.FUNCTION | ValueType.LAZY;\n staticExpressionCode?: string;\n staticImports: OxcStaticImportReference[];\n staticValue?: unknown;\n};\n\nexport type StaticLocalExpression = {\n importedFrom: string[];\n imports: OxcStaticImportReference[];\n source: string;\n};\n\nexport type ProgramAnalysis = {\n bindingsByName: Map<string, Binding[]>;\n rootMutationsByBinding: Map<\n string,\n Array<AssignmentExpression | UpdateExpression>\n >;\n targetExpressions: Expression[];\n templateLiterals: TemplateLiteral[];\n usedNames: Set<string>;\n};\n\nexport type ExtractionContext = {\n bindingResolutionCache: Map<string, Map<number, Binding | null>>;\n bindingsByName: Map<string, Binding[]>;\n code: string;\n currentInsertionPoint: number;\n currentExpressionStart: number;\n dependencyNames: Set<string>;\n expressionValues: Omit<ExpressionValue, 'buildCodeFrameError'>[];\n filename: string;\n hoistedBindingNames: Map<string, string>;\n hoistedDeclarations: Map<string, string>;\n hoistedDeclarationsByInsertionPoint: Map<number, string[]>;\n loc: LocationLookup;\n referencesByNode: WeakMap<Node, ReferenceIdentifier[]>;\n replacements: Replacement[];\n rootMutationsByBinding: Map<\n string,\n Array<AssignmentExpression | UpdateExpression>\n >;\n staticBindings?: StaticBindings;\n staticImportAliases: Map<string, string>;\n staticValueCandidates: OxcStaticValueCandidate[];\n staticValues: OxcStaticValue[];\n usedNames: Set<string>;\n};\n"],"file":"types.js"}
@@ -0,0 +1,4 @@
1
+ export { lookupStaticBinding } from "./collectOxcTemplateDependencies/staticBindings.js";
2
+ export { createOxcStaticCallableValue } from "./collectOxcTemplateDependencies/staticEvaluator.js";
3
+ export { collectOxcExpressionDependencies, collectOxcTemplateDependencies, evaluateOxcStaticExpression, evaluateOxcStaticExpressionAt, isOxcStaticSerializableValue } from "./collectOxcTemplateDependencies/expressionExtraction.js";
4
+ //# sourceMappingURL=collectOxcTemplateDependencies.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAMA,SAAS,2BAA2B;AACpC,SAAS,oCAAoC;AAC7C,SACE,kCACA,gCACA,6BACA,+BACA,oCACK","names":[],"sources":["../../src/utils/collectOxcTemplateDependencies.ts"],"version":3,"sourcesContent":["export type {\n OxcStaticImportReference,\n OxcStaticValue,\n OxcStaticValueCandidate,\n StaticBindings,\n} from './collectOxcTemplateDependencies/types';\nexport { lookupStaticBinding } from './collectOxcTemplateDependencies/staticBindings';\nexport { createOxcStaticCallableValue } from './collectOxcTemplateDependencies/staticEvaluator';\nexport {\n collectOxcExpressionDependencies,\n collectOxcTemplateDependencies,\n evaluateOxcStaticExpression,\n evaluateOxcStaticExpressionAt,\n isOxcStaticSerializableValue,\n} from './collectOxcTemplateDependencies/expressionExtraction';\n"],"file":"collectOxcTemplateDependencies.js"}
@@ -1,6 +1,5 @@
1
1
  // @ts-expect-error
2
- Symbol.dispose ??= Symbol('Symbol.dispose');
3
-
2
+ Symbol.dispose ??= Symbol("Symbol.dispose");
4
3
  // @ts-expect-error
5
- Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose');
6
- //# sourceMappingURL=dispose-polyfill.js.map
4
+ Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
5
+ //# sourceMappingURL=dispose-polyfill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispose-polyfill.js","names":["Symbol","dispose","asyncDispose"],"sources":["../../src/utils/dispose-polyfill.ts"],"sourcesContent":["// @ts-expect-error\nSymbol.dispose ??= Symbol('Symbol.dispose');\n\n// @ts-expect-error\nSymbol.asyncDispose ??= Symbol('Symbol.asyncDispose');\n"],"mappings":"AAAA;AACAA,MAAM,CAACC,OAAO,KAAKD,MAAM,CAAC,gBAAgB,CAAC;;AAE3C;AACAA,MAAM,CAACE,YAAY,KAAKF,MAAM,CAAC,qBAAqB,CAAC","ignoreList":[]}
1
+ {"mappings":";AACA,OAAO,YAAY,OAAO,iBAAiB;;AAG3C,OAAO,iBAAiB,OAAO,sBAAsB","names":[],"sources":["../../src/utils/dispose-polyfill.ts"],"version":3,"sourcesContent":["// @ts-expect-error\nSymbol.dispose ??= Symbol('Symbol.dispose');\n\n// @ts-expect-error\nSymbol.asyncDispose ??= Symbol('Symbol.asyncDispose');\n"],"file":"dispose-polyfill.js"}