@annotorious/react 3.0.10 → 3.0.11
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,17 +1,17 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { j as f } from "./annotorious-react.es11.js";
|
|
2
|
+
import { forwardRef as m, useRef as p, useContext as u, useLayoutEffect as c, useImperativeHandle as d } from "react";
|
|
3
3
|
import l from "openseadragon";
|
|
4
4
|
import { OpenSeadragonAnnotatorContext as x } from "./annotorious-react.es8.js";
|
|
5
|
-
const S =
|
|
6
|
-
const { className: i, options:
|
|
5
|
+
const S = m((n, s) => {
|
|
6
|
+
const { className: i, options: t } = n, r = p(null), { viewer: a, setViewer: e } = u(x);
|
|
7
7
|
return c(() => {
|
|
8
|
-
if (
|
|
9
|
-
const o = l({ ...
|
|
10
|
-
return e &&
|
|
8
|
+
if (r.current) {
|
|
9
|
+
const o = l({ ...t, element: r.current });
|
|
10
|
+
return e && e(o), () => {
|
|
11
11
|
e && e(void 0), o.destroy();
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
}, [JSON.stringify(
|
|
14
|
+
}, [JSON.stringify(t)]), d(s, () => a), /* @__PURE__ */ f.jsx("div", { className: i, ref: r });
|
|
15
15
|
});
|
|
16
16
|
export {
|
|
17
17
|
S as OpenSeadragonViewer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n
|
|
1
|
+
{"version":3,"file":"annotorious-react.es10.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n useLayoutEffect(() => { \n if (element.current) {\n const v = OpenSeadragon({...options, element: element.current });\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n if (setViewer)\n setViewer(undefined);\n\n v.destroy();\n }\n }\n }, [JSON.stringify(options)]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useLayoutEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAY,IAAAH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,EAAU,IAAIC,EAAWC,CAA6B;AAEtE,SAAAC,EAAgB,MAAM;AACpB,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACP,QAAAJ,KACFA,EAAU,MAAS,GAErBI,EAAE,QAAQ;AAAA,MAAA;AAAA,IAEd;AAAA,KACC,CAAC,KAAK,UAAUR,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlCQ,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { j as d } from "./annotorious-react.es11.js";
|
|
2
|
-
import { createContext as u, useState as w, useContext as a, useEffect as
|
|
2
|
+
import { createContext as u, useState as w, useContext as a, useEffect as o } from "react";
|
|
3
3
|
import { createOSDAnnotator as g } from "@annotorious/openseadragon";
|
|
4
4
|
import { AnnotoriousContext as m } from "./annotorious-react.es2.js";
|
|
5
|
-
const s = u({ viewer: null, setViewer: null }),
|
|
6
|
-
const { children: S, tool:
|
|
7
|
-
return
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
return e.drawingEnabled !== void 0 &&
|
|
11
|
-
|
|
5
|
+
const s = u({ viewer: null, setViewer: null }), b = (e) => {
|
|
6
|
+
const { children: S, tool: l, ...c } = e, [n, f] = w(), { anno: t, setAnno: r } = a(m);
|
|
7
|
+
return o(() => {
|
|
8
|
+
if (n != null && n.element) {
|
|
9
|
+
const i = g(n, c);
|
|
10
|
+
return e.drawingEnabled !== void 0 && i.setDrawingEnabled(e.drawingEnabled), e.filter && i.setFilter(e.filter), e.style && i.setStyle(e.style), e.tool && i.setDrawingTool(e.tool), r(i), () => {
|
|
11
|
+
i.destroy(), r(void 0);
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
}, [
|
|
14
|
+
}, [n]), o(() => {
|
|
15
15
|
t && t.setDrawingEnabled(e.drawingEnabled);
|
|
16
|
-
}, [e.drawingEnabled]),
|
|
16
|
+
}, [e.drawingEnabled]), o(() => {
|
|
17
17
|
t && t.setFilter(e.filter);
|
|
18
|
-
}, [e.filter]),
|
|
18
|
+
}, [e.filter]), o(() => {
|
|
19
19
|
t && t.setStyle(e.style);
|
|
20
|
-
}, [e.style]),
|
|
21
|
-
t && t.setDrawingTool(
|
|
22
|
-
}, [
|
|
20
|
+
}, [e.style]), o(() => {
|
|
21
|
+
t && t.setDrawingTool(l);
|
|
22
|
+
}, [l]), o(() => {
|
|
23
23
|
t && t.setUserSelectAction(e.userSelectAction);
|
|
24
|
-
}, [e.userSelectAction]), /* @__PURE__ */ d.jsx(s.Provider, { value: { viewer:
|
|
25
|
-
},
|
|
24
|
+
}, [e.userSelectAction]), /* @__PURE__ */ d.jsx(s.Provider, { value: { viewer: n, setViewer: f }, children: e.children });
|
|
25
|
+
}, v = () => {
|
|
26
26
|
const { viewer: e } = a(s);
|
|
27
27
|
return e;
|
|
28
28
|
};
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
b as OpenSeadragonAnnotator,
|
|
31
31
|
s as OpenSeadragonAnnotatorContext,
|
|
32
|
-
|
|
32
|
+
v as useViewer
|
|
33
33
|
};
|
|
34
34
|
//# 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, 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<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}\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) {\n const anno = createOSDAnnotator<I, E>(viewer, opts as AnnotoriousOpts<I, E>);\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 useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [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,MAAM,GAcvBC,IAAyB,CAA0CC,MAA6C;AAE3H,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,
|
|
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, 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<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}\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\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 useEffect(() => {\n if (anno) anno.setUserSelectAction(props.userSelectAction);\n }, [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,MAAM,GAcvBC,IAAyB,CAA0CC,MAA6C;AAE3H,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,KAAA,QAAAA,EAAQ,SAAS;AACbG,YAAAA,IAAOK,EAAyBR,GAAQD,CAA6B;AAE3E,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,GAETS,EAAU,MAAM;AACd,IAAIJ,KAAMA,EAAK,oBAAoBP,EAAM,gBAAgB;AAAA,EAAA,GACxD,CAACA,EAAM,gBAAgB,CAAC,GAGzBa,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenSeadragonViewer.d.ts","sourceRoot":"","sources":["../../src/openseadragon/OpenSeadragonViewer.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,eAAe,CAAC;AAG1C,MAAM,WAAW,wBAAwB;IAEvC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;CAEhC;AAED,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"OpenSeadragonViewer.d.ts","sourceRoot":"","sources":["../../src/openseadragon/OpenSeadragonViewer.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,eAAe,CAAC;AAG1C,MAAM,WAAW,wBAAwB;IAEvC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;CAEhC;AAED,eAAO,MAAM,mBAAmB,2HAgC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/react",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Annotorious React bindings",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@annotorious/annotorious": "3.0.
|
|
48
|
-
"@annotorious/core": "3.0.
|
|
49
|
-
"@annotorious/openseadragon": "3.0.
|
|
47
|
+
"@annotorious/annotorious": "3.0.11",
|
|
48
|
+
"@annotorious/core": "3.0.11",
|
|
49
|
+
"@annotorious/openseadragon": "3.0.11",
|
|
50
50
|
"@floating-ui/react": "^0.26.24"
|
|
51
51
|
},
|
|
52
52
|
"sideEffects": false
|