@cornerstonejs/codemods 6.0.0-beta.0 → 6.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.oxlintrc.json +4 -0
  2. package/package.json +1 -1
  3. package/registry/cornerstone3d/6/README.md +46 -0
  4. package/registry/cornerstone3d/6/classes-and-types/README.md +16 -0
  5. package/registry/cornerstone3d/6/classes-and-types/scripts/classes-and-types.ts +32 -90
  6. package/registry/cornerstone3d/6/classes-and-types/scripts/lib.ts +864 -16
  7. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/expected.js +31 -0
  8. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/input.js +31 -0
  9. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
  10. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +34 -0
  11. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +34 -0
  12. package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
  13. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/metrics.json +10 -0
  14. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/expected.ts +61 -0
  15. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/input.ts +65 -0
  16. package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/metrics.json +36 -0
  17. package/registry/cornerstone3d/6/display-sets/README.md +4 -0
  18. package/registry/cornerstone3d/6/display-sets/scripts/display-sets.ts +4 -2
  19. package/registry/cornerstone3d/6/display-sets/scripts/lib.ts +864 -16
  20. package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/expected.js +45 -0
  21. package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/input.js +39 -0
  22. package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/metrics.json +84 -0
  23. package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +42 -0
  24. package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +42 -0
  25. package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
  26. package/registry/cornerstone3d/6/events/README.md +4 -0
  27. package/registry/cornerstone3d/6/events/scripts/events.ts +5 -3
  28. package/registry/cornerstone3d/6/events/scripts/lib.ts +864 -16
  29. package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
  30. package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/input.js +18 -0
  31. package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/metrics.json +38 -0
  32. package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
  33. package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
  34. package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
  35. package/registry/cornerstone3d/6/settings/README.md +4 -0
  36. package/registry/cornerstone3d/6/settings/scripts/lib.ts +864 -16
  37. package/registry/cornerstone3d/6/settings/scripts/settings.ts +5 -3
  38. package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
  39. package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/input.js +18 -0
  40. package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
  41. package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
  42. package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
  43. package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
  44. package/registry/cornerstone3d/6/tools/README.md +5 -0
  45. package/registry/cornerstone3d/6/tools/scripts/lib.ts +864 -16
  46. package/registry/cornerstone3d/6/tools/scripts/tools.ts +6 -3
  47. package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/expected.js +35 -0
  48. package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/input.js +35 -0
  49. package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/metrics.json +52 -0
  50. package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +38 -0
  51. package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +38 -0
  52. package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
  53. package/registry/cornerstone3d/6/viewport-members/README.md +5 -0
  54. package/registry/cornerstone3d/6/viewport-members/scripts/lib.ts +864 -16
  55. package/registry/cornerstone3d/6/viewport-members/scripts/viewport-members.ts +5 -3
  56. package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/expected.js +41 -0
  57. package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/input.js +41 -0
  58. package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/metrics.json +108 -0
  59. package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +44 -0
  60. package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +44 -0
  61. package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
  62. package/registry/cornerstone3d/6/viewport-types/README.md +35 -0
  63. package/registry/cornerstone3d/6/viewport-types/scripts/lib.ts +864 -16
  64. package/registry/cornerstone3d/6/viewport-types/scripts/viewport-types.ts +192 -4
  65. package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/expected.js +76 -0
  66. package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/input.js +76 -0
  67. package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/metrics.json +102 -0
  68. package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +79 -0
  69. package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +79 -0
  70. package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
  71. package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/expected.js +78 -0
  72. package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/input.js +78 -0
  73. package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/metrics.json +12 -0
  74. package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/expected.ts +173 -0
  75. package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/input.ts +173 -0
  76. package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/metrics.json +166 -0
  77. package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/expected.ts +103 -0
  78. package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/input.ts +103 -0
  79. package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/metrics.json +78 -0
@@ -3,6 +3,9 @@ import type TSX from 'codemod:ast-grep/langs/tsx';
3
3
  import { useMetricAtom } from 'codemod:metrics';
4
4
  import {
5
5
  EditSet,
6
+ HeldMetric,
7
+ analysed,
8
+ definitionAt,
6
9
  importSource,
7
10
  isNameTaken,
8
11
  referencesOf,
@@ -11,7 +14,7 @@ import {
11
14
  import type { Node } from './lib.ts';
12
15
 
13
16
  /** Sites that the reader changes. */
14
- const manual = useMetricAtom('cornerstone3d-6-manual');
17
+ const manual = new HeldMetric(useMetricAtom('cornerstone3d-6-manual'));
15
18
 
16
19
  /** The package of the tools. */
17
20
  const TOOLS_PACKAGE = '@cornerstonejs/tools';
@@ -378,7 +381,7 @@ function moveCapabilityReExport(run: Run, statement: Node): void {
378
381
  * namespace import of the tools.
379
382
  */
380
383
  function isToolsBinding(identifier: Node, name: string): boolean {
381
- const target = identifier.definition()?.node;
384
+ const target = definitionAt(identifier)?.node;
382
385
  const holder = target?.kind() === 'identifier' ? target.parent() : target;
383
386
  const statement = holder
384
387
  ?.ancestors()
@@ -514,4 +517,4 @@ const codemod: Codemod<TSX> = (root) => {
514
517
  return rootNode.commitEdits(run.edits.all());
515
518
  };
516
519
 
517
- export default codemod;
520
+ export default analysed(codemod, manual);
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import * as cornerstoneTools from '@cornerstonejs/tools';
3
+ import { utilities as toolsUtilities } from '@cornerstonejs/tools';
4
+ import addVolumesAsIndependentComponents from '@cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents';
5
+ import { getSlabThicknessOrDefault } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
6
+ import {
7
+ viewportSupportsStackCompatibility,
8
+ } from '@cornerstonejs/tools/utilities/viewportCapabilities';
9
+ import {
10
+ createLegacyVolumeLabelmapPlan,
11
+ legacyHelper,
12
+ } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan';
13
+
14
+ export function Panel({ viewport }) {
15
+ toolsUtilities.spatial.rotateViewportAroundWorldPoint(
16
+ viewport,
17
+ [0, 0, 0],
18
+ 90
19
+ );
20
+ cornerstoneTools.utilities.spatial.rotateViewportAroundWorldPoint(
21
+ viewport,
22
+ [0, 0, 0],
23
+ 90
24
+ );
25
+
26
+ return (
27
+ <span>
28
+ {String(addVolumesAsIndependentComponents)}{' '}
29
+ {getSlabThicknessOrDefault(viewport)}
30
+ {String(viewportSupportsStackCompatibility(viewport))}{' '}
31
+ {String(createLegacyVolumeLabelmapPlan)}
32
+ {String(legacyHelper)}
33
+ </span>
34
+ );
35
+ }
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import * as cornerstoneTools from '@cornerstonejs/tools';
3
+ import { utilities as toolsUtilities } from '@cornerstonejs/tools';
4
+ import addVolumesAsIndependentComponents from '@cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents';
5
+ import { getSlabThicknessOrDefault } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
6
+ import {
7
+ viewportSupportsStackCompatibility,
8
+ } from '@cornerstonejs/tools/utilities/viewportCapabilities';
9
+ import {
10
+ createLegacyVolumeLabelmapPlan,
11
+ legacyHelper,
12
+ } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan';
13
+
14
+ export function Panel({ viewport }) {
15
+ toolsUtilities.spatial.rotateViewportAroundWorldPoint(
16
+ viewport,
17
+ [0, 0, 0],
18
+ 90
19
+ );
20
+ cornerstoneTools.utilities.spatial.rotateViewportAroundWorldPoint(
21
+ viewport,
22
+ [0, 0, 0],
23
+ 90
24
+ );
25
+
26
+ return (
27
+ <span>
28
+ {String(addVolumesAsIndependentComponents)}{' '}
29
+ {getSlabThicknessOrDefault(viewport)}
30
+ {String(viewportSupportsStackCompatibility(viewport))}{' '}
31
+ {String(createLegacyVolumeLabelmapPlan)}
32
+ {String(legacyHelper)}
33
+ </span>
34
+ );
35
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "cornerstone3d-6-manual": [
3
+ {
4
+ "cardinality": {
5
+ "file": "input.js",
6
+ "line": "11",
7
+ "rule": "import of @cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan"
8
+ },
9
+ "count": 1
10
+ },
11
+ {
12
+ "cardinality": {
13
+ "file": "input.js",
14
+ "line": "15",
15
+ "rule": "rotateViewportAroundWorldPoint"
16
+ },
17
+ "count": 1
18
+ },
19
+ {
20
+ "cardinality": {
21
+ "file": "input.js",
22
+ "line": "20",
23
+ "rule": "rotateViewportAroundWorldPoint"
24
+ },
25
+ "count": 1
26
+ },
27
+ {
28
+ "cardinality": {
29
+ "file": "input.js",
30
+ "line": "4",
31
+ "rule": "import of @cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents"
32
+ },
33
+ "count": 1
34
+ },
35
+ {
36
+ "cardinality": {
37
+ "file": "input.js",
38
+ "line": "5",
39
+ "rule": "getSlabThicknessOrDefault"
40
+ },
41
+ "count": 1
42
+ },
43
+ {
44
+ "cardinality": {
45
+ "file": "input.js",
46
+ "line": "7",
47
+ "rule": "viewportSupportsStackCompatibility"
48
+ },
49
+ "count": 1
50
+ }
51
+ ]
52
+ }
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import * as cornerstoneTools from '@cornerstonejs/tools';
3
+ import { utilities as toolsUtilities } from '@cornerstonejs/tools';
4
+ import addVolumesAsIndependentComponents from '@cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents';
5
+ import { getSlabThicknessOrDefault } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
6
+ import {
7
+ viewportSupportsStackCompatibility,
8
+ } from '@cornerstonejs/tools/utilities/viewportCapabilities';
9
+ import {
10
+ createLegacyVolumeLabelmapPlan,
11
+ legacyHelper,
12
+ } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan';
13
+
14
+ export function Panel({ viewport }) {
15
+ toolsUtilities.spatial.rotateViewportAroundWorldPoint(
16
+ viewport,
17
+ [0, 0, 0],
18
+ 90
19
+ );
20
+ cornerstoneTools.utilities.spatial.rotateViewportAroundWorldPoint(
21
+ viewport,
22
+ [0, 0, 0],
23
+ 90
24
+ );
25
+
26
+ return (
27
+ <span>
28
+ {String(addVolumesAsIndependentComponents)}{' '}
29
+ {getSlabThicknessOrDefault(viewport)}
30
+ {String(viewportSupportsStackCompatibility(viewport))}{' '}
31
+ {String(createLegacyVolumeLabelmapPlan)}
32
+ {String(legacyHelper)}
33
+ </span>
34
+ );
35
+ }
36
+
37
+ const twice = 1;
38
+ const twice = 2;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import * as cornerstoneTools from '@cornerstonejs/tools';
3
+ import { utilities as toolsUtilities } from '@cornerstonejs/tools';
4
+ import addVolumesAsIndependentComponents from '@cornerstonejs/tools/tools/displayTools/Labelmap/addVolumesAsIndependentComponents';
5
+ import { getSlabThicknessOrDefault } from '@cornerstonejs/tools/utilities/genericViewportToolHelpers';
6
+ import {
7
+ viewportSupportsStackCompatibility,
8
+ } from '@cornerstonejs/tools/utilities/viewportCapabilities';
9
+ import {
10
+ createLegacyVolumeLabelmapPlan,
11
+ legacyHelper,
12
+ } from '@cornerstonejs/tools/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan';
13
+
14
+ export function Panel({ viewport }) {
15
+ toolsUtilities.spatial.rotateViewportAroundWorldPoint(
16
+ viewport,
17
+ [0, 0, 0],
18
+ 90
19
+ );
20
+ cornerstoneTools.utilities.spatial.rotateViewportAroundWorldPoint(
21
+ viewport,
22
+ [0, 0, 0],
23
+ 90
24
+ );
25
+
26
+ return (
27
+ <span>
28
+ {String(addVolumesAsIndependentComponents)}{' '}
29
+ {getSlabThicknessOrDefault(viewport)}
30
+ {String(viewportSupportsStackCompatibility(viewport))}{' '}
31
+ {String(createLegacyVolumeLabelmapPlan)}
32
+ {String(legacyHelper)}
33
+ </span>
34
+ );
35
+ }
36
+
37
+ const twice = 1;
38
+ const twice = 2;
@@ -0,0 +1,12 @@
1
+ {
2
+ "cornerstone3d-6-manual": [
3
+ {
4
+ "cardinality": {
5
+ "file": "input.tsx",
6
+ "line": "1",
7
+ "rule": "the file was not analysed: Identifier `twice` has already been declared"
8
+ },
9
+ "count": 1
10
+ }
11
+ ]
12
+ }
@@ -87,6 +87,11 @@ lists the actors of labelmaps, surfaces and the images of a stack, whose
87
87
  `referencedId` is not a volume id or is undefined. Keep the ids that
88
88
  `viewport.hasVolumeId(id)` takes where only the volumes count.
89
89
 
90
+ - Manual, at line 1: `the file was not analysed:` with the reason, for a
91
+ file whose names cannot be looked up (the tool cannot read it, or a name
92
+ is declared twice in one scope). The file stays as it is. See the README
93
+ of `@cornerstonejs/cornerstone3d-6`.
94
+
90
95
  ## Development
91
96
 
92
97
  From `packages/codemods`: