@annotorious/react 3.0.14 → 3.0.15

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,12 +1,13 @@
1
1
  import { j as f } from "./annotorious-react.es11.js";
2
- import { createContext as u, useState as m, useContext as a, useEffect as n } from "react";
3
- import { createOSDAnnotator as S } from "@annotorious/openseadragon";
2
+ import { createContext as d, useState as m, useContext as s, useEffect as n } from "react";
3
+ import { createAnonymousGuest as S } from "@annotorious/core";
4
+ import { createOSDAnnotator as A } from "@annotorious/openseadragon";
4
5
  import { AnnotoriousContext as w } from "./annotorious-react.es2.js";
5
- const s = u({ viewer: null, setViewer: null }), y = (t) => {
6
- const { children: x, tool: r, ...c } = t, [o, d] = m(), { anno: e, setAnno: i } = a(w);
6
+ const a = d({ viewer: null, setViewer: null }), b = (t) => {
7
+ const { children: x, tool: r, ...c } = t, [o, u] = m(), { anno: e, setAnno: i } = s(w);
7
8
  return n(() => {
8
9
  if (o != null && o.element) {
9
- const l = S(o, c);
10
+ const l = A(o, c);
10
11
  return i(l), () => {
11
12
  l.destroy(), i(void 0);
12
13
  };
@@ -22,17 +23,17 @@ const s = u({ viewer: null, setViewer: null }), y = (t) => {
22
23
  }, [e, r]), n(() => {
23
24
  e && e.setModalSelect(t.modalSelect);
24
25
  }, [e, t.modalSelect]), n(() => {
25
- e && e.setUser(t.user);
26
+ e && (t.user ? e.setUser(t.user) : e.setUser(S()));
26
27
  }, [e, t.user]), n(() => {
27
28
  e && e.setUserSelectAction(t.userSelectAction);
28
- }, [e, t.userSelectAction]), /* @__PURE__ */ f.jsx(s.Provider, { value: { viewer: o, setViewer: d }, children: t.children });
29
- }, C = () => {
30
- const { viewer: t } = a(s);
29
+ }, [e, t.userSelectAction]), /* @__PURE__ */ f.jsx(a.Provider, { value: { viewer: o, setViewer: u }, children: t.children });
30
+ }, h = () => {
31
+ const { viewer: t } = s(a);
31
32
  return t;
32
33
  };
33
34
  export {
34
- y as OpenSeadragonAnnotator,
35
- s as OpenSeadragonAnnotatorContext,
36
- C as useViewer
35
+ b as OpenSeadragonAnnotator,
36
+ a as OpenSeadragonAnnotatorContext,
37
+ h as useViewer
37
38
  };
38
39
  //# sourceMappingURL=annotorious-react.es8.js.map
@@ -1 +1 @@
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 { Annotation, AnnotoriousOpts, DrawingStyle, Filter, User} 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<I extends Annotation, E extends unknown> = AnnotoriousOpts<I, E> & {\n\n children?: ReactNode;\n\n filter?: Filter<I>;\n\n style?: DrawingStyle | ((annotation: I) => DrawingStyle);\n\n tool?: string | null;\n\n user?: User;\n\n}\n\nexport const OpenSeadragonAnnotator = <I extends Annotation, E extends unknown>(props: OpenSeadragonAnnotatorProps<I, 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?.element) {\n const anno = createOSDAnnotator<I, E>(viewer, opts as AnnotoriousOpts<I, E>);\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 }, [anno, props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [anno, props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [anno, props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool);\n }, [anno, tool]);\n\n useEffect(() => {\n if (anno) anno.setModalSelect(props.modalSelect);\n }, [anno, props.modalSelect]);\n\n useEffect(() => {\n if (anno) anno.setUser(props.user);\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}\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,KAAM,CAAA,GAgBvBC,IAAyB,CAA0CC,MAA6C;AAE3H,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,EAAS,IAAAH,GAE9B,CAACI,GAAQC,CAAS,IAAIC,EAA+B,GAErD,EAAE,MAAAC,GAAM,SAAAC,MAAYC,EAAWC,CAAkB;AAEvD,SAAAC,EAAU,MAAM;AACd,QAAIP,KAAA,QAAAA,EAAQ,SAAS;AACbG,YAAAA,IAAOK,EAAyBR,GAAQD,CAA6B;AAC3E,aAAAK,EAAQD,CAAI,GAEL,MAAM;AACXA,QAAAA,EAAK,QAAQ,GACbC,EAAQ,MAAS;AAAA,MACnB;AAAA,IAAA;AAAA,EACF,GACC,CAACJ,CAAM,CAAC,GAEXO,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,kBAAkBP,EAAM,cAAc;AAAA,EACpD,GAAA,CAACO,GAAMP,EAAM,cAAc,CAAC,GAE/BW,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,UAAUP,EAAM,MAAM;AAAA,EACpC,GAAA,CAACO,GAAMP,EAAM,MAAM,CAAC,GAEvBW,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,SAASP,EAAM,KAAK;AAAA,EAClC,GAAA,CAACO,GAAMP,EAAM,KAAK,CAAC,GAEtBW,EAAU,MAAM;AACV,IAAAJ,KAAWA,EAAA,eAAeL,CAAI;AAAA,EAAA,GACjC,CAACK,GAAML,CAAI,CAAC,GAEfS,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,eAAeP,EAAM,WAAW;AAAA,EAC9C,GAAA,CAACO,GAAMP,EAAM,WAAW,CAAC,GAE5BW,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,QAAQP,EAAM,IAAI;AAAA,EAChC,GAAA,CAACO,GAAMP,EAAM,IAAI,CAAC,GAErBW,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,oBAAoBP,EAAM,gBAAgB;AAAA,EACxD,GAAA,CAACO,GAAMP,EAAM,gBAAgB,CAAC,GAG/Ba,gBAAAA,MAAChB,EAA8B,UAA9B,EAAuC,OAAO,EAAE,QAAAO,GAAQ,WAAAC,KACtD,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.es8.js","sources":["../src/openseadragon/OpenSeadragonAnnotator.tsx"],"sourcesContent":["import { createContext, ReactNode, useContext, useEffect, useState } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { createAnonymousGuest } from '@annotorious/core';\nimport { createOSDAnnotator } from '@annotorious/openseadragon';\nimport { Annotation, AnnotoriousOpts, DrawingStyle, Filter, User} 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<I extends Annotation, E extends unknown> = AnnotoriousOpts<I, E> & {\n\n children?: ReactNode;\n\n filter?: Filter<I>;\n\n style?: DrawingStyle | ((annotation: I) => DrawingStyle);\n\n tool?: string | null;\n\n user?: User;\n\n}\n\nexport const OpenSeadragonAnnotator = <I extends Annotation, E extends unknown>(props: OpenSeadragonAnnotatorProps<I, 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?.element) {\n const anno = createOSDAnnotator<I, E>(viewer, opts as AnnotoriousOpts<I, E>);\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 }, [anno, props.drawingEnabled]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [anno, props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [anno, props.style]);\n\n useEffect(() => {\n if (anno) anno.setDrawingTool(tool);\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}\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","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AAsB,GAAI,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,SAAS,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,4CAsDvH,CAAA;AAED,eAAO,MAAM,SAAS,4BAGrB,CAAA"}
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;AAG1C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAGlG,eAAO,MAAM,6BAA6B;YAChC,aAAa,CAAC,MAAM;sBACV,aAAa,CAAC,MAAM,GAAG,IAAI;EACV,CAAC;AAEtC,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAEzG,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAEnB,KAAK,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC;IAEzD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,IAAI,CAAC,EAAE,IAAI,CAAC;CAEb,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,SAAS,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,4CA2DvH,CAAA;AAED,eAAO,MAAM,SAAS,4BAGrB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"toClientRects.d.ts","sourceRoot":"","sources":["../../src/utils/toClientRects.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,SAAU,OAAO,gBAO1B,CAAC"}
1
+ {"version":3,"file":"toClientRects.d.ts","sourceRoot":"","sources":["../../src/utils/toClientRects.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,SAAU,OAAO,KAOtC,WAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/react",
3
- "version": "3.0.14",
3
+ "version": "3.0.15",
4
4
  "description": "Annotorious React bindings",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -28,8 +28,8 @@
28
28
  "devDependencies": {
29
29
  "@types/react": "^18.3.12",
30
30
  "@types/react-dom": "^18.3.1",
31
- "@vitejs/plugin-react": "^4.3.3",
32
- "typescript": "5.6.3",
31
+ "@vitejs/plugin-react": "^4.3.4",
32
+ "typescript": "5.7.2",
33
33
  "vite": "^5.4.11",
34
34
  "vite-plugin-dts": "^4.3.0",
35
35
  "vite-tsconfig-paths": "^5.1.3"
@@ -45,9 +45,9 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@annotorious/annotorious": "3.0.14",
49
- "@annotorious/core": "3.0.14",
50
- "@annotorious/openseadragon": "3.0.14",
48
+ "@annotorious/annotorious": "3.0.15",
49
+ "@annotorious/core": "3.0.15",
50
+ "@annotorious/openseadragon": "3.0.15",
51
51
  "@floating-ui/react": "^0.26.28",
52
52
  "zustand": "^5.0.1"
53
53
  },