@annotorious/react-manifold 3.2.4 → 3.3.1
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,38 +1,38 @@
|
|
|
1
1
|
import { Origin as u } from "@annotorious/react";
|
|
2
2
|
const j = (c) => {
|
|
3
|
-
const a = (t) => Array.from(c.entries()).reduce((o, [n,
|
|
3
|
+
const a = (t) => Array.from(c.entries()).reduce((o, [n, r]) => {
|
|
4
4
|
if (o)
|
|
5
5
|
return o;
|
|
6
|
-
const e =
|
|
6
|
+
const e = r.state.store.getAnnotation(t);
|
|
7
7
|
if (e)
|
|
8
|
-
return { annotation: e, annotator:
|
|
8
|
+
return { annotation: e, annotator: r, source: n };
|
|
9
9
|
}, void 0) || { annotation: void 0, annotator: void 0, source: void 0 }, l = (t, o = u.LOCAL) => {
|
|
10
10
|
const { annotator: n } = a(t.annotation);
|
|
11
11
|
n && n.state.store.addBody(t, o);
|
|
12
12
|
}, A = (t = u.LOCAL) => Array.from(c.values()).forEach((o) => o.state.store.clear(t)), p = (t, o = u.LOCAL) => {
|
|
13
|
-
const
|
|
14
|
-
const { source: i } = a(
|
|
15
|
-
return { source: i, id:
|
|
16
|
-
}).filter((
|
|
17
|
-
Object.entries(e).forEach(([
|
|
18
|
-
const d = c.get(
|
|
19
|
-
d && d.state.store.
|
|
13
|
+
const r = t.map((s) => typeof s == "string" ? s : s.id).map((s) => {
|
|
14
|
+
const { source: i } = a(s);
|
|
15
|
+
return { source: i, id: s };
|
|
16
|
+
}).filter((s) => s.source), e = Object.groupBy(r, (s) => s.source);
|
|
17
|
+
Object.entries(e).forEach(([s, i]) => {
|
|
18
|
+
const d = c.get(s);
|
|
19
|
+
d && d.state.store.bulkDeleteAnnotations(i.map((f) => f.id), o);
|
|
20
20
|
});
|
|
21
21
|
}, y = (t, o = u.LOCAL) => {
|
|
22
22
|
const n = t.map((e) => {
|
|
23
|
-
const { source:
|
|
24
|
-
return { source:
|
|
25
|
-
}).filter((e) => e.source),
|
|
26
|
-
Object.entries(
|
|
23
|
+
const { source: s, annotator: i } = a(e.id);
|
|
24
|
+
return { source: s, annotation: e };
|
|
25
|
+
}).filter((e) => e.source), r = Object.groupBy(n, (e) => e.source);
|
|
26
|
+
Object.entries(r).forEach(([e, s]) => {
|
|
27
27
|
const i = c.get(e);
|
|
28
28
|
if (!i) return;
|
|
29
|
-
const d =
|
|
30
|
-
i.state.store.
|
|
29
|
+
const d = s.map((f) => f.annotation).filter(Boolean);
|
|
30
|
+
i.state.store.bulkUpdateAnnotations(d, o);
|
|
31
31
|
});
|
|
32
32
|
}, L = (t, o = u.LOCAL) => {
|
|
33
|
-
const { annotation: n, annotator:
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
33
|
+
const { annotation: n, annotator: r } = a(t);
|
|
34
|
+
if (r)
|
|
35
|
+
return r.state.store.deleteAnnotation(t, o), n;
|
|
36
36
|
}, m = (t, o = u.LOCAL) => {
|
|
37
37
|
const { annotator: n } = a(t.annotation);
|
|
38
38
|
n && n.state.store.deleteBody(t, o);
|
|
@@ -43,7 +43,7 @@ const j = (c) => {
|
|
|
43
43
|
const { source: o } = a(t);
|
|
44
44
|
return o;
|
|
45
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
|
|
46
|
+
const r = typeof t == "string" ? t : t.id, { annotator: e } = a(r);
|
|
47
47
|
e && e.state.store.updateAnnotation(t, o, n);
|
|
48
48
|
}, k = (t, o) => {
|
|
49
49
|
const { annotator: n } = a(t);
|
|
@@ -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, 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.
|
|
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.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, 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.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, 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;AAC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AAMC,IAAgB,OAAOH,KAAS,WAAWA,IAAOA,EAAK,IAEvD,EAAE,WAAA9B,EAAA,IAAcJ,EAAKqC,CAAK;AAC5B,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;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/react-manifold",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
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,16 +31,16 @@
|
|
|
31
31
|
"test": "echo 'Skipping tests in @annotorious/annotorious-react-manifold package'"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/react": "^19.0.
|
|
34
|
+
"@types/react": "^19.0.12",
|
|
35
35
|
"@types/react-dom": "^19.0.4",
|
|
36
36
|
"@vitejs/plugin-react": "^4.3.4",
|
|
37
37
|
"typescript": "5.8.2",
|
|
38
|
-
"vite": "^5.4.
|
|
38
|
+
"vite": "^5.4.15",
|
|
39
39
|
"vite-plugin-dts": "^4.5.3",
|
|
40
40
|
"vite-tsconfig-paths": "^5.1.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@annotorious/react": "3.
|
|
43
|
+
"@annotorious/react": "3.3.1",
|
|
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"
|