@annotorious/react-manifold 3.7.17 → 3.7.18

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":"AnnotoriousManifold.d.ts","sourceRoot":"","sources":["../src/AnnotoriousManifold.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0D,MAAM,OAAO,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAqC,MAAM,oBAAoB,CAAC;AAEnG,OAAO,EAAE,2BAA2B,EAA0B,MAAM,+BAA+B,CAAC;AAEpG,UAAU,+BAA+B;IAEvC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAExD,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAEvC,SAAS,EAAE,iBAAiB,CAAC;IAE7B,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,MAAM,IAAI,CAAC;CAEpF;AAED,UAAU,iBAAiB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAE3D,QAAQ,EAAE;QAAE,UAAU,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAEvE,KAAK,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;CAEtC;AAGD,eAAO,MAAM,0BAA0B,0DAAmD,CAAC;AAE3F,MAAM,WAAW,wBAAwB;IAEvC,oBAAoB,CAAC,EAAE,IAAI,CAAC;IAE5B,QAAQ,EAAE,SAAS,CAAC;CAErB;AAED,eAAO,MAAM,mBAAmB,GAAI,OAAO,wBAAwB,4C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C,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAEvE,KAAK,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;CAEtC;AAGD,eAAO,MAAM,0BAA0B,0DAAmD,CAAC;AAE3F,MAAM,WAAW,wBAAwB;IAEvC,oBAAoB,CAAC,EAAE,IAAI,CAAC;IAE5B,QAAQ,EAAE,SAAS,CAAC;CAErB;AAED,eAAO,MAAM,mBAAmB,GAAI,OAAO,wBAAwB,4CA2KlE,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,wCAI9G,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,EAAE,IAAI,MAAM,KAE5E,SAAS,CAAC,CAAC,EAAE,CAAC,CAClD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,uBAIlD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,UAAU,2BAIhD,CAAA"}
@@ -2,48 +2,50 @@ import { jsx as q } from "react/jsx-runtime";
2
2
  import { createContext as z, useState as y, useRef as V, useEffect as _, useContext as b } from "react";
3
3
  import { createManifoldInstance as j } from "./annotorious-react-manifold.es8.js";
4
4
  const m = z(), R = (e) => {
5
- const [A, g] = y(/* @__PURE__ */ new Map()), [E, w] = y(/* @__PURE__ */ new Map()), [x, u] = y({ selected: [] }), f = V(!1), K = (s, c) => {
6
- g((o) => new Map(o.entries()).set(s, c));
5
+ const [A, g] = y(/* @__PURE__ */ new Map()), [E, w] = y(/* @__PURE__ */ new Map()), [x, u] = y({ selected: [] }), f = V(!1), K = (r, c) => {
6
+ g((o) => new Map(o.entries()).set(r, c));
7
7
  const { store: i } = c.state, a = c.state.selection;
8
- w((o) => new Map(o.entries()).set(s, i.all()));
9
- const h = () => w((o) => new Map(o.entries()).set(s, i.all()));
8
+ w((o) => new Map(o.entries()).set(r, i.all()));
9
+ const h = () => w((o) => new Map(o.entries()).set(r, i.all()));
10
10
  i.observe(h);
11
11
  let n;
12
12
  const C = a.subscribe(({ selected: o, event: t }) => {
13
13
  n && i.unobserve(n);
14
- const l = (o || []).map((r) => ({ annotation: i.getAnnotation(r.id), editable: r.editable, annotatorId: s }));
15
- if (!f.current) {
16
- const r = (t == null ? void 0 : t.ctrlKey) || (t == null ? void 0 : t.metaKey) || (t == null ? void 0 : t.shiftKey);
17
- e.crossAnnotatorSelect ? l.length === 0 && !r ? u({ selected: [], event: t }) : u(r ? (S) => {
18
- const p = S.selected.filter((d) => d.annotatorId !== s);
19
- return {
20
- selected: [...l, ...p],
21
- event: t
22
- };
23
- } : { selected: l, event: t }) : u({ selected: l, event: t });
24
- }
25
- n = (r) => {
26
- const { updated: S } = r.changes;
14
+ const l = (o || []).map((s) => ({ annotation: i.getAnnotation(s.id), editable: s.editable, annotatorId: r }));
15
+ if (!f.current)
16
+ if (e.crossAnnotatorSelect) {
17
+ const s = !t || (t == null ? void 0 : t.ctrlKey) || (t == null ? void 0 : t.metaKey) || (t == null ? void 0 : t.shiftKey);
18
+ l.length === 0 && !s ? u({ selected: [], event: t }) : u(s ? (S) => {
19
+ const p = S.selected.filter((d) => d.annotatorId !== r);
20
+ return {
21
+ selected: [...l, ...p],
22
+ event: t
23
+ };
24
+ } : { selected: l, event: t });
25
+ } else
26
+ u({ selected: l, event: t });
27
+ n = (s) => {
28
+ const { updated: S } = s.changes;
27
29
  u(({ selected: p }) => ({
28
- id: e.crossAnnotatorSelect ? void 0 : s,
30
+ id: e.crossAnnotatorSelect ? void 0 : r,
29
31
  selected: p.map((d) => {
30
32
  const I = S.find((k) => k.oldValue.id === d.annotation.id);
31
33
  return I ? { annotation: I.newValue, editable: d.editable, annotatorId: d.annotatorId } : d;
32
34
  }),
33
35
  event: t
34
36
  }));
35
- }, i.observe(n, { annotations: o.map(({ id: r }) => r) });
37
+ }, i.observe(n, { annotations: o.map(({ id: s }) => s) });
36
38
  });
37
39
  let M;
38
40
  return e.crossAnnotatorSelect && (M = (o, t) => {
39
- (t != null && t.ctrlKey || t != null && t.metaKey || t != null && t.shiftKey) && a.selected.length === 1 && a.selected[0].id === o.id && (f.current = !0, a.clear(), u((r) => ({ selected: r.selected.filter((S) => S.annotatorId !== s), event: t })), f.current = !1, "viewer" in c && c.viewer.setMouseNavEnabled(!0));
41
+ (t != null && t.ctrlKey || t != null && t.metaKey || t != null && t.shiftKey) && a.selected.length === 1 && a.selected[0].id === o.id && (f.current = !0, a.clear(), u((s) => ({ selected: s.selected.filter((S) => S.annotatorId !== r), event: t })), f.current = !1, "viewer" in c && c.viewer.setMouseNavEnabled(!0));
40
42
  }, c.on("clickAnnotation", M)), () => {
41
- g((o) => new Map(Array.from(o.entries()).filter(([t, l]) => t !== s))), w((o) => new Map(Array.from(o.entries()).filter(([t, l]) => t !== s))), i.unobserve(h), C(), M && c.off("clickAnnotation", M);
43
+ g((o) => new Map(Array.from(o.entries()).filter(([t, l]) => t !== r))), w((o) => new Map(Array.from(o.entries()).filter(([t, l]) => t !== r))), i.unobserve(h), C(), M && c.off("clickAnnotation", M);
42
44
  };
43
45
  };
44
46
  return _(() => {
45
- f.current || (f.current = !0, Array.from(A.entries()).forEach(([s, c]) => {
46
- const i = new Set(c.getSelected().map((n) => n.id)), a = new Set(x.selected.filter((n) => n.annotatorId === s).map((n) => n.annotation.id));
47
+ f.current || (f.current = !0, Array.from(A.entries()).forEach(([r, c]) => {
48
+ const i = new Set(c.getSelected().map((n) => n.id)), a = new Set(x.selected.filter((n) => n.annotatorId === r).map((n) => n.annotation.id));
47
49
  i.size === a.size && [...i].every((n) => a.has(n)) || c.setSelected([...a]);
48
50
  }), f.current = !1);
49
51
  }, [x, A]), /* @__PURE__ */ q(m.Provider, { value: {
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react-manifold.es7.js","sources":["../src/AnnotoriousManifold.tsx"],"sourcesContent":["import { ReactNode, createContext, useContext, useEffect, useRef, useState } from 'react';\nimport type { Annotation, Annotator, AnnotoriousOpenSeadragonAnnotator } from '@annotorious/react';\nimport type { StoreChangeEvent } from '@annotorious/react';\nimport { AnnotoriousManifoldInstance, createManifoldInstance } from './AnnotoriousManifoldInstance';\n\ninterface AnnotoriousManifoldContextValue {\n\n annotators: Map<string, Annotator<any, { id: string }>>;\n\n annotations: Map<string, Annotation[]>;\n\n selection: ManifoldSelection;\n\n connectAnnotator(source: string, anno: Annotator<any, { id: string }>): () => void;\n\n}\n\ninterface ManifoldSelection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean, annotatorId: string }[],\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\n// @ts-ignore\nexport const AnnotoriousManifoldContext = createContext<AnnotoriousManifoldContextValue>();\n\nexport interface AnnotoriousManifoldProps {\n\n crossAnnotatorSelect?: true;\n\n children: ReactNode;\n\n}\n\nexport const AnnotoriousManifold = (props: AnnotoriousManifoldProps) => {\n\n const [annotators, setAnnotators] = useState<Map<string, Annotator<any, { id: string }>>>(new Map());\n\n const [annotations, setAnnotations] = useState<Map<string, Annotation[]>>(new Map());\n\n const [selection, setSelection] = \n useState<ManifoldSelection>({ selected: [] });\n\n // To prevent selection state updates when de-selecting other annotators\n const muteSelectionEvents = useRef<boolean>(false);\n\n const connectAnnotator = (id: string, anno: Annotator<any, { id: string }>) => {\n // Add the annotator to the state\n setAnnotators(m => new Map(m.entries()).set(id, anno))\n\n const { store } = anno.state;\n\n const selectionState = anno.state.selection;\n\n // Add the annotations to the state\n setAnnotations(m => new Map(m.entries()).set(id, store.all()));\n\n const onStoreChange = () =>\n setAnnotations(m => new Map(m.entries()).set(id, store.all()));\n\n store.observe(onStoreChange);\n\n // Track selection\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selectionState.subscribe(({ selected, event }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(t => ({ annotation: store.getAnnotation(t.id), editable: t.editable, annotatorId: id }));\n\n // Set the new selection\n if (!muteSelectionEvents.current) {\n const isMultiSelect = event?.ctrlKey || event?.metaKey || event?.shiftKey; \n if (props.crossAnnotatorSelect) {\n if (resolved.length === 0 && !isMultiSelect) {\n // When crossAnnotatorSelect is enabled, clearing the selection in one image\n // clears everything\n setSelection({ selected: [], event });\n } else {\n // If this is CMD/CTRL/SHIFT-select, modify the global selection instead\n // of replacing it.\n if (isMultiSelect) {\n setSelection(current => {\n const other = current.selected.filter(s => s.annotatorId !== id);\n return {\n selected: [...resolved, ...other],\n event\n };\n });\n } else {\n setSelection({ selected: resolved, event });\n }\n }\n } else {\n setSelection({ selected: resolved, event });\n }\n }\n\n // Track the state of the selected annotations in the store\n selectionStoreObserver = e => {\n const { updated } = e.changes;\n\n setSelection(({ selected }) => ({\n id: props.crossAnnotatorSelect ? undefined : id,\n selected: selected.map(s => {\n const next = updated.find(u => u.oldValue.id === s.annotation.id);\n return next ? { annotation: next.newValue, editable: s.editable, annotatorId: s.annotatorId } : s; \n }),\n event\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n // Edge case: if crossAnnotatorSelect is enabled, track the click event, so we can\n // toggle a single selected shape.\n let onClick: (annotation: { id: string}, event: PointerEvent) => void;\n\n if (props.crossAnnotatorSelect) {\n onClick = (annotation, event) => {\n // Nothing to do unless this is a CMD + click\n const isMultiSelect = event?.ctrlKey || event?.metaKey || event?.shiftKey;\n if (!isMultiSelect) return;\n\n // Nothing to do if there is no selection, or more than 1 – default\n // annotator selection behavior will handle everything correctly.\n if (selectionState.selected.length !== 1) return;\n\n // Only a single annotation selected? Nothing to do if it's not the selected one.\n if (selectionState.selected[0].id !== annotation.id) return;\n\n // Edge case: one selected annotation and the user CMD + clicked it - deselect!\n muteSelectionEvents.current = true;\n selectionState.clear();\n setSelection(current => ({ selected: current.selected.filter(t => t.annotatorId !== id), event }));\n muteSelectionEvents.current = false;\n\n // Special patching required for OSD: the click will have triggered a 'grab' event on the \n // shape in SVGDrawingLayer. This disables the OSD viewer navigation. (Because otherwise the \n // viewer would move along with the shape!) Normally, releasing the shape will re-enable viewer \n // navigation. HOWEVER: in this case, we clear the selection programmatically, which destroys \n // the editor shape before the 'release' event can trigger.\n // Therefore, we're re-enabling the viewer nav manually here!\n if ('viewer' in anno)\n (anno as AnnotoriousOpenSeadragonAnnotator).viewer.setMouseNavEnabled(true)\n }\n\n anno.on('clickAnnotation', onClick);\n }\n\n return () => {\n // Remove annotator\n setAnnotators(m => new Map(Array.from(m.entries()).filter(([key, _]) => key !== id)));\n\n // Remove & untrack annotations\n setAnnotations(m => new Map(Array.from(m.entries()).filter(([key, _]) => key !== id)));\n store.unobserve(onStoreChange);\n\n // Un-track selection\n unsubscribeSelection();\n\n // Un-track click\n if (onClick)\n anno.off('clickAnnotation', onClick);\n }\n }\n\n useEffect(() => {\n if (muteSelectionEvents.current) return;\n muteSelectionEvents.current = true;\n\n Array.from(annotators.entries()).forEach(([source, anno]) => {\n const currentSelection = new Set(anno.getSelected().map(s => s.id));\n\n const nextSelection = new Set(selection.selected\n .filter(s => s.annotatorId === source)\n .map(s => s.annotation.id));\n\n const isEqual = currentSelection.size === nextSelection.size &&\n [...currentSelection].every(id => nextSelection.has(id));\n\n if (!isEqual)\n anno.setSelected([...nextSelection]);\n });\n\n muteSelectionEvents.current = false;\n }, [selection, annotators]);\n\n return (\n <AnnotoriousManifoldContext.Provider value={{ \n annotators, \n annotations,\n selection,\n connectAnnotator \n }}>\n {props.children}\n </AnnotoriousManifoldContext.Provider>\n )\n\n}\n\nexport const useAnnotoriousManifold = <I extends Annotation = Annotation, E extends { id: string } = Annotation>() => {\n const ctx = useContext(AnnotoriousManifoldContext);\n if (ctx)\n return createManifoldInstance(ctx.annotators) as AnnotoriousManifoldInstance<I, E>;\n}\n\nexport const useAnnotator = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(id: string) => {\n const ctx = useContext(AnnotoriousManifoldContext);\n return ctx.annotators.get(id) as Annotator<I, E>;\n}\n\nexport const useAnnotations = <T extends Annotation>() => {\n const ctx = useContext(AnnotoriousManifoldContext);\n if (ctx)\n return ctx.annotations as Map<string, T[]>;\n}\n\nexport const useSelection = <T extends Annotation>() => {\n const ctx = useContext(AnnotoriousManifoldContext);\n if (ctx)\n return ctx.selection as ManifoldSelection<T>;\n}\n"],"names":["AnnotoriousManifoldContext","createContext","AnnotoriousManifold","props","annotators","setAnnotators","useState","annotations","setAnnotations","selection","setSelection","muteSelectionEvents","useRef","connectAnnotator","id","anno","m","store","selectionState","onStoreChange","selectionStoreObserver","unsubscribeSelection","selected","event","resolved","t","isMultiSelect","current","other","s","e","updated","next","u","onClick","annotation","key","_","useEffect","source","currentSelection","nextSelection","jsx","useAnnotoriousManifold","ctx","useContext","createManifoldInstance","useAnnotator","useAnnotations","useSelection"],"mappings":";;;AA0BO,MAAMA,IAA6BC,EAAA,GAU7BC,IAAsB,CAACC,MAAoC;AAEtE,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAsD,oBAAI,KAAK,GAE7F,CAACC,GAAaC,CAAc,IAAIF,EAAoC,oBAAI,KAAK,GAE7E,CAACG,GAAWC,CAAY,IAC5BJ,EAA4B,EAAE,UAAU,CAAA,GAAI,GAGxCK,IAAsBC,EAAgB,EAAK,GAE3CC,IAAmB,CAACC,GAAYC,MAAyC;AAE7E,IAAAV,EAAc,CAAAW,MAAK,IAAI,IAAIA,EAAE,QAAA,CAAS,EAAE,IAAIF,GAAIC,CAAI,CAAC;AAErD,UAAM,EAAE,OAAAE,MAAUF,EAAK,OAEjBG,IAAiBH,EAAK,MAAM;AAGlC,IAAAP,EAAe,CAAAQ,MAAK,IAAI,IAAIA,EAAE,SAAS,EAAE,IA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js","sources":["../src/AnnotoriousManifold.tsx"],"sourcesContent":["import { ReactNode, createContext, useContext, useEffect, useRef, useState } from 'react';\nimport type { Annotation, Annotator, AnnotoriousOpenSeadragonAnnotator } from '@annotorious/react';\nimport type { StoreChangeEvent } from '@annotorious/react';\nimport { AnnotoriousManifoldInstance, createManifoldInstance } from './AnnotoriousManifoldInstance';\n\ninterface AnnotoriousManifoldContextValue {\n\n annotators: Map<string, Annotator<any, { id: string }>>;\n\n annotations: Map<string, Annotation[]>;\n\n selection: ManifoldSelection;\n\n connectAnnotator(source: string, anno: Annotator<any, { id: string }>): () => void;\n\n}\n\ninterface ManifoldSelection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean, annotatorId: string }[],\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\n// @ts-ignore\nexport const AnnotoriousManifoldContext = createContext<AnnotoriousManifoldContextValue>();\n\nexport interface AnnotoriousManifoldProps {\n\n crossAnnotatorSelect?: true;\n\n children: ReactNode;\n\n}\n\nexport const AnnotoriousManifold = (props: AnnotoriousManifoldProps) => {\n\n const [annotators, setAnnotators] = useState<Map<string, Annotator<any, { id: string }>>>(new Map());\n\n const [annotations, setAnnotations] = useState<Map<string, Annotation[]>>(new Map());\n\n const [selection, setSelection] = \n useState<ManifoldSelection>({ selected: [] });\n\n // To prevent selection state updates when de-selecting other annotators\n const muteSelectionEvents = useRef<boolean>(false);\n\n const connectAnnotator = (id: string, anno: Annotator<any, { id: string }>) => {\n // Add the annotator to the state\n setAnnotators(m => new Map(m.entries()).set(id, anno))\n\n const { store } = anno.state;\n\n const selectionState = anno.state.selection;\n\n // Add the annotations to the state\n setAnnotations(m => new Map(m.entries()).set(id, store.all()));\n\n const onStoreChange = () =>\n setAnnotations(m => new Map(m.entries()).set(id, store.all()));\n\n store.observe(onStoreChange);\n\n // Track selection\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selectionState.subscribe(({ selected, event }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(t => ({ annotation: store.getAnnotation(t.id), editable: t.editable, annotatorId: id }));\n\n // Set the new selection\n if (!muteSelectionEvents.current) { \n if (props.crossAnnotatorSelect) {\n const allowMultiSelect = \n !event // Always allow programmatic cross-annotator multi-select \n || (event?.ctrlKey || event?.metaKey || event?.shiftKey); // Manual multi-select\n\n if (resolved.length === 0 && !allowMultiSelect) {\n // When crossAnnotatorSelect is enabled, clearing the selection in one image\n // clears everything\n setSelection({ selected: [], event });\n } else {\n // If this is CMD/CTRL/SHIFT- or programmatic select, modify the global selection instead\n // of replacing it.\n if (allowMultiSelect) {\n setSelection(current => {\n const other = current.selected.filter(s => s.annotatorId !== id);\n return {\n selected: [...resolved, ...other],\n event\n };\n });\n } else {\n setSelection({ selected: resolved, event });\n }\n }\n } else {\n setSelection({ selected: resolved, event });\n }\n }\n\n // Track the state of the selected annotations in the store\n selectionStoreObserver = e => {\n const { updated } = e.changes;\n\n setSelection(({ selected }) => ({\n id: props.crossAnnotatorSelect ? undefined : id,\n selected: selected.map(s => {\n const next = updated.find(u => u.oldValue.id === s.annotation.id);\n return next ? { annotation: next.newValue, editable: s.editable, annotatorId: s.annotatorId } : s; \n }),\n event\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n // Edge case: if crossAnnotatorSelect is enabled, track the click event, so we can\n // toggle a single selected shape.\n let onClick: (annotation: { id: string}, event: PointerEvent) => void;\n\n if (props.crossAnnotatorSelect) {\n onClick = (annotation, event) => {\n // Nothing to do unless this is a CMD + click\n const isMultiSelect = event?.ctrlKey || event?.metaKey || event?.shiftKey;\n if (!isMultiSelect) return;\n\n // Nothing to do if there is no selection, or more than 1 – default\n // annotator selection behavior will handle everything correctly.\n if (selectionState.selected.length !== 1) return;\n\n // Only a single annotation selected? Nothing to do if it's not the selected one.\n if (selectionState.selected[0].id !== annotation.id) return;\n\n // Edge case: one selected annotation and the user CMD + clicked it - deselect!\n muteSelectionEvents.current = true;\n selectionState.clear();\n setSelection(current => ({ selected: current.selected.filter(t => t.annotatorId !== id), event }));\n muteSelectionEvents.current = false;\n\n // Special patching required for OSD: the click will have triggered a 'grab' event on the \n // shape in SVGDrawingLayer. This disables the OSD viewer navigation. (Because otherwise the \n // viewer would move along with the shape!) Normally, releasing the shape will re-enable viewer \n // navigation. HOWEVER: in this case, we clear the selection programmatically, which destroys \n // the editor shape before the 'release' event can trigger.\n // Therefore, we're re-enabling the viewer nav manually here!\n if ('viewer' in anno)\n (anno as AnnotoriousOpenSeadragonAnnotator).viewer.setMouseNavEnabled(true)\n }\n\n anno.on('clickAnnotation', onClick);\n }\n\n return () => {\n // Remove annotator\n setAnnotators(m => new Map(Array.from(m.entries()).filter(([key, _]) => key !== id)));\n\n // Remove & untrack annotations\n setAnnotations(m => new Map(Array.from(m.entries()).filter(([key, _]) => key !== id)));\n store.unobserve(onStoreChange);\n\n // Un-track selection\n unsubscribeSelection();\n\n // Un-track click\n if (onClick)\n anno.off('clickAnnotation', onClick);\n }\n }\n\n useEffect(() => {\n if (muteSelectionEvents.current) return;\n muteSelectionEvents.current = true;\n\n Array.from(annotators.entries()).forEach(([source, anno]) => {\n const currentSelection = new Set(anno.getSelected().map(s => s.id));\n\n const nextSelection = new Set(selection.selected\n .filter(s => s.annotatorId === source)\n .map(s => s.annotation.id));\n\n const isEqual = currentSelection.size === nextSelection.size &&\n [...currentSelection].every(id => nextSelection.has(id));\n\n if (!isEqual)\n anno.setSelected([...nextSelection]);\n });\n\n muteSelectionEvents.current = false;\n }, [selection, annotators]);\n\n return (\n <AnnotoriousManifoldContext.Provider value={{ \n annotators, \n annotations,\n selection,\n connectAnnotator \n }}>\n {props.children}\n </AnnotoriousManifoldContext.Provider>\n )\n\n}\n\nexport const useAnnotoriousManifold = <I extends Annotation = Annotation, E extends { id: string } = Annotation>() => {\n const ctx = useContext(AnnotoriousManifoldContext);\n if (ctx)\n return createManifoldInstance(ctx.annotators) as AnnotoriousManifoldInstance<I, E>;\n}\n\nexport const useAnnotator = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(id: string) => {\n const ctx = useContext(AnnotoriousManifoldContext);\n return ctx.annotators.get(id) as Annotator<I, E>;\n}\n\nexport const useAnnotations = <T extends Annotation>() => {\n const ctx = useContext(AnnotoriousManifoldContext);\n if (ctx)\n return ctx.annotations as Map<string, T[]>;\n}\n\nexport const useSelection = <T extends Annotation>() => {\n const ctx = useContext(AnnotoriousManifoldContext);\n if (ctx)\n return ctx.selection as ManifoldSelection<T>;\n}\n"],"names":["AnnotoriousManifoldContext","createContext","AnnotoriousManifold","props","annotators","setAnnotators","useState","annotations","setAnnotations","selection","setSelection","muteSelectionEvents","useRef","connectAnnotator","id","anno","m","store","selectionState","onStoreChange","selectionStoreObserver","unsubscribeSelection","selected","event","resolved","t","allowMultiSelect","current","other","s","e","updated","next","u","onClick","annotation","key","_","useEffect","source","currentSelection","nextSelection","jsx","useAnnotoriousManifold","ctx","useContext","createManifoldInstance","useAnnotator","useAnnotations","useSelection"],"mappings":";;;AA0BO,MAAMA,IAA6BC,EAAA,GAU7BC,IAAsB,CAACC,MAAoC;AAEtE,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAsD,oBAAI,KAAK,GAE7F,CAACC,GAAaC,CAAc,IAAIF,EAAoC,oBAAI,KAAK,GAE7E,CAACG,GAAWC,CAAY,IAC5BJ,EAA4B,EAAE,UAAU,CAAA,GAAI,GAGxCK,IAAsBC,EAAgB,EAAK,GAE3CC,IAAmB,CAACC,GAAYC,MAAyC;AAE7E,IAAAV,EAAc,CAAAW,MAAK,IAAI,IAAIA,EAAE,QAAA,CAAS,EAAE,IAAIF,GAAIC,CAAI,CAAC;AAErD,UAAM,EAAE,OAAAE,MAAUF,EAAK,OAEjBG,IAAiBH,EAAK,MAAM;AAGlC,IAAAP,EAAe,CAAAQ,MAAK,IAAI,IAAIA,EAAE,SAAS,EAAE,IAAIF,GAAIG,EAAM,IA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origin as d } from "@annotorious/react";
2
- const k = (c) => {
3
- const i = (t) => Array.from(c.entries()).reduce((e, [n, r]) => {
2
+ const k = (a) => {
3
+ const i = (t) => Array.from(a.entries()).reduce((e, [n, r]) => {
4
4
  if (e)
5
5
  return e;
6
6
  const s = r.state.store.getAnnotation(t);
@@ -9,14 +9,14 @@ const k = (c) => {
9
9
  }, void 0) || { annotation: void 0, annotator: void 0, source: void 0 }, f = (t, e = d.LOCAL) => {
10
10
  const { annotator: n } = i(t.annotation);
11
11
  n && n.state.store.addBody(t, e);
12
- }, A = (t = d.LOCAL) => Array.from(c.values()).forEach((e) => e.state.store.clear(t)), p = (t, e = d.LOCAL) => {
12
+ }, A = (t = d.LOCAL) => Array.from(a.values()).forEach((e) => e.state.store.clear(t)), p = (t, e = d.LOCAL) => {
13
13
  const r = t.map((o) => typeof o == "string" ? o : o.id).map((o) => {
14
- const { source: a } = i(o);
15
- return { source: a, id: o };
14
+ const { source: c } = i(o);
15
+ return { source: c, id: o };
16
16
  }).filter((o) => o.source), s = Object.groupBy(r, (o) => o.source);
17
- Object.entries(s).forEach(([o, a]) => {
18
- const u = c.get(o);
19
- u && u.state.store.bulkDeleteAnnotations(a.map((l) => l.id), e);
17
+ Object.entries(s).forEach(([o, c]) => {
18
+ const u = a.get(o);
19
+ u && u.state.store.bulkDeleteAnnotations(c.map((l) => l.id), e);
20
20
  });
21
21
  }, y = (t, e = d.LOCAL) => {
22
22
  const n = t.map((s) => {
@@ -24,10 +24,10 @@ const k = (c) => {
24
24
  return { source: o, annotation: s };
25
25
  }).filter((s) => s.source), r = Object.groupBy(n, (s) => s.source);
26
26
  Object.entries(r).forEach(([s, o]) => {
27
- const a = c.get(s);
28
- if (!a) return;
27
+ const c = a.get(s);
28
+ if (!c) return;
29
29
  const u = o.map((l) => l.annotation).filter(Boolean);
30
- a.state.store.bulkUpdateAnnotations(u, e);
30
+ c.state.store.bulkUpdateAnnotations(u, e);
31
31
  });
32
32
  }, m = (t, e = d.LOCAL) => {
33
33
  const { annotation: n, annotator: r } = i(t);
@@ -36,28 +36,28 @@ const k = (c) => {
36
36
  }, L = (t, e = d.LOCAL) => {
37
37
  const { annotator: n } = i(t.annotation);
38
38
  n && n.state.store.deleteBody(t, e);
39
- }, h = () => Array.from(c.values()).forEach((t) => t.destroy()), O = (t) => {
39
+ }, h = () => Array.from(a.values()).forEach((t) => t.destroy()), O = (t) => {
40
40
  const { annotator: e } = i(t);
41
41
  return e;
42
42
  }, b = (t) => {
43
43
  const { source: e } = i(t);
44
44
  return e;
45
- }, g = (t) => i(t).annotation, v = () => Array.from(c.values()).reduce((t, e) => [...t, ...e.state.store.all()], []), C = (t) => c.get(t), B = (t, e, n) => {
45
+ }, g = (t) => i(t).annotation, v = () => Array.from(a.values()).reduce((t, e) => [...t, ...e.state.store.all()], []), C = (t) => a.get(t), B = (t, e, n) => {
46
46
  const r = typeof t == "string" ? t : t.id, { annotator: s } = i(r);
47
47
  s && s.state.store.updateAnnotation(t, e, n);
48
48
  }, E = (t, e) => {
49
49
  const n = /* @__PURE__ */ new Map();
50
50
  (Array.isArray(t) ? t : [t]).forEach((o) => {
51
- const { source: a } = i(o), u = [...n.get(a) || [], o];
52
- n.set(a, u);
53
- }), c.entries().filter(([o, a]) => !n.has(o)).map((o) => o[1]).forEach((o) => o.cancelSelected()), n.entries().forEach(([o, a]) => {
54
- const u = c.get(o);
55
- u && u.setSelected(t, e);
51
+ const { source: c } = i(o), u = [...n.get(c) || [], o];
52
+ n.set(c, u);
53
+ }), a.entries().filter(([o, c]) => !n.has(o)).map((o) => o[1]).forEach((o) => o.cancelSelected()), n.entries().forEach(([o, c]) => {
54
+ const u = a.get(o);
55
+ u && u.setSelected(c, e);
56
56
  });
57
57
  };
58
58
  return {
59
- annotators: [...c.values()],
60
- sources: [...c.keys()],
59
+ annotators: [...a.values()],
60
+ sources: [...a.keys()],
61
61
  addBody: f,
62
62
  bulkDeleteAnnotations: p,
63
63
  bulkUpdateAnnotations: y,
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react-manifold.es8.js","sources":["../src/AnnotoriousManifoldInstance.ts"],"sourcesContent":["import { Origin } from '@annotorious/react';\nimport type { Annotation, AnnotationBody, Annotator } from '@annotorious/react';\n\nexport interface AnnotoriousManifoldInstance<I extends Annotation = Annotation, E extends { id: string } = Annotation> {\n\n annotators: Annotator<I, E>[];\n\n sources: string[];\n\n addBody(body: AnnotationBody, origin?: Origin): void;\n\n bulkDeleteAnnotations(annotationsOrIds: (I | string)[], origin?: Origin): void;\n\n bulkUpdateAnnotations(annotations: I[], origin?: Origin): void; \n\n clear(origin: Origin): void;\n\n deleteAnnotation(id: string, origin?: Origin): I | undefined;\n\n deleteBody(body: AnnotationBody, origin?: Origin): void;\n\n destroy(): void;\n\n findAnnotator(annotationId: string): Annotator<I, E> | undefined;\n\n findSource(annotationId: string): string | undefined;\n\n getAnnotation(id: string): I | undefined;\n \n getAnnotations(): I[];\n\n getAnnotator(id: string): Annotator<I, E> | undefined;\n \n setSelected(annotationId: string | string[], editable?: boolean): void;\n\n updateAnnotation(arg1: string | I, arg2?: I | Origin, arg3?: Origin): void;\n\n}\n\nexport const createManifoldInstance = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(\n annotators: Map<string, Annotator<I, E>>\n): AnnotoriousManifoldInstance<I, E> => {\n\n const find = (annotationId: string): { annotation?: I, source?: string, annotator?: Annotator<I, E> } =>\n Array.from(annotators.entries()).reduce((found, [source, annotator]) => {\n if (found)\n return found;\n\n const annotation = annotator.state.store.getAnnotation(annotationId);\n if (annotation) \n return { annotation, annotator, source };\n }, undefined as { annotation: I, annotator: Annotator<I, E> } | undefined ) || \n\n { annotation: undefined, annotator: undefined, source: undefined };\n\n /*********/\n /** API **/\n /*********/\n\n const addBody = (body: AnnotationBody, origin = Origin.LOCAL) => {\n const { annotator } = find(body.annotation);\n if (annotator)\n annotator.state.store.addBody(body, origin);\n }\n\n const clear = (origin = Origin.LOCAL) =>\n Array.from(annotators.values()).forEach(a => a.state.store.clear(origin));\n\n const bulkDeleteAnnotations = (annotationsOrIds: (I | string)[], origin = Origin.LOCAL) => {\n const ids = annotationsOrIds.map(arg => typeof arg === 'string' ? arg : arg.id);\n\n const withAnnotator = ids.map(id => {\n const { source } = find(id);\n return { source, id };\n }).filter(t => t.source);\n\n const bySource = Object.groupBy(withAnnotator, t => t.source);\n\n Object.entries(bySource).forEach(([source, data]) => {\n const annotator = annotators.get(source);\n if (annotator)\n annotator.state.store.bulkDeleteAnnotations(data.map(d => d.id), origin);\n });\n }\n\n const bulkUpdateAnnotations = (annotations: I[], origin = Origin.LOCAL) => {\n const withAnnotator = annotations.map(annotation => {\n // Keep source and annotator, but replace annotation\n const { source } = find(annotation.id);\n return { source, annotation };\n }).filter(t => t.source);\n\n const bySource = Object.groupBy(withAnnotator, t => t.source);\n\n Object.entries(bySource).forEach(([source, data]) => {\n const annotator = annotators.get(source);\n if (!annotator) return;\n\n const toUpdate: I[] = data.map(d => d.annotation).filter(Boolean);\n annotator.state.store.bulkUpdateAnnotations(toUpdate, origin);\n })\n }\n\n const deleteAnnotation = (id: string, origin = Origin.LOCAL) => {\n const { annotation, annotator } = find(id);\n\n if (annotator) {\n annotator.state.store.deleteAnnotation(id, origin);\n return annotation;\n }\n }\n\n const deleteBody = (body: AnnotationBody, origin = Origin.LOCAL) => {\n const { annotator } = find(body.annotation);\n if (annotator)\n annotator.state.store.deleteBody(body, origin);\n }\n\n const destroy = () =>\n Array.from(annotators.values()).forEach(a => a.destroy());\n\n const findAnnotator = (annotationId: string) => {\n const { annotator } = find(annotationId);\n return annotator;\n }\n\n const findSource = (annotationId: string) => {\n const { source } = find(annotationId);\n return source;\n }\n\n const getAnnotation = (annotationId: string) => \n find(annotationId).annotation;\n\n const getAnnotations = () => \n Array.from(annotators.values()).reduce((all, annotator) =>\n [...all, ...annotator.state.store.all()], [] as I[]);\n\n const getAnnotator = (id: string) => annotators.get(id);\n\n const updateAnnotation = (arg1: string | I, arg2?: I | Origin, arg3?: Origin) => {\n const oldId: string = typeof arg1 === 'string' ? arg1 : arg1.id;\n\n const { annotator } = find(oldId);\n if (annotator)\n annotator.state.store.updateAnnotation(arg1, arg2, arg3);\n }\n\n const setSelected = (id: string | string[], editable?: boolean) => {\n const byAnnotator = new Map<string, string[]>();\n\n // Group annotations by annotator source\n const ids = Array.isArray(id) ? id : [id];\n ids.forEach(id => {\n const { source } = find(id);\n const atThisSource = [...(byAnnotator.get(source) || []), id];\n byAnnotator.set(source, atThisSource);\n });\n\n // byAnnotator will now include all annotators that have selected\n // annotations. But there may be an existing selection on annotators\n // that are not in byAnnotator. We need to clear it.\n const toClear = annotators\n .entries()\n .filter(([source, _]) => !byAnnotator.has(source))\n .map(t => t[1]);\n\n toClear.forEach(annotator => annotator.cancelSelected());\n\n byAnnotator.entries().forEach(([source, ids]) => {\n const annotator = annotators.get(source);\n if (annotator)\n annotator.setSelected(id, editable);\n });\n }\n\n return {\n annotators: [...annotators.values()],\n sources: [...annotators.keys()],\n addBody,\n bulkDeleteAnnotations,\n bulkUpdateAnnotations,\n clear,\n deleteAnnotation,\n deleteBody,\n destroy,\n findAnnotator,\n findSource,\n getAnnotation,\n getAnnotations,\n getAnnotator,\n setSelected,\n updateAnnotation\n }\n\n}"],"names":["createManifoldInstance","annotators","find","annotationId","found","source","annotator","annotation","addBody","body","origin","Origin","clear","a","bulkDeleteAnnotations","annotationsOrIds","withAnnotator","arg","id","t","bySource","data","d","bulkUpdateAnnotations","annotations","toUpdate","deleteAnnotation","deleteBody","destroy","findAnnotator","findSource","getAnnotation","getAnnotations","all","getAnnotator","updateAnnotation","arg1","arg2","arg3","oldId","setSelected","editable","byAnnotator","atThisSource","_","ids"],"mappings":";AAuCO,MAAMA,IAAyB,CACpCC,MACsC;AAEtC,QAAMC,IAAO,CAACC,MACZ,MAAM,KAAKF,EAAW,SAAS,EAAE,OAAO,CAACG,GAAO,CAACC,GAAQC,CAAS,MAAM;AACtE,QAAIF;AACF,aAAOA;AAET,UAAMG,IAAa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AC,GAAGA,EAAW,MAAM;AAAA,IAC9B,SAAAO;AAAA,IACA,uBAAAM;AAAA,IACA,uBAAAS;AAAA,IACA,OAAAX;AAAA,IACA,kBAAAc;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,eAAAC;AAAA,IACA,YAAAC;AAAA,IACA,eAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,cAAAE;AAAA,IACA,aAAAM;AAAA,IACA,kBAAAL;AAAA,EAAA;AAGJ;"}
1
+ {"version":3,"file":"annotorious-react-manifold.es8.js","sources":["../src/AnnotoriousManifoldInstance.ts"],"sourcesContent":["import { Origin } from '@annotorious/react';\nimport type { Annotation, AnnotationBody, Annotator } from '@annotorious/react';\n\nexport interface AnnotoriousManifoldInstance<I extends Annotation = Annotation, E extends { id: string } = Annotation> {\n\n annotators: Annotator<I, E>[];\n\n sources: string[];\n\n addBody(body: AnnotationBody, origin?: Origin): void;\n\n bulkDeleteAnnotations(annotationsOrIds: (I | string)[], origin?: Origin): void;\n\n bulkUpdateAnnotations(annotations: I[], origin?: Origin): void; \n\n clear(origin: Origin): void;\n\n deleteAnnotation(id: string, origin?: Origin): I | undefined;\n\n deleteBody(body: AnnotationBody, origin?: Origin): void;\n\n destroy(): void;\n\n findAnnotator(annotationId: string): Annotator<I, E> | undefined;\n\n findSource(annotationId: string): string | undefined;\n\n getAnnotation(id: string): I | undefined;\n \n getAnnotations(): I[];\n\n getAnnotator(id: string): Annotator<I, E> | undefined;\n \n setSelected(annotationId: string | string[], editable?: boolean): void;\n\n updateAnnotation(arg1: string | I, arg2?: I | Origin, arg3?: Origin): void;\n\n}\n\nexport const createManifoldInstance = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(\n annotators: Map<string, Annotator<I, E>>\n): AnnotoriousManifoldInstance<I, E> => {\n\n const find = (annotationId: string): { annotation?: I, source?: string, annotator?: Annotator<I, E> } =>\n Array.from(annotators.entries()).reduce((found, [source, annotator]) => {\n if (found)\n return found;\n\n const annotation = annotator.state.store.getAnnotation(annotationId);\n if (annotation) \n return { annotation, annotator, source };\n }, undefined as { annotation: I, annotator: Annotator<I, E> } | undefined ) || \n\n { annotation: undefined, annotator: undefined, source: undefined };\n\n /*********/\n /** API **/\n /*********/\n\n const addBody = (body: AnnotationBody, origin = Origin.LOCAL) => {\n const { annotator } = find(body.annotation);\n if (annotator)\n annotator.state.store.addBody(body, origin);\n }\n\n const clear = (origin = Origin.LOCAL) =>\n Array.from(annotators.values()).forEach(a => a.state.store.clear(origin));\n\n const bulkDeleteAnnotations = (annotationsOrIds: (I | string)[], origin = Origin.LOCAL) => {\n const ids = annotationsOrIds.map(arg => typeof arg === 'string' ? arg : arg.id);\n\n const withAnnotator = ids.map(id => {\n const { source } = find(id);\n return { source, id };\n }).filter(t => t.source);\n\n const bySource = Object.groupBy(withAnnotator, t => t.source);\n\n Object.entries(bySource).forEach(([source, data]) => {\n const annotator = annotators.get(source);\n if (annotator)\n annotator.state.store.bulkDeleteAnnotations(data.map(d => d.id), origin);\n });\n }\n\n const bulkUpdateAnnotations = (annotations: I[], origin = Origin.LOCAL) => {\n const withAnnotator = annotations.map(annotation => {\n // Keep source and annotator, but replace annotation\n const { source } = find(annotation.id);\n return { source, annotation };\n }).filter(t => t.source);\n\n const bySource = Object.groupBy(withAnnotator, t => t.source);\n\n Object.entries(bySource).forEach(([source, data]) => {\n const annotator = annotators.get(source);\n if (!annotator) return;\n\n const toUpdate: I[] = data.map(d => d.annotation).filter(Boolean);\n annotator.state.store.bulkUpdateAnnotations(toUpdate, origin);\n })\n }\n\n const deleteAnnotation = (id: string, origin = Origin.LOCAL) => {\n const { annotation, annotator } = find(id);\n\n if (annotator) {\n annotator.state.store.deleteAnnotation(id, origin);\n return annotation;\n }\n }\n\n const deleteBody = (body: AnnotationBody, origin = Origin.LOCAL) => {\n const { annotator } = find(body.annotation);\n if (annotator)\n annotator.state.store.deleteBody(body, origin);\n }\n\n const destroy = () =>\n Array.from(annotators.values()).forEach(a => a.destroy());\n\n const findAnnotator = (annotationId: string) => {\n const { annotator } = find(annotationId);\n return annotator;\n }\n\n const findSource = (annotationId: string) => {\n const { source } = find(annotationId);\n return source;\n }\n\n const getAnnotation = (annotationId: string) => \n find(annotationId).annotation;\n\n const getAnnotations = () => \n Array.from(annotators.values()).reduce((all, annotator) =>\n [...all, ...annotator.state.store.all()], [] as I[]);\n\n const getAnnotator = (id: string) => annotators.get(id);\n\n const updateAnnotation = (arg1: string | I, arg2?: I | Origin, arg3?: Origin) => {\n const oldId: string = typeof arg1 === 'string' ? arg1 : arg1.id;\n\n const { annotator } = find(oldId);\n if (annotator)\n annotator.state.store.updateAnnotation(arg1, arg2, arg3);\n }\n\n const setSelected = (id: string | string[], editable?: boolean) => {\n const byAnnotator = new Map<string, string[]>();\n\n // Group annotations by annotator source\n const ids = Array.isArray(id) ? id : [id];\n ids.forEach(id => {\n const { source } = find(id);\n const atThisSource = [...(byAnnotator.get(source) || []), id];\n byAnnotator.set(source, atThisSource);\n });\n\n // byAnnotator will now include all annotators that have selected\n // annotations. But there may be an existing selection on annotators\n // that are not in byAnnotator. We need to clear it.\n const toClear = annotators\n .entries()\n .filter(([source, _]) => !byAnnotator.has(source))\n .map(t => t[1]);\n\n toClear.forEach(annotator => annotator.cancelSelected());\n\n byAnnotator.entries().forEach(([source, ids]) => {\n const annotator = annotators.get(source);\n if (annotator)\n annotator.setSelected(ids, editable);\n });\n }\n\n return {\n annotators: [...annotators.values()],\n sources: [...annotators.keys()],\n addBody,\n bulkDeleteAnnotations,\n bulkUpdateAnnotations,\n clear,\n deleteAnnotation,\n deleteBody,\n destroy,\n findAnnotator,\n findSource,\n getAnnotation,\n getAnnotations,\n getAnnotator,\n setSelected,\n updateAnnotation\n }\n\n}"],"names":["createManifoldInstance","annotators","find","annotationId","found","source","annotator","annotation","addBody","body","origin","Origin","clear","a","bulkDeleteAnnotations","annotationsOrIds","withAnnotator","arg","id","t","bySource","data","d","bulkUpdateAnnotations","annotations","toUpdate","deleteAnnotation","deleteBody","destroy","findAnnotator","findSource","getAnnotation","getAnnotations","all","getAnnotator","updateAnnotation","arg1","arg2","arg3","oldId","setSelected","editable","byAnnotator","atThisSource","_","ids"],"mappings":";AAuCO,MAAMA,IAAyB,CACpCC,MACsC;AAEtC,QAAMC,IAAO,CAACC,MACZ,MAAM,KAAKF,EAAW,SAAS,EAAE,OAAO,CAACG,GAAO,CAACC,GAAQC,CAAS,MAAM;AACtE,QAAIF;AACF,aAAOA;AAET,UAAMG,IAAaD,EAAU,MAAM,MAAM,cAAcH,CAAY;AACnE,QAAII;AACF,aAAO,EAAE,YAAAA,GAAY,WAAAD,GAAW,QAAAD,EAAA;AAAA,EACpC,GAAG,MAAuE,KAE1E,EAAE,YAAY,QAAW,WAAW,QAAW,QAAQ,OAAA,GAMnDG,IAAU,CAACC,GAAsBC,IAASC,EAAO,UAAU;AAC/D,UAAM,EAAE,WAAAL,EAAA,IAAcJ,EAAKO,EAAK,UAAU;AAC1C,IAAIH,KACFA,EAAU,MAAM,MAAM,QAAQG,GAAMC,CAAM;AAAA,EAC9C,GAEME,IAAQ,CAACF,IAASC,EAAO,UAC7B,MAAM,KAAKV,EAAW,OAAA,CAAQ,EAAE,QAAQ,CAAAY,MAAKA,EAAE,MAAM,MAAM,MAAMH,CAAM,CAAC,GAEpEI,IAAwB,CAACC,GAAkCL,IAASC,EAAO,UAAU;AAGzF,UAAMK,IAFMD,EAAiB,IAAI,CAAAE,MAAO,OAAOA,KAAQ,WAAWA,IAAMA,EAAI,EAAE,EAEpD,IAAI,CAAAC,MAAM;AAClC,YAAM,EAAE,QAAAb,EAAA,IAAWH,EAAKgB,CAAE;AAC1B,aAAO,EAAE,QAAAb,GAAQ,IAAAa,EAAA;AAAA,IACnB,CAAC,EAAE,OAAO,CAAAC,MAAKA,EAAE,MAAM,GAEjBC,IAAW,OAAO,QAAQJ,GAAe,CAAAG,MAAKA,EAAE,MAAM;AAE5D,WAAO,QAAQC,CAAQ,EAAE,QAAQ,CAAC,CAACf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C,EAER,QAAQ,CAAAb,MAAaA,EAAU,eAAA,CAAgB,GAEvDoC,EAAY,UAAU,QAAQ,CAAC,CAACrC,GAAQwC,CAAG,MAAM;AAC/C,YAAMvC,IAAYL,EAAW,IAAII,CAAM;AACvC,MAAIC,KACFA,EAAU,YAAYuC,GAAKJ,CAAQ;AAAA,IACvC,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,YAAY,CAAC,GAAGxC,EAAW,QAAQ;AAAA,IACnC,SAAS,CAAC,GAAGA,EAAW,MAAM;AAAA,IAC9B,SAAAO;AAAA,IACA,uBAAAM;AAAA,IACA,uBAAAS;AAAA,IACA,OAAAX;AAAA,IACA,kBAAAc;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,eAAAC;AAAA,IACA,YAAAC;AAAA,IACA,eAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,cAAAE;AAAA,IACA,aAAAM;AAAA,IACA,kBAAAL;AAAA,EAAA;AAGJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/react-manifold",
3
- "version": "3.7.17",
3
+ "version": "3.7.18",
4
4
  "description": "A utility to manage multiple parallel Annotorious instances more efficiently",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -31,8 +31,8 @@
31
31
  "test": "echo 'Skipping tests in @annotorious/annotorious-react-manifold package'"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/react": "^19.2.2",
35
- "@types/react-dom": "^19.2.2",
34
+ "@types/react": "^19.2.6",
35
+ "@types/react-dom": "^19.2.3",
36
36
  "@vitejs/plugin-react": "^4.7.0",
37
37
  "typescript": "^5.9.3",
38
38
  "vite": "^5.4.21",
@@ -40,7 +40,7 @@
40
40
  "vite-tsconfig-paths": "^5.1.4"
41
41
  },
42
42
  "peerDependencies": {
43
- "@annotorious/react": "3.7.17",
43
+ "@annotorious/react": "3.7.18",
44
44
  "openseadragon": ">= ^4.0.0 || >= ^5.0.0",
45
45
  "react": "^16.8.0 || >= ^17.x || >= ^18.x || >= ^19.x",
46
46
  "react-dom": "^16.8.0 || >= ^17.x || >= ^18.x|| >= ^19.x"
@@ -1,3 +0,0 @@
1
- import { Annotation, Annotator } from '@annotorious/react';
2
- export declare const synchronizeInstances: <I extends Annotation = Annotation, E extends unknown = Annotation>(instances: Annotator<I, E>[]) => any;
3
- //# sourceMappingURL=synchronizeInstances.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"synchronizeInstances.d.ts","sourceRoot":"","sources":["../src/synchronizeInstances.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE3D,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS,OAAO,GAAG,UAAU,EACpG,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAO7B,CAAA"}