packtory 0.0.96 → 0.0.98

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 (517) hide show
  1. package/artifacts/artifacts-builder.js +37 -4
  2. package/artifacts/artifacts-builder.js.map +1 -1
  3. package/artifacts/content-collection.js +59 -2
  4. package/artifacts/content-collection.js.map +1 -1
  5. package/artifacts/folder-writer.js +25 -2
  6. package/artifacts/folder-writer.js.map +1 -1
  7. package/bundle-emitter/emitter.js +137 -6
  8. package/bundle-emitter/emitter.js.map +1 -1
  9. package/bundle-emitter/extract-package-tarball.js +13 -2
  10. package/bundle-emitter/extract-package-tarball.js.map +1 -1
  11. package/bundle-emitter/fetch-published-artifacts.js +19 -2
  12. package/bundle-emitter/fetch-published-artifacts.js.map +1 -1
  13. package/bundle-emitter/publication-outcome.js +5 -0
  14. package/bundle-emitter/publication-outcome.js.map +1 -1
  15. package/bundle-emitter/publish-error/auto-mode-error-matching.js +28 -2
  16. package/bundle-emitter/publish-error/auto-mode-error-matching.js.map +1 -1
  17. package/bundle-emitter/publish-error/error-shape-helpers.js +9 -0
  18. package/bundle-emitter/publish-error/error-shape-helpers.js.map +1 -1
  19. package/bundle-emitter/publish-error/file-mode-error-matching.js +33 -2
  20. package/bundle-emitter/publish-error/file-mode-error-matching.js.map +1 -1
  21. package/bundle-emitter/publish-error/publish-error-messages.js +24 -0
  22. package/bundle-emitter/publish-error/publish-error-messages.js.map +1 -1
  23. package/bundle-emitter/registry/metadata-auth-retry.js +24 -1
  24. package/bundle-emitter/registry/metadata-auth-retry.js.map +1 -1
  25. package/bundle-emitter/registry/oidc-token-exchange.js +68 -3
  26. package/bundle-emitter/registry/oidc-token-exchange.js.map +1 -1
  27. package/bundle-emitter/registry/package-metadata-fetcher.js +210 -7
  28. package/bundle-emitter/registry/package-metadata-fetcher.js.map +1 -1
  29. package/bundle-emitter/registry/publish-settings-bridge.js +34 -3
  30. package/bundle-emitter/registry/publish-settings-bridge.js.map +1 -1
  31. package/bundle-emitter/registry/registry-auth-config.js +106 -0
  32. package/bundle-emitter/registry/registry-auth-config.js.map +1 -1
  33. package/bundle-emitter/registry/registry-client.js +74 -4
  34. package/bundle-emitter/registry/registry-client.js.map +1 -1
  35. package/bundle-emitter/registry/registry-package-path.js +3 -0
  36. package/bundle-emitter/registry/registry-package-path.js.map +1 -1
  37. package/bundle-emitter/registry/registry-response-schemas.js +50 -2
  38. package/bundle-emitter/registry/registry-response-schemas.js.map +1 -1
  39. package/bundle-emitter/registry/tarball-integrity.js +31 -1
  40. package/bundle-emitter/registry/tarball-integrity.js.map +1 -1
  41. package/bundle-emitter/registry/validate-tarball-host.js +26 -1
  42. package/bundle-emitter/registry/validate-tarball-host.js.map +1 -1
  43. package/bundle-emitter/release-artifact-canonicalizer.js +31 -5
  44. package/bundle-emitter/release-artifact-canonicalizer.js.map +1 -1
  45. package/checks/check-runner.js +8 -0
  46. package/checks/check-runner.js.map +1 -1
  47. package/checks/rule.js +12 -2
  48. package/checks/rule.js.map +1 -1
  49. package/checks/rules/duplicate-detection.js +23 -1
  50. package/checks/rules/duplicate-detection.js.map +1 -1
  51. package/checks/rules/duplicate-messages.js +22 -0
  52. package/checks/rules/duplicate-messages.js.map +1 -1
  53. package/checks/rules/file-ownership.js +15 -0
  54. package/checks/rules/file-ownership.js.map +1 -1
  55. package/checks/rules/max-bundle-size.js +55 -1
  56. package/checks/rules/max-bundle-size.js.map +1 -1
  57. package/checks/rules/no-dev-dependency-imports.js +51 -1
  58. package/checks/rules/no-dev-dependency-imports.js.map +1 -1
  59. package/checks/rules/no-duplicated-files.js +53 -3
  60. package/checks/rules/no-duplicated-files.js.map +1 -1
  61. package/checks/rules/no-side-effects.js +50 -1
  62. package/checks/rules/no-side-effects.js.map +1 -1
  63. package/checks/rules/no-unexposed-executables.js +43 -2
  64. package/checks/rules/no-unexposed-executables.js.map +1 -1
  65. package/checks/rules/no-unused-bundle-dependencies.js +30 -2
  66. package/checks/rules/no-unused-bundle-dependencies.js.map +1 -1
  67. package/checks/rules/registry.js +22 -9
  68. package/checks/rules/registry.js.map +1 -1
  69. package/checks/rules/required-files.js +41 -3
  70. package/checks/rules/required-files.js.map +1 -1
  71. package/checks/rules/type-script-declaration-integrity.js +81 -3
  72. package/checks/rules/type-script-declaration-integrity.js.map +1 -1
  73. package/checks/rules/type-script-declaration-paths.js +55 -1
  74. package/checks/rules/type-script-declaration-paths.js.map +1 -1
  75. package/checks/rules/type-script-declaration-project.js +202 -3
  76. package/checks/rules/type-script-declaration-project.js.map +1 -1
  77. package/checks/rules/type-script-declaration-reachability.js +38 -2
  78. package/checks/rules/type-script-declaration-reachability.js.map +1 -1
  79. package/checks/rules/type-script-declaration-roots.js +29 -0
  80. package/checks/rules/type-script-declaration-roots.js.map +1 -1
  81. package/checks/rules/type-script-integrity.js +72 -2
  82. package/checks/rules/type-script-integrity.js.map +1 -1
  83. package/checks/rules/type-script-package-resolution.js +42 -1
  84. package/checks/rules/type-script-package-resolution.js.map +1 -1
  85. package/checks/rules/type-script-resolution-summary.js +53 -0
  86. package/checks/rules/type-script-resolution-summary.js.map +1 -1
  87. package/checks/rules/unique-target-paths.js +34 -2
  88. package/checks/rules/unique-target-paths.js.map +1 -1
  89. package/common/bundled-dependency-groups.js +27 -0
  90. package/common/bundled-dependency-groups.js.map +1 -1
  91. package/common/code-files.js +28 -0
  92. package/common/code-files.js.map +1 -1
  93. package/common/declaration-companion-paths.js +24 -0
  94. package/common/declaration-companion-paths.js.map +1 -1
  95. package/common/package-name-map.js +7 -0
  96. package/common/package-name-map.js.map +1 -1
  97. package/common/stable-json.js +42 -2
  98. package/common/stable-json.js.map +1 -1
  99. package/common/worklist.js +22 -0
  100. package/common/worklist.js.map +1 -1
  101. package/config/additional-files.js +6 -2
  102. package/config/additional-files.js.map +1 -1
  103. package/config/additional-package-json-attributes-schema.js +6 -2
  104. package/config/additional-package-json-attributes-schema.js.map +1 -1
  105. package/config/automatic-versioning-settings.js +6 -2
  106. package/config/automatic-versioning-settings.js.map +1 -1
  107. package/config/changelog-settings.js +120 -3
  108. package/config/changelog-settings.js.map +1 -1
  109. package/config/common-package-settings-schemas.js +19 -3
  110. package/config/common-package-settings-schemas.js.map +1 -1
  111. package/config/config.js +3 -1
  112. package/config/config.js.map +1 -1
  113. package/config/cross-package-validation.js +17 -0
  114. package/config/cross-package-validation.js.map +1 -1
  115. package/config/dead-code-elimination-settings.js +36 -2
  116. package/config/dead-code-elimination-settings.js.map +1 -1
  117. package/config/dependency-existence-validation.js +19 -1
  118. package/config/dependency-existence-validation.js.map +1 -1
  119. package/config/dependency-policy.js +5 -2
  120. package/config/dependency-policy.js.map +1 -1
  121. package/config/main-package-json-schema.js +11 -2
  122. package/config/main-package-json-schema.js.map +1 -1
  123. package/config/manual-versioning-settings.d.ts +12 -0
  124. package/config/manual-versioning-settings.d.ts.map +1 -1
  125. package/config/manual-versioning-settings.js +29 -2
  126. package/config/manual-versioning-settings.js.map +1 -1
  127. package/config/optional-package-settings-schema.js +16 -7
  128. package/config/optional-package-settings-schema.js.map +1 -1
  129. package/config/package-config.js +2 -1
  130. package/config/package-config.js.map +1 -1
  131. package/config/package-graph-builder.js +14 -2
  132. package/config/package-graph-builder.js.map +1 -1
  133. package/config/package-interface.js +25 -2
  134. package/config/package-interface.js.map +1 -1
  135. package/config/package-json.d.ts.map +1 -1
  136. package/config/package-json.js +16 -0
  137. package/config/package-json.js.map +1 -1
  138. package/config/packtory-config-without-registry-schema.js +6 -0
  139. package/config/packtory-config-without-registry-schema.js.map +1 -1
  140. package/config/per-package-settings-schema.js +22 -6
  141. package/config/per-package-settings-schema.js.map +1 -1
  142. package/config/pre-graph-validation.js +20 -5
  143. package/config/pre-graph-validation.js.map +1 -1
  144. package/config/publish-settings.js +25 -3
  145. package/config/publish-settings.js.map +1 -1
  146. package/config/publish-settings.report.js +17 -1
  147. package/config/publish-settings.report.js.map +1 -1
  148. package/config/registry-settings.js +40 -2
  149. package/config/registry-settings.js.map +1 -1
  150. package/config/registry-settings.report.js +46 -0
  151. package/config/registry-settings.report.js.map +1 -1
  152. package/config/root-config-validation.js +141 -0
  153. package/config/root-config-validation.js.map +1 -1
  154. package/config/root.js +6 -2
  155. package/config/root.js.map +1 -1
  156. package/config/sbom-settings.js +4 -1
  157. package/config/sbom-settings.js.map +1 -1
  158. package/config/settings-validation.js +28 -0
  159. package/config/settings-validation.js.map +1 -1
  160. package/config/versioning-settings.js +10 -3
  161. package/config/versioning-settings.js.map +1 -1
  162. package/dead-code-eliminator/analyzed-bundle.js +7 -0
  163. package/dead-code-eliminator/analyzed-bundle.js.map +1 -1
  164. package/dead-code-eliminator/artifact-module-reference-contract.js +27 -0
  165. package/dead-code-eliminator/artifact-module-reference-contract.js.map +1 -0
  166. package/dead-code-eliminator/bundle-analysis.js +38 -5
  167. package/dead-code-eliminator/bundle-analysis.js.map +1 -1
  168. package/dead-code-eliminator/class-purity.js +48 -2
  169. package/dead-code-eliminator/class-purity.js.map +1 -1
  170. package/dead-code-eliminator/code-file-analyzer.js +68 -4
  171. package/dead-code-eliminator/code-file-analyzer.js.map +1 -1
  172. package/dead-code-eliminator/cross-bundle/bundle-index.js +10 -0
  173. package/dead-code-eliminator/cross-bundle/bundle-index.js.map +1 -1
  174. package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js +22 -3
  175. package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js.map +1 -1
  176. package/dead-code-eliminator/cross-bundle/import-export-walker.js +164 -3
  177. package/dead-code-eliminator/cross-bundle/import-export-walker.js.map +1 -1
  178. package/dead-code-eliminator/cross-bundle/seed-store.js +10 -0
  179. package/dead-code-eliminator/cross-bundle/seed-store.js.map +1 -1
  180. package/dead-code-eliminator/dependency-metadata.js +172 -2
  181. package/dead-code-eliminator/dependency-metadata.js.map +1 -1
  182. package/dead-code-eliminator/elimination-emitter.js +52 -0
  183. package/dead-code-eliminator/elimination-emitter.js.map +1 -1
  184. package/dead-code-eliminator/eliminator.js +22 -4
  185. package/dead-code-eliminator/eliminator.js.map +1 -1
  186. package/dead-code-eliminator/expression-unwrapping.js +16 -1
  187. package/dead-code-eliminator/expression-unwrapping.js.map +1 -1
  188. package/dead-code-eliminator/imported-expression-origin.js +101 -2
  189. package/dead-code-eliminator/imported-expression-origin.js.map +1 -1
  190. package/dead-code-eliminator/liveness/asset-side-effects.js +9 -1
  191. package/dead-code-eliminator/liveness/asset-side-effects.js.map +1 -1
  192. package/dead-code-eliminator/liveness/boolean-facts.js +98 -2
  193. package/dead-code-eliminator/liveness/boolean-facts.js.map +1 -1
  194. package/dead-code-eliminator/liveness/external-purity-summary.js +314 -3
  195. package/dead-code-eliminator/liveness/external-purity-summary.js.map +1 -1
  196. package/dead-code-eliminator/liveness/external-purity.js +39 -3
  197. package/dead-code-eliminator/liveness/external-purity.js.map +1 -1
  198. package/dead-code-eliminator/liveness/module-analysis.js +27 -2
  199. package/dead-code-eliminator/liveness/module-analysis.js.map +1 -1
  200. package/dead-code-eliminator/liveness/resource-retention.js +91 -1
  201. package/dead-code-eliminator/liveness/resource-retention.js.map +1 -1
  202. package/dead-code-eliminator/liveness/runtime-code.js +15 -1
  203. package/dead-code-eliminator/liveness/runtime-code.js.map +1 -1
  204. package/dead-code-eliminator/load-bundle.js +86 -5
  205. package/dead-code-eliminator/load-bundle.js.map +1 -1
  206. package/dead-code-eliminator/pure-expression.js +178 -5
  207. package/dead-code-eliminator/pure-expression.js.map +1 -1
  208. package/dead-code-eliminator/reachability/bfs-closure.js +53 -0
  209. package/dead-code-eliminator/reachability/bfs-closure.js.map +1 -1
  210. package/dead-code-eliminator/reachability/binding-extractor.js +100 -2
  211. package/dead-code-eliminator/reachability/binding-extractor.js.map +1 -1
  212. package/dead-code-eliminator/reachability/binding-id.js +106 -1
  213. package/dead-code-eliminator/reachability/binding-id.js.map +1 -1
  214. package/dead-code-eliminator/reachability/identifier-target-collector.js +96 -1
  215. package/dead-code-eliminator/reachability/identifier-target-collector.js.map +1 -1
  216. package/dead-code-eliminator/reachability/impure-statements.js +11 -2
  217. package/dead-code-eliminator/reachability/impure-statements.js.map +1 -1
  218. package/dead-code-eliminator/reachability/local-seed-gathering.js +91 -4
  219. package/dead-code-eliminator/reachability/local-seed-gathering.js.map +1 -1
  220. package/dead-code-eliminator/reachability/reachability.js +70 -4
  221. package/dead-code-eliminator/reachability/reachability.js.map +1 -1
  222. package/dead-code-eliminator/side-effect-classifier.js +39 -4
  223. package/dead-code-eliminator/side-effect-classifier.js.map +1 -1
  224. package/dead-code-eliminator/side-effects-field.js +23 -1
  225. package/dead-code-eliminator/side-effects-field.js.map +1 -1
  226. package/dead-code-eliminator/source-map-recomposition.js +29 -2
  227. package/dead-code-eliminator/source-map-recomposition.js.map +1 -1
  228. package/dead-code-eliminator/statement-classifiers.js +94 -4
  229. package/dead-code-eliminator/statement-classifiers.js.map +1 -1
  230. package/dead-code-eliminator/syntax-kind-sets.js +16 -0
  231. package/dead-code-eliminator/syntax-kind-sets.js.map +1 -1
  232. package/dead-code-eliminator/transform/atom-translator.js +57 -2
  233. package/dead-code-eliminator/transform/atom-translator.js.map +1 -1
  234. package/dead-code-eliminator/transform/declaration-removal.js +183 -5
  235. package/dead-code-eliminator/transform/declaration-removal.js.map +1 -1
  236. package/dead-code-eliminator/transform/declaration-remover.js +17 -2
  237. package/dead-code-eliminator/transform/declaration-remover.js.map +1 -1
  238. package/dead-code-eliminator/transform/line-index.js +20 -0
  239. package/dead-code-eliminator/transform/line-index.js.map +1 -1
  240. package/dead-code-eliminator/transform/named-declaration-kinds.js +3 -0
  241. package/dead-code-eliminator/transform/named-declaration-kinds.js.map +1 -1
  242. package/dead-code-eliminator/transform/source-map-composer.js +84 -3
  243. package/dead-code-eliminator/transform/source-map-composer.js.map +1 -1
  244. package/dead-code-eliminator/variable-declaration-bindings.js +25 -1
  245. package/dead-code-eliminator/variable-declaration-bindings.js.map +1 -1
  246. package/dependency-scanner/dependency-graph.js +77 -3
  247. package/dependency-scanner/dependency-graph.js.map +1 -1
  248. package/dependency-scanner/external-dependencies.js +55 -1
  249. package/dependency-scanner/external-dependencies.js.map +1 -1
  250. package/dependency-scanner/file-host-predicates.js +9 -0
  251. package/dependency-scanner/file-host-predicates.js.map +1 -1
  252. package/dependency-scanner/host-method-binding.js +18 -0
  253. package/dependency-scanner/host-method-binding.js.map +1 -1
  254. package/dependency-scanner/injected-dynamic-imports.js +232 -1
  255. package/dependency-scanner/injected-dynamic-imports.js.map +1 -1
  256. package/dependency-scanner/node-modules-manifest-synthesizer.js +52 -4
  257. package/dependency-scanner/node-modules-manifest-synthesizer.js.map +1 -1
  258. package/dependency-scanner/package-owned-asset-file-path.js +9 -1
  259. package/dependency-scanner/package-owned-asset-file-path.js.map +1 -1
  260. package/dependency-scanner/scanner.js +109 -4
  261. package/dependency-scanner/scanner.js.map +1 -1
  262. package/dependency-scanner/source-file-references.js +171 -6
  263. package/dependency-scanner/source-file-references.js.map +1 -1
  264. package/dependency-scanner/source-map-file-locator.js +66 -2
  265. package/dependency-scanner/source-map-file-locator.js.map +1 -1
  266. package/dependency-scanner/typescript-compiler-options.js +21 -1
  267. package/dependency-scanner/typescript-compiler-options.js.map +1 -1
  268. package/dependency-scanner/typescript-file-host.js +49 -5
  269. package/dependency-scanner/typescript-file-host.js.map +1 -1
  270. package/dependency-scanner/typescript-module-resolution.js +214 -0
  271. package/dependency-scanner/typescript-module-resolution.js.map +1 -0
  272. package/dependency-scanner/typescript-project-analyzer.js +32 -3
  273. package/dependency-scanner/typescript-project-analyzer.js.map +1 -1
  274. package/dependency-scanner/virtual-package-json-host.js +45 -4
  275. package/dependency-scanner/virtual-package-json-host.js.map +1 -1
  276. package/directed-graph/graph.js +240 -1
  277. package/directed-graph/graph.js.map +1 -1
  278. package/file-manager/compare.js +23 -2
  279. package/file-manager/compare.js.map +1 -1
  280. package/file-manager/equal.js +5 -0
  281. package/file-manager/equal.js.map +1 -1
  282. package/file-manager/file-description.js +3 -0
  283. package/file-manager/file-description.js.map +1 -1
  284. package/file-manager/permissions.js +28 -1
  285. package/file-manager/permissions.js.map +1 -1
  286. package/git/current-git-head.js +24 -0
  287. package/git/current-git-head.js.map +1 -1
  288. package/git/git-command.js +49 -1
  289. package/git/git-command.js.map +1 -1
  290. package/linker/linked-bundle.js +5 -0
  291. package/linker/linked-bundle.js.map +1 -1
  292. package/linker/linker.js +51 -5
  293. package/linker/linker.js.map +1 -1
  294. package/linker/replacement-lookup.js +297 -8
  295. package/linker/replacement-lookup.js.map +1 -1
  296. package/linker/resource-graph.js +65 -2
  297. package/linker/resource-graph.js.map +1 -1
  298. package/linker/source-modifier/import-paths.js +80 -3
  299. package/linker/source-modifier/import-paths.js.map +1 -1
  300. package/linker/substitute-bundles.js +166 -3
  301. package/linker/substitute-bundles.js.map +1 -1
  302. package/linker/substituted-resource-graph.js +111 -2
  303. package/linker/substituted-resource-graph.js.map +1 -1
  304. package/npm-oidc-id-token-resolver.js +82 -0
  305. package/npm-oidc-id-token-resolver.js.map +1 -1
  306. package/pack-emitter/pack-emitter.js +27 -0
  307. package/pack-emitter/pack-emitter.js.map +1 -1
  308. package/package-surface/bin-field.js +8 -2
  309. package/package-surface/bin-field.js.map +1 -1
  310. package/package-surface/explicit-bin.js +24 -2
  311. package/package-surface/explicit-bin.js.map +1 -1
  312. package/package-surface/explicit-exports.js +26 -3
  313. package/package-surface/explicit-exports.js.map +1 -1
  314. package/package-surface/export-map.js +9 -2
  315. package/package-surface/export-map.js.map +1 -1
  316. package/package-surface/implicit-bin.js +25 -1
  317. package/package-surface/implicit-bin.js.map +1 -1
  318. package/package-surface/implicit-exports.js +10 -3
  319. package/package-surface/implicit-exports.js.map +1 -1
  320. package/package-surface/implicit-root-exports.js +13 -2
  321. package/package-surface/implicit-root-exports.js.map +1 -1
  322. package/package-surface/package-json-export.js +9 -0
  323. package/package-surface/package-json-export.js.map +1 -1
  324. package/package-surface/package-shape.js +10 -1
  325. package/package-surface/package-shape.js.map +1 -1
  326. package/package-surface/package-surface-index.js +165 -3
  327. package/package-surface/package-surface-index.js.map +1 -1
  328. package/package-surface/public-module-usage.js +46 -3
  329. package/package-surface/public-module-usage.js.map +1 -1
  330. package/package-surface/public-specifiers.js +7 -1
  331. package/package-surface/public-specifiers.js.map +1 -1
  332. package/package-surface/root-registry.js +26 -0
  333. package/package-surface/root-registry.js.map +1 -1
  334. package/package-surface/specifier-syntax.js +4 -0
  335. package/package-surface/specifier-syntax.js.map +1 -1
  336. package/package-surface/substitution-exports.js +101 -3
  337. package/package-surface/substitution-exports.js.map +1 -1
  338. package/package-surface/surface.js +12 -0
  339. package/package-surface/surface.js.map +1 -1
  340. package/package.json +2 -2
  341. package/packages/package-processor.composition.js +161 -34
  342. package/packages/package-processor.composition.js.map +1 -1
  343. package/packtory/map-config.js +35 -4
  344. package/packtory/map-config.js.map +1 -1
  345. package/packtory/normalize-paths.js +25 -1
  346. package/packtory/normalize-paths.js.map +1 -1
  347. package/packtory/options/bundle-dependency-resolution.js +17 -1
  348. package/packtory/options/bundle-dependency-resolution.js.map +1 -1
  349. package/packtory/options/dead-code-elimination-resolution.js +10 -1
  350. package/packtory/options/dead-code-elimination-resolution.js.map +1 -1
  351. package/packtory/options/prepare-package-options.js +46 -5
  352. package/packtory/options/prepare-package-options.js.map +1 -1
  353. package/packtory/options/required-value-helpers.js +17 -0
  354. package/packtory/options/required-value-helpers.js.map +1 -1
  355. package/packtory/options/setting-resolvers.js +47 -3
  356. package/packtory/options/setting-resolvers.js.map +1 -1
  357. package/packtory/options/surface-resolution.js +15 -2
  358. package/packtory/options/surface-resolution.js.map +1 -1
  359. package/packtory/options/version-provider-context.js +24 -2
  360. package/packtory/options/version-provider-context.js.map +1 -1
  361. package/packtory/options/version-trigger.js +39 -2
  362. package/packtory/options/version-trigger.js.map +1 -1
  363. package/packtory/pack-output-preflight.js +60 -3
  364. package/packtory/pack-output-preflight.js.map +1 -1
  365. package/packtory/package-processor-build.js +97 -3
  366. package/packtory/package-processor-build.js.map +1 -1
  367. package/packtory/package-processor-publish.js +297 -6
  368. package/packtory/package-processor-publish.js.map +1 -1
  369. package/packtory/package-processor.js +10 -2
  370. package/packtory/package-processor.js.map +1 -1
  371. package/packtory/packtory-pack.js +298 -10
  372. package/packtory/packtory-pack.js.map +1 -1
  373. package/packtory/packtory-package-dependencies.js +116 -2
  374. package/packtory/packtory-package-dependencies.js.map +1 -1
  375. package/packtory/packtory-package-inspection.js +26 -5
  376. package/packtory/packtory-package-inspection.js.map +1 -1
  377. package/packtory/packtory-package-side-effects.js +64 -3
  378. package/packtory/packtory-package-side-effects.js.map +1 -1
  379. package/packtory/packtory-package-tree.js +43 -4
  380. package/packtory/packtory-package-tree.js.map +1 -1
  381. package/packtory/packtory-publish.js +17 -4
  382. package/packtory/packtory-publish.js.map +1 -1
  383. package/packtory/packtory-release-analysis.js +64 -6
  384. package/packtory/packtory-release-analysis.js.map +1 -1
  385. package/packtory/packtory-release-diff.js +48 -5
  386. package/packtory/packtory-release-diff.js.map +1 -1
  387. package/packtory/packtory-release-plan.js +87 -6
  388. package/packtory/packtory-release-plan.js.map +1 -1
  389. package/packtory/packtory-resolve.js +16 -5
  390. package/packtory/packtory-resolve.js.map +1 -1
  391. package/packtory/packtory.js +242 -13
  392. package/packtory/packtory.js.map +1 -1
  393. package/packtory/publish-failure-mapping.js +6 -0
  394. package/packtory/publish-failure-mapping.js.map +1 -1
  395. package/packtory/publish-target-preflight.js +25 -3
  396. package/packtory/publish-target-preflight.js.map +1 -1
  397. package/packtory/published-release-state.js +11 -0
  398. package/packtory/published-release-state.js.map +1 -1
  399. package/packtory/release-analysis.js +153 -5
  400. package/packtory/release-analysis.js.map +1 -1
  401. package/packtory/release-diff-failure-mapping.js +6 -0
  402. package/packtory/release-diff-failure-mapping.js.map +1 -1
  403. package/packtory/release-plan.js +135 -7
  404. package/packtory/release-plan.js.map +1 -1
  405. package/packtory/report-attachment.js +35 -2
  406. package/packtory/report-attachment.js.map +1 -1
  407. package/packtory/resolved-package.js +97 -3
  408. package/packtory/resolved-package.js.map +1 -1
  409. package/packtory/scheduler.js +99 -1
  410. package/packtory/scheduler.js.map +1 -1
  411. package/packtory/stages/package-analysis-stage.js +50 -2
  412. package/packtory/stages/package-analysis-stage.js.map +1 -1
  413. package/packtory/stages/package-resolution-stage.js +80 -5
  414. package/packtory/stages/package-resolution-stage.js.map +1 -1
  415. package/packtory/stages/publish-stage.js +125 -4
  416. package/packtory/stages/publish-stage.js.map +1 -1
  417. package/packtory/stages/release-diff-stage.js +84 -5
  418. package/packtory/stages/release-diff-stage.js.map +1 -1
  419. package/progress/progress-broadcaster.js +45 -0
  420. package/progress/progress-broadcaster.js.map +1 -1
  421. package/published-package/published-package.js +12 -1
  422. package/published-package/published-package.js.map +1 -1
  423. package/report/aggregator/artifact-entry-merger.js +20 -0
  424. package/report/aggregator/artifact-entry-merger.js.map +1 -1
  425. package/report/aggregator/package-report-materialization.js +75 -2
  426. package/report/aggregator/package-report-materialization.js.map +1 -1
  427. package/report/aggregator/report-aggregator.js +37 -2
  428. package/report/aggregator/report-aggregator.js.map +1 -1
  429. package/report/aggregator/report-event-handlers.js +141 -2
  430. package/report/aggregator/report-event-handlers.js.map +1 -1
  431. package/report/aggregator/report-types.js +3 -0
  432. package/report/aggregator/report-types.js.map +1 -1
  433. package/report/config-redactor.js +29 -3
  434. package/report/config-redactor.js.map +1 -1
  435. package/report/decorators.js +85 -0
  436. package/report/decorators.js.map +1 -1
  437. package/report/inspectors/inspect-artifact-sizes.js +34 -1
  438. package/report/inspectors/inspect-artifact-sizes.js.map +1 -1
  439. package/report/inspectors/inspect-linker-rewrites.js +14 -1
  440. package/report/inspectors/inspect-linker-rewrites.js.map +1 -1
  441. package/report/inspectors/inspect-package-json-provenance.js +15 -0
  442. package/report/inspectors/inspect-package-json-provenance.js.map +1 -1
  443. package/report/inspectors/inspect-scan-results.js +15 -0
  444. package/report/inspectors/inspect-scan-results.js.map +1 -1
  445. package/report/release-diff/release-version-transition.js +18 -0
  446. package/report/release-diff/release-version-transition.js.map +1 -1
  447. package/resource-resolver/bundle-resource-lookup.js +25 -0
  448. package/resource-resolver/bundle-resource-lookup.js.map +1 -1
  449. package/resource-resolver/content.js +136 -4
  450. package/resource-resolver/content.js.map +1 -1
  451. package/resource-resolver/dependency-resolution-walker.js +73 -2
  452. package/resource-resolver/dependency-resolution-walker.js.map +1 -1
  453. package/resource-resolver/resolved-bundle.js +3 -0
  454. package/resource-resolver/resolved-bundle.js.map +1 -1
  455. package/resource-resolver/resource-resolve-options.js +13 -1
  456. package/resource-resolver/resource-resolve-options.js.map +1 -1
  457. package/resource-resolver/resource-resolver.js +128 -6
  458. package/resource-resolver/resource-resolver.js.map +1 -1
  459. package/sbom/extract-license.js +11 -1
  460. package/sbom/extract-license.js.map +1 -1
  461. package/sbom/license-resolver.js +23 -2
  462. package/sbom/license-resolver.js.map +1 -1
  463. package/sbom/sbom-builder.js +57 -2
  464. package/sbom/sbom-builder.js.map +1 -1
  465. package/sbom/sbom-canonicalizer.js +45 -3
  466. package/sbom/sbom-canonicalizer.js.map +1 -1
  467. package/sbom/sbom-file.js +54 -5
  468. package/sbom/sbom-file.js.map +1 -1
  469. package/sbom/sbom-serializer.js +14 -1
  470. package/sbom/sbom-serializer.js.map +1 -1
  471. package/sbom/tool-version.js +49 -1
  472. package/sbom/tool-version.js.map +1 -1
  473. package/sbom.cdx.json +10 -10
  474. package/tar/extract-tar.js +83 -3
  475. package/tar/extract-tar.js.map +1 -1
  476. package/tar/gzipped-pack.js +20 -0
  477. package/tar/gzipped-pack.js.map +1 -1
  478. package/tar/tarball-builder.js +44 -4
  479. package/tar/tarball-builder.js.map +1 -1
  480. package/vendor-materializer/vendor-entry.js +20 -1
  481. package/vendor-materializer/vendor-entry.js.map +1 -1
  482. package/vendor-materializer/vendor-materializer.js +240 -8
  483. package/vendor-materializer/vendor-materializer.js.map +1 -1
  484. package/version-manager/dependencies/bundle-dependency-grouping.js +32 -2
  485. package/version-manager/dependencies/bundle-dependency-grouping.js.map +1 -1
  486. package/version-manager/dependencies/dependency-groups.js +11 -1
  487. package/version-manager/dependencies/dependency-groups.js.map +1 -1
  488. package/version-manager/dependencies/external-dependency-classification.js +82 -3
  489. package/version-manager/dependencies/external-dependency-classification.js.map +1 -1
  490. package/version-manager/dependencies/versioned-bundle-dependencies.js +8 -3
  491. package/version-manager/dependencies/versioned-bundle-dependencies.js.map +1 -1
  492. package/version-manager/imports/hash-import-scanner.js +20 -2
  493. package/version-manager/imports/hash-import-scanner.js.map +1 -1
  494. package/version-manager/imports/imports-key-matcher.js +22 -0
  495. package/version-manager/imports/imports-key-matcher.js.map +1 -1
  496. package/version-manager/imports/versioned-bundle-imports.js +44 -2
  497. package/version-manager/imports/versioned-bundle-imports.js.map +1 -1
  498. package/version-manager/manager.js +46 -6
  499. package/version-manager/manager.js.map +1 -1
  500. package/version-manager/manifest/builder.js +51 -1
  501. package/version-manager/manifest/builder.js.map +1 -1
  502. package/version-manager/manifest/serialize.js +8 -1
  503. package/version-manager/manifest/serialize.js.map +1 -1
  504. package/version-manager/optional-bundle-fields.js +5 -1
  505. package/version-manager/optional-bundle-fields.js.map +1 -1
  506. package/version-manager/representative-root.js +9 -1
  507. package/version-manager/representative-root.js.map +1 -1
  508. package/version-manager/specifier-classifier.js +42 -2
  509. package/version-manager/specifier-classifier.js.map +1 -1
  510. package/version-manager/specifier-errors.js +58 -0
  511. package/version-manager/specifier-errors.js.map +1 -1
  512. package/version-manager/versioned-bundle.js +31 -6
  513. package/version-manager/versioned-bundle.js.map +1 -1
  514. package/zip/zip-builder.js +81 -2
  515. package/zip/zip-builder.js.map +1 -1
  516. package/dead-code-eliminator/liveness/external-module-resolution.js +0 -3
  517. package/dead-code-eliminator/liveness/external-module-resolution.js.map +0 -1
@@ -1,2 +1,16 @@
1
- import 'node:path';
1
+ import path from 'node:path';
2
+ const runtimeCodeExtensions = new Set(['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx']);
3
+ const declarationCodeExtensions = ['.d.ts', '.d.cts', '.d.mts'];
4
+ export function isDeclarationCodeTargetPath(targetFilePath) {
5
+ return declarationCodeExtensions.some(function (extension) {
6
+ return targetFilePath.endsWith(extension);
7
+ });
8
+ }
9
+ export function isRuntimeCodeTargetPath(targetFilePath) {
10
+ return runtimeCodeExtensions.has(path.extname(targetFilePath)) &&
11
+ !isDeclarationCodeTargetPath(targetFilePath);
12
+ }
13
+ export function isCodeTargetPath(targetFilePath) {
14
+ return isRuntimeCodeTargetPath(targetFilePath) || isDeclarationCodeTargetPath(targetFilePath);
15
+ }
2
16
  //# sourceMappingURL=runtime-code.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-code.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/liveness/runtime-code.ts"],"names":[],"mappings":"AAAA,OAAiB,WAAW,CAAC"}
1
+ {"version":3,"file":"runtime-code.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/liveness/runtime-code.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAE,CAAC,CAAC;AACxG,MAAM,yBAAyB,GAAG,CAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAE,CAAC;AAElE,MAAM,UAAU,2BAA2B,CAAC,cAAsB;IAC9D,OAAO,yBAAyB,CAAC,IAAI,CAAC,UAAU,SAAS;QACrD,OAAO,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,cAAsB;IAC1D,OAAO,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1D,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,cAAsB;IACnD,OAAO,uBAAuB,CAAC,cAAc,CAAC,IAAI,2BAA2B,CAAC,cAAc,CAAC,CAAC;AAClG,CAAC"}
@@ -1,6 +1,87 @@
1
- import "../common/declaration-companion-paths.js";
2
- import "../common/code-files.js";
3
- import "../package-surface/root-registry.js";
4
- import "./reachability/binding-extractor.js";
5
- import "./reachability/reachability.js";
1
+ import { declarationCompanionCandidates } from "../common/declaration-companion-paths.js";
2
+ import { isCodeFile, isDeclarationCodeFile } from "../common/code-files.js";
3
+ import { getEntryRootIds } from "../package-surface/root-registry.js";
4
+ import { extractTopLevelBindings } from "./reachability/binding-extractor.js";
5
+ import { buildReachabilityIndex } from "./reachability/reachability.js";
6
+ function parseFilePathFor(resource) {
7
+ return `/.packtory-artifacts/${resource.fileDescription.targetFilePath}`;
8
+ }
9
+ function projectForResource(runtimeProject, declarationProject, resource) {
10
+ return isDeclarationCodeFile(resource.fileDescription.targetFilePath) ? declarationProject : runtimeProject;
11
+ }
12
+ function loadResource(runtimeProject, declarationProject, resource) {
13
+ if (!isCodeFile(resource.fileDescription.targetFilePath)) {
14
+ return { resource };
15
+ }
16
+ const project = projectForResource(runtimeProject, declarationProject, resource);
17
+ const sourceFile = project.createSourceFile(parseFilePathFor(resource), resource.fileDescription.content, { overwrite: true });
18
+ return { resource, sourceFile, bindings: extractTopLevelBindings(sourceFile) };
19
+ }
20
+ function buildFileBindings(loaded) {
21
+ const result = [];
22
+ for (const entry of loaded) {
23
+ if (entry.sourceFile !== undefined) {
24
+ result.push({
25
+ inputFilePath: entry.resource.fileDescription.inputFilePath,
26
+ parsedInputFilePath: entry.sourceFile.getFilePath(),
27
+ targetFilePath: entry.resource.fileDescription.targetFilePath,
28
+ moduleReferences: entry.resource.moduleReferences,
29
+ sourceFile: entry.sourceFile,
30
+ bindings: entry.bindings
31
+ });
32
+ }
33
+ }
34
+ return result;
35
+ }
36
+ function targetFilePathByInputFilePath(resources) {
37
+ return new Map(resources.map(function (resource) {
38
+ return [resource.fileDescription.inputFilePath, resource.fileDescription.targetFilePath];
39
+ }));
40
+ }
41
+ function substitutionPublicModuleTargetPathsFor(substitutionPublicModuleInputFilePaths, targetPathsByInputPath) {
42
+ return new Set(Array
43
+ .from(substitutionPublicModuleInputFilePaths, function (inputFilePath) {
44
+ return targetPathsByInputPath.get(inputFilePath);
45
+ })
46
+ .filter(function (targetFilePath) {
47
+ return targetFilePath !== undefined;
48
+ })
49
+ .flatMap(function (targetFilePath) {
50
+ return [targetFilePath, ...declarationCompanionCandidates(targetFilePath)];
51
+ }));
52
+ }
53
+ function rootFilePathsFor(bundle, rootId) {
54
+ const root = bundle.roots[rootId];
55
+ if (root === undefined) {
56
+ throw new Error(`Bundle "${bundle.name}" is missing root "${rootId}" referenced by its entry surface`);
57
+ }
58
+ return root.declarationFile === undefined
59
+ ? [root.js.targetFilePath]
60
+ : [root.js.targetFilePath, root.declarationFile.targetFilePath];
61
+ }
62
+ function entryRootFilePathsFor(bundle, substitutionPublicModuleInputFilePaths) {
63
+ const targetPathsByInputPath = targetFilePathByInputFilePath(bundle.contents);
64
+ return new Set([
65
+ ...Array.from(getEntryRootIds(bundle)).flatMap(function (rootId) {
66
+ return rootFilePathsFor(bundle, rootId);
67
+ }),
68
+ ...substitutionPublicModuleTargetPathsFor(substitutionPublicModuleInputFilePaths, targetPathsByInputPath)
69
+ ]);
70
+ }
71
+ export function loadBundle(createProject, input, trace) {
72
+ const runtimeProject = createProject();
73
+ const declarationProject = createProject();
74
+ const loaded = input.bundle.contents.map(function (resource) {
75
+ return loadResource(runtimeProject, declarationProject, resource);
76
+ });
77
+ const fileBindings = buildFileBindings(loaded);
78
+ const reachability = buildReachabilityIndex({
79
+ bundleName: input.bundle.name,
80
+ files: fileBindings,
81
+ entryPointFilePaths: entryRootFilePathsFor(input.bundle, input.substitutionPublicModuleInputFilePaths),
82
+ deadCodeElimination: input.deadCodeElimination,
83
+ trace
84
+ });
85
+ return { input, loaded, fileBindings, reachability };
86
+ }
6
87
  //# sourceMappingURL=load-bundle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-bundle.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/load-bundle.ts"],"names":[],"mappings":"AACA,OAA+C,0CAA0C,CAAC;AAC1F,OAAkD,yBAAyB,CAAC;AAE5E,OAAgC,qCAAqC,CAAC;AAEtE,OAAgE,qCAAqC,CAAC;AAEtG,OAA+D,gCAAgC,CAAC"}
1
+ {"version":3,"file":"load-bundle.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/load-bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAA0B,MAAM,qCAAqC,CAAC;AAEtG,OAAO,EAAE,sBAAsB,EAA0B,MAAM,gCAAgC,CAAC;AAyBhG,SAAS,gBAAgB,CAAC,QAA8B;IACpD,OAAO,wBAAwB,QAAQ,CAAC,eAAe,CAAC,cAAc,EAAE,CAAC;AAC7E,CAAC;AAED,SAAS,kBAAkB,CACvB,cAAuB,EACvB,kBAA2B,EAC3B,QAA8B;IAE9B,OAAO,qBAAqB,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,cAAc,CAAC;AAChH,CAAC;AAED,SAAS,YAAY,CACjB,cAAuB,EACvB,kBAA2B,EAC3B,QAA8B;IAE9B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,CAAC;QACvD,OAAO,EAAE,QAAQ,EAAE,CAAC;IACxB,CAAC;IACD,MAAM,OAAO,GAAG,kBAAkB,CAAC,cAAc,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IACjF,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B,EACvB,KAA+B;IAE/B,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC;IACvC,MAAM,kBAAkB,GAAG,aAAa,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,QAAQ;QACvD,OAAO,YAAY,CAAC,cAAc,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,sBAAsB,CAAC;QACxC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;QAC7B,KAAK,EAAE,YAAY;QACnB,mBAAmB,EAAE,qBAAqB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,sCAAsC,CAAC;QACtG,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;QAC9C,KAAK;KACR,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AACzD,CAAC"}
@@ -1,8 +1,8 @@
1
- import { SyntaxKind } from 'ts-morph';
2
- import "./expression-unwrapping.js";
3
- import "./imported-expression-origin.js";
4
- import "./liveness/external-purity.js";
5
- import "./syntax-kind-sets.js";
1
+ import { Node as TsMorphNode, SyntaxKind } from 'ts-morph';
2
+ import { unwrapExpression } from "./expression-unwrapping.js";
3
+ import { arePureCallArguments, resolveImportedExpressionOrigin } from "./imported-expression-origin.js";
4
+ import { externalCallIsPure } from "./liveness/external-purity.js";
5
+ import { allowedBinaryOperators, allowedPrefixUnaryOperators, inherentlyPurePropertyKinds, pureLeafKinds } from "./syntax-kind-sets.js";
6
6
  const alwaysAvailableDeclarationKinds = new Set([
7
7
  SyntaxKind.FunctionDeclaration,
8
8
  SyntaxKind.ImportClause,
@@ -15,4 +15,177 @@ const orderedDeclarationKinds = new Set([
15
15
  SyntaxKind.EnumDeclaration,
16
16
  SyntaxKind.VariableDeclaration
17
17
  ]);
18
+ function isPureArrayElement(element, recurse) {
19
+ if (TsMorphNode.isOmittedExpression(element)) {
20
+ return true;
21
+ }
22
+ if (TsMorphNode.isSpreadElement(element)) {
23
+ return recurse(element.getExpression());
24
+ }
25
+ return recurse(element);
26
+ }
27
+ function computedPropertyNameExpression(property) {
28
+ if (TsMorphNode.isPropertyAssignment(property) ||
29
+ TsMorphNode.isMethodDeclaration(property) ||
30
+ TsMorphNode.isGetAccessorDeclaration(property) ||
31
+ TsMorphNode.isSetAccessorDeclaration(property)) {
32
+ const name = property.getNameNode();
33
+ if (TsMorphNode.isComputedPropertyName(name)) {
34
+ return name.getExpression();
35
+ }
36
+ }
37
+ return undefined;
38
+ }
39
+ function isPurePropertyAssignment(property, recurse) {
40
+ const computedNameExpression = computedPropertyNameExpression(property);
41
+ if (computedNameExpression !== undefined && !recurse(computedNameExpression)) {
42
+ return false;
43
+ }
44
+ if (TsMorphNode.isPropertyAssignment(property)) {
45
+ return recurse(property.getInitializerOrThrow());
46
+ }
47
+ if (TsMorphNode.isSpreadAssignment(property)) {
48
+ return recurse(property.getExpression());
49
+ }
50
+ return inherentlyPurePropertyKinds.has(property.getKind());
51
+ }
52
+ function declarationIsAvailableBeforeRead(declaration, expression) {
53
+ return Math.sign(expression.getStart() - declaration.getEnd()) === 1;
54
+ }
55
+ function declarationMakesIdentifierReadPure(declaration, expression) {
56
+ const kind = declaration.getKind();
57
+ if (alwaysAvailableDeclarationKinds.has(kind)) {
58
+ return true;
59
+ }
60
+ if (orderedDeclarationKinds.has(kind)) {
61
+ return declarationIsAvailableBeforeRead(declaration, expression);
62
+ }
63
+ return false;
64
+ }
65
+ function identifierDeclarations(expression) {
66
+ const symbol = expression.getSymbol();
67
+ return symbol?.getDeclarations() ?? [];
68
+ }
69
+ function isPureIdentifierRead(expression) {
70
+ if (expression.getText() === 'undefined') {
71
+ return true;
72
+ }
73
+ return identifierDeclarations(expression).some(function (declaration) {
74
+ return declarationMakesIdentifierReadPure(declaration, expression);
75
+ });
76
+ }
77
+ function isPureBuiltinCallExpression(callTarget, expression, recurse) {
78
+ return TsMorphNode.isIdentifier(callTarget) && callTarget.getText() === 'Symbol'
79
+ ? arePureCallArguments(expression.getArguments(), recurse)
80
+ : false;
81
+ }
82
+ function hasPureAnnotation(expression) {
83
+ const text = expression.getFullText();
84
+ return text.includes('@__PURE__') || text.includes('#__PURE__');
85
+ }
86
+ function pureAnnotationMakesCallPure(expression, recurse) {
87
+ return hasPureAnnotation(expression) && arePureCallArguments(expression.getArguments(), recurse);
88
+ }
89
+ function isPureCallExpression(expression, recurse, settings) {
90
+ const callTarget = unwrapExpression(expression.getExpression());
91
+ return (pureAnnotationMakesCallPure(expression, recurse) ||
92
+ isPureBuiltinCallExpression(callTarget, expression, recurse) ||
93
+ externalCallIsPure(expression, recurse) ||
94
+ resolveImportedExpressionOrigin(expression, recurse, settings) !== undefined);
95
+ }
96
+ function constructorNameIsTrusted(constructorExpression, settings) {
97
+ return TsMorphNode.isIdentifier(constructorExpression) &&
98
+ settings?.pureConstructors?.includes(constructorExpression.getText()) === true;
99
+ }
100
+ function isPureNewExpression(expression, recurse, settings) {
101
+ const constructorExpression = unwrapExpression(expression.getExpression());
102
+ const trustedConstructorCall = constructorNameIsTrusted(constructorExpression, settings) &&
103
+ arePureCallArguments(expression.getArguments(), recurse);
104
+ return pureAnnotationMakesCallPure(expression, recurse) || trustedConstructorCall;
105
+ }
106
+ function templateExpressionIsPure(expression, recurse) {
107
+ return expression
108
+ .asKindOrThrow(SyntaxKind.TemplateExpression)
109
+ .getTemplateSpans()
110
+ .every(function (span) {
111
+ return recurse(span.getExpression());
112
+ });
113
+ }
114
+ function arrayLiteralExpressionIsPure(expression, recurse) {
115
+ return expression
116
+ .asKindOrThrow(SyntaxKind.ArrayLiteralExpression)
117
+ .getElements()
118
+ .every(function (element) {
119
+ return isPureArrayElement(element, recurse);
120
+ });
121
+ }
122
+ function objectLiteralExpressionIsPure(expression, recurse) {
123
+ return expression
124
+ .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
125
+ .getProperties()
126
+ .every(function (property) {
127
+ return isPurePropertyAssignment(property, recurse);
128
+ });
129
+ }
130
+ function prefixUnaryExpressionIsPure(expression, recurse) {
131
+ const unary = expression.asKindOrThrow(SyntaxKind.PrefixUnaryExpression);
132
+ return allowedPrefixUnaryOperators.has(unary.getOperatorToken()) && recurse(unary.getOperand());
133
+ }
134
+ function binaryExpressionIsPure(expression, recurse) {
135
+ const binary = expression.asKindOrThrow(SyntaxKind.BinaryExpression);
136
+ if (!allowedBinaryOperators.has(binary.getOperatorToken().getKind())) {
137
+ return false;
138
+ }
139
+ return recurse(binary.getLeft()) && recurse(binary.getRight());
140
+ }
141
+ function callExpressionIsPure(expression, recurse, settings) {
142
+ return isPureCallExpression(expression.asKindOrThrow(SyntaxKind.CallExpression), recurse, settings);
143
+ }
144
+ function newExpressionIsPure(expression, recurse, settings) {
145
+ return isPureNewExpression(expression.asKindOrThrow(SyntaxKind.NewExpression), recurse, settings);
146
+ }
147
+ function literalStructurePurityRuleFor(kind) {
148
+ if (kind === SyntaxKind.TemplateExpression) {
149
+ return templateExpressionIsPure;
150
+ }
151
+ if (kind === SyntaxKind.ArrayLiteralExpression) {
152
+ return arrayLiteralExpressionIsPure;
153
+ }
154
+ if (kind === SyntaxKind.ObjectLiteralExpression) {
155
+ return objectLiteralExpressionIsPure;
156
+ }
157
+ return undefined;
158
+ }
159
+ function operationPurityRuleFor(kind) {
160
+ if (kind === SyntaxKind.PrefixUnaryExpression) {
161
+ return prefixUnaryExpressionIsPure;
162
+ }
163
+ if (kind === SyntaxKind.BinaryExpression) {
164
+ return binaryExpressionIsPure;
165
+ }
166
+ if (kind === SyntaxKind.CallExpression) {
167
+ return callExpressionIsPure;
168
+ }
169
+ if (kind === SyntaxKind.NewExpression) {
170
+ return newExpressionIsPure;
171
+ }
172
+ return undefined;
173
+ }
174
+ function expressionPurityRuleFor(kind) {
175
+ return literalStructurePurityRuleFor(kind) ?? operationPurityRuleFor(kind);
176
+ }
177
+ export function isPureExpression(expression, settings) {
178
+ const unwrapped = unwrapExpression(expression);
179
+ if (TsMorphNode.isIdentifier(unwrapped)) {
180
+ return isPureIdentifierRead(unwrapped);
181
+ }
182
+ const recurse = function (candidate) {
183
+ return isPureExpression(candidate, settings);
184
+ };
185
+ const kind = unwrapped.getKind();
186
+ if (pureLeafKinds.has(kind)) {
187
+ return true;
188
+ }
189
+ return expressionPurityRuleFor(kind)?.(unwrapped, recurse, settings) ?? false;
190
+ }
18
191
  //# sourceMappingURL=pure-expression.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pure-expression.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/pure-expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EAMb,MAAM,UAAU,CAAC;AAElB,OAAiC,4BAA4B,CAAC;AAC9D,OAIO,iCAAiC,CAAC;AACzC,OAAmC,+BAA+B,CAAC;AACnE,OAKO,uBAAuB,CAAC;AAQ/B,MAAM,+BAA+B,GAAG,IAAI,GAAG,CAAa;IACxD,UAAU,CAAC,mBAAmB;IAC9B,UAAU,CAAC,YAAY;IACvB,UAAU,CAAC,eAAe;IAC1B,UAAU,CAAC,eAAe;IAC1B,UAAU,CAAC,SAAS;CACvB,CAAC,CAAC;AACH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAa;IAChD,UAAU,CAAC,gBAAgB;IAC3B,UAAU,CAAC,eAAe;IAC1B,UAAU,CAAC,mBAAmB;CACjC,CAAC,CAAC"}
1
+ {"version":3,"file":"pure-expression.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/pure-expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,IAAI,WAAW,EACnB,UAAU,EAMb,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EACH,oBAAoB,EACpB,+BAA+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AM,OAAO,GAA4B,UAAU,SAAS;QACxD,OAAO,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,KAAK,CAAC;AAClF,CAAC"}
@@ -1 +1,54 @@
1
+ function initialTraversalState(initialVisited, seedList) {
2
+ const [current, ...pending] = seedList;
3
+ return { current, pending, visited: new Set([...initialVisited, ...seedList]) };
4
+ }
5
+ function enqueueNeighbor(state, current, neighbor, dependencies) {
6
+ if (dependencies.visitedHas(state.visited, neighbor)) {
7
+ return state;
8
+ }
9
+ if (dependencies.neighborAdded !== undefined) {
10
+ dependencies.neighborAdded(current, neighbor);
11
+ }
12
+ return {
13
+ current: state.current,
14
+ pending: [...state.pending, neighbor],
15
+ visited: new Set([...state.visited, neighbor])
16
+ };
17
+ }
18
+ function visitCurrent(state, expand, dependencies) {
19
+ let nextState = state;
20
+ for (const neighbor of expand(state.current)) {
21
+ nextState = enqueueNeighbor(nextState, state.current, neighbor, dependencies);
22
+ }
23
+ const [current, ...pending] = nextState.pending;
24
+ return { current, pending, visited: nextState.visited };
25
+ }
26
+ function attemptIndexes(maximumAttempts) {
27
+ return Array.from({ length: maximumAttempts }, function (_value, index) {
28
+ return index;
29
+ });
30
+ }
31
+ function traverseUntilExhausted(state, expand, maximumAttempts, options) {
32
+ let traversalState = state;
33
+ let current = state.current;
34
+ let attemptsUsed = 0;
35
+ for (const attempt of attemptIndexes(maximumAttempts)) {
36
+ attemptsUsed = attempt + 1;
37
+ traversalState = visitCurrent({ current, pending: traversalState.pending, visited: traversalState.visited }, expand, options.dependencies);
38
+ if (traversalState.current === undefined) {
39
+ return new Set(traversalState.visited);
40
+ }
41
+ current = traversalState.current;
42
+ }
43
+ throw new Error(`Reachability traversal exceeded ${attemptsUsed} attempts`);
44
+ }
45
+ export function bfsClosure(seeds, expand, initialVisited, options) {
46
+ const seedList = Array.from(seeds);
47
+ const maximumAttempts = initialVisited.size + seedList.length + options.maximumNodeCount * options.maximumNodeCount;
48
+ const state = initialTraversalState(initialVisited, seedList);
49
+ if (state.current === undefined) {
50
+ return new Set(state.visited);
51
+ }
52
+ return traverseUntilExhausted({ ...state, current: state.current }, expand, maximumAttempts, options);
53
+ }
1
54
  //# sourceMappingURL=bfs-closure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bfs-closure.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/bfs-closure.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"bfs-closure.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/bfs-closure.ts"],"names":[],"mappings":"AAmBA,SAAS,qBAAqB,CAAI,cAA8B,EAAE,QAAsB;IACpF,MAAM,CAAE,OAAO,EAAE,GAAG,OAAO,CAAE,GAAG,QAAQ,CAAC;IACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,GAAG,CAAC,CAAE,GAAG,cAAc,EAAE,GAAG,QAAQ,CAAE,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,eAAe,CACpB,KAAwB,EACxB,OAAU,EACV,QAAW,EACX,YAAuC;IAEvC,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,YAAY,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAC3C,YAAY,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IACD,OAAO;QACH,OAAO,EAAE,KAAK,CAAC,OAAO;Q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,cAAc,CAAC,OAAO,EAAE,EAC7E,MAAM,EACN,OAAO,CAAC,YAAY,CACvB,CAAC;QACF,IAAI,cAAc,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACvC,OAAO,IAAI,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;IACrC,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,mCAAmC,YAAY,WAAW,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,UAAU,CACtB,KAAkB,EAClB,MAAmC,EACnC,cAA8B,EAC9B,OAA6B;IAE7B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACpH,MAAM,KAAK,GAAG,qBAAqB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAE9D,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,sBAAsB,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;AAC1G,CAAC"}
@@ -1,3 +1,101 @@
1
- import 'ts-morph';
2
- import "../variable-declaration-bindings.js";
1
+ import { Node as TsMorphNode } from 'ts-morph';
2
+ import { collectVariableDeclarationBindings } from "../variable-declaration-bindings.js";
3
+ function isNamedDeclaration(statement) {
4
+ return (TsMorphNode.isFunctionDeclaration(statement) ||
5
+ TsMorphNode.isClassDeclaration(statement) ||
6
+ TsMorphNode.isInterfaceDeclaration(statement) ||
7
+ TsMorphNode.isTypeAliasDeclaration(statement) ||
8
+ TsMorphNode.isEnumDeclaration(statement) ||
9
+ TsMorphNode.isModuleDeclaration(statement));
10
+ }
11
+ function bindingsFromNamedDeclaration(statement) {
12
+ const name = statement.getName();
13
+ if (name === undefined) {
14
+ return [];
15
+ }
16
+ const isExported = statement.isExported() || statement.isDefaultExport();
17
+ return [{ name, isExported, statement, declarationNode: statement, referenceNode: statement }];
18
+ }
19
+ function bindingsFromVariableStatement(statement) {
20
+ const isExported = statement.isExported();
21
+ return statement.getDeclarations().flatMap(function (declarator) {
22
+ return collectVariableDeclarationBindings(declarator).map(function (binding) {
23
+ return {
24
+ name: binding.name,
25
+ isExported,
26
+ statement,
27
+ declarationNode: binding.declarationNode,
28
+ referenceNode: binding.referenceNode
29
+ };
30
+ });
31
+ });
32
+ }
33
+ function localNameOfNamedImport(namedImport) {
34
+ return namedImport.getAliasNode()?.getText() ?? namedImport.getName();
35
+ }
36
+ function bindingsFromImportDeclaration(statement) {
37
+ const result = [];
38
+ const defaultImport = statement.getDefaultImport();
39
+ if (defaultImport !== undefined) {
40
+ result.push({
41
+ name: defaultImport.getText(),
42
+ isExported: false,
43
+ statement,
44
+ declarationNode: defaultImport.getParent(),
45
+ referenceNode: defaultImport.getParent()
46
+ });
47
+ }
48
+ const namespaceImport = statement.getNamespaceImport();
49
+ if (namespaceImport !== undefined) {
50
+ result.push({
51
+ name: namespaceImport.getText(),
52
+ isExported: false,
53
+ statement,
54
+ declarationNode: namespaceImport.getParent(),
55
+ referenceNode: namespaceImport.getParent()
56
+ });
57
+ }
58
+ for (const namedImport of statement.getNamedImports()) {
59
+ result.push({
60
+ name: localNameOfNamedImport(namedImport),
61
+ isExported: false,
62
+ statement,
63
+ declarationNode: namedImport,
64
+ referenceNode: namedImport
65
+ });
66
+ }
67
+ return result;
68
+ }
69
+ function bindingsFromExportAssignment(statement) {
70
+ if (statement.isExportEquals()) {
71
+ return [];
72
+ }
73
+ return [
74
+ {
75
+ name: 'default',
76
+ isExported: true,
77
+ statement,
78
+ declarationNode: statement,
79
+ referenceNode: statement
80
+ }
81
+ ];
82
+ }
83
+ function bindingsFromStatement(statement) {
84
+ if (isNamedDeclaration(statement)) {
85
+ return bindingsFromNamedDeclaration(statement);
86
+ }
87
+ if (TsMorphNode.isVariableStatement(statement)) {
88
+ return bindingsFromVariableStatement(statement);
89
+ }
90
+ if (TsMorphNode.isImportDeclaration(statement)) {
91
+ return bindingsFromImportDeclaration(statement);
92
+ }
93
+ if (TsMorphNode.isExportAssignment(statement)) {
94
+ return bindingsFromExportAssignment(statement);
95
+ }
96
+ return [];
97
+ }
98
+ export function extractTopLevelBindings(sourceFile) {
99
+ return sourceFile.getStatements().flatMap(bindingsFromStatement);
100
+ }
3
101
  //# sourceMappingURL=binding-extractor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding-extractor.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/binding-extractor.ts"],"names":[],"mappings":"AAAA,OAaO,UAAU,CAAC;AAClB,OAAmD,qCAAqC,CAAC"}
1
+ {"version":3,"file":"binding-extractor.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/binding-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,IAAI,WAAW,EAYtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AAazF,SAAS,kBAAkB,CAAC,SAAoB;IAC5C,OAAO,CACH,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC;QAC5C,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC;QACzC,WAAW,CAAC,sBAAsB,CAAC,SAAS,CAAC;QAC7C,WAAW,CAAC,sBAAsB,CAAC,SAAS,CAAC;QAC7C,WAAW,CAAC,iBAAiB,CAAC,SAAS,CAAC;QACxC,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAC7C,CAAC;AACN,CAAC;AAED,SAAS,4BAA4B,CAAC,SAAoC;IACtE,MA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AC,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7C,OAAO,6BAA6B,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,OAAO,4BAA4B,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,UAAgC;IACpE,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACrE,CAAC"}
@@ -1,2 +1,107 @@
1
- import "../../common/declaration-companion-paths.js";
1
+ import { declarationCompanionCandidates } from "../../common/declaration-companion-paths.js";
2
+ export function bindingId(filePath, name) {
3
+ return `${filePath}::${name}`;
4
+ }
5
+ function bindingIdsByFile(files) {
6
+ const result = new Map();
7
+ for (const file of files) {
8
+ result.set(file.targetFilePath, new Map(file.bindings.map(function (binding) {
9
+ return [binding.name, bindingId(file.targetFilePath, binding.name)];
10
+ })));
11
+ }
12
+ return result;
13
+ }
14
+ function companionBindingId(binding, file, idsByFile) {
15
+ for (const [targetFilePath, bindingIds] of idsByFile) {
16
+ if (declarationCompanionCandidates(targetFilePath).includes(file.targetFilePath)) {
17
+ return bindingIds.get(binding.name);
18
+ }
19
+ }
20
+ return undefined;
21
+ }
22
+ function declarationBindingIds(binding, file, idsByFile) {
23
+ const companionId = companionBindingId(binding, file, idsByFile);
24
+ return [
25
+ bindingId(file.targetFilePath, binding.name),
26
+ ...companionId === undefined ? [] : [companionId]
27
+ ];
28
+ }
29
+ function inputFilePathFromDeclaration(declarationNode) {
30
+ const node = declarationNode;
31
+ return node.getSourceFile?.().getFilePath();
32
+ }
33
+ function bindingIdsForFile(file, idsByFile) {
34
+ const idsByName = new Map();
35
+ const idsByNode = [];
36
+ for (const binding of file.bindings) {
37
+ const bindingIds = declarationBindingIds(binding, file, idsByFile);
38
+ idsByNode.push([binding.declarationNode, bindingIds]);
39
+ idsByName.set(binding.name, bindingIds);
40
+ }
41
+ return { idsByName, idsByNode };
42
+ }
43
+ function parsedDeclarationInputFilePaths(file) {
44
+ return file.bindings.flatMap(function (binding) {
45
+ const declarationInputFilePath = inputFilePathFromDeclaration(binding.declarationNode);
46
+ return declarationInputFilePath === undefined ? [] : [declarationInputFilePath];
47
+ });
48
+ }
49
+ function parsedPathsForTarget(file) {
50
+ return [
51
+ file.parsedInputFilePath,
52
+ ...parsedDeclarationInputFilePaths(file)
53
+ ];
54
+ }
55
+ export function buildDeclarationNodeIndex(files) {
56
+ const index = {
57
+ idsByNode: new Map(),
58
+ idsByFileAndName: new Map(),
59
+ idsByTargetFileAndName: new Map(),
60
+ moduleReferencesByTargetFilePath: new Map(),
61
+ targetFilePathByInputFilePath: new Map()
62
+ };
63
+ const idsByFile = bindingIdsByFile(files);
64
+ function addFilePathEntries(file, idsByName) {
65
+ index.idsByFileAndName.set(file.inputFilePath, idsByName);
66
+ index.idsByFileAndName.set(file.parsedInputFilePath, idsByName);
67
+ index.idsByFileAndName.set(file.targetFilePath, idsByName);
68
+ index.idsByTargetFileAndName.set(file.targetFilePath, idsByName);
69
+ index.moduleReferencesByTargetFilePath.set(file.targetFilePath, file.moduleReferences);
70
+ for (const parsedPath of parsedPathsForTarget(file)) {
71
+ index.idsByFileAndName.set(parsedPath, idsByName);
72
+ index.targetFilePathByInputFilePath.set(parsedPath, file.targetFilePath);
73
+ }
74
+ }
75
+ function addFileDeclarationIds(file) {
76
+ const { idsByName, idsByNode: nodeIds } = bindingIdsForFile(file, idsByFile);
77
+ for (const [node, bindingIds] of nodeIds) {
78
+ index.idsByNode.set(node, bindingIds);
79
+ }
80
+ addFilePathEntries(file, idsByName);
81
+ }
82
+ for (const file of files) {
83
+ addFileDeclarationIds(file);
84
+ }
85
+ return index;
86
+ }
87
+ export function buildBindingsByFile(files) {
88
+ const map = new Map();
89
+ for (const file of files) {
90
+ const ids = new Set();
91
+ for (const binding of file.bindings) {
92
+ ids.add(bindingId(file.targetFilePath, binding.name));
93
+ }
94
+ map.set(file.targetFilePath, ids);
95
+ }
96
+ return map;
97
+ }
98
+ export function buildNodeById(files) {
99
+ const map = new Map();
100
+ for (const file of files) {
101
+ for (const binding of file.bindings) {
102
+ map.set(bindingId(file.targetFilePath, binding.name), binding.referenceNode);
103
+ }
104
+ }
105
+ return map;
106
+ }
2
107
  //# sourceMappingURL=binding-id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding-id.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/binding-id.ts"],"names":[],"mappings":"AACA,OAA+C,6CAA6C,CAAC"}
1
+ {"version":3,"file":"binding-id.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/binding-id.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AA2B7F,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAY;IACpD,OAAO,GAAG,QAAQ,KAAK,IAAI,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAgC;IACtD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAC;IACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CACN,IAAI,CAAC,cAAc,EACnB,IAAI,GAAG,CACH,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,OAAO;YAC/B,OAAO,CAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAE,CAAC;QAC1E,CAAC,CAAC,CACL,CACJ,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,kBAAkB,CACvB,OAA0B,EAC1B,IAAoB,EACpB,SAAgD;IAEhD,KAAK,MAAM,CAAE,cAAc,EAAE,UAAU,CAAE,IAAI,S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