@cornerstonejs/codemods 5.19.4 → 6.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/README.md +23 -0
  2. package/package.json +2 -2
  3. package/registry/cornerstone3d/6/README.md +87 -0
  4. package/registry/cornerstone3d/6/classes-and-types/README.md +113 -0
  5. package/registry/cornerstone3d/6/classes-and-types/codemod.yaml +20 -0
  6. package/registry/cornerstone3d/6/classes-and-types/scripts/classes-and-types.ts +1461 -0
  7. package/registry/cornerstone3d/6/classes-and-types/scripts/lib.ts +2386 -0
  8. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/edge-namespace-and-reported/expected.tsx +27 -0
  9. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/edge-namespace-and-reported/input.tsx +27 -0
  10. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/edge-namespace-and-reported/metrics.json +36 -0
  11. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/edge-already-6/expected.ts +15 -0
  12. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/edge-already-6/input.ts +15 -0
  13. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/negative-other-packages/expected.ts +11 -0
  14. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/negative-other-packages/input.ts +11 -0
  15. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-3d-family-of-predicate-or-cast-object/expected.ts +55 -0
  16. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-3d-family-of-predicate-or-cast-object/input.ts +51 -0
  17. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-3d-family-of-predicate-or-cast-object/metrics.json +36 -0
  18. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-types-from-the-types-subpath/expected.ts +26 -0
  19. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-types-from-the-types-subpath/input.ts +26 -0
  20. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-types-from-the-types-subpath/metrics.json +52 -0
  21. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-3d-evidence/expected.ts +34 -0
  22. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-3d-evidence/input.ts +30 -0
  23. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-3d-evidence/metrics.json +12 -0
  24. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/expected.ts +35 -0
  25. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/input.ts +35 -0
  26. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/metrics.json +28 -0
  27. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-types-and-casts/expected.ts +46 -0
  28. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-types-and-casts/input.ts +42 -0
  29. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-class-import-cleanup-orphans-shorthand/expected.ts +4 -0
  30. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-class-import-cleanup-orphans-shorthand/input.ts +4 -0
  31. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-class-import-cleanup-orphans-shorthand/metrics.json +12 -0
  32. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-check-can-prevent-the-first-mount/expected.ts +24 -0
  33. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-check-can-prevent-the-first-mount/input.ts +25 -0
  34. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-check-can-prevent-the-first-mount/metrics.json +38 -0
  35. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-replacement-inverts-comparison/expected.ts +11 -0
  36. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-replacement-inverts-comparison/input.ts +11 -0
  37. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-replacement-inverts-comparison/metrics.json +20 -0
  38. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-negative-3d-test-taken-as-3d-viewport/expected.ts +29 -0
  39. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-negative-3d-test-taken-as-3d-viewport/input.ts +29 -0
  40. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-negative-3d-test-taken-as-3d-viewport/metrics.json +20 -0
  41. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-re-exports-of-removed-classes/expected.ts +6 -0
  42. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-re-exports-of-removed-classes/input.ts +6 -0
  43. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-re-exports-of-removed-classes/metrics.json +20 -0
  44. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-type-only-namespace-used-as-value/expected.ts +8 -0
  45. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-type-only-namespace-used-as-value/input.ts +8 -0
  46. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-type-only-namespace-used-as-value/metrics.json +12 -0
  47. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-instanceof-mount-proof-crosses-shadowed-binding/expected.ts +19 -0
  48. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-instanceof-mount-proof-crosses-shadowed-binding/input.ts +19 -0
  49. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-instanceof-mount-proof-crosses-shadowed-binding/metrics.json +22 -0
  50. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-unrelated-discriminator-taken-as-3d-proof/expected.ts +40 -0
  51. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-unrelated-discriminator-taken-as-3d-proof/input.ts +40 -0
  52. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-unrelated-discriminator-taken-as-3d-proof/metrics.json +28 -0
  53. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review3-conditional-viewport-type-taken-as-3d/expected.ts +39 -0
  54. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review3-conditional-viewport-type-taken-as-3d/input.ts +38 -0
  55. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review3-conditional-viewport-type-taken-as-3d/metrics.json +20 -0
  56. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-spread-or-computed-key-overrides-viewport-type/expected.ts +76 -0
  57. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-spread-or-computed-key-overrides-viewport-type/input.ts +75 -0
  58. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-spread-or-computed-key-overrides-viewport-type/metrics.json +36 -0
  59. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-viewport-family-proved-on-another-engine/expected.ts +92 -0
  60. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-viewport-family-proved-on-another-engine/input.ts +91 -0
  61. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-viewport-family-proved-on-another-engine/metrics.json +20 -0
  62. package/registry/cornerstone3d/6/classes-and-types/workflow.yaml +29 -0
  63. package/registry/cornerstone3d/6/codemod.yaml +19 -0
  64. package/registry/cornerstone3d/6/display-sets/README.md +173 -0
  65. package/registry/cornerstone3d/6/display-sets/codemod.yaml +20 -0
  66. package/registry/cornerstone3d/6/display-sets/scripts/display-sets.ts +965 -0
  67. package/registry/cornerstone3d/6/display-sets/scripts/lib.ts +2386 -0
  68. package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes/expected.tsx +32 -0
  69. package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes/input.tsx +32 -0
  70. package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes/metrics.json +84 -0
  71. package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes-on-a-typed-engine/expected.tsx +33 -0
  72. package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes-on-a-typed-engine/input.tsx +33 -0
  73. package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes-on-a-typed-engine/metrics.json +84 -0
  74. package/registry/cornerstone3d/6/display-sets/tests/tsx/positive-javascript/expected.js +23 -0
  75. package/registry/cornerstone3d/6/display-sets/tests/tsx/positive-javascript/input.js +17 -0
  76. package/registry/cornerstone3d/6/display-sets/tests/tsx/review-commonjs-module-gets-es-import/expected.js +10 -0
  77. package/registry/cornerstone3d/6/display-sets/tests/tsx/review-commonjs-module-gets-es-import/input.js +10 -0
  78. package/registry/cornerstone3d/6/display-sets/tests/tsx/review-commonjs-module-gets-es-import/metrics.json +12 -0
  79. package/registry/cornerstone3d/6/display-sets/tests/typescript/negative-already-6/expected.ts +20 -0
  80. package/registry/cornerstone3d/6/display-sets/tests/typescript/negative-already-6/input.ts +20 -0
  81. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-set-volumes-for-viewports/expected.ts +27 -0
  82. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-set-volumes-for-viewports/input.ts +27 -0
  83. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-set-volumes-for-viewports/metrics.json +12 -0
  84. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-stack-and-volume/expected.ts +37 -0
  85. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-stack-and-volume/input.ts +31 -0
  86. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-stack-and-volume/metrics.json +20 -0
  87. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-video-and-ecg/expected.ts +15 -0
  88. package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-video-and-ecg/input.ts +15 -0
  89. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-mount-breaks-control-flow/expected.ts +26 -0
  90. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-mount-breaks-control-flow/input.ts +18 -0
  91. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-mount-breaks-control-flow/metrics.json +20 -0
  92. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-viewport-lists-and-callback-capture/expected.ts +46 -0
  93. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-viewport-lists-and-callback-capture/input.ts +21 -0
  94. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-generated-references-resolve-to-shadowing-parameter/expected.ts +23 -0
  95. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-generated-references-resolve-to-shadowing-parameter/input.ts +13 -0
  96. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-optional-mounts-become-unconditional/expected.ts +11 -0
  97. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-optional-mounts-become-unconditional/input.ts +11 -0
  98. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-optional-mounts-become-unconditional/metrics.json +28 -0
  99. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-regenerated-import-drops-comments/expected.ts +22 -0
  100. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-regenerated-import-drops-comments/input.ts +15 -0
  101. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-stack-display-set-id-reused-across-series/expected.ts +41 -0
  102. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-stack-display-set-id-reused-across-series/input.ts +16 -0
  103. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/expected.ts +11 -0
  104. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/input.ts +11 -0
  105. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/metrics.json +20 -0
  106. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-helper-binding-still-used/expected.ts +46 -0
  107. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-helper-binding-still-used/input.ts +17 -0
  108. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-helper-binding-still-used/metrics.json +20 -0
  109. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-registration-references-image-list-outside-block/expected.ts +16 -0
  110. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-registration-references-image-list-outside-block/input.ts +16 -0
  111. package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-registration-references-image-list-outside-block/metrics.json +12 -0
  112. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-bracketed-and-re-exported-data-names/expected.ts +19 -0
  113. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-bracketed-and-re-exported-data-names/input.ts +19 -0
  114. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-bracketed-and-re-exported-data-names/metrics.json +44 -0
  115. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-generic-container-taken-as-viewport/expected.ts +22 -0
  116. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-generic-container-taken-as-viewport/input.ts +22 -0
  117. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-generic-container-taken-as-viewport/metrics.json +36 -0
  118. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-image-list-getter-read-twice/expected.ts +62 -0
  119. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-image-list-getter-read-twice/input.ts +28 -0
  120. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-missing-target-partly-updates-layout/expected.ts +50 -0
  121. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-missing-target-partly-updates-layout/input.ts +25 -0
  122. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-missing-target-partly-updates-layout/metrics.json +12 -0
  123. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-reassigned-receiver-keeps-initializer-evidence/expected.ts +45 -0
  124. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-reassigned-receiver-keeps-initializer-evidence/input.ts +39 -0
  125. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-reassigned-receiver-keeps-initializer-evidence/metrics.json +36 -0
  126. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-stack-ids-collide-across-engines/expected.ts +24 -0
  127. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-stack-ids-collide-across-engines/input.ts +12 -0
  128. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-volume-registration-attaches-another-series/expected.ts +47 -0
  129. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-volume-registration-attaches-another-series/input.ts +42 -0
  130. package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-volume-registration-attaches-another-series/metrics.json +28 -0
  131. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-computed-option-key-overrides-image-ids/expected.ts +18 -0
  132. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-computed-option-key-overrides-image-ids/input.ts +18 -0
  133. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-computed-option-key-overrides-image-ids/metrics.json +12 -0
  134. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-loop-increment-taken-as-volume-creation/expected.ts +18 -0
  135. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-loop-increment-taken-as-volume-creation/input.ts +18 -0
  136. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-loop-increment-taken-as-volume-creation/metrics.json +12 -0
  137. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-mixed-family-targets-partly-update-layout/expected.ts +42 -0
  138. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-mixed-family-targets-partly-update-layout/input.ts +18 -0
  139. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-ecg-mount-empty-after-the-call/expected.ts +18 -0
  140. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-ecg-mount-empty-after-the-call/input.ts +18 -0
  141. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-ecg-mount-empty-after-the-call/metrics.json +20 -0
  142. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-helper-blocks-async-function/expected.ts +18 -0
  143. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-helper-blocks-async-function/input.ts +18 -0
  144. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-helper-blocks-async-function/metrics.json +12 -0
  145. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-stack-mount-blocks-async-function/expected.ts +19 -0
  146. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-stack-mount-blocks-async-function/input.ts +19 -0
  147. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-stack-mount-blocks-async-function/metrics.json +20 -0
  148. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-video-mount-empty-after-the-call/expected.ts +18 -0
  149. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-video-mount-empty-after-the-call/input.ts +18 -0
  150. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-video-mount-empty-after-the-call/metrics.json +20 -0
  151. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-volume-mount-blocks-async-function/expected.ts +23 -0
  152. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-volume-mount-blocks-async-function/input.ts +23 -0
  153. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-volume-mount-blocks-async-function/metrics.json +20 -0
  154. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-viewport-getter-read-three-times/expected.ts +34 -0
  155. package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-viewport-getter-read-three-times/input.ts +19 -0
  156. package/registry/cornerstone3d/6/display-sets/tests/typescript/review4-argument-getter-redirects-stack-mount/expected.ts +80 -0
  157. package/registry/cornerstone3d/6/display-sets/tests/typescript/review4-argument-getter-redirects-stack-mount/input.ts +50 -0
  158. package/registry/cornerstone3d/6/display-sets/workflow.yaml +29 -0
  159. package/registry/cornerstone3d/6/events/README.md +65 -0
  160. package/registry/cornerstone3d/6/events/codemod.yaml +20 -0
  161. package/registry/cornerstone3d/6/events/scripts/events.ts +442 -0
  162. package/registry/cornerstone3d/6/events/scripts/lib.ts +2386 -0
  163. package/registry/cornerstone3d/6/events/tests/tsx/edge-reported-and-conflicts/expected.tsx +18 -0
  164. package/registry/cornerstone3d/6/events/tests/tsx/edge-reported-and-conflicts/input.tsx +18 -0
  165. package/registry/cornerstone3d/6/events/tests/tsx/edge-reported-and-conflicts/metrics.json +46 -0
  166. package/registry/cornerstone3d/6/events/tests/typescript/negative-other-events/expected.ts +10 -0
  167. package/registry/cornerstone3d/6/events/tests/typescript/negative-other-events/input.ts +10 -0
  168. package/registry/cornerstone3d/6/events/tests/typescript/ohif-core-events-export/expected.ts +22 -0
  169. package/registry/cornerstone3d/6/events/tests/typescript/ohif-core-events-export/input.ts +22 -0
  170. package/registry/cornerstone3d/6/events/tests/typescript/ohif-core-events-export/metrics.json +54 -0
  171. package/registry/cornerstone3d/6/events/tests/typescript/positive-destructured/expected.ts +20 -0
  172. package/registry/cornerstone3d/6/events/tests/typescript/positive-destructured/input.ts +20 -0
  173. package/registry/cornerstone3d/6/events/tests/typescript/positive-destructured/metrics.json +12 -0
  174. package/registry/cornerstone3d/6/events/tests/typescript/positive-members/expected.ts +16 -0
  175. package/registry/cornerstone3d/6/events/tests/typescript/positive-members/input.ts +16 -0
  176. package/registry/cornerstone3d/6/events/tests/typescript/positive-members/metrics.json +52 -0
  177. package/registry/cornerstone3d/6/events/tests/typescript/review-aliased-event-destructuring-left-silently/expected.ts +5 -0
  178. package/registry/cornerstone3d/6/events/tests/typescript/review-aliased-event-destructuring-left-silently/input.ts +5 -0
  179. package/registry/cornerstone3d/6/events/tests/typescript/review-aliased-event-destructuring-left-silently/metrics.json +12 -0
  180. package/registry/cornerstone3d/6/events/tests/typescript/review-event-destructuring-introduces-undeclared-name/expected.ts +9 -0
  181. package/registry/cornerstone3d/6/events/tests/typescript/review-event-destructuring-introduces-undeclared-name/input.ts +10 -0
  182. package/registry/cornerstone3d/6/events/tests/typescript/review-event-destructuring-introduces-undeclared-name/metrics.json +20 -0
  183. package/registry/cornerstone3d/6/events/tests/typescript/review-removed-event-strings-not-reported/expected.ts +11 -0
  184. package/registry/cornerstone3d/6/events/tests/typescript/review-removed-event-strings-not-reported/input.ts +11 -0
  185. package/registry/cornerstone3d/6/events/tests/typescript/review-removed-event-strings-not-reported/metrics.json +28 -0
  186. package/registry/cornerstone3d/6/events/tests/typescript/review2-quoted-defaulted-and-bracketed-event-keys/expected.ts +15 -0
  187. package/registry/cornerstone3d/6/events/tests/typescript/review2-quoted-defaulted-and-bracketed-event-keys/input.ts +15 -0
  188. package/registry/cornerstone3d/6/events/tests/typescript/review2-quoted-defaulted-and-bracketed-event-keys/metrics.json +62 -0
  189. package/registry/cornerstone3d/6/events/workflow.yaml +29 -0
  190. package/registry/cornerstone3d/6/settings/README.md +69 -0
  191. package/registry/cornerstone3d/6/settings/codemod.yaml +20 -0
  192. package/registry/cornerstone3d/6/settings/scripts/lib.ts +2386 -0
  193. package/registry/cornerstone3d/6/settings/scripts/settings.ts +647 -0
  194. package/registry/cornerstone3d/6/settings/tests/tsx/edge-namespace-and-reported/expected.tsx +18 -0
  195. package/registry/cornerstone3d/6/settings/tests/tsx/edge-namespace-and-reported/input.tsx +18 -0
  196. package/registry/cornerstone3d/6/settings/tests/tsx/edge-namespace-and-reported/metrics.json +46 -0
  197. package/registry/cornerstone3d/6/settings/tests/typescript/negative-other-names/expected.ts +18 -0
  198. package/registry/cornerstone3d/6/settings/tests/typescript/negative-other-names/input.ts +18 -0
  199. package/registry/cornerstone3d/6/settings/tests/typescript/positive-configuration/expected.ts +27 -0
  200. package/registry/cornerstone3d/6/settings/tests/typescript/positive-configuration/input.ts +28 -0
  201. package/registry/cornerstone3d/6/settings/tests/typescript/positive-configuration/metrics.json +46 -0
  202. package/registry/cornerstone3d/6/settings/tests/typescript/positive-functions/expected.ts +32 -0
  203. package/registry/cornerstone3d/6/settings/tests/typescript/positive-functions/input.ts +33 -0
  204. package/registry/cornerstone3d/6/settings/tests/typescript/positive-functions/metrics.json +36 -0
  205. package/registry/cornerstone3d/6/settings/tests/typescript/review-aliased-setting-imports-removed-while-used/expected.ts +10 -0
  206. package/registry/cornerstone3d/6/settings/tests/typescript/review-aliased-setting-imports-removed-while-used/input.ts +9 -0
  207. package/registry/cornerstone3d/6/settings/tests/typescript/review-aliased-setting-imports-removed-while-used/metrics.json +22 -0
  208. package/registry/cornerstone3d/6/settings/tests/typescript/review-generated-references-resolve-to-shadowing-locals/expected.ts +12 -0
  209. package/registry/cornerstone3d/6/settings/tests/typescript/review-generated-references-resolve-to-shadowing-locals/input.ts +12 -0
  210. package/registry/cornerstone3d/6/settings/tests/typescript/review-import-name-collision-calls-undefined/expected.ts +9 -0
  211. package/registry/cornerstone3d/6/settings/tests/typescript/review-import-name-collision-calls-undefined/input.ts +9 -0
  212. package/registry/cornerstone3d/6/settings/tests/typescript/review-import-name-collision-calls-undefined/metrics.json +12 -0
  213. package/registry/cornerstone3d/6/settings/tests/typescript/review-settings-deletes-unrelated-configuration/expected.ts +12 -0
  214. package/registry/cornerstone3d/6/settings/tests/typescript/review-settings-deletes-unrelated-configuration/input.ts +12 -0
  215. package/registry/cornerstone3d/6/settings/tests/typescript/review-settings-deletes-unrelated-configuration/metrics.json +28 -0
  216. package/registry/cornerstone3d/6/settings/tests/typescript/review2-adjacent-obsolete-settings/expected.ts +24 -0
  217. package/registry/cornerstone3d/6/settings/tests/typescript/review2-adjacent-obsolete-settings/input.ts +29 -0
  218. package/registry/cornerstone3d/6/settings/tests/typescript/review2-adjacent-obsolete-settings/metrics.json +12 -0
  219. package/registry/cornerstone3d/6/settings/tests/typescript/review2-nested-cpu-getter-in-rewritten-setting/expected.ts +3 -0
  220. package/registry/cornerstone3d/6/settings/tests/typescript/review2-nested-cpu-getter-in-rewritten-setting/input.ts +3 -0
  221. package/registry/cornerstone3d/6/settings/tests/typescript/review2-nested-cpu-getter-in-rewritten-setting/metrics.json +12 -0
  222. package/registry/cornerstone3d/6/settings/tests/typescript/review2-re-exported-setting-names/expected.ts +1 -0
  223. package/registry/cornerstone3d/6/settings/tests/typescript/review2-re-exported-setting-names/input.ts +1 -0
  224. package/registry/cornerstone3d/6/settings/tests/typescript/review2-re-exported-setting-names/metrics.json +20 -0
  225. package/registry/cornerstone3d/6/settings/tests/typescript/review2-spread-boolean-tuple/expected.ts +6 -0
  226. package/registry/cornerstone3d/6/settings/tests/typescript/review2-spread-boolean-tuple/input.ts +6 -0
  227. package/registry/cornerstone3d/6/settings/tests/typescript/review2-spread-boolean-tuple/metrics.json +22 -0
  228. package/registry/cornerstone3d/6/settings/tests/typescript/review3-shorthand-cpu-setting/expected.ts +13 -0
  229. package/registry/cornerstone3d/6/settings/tests/typescript/review3-shorthand-cpu-setting/input.ts +13 -0
  230. package/registry/cornerstone3d/6/settings/tests/typescript/review3-shorthand-cpu-setting/metrics.json +12 -0
  231. package/registry/cornerstone3d/6/settings/workflow.yaml +29 -0
  232. package/registry/cornerstone3d/6/tools/README.md +59 -0
  233. package/registry/cornerstone3d/6/tools/codemod.yaml +20 -0
  234. package/registry/cornerstone3d/6/tools/scripts/lib.ts +2386 -0
  235. package/registry/cornerstone3d/6/tools/scripts/tools.ts +517 -0
  236. package/registry/cornerstone3d/6/tools/tests/tsx/edge-removed-names/expected.tsx +36 -0
  237. package/registry/cornerstone3d/6/tools/tests/tsx/edge-removed-names/input.tsx +36 -0
  238. package/registry/cornerstone3d/6/tools/tests/tsx/edge-removed-names/metrics.json +60 -0
  239. package/registry/cornerstone3d/6/tools/tests/typescript/negative-other-modules/expected.ts +13 -0
  240. package/registry/cornerstone3d/6/tools/tests/typescript/negative-other-modules/input.ts +13 -0
  241. package/registry/cornerstone3d/6/tools/tests/typescript/positive-moved-modules/expected.ts +11 -0
  242. package/registry/cornerstone3d/6/tools/tests/typescript/positive-moved-modules/input.ts +11 -0
  243. package/registry/cornerstone3d/6/tools/tests/typescript/positive-viewport-capabilities-to-core/expected.ts +13 -0
  244. package/registry/cornerstone3d/6/tools/tests/typescript/positive-viewport-capabilities-to-core/input.ts +13 -0
  245. package/registry/cornerstone3d/6/tools/tests/typescript/review-moved-import-collides-with-local/expected.ts +7 -0
  246. package/registry/cornerstone3d/6/tools/tests/typescript/review-moved-import-collides-with-local/input.ts +7 -0
  247. package/registry/cornerstone3d/6/tools/tests/typescript/review-viewport-capabilities-not-plain/expected.ts +26 -0
  248. package/registry/cornerstone3d/6/tools/tests/typescript/review-viewport-capabilities-not-plain/input.ts +26 -0
  249. package/registry/cornerstone3d/6/tools/tests/typescript/review-viewport-capabilities-not-plain/metrics.json +60 -0
  250. package/registry/cornerstone3d/6/tools/tests/typescript/review2-barrel-re-export-of-moved-module/expected.ts +6 -0
  251. package/registry/cornerstone3d/6/tools/tests/typescript/review2-barrel-re-export-of-moved-module/input.ts +6 -0
  252. package/registry/cornerstone3d/6/tools/tests/typescript/review2-barrel-re-export-of-moved-module/metrics.json +28 -0
  253. package/registry/cornerstone3d/6/tools/tests/typescript/review3-side-effect-and-empty-imports-of-deleted-module/expected.ts +12 -0
  254. package/registry/cornerstone3d/6/tools/tests/typescript/review3-side-effect-and-empty-imports-of-deleted-module/input.ts +12 -0
  255. package/registry/cornerstone3d/6/tools/tests/typescript/review3-side-effect-and-empty-imports-of-deleted-module/metrics.json +36 -0
  256. package/registry/cornerstone3d/6/tools/workflow.yaml +29 -0
  257. package/registry/cornerstone3d/6/viewport-members/README.md +101 -0
  258. package/registry/cornerstone3d/6/viewport-members/codemod.yaml +20 -0
  259. package/registry/cornerstone3d/6/viewport-members/scripts/lib.ts +2386 -0
  260. package/registry/cornerstone3d/6/viewport-members/scripts/viewport-members.ts +815 -0
  261. package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members/expected.tsx +31 -0
  262. package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members/input.tsx +31 -0
  263. package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members/metrics.json +100 -0
  264. package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members-on-a-typed-viewport/expected.tsx +31 -0
  265. package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members-on-a-typed-viewport/input.tsx +31 -0
  266. package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members-on-a-typed-viewport/metrics.json +100 -0
  267. package/registry/cornerstone3d/6/viewport-members/tests/typescript/negative-other-receivers/expected.ts +24 -0
  268. package/registry/cornerstone3d/6/viewport-members/tests/typescript/negative-other-receivers/input.ts +24 -0
  269. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-3d-presentation/expected.ts +11 -0
  270. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-3d-presentation/input.ts +11 -0
  271. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-3d-presentation/metrics.json +28 -0
  272. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-engine-render-frame-of-reference/expected.ts +16 -0
  273. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-engine-render-frame-of-reference/input.ts +16 -0
  274. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-engine-render-frame-of-reference/metrics.json +28 -0
  275. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-presentation-and-view/expected.ts +31 -0
  276. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-presentation-and-view/input.ts +31 -0
  277. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-questions-and-actors/expected.ts +31 -0
  278. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-questions-and-actors/input.ts +26 -0
  279. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-questions-and-actors/metrics.json +22 -0
  280. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-video-and-ecg/expected.ts +15 -0
  281. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-video-and-ecg/input.ts +15 -0
  282. package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-video-and-ecg/metrics.json +28 -0
  283. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-generated-imports-invalidate-file-directives/expected.ts +5 -0
  284. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-generated-imports-invalidate-file-directives/input.ts +5 -0
  285. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-generated-imports-invalidate-file-directives/metrics.json +12 -0
  286. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-quoted-presentation-key-loses-effect/expected.ts +12 -0
  287. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-quoted-presentation-key-loses-effect/input.ts +12 -0
  288. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-quoted-presentation-key-loses-effect/metrics.json +12 -0
  289. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-slice-index-rewrite-mishandles-references/expected.ts +12 -0
  290. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-slice-index-rewrite-mishandles-references/input.ts +12 -0
  291. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-slice-index-rewrite-mishandles-references/metrics.json +20 -0
  292. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/expected.ts +9 -0
  293. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/input.ts +9 -0
  294. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/metrics.json +20 -0
  295. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-bracket-access-hides-removed-methods/expected.ts +11 -0
  296. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-bracket-access-hides-removed-methods/input.ts +11 -0
  297. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-bracket-access-hides-removed-methods/metrics.json +36 -0
  298. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-re-exported-core-helpers/expected.ts +5 -0
  299. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-re-exported-core-helpers/input.ts +5 -0
  300. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-re-exported-core-helpers/metrics.json +20 -0
  301. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review3-conditional-mount-drops-presentation/expected.ts +58 -0
  302. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review3-conditional-mount-drops-presentation/input.ts +58 -0
  303. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review3-conditional-mount-drops-presentation/metrics.json +20 -0
  304. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review4-strict-bounds-and-actor-volume-ids/expected.ts +16 -0
  305. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review4-strict-bounds-and-actor-volume-ids/input.ts +16 -0
  306. package/registry/cornerstone3d/6/viewport-members/tests/typescript/review4-strict-bounds-and-actor-volume-ids/metrics.json +12 -0
  307. package/registry/cornerstone3d/6/viewport-members/workflow.yaml +29 -0
  308. package/registry/cornerstone3d/6/viewport-types/README.md +73 -0
  309. package/registry/cornerstone3d/6/viewport-types/codemod.yaml +20 -0
  310. package/registry/cornerstone3d/6/viewport-types/scripts/lib.ts +2386 -0
  311. package/registry/cornerstone3d/6/viewport-types/scripts/viewport-types.ts +714 -0
  312. package/registry/cornerstone3d/6/viewport-types/tests/tsx/edge-reported-sites/expected.tsx +57 -0
  313. package/registry/cornerstone3d/6/viewport-types/tests/tsx/edge-reported-sites/input.tsx +57 -0
  314. package/registry/cornerstone3d/6/viewport-types/tests/tsx/edge-reported-sites/metrics.json +70 -0
  315. package/registry/cornerstone3d/6/viewport-types/tests/typescript/edge-already-6/expected.ts +25 -0
  316. package/registry/cornerstone3d/6/viewport-types/tests/typescript/edge-already-6/input.ts +25 -0
  317. package/registry/cornerstone3d/6/viewport-types/tests/typescript/negative-other-names/expected.ts +22 -0
  318. package/registry/cornerstone3d/6/viewport-types/tests/typescript/negative-other-names/input.ts +22 -0
  319. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-destructured-viewport-type/expected.ts +68 -0
  320. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-destructured-viewport-type/input.ts +65 -0
  321. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-destructured-viewport-type/metrics.json +46 -0
  322. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-namespaced-and-aliased/expected.ts +20 -0
  323. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-namespaced-and-aliased/input.ts +19 -0
  324. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-namespaced-and-aliased/metrics.json +12 -0
  325. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-strings/expected.ts +25 -0
  326. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-strings/input.ts +24 -0
  327. package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-strings/metrics.json +22 -0
  328. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-destructured-viewport-type-members/expected.ts +19 -0
  329. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-destructured-viewport-type-members/input.ts +19 -0
  330. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-destructured-viewport-type-members/metrics.json +12 -0
  331. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-type-check-can-prevent-the-first-mount/expected.ts +27 -0
  332. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-type-check-can-prevent-the-first-mount/input.ts +27 -0
  333. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-type-check-can-prevent-the-first-mount/metrics.json +28 -0
  334. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/expected.ts +9 -0
  335. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/input.ts +9 -0
  336. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/metrics.json +20 -0
  337. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-type-pass-changes-unrelated-discriminators/expected.ts +18 -0
  338. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-type-pass-changes-unrelated-discriminators/input.ts +18 -0
  339. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-type-pass-changes-unrelated-discriminators/metrics.json +30 -0
  340. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-mount-proof-crosses-shadowed-binding/expected.ts +42 -0
  341. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-mount-proof-crosses-shadowed-binding/input.ts +42 -0
  342. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-mount-proof-crosses-shadowed-binding/metrics.json +36 -0
  343. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-quoted-defaulted-and-bracketed-viewport-type-keys/expected.ts +10 -0
  344. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-quoted-defaulted-and-bracketed-viewport-type-keys/input.ts +10 -0
  345. package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-quoted-defaulted-and-bracketed-viewport-type-keys/metrics.json +36 -0
  346. package/registry/cornerstone3d/6/viewport-types/workflow.yaml +29 -0
  347. package/registry/cornerstone3d/6/workflow.yaml +26 -0
  348. package/scripts/test-registry-packages.mjs +86 -0
  349. package/scripts/validate-registry-packages.mjs +43 -2
@@ -0,0 +1,517 @@
1
+ import type { Codemod, SgRoot } from 'codemod:ast-grep';
2
+ import type TSX from 'codemod:ast-grep/langs/tsx';
3
+ import { useMetricAtom } from 'codemod:metrics';
4
+ import {
5
+ EditSet,
6
+ importSource,
7
+ isNameTaken,
8
+ referencesOf,
9
+ site,
10
+ } from './lib.ts';
11
+ import type { Node } from './lib.ts';
12
+
13
+ /** Sites that the reader changes. */
14
+ const manual = useMetricAtom('cornerstone3d-6-manual');
15
+
16
+ /** The package of the tools. */
17
+ const TOOLS_PACKAGE = '@cornerstonejs/tools';
18
+
19
+ /** The modules of the tools that 6.0 moves, with the names each keeps. */
20
+ const MOVED_MODULES: Record<
21
+ string,
22
+ { path: string; names: Record<string, string> }
23
+ > = {
24
+ [`${TOOLS_PACKAGE}/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan`]:
25
+ {
26
+ path: `${TOOLS_PACKAGE}/tools/displayTools/Labelmap/labelmapRenderPlan/volumeLabelmapPlan`,
27
+ names: { createLegacyVolumeLabelmapPlan: 'createVolumeLabelmapPlan' },
28
+ },
29
+ [`${TOOLS_PACKAGE}/segmentation/labelmapModel/labelmapLegacyAdapter`]: {
30
+ path: `${TOOLS_PACKAGE}/segmentation/labelmapModel/labelmapPrimaryLayerFields`,
31
+ names: {
32
+ syncLegacyLabelmapData: 'syncLegacyLabelmapData',
33
+ getReferencedImageIdToCurrentImageIdMap:
34
+ 'getReferencedImageIdToCurrentImageIdMap',
35
+ },
36
+ },
37
+ };
38
+
39
+ /** The modules of the tools whose names 6.0 removes; `*` for the whole module. */
40
+ const REMOVED_NAMES: Record<string, string[] | '*'> = {
41
+ [`${TOOLS_PACKAGE}/tools/displayTools/Labelmap/addVolumesAsIndependentComponents`]:
42
+ '*',
43
+ [`${TOOLS_PACKAGE}/tools/displayTools/Labelmap/volumeLabelmapImageMapper`]: [
44
+ 'removeVolumeLabelmapImageMapperActors',
45
+ ],
46
+ [`${TOOLS_PACKAGE}/utilities/genericViewportToolHelpers`]: [
47
+ 'getSlabThicknessOrDefault',
48
+ ],
49
+ [`${TOOLS_PACKAGE}/utilities/viewportCapabilities`]: [
50
+ 'viewportSupportsStackCompatibility',
51
+ 'StackCompatibilityViewport',
52
+ ],
53
+ [`${TOOLS_PACKAGE}/utilities/spatial/rotateViewportAroundWorldPoint`]: '*',
54
+ };
55
+
56
+ /** The module of the tools that 6.0 deletes; the core exports two of its checks. */
57
+ const CAPABILITIES_MODULE = `${TOOLS_PACKAGE}/utilities/viewportCapabilities`;
58
+
59
+ /** The entry point of the core that exports those checks by the same names. */
60
+ const CORE_UTILITIES_MODULE = '@cornerstonejs/core/utilities';
61
+
62
+ /** The checks of the deleted module that the core exports. */
63
+ const CORE_CHECKS = [
64
+ 'viewportSupportsImageSlices',
65
+ 'viewportSupportsStackCalibration',
66
+ ];
67
+
68
+ /**
69
+ * The state of one run of the transform on a file.
70
+ */
71
+ interface Run {
72
+ root: SgRoot<TSX>;
73
+ rootNode: Node;
74
+ edits: EditSet;
75
+ }
76
+
77
+ /**
78
+ * Returns the named specifiers of an import statement, or undefined when it
79
+ * has a default or a namespace import.
80
+ */
81
+ function namedSpecifiers(statement: Node): Node[] | undefined {
82
+ const clause = statement
83
+ .children()
84
+ .find((child) => child.kind() === 'import_clause');
85
+
86
+ if (!clause) {
87
+ return [];
88
+ }
89
+
90
+ if (clause.children().some((child) => child.kind() !== 'named_imports')) {
91
+ return undefined;
92
+ }
93
+
94
+ return clause.findAll({ rule: { kind: 'import_specifier' } });
95
+ }
96
+
97
+ /**
98
+ * Moves an import of a module of the tools to its 6.0 path, with its names
99
+ * and their uses. A renamed name keeps its old local name through `as` when
100
+ * the new name is taken in the file or a use is not a plain name, such as a
101
+ * shorthand property. Reports a statement with a name the move does not
102
+ * know.
103
+ */
104
+ function moveImport(
105
+ run: Run,
106
+ statement: Node,
107
+ move: { path: string; names: Record<string, string> }
108
+ ): void {
109
+ const specifiers = namedSpecifiers(statement);
110
+ const unknown = specifiers?.find(
111
+ (specifier) => !move.names[specifier.field('name')?.text() ?? '']
112
+ );
113
+
114
+ if (!specifiers || unknown) {
115
+ manual.increment(
116
+ site(
117
+ run.root,
118
+ `import of ${importSource(statement)}`,
119
+ unknown ?? statement
120
+ )
121
+ );
122
+
123
+ return;
124
+ }
125
+
126
+ const source = statement.field('source');
127
+ const quote = source.text()[0];
128
+
129
+ run.edits.add(source.replace(`${quote}${move.path}${quote}`));
130
+
131
+ for (const specifier of specifiers) {
132
+ const nameNode = specifier.field('name');
133
+ const name = nameNode.text();
134
+ const newName = move.names[name];
135
+
136
+ if (newName === name) {
137
+ continue;
138
+ }
139
+
140
+ if (specifier.field('alias')) {
141
+ run.edits.add(nameNode.replace(newName));
142
+ continue;
143
+ }
144
+
145
+ const uses = referencesOf(nameNode);
146
+ const keepLocal =
147
+ isNameTaken(run.rootNode, newName) ||
148
+ uses.some((use) => use.kind() !== 'identifier');
149
+
150
+ if (keepLocal) {
151
+ run.edits.add(nameNode.replace(`${newName} as ${name}`));
152
+ continue;
153
+ }
154
+
155
+ run.edits.add(
156
+ nameNode.replace(newName),
157
+ ...uses.map((use) => use.replace(newName))
158
+ );
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Moves a re-export of a module of the tools to its 6.0 path. A renamed name
164
+ * keeps its public name through `as`. Reports `export *`, which takes every
165
+ * name of the module, and a statement with a name the move does not know.
166
+ */
167
+ function moveReExport(
168
+ run: Run,
169
+ statement: Node,
170
+ move: { path: string; names: Record<string, string> }
171
+ ): void {
172
+ const clause = statement
173
+ .children()
174
+ .find((child) => child.kind() === 'export_clause');
175
+ const specifiers =
176
+ clause?.findAll({ rule: { kind: 'export_specifier' } }) ?? [];
177
+ const unknown = specifiers.find(
178
+ (specifier) => !move.names[specifier.field('name')?.text() ?? '']
179
+ );
180
+
181
+ if (!clause || unknown) {
182
+ manual.increment(
183
+ site(
184
+ run.root,
185
+ `export of ${importSource(statement)}`,
186
+ unknown ?? statement
187
+ )
188
+ );
189
+
190
+ return;
191
+ }
192
+
193
+ const source = statement.field('source');
194
+ const quote = source.text()[0];
195
+
196
+ run.edits.add(source.replace(`${quote}${move.path}${quote}`));
197
+
198
+ for (const specifier of specifiers) {
199
+ const nameNode = specifier.field('name');
200
+ const name = nameNode.text();
201
+ const newName = move.names[name];
202
+
203
+ if (newName === name) {
204
+ continue;
205
+ }
206
+
207
+ run.edits.add(
208
+ specifier.field('alias')
209
+ ? nameNode.replace(newName)
210
+ : specifier.replace(`${newName} as ${name}`)
211
+ );
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Reports a re-export of a module of the tools whose names 6.0 removes:
217
+ * each removed name, or the statement for `export *` and a module that
218
+ * 6.0 removes whole.
219
+ */
220
+ function reportRemovedReExport(
221
+ run: Run,
222
+ statement: Node,
223
+ names: string[] | '*'
224
+ ): void {
225
+ const clause = statement
226
+ .children()
227
+ .find((child) => child.kind() === 'export_clause');
228
+
229
+ if (names === '*' || !clause) {
230
+ manual.increment(
231
+ site(run.root, `export of ${importSource(statement)}`, statement)
232
+ );
233
+
234
+ return;
235
+ }
236
+
237
+ for (const specifier of clause.findAll({
238
+ rule: { kind: 'export_specifier' },
239
+ })) {
240
+ const name = specifier.field('name')?.text() ?? '';
241
+
242
+ if (names.includes(name)) {
243
+ manual.increment(site(run.root, name, specifier));
244
+ }
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Reports an import of a module of the tools whose names 6.0 removes.
250
+ */
251
+ function reportRemoved(run: Run, statement: Node, names: string[] | '*'): void {
252
+ const source = importSource(statement);
253
+
254
+ if (names === '*') {
255
+ manual.increment(site(run.root, `import of ${source}`, statement));
256
+
257
+ return;
258
+ }
259
+
260
+ const specifiers = namedSpecifiers(statement);
261
+
262
+ if (!specifiers) {
263
+ manual.increment(site(run.root, `import of ${source}`, statement));
264
+
265
+ return;
266
+ }
267
+
268
+ for (const specifier of specifiers) {
269
+ const name = specifier.field('name')?.text() ?? '';
270
+
271
+ if (names.includes(name)) {
272
+ manual.increment(site(run.root, name, specifier));
273
+ }
274
+ }
275
+ }
276
+
277
+ /** Tells whether a statement is `import type` or `export type`. */
278
+ function isTypeOnly(statement: Node): boolean {
279
+ return statement.children().some((child) => child.kind() === 'type');
280
+ }
281
+
282
+ /**
283
+ * Tells whether import or export specifiers name only the checks that the
284
+ * core exports, each as a value.
285
+ */
286
+ function namesOnlyCoreChecks(specifiers: Node[]): boolean {
287
+ return (
288
+ specifiers.length > 0 &&
289
+ specifiers.every(
290
+ (specifier) =>
291
+ CORE_CHECKS.includes(specifier.field('name')?.text() ?? '') &&
292
+ !specifier.children().some((child) => child.kind() === 'type')
293
+ )
294
+ );
295
+ }
296
+
297
+ /**
298
+ * Tells whether a statement with these specifiers keeps the deleted
299
+ * capabilities module in the file once its removed names are reported: no
300
+ * specifier at all (`import {} from`, `export {} from`, or an import for its
301
+ * side effects), or a name that 6.0 does not just remove, such as a check
302
+ * that moved to the core, or a type.
303
+ */
304
+ function keepsDeletedModule(specifiers: Node[] | undefined): boolean {
305
+ const removed = REMOVED_NAMES[CAPABILITIES_MODULE] as string[];
306
+
307
+ return Boolean(
308
+ specifiers &&
309
+ (!specifiers.length ||
310
+ specifiers.some(
311
+ (specifier) =>
312
+ !removed.includes(specifier.field('name')?.text() ?? '')
313
+ ))
314
+ );
315
+ }
316
+
317
+ /** Points the source of an import or a re-export at another module. */
318
+ function moveSource(run: Run, statement: Node, path: string): void {
319
+ const source = statement.field('source');
320
+ const quote = source.text()[0];
321
+
322
+ run.edits.add(source.replace(`${quote}${path}${quote}`));
323
+ }
324
+
325
+ /**
326
+ * Moves a plain named import of the checks of
327
+ * `utilities/viewportCapabilities` of the tools to `@cornerstonejs/core/utilities`,
328
+ * which exports them by the same names. Any other import of the module
329
+ * reports its removed names, and the statement when it takes anything else.
330
+ */
331
+ function moveCapabilityImport(run: Run, statement: Node): void {
332
+ const specifiers = namedSpecifiers(statement);
333
+
334
+ if (specifiers && !isTypeOnly(statement) && namesOnlyCoreChecks(specifiers)) {
335
+ moveSource(run, statement, CORE_UTILITIES_MODULE);
336
+
337
+ return;
338
+ }
339
+
340
+ reportRemoved(run, statement, REMOVED_NAMES[CAPABILITIES_MODULE]);
341
+
342
+ if (keepsDeletedModule(specifiers)) {
343
+ manual.increment(
344
+ site(run.root, `import of ${CAPABILITIES_MODULE}`, statement)
345
+ );
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Moves a plain re-export of the checks of `utilities/viewportCapabilities`
351
+ * of the tools to `@cornerstonejs/core/utilities`. Any other re-export of the
352
+ * module reports its removed names, and the statement when it takes anything
353
+ * else.
354
+ */
355
+ function moveCapabilityReExport(run: Run, statement: Node): void {
356
+ const clause = statement
357
+ .children()
358
+ .find((child) => child.kind() === 'export_clause');
359
+ const specifiers = clause?.findAll({ rule: { kind: 'export_specifier' } });
360
+
361
+ if (specifiers && !isTypeOnly(statement) && namesOnlyCoreChecks(specifiers)) {
362
+ moveSource(run, statement, CORE_UTILITIES_MODULE);
363
+
364
+ return;
365
+ }
366
+
367
+ reportRemovedReExport(run, statement, REMOVED_NAMES[CAPABILITIES_MODULE]);
368
+
369
+ if (keepsDeletedModule(specifiers)) {
370
+ manual.increment(
371
+ site(run.root, `export of ${CAPABILITIES_MODULE}`, statement)
372
+ );
373
+ }
374
+ }
375
+
376
+ /**
377
+ * Tells whether an identifier is the `utilities` of the tools, or the
378
+ * namespace import of the tools.
379
+ */
380
+ function isToolsBinding(identifier: Node, name: string): boolean {
381
+ const target = identifier.definition()?.node;
382
+ const holder = target?.kind() === 'identifier' ? target.parent() : target;
383
+ const statement = holder
384
+ ?.ancestors()
385
+ .find((ancestor) => ancestor.kind() === 'import_statement');
386
+
387
+ if (!statement || importSource(statement) !== TOOLS_PACKAGE) {
388
+ return false;
389
+ }
390
+
391
+ if (holder.kind() === 'import_specifier') {
392
+ return holder.field('name')?.text() === name;
393
+ }
394
+
395
+ return (
396
+ holder
397
+ .ancestors()
398
+ .some((ancestor) => ancestor.kind() === 'namespace_import') ||
399
+ holder.kind() === 'namespace_import'
400
+ );
401
+ }
402
+
403
+ /**
404
+ * Reports `utilities.spatial.rotateViewportAroundWorldPoint` of the tools.
405
+ */
406
+ function reportRotateViewport(run: Run): void {
407
+ const members = run.rootNode.findAll({
408
+ rule: {
409
+ kind: 'member_expression',
410
+ has: { field: 'property', regex: '^rotateViewportAroundWorldPoint$' },
411
+ },
412
+ });
413
+
414
+ for (const member of members) {
415
+ const spatial = member.field('object');
416
+ const utilities =
417
+ spatial?.kind() === 'member_expression'
418
+ ? spatial.field('object')
419
+ : undefined;
420
+ const root =
421
+ utilities?.kind() === 'member_expression'
422
+ ? utilities.field('object')
423
+ : utilities;
424
+ const isTools =
425
+ spatial?.field('property')?.text() === 'spatial' &&
426
+ root?.kind() === 'identifier' &&
427
+ (isToolsBinding(root, 'utilities') || isToolsBinding(root, '*'));
428
+
429
+ if (isTools) {
430
+ manual.increment(
431
+ site(run.root, 'rotateViewportAroundWorldPoint', member)
432
+ );
433
+ }
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Reports a dynamic `import()` or a `require()` of a module of the tools that
439
+ * 6.0 moves or deletes whole: its path no longer resolves, and the names that
440
+ * the code reads from it cannot be followed.
441
+ */
442
+ function reportDynamicImports(run: Run): void {
443
+ for (const call of run.rootNode.findAll({
444
+ rule: { kind: 'call_expression' },
445
+ })) {
446
+ const callee = call.field('function');
447
+ const [argument] =
448
+ call
449
+ .field('arguments')
450
+ ?.children()
451
+ .filter((child) => child.isNamed() && child.kind() !== 'comment') ?? [];
452
+ const isLoader =
453
+ callee?.kind() === 'import' ||
454
+ (callee?.kind() === 'identifier' && callee.text() === 'require');
455
+ const path =
456
+ argument?.kind() === 'string' ? argument.text().slice(1, -1) : '';
457
+ const isGone =
458
+ path === CAPABILITIES_MODULE ||
459
+ REMOVED_NAMES[path] === '*' ||
460
+ Boolean(MOVED_MODULES[path]);
461
+
462
+ if (isLoader && isGone) {
463
+ manual.increment(site(run.root, `import of ${path}`, call));
464
+ }
465
+ }
466
+ }
467
+
468
+ /**
469
+ * Moves the two modules of the tools that 6.0 renames to their new paths
470
+ * (`labelmapRenderPlan/legacyVolumePlan` and
471
+ * `labelmapModel/labelmapLegacyAdapter`), moves the checks of the deleted
472
+ * `utilities/viewportCapabilities` to the core, and reports the names of the
473
+ * tools that 6.0 removes.
474
+ */
475
+ const codemod: Codemod<TSX> = (root) => {
476
+ const rootNode = root.root();
477
+ const run: Run = { root, rootNode, edits: new EditSet() };
478
+
479
+ for (const statement of rootNode
480
+ .children()
481
+ .filter((child) => child.kind() === 'import_statement')) {
482
+ const source = importSource(statement) ?? '';
483
+
484
+ if (source === CAPABILITIES_MODULE) {
485
+ moveCapabilityImport(run, statement);
486
+ } else if (MOVED_MODULES[source]) {
487
+ moveImport(run, statement, MOVED_MODULES[source]);
488
+ } else if (REMOVED_NAMES[source]) {
489
+ reportRemoved(run, statement, REMOVED_NAMES[source]);
490
+ }
491
+ }
492
+
493
+ for (const statement of rootNode
494
+ .children()
495
+ .filter((child) => child.kind() === 'export_statement')) {
496
+ const source = importSource(statement) ?? '';
497
+
498
+ if (source === CAPABILITIES_MODULE) {
499
+ moveCapabilityReExport(run, statement);
500
+ } else if (MOVED_MODULES[source]) {
501
+ moveReExport(run, statement, MOVED_MODULES[source]);
502
+ } else if (REMOVED_NAMES[source]) {
503
+ reportRemovedReExport(run, statement, REMOVED_NAMES[source]);
504
+ }
505
+ }
506
+
507
+ reportRotateViewport(run);
508
+ reportDynamicImports(run);
509
+
510
+ if (!run.edits.all().length) {
511
+ return null;
512
+ }
513
+
514
+ return rootNode.commitEdits(run.edits.all());
515
+ };
516
+
517
+ export default codemod;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import * as cornerstoneTools from '@cornerstonejs/tools';
3
+ import { utilities as toolsUtilities } from '@cornerstonejs/tools';
4
+ import addVolumesAsIndependentComponents from '@cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents';
5
+ import { getSlabThicknessOrDefault } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
6
+ import {
7
+ viewportSupportsStackCompatibility,
8
+ type StackCompatibilityViewport,
9
+ } from '@cornerstonejs/tools/utilities/viewportCapabilities';
10
+ import {
11
+ createLegacyVolumeLabelmapPlan,
12
+ legacyHelper,
13
+ } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan';
14
+
15
+ export function Panel({ viewport }: { viewport: StackCompatibilityViewport }) {
16
+ toolsUtilities.spatial.rotateViewportAroundWorldPoint(
17
+ viewport,
18
+ [0, 0, 0],
19
+ 90
20
+ );
21
+ cornerstoneTools.utilities.spatial.rotateViewportAroundWorldPoint(
22
+ viewport,
23
+ [0, 0, 0],
24
+ 90
25
+ );
26
+
27
+ return (
28
+ <span>
29
+ {String(addVolumesAsIndependentComponents)}{' '}
30
+ {getSlabThicknessOrDefault(viewport)}
31
+ {String(viewportSupportsStackCompatibility(viewport))}{' '}
32
+ {String(createLegacyVolumeLabelmapPlan)}
33
+ {String(legacyHelper)}
34
+ </span>
35
+ );
36
+ }
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import * as cornerstoneTools from '@cornerstonejs/tools';
3
+ import { utilities as toolsUtilities } from '@cornerstonejs/tools';
4
+ import addVolumesAsIndependentComponents from '@cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents';
5
+ import { getSlabThicknessOrDefault } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
6
+ import {
7
+ viewportSupportsStackCompatibility,
8
+ type StackCompatibilityViewport,
9
+ } from '@cornerstonejs/tools/utilities/viewportCapabilities';
10
+ import {
11
+ createLegacyVolumeLabelmapPlan,
12
+ legacyHelper,
13
+ } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan';
14
+
15
+ export function Panel({ viewport }: { viewport: StackCompatibilityViewport }) {
16
+ toolsUtilities.spatial.rotateViewportAroundWorldPoint(
17
+ viewport,
18
+ [0, 0, 0],
19
+ 90
20
+ );
21
+ cornerstoneTools.utilities.spatial.rotateViewportAroundWorldPoint(
22
+ viewport,
23
+ [0, 0, 0],
24
+ 90
25
+ );
26
+
27
+ return (
28
+ <span>
29
+ {String(addVolumesAsIndependentComponents)}{' '}
30
+ {getSlabThicknessOrDefault(viewport)}
31
+ {String(viewportSupportsStackCompatibility(viewport))}{' '}
32
+ {String(createLegacyVolumeLabelmapPlan)}
33
+ {String(legacyHelper)}
34
+ </span>
35
+ );
36
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "cornerstone3d-6-manual": [
3
+ {
4
+ "cardinality": {
5
+ "file": "input.tsx",
6
+ "line": "12",
7
+ "rule": "import of @cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan"
8
+ },
9
+ "count": 1
10
+ },
11
+ {
12
+ "cardinality": {
13
+ "file": "input.tsx",
14
+ "line": "16",
15
+ "rule": "rotateViewportAroundWorldPoint"
16
+ },
17
+ "count": 1
18
+ },
19
+ {
20
+ "cardinality": {
21
+ "file": "input.tsx",
22
+ "line": "21",
23
+ "rule": "rotateViewportAroundWorldPoint"
24
+ },
25
+ "count": 1
26
+ },
27
+ {
28
+ "cardinality": {
29
+ "file": "input.tsx",
30
+ "line": "4",
31
+ "rule": "import of @cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents"
32
+ },
33
+ "count": 1
34
+ },
35
+ {
36
+ "cardinality": {
37
+ "file": "input.tsx",
38
+ "line": "5",
39
+ "rule": "getSlabThicknessOrDefault"
40
+ },
41
+ "count": 1
42
+ },
43
+ {
44
+ "cardinality": {
45
+ "file": "input.tsx",
46
+ "line": "7",
47
+ "rule": "viewportSupportsStackCompatibility"
48
+ },
49
+ "count": 1
50
+ },
51
+ {
52
+ "cardinality": {
53
+ "file": "input.tsx",
54
+ "line": "8",
55
+ "rule": "StackCompatibilityViewport"
56
+ },
57
+ "count": 1
58
+ }
59
+ ]
60
+ }
@@ -0,0 +1,13 @@
1
+ import { utilities, segmentation } from '@cornerstonejs/tools';
2
+ import { createVolumeLabelmapPlan } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/volumeLabelmapPlan';
3
+ import { getViewSlabDepthOfViewport } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
4
+
5
+ const spatial = { rotateViewportAroundWorldPoint: () => false };
6
+
7
+ console.log(
8
+ utilities.calibrateImageSpacing,
9
+ segmentation,
10
+ createVolumeLabelmapPlan,
11
+ getViewSlabDepthOfViewport,
12
+ spatial.rotateViewportAroundWorldPoint()
13
+ );
@@ -0,0 +1,13 @@
1
+ import { utilities, segmentation } from '@cornerstonejs/tools';
2
+ import { createVolumeLabelmapPlan } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/volumeLabelmapPlan';
3
+ import { getViewSlabDepthOfViewport } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
4
+
5
+ const spatial = { rotateViewportAroundWorldPoint: () => false };
6
+
7
+ console.log(
8
+ utilities.calibrateImageSpacing,
9
+ segmentation,
10
+ createVolumeLabelmapPlan,
11
+ getViewSlabDepthOfViewport,
12
+ spatial.rotateViewportAroundWorldPoint()
13
+ );
@@ -0,0 +1,11 @@
1
+ import { createVolumeLabelmapPlan } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/volumeLabelmapPlan';
2
+ import {
3
+ syncLegacyLabelmapData,
4
+ getReferencedImageIdToCurrentImageIdMap as imageIdMap,
5
+ } from '@cornerstonejs/tools/segmentation/labelmapModel/labelmapPrimaryLayerFields';
6
+
7
+ const plan = createVolumeLabelmapPlan(viewport, representation);
8
+
9
+ syncLegacyLabelmapData(labelmap);
10
+
11
+ console.log(plan, imageIdMap(labelmap));
@@ -0,0 +1,11 @@
1
+ import { createLegacyVolumeLabelmapPlan } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan';
2
+ import {
3
+ syncLegacyLabelmapData,
4
+ getReferencedImageIdToCurrentImageIdMap as imageIdMap,
5
+ } from '@cornerstonejs/tools/segmentation/labelmapModel/labelmapLegacyAdapter';
6
+
7
+ const plan = createLegacyVolumeLabelmapPlan(viewport, representation);
8
+
9
+ syncLegacyLabelmapData(labelmap);
10
+
11
+ console.log(plan, imageIdMap(labelmap));