@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.
- package/.oxlintrc.json +4 -0
- package/package.json +1 -1
- package/registry/cornerstone3d/6/README.md +46 -0
- package/registry/cornerstone3d/6/classes-and-types/README.md +16 -0
- package/registry/cornerstone3d/6/classes-and-types/scripts/classes-and-types.ts +32 -90
- package/registry/cornerstone3d/6/classes-and-types/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/expected.js +31 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/input.js +31 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +34 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +34 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/metrics.json +10 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/expected.ts +61 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/input.ts +65 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/metrics.json +36 -0
- package/registry/cornerstone3d/6/display-sets/README.md +4 -0
- package/registry/cornerstone3d/6/display-sets/scripts/display-sets.ts +4 -2
- package/registry/cornerstone3d/6/display-sets/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/expected.js +45 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/input.js +39 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/metrics.json +84 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/events/README.md +4 -0
- package/registry/cornerstone3d/6/events/scripts/events.ts +5 -3
- package/registry/cornerstone3d/6/events/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/input.js +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/metrics.json +38 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/settings/README.md +4 -0
- package/registry/cornerstone3d/6/settings/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/settings/scripts/settings.ts +5 -3
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/input.js +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/tools/README.md +5 -0
- package/registry/cornerstone3d/6/tools/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/tools/scripts/tools.ts +6 -3
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/expected.js +35 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/input.js +35 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/metrics.json +52 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +38 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +38 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-members/README.md +5 -0
- package/registry/cornerstone3d/6/viewport-members/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/viewport-members/scripts/viewport-members.ts +5 -3
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/expected.js +41 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/input.js +41 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/metrics.json +108 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +44 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +44 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/README.md +35 -0
- package/registry/cornerstone3d/6/viewport-types/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/viewport-types/scripts/viewport-types.ts +192 -4
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/expected.js +76 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/input.js +76 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/metrics.json +102 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +79 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +79 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/expected.js +78 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/input.js +78 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/expected.ts +173 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/input.ts +173 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/metrics.json +166 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/expected.ts +103 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/input.ts +103 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/metrics.json +78 -0
|
@@ -4,6 +4,8 @@ import { useMetricAtom } from 'codemod:metrics';
|
|
|
4
4
|
import {
|
|
5
5
|
CoreImports,
|
|
6
6
|
EditSet,
|
|
7
|
+
HeldMetric,
|
|
8
|
+
analysed,
|
|
7
9
|
bracketKey,
|
|
8
10
|
comparisonAt,
|
|
9
11
|
coreImportOf,
|
|
@@ -19,10 +21,10 @@ import {
|
|
|
19
21
|
import type { Node } from './lib.ts';
|
|
20
22
|
|
|
21
23
|
/** Sites that the reader changes. */
|
|
22
|
-
const manual = useMetricAtom('cornerstone3d-6-manual');
|
|
24
|
+
const manual = new HeldMetric(useMetricAtom('cornerstone3d-6-manual'));
|
|
23
25
|
|
|
24
26
|
/** Rewrites at a decision of the migration guide. */
|
|
25
|
-
const review = useMetricAtom('cornerstone3d-6-review');
|
|
27
|
+
const review = new HeldMetric(useMetricAtom('cornerstone3d-6-review'));
|
|
26
28
|
|
|
27
29
|
/** The removed functions of the CPU switch and of the generic switch. */
|
|
28
30
|
const SETTING_FUNCTIONS = new Set([
|
|
@@ -644,4 +646,4 @@ const codemod: Codemod<TSX> = (root) => {
|
|
|
644
646
|
return rootNode.commitEdits([...run.edits.all(), ...importEdits]);
|
|
645
647
|
};
|
|
646
648
|
|
|
647
|
-
export default codemod;
|
|
649
|
+
export default analysed(codemod, manual, review);
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cornerstone3d-6-manual": [
|
|
3
|
+
{
|
|
4
|
+
"cardinality": {
|
|
5
|
+
"file": "input.js",
|
|
6
|
+
"line": "11",
|
|
7
|
+
"rule": "setUseCPURendering"
|
|
8
|
+
},
|
|
9
|
+
"count": 1
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"cardinality": {
|
|
13
|
+
"file": "input.js",
|
|
14
|
+
"line": "14",
|
|
15
|
+
"rule": "setUseCPURendering()"
|
|
16
|
+
},
|
|
17
|
+
"count": 1
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"cardinality": {
|
|
21
|
+
"file": "input.js",
|
|
22
|
+
"line": "15",
|
|
23
|
+
"rule": "getUseGenericViewport()"
|
|
24
|
+
},
|
|
25
|
+
"count": 1
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"cardinality": {
|
|
29
|
+
"file": "input.js",
|
|
30
|
+
"line": "7",
|
|
31
|
+
"rule": "rendering.useCPURendering"
|
|
32
|
+
},
|
|
33
|
+
"count": 1
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"cornerstone3d-6-review": [
|
|
37
|
+
{
|
|
38
|
+
"cardinality": {
|
|
39
|
+
"file": "input.js",
|
|
40
|
+
"line": "5",
|
|
41
|
+
"rule": "setUseCPURendering: it marked the library initialized, call init() first"
|
|
42
|
+
},
|
|
43
|
+
"count": 1
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
19
|
+
|
|
20
|
+
const twice = 1;
|
|
21
|
+
const twice = 2;
|
package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/input.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
19
|
+
|
|
20
|
+
const twice = 1;
|
|
21
|
+
const twice = 2;
|
|
@@ -45,6 +45,11 @@ longer resolves); a dynamic `import()` or a `require()` of a module that
|
|
|
45
45
|
6.0 moves or deletes whole;
|
|
46
46
|
`utilities.spatial.rotateViewportAroundWorldPoint`.
|
|
47
47
|
|
|
48
|
+
Also manual, at line 1: `the file was not analysed:` with the reason, for a
|
|
49
|
+
file whose names cannot be looked up (the tool cannot read it, or a name is
|
|
50
|
+
declared twice in one scope). The file stays as it is. See the README of
|
|
51
|
+
`@cornerstonejs/cornerstone3d-6`.
|
|
52
|
+
|
|
48
53
|
## Development
|
|
49
54
|
|
|
50
55
|
From `packages/codemods`:
|