cs-label-tool 2.0.0-alpha.1 → 2.0.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.
Files changed (74) hide show
  1. package/README.md +2 -0
  2. package/dist/components/annotator-element.d.ts +0 -1
  3. package/dist/components/define.d.ts +0 -1
  4. package/dist/components/styles.d.ts +0 -1
  5. package/dist/core/annotator.d.ts +0 -1
  6. package/dist/core/commands.d.ts +0 -1
  7. package/dist/core/events.d.ts +0 -1
  8. package/dist/core/immutability.d.ts +0 -1
  9. package/dist/core/state.d.ts +0 -1
  10. package/dist/core/types.d.ts +0 -1
  11. package/dist/cs-label-tool.d.ts +0 -1
  12. package/dist/geometry/matrix.d.ts +0 -1
  13. package/dist/geometry/polygon.d.ts +0 -1
  14. package/dist/geometry/rect.d.ts +0 -1
  15. package/dist/geometry/types.d.ts +0 -1
  16. package/dist/image/image-commands.d.ts +0 -1
  17. package/dist/image/standard-source.d.ts +0 -1
  18. package/dist/image/types.d.ts +0 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.js +1 -3
  21. package/dist/labels/labels.d.ts +0 -1
  22. package/dist/mask/rle.d.ts +0 -1
  23. package/dist/render/canvas-layers.d.ts +0 -1
  24. package/dist/render/canvas-renderer.d.ts +0 -1
  25. package/dist/render/scheduler.d.ts +0 -1
  26. package/dist/spatial/grid-index.d.ts +0 -1
  27. package/dist/tools/api.d.ts +0 -1
  28. package/dist/tools/brush-tool.d.ts +0 -1
  29. package/dist/tools/controller.d.ts +0 -1
  30. package/dist/tools/eraser-tool.d.ts +0 -1
  31. package/dist/tools/index.d.ts +0 -1
  32. package/dist/tools/polygon-tool.d.ts +0 -1
  33. package/dist/tools/rect-tool.d.ts +0 -1
  34. package/dist/tools/registry.d.ts +0 -1
  35. package/dist/tools/select-tool.d.ts +0 -1
  36. package/dist/tools/types.d.ts +0 -1
  37. package/dist/viewport/viewport.d.ts +0 -1
  38. package/package.json +7 -1
  39. package/dist/components/annotator-element.d.ts.map +0 -1
  40. package/dist/components/define.d.ts.map +0 -1
  41. package/dist/components/styles.d.ts.map +0 -1
  42. package/dist/core/annotator.d.ts.map +0 -1
  43. package/dist/core/commands.d.ts.map +0 -1
  44. package/dist/core/events.d.ts.map +0 -1
  45. package/dist/core/immutability.d.ts.map +0 -1
  46. package/dist/core/state.d.ts.map +0 -1
  47. package/dist/core/types.d.ts.map +0 -1
  48. package/dist/cs-label-tool.d.ts.map +0 -1
  49. package/dist/geometry/matrix.d.ts.map +0 -1
  50. package/dist/geometry/polygon.d.ts.map +0 -1
  51. package/dist/geometry/rect.d.ts.map +0 -1
  52. package/dist/geometry/types.d.ts.map +0 -1
  53. package/dist/image/image-commands.d.ts.map +0 -1
  54. package/dist/image/standard-source.d.ts.map +0 -1
  55. package/dist/image/types.d.ts.map +0 -1
  56. package/dist/index.d.ts.map +0 -1
  57. package/dist/index.js.map +0 -1
  58. package/dist/labels/labels.d.ts.map +0 -1
  59. package/dist/mask/rle.d.ts.map +0 -1
  60. package/dist/render/canvas-layers.d.ts.map +0 -1
  61. package/dist/render/canvas-renderer.d.ts.map +0 -1
  62. package/dist/render/scheduler.d.ts.map +0 -1
  63. package/dist/spatial/grid-index.d.ts.map +0 -1
  64. package/dist/tools/api.d.ts.map +0 -1
  65. package/dist/tools/brush-tool.d.ts.map +0 -1
  66. package/dist/tools/controller.d.ts.map +0 -1
  67. package/dist/tools/eraser-tool.d.ts.map +0 -1
  68. package/dist/tools/index.d.ts.map +0 -1
  69. package/dist/tools/polygon-tool.d.ts.map +0 -1
  70. package/dist/tools/rect-tool.d.ts.map +0 -1
  71. package/dist/tools/registry.d.ts.map +0 -1
  72. package/dist/tools/select-tool.d.ts.map +0 -1
  73. package/dist/tools/types.d.ts.map +0 -1
  74. package/dist/viewport/viewport.d.ts.map +0 -1
package/README.md CHANGED
@@ -14,6 +14,8 @@
14
14
 
15
15
  ## 环境与安装
16
16
 
17
+ 当前稳定版为 `2.0.0`,仅提供 ESM,没有运行时依赖。
18
+
17
19
  - Node.js 22.12+
18
20
  - Chrome、Edge、Firefox 最近两个大版本
19
21
  - Safari 17+
@@ -11,4 +11,3 @@ export declare class CSAnnotatorElement extends HTMLElementBase {
11
11
  destroy(): void;
12
12
  }
13
13
  export {};
14
- //# sourceMappingURL=annotator-element.d.ts.map
@@ -3,4 +3,3 @@ import { type ComponentAnnotatorOptions } from './annotator-element.js';
3
3
  export declare function defineAnnotatorElements(): void;
4
4
  export declare function mountAnnotator(target: string | Element, options?: ComponentAnnotatorOptions): Annotator;
5
5
  export declare function unmountAnnotator(target: string | Element): void;
6
- //# sourceMappingURL=define.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare const annotatorStyles = "\n :host {\n --cs-annotator-background: #101318;\n --cs-annotator-border: #2a3039;\n --cs-annotator-control: #1a2029;\n --cs-annotator-control-active: #2563eb;\n --cs-annotator-foreground: #f8fafc;\n display: block;\n width: 100%;\n height: 100%;\n color: var(--cs-annotator-foreground);\n font: 14px/1.4 system-ui, sans-serif;\n }\n\n [part=\"shell\"] {\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n width: 100%;\n height: 100%;\n overflow: hidden;\n background: var(--cs-annotator-background);\n }\n\n [part=\"toolbar\"] {\n display: flex;\n gap: 6px;\n align-items: center;\n padding: 8px;\n border-bottom: 1px solid var(--cs-annotator-border);\n }\n\n button {\n min-height: 32px;\n padding: 5px 10px;\n color: inherit;\n background: var(--cs-annotator-control);\n border: 1px solid var(--cs-annotator-border);\n border-radius: 6px;\n cursor: pointer;\n }\n\n button[aria-pressed=\"true\"] {\n background: var(--cs-annotator-control-active);\n border-color: #93c5fd;\n outline: 2px solid #ffffff;\n outline-offset: -4px;\n }\n\n button:focus-visible {\n outline: 2px solid #93c5fd;\n outline-offset: 2px;\n }\n\n button:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n }\n\n [part=\"workspace\"] {\n display: grid;\n grid-template-columns: minmax(0, 1fr) 180px;\n min-height: 0;\n }\n\n [part=\"viewport\"] {\n position: relative;\n min-width: 0;\n min-height: 0;\n background: #090b0f;\n }\n\n [part=\"labels\"] {\n overflow: auto;\n padding: 8px;\n border-left: 1px solid var(--cs-annotator-border);\n }\n\n [part=\"labels\"] button {\n display: block;\n width: 100%;\n margin-bottom: 6px;\n text-align: left;\n }\n";
2
- //# sourceMappingURL=styles.d.ts.map
@@ -5,4 +5,3 @@ export declare function getInternalState(annotator: Annotator): InternalState;
5
5
  export declare function createAnnotator(options: AnnotatorOptions): Annotator;
6
6
  export declare function destroyAnnotator(annotator: Annotator): void;
7
7
  export declare function getSnapshot(annotator: Annotator): AnnotationSnapshot;
8
- //# sourceMappingURL=annotator.d.ts.map
@@ -31,4 +31,3 @@ export declare function canRedo(annotator: Annotator): boolean;
31
31
  export declare function undo(annotator: Annotator): boolean;
32
32
  export declare function redo(annotator: Annotator): boolean;
33
33
  export declare function queryAnnotations(annotator: Annotator, bounds: Bounds): Annotation[];
34
- //# sourceMappingURL=commands.d.ts.map
@@ -22,4 +22,3 @@ export interface EventListeners {
22
22
  }
23
23
  export declare function emitChange(annotator: Annotator, kind: ChangeKind): void;
24
24
  export declare function subscribe<K extends AnnotatorEventName>(annotator: Annotator, type: K, listener: AnnotatorEventListener<K>): () => void;
25
- //# sourceMappingURL=events.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { Annotation, MaskGeometry, PolygonGeometry, RectGeometry } from './types.js';
2
2
  export declare function cloneGeometry(geometry: RectGeometry | PolygonGeometry | MaskGeometry): RectGeometry | PolygonGeometry | MaskGeometry;
3
3
  export declare function cloneAnnotation(annotation: Annotation): Annotation;
4
- //# sourceMappingURL=immutability.d.ts.map
@@ -39,4 +39,3 @@ export interface InternalState {
39
39
  readonly toolRegistry: ToolRegistry;
40
40
  }
41
41
  export declare function createInternalState(options: AnnotatorOptions): InternalState;
42
- //# sourceMappingURL=state.d.ts.map
@@ -61,4 +61,3 @@ export declare class AnnotatorError extends Error {
61
61
  }
62
62
  export declare function createAnnotatorHandle(): Annotator;
63
63
  export {};
64
- //# sourceMappingURL=types.d.ts.map
@@ -244,4 +244,3 @@ export declare const csLabelTool: {
244
244
  removePolygonVertex: typeof SelectTool.removePolygonVertex;
245
245
  AnnotatorError: typeof Types.AnnotatorError;
246
246
  };
247
- //# sourceMappingURL=cs-label-tool.d.ts.map
@@ -2,4 +2,3 @@ import type { Matrix2D, Point } from './types.js';
2
2
  export declare function createScaleTranslateMatrix(scale: number, offsetX: number, offsetY: number): Matrix2D;
3
3
  export declare function invertMatrix(matrix: Matrix2D): Matrix2D;
4
4
  export declare function transformPoint(matrix: Matrix2D, point: Point): Point;
5
- //# sourceMappingURL=matrix.d.ts.map
@@ -7,4 +7,3 @@ export type PolygonValidation = {
7
7
  };
8
8
  export declare function pointInPolygon(point: Point, polygon: readonly Point[]): boolean;
9
9
  export declare function validatePolygon(polygon: readonly Point[]): PolygonValidation;
10
- //# sourceMappingURL=polygon.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { Bounds, Point } from './types.js';
2
2
  export declare function normalizeRect(start: Point, end: Point): Bounds;
3
3
  export declare function pointInRect(point: Point, rect: Bounds): boolean;
4
- //# sourceMappingURL=rect.d.ts.map
@@ -16,4 +16,3 @@ export interface Matrix2D {
16
16
  readonly e: number;
17
17
  readonly f: number;
18
18
  }
19
- //# sourceMappingURL=types.d.ts.map
@@ -11,4 +11,3 @@ export declare function zoomBy(annotator: Annotator, factor: number, anchor?: Po
11
11
  export declare function panBy(annotator: Annotator, delta: Point): void;
12
12
  export declare function imageToClient(annotator: Annotator, point: Point): Point;
13
13
  export declare function clientToImage(annotator: Annotator, point: Point): Point;
14
- //# sourceMappingURL=image-commands.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import type { ImageSource, StandardImageInput } from './types.js';
2
2
  export declare function createStandardImageSource(input: StandardImageInput): ImageSource;
3
- //# sourceMappingURL=standard-source.d.ts.map
@@ -9,4 +9,3 @@ export interface ImageSource {
9
9
  readonly dispose: () => void;
10
10
  }
11
11
  export type StandardImageInput = string | Blob | ImageBitmap;
12
- //# sourceMappingURL=types.d.ts.map
package/dist/index.d.ts CHANGED
@@ -22,4 +22,3 @@ export { CSAnnotatorElement, type ComponentAnnotatorOptions, } from './component
22
22
  export { defineAnnotatorElements, mountAnnotator, unmountAnnotator, } from './components/define.js';
23
23
  export { create, mount, csLabelTool, type AnnotatorInstance, } from './cs-label-tool.js';
24
24
  export { binaryMasksWithinDistance, decodeBinaryMaskRle, encodeBinaryMaskRle, getBinaryMaskBounds, splitBinaryMaskComponents, translateBinaryMask, } from './mask/rle.js';
25
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -803,7 +803,7 @@ function M(e) {
803
803
  }
804
804
  async function Ge(e, t) {
805
805
  let n = Q(e), r = n.image !== null;
806
- n.imageAbortController?.abort(), n.imageAbortController = null, n.image = null, n.viewport = null, n.toolController?.cancel(), n.interactionDraft = null, n.renderer?.invalidate("image"), n.renderer?.invalidate("annotations"), n.renderer?.invalidate("interaction"), n.renderer?.invalidate("interaction"), n.imageSource?.dispose(), n.imageSource = null, r && g(e, "image:clear");
806
+ n.imageAbortController?.abort(), n.imageAbortController = null, n.image = null, n.viewport = null, n.toolController?.cancel(), n.interactionDraft = null, n.renderer?.invalidate("image"), n.renderer?.invalidate("annotations"), n.renderer?.invalidate("interaction"), n.imageSource?.dispose(), n.imageSource = null, r && g(e, "image:clear");
807
807
  let i = new AbortController();
808
808
  n.imageAbortController = i, n.imageSource = t;
809
809
  let a = await t.load(i.signal), o = Q(e);
@@ -2295,5 +2295,3 @@ function ln(e, t) {
2295
2295
  var un = on;
2296
2296
  //#endregion
2297
2297
  export { y as AnnotatorError, en as CSAnnotatorElement, R as activateTool, z as activateToolById, _e as addLabel, w as addMask, de as addPolygon, C as addRect, Le as binaryMasksWithinDistance, me as canRedo, pe as canUndo, B as cancelActiveGesture, W as clearSelection, Ye as clientToImage, cn as create, Lt as createAnnotator, at as createBrushMaskGeometry, st as createBrushTool, Pt as createDefaultToolRegistry, Et as createEraserTool, a as createGridIndex, kt as createPolygonTool, Dt as createPolygonToolState, Mt as createRectTool, X as createRectToolState, wt as createSelectTool, Ht as createStandardImageSource, Kt as createToolApi, Nt as createToolRegistry, Te as createViewport, un as csLabelTool, j as decodeBinaryMaskRle, tn as defineAnnotatorElements, Wt as deleteSelectedAnnotations, Rt as destroyAnnotator, A as encodeBinaryMaskRle, P as fitToScreen, ke as fitViewport, O as getActiveLabel, Ut as getActiveToolId, Fe as getBinaryMaskBounds, et as getRegisteredTools, tt as getRegisteredToolsByCategory, G as getSelection, zt as getSnapshot, Yt as getTool, Ke as getZoom, N as hasImage, Je as imageToClient, Ee as imageToScreen, o as insertSpatialItem, Xt as listTools, Zt as listToolsByCategory, ln as mount, rn as mountAnnotator, dt as movePolygonVertex, ut as moveRect, H as normalizeRect, L as panBy, Oe as panViewport, m as pointInPolygon, lt as pointInRect, D as queryAnnotations, u as querySpatialBounds, ge as redo, J as reducePolygonTool, At as reduceRectTool, qt as registerTool, E as removeAnnotation, ft as removePolygonVertex, c as removeSpatialItem, pt as resizeRect, qe as resizeViewport, k as screenToImage, U as selectAnnotation, ve as setActiveLabel, Ge as setImageSource, Pe as splitBinaryMaskComponents, _ as subscribe, Ie as translateBinaryMask, he as undo, an as unmountAnnotator, Jt as unregisterTool, T as updateAnnotation, fe as updateAnnotationLabel, ye as updateLabel, Gt as updateSelectedAnnotationsLabel, s as updateSpatialItem, V as useBrush, q as useEraser, Y as usePolygon, Z as useRect, K as useSelect, h as validatePolygon, De as zoomAt, I as zoomBy, F as zoomTo };
2298
-
2299
- //# sourceMappingURL=index.js.map
@@ -3,4 +3,3 @@ export declare function addLabel(annotator: Annotator, label: LabelDefinition):
3
3
  export declare function setActiveLabel(annotator: Annotator, labelId: string): void;
4
4
  export declare function getActiveLabel(annotator: Annotator): string | null;
5
5
  export declare function updateLabel(annotator: Annotator, labelId: string, updates: Partial<Pick<LabelDefinition, 'name' | 'color'>>): void;
6
- //# sourceMappingURL=labels.d.ts.map
@@ -10,4 +10,3 @@ export declare function splitBinaryMaskComponents(mask: ArrayLike<number>, width
10
10
  export declare function getBinaryMaskBounds(mask: ArrayLike<number>, width: number, height: number): Bounds | null;
11
11
  export declare function translateBinaryMask(mask: ArrayLike<number>, width: number, height: number, deltaX: number, deltaY: number): Uint8Array;
12
12
  export declare function binaryMasksWithinDistance(first: ArrayLike<number>, second: ArrayLike<number>, width: number, height: number, distance: number): boolean;
13
- //# sourceMappingURL=rle.d.ts.map
@@ -11,4 +11,3 @@ export interface CanvasLayerSize {
11
11
  readonly dpr: number;
12
12
  }
13
13
  export declare function createCanvasLayers(container: HTMLElement): CanvasLayerSet;
14
- //# sourceMappingURL=canvas-layers.d.ts.map
@@ -7,4 +7,3 @@ export interface CanvasRenderer {
7
7
  readonly destroy: () => void;
8
8
  }
9
9
  export declare function createCanvasRenderer(annotator: Annotator): CanvasRenderer;
10
- //# sourceMappingURL=canvas-renderer.d.ts.map
@@ -9,4 +9,3 @@ export interface RenderScheduler {
9
9
  readonly destroy: () => void;
10
10
  }
11
11
  export declare function createRenderScheduler(options: RenderSchedulerOptions): RenderScheduler;
12
- //# sourceMappingURL=scheduler.d.ts.map
@@ -12,4 +12,3 @@ export declare function updateSpatialItem(index: GridIndex, id: string, bounds:
12
12
  export declare function removeSpatialItem(index: GridIndex, id: string): GridIndex;
13
13
  export declare function restoreSpatialItem(index: GridIndex, id: string, bounds: Bounds, order: number): GridIndex;
14
14
  export declare function querySpatialBounds(index: GridIndex, bounds: Bounds): string[];
15
- //# sourceMappingURL=grid-index.d.ts.map
@@ -29,4 +29,3 @@ export declare function getActiveToolId(annotator: Annotator): string | null;
29
29
  export declare function deleteSelectedAnnotations(annotator: Annotator): number;
30
30
  export declare function updateSelectedAnnotationsLabel(annotator: Annotator, labelId: string): number;
31
31
  export declare function createToolApi(annotator: Annotator): AnnotationToolApi;
32
- //# sourceMappingURL=api.d.ts.map
@@ -20,4 +20,3 @@ export interface BrushMaskInput {
20
20
  export declare function createBrushMaskGeometry(input: BrushMaskInput): MaskGeometry;
21
21
  export declare function createBrushTool(options?: BrushToolOptions): Tool;
22
22
  export declare function useBrush(annotator: Annotator, options?: Partial<BrushToolOptions>): void;
23
- //# sourceMappingURL=brush-tool.d.ts.map
@@ -6,4 +6,3 @@ export declare function activateToolById(annotator: Annotator, toolId: string):
6
6
  export declare function cancelActiveGesture(annotator: Annotator): void;
7
7
  export declare function getRegisteredTools(annotator: Annotator): readonly Tool[];
8
8
  export declare function getRegisteredToolsByCategory(annotator: Annotator, category: ToolCategory): readonly Tool[];
9
- //# sourceMappingURL=controller.d.ts.map
@@ -5,4 +5,3 @@ export interface EraserToolOptions {
5
5
  }
6
6
  export declare function createEraserTool(options?: EraserToolOptions): Tool;
7
7
  export declare function useEraser(annotator: Annotator, options?: Partial<EraserToolOptions>): void;
8
- //# sourceMappingURL=eraser-tool.d.ts.map
@@ -8,4 +8,3 @@ export declare function unregisterTool(annotator: Annotator, toolId: string): vo
8
8
  export declare function getTool(annotator: Annotator, toolId: string): Tool | undefined;
9
9
  export declare function listTools(annotator: Annotator): readonly Tool[];
10
10
  export declare function listToolsByCategory(annotator: Annotator, category: ToolCategory): readonly Tool[];
11
- //# sourceMappingURL=index.d.ts.map
@@ -30,4 +30,3 @@ export interface PolygonToolOptions {
30
30
  }
31
31
  export declare function createPolygonTool(options: PolygonToolOptions): Tool;
32
32
  export declare function usePolygon(annotator: Annotator, options?: Partial<PolygonToolOptions>): void;
33
- //# sourceMappingURL=polygon-tool.d.ts.map
@@ -29,4 +29,3 @@ export interface RectToolOptions {
29
29
  }
30
30
  export declare function createRectTool(options: RectToolOptions): Tool;
31
31
  export declare function useRect(annotator: Annotator, options?: Partial<RectToolOptions>): void;
32
- //# sourceMappingURL=rect-tool.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { ToolRegistry } from './types.js';
2
2
  export declare function createToolRegistry(): ToolRegistry;
3
3
  export declare function createDefaultToolRegistry(): ToolRegistry;
4
- //# sourceMappingURL=registry.d.ts.map
@@ -12,4 +12,3 @@ export declare function clearSelection(annotator: Annotator): void;
12
12
  export declare function getSelection(annotator: Annotator): readonly string[];
13
13
  export declare function createSelectTool(): Tool;
14
14
  export declare function useSelect(annotator: Annotator): void;
15
- //# sourceMappingURL=select-tool.d.ts.map
@@ -77,4 +77,3 @@ export interface ToolRegistry {
77
77
  readonly list: () => readonly Tool[];
78
78
  readonly listByCategory: (category: ToolCategory) => readonly Tool[];
79
79
  }
80
- //# sourceMappingURL=types.d.ts.map
@@ -17,4 +17,3 @@ export declare function screenToImage(viewport: ViewportState, point: Point): Po
17
17
  export declare function zoomAt(viewport: ViewportState, screenAnchor: Point, requestedScale: number): ViewportState;
18
18
  export declare function panViewport(viewport: ViewportState, delta: Point): ViewportState;
19
19
  export declare function fitViewport(viewport: ViewportState, imageSize: Size): ViewportState;
20
- //# sourceMappingURL=viewport.d.ts.map
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "cs-label-tool",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0",
4
4
  "description": "Framework-free TypeScript library for AI-assisted image annotation.",
5
5
  "type": "module",
6
+ "sideEffects": false,
6
7
  "files": [
7
8
  "dist"
8
9
  ],
@@ -12,6 +13,11 @@
12
13
  "import": "./dist/index.js"
13
14
  }
14
15
  },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/",
19
+ "tag": "latest"
20
+ },
15
21
  "scripts": {
16
22
  "dev": "vite",
17
23
  "build": "vite build && tsc -p tsconfig.build.json",
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotator-element.d.ts","sourceRoot":"","sources":["../../src/components/annotator-element.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAUnE,KAAK,sBAAsB,GAAG,UAAU,WAAW,CAAA;AACnD,QAAA,MAAM,eAAe,EAEhB,sBAAsB,CAAA;AAE3B,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;AAE3E,qBAAa,kBAAmB,SAAQ,eAAe;;IAQrD,iBAAiB,IAAI,IAAI,CAoCxB;IAED,oBAAoB,IAAI,IAAI,CAE3B;IAED,SAAS,CAAC,OAAO,GAAE,yBAA8B,GAAG,SAAS,CAoB5D;IAED,IAAI,SAAS,IAAI,SAAS,GAAG,IAAI,CAEhC;IAED,OAAO,IAAI,IAAI,CASd;CAyFF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/components/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,uBAAuB,IAAI,IAAI,CAI9C;AAYD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,GAAG,OAAO,EACxB,OAAO,GAAE,yBAA8B,GACtC,SAAS,CAMX;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAU/D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,0xDAmF3B,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotator.d.ts","sourceRoot":"","sources":["../../src/core/annotator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAA;AAKnB,iCAAiC;AACjC,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,CASpE;AAED,wBAAgB,eAAe,CAAC,O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K,EAAE,MAAM,YAAY,CAAA;AAEjD,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,QAAQ,CAQV;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAcvD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAKpE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../src/geometry/polygon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GACxB;IACE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,MAAM,EACX,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,WAAW,CAAA;CAChB,CAAA;AAsDL,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,OAAO,CA6B/E;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,iBAAiB,CA+CnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../src/geometry/rect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAW/C,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM,CAY9D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ/D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/geometry/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,MAAO,SAAQ,KAAK,EAAE,IAAI;CAAG;AAE9C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CACnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-commands.d.ts","sourceRoot":"","sources":["../../src/image/image-commands.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,KAAK,EAAQ,MAAM,sBAAsB,CAAA;AAUvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAkB7C,wBAAsB,cAAc,CAClC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAyCf;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAEtD;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAEpD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAKzD;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAStD;AAED,wBAAgB,MAAM,CACpB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,KAAK,GACb,IAAI,CAUN;AAED,wBAAgB,MAAM,CACpB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,KAAK,GACb,IAAI,CAGN;AAED,wBAAgB,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAM9D;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAMvE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAQvE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"standard-source.d.ts","sourceRoot":"","sources":["../../src/image/standard-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAEX,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAsCnB,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,kBAAkB,GACxB,WAAW,CAkFb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/image/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAC7B;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,IAAI,GAAG,WAAW,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,UAAU,EACV,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,IAAI,EACJ,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,SAAS,EACT,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,cAAc,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,aAAa,EACb,WAAW,GACZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,cAAc,EACd,eAAe,EACf,KAAK,iBAAiB,GACvB,MAAM,uBAAuB,CAAA;AAE9B,YAAY,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,GACL,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,cAAc,EACd,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,MAAM,EACN,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,wBAAwB,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AEhC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,KAAK,UAAU,GAChB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,gBAAgB,GACjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,MAAM,EACN,KAAK,EACL,WAAW,EACX,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,eAAe,CAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["#viewport","#labelList","#buttons","#runAction","#refreshControls","#annotator","#unsubscribe","#refreshLabels","#activeTool","#setActiveTool"],"sources":["../src/spatial/grid-index.ts","../src/geometry/polygon.ts","../src/core/events.ts","../src/core/immutability.ts","../src/core/types.ts","../src/core/commands.ts","../src/labels/labels.ts","../src/geometry/matrix.ts","../src/viewport/viewport.ts","../src/mask/rle.ts","../src/render/canvas-layers.ts","../src/render/scheduler.ts","../src/render/canvas-renderer.ts","../src/image/image-commands.ts","../src/tools/controller.ts","../src/tools/brush-tool.ts","../src/geometry/rect.ts","../src/tools/select-tool.ts","../src/tools/eraser-tool.ts","../src/tools/polygon-tool.ts","../src/tools/rect-tool.ts","../src/tools/registry.ts","../src/core/state.ts","../src/core/annotator.ts","../src/image/standard-source.ts","../src/tools/api.ts","../src/tools/index.ts","../src/components/styles.ts","../src/components/annotator-element.ts","../src/components/define.ts","../src/cs-label-tool.ts"],"sourcesContent":["import type { Bounds } from '../geometry/types.js'\n\nexport interface GridIndex {\n // 一个标注可能跨越多个网格;cells 用于召回候选,items 保存精确包围盒。\n readonly cellSize: number\n readonly cells: Map<string, Set<string>>\n readonly items: Map<string, Bounds>\n readonly order: Map<string, number>\n nextOrder: number\n}\n\nfunction assertBounds(bounds: Bounds): void {\n if (\n ![\n bounds.x,\n bounds.y,\n bounds.width,\n bounds.height,\n ].every(Number.isFinite) ||\n bounds.width < 0 ||\n bounds.height < 0\n ) {\n throw new RangeError('Spatial bounds must be finite and non-negative.')\n }\n}\n\nfunction getCellKeys(cellSize: number, bounds: Bounds): string[] {\n // 边界落在哪些网格中,插入、更新、删除和查询都使用同一套计算规则。\n const minX = Math.floor(bounds.x / cellSize)\n const minY = Math.floor(bounds.y / cellSize)\n const maxX = Math.floor((bounds.x + bounds.width) / cellSize)\n const maxY = Math.floor((bounds.y + bounds.height) / cellSize)\n const keys: string[] = []\n for (let y = minY; y <= maxY; y += 1) {\n for (let x = minX; x <= maxX; x += 1) {\n keys.push(`${x}:${y}`)\n }\n }\n return keys\n}\n\nfunction removeFromCells(index: GridIndex, id: string): void {\n const bounds = index.items.get(id)\n if (bounds === undefined) {\n return\n }\n\n for (const key of getCellKeys(index.cellSize, bounds)) {\n const occupants = index.cells.get(key)\n if (occupants === undefined) {\n continue\n }\n occupants.delete(id)\n if (occupants.size === 0) {\n index.cells.delete(key)\n }\n }\n}\n\nfunction addToCells(\n cells: Map<string, Set<string>>,\n cellSize: number,\n id: string,\n bounds: Bounds,\n): void {\n for (const key of getCellKeys(cellSize, bounds)) {\n const occupants = cells.get(key) ?? new Set<string>()\n occupants.add(id)\n cells.set(key, occupants)\n }\n}\n\nfunction intersects(first: Bounds, second: Bounds): boolean {\n return !(\n first.x + first.width < second.x ||\n second.x + second.width < first.x ||\n first.y + first.height < second.y ||\n second.y + second.height < first.y\n )\n}\n\nexport function createGridIndex(cellSize: number): GridIndex {\n if (!Number.isFinite(cellSize) || cellSize <= 0) {\n throw new RangeError('Spatial cell size must be finite and positive.')\n }\n return {\n cellSize,\n cells: new Map(),\n items: new Map(),\n order: new Map(),\n nextOrder: 0,\n }\n}\n\nexport function insertSpatialItem(\n index: GridIndex,\n id: string,\n bounds: Bounds,\n): GridIndex {\n assertBounds(bounds)\n if (index.items.has(id)) {\n return updateSpatialItem(index, id, bounds)\n }\n\n addToCells(index.cells, index.cellSize, id, bounds)\n index.items.set(id, { ...bounds })\n // order 记录插入顺序,查询结果据此保持稳定,也对应画布上的绘制层级。\n index.order.set(id, index.nextOrder)\n index.nextOrder += 1\n return index\n}\n\nexport function updateSpatialItem(\n index: GridIndex,\n id: string,\n bounds: Bounds,\n): GridIndex {\n assertBounds(bounds)\n if (!index.items.has(id)) {\n return insertSpatialItem(index, id, bounds)\n }\n\n removeFromCells(index, id)\n addToCells(index.cells, index.cellSize, id, bounds)\n index.items.set(id, { ...bounds })\n return index\n}\n\nexport function removeSpatialItem(index: GridIndex, id: string): GridIndex {\n if (!index.items.has(id)) {\n return index\n }\n removeFromCells(index, id)\n index.items.delete(id)\n index.order.delete(id)\n return index\n}\n\nexport function restoreSpatialItem(\n index: GridIndex,\n id: string,\n bounds: Bounds,\n order: number,\n): GridIndex {\n insertSpatialItem(index, id, bounds)\n index.order.set(id, order)\n return index\n}\n\nexport function querySpatialBounds(\n index: GridIndex,\n bounds: Bounds,\n): string[] {\n assertBounds(bounds)\n const candidates = new Set<string>()\n // 网格查询是粗筛:先合并所有相关单元格,再用真实包围盒剔除误命中。\n for (const key of getCellKeys(index.cellSize, bounds)) {\n for (const id of index.cells.get(key) ?? []) {\n candidates.add(id)\n }\n }\n\n return [...candidates]\n .filter(id => {\n const item = index.items.get(id)\n return item !== undefined && intersects(item, bounds)\n })\n .sort((first, second) =>\n (index.order.get(first) ?? 0) - (index.order.get(second) ?? 0),\n )\n}\n","import type { Point } from './types.js'\n\nexport type PolygonValidation =\n | { readonly valid: true }\n | {\n readonly valid: false\n readonly reason:\n | 'NON_FINITE_POINT'\n | 'SELF_INTERSECTION'\n | 'TOO_FEW_POINTS'\n | 'ZERO_AREA'\n }\n\nfunction pointOnSegment(point: Point, start: Point, end: Point): boolean {\n const firstProduct = (point.y - start.y) * (end.x - start.x)\n const secondProduct = (point.x - start.x) * (end.y - start.y)\n const cross = firstProduct - secondProduct\n const tolerance = Number.EPSILON * 16 * Math.max(\n 1,\n Math.abs(firstProduct) + Math.abs(secondProduct),\n )\n if (Math.abs(cross) > tolerance) {\n return false\n }\n\n return (\n point.x >= Math.min(start.x, end.x) &&\n point.x <= Math.max(start.x, end.x) &&\n point.y >= Math.min(start.y, end.y) &&\n point.y <= Math.max(start.y, end.y)\n )\n}\n\nfunction orientation(start: Point, end: Point, point: Point): -1 | 0 | 1 {\n const firstProduct = (end.y - start.y) * (point.x - end.x)\n const secondProduct = (end.x - start.x) * (point.y - end.y)\n const value = firstProduct - secondProduct\n const tolerance = Number.EPSILON * 16 * Math.max(\n 1,\n Math.abs(firstProduct) + Math.abs(secondProduct),\n )\n return Math.abs(value) <= tolerance ? 0 : value > 0 ? 1 : -1\n}\n\nfunction segmentsIntersect(\n firstStart: Point,\n firstEnd: Point,\n secondStart: Point,\n secondEnd: Point,\n): boolean {\n const first = orientation(firstStart, firstEnd, secondStart)\n const second = orientation(firstStart, firstEnd, secondEnd)\n const third = orientation(secondStart, secondEnd, firstStart)\n const fourth = orientation(secondStart, secondEnd, firstEnd)\n if (first !== 0 && second !== 0 && third !== 0 && fourth !== 0) {\n return first !== second && third !== fourth\n }\n return (\n (first === 0 && pointOnSegment(secondStart, firstStart, firstEnd)) ||\n (second === 0 && pointOnSegment(secondEnd, firstStart, firstEnd)) ||\n (third === 0 && pointOnSegment(firstStart, secondStart, secondEnd)) ||\n (fourth === 0 && pointOnSegment(firstEnd, secondStart, secondEnd))\n )\n}\n\nexport function pointInPolygon(point: Point, polygon: readonly Point[]): boolean {\n if (polygon.length < 3) {\n return false\n }\n\n let inside = false\n for (let currentIndex = 0, previousIndex = polygon.length - 1;\n currentIndex < polygon.length;\n previousIndex = currentIndex, currentIndex += 1) {\n const current = polygon[currentIndex]\n const previous = polygon[previousIndex]\n if (current === undefined || previous === undefined) {\n continue\n }\n if (pointOnSegment(point, previous, current)) {\n return true\n }\n\n const crossesRay =\n current.y > point.y !== previous.y > point.y &&\n point.x <\n ((previous.x - current.x) * (point.y - current.y)) /\n (previous.y - current.y) +\n current.x\n if (crossesRay) {\n inside = !inside\n }\n }\n return inside\n}\n\nexport function validatePolygon(\n polygon: readonly Point[],\n): PolygonValidation {\n if (polygon.some(point => !Number.isFinite(point.x) || !Number.isFinite(point.y))) {\n return { valid: false, reason: 'NON_FINITE_POINT' }\n }\n\n const uniquePoints = new Set(polygon.map(point => `${point.x}:${point.y}`))\n if (uniquePoints.size < 3) {\n return { valid: false, reason: 'TOO_FEW_POINTS' }\n }\n\n for (let first = 0; first < polygon.length; first += 1) {\n const firstNext = (first + 1) % polygon.length\n for (let second = first + 1; second < polygon.length; second += 1) {\n const secondNext = (second + 1) % polygon.length\n const adjacent =\n first === second ||\n firstNext === second ||\n secondNext === first\n if (adjacent) {\n continue\n }\n const firstStart = polygon[first]\n const firstEnd = polygon[firstNext]\n const secondStart = polygon[second]\n const secondEnd = polygon[secondNext]\n if (\n firstStart !== undefined &&\n firstEnd !== undefined &&\n secondStart !== undefined &&\n secondEnd !== undefined &&\n segmentsIntersect(firstStart, firstEnd, secondStart, secondEnd)\n ) {\n return { valid: false, reason: 'SELF_INTERSECTION' }\n }\n }\n }\n\n const twiceArea = polygon.reduce((sum, point, index) => {\n const next = polygon[(index + 1) % polygon.length]\n return next === undefined\n ? sum\n : sum + point.x * next.y - next.x * point.y\n }, 0)\n if (Math.abs(twiceArea) <= Number.EPSILON) {\n return { valid: false, reason: 'ZERO_AREA' }\n }\n return { valid: true }\n}\n","import { getInternalState } from './annotator.js'\nimport type { Annotator } from './types.js'\n\nexport type ChangeKind =\n | 'annotation:add'\n | 'annotation:remove'\n | 'annotation:update'\n | 'history:redo'\n | 'history:undo'\n | 'image:clear'\n | 'image:load'\n | 'label:activate'\n | 'label:add'\n | 'label:update'\n | 'selection:update'\n\nexport interface ChangeEvent {\n readonly type: 'change'\n readonly kind: ChangeKind\n readonly revision: number\n}\n\nexport interface AnnotatorErrorEvent {\n readonly type: 'error'\n readonly code: 'SUBSCRIBER_ERROR'\n readonly error: unknown\n}\n\nexport interface AnnotatorEventMap {\n readonly change: ChangeEvent\n readonly error: AnnotatorErrorEvent\n}\n\nexport type AnnotatorEventName = keyof AnnotatorEventMap\nexport type AnnotatorEventListener<K extends AnnotatorEventName> = (\n event: AnnotatorEventMap[K],\n) => void\n\nexport interface EventListeners {\n readonly change: Set<AnnotatorEventListener<'change'>>\n readonly error: Set<AnnotatorEventListener<'error'>>\n}\n\nfunction emitSubscriberError(annotator: Annotator, error: unknown): void {\n const state = getInternalState(annotator)\n const event: AnnotatorErrorEvent = {\n type: 'error',\n code: 'SUBSCRIBER_ERROR',\n error,\n }\n for (const listener of [...state.listeners.error]) {\n try {\n listener(event)\n } catch {\n // 隔离业务侧错误监听器,避免错误处理再次递归触发自身。\n }\n }\n}\n\nexport function emitChange(annotator: Annotator, kind: ChangeKind): void {\n const state = getInternalState(annotator)\n const event: ChangeEvent = {\n type: 'change',\n kind,\n revision: state.revision,\n }\n for (const listener of [...state.listeners.change]) {\n try {\n listener(event)\n } catch (error) {\n emitSubscriberError(annotator, error)\n }\n }\n}\n\nexport function subscribe<K extends AnnotatorEventName>(\n annotator: Annotator,\n type: K,\n listener: AnnotatorEventListener<K>,\n): () => void {\n const state = getInternalState(annotator)\n const listeners = state.listeners[type] as Set<AnnotatorEventListener<K>>\n listeners.add(listener)\n let subscribed = true\n\n return () => {\n if (!subscribed) {\n return\n }\n subscribed = false\n listeners.delete(listener)\n }\n}\n","import type {\n Annotation,\n MaskGeometry,\n PolygonGeometry,\n RectGeometry,\n} from './types.js'\n\nfunction deepFreeze(value: unknown, seen = new WeakSet<object>()): unknown {\n // metadata 可能存在共享引用,WeakSet 用来避免重复遍历和循环引用导致死递归。\n if (value === null || typeof value !== 'object' || seen.has(value)) {\n return value\n }\n seen.add(value)\n for (const child of Object.values(value)) {\n deepFreeze(child, seen)\n }\n return Object.freeze(value)\n}\n\nexport function cloneGeometry(\n geometry: RectGeometry | PolygonGeometry | MaskGeometry,\n): RectGeometry | PolygonGeometry | MaskGeometry {\n // 对外快照既要复制容器,也要冻结 points/rle 等内部数组,防止调用方改写内部状态。\n if (geometry.type === 'rect') {\n return Object.freeze({ ...geometry })\n }\n if (geometry.type === 'polygon') {\n return Object.freeze({\n type: 'polygon' as const,\n points: Object.freeze(\n geometry.points.map(([x, y]) => Object.freeze([x, y] as const)),\n ),\n })\n }\n return Object.freeze({\n type: 'mask' as const,\n width: geometry.width,\n height: geometry.height,\n rle: Object.freeze([...geometry.rle]),\n })\n}\n\nexport function cloneAnnotation(annotation: Annotation): Annotation {\n const metadata = structuredClone(annotation.metadata)\n return Object.freeze({\n ...annotation,\n geometry: cloneGeometry(annotation.geometry),\n metadata: deepFreeze(metadata),\n }) as Annotation\n}\n","const annotatorBrand: unique symbol = Symbol('Annotator')\n\nexport interface Annotator {\n readonly [annotatorBrand]: true\n}\n\nexport interface AnnotatorOptions {\n readonly container: HTMLElement\n readonly historyLimit?: number\n}\n\nexport interface LabelDefinition {\n readonly id: string\n readonly name: string\n readonly color: string\n}\n\nexport interface AnnotationBase {\n readonly id: string\n readonly labelId: string\n readonly source: 'manual' | 'ai'\n readonly status: 'suggested' | 'accepted' | 'rejected' | 'modified'\n readonly revision: number\n readonly createdAt: number\n readonly updatedAt: number\n readonly metadata: Readonly<Record<string, unknown>>\n}\n\nexport interface RectGeometry {\n readonly type: 'rect'\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\n\nexport interface PolygonGeometry {\n readonly type: 'polygon'\n readonly points: readonly (readonly [number, number])[]\n}\n\nexport interface MaskGeometry {\n readonly type: 'mask'\n readonly width: number\n readonly height: number\n readonly rle: readonly number[]\n}\n\nexport interface RectAnnotation extends AnnotationBase {\n readonly geometry: RectGeometry\n}\n\nexport interface PolygonAnnotation extends AnnotationBase {\n readonly geometry: PolygonGeometry\n}\n\nexport interface MaskAnnotation extends AnnotationBase {\n readonly geometry: MaskGeometry\n}\n\nexport type Annotation = RectAnnotation | PolygonAnnotation | MaskAnnotation\n\nexport interface AnnotationSnapshot {\n readonly schemaVersion: 1\n readonly revision: number\n readonly annotations: readonly Annotation[]\n readonly labels: readonly LabelDefinition[]\n}\n\nexport type AnnotatorErrorCode =\n | 'ANNOTATOR_DESTROYED'\n | 'ANNOTATION_NOT_FOUND'\n | 'DUPLICATE_LABEL'\n | 'INVALID_GEOMETRY'\n | 'UNKNOWN_LABEL'\n\nexport class AnnotatorError extends Error {\n readonly code: AnnotatorErrorCode\n\n constructor(code: AnnotatorErrorCode, message: string) {\n super(message)\n this.name = 'AnnotatorError'\n this.code = code\n }\n}\n\nexport function createAnnotatorHandle(): Annotator {\n return Object.freeze({ [annotatorBrand]: true as const })\n}\n","import type { Bounds, Point } from '../geometry/types.js'\nimport { validatePolygon } from '../geometry/polygon.js'\nimport {\n insertSpatialItem,\n querySpatialBounds,\n removeSpatialItem,\n restoreSpatialItem,\n updateSpatialItem,\n} from '../spatial/grid-index.js'\nimport { getInternalState } from './annotator.js'\nimport { emitChange, type ChangeKind } from './events.js'\nimport { cloneAnnotation } from './immutability.js'\nimport type { HistoryEntry, InternalState } from './state.js'\nimport { AnnotatorError } from './types.js'\nimport type {\n Annotation,\n AnnotationBase,\n Annotator,\n MaskGeometry,\n PolygonGeometry,\n RectGeometry,\n} from './types.js'\n\nexport interface AddRectInput extends Omit<RectGeometry, 'type'> {\n readonly labelId: string\n}\n\nexport interface AddPolygonInput {\n readonly labelId: string\n readonly points: readonly Point[]\n}\n\nfunction recordHistory(\n annotator: Annotator,\n kind: ChangeKind,\n entry: HistoryEntry,\n): void {\n const state = getInternalState(annotator)\n state.revision += 1\n state.undoStack.push(entry)\n if (state.undoStack.length > state.historyLimit) {\n state.undoStack.shift()\n }\n state.redoStack = []\n emitChange(annotator, kind)\n}\n\n/**\n * 所有领域修改的统一入口:先执行 redo,再记录可撤销操作并发送 change 事件。\n * UI 和工具不应直接修改 InternalState。\n */\nexport function commitDomainCommand(\n annotator: Annotator,\n kind: ChangeKind,\n redo: (state: InternalState) => void,\n undo: (state: InternalState) => void,\n): void {\n const state = getInternalState(annotator)\n redo(state)\n recordHistory(annotator, kind, { undo, redo })\n}\n\nfunction requireLabel(state: InternalState, labelId: string): void {\n if (!state.labels.some(label => label.id === labelId)) {\n throw new AnnotatorError('UNKNOWN_LABEL', `Unknown label: ${labelId}`)\n }\n}\n\nfunction createAnnotationBase(labelId: string): AnnotationBase {\n const now = Date.now()\n return {\n id: globalThis.crypto.randomUUID(),\n labelId,\n source: 'manual',\n status: 'accepted',\n revision: 1,\n createdAt: now,\n updatedAt: now,\n metadata: Object.freeze({}),\n }\n}\n\nfunction validateRect(geometry: RectGeometry): void {\n if (\n ![\n geometry.x,\n geometry.y,\n geometry.width,\n geometry.height,\n ].every(Number.isFinite) ||\n geometry.width <= 0 ||\n geometry.height <= 0\n ) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n 'Rectangle coordinates must be finite and dimensions must be positive.',\n )\n }\n}\n\nfunction validateGeometry(geometry: RectGeometry | PolygonGeometry | MaskGeometry): void {\n if (geometry.type === 'rect') {\n validateRect(geometry)\n return\n }\n if (geometry.type === 'polygon') {\n const result = validatePolygon(\n geometry.points.map(([x, y]) => ({ x, y })),\n )\n if (!result.valid) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n `Invalid polygon: ${result.reason}`,\n )\n }\n return\n }\n if (geometry.type === 'mask') {\n if (geometry.width <= 0 || geometry.height <= 0) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n 'Mask dimensions must be positive.',\n )\n }\n return\n }\n}\n\nfunction getGeometryBounds(\n geometry: RectGeometry | PolygonGeometry | MaskGeometry,\n): Bounds {\n if (geometry.type === 'rect') {\n return geometry\n }\n if (geometry.type === 'mask') {\n // Mask 数据与原图等大;更精确的像素边界由 mask 工具函数按需计算。\n return { x: 0, y: 0, width: geometry.width, height: geometry.height }\n }\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n for (const [x, y] of geometry.points) {\n minX = Math.min(minX, x)\n minY = Math.min(minY, y)\n maxX = Math.max(maxX, x)\n maxY = Math.max(maxY, y)\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n\nfunction insertAnnotation(\n state: InternalState,\n annotation: Annotation,\n index = state.annotations.length,\n order?: number,\n): void {\n // 主数组、ID Map 和空间索引必须作为一个整体更新。\n state.annotations.splice(index, 0, annotation)\n state.annotationsById.set(annotation.id, annotation)\n const bounds = getGeometryBounds(annotation.geometry)\n if (order === undefined) {\n insertSpatialItem(state.spatialIndex, annotation.id, bounds)\n } else {\n restoreSpatialItem(state.spatialIndex, annotation.id, bounds, order)\n }\n}\n\nfunction deleteAnnotation(state: InternalState, id: string): void {\n // 删除正在编辑的标注前先取消手势,避免 interaction draft 引用失效对象。\n if (state.selectedIds.includes(id)) {\n state.toolController?.cancel()\n state.selectedIds = state.selectedIds.filter(selectedId => selectedId !== id)\n state.interactionDraft = null\n }\n const index = state.annotations.findIndex(annotation => annotation.id === id)\n if (index >= 0) {\n state.annotations.splice(index, 1)\n }\n state.annotationsById.delete(id)\n removeSpatialItem(state.spatialIndex, id)\n}\n\nexport function addRect(annotator: Annotator, input: AddRectInput): string {\n const state = getInternalState(annotator)\n requireLabel(state, input.labelId)\n const geometry: RectGeometry = {\n type: 'rect',\n x: input.x,\n y: input.y,\n width: input.width,\n height: input.height,\n }\n validateRect(geometry)\n const annotation = cloneAnnotation({\n ...createAnnotationBase(input.labelId),\n geometry,\n })\n const index = state.annotations.length\n\n commitDomainCommand(\n annotator,\n 'annotation:add',\n current => insertAnnotation(current, annotation, index),\n current => deleteAnnotation(current, annotation.id),\n )\n return annotation.id\n}\n\nexport function addPolygon(\n annotator: Annotator,\n input: AddPolygonInput,\n): string {\n const state = getInternalState(annotator)\n requireLabel(state, input.labelId)\n const geometry: PolygonGeometry = {\n type: 'polygon',\n points: input.points.map(point => [point.x, point.y] as const),\n }\n validateGeometry(geometry)\n const annotation = cloneAnnotation({\n ...createAnnotationBase(input.labelId),\n geometry,\n })\n const index = state.annotations.length\n\n commitDomainCommand(\n annotator,\n 'annotation:add',\n current => insertAnnotation(current, annotation, index),\n current => deleteAnnotation(current, annotation.id),\n )\n return annotation.id\n}\n\nexport interface AddMaskInput {\n readonly labelId: string\n readonly width: number\n readonly height: number\n readonly rle: readonly number[]\n}\n\nexport function addMask(annotator: Annotator, input: AddMaskInput): string {\n const state = getInternalState(annotator)\n requireLabel(state, input.labelId)\n const geometry: MaskGeometry = {\n type: 'mask',\n width: input.width,\n height: input.height,\n rle: input.rle,\n }\n validateGeometry(geometry)\n const annotation = cloneAnnotation({\n ...createAnnotationBase(input.labelId),\n geometry,\n })\n const index = state.annotations.length\n\n commitDomainCommand(\n annotator,\n 'annotation:add',\n current => insertAnnotation(current, annotation, index),\n current => deleteAnnotation(current, annotation.id),\n )\n return annotation.id\n}\n\nexport function updateAnnotation(\n annotator: Annotator,\n id: string,\n geometry: RectGeometry | PolygonGeometry | MaskGeometry,\n): void {\n validateGeometry(geometry)\n const state = getInternalState(annotator)\n const previous = state.annotationsById.get(id)\n if (previous === undefined) {\n throw new AnnotatorError(\n 'ANNOTATION_NOT_FOUND',\n `Annotation not found: ${id}`,\n )\n }\n if (previous.geometry.type !== geometry.type) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n 'Annotation geometry type cannot be changed.',\n )\n }\n const next = cloneAnnotation({\n ...previous,\n geometry,\n revision: previous.revision + 1,\n updatedAt: Date.now(),\n } as Annotation)\n const index = state.annotations.findIndex(annotation => annotation.id === id)\n\n const apply = (current: InternalState, annotation: Annotation) => {\n // 更新几何后同步刷新空间索引,否则区域查询仍会命中旧位置。\n current.annotations[index] = annotation\n current.annotationsById.set(id, annotation)\n updateSpatialItem(\n current.spatialIndex,\n id,\n getGeometryBounds(annotation.geometry),\n )\n }\n commitDomainCommand(\n annotator,\n 'annotation:update',\n current => apply(current, next),\n current => apply(current, previous),\n )\n}\n\nexport function updateAnnotationLabel(\n annotator: Annotator,\n id: string,\n labelId: string,\n): void {\n const state = getInternalState(annotator)\n requireLabel(state, labelId)\n const previous = state.annotationsById.get(id)\n if (previous === undefined) {\n throw new AnnotatorError(\n 'ANNOTATION_NOT_FOUND',\n `Annotation not found: ${id}`,\n )\n }\n if (previous.labelId === labelId) {\n return\n }\n const next = cloneAnnotation({\n ...previous,\n labelId,\n revision: previous.revision + 1,\n updatedAt: Date.now(),\n } as Annotation)\n const index = state.annotations.findIndex(annotation => annotation.id === id)\n\n const apply = (current: InternalState, annotation: Annotation) => {\n current.annotations[index] = annotation\n current.annotationsById.set(id, annotation)\n }\n commitDomainCommand(\n annotator,\n 'annotation:update',\n current => apply(current, next),\n current => apply(current, previous),\n )\n}\n\nexport function removeAnnotation(annotator: Annotator, id: string): boolean {\n const state = getInternalState(annotator)\n const annotation = state.annotationsById.get(id)\n if (annotation === undefined) {\n return false\n }\n const index = state.annotations.findIndex(item => item.id === id)\n const order = state.spatialIndex.order.get(id)\n if (order === undefined) {\n throw new Error(`Spatial index is missing annotation: ${id}`)\n }\n\n commitDomainCommand(\n annotator,\n 'annotation:remove',\n current => deleteAnnotation(current, id),\n current => insertAnnotation(current, annotation, index, order),\n )\n return true\n}\n\nexport function canUndo(annotator: Annotator): boolean {\n return getInternalState(annotator).undoStack.length > 0\n}\n\nexport function canRedo(annotator: Annotator): boolean {\n return getInternalState(annotator).redoStack.length > 0\n}\n\nexport function undo(annotator: Annotator): boolean {\n const state = getInternalState(annotator)\n const entry = state.undoStack.pop()\n if (entry === undefined) {\n return false\n }\n entry.undo(state)\n state.redoStack.push(entry)\n state.revision += 1\n emitChange(annotator, 'history:undo')\n return true\n}\n\nexport function redo(annotator: Annotator): boolean {\n const state = getInternalState(annotator)\n const entry = state.redoStack.pop()\n if (entry === undefined) {\n return false\n }\n entry.redo(state)\n state.undoStack.push(entry)\n state.revision += 1\n emitChange(annotator, 'history:redo')\n return true\n}\n\nexport function queryAnnotations(\n annotator: Annotator,\n bounds: Bounds,\n): Annotation[] {\n const state = getInternalState(annotator)\n // 先通过网格索引取候选,再由上层按具体几何做精确命中。\n return querySpatialBounds(state.spatialIndex, bounds)\n .map(id => state.annotationsById.get(id))\n .filter((annotation): annotation is Annotation => annotation !== undefined)\n}\n","import { commitDomainCommand } from '../core/commands.js'\nimport { getInternalState } from '../core/annotator.js'\nimport { AnnotatorError } from '../core/types.js'\nimport type { Annotator, LabelDefinition } from '../core/types.js'\n\nexport function addLabel(\n annotator: Annotator,\n label: LabelDefinition,\n): void {\n const state = getInternalState(annotator)\n if (state.labels.some(existing => existing.id === label.id)) {\n throw new AnnotatorError(\n 'DUPLICATE_LABEL',\n `Label already exists: ${label.id}`,\n )\n }\n const storedLabel = Object.freeze({ ...label })\n const index = state.labels.length\n const previousActiveLabel = state.activeLabelId\n commitDomainCommand(\n annotator,\n 'label:add',\n current => {\n current.labels.splice(index, 0, storedLabel)\n if (previousActiveLabel === null) {\n current.activeLabelId = storedLabel.id\n }\n },\n current => {\n current.labels.splice(index, 1)\n current.activeLabelId = previousActiveLabel\n },\n )\n}\n\nexport function setActiveLabel(annotator: Annotator, labelId: string): void {\n const state = getInternalState(annotator)\n if (!state.labels.some(label => label.id === labelId)) {\n throw new AnnotatorError('UNKNOWN_LABEL', `Unknown label: ${labelId}`)\n }\n const previousActiveLabel = state.activeLabelId\n commitDomainCommand(\n annotator,\n 'label:activate',\n current => { current.activeLabelId = labelId },\n current => { current.activeLabelId = previousActiveLabel },\n )\n}\n\nexport function getActiveLabel(annotator: Annotator): string | null {\n return getInternalState(annotator).activeLabelId\n}\n\nexport function updateLabel(\n annotator: Annotator,\n labelId: string,\n updates: Partial<Pick<LabelDefinition, 'name' | 'color'>>,\n): void {\n const state = getInternalState(annotator)\n const index = state.labels.findIndex(label => label.id === labelId)\n if (index === -1) {\n throw new AnnotatorError('UNKNOWN_LABEL', `Unknown label: ${labelId}`)\n }\n const previous = state.labels[index]\n const next = Object.freeze({ ...previous, ...updates }) as LabelDefinition\n commitDomainCommand(\n annotator,\n 'label:update',\n current => { current.labels[index] = next },\n current => { current.labels[index] = previous! },\n )\n}\n","import { AnnotatorError } from '../core/types.js'\nimport type { Matrix2D, Point } from './types.js'\n\nexport function createScaleTranslateMatrix(\n scale: number,\n offsetX: number,\n offsetY: number,\n): Matrix2D {\n if (![scale, offsetX, offsetY].every(Number.isFinite) || scale <= 0) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n 'Matrix scale must be positive and all values must be finite.',\n )\n }\n return { a: scale, b: 0, c: 0, d: scale, e: offsetX, f: offsetY }\n}\n\nexport function invertMatrix(matrix: Matrix2D): Matrix2D {\n const determinant = matrix.a * matrix.d - matrix.b * matrix.c\n if (!Number.isFinite(determinant) || determinant === 0) {\n throw new AnnotatorError('INVALID_GEOMETRY', 'Matrix is not invertible.')\n }\n\n return {\n a: matrix.d / determinant,\n b: -matrix.b / determinant,\n c: -matrix.c / determinant,\n d: matrix.a / determinant,\n e: (matrix.c * matrix.f - matrix.d * matrix.e) / determinant,\n f: (matrix.b * matrix.e - matrix.a * matrix.f) / determinant,\n }\n}\n\nexport function transformPoint(matrix: Matrix2D, point: Point): Point {\n return {\n x: matrix.a * point.x + matrix.c * point.y + matrix.e,\n y: matrix.b * point.x + matrix.d * point.y + matrix.f,\n }\n}\n","import { AnnotatorError } from '../core/types.js'\nimport {\n createScaleTranslateMatrix,\n invertMatrix,\n transformPoint,\n} from '../geometry/matrix.js'\nimport type { Point, Size } from '../geometry/types.js'\n\nexport interface ViewportOptions extends Size {\n readonly minScale?: number\n readonly maxScale?: number\n}\n\nexport interface ViewportState extends Size {\n readonly scale: number\n readonly offsetX: number\n readonly offsetY: number\n readonly minScale: number\n readonly maxScale: number\n}\n\nfunction assertPositiveSize(size: Size, name: string): void {\n if (\n !Number.isFinite(size.width) ||\n !Number.isFinite(size.height) ||\n size.width <= 0 ||\n size.height <= 0\n ) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n `${name} dimensions must be finite and positive.`,\n )\n }\n}\n\nfunction clampScale(viewport: ViewportState, scale: number): number {\n if (!Number.isFinite(scale) || scale <= 0) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n 'Viewport scale must be finite and positive.',\n )\n }\n return Math.min(viewport.maxScale, Math.max(viewport.minScale, scale))\n}\n\nexport function createViewport(options: ViewportOptions): ViewportState {\n assertPositiveSize(options, 'Viewport')\n const minScale = options.minScale ?? 0.01\n const maxScale = options.maxScale ?? 64\n if (minScale <= 0 || maxScale < minScale) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n 'Viewport scale limits must be positive and ordered.',\n )\n }\n return {\n width: options.width,\n height: options.height,\n scale: 1,\n offsetX: 0,\n offsetY: 0,\n minScale,\n maxScale,\n }\n}\n\nexport function imageToScreen(viewport: ViewportState, point: Point): Point {\n return transformPoint(\n createScaleTranslateMatrix(\n viewport.scale,\n viewport.offsetX,\n viewport.offsetY,\n ),\n point,\n )\n}\n\n/** screenToImage 与 imageToScreen 使用同一矩阵的逆变换,避免两套公式产生误差。 */\nexport function screenToImage(viewport: ViewportState, point: Point): Point {\n return transformPoint(\n invertMatrix(\n createScaleTranslateMatrix(\n viewport.scale,\n viewport.offsetX,\n viewport.offsetY,\n ),\n ),\n point,\n )\n}\n\nexport function zoomAt(\n viewport: ViewportState,\n screenAnchor: Point,\n requestedScale: number,\n): ViewportState {\n // 先记录锚点对应的原图坐标,再反推新 offset,保证缩放前后锚点不跳动。\n const imageAnchor = screenToImage(viewport, screenAnchor)\n const scale = clampScale(viewport, requestedScale)\n return {\n ...viewport,\n scale,\n offsetX: screenAnchor.x - imageAnchor.x * scale,\n offsetY: screenAnchor.y - imageAnchor.y * scale,\n }\n}\n\nexport function panViewport(\n viewport: ViewportState,\n delta: Point,\n): ViewportState {\n return {\n ...viewport,\n offsetX: viewport.offsetX + delta.x,\n offsetY: viewport.offsetY + delta.y,\n }\n}\n\nexport function fitViewport(\n viewport: ViewportState,\n imageSize: Size,\n): ViewportState {\n assertPositiveSize(imageSize, 'Image')\n const scale = clampScale(\n viewport,\n Math.min(\n viewport.width / imageSize.width,\n viewport.height / imageSize.height,\n ),\n )\n // 使用同一个 scale 等比缩放,并把剩余空间平均分到两侧。\n return {\n ...viewport,\n scale,\n offsetX: (viewport.width - imageSize.width * scale) / 2,\n offsetY: (viewport.height - imageSize.height * scale) / 2,\n }\n}\n","import type { Bounds } from '../geometry/types.js'\n\nexport function encodeBinaryMaskRle(mask: ArrayLike<number>): readonly number[] {\n // RLE 固定从 0 段开始,之后按 0/1 交替记录连续长度。\n const runs: number[] = []\n let expected = 0\n let length = 0\n for (let index = 0; index < mask.length; index += 1) {\n const value = mask[index] ?? 0\n const bit = value > 0 ? 1 : 0\n if (bit === expected) {\n length += 1\n } else {\n runs.push(length)\n expected = bit\n length = 1\n }\n }\n runs.push(length)\n return Object.freeze(runs)\n}\n\nexport function decodeBinaryMaskRle(\n rle: readonly number[],\n width: number,\n height: number,\n): Uint8Array {\n const total = width * height\n const mask = new Uint8Array(total)\n let offset = 0\n let value = 0\n for (const run of rle) {\n const count = Math.max(0, Math.floor(run))\n if (value === 1) {\n mask.fill(1, offset, Math.min(total, offset + count))\n }\n offset += count\n value = value === 0 ? 1 : 0\n if (offset >= total) {\n break\n }\n }\n return mask\n}\n\n/** 判断两个二进制 Mask 是否至少共享一个前景像素。 */\nexport function masksIntersect(\n first: ArrayLike<number>,\n second: ArrayLike<number>,\n): boolean {\n const length = Math.min(first.length, second.length)\n for (let index = 0; index < length; index += 1) {\n if ((first[index] ?? 0) > 0 && (second[index] ?? 0) > 0) {\n return true\n }\n }\n return false\n}\n\nexport function mergeBinaryMasks(\n first: ArrayLike<number>,\n second: ArrayLike<number>,\n): Uint8Array {\n // OR 用于合并涂抹区域。\n const length = Math.max(first.length, second.length)\n const merged = new Uint8Array(length)\n for (let index = 0; index < length; index += 1) {\n merged[index] = (first[index] ?? 0) > 0 || (second[index] ?? 0) > 0\n ? 1\n : 0\n }\n return merged\n}\n\nexport function subtractBinaryMask(\n source: ArrayLike<number>,\n eraser: ArrayLike<number>,\n): Uint8Array {\n // source AND NOT eraser,只擦除 Mask,不影响其他几何类型。\n const length = source.length\n const result = new Uint8Array(length)\n for (let index = 0; index < length; index += 1) {\n result[index] = (source[index] ?? 0) > 0 && (eraser[index] ?? 0) === 0\n ? 1\n : 0\n }\n return result\n}\n\nexport function hasMaskPixels(mask: ArrayLike<number>): boolean {\n for (let index = 0; index < mask.length; index += 1) {\n if ((mask[index] ?? 0) > 0) {\n return true\n }\n }\n return false\n}\n\nexport function splitBinaryMaskComponents(\n mask: ArrayLike<number>,\n width: number,\n height: number,\n): Uint8Array[] {\n const normalizedWidth = Math.max(0, Math.floor(width))\n const normalizedHeight = Math.max(0, Math.floor(height))\n const length = normalizedWidth * normalizedHeight\n const visited = new Uint8Array(length)\n const queue = new Int32Array(length)\n const components: Uint8Array[] = []\n\n for (let start = 0; start < length; start += 1) {\n if (visited[start] === 1 || (mask[start] ?? 0) === 0) {\n continue\n }\n const component = new Uint8Array(length)\n // 使用预分配整型队列做 BFS,避免大区域中频繁创建临时数组。\n let head = 0\n let tail = 0\n queue[tail] = start\n tail += 1\n visited[start] = 1\n\n while (head < tail) {\n const index = queue[head]\n head += 1\n if (index === undefined) {\n continue\n }\n component[index] = 1\n const x = index % normalizedWidth\n const y = Math.floor(index / normalizedWidth)\n for (let offsetY = -1; offsetY <= 1; offsetY += 1) {\n for (let offsetX = -1; offsetX <= 1; offsetX += 1) {\n if (offsetX === 0 && offsetY === 0) {\n continue\n }\n // 采用 8 邻域,视觉上连续的斜线不会被错误拆开。\n const nextX = x + offsetX\n const nextY = y + offsetY\n if (\n nextX < 0 ||\n nextY < 0 ||\n nextX >= normalizedWidth ||\n nextY >= normalizedHeight\n ) {\n continue\n }\n const next = nextY * normalizedWidth + nextX\n if (visited[next] === 1 || (mask[next] ?? 0) === 0) {\n continue\n }\n visited[next] = 1\n queue[tail] = next\n tail += 1\n }\n }\n }\n components.push(component)\n }\n\n return components\n}\n\nexport function getBinaryMaskBounds(\n mask: ArrayLike<number>,\n width: number,\n height: number,\n): Bounds | null {\n // 扫描真实前景像素,而不是直接返回整张图片范围。\n let minX = Number.POSITIVE_INFINITY\n let minY = Number.POSITIVE_INFINITY\n let maxX = Number.NEGATIVE_INFINITY\n let maxY = Number.NEGATIVE_INFINITY\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n if ((mask[y * width + x] ?? 0) === 0) {\n continue\n }\n minX = Math.min(minX, x)\n minY = Math.min(minY, y)\n maxX = Math.max(maxX, x)\n maxY = Math.max(maxY, y)\n }\n }\n return Number.isFinite(minX)\n ? { x: minX, y: minY, width: maxX - minX + 1, height: maxY - minY + 1 }\n : null\n}\n\nexport function translateBinaryMask(\n mask: ArrayLike<number>,\n width: number,\n height: number,\n deltaX: number,\n deltaY: number,\n): Uint8Array {\n // Mask 像素只能落在整数网格,拖拽位移在提交时取整并裁剪到图像边界。\n const offsetX = Math.round(deltaX)\n const offsetY = Math.round(deltaY)\n const translated = new Uint8Array(width * height)\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n if ((mask[y * width + x] ?? 0) === 0) {\n continue\n }\n const nextX = x + offsetX\n const nextY = y + offsetY\n if (nextX >= 0 && nextY >= 0 && nextX < width && nextY < height) {\n translated[nextY * width + nextX] = 1\n }\n }\n }\n return translated\n}\n\nexport function binaryMasksWithinDistance(\n first: ArrayLike<number>,\n second: ArrayLike<number>,\n width: number,\n height: number,\n distance: number,\n): boolean {\n // 在第一个 Mask 的每个前景像素周围搜索,用于拖拽后的近距离吸附合并。\n const radius = Math.max(0, Math.ceil(distance))\n const distanceSquared = distance * distance\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n if ((first[y * width + x] ?? 0) === 0) {\n continue\n }\n for (let offsetY = -radius; offsetY <= radius; offsetY += 1) {\n for (let offsetX = -radius; offsetX <= radius; offsetX += 1) {\n if (offsetX * offsetX + offsetY * offsetY > distanceSquared) {\n continue\n }\n const nextX = x + offsetX\n const nextY = y + offsetY\n if (\n nextX >= 0 &&\n nextY >= 0 &&\n nextX < width &&\n nextY < height &&\n (second[nextY * width + nextX] ?? 0) > 0\n ) {\n return true\n }\n }\n }\n }\n }\n return false\n}\n","import type { RenderLayer } from './scheduler.js'\n\nexport type CanvasLayerName = RenderLayer | 'event'\n\nexport interface CanvasLayerSet {\n readonly canvases: Readonly<Record<CanvasLayerName, HTMLCanvasElement>>\n readonly resize: () => CanvasLayerSize\n readonly destroy: () => void\n}\n\nexport interface CanvasLayerSize {\n readonly width: number\n readonly height: number\n readonly dpr: number\n}\n\nconst layerNames: readonly CanvasLayerName[] = [\n // 从下到上:底图、持久标注、临时交互、透明事件层。\n 'image',\n 'annotations',\n 'interaction',\n 'event',\n]\n\nexport function createCanvasLayers(container: HTMLElement): CanvasLayerSet {\n const originalPosition = container.style.position\n const originalOverflow = container.style.overflow\n if (getComputedStyle(container).position === 'static') {\n container.style.position = 'relative'\n }\n container.style.overflow = 'hidden'\n\n const entries = layerNames.map((name, index) => {\n const canvas = document.createElement('canvas')\n canvas.dataset.layer = name\n canvas.style.position = 'absolute'\n canvas.style.inset = '0'\n canvas.style.width = '100%'\n canvas.style.height = '100%'\n canvas.style.zIndex = String(index)\n // 只有最上层接收事件,其他 Canvas 永远不会拦截鼠标。\n canvas.style.pointerEvents = name === 'event' ? 'auto' : 'none'\n container.append(canvas)\n return [name, canvas] as const\n })\n const canvases = Object.fromEntries(entries) as Record<\n CanvasLayerName,\n HTMLCanvasElement\n >\n\n return {\n canvases,\n resize() {\n const bounds = container.getBoundingClientRect()\n const width = Math.max(1, Math.round(bounds.width))\n const height = Math.max(1, Math.round(bounds.height))\n const dpr = Math.max(1, window.devicePixelRatio || 1)\n // CSS 尺寸保持不变,backing store 乘 DPR,避免高分屏绘制发虚。\n for (const canvas of Object.values(canvases)) {\n canvas.width = Math.round(width * dpr)\n canvas.height = Math.round(height * dpr)\n }\n return { width, height, dpr }\n },\n destroy() {\n for (const canvas of Object.values(canvases)) {\n canvas.remove()\n }\n container.style.position = originalPosition\n container.style.overflow = originalOverflow\n },\n }\n}\n","export type RenderLayer =\n | 'annotations'\n | 'image'\n | 'interaction'\n\nexport interface RenderSchedulerOptions {\n readonly requestFrame: (callback: FrameRequestCallback) => number\n readonly cancelFrame: (handle: number) => void\n readonly render: (layers: ReadonlySet<RenderLayer>) => void\n}\n\nexport interface RenderScheduler {\n readonly invalidate: (layer: RenderLayer) => void\n readonly destroy: () => void\n}\n\nexport function createRenderScheduler(\n options: RenderSchedulerOptions,\n): RenderScheduler {\n const dirtyLayers = new Set<RenderLayer>()\n let frame: number | null = null\n let destroyed = false\n\n const flush = () => {\n frame = null\n if (destroyed || dirtyLayers.size === 0) {\n return\n }\n // 拷贝后立即清空,绘制期间新增的失效请求会进入下一帧。\n const layers = new Set(dirtyLayers)\n dirtyLayers.clear()\n options.render(layers)\n }\n\n return {\n invalidate(layer) {\n if (destroyed) {\n return\n }\n dirtyLayers.add(layer)\n // 同一帧内多次 invalidate 只安排一次 requestAnimationFrame。\n if (frame === null) {\n frame = options.requestFrame(flush)\n }\n },\n destroy() {\n if (destroyed) {\n return\n }\n destroyed = true\n dirtyLayers.clear()\n if (frame !== null) {\n options.cancelFrame(frame)\n frame = null\n }\n },\n }\n}\n","import { getInternalState } from '../core/annotator.js'\nimport { subscribe } from '../core/events.js'\nimport type {\n Annotator,\n MaskAnnotation,\n PolygonAnnotation,\n RectAnnotation,\n} from '../core/types.js'\nimport { screenToImage } from '../viewport/viewport.js'\nimport { queryAnnotations } from '../core/commands.js'\nimport {\n decodeBinaryMaskRle,\n getBinaryMaskBounds,\n} from '../mask/rle.js'\nimport { createCanvasLayers } from './canvas-layers.js'\nimport { createRenderScheduler, type RenderLayer } from './scheduler.js'\nimport type { EraserInteractionDraft } from '../tools/types.js'\n\nexport interface CanvasRenderer {\n readonly eventCanvas: HTMLCanvasElement\n readonly invalidate: (layer: RenderLayer) => void\n readonly resize: () => void\n readonly destroy: () => void\n}\n\nfunction resetAndClear(\n context: CanvasRenderingContext2D,\n canvas: HTMLCanvasElement,\n): void {\n // clearRect 会受当前 transform 影响,清空前必须恢复单位矩阵。\n context.setTransform(1, 0, 0, 1, 0, 0)\n context.clearRect(0, 0, canvas.width, canvas.height)\n}\n\nfunction renderMaskAnnotation(\n context: CanvasRenderingContext2D,\n annotation: MaskAnnotation,\n color: string,\n eraserDraft?: EraserInteractionDraft,\n): void {\n // Mask 先在原图尺寸的离屏 Canvas 上生成,再复用主 Canvas 的 viewport 变换绘制。\n const maskCanvas = document.createElement('canvas')\n maskCanvas.width = annotation.geometry.width\n maskCanvas.height = annotation.geometry.height\n const maskContext = maskCanvas.getContext('2d')\n if (maskContext === null) {\n return\n }\n const imageData = maskContext.createImageData(\n annotation.geometry.width,\n annotation.geometry.height,\n )\n const mask = decodeBinaryMaskRle(\n annotation.geometry.rle,\n annotation.geometry.width,\n annotation.geometry.height,\n )\n const colorMatch = /^#?([0-9a-f]{6})$/i.exec(color)\n const hex = colorMatch?.[1] ?? '2c9c21'\n const red = Number.parseInt(hex.slice(0, 2), 16)\n const green = Number.parseInt(hex.slice(2, 4), 16)\n const blue = Number.parseInt(hex.slice(4, 6), 16)\n for (let index = 0; index < mask.length; index += 1) {\n if (mask[index] !== 1) {\n continue\n }\n const offset = index * 4\n imageData.data[offset] = red\n imageData.data[offset + 1] = green\n imageData.data[offset + 2] = blue\n imageData.data[offset + 3] = 96\n }\n maskContext.putImageData(imageData, 0, 0)\n const firstEraserPoint = eraserDraft?.points[0]\n if (eraserDraft !== undefined && firstEraserPoint !== undefined) {\n // 实时预览只改离屏画面;真正的 Mask 数据在 pointerup 时一次性提交。\n maskContext.globalCompositeOperation = 'destination-out'\n maskContext.beginPath()\n maskContext.moveTo(firstEraserPoint.x, firstEraserPoint.y)\n for (const point of eraserDraft.points.slice(1)) {\n maskContext.lineTo(point.x, point.y)\n }\n if (eraserDraft.points.length === 1) {\n maskContext.lineTo(firstEraserPoint.x, firstEraserPoint.y)\n }\n maskContext.lineWidth = eraserDraft.size\n maskContext.lineCap = 'round'\n maskContext.lineJoin = 'round'\n maskContext.stroke()\n maskContext.globalCompositeOperation = 'source-over'\n }\n context.drawImage(maskCanvas, 0, 0)\n}\n\nexport function createCanvasRenderer(annotator: Annotator): CanvasRenderer {\n const state = getInternalState(annotator)\n const layers = createCanvasLayers(state.container)\n let layerSize = layers.resize()\n\n const renderImage = () => {\n const canvas = layers.canvases.image\n const context = canvas.getContext('2d')\n if (context === null) {\n return\n }\n resetAndClear(context, canvas)\n if (state.image === null || state.viewport === null) {\n return\n }\n const { scale, offsetX, offsetY } = state.viewport\n // 缩小时使用高质量插值;放大时保留原始像素边界。\n context.imageSmoothingEnabled = scale < 1\n context.imageSmoothingQuality = 'high'\n context.setTransform(\n layerSize.dpr * scale,\n 0,\n 0,\n layerSize.dpr * scale,\n layerSize.dpr * offsetX,\n layerSize.dpr * offsetY,\n )\n context.drawImage(state.image.source, 0, 0)\n }\n\n const renderAnnotations = () => {\n const canvas = layers.canvases.annotations\n const context = canvas.getContext('2d')\n if (context === null) {\n return\n }\n resetAndClear(context, canvas)\n if (state.viewport === null) {\n return\n }\n const topLeft = screenToImage(state.viewport, { x: 0, y: 0 })\n const bottomRight = screenToImage(state.viewport, {\n x: layerSize.width,\n y: layerSize.height,\n })\n // 只查询当前 viewport 内可能可见的标注。\n const annotations = queryAnnotations(annotator, {\n x: Math.min(topLeft.x, bottomRight.x),\n y: Math.min(topLeft.y, bottomRight.y),\n width: Math.abs(bottomRight.x - topLeft.x),\n height: Math.abs(bottomRight.y - topLeft.y),\n })\n const { scale, offsetX, offsetY } = state.viewport\n context.imageSmoothingEnabled = false\n context.setTransform(\n layerSize.dpr * scale,\n 0,\n 0,\n layerSize.dpr * scale,\n layerSize.dpr * offsetX,\n layerSize.dpr * offsetY,\n )\n context.lineWidth = 2 / scale\n\n for (const annotation of annotations) {\n if (\n state.interactionDraft?.type === 'vector' &&\n state.interactionDraft.annotationId === annotation.id &&\n state.interactionDraft.geometry.type === 'mask'\n ) {\n // Mask 拖拽时由 interaction 层绘制新位置,持久层暂时隐藏旧位置。\n continue\n }\n const label = state.labels.find(item => item.id === annotation.labelId)\n context.strokeStyle = label?.color ?? '#2c9c21'\n context.fillStyle = label?.color ?? '#2c9c21'\n context.globalAlpha = 1\n\n let labelX = 0\n let labelY = 0\n\n if (annotation.geometry.type === 'rect') {\n const rect = annotation as RectAnnotation\n labelX = rect.geometry.x\n labelY = rect.geometry.y\n context.globalAlpha = 0.16\n context.fillRect(\n rect.geometry.x,\n rect.geometry.y,\n rect.geometry.width,\n rect.geometry.height,\n )\n context.globalAlpha = 1\n context.strokeRect(\n rect.geometry.x,\n rect.geometry.y,\n rect.geometry.width,\n rect.geometry.height,\n )\n } else if (annotation.geometry.type === 'polygon') {\n const polygon = annotation as PolygonAnnotation\n const first = polygon.geometry.points[0]\n if (first === undefined) {\n continue\n }\n labelX = first[0]\n labelY = first[1]\n context.beginPath()\n context.moveTo(first[0], first[1])\n for (const [x, y] of polygon.geometry.points.slice(1)) {\n context.lineTo(x, y)\n }\n context.closePath()\n context.globalAlpha = 0.16\n context.fill()\n context.globalAlpha = 1\n context.stroke()\n } else if (annotation.geometry.type === 'mask') {\n const mask = annotation as MaskAnnotation\n const maskPixels = decodeBinaryMaskRle(\n mask.geometry.rle,\n mask.geometry.width,\n mask.geometry.height,\n )\n // 标签和选框使用真实像素边界,不能固定放在整图左上角。\n const maskBounds = getBinaryMaskBounds(\n maskPixels,\n mask.geometry.width,\n mask.geometry.height,\n )\n labelX = maskBounds?.x ?? 0\n labelY = maskBounds?.y ?? 0\n const eraserDraft = state.interactionDraft?.type === 'eraser'\n ? state.interactionDraft\n : undefined\n renderMaskAnnotation(\n context,\n mask,\n label?.color ?? '#2c9c21',\n eraserDraft,\n )\n }\n\n if (label?.name) {\n context.font = `${14 / scale}px sans-serif`\n context.fillStyle = '#ffffff'\n context.strokeStyle = label.color\n context.lineWidth = 3 / scale\n context.lineJoin = 'round'\n context.globalAlpha = 1\n\n const textWidth = context.measureText(label.name).width\n const textHeight = 14 / scale\n const padding = 4 / scale\n\n context.strokeRect(\n labelX - padding,\n labelY - textHeight - padding,\n textWidth + padding * 2,\n textHeight + padding * 2,\n )\n context.fillRect(\n labelX - padding,\n labelY - textHeight - padding,\n textWidth + padding * 2,\n textHeight + padding * 2,\n )\n context.fillStyle = label.color\n context.fillText(label.name, labelX, labelY - padding)\n }\n }\n }\n\n const scheduler = createRenderScheduler({\n requestFrame: callback => requestAnimationFrame(callback),\n cancelFrame: handle => cancelAnimationFrame(handle),\n render(dirtyLayers) {\n // 每层只在被标记为 dirty 时重绘。\n if (dirtyLayers.has('image')) {\n renderImage()\n }\n if (dirtyLayers.has('annotations')) {\n renderAnnotations()\n }\n if (dirtyLayers.has('interaction')) {\n const canvas = layers.canvases.interaction\n const context = canvas.getContext('2d')\n if (context !== null) {\n resetAndClear(context, canvas)\n const draft = state.interactionDraft\n if (draft !== null && state.viewport !== null) {\n const label = 'labelId' in draft\n ? state.labels.find(item => item.id === draft.labelId)\n : undefined\n const { scale, offsetX, offsetY } = state.viewport\n context.imageSmoothingEnabled = false\n context.setTransform(\n layerSize.dpr * scale,\n 0,\n 0,\n layerSize.dpr * scale,\n layerSize.dpr * offsetX,\n layerSize.dpr * offsetY,\n )\n context.strokeStyle = label?.color ?? '#2c9c21'\n context.lineWidth = 2 / scale\n context.setLineDash([6 / scale, 4 / scale])\n if (draft.type === 'vector' && draft.geometry.type === 'mask') {\n const source = state.annotationsById.get(draft.annotationId)\n if (source?.geometry.type === 'mask') {\n renderMaskAnnotation(\n context,\n { ...source, geometry: draft.geometry },\n label?.color ?? '#2c9c21',\n )\n }\n } else if (draft.type === 'brush') {\n // 画笔预览使用工具配置色;提交后的 Mask 使用标签色。\n context.strokeStyle = draft.color\n const first = draft.points[0]\n if (first !== undefined) {\n context.beginPath()\n context.moveTo(first.x, first.y)\n for (const point of draft.points.slice(1)) {\n context.lineTo(point.x, point.y)\n }\n if (draft.points.length === 1) {\n context.lineTo(first.x, first.y)\n }\n context.globalAlpha = 0.7\n context.lineWidth = draft.size\n context.lineCap = 'round'\n context.lineJoin = 'round'\n context.setLineDash([])\n context.stroke()\n }\n } else if (draft.type === 'rect') {\n context.strokeRect(\n draft.geometry.x,\n draft.geometry.y,\n draft.geometry.width,\n draft.geometry.height,\n )\n } else if (draft.type !== 'eraser') {\n const points = draft.type === 'polygon'\n ? draft.points.map(point => [point.x, point.y] as const)\n : draft.geometry.type === 'polygon'\n ? draft.geometry.points\n : []\n if (draft.type === 'vector' && draft.geometry.type === 'rect') {\n context.strokeRect(\n draft.geometry.x,\n draft.geometry.y,\n draft.geometry.width,\n draft.geometry.height,\n )\n } else if (points[0] !== undefined) {\n context.beginPath()\n context.moveTo(points[0][0], points[0][1])\n for (const point of points.slice(1)) {\n context.lineTo(point[0], point[1])\n }\n if (draft.type === 'vector') {\n context.closePath()\n }\n context.stroke()\n }\n }\n }\n if (state.viewport !== null) {\n // 选框和控制点也属于 interaction 层,尺寸始终按屏幕像素保持稳定。\n const { scale, offsetX, offsetY } = state.viewport\n context.setTransform(\n layerSize.dpr * scale,\n 0,\n 0,\n layerSize.dpr * scale,\n layerSize.dpr * offsetX,\n layerSize.dpr * offsetY,\n )\n const size = 8 / scale\n context.setLineDash([])\n for (const id of state.selectedIds) {\n const annotation = state.annotationsById.get(id)\n if (annotation === undefined) {\n continue\n }\n const geometry = state.interactionDraft?.type === 'vector' &&\n state.interactionDraft.annotationId === id\n ? state.interactionDraft.geometry\n : annotation.geometry\n const points = geometry.type === 'rect'\n ? [\n [geometry.x, geometry.y],\n [geometry.x + geometry.width / 2, geometry.y],\n [geometry.x + geometry.width, geometry.y],\n [geometry.x + geometry.width, geometry.y + geometry.height / 2],\n [geometry.x + geometry.width, geometry.y + geometry.height],\n [geometry.x + geometry.width / 2, geometry.y + geometry.height],\n [geometry.x, geometry.y + geometry.height],\n [geometry.x, geometry.y + geometry.height / 2],\n ] as const\n : geometry.type === 'polygon'\n ? geometry.points\n : []\n context.fillStyle = '#ffffff'\n context.strokeStyle = '#1677ff'\n context.globalAlpha = 1\n if (geometry.type === 'mask') {\n const maskBounds = getBinaryMaskBounds(\n decodeBinaryMaskRle(\n geometry.rle,\n geometry.width,\n geometry.height,\n ),\n geometry.width,\n geometry.height,\n )\n if (maskBounds !== null) {\n context.setLineDash([5 / scale, 3 / scale])\n context.lineWidth = 2 / scale\n context.strokeRect(\n maskBounds.x,\n maskBounds.y,\n maskBounds.width,\n maskBounds.height,\n )\n context.setLineDash([])\n }\n }\n for (const [x, y] of points) {\n context.fillRect(x - size / 2, y - size / 2, size, size)\n context.strokeRect(x - size / 2, y - size / 2, size, size)\n }\n }\n }\n }\n }\n },\n })\n const unsubscribe = subscribe(annotator, 'change', event => {\n if (event.kind !== 'label:activate') {\n // 标注变化后同时刷新控制点,避免数据已更新但选框仍停在旧位置。\n scheduler.invalidate('annotations')\n scheduler.invalidate('interaction')\n }\n })\n let destroyed = false\n\n return {\n eventCanvas: layers.canvases.event,\n invalidate: layer => scheduler.invalidate(layer),\n resize() {\n if (destroyed) {\n return\n }\n layerSize = layers.resize()\n scheduler.invalidate('image')\n scheduler.invalidate('annotations')\n scheduler.invalidate('interaction')\n },\n destroy() {\n if (destroyed) {\n return\n }\n destroyed = true\n unsubscribe()\n scheduler.destroy()\n layers.destroy()\n },\n }\n}\n","import { getInternalState } from '../core/annotator.js'\nimport { emitChange } from '../core/events.js'\nimport type { Annotator } from '../core/types.js'\nimport type { Point, Size } from '../geometry/types.js'\nimport { createCanvasRenderer } from '../render/canvas-renderer.js'\nimport {\n createViewport,\n fitViewport,\n imageToScreen,\n panViewport,\n screenToImage,\n zoomAt,\n} from '../viewport/viewport.js'\nimport type { ImageSource } from './types.js'\n\nfunction getContainerSize(container: HTMLElement): Size {\n const bounds = container.getBoundingClientRect()\n return {\n width: Math.max(1, Math.round(bounds.width)),\n height: Math.max(1, Math.round(bounds.height)),\n }\n}\n\nfunction requireViewport(annotator: Annotator) {\n const state = getInternalState(annotator)\n if (state.viewport === null) {\n throw new Error('An image must be loaded before using viewport commands.')\n }\n return { state, viewport: state.viewport }\n}\n\nexport async function setImageSource(\n annotator: Annotator,\n source: ImageSource,\n): Promise<void> {\n const state = getInternalState(annotator)\n const hadImage = state.image !== null\n // 切图前终止上一次异步加载,并清理所有依赖旧图片坐标系的交互状态。\n state.imageAbortController?.abort()\n state.imageAbortController = null\n state.image = null\n state.viewport = null\n state.toolController?.cancel()\n state.interactionDraft = null\n state.renderer?.invalidate('image')\n state.renderer?.invalidate('annotations')\n state.renderer?.invalidate('interaction')\n state.renderer?.invalidate('interaction')\n state.imageSource?.dispose()\n state.imageSource = null\n if (hadImage) {\n emitChange(annotator, 'image:clear')\n }\n\n const controller = new AbortController()\n state.imageAbortController = controller\n state.imageSource = source\n const image = await source.load(controller.signal)\n const currentState = getInternalState(annotator)\n // 加载期间可能再次切图。只有当前 source 仍然有效时,才允许写回结果。\n if (currentState.imageSource !== source || controller.signal.aborted) {\n return\n }\n\n currentState.image = image\n const containerSize = getContainerSize(currentState.container)\n currentState.viewport = fitViewport(\n createViewport(containerSize),\n { width: image.width, height: image.height },\n )\n currentState.renderer ??= createCanvasRenderer(annotator)\n currentState.renderer.resize()\n currentState.renderer.invalidate('image')\n currentState.renderer.invalidate('annotations')\n emitChange(annotator, 'image:load')\n}\n\nexport function hasImage(annotator: Annotator): boolean {\n return getInternalState(annotator).image !== null\n}\n\nexport function getZoom(annotator: Annotator): number {\n return requireViewport(annotator).viewport.scale\n}\n\nexport function resizeViewport(annotator: Annotator): void {\n const { state, viewport } = requireViewport(annotator)\n const size = getContainerSize(state.container)\n state.viewport = { ...viewport, ...size }\n state.renderer?.resize()\n}\n\nexport function fitToScreen(annotator: Annotator): void {\n const { state, viewport } = requireViewport(annotator)\n if (state.image === null) {\n return\n }\n state.viewport = fitViewport(viewport, state.image)\n state.renderer?.invalidate('image')\n state.renderer?.invalidate('annotations')\n state.renderer?.invalidate('interaction')\n}\n\nexport function zoomTo(\n annotator: Annotator,\n scale: number,\n anchor?: Point,\n): void {\n const { state, viewport } = requireViewport(annotator)\n state.viewport = zoomAt(\n viewport,\n anchor ?? { x: viewport.width / 2, y: viewport.height / 2 },\n scale,\n )\n state.renderer?.invalidate('image')\n state.renderer?.invalidate('annotations')\n state.renderer?.invalidate('interaction')\n}\n\nexport function zoomBy(\n annotator: Annotator,\n factor: number,\n anchor?: Point,\n): void {\n const { viewport } = requireViewport(annotator)\n zoomTo(annotator, viewport.scale * factor, anchor)\n}\n\nexport function panBy(annotator: Annotator, delta: Point): void {\n const { state, viewport } = requireViewport(annotator)\n state.viewport = panViewport(viewport, delta)\n state.renderer?.invalidate('image')\n state.renderer?.invalidate('annotations')\n state.renderer?.invalidate('interaction')\n}\n\nexport function imageToClient(annotator: Annotator, point: Point): Point {\n // viewport 负责图片坐标到容器坐标,容器偏移再把结果转换为页面客户区坐标。\n const { state, viewport } = requireViewport(annotator)\n const screenPoint = imageToScreen(viewport, point)\n const bounds = state.container.getBoundingClientRect()\n return { x: screenPoint.x + bounds.left, y: screenPoint.y + bounds.top }\n}\n\nexport function clientToImage(annotator: Annotator, point: Point): Point {\n // 所有绘制和编辑统一回到原图坐标,缩放和平移只影响显示,不污染标注数据。\n const { state, viewport } = requireViewport(annotator)\n const bounds = state.container.getBoundingClientRect()\n return screenToImage(viewport, {\n x: point.x - bounds.left,\n y: point.y - bounds.top,\n })\n}\n","import { getInternalState } from '../core/annotator.js'\nimport type { Annotator } from '../core/types.js'\nimport {\n clientToImage,\n panBy,\n zoomBy,\n} from '../image/image-commands.js'\nimport type {\n InteractionDraft,\n NormalizedPointerInput,\n Tool,\n ToolCategory,\n ToolContext,\n ToolController,\n ToolRegistry,\n} from './types.js'\n\nfunction createToolContext(annotator: Annotator): ToolContext {\n return {\n annotator,\n setDraft(draft: InteractionDraft) {\n const state = getInternalState(annotator)\n state.interactionDraft = draft\n if (draft.type === 'eraser') {\n // 橡皮擦预览会改变持久 Mask 的显示结果,因此 annotation 层也要重绘。\n state.renderer?.invalidate('annotations')\n }\n state.renderer?.invalidate('interaction')\n },\n clearDraft() {\n const state = getInternalState(annotator)\n const redrawAnnotations = state.interactionDraft?.type === 'eraser'\n state.interactionDraft = null\n if (redrawAnnotations) {\n state.renderer?.invalidate('annotations')\n }\n state.renderer?.invalidate('interaction')\n },\n }\n}\n\nfunction normalizePointer(\n annotator: Annotator,\n event: PointerEvent,\n type: 'down' | 'move' | 'up',\n): NormalizedPointerInput {\n const state = getInternalState(annotator)\n // 工具只接收原图坐标,不感知 DOM 位置、缩放比例和 DPR。\n const point = clientToImage(annotator, {\n x: event.clientX,\n y: event.clientY,\n })\n const imagePoint = state.image === null\n ? point\n : {\n // 指针捕获后鼠标可能移出画布,提交点需要裁剪到原图范围。\n x: Math.min(state.image.width, Math.max(0, point.x)),\n y: Math.min(state.image.height, Math.max(0, point.y)),\n }\n return {\n type,\n pointerId: event.pointerId,\n imagePoint,\n buttons: event.buttons,\n pressure: event.pressure,\n detail: event.detail,\n }\n}\n\nexport function createToolController(\n annotator: Annotator,\n canvas: HTMLCanvasElement,\n registry: ToolRegistry,\n): ToolController {\n const context = createToolContext(annotator)\n let activeTool: Tool | null = null\n let destroyed = false\n let activeCursor = 'default'\n let spacePressed = false\n let pointerInside = false\n let panPointerId: number | null = null\n let lastPanPoint = { x: 0, y: 0 }\n\n canvas.tabIndex = 0\n\n const down = (event: PointerEvent) => {\n const startsPan = event.button === 1 || (\n event.button === 0 && (event.altKey || spacePressed)\n )\n if (startsPan) {\n // 平移是临时导航手势,不应继续当前绘制或编辑状态。\n event.preventDefault()\n activeTool?.cancel(context)\n panPointerId = event.pointerId\n lastPanPoint = { x: event.clientX, y: event.clientY }\n canvas.setPointerCapture(event.pointerId)\n canvas.style.cursor = 'grabbing'\n return\n }\n if (activeTool === null || event.button !== 0) {\n return\n }\n canvas.focus({ preventScroll: true })\n // 捕获指针后,即使鼠标移出 Canvas 也能收到 move/up。\n canvas.setPointerCapture(event.pointerId)\n activeTool.handle(normalizePointer(annotator, event, 'down'), context)\n }\n const move = (event: PointerEvent) => {\n if (panPointerId === event.pointerId) {\n const next = { x: event.clientX, y: event.clientY }\n panBy(annotator, {\n x: next.x - lastPanPoint.x,\n y: next.y - lastPanPoint.y,\n })\n lastPanPoint = next\n return\n }\n activeTool?.handle(normalizePointer(annotator, event, 'move'), context)\n }\n const up = (event: PointerEvent) => {\n if (panPointerId === event.pointerId) {\n panPointerId = null\n canvas.style.cursor = spacePressed ? 'grab' : activeCursor\n if (canvas.hasPointerCapture(event.pointerId)) {\n canvas.releasePointerCapture(event.pointerId)\n }\n return\n }\n activeTool?.handle(normalizePointer(annotator, event, 'up'), context)\n if (canvas.hasPointerCapture(event.pointerId)) {\n canvas.releasePointerCapture(event.pointerId)\n }\n }\n const cancelPointer = () => {\n panPointerId = null\n canvas.style.cursor = spacePressed ? 'grab' : activeCursor\n activeTool?.handle({ type: 'cancel' }, context)\n }\n const keydown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n activeTool?.cancel(context)\n return\n }\n activeTool?.handleKey?.(event, context)\n }\n const windowKeydown = (event: KeyboardEvent) => {\n if (\n event.code !== 'Space' ||\n event.repeat ||\n (!pointerInside && document.activeElement !== canvas)\n ) {\n return\n }\n event.preventDefault()\n spacePressed = true\n // 空格只临时切换为平移,松开后恢复原工具和光标。\n activeTool?.cancel(context)\n canvas.style.cursor = panPointerId === null ? 'grab' : 'grabbing'\n }\n const windowKeyup = (event: KeyboardEvent) => {\n if (event.code !== 'Space' || !spacePressed) {\n return\n }\n event.preventDefault()\n spacePressed = false\n if (panPointerId === null) {\n canvas.style.cursor = activeCursor\n }\n }\n const wheel = (event: WheelEvent) => {\n event.preventDefault()\n const bounds = canvas.getBoundingClientRect()\n const unit = event.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16 :\n event.deltaMode === WheelEvent.DOM_DELTA_PAGE ? bounds.height : 1\n // 指数缩放让不同滚轮增量保持连续手感,并以鼠标位置作为缩放锚点。\n const factor = Math.exp(-event.deltaY * unit * 0.0015)\n zoomBy(annotator, factor, {\n x: event.clientX - bounds.left,\n y: event.clientY - bounds.top,\n })\n }\n const pointerenter = () => {\n pointerInside = true\n }\n const pointerleave = () => {\n pointerInside = false\n }\n\n canvas.addEventListener('pointerdown', down)\n canvas.addEventListener('pointermove', move)\n canvas.addEventListener('pointerup', up)\n canvas.addEventListener('pointercancel', cancelPointer)\n canvas.addEventListener('pointerenter', pointerenter)\n canvas.addEventListener('pointerleave', pointerleave)\n canvas.addEventListener('wheel', wheel, { passive: false })\n canvas.addEventListener('keydown', keydown)\n window.addEventListener('keydown', windowKeydown)\n window.addEventListener('keyup', windowKeyup)\n\n return {\n activate(tool) {\n if (destroyed) {\n return\n }\n activeTool?.cancel(context)\n activeTool = tool\n activeCursor = tool.cursor\n canvas.style.cursor = spacePressed ? 'grab' : activeCursor\n getInternalState(annotator).activeToolId = tool.id\n },\n activateById(toolId) {\n const tool = registry.get(toolId)\n if (tool !== undefined) {\n this.activate(tool)\n }\n },\n cancel() {\n activeTool?.cancel(context)\n },\n destroy() {\n if (destroyed) {\n return\n }\n destroyed = true\n activeTool?.cancel(context)\n activeTool = null\n canvas.removeEventListener('pointerdown', down)\n canvas.removeEventListener('pointermove', move)\n canvas.removeEventListener('pointerup', up)\n canvas.removeEventListener('pointercancel', cancelPointer)\n canvas.removeEventListener('pointerenter', pointerenter)\n canvas.removeEventListener('pointerleave', pointerleave)\n canvas.removeEventListener('wheel', wheel)\n canvas.removeEventListener('keydown', keydown)\n window.removeEventListener('keydown', windowKeydown)\n window.removeEventListener('keyup', windowKeyup)\n },\n }\n}\n\nfunction requireController(annotator: Annotator): ToolController {\n const state = getInternalState(annotator)\n if (state.renderer === null) {\n throw new Error('An image must be loaded before activating a drawing tool.')\n }\n // 控制器延迟创建:图片加载前不挂载依赖 Canvas 的交互监听。\n state.toolController ??= createToolController(\n annotator,\n state.renderer.eventCanvas,\n getInternalState(annotator).toolRegistry!,\n )\n return state.toolController\n}\n\nexport function activateTool(annotator: Annotator, tool: Tool): void {\n requireController(annotator).activate(tool)\n}\n\nexport function activateToolById(annotator: Annotator, toolId: string): void {\n requireController(annotator).activateById(toolId)\n}\n\nexport function cancelActiveGesture(annotator: Annotator): void {\n getInternalState(annotator).toolController?.cancel()\n}\n\nexport function getRegisteredTools(annotator: Annotator): readonly Tool[] {\n return getInternalState(annotator).toolRegistry.list()\n}\n\nexport function getRegisteredToolsByCategory(\n annotator: Annotator,\n category: ToolCategory,\n): readonly Tool[] {\n return getInternalState(annotator).toolRegistry.listByCategory(category)\n}\n","import type { Point } from '../geometry/types.js'\nimport type { Annotator } from '../core/types.js'\nimport { getActiveLabel } from '../labels/labels.js'\nimport { AnnotatorError, type MaskGeometry } from '../core/types.js'\nimport { activateTool } from './controller.js'\nimport { getInternalState } from '../core/annotator.js'\nimport {\n addMask,\n queryAnnotations,\n removeAnnotation,\n updateAnnotation,\n} from '../core/commands.js'\nimport {\n decodeBinaryMaskRle,\n encodeBinaryMaskRle,\n mergeBinaryMasks,\n masksIntersect,\n} from '../mask/rle.js'\nimport type {\n NormalizedPointerInput,\n Tool,\n ToolContext,\n} from './types.js'\n\nexport interface BrushToolOptions {\n readonly labelId?: string\n readonly size?: number\n readonly color?: string\n}\n\nexport interface BrushToolState {\n readonly pointerId: number | null\n readonly points: readonly Point[]\n}\n\nexport interface BrushMaskInput {\n readonly imageWidth: number\n readonly imageHeight: number\n readonly brushSize: number\n readonly points: readonly Point[]\n}\n\nfunction resolveLabelId(\n annotator: Annotator,\n configuredLabelId: string | undefined,\n): string {\n const labelId = configuredLabelId ?? getActiveLabel(annotator)\n if (labelId === null) {\n throw new AnnotatorError(\n 'UNKNOWN_LABEL',\n 'A label must be active before using the brush tool.',\n )\n }\n return labelId\n}\n\nfunction paintCircle(\n mask: Uint8Array,\n width: number,\n height: number,\n point: Point,\n radius: number,\n): void {\n // 每个采样点绘制一个实心圆,圆形叠加后形成连续笔迹。\n const minX = Math.max(0, Math.floor(point.x - radius))\n const maxX = Math.min(width - 1, Math.ceil(point.x + radius))\n const minY = Math.max(0, Math.floor(point.y - radius))\n const maxY = Math.min(height - 1, Math.ceil(point.y + radius))\n const radiusSquared = radius * radius\n for (let y = minY; y <= maxY; y += 1) {\n for (let x = minX; x <= maxX; x += 1) {\n const dx = x + 0.5 - point.x\n const dy = y + 0.5 - point.y\n if (dx * dx + dy * dy <= radiusSquared) {\n mask[y * width + x] = 1\n }\n }\n }\n}\n\nfunction interpolateStroke(points: readonly Point[], step: number): Point[] {\n // PointerEvent 采样可能稀疏,按距离补点避免快速拖动时出现断线。\n const sampled: Point[] = []\n for (let index = 0; index < points.length; index += 1) {\n const current = points[index]\n const previous = points[index - 1]\n if (current === undefined) {\n continue\n }\n if (previous === undefined) {\n sampled.push(current)\n continue\n }\n const dx = current.x - previous.x\n const dy = current.y - previous.y\n const distance = Math.hypot(dx, dy)\n const segments = Math.max(1, Math.ceil(distance / step))\n for (let segment = 1; segment <= segments; segment += 1) {\n sampled.push({\n x: previous.x + (dx * segment) / segments,\n y: previous.y + (dy * segment) / segments,\n })\n }\n }\n return sampled\n}\n\nexport function createBrushMaskGeometry(input: BrushMaskInput): MaskGeometry {\n const width = Math.max(1, Math.round(input.imageWidth))\n const height = Math.max(1, Math.round(input.imageHeight))\n const brushSize = Math.max(1, input.brushSize)\n const radius = brushSize / 2\n const mask = new Uint8Array(width * height)\n for (const point of interpolateStroke(input.points, Math.max(1, radius / 2))) {\n paintCircle(mask, width, height, point, radius)\n }\n return {\n type: 'mask',\n width,\n height,\n rle: encodeBinaryMaskRle(mask),\n }\n}\n\nfunction mergeBrushMask(\n annotator: Annotator,\n labelId: string,\n geometry: MaskGeometry,\n): void {\n const brushMask = decodeBinaryMaskRle(\n geometry.rle,\n geometry.width,\n geometry.height,\n )\n const intersectingMasks = queryAnnotations(annotator, {\n x: 0,\n y: 0,\n width: geometry.width,\n height: geometry.height,\n }).filter(annotation => {\n // 只合并同标签、同图片尺寸并且像素真实相交的 Mask。\n if (\n annotation.labelId !== labelId ||\n annotation.geometry.type !== 'mask' ||\n annotation.geometry.width !== geometry.width ||\n annotation.geometry.height !== geometry.height\n ) {\n return false\n }\n const existingMask = decodeBinaryMaskRle(\n annotation.geometry.rle,\n annotation.geometry.width,\n annotation.geometry.height,\n )\n return masksIntersect(existingMask, brushMask)\n })\n\n if (intersectingMasks.length === 0) {\n addMask(annotator, { labelId, ...geometry })\n return\n }\n\n let merged = brushMask\n for (const annotation of intersectingMasks) {\n if (annotation.geometry.type !== 'mask') {\n continue\n }\n merged = mergeBinaryMasks(\n merged,\n decodeBinaryMaskRle(\n annotation.geometry.rle,\n annotation.geometry.width,\n annotation.geometry.height,\n ),\n )\n }\n\n const [target, ...duplicates] = intersectingMasks\n if (target === undefined || target.geometry.type !== 'mask') {\n return\n }\n updateAnnotation(annotator, target.id, {\n type: 'mask',\n width: geometry.width,\n height: geometry.height,\n rle: encodeBinaryMaskRle(merged),\n })\n for (const duplicate of duplicates) {\n // 保留第一条标注的 ID,其余重叠标注在合并后删除。\n removeAnnotation(annotator, duplicate.id)\n }\n}\n\nexport function createBrushTool(options: BrushToolOptions = {}): Tool {\n let state: BrushToolState = { pointerId: null, points: [] }\n const brushSize = Math.max(1, options.size ?? 10)\n\n return {\n id: 'brush',\n name: '涂抹',\n description: '在图像上绘制笔触',\n icon: '🖌️',\n cursor: 'crosshair',\n category: 'drawing',\n shortcuts: [{ key: 'b' }],\n handle(input: NormalizedPointerInput, context: ToolContext) {\n const internal = getInternalState(context.annotator)\n if (input.type === 'cancel') {\n state = { pointerId: null, points: [] }\n context.clearDraft()\n return\n }\n\n if (input.type === 'down') {\n const labelId = resolveLabelId(context.annotator, options.labelId)\n const color = options.color ?? internal.labels.find(\n label => label.id === labelId,\n )?.color ?? '#ff4d4f'\n state = { pointerId: input.pointerId, points: [input.imagePoint] }\n context.setDraft({\n type: 'brush',\n points: state.points,\n size: brushSize,\n color,\n labelId,\n })\n return\n }\n\n if (input.type === 'move') {\n // hover 不属于笔迹;必须是同一 pointer 且左键仍按住。\n if (state.pointerId !== input.pointerId || (input.buttons & 1) === 0) {\n return\n }\n state = { pointerId: input.pointerId, points: [...state.points, input.imagePoint] }\n const labelId = resolveLabelId(context.annotator, options.labelId)\n const color = options.color ?? internal.labels.find(\n label => label.id === labelId,\n )?.color ?? '#ff4d4f'\n context.setDraft({\n type: 'brush',\n points: state.points,\n size: brushSize,\n color,\n labelId,\n })\n return\n }\n\n if (input.type === 'up') {\n if (state.pointerId !== input.pointerId) {\n return\n }\n const points = [...state.points, input.imagePoint]\n const image = internal.image\n if (points.length >= 2 && image !== null) {\n const labelId = resolveLabelId(context.annotator, options.labelId)\n mergeBrushMask(\n context.annotator,\n labelId,\n createBrushMaskGeometry({\n imageWidth: image.width,\n imageHeight: image.height,\n brushSize,\n points,\n }),\n )\n }\n state = { pointerId: null, points: [] }\n context.clearDraft()\n }\n },\n cancel(context) {\n state = { pointerId: null, points: [] }\n context.clearDraft()\n },\n }\n}\n\nexport function useBrush(\n annotator: Annotator,\n options: Partial<BrushToolOptions> = {},\n): void {\n const labelId = resolveLabelId(annotator, options.labelId)\n activateTool(annotator, createBrushTool({\n labelId,\n size: options.size ?? 10,\n color: options.color ?? '#ff4d4f',\n }))\n}\n","import { AnnotatorError } from '../core/types.js'\nimport type { Bounds, Point } from './types.js'\n\nfunction assertFinitePoint(point: Point): void {\n if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) {\n throw new AnnotatorError(\n 'INVALID_GEOMETRY',\n 'Point coordinates must be finite.',\n )\n }\n}\n\nexport function normalizeRect(start: Point, end: Point): Bounds {\n assertFinitePoint(start)\n assertFinitePoint(end)\n\n const x = Math.min(start.x, end.x)\n const y = Math.min(start.y, end.y)\n return {\n x,\n y,\n width: Math.max(start.x, end.x) - x,\n height: Math.max(start.y, end.y) - y,\n }\n}\n\nexport function pointInRect(point: Point, rect: Bounds): boolean {\n assertFinitePoint(point)\n return (\n point.x >= rect.x &&\n point.x <= rect.x + rect.width &&\n point.y >= rect.y &&\n point.y <= rect.y + rect.height\n )\n}\n","import { normalizeRect, pointInRect } from '../geometry/rect.js'\nimport { pointInPolygon, validatePolygon } from '../geometry/polygon.js'\nimport type { Bounds, Point } from '../geometry/types.js'\nimport {\n AnnotatorError,\n type Annotation,\n type Annotator,\n type MaskGeometry,\n type PolygonGeometry,\n type RectGeometry,\n} from '../core/types.js'\nimport {\n queryAnnotations,\n removeAnnotation,\n updateAnnotation,\n} from '../core/commands.js'\nimport { emitChange } from '../core/events.js'\nimport { getInternalState } from '../core/annotator.js'\nimport {\n binaryMasksWithinDistance,\n decodeBinaryMaskRle,\n encodeBinaryMaskRle,\n mergeBinaryMasks,\n translateBinaryMask,\n} from '../mask/rle.js'\nimport { activateTool } from './controller.js'\nimport type {\n NormalizedPointerInput,\n Tool,\n ToolContext,\n} from './types.js'\n\nexport type RectHandle =\n | 'east'\n | 'north'\n | 'north-east'\n | 'north-west'\n | 'south'\n | 'south-east'\n | 'south-west'\n | 'west'\n\nexport function moveRect(\n geometry: RectGeometry,\n delta: Point,\n): RectGeometry {\n return {\n ...geometry,\n x: geometry.x + delta.x,\n y: geometry.y + delta.y,\n }\n}\n\nexport function movePolygonVertex(\n geometry: PolygonGeometry,\n index: number,\n point: Point,\n): PolygonGeometry {\n return {\n type: 'polygon',\n points: geometry.points.map((current, currentIndex) =>\n currentIndex === index ? [point.x, point.y] as const : current,\n ),\n }\n}\n\nexport function removePolygonVertex(\n geometry: PolygonGeometry,\n index: number,\n): PolygonGeometry | null {\n if (geometry.points.length <= 3) {\n return null\n }\n const points = geometry.points.filter((_, currentIndex) => currentIndex !== index)\n const candidate: PolygonGeometry = { type: 'polygon', points }\n return validatePolygon(points.map(([x, y]) => ({ x, y }))).valid\n ? candidate\n : null\n}\n\nexport function resizeRect(\n geometry: RectGeometry,\n handle: RectHandle,\n point: Point,\n): RectGeometry {\n const left = geometry.x\n const top = geometry.y\n const right = geometry.x + geometry.width\n const bottom = geometry.y + geometry.height\n const movesWest = handle.includes('west')\n const movesEast = handle.includes('east')\n const movesNorth = handle.includes('north')\n const movesSouth = handle.includes('south')\n const start = {\n x: movesWest ? point.x : left,\n y: movesNorth ? point.y : top,\n }\n const end = {\n x: movesEast ? point.x : right,\n y: movesSouth ? point.y : bottom,\n }\n return { type: 'rect', ...normalizeRect(start, end) }\n}\n\nfunction squaredDistance(first: Point, second: Point): number {\n const x = first.x - second.x\n const y = first.y - second.y\n return x * x + y * y\n}\n\nfunction rectHandlePoints(geometry: RectGeometry): readonly [RectHandle, Point][] {\n const left = geometry.x\n const top = geometry.y\n const right = geometry.x + geometry.width\n const bottom = geometry.y + geometry.height\n const centerX = (left + right) / 2\n const centerY = (top + bottom) / 2\n return [\n ['north-west', { x: left, y: top }],\n ['north', { x: centerX, y: top }],\n ['north-east', { x: right, y: top }],\n ['east', { x: right, y: centerY }],\n ['south-east', { x: right, y: bottom }],\n ['south', { x: centerX, y: bottom }],\n ['south-west', { x: left, y: bottom }],\n ['west', { x: left, y: centerY }],\n ]\n}\n\nexport function getRectResizeHandleAtPoint(\n geometry: RectGeometry,\n point: Point,\n tolerance: number,\n): RectHandle | null {\n const left = geometry.x\n const top = geometry.y\n const right = geometry.x + geometry.width\n const bottom = geometry.y + geometry.height\n const withinX = point.x >= left - tolerance && point.x <= right + tolerance\n const withinY = point.y >= top - tolerance && point.y <= bottom + tolerance\n const nearLeft = Math.abs(point.x - left) <= tolerance && withinY\n const nearRight = Math.abs(point.x - right) <= tolerance && withinY\n const nearTop = Math.abs(point.y - top) <= tolerance && withinX\n const nearBottom = Math.abs(point.y - bottom) <= tolerance && withinX\n\n if (nearLeft && nearTop) {\n return 'north-west'\n }\n if (nearRight && nearTop) {\n return 'north-east'\n }\n if (nearRight && nearBottom) {\n return 'south-east'\n }\n if (nearLeft && nearBottom) {\n return 'south-west'\n }\n if (nearLeft) {\n return 'west'\n }\n if (nearRight) {\n return 'east'\n }\n if (nearTop) {\n return 'north'\n }\n if (nearBottom) {\n return 'south'\n }\n return null\n}\n\nfunction annotationContains(annotation: Annotation, point: Point): boolean {\n // 空间索引只负责粗筛包围盒,这里再按真实几何做一次精确命中。\n if (annotation.geometry.type === 'rect') {\n return pointInRect(point, annotation.geometry)\n }\n if (annotation.geometry.type === 'polygon') {\n return pointInPolygon(\n point,\n annotation.geometry.points.map(([x, y]) => ({ x, y })),\n )\n }\n if (annotation.geometry.type === 'mask') {\n // Mask 的 RLE 数据覆盖整张原图,命中判断必须读取对应像素,不能只看外接框。\n const x = Math.floor(point.x)\n const y = Math.floor(point.y)\n if (\n x < 0 ||\n y < 0 ||\n x >= annotation.geometry.width ||\n y >= annotation.geometry.height\n ) {\n return false\n }\n const mask = decodeBinaryMaskRle(\n annotation.geometry.rle,\n annotation.geometry.width,\n annotation.geometry.height,\n )\n return mask[y * annotation.geometry.width + x] === 1\n }\n return false\n}\n\nfunction translateGeometry(\n geometry: RectGeometry | PolygonGeometry | MaskGeometry,\n delta: Point,\n): RectGeometry | PolygonGeometry | MaskGeometry {\n if (geometry.type === 'rect') {\n return moveRect(geometry, delta)\n }\n if (geometry.type === 'polygon') {\n return {\n type: 'polygon',\n points: geometry.points.map(([x, y]) => [x + delta.x, y + delta.y]),\n }\n }\n // Mask 没有单独的 x/y,移动时需要解码、平移像素,再重新编码。\n const mask = decodeBinaryMaskRle(\n geometry.rle,\n geometry.width,\n geometry.height,\n )\n return {\n type: 'mask',\n width: geometry.width,\n height: geometry.height,\n rle: encodeBinaryMaskRle(translateBinaryMask(\n mask,\n geometry.width,\n geometry.height,\n delta.x,\n delta.y,\n )),\n }\n}\n\nfunction updateAndMergeNearbyMasks(\n annotator: Annotator,\n annotation: Annotation,\n geometry: MaskGeometry,\n tolerance: number,\n): void {\n // 拖动结束后,同标签且距离足够近的 Mask 会并入当前标注。\n // 当前标注保留原 id,便于外部业务继续引用;被吸收的标注随后删除。\n let merged = decodeBinaryMaskRle(\n geometry.rle,\n geometry.width,\n geometry.height,\n )\n const nearby = queryAnnotations(annotator, {\n x: 0,\n y: 0,\n width: geometry.width,\n height: geometry.height,\n }).filter(candidate => {\n if (\n candidate.id === annotation.id ||\n candidate.labelId !== annotation.labelId ||\n candidate.geometry.type !== 'mask' ||\n candidate.geometry.width !== geometry.width ||\n candidate.geometry.height !== geometry.height\n ) {\n return false\n }\n return binaryMasksWithinDistance(\n merged,\n decodeBinaryMaskRle(\n candidate.geometry.rle,\n candidate.geometry.width,\n candidate.geometry.height,\n ),\n geometry.width,\n geometry.height,\n tolerance,\n )\n })\n for (const candidate of nearby) {\n if (candidate.geometry.type !== 'mask') {\n continue\n }\n merged = mergeBinaryMasks(merged, decodeBinaryMaskRle(\n candidate.geometry.rle,\n candidate.geometry.width,\n candidate.geometry.height,\n ))\n }\n updateAnnotation(annotator, annotation.id, {\n ...geometry,\n rle: encodeBinaryMaskRle(merged),\n })\n for (const candidate of nearby) {\n removeAnnotation(annotator, candidate.id)\n }\n}\n\nfunction sameGeometry(\n first: RectGeometry | PolygonGeometry | MaskGeometry,\n second: RectGeometry | PolygonGeometry | MaskGeometry,\n): boolean {\n return JSON.stringify(first) === JSON.stringify(second)\n}\n\nfunction polygonVertexIsSeparated(\n geometry: PolygonGeometry,\n index: number,\n minimumDistance: number,\n): boolean {\n const minimumSquared = minimumDistance * minimumDistance\n const point = geometry.points[index]\n return point !== undefined && geometry.points.every(\n ([x, y], otherIndex) =>\n index === otherIndex || squaredDistance(\n { x: point[0], y: point[1] },\n { x, y },\n ) >= minimumSquared,\n )\n}\n\ntype DragMode =\n | { readonly type: 'move' }\n | { readonly type: 'polygon-vertex'; readonly index: number }\n | { readonly type: 'rect-handle'; readonly handle: RectHandle }\n\ntype SelectState =\n | { readonly phase: 'idle' }\n | {\n readonly phase: 'dragging'\n readonly pointerId: number\n readonly annotation: Annotation\n readonly start: Point\n readonly mode: DragMode\n readonly currentGeometry: RectGeometry | PolygonGeometry | MaskGeometry\n readonly moved: boolean\n readonly clickTolerance: number\n readonly cycleOnClick: boolean\n readonly cycleIds: readonly string[]\n readonly cycleNextIndex: number\n }\n\nfunction findHandleMode(\n annotation: Annotation,\n point: Point,\n tolerance: number,\n): DragMode | null {\n // tolerance 使用图片坐标。调用方会除以缩放倍率,保证控制点在屏幕上始终好点中。\n const toleranceSquared = tolerance * tolerance\n if (annotation.geometry.type === 'polygon') {\n const index = annotation.geometry.points.findIndex(([x, y]) =>\n squaredDistance(point, { x, y }) <= toleranceSquared,\n )\n return index < 0 ? null : { type: 'polygon-vertex', index }\n }\n if (annotation.geometry.type === 'rect') {\n const handle = rectHandlePoints(annotation.geometry).find(([, handlePoint]) =>\n squaredDistance(point, handlePoint) <= toleranceSquared,\n )\n const edgeHandle = handle === undefined\n ? getRectResizeHandleAtPoint(annotation.geometry, point, tolerance)\n : handle[0]\n return edgeHandle === null\n ? null\n : { type: 'rect-handle', handle: edgeHandle }\n }\n return null\n}\n\nfunction geometryForPoint(state: Extract<SelectState, { phase: 'dragging' }>, point: Point) {\n if (state.mode.type === 'polygon-vertex') {\n if (state.annotation.geometry.type !== 'polygon') {\n return state.annotation.geometry\n }\n return movePolygonVertex(\n state.annotation.geometry,\n state.mode.index,\n point,\n )\n }\n if (state.mode.type === 'rect-handle') {\n if (state.annotation.geometry.type !== 'rect') {\n return state.annotation.geometry\n }\n return resizeRect(state.annotation.geometry, state.mode.handle, point)\n }\n return translateGeometry(state.annotation.geometry, {\n x: point.x - state.start.x,\n y: point.y - state.start.y,\n })\n}\n\nexport function selectAnnotation(annotator: Annotator, id: string): void {\n const state = getInternalState(annotator)\n if (!state.annotationsById.has(id)) {\n throw new AnnotatorError(\n 'ANNOTATION_NOT_FOUND',\n `Annotation not found: ${id}`,\n )\n }\n state.selectedIds = [id]\n state.renderer?.invalidate('interaction')\n emitChange(annotator, 'selection:update')\n}\n\nexport function clearSelection(annotator: Annotator): void {\n const state = getInternalState(annotator)\n const hadSelection = state.selectedIds.length > 0\n state.selectedIds = []\n state.renderer?.invalidate('interaction')\n if (hadSelection) {\n emitChange(annotator, 'selection:update')\n }\n}\n\nexport function getSelection(annotator: Annotator): readonly string[] {\n return [...getInternalState(annotator).selectedIds]\n}\n\nexport function createSelectTool(): Tool {\n // 编辑过程只保存在工具内部状态和 interactionDraft 中,抬手后才写入标注数据。\n // 这样取消手势时无需回滚,也不会为每个 pointermove 生成一条历史记录。\n let state: SelectState = { phase: 'idle' }\n let selectedVertex: { annotationId: string; index: number } | null = null\n\n return {\n id: 'select',\n name: '选择',\n description: '选择、移动和编辑标注',\n icon: '☝️',\n cursor: 'default',\n category: 'selection',\n shortcuts: [{ key: 's' }],\n handle(input: NormalizedPointerInput, context: ToolContext) {\n if (input.type === 'cancel') {\n state = { phase: 'idle' }\n context.clearDraft()\n return\n }\n if (input.type === 'down') {\n const internal = getInternalState(context.annotator)\n // 8px 是屏幕命中半径;换算为图片坐标后,缩放不会造成控制点错位或难以操作。\n const tolerance = 8 / (internal.viewport?.scale ?? 1)\n const selected = internal.selectedIds[0] === undefined\n ? undefined\n : internal.annotationsById.get(internal.selectedIds[0])\n let annotation: Annotation | undefined = selected\n let mode: DragMode | null = selected === undefined\n ? null\n : findHandleMode(selected, input.imagePoint, tolerance)\n\n // 已选中标注的控制点优先级最高,避免它被上层重叠标注抢走。\n const bounds: Bounds = {\n x: input.imagePoint.x - tolerance,\n y: input.imagePoint.y - tolerance,\n width: tolerance * 2,\n height: tolerance * 2,\n }\n const candidates = queryAnnotations(context.annotator, bounds)\n .reverse()\n .filter(candidate => annotationContains(candidate, input.imagePoint))\n const candidateIds = candidates.map(candidate => candidate.id)\n const selectedIndex = selected === undefined\n ? -1\n : candidateIds.indexOf(selected.id)\n let cycleOnClick = false\n let cycleNextIndex = 0\n if (mode === null) {\n // reverse 后先命中最上层;重复点击同一重叠区域时,从当前项继续向下轮选。\n const candidateIndex = selectedIndex >= 0 ? selectedIndex : 0\n annotation = candidates[candidateIndex]\n cycleOnClick = selectedIndex >= 0 && candidates.length > 1\n cycleNextIndex = candidates.length > 0\n ? (candidateIndex + 1) % candidates.length\n : 0\n mode = annotation === undefined\n ? null\n : findHandleMode(annotation, input.imagePoint, tolerance) ?? { type: 'move' }\n }\n if (annotation === undefined || mode === null) {\n selectedVertex = null\n clearSelection(context.annotator)\n return\n }\n selectAnnotation(context.annotator, annotation.id)\n selectedVertex = mode.type === 'polygon-vertex'\n ? { annotationId: annotation.id, index: mode.index }\n : null\n state = {\n phase: 'dragging',\n pointerId: input.pointerId,\n annotation,\n start: input.imagePoint,\n mode,\n currentGeometry: annotation.geometry,\n moved: false,\n clickTolerance: tolerance,\n cycleOnClick,\n cycleIds: candidateIds,\n cycleNextIndex,\n }\n return\n }\n if (state.phase !== 'dragging' || input.pointerId !== state.pointerId) {\n return\n }\n const moved = state.moved ||\n squaredDistance(state.start, input.imagePoint) >\n state.clickTolerance * state.clickTolerance\n const geometry = geometryForPoint(state, input.imagePoint)\n state = { ...state, currentGeometry: geometry, moved }\n if (input.type === 'move') {\n // pointermove 只更新预览,真正的数据提交统一放在 pointerup。\n context.setDraft({\n type: 'vector',\n annotationId: state.annotation.id,\n geometry,\n labelId: state.annotation.labelId,\n })\n return\n }\n if (!state.moved && state.cycleOnClick && state.cycleIds.length > 1) {\n // 没有超过拖动阈值,说明这是点击:切换到重叠区域中的下一条标注。\n const nextId = state.cycleIds[\n state.cycleNextIndex % state.cycleIds.length\n ]\n if (nextId !== undefined) {\n selectAnnotation(context.annotator, nextId)\n }\n state = { phase: 'idle' }\n context.clearDraft()\n return\n }\n const minimumImageSize = 1 / (\n getInternalState(context.annotator).viewport?.scale ?? 1\n )\n // 最小尺寸同样以 1 个屏幕像素为准,防止缩放后生成退化矩形或重合顶点。\n const valid = geometry.type === 'rect'\n ? geometry.width >= minimumImageSize &&\n geometry.height >= minimumImageSize\n : geometry.type === 'polygon'\n ? validatePolygon(\n geometry.points.map(([x, y]) => ({ x, y })),\n ).valid && (\n state.mode.type !== 'polygon-vertex' ||\n polygonVertexIsSeparated(\n geometry,\n state.mode.index,\n minimumImageSize,\n )\n )\n : true\n if (valid && !sameGeometry(state.annotation.geometry, geometry)) {\n if (geometry.type === 'mask') {\n // Mask 移动后可能靠近同标签区域,抬手时执行一次合并。\n updateAndMergeNearbyMasks(\n context.annotator,\n state.annotation,\n geometry,\n state.clickTolerance,\n )\n } else {\n updateAnnotation(context.annotator, state.annotation.id, geometry)\n }\n }\n state = { phase: 'idle' }\n context.clearDraft()\n },\n handleKey(event, context) {\n const internal = getInternalState(context.annotator)\n const selectedId = internal.selectedIds[0]\n if (event.key === 'Delete' && selectedId !== undefined) {\n event.preventDefault()\n removeAnnotation(context.annotator, selectedId)\n selectedVertex = null\n clearSelection(context.annotator)\n return\n }\n if (event.key === 'Backspace') {\n event.preventDefault()\n }\n if (event.key === 'Backspace' && selectedVertex !== null) {\n // Backspace 只删除当前选中的多边形顶点;至少保留三个点,并再次校验多边形。\n const annotation = internal.annotationsById.get(\n selectedVertex.annotationId,\n )\n if (annotation?.geometry.type !== 'polygon') {\n return\n }\n const geometry = removePolygonVertex(\n annotation.geometry,\n selectedVertex.index,\n )\n if (geometry !== null) {\n updateAnnotation(context.annotator, annotation.id, geometry)\n selectedVertex = null\n context.clearDraft()\n }\n }\n },\n cancel(context) {\n state = { phase: 'idle' }\n selectedVertex = null\n context.clearDraft()\n },\n }\n}\n\nexport function useSelect(annotator: Annotator): void {\n activateTool(annotator, createSelectTool())\n}\n","import {\n addMask,\n removeAnnotation,\n updateAnnotation,\n} from '../core/commands.js'\nimport { clearSelection, getSelection } from './select-tool.js'\nimport { queryAnnotations } from '../core/commands.js'\nimport type { Annotation, Annotator } from '../core/types.js'\nimport type { Point } from '../geometry/types.js'\nimport {\n decodeBinaryMaskRle,\n encodeBinaryMaskRle,\n hasMaskPixels,\n masksIntersect,\n splitBinaryMaskComponents,\n subtractBinaryMask,\n} from '../mask/rle.js'\nimport { getInternalState } from '../core/annotator.js'\nimport { activateTool } from './controller.js'\nimport { createBrushMaskGeometry } from './brush-tool.js'\nimport type {\n NormalizedPointerInput,\n Tool,\n ToolContext,\n} from './types.js'\n\nexport interface EraserToolOptions {\n readonly size?: number\n}\n\ninterface EraserToolState {\n readonly pointerId: number | null\n readonly points: readonly Point[]\n}\n\nfunction maskContainsPoint(annotation: Annotation, point: Point): boolean {\n if (annotation.geometry.type !== 'mask') {\n return false\n }\n const x = Math.floor(point.x)\n const y = Math.floor(point.y)\n if (\n x < 0 ||\n y < 0 ||\n x >= annotation.geometry.width ||\n y >= annotation.geometry.height\n ) {\n return false\n }\n const mask = decodeBinaryMaskRle(\n annotation.geometry.rle,\n annotation.geometry.width,\n annotation.geometry.height,\n )\n return mask[y * annotation.geometry.width + x] === 1\n}\n\nfunction eraseMaskStroke(\n annotator: Annotator,\n points: readonly Point[],\n size: number,\n): void {\n const image = getInternalState(annotator).image\n if (image === null || points.length < 2) {\n return\n }\n const eraserGeometry = createBrushMaskGeometry({\n imageWidth: image.width,\n imageHeight: image.height,\n brushSize: size,\n points,\n })\n const eraserMask = decodeBinaryMaskRle(\n eraserGeometry.rle,\n eraserGeometry.width,\n eraserGeometry.height,\n )\n const candidates = queryAnnotations(annotator, {\n x: 0,\n y: 0,\n width: eraserGeometry.width,\n height: eraserGeometry.height,\n }).filter(annotation =>\n // 橡皮擦明确只处理 Mask,矩形和多边形不会进入候选集合。\n annotation.geometry.type === 'mask' &&\n annotation.geometry.width === eraserGeometry.width &&\n annotation.geometry.height === eraserGeometry.height,\n )\n\n for (const annotation of candidates) {\n if (annotation.geometry.type !== 'mask') {\n continue\n }\n const currentMask = decodeBinaryMaskRle(\n annotation.geometry.rle,\n annotation.geometry.width,\n annotation.geometry.height,\n )\n if (!masksIntersect(currentMask, eraserMask)) {\n continue\n }\n const nextMask = subtractBinaryMask(currentMask, eraserMask)\n // 擦除可能把一块区域切断,提交前拆成多个独立连通块。\n const components = splitBinaryMaskComponents(\n nextMask,\n annotation.geometry.width,\n annotation.geometry.height,\n )\n const firstComponent = components[0]\n if (firstComponent !== undefined && hasMaskPixels(firstComponent)) {\n // 第一块沿用原 ID,其他块新增为独立标注。\n updateAnnotation(annotator, annotation.id, {\n type: 'mask',\n width: annotation.geometry.width,\n height: annotation.geometry.height,\n rle: encodeBinaryMaskRle(firstComponent),\n })\n for (const component of components.slice(1)) {\n addMask(annotator, {\n labelId: annotation.labelId,\n width: annotation.geometry.width,\n height: annotation.geometry.height,\n rle: encodeBinaryMaskRle(component),\n })\n }\n } else {\n removeAnnotation(annotator, annotation.id)\n }\n }\n}\n\nexport function createEraserTool(options: EraserToolOptions = {}): Tool {\n const size = options.size ?? 10\n let state: EraserToolState = { pointerId: null, points: [] }\n\n return {\n id: 'eraser',\n name: '橡皮擦',\n description: '擦除涂抹区域',\n icon: '🧹',\n cursor: 'crosshair',\n category: 'drawing',\n shortcuts: [{ key: 'e' }],\n handle(input: NormalizedPointerInput, context: ToolContext) {\n if (input.type === 'cancel') {\n state = { pointerId: null, points: [] }\n context.clearDraft()\n clearSelection(context.annotator)\n return\n }\n\n if (input.type === 'down') {\n state = { pointerId: input.pointerId, points: [input.imagePoint] }\n // draft 负责实时透明预览,持久数据仍等到 pointerup 再修改。\n context.setDraft({ type: 'eraser', points: state.points, size })\n return\n }\n\n if (input.type === 'move') {\n if (state.pointerId !== input.pointerId || (input.buttons & 1) === 0) {\n return\n }\n state = { pointerId: input.pointerId, points: [...state.points, input.imagePoint] }\n context.setDraft({ type: 'eraser', points: state.points, size })\n return\n }\n\n if (input.type === 'up') {\n if (state.pointerId !== input.pointerId) {\n return\n }\n eraseMaskStroke(\n context.annotator,\n [...state.points, input.imagePoint],\n size,\n )\n const selected = getSelection(context.annotator)\n .filter(id => {\n const annotation = queryAnnotations(context.annotator, {\n x: 0,\n y: 0,\n width: Number.MAX_SAFE_INTEGER,\n height: Number.MAX_SAFE_INTEGER,\n }).find(item => item.id === id)\n return annotation === undefined || annotation.geometry.type === 'mask'\n })\n if (selected.length > 0) {\n clearSelection(context.annotator)\n }\n state = { pointerId: null, points: [] }\n context.clearDraft()\n }\n },\n cancel(context) {\n state = { pointerId: null, points: [] }\n context.clearDraft()\n clearSelection(context.annotator)\n },\n }\n}\n\nexport function useEraser(\n annotator: Annotator,\n options: Partial<EraserToolOptions> = {},\n): void {\n activateTool(annotator, createEraserTool(options))\n}\n","import { validatePolygon } from '../geometry/polygon.js'\nimport type { Point } from '../geometry/types.js'\nimport { addPolygon } from '../core/commands.js'\nimport { AnnotatorError, type Annotator } from '../core/types.js'\nimport { getActiveLabel } from '../labels/labels.js'\nimport { activateTool } from './controller.js'\nimport type {\n NormalizedPointerInput,\n Tool,\n ToolContext,\n} from './types.js'\n\nexport interface PolygonToolState {\n readonly points: readonly Point[]\n readonly preview: Point | null\n}\n\nexport type PolygonToolInput =\n | { readonly type: 'cancel' }\n | { readonly type: 'commit' }\n | { readonly type: 'remove-last' }\n | { readonly type: 'move'; readonly imagePoint: Point }\n | { readonly type: 'point'; readonly imagePoint: Point }\n\nexport interface PolygonToolResult {\n readonly state: PolygonToolState\n readonly draft?: readonly Point[]\n readonly commit?: readonly Point[]\n}\n\nexport function createPolygonToolState(): PolygonToolState {\n return { points: [], preview: null }\n}\n\nexport function reducePolygonTool(\n state: PolygonToolState,\n input: PolygonToolInput,\n): PolygonToolResult {\n // points 是已确认顶点,preview 只用于显示当前鼠标位置。\n if (input.type === 'cancel') {\n return { state: createPolygonToolState() }\n }\n if (input.type === 'move') {\n const next = { ...state, preview: input.imagePoint }\n return {\n state: next,\n draft: [...next.points, input.imagePoint],\n }\n }\n if (input.type === 'remove-last') {\n const next = { ...state, points: state.points.slice(0, -1) }\n return { state: next, draft: next.points }\n }\n if (input.type === 'commit') {\n // 提交前统一检查点数、自相交和面积。\n if (!validatePolygon(state.points).valid) {\n return { state }\n }\n return {\n state: createPolygonToolState(),\n commit: [...state.points],\n }\n }\n\n const previous = state.points.at(-1)\n if (\n previous !== undefined &&\n previous.x === input.imagePoint.x &&\n previous.y === input.imagePoint.y\n ) {\n return { state }\n }\n const next = {\n points: [...state.points, input.imagePoint],\n preview: input.imagePoint,\n }\n return { state: next, draft: next.points }\n}\n\nexport interface PolygonToolOptions {\n readonly labelId?: string\n}\n\nfunction resolveLabelId(\n annotator: Annotator,\n configuredLabelId: string | undefined,\n): string {\n const labelId = configuredLabelId ?? getActiveLabel(annotator)\n if (labelId === null) {\n throw new AnnotatorError(\n 'UNKNOWN_LABEL',\n 'A label must be active before drawing a polygon.',\n )\n }\n return labelId\n}\n\nexport function createPolygonTool(options: PolygonToolOptions): Tool {\n let state = createPolygonToolState()\n\n const applyResult = (\n result: PolygonToolResult,\n context: ToolContext,\n ) => {\n state = result.state\n if (result.draft !== undefined) {\n const labelId = resolveLabelId(context.annotator, options.labelId)\n context.setDraft({\n type: 'polygon',\n points: result.draft,\n labelId,\n })\n } else if (state.points.length === 0) {\n context.clearDraft()\n }\n if (result.commit !== undefined) {\n const labelId = resolveLabelId(context.annotator, options.labelId)\n addPolygon(context.annotator, {\n labelId,\n points: result.commit,\n })\n context.clearDraft()\n }\n }\n\n const commit = (context: ToolContext) => {\n applyResult(reducePolygonTool(state, { type: 'commit' }), context)\n }\n\n return {\n id: 'polygon',\n name: '多边形',\n description: '绘制多边形标注',\n icon: '⬡',\n cursor: 'crosshair',\n category: 'drawing',\n shortcuts: [{ key: 'p' }],\n handle(input: NormalizedPointerInput, context: ToolContext) {\n if (input.type === 'cancel') {\n applyResult(reducePolygonTool(state, { type: 'cancel' }), context)\n return\n }\n if (input.type === 'move' && state.points.length > 0) {\n // 移动鼠标只更新预览,不增加正式顶点。\n applyResult(reducePolygonTool(state, {\n type: 'move',\n imagePoint: input.imagePoint,\n }), context)\n return\n }\n if (input.type === 'down') {\n applyResult(reducePolygonTool(state, {\n type: 'point',\n imagePoint: input.imagePoint,\n }), context)\n if (input.detail >= 2) {\n commit(context)\n }\n }\n },\n handleKey(event, context) {\n if (event.key === 'Enter') {\n event.preventDefault()\n commit(context)\n } else if (event.key === 'Backspace') {\n event.preventDefault()\n applyResult(\n reducePolygonTool(state, { type: 'remove-last' }),\n context,\n )\n }\n },\n cancel(context) {\n applyResult(reducePolygonTool(state, { type: 'cancel' }), context)\n },\n }\n}\n\nexport function usePolygon(\n annotator: Annotator,\n options: Partial<PolygonToolOptions> = {},\n): void {\n const labelId = resolveLabelId(annotator, options.labelId)\n activateTool(annotator, createPolygonTool({ labelId }))\n}\n","import { normalizeRect } from '../geometry/rect.js'\nimport type { Bounds, Point } from '../geometry/types.js'\nimport { addRect } from '../core/commands.js'\nimport { getActiveLabel } from '../labels/labels.js'\nimport { AnnotatorError } from '../core/types.js'\nimport type { Annotator } from '../core/types.js'\nimport { activateTool } from './controller.js'\nimport type {\n NormalizedPointerInput,\n Tool,\n ToolContext,\n} from './types.js'\n\nexport type RectToolState =\n | { readonly phase: 'idle' }\n | {\n readonly phase: 'drawing'\n readonly pointerId: number\n readonly start: Point\n readonly current: Point\n }\n\nexport type RectToolInput =\n | { readonly type: 'cancel' }\n | {\n readonly type: 'down' | 'move' | 'up'\n readonly pointerId: number\n readonly imagePoint: Point\n }\n\nexport interface RectToolResult {\n readonly state: RectToolState\n readonly draft?: Bounds\n readonly commit?: Bounds\n}\n\nexport function createRectToolState(): RectToolState {\n return { phase: 'idle' }\n}\n\nexport function reduceRectTool(\n state: RectToolState,\n input: RectToolInput,\n minimumSize = 0,\n): RectToolResult {\n // reducer 只计算状态和结果,不直接读写标注器,便于单元测试。\n if (input.type === 'cancel') {\n return { state: createRectToolState() }\n }\n\n if (input.type === 'down') {\n if (state.phase !== 'idle') {\n return { state }\n }\n return {\n state: {\n phase: 'drawing',\n pointerId: input.pointerId,\n start: input.imagePoint,\n current: input.imagePoint,\n },\n draft: normalizeRect(input.imagePoint, input.imagePoint),\n }\n }\n\n if (state.phase !== 'drawing' || input.pointerId !== state.pointerId) {\n return { state }\n }\n\n const draft = normalizeRect(state.start, input.imagePoint)\n if (input.type === 'move') {\n return {\n state: { ...state, current: input.imagePoint },\n draft,\n }\n }\n\n if (draft.width < minimumSize || draft.height < minimumSize) {\n // 过滤误点击和过小矩形,不生成历史记录。\n return { state: createRectToolState() }\n }\n return { state: createRectToolState(), commit: draft }\n}\n\nexport interface RectToolOptions {\n readonly labelId?: string\n readonly minimumSize?: number\n}\n\nfunction resolveLabelId(\n annotator: Annotator,\n configuredLabelId: string | undefined,\n): string {\n const labelId = configuredLabelId ?? getActiveLabel(annotator)\n if (labelId === null) {\n throw new AnnotatorError(\n 'UNKNOWN_LABEL',\n 'A label must be active before drawing a rectangle.',\n )\n }\n return labelId\n}\n\nexport function createRectTool(options: RectToolOptions): Tool {\n let state = createRectToolState()\n\n const applyResult = (\n input: NormalizedPointerInput,\n context: ToolContext,\n ) => {\n const result = reduceRectTool(\n state,\n input,\n options.minimumSize ?? 1,\n )\n state = result.state\n if (result.draft !== undefined) {\n const labelId = resolveLabelId(context.annotator, options.labelId)\n context.setDraft({\n type: 'rect',\n geometry: result.draft,\n labelId,\n })\n } else {\n context.clearDraft()\n }\n if (result.commit !== undefined) {\n // 只有 pointerup 产生 commit 时才写入持久标注。\n const labelId = resolveLabelId(context.annotator, options.labelId)\n addRect(context.annotator, {\n labelId,\n ...result.commit,\n })\n }\n }\n\n return {\n id: 'rect',\n name: '矩形',\n description: '绘制矩形标注',\n icon: '⬜',\n cursor: 'crosshair',\n category: 'drawing',\n shortcuts: [{ key: 'r' }],\n handle: applyResult,\n cancel(context) {\n state = reduceRectTool(state, { type: 'cancel' }).state\n context.clearDraft()\n },\n }\n}\n\nexport function useRect(\n annotator: Annotator,\n options: Partial<RectToolOptions> = {},\n): void {\n const labelId = resolveLabelId(annotator, options.labelId)\n activateTool(annotator, createRectTool({\n labelId,\n ...(options.minimumSize === undefined\n ? {}\n : { minimumSize: options.minimumSize }),\n }))\n}\n","import type { Tool, ToolCategory, ToolRegistry } from './types.js'\nimport { createBrushTool } from './brush-tool.js'\nimport { createEraserTool } from './eraser-tool.js'\nimport { createPolygonTool } from './polygon-tool.js'\nimport { createRectTool } from './rect-tool.js'\nimport { createSelectTool } from './select-tool.js'\n\nexport function createToolRegistry(): ToolRegistry {\n const tools = new Map<string, Tool>()\n\n return {\n register(tool): void {\n tools.set(tool.id, tool)\n },\n\n unregister(toolId): void {\n tools.delete(toolId)\n },\n\n get(toolId): Tool | undefined {\n return tools.get(toolId)\n },\n\n list(): readonly Tool[] {\n return [...tools.values()]\n },\n\n listByCategory(category): readonly Tool[] {\n return [...tools.values()].filter(tool => tool.category === category)\n },\n }\n}\n\nexport function createDefaultToolRegistry(): ToolRegistry {\n const registry = createToolRegistry()\n registry.register(createSelectTool())\n registry.register(createRectTool({}))\n registry.register(createPolygonTool({}))\n registry.register(createBrushTool({}))\n registry.register(createEraserTool())\n return registry\n}\n","import type {\n Annotation,\n AnnotatorOptions,\n LabelDefinition,\n} from './types.js'\nimport type { EventListeners } from './events.js'\nimport { createGridIndex, type GridIndex } from '../spatial/grid-index.js'\nimport type { ImageSource, LoadedImage } from '../image/types.js'\nimport type { CanvasRenderer } from '../render/canvas-renderer.js'\nimport type { ViewportState } from '../viewport/viewport.js'\nimport type { ToolController, InteractionDraft, ToolRegistry } from '../tools/types.js'\nimport { createDefaultToolRegistry } from '../tools/registry.js'\n\nexport interface HistoryEntry {\n /** 同一条历史记录必须同时描述正向执行和反向恢复。 */\n readonly undo: (state: InternalState) => void\n readonly redo: (state: InternalState) => void\n}\n\n/**\n * 标注器的唯一可变状态。对外只暴露不透明 Annotator 句柄,所有读写都经过命令层。\n * 这样可以保证数组、ID 索引、空间索引、历史记录和渲染通知始终一起更新。\n */\nexport interface InternalState {\n readonly container: HTMLElement\n readonly historyLimit: number\n destroyed: boolean\n revision: number\n annotations: Annotation[]\n labels: LabelDefinition[]\n activeLabelId: string | null\n spatialIndex: GridIndex\n annotationsById: Map<string, Annotation>\n undoStack: HistoryEntry[]\n redoStack: HistoryEntry[]\n readonly listeners: EventListeners\n imageSource: ImageSource | null\n image: LoadedImage | null\n imageAbortController: AbortController | null\n renderer: CanvasRenderer | null\n viewport: ViewportState | null\n toolController: ToolController | null\n activeToolId: string | null\n interactionDraft: InteractionDraft | null\n selectedIds: string[]\n readonly toolRegistry: ToolRegistry\n}\n\nexport function createInternalState(options: AnnotatorOptions): InternalState {\n return {\n container: options.container,\n historyLimit: options.historyLimit ?? 100,\n destroyed: false,\n revision: 0,\n annotations: [],\n labels: [],\n activeLabelId: null,\n spatialIndex: createGridIndex(512),\n annotationsById: new Map(),\n undoStack: [],\n redoStack: [],\n listeners: {\n change: new Set(),\n error: new Set(),\n },\n imageSource: null,\n image: null,\n imageAbortController: null,\n renderer: null,\n viewport: null,\n toolController: null,\n activeToolId: null,\n interactionDraft: null,\n selectedIds: [],\n toolRegistry: createDefaultToolRegistry(),\n }\n}\n","import { createInternalState, type InternalState } from './state.js'\nimport {\n AnnotatorError,\n createAnnotatorHandle,\n type AnnotationSnapshot,\n type Annotator,\n type AnnotatorOptions,\n} from './types.js'\nimport { cloneAnnotation } from './immutability.js'\n\nconst states = new WeakMap<Annotator, InternalState>()\n\n/** 通过不透明句柄读取内部状态,同时统一拦截已销毁实例。 */\nexport function getInternalState(annotator: Annotator): InternalState {\n const state = states.get(annotator)\n if (state === undefined || state.destroyed) {\n throw new AnnotatorError(\n 'ANNOTATOR_DESTROYED',\n 'The annotator has been destroyed.',\n )\n }\n return state\n}\n\nexport function createAnnotator(options: AnnotatorOptions): Annotator {\n const annotator = createAnnotatorHandle()\n states.set(annotator, createInternalState(options))\n return annotator\n}\n\nexport function destroyAnnotator(annotator: Annotator): void {\n const state = states.get(annotator)\n if (state === undefined || state.destroyed) {\n return\n }\n state.toolController?.destroy()\n state.imageAbortController?.abort()\n state.renderer?.destroy()\n state.imageSource?.dispose()\n state.destroyed = true\n state.imageAbortController = null\n state.renderer = null\n state.imageSource = null\n state.image = null\n state.viewport = null\n state.toolController = null\n state.activeToolId = null\n state.interactionDraft = null\n state.selectedIds = []\n state.listeners.change.clear()\n state.listeners.error.clear()\n}\n\nexport function getSnapshot(annotator: Annotator): AnnotationSnapshot {\n const state = getInternalState(annotator)\n // 快照中的标注会深拷贝并冻结,调用方不能绕过命令层直接修改内部数据。\n return Object.freeze({\n schemaVersion: 1 as const,\n revision: state.revision,\n annotations: Object.freeze(state.annotations.map(cloneAnnotation)),\n labels: Object.freeze(\n state.labels.map(label => Object.freeze({ ...label })),\n ),\n })\n}\n","import type {\n ImageSource,\n LoadedImage,\n StandardImageInput,\n} from './types.js'\n\nfunction createAbortError(): DOMException {\n return new DOMException('Image loading was aborted.', 'AbortError')\n}\n\nfunction isImageBitmap(input: StandardImageInput): input is ImageBitmap {\n return typeof ImageBitmap !== 'undefined' && input instanceof ImageBitmap\n}\n\nfunction loadImageElement(url: string, signal: AbortSignal): Promise<HTMLImageElement> {\n return new Promise((resolve, reject) => {\n const image = new Image()\n image.crossOrigin = 'anonymous'\n const cleanup = () => {\n // 加载完成、失败或取消后都解除监听,避免旧图片对象长期持有闭包。\n signal.removeEventListener('abort', abort)\n image.onload = null\n image.onerror = null\n }\n const abort = () => {\n cleanup()\n image.src = ''\n reject(createAbortError())\n }\n image.onload = () => {\n cleanup()\n resolve(image)\n }\n image.onerror = () => {\n cleanup()\n reject(new Error('The source image could not be decoded.'))\n }\n signal.addEventListener('abort', abort, { once: true })\n image.src = url\n })\n}\n\nexport function createStandardImageSource(\n input: StandardImageInput,\n): ImageSource {\n // ImageBitmap 由本模块复制并持有,dispose 时负责 close;外部传入对象不在这里销毁。\n let sourceInput: StandardImageInput | null = input\n let loadedImage: HTMLImageElement | null = null\n let ownedBitmap: ImageBitmap | null = null\n let bitmapPromise: Promise<ImageBitmap> | null = null\n let objectUrl: string | null = null\n let disposed = false\n\n return {\n id: globalThis.crypto.randomUUID(),\n async load(signal): Promise<LoadedImage> {\n if (disposed) {\n throw new Error('The image source has been disposed.')\n }\n if (signal.aborted) {\n throw createAbortError()\n }\n if (sourceInput !== null && isImageBitmap(sourceInput)) {\n const bitmapInput = sourceInput\n sourceInput = null\n bitmapPromise = createImageBitmap(bitmapInput).then(bitmap => {\n if (disposed) {\n bitmap.close()\n throw createAbortError()\n }\n ownedBitmap = bitmap\n return bitmap\n })\n }\n if (bitmapPromise !== null) {\n const bitmap = await bitmapPromise\n if (disposed || signal.aborted) {\n throw createAbortError()\n }\n return { source: bitmap, width: bitmap.width, height: bitmap.height }\n }\n if (loadedImage !== null) {\n return {\n source: loadedImage,\n width: loadedImage.naturalWidth,\n height: loadedImage.naturalHeight,\n }\n }\n\n if (sourceInput === null) {\n throw new Error('The image input is unavailable.')\n }\n if (typeof sourceInput !== 'string') {\n // Blob/File 先转成临时 URL,资源销毁时必须配对 revokeObjectURL。\n objectUrl = URL.createObjectURL(sourceInput)\n }\n const image = await loadImageElement(\n typeof sourceInput === 'string' ? sourceInput : objectUrl as string,\n signal,\n )\n if (disposed) {\n throw createAbortError()\n }\n loadedImage = image\n sourceInput = null\n return {\n source: image,\n width: image.naturalWidth,\n height: image.naturalHeight,\n }\n },\n dispose(): void {\n if (disposed) {\n return\n }\n disposed = true\n sourceInput = null\n loadedImage = null\n ownedBitmap?.close()\n ownedBitmap = null\n if (objectUrl !== null) {\n URL.revokeObjectURL(objectUrl)\n objectUrl = null\n }\n },\n }\n}\n","import { removeAnnotation, updateAnnotationLabel } from '../core/commands.js'\nimport { getInternalState } from '../core/annotator.js'\nimport type { Annotator } from '../core/types.js'\nimport { useBrush, type BrushToolOptions } from './brush-tool.js'\nimport {\n activateTool,\n activateToolById,\n cancelActiveGesture,\n} from './controller.js'\nimport { useEraser, type EraserToolOptions } from './eraser-tool.js'\nimport { usePolygon, type PolygonToolOptions } from './polygon-tool.js'\nimport { useRect, type RectToolOptions } from './rect-tool.js'\nimport {\n clearSelection,\n getSelection,\n selectAnnotation,\n useSelect,\n} from './select-tool.js'\nimport type { Tool, ToolCategory } from './types.js'\n\nexport interface AnnotationToolApi {\n readonly select: () => void\n readonly rect: (options?: Partial<RectToolOptions>) => void\n readonly polygon: (options?: Partial<PolygonToolOptions>) => void\n readonly brush: (options?: Partial<BrushToolOptions>) => void\n readonly eraser: (options?: Partial<EraserToolOptions>) => void\n readonly activate: (tool: Tool) => void\n readonly activateById: (toolId: string) => void\n readonly activeId: () => string | null\n readonly cancel: () => void\n readonly get: (toolId: string) => Tool | undefined\n readonly list: () => readonly Tool[]\n readonly listByCategory: (category: ToolCategory) => readonly Tool[]\n readonly register: (tool: Tool) => void\n readonly unregister: (toolId: string) => void\n readonly selectAnnotation: (annotationId: string) => void\n readonly clearSelection: () => void\n readonly selection: () => readonly string[]\n readonly deleteSelection: () => number\n readonly setSelectionLabel: (labelId: string) => number\n}\n\nexport function getActiveToolId(annotator: Annotator): string | null {\n return getInternalState(annotator).activeToolId\n}\n\nexport function deleteSelectedAnnotations(annotator: Annotator): number {\n // 复制选中列表,避免删除标注时 selection:update 影响当前遍历。\n const selectedIds = [...getSelection(annotator)]\n let removed = 0\n for (const id of selectedIds) {\n if (removeAnnotation(annotator, id)) {\n removed += 1\n }\n }\n clearSelection(annotator)\n return removed\n}\n\nexport function updateSelectedAnnotationsLabel(\n annotator: Annotator,\n labelId: string,\n): number {\n const selectedIds = [...getSelection(annotator)]\n for (const id of selectedIds) {\n updateAnnotationLabel(annotator, id, labelId)\n }\n return selectedIds.length\n}\n\nexport function createToolApi(annotator: Annotator): AnnotationToolApi {\n // 对外暴露绑定 annotator 的门面,业务层调用时不必反复传入实例。\n return Object.freeze({\n select() {\n useSelect(annotator)\n },\n rect(options = {}) {\n useRect(annotator, options)\n },\n polygon(options = {}) {\n usePolygon(annotator, options)\n },\n brush(options = {}) {\n useBrush(annotator, options)\n },\n eraser(options = {}) {\n useEraser(annotator, options)\n },\n activate(tool: Tool) {\n activateTool(annotator, tool)\n },\n activateById(toolId: string) {\n activateToolById(annotator, toolId)\n },\n activeId() {\n return getActiveToolId(annotator)\n },\n cancel() {\n cancelActiveGesture(annotator)\n },\n get(toolId: string) {\n return getInternalState(annotator).toolRegistry.get(toolId)\n },\n list() {\n return getInternalState(annotator).toolRegistry.list()\n },\n listByCategory(category: ToolCategory) {\n return getInternalState(annotator).toolRegistry.listByCategory(category)\n },\n register(tool: Tool) {\n getInternalState(annotator).toolRegistry.register(tool)\n },\n unregister(toolId: string) {\n getInternalState(annotator).toolRegistry.unregister(toolId)\n },\n selectAnnotation(annotationId: string) {\n selectAnnotation(annotator, annotationId)\n },\n clearSelection() {\n clearSelection(annotator)\n },\n selection() {\n return getSelection(annotator)\n },\n deleteSelection() {\n return deleteSelectedAnnotations(annotator)\n },\n setSelectionLabel(labelId: string) {\n return updateSelectedAnnotationsLabel(annotator, labelId)\n },\n })\n}\n","import { getInternalState } from '../core/annotator.js'\nimport type { Annotator } from '../core/types.js'\nimport type { Tool, ToolCategory } from './types.js'\n\nexport { createDefaultToolRegistry, createToolRegistry } from './registry.js'\n\nexport {\n createToolApi,\n deleteSelectedAnnotations,\n getActiveToolId,\n updateSelectedAnnotationsLabel,\n type AnnotationToolApi,\n} from './api.js'\n\nexport {\n activateTool,\n activateToolById,\n cancelActiveGesture,\n getRegisteredTools,\n getRegisteredToolsByCategory,\n} from './controller.js'\n\nexport function registerTool(annotator: Annotator, tool: Tool): void {\n getInternalState(annotator).toolRegistry.register(tool)\n}\n\nexport function unregisterTool(annotator: Annotator, toolId: string): void {\n getInternalState(annotator).toolRegistry.unregister(toolId)\n}\n\nexport function getTool(annotator: Annotator, toolId: string): Tool | undefined {\n return getInternalState(annotator).toolRegistry.get(toolId)\n}\n\nexport function listTools(annotator: Annotator): readonly Tool[] {\n return getInternalState(annotator).toolRegistry.list()\n}\n\nexport function listToolsByCategory(\n annotator: Annotator,\n category: ToolCategory,\n): readonly Tool[] {\n return getInternalState(annotator).toolRegistry.listByCategory(category)\n}\n","export const annotatorStyles = `\n :host {\n --cs-annotator-background: #101318;\n --cs-annotator-border: #2a3039;\n --cs-annotator-control: #1a2029;\n --cs-annotator-control-active: #2563eb;\n --cs-annotator-foreground: #f8fafc;\n display: block;\n width: 100%;\n height: 100%;\n color: var(--cs-annotator-foreground);\n font: 14px/1.4 system-ui, sans-serif;\n }\n\n [part=\"shell\"] {\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n width: 100%;\n height: 100%;\n overflow: hidden;\n background: var(--cs-annotator-background);\n }\n\n [part=\"toolbar\"] {\n display: flex;\n gap: 6px;\n align-items: center;\n padding: 8px;\n border-bottom: 1px solid var(--cs-annotator-border);\n }\n\n button {\n min-height: 32px;\n padding: 5px 10px;\n color: inherit;\n background: var(--cs-annotator-control);\n border: 1px solid var(--cs-annotator-border);\n border-radius: 6px;\n cursor: pointer;\n }\n\n button[aria-pressed=\"true\"] {\n background: var(--cs-annotator-control-active);\n border-color: #93c5fd;\n outline: 2px solid #ffffff;\n outline-offset: -4px;\n }\n\n button:focus-visible {\n outline: 2px solid #93c5fd;\n outline-offset: 2px;\n }\n\n button:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n }\n\n [part=\"workspace\"] {\n display: grid;\n grid-template-columns: minmax(0, 1fr) 180px;\n min-height: 0;\n }\n\n [part=\"viewport\"] {\n position: relative;\n min-width: 0;\n min-height: 0;\n background: #090b0f;\n }\n\n [part=\"labels\"] {\n overflow: auto;\n padding: 8px;\n border-left: 1px solid var(--cs-annotator-border);\n }\n\n [part=\"labels\"] button {\n display: block;\n width: 100%;\n margin-bottom: 6px;\n text-align: left;\n }\n`\n","import {\n canRedo,\n canUndo,\n redo,\n undo,\n} from '../core/commands.js'\nimport {\n createAnnotator,\n destroyAnnotator,\n getSnapshot,\n} from '../core/annotator.js'\nimport { subscribe } from '../core/events.js'\nimport type { Annotator, AnnotatorOptions } from '../core/types.js'\nimport { fitToScreen, hasImage, zoomBy } from '../image/image-commands.js'\nimport { getActiveLabel, setActiveLabel } from '../labels/labels.js'\nimport { useBrush } from '../tools/brush-tool.js'\nimport { useEraser } from '../tools/eraser-tool.js'\nimport { usePolygon } from '../tools/polygon-tool.js'\nimport { useRect } from '../tools/rect-tool.js'\nimport { useSelect } from '../tools/select-tool.js'\nimport { annotatorStyles } from './styles.js'\n\ntype HTMLElementConstructor = new () => HTMLElement\nconst HTMLElementBase = (\n globalThis.HTMLElement ?? class {}\n) as HTMLElementConstructor\n\nexport type ComponentAnnotatorOptions = Omit<AnnotatorOptions, 'container'>\n\nexport class CSAnnotatorElement extends HTMLElementBase {\n #annotator: Annotator | null = null\n #unsubscribe: (() => void) | null = null\n #viewport: HTMLElement | null = null\n #labelList: HTMLElement | null = null\n #buttons = new Map<string, HTMLButtonElement>()\n #activeTool: string | null = null\n\n connectedCallback(): void {\n if (this.shadowRoot !== null) {\n return\n }\n const root = this.attachShadow({ mode: 'open' })\n root.innerHTML = `\n <style>${annotatorStyles}</style>\n <div part=\"shell\">\n <div part=\"toolbar\" role=\"toolbar\" aria-label=\"Annotation tools\">\n <button type=\"button\" data-action=\"select\" aria-label=\"Select\" aria-pressed=\"false\">Select</button>\n <button type=\"button\" data-action=\"rect\" aria-label=\"Rectangle\" aria-pressed=\"false\">Rectangle</button>\n <button type=\"button\" data-action=\"polygon\" aria-label=\"Polygon\" aria-pressed=\"false\">Polygon</button>\n <button type=\"button\" data-action=\"brush\" aria-label=\"Brush\" aria-pressed=\"false\">Brush</button>\n <button type=\"button\" data-action=\"eraser\" aria-label=\"Eraser\" aria-pressed=\"false\">Eraser</button>\n <button type=\"button\" data-action=\"zoom-in\" aria-label=\"Zoom in\">Zoom in</button>\n <button type=\"button\" data-action=\"zoom-out\" aria-label=\"Zoom out\">Zoom out</button>\n <button type=\"button\" data-action=\"fit\" aria-label=\"Fit\">Fit</button>\n <button type=\"button\" data-action=\"undo\" aria-label=\"Undo\">Undo</button>\n <button type=\"button\" data-action=\"redo\" aria-label=\"Redo\">Redo</button>\n </div>\n <div part=\"workspace\">\n <div part=\"viewport\" role=\"region\" aria-label=\"Annotation viewport\"></div>\n <div part=\"labels\" role=\"group\" aria-label=\"Labels\"></div>\n </div>\n </div>\n `\n this.#viewport = root.querySelector('[part=\"viewport\"]')\n this.#labelList = root.querySelector('[part=\"labels\"]')\n for (const button of root.querySelectorAll<HTMLButtonElement>('button[data-action]')) {\n const action = button.dataset.action\n if (action !== undefined) {\n this.#buttons.set(action, button)\n button.addEventListener('click', () => this.#runAction(action))\n }\n }\n this.#refreshControls()\n }\n\n disconnectedCallback(): void {\n this.destroy()\n }\n\n configure(options: ComponentAnnotatorOptions = {}): Annotator {\n this.connectedCallback()\n if (this.#viewport === null) {\n throw new Error('Annotation viewport is unavailable.')\n }\n this.destroy()\n const annotator = createAnnotator({\n container: this.#viewport,\n ...(options.historyLimit === undefined\n ? {}\n : { historyLimit: options.historyLimit }),\n })\n this.#annotator = annotator\n this.#unsubscribe = subscribe(annotator, 'change', () => {\n this.#refreshControls()\n this.#refreshLabels()\n })\n this.#refreshControls()\n this.#refreshLabels()\n return annotator\n }\n\n get annotator(): Annotator | null {\n return this.#annotator\n }\n\n destroy(): void {\n this.#unsubscribe?.()\n this.#unsubscribe = null\n if (this.#annotator !== null) {\n destroyAnnotator(this.#annotator)\n this.#annotator = null\n }\n this.#activeTool = null\n this.#refreshControls()\n }\n\n #runAction(action: string): void {\n const annotator = this.#annotator\n if (annotator === null) {\n return\n }\n try {\n if (action === 'select') {\n useSelect(annotator)\n this.#setActiveTool('select')\n } else if (action === 'rect') {\n useRect(annotator)\n this.#setActiveTool('rect')\n } else if (action === 'polygon') {\n usePolygon(annotator)\n this.#setActiveTool('polygon')\n } else if (action === 'brush') {\n useBrush(annotator)\n this.#setActiveTool('brush')\n } else if (action === 'eraser') {\n useEraser(annotator)\n this.#setActiveTool('eraser')\n } else if (action === 'fit') {\n fitToScreen(annotator)\n } else if (action === 'zoom-in') {\n zoomBy(annotator, 1.25)\n } else if (action === 'zoom-out') {\n zoomBy(annotator, 0.8)\n } else if (action === 'undo') {\n undo(annotator)\n } else if (action === 'redo') {\n redo(annotator)\n }\n this.#refreshControls()\n } catch (error) {\n this.dispatchEvent(new CustomEvent('annotatorerror', {\n bubbles: true,\n composed: true,\n detail: error,\n }))\n }\n }\n\n #setActiveTool(tool: string): void {\n this.#activeTool = tool\n for (const [action, button] of this.#buttons) {\n if (['select', 'rect', 'polygon', 'brush', 'eraser'].includes(action)) {\n button.setAttribute('aria-pressed', String(action === tool))\n }\n }\n }\n\n #refreshControls(): void {\n const annotator = this.#annotator\n const enabled = annotator !== null\n const imageLoaded = enabled && hasImage(annotator)\n for (const [action, button] of this.#buttons) {\n if (action === 'undo') {\n button.disabled = !enabled || !canUndo(annotator as Annotator)\n } else if (action === 'redo') {\n button.disabled = !enabled || !canRedo(annotator as Annotator)\n } else {\n button.disabled = !imageLoaded\n }\n }\n this.#setActiveTool(this.#activeTool ?? '')\n }\n\n #refreshLabels(): void {\n if (this.#labelList === null || this.#annotator === null) {\n return\n }\n const annotator = this.#annotator\n const activeLabel = getActiveLabel(annotator)\n this.#labelList.replaceChildren()\n for (const label of getSnapshot(annotator).labels) {\n const button = document.createElement('button')\n button.type = 'button'\n button.textContent = label.name\n button.style.borderLeft = `4px solid ${label.color}`\n button.setAttribute('aria-pressed', String(label.id === activeLabel))\n button.addEventListener('click', () => {\n setActiveLabel(annotator, label.id)\n this.#refreshLabels()\n })\n this.#labelList.append(button)\n }\n }\n}\n","import type { Annotator } from '../core/types.js'\nimport {\n CSAnnotatorElement,\n type ComponentAnnotatorOptions,\n} from './annotator-element.js'\n\nexport function defineAnnotatorElements(): void {\n if (customElements.get('cs-annotator') === undefined) {\n customElements.define('cs-annotator', CSAnnotatorElement)\n }\n}\n\nfunction resolveTarget(target: string | Element): Element {\n const element = typeof target === 'string'\n ? document.querySelector(target)\n : target\n if (element === null) {\n throw new Error(`Mount target not found: ${target}`)\n }\n return element\n}\n\nexport function mountAnnotator(\n target: string | Element,\n options: ComponentAnnotatorOptions = {},\n): Annotator {\n defineAnnotatorElements()\n const host = resolveTarget(target)\n const element = document.createElement('cs-annotator') as CSAnnotatorElement\n host.append(element)\n return element.configure(options)\n}\n\nexport function unmountAnnotator(target: string | Element): void {\n const host = resolveTarget(target)\n const element = host.matches('cs-annotator')\n ? host as CSAnnotatorElement\n : host.querySelector<CSAnnotatorElement>('cs-annotator')\n if (element === null) {\n return\n }\n element.destroy()\n element.remove()\n}\n","import * as Core from './core/annotator.js'\nimport * as Commands from './core/commands.js'\nimport * as Events from './core/events.js'\nimport * as Types from './core/types.js'\nimport * as Rect from './geometry/rect.js'\nimport * as Polygon from './geometry/polygon.js'\nimport * as GeometryTypes from './geometry/types.js'\nimport * as Viewport from './viewport/viewport.js'\nimport * as Labels from './labels/labels.js'\nimport * as Spatial from './spatial/grid-index.js'\nimport * as ImageCommands from './image/image-commands.js'\nimport * as ImageSource from './image/standard-source.js'\nimport * as ImageTypes from './image/types.js'\nimport * as Tools from './tools/index.js'\nimport * as RectTool from './tools/rect-tool.js'\nimport * as PolygonTool from './tools/polygon-tool.js'\nimport * as SelectTool from './tools/select-tool.js'\nimport * as BrushTool from './tools/brush-tool.js'\nimport * as EraserTool from './tools/eraser-tool.js'\nimport * as Components from './components/define.js'\nimport * as Element from './components/annotator-element.js'\nimport type { Tool, ToolCategory, LabelDefinition, Annotator } from './index.js'\n\nexport type {\n Annotation,\n AnnotationBase,\n AnnotationSnapshot,\n Annotator,\n AnnotatorErrorCode,\n AnnotatorOptions,\n LabelDefinition,\n PolygonAnnotation,\n PolygonGeometry,\n RectAnnotation,\n RectGeometry,\n AnnotatorError,\n} from './core/types.js'\n\nexport type {\n AddPolygonInput,\n AddRectInput,\n AddMaskInput,\n} from './core/commands.js'\n\nexport type {\n AnnotatorErrorEvent,\n AnnotatorEventListener,\n AnnotatorEventMap,\n AnnotatorEventName,\n ChangeEvent,\n ChangeKind,\n} from './core/events.js'\n\nexport type {\n Bounds,\n Matrix2D,\n Point,\n Size,\n} from './geometry/types.js'\n\nexport type {\n PolygonValidation,\n} from './geometry/polygon.js'\n\nexport type {\n ViewportOptions,\n ViewportState,\n} from './viewport/viewport.js'\n\nexport type {\n GridIndex,\n} from './spatial/grid-index.js'\n\nexport type {\n ImageSource,\n LoadedImage,\n StandardImageInput,\n} from './image/types.js'\n\nexport type {\n Tool,\n ToolCategory,\n ToolContext,\n ToolController,\n ToolRegistry,\n KeyboardShortcut,\n InteractionDraft,\n NormalizedPointerInput,\n} from './tools/types.js'\n\nexport type { AnnotationToolApi } from './tools/api.js'\n\nexport type {\n RectToolInput,\n RectToolOptions,\n RectToolResult,\n RectToolState,\n} from './tools/rect-tool.js'\n\nexport type {\n PolygonToolInput,\n PolygonToolOptions,\n PolygonToolResult,\n PolygonToolState,\n} from './tools/polygon-tool.js'\n\nexport type {\n BrushToolOptions,\n} from './tools/brush-tool.js'\n\nexport type {\n EraserToolOptions,\n} from './tools/eraser-tool.js'\n\nexport type {\n RectHandle,\n} from './tools/select-tool.js'\n\nexport type {\n CSAnnotatorElement,\n ComponentAnnotatorOptions,\n} from './components/annotator-element.js'\n\nconst API = {\n create: Core.createAnnotator,\n destroy: Core.destroyAnnotator,\n snapshot: Core.getSnapshot,\n\n addRect: Commands.addRect,\n addPolygon: Commands.addPolygon,\n addMask: Commands.addMask,\n updateAnnotation: Commands.updateAnnotation,\n removeAnnotation: Commands.removeAnnotation,\n queryAnnotations: Commands.queryAnnotations,\n updateAnnotationLabel: Commands.updateAnnotationLabel,\n undo: Commands.undo,\n redo: Commands.redo,\n canUndo: Commands.canUndo,\n canRedo: Commands.canRedo,\n\n subscribe: Events.subscribe,\n\n addLabel: Labels.addLabel,\n getActiveLabel: Labels.getActiveLabel,\n setActiveLabel: Labels.setActiveLabel,\n updateLabel: Labels.updateLabel,\n\n setImage: ImageCommands.setImageSource,\n fitToScreen: ImageCommands.fitToScreen,\n zoomTo: ImageCommands.zoomTo,\n zoomBy: ImageCommands.zoomBy,\n panBy: ImageCommands.panBy,\n getZoom: ImageCommands.getZoom,\n hasImage: ImageCommands.hasImage,\n resizeViewport: ImageCommands.resizeViewport,\n clientToImage: ImageCommands.clientToImage,\n imageToClient: ImageCommands.imageToClient,\n\n createImageSource: ImageSource.createStandardImageSource,\n\n useSelect: SelectTool.useSelect,\n useRect: RectTool.useRect,\n usePolygon: PolygonTool.usePolygon,\n useBrush: BrushTool.useBrush,\n useEraser: EraserTool.useEraser,\n activateTool: Tools.activateTool,\n activateToolById: Tools.activateToolById,\n registerTool: Tools.registerTool,\n unregisterTool: Tools.unregisterTool,\n getTool: Tools.getTool,\n listTools: Tools.listTools,\n listToolsByCategory: Tools.listToolsByCategory,\n cancelGesture: Tools.cancelActiveGesture,\n createToolApi: Tools.createToolApi,\n getActiveToolId: Tools.getActiveToolId,\n deleteSelectedAnnotations: Tools.deleteSelectedAnnotations,\n updateSelectedAnnotationsLabel: Tools.updateSelectedAnnotationsLabel,\n\n selectAnnotation: SelectTool.selectAnnotation,\n clearSelection: SelectTool.clearSelection,\n getSelection: SelectTool.getSelection,\n\n mount: Components.mountAnnotator,\n unmount: Components.unmountAnnotator,\n defineElements: Components.defineAnnotatorElements,\n\n normalizeRect: Rect.normalizeRect,\n pointInRect: Rect.pointInRect,\n pointInPolygon: Polygon.pointInPolygon,\n validatePolygon: Polygon.validatePolygon,\n\n createGridIndex: Spatial.createGridIndex,\n insertSpatialItem: Spatial.insertSpatialItem,\n updateSpatialItem: Spatial.updateSpatialItem,\n removeSpatialItem: Spatial.removeSpatialItem,\n querySpatialBounds: Spatial.querySpatialBounds,\n\n createViewport: Viewport.createViewport,\n fitViewport: Viewport.fitViewport,\n imageToScreen: Viewport.imageToScreen,\n screenToImage: Viewport.screenToImage,\n zoomAt: Viewport.zoomAt,\n panViewport: Viewport.panViewport,\n\n createSelectTool: SelectTool.createSelectTool,\n createRectTool: RectTool.createRectTool,\n createPolygonTool: PolygonTool.createPolygonTool,\n createBrushTool: BrushTool.createBrushTool,\n createEraserTool: EraserTool.createEraserTool,\n\n moveRect: SelectTool.moveRect,\n resizeRect: SelectTool.resizeRect,\n movePolygonVertex: SelectTool.movePolygonVertex,\n removePolygonVertex: SelectTool.removePolygonVertex,\n\n AnnotatorError: Types.AnnotatorError,\n}\n\nexport interface AnnotatorInstance {\n annotator: Annotator\n readonly tools: Tools.AnnotationToolApi\n\n addRect(input: Omit<Commands.AddRectInput, 'type'>): string\n addPolygon(input: Commands.AddPolygonInput): string\n addMask(input: Commands.AddMaskInput): string\n updateAnnotation(id: string, geometry: Types.RectGeometry | Types.PolygonGeometry | Types.MaskGeometry): void\n updateAnnotationLabel(id: string, labelId: string): void\n removeAnnotation(id: string): boolean\n queryAnnotations(bounds: GeometryTypes.Bounds): readonly Types.Annotation[]\n\n undo(): boolean\n redo(): boolean\n canUndo(): boolean\n canRedo(): boolean\n\n addLabel(label: LabelDefinition): void\n getActiveLabel(): string | null\n setActiveLabel(labelId: string): void\n updateLabel(labelId: string, updates: Partial<Pick<LabelDefinition, 'name' | 'color'>>): void\n\n setImage(source: ImageTypes.ImageSource): Promise<void>\n fitToScreen(): void\n zoomTo(scale: number, anchor?: GeometryTypes.Point): void\n zoomBy(factor: number): void\n panBy(delta: GeometryTypes.Point): void\n getZoom(): number\n hasImage(): boolean\n resizeViewport(): void\n\n useSelect(): void\n useRect(options?: Partial<RectTool.RectToolOptions>): void\n usePolygon(options?: Partial<PolygonTool.PolygonToolOptions>): void\n useBrush(options?: Partial<BrushTool.BrushToolOptions>): void\n useEraser(options?: Partial<EraserTool.EraserToolOptions>): void\n activateTool(tool: Tool): void\n activateToolById(toolId: string): void\n registerTool(tool: Tool): void\n unregisterTool(toolId: string): void\n getTool(toolId: string): Tool | undefined\n listTools(): readonly Tool[]\n listToolsByCategory(category: ToolCategory): readonly Tool[]\n cancelGesture(): void\n\n selectAnnotation(id: string): void\n clearSelection(): void\n getSelection(): readonly string[]\n\n subscribe<K extends Events.AnnotatorEventName>(\n type: K,\n listener: Events.AnnotatorEventListener<K>,\n ): () => void\n\n snapshot(): Types.AnnotationSnapshot\n destroy(): void\n}\n\nfunction createInstance(annotator: Annotator): AnnotatorInstance {\n return {\n annotator,\n tools: Tools.createToolApi(annotator),\n\n addRect(input) {\n return Commands.addRect(annotator, input)\n },\n\n addPolygon(input) {\n return Commands.addPolygon(annotator, input)\n },\n\n addMask(input) {\n return Commands.addMask(annotator, input)\n },\n\n updateAnnotation(id, geometry) {\n Commands.updateAnnotation(annotator, id, geometry)\n },\n\n updateAnnotationLabel(id, labelId) {\n Commands.updateAnnotationLabel(annotator, id, labelId)\n },\n\n removeAnnotation(id) {\n return Commands.removeAnnotation(annotator, id)\n },\n\n queryAnnotations(bounds) {\n return Commands.queryAnnotations(annotator, bounds)\n },\n\n undo() {\n return Commands.undo(annotator)\n },\n\n redo() {\n return Commands.redo(annotator)\n },\n\n canUndo() {\n return Commands.canUndo(annotator)\n },\n\n canRedo() {\n return Commands.canRedo(annotator)\n },\n\n addLabel(label) {\n Labels.addLabel(annotator, label)\n },\n\n getActiveLabel() {\n return Labels.getActiveLabel(annotator)\n },\n\n setActiveLabel(labelId) {\n Labels.setActiveLabel(annotator, labelId)\n },\n\n updateLabel(labelId, updates) {\n Labels.updateLabel(annotator, labelId, updates)\n },\n\n setImage(source) {\n return ImageCommands.setImageSource(annotator, source)\n },\n\n fitToScreen() {\n ImageCommands.fitToScreen(annotator)\n },\n\n zoomTo(scale, anchor?) {\n ImageCommands.zoomTo(annotator, scale, anchor)\n },\n\n zoomBy(factor) {\n ImageCommands.zoomBy(annotator, factor)\n },\n\n panBy(delta) {\n ImageCommands.panBy(annotator, delta)\n },\n\n getZoom() {\n return ImageCommands.getZoom(annotator)\n },\n\n hasImage() {\n return ImageCommands.hasImage(annotator)\n },\n\n resizeViewport() {\n ImageCommands.resizeViewport(annotator)\n },\n\n useSelect() {\n SelectTool.useSelect(annotator)\n },\n\n useRect(options) {\n RectTool.useRect(annotator, options)\n },\n\n usePolygon(options) {\n PolygonTool.usePolygon(annotator, options)\n },\n\n useBrush(options) {\n BrushTool.useBrush(annotator, options)\n },\n\n useEraser(options) {\n EraserTool.useEraser(annotator, options)\n },\n\n activateTool(tool) {\n Tools.activateTool(annotator, tool)\n },\n\n activateToolById(toolId) {\n Tools.activateToolById(annotator, toolId)\n },\n\n registerTool(tool) {\n Tools.registerTool(annotator, tool)\n },\n\n unregisterTool(toolId) {\n Tools.unregisterTool(annotator, toolId)\n },\n\n getTool(toolId) {\n return Tools.getTool(annotator, toolId)\n },\n\n listTools() {\n return Tools.listTools(annotator)\n },\n\n listToolsByCategory(category) {\n return Tools.listToolsByCategory(annotator, category)\n },\n\n cancelGesture() {\n Tools.cancelActiveGesture(annotator)\n },\n\n selectAnnotation(id) {\n SelectTool.selectAnnotation(annotator, id)\n },\n\n clearSelection() {\n SelectTool.clearSelection(annotator)\n },\n\n getSelection() {\n return SelectTool.getSelection(annotator)\n },\n\n subscribe(type, listener) {\n return Events.subscribe(annotator, type, listener)\n },\n\n snapshot() {\n return Core.getSnapshot(annotator)\n },\n\n destroy() {\n Core.destroyAnnotator(annotator)\n },\n }\n}\n\nexport function create(config: Types.AnnotatorOptions): AnnotatorInstance {\n const annotator = Core.createAnnotator(config)\n return createInstance(annotator)\n}\n\nexport function mount(\n container: string | HTMLElement,\n options?: Partial<Types.AnnotatorOptions>,\n): AnnotatorInstance {\n const annotator = Components.mountAnnotator(container, options)\n return createInstance(annotator)\n}\n\nexport { API as default }\n\nexport const csLabelTool = API\n"],"mappings":";AAWA,SAAS,EAAa,GAAsB;CAC1C,IACE,CAAC;EACC,EAAO;EACP,EAAO;EACP,EAAO;EACP,EAAO;CACT,CAAC,CAAC,MAAM,OAAO,QAAQ,KACvB,EAAO,QAAQ,KACf,EAAO,SAA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A,SAAgB,GACd,GACA,GACmB;CAEnB,OAAO,GADW,GAA0B,GAAW,CACjC,CAAS;AACjC;AAIA,IAAa,KAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/labels/labels.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElE,wBAAgB,QAAQ,CACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,eAAe,GACrB,IAAI,CAyBN;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAY1E;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAElE;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GACxD,IAAI,CAcN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rle.d.ts","sourceRoot":"","sources":["../../src/mask/rle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,CAkB9E;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,UAAU,CAiBZ;AAED,iCAAiC;AACjC,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EACxB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GACxB,OAAO,CAQT;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,CAAC,MAAM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AiB,CAAC,CAAC,CAAA;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,eAAe,CAAA;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAUD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,WAAW,GAAG,cAAc,CAgDzE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"canvas-renderer.d.ts","sourceRoot":"","sources":["../../src/render/canvas-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EAIV,MAAM,kBAAkB,CAAA;AAQzB,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAGxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAA;IACvC,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAC7B;AAuED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAmXzE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/render/scheduler.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,OAAO,GACP,aAAa,CAAA;AAEjB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,MAAM,CAAA;IACjE,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9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,YAAY,CAAA;AAsDnB,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,YAAY,GACrB,cAAc,CAqKhB;AAgBD,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAEnE;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAE3E;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAE9D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,IAAI,EAAE,CAExE;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,GACrB,SAAS,IAAI,EAAE,CAEjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"eraser-tool.d.ts","sourceRoot":"","sources":["../../src/tools/eraser-tool.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAa7D,OAAO,KAAK,EAEV,IAAI,EAEL,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAuGD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,IAAI,CAoEtE;AAED,wBAAgB,SAAS,CACvB,SAAS,EAAE,SAAS,EACpB,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAM,GACvC,IAAI,CAEN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,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