@cornerstonejs/codemods 5.19.3 → 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.
- package/README.md +23 -0
- package/package.json +2 -2
- package/registry/cornerstone3d/6/README.md +87 -0
- package/registry/cornerstone3d/6/classes-and-types/README.md +113 -0
- package/registry/cornerstone3d/6/classes-and-types/codemod.yaml +20 -0
- package/registry/cornerstone3d/6/classes-and-types/scripts/classes-and-types.ts +1461 -0
- package/registry/cornerstone3d/6/classes-and-types/scripts/lib.ts +2386 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/edge-namespace-and-reported/expected.tsx +27 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/edge-namespace-and-reported/input.tsx +27 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/edge-namespace-and-reported/metrics.json +36 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/edge-already-6/expected.ts +15 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/edge-already-6/input.ts +15 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/negative-other-packages/expected.ts +11 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/negative-other-packages/input.ts +11 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-3d-family-of-predicate-or-cast-object/expected.ts +55 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-3d-family-of-predicate-or-cast-object/input.ts +51 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-3d-family-of-predicate-or-cast-object/metrics.json +36 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-types-from-the-types-subpath/expected.ts +26 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-types-from-the-types-subpath/input.ts +26 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/ohif-types-from-the-types-subpath/metrics.json +52 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-3d-evidence/expected.ts +34 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-3d-evidence/input.ts +30 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-3d-evidence/metrics.json +12 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/expected.ts +35 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/input.ts +35 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/metrics.json +28 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-types-and-casts/expected.ts +46 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-types-and-casts/input.ts +42 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-class-import-cleanup-orphans-shorthand/expected.ts +4 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-class-import-cleanup-orphans-shorthand/input.ts +4 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-class-import-cleanup-orphans-shorthand/metrics.json +12 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-check-can-prevent-the-first-mount/expected.ts +24 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-check-can-prevent-the-first-mount/input.ts +25 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-check-can-prevent-the-first-mount/metrics.json +38 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-replacement-inverts-comparison/expected.ts +11 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-replacement-inverts-comparison/input.ts +11 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-instanceof-replacement-inverts-comparison/metrics.json +20 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-negative-3d-test-taken-as-3d-viewport/expected.ts +29 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-negative-3d-test-taken-as-3d-viewport/input.ts +29 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-negative-3d-test-taken-as-3d-viewport/metrics.json +20 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-re-exports-of-removed-classes/expected.ts +6 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-re-exports-of-removed-classes/input.ts +6 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-re-exports-of-removed-classes/metrics.json +20 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-type-only-namespace-used-as-value/expected.ts +8 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-type-only-namespace-used-as-value/input.ts +8 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review-type-only-namespace-used-as-value/metrics.json +12 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-instanceof-mount-proof-crosses-shadowed-binding/expected.ts +19 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-instanceof-mount-proof-crosses-shadowed-binding/input.ts +19 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-instanceof-mount-proof-crosses-shadowed-binding/metrics.json +22 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-unrelated-discriminator-taken-as-3d-proof/expected.ts +40 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-unrelated-discriminator-taken-as-3d-proof/input.ts +40 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review2-unrelated-discriminator-taken-as-3d-proof/metrics.json +28 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review3-conditional-viewport-type-taken-as-3d/expected.ts +39 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review3-conditional-viewport-type-taken-as-3d/input.ts +38 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review3-conditional-viewport-type-taken-as-3d/metrics.json +20 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-spread-or-computed-key-overrides-viewport-type/expected.ts +76 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-spread-or-computed-key-overrides-viewport-type/input.ts +75 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-spread-or-computed-key-overrides-viewport-type/metrics.json +36 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-viewport-family-proved-on-another-engine/expected.ts +92 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-viewport-family-proved-on-another-engine/input.ts +91 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/review4-viewport-family-proved-on-another-engine/metrics.json +20 -0
- package/registry/cornerstone3d/6/classes-and-types/workflow.yaml +29 -0
- package/registry/cornerstone3d/6/codemod.yaml +19 -0
- package/registry/cornerstone3d/6/display-sets/README.md +173 -0
- package/registry/cornerstone3d/6/display-sets/codemod.yaml +20 -0
- package/registry/cornerstone3d/6/display-sets/scripts/display-sets.ts +965 -0
- package/registry/cornerstone3d/6/display-sets/scripts/lib.ts +2386 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes/expected.tsx +32 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes/input.tsx +32 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes/metrics.json +84 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes-on-a-typed-engine/expected.tsx +33 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes-on-a-typed-engine/input.tsx +33 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/edge-reported-shapes-on-a-typed-engine/metrics.json +84 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/positive-javascript/expected.js +23 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/positive-javascript/input.js +17 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/review-commonjs-module-gets-es-import/expected.js +10 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/review-commonjs-module-gets-es-import/input.js +10 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/review-commonjs-module-gets-es-import/metrics.json +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/negative-already-6/expected.ts +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/negative-already-6/input.ts +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-set-volumes-for-viewports/expected.ts +27 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-set-volumes-for-viewports/input.ts +27 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-set-volumes-for-viewports/metrics.json +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-stack-and-volume/expected.ts +37 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-stack-and-volume/input.ts +31 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-stack-and-volume/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-video-and-ecg/expected.ts +15 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/positive-video-and-ecg/input.ts +15 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-mount-breaks-control-flow/expected.ts +26 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-mount-breaks-control-flow/input.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-mount-breaks-control-flow/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-viewport-lists-and-callback-capture/expected.ts +46 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-conditional-viewport-lists-and-callback-capture/input.ts +21 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-generated-references-resolve-to-shadowing-parameter/expected.ts +23 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-generated-references-resolve-to-shadowing-parameter/input.ts +13 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-optional-mounts-become-unconditional/expected.ts +11 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-optional-mounts-become-unconditional/input.ts +11 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-optional-mounts-become-unconditional/metrics.json +28 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-regenerated-import-drops-comments/expected.ts +22 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-regenerated-import-drops-comments/input.ts +15 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-stack-display-set-id-reused-across-series/expected.ts +41 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-stack-display-set-id-reused-across-series/input.ts +16 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/expected.ts +11 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/input.ts +11 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-helper-binding-still-used/expected.ts +46 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-helper-binding-still-used/input.ts +17 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-helper-binding-still-used/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-registration-references-image-list-outside-block/expected.ts +16 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-registration-references-image-list-outside-block/input.ts +16 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review-volume-registration-references-image-list-outside-block/metrics.json +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-bracketed-and-re-exported-data-names/expected.ts +19 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-bracketed-and-re-exported-data-names/input.ts +19 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-bracketed-and-re-exported-data-names/metrics.json +44 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-generic-container-taken-as-viewport/expected.ts +22 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-generic-container-taken-as-viewport/input.ts +22 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-generic-container-taken-as-viewport/metrics.json +36 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-image-list-getter-read-twice/expected.ts +62 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-image-list-getter-read-twice/input.ts +28 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-missing-target-partly-updates-layout/expected.ts +50 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-missing-target-partly-updates-layout/input.ts +25 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-missing-target-partly-updates-layout/metrics.json +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-reassigned-receiver-keeps-initializer-evidence/expected.ts +45 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-reassigned-receiver-keeps-initializer-evidence/input.ts +39 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-reassigned-receiver-keeps-initializer-evidence/metrics.json +36 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-stack-ids-collide-across-engines/expected.ts +24 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-stack-ids-collide-across-engines/input.ts +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-volume-registration-attaches-another-series/expected.ts +47 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-volume-registration-attaches-another-series/input.ts +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review2-volume-registration-attaches-another-series/metrics.json +28 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-computed-option-key-overrides-image-ids/expected.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-computed-option-key-overrides-image-ids/input.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-computed-option-key-overrides-image-ids/metrics.json +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-loop-increment-taken-as-volume-creation/expected.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-loop-increment-taken-as-volume-creation/input.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-loop-increment-taken-as-volume-creation/metrics.json +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-mixed-family-targets-partly-update-layout/expected.ts +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-mixed-family-targets-partly-update-layout/input.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-ecg-mount-empty-after-the-call/expected.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-ecg-mount-empty-after-the-call/input.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-ecg-mount-empty-after-the-call/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-helper-blocks-async-function/expected.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-helper-blocks-async-function/input.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-helper-blocks-async-function/metrics.json +12 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-stack-mount-blocks-async-function/expected.ts +19 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-stack-mount-blocks-async-function/input.ts +19 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-stack-mount-blocks-async-function/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-video-mount-empty-after-the-call/expected.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-video-mount-empty-after-the-call/input.ts +18 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-video-mount-empty-after-the-call/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-volume-mount-blocks-async-function/expected.ts +23 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-volume-mount-blocks-async-function/input.ts +23 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-unawaited-volume-mount-blocks-async-function/metrics.json +20 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-viewport-getter-read-three-times/expected.ts +34 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review3-viewport-getter-read-three-times/input.ts +19 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review4-argument-getter-redirects-stack-mount/expected.ts +80 -0
- package/registry/cornerstone3d/6/display-sets/tests/typescript/review4-argument-getter-redirects-stack-mount/input.ts +50 -0
- package/registry/cornerstone3d/6/display-sets/workflow.yaml +29 -0
- package/registry/cornerstone3d/6/events/README.md +65 -0
- package/registry/cornerstone3d/6/events/codemod.yaml +20 -0
- package/registry/cornerstone3d/6/events/scripts/events.ts +442 -0
- package/registry/cornerstone3d/6/events/scripts/lib.ts +2386 -0
- package/registry/cornerstone3d/6/events/tests/tsx/edge-reported-and-conflicts/expected.tsx +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/edge-reported-and-conflicts/input.tsx +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/edge-reported-and-conflicts/metrics.json +46 -0
- package/registry/cornerstone3d/6/events/tests/typescript/negative-other-events/expected.ts +10 -0
- package/registry/cornerstone3d/6/events/tests/typescript/negative-other-events/input.ts +10 -0
- package/registry/cornerstone3d/6/events/tests/typescript/ohif-core-events-export/expected.ts +22 -0
- package/registry/cornerstone3d/6/events/tests/typescript/ohif-core-events-export/input.ts +22 -0
- package/registry/cornerstone3d/6/events/tests/typescript/ohif-core-events-export/metrics.json +54 -0
- package/registry/cornerstone3d/6/events/tests/typescript/positive-destructured/expected.ts +20 -0
- package/registry/cornerstone3d/6/events/tests/typescript/positive-destructured/input.ts +20 -0
- package/registry/cornerstone3d/6/events/tests/typescript/positive-destructured/metrics.json +12 -0
- package/registry/cornerstone3d/6/events/tests/typescript/positive-members/expected.ts +16 -0
- package/registry/cornerstone3d/6/events/tests/typescript/positive-members/input.ts +16 -0
- package/registry/cornerstone3d/6/events/tests/typescript/positive-members/metrics.json +52 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-aliased-event-destructuring-left-silently/expected.ts +5 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-aliased-event-destructuring-left-silently/input.ts +5 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-aliased-event-destructuring-left-silently/metrics.json +12 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-event-destructuring-introduces-undeclared-name/expected.ts +9 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-event-destructuring-introduces-undeclared-name/input.ts +10 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-event-destructuring-introduces-undeclared-name/metrics.json +20 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-removed-event-strings-not-reported/expected.ts +11 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-removed-event-strings-not-reported/input.ts +11 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review-removed-event-strings-not-reported/metrics.json +28 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review2-quoted-defaulted-and-bracketed-event-keys/expected.ts +15 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review2-quoted-defaulted-and-bracketed-event-keys/input.ts +15 -0
- package/registry/cornerstone3d/6/events/tests/typescript/review2-quoted-defaulted-and-bracketed-event-keys/metrics.json +62 -0
- package/registry/cornerstone3d/6/events/workflow.yaml +29 -0
- package/registry/cornerstone3d/6/settings/README.md +69 -0
- package/registry/cornerstone3d/6/settings/codemod.yaml +20 -0
- package/registry/cornerstone3d/6/settings/scripts/lib.ts +2386 -0
- package/registry/cornerstone3d/6/settings/scripts/settings.ts +647 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/edge-namespace-and-reported/expected.tsx +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/edge-namespace-and-reported/input.tsx +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/edge-namespace-and-reported/metrics.json +46 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/negative-other-names/expected.ts +18 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/negative-other-names/input.ts +18 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/positive-configuration/expected.ts +27 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/positive-configuration/input.ts +28 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/positive-configuration/metrics.json +46 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/positive-functions/expected.ts +32 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/positive-functions/input.ts +33 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/positive-functions/metrics.json +36 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-aliased-setting-imports-removed-while-used/expected.ts +10 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-aliased-setting-imports-removed-while-used/input.ts +9 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-aliased-setting-imports-removed-while-used/metrics.json +22 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-generated-references-resolve-to-shadowing-locals/expected.ts +12 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-generated-references-resolve-to-shadowing-locals/input.ts +12 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-import-name-collision-calls-undefined/expected.ts +9 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-import-name-collision-calls-undefined/input.ts +9 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-import-name-collision-calls-undefined/metrics.json +12 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-settings-deletes-unrelated-configuration/expected.ts +12 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-settings-deletes-unrelated-configuration/input.ts +12 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review-settings-deletes-unrelated-configuration/metrics.json +28 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-adjacent-obsolete-settings/expected.ts +24 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-adjacent-obsolete-settings/input.ts +29 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-adjacent-obsolete-settings/metrics.json +12 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-nested-cpu-getter-in-rewritten-setting/expected.ts +3 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-nested-cpu-getter-in-rewritten-setting/input.ts +3 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-nested-cpu-getter-in-rewritten-setting/metrics.json +12 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-re-exported-setting-names/expected.ts +1 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-re-exported-setting-names/input.ts +1 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-re-exported-setting-names/metrics.json +20 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-spread-boolean-tuple/expected.ts +6 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-spread-boolean-tuple/input.ts +6 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review2-spread-boolean-tuple/metrics.json +22 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review3-shorthand-cpu-setting/expected.ts +13 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review3-shorthand-cpu-setting/input.ts +13 -0
- package/registry/cornerstone3d/6/settings/tests/typescript/review3-shorthand-cpu-setting/metrics.json +12 -0
- package/registry/cornerstone3d/6/settings/workflow.yaml +29 -0
- package/registry/cornerstone3d/6/tools/README.md +59 -0
- package/registry/cornerstone3d/6/tools/codemod.yaml +20 -0
- package/registry/cornerstone3d/6/tools/scripts/lib.ts +2386 -0
- package/registry/cornerstone3d/6/tools/scripts/tools.ts +517 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/edge-removed-names/expected.tsx +36 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/edge-removed-names/input.tsx +36 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/edge-removed-names/metrics.json +60 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/negative-other-modules/expected.ts +13 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/negative-other-modules/input.ts +13 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/positive-moved-modules/expected.ts +11 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/positive-moved-modules/input.ts +11 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/positive-viewport-capabilities-to-core/expected.ts +13 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/positive-viewport-capabilities-to-core/input.ts +13 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review-moved-import-collides-with-local/expected.ts +7 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review-moved-import-collides-with-local/input.ts +7 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review-viewport-capabilities-not-plain/expected.ts +26 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review-viewport-capabilities-not-plain/input.ts +26 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review-viewport-capabilities-not-plain/metrics.json +60 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review2-barrel-re-export-of-moved-module/expected.ts +6 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review2-barrel-re-export-of-moved-module/input.ts +6 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review2-barrel-re-export-of-moved-module/metrics.json +28 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review3-side-effect-and-empty-imports-of-deleted-module/expected.ts +12 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review3-side-effect-and-empty-imports-of-deleted-module/input.ts +12 -0
- package/registry/cornerstone3d/6/tools/tests/typescript/review3-side-effect-and-empty-imports-of-deleted-module/metrics.json +36 -0
- package/registry/cornerstone3d/6/tools/workflow.yaml +29 -0
- package/registry/cornerstone3d/6/viewport-members/README.md +101 -0
- package/registry/cornerstone3d/6/viewport-members/codemod.yaml +20 -0
- package/registry/cornerstone3d/6/viewport-members/scripts/lib.ts +2386 -0
- package/registry/cornerstone3d/6/viewport-members/scripts/viewport-members.ts +815 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members/expected.tsx +31 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members/input.tsx +31 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members/metrics.json +100 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members-on-a-typed-viewport/expected.tsx +31 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members-on-a-typed-viewport/input.tsx +31 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/edge-reported-members-on-a-typed-viewport/metrics.json +100 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/negative-other-receivers/expected.ts +24 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/negative-other-receivers/input.ts +24 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-3d-presentation/expected.ts +11 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-3d-presentation/input.ts +11 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-3d-presentation/metrics.json +28 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-engine-render-frame-of-reference/expected.ts +16 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-engine-render-frame-of-reference/input.ts +16 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-engine-render-frame-of-reference/metrics.json +28 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-presentation-and-view/expected.ts +31 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-presentation-and-view/input.ts +31 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-questions-and-actors/expected.ts +31 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-questions-and-actors/input.ts +26 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-questions-and-actors/metrics.json +22 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-video-and-ecg/expected.ts +15 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-video-and-ecg/input.ts +15 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/positive-video-and-ecg/metrics.json +28 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-generated-imports-invalidate-file-directives/expected.ts +5 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-generated-imports-invalidate-file-directives/input.ts +5 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-generated-imports-invalidate-file-directives/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-quoted-presentation-key-loses-effect/expected.ts +12 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-quoted-presentation-key-loses-effect/input.ts +12 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-quoted-presentation-key-loses-effect/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-slice-index-rewrite-mishandles-references/expected.ts +12 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-slice-index-rewrite-mishandles-references/input.ts +12 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-slice-index-rewrite-mishandles-references/metrics.json +20 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/expected.ts +9 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/input.ts +9 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/metrics.json +20 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-bracket-access-hides-removed-methods/expected.ts +11 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-bracket-access-hides-removed-methods/input.ts +11 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-bracket-access-hides-removed-methods/metrics.json +36 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-re-exported-core-helpers/expected.ts +5 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-re-exported-core-helpers/input.ts +5 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review2-re-exported-core-helpers/metrics.json +20 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review3-conditional-mount-drops-presentation/expected.ts +58 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review3-conditional-mount-drops-presentation/input.ts +58 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review3-conditional-mount-drops-presentation/metrics.json +20 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review4-strict-bounds-and-actor-volume-ids/expected.ts +16 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review4-strict-bounds-and-actor-volume-ids/input.ts +16 -0
- package/registry/cornerstone3d/6/viewport-members/tests/typescript/review4-strict-bounds-and-actor-volume-ids/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-members/workflow.yaml +29 -0
- package/registry/cornerstone3d/6/viewport-types/README.md +73 -0
- package/registry/cornerstone3d/6/viewport-types/codemod.yaml +20 -0
- package/registry/cornerstone3d/6/viewport-types/scripts/lib.ts +2386 -0
- package/registry/cornerstone3d/6/viewport-types/scripts/viewport-types.ts +714 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/edge-reported-sites/expected.tsx +57 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/edge-reported-sites/input.tsx +57 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/edge-reported-sites/metrics.json +70 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/edge-already-6/expected.ts +25 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/edge-already-6/input.ts +25 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/negative-other-names/expected.ts +22 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/negative-other-names/input.ts +22 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-destructured-viewport-type/expected.ts +68 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-destructured-viewport-type/input.ts +65 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-destructured-viewport-type/metrics.json +46 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-namespaced-and-aliased/expected.ts +20 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-namespaced-and-aliased/input.ts +19 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-namespaced-and-aliased/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-strings/expected.ts +25 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-strings/input.ts +24 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/positive-strings/metrics.json +22 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-destructured-viewport-type-members/expected.ts +19 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-destructured-viewport-type-members/input.ts +19 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-destructured-viewport-type-members/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-type-check-can-prevent-the-first-mount/expected.ts +27 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-type-check-can-prevent-the-first-mount/input.ts +27 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-type-check-can-prevent-the-first-mount/metrics.json +28 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/expected.ts +9 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/input.ts +9 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-like-name-rewrites-unrelated-objects/metrics.json +20 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-type-pass-changes-unrelated-discriminators/expected.ts +18 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-type-pass-changes-unrelated-discriminators/input.ts +18 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review-viewport-type-pass-changes-unrelated-discriminators/metrics.json +30 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-mount-proof-crosses-shadowed-binding/expected.ts +42 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-mount-proof-crosses-shadowed-binding/input.ts +42 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-mount-proof-crosses-shadowed-binding/metrics.json +36 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-quoted-defaulted-and-bracketed-viewport-type-keys/expected.ts +10 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-quoted-defaulted-and-bracketed-viewport-type-keys/input.ts +10 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/review2-quoted-defaulted-and-bracketed-viewport-type-keys/metrics.json +36 -0
- package/registry/cornerstone3d/6/viewport-types/workflow.yaml +29 -0
- package/registry/cornerstone3d/6/workflow.yaml +26 -0
- package/scripts/test-registry-packages.mjs +86 -0
- package/scripts/validate-registry-packages.mjs +43 -2
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
import type { Codemod, Edit, SgRoot } from 'codemod:ast-grep';
|
|
2
|
+
import type TSX from 'codemod:ast-grep/langs/tsx';
|
|
3
|
+
import { useMetricAtom } from 'codemod:metrics';
|
|
4
|
+
import {
|
|
5
|
+
CoreImports,
|
|
6
|
+
EditSet,
|
|
7
|
+
bracketKey,
|
|
8
|
+
coreImportOf,
|
|
9
|
+
coreReExports,
|
|
10
|
+
enclosingFunction,
|
|
11
|
+
isBoundTo,
|
|
12
|
+
isCoreExport,
|
|
13
|
+
isMountedBefore,
|
|
14
|
+
isRenderingEngine,
|
|
15
|
+
isRepeatable,
|
|
16
|
+
viewportEvidence,
|
|
17
|
+
methodCall,
|
|
18
|
+
objectEntries,
|
|
19
|
+
site,
|
|
20
|
+
stableBinding,
|
|
21
|
+
unwrap,
|
|
22
|
+
viewportFamily,
|
|
23
|
+
} from './lib.ts';
|
|
24
|
+
import type { Node } from './lib.ts';
|
|
25
|
+
|
|
26
|
+
/** Sites that the reader changes. */
|
|
27
|
+
const manual = useMetricAtom('cornerstone3d-6-manual');
|
|
28
|
+
|
|
29
|
+
/** Rewrites that the reader checks. */
|
|
30
|
+
const review = useMetricAtom('cornerstone3d-6-review');
|
|
31
|
+
|
|
32
|
+
/** The members whose call keeps its arguments under a new name. */
|
|
33
|
+
const RENAMED_METHODS: Record<string, string> = {
|
|
34
|
+
resetCameraForResize: 'resetViewStateForResize',
|
|
35
|
+
getTargetImageIdIndex: 'getCurrentImageIdIndex',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** The members whose call becomes a fixed read of `getActors()`. */
|
|
39
|
+
const ACTOR_READS: Record<string, (args: string[]) => string | undefined> = {
|
|
40
|
+
getActorUIDs: (args) =>
|
|
41
|
+
args.length === 0 ? 'getActors().map((entry) => entry.uid)' : undefined,
|
|
42
|
+
getAllVolumeIds: (args) =>
|
|
43
|
+
args.length === 0
|
|
44
|
+
? 'getActors().map((entry) => entry.referencedId)'
|
|
45
|
+
: undefined,
|
|
46
|
+
getActorByIndex: (args) =>
|
|
47
|
+
args.length === 1 ? `getActors()[${args[0]}]` : undefined,
|
|
48
|
+
getActorUIDByIndex: (args) =>
|
|
49
|
+
args.length === 1 ? `getActors()[${args[0]}]?.uid` : undefined,
|
|
50
|
+
getBounds: (args) =>
|
|
51
|
+
args.length === 0 ? 'getImageData()?.imageData.getBounds?.()' : undefined,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The review note of a rewritten read of `getActors()` whose answer can hold
|
|
56
|
+
* more than the legacy member gave.
|
|
57
|
+
*/
|
|
58
|
+
const ACTOR_READ_REVIEWS: Record<string, string> = {
|
|
59
|
+
getAllVolumeIds:
|
|
60
|
+
'getAllVolumeIds: getActors() also lists labelmaps, surfaces and stack images, keep the ids that viewport.hasVolumeId(id) takes',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** The members whose call becomes a function of the core `utilities`. */
|
|
64
|
+
const UTILITY_CALLS: Record<
|
|
65
|
+
string,
|
|
66
|
+
{ name: string; arity: number; suffix?: string }
|
|
67
|
+
> = {
|
|
68
|
+
isInAcquisitionPlane: { name: 'isInAcquisitionPlane', arity: 0 },
|
|
69
|
+
getSlicesClippingPlanes: { name: 'getSlicesClippingPlanes', arity: 0 },
|
|
70
|
+
getVtkDisplayCoords: { name: 'getVtkDisplayCoords', arity: 1 },
|
|
71
|
+
getCurrentSlicePixelData: {
|
|
72
|
+
name: 'getCurrentVolumeViewportSlice',
|
|
73
|
+
arity: 0,
|
|
74
|
+
suffix: '.scalarData',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** The properties that a read on a viewport renames. */
|
|
79
|
+
const RENAMED_PROPERTIES: Record<string, string> = {
|
|
80
|
+
isDisabled: 'isDestroyed',
|
|
81
|
+
uid: 'id',
|
|
82
|
+
fps: 'getFrameRate()',
|
|
83
|
+
numberOfFrames: 'getNumberOfFrames()',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** The legacy members that the transform reports on a viewport. */
|
|
87
|
+
const REPORTED_METHODS = new Set([
|
|
88
|
+
'getProperties',
|
|
89
|
+
'resetProperties',
|
|
90
|
+
'setDefaultProperties',
|
|
91
|
+
'getDefaultProperties',
|
|
92
|
+
'clearDefaultProperties',
|
|
93
|
+
'resetToDefaultProperties',
|
|
94
|
+
'getCamera',
|
|
95
|
+
'getViewPresentation',
|
|
96
|
+
'setViewPresentation',
|
|
97
|
+
'getActor',
|
|
98
|
+
'addActor',
|
|
99
|
+
'addActors',
|
|
100
|
+
'setActors',
|
|
101
|
+
'removeActors',
|
|
102
|
+
'removeAllActors',
|
|
103
|
+
'getWidget',
|
|
104
|
+
'getSliceViewInfo',
|
|
105
|
+
'getSliceInfo',
|
|
106
|
+
'getImageDataMetadata',
|
|
107
|
+
'getImagePlaneReferenceData',
|
|
108
|
+
'getIntensityFromWorld',
|
|
109
|
+
'jumpToWorld',
|
|
110
|
+
'setBestOrentation',
|
|
111
|
+
'setViewPlane',
|
|
112
|
+
'flip',
|
|
113
|
+
'setBlendMode',
|
|
114
|
+
'getBlendMode',
|
|
115
|
+
'setSlabThickness',
|
|
116
|
+
'getSlabThickness',
|
|
117
|
+
'resetSlabThickness',
|
|
118
|
+
'setSampleDistanceMultiplier',
|
|
119
|
+
'unsetColormap',
|
|
120
|
+
'createVTKImageData',
|
|
121
|
+
'setUseCPURendering',
|
|
122
|
+
'getSlicePlaneCoordinates',
|
|
123
|
+
'togglePlayPause',
|
|
124
|
+
'setScrollSpeed',
|
|
125
|
+
'setTime',
|
|
126
|
+
'setVOI',
|
|
127
|
+
'setWindowLevel',
|
|
128
|
+
'setChannelVisibility',
|
|
129
|
+
'getFrameRange',
|
|
130
|
+
'getMiddleSliceData',
|
|
131
|
+
'updateCameraClippingPlanesAndRange',
|
|
132
|
+
'setOrientationOfClippingPlanes',
|
|
133
|
+
'getClippingPlanesForActor',
|
|
134
|
+
'getAspectRatio',
|
|
135
|
+
'setAspectRatio',
|
|
136
|
+
'setOptions',
|
|
137
|
+
'reset',
|
|
138
|
+
'getSliceIndexForImage',
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
/** The legacy properties that the transform reports on a viewport. */
|
|
142
|
+
const REPORTED_PROPERTIES = new Set([
|
|
143
|
+
'requestedType',
|
|
144
|
+
'sx',
|
|
145
|
+
'sy',
|
|
146
|
+
'sWidth',
|
|
147
|
+
'sHeight',
|
|
148
|
+
'_actors',
|
|
149
|
+
'options',
|
|
150
|
+
'suppressEvents',
|
|
151
|
+
'scaling',
|
|
152
|
+
'stackActorReInitialized',
|
|
153
|
+
'useCPURendering',
|
|
154
|
+
]);
|
|
155
|
+
|
|
156
|
+
/** The removed exports of the core that the transform reports. */
|
|
157
|
+
const REPORTED_CORE_NAMES = new Set([
|
|
158
|
+
'viewportSupportsStackCompatibility',
|
|
159
|
+
'viewportSupportsVolumeCompatibility',
|
|
160
|
+
'StackCompatibilityViewport',
|
|
161
|
+
'VolumeCompatibilityViewport',
|
|
162
|
+
'getVolumeViewportScrollInfo',
|
|
163
|
+
'getImageSliceDataForVolumeViewport',
|
|
164
|
+
'getVolumeSliceRangeInfo',
|
|
165
|
+
'getImageLegacy',
|
|
166
|
+
'ECGUtilities',
|
|
167
|
+
'scrollVolume',
|
|
168
|
+
]);
|
|
169
|
+
|
|
170
|
+
/** The removed members of a rendering engine that the transform reports. */
|
|
171
|
+
const REPORTED_ENGINE_MEMBERS = new Set(['renderFrameOfReference']);
|
|
172
|
+
|
|
173
|
+
/** The keys of `setProperties` that are keys of the presentation too. */
|
|
174
|
+
const PRESENTATION_KEYS = new Set([
|
|
175
|
+
'voiRange',
|
|
176
|
+
'invert',
|
|
177
|
+
'colormap',
|
|
178
|
+
'interpolationType',
|
|
179
|
+
'sharpening',
|
|
180
|
+
'smoothing',
|
|
181
|
+
'loop',
|
|
182
|
+
'muted',
|
|
183
|
+
'playbackRate',
|
|
184
|
+
'showAmplitudeLabels',
|
|
185
|
+
]);
|
|
186
|
+
|
|
187
|
+
/** The keys of `setProperties` that are keys of the presentation of a 3D viewport only. */
|
|
188
|
+
const THREE_D_PRESENTATION_KEYS = new Set([
|
|
189
|
+
'preset',
|
|
190
|
+
'sampleDistanceMultiplier',
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
/** The keys of `setProperties` that change their name in the presentation. */
|
|
194
|
+
const RENAMED_PRESENTATION_KEYS: Record<string, string> = {
|
|
195
|
+
VOILUTFunction: 'voiLUTFunction',
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/** The keys of the ECG `setProperties` that are keys of its view state. */
|
|
199
|
+
const ECG_VIEW_KEYS: Record<string, string> = {
|
|
200
|
+
visibleChannels: 'visibleChannels',
|
|
201
|
+
sweepSpeed: 'sweepSpeed',
|
|
202
|
+
sensitivityMmMv: 'sensitivityMmMv',
|
|
203
|
+
traceLayout: 'traceLayout',
|
|
204
|
+
layoutType: 'traceLayout',
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/** The keys of `resetCamera` that `resetViewState` takes. */
|
|
208
|
+
const RESET_KEYS = new Set(['resetPan', 'resetZoom', 'resetOrientation']);
|
|
209
|
+
|
|
210
|
+
/** The keys of `setCamera` that the view state of a planar viewport takes. */
|
|
211
|
+
const FLIP_KEYS = new Set(['flipHorizontal', 'flipVertical']);
|
|
212
|
+
|
|
213
|
+
/** The calls that mount data on a viewport. */
|
|
214
|
+
const MOUNT_CALL = /\.(setDisplaySets|setStack|setVolumes|setVideo)\(/;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The state of one run of the transform on a file.
|
|
218
|
+
*/
|
|
219
|
+
interface Run {
|
|
220
|
+
root: SgRoot<TSX>;
|
|
221
|
+
rootNode: Node;
|
|
222
|
+
imports: CoreImports;
|
|
223
|
+
edits: EditSet;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Returns an edit that replaces the text from the property of a member call
|
|
228
|
+
* to the end of the call, so the receiver stays as it is.
|
|
229
|
+
*/
|
|
230
|
+
function replaceFromProperty(call: Node, property: Node, text: string): Edit {
|
|
231
|
+
return {
|
|
232
|
+
startPos: property.range().start.index,
|
|
233
|
+
endPos: call.range().end.index,
|
|
234
|
+
insertedText: text,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Reports a site and returns false, for a rewrite that does not apply.
|
|
240
|
+
*/
|
|
241
|
+
function reportSite(run: Run, rule: string, node: Node): false {
|
|
242
|
+
manual.increment(site(run.root, rule, node));
|
|
243
|
+
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Returns the keys of an object literal argument with their entries, or
|
|
249
|
+
* undefined when the argument is not a plain object literal.
|
|
250
|
+
*/
|
|
251
|
+
function literalKeys(arg: Node | undefined): string[] | undefined {
|
|
252
|
+
if (arg?.kind() !== 'object') {
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const { keys, hasSpread } = objectEntries(arg);
|
|
257
|
+
|
|
258
|
+
return hasSpread ? undefined : keys;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Tells whether the presentation of the source display set can be set at a
|
|
263
|
+
* call: the receiver is a name whose binding holds one value, a statement
|
|
264
|
+
* that awaits a mount on that binding runs before the call in its function,
|
|
265
|
+
* and no mount on that binding comes after the call in its function or runs
|
|
266
|
+
* before it without `await`. A mount under a condition or in another
|
|
267
|
+
* function proves nothing: 6.0 drops a presentation that is set before the
|
|
268
|
+
* first mount, where 5.x kept it.
|
|
269
|
+
*/
|
|
270
|
+
function isMountedAt(run: Run, call: Node, receiver: Node): boolean {
|
|
271
|
+
const target = unwrap(receiver);
|
|
272
|
+
const binding =
|
|
273
|
+
target.kind() === 'identifier' ? stableBinding(target) : undefined;
|
|
274
|
+
|
|
275
|
+
if (!binding || !isMountedBefore(call, receiver)) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const scope = enclosingFunction(call) ?? run.rootNode;
|
|
280
|
+
const start = call.range().start.index;
|
|
281
|
+
|
|
282
|
+
for (const other of scope.findAll({ rule: { kind: 'call_expression' } })) {
|
|
283
|
+
const parts = methodCall(other);
|
|
284
|
+
|
|
285
|
+
if (
|
|
286
|
+
!parts ||
|
|
287
|
+
!isBoundTo(unwrap(parts.object), binding) ||
|
|
288
|
+
!MOUNT_CALL.test(`.${parts.method}(`)
|
|
289
|
+
) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (other.range().start.index > start) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (other.parent()?.kind() !== 'await_expression') {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Returns the name of a key of a pair, without the quotes of a string key.
|
|
307
|
+
*/
|
|
308
|
+
function keyName(key: Node): string {
|
|
309
|
+
return key.kind() === 'string' ? key.text().slice(1, -1) : key.text();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Returns the text of an object literal with the keys of its pairs renamed by
|
|
314
|
+
* a map of key names. A quoted key keeps its quotes.
|
|
315
|
+
*/
|
|
316
|
+
function renameKeys(objectNode: Node, names: Record<string, string>): string {
|
|
317
|
+
const offset = objectNode.range().start.index;
|
|
318
|
+
const keys = objectNode
|
|
319
|
+
.children()
|
|
320
|
+
.filter((child) => child.kind() === 'pair')
|
|
321
|
+
.map((pair) => pair.field('key'))
|
|
322
|
+
.filter(
|
|
323
|
+
(key) =>
|
|
324
|
+
key && names[keyName(key)] && names[keyName(key)] !== keyName(key)
|
|
325
|
+
)
|
|
326
|
+
.reverse();
|
|
327
|
+
let text = objectNode.text();
|
|
328
|
+
|
|
329
|
+
for (const key of keys) {
|
|
330
|
+
const start = key.range().start.index - offset;
|
|
331
|
+
const end = key.range().end.index - offset;
|
|
332
|
+
const quote = key.kind() === 'string' ? key.text()[0] : '';
|
|
333
|
+
|
|
334
|
+
text = `${text.slice(0, start)}${quote}${names[keyName(key)]}${quote}${text.slice(end)}`;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return text;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Rewrites `viewport.setProperties({ ... })` of known keys.
|
|
342
|
+
*/
|
|
343
|
+
function rewriteSetProperties(
|
|
344
|
+
run: Run,
|
|
345
|
+
call: Node,
|
|
346
|
+
object: Node,
|
|
347
|
+
property: Node,
|
|
348
|
+
args: Node[]
|
|
349
|
+
): boolean {
|
|
350
|
+
const keys = literalKeys(args[0]);
|
|
351
|
+
|
|
352
|
+
if (args.length !== 1 || !keys) {
|
|
353
|
+
return reportSite(run, 'setProperties: not one object literal', call);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (
|
|
357
|
+
args[0]
|
|
358
|
+
.children()
|
|
359
|
+
.some(
|
|
360
|
+
(child) =>
|
|
361
|
+
child.kind() === 'shorthand_property_identifier' &&
|
|
362
|
+
RENAMED_PRESENTATION_KEYS[child.text()]
|
|
363
|
+
)
|
|
364
|
+
) {
|
|
365
|
+
return reportSite(
|
|
366
|
+
run,
|
|
367
|
+
'setProperties: a shorthand key that changes its name',
|
|
368
|
+
call
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const isThreeD = viewportFamily(object) === '3d';
|
|
373
|
+
const isPresentationKey = (key: string) =>
|
|
374
|
+
PRESENTATION_KEYS.has(key) ||
|
|
375
|
+
Boolean(RENAMED_PRESENTATION_KEYS[key]) ||
|
|
376
|
+
(isThreeD && THREE_D_PRESENTATION_KEYS.has(key));
|
|
377
|
+
const isPresentation = keys.every(isPresentationKey);
|
|
378
|
+
const isEcgView =
|
|
379
|
+
keys.length > 0 &&
|
|
380
|
+
keys.every((key) => ECG_VIEW_KEYS[key]) &&
|
|
381
|
+
!args[0]
|
|
382
|
+
.children()
|
|
383
|
+
.some(
|
|
384
|
+
(child) =>
|
|
385
|
+
child.kind() === 'shorthand_property_identifier' &&
|
|
386
|
+
child.text() === 'layoutType'
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
if (!isPresentation && !isEcgView) {
|
|
390
|
+
const key = keys.find((name) => !isPresentationKey(name));
|
|
391
|
+
|
|
392
|
+
return reportSite(run, `setProperties: the key ${key}`, call);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (isPresentation && !isMountedAt(run, call, object)) {
|
|
396
|
+
return reportSite(
|
|
397
|
+
run,
|
|
398
|
+
'setProperties: the viewport may not show its data yet',
|
|
399
|
+
call
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const method = isEcgView ? 'setViewState' : 'setDisplaySetPresentation';
|
|
404
|
+
const names = isEcgView ? ECG_VIEW_KEYS : RENAMED_PRESENTATION_KEYS;
|
|
405
|
+
|
|
406
|
+
return run.edits.add(
|
|
407
|
+
property.replace(method),
|
|
408
|
+
args[0].replace(renameKeys(args[0], names))
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Rewrites or reports one call of a legacy member on a viewport. A receiver
|
|
414
|
+
* that only its name shows to be a viewport is reported.
|
|
415
|
+
*/
|
|
416
|
+
function rewriteCall(run: Run, call: Node): void {
|
|
417
|
+
const parts = methodCall(call);
|
|
418
|
+
const evidence = parts ? viewportEvidence(parts.object) : undefined;
|
|
419
|
+
|
|
420
|
+
if (!evidence) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const { object, property, method, args } = parts;
|
|
425
|
+
|
|
426
|
+
if (evidence === 'name') {
|
|
427
|
+
reportSite(run, method, call);
|
|
428
|
+
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const argTexts = args.map((arg) => arg.text());
|
|
432
|
+
|
|
433
|
+
if (RENAMED_METHODS[method]) {
|
|
434
|
+
run.edits.add(property.replace(RENAMED_METHODS[method]));
|
|
435
|
+
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (ACTOR_READS[method]) {
|
|
440
|
+
const text = ACTOR_READS[method](argTexts);
|
|
441
|
+
|
|
442
|
+
if (!text || !run.edits.add(replaceFromProperty(call, property, text))) {
|
|
443
|
+
reportSite(run, method, call);
|
|
444
|
+
} else if (ACTOR_READ_REVIEWS[method]) {
|
|
445
|
+
review.increment(site(run.root, ACTOR_READ_REVIEWS[method], call));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (UTILITY_CALLS[method]) {
|
|
452
|
+
const { name, arity, suffix = '' } = UTILITY_CALLS[method];
|
|
453
|
+
const utilities =
|
|
454
|
+
args.length === arity
|
|
455
|
+
? run.imports.ensure('utilities', { at: call })
|
|
456
|
+
: undefined;
|
|
457
|
+
const callArgs = [unwrap(object).text(), ...argTexts].join(', ');
|
|
458
|
+
|
|
459
|
+
if (
|
|
460
|
+
!utilities ||
|
|
461
|
+
!run.edits.add(call.replace(`${utilities}.${name}(${callArgs})${suffix}`))
|
|
462
|
+
) {
|
|
463
|
+
reportSite(run, method, call);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
switch (method) {
|
|
470
|
+
case 'resetCamera': {
|
|
471
|
+
const keys = args.length === 0 ? [] : literalKeys(args[0]);
|
|
472
|
+
|
|
473
|
+
if (
|
|
474
|
+
args.length > 1 ||
|
|
475
|
+
!keys ||
|
|
476
|
+
keys.some((key) => !RESET_KEYS.has(key))
|
|
477
|
+
) {
|
|
478
|
+
reportSite(run, 'resetCamera: options without a twin', call);
|
|
479
|
+
} else {
|
|
480
|
+
run.edits.add(property.replace('resetViewState'));
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
case 'setProperties':
|
|
487
|
+
rewriteSetProperties(run, call, object, property, args);
|
|
488
|
+
|
|
489
|
+
return;
|
|
490
|
+
|
|
491
|
+
case 'setCamera': {
|
|
492
|
+
const keys = literalKeys(args[0]);
|
|
493
|
+
|
|
494
|
+
if (
|
|
495
|
+
args.length === 1 &&
|
|
496
|
+
keys?.length &&
|
|
497
|
+
keys.every((key) => FLIP_KEYS.has(key)) &&
|
|
498
|
+
viewportFamily(object) === 'planar'
|
|
499
|
+
) {
|
|
500
|
+
run.edits.add(property.replace('setViewState'));
|
|
501
|
+
} else {
|
|
502
|
+
reportSite(run, 'setCamera', call);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
case 'isOrientationChangeable': {
|
|
509
|
+
const enums =
|
|
510
|
+
isRepeatable(object) && !args.length
|
|
511
|
+
? run.imports.ensure('Enums', { at: call })
|
|
512
|
+
: undefined;
|
|
513
|
+
const utilities = enums
|
|
514
|
+
? run.imports.ensure('utilities', { at: call })
|
|
515
|
+
: undefined;
|
|
516
|
+
const viewport = unwrap(object).text();
|
|
517
|
+
|
|
518
|
+
if (
|
|
519
|
+
!utilities ||
|
|
520
|
+
!run.edits.add(
|
|
521
|
+
call.replace(
|
|
522
|
+
`(${viewport}.type === ${enums}.ViewportType.VOLUME_3D || ${utilities}.viewportIsInVolumeMode(${viewport}))`
|
|
523
|
+
)
|
|
524
|
+
)
|
|
525
|
+
) {
|
|
526
|
+
reportSite(run, method, call);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
case 'getCornerstoneImage': {
|
|
533
|
+
const cache =
|
|
534
|
+
args.length === 0
|
|
535
|
+
? run.imports.ensure('cache', { at: call })
|
|
536
|
+
: undefined;
|
|
537
|
+
|
|
538
|
+
if (
|
|
539
|
+
!cache ||
|
|
540
|
+
!run.edits.add(
|
|
541
|
+
call.replace(
|
|
542
|
+
`${cache}.getImage(${object.text()}.getCurrentImageId())`
|
|
543
|
+
)
|
|
544
|
+
)
|
|
545
|
+
) {
|
|
546
|
+
reportSite(run, method, call);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
case 'setAverageWhite':
|
|
553
|
+
if (args.length === 1 && !isMountedAt(run, call, object)) {
|
|
554
|
+
reportSite(
|
|
555
|
+
run,
|
|
556
|
+
'setAverageWhite: the viewport may not show its data yet',
|
|
557
|
+
call
|
|
558
|
+
);
|
|
559
|
+
} else if (args.length === 1) {
|
|
560
|
+
run.edits.add(
|
|
561
|
+
property.replace('setDisplaySetPresentation'),
|
|
562
|
+
call.field('arguments').replace(`({ averageWhite: ${argTexts[0]} })`)
|
|
563
|
+
);
|
|
564
|
+
} else {
|
|
565
|
+
reportSite(run, method, call);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return;
|
|
569
|
+
|
|
570
|
+
case 'setFrameRange':
|
|
571
|
+
if (args.length === 1) {
|
|
572
|
+
run.edits.add(
|
|
573
|
+
property.replace('setViewState'),
|
|
574
|
+
call.field('arguments').replace(`({ frameRange: ${argTexts[0]} })`)
|
|
575
|
+
);
|
|
576
|
+
} else {
|
|
577
|
+
reportSite(run, method, call);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return;
|
|
581
|
+
|
|
582
|
+
default:
|
|
583
|
+
if (REPORTED_METHODS.has(method)) {
|
|
584
|
+
reportSite(run, method, call);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Rewrites or reports one read of a legacy property on a viewport.
|
|
591
|
+
*/
|
|
592
|
+
function rewriteProperty(run: Run, member: Node): void {
|
|
593
|
+
const object = member.field('object');
|
|
594
|
+
const property = member.field('property');
|
|
595
|
+
const name = property?.text() ?? '';
|
|
596
|
+
const parent = member.parent();
|
|
597
|
+
const evidence = object ? viewportEvidence(object) : undefined;
|
|
598
|
+
|
|
599
|
+
if (
|
|
600
|
+
!evidence ||
|
|
601
|
+
(parent?.kind() === 'call_expression' &&
|
|
602
|
+
parent.field('function')?.id() === member.id())
|
|
603
|
+
) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
if (evidence === 'name') {
|
|
608
|
+
reportSite(run, name, member);
|
|
609
|
+
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const isWrite =
|
|
614
|
+
(parent?.kind() === 'assignment_expression' ||
|
|
615
|
+
parent?.kind() === 'augmented_assignment_expression') &&
|
|
616
|
+
parent.field('left')?.id() === member.id();
|
|
617
|
+
|
|
618
|
+
if (REPORTED_PROPERTIES.has(name) || isWrite) {
|
|
619
|
+
reportSite(run, name, member);
|
|
620
|
+
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (name === 'modality') {
|
|
625
|
+
const utilities = run.imports.ensure('utilities', { at: member });
|
|
626
|
+
|
|
627
|
+
if (
|
|
628
|
+
!utilities ||
|
|
629
|
+
!run.edits.add(
|
|
630
|
+
member.replace(
|
|
631
|
+
`${utilities}.getViewportModality(${unwrap(object).text()})`
|
|
632
|
+
)
|
|
633
|
+
)
|
|
634
|
+
) {
|
|
635
|
+
reportSite(run, name, member);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
run.edits.add(property.replace(RENAMED_PROPERTIES[name]));
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Reports the uses of the removed exports of the core.
|
|
646
|
+
*/
|
|
647
|
+
function reportCoreNames(run: Run): void {
|
|
648
|
+
const names = [...REPORTED_CORE_NAMES].join('|');
|
|
649
|
+
|
|
650
|
+
for (const node of run.rootNode.findAll({
|
|
651
|
+
rule: {
|
|
652
|
+
any: [
|
|
653
|
+
{ kind: 'identifier' },
|
|
654
|
+
{ kind: 'type_identifier' },
|
|
655
|
+
{ kind: 'property_identifier' },
|
|
656
|
+
],
|
|
657
|
+
regex: `^(${names})$`,
|
|
658
|
+
},
|
|
659
|
+
})) {
|
|
660
|
+
if (
|
|
661
|
+
node
|
|
662
|
+
.ancestors()
|
|
663
|
+
.some((ancestor) => ancestor.kind() === 'import_statement')
|
|
664
|
+
) {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const name = node.text();
|
|
669
|
+
const parent = node.parent();
|
|
670
|
+
const fromImport =
|
|
671
|
+
node.kind() !== 'property_identifier' && coreImportOf(node, true);
|
|
672
|
+
const fromUtilities =
|
|
673
|
+
node.kind() === 'property_identifier' &&
|
|
674
|
+
parent?.kind() === 'member_expression' &&
|
|
675
|
+
isCoreExport(parent.field('object'), 'utilities');
|
|
676
|
+
|
|
677
|
+
if (fromImport || fromUtilities) {
|
|
678
|
+
reportSite(run, name, node);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
for (const { specifier, name } of coreReExports(run.rootNode)) {
|
|
683
|
+
if (REPORTED_CORE_NAMES.has(name)) {
|
|
684
|
+
reportSite(run, name, specifier);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Reports the removed members of a rendering engine of the core, such as
|
|
691
|
+
* `renderingEngine.renderFrameOfReference(frameOfReferenceUID)`, also in
|
|
692
|
+
* brackets.
|
|
693
|
+
*/
|
|
694
|
+
function reportEngineMembers(run: Run): void {
|
|
695
|
+
const names = [...REPORTED_ENGINE_MEMBERS].join('|');
|
|
696
|
+
|
|
697
|
+
for (const node of run.rootNode.findAll({
|
|
698
|
+
rule: {
|
|
699
|
+
any: [
|
|
700
|
+
{
|
|
701
|
+
kind: 'member_expression',
|
|
702
|
+
has: { field: 'property', regex: `^(${names})$` },
|
|
703
|
+
},
|
|
704
|
+
{ kind: 'subscript_expression' },
|
|
705
|
+
],
|
|
706
|
+
},
|
|
707
|
+
})) {
|
|
708
|
+
const name =
|
|
709
|
+
node.kind() === 'member_expression'
|
|
710
|
+
? node.field('property')?.text()
|
|
711
|
+
: bracketKey(node);
|
|
712
|
+
|
|
713
|
+
if (
|
|
714
|
+
name &&
|
|
715
|
+
REPORTED_ENGINE_MEMBERS.has(name) &&
|
|
716
|
+
isRenderingEngine(node.field('object'))
|
|
717
|
+
) {
|
|
718
|
+
reportSite(run, name, node);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Reports a bracket access with a string key to a legacy member on a
|
|
725
|
+
* viewport, such as `viewport['getProperties']()`: it names the member that
|
|
726
|
+
* `viewport.getProperties` names, so it is reported where the dot form is
|
|
727
|
+
* rewritten or reported.
|
|
728
|
+
*/
|
|
729
|
+
function reportBracketMembers(run: Run, names: Set<string>): void {
|
|
730
|
+
for (const node of run.rootNode.findAll({
|
|
731
|
+
rule: { kind: 'subscript_expression' },
|
|
732
|
+
})) {
|
|
733
|
+
const name = bracketKey(node);
|
|
734
|
+
const object = node.field('object');
|
|
735
|
+
|
|
736
|
+
if (name && names.has(name) && object && viewportEvidence(object)) {
|
|
737
|
+
reportSite(run, name, node);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Rewrites the members of the legacy viewports that have a fixed 6.0 call:
|
|
744
|
+
* `resetCamera`, `setProperties` of presentation keys, the actor reads, the
|
|
745
|
+
* questions that became functions of `utilities`, and the renamed
|
|
746
|
+
* properties. Every other legacy member on a viewport is reported, and so
|
|
747
|
+
* are the removed helpers of the core and the removed members of a
|
|
748
|
+
* rendering engine.
|
|
749
|
+
*/
|
|
750
|
+
const codemod: Codemod<TSX> = (root) => {
|
|
751
|
+
const rootNode = root.root();
|
|
752
|
+
const run: Run = {
|
|
753
|
+
root,
|
|
754
|
+
rootNode,
|
|
755
|
+
imports: new CoreImports(rootNode),
|
|
756
|
+
edits: new EditSet(),
|
|
757
|
+
};
|
|
758
|
+
const methodNames = [
|
|
759
|
+
...Object.keys(RENAMED_METHODS),
|
|
760
|
+
...Object.keys(ACTOR_READS),
|
|
761
|
+
...Object.keys(UTILITY_CALLS),
|
|
762
|
+
...REPORTED_METHODS,
|
|
763
|
+
'resetCamera',
|
|
764
|
+
'setProperties',
|
|
765
|
+
'setCamera',
|
|
766
|
+
'isOrientationChangeable',
|
|
767
|
+
'getCornerstoneImage',
|
|
768
|
+
'setAverageWhite',
|
|
769
|
+
'setFrameRange',
|
|
770
|
+
];
|
|
771
|
+
const calls = rootNode.findAll({
|
|
772
|
+
rule: {
|
|
773
|
+
kind: 'call_expression',
|
|
774
|
+
has: {
|
|
775
|
+
field: 'function',
|
|
776
|
+
kind: 'member_expression',
|
|
777
|
+
has: { field: 'property', regex: `^(${methodNames.join('|')})$` },
|
|
778
|
+
},
|
|
779
|
+
},
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
for (const call of calls) {
|
|
783
|
+
rewriteCall(run, call);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const propertyNames = [
|
|
787
|
+
...Object.keys(RENAMED_PROPERTIES),
|
|
788
|
+
...REPORTED_PROPERTIES,
|
|
789
|
+
'modality',
|
|
790
|
+
];
|
|
791
|
+
const members = rootNode.findAll({
|
|
792
|
+
rule: {
|
|
793
|
+
kind: 'member_expression',
|
|
794
|
+
has: { field: 'property', regex: `^(${propertyNames.join('|')})$` },
|
|
795
|
+
},
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
for (const member of members) {
|
|
799
|
+
rewriteProperty(run, member);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
reportBracketMembers(run, new Set([...methodNames, ...propertyNames]));
|
|
803
|
+
reportCoreNames(run);
|
|
804
|
+
reportEngineMembers(run);
|
|
805
|
+
|
|
806
|
+
const importEdits = run.imports.edits();
|
|
807
|
+
|
|
808
|
+
if (!run.edits.all().length && !importEdits.length) {
|
|
809
|
+
return null;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
return rootNode.commitEdits([...run.edits.all(), ...importEdits]);
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
export default codemod;
|