@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,27 +4,34 @@ import { useMetricAtom } from 'codemod:metrics';
|
|
|
4
4
|
import {
|
|
5
5
|
CoreImports,
|
|
6
6
|
EditSet,
|
|
7
|
+
HeldMetric,
|
|
8
|
+
analysed,
|
|
7
9
|
bracketKey,
|
|
8
10
|
declarationNodeOf,
|
|
11
|
+
enclosingFunction,
|
|
9
12
|
indentOf,
|
|
10
13
|
isCoreEnum,
|
|
11
14
|
isMountedBefore,
|
|
12
15
|
isRenderingEngine,
|
|
16
|
+
isStableBinding,
|
|
17
|
+
mergedOperands,
|
|
13
18
|
methodCall,
|
|
14
19
|
objectEntries,
|
|
15
20
|
referencesOf,
|
|
16
21
|
site,
|
|
17
22
|
staticKeyName,
|
|
23
|
+
textAfterEdits,
|
|
18
24
|
unwrap,
|
|
19
25
|
viewportEvidence,
|
|
26
|
+
writtenValues,
|
|
20
27
|
} from './lib.ts';
|
|
21
28
|
import type { Node, ViewportEvidence } from './lib.ts';
|
|
22
29
|
|
|
23
30
|
/** Sites that the reader changes. */
|
|
24
|
-
const manual = useMetricAtom('cornerstone3d-6-manual');
|
|
31
|
+
const manual = new HeldMetric(useMetricAtom('cornerstone3d-6-manual'));
|
|
25
32
|
|
|
26
33
|
/** Rewrites at a decision of the migration guide. */
|
|
27
|
-
const review = useMetricAtom('cornerstone3d-6-review');
|
|
34
|
+
const review = new HeldMetric(useMetricAtom('cornerstone3d-6-review'));
|
|
28
35
|
|
|
29
36
|
/** The deprecated `_NEXT` members and their plain names. */
|
|
30
37
|
const NEXT_MEMBERS: Record<string, string> = {
|
|
@@ -64,6 +71,9 @@ const INPUT_KEYS = ['viewportId', 'element'];
|
|
|
64
71
|
/** The methods of a rendering engine that take viewport inputs. */
|
|
65
72
|
const INPUT_METHODS = new Set(['enableElement', 'setViewports']);
|
|
66
73
|
|
|
74
|
+
/** The longest chain of names that a returned value is followed through. */
|
|
75
|
+
const MAX_NAME_DEPTH = 4;
|
|
76
|
+
|
|
67
77
|
/** The parents through which a viewport input keeps flowing to a call. */
|
|
68
78
|
const FLOW_KINDS = new Set([
|
|
69
79
|
'parenthesized_expression',
|
|
@@ -648,12 +658,188 @@ function reportBracketMembers(run: Run): void {
|
|
|
648
658
|
}
|
|
649
659
|
}
|
|
650
660
|
|
|
661
|
+
/**
|
|
662
|
+
* Returns the values that a name holds: the value of a `const`, or every
|
|
663
|
+
* value of a `let` or a `var` that the file writes only as `name = value`.
|
|
664
|
+
* A parameter, a destructured name and a name written in another way give
|
|
665
|
+
* nothing.
|
|
666
|
+
*/
|
|
667
|
+
function valuesOfName(identifier: Node): Node[] {
|
|
668
|
+
const declaration = declarationNodeOf(identifier);
|
|
669
|
+
const holder = declaration?.parent();
|
|
670
|
+
|
|
671
|
+
if (
|
|
672
|
+
!declaration ||
|
|
673
|
+
holder?.kind() !== 'variable_declarator' ||
|
|
674
|
+
holder.field('name')?.id() !== declaration.id()
|
|
675
|
+
) {
|
|
676
|
+
return [];
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (!isStableBinding(declaration)) {
|
|
680
|
+
return writtenValues(declaration) ?? [];
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const value = holder.field('value');
|
|
684
|
+
|
|
685
|
+
return value ? [value] : [];
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Returns the members of the core `ViewportType` that an expression can
|
|
690
|
+
* give: the member itself, each branch of a conditional, and each value of
|
|
691
|
+
* a name. Any other expression gives nothing.
|
|
692
|
+
*/
|
|
693
|
+
function typeMembersOf(expression: Node, depth = 0): Node[] {
|
|
694
|
+
const value = unwrap(expression);
|
|
695
|
+
const kind = value.kind();
|
|
696
|
+
|
|
697
|
+
if (kind === 'member_expression') {
|
|
698
|
+
return isCoreEnum(value.field('object'), 'ViewportType') ? [value] : [];
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (kind === 'ternary_expression') {
|
|
702
|
+
return ['consequence', 'alternative'].flatMap((branch) => {
|
|
703
|
+
const node = value.field(branch);
|
|
704
|
+
|
|
705
|
+
return node ? typeMembersOf(node, depth) : [];
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
if (kind !== 'identifier' || depth >= MAX_NAME_DEPTH) {
|
|
710
|
+
return [];
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return valuesOfName(value).flatMap((node) => typeMembersOf(node, depth + 1));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Reports a function in which the rewrites turn the returns of two removed
|
|
718
|
+
* types into one 6.0 type: it returned `STACK` on one path and
|
|
719
|
+
* `ORTHOGRAPHIC` on another, and now returns `PLANAR` on both. That is right
|
|
720
|
+
* for a viewport type, and an application that read the answer as "a stack
|
|
721
|
+
* or a volume" has lost it. A return counts directly, in a branch of a
|
|
722
|
+
* conditional, and through a name whose values the file shows.
|
|
723
|
+
*/
|
|
724
|
+
function reportMergedReturns(run: Run): void {
|
|
725
|
+
const edits = run.edits.all();
|
|
726
|
+
|
|
727
|
+
if (!edits.length) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
const order = Object.keys(MODE_OF_LEGACY);
|
|
732
|
+
const returned = new Map<number, { fn: Node; members: Node[] }>();
|
|
733
|
+
const values = [
|
|
734
|
+
...run.rootNode
|
|
735
|
+
.findAll({ rule: { kind: 'return_statement' } })
|
|
736
|
+
.map((statement) =>
|
|
737
|
+
statement
|
|
738
|
+
.children()
|
|
739
|
+
.find((child) => child.isNamed() && child.kind() !== 'comment')
|
|
740
|
+
),
|
|
741
|
+
...run.rootNode
|
|
742
|
+
.findAll({ rule: { kind: 'arrow_function' } })
|
|
743
|
+
.map((arrow) => arrow.field('body'))
|
|
744
|
+
.filter((body) => body?.kind() !== 'statement_block'),
|
|
745
|
+
];
|
|
746
|
+
|
|
747
|
+
for (const value of values) {
|
|
748
|
+
const fn = value ? enclosingFunction(value) : undefined;
|
|
749
|
+
|
|
750
|
+
if (!fn) {
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
const entry = returned.get(fn.id()) ?? { fn, members: [] };
|
|
755
|
+
|
|
756
|
+
entry.members.push(...typeMembersOf(value));
|
|
757
|
+
returned.set(fn.id(), entry);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
for (const { fn, members } of returned.values()) {
|
|
761
|
+
const removed = new Map<string, string[]>();
|
|
762
|
+
|
|
763
|
+
for (const member of members) {
|
|
764
|
+
const property = member.field('property');
|
|
765
|
+
const before = property?.text() ?? '';
|
|
766
|
+
const after = property ? textAfterEdits(property, edits) : undefined;
|
|
767
|
+
|
|
768
|
+
if (!after || after === before || NEXT_MEMBERS[before]) {
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
const names = removed.get(after) ?? [];
|
|
773
|
+
|
|
774
|
+
if (!names.includes(before)) {
|
|
775
|
+
names.push(before);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
removed.set(after, names);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
for (const [after, names] of removed) {
|
|
782
|
+
if (names.length > 1) {
|
|
783
|
+
const list = names
|
|
784
|
+
.sort((a, b) => order.indexOf(a) - order.indexOf(b))
|
|
785
|
+
.join(' and ');
|
|
786
|
+
|
|
787
|
+
review.increment(
|
|
788
|
+
site(
|
|
789
|
+
run.root,
|
|
790
|
+
`ViewportType.${after}: one function returned ${list}, read what its callers do with the answer`,
|
|
791
|
+
fn
|
|
792
|
+
)
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Returns the name of a rule for two operands that became the same: the
|
|
801
|
+
* member or the string that the rewrite wrote. Undefined for another
|
|
802
|
+
* rewrite, such as two tests of the content mode: a member and its string
|
|
803
|
+
* meant the same in 5.x.
|
|
804
|
+
*/
|
|
805
|
+
function mergedLabel(inserted: string[]): string | undefined {
|
|
806
|
+
for (const text of inserted) {
|
|
807
|
+
if (/^[A-Z][A-Z0-9_]*$/.test(text)) {
|
|
808
|
+
return `ViewportType.${text}`;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
if (/^['"]\w+['"]$/.test(text)) {
|
|
812
|
+
return `'${text.slice(1, -1)}'`;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
return undefined;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Reports two operands that the rewrites make the same expression: in a
|
|
821
|
+
* chain of `||` or of `&&`, as `case` labels of one `switch`, or as entries
|
|
822
|
+
* of a list used with `includes`. A test of `VOLUME_3D` beside a test of
|
|
823
|
+
* `VOLUME_3D_NEXT` told a legacy viewport from a next one in 5.x, and the
|
|
824
|
+
* two are one test in 6.0.
|
|
825
|
+
*/
|
|
826
|
+
function reportMergedOperands(run: Run): void {
|
|
827
|
+
for (const merged of mergedOperands(run.rootNode, run.edits.all())) {
|
|
828
|
+
const label = mergedLabel(merged.inserted);
|
|
829
|
+
|
|
830
|
+
if (label) {
|
|
831
|
+
review.increment(site(run.root, `${label}: ${merged.note}`, merged.node));
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
651
836
|
/**
|
|
652
837
|
* Rewrites the removed and deprecated viewport types of Cornerstone3D 5.x:
|
|
653
838
|
* `STACK` and `ORTHOGRAPHIC` in a viewport input become `PLANAR`, a comparison
|
|
654
839
|
* with `viewport.type` asks for the content mode, the `_NEXT` members and
|
|
655
840
|
* the `*Next` strings get their plain names. `PERSPECTIVE` and every other
|
|
656
|
-
* site are reported.
|
|
841
|
+
* site are reported. A function that now returns one type where it returned
|
|
842
|
+
* two, and two operands that are now the same, are reported for review.
|
|
657
843
|
*/
|
|
658
844
|
const codemod: Codemod<TSX> = (root) => {
|
|
659
845
|
const rootNode = root.root();
|
|
@@ -703,6 +889,8 @@ const codemod: Codemod<TSX> = (root) => {
|
|
|
703
889
|
|
|
704
890
|
rewriteDestructured(run);
|
|
705
891
|
reportBracketMembers(run);
|
|
892
|
+
reportMergedReturns(run);
|
|
893
|
+
reportMergedOperands(run);
|
|
706
894
|
|
|
707
895
|
if (!run.edits.all().length) {
|
|
708
896
|
return null;
|
|
@@ -711,4 +899,4 @@ const codemod: Codemod<TSX> = (root) => {
|
|
|
711
899
|
return rootNode.commitEdits([...run.edits.all(), ...run.imports.edits()]);
|
|
712
900
|
};
|
|
713
901
|
|
|
714
|
-
export default codemod;
|
|
902
|
+
export default analysed(codemod, manual, review);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = Enums;
|
|
5
|
+
|
|
6
|
+
function inputFor(
|
|
7
|
+
viewportInput,
|
|
8
|
+
isStack,
|
|
9
|
+
options
|
|
10
|
+
) {
|
|
11
|
+
if (viewportInput.type === ViewportType.STACK) {
|
|
12
|
+
return viewportInput;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
switch (viewportInput.type) {
|
|
16
|
+
case ViewportType.ORTHOGRAPHIC:
|
|
17
|
+
return viewportInput;
|
|
18
|
+
default:
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
viewportId: 'conditional',
|
|
25
|
+
element: document.createElement('div'),
|
|
26
|
+
type: isStack ? ViewportType.PLANAR : ViewportType.PLANAR,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
viewportId: 'perspective',
|
|
30
|
+
element: document.createElement('div'),
|
|
31
|
+
type: ViewportType.PERSPECTIVE,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
viewportId: 'shorthand',
|
|
35
|
+
element: document.createElement('div'),
|
|
36
|
+
type: ViewportType.PLANAR,
|
|
37
|
+
defaultOptions,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
viewportId: 'stretched',
|
|
41
|
+
element: document.createElement('div'),
|
|
42
|
+
type: 'perspective',
|
|
43
|
+
defaultOptions: { displayArea: options.displayArea },
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const storedLayout = 'planarNext';
|
|
49
|
+
|
|
50
|
+
export function Viewer({ engine }) {
|
|
51
|
+
return (
|
|
52
|
+
<div data-type={storedLayout} data-engine={engine.id}>
|
|
53
|
+
{String(inputFor)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getType(kind) {
|
|
59
|
+
if (kind === 'stack') {
|
|
60
|
+
return ViewportType.PLANAR;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return ViewportType.PLANAR;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function is3D(type) {
|
|
67
|
+
return (
|
|
68
|
+
type === ViewportType.VOLUME_3D || type === ViewportType.VOLUME_3D
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const Label = ({ type }) => (
|
|
73
|
+
<span>
|
|
74
|
+
{type === ViewportType.ECG || type === ViewportType.ECG ? 'ECG' : ''}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = Enums;
|
|
5
|
+
|
|
6
|
+
function inputFor(
|
|
7
|
+
viewportInput,
|
|
8
|
+
isStack,
|
|
9
|
+
options
|
|
10
|
+
) {
|
|
11
|
+
if (viewportInput.type === ViewportType.STACK) {
|
|
12
|
+
return viewportInput;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
switch (viewportInput.type) {
|
|
16
|
+
case ViewportType.ORTHOGRAPHIC:
|
|
17
|
+
return viewportInput;
|
|
18
|
+
default:
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
viewportId: 'conditional',
|
|
25
|
+
element: document.createElement('div'),
|
|
26
|
+
type: isStack ? ViewportType.STACK : ViewportType.ORTHOGRAPHIC,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
viewportId: 'perspective',
|
|
30
|
+
element: document.createElement('div'),
|
|
31
|
+
type: ViewportType.PERSPECTIVE,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
viewportId: 'shorthand',
|
|
35
|
+
element: document.createElement('div'),
|
|
36
|
+
type: ViewportType.ORTHOGRAPHIC,
|
|
37
|
+
defaultOptions,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
viewportId: 'stretched',
|
|
41
|
+
element: document.createElement('div'),
|
|
42
|
+
type: 'perspective',
|
|
43
|
+
defaultOptions: { displayArea: options.displayArea },
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const storedLayout = 'planarNext';
|
|
49
|
+
|
|
50
|
+
export function Viewer({ engine }) {
|
|
51
|
+
return (
|
|
52
|
+
<div data-type={storedLayout} data-engine={engine.id}>
|
|
53
|
+
{String(inputFor)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getType(kind) {
|
|
59
|
+
if (kind === 'stack') {
|
|
60
|
+
return ViewportType.STACK;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function is3D(type) {
|
|
67
|
+
return (
|
|
68
|
+
type === ViewportType.VOLUME_3D || type === ViewportType.VOLUME_3D_NEXT
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const Label = ({ type }) => (
|
|
73
|
+
<span>
|
|
74
|
+
{type === ViewportType.ECG || type === ViewportType.ECG_NEXT ? 'ECG' : ''}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cornerstone3d-6-manual": [
|
|
3
|
+
{
|
|
4
|
+
"cardinality": {
|
|
5
|
+
"file": "input.js",
|
|
6
|
+
"line": "11",
|
|
7
|
+
"rule": "ViewportType.STACK"
|
|
8
|
+
},
|
|
9
|
+
"count": 1
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"cardinality": {
|
|
13
|
+
"file": "input.js",
|
|
14
|
+
"line": "16",
|
|
15
|
+
"rule": "ViewportType.ORTHOGRAPHIC"
|
|
16
|
+
},
|
|
17
|
+
"count": 1
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"cardinality": {
|
|
21
|
+
"file": "input.js",
|
|
22
|
+
"line": "31",
|
|
23
|
+
"rule": "ViewportType.PERSPECTIVE"
|
|
24
|
+
},
|
|
25
|
+
"count": 1
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"cardinality": {
|
|
29
|
+
"file": "input.js",
|
|
30
|
+
"line": "36",
|
|
31
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
32
|
+
},
|
|
33
|
+
"count": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"cardinality": {
|
|
37
|
+
"file": "input.js",
|
|
38
|
+
"line": "42",
|
|
39
|
+
"rule": "'perspective'"
|
|
40
|
+
},
|
|
41
|
+
"count": 1
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"cardinality": {
|
|
45
|
+
"file": "input.js",
|
|
46
|
+
"line": "43",
|
|
47
|
+
"rule": "defaultOptions.displayArea"
|
|
48
|
+
},
|
|
49
|
+
"count": 1
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"cardinality": {
|
|
53
|
+
"file": "input.js",
|
|
54
|
+
"line": "48",
|
|
55
|
+
"rule": "'planarNext'"
|
|
56
|
+
},
|
|
57
|
+
"count": 1
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"cornerstone3d-6-review": [
|
|
61
|
+
{
|
|
62
|
+
"cardinality": {
|
|
63
|
+
"file": "input.js",
|
|
64
|
+
"line": "26",
|
|
65
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
66
|
+
},
|
|
67
|
+
"count": 1
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"cardinality": {
|
|
71
|
+
"file": "input.js",
|
|
72
|
+
"line": "58",
|
|
73
|
+
"rule": "ViewportType.PLANAR: one function returned STACK and ORTHOGRAPHIC, read what its callers do with the answer"
|
|
74
|
+
},
|
|
75
|
+
"count": 1
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"cardinality": {
|
|
79
|
+
"file": "input.js",
|
|
80
|
+
"line": "63",
|
|
81
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
82
|
+
},
|
|
83
|
+
"count": 1
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"cardinality": {
|
|
87
|
+
"file": "input.js",
|
|
88
|
+
"line": "68",
|
|
89
|
+
"rule": "ViewportType.VOLUME_3D: two operands of one || are the same now, read what each tested in 5.x"
|
|
90
|
+
},
|
|
91
|
+
"count": 1
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"cardinality": {
|
|
95
|
+
"file": "input.js",
|
|
96
|
+
"line": "74",
|
|
97
|
+
"rule": "ViewportType.ECG: two operands of one || are the same now, read what each tested in 5.x"
|
|
98
|
+
},
|
|
99
|
+
"count": 1
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = Enums;
|
|
5
|
+
|
|
6
|
+
function inputFor(
|
|
7
|
+
viewportInput,
|
|
8
|
+
isStack,
|
|
9
|
+
options
|
|
10
|
+
) {
|
|
11
|
+
if (viewportInput.type === ViewportType.STACK) {
|
|
12
|
+
return viewportInput;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
switch (viewportInput.type) {
|
|
16
|
+
case ViewportType.ORTHOGRAPHIC:
|
|
17
|
+
return viewportInput;
|
|
18
|
+
default:
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
viewportId: 'conditional',
|
|
25
|
+
element: document.createElement('div'),
|
|
26
|
+
type: isStack ? ViewportType.STACK : ViewportType.ORTHOGRAPHIC,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
viewportId: 'perspective',
|
|
30
|
+
element: document.createElement('div'),
|
|
31
|
+
type: ViewportType.PERSPECTIVE,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
viewportId: 'shorthand',
|
|
35
|
+
element: document.createElement('div'),
|
|
36
|
+
type: ViewportType.ORTHOGRAPHIC,
|
|
37
|
+
defaultOptions,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
viewportId: 'stretched',
|
|
41
|
+
element: document.createElement('div'),
|
|
42
|
+
type: 'perspective',
|
|
43
|
+
defaultOptions: { displayArea: options.displayArea },
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const storedLayout = 'planarNext';
|
|
49
|
+
|
|
50
|
+
export function Viewer({ engine }) {
|
|
51
|
+
return (
|
|
52
|
+
<div data-type={storedLayout} data-engine={engine.id}>
|
|
53
|
+
{String(inputFor)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getType(kind) {
|
|
59
|
+
if (kind === 'stack') {
|
|
60
|
+
return ViewportType.STACK;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function is3D(type) {
|
|
67
|
+
return (
|
|
68
|
+
type === ViewportType.VOLUME_3D || type === ViewportType.VOLUME_3D_NEXT
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const Label = ({ type }) => (
|
|
73
|
+
<span>
|
|
74
|
+
{type === ViewportType.ECG || type === ViewportType.ECG_NEXT ? 'ECG' : ''}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const twice = 1;
|
|
79
|
+
const twice = 2;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = Enums;
|
|
5
|
+
|
|
6
|
+
function inputFor(
|
|
7
|
+
viewportInput,
|
|
8
|
+
isStack,
|
|
9
|
+
options
|
|
10
|
+
) {
|
|
11
|
+
if (viewportInput.type === ViewportType.STACK) {
|
|
12
|
+
return viewportInput;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
switch (viewportInput.type) {
|
|
16
|
+
case ViewportType.ORTHOGRAPHIC:
|
|
17
|
+
return viewportInput;
|
|
18
|
+
default:
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
viewportId: 'conditional',
|
|
25
|
+
element: document.createElement('div'),
|
|
26
|
+
type: isStack ? ViewportType.STACK : ViewportType.ORTHOGRAPHIC,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
viewportId: 'perspective',
|
|
30
|
+
element: document.createElement('div'),
|
|
31
|
+
type: ViewportType.PERSPECTIVE,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
viewportId: 'shorthand',
|
|
35
|
+
element: document.createElement('div'),
|
|
36
|
+
type: ViewportType.ORTHOGRAPHIC,
|
|
37
|
+
defaultOptions,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
viewportId: 'stretched',
|
|
41
|
+
element: document.createElement('div'),
|
|
42
|
+
type: 'perspective',
|
|
43
|
+
defaultOptions: { displayArea: options.displayArea },
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const storedLayout = 'planarNext';
|
|
49
|
+
|
|
50
|
+
export function Viewer({ engine }) {
|
|
51
|
+
return (
|
|
52
|
+
<div data-type={storedLayout} data-engine={engine.id}>
|
|
53
|
+
{String(inputFor)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getType(kind) {
|
|
59
|
+
if (kind === 'stack') {
|
|
60
|
+
return ViewportType.STACK;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function is3D(type) {
|
|
67
|
+
return (
|
|
68
|
+
type === ViewportType.VOLUME_3D || type === ViewportType.VOLUME_3D_NEXT
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const Label = ({ type }) => (
|
|
73
|
+
<span>
|
|
74
|
+
{type === ViewportType.ECG || type === ViewportType.ECG_NEXT ? 'ECG' : ''}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const twice = 1;
|
|
79
|
+
const twice = 2;
|