@annotorious/react-manifold 3.2.0 → 3.2.2
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.
- package/dist/AnnotoriousManifoldInstance.d.ts.map +1 -1
- package/dist/annotorious-react-manifold.es.js +18 -13
- package/dist/annotorious-react-manifold.es.js.map +1 -1
- package/dist/annotorious-react-manifold.es4.js +12 -12
- package/dist/annotorious-react-manifold.es4.js.map +1 -1
- package/dist/annotorious-react-manifold.es5.js +17 -57
- package/dist/annotorious-react-manifold.es5.js.map +1 -1
- package/dist/annotorious-react-manifold.es6.js +11 -48
- package/dist/annotorious-react-manifold.es6.js.map +1 -1
- package/dist/annotorious-react-manifold.es7.js +62 -0
- package/dist/annotorious-react-manifold.es7.js.map +1 -0
- package/dist/annotorious-react-manifold.es8.js +52 -0
- package/dist/annotorious-react-manifold.es8.js.map +1 -0
- package/dist/annotorious-react-manifold.es9.js +21 -0
- package/dist/annotorious-react-manifold.es9.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/plugins/Plugin.d.ts +9 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/PluginManifoldInstance.d.ts +5 -0
- package/dist/plugins/PluginManifoldInstance.d.ts.map +1 -0
- package/dist/plugins/PluginProvider.d.ts +18 -0
- package/dist/plugins/PluginProvider.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"AnnotoriousManifoldInstance.d.ts","sourceRoot":"","sources":["../src/AnnotoriousManifoldInstance.ts"],"names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AC,EAAE,IAAI,CAAC,EAAE,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,CA+FlC,CAAA"}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { OpenSeadragonViewer as n } from "./annotorious-react-manifold.es2.js";
|
|
2
|
-
import { OSDViewerContext as t, OSDViewerManifold as i, useViewers as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { OSDViewerContext as t, OSDViewerManifold as i, useViewers as f } from "./annotorious-react-manifold.es3.js";
|
|
3
|
+
import { Plugin as u } from "./annotorious-react-manifold.es4.js";
|
|
4
|
+
import { PluginProvider as l, usePluginManifold as x } from "./annotorious-react-manifold.es5.js";
|
|
5
|
+
import { Annotorious as p } from "./annotorious-react-manifold.es6.js";
|
|
6
|
+
import { AnnotoriousManifold as A, AnnotoriousManifoldContext as M, useAnnotations as g, useAnnotator as w, useAnnotoriousManifold as P, useSelection as S } from "./annotorious-react-manifold.es7.js";
|
|
7
|
+
import { createManifoldInstance as c } from "./annotorious-react-manifold.es8.js";
|
|
6
8
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
p as Annotorious,
|
|
10
|
+
A as AnnotoriousManifold,
|
|
11
|
+
M as AnnotoriousManifoldContext,
|
|
10
12
|
t as OSDViewerContext,
|
|
11
13
|
i as OSDViewerManifold,
|
|
12
14
|
n as OpenSeadragonViewer,
|
|
13
|
-
|
|
14
|
-
l as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
u as Plugin,
|
|
16
|
+
l as PluginProvider,
|
|
17
|
+
c as createManifoldInstance,
|
|
18
|
+
g as useAnnotations,
|
|
19
|
+
w as useAnnotator,
|
|
20
|
+
P as useAnnotoriousManifold,
|
|
21
|
+
x as usePluginManifold,
|
|
22
|
+
S as useSelection,
|
|
23
|
+
f as useViewers
|
|
19
24
|
};
|
|
20
25
|
//# sourceMappingURL=annotorious-react-manifold.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react-manifold.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"annotorious-react-manifold.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, [
|
|
11
|
-
}
|
|
1
|
+
import { useContext as o, useEffect as r } from "react";
|
|
2
|
+
import { PluginProviderContext as i } from "./annotorious-react-manifold.es5.js";
|
|
3
|
+
const s = (t) => {
|
|
4
|
+
const { setPlugins: n } = o(i);
|
|
5
|
+
return r(() => (n((e) => new Map(e).set(t.name, { mountFn: t.plugin, opts: t.opts })), () => {
|
|
6
|
+
n((e) => {
|
|
7
|
+
const u = new Map(e);
|
|
8
|
+
return u.delete(t.name), u;
|
|
9
|
+
});
|
|
10
|
+
}), []), null;
|
|
11
|
+
};
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
s as Plugin
|
|
14
14
|
};
|
|
15
15
|
//# sourceMappingURL=annotorious-react-manifold.es4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react-manifold.es4.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"annotorious-react-manifold.es4.js","sources":["../src/plugins/Plugin.tsx"],"sourcesContent":["import { Annotator } from '@annotorious/react';\nimport { useContext, useEffect } from 'react';\nimport { PluginProviderContext } from './PluginProvider';\n\ninterface PluginProps {\n\n name: string;\n\n plugin: (anno: Annotator, opts?: any) => unknown;\n\n opts?: any;\n\n}\n\nexport const Plugin = (props: PluginProps) => {\n\n const { setPlugins } = useContext(PluginProviderContext);\n\n useEffect(() => {\n setPlugins(current => new Map(current).set(props.name, { mountFn: props.plugin, opts: props.opts }));\n\n return () => {\n setPlugins(current => {\n const updated = new Map(current);\n updated.delete(props.name);\n return updated;\n });\n }\n }, []);\n\n return null;\n\n}"],"names":["Plugin","props","setPlugins","useContext","PluginProviderContext","useEffect","current","updated"],"mappings":";;AAca,MAAAA,IAAS,CAACC,MAAuB;AAE5C,QAAM,EAAE,YAAAC,EAAA,IAAeC,EAAWC,CAAqB;AAEvD,SAAAC,EAAU,OACRH,EAAW,OAAW,IAAI,IAAII,CAAO,EAAE,IAAIL,EAAM,MAAM,EAAE,SAASA,EAAM,QAAQ,MAAMA,EAAM,KAAA,CAAM,CAAC,GAE5F,MAAM;AACX,IAAAC,EAAW,CAAWI,MAAA;AACd,YAAAC,IAAU,IAAI,IAAID,CAAO;AACvB,aAAAC,EAAA,OAAON,EAAM,IAAI,GAClBM;AAAA,IAAA,CACR;AAAA,EACH,IACC,EAAE,GAEE;AAET;"}
|
|
@@ -1,62 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let u;
|
|
12
|
-
const E = y.subscribe(({ selected: e, event: s }) => {
|
|
13
|
-
u && o.unobserve(u);
|
|
14
|
-
const m = (e || []).map(({ id: c, editable: A }) => ({ annotation: o.getAnnotation(c), editable: A }));
|
|
15
|
-
p.current || b({ id: n, selected: m, event: s }), u = (c) => {
|
|
16
|
-
const { updated: A } = c.changes;
|
|
17
|
-
b(({ id: V, selected: _ }) => ({
|
|
18
|
-
id: V,
|
|
19
|
-
selected: _.map(({ annotation: w, editable: x }) => {
|
|
20
|
-
const h = A.find((j) => j.oldValue.id === w.id);
|
|
21
|
-
return h ? { annotation: h.newValue, editable: x } : { annotation: w, editable: x };
|
|
22
|
-
}),
|
|
23
|
-
event: s
|
|
24
|
-
}));
|
|
25
|
-
}, o.observe(u, { annotations: e.map(({ id: c }) => c) });
|
|
26
|
-
});
|
|
27
|
-
return () => {
|
|
28
|
-
S((e) => new Map(Array.from(e.entries()).filter(([s, m]) => s !== n))), d((e) => new Map(Array.from(e.entries()).filter(([s, m]) => s !== n))), o.unobserve(v), E();
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as P, useContext as u, useMemo as g, useState as i, useEffect as x } from "react";
|
|
3
|
+
import { AnnotoriousManifoldContext as M } from "./annotorious-react-manifold.es7.js";
|
|
4
|
+
import { createPluginManifold as v } from "./annotorious-react-manifold.es9.js";
|
|
5
|
+
const f = P(void 0), j = (n) => {
|
|
6
|
+
const o = u(M), r = g(() => Array.from(o.annotators.values()), [Array.from(o.annotators.keys()).join(":")]), [e, l] = i(/* @__PURE__ */ new Map()), [c, m] = i();
|
|
7
|
+
return x(() => {
|
|
8
|
+
const s = Array.from(e.entries()).map(([a, { mountFn: t, opts: d }]) => [a, v(r, t, d)]);
|
|
9
|
+
return m(new Map(s)), () => {
|
|
10
|
+
s.forEach(([a, t]) => t.destroy && t.destroy());
|
|
29
11
|
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}), p.current = !1);
|
|
35
|
-
}, [l, r]), /* @__PURE__ */ I(i.Provider, { value: {
|
|
36
|
-
annotators: r,
|
|
37
|
-
annotations: g,
|
|
38
|
-
selection: l,
|
|
39
|
-
connectAnnotator: C
|
|
40
|
-
}, children: t.children });
|
|
41
|
-
}, F = () => {
|
|
42
|
-
const { annotators: t } = f(i);
|
|
43
|
-
return k(t);
|
|
44
|
-
}, G = (t) => {
|
|
45
|
-
const { annotators: r } = f(i);
|
|
46
|
-
return r.get(t);
|
|
47
|
-
}, H = () => {
|
|
48
|
-
const { annotations: t } = f(i);
|
|
49
|
-
return t;
|
|
50
|
-
}, J = () => {
|
|
51
|
-
const { selection: t } = f(i);
|
|
52
|
-
return t;
|
|
12
|
+
}, [r, e]), /* @__PURE__ */ p(f.Provider, { value: { setPlugins: l, manifolds: c }, children: n.children });
|
|
13
|
+
}, w = (n) => {
|
|
14
|
+
const { manifolds: o } = u(f);
|
|
15
|
+
return o.get(n);
|
|
53
16
|
};
|
|
54
17
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
G as useAnnotator,
|
|
59
|
-
F as useAnnotoriousManifold,
|
|
60
|
-
J as useSelection
|
|
18
|
+
j as PluginProvider,
|
|
19
|
+
f as PluginProviderContext,
|
|
20
|
+
w as usePluginManifold
|
|
61
21
|
};
|
|
62
22
|
//# sourceMappingURL=annotorious-react-manifold.es5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react-manifold.es5.js","sources":["../src/
|
|
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,52 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { jsx as t, Fragment as i } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as e, useEffect as c } from "react";
|
|
3
|
+
import { Annotorious as s, useAnnotator as u } from "@annotorious/react";
|
|
4
|
+
import { AnnotoriousManifoldContext as m } from "./annotorious-react-manifold.es7.js";
|
|
5
|
+
const d = (n) => {
|
|
6
|
+
const o = u(), { connectAnnotator: r } = e(m);
|
|
7
|
+
return c(() => {
|
|
4
8
|
if (o)
|
|
5
|
-
return o;
|
|
6
|
-
|
|
7
|
-
|
|
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, o) => {
|
|
29
|
-
const { annotator: n } = e(t);
|
|
30
|
-
n && n.setSelected(t, o);
|
|
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
|
-
};
|
|
48
|
-
};
|
|
9
|
+
return r(n.id, o);
|
|
10
|
+
}, [o]), /* @__PURE__ */ t(i, { children: n.children });
|
|
11
|
+
}, l = (n) => /* @__PURE__ */ t(s, { children: /* @__PURE__ */ t(d, { id: n.id, children: n.children }) });
|
|
49
12
|
export {
|
|
50
|
-
|
|
13
|
+
l as Annotorious
|
|
51
14
|
};
|
|
52
15
|
//# sourceMappingURL=annotorious-react-manifold.es6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react-manifold.es6.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"annotorious-react-manifold.es6.js","sources":["../src/Annotorious.tsx"],"sourcesContent":["import { ReactNode, useContext, useEffect } from 'react';\nimport { Annotation, Annotator, useAnnotator } from '@annotorious/react';\nimport { Annotorious as AnnotoriousInstance } from '@annotorious/react';\nimport { AnnotoriousManifoldContext } from './AnnotoriousManifold';\n\ninterface AnnotoriousProps {\n\n children: ReactNode;\n\n id: string;\n\n}\n\n/**\n * Consumes the standard Annotorious context, and passes the Annotator\n * upwards to the manifold.\n */\nconst AnnotoriousInstanceShim = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(props: AnnotoriousProps) => {\n\n const anno = useAnnotator<Annotator<I, E>>();\n\n const { connectAnnotator } = useContext(AnnotoriousManifoldContext);\n\n useEffect(() => { \n if (anno) {\n return connectAnnotator(props.id, anno);\n }\n }, [anno]);\n\n return <>{props.children}</>;\n\n}\n\n/**\n * An alternative <Annotorious /> component that mimics the original\n * from @annotorious/react, but injects the shim component, which connects\n * the Annotator to the Manifold.\n */\nexport const Annotorious = (props: AnnotoriousProps) => {\n\n return (\n <AnnotoriousInstance>\n <AnnotoriousInstanceShim id={props.id}>\n {props.children}\n </AnnotoriousInstanceShim>\n </AnnotoriousInstance>\n )\n\n}"],"names":["AnnotoriousInstanceShim","props","anno","useAnnotator","connectAnnotator","useContext","AnnotoriousManifoldContext","useEffect","jsx","Fragment","Annotorious","AnnotoriousInstance"],"mappings":";;;;AAiBA,MAAMA,IAA0B,CAA2EC,MAA4B;AAErI,QAAMC,IAAOC,EAA8B,GAErC,EAAE,kBAAAC,EAAA,IAAqBC,EAAWC,CAA0B;AAElE,SAAAC,EAAU,MAAM;AACd,QAAIL;AACK,aAAAE,EAAiBH,EAAM,IAAIC,CAAI;AAAA,EACxC,GACC,CAACA,CAAI,CAAC,GAEF,gBAAAM,EAAAC,GAAA,EAAG,YAAM,SAAS,CAAA;AAE3B,GAOaC,IAAc,CAACT,MAGxB,gBAAAO,EAACG,KACC,UAAC,gBAAAH,EAAAR,GAAA,EAAwB,IAAIC,EAAM,IAChC,UAAMA,EAAA,SAAA,CACT,EACF,CAAA;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as I } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as O, useState as M, useRef as P, useEffect as R, useContext as f } from "react";
|
|
3
|
+
import { createManifoldInstance as k } from "./annotorious-react-manifold.es8.js";
|
|
4
|
+
const i = O(), D = (t) => {
|
|
5
|
+
const [r, S] = M(/* @__PURE__ */ new Map()), [g, d] = M(/* @__PURE__ */ new Map()), [l, b] = M({ selected: [] }), p = P(!1), C = (n, a) => {
|
|
6
|
+
S((e) => new Map(e.entries()).set(n, a));
|
|
7
|
+
const { store: o } = a.state, y = a.state.selection;
|
|
8
|
+
d((e) => new Map(e.entries()).set(n, o.all()));
|
|
9
|
+
const v = () => d((e) => new Map(e.entries()).set(n, o.all()));
|
|
10
|
+
o.observe(v);
|
|
11
|
+
let u;
|
|
12
|
+
const E = y.subscribe(({ selected: e, event: s }) => {
|
|
13
|
+
u && o.unobserve(u);
|
|
14
|
+
const m = (e || []).map(({ id: c, editable: A }) => ({ annotation: o.getAnnotation(c), editable: A }));
|
|
15
|
+
p.current || b({ id: n, selected: m, event: s }), u = (c) => {
|
|
16
|
+
const { updated: A } = c.changes;
|
|
17
|
+
b(({ id: V, selected: _ }) => ({
|
|
18
|
+
id: V,
|
|
19
|
+
selected: _.map(({ annotation: w, editable: x }) => {
|
|
20
|
+
const h = A.find((j) => j.oldValue.id === w.id);
|
|
21
|
+
return h ? { annotation: h.newValue, editable: x } : { annotation: w, editable: x };
|
|
22
|
+
}),
|
|
23
|
+
event: s
|
|
24
|
+
}));
|
|
25
|
+
}, o.observe(u, { annotations: e.map(({ id: c }) => c) });
|
|
26
|
+
});
|
|
27
|
+
return () => {
|
|
28
|
+
S((e) => new Map(Array.from(e.entries()).filter(([s, m]) => s !== n))), d((e) => new Map(Array.from(e.entries()).filter(([s, m]) => s !== n))), o.unobserve(v), E();
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
return R(() => {
|
|
32
|
+
l.id && (p.current = !0, Array.from(r.entries()).forEach(([n, a]) => {
|
|
33
|
+
n !== l.id && a.setSelected();
|
|
34
|
+
}), p.current = !1);
|
|
35
|
+
}, [l, r]), /* @__PURE__ */ I(i.Provider, { value: {
|
|
36
|
+
annotators: r,
|
|
37
|
+
annotations: g,
|
|
38
|
+
selection: l,
|
|
39
|
+
connectAnnotator: C
|
|
40
|
+
}, children: t.children });
|
|
41
|
+
}, F = () => {
|
|
42
|
+
const { annotators: t } = f(i);
|
|
43
|
+
return k(t);
|
|
44
|
+
}, G = (t) => {
|
|
45
|
+
const { annotators: r } = f(i);
|
|
46
|
+
return r.get(t);
|
|
47
|
+
}, H = () => {
|
|
48
|
+
const { annotations: t } = f(i);
|
|
49
|
+
return t;
|
|
50
|
+
}, J = () => {
|
|
51
|
+
const { selection: t } = f(i);
|
|
52
|
+
return t;
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
D as AnnotoriousManifold,
|
|
56
|
+
i as AnnotoriousManifoldContext,
|
|
57
|
+
H as useAnnotations,
|
|
58
|
+
G as useAnnotator,
|
|
59
|
+
F as useAnnotoriousManifold,
|
|
60
|
+
J as useSelection
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=annotorious-react-manifold.es7.js.map
|
|
@@ -0,0 +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 } 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 event?: PointerEvent | KeyboardEvent;\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\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(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n // Set the new selection\n if (!muteSelectionEvents.current)\n setSelection({ id, selected: resolved, event });\n\n // Track the state of the selected annotations in the store\n selectionStoreObserver = e => {\n const { updated } = e.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 event\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","event","resolved","editable","e","updated","annotation","next","u","key","_","useEffect","source","jsx","useAnnotoriousManifold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,EAAA,GAEC,YAAM,UACT;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;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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, o) => {
|
|
29
|
+
const { annotator: n } = e(t);
|
|
30
|
+
n && n.setSelected(t, o);
|
|
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
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
B as createManifoldInstance
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=annotorious-react-manifold.es8.js.map
|
|
@@ -0,0 +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,G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A,EAAU,MAAM,MAAM,iBAAiBmB,GAAMC,GAAMC,CAAI;AAAA,EAC3D,GAEME,IAAc,CAACd,GAAYe,MAAuB;AACtD,UAAM,EAAE,WAAAxB,EAAA,IAAcJ,EAAKa,CAAE;AACzB,IAAAT,KACQA,EAAA,YAAYS,GAAIe,CAAQ;AAAA,EACtC;AAEO,SAAA;AAAA,IACL,YAAY,CAAC,GAAG7B,EAAW,QAAQ;AAAA,IACnC,SAAS,CAAC,GAAGA,EAAW,MAAM;AAAA,IAC9B,SAAAO;AAAA,IACA,OAAAI;AAAA,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,EACF;AAEF;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const p = (c, f, s) => {
|
|
2
|
+
const n = c.map((t) => f(t, s));
|
|
3
|
+
return new Proxy({}, {
|
|
4
|
+
get: (t, r) => {
|
|
5
|
+
const e = n[0];
|
|
6
|
+
if (!e) return;
|
|
7
|
+
const o = e[r];
|
|
8
|
+
return typeof o == "function" ? function(...a) {
|
|
9
|
+
return n.map((u) => {
|
|
10
|
+
const i = u[r];
|
|
11
|
+
if (typeof i == "function")
|
|
12
|
+
return i.apply(u, a);
|
|
13
|
+
});
|
|
14
|
+
} : o;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
p as createPluginManifold
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=annotorious-react-manifold.es9.js.map
|
|
@@ -0,0 +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;"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Annotator } from '@annotorious/react';
|
|
2
|
+
interface PluginProps {
|
|
3
|
+
name: string;
|
|
4
|
+
plugin: (anno: Annotator, opts?: any) => unknown;
|
|
5
|
+
opts?: any;
|
|
6
|
+
}
|
|
7
|
+
export declare const Plugin: (props: PluginProps) => any;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/Plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,UAAU,WAAW;IAEnB,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;IAEjD,IAAI,CAAC,EAAE,GAAG,CAAC;CAEZ;AAED,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,QAkBxC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Annotation, Annotator } from '@annotorious/react';
|
|
2
|
+
export declare const createPluginManifold: <P extends unknown, I extends Annotation = Annotation, E extends {
|
|
3
|
+
id: string;
|
|
4
|
+
} = Annotation>(annotators: Annotator<I, E>[], mountFn: (anno: Annotator<I, E>, opts?: any) => P, opts?: any) => P;
|
|
5
|
+
//# sourceMappingURL=PluginManifoldInstance.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Annotator } from '@annotorious/react';
|
|
3
|
+
interface PluginManifoldData {
|
|
4
|
+
mountFn: (anno: Annotator, opts?: any) => unknown;
|
|
5
|
+
opts?: any;
|
|
6
|
+
}
|
|
7
|
+
interface PluginProviderContextValue {
|
|
8
|
+
setPlugins: React.Dispatch<React.SetStateAction<Map<string, PluginManifoldData>>>;
|
|
9
|
+
manifolds: Map<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare const PluginProviderContext: import('react').Context<PluginProviderContextValue>;
|
|
12
|
+
interface PluginProviderProps {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
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 {};
|
|
18
|
+
//# sourceMappingURL=PluginProvider.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/react-manifold",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
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.
|
|
43
|
+
"@annotorious/react": "3.2.2",
|
|
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"
|