@annotorious/react 3.0.0-rc.3 → 3.0.0-rc.30

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 (98) hide show
  1. package/dist/Annotorious.d.ts +8 -32
  2. package/dist/Annotorious.d.ts.map +1 -1
  3. package/dist/AnnotoriousPlugin.d.ts +8 -6
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -1
  5. package/dist/AnnotoriousPopup.d.ts +2 -1
  6. package/dist/ImageAnnotator.d.ts +2 -2
  7. package/dist/ImageAnnotator.d.ts.map +1 -1
  8. package/dist/annotorious-react.css +1 -1
  9. package/dist/annotorious-react.es.js +35 -52
  10. package/dist/annotorious-react.es.js.map +1 -1
  11. package/dist/annotorious-react.es10.js +16 -3
  12. package/dist/annotorious-react.es10.js.map +1 -1
  13. package/dist/annotorious-react.es11.js +6 -27
  14. package/dist/annotorious-react.es11.js.map +1 -1
  15. package/dist/annotorious-react.es12.js +7 -19
  16. package/dist/annotorious-react.es12.js.map +1 -1
  17. package/dist/annotorious-react.es13.js +131 -51
  18. package/dist/annotorious-react.es13.js.map +1 -1
  19. package/dist/annotorious-react.es14.js +32 -17
  20. package/dist/annotorious-react.es14.js.map +1 -1
  21. package/dist/annotorious-react.es15.js +2 -22
  22. package/dist/annotorious-react.es15.js.map +1 -1
  23. package/dist/annotorious-react.es16.js +26 -2
  24. package/dist/annotorious-react.es16.js.map +1 -1
  25. package/dist/annotorious-react.es17.js +606 -2
  26. package/dist/annotorious-react.es17.js.map +1 -1
  27. package/dist/annotorious-react.es18.js +2 -3859
  28. package/dist/annotorious-react.es18.js.map +1 -1
  29. package/dist/annotorious-react.es19.js +2 -29
  30. package/dist/annotorious-react.es19.js.map +1 -1
  31. package/dist/annotorious-react.es2.js +32 -32
  32. package/dist/annotorious-react.es2.js.map +1 -1
  33. package/dist/annotorious-react.es3.js +6 -7
  34. package/dist/annotorious-react.es3.js.map +1 -1
  35. package/dist/annotorious-react.es4.js +8 -8
  36. package/dist/annotorious-react.es4.js.map +1 -1
  37. package/dist/annotorious-react.es5.js +10 -10
  38. package/dist/annotorious-react.es5.js.map +1 -1
  39. package/dist/annotorious-react.es8.js +27 -47
  40. package/dist/annotorious-react.es8.js.map +1 -1
  41. package/dist/annotorious-react.es9.js +35 -12
  42. package/dist/annotorious-react.es9.js.map +1 -1
  43. package/dist/index.d.ts +10 -10
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +3 -2
  46. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  47. package/dist/openseadragon/OpenSeadragonPopup.d.ts +2 -1
  48. package/dist/openseadragon/OpenSeadragonViewer.d.ts +3 -3
  49. package/dist/openseadragon/OpenSeadragonViewer.d.ts.map +1 -1
  50. package/dist/openseadragon/setPosition.d.ts +2 -1
  51. package/dist/openseadragon/setPosition.d.ts.map +1 -1
  52. package/package.json +18 -10
  53. package/dist/annotorious-react.es20.js +0 -39
  54. package/dist/annotorious-react.es20.js.map +0 -1
  55. package/dist/annotorious-react.es21.js +0 -19
  56. package/dist/annotorious-react.es21.js.map +0 -1
  57. package/dist/annotorious-react.es22.js +0 -7
  58. package/dist/annotorious-react.es22.js.map +0 -1
  59. package/dist/annotorious-react.es23.js +0 -11
  60. package/dist/annotorious-react.es23.js.map +0 -1
  61. package/dist/annotorious-react.es24.js +0 -156
  62. package/dist/annotorious-react.es24.js.map +0 -1
  63. package/dist/annotorious-react.es25.js +0 -9
  64. package/dist/annotorious-react.es25.js.map +0 -1
  65. package/dist/annotorious-react.es26.js +0 -20665
  66. package/dist/annotorious-react.es26.js.map +0 -1
  67. package/dist/annotorious-react.es27.js +0 -35
  68. package/dist/annotorious-react.es27.js.map +0 -1
  69. package/dist/annotorious-react.es28.js +0 -5
  70. package/dist/annotorious-react.es28.js.map +0 -1
  71. package/dist/annotorious-react.es29.js +0 -33
  72. package/dist/annotorious-react.es29.js.map +0 -1
  73. package/dist/annotorious-react.es30.js +0 -602
  74. package/dist/annotorious-react.es30.js.map +0 -1
  75. package/dist/annotorious-react.es31.js +0 -5
  76. package/dist/annotorious-react.es31.js.map +0 -1
  77. package/dist/annotorious-react.es32.js +0 -5
  78. package/dist/annotorious-react.es32.js.map +0 -1
  79. package/dist/annotorious-react.es33.js +0 -20
  80. package/dist/annotorious-react.es33.js.map +0 -1
  81. package/dist/annotorious-react.es34.js +0 -30
  82. package/dist/annotorious-react.es34.js.map +0 -1
  83. package/dist/annotorious-react.es35.js +0 -19
  84. package/dist/annotorious-react.es35.js.map +0 -1
  85. package/dist/annotorious-react.es36.js +0 -24
  86. package/dist/annotorious-react.es36.js.map +0 -1
  87. package/dist/annotorious-react.es37.js +0 -19
  88. package/dist/annotorious-react.es37.js.map +0 -1
  89. package/dist/annotorious-react.es38.js +0 -7
  90. package/dist/annotorious-react.es38.js.map +0 -1
  91. package/dist/annotorious-react.es39.js +0 -11
  92. package/dist/annotorious-react.es39.js.map +0 -1
  93. package/dist/annotorious-react.es40.js +0 -10
  94. package/dist/annotorious-react.es40.js.map +0 -1
  95. package/dist/annotorious-react.es6.js +0 -5
  96. package/dist/annotorious-react.es6.js.map +0 -1
  97. package/dist/annotorious-react.es7.js +0 -5
  98. package/dist/annotorious-react.es7.js.map +0 -1
@@ -1,32 +1,5 @@
1
- import { jsx as d } from "./annotorious-react.es22.js";
2
- import { createContext as u, useState as w, useContext as l, useEffect as n } from "react";
3
- import { createOSDAnnotator as m } from "./annotorious-react.es26.js";
4
- import { AnnotoriousContext as g } from "./annotorious-react.es2.js";
5
- const s = u({ viewer: null, setViewer: null }), y = (e) => {
6
- const { children: v, tool: i, ...c } = e, [o, f] = w(), { anno: t, setAnno: a } = l(g);
7
- return n(() => {
8
- if (o) {
9
- const r = m(o, c);
10
- return e.tool && r.setDrawingTool(e.tool), a(r), () => {
11
- r.destroy(), a(void 0);
12
- };
13
- }
14
- }, [o]), n(() => {
15
- t && t.setDrawingTool(i);
16
- }, [i]), n(() => {
17
- t && t.setDrawingEnabled(e.drawingEnabled);
18
- }, [e.drawingEnabled]), n(() => {
19
- t && t.setFilter(e.filter);
20
- }, [e.filter]), n(() => {
21
- t && t.setStyle(e.style);
22
- }, [e.style]), /* @__PURE__ */ d(s.Provider, { value: { viewer: o, setViewer: f }, children: e.children });
23
- }, C = () => {
24
- const { viewer: e } = l(s);
25
- return e;
26
- };
1
+ var e = {};
27
2
  export {
28
- y as OpenSeadragonAnnotator,
29
- s as OpenSeadragonAnnotatorContext,
30
- C as useViewer
3
+ e as __exports
31
4
  };
32
5
  //# sourceMappingURL=annotorious-react.es19.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es19.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.tool)\n 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.setDrawingTool(tool);\n }, [tool]);\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 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,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9B,CAACI,GAAQC,CAAS,IAAIC,EAA+B,GAErD,EAAE,MAAAC,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB;AAEvD,SAAAC,EAAU,MAAM;AACd,QAAIP,GAAQ;AACJG,YAAAA,IAAOK,EAAsBR,GAAQD,CAAI;AAE/C,aAAIH,EAAM,QACRO,EAAK,eAAeP,EAAM,IAAI,GAEhCQ,EAAQD,CAAI,GAEL,MAAM;AACXA,QAAAA,EAAK,QAAQ,GACbC,EAAQ,MAAS;AAAA,MAAA;AAAA,IAErB;AAAA,EAAA,GACC,CAACJ,CAAM,CAAC,GAEXO,EAAU,MAAM;AACV,IAAAJ,KAAMA,EAAK,eAAeL,CAAI;AAAA,EAAA,GACjC,CAACA,CAAI,CAAC,GAETS,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,kBAAkBP,EAAM,cAAc;AAAA,EAAA,GACpD,CAACA,EAAM,cAAc,CAAC,GAEzBW,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,UAAUP,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBW,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,SAASP,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,GAGd,gBAAAa,EAAChB,EAA8B,UAA9B,EAAuC,OAAO,EAAE,QAAAO,GAAQ,WAAAC,EACtD,GAAA,UAAAL,EAAM,SACT,CAAA;AAGJ,GAEac,IAAY,MAAM;AAC7B,QAAM,EAAE,QAAAV,EAAA,IAAWK,EAAWZ,CAA6B;AACpD,SAAAO;AACT;"}
1
+ {"version":3,"file":"annotorious-react.es19.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,42 +1,42 @@
1
- import { jsx as U } from "./annotorious-react.es22.js";
2
- import { createContext as j, forwardRef as E, useState as f, useImperativeHandle as H, useEffect as h, useContext as c } from "react";
3
- import { useDebounce as C } from "./annotorious-react.es23.js";
4
- const o = j({
1
+ import { j as I } from "./annotorious-react.es11.js";
2
+ import { createContext as O, forwardRef as R, useState as f, useImperativeHandle as U, useEffect as h, useContext as c } from "react";
3
+ import { useDebounce as C } from "./annotorious-react.es12.js";
4
+ const o = O({
5
5
  anno: void 0,
6
6
  setAnno: void 0,
7
7
  annotations: [],
8
8
  selection: { selected: [] }
9
- }), B = E((t, s) => {
10
- const [n, u] = f(null), [p, r] = f([]), [A, l] = f({ selected: [] });
11
- return H(s, () => n), h(() => {
9
+ }), B = R((t, s) => {
10
+ const [n, a] = f(null), [p, r] = f([]), [m, u] = f({ selected: [] });
11
+ return U(s, () => n), h(() => {
12
12
  if (n) {
13
- const { selection: m, store: e } = n.state;
13
+ const { selection: A, store: e } = n.state;
14
14
  e.all().length > 0 && r(e.all());
15
- const v = (a) => r(() => e.all());
15
+ const v = () => r(() => e.all());
16
16
  e.observe(v);
17
17
  let i;
18
- const b = m.subscribe(({ selected: a, pointerEvent: w }) => {
18
+ const b = A.subscribe(({ selected: l, pointerEvent: w }) => {
19
19
  i && e.unobserve(i);
20
- const D = (a || []).map(({ id: d, editable: S }) => ({ annotation: e.getAnnotation(d), editable: S }));
21
- l({ selected: D, pointerEvent: w }), i = (d) => {
20
+ const j = (l || []).map(({ id: d, editable: S }) => ({ annotation: e.getAnnotation(d), editable: S }));
21
+ u({ selected: j, pointerEvent: w }), i = (d) => {
22
22
  const { updated: S } = d.changes;
23
- l(({ selected: I }) => ({
24
- selected: I.map(({ annotation: V, editable: g }) => {
25
- const x = S.find((O) => O.oldValue.id === V.id);
26
- return x ? { annotation: x.newValue, editable: g } : { annotation: V, editable: g };
23
+ u(({ selected: D }) => ({
24
+ selected: D.map(({ annotation: V, editable: x }) => {
25
+ const g = S.find((E) => E.oldValue.id === V.id);
26
+ return g ? { annotation: g.newValue, editable: x } : { annotation: V, editable: x };
27
27
  })
28
28
  }));
29
- }, e.observe(i, { annotations: a.map(({ id: d }) => d) });
29
+ }, e.observe(i, { annotations: l.map(({ id: d }) => d) });
30
30
  });
31
31
  return () => {
32
32
  e.unobserve(v), b();
33
33
  };
34
34
  }
35
- }, [n]), /* @__PURE__ */ U(o.Provider, { value: {
35
+ }, [n]), /* @__PURE__ */ I.jsx(o.Provider, { value: {
36
36
  anno: n,
37
- setAnno: u,
37
+ setAnno: a,
38
38
  annotations: p,
39
- selection: A
39
+ selection: m
40
40
  }, children: t.children });
41
41
  }), F = () => {
42
42
  const { anno: t } = c(o);
@@ -44,13 +44,13 @@ const o = j({
44
44
  }, G = () => {
45
45
  const { anno: t } = c(o);
46
46
  return t == null ? void 0 : t.state.store;
47
- }, P = () => {
47
+ }, H = () => {
48
48
  const { annotations: t } = c(o);
49
49
  return t;
50
- }, R = (t) => {
50
+ }, P = (t) => {
51
51
  const { annotations: s } = c(o);
52
52
  return C(s, t);
53
- }, J = (t) => t ? R(t) : P(), K = () => {
53
+ }, J = (t) => t ? P(t) : H(), K = () => {
54
54
  const { selection: t } = c(o);
55
55
  return t;
56
56
  }, L = () => {
@@ -60,23 +60,23 @@ const o = j({
60
60
  const { anno: t } = c(o), [s, n] = f([]);
61
61
  return h(() => {
62
62
  if (t) {
63
- const { store: u, viewport: p } = t.state;
63
+ const { store: a, viewport: p } = t.state;
64
64
  if (!p)
65
65
  return;
66
66
  let r;
67
- const A = p.subscribe((l) => {
68
- r && u.unobserve(r);
69
- const m = l.map((e) => u.getAnnotation(e));
70
- n(m), r = (e) => {
67
+ const m = p.subscribe((u) => {
68
+ r && a.unobserve(r);
69
+ const A = u.map((e) => a.getAnnotation(e));
70
+ n(A), r = (e) => {
71
71
  const { updated: v } = e.changes;
72
72
  n((i) => i.map((b) => {
73
- const a = v.find((w) => w.oldValue.id === b.id);
74
- return a ? a.newValue : b;
73
+ const l = v.find((w) => w.oldValue.id === b.id);
74
+ return l ? l.newValue : b;
75
75
  }));
76
- }, u.observe(r, { annotations: l });
76
+ }, a.observe(r, { annotations: u });
77
77
  });
78
78
  return () => {
79
- A();
79
+ m();
80
80
  };
81
81
  }
82
82
  }, [t]), s;
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es2.js","sources":["../src/Annotorious.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode} from 'react';\nimport { useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport { Annotation, Annotator, Store, StoreChangeEvent } from '@annotorious/core';\nimport { useDebounce } from './useDebounce';\n\ninterface Selection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean }[];\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport interface AnnotoriousContextState {\n\n anno: Annotator;\n\n setAnno(anno: Annotator<Annotation, unknown>): void;\n\n annotations: Annotation[];\n\n selection: Selection;\n\n}\n\nexport const AnnotoriousContext = createContext({ \n\n anno: undefined, \n\n setAnno: undefined, \n\n annotations: [], \n\n selection: { selected: [] }\n\n});\n\nexport const Annotorious = forwardRef<Annotator, { children: ReactNode }>((props: { children: ReactNode }, ref) => {\n\n const [anno, setAnno] = useState<Annotator>(null);\n\n const [annotations, setAnnotations] = useState<Annotation[]>([]);\n\n const [selection, setSelection] = useState<Selection>({ selected: [] });\n\n useImperativeHandle(ref, () => anno);\n\n useEffect(() => {\n if (anno) {\n const { selection, store } = anno.state;\n\n // Components below <Annotorious /> may have\n // loaded annotations into the store already! \n if (store.all().length > 0)\n setAnnotations(store.all());\n\n // Keeps annotations in sync with a React state,\n // so clients can render components the usual React way.\n const onStoreChange = (event: StoreChangeEvent<Annotation>) =>\n setAnnotations(() => store.all());\n\n store.observe(onStoreChange);\n\n // Keep selection in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selection.subscribe(({ selected, pointerEvent }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n setSelection({ selected: resolved, pointerEvent });\n\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ selected }) => ({\n selected: selected.map(({ annotation, editable }) => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? { annotation: next.newValue, editable } : { annotation, editable };\n })\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n return () => {\n store.unobserve(onStoreChange);\n unsubscribeSelection();\n }\n }\n }, [anno]);\n\n return (\n <AnnotoriousContext.Provider value={{ \n anno, \n setAnno,\n annotations, \n selection \n }}>\n {props.children}\n </AnnotoriousContext.Provider>\n )\n\n});\n\nexport const useAnnotator = <T extends Annotator<any, unknown>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno as T;\n}\n\nexport const useAnnotationStore = <T extends Store<Annotation>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.state.store as T | undefined;\n}\n\nconst _useAnnotations = <T extends Annotation>() => {\n const { annotations } = useContext(AnnotoriousContext);\n return annotations as T[];\n}\n\nconst _useAnnotationsDebouced = <T extends Annotation>(debounce: number) => {\n const { annotations } = useContext(AnnotoriousContext);\n return useDebounce(annotations, debounce) as T[];\n}\n\nexport const useAnnotations = <T extends Annotation>(debounce?: number) =>\n debounce ? _useAnnotationsDebouced<T>(debounce) : _useAnnotations<T>();\n\nexport const useSelection = <T extends Annotation>() => {\n const { selection } = useContext(AnnotoriousContext);\n return selection as Selection<T>;\n}\n\nexport const useAnnotatorUser = () => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.getUser();\n}\n\nconst _useViewportState = <T extends Annotation>() => {\n const { anno } = useContext(AnnotoriousContext);\n\n const [inViewport, setInViewport] = useState<T[]>([]);\n\n useEffect(() => {\n if (anno) {\n const { store, viewport} = anno.state;\n\n if (!viewport)\n return;\n\n // Keep viewport annotations in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let viewportStoreObserver: (event: StoreChangeEvent<T>) => void;\n\n const unsubscribeViewport = viewport.subscribe(ids => {\n if (viewportStoreObserver) \n store.unobserve(viewportStoreObserver);\n\n const resolved = ids.map(id => store.getAnnotation(id)) as T[];\n setInViewport(resolved);\n\n viewportStoreObserver = event => {\n const { updated } = event.changes;\n\n setInViewport(annotations => annotations.map(annotation => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? next.newValue : annotation;\n }));\n }\n\n store.observe(viewportStoreObserver, { annotations: ids });\n });\n\n return () => {\n unsubscribeViewport();\n }\n }\n }, [anno]);\n\n return inViewport;\n}\n\nconst _useViewportStateDebounced = <T extends Annotation>(debounce: number) => {\n const inViewport = _useViewportState();\n return useDebounce(inViewport, debounce) as T[];\n}\n\nexport const useViewportState = <T extends Annotation>(debounce?: number) =>\n debounce ? _useViewportStateDebounced<T>(debounce) : _useViewportState<T>();\n"],"names":["AnnotoriousContext","createContext","Annotorious","forwardRef","props","ref","anno","setAnno","useState","annotations","setAnnotations","selection","setSelection","useImperativeHandle","useEffect","store","onStoreChange","event","selectionStoreObserver","unsubscribeSelection","selected","pointerEvent","resolved","id","editable","updated","annotation","next","u","jsx","useAnnotator","useContext","useAnnotationStore","_useAnnotations","_useAnnotationsDebouced","debounce","useDebounce","useAnnotations","useSelection","useAnnotatorUser","_useViewportState","inViewport","setInViewport","viewport","viewportStoreObserver","unsubscribeViewport","ids","_useViewportStateDebounced","useViewportState"],"mappings":";;;AAyBO,MAAMA,IAAqBC,EAAc;AAAA,EAE9C,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,aAAa,CAAC;AAAA,EAEd,WAAW,EAAE,UAAU,GAAG;AAE5B,CAAC,GAEYC,IAAcC,EAA+C,CAACC,GAAgCC,MAAQ;AAEjH,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAoB,IAAI,GAE1C,CAACC,GAAaC,CAAc,IAAIF,EAAuB,CAAE,CAAA,GAEzD,CAACG,GAAWC,CAAY,IAAIJ,EAAoB,EAAE,UAAU,CAAC,EAAA,CAAG;AAElD,SAAAK,EAAAR,GAAK,MAAMC,CAAI,GAEnCQ,EAAU,MAAM;AACd,QAAIR,GAAM;AACR,YAAM,EAAE,WAAAK,GAAW,OAAAI,EAAA,IAAUT,EAAK;AAI9B,MAAAS,EAAM,MAAM,SAAS,KACRL,EAAAK,EAAM,KAAK;AAI5B,YAAMC,IAAgB,CAACC,MACrBP,EAAe,MAAMK,EAAM,KAAK;AAElC,MAAAA,EAAM,QAAQC,CAAa;AAIvB,UAAAE;AAEJ,YAAMC,IAAuBR,EAAU,UAAU,CAAC,EAAE,UAAAS,GAAU,cAAAC,QAAmB;AAC3E,QAAAH,KACFH,EAAM,UAAUG,CAAsB;AAExC,cAAMI,KAAYF,KAAY,CAC3B,GAAA,IAAI,CAAC,EAAE,IAAAG,GAAI,UAAAC,EAAS,OAAO,EAAE,YAAYT,EAAM,cAAcQ,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ED,aAAO,MAAM;AACS,QAAAD;MAAA;AAAA,IAExB;AAAA,EAAA,GACC,CAACvC,CAAI,CAAC,GAEFmC;AACT,GAEMM,IAA8B,CAAuBZ,MAAqB;AAC9E,QAAMM,IAAaD;AACZ,SAAAJ,EAAYK,GAAYN,CAAQ;AACzC,GAEaa,IAAoB,CAAuBb,MACtDA,IAAWY,EAA8BZ,CAAQ,IAAIK,EAAqB;"}
1
+ {"version":3,"file":"annotorious-react.es2.js","sources":["../src/Annotorious.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode} from 'react';\nimport { useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport { Annotation, Annotator, Store, StoreChangeEvent, User } from '@annotorious/annotorious';\nimport { useDebounce } from './useDebounce';\n\ninterface Selection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean }[];\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport interface AnnotoriousContextState {\n\n anno: Annotator;\n\n setAnno(anno: Annotator<Annotation, unknown>): void;\n\n annotations: Annotation[];\n\n selection: Selection;\n\n}\n\nexport const AnnotoriousContext = createContext({ \n\n anno: undefined, \n\n setAnno: undefined, \n\n annotations: [], \n\n selection: { selected: [] }\n\n});\n\nexport const Annotorious = forwardRef<Annotator, { children: ReactNode }>((props: { children: ReactNode }, ref) => {\n\n const [anno, setAnno] = useState<Annotator>(null);\n\n const [annotations, setAnnotations] = useState<Annotation[]>([]);\n\n const [selection, setSelection] = useState<Selection>({ selected: [] });\n\n useImperativeHandle(ref, () => anno);\n\n useEffect(() => {\n if (anno) {\n const { selection, store } = anno.state;\n\n // Components below <Annotorious /> may have\n // loaded annotations into the store already! \n if (store.all().length > 0)\n setAnnotations(store.all());\n\n // Keeps annotations in sync with a React state,\n // so clients can render components the usual React way.\n const onStoreChange = () => setAnnotations(() => store.all());\n\n store.observe(onStoreChange);\n\n // Keep selection in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selection.subscribe(({ selected, pointerEvent }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n setSelection({ selected: resolved, pointerEvent });\n\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ selected }) => ({\n selected: selected.map(({ annotation, editable }) => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? { annotation: next.newValue, editable } : { annotation, editable };\n })\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n return () => {\n store.unobserve(onStoreChange);\n unsubscribeSelection();\n }\n }\n }, [anno]);\n\n return (\n <AnnotoriousContext.Provider value={{ \n anno, \n setAnno,\n annotations, \n selection \n }}>\n {props.children}\n </AnnotoriousContext.Provider>\n )\n\n});\n\nexport const useAnnotator = <T extends unknown = Annotator<any, unknown>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno as T;\n}\n\nexport const useAnnotationStore = <T extends unknown = Store<Annotation>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.state.store as T | undefined;\n}\n\nconst _useAnnotations = <T extends Annotation>() => {\n const { annotations } = useContext(AnnotoriousContext);\n return annotations as T[];\n}\n\nconst _useAnnotationsDebounced = <T extends Annotation>(debounce: number) => {\n const { annotations } = useContext(AnnotoriousContext);\n return useDebounce(annotations, debounce) as T[];\n}\n\nexport const useAnnotations = <T extends Annotation>(debounce?: number) =>\n debounce ? _useAnnotationsDebounced<T>(debounce) : _useAnnotations<T>();\n\nexport const useSelection = <T extends Annotation>() => {\n const { selection } = useContext(AnnotoriousContext);\n return selection as Selection<T>;\n}\n\nexport const useAnnotatorUser = (): User => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.getUser();\n}\n\nconst _useViewportState = <T extends Annotation>() => {\n const { anno } = useContext(AnnotoriousContext);\n\n const [inViewport, setInViewport] = useState<T[]>([]);\n\n useEffect(() => {\n if (anno) {\n const { store, viewport } = anno.state;\n\n if (!viewport)\n return;\n\n // Keep viewport annotations in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let viewportStoreObserver: (event: StoreChangeEvent<T>) => void;\n\n const unsubscribeViewport = viewport.subscribe(ids => {\n if (viewportStoreObserver) \n store.unobserve(viewportStoreObserver);\n\n const resolved = ids.map(id => store.getAnnotation(id)) as T[];\n setInViewport(resolved);\n\n viewportStoreObserver = event => {\n const { updated } = event.changes;\n\n setInViewport(annotations => annotations.map(annotation => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? next.newValue : annotation;\n }));\n }\n\n store.observe(viewportStoreObserver, { annotations: ids });\n });\n\n return () => {\n unsubscribeViewport();\n }\n }\n }, [anno]);\n\n return inViewport;\n}\n\nconst _useViewportStateDebounced = <T extends Annotation>(debounce: number) => {\n const inViewport = _useViewportState();\n return useDebounce(inViewport, debounce) as T[];\n}\n\nexport const useViewportState = <T extends Annotation>(debounce?: number) =>\n debounce ? _useViewportStateDebounced<T>(debounce) : _useViewportState<T>();\n"],"names":["AnnotoriousContext","createContext","Annotorious","forwardRef","props","ref","anno","setAnno","useState","annotations","setAnnotations","selection","setSelection","useImperativeHandle","useEffect","store","onStoreChange","selectionStoreObserver","unsubscribeSelection","selected","pointerEvent","resolved","id","editable","event","updated","annotation","next","u","jsx","useAnnotator","useContext","useAnnotationStore","_useAnnotations","_useAnnotationsDebounced","debounce","useDebounce","useAnnotations","useSelection","useAnnotatorUser","_useViewportState","inViewport","setInViewport","viewport","viewportStoreObserver","unsubscribeViewport","ids","_useViewportStateDebounced","useViewportState"],"mappings":";;;AAyBO,MAAMA,IAAqBC,EAAc;AAAA,EAE9C,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,aAAa,CAAC;AAAA,EAEd,WAAW,EAAE,UAAU,GAAG;AAE5B,CAAC,GAEYC,IAAcC,EAA+C,CAACC,GAAgCC,MAAQ;AAEjH,QAAM,CAACC,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AAEpD,SAAAM,EAAU,MAAM;AACd,QAAIR,GAAM;AACR,YAAM,EAAE,OAAAS,GAAO,UAAA4B,MAAarC,EAAK;AAEjC,UAAI,CAACqC;AACH;AAIE,UAAAC;AAEE,YAAAC,IAAsBF,EAAS,UAAU,CAAOG,MAAA;AAChD,QAAAF,KACF7B,EAAM,UAAU6B,CAAqB;AAEvC,cAAMvB,IAAWyB,EAAI,IAAI,OAAM/B,EAAM,cAAcO,CAAE,CAAC;AACtD,QAAAoB,EAAcrB,CAAQ,GAEtBuB,IAAwB,CAASpB,MAAA;AACzB,gBAAA,EAAE,SAAAC,EAAQ,IAAID,EAAM;AAEZ,UAAAkB,EAAA,CAAAjC,MAAeA,EAAY,IAAI,CAAciB,MAAA;AACnD,kBAAAC,IAAOF,EAAQ,KAAK,CAAAG,MAAKA,EAAE,SAAS,OAAOF,EAAW,EAAE;AACvD,mBAAAC,IAAOA,EAAK,WAAWD;AAAA,UAC/B,CAAA,CAAC;AAAA,QAAA,GAGJX,EAAM,QAAQ6B,GAAuB,EAAE,aAAaE,EAAK,CAAA;AAAA,MAAA,CAC1D;AAED,aAAO,MAAM;AACS,QAAAD;MAAA;AAAA,IAExB;AAAA,EAAA,GACC,CAACvC,CAAI,CAAC,GAEFmC;AACT,GAEMM,IAA8B,CAAuBZ,MAAqB;AAC9E,QAAMM,IAAaD;AACZ,SAAAJ,EAAYK,GAAYN,CAAQ;AACzC,GAEaa,IAAoB,CAAuBb,MACtDA,IAAWY,EAA8BZ,CAAQ,IAAIK,EAAqB;"}
@@ -1,14 +1,13 @@
1
1
  import { useEffect as i } from "react";
2
2
  import { useAnnotator as s } from "./annotorious-react.es2.js";
3
3
  const m = (t) => {
4
- const { plugin: u, opts: r } = t, n = s();
4
+ const { plugin: r, opts: u } = t, n = s();
5
5
  return i(() => {
6
- if (n) {
7
- const o = u(n, r);
8
- return () => {
9
- o && "unmount" in o && o.unmount();
10
- };
11
- }
6
+ if (!n) return;
7
+ const o = r(n, u);
8
+ return () => {
9
+ o && "unmount" in o && o.unmount();
10
+ };
12
11
  }, [n]), null;
13
12
  };
14
13
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es3.js","sources":["../src/AnnotoriousPlugin.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { Annotation, Annotator } from '@annotorious/annotorious';\nimport { useAnnotator } from './Annotorious';\n\nexport interface AnnotoriousPluginProps <I extends Annotation, E extends unknown> {\n\n plugin: (anno: Annotator<I, E>, opts?: Object) => ({ unmount?: () => void }) | void;\n\n opts?: Object;\n\n}\n\nexport const AnnotoriousPlugin = <I extends Annotation = Annotation, E extends unknown = unknown>(props: AnnotoriousPluginProps<I, E>) => {\n const { plugin, opts } = props;\n\n const anno = useAnnotator<Annotator<I, E>>();\n\n useEffect(() => {\n if (anno) {\n const p = plugin(anno, opts);\n\n return () => {\n if (p && 'unmount' in p)\n p.unmount();\n }\n }\n }, [anno]);\n\n return null;\n\n}"],"names":["AnnotoriousPlugin","props","plugin","opts","anno","useAnnotator","useEffect","p"],"mappings":";;AAYa,MAAAA,IAAoB,CAAiEC,MAAwC;AAClI,QAAA,EAAE,QAAAC,GAAQ,MAAAC,EAAS,IAAAF,GAEnBG,IAAOC;AAEb,SAAAC,EAAU,MAAM;AACd,QAAIF,GAAM;AACF,YAAAG,IAAIL,EAAOE,GAAMD,CAAI;AAE3B,aAAO,MAAM;AACX,QAAII,KAAK,aAAaA,KACpBA,EAAE,QAAQ;AAAA,MAAA;AAAA,IAEhB;AAAA,EAAA,GACC,CAACH,CAAI,CAAC,GAEF;AAET;"}
1
+ {"version":3,"file":"annotorious-react.es3.js","sources":["../src/AnnotoriousPlugin.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { Annotator } from '@annotorious/annotorious';\nimport { useAnnotator } from './Annotorious';\n\nexport type AnnotatorPlugin<T extends unknown = Annotator<any, unknown>> =\n (anno: T, opts?: Object) => ({ unmount?: () => void }) | void;\n\nexport interface AnnotoriousPluginProps<T extends unknown = Annotator<any, unknown>> {\n\n plugin: AnnotatorPlugin<T>;\n\n opts?: Object;\n\n}\n\nexport const AnnotoriousPlugin = <T extends unknown = Annotator<any, unknown>>(props: AnnotoriousPluginProps<T>) => {\n const { plugin, opts } = props;\n\n const anno = useAnnotator<T>();\n\n useEffect(() => {\n if (!anno) return;\n\n const p = plugin(anno, opts);\n return () => {\n if (p && 'unmount' in p)\n p.unmount();\n };\n }, [anno]);\n\n return null;\n\n};\n"],"names":["AnnotoriousPlugin","props","plugin","opts","anno","useAnnotator","useEffect","p"],"mappings":";;AAea,MAAAA,IAAoB,CAA8CC,MAAqC;AAC5G,QAAA,EAAE,QAAAC,GAAQ,MAAAC,EAAS,IAAAF,GAEnBG,IAAOC;AAEb,SAAAC,EAAU,MAAM;AACd,QAAI,CAACF,EAAM;AAEL,UAAAG,IAAIL,EAAOE,GAAMD,CAAI;AAC3B,WAAO,MAAM;AACX,MAAII,KAAK,aAAaA,KACpBA,EAAE,QAAQ;AAAA,IAAA;AAAA,EACd,GACC,CAACH,CAAI,CAAC,GAEF;AAET;"}
@@ -1,19 +1,19 @@
1
- import { jsx as s } from "./annotorious-react.es22.js";
1
+ import { j as e } from "./annotorious-react.es11.js";
2
2
  import { forwardRef as g } from "react";
3
- import { useDraggable as i } from "./annotorious-react.es24.js";
4
- const d = g((r, o) => {
5
- const { children: a, className: t, onDragStart: n, onDragEnd: e } = r;
6
- return i(o, { onDragStart: n, onDragEnd: e, cancel: "button, .no-drag" }), /* @__PURE__ */ s(
3
+ import { useDraggable as i } from "./annotorious-react.es13.js";
4
+ const p = g((r, o) => {
5
+ const { children: t, className: a, onDragStart: s, onDragEnd: n } = r;
6
+ return i(o, { onDragStart: s, onDragEnd: n, cancel: "button, .no-drag" }), /* @__PURE__ */ e.jsx(
7
7
  "div",
8
8
  {
9
9
  ref: o,
10
- className: t,
10
+ className: a,
11
11
  style: { position: "absolute" },
12
- children: a
12
+ children: t
13
13
  }
14
14
  );
15
15
  });
16
16
  export {
17
- d as Draggable
17
+ p as Draggable
18
18
  };
19
19
  //# sourceMappingURL=annotorious-react.es4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es4.js","sources":["../src/AnnotoriousPopup.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useDraggable } from '@neodrag/react';\n\nexport interface AnnotoriousPopupProps {\n\n selected: { annotation: ImageAnnotation, editable?: boolean }[];\n\n}\n\nexport interface DraggableProps {\n\n children: ReactNode;\n\n className?: string;\n\n onDragStart?(): void;\n\n onDragEnd?(): void;\n\n}\n\nexport const Draggable = forwardRef((props: DraggableProps, ref: React.MutableRefObject<HTMLDivElement>) => {\n\n const { children, className, onDragStart, onDragEnd } = props;\n\n useDraggable(ref, { onDragStart, onDragEnd, cancel: 'button, .no-drag' });\n\n return (\n <div \n ref={ref} \n className={className} \n style={{ position: 'absolute' }}>\n {children}\n </div>\n )\n\n});"],"names":["Draggable","forwardRef","props","ref","children","className","onDragStart","onDragEnd","useDraggable","jsx"],"mappings":";;;AAsBO,MAAMA,IAAYC,EAAW,CAACC,GAAuBC,MAAiD;AAE3G,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,aAAAC,GAAa,WAAAC,MAAcL;AAExDM,SAAAA,EAAaL,GAAK,EAAE,aAAAG,GAAa,WAAAC,GAAW,QAAQ,oBAAoB,GAGtE,gBAAAE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,WAAAE;AAAA,MACA,OAAO,EAAE,UAAU,WAAW;AAAA,MAC7B,UAAAD;AAAA,IAAA;AAAA,EAAA;AAIP,CAAC;"}
1
+ {"version":3,"file":"annotorious-react.es4.js","sources":["../src/AnnotoriousPopup.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useDraggable } from '@neodrag/react';\n\nexport interface AnnotoriousPopupProps {\n\n selected: { annotation: ImageAnnotation, editable?: boolean }[];\n\n}\n\nexport interface DraggableProps {\n\n children: ReactNode;\n\n className?: string;\n\n onDragStart?(): void;\n\n onDragEnd?(): void;\n\n}\n\nexport const Draggable = forwardRef((props: DraggableProps, ref: React.MutableRefObject<HTMLDivElement>) => {\n\n const { children, className, onDragStart, onDragEnd } = props;\n\n useDraggable(ref, { onDragStart, onDragEnd, cancel: 'button, .no-drag' });\n\n return (\n <div \n ref={ref} \n className={className} \n style={{ position: 'absolute' }}>\n {children}\n </div>\n )\n\n});"],"names":["Draggable","forwardRef","props","ref","children","className","onDragStart","onDragEnd","useDraggable","jsx"],"mappings":";;;AAsBO,MAAMA,IAAYC,EAAW,CAACC,GAAuBC,MAAiD;AAE3G,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,aAAAC,GAAa,WAAAC,MAAcL;AAExDM,SAAAA,EAAaL,GAAK,EAAE,aAAAG,GAAa,WAAAC,GAAW,QAAQ,oBAAoB,GAGtEE,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,WAAAE;AAAA,MACA,OAAO,EAAE,UAAU,WAAW;AAAA,MAC7B,UAAAD;AAAA,IAAA;AAAA,EAAA;AAIP,CAAC;"}
@@ -1,12 +1,12 @@
1
- import { jsx as a, Fragment as g } from "./annotorious-react.es22.js";
2
- import { Children as d, useContext as x, useEffect as e, cloneElement as h } from "react";
3
- import { createImageAnnotator as u } from "./annotorious-react.es18.js";
4
- import { AnnotoriousContext as y } from "./annotorious-react.es2.js";
5
- const S = (t) => {
6
- const { children: n, tool: A, ...i } = t, l = d.only(n), { anno: o, setAnno: r } = x(y), c = (m) => {
1
+ import { j as n } from "./annotorious-react.es11.js";
2
+ import { Children as x, useContext as g, useEffect as e, cloneElement as d } from "react";
3
+ import { createImageAnnotator as u } from "@annotorious/annotorious";
4
+ import { AnnotoriousContext as h } from "./annotorious-react.es2.js";
5
+ const F = (t) => {
6
+ const { children: i, tool: y, ...l } = t, r = x.only(i), { anno: o, setAnno: m } = g(h), s = (c) => {
7
7
  if (!o) {
8
- const f = m.target, s = u(f, i);
9
- r(s);
8
+ const f = c.target, a = u(f, l);
9
+ m(a);
10
10
  }
11
11
  };
12
12
  return e(() => {
@@ -15,9 +15,9 @@ const S = (t) => {
15
15
  o && o.setFilter(t.filter);
16
16
  }, [t.filter]), e(() => {
17
17
  o && o.setStyle(t.style);
18
- }, [t.style]), /* @__PURE__ */ a(g, { children: h(l, { onLoad: c }) });
18
+ }, [t.style]), /* @__PURE__ */ n.jsx(n.Fragment, { children: d(r, { onLoad: s }) });
19
19
  };
20
20
  export {
21
- S as ImageAnnotator
21
+ F as ImageAnnotator
22
22
  };
23
23
  //# sourceMappingURL=annotorious-react.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: DrawingTool\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (props.tool && anno) anno.setDrawingTool(props.tool);\n }, [props.tool, anno]);\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 return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IACd;AAAA,EAAA;AAGF,SAAAE,EAAU,MAAM;AACd,IAAIf,EAAM,QAAQM,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EACrD,GAAA,CAACA,EAAM,MAAMM,CAAI,CAAC,GAErBS,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,0BAEN,UAAagB,EAAAZ,GAAO,EAAE,QAAAM,GAAsC,EAAE,CAAA;AAE1E;"}
1
+ {"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: DrawingTool\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (props.tool && anno) anno.setDrawingTool(props.tool);\n }, [props.tool, anno]);\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 return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IACd;AAAA,EAAA;AAGF,SAAAE,EAAU,MAAM;AACd,IAAIf,EAAM,QAAQM,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EACrD,GAAA,CAACA,EAAM,MAAMM,CAAI,CAAC,GAErBS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,uCAEN,UAAagB,EAAAZ,GAAO,EAAE,QAAAM,GAAsC,EAAE,CAAA;AAE1E;"}
@@ -1,52 +1,32 @@
1
- import { Origin as s } from "./annotorious-react.es17.js";
2
- import { parseAll as m } from "./annotorious-react.es9.js";
3
- const O = (t, l, i) => {
4
- const A = (o) => {
5
- if (i) {
6
- const { parsed: n, error: e } = i.parse(o);
7
- n ? t.addAnnotation(n, s.REMOTE) : console.error(e);
8
- } else
9
- t.addAnnotation(o, s.REMOTE);
10
- }, r = () => t.clear(), a = (o) => {
11
- const n = t.getAnnotation(o);
12
- return i && n ? i.serialize(n) : n;
13
- }, u = () => i ? t.all().map(i.serialize) : t.all(), d = (o) => fetch(o).then((n) => n.json()).then((n) => (c(n), n)), f = (o) => {
14
- if (typeof o == "string") {
15
- const n = t.getAnnotation(o);
16
- return t.deleteAnnotation(o), i ? i.serialize(n) : n;
17
- } else {
18
- const n = i ? i.parse(o).parsed : o;
19
- return t.deleteAnnotation(n), o;
1
+ import { j as c } from "./annotorious-react.es11.js";
2
+ import { createContext as w, useState as u, useContext as a, useEffect as i } from "react";
3
+ import { createOSDAnnotator as g } from "@annotorious/openseadragon";
4
+ import { AnnotoriousContext as m } from "./annotorious-react.es2.js";
5
+ const d = w({ viewer: null, setViewer: null }), S = (e) => {
6
+ const { children: x, tool: r, ...f } = e, [o, s] = u(), { anno: t, setAnno: l } = a(m);
7
+ return i(() => {
8
+ if (o) {
9
+ const n = g(o, f);
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
+ };
20
13
  }
21
- }, c = (o) => {
22
- if (i) {
23
- const { parsed: n, failed: e } = m(i)(o);
24
- e.length > 0 && console.warn(`Discarded ${e.length} invalid annotations`, e), t.bulkAddAnnotation(n, !0, s.REMOTE);
25
- } else
26
- t.bulkAddAnnotation(o, !0, s.REMOTE);
27
- }, E = (o) => {
28
- if (i) {
29
- const n = i.parse(o).parsed, e = i.serialize(t.getAnnotation(n.id));
30
- return t.updateAnnotation(n), e;
31
- } else {
32
- const n = t.getAnnotation(o.id);
33
- return t.updateAnnotation(o), n;
34
- }
35
- };
36
- return {
37
- addAnnotation: A,
38
- clearAnnotations: r,
39
- getAnnotationById: a,
40
- getAnnotations: u,
41
- loadAnnotations: d,
42
- redo: l.redo,
43
- removeAnnotation: f,
44
- setAnnotations: c,
45
- undo: l.undo,
46
- updateAnnotation: E
47
- };
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(d.Provider, { value: { viewer: o, setViewer: s }, children: e.children });
23
+ }, A = () => {
24
+ const { viewer: e } = a(d);
25
+ return e;
48
26
  };
49
27
  export {
50
- O as createBaseAnnotator
28
+ S as OpenSeadragonAnnotator,
29
+ d as OpenSeadragonAnnotatorContext,
30
+ A as useViewer
51
31
  };
52
32
  //# sourceMappingURL=annotorious-react.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es8.js","sources":["../../annotorious-core/src/model/Annotator.ts"],"sourcesContent":["import type { Annotation } from './Annotation';\nimport type { User } from './User';\nimport type { PresenceProvider } from '../presence';\nimport { Origin, type HoverState, type SelectionState, type Store, type UndoStack, type ViewportState } from '../state';\nimport type { LifecycleEvents } from '../lifecycle';\nimport { parseAll, type FormatAdapter } from './FormatAdapter';\nimport type { DrawingStyle } from './DrawingStyle';\nimport type { Filter } from './Filter';\n\n/**\n * Base annotator interface.\n * I ... internal core data model \n * E ... external adapted representation\n */\nexport interface Annotator<I extends Annotation = Annotation, E extends unknown = Annotation> {\n\n addAnnotation(annotation: E): void;\n\n clearAnnotations(): void;\n\n destroy(): void;\n\n getAnnotationById(id: string): E | undefined;\n\n getAnnotations(): E[];\n\n getUser(): User;\n\n loadAnnotations(url: string): Promise<E[]>;\n\n redo(): void;\n\n removeAnnotation(arg: E | string): E;\n\n setAnnotations(annotations: E[]): void;\n\n setFilter(filter: Filter): void;\n\n setPresenceProvider?(provider: PresenceProvider): void;\n\n setSelected(arg?: string | string[]): void;\n\n setStyle(arg: DrawingStyle | ((annotation: I) => DrawingStyle) | undefined): void;\n\n setUser(user: User): void;\n\n undo(): void;\n\n updateAnnotation(annotation: E): E;\n \n on<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n off<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n state: AnnotatorState<I>;\n\n}\n\nexport interface AnnotatorState<A extends Annotation> {\n\n store: Store<A>;\n\n selection: SelectionState<A>;\n\n hover: HoverState<A>;\n\n viewport: ViewportState;\n\n}\n\nexport const createBaseAnnotator = <I extends Annotation, E extends unknown>(\n store: Store<I>, \n undoStack: UndoStack,\n adapter?: FormatAdapter<I, E>\n) => {\n\n const addAnnotation = (annotation: E) => {\n if (adapter) {\n const { parsed, error } = adapter.parse(annotation);\n if (parsed) {\n store.addAnnotation(parsed, Origin.REMOTE);\n } else {\n console.error(error);\n }\n } else {\n store.addAnnotation(annotation as unknown as I, Origin.REMOTE);\n }\n }\n\n const clearAnnotations = () => store.clear();\n\n const getAnnotationById = (id: string): E | undefined => {\n const annotation = store.getAnnotation(id);\n return (adapter && annotation) ?\n adapter.serialize(annotation) as E : annotation as unknown as E;\n }\n\n const getAnnotations = () =>\n (adapter ? store.all().map(adapter.serialize) : store.all()) as E[];\n\n const loadAnnotations = (url: string) =>\n fetch(url)\n .then((response) => response.json())\n .then((annotations) => {\n setAnnotations(annotations);\n return annotations;\n });\n\n const removeAnnotation = (arg: E | string): E => {\n if (typeof arg === 'string') {\n const annotation = store.getAnnotation(arg);\n store.deleteAnnotation(arg);\n\n return adapter ? adapter.serialize(annotation) : annotation as unknown as E;\n } else {\n const annotation = adapter ? adapter.parse(arg).parsed : (arg as unknown as I);\n store.deleteAnnotation(annotation);\n return arg;\n }\n }\n\n const setAnnotations = (annotations: E[]) => {\n if (adapter) {\n const { parsed, failed } = parseAll(adapter)(annotations);\n\n if (failed.length > 0)\n console.warn(`Discarded ${failed.length} invalid annotations`, failed);\n\n store.bulkAddAnnotation(parsed, true, Origin.REMOTE);\n } else {\n store.bulkAddAnnotation(annotations as unknown as I[], true, Origin.REMOTE);\n }\n }\n\n const updateAnnotation = (updated: E): E => {\n if (adapter) {\n const crosswalked = adapter.parse(updated).parsed;\n const previous = adapter.serialize(store.getAnnotation(crosswalked.id));\n store.updateAnnotation(crosswalked);\n return previous;\n } else {\n const previous = store.getAnnotation((updated as unknown as I).id);\n store.updateAnnotation(updated as unknown as I);\n return previous as unknown as E;\n }\n }\n\n return { \n addAnnotation,\n clearAnnotations,\n getAnnotationById,\n getAnnotations,\n loadAnnotations,\n redo: undoStack.redo,\n removeAnnotation,\n setAnnotations,\n undo: undoStack.undo,\n updateAnnotation\n }\n\n}"],"names":["createBaseAnnotator","store","undoStack","adapter","addAnnotation","annotation","parsed","error","Origin","clearAnnotations","getAnnotationById","id","getAnnotations","loadAnnotations","url","response","annotations","setAnnotations","removeAnnotation","arg","failed","parseAll","updateAnnotation","updated","crosswalked","previous"],"mappings":";;AAsEO,MAAMA,IAAsB,CACjCC,GACAC,GACAC,MACG;AAEG,QAAAC,IAAgB,CAACC,MAAkB;AACvC,QAAIF,GAAS;AACX,YAAM,EAAE,QAAA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MAAM;AAAA,EAC5E,GAGIc,IAAmB,CAACC,MAAkB;AAC1C,QAAIpB,GAAS;AACX,YAAMqB,IAAcrB,EAAQ,MAAMoB,CAAO,EAAE,QACrCE,IAAWtB,EAAQ,UAAUF,EAAM,cAAcuB,EAAY,EAAE,CAAC;AACtE,aAAAvB,EAAM,iBAAiBuB,CAAW,GAC3BC;AAAA,IAAA,OACF;AACL,YAAMA,IAAWxB,EAAM,cAAesB,EAAyB,EAAE;AACjE,aAAAtB,EAAM,iBAAiBsB,CAAuB,GACvCE;AAAA,IACT;AAAA,EAAA;AAGK,SAAA;AAAA,IACL,eAAArB;AAAA,IACA,kBAAAK;AAAA,IACA,mBAAAC;AAAA,IACA,gBAAAE;AAAA,IACA,iBAAAC;AAAA,IACA,MAAMX,EAAU;AAAA,IAChB,kBAAAgB;AAAA,IACA,gBAAAD;AAAA,IACA,MAAMf,EAAU;AAAA,IAChB,kBAAAoB;AAAA,EAAA;AAGJ;"}
1
+ {"version":3,"file":"annotorious-react.es8.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,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9B,CAACI,GAAQC,CAAS,IAAIC,EAA+B,GAErD,EAAE,MAAAC,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB;AAEvD,SAAAC,EAAU,MAAM;AACd,QAAIP,GAAQ;AACJG,YAAAA,IAAOK,EAAsBR,GAAQD,CAAI;AAE/C,aAAIH,EAAM,mBAAmB,UAAWO,EAAK,kBAAkBP,EAAM,cAAc,GAC/EA,EAAM,UAAQO,EAAK,UAAUP,EAAM,MAAM,GACzCA,EAAM,SAAOO,EAAK,SAASP,EAAM,KAAK,GACtCA,EAAM,QAAMO,EAAK,eAAeP,EAAM,IAAI,GAE9CQ,EAAQD,CAAI,GAEL,MAAM;AACXA,QAAAA,EAAK,QAAQ,GACbC,EAAQ,MAAS;AAAA,MAAA;AAAA,IAErB;AAAA,EAAA,GACC,CAACJ,CAAM,CAAC,GAEXO,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,kBAAkBP,EAAM,cAAc;AAAA,EAAA,GACpD,CAACA,EAAM,cAAc,CAAC,GAEzBW,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,UAAUP,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBW,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,SAASP,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,GAEhBW,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,eAAeL,CAAI;AAAA,EAAA,GACjC,CAACA,CAAI,CAAC,GAGPW,gBAAAA,MAAChB,EAA8B,UAA9B,EAAuC,OAAO,EAAE,QAAAO,GAAQ,WAAAC,EACtD,GAAA,UAAAL,EAAM,SACT,CAAA;AAGJ,GAEac,IAAY,MAAM;AAC7B,QAAM,EAAE,QAAAV,EAAA,IAAWK,EAAWZ,CAA6B;AACpD,SAAAO;AACT;"}
@@ -1,15 +1,38 @@
1
- const i = (a) => (r) => r.map((e) => a.serialize(e)), l = (a) => (r) => r.reduce((e, d) => {
2
- const { parsed: p, error: s } = a.parse(d);
3
- return s ? {
4
- parsed: e.parsed,
5
- failed: [...e.failed, d]
6
- } : {
7
- parsed: [...e.parsed, p],
8
- failed: e.failed
9
- };
10
- }, { parsed: [], failed: [] });
1
+ import { j as v } from "./annotorious-react.es11.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.es8.js";
5
+ import { useSelection as j } from "./annotorious-react.es2.js";
6
+ import { setPosition as D } from "./annotorious-react.es14.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) return;
17
+ s || p();
18
+ const e = () => {
19
+ s || p();
20
+ };
21
+ return o.addHandler("update-viewport", e), () => {
22
+ o.removeHandler("update-viewport", e);
23
+ };
24
+ }, [t, s]), t.length > 0 ? /* @__PURE__ */ v.jsx(
25
+ x,
26
+ {
27
+ ref: n,
28
+ className: "a9s-popup a9s-osd-popup",
29
+ onDragStart: f,
30
+ children: c.popup({ viewer: o, selected: t })
31
+ },
32
+ t.map(({ annotation: e }) => e.id).join("-")
33
+ ) : null;
34
+ };
11
35
  export {
12
- l as parseAll,
13
- i as serializeAll
36
+ R as OpenSeadragonPopup
14
37
  };
15
38
  //# sourceMappingURL=annotorious-react.es9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es9.js","sources":["../../annotorious-core/src/model/FormatAdapter.ts"],"sourcesContent":["import type { Annotation } from './Annotation';\n\nexport interface FormatAdapter<A extends Annotation, T extends unknown> {\n\n parse(serialized: T): ParseResult<A>;\n\n serialize(core: A): T;\n\n}\n\nexport interface ParseResult<A extends Annotation> {\n\n parsed?: A;\n \n error?: Error;\n\n}\n\nexport const serializeAll = \n <A extends Annotation, T extends unknown>(adapter: FormatAdapter<A, T>) =>\n (annotations: A[]) => annotations.map(a => adapter.serialize(a));\n\nexport const parseAll = \n <A extends Annotation, T extends unknown>(adapter: FormatAdapter<A, T>) =>\n (serialized: T[]) => serialized.reduce((result, next) => {\n const { parsed, error } = adapter.parse(next);\n\n return error ? {\n parsed: result.parsed,\n failed: [...result.failed, next ]\n } : {\n parsed: [...result.parsed, parsed ],\n failed: result.failed\n }\n }, { parsed: [], failed: [] });\n "],"names":["serializeAll","adapter","annotations","a","parseAll","serialized","result","next","parsed","error"],"mappings":"AAkBa,MAAAA,IACX,CAA0CC,MACxC,CAACC,MAAqBA,EAAY,IAAI,CAAKC,MAAAF,EAAQ,UAAUE,CAAC,CAAC,GAEtDC,IACX,CAA0CH,MACxC,CAACI,MAAoBA,EAAW,OAAO,CAACC,GAAQC,MAAS;AACvD,QAAM,EAAE,QAAAC,GAAQ,OAAAC,EAAA,IAAUR,EAAQ,MAAMM,CAAI;AAE5C,SAAOE,IAAQ;AAAA,IACb,QAAQH,EAAO;AAAA,IACf,QAAQ,CAAC,GAAGA,EAAO,QAAQC,CAAK;AAAA,EAAA,IAC9B;AAAA,IACF,QAAQ,CAAC,GAAGD,EAAO,QAAQE,CAAO;AAAA,IAClC,QAAQF,EAAO;AAAA,EAAA;AAEnB,GAAG,EAAE,QAAQ,IAAI,QAAQ,CAAA,EAAI,CAAA;"}
1
+ {"version":3,"file":"annotorious-react.es9.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;AACV,QAAA,CAACnB,EAAG,QAAS;AAEb,IAACS,KAAwBG;AAE7B,UAAMS,IAAmB,MAAM;AACzB,MAACZ,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;"}
package/dist/index.d.ts CHANGED
@@ -1,20 +1,20 @@
1
+ import { createAnonymousGuest as _createAnonymousGuest, createBody as _createBody, defaultColorProvider as _defaultColorProvider, Origin as _Origin, PointerSelectAction as _PointerSelectAction } from '@annotorious/core';
2
+ import { ShapeType as _ShapeType } from '@annotorious/annotorious';
1
3
  export * from './Annotorious';
2
4
  export * from './AnnotoriousPlugin';
3
5
  export * from './AnnotoriousPopup';
4
6
  export * from './ImageAnnotator';
5
7
  export * from './openseadragon';
6
- export type { LifecycleEvents } from '@annotorious/core/src/lifecycle';
7
- export * from '@annotorious/core/src/model';
8
- export * from '@annotorious/core/src/presence';
9
- export * from '@annotorious/core/src/utils';
10
- export type { HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver } from '@annotorious/core/src/state';
11
- import { Origin as _Origin, PointerSelectAction as _PointerSelectAction } from '@annotorious/core/src/state';
8
+ export type { Annotation, AnnotationBody, AnnotationState, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, Color, DrawingStyle, DrawingStyleExpression, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
9
+ export { _createAnonymousGuest as createAnonymousGuest };
10
+ export { _createBody as createBody };
11
+ export { _defaultColorProvider as defaultColorProvider };
12
12
  export { _Origin as Origin };
13
13
  export { _PointerSelectAction as PointerSelectAction };
14
- export type { ImageAnnotator as AnnotoriousImageAnnotator, ImageAnnotation } from '@annotorious/annotorious';
14
+ export type { AnnotoriousOpts, DrawingMode, DrawingTool, FragmentSelector, ImageAnnotator as AnnotoriousImageAnnotator, ImageAnnotation, ImageAnnotatorState, Polygon, PolygonGeometry, Rectangle, RectangleGeometry, Shape, SVGSelector, W3CImageAnnotation, W3CImageAnnotationTarget } from '@annotorious/annotorious';
15
+ export declare const createImageAnnotator: <E extends unknown = import('@annotorious/annotorious').ImageAnnotation>(image: string | HTMLImageElement | HTMLCanvasElement, options?: import('@annotorious/annotorious').AnnotoriousOpts<import('@annotorious/annotorious').ImageAnnotation, E>) => import('@annotorious/annotorious').ImageAnnotator<E>;
16
+ export declare const ShapeType: typeof _ShapeType;
17
+ export declare const W3CImageFormat: (source: string, invertY?: boolean) => import('@annotorious/annotorious').W3CImageFormatAdapter;
15
18
  export type { OpenSeadragonAnnotator as AnnotoriousOpenSeadragonAnnotator } from '@annotorious/openseadragon';
16
- import { ShapeType as _ShapeType, W3CImageFormat as _W3CImageFormat } from '@annotorious/annotorious';
17
- export { _ShapeType as ShapeType };
18
- export { _W3CImageFormat as W3CImageFormat };
19
19
  export type { Viewer } from 'openseadragon';
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,iBAAiB,CAAC;AAGhC,OAAO,0CAA0C,CAAC;AAClD,OAAO,0DAA0D,CAAC;AAElE,YAAY,EACV,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAGzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAE5C,YAAY,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,aAAa,EACd,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,CAAC;AAC7B,OAAO,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,CAAC;AAGvD,YAAY,EACV,cAAc,IAAI,yBAAyB,EAC3C,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,sBAAsB,IAAI,iCAAiC,EAC5D,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,SAAS,IAAI,UAAU,EACvB,cAAc,IAAI,eAAe,E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WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,cAAc,IAAI,yBAAyB,EAC3C,eAAe,EACf,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,SAAS,IAAI,UAAU,EAExB,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,oBAAoB,6SAAwB,CAAC;AAC1D,eAAO,MAAM,SAAS,mBAAa,CAAC;AACpC,eAAO,MAAM,cAAc,iGAAkB,CAAC;AAG9C,YAAY,EACV,sBAAsB,IAAI,iCAAiC,EAC5D,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- import OpenSeadragon from 'openseadragon';
2
+ import { default as OpenSeadragon } from 'openseadragon';
3
3
  import { AnnotoriousOpts, DrawingStyle, Filter, ImageAnnotation } from '@annotorious/annotorious';
4
- export declare const OpenSeadragonAnnotatorContext: import("react").Context<{
4
+
5
+ export declare const OpenSeadragonAnnotatorContext: import('react').Context<{
5
6
  viewer: OpenSeadragon.Viewer;
6
7
  setViewer(viewer: OpenSeadragon.Viewer): void;
7
8
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenSeadragonAnnotator.d.ts","sourceRoot":"","sources":["../../src/openseadragon/OpenSeadragonAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmC,MAAM,OAAO,CAAC;AAClF,OAAO,aAAa,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGlG,eAAO,MAAM,6BAA6B;YAChC,cAAc,MAAM;sBACV,cAAc,MAAM,GAAG,IAAI;EACV,CAAC;AAEtC,MAAM,MAAM,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