@annotorious/react 3.0.0-rc.2 → 3.0.0-rc.21

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 (76) hide show
  1. package/dist/Annotorious.d.ts +3 -27
  2. package/dist/Annotorious.d.ts.map +1 -1
  3. package/dist/AnnotoriousPlugin.d.ts +7 -6
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -1
  5. package/dist/ImageAnnotator.d.ts.map +1 -1
  6. package/dist/annotorious-react.css +1 -1
  7. package/dist/annotorious-react.es.js +33 -34
  8. package/dist/annotorious-react.es.js.map +1 -1
  9. package/dist/annotorious-react.es10.js +29 -2
  10. package/dist/annotorious-react.es10.js.map +1 -1
  11. package/dist/annotorious-react.es11.js +36 -9
  12. package/dist/annotorious-react.es11.js.map +1 -1
  13. package/dist/annotorious-react.es12.js +16 -2
  14. package/dist/annotorious-react.es12.js.map +1 -1
  15. package/dist/annotorious-react.es13.js +6 -3752
  16. package/dist/annotorious-react.es13.js.map +1 -1
  17. package/dist/annotorious-react.es14.js +7 -28
  18. package/dist/annotorious-react.es14.js.map +1 -1
  19. package/dist/annotorious-react.es15.js +152 -35
  20. package/dist/annotorious-react.es15.js.map +1 -1
  21. package/dist/annotorious-react.es16.js +27433 -13
  22. package/dist/annotorious-react.es16.js.map +1 -1
  23. package/dist/annotorious-react.es17.js +32 -4
  24. package/dist/annotorious-react.es17.js.map +1 -1
  25. package/dist/annotorious-react.es18.js +2 -8
  26. package/dist/annotorious-react.es18.js.map +1 -1
  27. package/dist/annotorious-react.es19.js +29 -152
  28. package/dist/annotorious-react.es19.js.map +1 -1
  29. package/dist/annotorious-react.es2.js +32 -32
  30. package/dist/annotorious-react.es2.js.map +1 -1
  31. package/dist/annotorious-react.es20.js +599 -6
  32. package/dist/annotorious-react.es20.js.map +1 -1
  33. package/dist/annotorious-react.es21.js +2 -2
  34. package/dist/annotorious-react.es22.js +2 -30
  35. package/dist/annotorious-react.es22.js.map +1 -1
  36. package/dist/annotorious-react.es3.js +7 -7
  37. package/dist/annotorious-react.es3.js.map +1 -1
  38. package/dist/annotorious-react.es4.js +8 -8
  39. package/dist/annotorious-react.es4.js.map +1 -1
  40. package/dist/annotorious-react.es5.js +10 -10
  41. package/dist/annotorious-react.es5.js.map +1 -1
  42. package/dist/annotorious-react.es6.js +1 -4
  43. package/dist/annotorious-react.es6.js.map +1 -1
  44. package/dist/annotorious-react.es7.js +1 -4
  45. package/dist/annotorious-react.es7.js.map +1 -1
  46. package/dist/annotorious-react.es8.js +86 -7
  47. package/dist/annotorious-react.es8.js.map +1 -1
  48. package/dist/annotorious-react.es9.js +4241 -2
  49. package/dist/annotorious-react.es9.js.map +1 -1
  50. package/dist/index.d.ts +11 -12
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  53. package/dist/openseadragon/setPosition.d.ts.map +1 -1
  54. package/package.json +16 -8
  55. package/dist/annotorious-react.es23.js +0 -602
  56. package/dist/annotorious-react.es23.js.map +0 -1
  57. package/dist/annotorious-react.es24.js +0 -20611
  58. package/dist/annotorious-react.es24.js.map +0 -1
  59. package/dist/annotorious-react.es25.js +0 -35
  60. package/dist/annotorious-react.es25.js.map +0 -1
  61. package/dist/annotorious-react.es26.js +0 -5
  62. package/dist/annotorious-react.es26.js.map +0 -1
  63. package/dist/annotorious-react.es27.js +0 -5
  64. package/dist/annotorious-react.es27.js.map +0 -1
  65. package/dist/annotorious-react.es28.js +0 -24
  66. package/dist/annotorious-react.es28.js.map +0 -1
  67. package/dist/annotorious-react.es29.js +0 -5
  68. package/dist/annotorious-react.es29.js.map +0 -1
  69. package/dist/annotorious-react.es30.js +0 -20
  70. package/dist/annotorious-react.es30.js.map +0 -1
  71. package/dist/annotorious-react.es31.js +0 -7
  72. package/dist/annotorious-react.es31.js.map +0 -1
  73. package/dist/annotorious-react.es32.js +0 -11
  74. package/dist/annotorious-react.es32.js.map +0 -1
  75. package/dist/annotorious-react.es33.js +0 -10
  76. package/dist/annotorious-react.es33.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { Annotation, Annotator, StoreChangeEvent } from '@annotorious/core';
2
+ import { Annotation, Annotator, Store } from '@annotorious/annotorious';
3
3
  interface Selection<T extends Annotation = Annotation> {
4
4
  selected: {
5
5
  annotation: T;
@@ -24,32 +24,8 @@ export declare const AnnotoriousContext: import("react").Context<{
24
24
  export declare const Annotorious: import("react").ForwardRefExoticComponent<{
25
25
  children: ReactNode;
26
26
  } & import("react").RefAttributes<Annotator<Annotation, Annotation>>>;
27
- export declare const useAnnotator: <T extends Annotator<any, unknown>>() => T;
28
- export declare const useAnnotationStore: <T extends {
29
- addAnnotation: (annotation: Annotation, origin?: import("@annotorious/core").Origin) => void;
30
- addBody: (body: import("@annotorious/core").AnnotationBody, origin?: import("@annotorious/core").Origin) => void;
31
- all: () => Annotation[];
32
- bulkAddAnnotation: (annotations: Annotation[], replace?: boolean, origin?: import("@annotorious/core").Origin) => void;
33
- bulkDeleteAnnotation: (annotationsOrIds: (string | Annotation)[], origin?: import("@annotorious/core").Origin) => void;
34
- bulkUpdateBodies: (bodies: import("@annotorious/core").AnnotationBody[], origin?: import("@annotorious/core").Origin) => void;
35
- bulkUpdateTargets: (targets: import("@annotorious/core").AnnotationTarget[], origin?: import("@annotorious/core").Origin) => void;
36
- clear: (origin?: import("@annotorious/core").Origin) => void;
37
- deleteAnnotation: (annotationOrId: string | Annotation, origin?: import("@annotorious/core").Origin) => void;
38
- deleteBody: (body: {
39
- id: string;
40
- annotation: string;
41
- }, origin?: import("@annotorious/core").Origin) => void;
42
- getAnnotation: (id: string) => Annotation;
43
- getBody: (id: string) => import("@annotorious/core").AnnotationBody;
44
- observe: (onChange: (event: StoreChangeEvent<Annotation>) => void, options?: import("@annotorious/core").StoreObserveOptions) => number;
45
- unobserve: (onChange: (event: StoreChangeEvent<Annotation>) => void) => void;
46
- updateAnnotation: (arg1: string | Annotation, arg2?: Annotation | import("@annotorious/core").Origin, arg3?: import("@annotorious/core").Origin) => void;
47
- updateBody: (oldBodyId: {
48
- id: string;
49
- annotation: string;
50
- }, newBody: import("@annotorious/core").AnnotationBody, origin?: import("@annotorious/core").Origin) => void;
51
- updateTarget: (target: import("@annotorious/core").AnnotationTarget, origin?: import("@annotorious/core").Origin) => void;
52
- }>() => T;
27
+ export declare const useAnnotator: <T extends unknown = Annotator<any, unknown>>() => T;
28
+ export declare const useAnnotationStore: <T extends unknown = Store<Annotation>>() => T;
53
29
  export declare const useAnnotations: <T extends Annotation>(debounce?: number) => T[];
54
30
  export declare const useSelection: <T extends Annotation>() => Selection<T>;
55
31
  export declare const useAnnotatorUser: () => any;
@@ -1 +1 @@
1
- {"version":3,"file":"Annotorious.d.ts","sourceRoot":"","sources":["../src/Annotorious.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,SAAS,EAAC,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAS,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGnF,UAAU,SAAS,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAEnD,QAAQ,EAAE;QAAE,UAAU,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAElD,YAAY,CAAC,EAAE,YAAY,CAAC;CAE7B;AAED,MAAM,WAAW,uBAAuB;IAEtC,IAAI,EAAE,SAAS,CAAC;IAEhB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEpD,WAAW,EAAE,UAAU,EAAE,CAAC;IAE1B,SAAS,EAAE,SAAS,CAAC;CAEtB;AAED,eAAO,MAAM,kBAAkB;;;;;;;EAU7B,CAAC;AAEH,eAAO,MAAM,WAAW;cAAqC,SAAS;qEAuEpE,CAAC;AAEH,eAAO,MAAM,YAAY,4CAGxB,CAAA;AAED,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-1,9 +1,10 @@
1
- import { Annotation, Annotator } from '@annotorious/annotorious';
2
- export interface AnnotoriousPluginProps<I extends Annotation, E extends unknown> {
3
- plugin: (anno: Annotator<I, E>, opts?: Object) => ({
4
- unmount?: () => void;
5
- }) | void;
1
+ import { Annotator } from '@annotorious/annotorious';
2
+ export type AnnotatorPlugin<T extends unknown = Annotator<any, unknown>> = (anno: T, opts?: Object) => ({
3
+ unmount?: () => void;
4
+ }) | void;
5
+ export interface AnnotoriousPluginProps<T extends unknown = Annotator<any, unknown>> {
6
+ plugin: AnnotatorPlugin<T>;
6
7
  opts?: Object;
7
8
  }
8
- export declare const AnnotoriousPlugin: <I extends Annotation = Annotation, E extends unknown = unknown>(props: AnnotoriousPluginProps<I, E>) => any;
9
+ export declare const AnnotoriousPlugin: <T extends unknown = Annotator<any, unknown>>(props: AnnotoriousPluginProps<T>) => any;
9
10
  //# sourceMappingURL=AnnotoriousPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnnotoriousPlugin.d.ts","sourceRoot":"","sources":["../src/AnnotoriousPlugin.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGjE,MAAM,WAAW,sBAAsB,CAAE,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO;IAE9E,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAEpF,IAAI,CAAC,EAAE,MAAM,CAAC;CAEf;AAED,eAAO,MAAM,iBAAiB,8GAkB7B,CAAA"}
1
+ {"version":3,"file":"AnnotoriousPlugin.d.ts","sourceRoot":"","sources":["../src/AnnotoriousPlugin.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B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ageAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAuC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,eAAe,EAAwB,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGnG,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAE,SAAQ,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;IAEjG,QAAQ,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAEzC,MAAM,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,KAAK,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,UAAU,EAAE,eAAe,KAAK,YAAY,CAAC,CAAC;IAEvE,IAAI,CAAC,EAAE,WAAW,CAAA;CAEnB;AAED,eAAO,MAAM,cAAc,6BAA8B,oBAAoB,CAAC,CAAC,4CA+B9E,CAAA"}
@@ -1 +1 @@
1
- canvas.a9s-gl-canvas{height:100%;left:0;position:absolute;top:0;width:100%}canvas.a9s-gl-canvas.hover{cursor:pointer!important}svg.svelte-190cqdf.svelte-190cqdf{pointer-events:none}svg.drawing.svelte-190cqdf.svelte-190cqdf{pointer-events:all}svg.svelte-190cqdf .svelte-190cqdf{pointer-events:all}text.svelte-1rehw2p{fill:#fff;font-family:Arial,Helvetica,sans-serif;font-weight:600}rect.svelte-1rehw2p{stroke-width:1.2;vector-effect:non-scaling-stroke}polygon.svelte-fgq4n0{stroke-width:1.2;vector-effect:non-scaling-stroke}rect.svelte-gze948{stroke-width:1.2;vector-effect:non-scaling-stroke}svg.svelte-1krwc4m{position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}.a9s-annotationlayer{box-sizing:border-box;height:100%;left:0;outline:none;position:absolute;top:0;touch-action:none;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.a9s-annotationlayer ellipse,.a9s-annotationlayer polygon,.a9s-annotationlayer rect{fill:transparent;shape-rendering:geometricPrecision;vector-effect:non-scaling-stroke}.a9s-edge-handle{fill:transparent;stroke:transparent;stroke-width:6px}.a9s-shape-handle,.a9s-corner-handle{cursor:move}.a9s-edge-handle-top{cursor:n-resize}.a9s-edge-handle-right{cursor:e-resize}.a9s-edge-handle-bottom{cursor:s-resize}.a9s-edge-handle-left{cursor:w-resize}.a9s-corner-handle.a9s-corner-handle-topleft{cursor:nw-resize}.a9s-corner-handle.a9s-corner-handle-topright{cursor:ne-resize}.a9s-corner-handle.a9s-corner-handle-bottomright{cursor:se-resize}.a9s-corner-handle.a9s-corner-handle-bottomleft{cursor:sw-resize}.a9s-annotationlayer .a9s-outer,div[data-theme=dark] .a9s-annotationlayer .a9s-outer{display:none}.a9s-annotationlayer .a9s-inner,div[data-theme=dark] .a9s-annotationlayer .a9s-inner{fill:#0000001f;stroke:#000;stroke-width:1px}rect.a9s-corner-handle,div[data-theme=dark] rect.a9s-corner-handle{fill:#000;rx:2px}rect.a9s-close-polygon-handle,div[data-theme=dark] rect.a9s-close-polygon-handle{fill:#000;rx:1px}.a9s-annotationlayer .a9s-outer,div[data-theme=light] .a9s-annotationlayer .a9s-outer{display:block;stroke:#00000040;stroke-width:3.5px}.a9s-annotationlayer .a9s-inner,div[data-theme=light] .a9s-annotationlayer .a9s-inner{fill:#ffffff26;stroke:#fff;stroke-width:1.5px}rect.a9s-corner-handle,div[data-theme=light] rect.a9s-corner-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}rect.a9s-close-polygon-handle,div[data-theme=light] rect.a9s-close-polygon-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}
1
+ canvas.a9s-gl-canvas{height:100%;left:0;position:absolute;top:0;width:100%}canvas.a9s-gl-canvas.hover{cursor:pointer!important}svg.svelte-190cqdf.svelte-190cqdf{pointer-events:none}svg.drawing.svelte-190cqdf.svelte-190cqdf{pointer-events:all}svg.svelte-190cqdf .svelte-190cqdf{pointer-events:all}text.svelte-1rehw2p{fill:#fff;font-family:Arial,Helvetica,sans-serif;font-weight:600}rect.svelte-1rehw2p{stroke-width:1.2;vector-effect:non-scaling-stroke}polygon.svelte-fgq4n0{stroke-width:1.2;vector-effect:non-scaling-stroke}rect.svelte-gze948{stroke-width:1.2;vector-effect:non-scaling-stroke}svg.svelte-1krwc4m{position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}.a9s-touch-halo.svelte-1sgkh33{fill:transparent;stroke-width:0}.a9s-touch-halo.touched.svelte-1sgkh33{fill:#ffffff40}.a9s-annotationlayer{box-sizing:border-box;height:100%;left:0;outline:none;position:absolute;top:0;touch-action:none;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.a9s-annotationlayer ellipse,.a9s-annotationlayer polygon,.a9s-annotationlayer rect{fill:transparent;shape-rendering:geometricPrecision;vector-effect:non-scaling-stroke}.a9s-edge-handle{fill:transparent;stroke:transparent;stroke-width:6px}.a9s-shape-handle,.a9s-handle{cursor:move}.a9s-edge-handle-top{cursor:n-resize}.a9s-edge-handle-right{cursor:e-resize}.a9s-edge-handle-bottom{cursor:s-resize}.a9s-edge-handle-left{cursor:w-resize}.a9s-handle.a9s-corner-handle-topleft{cursor:nw-resize}.a9s-handle.a9s-corner-handle-topright{cursor:ne-resize}.a9s-handle.a9s-corner-handle-bottomright{cursor:se-resize}.a9s-handle.a9s-corner-handle-bottomleft{cursor:sw-resize}.a9s-annotationlayer .a9s-outer,div[data-theme=dark] .a9s-annotationlayer .a9s-outer{display:none}.a9s-annotationlayer .a9s-inner,div[data-theme=dark] .a9s-annotationlayer .a9s-inner{fill:#0000001f;stroke:#000;stroke-width:1px}rect.a9s-handle,div[data-theme=dark] rect.a9s-handle{fill:#000;rx:2px}rect.a9s-close-polygon-handle,div[data-theme=dark] rect.a9s-close-polygon-handle{fill:#000;rx:1px}.a9s-annotationlayer .a9s-outer,div[data-theme=light] .a9s-annotationlayer .a9s-outer{display:block;stroke:#00000040;stroke-width:3.5px}.a9s-annotationlayer .a9s-inner,div[data-theme=light] .a9s-annotationlayer .a9s-inner{fill:#ffffff26;stroke:#fff;stroke-width:1.5px}rect.a9s-handle,div[data-theme=light] rect.a9s-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}rect.a9s-close-polygon-handle,div[data-theme=light] rect.a9s-close-polygon-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}
@@ -1,39 +1,38 @@
1
- import { Annotorious as p, AnnotoriousContext as a, useAnnotationStore as i, useAnnotations as m, useAnnotator as f, useAnnotatorUser as u, useSelection as x, useViewportState as s } from "./annotorious-react.es2.js";
2
- import { AnnotoriousPlugin as g } from "./annotorious-react.es3.js";
3
- import { Draggable as d } from "./annotorious-react.es4.js";
4
- import { ImageAnnotator as c } from "./annotorious-react.es5.js";
1
+ import { Annotorious as A, AnnotoriousContext as g, useAnnotationStore as c, useAnnotations as f, useAnnotator as x, useAnnotatorUser as S, useSelection as d, useViewportState as l } from "./annotorious-react.es2.js";
2
+ import { AnnotoriousPlugin as y } from "./annotorious-react.es3.js";
3
+ import { Draggable as O } from "./annotorious-react.es4.js";
4
+ import { ImageAnnotator as w } from "./annotorious-react.es5.js";
5
5
  import "./annotorious-react.es6.js";
6
6
  import "./annotorious-react.es7.js";
7
- import { defaultColorProvider as P } from "./annotorious-react.es8.js";
8
- import "./annotorious-react.es9.js";
9
- import { PointerSelectAction as C } from "./annotorious-react.es10.js";
10
- import { createBody as y } from "./annotorious-react.es11.js";
11
- import { Origin as b } from "./annotorious-react.es12.js";
12
- import { ShapeType as v, W3CImageFormat as B } from "./annotorious-react.es13.js";
13
- import { OpenSeadragonAnnotator as F, useViewer as T } from "./annotorious-react.es14.js";
14
- import { OpenSeadragonPopup as W } from "./annotorious-react.es15.js";
15
- import { OpenSeadragonViewer as k } from "./annotorious-react.es16.js";
7
+ import { Origin as h, PointerSelectAction as D, createAnonymousGuest as F, createBody as T, defaultColorProvider as W } from "./annotorious-react.es8.js";
8
+ import { createImageAnnotator as o, ShapeType as e, W3CImageFormat as t } from "./annotorious-react.es9.js";
9
+ import { OpenSeadragonAnnotator as j, useViewer as v } from "./annotorious-react.es10.js";
10
+ import { OpenSeadragonPopup as G } from "./annotorious-react.es11.js";
11
+ import { OpenSeadragonViewer as Y } from "./annotorious-react.es12.js";
12
+ const p = o, i = e, m = t;
16
13
  export {
17
- p as Annotorious,
18
- a as AnnotoriousContext,
19
- g as AnnotoriousPlugin,
20
- d as Draggable,
21
- c as ImageAnnotator,
22
- F as OpenSeadragonAnnotator,
23
- W as OpenSeadragonPopup,
24
- k as OpenSeadragonViewer,
25
- b as Origin,
26
- C as PointerSelectAction,
27
- v as ShapeType,
28
- B as W3CImageFormat,
29
- y as createBody,
30
- P as defaultColorProvider,
31
- i as useAnnotationStore,
32
- m as useAnnotations,
33
- f as useAnnotator,
34
- u as useAnnotatorUser,
35
- x as useSelection,
36
- T as useViewer,
37
- s as useViewportState
14
+ A as Annotorious,
15
+ g as AnnotoriousContext,
16
+ y as AnnotoriousPlugin,
17
+ O as Draggable,
18
+ w as ImageAnnotator,
19
+ j as OpenSeadragonAnnotator,
20
+ G as OpenSeadragonPopup,
21
+ Y as OpenSeadragonViewer,
22
+ h as Origin,
23
+ D as PointerSelectAction,
24
+ i as ShapeType,
25
+ m as W3CImageFormat,
26
+ F as createAnonymousGuest,
27
+ T as createBody,
28
+ p as createImageAnnotator,
29
+ W as defaultColorProvider,
30
+ c as useAnnotationStore,
31
+ f as useAnnotations,
32
+ x as useAnnotator,
33
+ S as useAnnotatorUser,
34
+ d as useSelection,
35
+ v as useViewer,
36
+ l as useViewportState
38
37
  };
39
38
  //# sourceMappingURL=annotorious-react.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"annotorious-react.es.js","sources":["../src/index.ts"],"sourcesContent":["export * from './Annotorious';\nexport * from './AnnotoriousPlugin';\nexport * from './AnnotoriousPopup';\nexport * from './ImageAnnotator';\n\nexport * from './openseadragon';\n\n// This ensures the Annotorious stylesheet gets packaged into annotorious-react\nimport '@annotorious/annotorious/annotorious.css';\nimport '@annotorious/openseadragon/annotorious-openseadragon.css';\n\n// Essential re-exports from @annotorious/core\nexport type {\n Annotation,\n AnnotationBody,\n AnnotationTarget,\n Annotator,\n AnnotatorState,\n Appearance,\n AppearanceProvider,\n Color,\n DrawingStyle,\n Filter,\n FormatAdapter,\n HoverState,\n LifecycleEvents,\n ParseResult,\n PresentUser,\n Purpose,\n Selection,\n SelectionState,\n Store,\n StoreChangeEvent,\n StoreObserver,\n User,\n W3CAnnotation,\n W3CAnnotationBody,\n W3CAnnotationTarget\n} from '@annotorious/core';\n\nimport {\n createAnonymousGuest as _createAnonymousGuest, \n createBody as _createBody,\n defaultColorProvider as _defaultColorProvider,\n Origin as _Origin,\n PointerSelectAction as _PointerSelectAction\n} from '@annotorious/core';\n\nexport { _createAnonymousGuest as createAnonymousGuest };\nexport { _createBody as createBody };\nexport { _defaultColorProvider as defaultColorProvider };\nexport { _Origin as Origin };\nexport { _PointerSelectAction as PointerSelectAction };\n\n// Essential re-exports from @annotorious/annotorious \nexport type {\n AnnotoriousOpts,\n DrawingMode,\n DrawingTool,\n FragmentSelector,\n ImageAnnotator as AnnotoriousImageAnnotator,\n ImageAnnotation,\n ImageAnnotator,\n ImageAnnotatorState,\n Polygon,\n PolygonGeometry,\n Rectangle,\n RectangleGeometry,\n Shape,\n SVGSelector,\n W3CImageAnnotation,\n W3CImageAnnotationTarget\n} from '@annotorious/annotorious';\n\nimport { \n createImageAnnotator as _createImageAnnotator,\n ShapeType as _ShapeType,\n W3CImageFormat as _W3CImageFormat\n} from '@annotorious/annotorious';\n\nexport const createImageAnnotator = _createImageAnnotator;\nexport const ShapeType = _ShapeType;\nexport const W3CImageFormat = _W3CImageFormat;\n\n// Essential re-exports from @annotorious/openseadragon \nexport type {\n OpenSeadragonAnnotator as AnnotoriousOpenSeadragonAnnotator\n} from '@annotorious/openseadragon';\n\nexport type { Viewer } from 'openseadragon';\n"],"names":["createImageAnnotator","_createImageAnnotator","ShapeType","_ShapeType","W3CImageFormat","_W3CImageFormat"],"mappings":";;;;;;;;;;;AAgFO,MAAMA,IAAuBC,GACvBC,IAAYC,GACZC,IAAiBC;"}
@@ -1,5 +1,32 @@
1
- var N = /* @__PURE__ */ ((E) => (E.EDIT = "EDIT", E.SELECT = "SELECT", E.NONE = "NONE", E))(N || {});
1
+ import { j as c } from "./annotorious-react.es13.js";
2
+ import { createContext as w, useState as u, useContext as a, useEffect as i } from "react";
3
+ import { createOSDAnnotator as g } from "./annotorious-react.es16.js";
4
+ import { AnnotoriousContext as m } from "./annotorious-react.es2.js";
5
+ const s = w({ viewer: null, setViewer: null }), S = (e) => {
6
+ const { children: E, tool: r, ...d } = e, [o, f] = u(), { anno: t, setAnno: l } = a(m);
7
+ return i(() => {
8
+ if (o) {
9
+ const n = g(o, d);
10
+ return e.drawingEnabled !== void 0 && n.setDrawingEnabled(e.drawingEnabled), e.filter && n.setFilter(e.filter), e.style && n.setStyle(e.style), e.tool && n.setDrawingTool(e.tool), l(n), () => {
11
+ n.destroy(), l(void 0);
12
+ };
13
+ }
14
+ }, [o]), i(() => {
15
+ t && t.setDrawingEnabled(e.drawingEnabled);
16
+ }, [e.drawingEnabled]), i(() => {
17
+ t && t.setFilter(e.filter);
18
+ }, [e.filter]), i(() => {
19
+ t && t.setStyle(e.style);
20
+ }, [e.style]), i(() => {
21
+ t && t.setDrawingTool(r);
22
+ }, [r]), /* @__PURE__ */ c.jsx(s.Provider, { value: { viewer: o, setViewer: f }, children: e.children });
23
+ }, A = () => {
24
+ const { viewer: e } = a(s);
25
+ return e;
26
+ };
2
27
  export {
3
- N as PointerSelectAction
28
+ S as OpenSeadragonAnnotator,
29
+ s as OpenSeadragonAnnotatorContext,
30
+ A as useViewer
4
31
  };
5
32
  //# sourceMappingURL=annotorious-react.es10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es10.js","sources":["../../annotorious-core/src/state/Selection.ts"],"sourcesContent":["import { writable } from 'svelte/store';\nimport type { Annotation } from '../model';\nimport type { Store } from './Store';\n \nexport type Selection = {\n\n selected: { id: string, editable?: boolean }[],\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport type SelectionState<T extends Annotation> = ReturnType<typeof createSelectionState<T>>;\n\nexport enum PointerSelectAction {\n\n EDIT = 'EDIT', // Make annotation target(s) editable on pointer select\n \n SELECT = 'SELECT', // Just select, but don't make editable\n\n NONE = 'NONE' // Click won't select - annotation is completely inert\n\n}\n\nconst EMPTY: Selection = { selected: [] };\n\nexport const createSelectionState = <T extends Annotation>(\n store: Store<T>,\n selectAction: PointerSelectAction | ((a: Annotation) => PointerSelectAction) = PointerSelectAction.EDIT\n) => {\n const { subscribe, set } = writable<Selection>(EMPTY);\n\n let currentSelection: Selection = EMPTY;\n\n subscribe(updated => currentSelection = updated);\n\n const clear = () => set(EMPTY);\n\n const isEmpty = () => currentSelection.selected?.length === 0;\n\n const isSelected = (annotationOrId: T | string) => {\n if (currentSelection.selected.length === 0)\n return false;\n\n const id = typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id;\n return currentSelection.selected.some(i => i.id === id);\n }\n\n // TODO enable CTRL select\n const clickSelect = (id: string, pointerEvent: PointerEvent) => {\n const annotation = store.getAnnotation(id);\n if (annotation) {\n const action = onPointerSelect(annotation, selectAction);\n if (action === PointerSelectAction.EDIT)\n set({ selected: [{ id, editable: true }], pointerEvent }); \n else if (action === PointerSelectAction.SELECT)\n set({ selected: [{ id }], pointerEvent }); \n else\n set({ selected: [], pointerEvent });\n } else {\n console.warn('Invalid selection: ' + id);\n }\n }\n\n const setSelected = (idOrIds: string | string[], editable: boolean = true) => {\n const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];\n\n // Remove invalid\n const annotations = \n ids.map(id => store.getAnnotation(id)).filter(a => a); \n\n set({ selected: annotations.map(({ id }) => ({ id, editable })) });\n \n if (annotations.length !== ids.length)\n console.warn('Invalid selection', idOrIds);\n }\n\n const removeFromSelection = (ids: string[]) => {\n if (currentSelection.selected.length === 0)\n return false;\n\n const { selected } = currentSelection;\n\n // Checks which of the given annotations are actually in the selection\n const toRemove = selected.filter(({ id }) => ids.includes(id))\n\n if (toRemove.length > 0)\n set({ selected: selected.filter(({ id }) => !ids.includes(id)) });\n }\n\n // Track store delete and update events\n store.observe(({ changes }) =>\n removeFromSelection(changes.deleted.map(a => a.id)));\n\n return { \n clear, \n clickSelect, \n get selected() { return currentSelection ? [...currentSelection.selected ] : null},\n get pointerEvent() { return currentSelection ? currentSelection.pointerEvent : null },\n isEmpty, \n isSelected, \n setSelected, \n subscribe \n };\n\n}\n\nexport const onPointerSelect = (\n annotation: Annotation, \n action?: PointerSelectAction | ((a: Annotation) => PointerSelectAction)\n): PointerSelectAction => (typeof action === 'function') ?\n (action(annotation) || PointerSelectAction.EDIT) : \n (action || PointerSelectAction.EDIT);\n"],"names":["PointerSelectAction"],"mappings":"AAcY,IAAAA,sBAAAA,OAEVA,EAAA,OAAO,QAEPA,EAAA,SAAS,UAETA,EAAA,OAAO,QANGA,IAAAA,KAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonAnnotator.tsx"],"sourcesContent":["import { createContext, ReactNode, useContext, useEffect, useState } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { createOSDAnnotator } from '@annotorious/openseadragon';\nimport { AnnotoriousOpts, DrawingStyle, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from '../Annotorious';\n\nexport const OpenSeadragonAnnotatorContext = createContext<{ \n viewer: OpenSeadragon.Viewer,\n setViewer(viewer: OpenSeadragon.Viewer): void\n}>({ viewer: null, setViewer: null });\n\nexport type OpenSeadragonAnnotatorProps<E extends unknown> = AnnotoriousOpts<ImageAnnotation, E> & {\n\n children?: ReactNode;\n\n drawingEnabled?: boolean;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: string | null;\n\n}\n\nexport const OpenSeadragonAnnotator = <E extends unknown>(props: OpenSeadragonAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const [viewer, setViewer] = useState<OpenSeadragon.Viewer>();\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (viewer) {\n const anno = createOSDAnnotator<E>(viewer, opts);\n\n if (props.drawingEnabled !== undefined) anno.setDrawingEnabled(props.drawingEnabled);\n if (props.filter) anno.setFilter(props.filter);\n if (props.style) anno.setStyle(props.style);\n if (props.tool) anno.setDrawingTool(props.tool);\n\n setAnno(anno);\n\n return () => {\n anno.destroy();\n setAnno(undefined);\n }\n }\n }, [viewer]);\n\n useEffect(() => {\n if (anno) anno.setDrawingEnabled(props.drawingEnabled);\n }, [props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool);\n }, [tool]);\n\n return (\n <OpenSeadragonAnnotatorContext.Provider value={{ viewer, setViewer }}>\n {props.children}\n </OpenSeadragonAnnotatorContext.Provider>\n )\n\n}\n\nexport const useViewer = () => {\n const { viewer } = useContext(OpenSeadragonAnnotatorContext);\n return viewer;\n}"],"names":["OpenSeadragonAnnotatorContext","createContext","OpenSeadragonAnnotator","props","children","tool","opts","viewer","setViewer","useState","anno","setAnno","useContext","AnnotoriousContext","useEffect","createOSDAnnotator","jsx","useViewer"],"mappings":";;;;AAMO,MAAMA,IAAgCC,EAG1C,EAAE,QAAQ,MAAM,WAAW,MAAM,GAgBvBC,IAAyB,CAAoBC,MAA0C;AAElG,QAAM,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@
1
- import n from "./annotorious-react.es30.js";
2
- const d = (t, e, o, a) => ({
3
- id: n(),
4
- annotation: t.id,
5
- created: o || /* @__PURE__ */ new Date(),
6
- creator: a,
7
- ...e
8
- });
1
+ import { j as v } from "./annotorious-react.es13.js";
2
+ import { useRef as w, useState as d, useEffect as u } from "react";
3
+ import { Draggable as x } from "./annotorious-react.es4.js";
4
+ import { useViewer as S } from "./annotorious-react.es10.js";
5
+ import { useSelection as j } from "./annotorious-react.es2.js";
6
+ import { setPosition as D } from "./annotorious-react.es17.js";
7
+ const R = (c) => {
8
+ const n = w(null), o = S(), { selected: t } = j(), [l, m] = d([]), [s, i] = d(!1), f = () => i(!0), p = () => {
9
+ const e = t[0].annotation;
10
+ D(o, e, n.current);
11
+ }, g = (e, r) => e.every((a) => r.includes(a)) && r.every((a) => e.includes(a));
12
+ return u(() => {
13
+ const e = t.map(({ annotation: r }) => r.id);
14
+ g(l, e) || (i(!1), m(e));
15
+ }, [t]), u(() => {
16
+ if (!n.current)
17
+ return;
18
+ s || p();
19
+ const e = () => {
20
+ s || p();
21
+ };
22
+ return o.addHandler("update-viewport", e), () => {
23
+ o.removeHandler("update-viewport", e);
24
+ };
25
+ }, [t, s]), t.length > 0 ? /* @__PURE__ */ v.jsx(
26
+ x,
27
+ {
28
+ ref: n,
29
+ className: "a9s-popup a9s-osd-popup",
30
+ onDragStart: f,
31
+ children: c.popup({ viewer: o, selected: t })
32
+ },
33
+ t.map(({ annotation: e }) => e.id).join("-")
34
+ ) : null;
35
+ };
9
36
  export {
10
- d as createBody
37
+ R as OpenSeadragonPopup
11
38
  };
12
39
  //# sourceMappingURL=annotorious-react.es11.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es11.js","sources":["../../annotorious-core/src/utils/annotationUtils.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport type { Annotation, AnnotationBody, User } from '../model';\n\n/**\n * Returns all users listed as creators or updaters in any parts of this\n * annotation.\n */\nexport const getContributors = (annotation: Annotation): User[] => {\n const { creator, updatedBy } = annotation.target;\n\n const bodyCollaborators = annotation.bodies.reduce((users, body) => (\n [...users, body.creator, body.updatedBy]\n ), [] as User[]);\n\n return [\n creator,\n updatedBy,\n ...bodyCollaborators\n ].filter(u => u); // Remove undefined\n}\n\nexport const createBody = (\n annotation: Annotation, \n payload: { [key: string]: any },\n created?: Date,\n creator?: User\n): AnnotationBody => ({\n id: uuidv4(),\n annotation: annotation.id,\n created: created || new Date(),\n creator,\n ...payload\n});"],"names":["createBody","annotation","payload","created","creator","uuidv4"],"mappings":";AAqBO,MAAMA,IAAa,CACxBC,GACAC,GACAC,GACAC,OACoB;AAAA,EACpB,IAAIC,EAAO;AAAA,EACX,YAAYJ,EAAW;AAAA,EACvB,SAASE,KAAW,oBAAI,KAAK;AAAA,EAC7B,SAAAC;AAAA,EACA,GAAGF;AACL;"}
1
+ {"version":3,"file":"annotorious-react.es11.js","sources":["../src/openseadragon/OpenSeadragonPopup.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport OpenSeadragon from 'openseadragon';\nimport { AnnotoriousPopupProps, Draggable } from '../AnnotoriousPopup';\nimport { useViewer } from './OpenSeadragonAnnotator';\nimport { useSelection } from '../Annotorious';\nimport { setPosition } from './setPosition';\n\nexport type OpenSeadragonPopupProps = AnnotoriousPopupProps & {\n\n viewer: OpenSeadragon.Viewer\n\n}\n\nexport type OpenSeadragonPopupContainerProps = {\n\n popup(props: OpenSeadragonPopupProps): ReactNode\n\n}\n\nexport const OpenSeadragonPopup = (props: OpenSeadragonPopupContainerProps) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const viewer = useViewer();\n\n const { selected } = useSelection<ImageAnnotation>();\n\n const [selectedIds, setSelectedIds] = useState<string[]>([]);\n\n const [dragged, setDragged] = useState(false);\n\n const onDragStart = () => setDragged(true);\n\n const updatePosition = () => {\n // Note: this popup only supports a single selection\n const annotation = selected[0].annotation;\n setPosition(viewer, annotation, el.current);\n }\n\n const equal = (a: string[], b: string[]) => \n a.every(str => b.includes(str)) && b.every(str => a.includes(str));\n\n useEffect(() => {\n // Reset drag flag if selected IDs have changed\n const nextIds = selected.map(({ annotation }) => annotation.id);\n\n if (!equal(selectedIds, nextIds)) {\n setDragged(false);\n setSelectedIds(nextIds);\n }\n }, [selected]);\n\n useEffect(() => {\n if (!el.current) return;\n\n if (!dragged) updatePosition();\n\n const onUpdateViewport = () => {\n if (!dragged) updatePosition();\n }\n\n viewer.addHandler('update-viewport', onUpdateViewport);\n\n return () => {\n viewer.removeHandler('update-viewport', onUpdateViewport);\n }\n }, [selected, dragged]);\n \n return selected.length > 0 ? (\n <Draggable \n ref={el} \n key={selected.map(({ annotation }) => annotation.id).join('-')} \n className=\"a9s-popup a9s-osd-popup\" \n onDragStart={onDragStart}>\n\n {props.popup({ viewer, selected })}\n \n </Draggable>\n ) : null;\n\n}"],"names":["OpenSeadragonPopup","props","el","useRef","viewer","useViewer","selected","useSelection","selectedIds","setSelectedIds","useState","dragged","setDragged","onDragStart","updatePosition","annotation","setPosition","equal","a","b","str","useEffect","nextIds","onUpdateViewport","jsx","Draggable"],"mappings":";;;;;;AAoBa,MAAAA,IAAqB,CAACC,MAA4C;AAEvE,QAAAC,IAAKC,EAAuB,IAAI,GAEhCC,IAASC,KAET,EAAE,UAAAC,MAAaC,KAEf,CAACC,GAAaC,CAAc,IAAIC,EAAmB,CAAE,CAAA,GAErD,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAK,GAEtCG,IAAc,MAAMD,EAAW,EAAI,GAEnCE,IAAiB,MAAM;AAErB,UAAAC,IAAaT,EAAS,CAAC,EAAE;AACnB,IAAAU,EAAAZ,GAAQW,GAAYb,EAAG,OAAO;AAAA,EAAA,GAGtCe,IAAQ,CAACC,GAAaC,MAC1BD,EAAE,MAAM,OAAOC,EAAE,SAASC,CAAG,CAAC,KAAKD,EAAE,MAAM,OAAOD,EAAE,SAASE,CAAG,CAAC;AAEnE,SAAAC,EAAU,MAAM;AAER,UAAAC,IAAUhB,EAAS,IAAI,CAAC,EAAE,YAAAS,QAAiBA,EAAW,EAAE;AAE9D,IAAKE,EAAMT,GAAac,CAAO,MAC7BV,EAAW,EAAK,GAChBH,EAAea,CAAO;AAAA,EACxB,GACC,CAAChB,CAAQ,CAAC,GAEbe,EAAU,MAAM;AACd,QAAI,CAACnB,EAAG;AAAS;AAEjB,IAAKS,KAAwBG;AAE7B,UAAMS,IAAmB,MAAM;AAC7B,MAAKZ,KAAwBG;IAAA;AAGxB,WAAAV,EAAA,WAAW,mBAAmBmB,CAAgB,GAE9C,MAAM;AACJ,MAAAnB,EAAA,cAAc,mBAAmBmB,CAAgB;AAAA,IAAA;AAAA,EAC1D,GACC,CAACjB,GAAUK,CAAO,CAAC,GAEfL,EAAS,SAAS,IACvBkB,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAKvB;AAAA,MAEL,WAAU;AAAA,MACV,aAAAW;AAAA,MAEC,UAAMZ,EAAA,MAAM,EAAE,QAAAG,GAAQ,UAAAE,GAAU;AAAA,IAAA;AAAA,IAJ5BA,EAAS,IAAI,CAAC,EAAE,YAAAS,EAAA,MAAiBA,EAAW,EAAE,EAAE,KAAK,GAAG;AAAA,EAO7D,IAAA;AAEN;"}
@@ -1,5 +1,19 @@
1
- var L = /* @__PURE__ */ ((E) => (E.LOCAL = "LOCAL", E.REMOTE = "REMOTE", E))(L || {});
1
+ import { j as m } from "./annotorious-react.es13.js";
2
+ import { forwardRef as a, useRef as u, useContext as p, useEffect as c, useImperativeHandle as d } from "react";
3
+ import l from "openseadragon";
4
+ import { OpenSeadragonAnnotatorContext as x } from "./annotorious-react.es10.js";
5
+ const O = a((n, s) => {
6
+ const { className: i, options: t } = n, r = u(null), { viewer: f, setViewer: e } = p(x);
7
+ return c(() => {
8
+ if (r.current) {
9
+ const o = l({ ...t, element: r.current });
10
+ return e && e(o), () => {
11
+ o.destroy(), e && e(void 0);
12
+ };
13
+ }
14
+ }, [JSON.stringify(t)]), d(s, () => f), /* @__PURE__ */ m.jsx("div", { className: i, ref: r });
15
+ });
2
16
  export {
3
- L as Origin
17
+ O as OpenSeadragonViewer
4
18
  };
5
19
  //# sourceMappingURL=annotorious-react.es12.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es12.js","sources":["../../annotorious-core/src/state/StoreObserver.ts"],"sourcesContent":["import type { Annotation, AnnotationBody, AnnotationTarget } from '../model';\n\n/** Interface for listening to changes in the annotation store **/\nexport interface StoreObserver<T extends Annotation> { \n\n onChange: { (event: StoreChangeEvent<T>): void };\n\n options: StoreObserveOptions;\n\n}\n\n/** A change event fired when the store state changes **/\nexport interface StoreChangeEvent<T extends Annotation> {\n\n origin: Origin;\n\n changes: ChangeSet<T>;\n\n state: T[];\n\n}\n\nexport interface ChangeSet<T extends Annotation> {\n\n created?: T[];\n\n deleted?: T[];\n\n updated?: Update<T>[];\n\n}\n\nexport interface Update<T extends Annotation> {\n\n oldValue: T;\n\n newValue: T;\n\n bodiesCreated?: AnnotationBody[];\n\n bodiesDeleted?: AnnotationBody[];\n\n bodiesUpdated?: Array<{ oldBody: AnnotationBody, newBody: AnnotationBody }>;\n\n targetUpdated?: { oldTarget: AnnotationTarget, newTarget: AnnotationTarget};\n\n}\n\n/** Options to control which events the observer wants to get notified about **/\nexport interface StoreObserveOptions {\n\n // Observe changes on targets, bodies or both?\n ignore?: Ignore;\n\n // Observe changes on one more specific annotations\n annotations?: string | string[];\n\n // Observer changes only for a specific origin\n origin?: Origin\n\n}\n\n/** Allows the observer to ignore certain event types **/\nexport enum Ignore { \n\n // Don't notify this observer for changes that involve bodies only\n BODY_ONLY = 'BODY_ONLY',\n\n // Don't notify for changes on targets only\n TARGET_ONLY = 'TARGET_ONLY'\n\n}\n\n/** Allows the observer to listen only for events that originated locally or from a remote source **/\nexport enum Origin { \n \n LOCAL = 'LOCAL', \n \n REMOTE = 'REMOTE' \n\n}\n\n/** Tests if this observer should be notified about this event **/\nexport const shouldNotify = <T extends Annotation>(observer: StoreObserver<T>, event: StoreChangeEvent<T>) => {\n const { changes, origin } = event;\n\n const isRelevantOrigin = \n !observer.options.origin || observer.options.origin === origin;\n\n if (!isRelevantOrigin)\n return false;\n\n if (observer.options.ignore) {\n const { ignore } = observer.options;\n\n // Shorthand\n const has = (arg: any[]) => arg?.length > 0;\n\n const hasAnnotationChanges =\n has(changes.created) || has(changes.deleted);\n\n if (!hasAnnotationChanges) {\n const hasBodyChanges =\n changes.updated?.some(u => has(u.bodiesCreated) || has(u.bodiesDeleted) || has(u.bodiesUpdated));\n \n const hasTargetChanges = \n changes.updated?.some(u => u.targetUpdated);\n\n if (ignore === Ignore.BODY_ONLY && hasBodyChanges && !hasTargetChanges)\n return false;\n\n if (ignore === Ignore.TARGET_ONLY && hasTargetChanges && !hasBodyChanges)\n return false;\n }\n }\n\n if (observer.options.annotations) {\n // This observer has a filter set on specific annotations - check affected\n const affectedAnnotations = new Set([\n ...changes.created.map(a => a.id),\n ...changes.deleted.map(a => a.id),\n ...changes.updated.map(({ oldValue }) => oldValue.id)\n ]);\n\n const observed = Array.isArray(observer.options.annotations) ?\n observer.options.annotations : [ observer.options.annotations ];\n\n return Boolean(observed.find(id => affectedAnnotations.has(id)));\n } else {\n return true;\n }\n\n}\n\nexport const mergeChanges = <T extends Annotation>(event: StoreChangeEvent<T>, toMerge: StoreChangeEvent<T>) => {\n if (event.origin !== toMerge.origin)\n throw 'Cannot merge events from different origins';\n\n return {\n origin: toMerge.origin,\n changes: {\n // TODO filter created that were deleted in the same go\n created: [...(event.changes.created || []), ...(toMerge.changes.created || []) ],\n deleted: [...(event.changes.deleted || []), ...(toMerge.changes.deleted || []) ] \n // TODO merge updates\n },\n state: toMerge.state\n }\n}"],"names":["Origin"],"mappings":"AA0EY,IAAAA,sBAAAA,OAEVA,EAAA,QAAQ,SAERA,EAAA,SAAS,UAJCA,IAAAA,KAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"annotorious-react.es12.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n useEffect(() => { \n if (element.current) {\n const v = OpenSeadragon({...options, element: element.current });\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n v.destroy();\n\n if (setViewer) \n setViewer(undefined);\n }\n }\n }, [JSON.stringify(options)]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAY,IAAAH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,EAAU,IAAIC,EAAWC,CAA6B;AAEtE,SAAAC,EAAU,MAAM;AACd,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACX,QAAAA,EAAE,QAAQ,GAENJ,KACFA,EAAU,MAAS;AAAA,MAAA;AAAA,IAEzB;AAAA,KACC,CAAC,KAAK,UAAUJ,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlCQ,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}