@annotorious/react 3.7.17 → 3.7.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ImageAnnotator.d.ts","sourceRoot":"","sources":["../src/ImageAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAuC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,eAAe,EAAwB,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGjG,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,CAAE,SAAQ,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;IAEvH,QAAQ,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAEzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAEnB,IAAI,CAAC,EAAE,WAAW,CAAC;CAEpB;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,EAAE,OAAO,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,4CA4CvG,CAAA"}
1
+ {"version":3,"file":"ImageAnnotator.d.ts","sourceRoot":"","sources":["../src/ImageAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAuC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,eAAe,EAAwB,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGjG,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,CAAE,SAAQ,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;IAEvH,QAAQ,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAEzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAEnB,IAAI,CAAC,EAAE,WAAW,CAAC;CAEpB;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,EAAE,OAAO,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,4CAgDvG,CAAA"}
@@ -1,12 +1,12 @@
1
1
  import { jsx as d, Fragment as g } from "react/jsx-runtime";
2
- import { Children as u, useContext as A, useEffect as n, cloneElement as C } from "react";
3
- import { createImageAnnotator as x } from "@annotorious/annotorious";
4
- import { AnnotoriousContext as E } from "./annotorious-react.es2.js";
2
+ import { Children as u, useContext as w, useEffect as n, cloneElement as A } from "react";
3
+ import { createImageAnnotator as C } from "@annotorious/annotorious";
4
+ import { AnnotoriousContext as x } from "./annotorious-react.es2.js";
5
5
  const S = (t) => {
6
- const { children: i, tool: o, ...a } = t, l = u.only(i), { anno: e, setAnno: c } = A(E), r = (s) => {
6
+ const { children: o, tool: i, ...a } = t, l = u.only(o), { anno: e, setAnno: r } = w(x), c = (m) => {
7
7
  if (!e) {
8
- const m = s.target, f = x(m, a);
9
- c(f);
8
+ const s = m.target, f = C(s, a);
9
+ r(f);
10
10
  }
11
11
  };
12
12
  return n(() => {
@@ -14,14 +14,16 @@ const S = (t) => {
14
14
  }, [t.containerClassName, e]), n(() => {
15
15
  e && e.setDrawingEnabled(t.drawingEnabled);
16
16
  }, [t.drawingEnabled]), n(() => {
17
+ e && e.setDrawingMode(t.drawingMode);
18
+ }, [t.drawingMode]), n(() => {
17
19
  e && e.setFilter(t.filter);
18
20
  }, [t.filter]), n(() => {
19
21
  e && e.setStyle(t.style);
20
22
  }, [t.style]), n(() => {
21
- o && e && e.setDrawingTool(t.tool);
22
- }, [o, e]), n(() => {
23
+ i && e && e.setDrawingTool(t.tool);
24
+ }, [i, e]), n(() => {
23
25
  e && e.setUserSelectAction(t.userSelectAction);
24
- }, [t.userSelectAction]), /* @__PURE__ */ d(g, { children: C(l, { onLoad: r }) });
26
+ }, [t.userSelectAction]), /* @__PURE__ */ d(g, { children: A(l, { onLoad: c }) });
25
27
  };
26
28
  export {
27
29
  S as ImageAnnotator
@@ -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 { Annotation, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<I extends Annotation, E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n containerClassName?: string;\n\n filter?: Filter<I>;\n\n tool?: DrawingTool;\n\n}\n\nexport const ImageAnnotator = <I extends Annotation, E extends unknown>(props: ImageAnnotatorProps<I, 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 (!anno || !props.containerClassName) return;\n anno.element.className = props.containerClassName;\n }, [props.containerClassName, anno]);\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 (tool && anno) anno.setDrawingTool(props.tool);\n }, [tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [props.userSelectAction]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}\n"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBO,MAAMA,IAAiB,CAA0CC,MAAqC;AAE3G,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,MAAYC,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,EACF;AAEA,SAAAE,EAAU,MAAM;AACd,IAAI,CAACT,KAAQ,CAACN,EAAM,uBACpBM,EAAK,QAAQ,YAAYN,EAAM;AAAA,EACjC,GAAG,CAACA,EAAM,oBAAoBM,CAAI,CAAC,GAEnCS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,kBAAkBN,EAAM,cAAc;AAAA,EACvD,GAAG,CAACA,EAAM,cAAc,CAAC,GAEzBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,UAAUN,EAAM,MAAM;AAAA,EACvC,GAAG,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,SAASN,EAAM,KAAK;AAAA,EACrC,GAAG,CAACA,EAAM,KAAK,CAAC,GAEhBe,EAAU,MAAM;AACd,IAAIb,KAAQI,KAAMA,EAAK,eAAeN,EAAM,IAAI;AAAA,EAClD,GAAG,CAACE,GAAMI,CAAI,CAAC,GAEfS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,oBAAoBN,EAAM,gBAAgB;AAAA,EAC3D,GAAG,CAACA,EAAM,gBAAgB,CAAC,0BAEjB,UAAAgB,EAAaZ,GAAO,EAAE,QAAAM,EAAA,CAAsC,GAAE;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 { Annotation, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<I extends Annotation, E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n containerClassName?: string;\n\n filter?: Filter<I>;\n\n tool?: DrawingTool;\n\n}\n\nexport const ImageAnnotator = <I extends Annotation, E extends unknown>(props: ImageAnnotatorProps<I, 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 (!anno || !props.containerClassName) return;\n anno.element.className = props.containerClassName;\n }, [props.containerClassName, anno]);\n\n useEffect(() => {\n if (anno) anno.setDrawingEnabled(props.drawingEnabled);\n }, [props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setDrawingMode(props.drawingMode);\n }, [props.drawingMode]);\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 (tool && anno) anno.setDrawingTool(props.tool);\n }, [tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [props.userSelectAction]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}\n"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBO,MAAMA,IAAiB,CAA0CC,MAAqC;AAE3G,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,MAAYC,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,EACF;AAEA,SAAAE,EAAU,MAAM;AACd,IAAI,CAACT,KAAQ,CAACN,EAAM,uBACpBM,EAAK,QAAQ,YAAYN,EAAM;AAAA,EACjC,GAAG,CAACA,EAAM,oBAAoBM,CAAI,CAAC,GAEnCS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,kBAAkBN,EAAM,cAAc;AAAA,EACvD,GAAG,CAACA,EAAM,cAAc,CAAC,GAEzBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,eAAeN,EAAM,WAAW;AAAA,EACjD,GAAG,CAACA,EAAM,WAAW,CAAC,GAEtBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,UAAUN,EAAM,MAAM;AAAA,EACvC,GAAG,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,SAASN,EAAM,KAAK;AAAA,EACrC,GAAG,CAACA,EAAM,KAAK,CAAC,GAEhBe,EAAU,MAAM;AACd,IAAIb,KAAQI,KAAMA,EAAK,eAAeN,EAAM,IAAI;AAAA,EAClD,GAAG,CAACE,GAAMI,CAAI,CAAC,GAEfS,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,oBAAoBN,EAAM,gBAAgB;AAAA,EAC3D,GAAG,CAACA,EAAM,gBAAgB,CAAC,0BAEjB,UAAAgB,EAAaZ,GAAO,EAAE,QAAAM,EAAA,CAAsC,GAAE;AAE1E;"}
@@ -1,24 +1,26 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
- import { forwardRef as A, createContext as S, useState as w, useContext as c, useImperativeHandle as g, useEffect as n } from "react";
2
+ import { forwardRef as w, createContext as A, useState as S, useContext as c, useImperativeHandle as g, useEffect as n } from "react";
3
3
  import { createAnonymousGuest as h } from "@annotorious/core";
4
4
  import { createOSDAnnotator as x } from "@annotorious/openseadragon";
5
5
  import { AnnotoriousContext as y } from "./annotorious-react.es2.js";
6
- const s = S({ viewer: null, setViewer: null }), O = A((t, f) => {
7
- const { children: v, tool: o, ...d } = t, [i, u] = w(), { anno: e, setAnno: l } = c(y);
8
- return g(f, () => e, [e]), n(() => {
9
- var a;
6
+ const d = A({ viewer: null, setViewer: null }), V = w((t, s) => {
7
+ const { children: v, tool: o, ...f } = t, [i, u] = S(), { anno: e, setAnno: a } = c(y);
8
+ return g(s, () => e, [e]), n(() => {
9
+ var l;
10
10
  if (i != null && i.element)
11
11
  try {
12
- const r = x(i, d);
13
- return l(r), () => {
14
- r.destroy(), l(void 0);
12
+ const r = x(i, f);
13
+ return a(r), () => {
14
+ r.destroy(), a(void 0);
15
15
  };
16
16
  } catch (r) {
17
- (a = t.onInitError) == null || a.call(t, r);
17
+ (l = t.onInitError) == null || l.call(t, r);
18
18
  }
19
19
  }, [i]), n(() => {
20
20
  e && e.setDrawingEnabled(t.drawingEnabled);
21
21
  }, [e, t.drawingEnabled]), n(() => {
22
+ e && e.setDrawingMode(t.drawingMode);
23
+ }, [e, t.drawingMode]), n(() => {
22
24
  e && e.setFilter(t.filter);
23
25
  }, [e, t.filter]), n(() => {
24
26
  e && e.setVisible(!t.hideAnnotations);
@@ -32,14 +34,14 @@ const s = S({ viewer: null, setViewer: null }), O = A((t, f) => {
32
34
  e && (t.user ? e.setUser(t.user) : e.setUser(h()));
33
35
  }, [e, t.user]), n(() => {
34
36
  e && e.setUserSelectAction(t.userSelectAction);
35
- }, [e, t.userSelectAction]), /* @__PURE__ */ m(s.Provider, { value: { viewer: i, setViewer: u }, children: t.children });
36
- }), U = () => {
37
- const { viewer: t } = c(s);
37
+ }, [e, t.userSelectAction]), /* @__PURE__ */ m(d.Provider, { value: { viewer: i, setViewer: u }, children: t.children });
38
+ }), O = () => {
39
+ const { viewer: t } = c(d);
38
40
  return t;
39
41
  };
40
42
  export {
41
- O as OpenSeadragonAnnotator,
42
- s as OpenSeadragonAnnotatorContext,
43
- U as useViewer
43
+ V as OpenSeadragonAnnotator,
44
+ d as OpenSeadragonAnnotatorContext,
45
+ O as useViewer
44
46
  };
45
47
  //# sourceMappingURL=annotorious-react.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es8.js","sources":["../src/openseadragon/OpenSeadragonAnnotator.tsx"],"sourcesContent":["import { \n createContext, \n forwardRef, \n ReactNode, \n useContext, \n useEffect, \n useImperativeHandle, \n useState \n} from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { createAnonymousGuest } from '@annotorious/core';\nimport { AnnotoriousOSDOpts, createOSDAnnotator } from '@annotorious/openseadragon';\nimport { Annotation, DrawingStyle, Filter, User} from '@annotorious/annotorious';\nimport { AnnotoriousContext } from '../Annotorious';\nimport { AnnotoriousOpenSeadragonAnnotator } from '.';\n\nexport const OpenSeadragonAnnotatorContext = createContext<{ \n viewer: OpenSeadragon.Viewer,\n setViewer(viewer: OpenSeadragon.Viewer): void\n}>({ viewer: null, setViewer: null });\n\nexport type OpenSeadragonAnnotatorProps<I extends Annotation, E extends unknown> = AnnotoriousOSDOpts<I, E> & {\n\n children?: ReactNode;\n\n filter?: Filter<I>;\n\n hideAnnotations?: boolean;\n\n style?: DrawingStyle | ((annotation: I) => DrawingStyle);\n\n tool?: string | null;\n\n user?: User;\n\n onInitError?(error: Error): void;\n\n}\n\nexport const OpenSeadragonAnnotator = forwardRef(<I extends Annotation, E extends unknown>(\n props: OpenSeadragonAnnotatorProps<I, E>, \n ref: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null>\n) => {\n const { children, tool, ...opts } = props;\n\n const [viewer, setViewer] = useState<OpenSeadragon.Viewer>();\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useImperativeHandle(ref, () => anno as AnnotoriousOpenSeadragonAnnotator<I, E> | null, [anno]);\n\n useEffect(() => {\n if (viewer?.element) {\n try {\n const anno = createOSDAnnotator<I, E>(viewer, opts as AnnotoriousOSDOpts<I, E>);\n setAnno(anno);\n\n return () => {\n anno.destroy();\n setAnno(undefined);\n }\n } catch (error) {\n // Typical scenario: hardware acceleration is disabled \n props.onInitError?.(error);\n }\n }\n }, [viewer]);\n\n useEffect(() => {\n if (anno) anno.setDrawingEnabled(props.drawingEnabled);\n }, [anno, props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [anno, props.filter]);\n\n useEffect(() => {\n if (anno) anno.setVisible(!props.hideAnnotations);\n }, [anno, props.hideAnnotations]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [anno, props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool || 'rectangle');\n }, [anno, tool]);\n\n useEffect(() => {\n if (anno) anno.setModalSelect(props.modalSelect);\n }, [anno, props.modalSelect]);\n\n useEffect(() => {\n if (!anno) return;\n \n if (props.user)\n anno.setUser(props.user);\n else \n anno.setUser(createAnonymousGuest());\n }, [anno, props.user]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [anno, props.userSelectAction]);\n\n return (\n <OpenSeadragonAnnotatorContext.Provider value={{ viewer, setViewer }}>\n {props.children}\n </OpenSeadragonAnnotatorContext.Provider>\n )\n\n}) as <I extends Annotation, E extends unknown> (\n props: OpenSeadragonAnnotatorProps<I, E> & { ref?: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null> }\n) => React.ReactElement;\n\nexport const useViewer = () => {\n const { viewer } = useContext(OpenSeadragonAnnotatorContext);\n return viewer;\n}"],"names":["OpenSeadragonAnnotatorContext","createContext","OpenSeadragonAnnotator","forwardRef","props","ref","children","tool","opts","viewer","setViewer","useState","anno","setAnno","useContext","AnnotoriousContext","useImperativeHandle","useEffect","createOSDAnnotator","error","_a","createAnonymousGuest","jsx","useViewer"],"mappings":";;;;;AAgBO,MAAMA,IAAgCC,EAG1C,EAAE,QAAQ,MAAM,WAAW,MAAM,GAoBvBC,IAAyBC,EAAW,CAC/CC,GACAC,MACG;AACH,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASJ,GAE9B,CAACK,GAAQC,CAAS,IAAIC,EAAA,GAEtB,EAAE,MAAAC,GAAM,SAAAC,MAAYC,EAAWC,CAAkB;AAEvD,SAAAC,EAAoBX,GAAK,MAAMO,GAAwD,CAACA,CAAI,CAAC,GAE7FK,EAAU,MAAM;;AACd,QAAIR,KAAA,QAAAA,EAAQ;AACV,UAAI;AACF,cAAMG,IAAOM,EAAyBT,GAAQD,CAAgC;AAC9E,eAAAK,EAAQD,CAAI,GAEL,MAAM;AACXA,UAAAA,EAAK,QAAA,GACLC,EAAQ,MAAS;AAAA,QACnB;AAAA,MACF,SAASM,GAAO;AAEd,SAAAC,IAAAhB,EAAM,gBAAN,QAAAgB,EAAA,KAAAhB,GAAoBe;AAAA,MACtB;AAAA,EAEJ,GAAG,CAACV,CAAM,CAAC,GAEXQ,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,kBAAkBR,EAAM,cAAc;AAAA,EACvD,GAAG,CAACQ,GAAMR,EAAM,cAAc,CAAC,GAE/Ba,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,UAAUR,EAAM,MAAM;AAAA,EACvC,GAAG,CAACQ,GAAMR,EAAM,MAAM,CAAC,GAEvBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,WAAW,CAACR,EAAM,eAAe;AAAA,EAClD,GAAG,CAACQ,GAAMR,EAAM,eAAe,CAAC,GAEhCa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,SAASR,EAAM,KAAK;AAAA,EACrC,GAAG,CAACQ,GAAMR,EAAM,KAAK,CAAC,GAEtBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,eAAeL,KAAQ,WAAW;AAAA,EACnD,GAAG,CAACK,GAAML,CAAI,CAAC,GAEfU,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,eAAeR,EAAM,WAAW;AAAA,EACjD,GAAG,CAACQ,GAAMR,EAAM,WAAW,CAAC,GAE5Ba,EAAU,MAAM;AACd,IAAKL,MAEDR,EAAM,OACRQ,EAAK,QAAQR,EAAM,IAAI,IAEvBQ,EAAK,QAAQS,GAAsB;AAAA,EACvC,GAAG,CAACT,GAAMR,EAAM,IAAI,CAAC,GAErBa,EAAU,MAAM;AACd,IAAIL,KAAMA,EAAK,oBAAoBR,EAAM,gBAAgB;AAAA,EAC3D,GAAG,CAACQ,GAAMR,EAAM,gBAAgB,CAAC,GAG/B,gBAAAkB,EAACtB,EAA8B,UAA9B,EAAuC,OAAO,EAAE,QAAAS,GAAQ,WAAAC,KACtD,UAAAN,EAAM,SAAA,CACT;AAGJ,CAAC,GAIYmB,IAAY,MAAM;AAC7B,QAAM,EAAE,QAAAd,EAAA,IAAWK,EAAWd,CAA6B;AAC3D,SAAOS;AACT;"}
1
+ {"version":3,"file":"annotorious-react.es8.js","sources":["../src/openseadragon/OpenSeadragonAnnotator.tsx"],"sourcesContent":["import { \n createContext, \n forwardRef, \n ReactNode, \n useContext, \n useEffect, \n useImperativeHandle, \n useState \n} from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { createAnonymousGuest } from '@annotorious/core';\nimport { AnnotoriousOSDOpts, createOSDAnnotator } from '@annotorious/openseadragon';\nimport { Annotation, DrawingStyle, Filter, User} from '@annotorious/annotorious';\nimport { AnnotoriousContext } from '../Annotorious';\nimport { AnnotoriousOpenSeadragonAnnotator } from '.';\n\nexport const OpenSeadragonAnnotatorContext = createContext<{ \n viewer: OpenSeadragon.Viewer,\n setViewer(viewer: OpenSeadragon.Viewer): void\n}>({ viewer: null, setViewer: null });\n\nexport type OpenSeadragonAnnotatorProps<I extends Annotation, E extends unknown> = AnnotoriousOSDOpts<I, E> & {\n\n children?: ReactNode;\n\n filter?: Filter<I>;\n\n hideAnnotations?: boolean;\n\n style?: DrawingStyle | ((annotation: I) => DrawingStyle);\n\n tool?: string | null;\n\n user?: User;\n\n onInitError?(error: Error): void;\n\n}\n\nexport const OpenSeadragonAnnotator = forwardRef(<I extends Annotation, E extends unknown>(\n props: OpenSeadragonAnnotatorProps<I, E>, \n ref: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null>\n) => {\n const { children, tool, ...opts } = props;\n\n const [viewer, setViewer] = useState<OpenSeadragon.Viewer>();\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useImperativeHandle(ref, () => anno as AnnotoriousOpenSeadragonAnnotator<I, E> | null, [anno]);\n\n useEffect(() => {\n if (viewer?.element) {\n try {\n const anno = createOSDAnnotator<I, E>(viewer, opts as AnnotoriousOSDOpts<I, E>);\n setAnno(anno);\n\n return () => {\n anno.destroy();\n setAnno(undefined);\n }\n } catch (error) {\n // Typical scenario: hardware acceleration is disabled \n props.onInitError?.(error);\n }\n }\n }, [viewer]);\n\n useEffect(() => {\n if (anno) anno.setDrawingEnabled(props.drawingEnabled);\n }, [anno, props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setDrawingMode(props.drawingMode);\n }, [anno, props.drawingMode]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [anno, props.filter]);\n\n useEffect(() => {\n if (anno) anno.setVisible(!props.hideAnnotations);\n }, [anno, props.hideAnnotations]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [anno, props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool || 'rectangle');\n }, [anno, tool]);\n\n useEffect(() => {\n if (anno) anno.setModalSelect(props.modalSelect);\n }, [anno, props.modalSelect]);\n\n useEffect(() => {\n if (!anno) return;\n \n if (props.user)\n anno.setUser(props.user);\n else \n anno.setUser(createAnonymousGuest());\n }, [anno, props.user]);\n\n useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [anno, props.userSelectAction]);\n\n return (\n <OpenSeadragonAnnotatorContext.Provider value={{ viewer, setViewer }}>\n {props.children}\n </OpenSeadragonAnnotatorContext.Provider>\n )\n\n}) as <I extends Annotation, E extends unknown> (\n props: OpenSeadragonAnnotatorProps<I, E> & { ref?: React.ForwardedRef<AnnotoriousOpenSeadragonAnnotator<I, E> | null> }\n) => React.ReactElement;\n\nexport const useViewer = () => {\n const { viewer } = useContext(OpenSeadragonAnnotatorContext);\n return viewer;\n}"],"names":["OpenSeadragonAnnotatorContext","createContext","OpenSeadragonAnnotator","forwardRef","props","ref","children","tool","opts","viewer","setViewer","useState","anno","setAnno","useContext","AnnotoriousContext","useImperativeHandle","useEffect","createOSDAnnotator","error","_a","createAnonymousGuest","jsx","useViewer"],"mappings":";;;;;AAgBO,MAAMA,IAAgCC,EAG1C,EAAE,QAAQ,MAAM,WAAW,MAAM,GAoBvBC,IAAyBC,EAAW,CAC/CC,GACAC,MACG;AACH,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASJ,GAE9B,CAACK,GAAQC,CAAS,IAAIC,EAAA,GAEtB,EAAE,MAAAC,GAAM,SAAAC,MAAYC,EAAWC,CAAkB;AAEvD,SAAAC,EAAoBX,GAAK,MAAMO,GAAwD,CAACA,CAAI,CAAC,GAE7FK,EAAU,MAAM;;AACd,QAAIR,KAAA,QAAAA,EAAQ;AACV,UAAI;AACF,cAAMG,IAAOM,EAAyBT,GAAQD,CAAgC;AAC9E,eAAAK,EAAQD,CAAI,GAEL,MAAM;AACXA,UAAAA,EAAK,QAAA,GACLC,EAAQ,MAAS;AAA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AAC;IAEZ,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAElC,CAAA;AAED,eAAO,MAAM,sBAAsB,EA4E7B,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,EAC5C,KAAK,EAAE,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,iCAAiC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;CAAE,KACpH,KAAK,CAAC,YAAY,CAAC;AAExB,eAAO,MAAM,SAAS,4BAGrB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/react",
3
- "version": "3.7.17",
3
+ "version": "3.7.19",
4
4
  "description": "Annotorious React bindings",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -26,8 +26,8 @@
26
26
  "./annotorious-react.css": "./dist/annotorious-react.css"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/react": "^19.2.2",
30
- "@types/react-dom": "^19.2.2",
29
+ "@types/react": "^19.2.6",
30
+ "@types/react-dom": "^19.2.3",
31
31
  "@vitejs/plugin-react": "^4.7.0",
32
32
  "typescript": "^5.9.3",
33
33
  "vite": "^5.4.21",
@@ -45,9 +45,9 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@annotorious/annotorious": "3.7.17",
49
- "@annotorious/core": "3.7.17",
50
- "@annotorious/openseadragon": "3.7.17",
48
+ "@annotorious/annotorious": "3.7.19",
49
+ "@annotorious/core": "3.7.19",
50
+ "@annotorious/openseadragon": "3.7.19",
51
51
  "@floating-ui/react": "^0.27.16",
52
52
  "dequal": "^2.0.3"
53
53
  },