@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.
- 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,647 @@
|
|
|
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
|
+
comparisonAt,
|
|
9
|
+
coreImportOf,
|
|
10
|
+
coreReExports,
|
|
11
|
+
coreSpecifiers,
|
|
12
|
+
isCoreExport,
|
|
13
|
+
isCoreNamespace,
|
|
14
|
+
isPure,
|
|
15
|
+
objectEntries,
|
|
16
|
+
referencesOf,
|
|
17
|
+
site,
|
|
18
|
+
} from './lib.ts';
|
|
19
|
+
import type { Node } from './lib.ts';
|
|
20
|
+
|
|
21
|
+
/** Sites that the reader changes. */
|
|
22
|
+
const manual = useMetricAtom('cornerstone3d-6-manual');
|
|
23
|
+
|
|
24
|
+
/** Rewrites at a decision of the migration guide. */
|
|
25
|
+
const review = useMetricAtom('cornerstone3d-6-review');
|
|
26
|
+
|
|
27
|
+
/** The removed functions of the CPU switch and of the generic switch. */
|
|
28
|
+
const SETTING_FUNCTIONS = new Set([
|
|
29
|
+
'setUseCPURendering',
|
|
30
|
+
'resetUseCPURendering',
|
|
31
|
+
'getShouldUseCPURendering',
|
|
32
|
+
'getUseGenericViewport',
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
/** The keys of the configuration that 6.0 removes, as a regular expression. */
|
|
36
|
+
const REMOVED_KEYS =
|
|
37
|
+
'useGenericViewport|useCPURendering|useViewportSamplingForLinear';
|
|
38
|
+
|
|
39
|
+
/** The core functions that take the configuration. */
|
|
40
|
+
const CONFIGURATION_FUNCTIONS = ['init', 'setConfiguration'];
|
|
41
|
+
|
|
42
|
+
/** The expressions that need parentheses before `? :`. */
|
|
43
|
+
const LOW_PRECEDENCE = new Set([
|
|
44
|
+
'ternary_expression',
|
|
45
|
+
'assignment_expression',
|
|
46
|
+
'augmented_assignment_expression',
|
|
47
|
+
'sequence_expression',
|
|
48
|
+
'arrow_function',
|
|
49
|
+
'yield_expression',
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The state of one run of the transform on a file.
|
|
54
|
+
*/
|
|
55
|
+
interface Run {
|
|
56
|
+
root: SgRoot<TSX>;
|
|
57
|
+
rootNode: Node;
|
|
58
|
+
imports: CoreImports;
|
|
59
|
+
edits: EditSet;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A pair of the configuration to remove, with the pair that holds it. */
|
|
63
|
+
interface Removal {
|
|
64
|
+
pair: Node;
|
|
65
|
+
holder: Node;
|
|
66
|
+
rule: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The pairs to remove from one object literal; `outer` when they are pairs
|
|
71
|
+
* that hold objects which lose every key.
|
|
72
|
+
*/
|
|
73
|
+
interface RemovalGroup {
|
|
74
|
+
objectNode: Node;
|
|
75
|
+
pairs: Node[];
|
|
76
|
+
outer: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Returns the key of a pair, without quotes.
|
|
81
|
+
*/
|
|
82
|
+
function keyOf(pair: Node): string {
|
|
83
|
+
const key = pair.field('key');
|
|
84
|
+
|
|
85
|
+
return key?.kind() === 'string'
|
|
86
|
+
? key.text().slice(1, -1)
|
|
87
|
+
: (key?.text() ?? '');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns the pair whose value is the object that holds a pair, when its key
|
|
92
|
+
* is `name`.
|
|
93
|
+
*/
|
|
94
|
+
function holderPair(pair: Node, name: string): Node | undefined {
|
|
95
|
+
const objectNode = pair.parent();
|
|
96
|
+
const holder = objectNode?.parent();
|
|
97
|
+
|
|
98
|
+
return holder?.kind() === 'pair' && keyOf(holder) === name
|
|
99
|
+
? holder
|
|
100
|
+
: undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the edits that remove entries of an object literal, each run of
|
|
105
|
+
* neighbouring entries in one edit with its commas, so that two removals
|
|
106
|
+
* never share a comma.
|
|
107
|
+
*/
|
|
108
|
+
function removeEntries(objectNode: Node, removed: Node[]): Edit[] {
|
|
109
|
+
const ids = new Set(removed.map((entry) => entry.id()));
|
|
110
|
+
const entries = objectNode
|
|
111
|
+
.children()
|
|
112
|
+
.filter((child) => child.isNamed() && child.kind() !== 'comment');
|
|
113
|
+
const edits: Edit[] = [];
|
|
114
|
+
let index = 0;
|
|
115
|
+
|
|
116
|
+
while (index < entries.length) {
|
|
117
|
+
if (!ids.has(entries[index].id())) {
|
|
118
|
+
index += 1;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const first = index;
|
|
123
|
+
|
|
124
|
+
while (index < entries.length && ids.has(entries[index].id())) {
|
|
125
|
+
index += 1;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const last = entries[index - 1];
|
|
129
|
+
const next = entries[index];
|
|
130
|
+
const previous = entries[first - 1];
|
|
131
|
+
|
|
132
|
+
if (next) {
|
|
133
|
+
edits.push({
|
|
134
|
+
startPos: entries[first].range().start.index,
|
|
135
|
+
endPos: next.range().start.index,
|
|
136
|
+
insertedText: '',
|
|
137
|
+
});
|
|
138
|
+
} else if (previous) {
|
|
139
|
+
const comma = previous.next();
|
|
140
|
+
|
|
141
|
+
edits.push({
|
|
142
|
+
startPos:
|
|
143
|
+
comma?.kind() === ','
|
|
144
|
+
? comma.range().start.index
|
|
145
|
+
: previous.range().end.index,
|
|
146
|
+
endPos: last.range().end.index,
|
|
147
|
+
insertedText: '',
|
|
148
|
+
});
|
|
149
|
+
} else {
|
|
150
|
+
edits.push({
|
|
151
|
+
startPos: entries[first].range().start.index,
|
|
152
|
+
endPos: last.range().end.index,
|
|
153
|
+
insertedText: '',
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return edits;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Tells whether an object literal is the one argument of the core `init`.
|
|
163
|
+
*/
|
|
164
|
+
function isInitArgument(objectNode: Node): boolean {
|
|
165
|
+
const args = objectNode.parent();
|
|
166
|
+
const call = args?.parent();
|
|
167
|
+
const namedArgs = args?.children().filter((child) => child.isNamed()) ?? [];
|
|
168
|
+
const callee =
|
|
169
|
+
call?.kind() === 'call_expression' ? call.field('function') : undefined;
|
|
170
|
+
|
|
171
|
+
return Boolean(
|
|
172
|
+
args?.kind() === 'arguments' &&
|
|
173
|
+
namedArgs.length === 1 &&
|
|
174
|
+
callee &&
|
|
175
|
+
(coreImportOf(callee)?.name === 'init' ||
|
|
176
|
+
(callee.kind() === 'member_expression' &&
|
|
177
|
+
callee.field('property')?.text() === 'init' &&
|
|
178
|
+
isCoreNamespace(callee.field('object'))))
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Removes the obsolete pairs of the configuration, each object in one set
|
|
184
|
+
* of edits. An object that loses every key goes with the pair that holds
|
|
185
|
+
* it; an outer object that loses every key becomes `{}`, and `init({})`
|
|
186
|
+
* becomes `init()`. A removal that another edit overlaps is reported.
|
|
187
|
+
*/
|
|
188
|
+
function removeSettings(run: Run, removals: Removal[]): void {
|
|
189
|
+
const groups = new Map<number, RemovalGroup>();
|
|
190
|
+
const addTo = (objectNode: Node, pair: Node, outer: boolean) => {
|
|
191
|
+
const group = groups.get(objectNode.id()) ?? {
|
|
192
|
+
objectNode,
|
|
193
|
+
pairs: [],
|
|
194
|
+
outer,
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
group.pairs.push(pair);
|
|
198
|
+
group.outer ||= outer;
|
|
199
|
+
groups.set(objectNode.id(), group);
|
|
200
|
+
};
|
|
201
|
+
const isEmptied = ({ objectNode, pairs }: RemovalGroup) => {
|
|
202
|
+
const { keys, hasSpread } = objectEntries(objectNode);
|
|
203
|
+
|
|
204
|
+
return !hasSpread && keys.length === pairs.length;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
for (const { pair } of removals) {
|
|
208
|
+
addTo(pair.parent(), pair, false);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
for (const group of [...groups.values()].filter(isEmptied)) {
|
|
212
|
+
const holder = removals.find(
|
|
213
|
+
({ pair }) => pair.id() === group.pairs[0].id()
|
|
214
|
+
).holder;
|
|
215
|
+
|
|
216
|
+
groups.delete(group.objectNode.id());
|
|
217
|
+
addTo(holder.parent(), holder, true);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const failed = new Set<number>();
|
|
221
|
+
|
|
222
|
+
for (const group of groups.values()) {
|
|
223
|
+
const { objectNode, pairs } = group;
|
|
224
|
+
const edits =
|
|
225
|
+
group.outer && isEmptied(group)
|
|
226
|
+
? [
|
|
227
|
+
isInitArgument(objectNode)
|
|
228
|
+
? objectNode.parent().replace('()')
|
|
229
|
+
: objectNode.replace('{}'),
|
|
230
|
+
]
|
|
231
|
+
: removeEntries(objectNode, pairs);
|
|
232
|
+
|
|
233
|
+
if (!run.edits.add(...edits)) {
|
|
234
|
+
pairs.forEach((pair) => failed.add(pair.id()));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
for (const { pair, holder, rule } of removals) {
|
|
239
|
+
if (failed.has(pair.id()) || failed.has(holder.id())) {
|
|
240
|
+
manual.increment(site(run.root, rule, pair));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Tells whether an object literal, or a variable that holds it, is passed to
|
|
247
|
+
* the core `init` or `setConfiguration` in the file.
|
|
248
|
+
*/
|
|
249
|
+
function reachesConfigurationCall(node: Node): boolean {
|
|
250
|
+
let current = node;
|
|
251
|
+
|
|
252
|
+
while (
|
|
253
|
+
[
|
|
254
|
+
'parenthesized_expression',
|
|
255
|
+
'as_expression',
|
|
256
|
+
'satisfies_expression',
|
|
257
|
+
].includes(current.parent()?.kind() ?? '')
|
|
258
|
+
) {
|
|
259
|
+
current = current.parent();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const parent = current.parent();
|
|
263
|
+
|
|
264
|
+
if (parent?.kind() === 'arguments') {
|
|
265
|
+
const callee = parent.parent()?.field('function');
|
|
266
|
+
|
|
267
|
+
return Boolean(
|
|
268
|
+
callee &&
|
|
269
|
+
CONFIGURATION_FUNCTIONS.some((name) => isCoreExport(callee, name))
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (
|
|
274
|
+
parent?.kind() !== 'variable_declarator' ||
|
|
275
|
+
parent.field('value')?.id() !== current.id()
|
|
276
|
+
) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const name = parent.field('name');
|
|
281
|
+
|
|
282
|
+
return Boolean(
|
|
283
|
+
name?.kind() === 'identifier' &&
|
|
284
|
+
referencesOf(name).some(
|
|
285
|
+
(reference) =>
|
|
286
|
+
reference.kind() === 'identifier' &&
|
|
287
|
+
reachesConfigurationCall(reference)
|
|
288
|
+
)
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Returns the outermost object literal that holds a pair through nested
|
|
294
|
+
* pairs.
|
|
295
|
+
*/
|
|
296
|
+
function configurationOf(pair: Node): Node {
|
|
297
|
+
let objectNode = pair.parent();
|
|
298
|
+
|
|
299
|
+
while (
|
|
300
|
+
objectNode.parent()?.kind() === 'pair' &&
|
|
301
|
+
objectNode.parent().parent()?.kind() === 'object'
|
|
302
|
+
) {
|
|
303
|
+
objectNode = objectNode.parent().parent();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return objectNode;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Rewrites the removed keys of the `rendering` configuration of an object
|
|
311
|
+
* that the file passes to `init` or `setConfiguration`. A key of another
|
|
312
|
+
* object, or a key whose value runs code, is reported. A shorthand entry,
|
|
313
|
+
* such as `{ useCPURendering }`, is a key whose value is the name it reads.
|
|
314
|
+
*/
|
|
315
|
+
function rewriteConfiguration(run: Run): void {
|
|
316
|
+
const pairs = run.rootNode.findAll({
|
|
317
|
+
rule: {
|
|
318
|
+
any: [
|
|
319
|
+
{
|
|
320
|
+
kind: 'pair',
|
|
321
|
+
has: {
|
|
322
|
+
field: 'key',
|
|
323
|
+
regex: `^['"]?(${REMOVED_KEYS})['"]?$`,
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
kind: 'shorthand_property_identifier',
|
|
328
|
+
regex: `^(${REMOVED_KEYS})$`,
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
const removals: Removal[] = [];
|
|
335
|
+
|
|
336
|
+
for (const pair of pairs) {
|
|
337
|
+
const isShorthand = pair.kind() === 'shorthand_property_identifier';
|
|
338
|
+
const key = isShorthand ? pair.text() : keyOf(pair);
|
|
339
|
+
const holderName =
|
|
340
|
+
key === 'useViewportSamplingForLinear' ? 'cpuVolume' : 'rendering';
|
|
341
|
+
const holder = holderPair(pair, holderName);
|
|
342
|
+
const rule = `${holderName}.${key}`;
|
|
343
|
+
const value = isShorthand ? pair : pair.field('value');
|
|
344
|
+
|
|
345
|
+
if (!holder) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (!reachesConfigurationCall(configurationOf(pair))) {
|
|
350
|
+
manual.increment(
|
|
351
|
+
site(run.root, `${rule}: not shown to reach init()`, pair)
|
|
352
|
+
);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (value && callsSettingFunction(value)) {
|
|
357
|
+
manual.increment(
|
|
358
|
+
site(
|
|
359
|
+
run.root,
|
|
360
|
+
`${rule}: its value calls a removed setting function`,
|
|
361
|
+
pair
|
|
362
|
+
)
|
|
363
|
+
);
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const removes = key !== 'useCPURendering' || value?.text() === 'false';
|
|
368
|
+
|
|
369
|
+
if (removes && (!value || !(isShorthand || isPure(value)))) {
|
|
370
|
+
manual.increment(site(run.root, `${rule}: its value has effects`, pair));
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (removes) {
|
|
375
|
+
removals.push({ pair, holder, rule });
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const { keys } = objectEntries(pair.parent());
|
|
380
|
+
|
|
381
|
+
if (keys.includes('planar')) {
|
|
382
|
+
manual.increment(site(run.root, 'rendering.useCPURendering', pair));
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const backend =
|
|
387
|
+
value?.text() === 'true'
|
|
388
|
+
? "'cpu'"
|
|
389
|
+
: `${LOW_PRECEDENCE.has(value.kind()) ? `(${value.text()})` : value.text()} ? 'cpu' : 'auto'`;
|
|
390
|
+
|
|
391
|
+
if (run.edits.add(pair.replace(`planar: { renderBackend: ${backend} }`))) {
|
|
392
|
+
review.increment(
|
|
393
|
+
site(
|
|
394
|
+
run.root,
|
|
395
|
+
'rendering.useCPURendering: a 3D viewport stays on the GPU',
|
|
396
|
+
pair
|
|
397
|
+
)
|
|
398
|
+
);
|
|
399
|
+
} else {
|
|
400
|
+
manual.increment(site(run.root, rule, pair));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
removeSettings(run, removals);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Tells whether an expression refers to a removed setting function of the
|
|
409
|
+
* core, which the function pass rewrites: the pair that holds it is
|
|
410
|
+
* reported, so the two rewrites never replace the same text.
|
|
411
|
+
*/
|
|
412
|
+
function callsSettingFunction(value: Node): boolean {
|
|
413
|
+
return [
|
|
414
|
+
value,
|
|
415
|
+
...value.findAll({
|
|
416
|
+
rule: { any: [{ kind: 'identifier' }, { kind: 'member_expression' }] },
|
|
417
|
+
}),
|
|
418
|
+
].some((node) => {
|
|
419
|
+
if (node.kind() === 'identifier') {
|
|
420
|
+
return SETTING_FUNCTIONS.has(coreImportOf(node)?.name ?? '');
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const object = node.field('object');
|
|
424
|
+
|
|
425
|
+
return Boolean(
|
|
426
|
+
node.kind() === 'member_expression' &&
|
|
427
|
+
SETTING_FUNCTIONS.has(node.field('property')?.text() ?? '') &&
|
|
428
|
+
object?.kind() === 'identifier' &&
|
|
429
|
+
isCoreNamespace(object)
|
|
430
|
+
);
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Returns the expression that names a core function at a call, the way the
|
|
436
|
+
* old call named its function.
|
|
437
|
+
*/
|
|
438
|
+
function functionRef(
|
|
439
|
+
run: Run,
|
|
440
|
+
call: Node,
|
|
441
|
+
callee: Node,
|
|
442
|
+
name: string
|
|
443
|
+
): string | undefined {
|
|
444
|
+
if (callee.kind() === 'member_expression') {
|
|
445
|
+
return `${callee.field('object').text()}.${name}`;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return run.imports.ensure(name, { at: call });
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Rewrites one call of a removed setting function. Returns whether the call
|
|
453
|
+
* changed. A spread argument, and a call inside text that another rewrite
|
|
454
|
+
* replaces, are reported.
|
|
455
|
+
*/
|
|
456
|
+
function rewriteCall(
|
|
457
|
+
run: Run,
|
|
458
|
+
call: Node,
|
|
459
|
+
callee: Node,
|
|
460
|
+
name: string
|
|
461
|
+
): boolean {
|
|
462
|
+
const args = call
|
|
463
|
+
.field('arguments')
|
|
464
|
+
.children()
|
|
465
|
+
.filter((child) => child.isNamed() && child.kind() !== 'comment');
|
|
466
|
+
|
|
467
|
+
if (args.some((arg) => arg.kind() === 'spread_element')) {
|
|
468
|
+
manual.increment(site(run.root, `${name}: a spread argument`, call));
|
|
469
|
+
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (
|
|
474
|
+
name === 'getUseGenericViewport' ||
|
|
475
|
+
(name === 'setUseCPURendering' && args.length !== 1)
|
|
476
|
+
) {
|
|
477
|
+
manual.increment(site(run.root, `${name}()`, call));
|
|
478
|
+
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (run.edits.covers(call)) {
|
|
483
|
+
manual.increment(site(run.root, name, call));
|
|
484
|
+
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const newName =
|
|
489
|
+
name === 'getShouldUseCPURendering'
|
|
490
|
+
? 'getEffectiveRenderBackend'
|
|
491
|
+
: 'setRenderBackend';
|
|
492
|
+
const ref = functionRef(run, call, callee, newName);
|
|
493
|
+
|
|
494
|
+
if (!ref) {
|
|
495
|
+
manual.increment(
|
|
496
|
+
site(run.root, `${name}: ${newName} cannot be imported`, call)
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (name === 'getShouldUseCPURendering') {
|
|
503
|
+
return run.edits.add(
|
|
504
|
+
call.replace(comparisonAt(call, `${ref}() === 'cpu'`))
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (name === 'resetUseCPURendering') {
|
|
509
|
+
return run.edits.add(call.replace(`${ref}('auto')`));
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const [arg] = args;
|
|
513
|
+
const backend =
|
|
514
|
+
arg.text() === 'true'
|
|
515
|
+
? "'cpu'"
|
|
516
|
+
: arg.text() === 'false'
|
|
517
|
+
? "'auto'"
|
|
518
|
+
: `${LOW_PRECEDENCE.has(arg.kind()) ? `(${arg.text()})` : arg.text()} ? 'cpu' : 'auto'`;
|
|
519
|
+
const changed = run.edits.add(call.replace(`${ref}(${backend})`));
|
|
520
|
+
|
|
521
|
+
if (changed) {
|
|
522
|
+
review.increment(
|
|
523
|
+
site(
|
|
524
|
+
run.root,
|
|
525
|
+
'setUseCPURendering: it marked the library initialized, call init() first',
|
|
526
|
+
call
|
|
527
|
+
)
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return changed;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Rewrites a reference to a removed setting function when it is the callee
|
|
536
|
+
* of a call, and reports it otherwise. Returns whether it changed.
|
|
537
|
+
*/
|
|
538
|
+
function rewriteReference(run: Run, callee: Node, name: string): boolean {
|
|
539
|
+
const call = callee.parent();
|
|
540
|
+
const isCall =
|
|
541
|
+
call?.kind() === 'call_expression' &&
|
|
542
|
+
call.field('function')?.id() === callee.id();
|
|
543
|
+
|
|
544
|
+
if (!isCall) {
|
|
545
|
+
manual.increment(site(run.root, name, callee));
|
|
546
|
+
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
return rewriteCall(run, call, callee, name);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Rewrites the calls of the removed setting functions, through each named
|
|
555
|
+
* import with its local name or through the core namespace. A named import
|
|
556
|
+
* goes when every reference to it changed.
|
|
557
|
+
*/
|
|
558
|
+
function rewriteFunctions(run: Run): void {
|
|
559
|
+
for (const { name, local } of coreSpecifiers(run.rootNode)) {
|
|
560
|
+
if (!SETTING_FUNCTIONS.has(name)) {
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
let left = 0;
|
|
565
|
+
|
|
566
|
+
for (const reference of referencesOf(local)) {
|
|
567
|
+
const isIdentifier = reference.kind() === 'identifier';
|
|
568
|
+
|
|
569
|
+
if (!isIdentifier) {
|
|
570
|
+
manual.increment(site(run.root, name, reference));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
left += isIdentifier && rewriteReference(run, reference, name) ? 0 : 1;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (!left) {
|
|
577
|
+
run.imports.remove(name, local.text());
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
for (const member of run.rootNode.findAll({
|
|
582
|
+
rule: {
|
|
583
|
+
kind: 'member_expression',
|
|
584
|
+
has: {
|
|
585
|
+
field: 'property',
|
|
586
|
+
regex: `^(${[...SETTING_FUNCTIONS].join('|')})$`,
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
})) {
|
|
590
|
+
const object = member.field('object');
|
|
591
|
+
|
|
592
|
+
if (object?.kind() === 'identifier' && isCoreNamespace(object)) {
|
|
593
|
+
rewriteReference(run, member, member.field('property').text());
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
for (const { specifier, name } of coreReExports(run.rootNode)) {
|
|
598
|
+
if (SETTING_FUNCTIONS.has(name)) {
|
|
599
|
+
manual.increment(site(run.root, name, specifier));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
for (const node of run.rootNode.findAll({
|
|
604
|
+
rule: { kind: 'subscript_expression' },
|
|
605
|
+
})) {
|
|
606
|
+
const name = bracketKey(node) ?? '';
|
|
607
|
+
const object = node.field('object');
|
|
608
|
+
|
|
609
|
+
if (
|
|
610
|
+
SETTING_FUNCTIONS.has(name) &&
|
|
611
|
+
object?.kind() === 'identifier' &&
|
|
612
|
+
isCoreNamespace(object)
|
|
613
|
+
) {
|
|
614
|
+
manual.increment(site(run.root, name, node));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Rewrites the settings that Cornerstone3D 6.0 removes:
|
|
621
|
+
* `rendering.useGenericViewport` and `useViewportSamplingForLinear` go,
|
|
622
|
+
* `rendering.useCPURendering` becomes `rendering.planar.renderBackend`, and
|
|
623
|
+
* the CPU functions become `setRenderBackend` and `getEffectiveRenderBackend`.
|
|
624
|
+
* `getUseGenericViewport()` is reported.
|
|
625
|
+
*/
|
|
626
|
+
const codemod: Codemod<TSX> = (root) => {
|
|
627
|
+
const rootNode = root.root();
|
|
628
|
+
const run: Run = {
|
|
629
|
+
root,
|
|
630
|
+
rootNode,
|
|
631
|
+
imports: new CoreImports(rootNode),
|
|
632
|
+
edits: new EditSet(),
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
rewriteConfiguration(run);
|
|
636
|
+
rewriteFunctions(run);
|
|
637
|
+
|
|
638
|
+
const importEdits = run.imports.edits();
|
|
639
|
+
|
|
640
|
+
if (!run.edits.all().length && !importEdits.length) {
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return rootNode.commitEdits([...run.edits.all(), ...importEdits]);
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
export default codemod;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as cornerstone from '@cornerstonejs/core';
|
|
3
|
+
import { getUseGenericViewport, setUseCPURendering } from '@cornerstonejs/core';
|
|
4
|
+
|
|
5
|
+
cornerstone.setRenderBackend('cpu');
|
|
6
|
+
cornerstone.init({
|
|
7
|
+
rendering: { useCPURendering: true, planar: { sliceFirst: false } },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export function Toggle() {
|
|
11
|
+
const handlers = [setUseCPURendering];
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<button onClick={() => setUseCPURendering(true, false)}>
|
|
15
|
+
{String(getUseGenericViewport())} {handlers.length}
|
|
16
|
+
</button>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as cornerstone from '@cornerstonejs/core';
|
|
3
|
+
import { getUseGenericViewport, setUseCPURendering } from '@cornerstonejs/core';
|
|
4
|
+
|
|
5
|
+
cornerstone.setUseCPURendering(true);
|
|
6
|
+
cornerstone.init({
|
|
7
|
+
rendering: { useCPURendering: true, planar: { sliceFirst: false } },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export function Toggle() {
|
|
11
|
+
const handlers = [setUseCPURendering];
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<button onClick={() => setUseCPURendering(true, false)}>
|
|
15
|
+
{String(getUseGenericViewport())} {handlers.length}
|
|
16
|
+
</button>
|
|
17
|
+
);
|
|
18
|
+
}
|