med-viewer-sdk 0.1.21 → 0.1.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "med-viewer-sdk",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "main": "dist/med-viewer-sdk.umd.js",
5
5
  "module": "dist/med-viewer-sdk.mjs",
6
6
  "types": "dist/med-viewer-sdk.d.ts",
@@ -9,7 +9,7 @@
9
9
  "README.md"
10
10
  ],
11
11
  "scripts": {
12
- "build": "npx vite build && tsc -p tsconfig.dts.json && powershell -Command \"if (Test-Path -Path 'dist\\med-viewer-sdk.d.ts') { Remove-Item -Path 'dist\\med-viewer-sdk.d.ts' } ; Move-Item -Path 'dist\\index.d.ts' -Destination 'dist\\med-viewer-sdk.d.ts'\"",
12
+ "build": "npx vite build && tsc -p tsconfig.dts.json && powershell -Command \"if (Test-Path -Path 'dist\\med-viewer-sdk.d.ts') { Remove-Item -Path 'dist\\med-viewer-sdk.d.ts' } ; Move-Item -Path 'dist\\index.d.ts' -Destination 'dist\\med-viewer-sdk.d.ts' ; @('dist\\src','dist\\core','dist\\adapters','dist\\i18n','dist\\plugins','dist\\types') | ForEach-Object { if (Test-Path $_) { Remove-Item $_ -Recurse -Force } }\"",
13
13
  "test": "echo \"Error: no test specified\" && exit 1"
14
14
  },
15
15
  "peerDependencies": {
@@ -1,17 +0,0 @@
1
- import type { MedEngineOptions } from '../../core/Engine';
2
- declare const _default: import("vue-demi").DefineComponent<import("vue-demi").ExtractPropTypes<{
3
- options: {
4
- type: () => Omit<MedEngineOptions, "element">;
5
- required: true;
6
- };
7
- }>, () => import("vue-demi").VNode<import("vue-demi").RendererNode, import("vue-demi").RendererElement, {
8
- [key: string]: any;
9
- }>, {}, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, "ready"[], "ready", import("vue-demi").PublicProps, Readonly<import("vue-demi").ExtractPropTypes<{
10
- options: {
11
- type: () => Omit<MedEngineOptions, "element">;
12
- required: true;
13
- };
14
- }>> & Readonly<{
15
- onReady?: ((...args: any[]) => any) | undefined;
16
- }>, {}, {}, {}, {}, string, import("vue-demi").ComponentProvideOptions, true, {}, any>;
17
- export default _default;
@@ -1,2 +0,0 @@
1
- import MedViewer from './MedViewer';
2
- export default MedViewer;
@@ -1,16 +0,0 @@
1
- import 'annotorious-openseadragon-ld/dist/annotorious.min.css';
2
- import { MedViewerEngine } from './Engine';
3
- import { BaseAnnotator } from './BaseAnnotator';
4
- export declare class AnnoAnnotator extends BaseAnnotator {
5
- anno: any;
6
- constructor(engine: MedViewerEngine, config?: any);
7
- setEnabled(enabled: boolean): void;
8
- setTool(tool: 'rect' | 'polygon' | 'line' | 'point' | 'circle' | 'ellipse' | 'freehand' | null, color?: string): void;
9
- setLocale(locale: string): void;
10
- getAnnotations(): any[];
11
- setAnnotations(data: any[]): void;
12
- clear(): void;
13
- destroy(): void;
14
- private initEvents;
15
- private injectStyles;
16
- }
@@ -1,33 +0,0 @@
1
- import { MedViewerEngine } from './Engine';
2
- /**
3
- * 标注插件的基类
4
- */
5
- export declare abstract class BaseAnnotator {
6
- protected engine: MedViewerEngine;
7
- protected isEnabled: boolean;
8
- constructor(engine: MedViewerEngine);
9
- /**
10
- * 启用/禁用标注功能
11
- */
12
- abstract setEnabled(enabled: boolean): void;
13
- /**
14
- * 设置当前的工具模式 (例如:矩形、箭头、多边形)
15
- */
16
- abstract setTool(tool: string | null): void;
17
- /**
18
- * 获取所有标注数据 (建议在此处进行格式标准化)
19
- */
20
- abstract getAnnotations(): any[];
21
- /**
22
- * 加载标注数据
23
- */
24
- abstract setAnnotations(data: any[]): void;
25
- /**
26
- * 清除所有标注
27
- */
28
- abstract clear(): void;
29
- /**
30
- * 销毁插件,移除事件监听
31
- */
32
- abstract destroy(): void;
33
- }
@@ -1,46 +0,0 @@
1
- import 'openseadragon-filtering';
2
- export interface ColorAdjustments {
3
- brightness?: number;
4
- contrast?: number;
5
- saturation?: number;
6
- gamma?: number;
7
- hue?: number;
8
- invert?: boolean;
9
- sepia?: boolean;
10
- greyscale?: boolean;
11
- }
12
- export interface ColorAdjustOptions {
13
- adjustments?: ColorAdjustments;
14
- debounceMs?: number;
15
- loadMode?: 'async' | 'sync';
16
- onAdjustmentsChange?: (adjustments: ColorAdjustments) => void;
17
- }
18
- export declare class ColorAdjustPlugin {
19
- private viewer;
20
- private _adjustments;
21
- private options;
22
- private lut;
23
- private needUpdate;
24
- private debounceTimer;
25
- constructor(viewer: any, options?: ColorAdjustOptions);
26
- /**
27
- * 更新查找表 (LUT)
28
- * 将亮度、对比度、反色、伽马合并为一个 256 长度的数组,大幅减少循环内计算
29
- */
30
- private updateLut;
31
- /**
32
- * 核心处理器:利用异步调度减少主线程占用
33
- */
34
- private combinedProcessor;
35
- /**
36
- * 应用滤镜配置到 Viewer
37
- */
38
- apply(): void;
39
- /**
40
- * 业务层调用的 API,内置防抖
41
- */
42
- setAdjustments(adj: ColorAdjustments): void;
43
- get adjustments(): ColorAdjustments;
44
- reset(): void;
45
- destroy(): void;
46
- }
@@ -1,6 +0,0 @@
1
- export declare class Coords {
2
- static imageToScreen(imageX: number, imageY: number, scale: number): {
3
- x: number;
4
- y: number;
5
- };
6
- }
@@ -1,104 +0,0 @@
1
- import type OpenSeadragonType from 'openseadragon';
2
- import OpenSeadragon from 'openseadragon';
3
- import { AnnoAnnotator } from './AnnoAnnotator';
4
- import { ColorAdjustPlugin, type ColorAdjustOptions } from './ColorAdjustPlugin';
5
- import { MagnificationPlugin, type MagnificationOptions } from './Magnification';
6
- import { ScalebarPlugin, type ScalebarOptions } from './Scalebar';
7
- import { SelectionPlugin, type SelectionOptions } from './SelectionPlugin';
8
- import { MedToolbar, type ToolbarOptions } from './Toolbar';
9
- import { Locale } from '../i18n/i18n';
10
- export interface AnnotoriousOptions {
11
- onCreateAnnotation?: (annotation: any) => void;
12
- onUpdateAnnotation?: (annotation: any, previous: any) => void;
13
- onDeleteAnnotation?: (annotation: any) => void;
14
- [key: string]: any;
15
- }
16
- /**
17
- * 引擎配置接口
18
- */
19
- export interface MedEngineOptions {
20
- osdOptions: OpenSeadragonType.Options;
21
- locale?: Locale;
22
- plugins?: {
23
- annotorious?: boolean | AnnotoriousOptions;
24
- toolbar?: boolean | ToolbarOptions;
25
- colorAdjust?: boolean | ColorAdjustOptions;
26
- selection?: boolean | SelectionOptions;
27
- scalebar?: boolean | ScalebarOptions;
28
- magnification?: boolean | MagnificationOptions;
29
- };
30
- }
31
- export interface AiBoxRectLabel {
32
- label: string;
33
- value: string;
34
- style?: {
35
- color: string;
36
- fontSize: number;
37
- [key: string]: any;
38
- };
39
- }
40
- export interface AiBoxRect {
41
- x: number;
42
- y: number;
43
- width: number;
44
- height: number;
45
- style: {
46
- border: string;
47
- fontSize: number;
48
- [key: string]: any;
49
- };
50
- labels: Array<AiBoxRectLabel>;
51
- }
52
- export interface SelectionBox {
53
- x: number;
54
- y: number;
55
- width: number;
56
- height: number;
57
- style: {
58
- border: string;
59
- fontSize: number;
60
- [key: string]: any;
61
- };
62
- }
63
- /**
64
- * 医学影像核心引擎
65
- * 职责:初始化 OpenSeadragon,管理插件生命周期
66
- */
67
- export declare class MedViewerEngine {
68
- viewer: OpenSeadragon.Viewer;
69
- anno: AnnoAnnotator | null;
70
- toolbar: MedToolbar | null;
71
- colorAdjust: ColorAdjustPlugin | null;
72
- selection: SelectionPlugin | null;
73
- scalebar: ScalebarPlugin | null;
74
- magnification: MagnificationPlugin | null;
75
- private options;
76
- private events;
77
- constructor(options: MedEngineOptions);
78
- /**
79
- * 内部插件初始化逻辑
80
- * 解决异步 DOM 挂载问题,防止 Annotorious 初始化时找不到 Canvas
81
- */
82
- private initPlugins;
83
- /**
84
- * 真正挂载 Annotorious 的私有方法
85
- */
86
- private mountAnnotorious;
87
- loadAIMarks(aiBoxes?: AiBoxRect[], showLabel?: boolean): void;
88
- updateAIMarks(aiBoxes?: AiBoxRect[], showLabel?: boolean): void;
89
- clearAIMarks(): void;
90
- loadSelectionBox(selections?: SelectionBox[]): void;
91
- addHandler(event: string, handler: Function): void;
92
- addOnceHandler(event: string, handler: Function): void;
93
- removeHandler(event: string, handler: Function): void;
94
- private emit;
95
- /**
96
- * 销毁引擎与所有插件
97
- */
98
- destroy(): void;
99
- /**
100
- * 动态设置语言
101
- * @param locale 语言标识,如 'en' 或 'zh-CN'
102
- */
103
- setLocale(locale: Locale): void;
104
- }
@@ -1,54 +0,0 @@
1
- import OpenSeadragon from 'openseadragon';
2
- export declare enum MagnificationPosition {
3
- TOP_LEFT = "TOP_LEFT",
4
- TOP_CENTER = "TOP_CENTER",
5
- TOP_RIGHT = "TOP_RIGHT",
6
- BOTTOM_LEFT = "BOTTOM_LEFT",
7
- BOTTOM_CENTER = "BOTTOM_CENTER",
8
- BOTTOM_RIGHT = "BOTTOM_RIGHT",
9
- MIDDLE_LEFT = "MIDDLE_LEFT",
10
- MIDDLE_RIGHT = "MIDDLE_RIGHT"
11
- }
12
- export declare enum MagnificationType {
13
- LD = "LD",
14
- OSD = "OSD"
15
- }
16
- export interface MagnificationOptions {
17
- type?: MagnificationType;
18
- position?: MagnificationPosition;
19
- offsetX?: number;
20
- offsetY?: number;
21
- pixelsPerMeter?: number;
22
- }
23
- export declare class MagnificationPlugin {
24
- private viewer;
25
- private options;
26
- private magnificationElement;
27
- private magnificationDisplay;
28
- constructor(viewer: OpenSeadragon.Viewer, options?: MagnificationOptions);
29
- private init;
30
- private createButton;
31
- private updateMagnificationDisplay;
32
- getMagnification(): number;
33
- private setMagnification;
34
- private fitToScreen;
35
- /**
36
- * 显示放大镜控件
37
- */
38
- show(): void;
39
- /**
40
- * 隐藏放大镜控件
41
- */
42
- hide(): void;
43
- /**
44
- * 切换放大镜控件的可见性
45
- */
46
- toggle(): void;
47
- /**
48
- * 检查放大镜控件是否可见
49
- */
50
- isVisible(): boolean;
51
- refresh(): void;
52
- destroy(): void;
53
- private injectStyles;
54
- }
@@ -1,42 +0,0 @@
1
- import OpenSeadragon from "openseadragon";
2
- import "../plugins/openseadragon-scalebar.js";
3
- export declare enum ScalebarType {
4
- NONE = 0,
5
- MICROSCOPY = 1,
6
- MAP = 2
7
- }
8
- export declare enum ScalebarLocation {
9
- NONE = 0,
10
- TOP_LEFT = 1,
11
- TOP_RIGHT = 2,
12
- BOTTOM_RIGHT = 3,
13
- BOTTOM_LEFT = 4
14
- }
15
- export interface ScalebarOptions {
16
- type?: ScalebarType;
17
- pixelsPerMeter?: number;
18
- xOffset?: number;
19
- yOffset?: number;
20
- stayInsideImage?: boolean;
21
- color?: string;
22
- fontColor?: string;
23
- backgroundColor?: string;
24
- fontSize?: string;
25
- fontFamily?: string;
26
- barThickness?: number;
27
- minWidth?: string;
28
- location?: ScalebarLocation;
29
- referenceItemIdx?: number;
30
- sizeAndTextRenderer?: (ppm: number, minSize: number) => {
31
- size: number;
32
- text: string;
33
- };
34
- }
35
- export declare class ScalebarPlugin {
36
- private viewer;
37
- private options;
38
- private scalebar;
39
- constructor(viewer: OpenSeadragon.Viewer, options?: ScalebarOptions);
40
- private init;
41
- destroy(): void;
42
- }
@@ -1,106 +0,0 @@
1
- import OpenSeadragon from 'openseadragon';
2
- import '../plugins/openseadragon-selection.js';
3
- export interface SelectionOptions {
4
- element?: HTMLElement | null;
5
- showSelectionControl?: boolean;
6
- toggleButton?: HTMLElement | null;
7
- showConfirmDenyButtons?: boolean;
8
- styleConfirmDenyButtons?: boolean;
9
- returnPixelCoordinates?: boolean;
10
- keyboardShortcut?: string;
11
- rect?: OpenSeadragon.Rect | null;
12
- allowRotation?: boolean;
13
- startRotated?: boolean;
14
- startRotatedHeight?: number;
15
- restrictToImage?: boolean;
16
- onSelection?: (rect: OpenSeadragon.Rect, blob: Blob | null) => void;
17
- onSelectionCanceled?: () => void;
18
- onSelectionChange?: (rect: OpenSeadragon.Rect) => void;
19
- onSelectionToggled?: (state: {
20
- enabled: boolean;
21
- }) => void;
22
- prefixUrl?: string | null;
23
- navImages?: {
24
- selection: {
25
- REST: string;
26
- GROUP: string;
27
- HOVER: string;
28
- DOWN: string;
29
- };
30
- selectionConfirm: {
31
- REST: string;
32
- GROUP: string;
33
- HOVER: string;
34
- DOWN: string;
35
- };
36
- selectionCancel: {
37
- REST: string;
38
- GROUP: string;
39
- HOVER: string;
40
- DOWN: string;
41
- };
42
- };
43
- borderStyle?: {
44
- width: string;
45
- color: string;
46
- };
47
- handleStyle?: {
48
- top: string;
49
- left: string;
50
- width: string;
51
- height: string;
52
- margin: string;
53
- background: string;
54
- border: string;
55
- };
56
- cornersStyle?: {
57
- width: string;
58
- height: string;
59
- background: string;
60
- border: string;
61
- };
62
- }
63
- export declare class SelectionPlugin {
64
- private viewer;
65
- private selection;
66
- private options;
67
- constructor(viewer: OpenSeadragon.Viewer, options?: SelectionOptions);
68
- /**
69
- * 更新语言环境,刷新工具提示
70
- */
71
- updateLocale(): void;
72
- private init;
73
- private setupSelection;
74
- /**
75
- * 启用选择模式
76
- */
77
- enable(): void;
78
- /**
79
- * 禁用选择模式
80
- */
81
- disable(): void;
82
- /**
83
- * 切换选择模式状态
84
- */
85
- toggleState(): void;
86
- /**
87
- * 获取当前选择区域
88
- */
89
- getSelection(): OpenSeadragon.Rect | null;
90
- /**
91
- * 设置选择区域
92
- */
93
- setSelection(rect: OpenSeadragon.Rect): void;
94
- /**
95
- * 清除选择
96
- */
97
- clearSelection(): void;
98
- /**
99
- * 检查是否启用选择模式
100
- */
101
- isEnabled(): boolean;
102
- /**
103
- * 销毁插件
104
- */
105
- destroy(): void;
106
- }
@@ -1,57 +0,0 @@
1
- import type { MedViewerEngine } from './Engine';
2
- export declare enum ToolbarPosition {
3
- TOP_LEFT = "TOP_LEFT",
4
- TOP_CENTER = "TOP_CENTER",
5
- TOP_RIGHT = "TOP_RIGHT",
6
- BOTTOM_LEFT = "BOTTOM_LEFT",
7
- BOTTOM_CENTER = "BOTTOM_CENTER",
8
- BOTTOM_RIGHT = "BOTTOM_RIGHT",
9
- MIDDLE_LEFT = "MIDDLE_LEFT",
10
- MIDDLE_RIGHT = "MIDDLE_RIGHT"
11
- }
12
- export interface ToolbarButton {
13
- id: string;
14
- label?: string;
15
- icon?: string;
16
- dropdownContent?: (engine: MedViewerEngine, hide: () => void) => HTMLElement;
17
- onClick?: (engine: MedViewerEngine, hide: () => void) => void;
18
- }
19
- export interface ToolbarOptions {
20
- position?: ToolbarPosition;
21
- buttons?: ToolbarButton[];
22
- }
23
- /**
24
- * MedToolbar 主类
25
- */
26
- export declare class MedToolbar {
27
- private engine;
28
- private options;
29
- private element;
30
- private dropdownElement;
31
- private outsideClickHandler;
32
- constructor(engine: MedViewerEngine, options?: ToolbarOptions);
33
- /**
34
- * 显示工具栏
35
- */
36
- show(): void;
37
- /**
38
- * 隐藏工具栏
39
- */
40
- hide(): void;
41
- /**
42
- * 切换工具栏的可见性
43
- */
44
- toggle(): void;
45
- /**
46
- * 检查工具栏是否可见
47
- */
48
- isVisible(): boolean;
49
- destroy(): void;
50
- private render;
51
- private showDropdown;
52
- private adjustDropdownPosition;
53
- private closeDropdown;
54
- private mount;
55
- private getClassName;
56
- private injectStyles;
57
- }
@@ -1,6 +0,0 @@
1
- export type Locale = 'zh-CN' | 'en-US';
2
- export interface I18nDict {
3
- [key: string]: string | I18nDict;
4
- }
5
- export declare function setLocale(locale: Locale): void;
6
- export declare function t(path: string): string;