@annotorious/react 3.0.0-rc.9 → 3.0.0

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 (62) hide show
  1. package/dist/Annotorious.d.ts +11 -40
  2. package/dist/Annotorious.d.ts.map +1 -1
  3. package/dist/AnnotoriousPlugin.d.ts +9 -6
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -1
  5. package/dist/AnnotoriousPopup.d.ts +2 -2
  6. package/dist/AnnotoriousPopup.d.ts.map +1 -1
  7. package/dist/ImageAnnotator.d.ts +1 -2
  8. package/dist/ImageAnnotator.d.ts.map +1 -1
  9. package/dist/annotorious-react.css +1 -1
  10. package/dist/annotorious-react.es.js +35 -32
  11. package/dist/annotorious-react.es.js.map +1 -1
  12. package/dist/annotorious-react.es10.js +15 -35
  13. package/dist/annotorious-react.es10.js.map +1 -1
  14. package/dist/annotorious-react.es11.js +6 -16
  15. package/dist/annotorious-react.es11.js.map +1 -1
  16. package/dist/annotorious-react.es12.js +8 -4
  17. package/dist/annotorious-react.es12.js.map +1 -1
  18. package/dist/annotorious-react.es13.js +134 -8
  19. package/dist/annotorious-react.es13.js.map +1 -1
  20. package/dist/annotorious-react.es14.js +31 -152
  21. package/dist/annotorious-react.es14.js.map +1 -1
  22. package/dist/annotorious-react.es15.js +2 -6
  23. package/dist/annotorious-react.es15.js.map +1 -1
  24. package/dist/annotorious-react.es16.js +20 -22149
  25. package/dist/annotorious-react.es16.js.map +1 -1
  26. package/dist/annotorious-react.es17.js +606 -32
  27. package/dist/annotorious-react.es17.js.map +1 -1
  28. package/dist/annotorious-react.es18.js +2 -2
  29. package/dist/annotorious-react.es19.js +2 -30
  30. package/dist/annotorious-react.es19.js.map +1 -1
  31. package/dist/annotorious-react.es2.js +87 -68
  32. package/dist/annotorious-react.es2.js.map +1 -1
  33. package/dist/annotorious-react.es3.js +12 -13
  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 +19 -20
  38. package/dist/annotorious-react.es5.js.map +1 -1
  39. package/dist/annotorious-react.es8.js +27 -80
  40. package/dist/annotorious-react.es8.js.map +1 -1
  41. package/dist/annotorious-react.es9.js +34 -28
  42. package/dist/annotorious-react.es9.js.map +1 -1
  43. package/dist/index.d.ts +8 -9
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +3 -3
  46. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  47. package/dist/openseadragon/OpenSeadragonPopup.d.ts +1 -1
  48. package/dist/openseadragon/OpenSeadragonViewer.d.ts +2 -3
  49. package/dist/openseadragon/OpenSeadragonViewer.d.ts.map +1 -1
  50. package/dist/openseadragon/setPosition.d.ts +1 -1
  51. package/dist/openseadragon/setPosition.d.ts.map +1 -1
  52. package/package.json +14 -12
  53. package/dist/annotorious-react.es20.js +0 -602
  54. package/dist/annotorious-react.es20.js.map +0 -1
  55. package/dist/annotorious-react.es21.js +0 -5
  56. package/dist/annotorious-react.es21.js.map +0 -1
  57. package/dist/annotorious-react.es22.js +0 -5
  58. package/dist/annotorious-react.es22.js.map +0 -1
  59. package/dist/annotorious-react.es6.js +0 -5
  60. package/dist/annotorious-react.es6.js.map +0 -1
  61. package/dist/annotorious-react.es7.js +0 -5
  62. package/dist/annotorious-react.es7.js.map +0 -1
@@ -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 '.';\nimport type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '.';\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 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":";;;;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,GAEhBe,EAAU,MAAM;AACd,IAAIT,KAAMA,EAAK,oBAAoBN,EAAM,gBAAgB;AAAA,EAAA,GACxD,CAACA,EAAM,gBAAgB,CAAC,uCAEjB,UAAagB,EAAAZ,GAAO,EAAE,QAAAM,GAAsC,EAAE,CAAA;AAE1E;"}
@@ -1,85 +1,32 @@
1
- var f = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(f || {});
2
- let c;
3
- const p = new Uint8Array(16);
4
- function g() {
5
- if (!c && (c = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !c))
6
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
7
- return c(p);
8
- }
9
- const o = [];
10
- for (let t = 0; t < 256; ++t)
11
- o.push((t + 256).toString(16).slice(1));
12
- function y(t, r = 0) {
13
- return o[t[r + 0]] + o[t[r + 1]] + o[t[r + 2]] + o[t[r + 3]] + "-" + o[t[r + 4]] + o[t[r + 5]] + "-" + o[t[r + 6]] + o[t[r + 7]] + "-" + o[t[r + 8]] + o[t[r + 9]] + "-" + o[t[r + 10]] + o[t[r + 11]] + o[t[r + 12]] + o[t[r + 13]] + o[t[r + 14]] + o[t[r + 15]];
14
- }
15
- const m = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), i = {
16
- randomUUID: m
17
- };
18
- function U(t, r, e) {
19
- if (i.randomUUID && !r && !t)
20
- return i.randomUUID();
21
- t = t || {};
22
- const a = t.random || (t.rng || g)();
23
- if (a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, r) {
24
- e = e || 0;
25
- for (let n = 0; n < 16; ++n)
26
- r[e + n] = a[n];
27
- return r;
28
- }
29
- return y(a);
30
- }
31
- const b = (t, r, e, a) => ({
32
- id: U(),
33
- annotation: t.id,
34
- created: e || /* @__PURE__ */ new Date(),
35
- creator: a,
36
- ...r
37
- });
38
- var h = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(h || {});
39
- let E = (t) => crypto.getRandomValues(new Uint8Array(t)), C = (t, r, e) => {
40
- let a = (2 << Math.log(t.length - 1) / Math.LN2) - 1, n = -~(1.6 * a * r / t.length);
41
- return (d = r) => {
42
- let s = "";
43
- for (; ; ) {
44
- let l = e(n), u = n;
45
- for (; u--; )
46
- if (s += t[l[u] & a] || "", s.length === d)
47
- return s;
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
+ };
48
13
  }
49
- };
50
- }, D = (t, r = 21) => C(t, r, E), R = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((r, e) => (e &= 63, e < 36 ? r += e.toString(36) : e < 62 ? r += (e - 26).toString(36).toUpperCase() : e > 62 ? r += "-" : r += "_", r), "");
51
- const A = () => ({ isGuest: !0, id: D("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), O = [
52
- "#ff7c00",
53
- // orange
54
- "#1ac938",
55
- // green
56
- "#e8000b",
57
- // red
58
- "#8b2be2",
59
- // purple
60
- "#9f4800",
61
- // brown
62
- "#f14cc1",
63
- // pink
64
- "#ffc400",
65
- // khaki
66
- "#00d7ff",
67
- // cyan
68
- "#023eff"
69
- // blue
70
- ], I = () => {
71
- const t = [...O];
72
- return { assignRandomColor: () => {
73
- const r = Math.floor(Math.random() * t.length), e = t[r];
74
- return t.splice(r, 1), e;
75
- }, releaseColor: (r) => t.push(r) };
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;
76
26
  };
77
- R();
78
27
  export {
79
- h as Origin,
80
- f as PointerSelectAction,
81
- A as createAnonymousGuest,
82
- b as createBody,
83
- I as defaultColorProvider
28
+ S as OpenSeadragonAnnotator,
29
+ d as OpenSeadragonAnnotatorContext,
30
+ A as useViewer
84
31
  };
85
32
  //# sourceMappingURL=annotorious-react.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es8.js","sources":["../../annotorious-core/dist/annotorious-core.es.js"],"sourcesContent":["var Y = Object.prototype.hasOwnProperty;\nfunction B(e, n) {\n var t, o;\n if (e === n)\n return !0;\n if (e && n && (t = e.constructor) === n.constructor) {\n if (t === Date)\n return e.getTime() === n.getTime();\n if (t === RegExp)\n return e.toString() === n.toString();\n if (t === Array) {\n if ((o = e.length) === n.length)\n for (; o-- && B(e[o], n[o]); )\n ;\n return o === -1;\n }\n if (!t || typeof e == \"object\") {\n o = 0;\n for (t in e)\n if (Y.call(e, t) && ++o && !Y.call(n, t) || !(t in n) || !B(e[t], n[t]))\n return !1;\n return Object.keys(n).length === o;\n }\n }\n return e !== e && n !== n;\n}\nfunction $() {\n}\nfunction q(e, n) {\n return e != e ? n == n : e !== n || e && typeof e == \"object\" || typeof e == \"function\";\n}\nconst k = [];\nfunction _(e, n = $) {\n let t;\n const o = /* @__PURE__ */ new Set();\n function i(b) {\n if (q(e, b) && (e = b, t)) {\n const v = !k.length;\n for (const u of o)\n u[1](), k.push(u, e);\n if (v) {\n for (let u = 0; u < k.length; u += 2)\n k[u][0](k[u + 1]);\n k.length = 0;\n }\n }\n }\n function h(b) {\n i(b(e));\n }\n function U(b, v = $) {\n const u = [b, v];\n return o.add(u), o.size === 1 && (t = n(i) || $), b(e), () => {\n o.delete(u), o.size === 0 && t && (t(), t = null);\n };\n }\n return { set: i, update: h, subscribe: U };\n}\nconst Ee = (e) => {\n const { subscribe: n, set: t } = _(null);\n let o = null;\n return n((i) => o = i), e.observe(({ changes: i }) => {\n if (o) {\n i.deleted.some((b) => b.id === o) && t(null);\n const U = i.updated.find(({ oldValue: b }) => b.id === o);\n U && t(U.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: n,\n set: t\n };\n};\nvar G = /* @__PURE__ */ ((e) => (e.EDIT = \"EDIT\", e.SELECT = \"SELECT\", e.NONE = \"NONE\", e))(G || {});\nconst V = { selected: [] }, be = (e, n = \"EDIT\") => {\n const { subscribe: t, set: o } = _(V);\n let i = V;\n t((s) => i = s);\n const h = () => o(V), U = () => {\n var s;\n return ((s = i.selected) == null ? void 0 : s.length) === 0;\n }, b = (s) => {\n if (i.selected.length === 0)\n return !1;\n const f = typeof s == \"string\" ? s : s.id;\n return i.selected.some((y) => y.id === f);\n }, v = (s, f) => {\n const y = e.getAnnotation(s);\n if (y) {\n const A = W(y, n);\n o(A === \"EDIT\" ? { selected: [{ id: s, editable: !0 }], pointerEvent: f } : A === \"SELECT\" ? { selected: [{ id: s }], pointerEvent: f } : { selected: [], pointerEvent: f });\n } else\n console.warn(\"Invalid selection: \" + s);\n }, u = (s, f = !0) => {\n const y = Array.isArray(s) ? s : [s], A = y.map((L) => e.getAnnotation(L)).filter((L) => L);\n o({ selected: A.map(({ id: L }) => ({ id: L, editable: f })) }), A.length !== y.length && console.warn(\"Invalid selection\", s);\n }, T = (s) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: f } = i;\n f.filter(({ id: A }) => s.includes(A)).length > 0 && o({ selected: f.filter(({ id: A }) => !s.includes(A)) });\n };\n return e.observe(({ changes: s }) => T(s.deleted.map((f) => f.id))), {\n clear: h,\n clickSelect: v,\n get selected() {\n return i ? [...i.selected] : null;\n },\n get pointerEvent() {\n return i ? i.pointerEvent : null;\n },\n isEmpty: U,\n isSelected: b,\n setSelected: u,\n subscribe: t\n };\n}, W = (e, n) => typeof n == \"function\" ? n(e) || \"EDIT\" : n || \"EDIT\";\nlet z;\nconst H = new Uint8Array(16);\nfunction F() {\n if (!z && (z = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !z))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return z(H);\n}\nconst R = [];\nfor (let e = 0; e < 256; ++e)\n R.push((e + 256).toString(16).slice(1));\nfunction J(e, n = 0) {\n return R[e[n + 0]] + R[e[n + 1]] + R[e[n + 2]] + R[e[n + 3]] + \"-\" + R[e[n + 4]] + R[e[n + 5]] + \"-\" + R[e[n + 6]] + R[e[n + 7]] + \"-\" + R[e[n + 8]] + R[e[n + 9]] + \"-\" + R[e[n + 10]] + R[e[n + 11]] + R[e[n + 12]] + R[e[n + 13]] + R[e[n + 14]] + R[e[n + 15]];\n}\nconst Q = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto), j = {\n randomUUID: Q\n};\nfunction X(e, n, t) {\n if (j.randomUUID && !n && !e)\n return j.randomUUID();\n e = e || {};\n const o = e.random || (e.rng || F)();\n if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, n) {\n t = t || 0;\n for (let i = 0; i < 16; ++i)\n n[t + i] = o[i];\n return n;\n }\n return J(o);\n}\nconst ve = (e) => {\n const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, h) => [...i, h.creator, h.updatedBy], []);\n return [\n n,\n t,\n ...o\n ].filter((i) => i);\n}, Ce = (e, n, t, o) => ({\n id: X(),\n annotation: e.id,\n created: t || /* @__PURE__ */ new Date(),\n creator: o,\n ...n\n}), Z = (e, n) => {\n const t = new Set(e.bodies.map((o) => o.id));\n return n.bodies.filter((o) => !t.has(o.id));\n}, K = (e, n) => {\n const t = new Set(n.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !t.has(o.id));\n}, ee = (e, n) => n.bodies.map((t) => {\n const o = e.bodies.find((i) => i.id === t.id);\n return { newBody: t, oldBody: o && !B(o, t) ? o : void 0 };\n}).filter(({ oldBody: t }) => t), te = (e, n) => !B(e.target, n.target), M = (e, n) => {\n const t = Z(e, n), o = K(e, n), i = ee(e, n);\n return {\n oldValue: e,\n newValue: n,\n bodiesCreated: t.length > 0 ? t : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: te(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0\n };\n};\nvar ne = /* @__PURE__ */ ((e) => (e.BODY_ONLY = \"BODY_ONLY\", e.TARGET_ONLY = \"TARGET_ONLY\", e))(ne || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = \"LOCAL\", e.REMOTE = \"REMOTE\", e))(O || {});\nconst oe = (e, n) => {\n var h, U;\n const { changes: t, origin: o } = n;\n if (!(!e.options.origin || e.options.origin === o))\n return !1;\n if (e.options.ignore) {\n const { ignore: b } = e.options, v = (T) => (T == null ? void 0 : T.length) > 0;\n if (!(v(t.created) || v(t.deleted))) {\n const T = (h = t.updated) == null ? void 0 : h.some((f) => v(f.bodiesCreated) || v(f.bodiesDeleted) || v(f.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((f) => f.targetUpdated);\n if (b === \"BODY_ONLY\" && T && !s || b === \"TARGET_ONLY\" && s && !T)\n return !1;\n }\n }\n if (e.options.annotations) {\n const b = /* @__PURE__ */ new Set([\n ...t.created.map((u) => u.id),\n ...t.deleted.map((u) => u.id),\n ...t.updated.map(({ oldValue: u }) => u.id)\n ]);\n return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => b.has(u));\n } else\n return !0;\n}, se = (e, n) => {\n const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), h = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), b = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)), v = [\n ...(e.created || []).filter((s) => !h.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: f }) => f.id === s.id).newValue : s),\n ...n.created || []\n ], u = [\n ...(e.deleted || []).filter((s) => !i.has(s.id)),\n ...(n.deleted || []).filter((s) => !t.has(s.id))\n ], T = [\n ...(e.updated || []).filter(({ newValue: s }) => !h.has(s.id)).map((s) => {\n const { oldValue: f, newValue: y } = s;\n if (U.has(y.id)) {\n const A = n.updated.find((L) => L.oldValue.id === y.id).newValue;\n return M(f, A);\n } else\n return s;\n }),\n ...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))\n ];\n return { created: v, deleted: u, updated: T };\n}, ie = (e) => e.id !== void 0, we = () => {\n const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (r, l = {}) => t.push({ onChange: r, options: l }), i = (r) => {\n const l = t.findIndex((a) => a.onChange == r);\n l > -1 && t.splice(l, 1);\n }, h = (r, l) => {\n const a = {\n origin: r,\n changes: {\n created: l.created || [],\n updated: l.updated || [],\n deleted: l.deleted || []\n },\n state: [...e.values()]\n };\n t.forEach((p) => {\n oe(p, a) && p.onChange(a);\n });\n }, U = (r, l = O.LOCAL) => {\n if (e.get(r.id))\n throw Error(`Cannot add annotation ${r.id} - exists already`);\n e.set(r.id, r), r.bodies.forEach((p) => n.set(p.id, r.id)), h(l, { created: [r] });\n }, b = (r, l) => {\n const a = typeof r == \"string\" ? l : r, p = typeof r == \"string\" ? r : r.id, C = e.get(p);\n if (C) {\n const D = M(C, a);\n return p === a.id ? e.set(p, a) : (e.delete(p), e.set(a.id, a)), C.bodies.forEach((x) => n.delete(x.id)), a.bodies.forEach((x) => n.set(x.id, a.id)), D;\n } else\n console.warn(`Cannot update annotation ${p} - does not exist`);\n }, v = (r, l = O.LOCAL, a = O.LOCAL) => {\n const p = ie(l) ? a : l, C = b(r, l);\n C && h(p, { updated: [C] });\n }, u = (r, l = O.LOCAL) => {\n const a = r.reduce((p, C) => {\n const D = b(C);\n return D ? [...p, D] : p;\n }, []);\n a.length > 0 && h(l, { updated: a });\n }, T = (r, l = O.LOCAL) => {\n const a = e.get(r.annotation);\n if (a) {\n const p = {\n ...a,\n bodies: [...a.bodies, r]\n };\n e.set(a.id, p), n.set(r.id, p.id), h(l, { updated: [{\n oldValue: a,\n newValue: p,\n bodiesCreated: [r]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${r.annotation}`);\n }, s = () => [...e.values()], f = (r = O.LOCAL) => {\n const l = [...e.values()];\n e.clear(), n.clear(), h(r, { deleted: l });\n }, y = (r, l = !0, a = O.LOCAL) => {\n if (l) {\n const p = [...e.values()];\n e.clear(), n.clear(), r.forEach((C) => {\n e.set(C.id, C), C.bodies.forEach((D) => n.set(D.id, C.id));\n }), h(a, { created: r, deleted: p });\n } else {\n const p = r.reduce((C, D) => {\n const x = e.get(D.id);\n return x ? [...C, x] : C;\n }, []);\n if (p.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${p.map((C) => C.id).join(\", \")}`);\n r.forEach((C) => {\n e.set(C.id, C), C.bodies.forEach((D) => n.set(D.id, C.id));\n }), h(a, { created: r });\n }\n }, A = (r) => {\n const l = typeof r == \"string\" ? r : r.id, a = e.get(l);\n if (a)\n return e.delete(l), a.bodies.forEach((p) => n.delete(p.id)), a;\n console.warn(`Attempt to delete missing annotation: ${l}`);\n }, L = (r, l = O.LOCAL) => {\n const a = A(r);\n a && h(l, { deleted: [a] });\n }, w = (r, l = O.LOCAL) => {\n const a = r.reduce((p, C) => {\n const D = A(C);\n return D ? [...p, D] : p;\n }, []);\n a.length > 0 && h(l, { deleted: a });\n }, c = (r, l = O.LOCAL) => {\n const a = e.get(r.annotation);\n if (a) {\n const p = a.bodies.find((C) => C.id === r.id);\n if (p) {\n n.delete(p.id);\n const C = {\n ...a,\n bodies: a.bodies.filter((x) => x.id !== r.id)\n };\n e.set(a.id, C), h(l, { updated: [{\n oldValue: a,\n newValue: C,\n bodiesDeleted: [p]\n }] });\n } else\n console.warn(`Attempt to delete missing body ${r.id} from annotation ${r.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${r.annotation}`);\n }, m = (r) => {\n const l = e.get(r);\n return l ? { ...l } : void 0;\n }, d = (r) => {\n const l = n.get(r);\n if (l) {\n const p = m(l).bodies.find((C) => C.id === r);\n if (p)\n return p;\n console.error(`Store integrity error: body ${r} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${r}`);\n }, E = (r, l) => {\n if (r.annotation !== l.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const a = e.get(r.annotation);\n if (a) {\n const p = a.bodies.find((D) => D.id === r.id), C = {\n ...a,\n bodies: a.bodies.map((D) => D.id === p.id ? l : D)\n };\n return e.set(a.id, C), p.id !== l.id && (n.delete(p.id), n.set(l.id, C.id)), {\n oldValue: a,\n newValue: C,\n bodiesUpdated: [{ oldBody: p, newBody: l }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${r.annotation}`);\n }, g = (r, l, a = O.LOCAL) => {\n const p = E(r, l);\n h(a, { updated: [p] });\n }, S = (r, l = O.LOCAL) => {\n const a = r.map((p) => E({ id: p.id, annotation: p.annotation }, p));\n h(l, { updated: a });\n }, I = (r) => {\n const l = e.get(r.annotation);\n if (l) {\n const a = {\n ...l,\n target: {\n ...l.target,\n ...r\n }\n };\n return e.set(l.id, a), {\n oldValue: l,\n newValue: a,\n targetUpdated: {\n oldTarget: l.target,\n newTarget: r\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${r.annotation}`);\n };\n return {\n addAnnotation: U,\n addBody: T,\n all: s,\n bulkAddAnnotation: y,\n bulkDeleteAnnotation: w,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: S,\n bulkUpdateTargets: (r, l = O.LOCAL) => {\n const a = r.map(I).filter((p) => p);\n a.length > 0 && h(l, { updated: a });\n },\n clear: f,\n deleteAnnotation: L,\n deleteBody: c,\n getAnnotation: m,\n getBody: d,\n observe: o,\n unobserve: i,\n updateAnnotation: v,\n updateBody: g,\n updateTarget: (r, l = O.LOCAL) => {\n const a = I(r);\n a && h(l, { updated: [a] });\n }\n };\n}, ye = (e) => ({\n ...e,\n subscribe: (t) => {\n const o = (i) => t(i.state);\n return e.observe(o), t(e.all()), () => e.unobserve(o);\n }\n});\nlet P = () => ({\n emit(e, ...n) {\n let t = this.events[e] || [];\n for (let o = 0, i = t.length; o < i; o++)\n t[o](...n);\n },\n events: {},\n on(e, n) {\n var t;\n return (t = this.events[e]) != null && t.push(n) || (this.events[e] = [n]), () => {\n var o;\n this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => n !== i);\n };\n }\n});\nconst de = 250, Ue = (e) => {\n const n = P(), t = [];\n let o = -1, i = !1, h = 0;\n const U = (d) => {\n if (!i) {\n const { changes: E } = d, g = performance.now();\n if (g - h > de)\n t.splice(o + 1), t.push(E), o = t.length - 1;\n else {\n const S = t.length - 1;\n t[S] = se(t[S], E);\n }\n h = g;\n }\n i = !1;\n };\n e.observe(U, { origin: O.LOCAL });\n const b = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d), v = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), u = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ oldValue: E }) => E)), T = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ newValue: E }) => E)), s = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), f = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d);\n return {\n canRedo: () => t.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => e.unobserve(U),\n on: (d, E) => n.on(d, E),\n redo: () => {\n if (t.length - 1 > o) {\n i = !0;\n const { created: d, updated: E, deleted: g } = t[o + 1];\n v(d), T(E), f(g), n.emit(\"redo\", t[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: d, updated: E, deleted: g } = t[o];\n b(d), u(E), s(g), n.emit(\"undo\", t[o]), o -= 1;\n }\n }\n };\n}, Le = () => {\n const { subscribe: e, set: n } = _([]);\n return {\n subscribe: e,\n set: n\n };\n}, Se = (e, n, t, o) => {\n const { store: i, selection: h, hover: U, viewport: b } = e, v = /* @__PURE__ */ new Map();\n let u = [], T, s;\n const f = (c, m) => {\n v.has(c) ? v.get(c).push(m) : v.set(c, [m]);\n }, y = (c, m) => {\n const d = v.get(c);\n d && d.indexOf(m) > 0 && d.splice(d.indexOf(m), 1);\n }, A = (c, m, d) => {\n v.has(c) && setTimeout(() => {\n v.get(c).forEach((E) => {\n if (t) {\n const g = Array.isArray(m) ? m.map((I) => t.serialize(I)) : t.serialize(m), S = d ? d instanceof PointerEvent ? d : t.serialize(d) : void 0;\n E(g, S);\n } else\n E(m, d);\n });\n }, 1);\n }, L = () => {\n const { selected: c } = h, m = c.map(({ id: d }) => i.getAnnotation(d));\n m.forEach((d) => {\n const E = u.find((g) => g.id === d.id);\n (!E || !B(E, d)) && A(\"updateAnnotation\", d, E);\n }), u = u.map((d) => {\n const E = m.find(({ id: g }) => g === d.id);\n return E || d;\n });\n };\n h.subscribe(({ selected: c }) => {\n if (!(u.length === 0 && c.length === 0)) {\n if (u.length === 0 && c.length > 0)\n u = c.map(({ id: m }) => i.getAnnotation(m));\n else if (u.length > 0 && c.length === 0)\n u.forEach((m) => {\n const d = i.getAnnotation(m.id);\n d && !B(d, m) && A(\"updateAnnotation\", d, m);\n }), u = [];\n else {\n const m = new Set(u.map((g) => g.id)), d = new Set(c.map(({ id: g }) => g));\n u.filter((g) => !d.has(g.id)).forEach((g) => {\n const S = i.getAnnotation(g.id);\n S && !B(S, g) && A(\"updateAnnotation\", S, g);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((g) => d.has(g.id)),\n // Add editable annotations that were selected\n ...c.filter(({ id: g }) => !m.has(g)).map(({ id: g }) => i.getAnnotation(g))\n ];\n }\n A(\"selectionChanged\", u);\n }\n }), U.subscribe((c) => {\n !T && c ? A(\"mouseEnterAnnotation\", i.getAnnotation(c)) : T && !c ? A(\"mouseLeaveAnnotation\", i.getAnnotation(T)) : T && c && (A(\"mouseLeaveAnnotation\", i.getAnnotation(T)), A(\"mouseEnterAnnotation\", i.getAnnotation(c))), T = c;\n }), b == null || b.subscribe((c) => A(\"viewportIntersect\", c.map(i.getAnnotation))), i.observe((c) => {\n o && (s && clearTimeout(s), s = setTimeout(L, 1e3));\n const { created: m, deleted: d } = c.changes;\n m.forEach((g) => A(\"createAnnotation\", g)), d.forEach((g) => A(\"deleteAnnotation\", g)), c.changes.updated.filter((g) => [\n ...g.bodiesCreated || [],\n ...g.bodiesDeleted || [],\n ...g.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: g, newValue: S }) => {\n const I = u.find((N) => N.id === g.id) || g;\n u = u.map((N) => N.id === g.id ? S : N), A(\"updateAnnotation\", S, I);\n });\n }, { origin: O.LOCAL }), i.observe((c) => {\n if (u) {\n const m = new Set(u.map((E) => E.id)), d = c.changes.updated.filter(({ newValue: E }) => m.has(E.id)).map(({ newValue: E }) => E);\n d.length > 0 && (u = u.map((E) => {\n const g = d.find((S) => S.id === E.id);\n return g || E;\n }));\n }\n }, { origin: O.REMOTE });\n const w = (c) => (m) => {\n const { created: d, deleted: E, updated: g } = m;\n d.forEach((S) => A(\"createAnnotation\", S)), E.forEach((S) => A(\"deleteAnnotation\", S)), c ? g.forEach((S) => A(\"updateAnnotation\", S.oldValue, S.newValue)) : g.forEach((S) => A(\"updateAnnotation\", S.newValue, S.oldValue));\n };\n return n.on(\"undo\", w(!0)), n.on(\"redo\", w(!1)), { on: f, off: y, emit: A };\n}, Te = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {\n const { parsed: i, error: h } = e.parse(o);\n return h ? {\n parsed: t.parsed,\n failed: [...t.failed, o]\n } : {\n parsed: [...t.parsed, i],\n failed: t.failed\n };\n}, { parsed: [], failed: [] }), Oe = (e, n, t) => {\n const { store: o, selection: i } = e, h = (w) => {\n if (t) {\n const { parsed: c, error: m } = t.parse(w);\n c ? o.addAnnotation(c, O.REMOTE) : console.error(m);\n } else\n o.addAnnotation(w, O.REMOTE);\n }, U = () => i.clear(), b = () => o.clear(), v = (w) => {\n const c = o.getAnnotation(w);\n return t && c ? t.serialize(c) : c;\n }, u = () => t ? o.all().map(t.serialize) : o.all(), T = () => {\n var m;\n const c = (((m = i.selected) == null ? void 0 : m.map((d) => d.id)) || []).map((d) => o.getAnnotation(d));\n return t ? c.map(t.serialize) : c;\n }, s = (w) => fetch(w).then((c) => c.json()).then((c) => (y(c), c)), f = (w) => {\n if (typeof w == \"string\") {\n const c = o.getAnnotation(w);\n return o.deleteAnnotation(w), t ? t.serialize(c) : c;\n } else {\n const c = t ? t.parse(w).parsed : w;\n return o.deleteAnnotation(c), w;\n }\n }, y = (w) => {\n if (t) {\n const { parsed: c, failed: m } = re(t)(w);\n m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(c, !0, O.REMOTE);\n } else\n o.bulkAddAnnotation(w, !0, O.REMOTE);\n }, A = (w) => {\n w ? i.setSelected(w) : i.clear();\n }, L = (w) => {\n if (t) {\n const c = t.parse(w).parsed, m = t.serialize(o.getAnnotation(c.id));\n return o.updateAnnotation(c), m;\n } else {\n const c = o.getAnnotation(w.id);\n return o.updateAnnotation(w), c;\n }\n };\n return {\n addAnnotation: h,\n cancelSelected: U,\n canRedo: n.canRedo,\n canUndo: n.canUndo,\n clearAnnotations: b,\n getAnnotationById: v,\n getAnnotations: u,\n getSelected: T,\n loadAnnotations: s,\n redo: n.redo,\n removeAnnotation: f,\n setAnnotations: y,\n setSelected: A,\n undo: n.undo,\n updateAnnotation: L\n };\n};\nlet ae = (e) => crypto.getRandomValues(new Uint8Array(e)), ce = (e, n, t) => {\n let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);\n return (h = n) => {\n let U = \"\";\n for (; ; ) {\n let b = t(i), v = i;\n for (; v--; )\n if (U += e[b[v] & o] || \"\", U.length === h)\n return U;\n }\n };\n}, le = (e, n = 21) => ce(e, n, ae), ue = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((n, t) => (t &= 63, t < 36 ? n += t.toString(36) : t < 62 ? n += (t - 26).toString(36).toUpperCase() : t > 62 ? n += \"-\" : n += \"_\", n), \"\");\nconst De = () => ({ isGuest: !0, id: le(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), fe = (e) => {\n const n = JSON.stringify(e);\n let t = 0;\n for (let o = 0, i = n.length; o < i; o++) {\n let h = n.charCodeAt(o);\n t = (t << 5) - t + h, t |= 0;\n }\n return `${t}`;\n}, Re = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {\n const { id: o, type: i, purpose: h, value: U, created: b, creator: v, ...u } = t;\n return {\n id: o || `temp-${fe(t)}`,\n annotation: n,\n type: i,\n purpose: h,\n value: U,\n created: b,\n creator: v ? typeof v == \"object\" ? { ...v } : v : void 0,\n ...u\n };\n}), xe = (e) => e.map((n) => {\n var o;\n const t = { ...n };\n return delete t.annotation, (o = t.id) != null && o.startsWith(\"temp-\") && delete t.id, t;\n}), pe = [\n \"#ff7c00\",\n // orange\n \"#1ac938\",\n // green\n \"#e8000b\",\n // red\n \"#8b2be2\",\n // purple\n \"#9f4800\",\n // brown\n \"#f14cc1\",\n // pink\n \"#ffc400\",\n // khaki\n \"#00d7ff\",\n // cyan\n \"#023eff\"\n // blue\n], he = () => {\n const e = [...pe];\n return { assignRandomColor: () => {\n const o = Math.floor(Math.random() * e.length), i = e[o];\n return e.splice(o, 1), i;\n }, releaseColor: (o) => e.push(o) };\n}, ge = () => {\n const e = he();\n return { addUser: (o, i) => {\n const h = e.assignRandomColor();\n return {\n label: i.name || i.id,\n avatar: i.avatar,\n color: h\n };\n }, removeUser: (o) => e.releaseColor(o.appearance.color) };\n}, me = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Be = ue(), Ie = (e = ge()) => {\n const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, f) => {\n if (t.has(s)) {\n console.warn(\"Attempt to add user that is already present\", s, f);\n return;\n }\n const y = e.addUser(s, f);\n t.set(s, {\n ...f,\n presenceKey: s,\n appearance: y\n });\n }, h = (s) => {\n const f = t.get(s);\n if (!f) {\n console.warn(\"Attempt to remove user that is not present\", s);\n return;\n }\n e.removeUser(f), t.delete(s);\n }, U = (s) => {\n const f = new Set(s.map((L) => L.presenceKey)), y = s.filter(({ presenceKey: L }) => !t.has(L)), A = Array.from(t.values()).filter((L) => !f.has(L.presenceKey));\n y.forEach(({ presenceKey: L, user: w }) => i(L, w)), A.forEach((L) => {\n const { presenceKey: w } = L;\n o.has(w) && n.emit(\"selectionChange\", L, null), h(w);\n }), (y.length > 0 || A.length > 0) && n.emit(\"presence\", u());\n }, b = (s, f) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Activity notification from user that is not present\");\n return;\n }\n const A = o.get(s);\n (!A || !me(A, f)) && (o.set(s, f), n.emit(\"selectionChange\", y, f));\n }, v = (s, f) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Selection change for user that is not present\", s);\n return;\n }\n f ? o.set(s, f) : o.delete(s), n.emit(\"selectionChange\", y, f);\n }, u = () => [...Array.from(t.values())];\n return {\n getPresentUsers: u,\n notifyActivity: b,\n on: (s, f) => n.on(s, f),\n syncUsers: U,\n updateSelection: v\n };\n};\nexport {\n ne as Ignore,\n O as Origin,\n Be as PRESENCE_KEY,\n G as PointerSelectAction,\n De as createAnonymousGuest,\n Oe as createBaseAnnotator,\n Ce as createBody,\n ge as createDefaultAppearenceProvider,\n Ee as createHoverState,\n Se as createLifecyleObserver,\n Ie as createPresenceState,\n be as createSelectionState,\n we as createStore,\n Ue as createUndoStack,\n Le as createViewportState,\n he as defaultColorProvider,\n M as diffAnnotations,\n ve as getContributors,\n se as mergeChanges,\n W as onPointerSelect,\n re as parseAll,\n Re as parseW3CBodies,\n Te as serializeAll,\n xe as serializeW3CBodies,\n oe as shouldNotify,\n ye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Annotator.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,32 +1,38 @@
1
- import { jsx as d } from "./annotorious-react.es12.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.es16.js";
4
- import { AnnotoriousContext as g } from "./annotorious-react.es2.js";
5
- const s = u({ viewer: null, setViewer: null }), C = (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
- }, D = () => {
24
- const { viewer: e } = l(s);
25
- return e;
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;
26
34
  };
27
35
  export {
28
- C as OpenSeadragonAnnotator,
29
- s as OpenSeadragonAnnotatorContext,
30
- D as useViewer
36
+ R as OpenSeadragonPopup
31
37
  };
32
38
  //# sourceMappingURL=annotorious-react.es9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es9.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 '..';\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.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,21 +1,20 @@
1
+ import { createAnonymousGuest as _createAnonymousGuest, createBody as _createBody, defaultColorProvider as _defaultColorProvider, Origin as _Origin, UserSelectAction as _UserSelectAction } 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 { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Appearance, AppearanceProvider, Color, DrawingStyle, Filter, FormatAdapter, HoverState, LifecycleEvents, ParseResult, PresentUser, Purpose, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget, W3CSelector } from '@annotorious/core';
7
- import { createAnonymousGuest as _createAnonymousGuest, createBody as _createBody, defaultColorProvider as _defaultColorProvider, Origin as _Origin, PointerSelectAction as _PointerSelectAction } from '@annotorious/core';
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';
8
9
  export { _createAnonymousGuest as createAnonymousGuest };
9
10
  export { _createBody as createBody };
10
11
  export { _defaultColorProvider as defaultColorProvider };
11
12
  export { _Origin as Origin };
12
- export { _PointerSelectAction as PointerSelectAction };
13
- export type { AnnotoriousOpts, DrawingMode, DrawingTool, ImageAnnotator as AnnotoriousImageAnnotator, ImageAnnotation } from '@annotorious/annotorious';
14
- import { createImageAnnotator as _createImageAnnotator } from '@annotorious/annotorious';
15
- export { _createImageAnnotator as createImageAnnotator };
13
+ export { _UserSelectAction as UserSelectAction };
14
+ export type { AnnotoriousOpts, DrawingMode, DrawingTool, FragmentSelector, ImageAnnotator as AnnotoriousImageAnnotator, ImageAnnotation, ImageAnnotatorState, Polygon, PolygonGeometry, Rectangle, RectangleGeometry, Shape, SVGSelector, W3CImageAnnotation, W3CImageAnnotationTarget, W3CImageFormatAdapter, W3CImageFormatAdapterOpts } 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, opts?: import('@annotorious/annotorious').W3CImageFormatAdapterOpts) => import('@annotorious/annotorious').W3CImageFormatAdapter;
16
18
  export type { OpenSeadragonAnnotator as AnnotoriousOpenSeadragonAnnotator } from '@annotorious/openseadragon';
17
- import { ShapeType as _ShapeType, W3CImageFormat as _W3CImageFormat } from '@annotorious/annotorious';
18
- export { _ShapeType as ShapeType };
19
- export { _W3CImageFormat as W3CImageFormat };
20
19
  export type { Viewer } from 'openseadragon';
21
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;AAGlE,YAAY,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,YAAY,EACZ,MAAM,EACN,aAAa,EACb,UAAU,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,aAAa,EACb,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,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AAc,mJAAkB,CAAC;AAG9C,YAAY,EACV,sBAAsB,IAAI,iCAAiC,EAC5D,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
- import OpenSeadragon from 'openseadragon';
3
- import { AnnotoriousOpts, DrawingStyle, Filter, ImageAnnotation } from '..';
4
- export declare const OpenSeadragonAnnotatorContext: import("react").Context<{
2
+ import { default as OpenSeadragon } from 'openseadragon';
3
+ import { AnnotoriousOpts, DrawingStyle, Filter, ImageAnnotation } from '@annotorious/annotorious';
4
+ export declare const OpenSeadragonAnnotatorContext: import('react').Context<{
5
5
  viewer: OpenSeadragon.Viewer;
6
6
  setViewer(viewer: OpenSeadragon.Viewer): void;
7
7
  }>;
@@ -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,IAAI,CAAC;AAG5E,eAAO,MAAM,6BAA6B;YAChC,cAAc,MAAM;sBACV,cAAc,MAAM,GAAG,IAAI;EACV,CAAC;AAEtC,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,OAAO,IAAI,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG;IAEjG,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,MAAM,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,KAAK,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,UAAU,EAAE,eAAe,KAAK,YAAY,CAAC,CAAC;IAEvE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAEtB,CAAA;AAED,eAAO,MAAM,sBAAsB,uGA8ClC,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;AAE1C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,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,OAAO,IAAI,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG;IAEjG,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,MAAM,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,KAAK,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,UAAU,EAAE,eAAe,KAAK,YAAY,CAAC,CAAC;IAEvE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAEtB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,OAAO,SAAS,2BAA2B,CAAC,CAAC,CAAC,4CAgD9F,CAAA;AAED,eAAO,MAAM,SAAS,4BAGrB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import OpenSeadragon from 'openseadragon';
2
+ import { default as OpenSeadragon } from 'openseadragon';
3
3
  import { AnnotoriousPopupProps } from '../AnnotoriousPopup';
4
4
  export type OpenSeadragonPopupProps = AnnotoriousPopupProps & {
5
5
  viewer: OpenSeadragon.Viewer;
@@ -1,8 +1,7 @@
1
- /// <reference types="react" />
2
- import OpenSeadragon from 'openseadragon';
1
+ import { default as OpenSeadragon } from 'openseadragon';
3
2
  export interface OpenSeadragonViewerProps {
4
3
  className?: string;
5
4
  options: OpenSeadragon.Options;
6
5
  }
7
- export declare const OpenSeadragonViewer: import("react").ForwardRefExoticComponent<OpenSeadragonViewerProps & import("react").RefAttributes<OpenSeadragon.Viewer>>;
6
+ export declare const OpenSeadragonViewer: import('react').ForwardRefExoticComponent<OpenSeadragonViewerProps & import('react').RefAttributes<OpenSeadragon.Viewer>>;
8
7
  //# sourceMappingURL=OpenSeadragonViewer.d.ts.map
@@ -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,2HAgC9B,CAAC"}
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"}
@@ -1,4 +1,4 @@
1
1
  import { ImageAnnotation } from '@annotorious/annotorious';
2
- import OpenSeadragon from 'openseadragon';
2
+ import { default as OpenSeadragon } from 'openseadragon';
3
3
  export declare const setPosition: (viewer: OpenSeadragon.Viewer, annotation: ImageAnnotation, popup: HTMLElement, sideOffset?: number) => void;
4
4
  //# sourceMappingURL=setPosition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setPosition.d.ts","sourceRoot":"","sources":["../../src/openseadragon/setPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,aAAa,MAAM,eAAe,CAAC;AAuB1C,eAAO,MAAM,WAAW,WACd,cAAc,MAAM,cAChB,eAAe,SACpB,WAAW,eACN,MAAM,SAqGnB,CAAA"}
1
+ {"version":3,"file":"setPosition.d.ts","sourceRoot":"","sources":["../../src/openseadragon/setPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,aAAa,MAAM,eAAe,CAAC;AAqB1C,eAAO,MAAM,WAAW,WACd,aAAa,CAAC,MAAM,cAChB,eAAe,SACpB,WAAW,eACN,MAAM,SAqGnB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/react",
3
- "version": "3.0.0-rc.9",
3
+ "version": "3.0.0",
4
4
  "description": "Annotorious React bindings",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -24,17 +24,16 @@
24
24
  "./annotorious-react.css": "./dist/annotorious-react.css"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/react": "^18.2.15",
28
- "@types/react-dom": "^18.2.7",
29
- "@vitejs/plugin-react": "^3.1.0",
30
- "typescript": "^4.9.5",
31
- "vite": "^4.4.9",
32
- "vite-plugin-dts": "^3.6.0",
33
- "vite-tsconfig-paths": "^4.2.1"
27
+ "@types/react": "^18.3.4",
28
+ "@types/react-dom": "^18.3.0",
29
+ "@vitejs/plugin-react": "^4.3.1",
30
+ "typescript": "5.5.4",
31
+ "vite": "^5.4.2",
32
+ "vite-plugin-dts": "^4.0.3",
33
+ "vite-tsconfig-paths": "^5.0.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@annotorious/annotorious": "*",
37
- "openseadragon": "^3.0.0 || ^4.0.0",
36
+ "openseadragon": "^3.0.0 || ^4.0.0 || ^5.0.0",
38
37
  "react": "16.8.0 || >=17.x || >=18.x",
39
38
  "react-dom": "16.8.0 || >=17.x || >=18.x"
40
39
  },
@@ -44,7 +43,10 @@
44
43
  }
45
44
  },
46
45
  "dependencies": {
47
- "@neodrag/react": "^2.0.3"
46
+ "@annotorious/core": "3.0.0",
47
+ "@annotorious/annotorious": "3.0.0",
48
+ "@annotorious/openseadragon": "3.0.0",
49
+ "@neodrag/react": "^2.0.4"
48
50
  },
49
51
  "sideEffects": false
50
- }
52
+ }