@annotorious/annotorious 3.0.0-rc.9 → 3.0.1

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 (160) hide show
  1. package/dist/Annotorious.d.ts +9 -10
  2. package/dist/AnnotoriousOpts.d.ts +5 -7
  3. package/dist/annotation/SVGAnnotationLayer.svelte.d.ts +1 -1
  4. package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +6 -6
  5. package/dist/annotation/Transform.d.ts +0 -1
  6. package/dist/annotation/editors/Editor.svelte.d.ts +1 -1
  7. package/dist/annotation/editors/EditorMount.svelte.d.ts +1 -1
  8. package/dist/annotation/editors/Handle.svelte.d.ts +1 -0
  9. package/dist/annotation/editors/editorsRegistry.d.ts +3 -4
  10. package/dist/annotation/editors/index.d.ts +1 -2
  11. package/dist/annotation/editors/polygon/PolygonEditor.svelte.d.ts +1 -1
  12. package/dist/annotation/editors/polygon/index.d.ts +0 -1
  13. package/dist/annotation/editors/rectangle/RectangleEditor.svelte.d.ts +1 -1
  14. package/dist/annotation/editors/rectangle/index.d.ts +0 -1
  15. package/dist/annotation/index.d.ts +0 -1
  16. package/dist/annotation/shapes/Ellipse.svelte.d.ts +1 -1
  17. package/dist/annotation/shapes/Polygon.svelte.d.ts +1 -1
  18. package/dist/annotation/shapes/Rectangle.svelte.d.ts +1 -1
  19. package/dist/annotation/shapes/index.d.ts +0 -1
  20. package/dist/annotation/tools/DrawingToolConfig.d.ts +1 -2
  21. package/dist/annotation/tools/ToolMount.svelte.d.ts +1 -1
  22. package/dist/annotation/tools/drawingToolsRegistry.d.ts +4 -5
  23. package/dist/annotation/tools/index.d.ts +0 -1
  24. package/dist/annotation/tools/polygon/RubberbandPolygon.svelte.d.ts +1 -1
  25. package/dist/annotation/tools/polygon/index.d.ts +0 -1
  26. package/dist/annotation/tools/rectangle/RubberbandRectangle.svelte.d.ts +1 -1
  27. package/dist/annotation/tools/rectangle/index.d.ts +0 -1
  28. package/dist/annotation/utils/index.d.ts +0 -1
  29. package/dist/annotation/utils/math.d.ts +0 -1
  30. package/dist/annotation/utils/responsive.d.ts +1 -2
  31. package/dist/annotation/utils/styling.d.ts +3 -4
  32. package/dist/annotation/utils/touch.d.ts +0 -1
  33. package/dist/annotorious.css +1 -1
  34. package/dist/annotorious.es.js +2538 -2061
  35. package/dist/annotorious.es.js.map +1 -1
  36. package/dist/annotorious.js +1 -1
  37. package/dist/annotorious.js.map +1 -1
  38. package/dist/index.d.ts +1 -2
  39. package/dist/keyboardCommands.d.ts +2 -2
  40. package/dist/model/core/ImageAnnotation.d.ts +4 -3
  41. package/dist/model/core/Shape.d.ts +1 -2
  42. package/dist/model/core/ellipse/Ellipse.d.ts +1 -2
  43. package/dist/model/core/ellipse/ellipseUtils.d.ts +0 -1
  44. package/dist/model/core/ellipse/index.d.ts +0 -1
  45. package/dist/model/core/index.d.ts +0 -1
  46. package/dist/model/core/polygon/Polygon.d.ts +1 -2
  47. package/dist/model/core/polygon/index.d.ts +0 -1
  48. package/dist/model/core/polygon/polygonUtils.d.ts +0 -1
  49. package/dist/model/core/rectangle/Rectangle.d.ts +1 -2
  50. package/dist/model/core/rectangle/index.d.ts +0 -1
  51. package/dist/model/core/rectangle/rectangleUtils.d.ts +2 -3
  52. package/dist/model/core/shapeUtils.d.ts +2 -6
  53. package/dist/model/index.d.ts +0 -1
  54. package/dist/model/w3c/W3CImageAnnotation.d.ts +10 -0
  55. package/dist/model/w3c/W3CImageFormatAdapter.d.ts +11 -7
  56. package/dist/model/w3c/fragment/FragmentSelector.d.ts +2 -4
  57. package/dist/model/w3c/fragment/index.d.ts +0 -1
  58. package/dist/model/w3c/index.d.ts +1 -1
  59. package/dist/model/w3c/svg/SVG.d.ts +0 -1
  60. package/dist/model/w3c/svg/SVGSelector.d.ts +2 -4
  61. package/dist/model/w3c/svg/index.d.ts +0 -1
  62. package/dist/state/ImageAnnotationStore.d.ts +6 -7
  63. package/dist/state/ImageAnnotatorState.d.ts +8 -9
  64. package/dist/state/index.d.ts +0 -1
  65. package/dist/state/spatialTree.d.ts +7 -7
  66. package/dist/themes/index.d.ts +0 -1
  67. package/dist/themes/smart/index.d.ts +0 -1
  68. package/dist/themes/smart/setTheme.d.ts +1 -2
  69. package/package.json +16 -17
  70. package/src/Annotorious.css +13 -5
  71. package/src/Annotorious.ts +42 -26
  72. package/src/AnnotoriousOpts.ts +13 -17
  73. package/src/annotation/SVGAnnotationLayer.svelte +77 -42
  74. package/src/annotation/SVGAnnotationLayerPointerEvent.ts +8 -9
  75. package/src/annotation/Transform.ts +1 -1
  76. package/src/annotation/editors/Editor.svelte +10 -11
  77. package/src/annotation/editors/EditorMount.svelte +3 -3
  78. package/src/annotation/editors/Handle.svelte +66 -0
  79. package/src/annotation/editors/editorsRegistry.ts +2 -2
  80. package/src/annotation/editors/index.ts +2 -2
  81. package/src/annotation/editors/polygon/PolygonEditor.svelte +16 -16
  82. package/src/annotation/editors/rectangle/RectangleEditor.svelte +46 -43
  83. package/src/annotation/shapes/Ellipse.svelte +4 -4
  84. package/src/annotation/shapes/Polygon.svelte +4 -4
  85. package/src/annotation/shapes/Rectangle.svelte +4 -4
  86. package/src/annotation/tools/ToolMount.svelte +3 -3
  87. package/src/annotation/tools/drawingToolsRegistry.ts +2 -1
  88. package/src/annotation/tools/polygon/RubberbandPolygon.svelte +36 -11
  89. package/src/annotation/tools/rectangle/RubberbandRectangle.svelte +27 -11
  90. package/src/annotation/utils/responsive.ts +1 -1
  91. package/src/annotation/utils/styling.ts +18 -9
  92. package/src/annotation/utils/touch.ts +9 -1
  93. package/src/index.ts +1 -3
  94. package/src/keyboardCommands.ts +13 -5
  95. package/src/model/core/ImageAnnotation.ts +12 -1
  96. package/src/model/w3c/W3CImageAnnotation.ts +17 -0
  97. package/src/model/w3c/W3CImageFormatAdapter.ts +79 -32
  98. package/src/model/w3c/fragment/FragmentSelector.ts +5 -6
  99. package/src/model/w3c/index.ts +1 -0
  100. package/src/model/w3c/svg/SVG.ts +1 -2
  101. package/src/model/w3c/svg/SVGSelector.ts +11 -13
  102. package/src/state/ImageAnnotationStore.ts +5 -5
  103. package/src/state/ImageAnnotatorState.ts +19 -19
  104. package/src/state/spatialTree.ts +23 -11
  105. package/src/themes/dark/index.css +3 -3
  106. package/src/themes/light/index.css +2 -2
  107. package/src/themes/smart/setTheme.ts +2 -2
  108. package/dist/Annotorious.d.ts.map +0 -1
  109. package/dist/AnnotoriousOpts.d.ts.map +0 -1
  110. package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +0 -1
  111. package/dist/annotation/Transform.d.ts.map +0 -1
  112. package/dist/annotation/editors/Handle.d.ts +0 -14
  113. package/dist/annotation/editors/Handle.d.ts.map +0 -1
  114. package/dist/annotation/editors/editorsRegistry.d.ts.map +0 -1
  115. package/dist/annotation/editors/index.d.ts.map +0 -1
  116. package/dist/annotation/editors/polygon/index.d.ts.map +0 -1
  117. package/dist/annotation/editors/rectangle/index.d.ts.map +0 -1
  118. package/dist/annotation/index.d.ts.map +0 -1
  119. package/dist/annotation/shapes/index.d.ts.map +0 -1
  120. package/dist/annotation/tools/DrawingToolConfig.d.ts.map +0 -1
  121. package/dist/annotation/tools/drawingToolsRegistry.d.ts.map +0 -1
  122. package/dist/annotation/tools/index.d.ts.map +0 -1
  123. package/dist/annotation/tools/polygon/index.d.ts.map +0 -1
  124. package/dist/annotation/tools/rectangle/index.d.ts.map +0 -1
  125. package/dist/annotation/utils/index.d.ts.map +0 -1
  126. package/dist/annotation/utils/math.d.ts.map +0 -1
  127. package/dist/annotation/utils/responsive.d.ts.map +0 -1
  128. package/dist/annotation/utils/styling.d.ts.map +0 -1
  129. package/dist/annotation/utils/touch.d.ts.map +0 -1
  130. package/dist/index.d.ts.map +0 -1
  131. package/dist/keyboardCommands.d.ts.map +0 -1
  132. package/dist/model/core/ImageAnnotation.d.ts.map +0 -1
  133. package/dist/model/core/Shape.d.ts.map +0 -1
  134. package/dist/model/core/ellipse/Ellipse.d.ts.map +0 -1
  135. package/dist/model/core/ellipse/ellipseUtils.d.ts.map +0 -1
  136. package/dist/model/core/ellipse/index.d.ts.map +0 -1
  137. package/dist/model/core/index.d.ts.map +0 -1
  138. package/dist/model/core/polygon/Polygon.d.ts.map +0 -1
  139. package/dist/model/core/polygon/index.d.ts.map +0 -1
  140. package/dist/model/core/polygon/polygonUtils.d.ts.map +0 -1
  141. package/dist/model/core/rectangle/Rectangle.d.ts.map +0 -1
  142. package/dist/model/core/rectangle/index.d.ts.map +0 -1
  143. package/dist/model/core/rectangle/rectangleUtils.d.ts.map +0 -1
  144. package/dist/model/core/shapeUtils.d.ts.map +0 -1
  145. package/dist/model/index.d.ts.map +0 -1
  146. package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +0 -1
  147. package/dist/model/w3c/fragment/FragmentSelector.d.ts.map +0 -1
  148. package/dist/model/w3c/fragment/index.d.ts.map +0 -1
  149. package/dist/model/w3c/index.d.ts.map +0 -1
  150. package/dist/model/w3c/svg/SVG.d.ts.map +0 -1
  151. package/dist/model/w3c/svg/SVGSelector.d.ts.map +0 -1
  152. package/dist/model/w3c/svg/index.d.ts.map +0 -1
  153. package/dist/state/ImageAnnotationStore.d.ts.map +0 -1
  154. package/dist/state/ImageAnnotatorState.d.ts.map +0 -1
  155. package/dist/state/index.d.ts.map +0 -1
  156. package/dist/state/spatialTree.d.ts.map +0 -1
  157. package/dist/themes/index.d.ts.map +0 -1
  158. package/dist/themes/smart/index.d.ts.map +0 -1
  159. package/dist/themes/smart/setTheme.d.ts.map +0 -1
  160. package/src/annotation/editors/Handle.ts +0 -21
package/dist/index.d.ts CHANGED
@@ -6,5 +6,4 @@ export * from './annotation/tools';
6
6
  export * from './Annotorious';
7
7
  export * from './AnnotoriousOpts';
8
8
  export * from './keyboardCommands';
9
- export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, Color, DrawingStyle, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser, Purpose, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget, W3CSelector } from '@annotorious/core';
10
- //# sourceMappingURL=index.d.ts.map
9
+ export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, Color, DrawingStyle, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
@@ -1,5 +1,5 @@
1
- import type { Annotation, UndoStack } from '@annotorious/core';
1
+ import { Annotation, UndoStack } from '@annotorious/core';
2
+ export declare const isMac: boolean;
2
3
  export declare const initKeyboardCommands: <T extends Annotation>(undoStack: UndoStack<T>, container?: Element) => {
3
4
  destroy: () => void;
4
5
  };
5
- //# sourceMappingURL=keyboardCommands.d.ts.map
@@ -1,9 +1,10 @@
1
- import type { Annotation, AnnotationTarget } from '@annotorious/core';
2
- import type { Shape } from './Shape';
1
+ import { Annotation, AnnotationTarget } from '@annotorious/core';
2
+ import { Shape } from './Shape';
3
3
  export interface ImageAnnotation extends Annotation {
4
4
  target: ImageAnnotationTarget;
5
5
  }
6
6
  export interface ImageAnnotationTarget extends AnnotationTarget {
7
7
  selector: Shape;
8
8
  }
9
- //# sourceMappingURL=ImageAnnotation.d.ts.map
9
+ export declare const isImageAnnotation: <T extends Annotation>(a: T | ImageAnnotation) => a is ImageAnnotation;
10
+ export declare const isImageAnnotationTarget: <T extends AnnotationTarget>(t: T | ImageAnnotationTarget) => t is ImageAnnotationTarget;
@@ -1,4 +1,4 @@
1
- import type { AbstractSelector } from '@annotorious/core';
1
+ import { AbstractSelector } from '@annotorious/core';
2
2
  export interface Shape extends AbstractSelector {
3
3
  type: ShapeType;
4
4
  geometry: Geometry;
@@ -17,4 +17,3 @@ export interface Bounds {
17
17
  maxX: number;
18
18
  maxY: number;
19
19
  }
20
- //# sourceMappingURL=Shape.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Bounds, Geometry, Shape } from '../Shape';
1
+ import { Bounds, Geometry, Shape } from '../Shape';
2
2
  export interface Ellipse extends Shape {
3
3
  geometry: EllipseGeometry;
4
4
  }
@@ -9,4 +9,3 @@ export interface EllipseGeometry extends Geometry {
9
9
  ry: number;
10
10
  bounds: Bounds;
11
11
  }
12
- //# sourceMappingURL=Ellipse.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=ellipseUtils.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './Ellipse';
2
2
  export * from './ellipseUtils';
3
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@ export * from './rectangle';
4
4
  export * from './ImageAnnotation';
5
5
  export * from './Shape';
6
6
  export * from './shapeUtils';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Bounds, Geometry, Shape } from '../Shape';
1
+ import { Bounds, Geometry, Shape } from '../Shape';
2
2
  export interface Polygon extends Shape {
3
3
  geometry: PolygonGeometry;
4
4
  }
@@ -6,4 +6,3 @@ export interface PolygonGeometry extends Geometry {
6
6
  points: Array<Array<number>>;
7
7
  bounds: Bounds;
8
8
  }
9
- //# sourceMappingURL=Polygon.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './Polygon';
2
2
  export * from './polygonUtils';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=polygonUtils.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Bounds, Geometry, Shape } from '../Shape';
1
+ import { Bounds, Geometry, Shape } from '../Shape';
2
2
  export interface Rectangle extends Shape {
3
3
  geometry: RectangleGeometry;
4
4
  }
@@ -9,4 +9,3 @@ export interface RectangleGeometry extends Geometry {
9
9
  h: number;
10
10
  bounds: Bounds;
11
11
  }
12
- //# sourceMappingURL=Rectangle.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './Rectangle';
2
2
  export * from './rectangleUtils';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
- import type { Rectangle } from './Rectangle';
2
- import { type ShapeUtil } from '../shapeUtils';
1
+ import { Rectangle } from './Rectangle';
2
+ import { ShapeUtil } from '../shapeUtils';
3
3
  export declare const RectangleUtil: ShapeUtil<Rectangle>;
4
- //# sourceMappingURL=rectangleUtils.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Bounds, Shape, ShapeType } from './Shape';
1
+ import { Bounds, Shape, ShapeType } from './Shape';
2
2
  export interface ShapeUtil<T extends Shape> {
3
3
  area: (shape: T) => number;
4
4
  intersects: (shape: T, x: number, y: number) => boolean;
@@ -28,8 +28,4 @@ export declare const intersects: (shape: Shape, x: number, y: number) => boolean
28
28
  * @param points the points
29
29
  * @returns the Bounds
30
30
  */
31
- export declare const boundsFromPoints: (points: Array<[
32
- number,
33
- number
34
- ]>) => Bounds;
35
- //# sourceMappingURL=shapeUtils.d.ts.map
31
+ export declare const boundsFromPoints: (points: Array<[number, number]>) => Bounds;
@@ -1,3 +1,2 @@
1
1
  export * from './core';
2
2
  export * from './w3c';
3
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core';
2
+ import { FragmentSelector } from './fragment';
3
+ import { SVGSelector } from './svg';
4
+ export interface W3CImageAnnotation extends W3CAnnotation {
5
+ target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[];
6
+ }
7
+ export interface W3CImageAnnotationTarget extends W3CAnnotationTarget {
8
+ selector: W3CImageSelector | W3CImageSelector[];
9
+ }
10
+ export type W3CImageSelector = FragmentSelector | SVGSelector;
@@ -1,7 +1,11 @@
1
- import type { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core';
2
- import type { ImageAnnotation } from '../core';
3
- export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation, W3CAnnotation>;
4
- export declare const W3CImageFormat: (source: string, invertY?: boolean) => W3CImageFormatAdapter;
5
- export declare const parseW3CImageAnnotation: (annotation: W3CAnnotation, invertY?: boolean) => ParseResult<ImageAnnotation>;
6
- export declare const serializeW3CImageAnnotation: (annotation: ImageAnnotation, source: string) => W3CAnnotation;
7
- //# sourceMappingURL=W3CImageFormatAdapter.d.ts.map
1
+ import { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core';
2
+ import { ImageAnnotation } from '../core';
3
+ import { W3CImageAnnotation } from './W3CImageAnnotation';
4
+ export type W3CImageFormatAdapter = FormatAdapter<ImageAnnotation, W3CImageAnnotation>;
5
+ export interface W3CImageFormatAdapterOpts {
6
+ strict: boolean;
7
+ invertY: boolean;
8
+ }
9
+ export declare const W3CImageFormat: (source: string, opts?: W3CImageFormatAdapterOpts) => W3CImageFormatAdapter;
10
+ export declare const parseW3CImageAnnotation: (annotation: W3CAnnotation, opts?: W3CImageFormatAdapterOpts) => ParseResult<ImageAnnotation>;
11
+ export declare const serializeW3CImageAnnotation: (annotation: ImageAnnotation, source: string, opts?: W3CImageFormatAdapterOpts) => W3CImageAnnotation;
@@ -1,10 +1,8 @@
1
- import type { W3CSelector } from '@annotorious/core';
2
- import type { Rectangle, RectangleGeometry } from '../../core';
3
- export interface FragmentSelector extends W3CSelector {
1
+ import { Rectangle, RectangleGeometry } from '../../core';
2
+ export interface FragmentSelector {
4
3
  type: 'FragmentSelector';
5
4
  conformsTo: 'http://www.w3.org/TR/media-frags/';
6
5
  value: string;
7
6
  }
8
7
  export declare const parseFragmentSelector: (fragmentOrSelector: FragmentSelector | string, invertY?: boolean) => Rectangle;
9
8
  export declare const serializeFragmentSelector: (geometry: RectangleGeometry) => FragmentSelector;
10
- //# sourceMappingURL=FragmentSelector.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './FragmentSelector';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export * from './fragment';
2
2
  export * from './svg';
3
+ export * from './W3CImageAnnotation';
3
4
  export * from './W3CImageFormatAdapter';
4
- //# sourceMappingURL=index.d.ts.map
@@ -2,4 +2,3 @@ export declare const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2
2
  export declare const sanitize: (doc: Element | Document) => Element | Document;
3
3
  /** Helper that forces an un-namespaced node to SVG **/
4
4
  export declare const insertSVGNamespace: (originalDoc: Document) => Element;
5
- //# sourceMappingURL=SVG.d.ts.map
@@ -1,9 +1,7 @@
1
- import type { W3CSelector } from '@annotorious/core';
2
- import type { Shape } from '../../core';
3
- export interface SVGSelector extends W3CSelector {
1
+ import { Shape } from '../../core';
2
+ export interface SVGSelector {
4
3
  type: 'SvgSelector';
5
4
  value: string;
6
5
  }
7
6
  export declare const parseSVGSelector: <T extends Shape>(valueOrSelector: SVGSelector | string) => T;
8
7
  export declare const serializeSVGSelector: (shape: Shape) => SVGSelector;
9
- //# sourceMappingURL=SVGSelector.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './SVGSelector';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,10 @@
1
- import type { Store, SvelteAnnotatorState, SvelteStore } from '@annotorious/core';
2
- import type { ImageAnnotation } from '../model';
3
- export type ImageAnnotationStore = Store<ImageAnnotation> & {
1
+ import { Annotation, Store, SvelteAnnotatorState, SvelteStore } from '@annotorious/core';
2
+ import { ImageAnnotation } from '../model';
3
+ export type ImageAnnotationStore<I extends Annotation> = Store<I> & {
4
4
  getAt(x: number, y: number): ImageAnnotation | undefined;
5
5
  getIntersecting(x: number, y: number, width: number, height: number): ImageAnnotation[];
6
6
  };
7
- export type SvelteImageAnnotationStore = SvelteStore<ImageAnnotation> & ImageAnnotationStore;
8
- export type SvelteImageAnnotatorState = SvelteAnnotatorState<ImageAnnotation> & {
9
- store: SvelteImageAnnotationStore;
7
+ export type SvelteImageAnnotationStore<I extends Annotation = Annotation> = SvelteStore<I> & ImageAnnotationStore<I>;
8
+ export type SvelteImageAnnotatorState<I extends Annotation = Annotation> = SvelteAnnotatorState<I> & {
9
+ store: SvelteImageAnnotationStore<I>;
10
10
  };
11
- //# sourceMappingURL=ImageAnnotationStore.d.ts.map
@@ -1,12 +1,11 @@
1
- import type { ImageAnnotation } from '../model';
2
- import type { AnnotoriousOpts } from '../AnnotoriousOpts';
3
- import { type AnnotatorState, type HoverState, type SelectionState } from '@annotorious/core';
4
- import type { ImageAnnotationStore, SvelteImageAnnotatorState } from './ImageAnnotationStore';
5
- export type ImageAnnotatorState<T extends ImageAnnotationStore = ImageAnnotationStore> = AnnotatorState<ImageAnnotation> & {
6
- store: T;
1
+ import { ImageAnnotation } from '../model';
2
+ import { AnnotoriousOpts } from '../AnnotoriousOpts';
3
+ import { Annotation, AnnotatorState, HoverState, SelectionState } from '@annotorious/core';
4
+ import { ImageAnnotationStore, SvelteImageAnnotatorState } from './ImageAnnotationStore';
5
+ export type ImageAnnotatorState<I extends Annotation> = AnnotatorState<I> & {
6
+ store: ImageAnnotationStore<I>;
7
7
  selection: SelectionState<ImageAnnotation>;
8
8
  hover: HoverState<ImageAnnotation>;
9
9
  };
10
- export declare const createImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<ImageAnnotation, E>) => ImageAnnotatorState<ImageAnnotationStore>;
11
- export declare const createSvelteImageAnnotatorState: <E extends unknown>(opts: AnnotoriousOpts<ImageAnnotation, E>) => SvelteImageAnnotatorState;
12
- //# sourceMappingURL=ImageAnnotatorState.d.ts.map
10
+ export declare const createImageAnnotatorState: <I extends Annotation, E extends unknown>(opts: AnnotoriousOpts<I, E>) => ImageAnnotatorState<I>;
11
+ export declare const createSvelteImageAnnotatorState: <I extends Annotation, E extends unknown>(opts: AnnotoriousOpts<I, E>) => SvelteImageAnnotatorState<I>;
@@ -1,3 +1,2 @@
1
1
  export * from './ImageAnnotationStore';
2
2
  export * from './ImageAnnotatorState';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,5 @@
1
- import type { ImageAnnotationTarget } from '../model';
1
+ import { ImageAnnotationTarget } from '../model';
2
+ import { AnnotationTarget } from '@annotorious/core';
2
3
  interface IndexedTarget {
3
4
  minX: number;
4
5
  minY: number;
@@ -9,13 +10,12 @@ interface IndexedTarget {
9
10
  export declare const createSpatialTree: () => {
10
11
  all: () => IndexedTarget[];
11
12
  clear: () => void;
12
- getAt: (x: number, y: number) => ImageAnnotationTarget | null;
13
+ getAt: (x: number, y: number) => ImageAnnotationTarget | undefined;
13
14
  getIntersecting: (x: number, y: number, width: number, height: number) => ImageAnnotationTarget[];
14
- insert: (target: ImageAnnotationTarget) => void;
15
- remove: (target: ImageAnnotationTarget) => void;
16
- set: (targets: ImageAnnotationTarget[], replace?: boolean) => void;
15
+ insert: (target: AnnotationTarget) => void;
16
+ remove: (target: AnnotationTarget) => void;
17
+ set: (targets: AnnotationTarget[], replace?: boolean) => void;
17
18
  size: () => number;
18
- update: (previous: ImageAnnotationTarget, updated: ImageAnnotationTarget) => void;
19
+ update: (previous: AnnotationTarget, updated: AnnotationTarget) => void;
19
20
  };
20
21
  export {};
21
- //# sourceMappingURL=spatialTree.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './smart';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './setTheme';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,4 @@
1
- import type { Theme } from '../../AnnotoriousOpts';
1
+ import { Theme } from '../../AnnotoriousOpts';
2
2
  export declare const sampleBrightness: (imageOrCanvas: HTMLElement) => number;
3
3
  export declare const detectTheme: (imageOrCanvas: HTMLElement) => "dark" | "light";
4
4
  export declare const setTheme: (imageOrCanvas: HTMLElement, container: HTMLElement, theme: Theme) => void;
5
- //# sourceMappingURL=setTheme.d.ts.map
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@annotorious/annotorious",
3
- "version": "3.0.0-rc.9",
3
+ "version": "3.0.1",
4
4
  "description": "Add image annotation functionality to any web page with a few lines of JavaScript",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
7
- "homepage": "https://annotorious.github.io",
7
+ "homepage": "https://annotorious.dev",
8
8
  "type": "module",
9
9
  "repository": {
10
10
  "type": "git",
@@ -36,21 +36,20 @@
36
36
  "./src": "./src/index.ts"
37
37
  },
38
38
  "devDependencies": {
39
- "@sveltejs/vite-plugin-svelte": "^2.4.6",
40
- "@tsconfig/svelte": "^3.0.0",
41
- "@types/rbush": "^3.0.2",
42
- "jsdom": "^22.1.0",
43
- "svelte": "^3.59.2",
44
- "typescript": "^4.9.5",
45
- "vite": "^4.4.9",
46
- "vite-plugin-dts": "^3.6.0",
47
- "vitest": "^0.34.6"
48
- },
49
- "peerDependencies": {
50
- "@annotorious/core": "*"
39
+ "@sveltejs/vite-plugin-svelte": "^3.1.2",
40
+ "@tsconfig/svelte": "^5.0.4",
41
+ "@types/rbush": "^3.0.4",
42
+ "jsdom": "^25.0.0",
43
+ "svelte": "^4.2.19",
44
+ "svelte-preprocess": "^6.0.2",
45
+ "typescript": "5.5.4",
46
+ "vite": "^5.4.2",
47
+ "vite-plugin-dts": "^4.0.3",
48
+ "vitest": "^2.0.5"
51
49
  },
52
50
  "dependencies": {
53
- "rbush": "^3.0.1",
54
- "uuid": "^9.0.1"
51
+ "@annotorious/core": "3.0.1",
52
+ "rbush": "^4.0.1",
53
+ "uuid": "^10.0.0"
55
54
  }
56
- }
55
+ }
@@ -19,6 +19,14 @@
19
19
  user-select: none;
20
20
  }
21
21
 
22
+ .a9s-annotationlayer.hidden {
23
+ display: none;
24
+ }
25
+
26
+ .a9s-annotationlayer .a9s-annotation {
27
+ cursor: pointer;
28
+ }
29
+
22
30
  .a9s-annotationlayer ellipse,
23
31
  .a9s-annotationlayer polygon,
24
32
  .a9s-annotationlayer rect {
@@ -37,7 +45,7 @@
37
45
  cursor: move;
38
46
  }
39
47
 
40
- .a9s-corner-handle {
48
+ .a9s-handle {
41
49
  cursor: move;
42
50
  }
43
51
 
@@ -57,18 +65,18 @@
57
65
  cursor: w-resize;
58
66
  }
59
67
 
60
- .a9s-corner-handle.a9s-corner-handle-topleft {
68
+ .a9s-handle.a9s-corner-handle-topleft {
61
69
  cursor: nw-resize;
62
70
  }
63
71
 
64
- .a9s-corner-handle.a9s-corner-handle-topright {
72
+ .a9s-handle.a9s-corner-handle-topright {
65
73
  cursor: ne-resize;
66
74
  }
67
75
 
68
- .a9s-corner-handle.a9s-corner-handle-bottomright {
76
+ .a9s-handle.a9s-corner-handle-bottomright {
69
77
  cursor: se-resize;
70
78
  }
71
79
 
72
- .a9s-corner-handle.a9s-corner-handle-bottomleft {
80
+ .a9s-handle.a9s-corner-handle-bottomleft {
73
81
  cursor: sw-resize;
74
82
  }
@@ -1,6 +1,7 @@
1
1
  import type { SvelteComponent } from 'svelte';
2
- import type { Annotator, DrawingStyle, Filter, User } from '@annotorious/core';
3
- import { createAnonymousGuest, createBaseAnnotator, createLifecyleObserver, createUndoStack } from '@annotorious/core';
2
+ import { UserSelectAction } from '@annotorious/core';
3
+ import type { Annotation, Annotator, DrawingStyleExpression, Filter, User } from '@annotorious/core';
4
+ import { createAnonymousGuest, createBaseAnnotator, createLifecycleObserver, createUndoStack } from '@annotorious/core';
4
5
  import { registerEditor } from './annotation/editors';
5
6
  import { getTool, registerTool, listDrawingTools, type DrawingTool } from './annotation/tools';
6
7
  import { SVGAnnotationLayer } from './annotation';
@@ -16,7 +17,9 @@ import './Annotorious.css';
16
17
  import './themes/dark/index.css';
17
18
  import './themes/light/index.css';
18
19
 
19
- export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Annotator<ImageAnnotation, E> {
20
+ export interface ImageAnnotator<I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> extends Annotator<I, E> {
21
+
22
+ element: HTMLDivElement;
20
23
 
21
24
  listDrawingTools(): string[];
22
25
 
@@ -32,62 +35,68 @@ export interface ImageAnnotator<E extends unknown = ImageAnnotation> extends Ann
32
35
 
33
36
  }
34
37
 
35
- export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
38
+ export const createImageAnnotator = <I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation>(
36
39
  image: string | HTMLImageElement | HTMLCanvasElement,
37
- options: AnnotoriousOpts<ImageAnnotation, E> = {}
38
- ): ImageAnnotator<E> => {
40
+ options: AnnotoriousOpts<I, E> = {}
41
+ ): ImageAnnotator<I, E> => {
39
42
 
40
43
  if (!image)
41
44
  throw 'Missing argument: image';
42
45
 
43
- const img = (typeof image === 'string' ?
44
- document.getElementById(image) : image) as HTMLImageElement | HTMLCanvasElement;
46
+ const img = (
47
+ typeof image === 'string' ? document.getElementById(image) : image
48
+ ) as HTMLImageElement | HTMLCanvasElement;
45
49
 
46
- const opts = fillDefaults<ImageAnnotation, E>(options);
50
+ const opts = fillDefaults<I, E>(options, {
51
+ drawingEnabled: true,
52
+ drawingMode: 'drag',
53
+ userSelectAction: UserSelectAction.EDIT,
54
+ theme: 'light'
55
+ });
47
56
 
48
- const state = createSvelteImageAnnotatorState(opts);
57
+ const state = createSvelteImageAnnotatorState<I, E>(opts);
49
58
 
50
59
  const { selection, store } = state;
51
60
 
52
61
  const undoStack = createUndoStack(store);
53
62
 
54
- const lifecycle = createLifecyleObserver<ImageAnnotation, E>(
63
+ const lifecycle = createLifecycleObserver<I, E>(
55
64
  state, undoStack, opts.adapter, opts.autoSave
56
65
  );
57
66
 
58
67
  // We'll wrap the image in a container DIV.
59
- const container = document.createElement('DIV');
68
+ const container = document.createElement('DIV') as HTMLDivElement;
60
69
  container.style.position = 'relative';
61
70
  container.style.display = 'inline-block';
62
71
 
63
72
  // Wrapper div has unwanted margin at the bottom otherwise!
64
73
  img.style.display = 'block';
65
74
 
66
- img.parentNode.insertBefore(container, img);
75
+ img.parentNode!.insertBefore(container, img);
67
76
  container.appendChild(img);
68
77
 
69
78
  const keyboardCommands = initKeyboardCommands(undoStack);
70
79
 
71
80
  let currentUser: User = createAnonymousGuest();
72
81
 
73
- _setTheme(img, container, opts.theme);
82
+ _setTheme(img, container, opts.theme!);
74
83
 
75
84
  const annotationLayer = new SVGAnnotationLayer({
76
85
  target: container,
77
86
  props: {
78
- drawingEnabled: opts.drawingEnabled,
87
+ drawingEnabled: Boolean(opts.drawingEnabled),
79
88
  image: img,
80
- preferredDrawingMode: opts.drawingMode,
81
- state,
89
+ preferredDrawingMode: opts.drawingMode!,
90
+ state: state,
82
91
  style: opts.style,
83
92
  user: currentUser
84
93
  }
85
94
  });
86
95
 
87
- annotationLayer.$on('click', (evt: CustomEvent<SVGAnnotationLayerPointerEvent>) => {
96
+ annotationLayer.$on('click', (evt: CustomEvent<SVGAnnotationLayerPointerEvent<I>>) => {
88
97
  const { originalEvent, annotation } = evt.detail;
89
98
  if (annotation)
90
- selection.clickSelect(annotation.id, originalEvent);
99
+ selection.userSelect(annotation.id, originalEvent);
91
100
  else if (!selection.isEmpty())
92
101
  selection.clear();
93
102
  });
@@ -97,15 +106,15 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
97
106
  /******++++++*************/
98
107
 
99
108
  // Most of the external API functions are covered in the base annotator
100
- const base = createBaseAnnotator<ImageAnnotation, E>(state, undoStack, opts.adapter);
109
+ const base = createBaseAnnotator<I, E>(state, undoStack, opts.adapter);
101
110
 
102
111
  const destroy = () => {
103
112
  // Destroy Svelte annotation layer
104
113
  annotationLayer.$destroy();
105
114
 
106
115
  // Unwrap the image
107
- container.parentNode.insertBefore(img, container);
108
- container.parentNode.removeChild(container);
116
+ container.parentNode!.insertBefore(img, container);
117
+ container.parentNode!.removeChild(container);
109
118
 
110
119
  // Other cleanup actions
111
120
  keyboardCommands.destroy();
@@ -126,18 +135,19 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
126
135
  if (!toolSpec)
127
136
  throw `No drawing tool named ${name}`;
128
137
 
138
+ // @ts-ignore
129
139
  annotationLayer.$set({ toolName: name })
130
140
  }
131
141
 
132
142
  const setDrawingEnabled = (enabled: boolean) =>
133
143
  annotationLayer.$set({ drawingEnabled: enabled });
134
144
 
135
- const setFilter = (filter: Filter) => {
145
+ const setFilter = (_: Filter) => {
136
146
  console.warn('Filter not implemented yet');
137
147
  }
138
148
 
139
- const setStyle = (style: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle) | undefined) =>
140
- annotationLayer.$set({ style });
149
+ const setStyle = (style: DrawingStyleExpression<I> | undefined) =>
150
+ annotationLayer.$set({ style: style as DrawingStyleExpression<ImageAnnotation> });
141
151
 
142
152
  const setTheme = (theme: Theme) => _setTheme(img, container, theme);
143
153
 
@@ -146,6 +156,10 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
146
156
  annotationLayer.$set({ user });
147
157
  }
148
158
 
159
+ const setVisible = (visible: boolean) =>
160
+ // @ts-ignore
161
+ annotationLayer.$set({ visible });
162
+
149
163
  return {
150
164
  ...base,
151
165
  destroy,
@@ -161,7 +175,9 @@ export const createImageAnnotator = <E extends unknown = ImageAnnotation>(
161
175
  setStyle,
162
176
  setTheme,
163
177
  setUser,
178
+ setVisible,
179
+ element: container,
164
180
  state
165
181
  }
166
182
 
167
- }
183
+ }
@@ -1,5 +1,4 @@
1
- import { PointerSelectAction } from '@annotorious/core';
2
- import type { Annotation, DrawingStyle, FormatAdapter } from '@annotorious/core';
1
+ import type { Annotation, DrawingStyleExpression, FormatAdapter, UserSelectActionExpression } from '@annotorious/core';
3
2
  import type { ImageAnnotation } from './model';
4
3
 
5
4
  export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> {
@@ -14,9 +13,9 @@ export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E exten
14
13
  // 'drag': starts drawing on drag, single click always selects
15
14
  drawingMode?: DrawingMode;
16
15
 
17
- pointerSelectAction?: PointerSelectAction | ((a: I) => PointerSelectAction);
16
+ userSelectAction?: UserSelectActionExpression<I>;
18
17
 
19
- style?: DrawingStyle | ((annotation: I) => DrawingStyle);
18
+ style?: DrawingStyleExpression<ImageAnnotation>;
20
19
 
21
20
  theme?: Theme;
22
21
 
@@ -26,19 +25,16 @@ export type DrawingMode = 'click' | 'drag';
26
25
 
27
26
  export type Theme = 'dark' | 'light' | 'auto';
28
27
 
29
- export const fillDefaults = <I extends ImageAnnotation = ImageAnnotation, E extends unknown = ImageAnnotation> (
30
- opts: AnnotoriousOpts<I, E>
31
- ): AnnotoriousOpts<I, E> => {
32
-
33
- return {
34
- ...opts,
35
- drawingEnabled: opts.drawingEnabled === undefined ? true : opts.drawingEnabled,
36
- drawingMode: opts.drawingMode || 'drag',
37
- pointerSelectAction: opts.pointerSelectAction || PointerSelectAction.EDIT,
38
- theme: opts.theme || 'light'
39
- };
40
-
41
- };
28
+ export const fillDefaults = <I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> (
29
+ opts: AnnotoriousOpts<I, E>,
30
+ defaults: AnnotoriousOpts<I, E>
31
+ ): AnnotoriousOpts<I, E> => ({
32
+ ...opts,
33
+ drawingEnabled: opts.drawingEnabled === undefined ? defaults.drawingEnabled : opts.drawingEnabled,
34
+ drawingMode: opts.drawingMode || defaults.drawingMode,
35
+ userSelectAction: opts.userSelectAction || defaults.userSelectAction,
36
+ theme: opts.theme || defaults.theme
37
+ });
42
38
 
43
39
 
44
40