@annotorious/react-manifold 3.2.2 → 3.2.4

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.
@@ -5,6 +5,8 @@ export interface AnnotoriousManifoldInstance<I extends Annotation = Annotation,
5
5
  annotators: Annotator<I, E>[];
6
6
  sources: string[];
7
7
  addBody(body: AnnotationBody, origin?: Origin): void;
8
+ bulkDeleteAnnotations(annotationsOrIds: (I | string)[], origin?: Origin): void;
9
+ bulkUpdateAnnotations(annotations: I[], origin?: Origin): void;
8
10
  clear(origin: Origin): void;
9
11
  deleteAnnotation(id: string, origin?: Origin): I | undefined;
10
12
  deleteBody(body: AnnotationBody, origin?: Origin): void;
@@ -1 +1 @@
1
- {"version":3,"file":"AnnotoriousManifoldInstance.d.ts","sourceRoot":"","sources":["../src/AnnotoriousManifoldInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEhF,MAAM,WAAW,2BAA2B,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU;IAEnH,UAAU,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IAE9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErD,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAE7D,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,I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CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAE5E;AAED,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,EAC7G,YAAY,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KACvC,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAoIlC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react-manifold.es5.js","sources":["../src/plugins/PluginProvider.tsx"],"sourcesContent":["import { createContext, ReactNode, useContext, useEffect, useMemo, useState } from 'react';\nimport { Annotator } from '@annotorious/react';\nimport { AnnotoriousManifoldContext } from '../AnnotoriousManifold';\nimport { createPluginManifold } from './PluginManifoldInstance';\n\ninterface PluginManifoldData {\n\n mountFn: (anno: Annotator, opts?: any) => unknown;\n\n opts?: any;\n\n}\n\ninterface PluginProviderContextValue {\n\n setPlugins: React.Dispatch<React.SetStateAction<Map<string, PluginManifoldData>>>\n\n manifolds: Map<string, unknown>;\n\n}\n\n// @ts-ignore\nexport const PluginProviderContext = createContext<PluginProviderContextValue>(undefined); \n\ninterface PluginProviderProps {\n\n children: ReactNode;\n\n}\n\nexport const PluginProvider = (props: PluginProviderProps) => {\n\n const context = useContext(AnnotoriousManifoldContext);\n\n const annotators = useMemo(() => (\n Array.from(context.annotators.values())\n ), [Array.from(context.annotators.keys()).join(':')]);\n\n // Registered plugins (by plugin name)\n const [plugins, setPlugins] = useState<Map<string, PluginManifoldData>>(new Map());\n\n // One manifold per plugin (each managing one plugin instance per annotator)\n const [manifolds, setManifolds] = useState<Map<string, any>>();\n\n useEffect(() => {\n const manifoldInstances = Array.from(plugins.entries()).map(([name, { mountFn, opts }]) => {\n return [name, createPluginManifold(annotators, mountFn, opts)];\n }) as [string, any][];\n\n setManifolds(new Map(manifoldInstances));\n\n return () => {\n manifoldInstances.forEach(([_, instance]) => instance.destroy && instance.destroy());\n }\n }, [annotators, plugins]);\n\n return (\n <PluginProviderContext.Provider value={{ setPlugins, manifolds }}>\n {props.children}\n </PluginProviderContext.Provider>\n )\n\n}\n\nexport const usePluginManifold = <P extends unknown>(name: string) => {\n const { manifolds } = useContext(PluginProviderContext);\n return manifolds.get(name) as P;\n}"],"names":["PluginProviderContext","createContext","PluginProvider","props","context","useContext","AnnotoriousManifoldContext","annotators","useMemo","plugins","setPlugins","useState","manifolds","setManifolds","useEffect","manifoldInstances","name","mountFn","opts","createPluginManifold","_","instance","jsx","usePluginManifold"],"mappings":";;;;AAsBa,MAAAA,IAAwBC,EAA0C,MAAS,GAQ3EC,IAAiB,CAACC,MAA+B;AAEtD,QAAAC,IAAUC,EAAWC,CAA0B,GAE/CC,IAAaC,EAAQ,MACzB,MAAM,KAAKJ,EAAQ,WAAW,QAAQ,GACrC,CAAC,MAAM,KAAKA,EAAQ,WAAW,KAAM,CAAA,EAAE,KAAK,GAAG,CAAC,CAAC,GAG9C,CAACK,GAASC,CAAU,IAAIC,EAA0C,oBAAI,KAAK,GAG3E,CAACC,GAAWC,CAAY,IAAIF,EAA2B;AAE7D,SAAAG,EAAU,MAAM;AACd,UAAMC,IAAoB,MAAM,KAAKN,EAAQ,QAAS,CAAA,EAAE,IAAI,CAAC,CAACO,GAAM,EAAE,SAAAC,GAAS,MAAAC,EAAM,CAAA,MAC5E,CAACF,GAAMG,EAAqBZ,GAAYU,GAASC,CAAI,CAAC,CAC9D;AAEY,WAAAL,EAAA,IAAI,IAAIE,CAAiB,CAAC,GAEhC,MAAM;AACO,MAAAA,EAAA,QAAQ,CAAC,CAACK,GAAGC,CAAQ,MAAMA,EAAS,WAAWA,EAAS,SAAS;AAAA,IACrF;AAAA,EAAA,GACC,CAACd,GAAYE,CAAO,CAAC,GAGtB,gBAAAa,EAACtB,EAAsB,UAAtB,EAA+B,OAAO,EAAE,YAAAU,GAAY,WAAAE,KAClD,UAAAT,EAAM,SACT,CAAA;AAGJ,GAEaoB,IAAoB,CAAoBP,MAAiB;AACpE,QAAM,EAAE,WAAAJ,EAAA,IAAcP,EAAWL,CAAqB;AAC/C,SAAAY,EAAU,IAAII,CAAI;AAC3B;"}
1
+ {"version":3,"file":"annotorious-react-manifold.es5.js","sources":["../src/plugins/PluginProvider.tsx"],"sourcesContent":["import { createContext, ReactNode, useContext, useEffect, useMemo, useState } from 'react';\nimport { Annotator } from '@annotorious/react';\nimport { AnnotoriousManifoldContext } from '../AnnotoriousManifold';\nimport { createPluginManifold, PluginManifoldProxy } from './PluginManifoldInstance';\n\ninterface PluginManifoldData {\n\n mountFn: (anno: Annotator, opts?: any) => unknown;\n\n opts?: any;\n\n}\n\ninterface PluginProviderContextValue {\n\n setPlugins: React.Dispatch<React.SetStateAction<Map<string, PluginManifoldData>>>\n\n manifolds: Map<string, unknown>;\n\n}\n\n// @ts-ignore\nexport const PluginProviderContext = createContext<PluginProviderContextValue>(undefined); \n\ninterface PluginProviderProps {\n\n children: ReactNode;\n\n}\n\nexport const PluginProvider = (props: PluginProviderProps) => {\n\n const context = useContext(AnnotoriousManifoldContext);\n\n const annotators = useMemo(() => (\n Array.from(context.annotators.values())\n ), [Array.from(context.annotators.keys()).join(':')]);\n\n // Registered plugins (by plugin name)\n const [plugins, setPlugins] = useState<Map<string, PluginManifoldData>>(new Map());\n\n // One manifold per plugin (each managing one plugin instance per annotator)\n const [manifolds, setManifolds] = useState<Map<string, any>>();\n\n useEffect(() => {\n const manifoldInstances = Array.from(plugins.entries()).map(([name, { mountFn, opts }]) => {\n return [name, createPluginManifold(annotators, mountFn, opts)];\n }) as [string, any][];\n\n setManifolds(new Map(manifoldInstances));\n\n return () => {\n manifoldInstances.forEach(([_, instance]) => instance.destroy && instance.destroy());\n }\n }, [annotators, plugins]);\n\n return (\n <PluginProviderContext.Provider value={{ setPlugins, manifolds }}>\n {props.children}\n </PluginProviderContext.Provider>\n )\n\n}\n\nexport const usePluginManifold = <P extends unknown>(name: string) => {\n const { manifolds } = useContext(PluginProviderContext);\n return manifolds.get(name) as PluginManifoldProxy<P>;\n}"],"names":["PluginProviderContext","createContext","PluginProvider","props","context","useContext","AnnotoriousManifoldContext","annotators","useMemo","plugins","setPlugins","useState","manifolds","setManifolds","useEffect","manifoldInstances","name","mountFn","opts","createPluginManifold","_","instance","jsx","usePluginManifold"],"mappings":";;;;AAsBa,MAAAA,IAAwBC,EAA0C,MAAS,GAQ3EC,IAAiB,CAACC,MAA+B;AAEtD,QAAAC,IAAUC,EAAWC,CAA0B,GAE/CC,IAAaC,EAAQ,MACzB,MAAM,KAAKJ,EAAQ,WAAW,QAAQ,GACrC,CAAC,MAAM,KAAKA,EAAQ,WAAW,KAAM,CAAA,EAAE,KAAK,GAAG,CAAC,CAAC,GAG9C,CAACK,GAASC,CAAU,IAAIC,EAA0C,oBAAI,KAAK,GAG3E,CAACC,GAAWC,CAAY,IAAIF,EAA2B;AAE7D,SAAAG,EAAU,MAAM;AACd,UAAMC,IAAoB,MAAM,KAAKN,EAAQ,QAAS,CAAA,EAAE,IAAI,CAAC,CAACO,GAAM,EAAE,SAAAC,GAAS,MAAAC,EAAM,CAAA,MAC5E,CAACF,GAAMG,EAAqBZ,GAAYU,GAASC,CAAI,CAAC,CAC9D;AAEY,WAAAL,EAAA,IAAI,IAAIE,CAAiB,CAAC,GAEhC,MAAM;AACO,MAAAA,EAAA,QAAQ,CAAC,CAACK,GAAGC,CAAQ,MAAMA,EAAS,WAAWA,EAAS,SAAS;AAAA,IACrF;AAAA,EAAA,GACC,CAACd,GAAYE,CAAO,CAAC,GAGtB,gBAAAa,EAACtB,EAAsB,UAAtB,EAA+B,OAAO,EAAE,YAAAU,GAAY,WAAAE,KAClD,UAAAT,EAAM,SACT,CAAA;AAGJ,GAEaoB,IAAoB,CAAoBP,MAAiB;AACpE,QAAM,EAAE,WAAAJ,EAAA,IAAcP,EAAWL,CAAqB;AAC/C,SAAAY,EAAU,IAAII,CAAI;AAC3B;"}
@@ -1,52 +1,74 @@
1
- import { Origin as c } from "@annotorious/react";
2
- const B = (r) => {
3
- const e = (t) => Array.from(r.entries()).reduce((o, [n, s]) => {
1
+ import { Origin as u } from "@annotorious/react";
2
+ const j = (c) => {
3
+ const a = (t) => Array.from(c.entries()).reduce((o, [n, s]) => {
4
4
  if (o)
5
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);
6
+ const e = s.state.store.getAnnotation(t);
7
+ if (e)
8
+ return { annotation: e, annotator: s, source: n };
9
+ }, void 0) || { annotation: void 0, annotator: void 0, source: void 0 }, l = (t, o = u.LOCAL) => {
10
+ const { annotator: n } = a(t.annotation);
11
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);
12
+ }, A = (t = u.LOCAL) => Array.from(c.values()).forEach((o) => o.state.store.clear(t)), p = (t, o = u.LOCAL) => {
13
+ const s = t.map((r) => typeof r == "string" ? r : r.id).map((r) => {
14
+ const { source: i } = a(r);
15
+ return { source: i, id: r };
16
+ }).filter((r) => r.source), e = Object.groupBy(s, (r) => r.source);
17
+ Object.entries(e).forEach(([r, i]) => {
18
+ const d = c.get(r);
19
+ d && d.state.store.bulkDeleteAnnotation(i.map((f) => f.id), o);
20
+ });
21
+ }, y = (t, o = u.LOCAL) => {
22
+ const n = t.map((e) => {
23
+ const { source: r, annotator: i } = a(e.id);
24
+ return { source: r, annotation: e };
25
+ }).filter((e) => e.source), s = Object.groupBy(n, (e) => e.source);
26
+ Object.entries(s).forEach(([e, r]) => {
27
+ const i = c.get(e);
28
+ if (!i) return;
29
+ const d = r.map((f) => f.annotation).filter(Boolean);
30
+ i.state.store.bulkUpdateAnnotation(d, o);
31
+ });
32
+ }, L = (t, o = u.LOCAL) => {
33
+ const { annotation: n, annotator: s } = a(t);
14
34
  if (s)
15
35
  return s.state.store.deleteAnnotation(t, o), n;
16
- }, u = (t, o = c.LOCAL) => {
17
- const { annotator: n } = e(t.annotation);
36
+ }, m = (t, o = u.LOCAL) => {
37
+ const { annotator: n } = a(t.annotation);
18
38
  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);
39
+ }, O = () => Array.from(c.values()).forEach((t) => t.destroy()), b = (t) => {
40
+ const { annotator: o } = a(t);
21
41
  return o;
22
- }, y = (t) => {
23
- const { source: o } = e(t);
42
+ }, v = (t) => {
43
+ const { source: o } = a(t);
24
44
  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, o) => {
29
- const { annotator: n } = e(t);
45
+ }, g = (t) => a(t).annotation, B = () => Array.from(c.values()).reduce((t, o) => [...t, ...o.state.store.all()], []), h = (t) => c.get(t), C = (t, o, n) => {
46
+ const s = typeof t == "string" ? t : t.id, { annotator: e } = a(s);
47
+ e && e.state.store.updateAnnotation(t, o, n);
48
+ }, k = (t, o) => {
49
+ const { annotator: n } = a(t);
30
50
  n && n.setSelected(t, o);
31
51
  };
32
52
  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
53
+ annotators: [...c.values()],
54
+ sources: [...c.keys()],
55
+ addBody: l,
56
+ bulkDeleteAnnotations: p,
57
+ bulkUpdateAnnotations: y,
58
+ clear: A,
59
+ deleteAnnotation: L,
60
+ deleteBody: m,
61
+ destroy: O,
62
+ findAnnotator: b,
63
+ findSource: v,
64
+ getAnnotation: g,
65
+ getAnnotations: B,
66
+ getAnnotator: h,
67
+ setSelected: k,
68
+ updateAnnotation: C
47
69
  };
48
70
  };
49
71
  export {
50
- B as createManifoldInstance
72
+ j as createManifoldInstance
51
73
  };
52
74
  //# sourceMappingURL=annotorious-react-manifold.es8.js.map
@@ -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 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, 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 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, editable?: boolean) => {\n const { annotator } = find(id);\n if (annotator)\n annotator.setSelected(id, editable);\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","editable"],"mappings":";AAmCa,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,EAAO;AAAA,EAAA,GACxC,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,EAC9C,GAEME,IAAQ,CAACF,IAASC,EAAO,UAC7B,MAAM,KAAKV,EAAW,OAAQ,CAAA,EAAE,QAAQ,CAAKY,MAAAA,EAAE,MAAM,MAAM,MAAMH,CAAM,CAAC,GAEpEI,IAAmB,CAACC,GAAYL,IAASC,EAAO,UAAU;AAC9D,UAAM,EAAE,YAAAJ,GAAY,WAAAD,MAAcJ,EAAKa,CAAE;AAEzC,QAAIT;AACF,aAAAA,EAAU,MAAM,MAAM,iBAAiBS,GAAIL,CAAM,GAC1CH;AAAA,EAEX,GAEMS,IAAa,CAACP,GAAsBC,IAASC,EAAO,UAAU;AAClE,UAAM,EAAE,WAAAL,EAAc,IAAAJ,EAAKO,EAAK,UAAU;AACtC,IAAAH,KACFA,EAAU,MAAM,MAAM,WAAWG,GAAMC,CAAM;AAAA,EACjD,GAEMO,IAAU,MACd,MAAM,KAAKhB,EAAW,Q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EF;"}
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, 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.bulkDeleteAnnotation(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, annotator } = 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.bulkUpdateAnnotation(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, editable?: boolean) => {\n const { annotator } = find(id);\n if (annotator)\n annotator.setSelected(id, editable);\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"],"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,EAAO;AAAA,EAAA,GACxC,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,EAC9C,GAEME,IAAQ,CAACF,IAASC,EAA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AC5B,IAAAjC,KACFA,EAAU,MAAM,MAAM,iBAAiB8B,GAAMC,GAAMC,CAAI;AAAA,EAC3D,GAEME,IAAc,CAACtB,GAAYuB,MAAuB;AACtD,UAAM,EAAE,WAAAnC,EAAA,IAAcJ,EAAKgB,CAAE;AACzB,IAAAZ,KACQA,EAAA,YAAYY,GAAIuB,CAAQ;AAAA,EACtC;AAEO,SAAA;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,EACF;AAEF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react-manifold.es9.js","sources":["../src/plugins/PluginManifoldInstance.ts"],"sourcesContent":["import { Annotation, Annotator } from '@annotorious/react';\n\nexport const createPluginManifold = <\n P extends unknown,\n I extends Annotation = Annotation, \n E extends { id: string } = Annotation\n>(\n annotators: Annotator<I, E>[],\n mountFn: (anno: Annotator<I, E>, opts?: any) => P, \n opts?: any, \n): P => {\n\n const instances = annotators.map(anno => mountFn(anno, opts));\n\n return new Proxy({} as any, {\n get: (_, prop: string | symbol) => {\n const firstInstance = instances[0];\n if (!firstInstance) return undefined;\n \n const propValue = (firstInstance as any)[prop];\n \n if (typeof propValue === 'function') {\n return function(...args: any[]) {\n return instances.map(instance => {\n const method = (instance as any)[prop];\n if (typeof method === 'function') {\n return method.apply(instance, args);\n }\n return undefined;\n });\n };\n }\n\n return propValue;\n }\n });\n\n}"],"names":["createPluginManifold","annotators","mountFn","opts","instances","anno","_","prop","firstInstance","propValue","args","instance","method"],"mappings":"AAEO,MAAMA,IAAuB,CAKlCC,GACAC,GACAC,MACM;AAEN,QAAMC,IAAYH,EAAW,IAAI,OAAQC,EAAQG,GAAMF,CAAI,CAAC;AAErD,SAAA,IAAI,MAAM,IAAW;AAAA,IAC1B,KAAK,CAACG,GAAGC,MAA0B;AAC3B,YAAAC,IAAgBJ,EAAU,CAAC;AAC7B,UAAA,CAACI,EAAsB;AAErB,YAAAC,IAAaD,EAAsBD,CAAI;AAEzC,aAAA,OAAOE,KAAc,aAChB,YAAYC,GAAa;AACvB,eAAAN,EAAU,IAAI,CAAYO,MAAA;AACzB,gBAAAC,IAAUD,EAAiBJ,CAAI;AACjC,cAAA,OAAOK,KAAW;AACb,mBAAAA,EAAO,MAAMD,GAAUD,CAAI;AAAA,QAE7B,CACR;AAAA,MACH,IAGKD;AAAA,IAAA;AAAA,EACT,CACD;AAEH;"}
1
+ {"version":3,"file":"annotorious-react-manifold.es9.js","sources":["../src/plugins/PluginManifoldInstance.ts"],"sourcesContent":["import { Annotation, Annotator } from '@annotorious/react';\n\nexport type PluginManifoldProxy<P> = {\n [K in keyof P]: P[K] extends (...args: infer Args) => infer Return\n ? (...args: Args) => Return[]\n : P[K];\n};\n\nexport const createPluginManifold = <\n P extends unknown,\n I extends Annotation = Annotation, \n E extends { id: string } = Annotation\n>(\n annotators: Annotator<I, E>[],\n mountFn: (anno: Annotator<I, E>, opts?: any) => P, \n opts?: any, \n): PluginManifoldProxy<P> => {\n\n const instances = annotators.map(anno => mountFn(anno, opts));\n\n return new Proxy({} as any, {\n get: (_, prop: string | symbol) => {\n const firstInstance = instances[0];\n if (!firstInstance) return undefined;\n \n const propValue = (firstInstance as any)[prop];\n \n if (typeof propValue === 'function') {\n return function(...args: any[]) {\n return instances.map(instance => {\n const method = (instance as any)[prop];\n if (typeof method === 'function') {\n return method.apply(instance, args);\n }\n return undefined;\n });\n };\n }\n\n return propValue;\n }\n });\n\n}"],"names":["createPluginManifold","annotators","mountFn","opts","instances","anno","_","prop","firstInstance","propValue","args","instance","method"],"mappings":"AAQO,MAAMA,IAAuB,CAKlCC,GACAC,GACAC,MAC2B;AAE3B,QAAMC,IAAYH,EAAW,IAAI,OAAQC,EAAQG,GAAMF,CAAI,CAAC;AAErD,SAAA,IAAI,MAAM,IAAW;AAAA,IAC1B,KAAK,CAACG,GAAGC,MAA0B;AAC3B,YAAAC,IAAgBJ,EAAU,CAAC;AAC7B,UAAA,CAACI,EAAsB;AAErB,YAAAC,IAAaD,EAAsBD,CAAI;AAEzC,aAAA,OAAOE,KAAc,aAChB,YAAYC,GAAa;AACvB,eAAAN,EAAU,IAAI,CAAYO,MAAA;AACzB,gBAAAC,IAAUD,EAAiBJ,CAAI;AACjC,cAAA,OAAOK,KAAW;AACb,mBAAAA,EAAO,MAAMD,GAAUD,CAAI;AAAA,QAE7B,CACR;AAAA,MACH,IAGKD;AAAA,IAAA;AAAA,EACT,CACD;AAEH;"}
@@ -1,5 +1,8 @@
1
1
  import { Annotation, Annotator } from '@annotorious/react';
2
+ export type PluginManifoldProxy<P> = {
3
+ [K in keyof P]: P[K] extends (...args: infer Args) => infer Return ? (...args: Args) => Return[] : P[K];
4
+ };
2
5
  export declare const createPluginManifold: <P extends unknown, I extends Annotation = Annotation, E extends {
3
6
  id: string;
4
- } = Annotation>(annotators: Annotator<I, E>[], mountFn: (anno: Annotator<I, E>, opts?: any) => P, opts?: any) => P;
7
+ } = Annotation>(annotators: Annotator<I, E>[], mountFn: (anno: Annotator<I, E>, opts?: any) => P, opts?: any) => PluginManifoldProxy<P>;
5
8
  //# sourceMappingURL=PluginManifoldInstance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginManifoldInstance.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginManifoldInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE3D,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,UAAU,GAAG,UAAU,EACjC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,EAErC,YAAY,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAC7B,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EACjD,OAAO,GAAG,KACT,CA2BF,CAAA"}
1
+ {"version":3,"file":"PluginManifoldInstance.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginManifoldInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;KAClC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,IAAI,KAAK,MAAM,MAAM,GAC9D,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,GAC3B,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,UAAU,GAAG,UAAU,EACjC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,EAErC,YAAY,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAC7B,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EACjD,OAAO,GAAG,KACT,mBAAmB,CAAC,CAAC,CA2BvB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Annotator } from '@annotorious/react';
3
+ import { PluginManifoldProxy } from './PluginManifoldInstance';
3
4
  interface PluginManifoldData {
4
5
  mountFn: (anno: Annotator, opts?: any) => unknown;
5
6
  opts?: any;
@@ -13,6 +14,6 @@ interface PluginProviderProps {
13
14
  children: ReactNode;
14
15
  }
15
16
  export declare const PluginProvider: (props: PluginProviderProps) => import("react/jsx-runtime").JSX.Element;
16
- export declare const usePluginManifold: <P extends unknown>(name: string) => P;
17
+ export declare const usePluginManifold: <P extends unknown>(name: string) => PluginManifoldProxy<P>;
17
18
  export {};
18
19
  //# sourceMappingURL=PluginProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginProvider.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAA4C,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,UAAU,kBAAkB;IAE1B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;IAElD,IAAI,CAAC,EAAE,GAAG,CAAC;CAEZ;AAED,UAAU,0BAA0B;IAElC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;IAEjF,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAEjC;AAGD,eAAO,MAAM,qBAAqB,qDAAuD,CAAC;AAE1F,UAAU,mBAAmB;IAE3B,QAAQ,EAAE,SAAS,CAAC;CAErB;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CAgCxD,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,MAAM,KAEjC,CAC/B,CAAA"}
1
+ {"version":3,"file":"PluginProvider.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAA4C,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAwB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAErF,UAAU,kBAAkB;IAE1B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;IAElD,IAAI,CAAC,EAAE,GAAG,CAAC;CAEZ;AAED,UAAU,0BAA0B;IAElC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;IAEjF,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAEjC;AAGD,eAAO,MAAM,qBAAqB,qDAAuD,CAAC;AAE1F,UAAU,mBAAmB;IAE3B,QAAQ,EAAE,SAAS,CAAC;CAErB;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CAgCxD,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,MAAM,KAEjC,mBAAmB,CAAC,CAAC,CACpD,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export * from './Plugin';
2
+ export type { PluginManifoldProxy } from './PluginManifoldInstance';
2
3
  export { PluginProvider, usePluginManifold } from './PluginProvider';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/react-manifold",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "description": "A utility to manage multiple parallel Annotorious instances more efficiently",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -40,7 +40,7 @@
40
40
  "vite-tsconfig-paths": "^5.1.4"
41
41
  },
42
42
  "peerDependencies": {
43
- "@annotorious/react": "3.2.2",
43
+ "@annotorious/react": "3.2.4",
44
44
  "openseadragon": "^5.0.1",
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"