@annotorious/react-manifold 0.11.0 → 0.13.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 (47) hide show
  1. package/dist/annotorious-react-manifold.es.js +17 -17
  2. package/dist/annotorious-react-manifold.es10.js +599 -8
  3. package/dist/annotorious-react-manifold.es10.js.map +1 -1
  4. package/dist/annotorious-react-manifold.es11.js +2 -8
  5. package/dist/annotorious-react-manifold.es11.js.map +1 -1
  6. package/dist/annotorious-react-manifold.es12.js +2 -16
  7. package/dist/annotorious-react-manifold.es12.js.map +1 -1
  8. package/dist/annotorious-react-manifold.es2.js +17 -13
  9. package/dist/annotorious-react-manifold.es2.js.map +1 -1
  10. package/dist/annotorious-react-manifold.es3.js +14 -58
  11. package/dist/annotorious-react-manifold.es3.js.map +1 -1
  12. package/dist/annotorious-react-manifold.es4.js +12 -50
  13. package/dist/annotorious-react-manifold.es4.js.map +1 -1
  14. package/dist/annotorious-react-manifold.es5.js +59 -19
  15. package/dist/annotorious-react-manifold.es5.js.map +1 -1
  16. package/dist/annotorious-react-manifold.es6.js +48 -14
  17. package/dist/annotorious-react-manifold.es6.js.map +1 -1
  18. package/dist/annotorious-react-manifold.es7.js +3 -3
  19. package/dist/annotorious-react-manifold.es8.js +2 -46
  20. package/dist/annotorious-react-manifold.es8.js.map +1 -1
  21. package/dist/annotorious-react-manifold.es9.js +29 -1116
  22. package/dist/annotorious-react-manifold.es9.js.map +1 -1
  23. package/package.json +2 -5
  24. package/dist/annotorious-react-manifold.es13.js +0 -5
  25. package/dist/annotorious-react-manifold.es13.js.map +0 -1
  26. package/dist/annotorious-react-manifold.es14.js +0 -33
  27. package/dist/annotorious-react-manifold.es14.js.map +0 -1
  28. package/dist/annotorious-react-manifold.es15.js +0 -602
  29. package/dist/annotorious-react-manifold.es15.js.map +0 -1
  30. package/dist/annotorious-react-manifold.es16.js +0 -5
  31. package/dist/annotorious-react-manifold.es16.js.map +0 -1
  32. package/dist/annotorious-react-manifold.es17.js +0 -5
  33. package/dist/annotorious-react-manifold.es17.js.map +0 -1
  34. package/dist/annotorious-react-manifold.es18.js +0 -7
  35. package/dist/annotorious-react-manifold.es18.js.map +0 -1
  36. package/dist/annotorious-react-manifold.es19.js +0 -9
  37. package/dist/annotorious-react-manifold.es19.js.map +0 -1
  38. package/dist/annotorious-react-manifold.es20.js +0 -5
  39. package/dist/annotorious-react-manifold.es20.js.map +0 -1
  40. package/dist/annotorious-react-manifold.es21.js +0 -33
  41. package/dist/annotorious-react-manifold.es21.js.map +0 -1
  42. package/dist/annotorious-react-manifold.es22.js +0 -602
  43. package/dist/annotorious-react-manifold.es22.js.map +0 -1
  44. package/dist/annotorious-react-manifold.es23.js +0 -5
  45. package/dist/annotorious-react-manifold.es23.js.map +0 -1
  46. package/dist/annotorious-react-manifold.es24.js +0 -5
  47. package/dist/annotorious-react-manifold.es24.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react-manifold.es5.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { useContext, useEffect } from 'react';\nimport { OSDViewerContext } from './OpenSeadragonViewerManifold';\nimport { \n OpenSeadragonViewer as OpenSeadragonViewerInstance, \n OpenSeadragonViewerProps as OpenSeadragonViewerInstanceProps, \n useViewer \n} from '@annotorious/react';\n\n/** Passes the OSD viewer instance upwards to the manifold **/\nconst OpenSeadragonViewerInstanceShim = (props: { id: string }) => {\n\n const viewer = useViewer();\n\n const { setViewers } = useContext(OSDViewerContext);\n\n useEffect(() => {\n if (viewer) {\n setViewers(m => new Map(m.entries()).set(props.id, viewer));\n\n return () => {\n setViewers(m => new Map(Array.from(m.entries()).filter(([key, _]) => key !== props.id)));\n }\n }\n }, [viewer]);\n\n return null;\n\n}\n\ntype OpenSeadragonViewerProps = OpenSeadragonViewerInstanceProps & {\n\n id: string\n\n};\n\n/**\n * An alternative <OpenSeadragonViewer /> component that mimicks the original\n * from @annotorious/react, but injects a shim component that connects\n * the Viewer to the ViewerManifold.\n */\nexport const OpenSeadragonViewer = (props: OpenSeadragonViewerProps) => {\n\n return (\n <>\n <OpenSeadragonViewerInstance {...props} />\n <OpenSeadragonViewerInstanceShim id={props.id} />\n </>\n )\n\n}"],"names":["OpenSeadragonViewerInstanceShim","props","viewer","useViewer","setViewers","useContext","OSDViewerContext","useEffect","m","key","_","OpenSeadragonViewer","jsxs","Fragment","jsx","OpenSeadragonViewerInstance"],"mappings":";;;;;;AASA,MAAMA,IAAkC,CAACC,MAA0B;AAEjE,QAAMC,IAASC,KAET,EAAE,YAAAC,EAAA,IAAeC,EAAWC,CAAgB;AAElD,SAAAC,EAAU,MAAM;AACd,QAAIL;AACS,aAAAE,EAAA,CAAAI,MAAK,IAAI,IAAIA,EAAE,SAAS,EAAE,IAAIP,EAAM,IAAIC,CAAM,CAAC,GAEnD,MAAM;AACX,QAAAE,EAAW,OAAK,IAAI,IAAI,MAAM,KAAKI,EAAE,QAAS,CAAA,EAAE,OAAO,CAAC,CAACC,GAAKC,CAAC,MAAMD,MAAQR,EAAM,EAAE,CAAC,CAAC;AAAA,MAAA;AAAA,EAE3F,GACC,CAACC,CAAM,CAAC,GAEJ;AAET,GAaaS,IAAsB,CAACV,MAI9BW,gBAAAA,EAAA,KAAAC,YAAA,EAAA,UAAA;AAAA,EAACC,gBAAAA,EAAAA,IAAAC,GAAA,EAA6B,GAAGd,GAAO;AAAA,EACvCa,gBAAAA,EAAAA,IAAAd,GAAA,EAAgC,IAAIC,EAAM,GAAI,CAAA;AACjD,EAAA,CAAA;"}
1
+ {"version":3,"file":"annotorious-react-manifold.es5.js","sources":["../src/AnnotoriousManifold.tsx"],"sourcesContent":["import { ReactNode, createContext, useContext, useEffect, useRef, useState } from 'react';\nimport type { Annotation, Annotator } 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 id?: string;\n\n selected: { annotation: T, editable?: boolean }[],\n\n pointerEvent?: PointerEvent;\n\n}\n\n// @ts-ignore\nexport const AnnotoriousManifoldContext = createContext<AnnotoriousManifoldContextValue>();\n\nexport const AnnotoriousManifold = (props: { children: ReactNode }) => {\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 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, pointerEvent }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n // Set the new selection\n if (!muteSelectionEvents.current)\n setSelection({ id, selected: resolved, pointerEvent });\n\n // Track the state of the selected annotations in the store\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ id, selected }) => ({\n id,\n selected: selected.map(({ annotation, editable }) => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? { annotation: next.newValue, editable } : { annotation, editable };\n }),\n pointerEvent\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\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 }\n\n useEffect(() => {\n if (selection.id) {\n muteSelectionEvents.current = true;\n\n Array.from(annotators.entries()).forEach(([source, anno]) => {\n if (source !== selection.id)\n anno.setSelected();\n });\n\n muteSelectionEvents.current = false;\n }\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 { annotators } = useContext(AnnotoriousManifoldContext);\n return createManifoldInstance(annotators) as AnnotoriousManifoldInstance<I, E>;\n}\n\nexport const useAnnotator = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(id: string) => {\n const { annotators } = useContext(AnnotoriousManifoldContext);\n return annotators.get(id) as Annotator<I, E>;\n}\n\nexport const useAnnotations = <T extends Annotation>() => {\n const { annotations } = useContext(AnnotoriousManifoldContext);\n return annotations as Map<string, T[]>;\n}\n\nexport const useSelection = <T extends Annotation>() => {\n const { selection } = useContext(AnnotoriousManifoldContext);\n return 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","pointerEvent","resolved","editable","event","updated","annotation","next","u","key","_","useEffect","source","jsx","useAnnotoriousManifold","useContext","createManifoldInstance","useAnnotator","useA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F,GACG,YAAM,SACT,CAAA;AAGJ,GAEauB,IAAyB,MAAgF;AACpH,QAAM,EAAE,YAAAhC,EAAA,IAAeiC,EAAWrC,CAA0B;AAC5D,SAAOsC,EAAuBlC,CAAU;AAC1C,GAEamC,IAAe,CAA2EzB,MAAe;AACpH,QAAM,EAAE,YAAAV,EAAA,IAAeiC,EAAWrC,CAA0B;AACrD,SAAAI,EAAW,IAAIU,CAAE;AAC1B,GAEa0B,IAAiB,MAA4B;AACxD,QAAM,EAAE,aAAAjC,EAAA,IAAgB8B,EAAWrC,CAA0B;AACtD,SAAAO;AACT,GAEakC,IAAe,MAA4B;AACtD,QAAM,EAAE,WAAAhC,EAAA,IAAc4B,EAAWrC,CAA0B;AACpD,SAAAS;AACT;"}
@@ -1,18 +1,52 @@
1
- import { j as o } from "./annotorious-react-manifold.es7.js";
2
- import { createContext as i, useState as n, useContext as w } from "react";
3
- const r = i({
4
- viewers: void 0,
5
- setViewers: void 0
6
- }), v = (e) => {
7
- const [t, s] = n(/* @__PURE__ */ new Map());
8
- return /* @__PURE__ */ o.jsx(r.Provider, { value: { viewers: t, setViewers: s }, children: e.children });
9
- }, x = () => {
10
- const { viewers: e } = w(r);
11
- return e;
1
+ import { Origin as c } from "@annotorious/react";
2
+ const B = (r) => {
3
+ const e = (t) => Array.from(r.entries()).reduce((o, [n, s]) => {
4
+ if (o)
5
+ return o;
6
+ const a = s.state.store.getAnnotation(t);
7
+ if (a)
8
+ return { annotation: a, annotator: s, source: n };
9
+ }, void 0) || { annotation: void 0, annotator: void 0, source: void 0 }, i = (t, o = c.LOCAL) => {
10
+ const { annotator: n } = e(t.annotation);
11
+ n && n.state.store.addBody(t, o);
12
+ }, d = (t = c.LOCAL) => Array.from(r.values()).forEach((o) => o.state.store.clear(t)), f = (t, o = c.LOCAL) => {
13
+ const { annotation: n, annotator: s } = e(t);
14
+ if (s)
15
+ return s.state.store.deleteAnnotation(t, o), n;
16
+ }, u = (t, o = c.LOCAL) => {
17
+ const { annotator: n } = e(t.annotation);
18
+ n && n.state.store.deleteBody(t, o);
19
+ }, A = () => Array.from(r.values()).forEach((t) => t.destroy()), l = (t) => {
20
+ const { annotator: o } = e(t);
21
+ return o;
22
+ }, y = (t) => {
23
+ const { source: o } = e(t);
24
+ return o;
25
+ }, v = (t) => e(t).annotation, L = () => Array.from(r.values()).reduce((t, o) => [...t, ...o.state.store.all()], []), m = (t) => r.get(t), p = (t, o, n) => {
26
+ const s = typeof t == "string" ? t : t.id, { annotator: a } = e(s);
27
+ a && a.state.store.updateAnnotation(t, o, n);
28
+ }, O = (t) => {
29
+ const { annotator: o } = e(t);
30
+ o && o.setSelected(t);
31
+ };
32
+ return {
33
+ annotators: [...r.values()],
34
+ sources: [...r.keys()],
35
+ addBody: i,
36
+ clear: d,
37
+ deleteAnnotation: f,
38
+ deleteBody: u,
39
+ destroy: A,
40
+ findAnnotator: l,
41
+ findSource: y,
42
+ getAnnotation: v,
43
+ getAnnotations: L,
44
+ getAnnotator: m,
45
+ setSelected: O,
46
+ updateAnnotation: p
47
+ };
12
48
  };
13
49
  export {
14
- r as OSDViewerContext,
15
- v as OSDViewerManifold,
16
- x as useViewers
50
+ B as createManifoldInstance
17
51
  };
18
52
  //# sourceMappingURL=annotorious-react-manifold.es6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react-manifold.es6.js","sources":["../src/openseadragon/OpenSeadragonViewerManifold.tsx"],"sourcesContent":["import { ReactNode, createContext, useContext, useState } from 'react';\nimport { Viewer } from '@annotorious/react';\n\ninterface OSDViewerContextValue {\n\n viewers: Map<string, Viewer>;\n\n setViewers: React.Dispatch<React.SetStateAction<Map<string, Viewer>>>\n\n}\n\nexport const OSDViewerContext = createContext<OSDViewerContextValue>({\n\n viewers: undefined,\n\n setViewers: undefined,\n\n});\n\nexport const OSDViewerManifold = (props: { children: ReactNode }) => {\n\n const [viewers, setViewers] = useState(new Map<string, Viewer>());\n\n return (\n <OSDViewerContext.Provider value={{ viewers, setViewers }}>\n {props.children}\n </OSDViewerContext.Provider>\n )\n\n}\n\nexport const useViewers = () => {\n const { viewers } = useContext(OSDViewerContext);\n return viewers;\n}"],"names":["OSDViewerContext","createContext","OSDViewerManifold","props","viewers","setViewers","useState","jsx","useViewers","useContext"],"mappings":";;AAWO,MAAMA,IAAmBC,EAAqC;AAAA,EAEnE,SAAS;AAAA,EAET,YAAY;AAEd,CAAC,GAEYC,IAAoB,CAACC,MAAmC;AAEnE,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,oBAAI,KAAqB;AAG9D,SAAAC,gBAAAA,MAACP,EAAiB,UAAjB,EAA0B,OAAO,EAAE,SAAAI,GAAS,YAAAC,EAC1C,GAAA,UAAAF,EAAM,SACT,CAAA;AAGJ,GAEaK,IAAa,MAAM;AAC9B,QAAM,EAAE,SAAAJ,EAAA,IAAYK,EAAWT,CAAgB;AACxC,SAAAI;AACT;"}
1
+ {"version":3,"file":"annotorious-react-manifold.es6.js","sources":["../src/AnnotoriousManifoldInstance.ts"],"sourcesContent":["import { Origin } from '@annotorious/react';\nimport type {\n Annotation, \n AnnotationBody, \n Annotator\n} 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 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): 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 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) => {\n const { annotator } = find(id);\n if (annotator)\n annotator.setSelected(id);\n }\n\n return {\n annotators: [...annotators.values()],\n sources: [...annotators.keys()],\n addBody,\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","deleteAnnotation","id","deleteBody","destroy","findAnnotator","findSource","getAnnotation","getAnnotations","all","getAnnotator","updateAnnotation","arg1","arg2","arg3","oldId","setSelected"],"mappings":";AAuCa,MAAAA,IAAyB,CACpCC,MACsC;AAEtC,QAAMC,IAAO,CAACC,MACZ,MAAM,KAAKF,EAAW,SAAS,EAAE,OAAO,CAACG,GAAO,CAACC,GAAQC,CAAS,MAAM;AAClE,QAAAF;AACK,aAAAA;AAET,UAAMG,IAAaD,EAAU,MAAM,MAAM,cAAcH,CAAY;AAC/D,QAAAI;AACK,aAAA,EAAE,YAAAA,GAAY,WAAAD,GAAW,QAAAD;EACpC,GAAG,MAAuE,KAE1E,EAAE,YAAY,QAAW,WAAW,QAAW,QAAQ,OAAU,GAM7DG,IAAU,CAACC,GAAsBC,IAASC,EAAO,UAAU;AAC/D,UAAM,EAAE,WAAAL,EAAc,IAAAJ,EAAKO,EAAK,UAAU;AACtC,IAAAH,KACFA,EAAU,MAAM,MAAM,QAAQG,GAAMC,CAAM;AAAA,EAAA,GAGxCE,IAAQ,CAACF,IAASC,EAAO,UAC7B,MAAM,KAAKV,EAAW,OAAA,CAAQ,EAAE,QAAQ,CAAKY,MAAAA,EAAE,MAAM,MAAM,MAAMH,CAAM,CAAC,GAEpEI,IAAmB,CAACC,GAAYL,IAASC,EAAO,UAAU;AAC9D,UAAM,EAAE,YAAAJ,GAAY,WAAAD,EAAU,IAAIJ,EAAKa,CAAE;AAEzC,QAAIT;AACF,aAAAA,EAAU,MAAM,MAAM,iBAAiBS,GAAIL,CAAM,GAC1CH;AAAA,EACT,GAGIS,IAAa,CAACP,GAAsB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A,IACA,kBAAAE;AAAA,IACA,YAAAE;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,6 +1,6 @@
1
- import { __module as e } from "./annotorious-react-manifold.es13.js";
2
- import { __require as r } from "./annotorious-react-manifold.es14.js";
3
- import { __require as o } from "./annotorious-react-manifold.es15.js";
1
+ import { __module as e } from "./annotorious-react-manifold.es8.js";
2
+ import { __require as r } from "./annotorious-react-manifold.es9.js";
3
+ import { __require as o } from "./annotorious-react-manifold.es10.js";
4
4
  process.env.NODE_ENV === "production" ? e.exports = r() : e.exports = o();
5
5
  var m = e.exports;
6
6
  export {
@@ -1,49 +1,5 @@
1
- import { jsx as j } from "./annotorious-react-manifold.es18.js";
2
- import { createContext as B, forwardRef as D, useState as r, useImperativeHandle as G, useEffect as H, useContext as I } from "react";
3
- const p = B({
4
- anno: void 0,
5
- setAnno: void 0,
6
- annotations: [],
7
- selection: { selected: [] }
8
- }), V = D((a, m) => {
9
- const [t, f] = r(null), [A, l] = r([]), [x, d] = r({ selected: [] });
10
- return G(m, () => t), H(() => {
11
- if (t) {
12
- const { selection: h, store: e } = t.state;
13
- e.all().length > 0 && l(e.all());
14
- const c = (s) => l(() => e.all());
15
- e.observe(c);
16
- let o;
17
- const C = h.subscribe(({ selected: s, pointerEvent: E }) => {
18
- o && e.unobserve(o);
19
- const g = (s || []).map(({ id: n, editable: i }) => ({ annotation: e.getAnnotation(n), editable: i }));
20
- d({ selected: g, pointerEvent: E }), o = (n) => {
21
- const { updated: i } = n.changes;
22
- d(({ selected: w }) => ({
23
- selected: w.map(({ annotation: u, editable: b }) => {
24
- const v = i.find((S) => S.oldValue.id === u.id);
25
- return v ? { annotation: v.newValue, editable: b } : { annotation: u, editable: b };
26
- })
27
- }));
28
- }, e.observe(o, { annotations: s.map(({ id: n }) => n) });
29
- });
30
- return () => {
31
- e.unobserve(c), C();
32
- };
33
- }
34
- }, [t]), /* @__PURE__ */ j(p.Provider, { value: {
35
- anno: t,
36
- setAnno: f,
37
- annotations: A,
38
- selection: x
39
- }, children: a.children });
40
- }), k = () => {
41
- const { anno: a } = I(p);
42
- return a;
43
- };
1
+ var e = { exports: {} };
44
2
  export {
45
- V as Annotorious,
46
- p as AnnotoriousContext,
47
- k as useAnnotator
3
+ e as __module
48
4
  };
49
5
  //# sourceMappingURL=annotorious-react-manifold.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react-manifold.es8.js","sources":["../node_modules/@annotorious/react/dist/annotorious-react.es2.js"],"sourcesContent":["import { jsx as U } from \"./annotorious-react.es12.js\";\nimport { createContext as j, forwardRef as E, useState as f, useImperativeHandle as H, useEffect as h, useContext as s } from \"react\";\nimport { useDebounce as C } from \"./annotorious-react.es13.js\";\nconst n = j({\n anno: void 0,\n setAnno: void 0,\n annotations: [],\n selection: { selected: [] }\n}), B = E((t, r) => {\n const [o, u] = f(null), [p, c] = f([]), [A, l] = f({ selected: [] });\n return H(r, () => o), h(() => {\n if (o) {\n const { selection: m, store: e } = o.state;\n e.all().length > 0 && c(e.all());\n const v = (a) => c(() => e.all());\n e.observe(v);\n let i;\n const b = m.subscribe(({ selected: a, pointerEvent: w }) => {\n i && e.unobserve(i);\n const D = (a || []).map(({ id: d, editable: S }) => ({ annotation: e.getAnnotation(d), editable: S }));\n l({ selected: D, pointerEvent: w }), i = (d) => {\n const { updated: S } = d.changes;\n l(({ selected: I }) => ({\n selected: I.map(({ annotation: V, editable: g }) => {\n const x = S.find((O) => O.oldValue.id === V.id);\n return x ? { annotation: x.newValue, editable: g } : { annotation: V, editable: g };\n })\n }));\n }, e.observe(i, { annotations: a.map(({ id: d }) => d) });\n });\n return () => {\n e.unobserve(v), b();\n };\n }\n }, [o]), /* @__PURE__ */ U(n.Provider, { value: {\n anno: o,\n setAnno: u,\n annotations: p,\n selection: A\n }, children: t.children });\n}), F = () => s(n), G = () => {\n const { anno: t } = s(n);\n return t;\n}, J = () => {\n const { anno: t } = s(n);\n return t == null ? void 0 : t.state.store;\n}, P = () => {\n const { annotations: t } = s(n);\n return t;\n}, R = (t) => {\n const { annotations: r } = s(n);\n return C(r, t);\n}, K = (t) => t ? R(t) : P(), L = () => {\n const { selection: t } = s(n);\n return t;\n}, M = () => {\n const { anno: t } = s(n);\n return t == null ? void 0 : t.getUser();\n}, _ = () => {\n const { anno: t } = s(n), [r, o] = f([]);\n return h(() => {\n if (t) {\n const { store: u, viewport: p } = t.state;\n if (!p)\n return;\n let c;\n const A = p.subscribe((l) => {\n c && u.unobserve(c);\n const m = l.map((e) => u.getAnnotation(e));\n o(m), c = (e) => {\n const { updated: v } = e.changes;\n o((i) => i.map((b) => {\n const a = v.find((w) => w.oldValue.id === b.id);\n return a ? a.newValue : b;\n }));\n }, u.observe(c, { annotations: l });\n });\n return () => {\n A();\n };\n }\n }, [t]), r;\n}, k = (t) => {\n const r = _();\n return C(r, t);\n}, N = (t) => t ? k(t) : _();\nexport {\n B as Annotorious,\n n as AnnotoriousContext,\n J as useAnnotationStore,\n K as useAnnotations,\n G as useAnnotator,\n F as useAnnotatorState,\n M as useAnnotatorUser,\n L as useSelection,\n N as useViewportState\n};\n//# sourceMappingURL=annotorious-react.es2.js.map\n"],"names":["n","j","B","E","t","r","o","u","f","p","c","A","l","H","h","m","v","a","i","b","w","D","d","S","I","V","g","x","O","U","G","s"],"mappings":";;AAGK,MAACA,IAAIC,EAAE;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa,CAAE;AAAA,EACf,WAAW,EAAE,UAAU,GAAI;AAC7B,CAAC,GAAGC,IAAIC,EAAE,CAACC,GAAGC,MAAM;AAClB,QAAM,CAACC,GAAGC,CAAC,IAAIC,EAAE,IAAI,GAAG,CAACC,GAAGC,CAAC,IAAIF,EAAE,EAAE,GAAG,CAACG,GAAGC,CAA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