@annotorious/react 3.0.0-rc.11 → 3.0.0-rc.14
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/openseadragon/annotorious-react-osd.es.js +10 -0
- package/dist/openseadragon/annotorious-react-osd.es.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es10.js +9 -0
- package/dist/openseadragon/annotorious-react-osd.es10.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es11.js +156 -0
- package/dist/openseadragon/annotorious-react-osd.es11.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es12.js +5 -0
- package/dist/openseadragon/annotorious-react-osd.es12.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es13.js +33 -0
- package/dist/openseadragon/annotorious-react-osd.es13.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es14.js +602 -0
- package/dist/openseadragon/annotorious-react-osd.es14.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es15.js +5 -0
- package/dist/openseadragon/annotorious-react-osd.es15.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es16.js +5 -0
- package/dist/openseadragon/annotorious-react-osd.es16.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es2.js +32 -0
- package/dist/openseadragon/annotorious-react-osd.es2.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es3.js +39 -0
- package/dist/openseadragon/annotorious-react-osd.es3.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es4.js +19 -0
- package/dist/openseadragon/annotorious-react-osd.es4.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es5.js +6 -0
- package/dist/openseadragon/annotorious-react-osd.es5.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es6.js +21012 -0
- package/dist/openseadragon/annotorious-react-osd.es6.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es7.js +50 -0
- package/dist/openseadragon/annotorious-react-osd.es7.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es8.js +19 -0
- package/dist/openseadragon/annotorious-react-osd.es8.js.map +1 -0
- package/dist/openseadragon/annotorious-react-osd.es9.js +35 -0
- package/dist/openseadragon/annotorious-react-osd.es9.js.map +1 -0
- package/package.json +16 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as j } from "./annotorious-react-osd.es5.js";
|
|
2
|
+
import { createContext as E, forwardRef as H, useState as i, useImperativeHandle as I, useEffect as O, useContext as P } from "react";
|
|
3
|
+
const b = E({
|
|
4
|
+
anno: void 0,
|
|
5
|
+
setAnno: void 0,
|
|
6
|
+
annotations: [],
|
|
7
|
+
selection: { selected: [] }
|
|
8
|
+
});
|
|
9
|
+
H((s, m) => {
|
|
10
|
+
const [n, p] = i(null), [x, l] = i([]), [S, a] = i({ selected: [] });
|
|
11
|
+
return I(m, () => n), O(() => {
|
|
12
|
+
if (n) {
|
|
13
|
+
const { selection: h, store: e } = n.state;
|
|
14
|
+
e.all().length > 0 && l(e.all());
|
|
15
|
+
const u = (r) => l(() => e.all());
|
|
16
|
+
e.observe(u);
|
|
17
|
+
let o;
|
|
18
|
+
const A = h.subscribe(({ selected: r, pointerEvent: g }) => {
|
|
19
|
+
o && e.unobserve(o);
|
|
20
|
+
const C = (r || []).map(({ id: t, editable: c }) => ({ annotation: e.getAnnotation(t), editable: c }));
|
|
21
|
+
a({ selected: C, pointerEvent: g }), o = (t) => {
|
|
22
|
+
const { updated: c } = t.changes;
|
|
23
|
+
a(({ selected: w }) => ({
|
|
24
|
+
selected: w.map(({ annotation: d, editable: v }) => {
|
|
25
|
+
const f = c.find((V) => V.oldValue.id === d.id);
|
|
26
|
+
return f ? { annotation: f.newValue, editable: v } : { annotation: d, editable: v };
|
|
27
|
+
})
|
|
28
|
+
}));
|
|
29
|
+
}, e.observe(o, { annotations: r.map(({ id: t }) => t) });
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
e.unobserve(u), A();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}, [n]), /* @__PURE__ */ j(b.Provider, { value: {
|
|
36
|
+
anno: n,
|
|
37
|
+
setAnno: p,
|
|
38
|
+
annotations: x,
|
|
39
|
+
selection: S
|
|
40
|
+
}, children: s.children });
|
|
41
|
+
});
|
|
42
|
+
const q = () => {
|
|
43
|
+
const { selection: s } = P(b);
|
|
44
|
+
return s;
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
b as AnnotoriousContext,
|
|
48
|
+
q as useSelection
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=annotorious-react-osd.es7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react-osd.es7.js","sources":["../../src/Annotorious.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode} from 'react';\nimport { useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport { Annotation, Annotator, Store, StoreChangeEvent } from '@annotorious/annotorious';\nimport { useDebounce } from './useDebounce';\n\ninterface Selection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean }[];\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport interface AnnotoriousContextState {\n\n anno: Annotator;\n\n setAnno(anno: Annotator<Annotation, unknown>): void;\n\n annotations: Annotation[];\n\n selection: Selection;\n\n}\n\nexport const AnnotoriousContext = createContext({ \n\n anno: undefined, \n\n setAnno: undefined, \n\n annotations: [], \n\n selection: { selected: [] }\n\n});\n\nexport const Annotorious = forwardRef<Annotator, { children: ReactNode }>((props: { children: ReactNode }, ref) => {\n\n const [anno, setAnno] = useState<Annotator>(null);\n\n const [annotations, setAnnotations] = useState<Annotation[]>([]);\n\n const [selection, setSelection] = useState<Selection>({ selected: [] });\n\n useImperativeHandle(ref, () => anno);\n\n useEffect(() => {\n if (anno) {\n const { selection, store } = anno.state;\n\n // Components below <Annotorious /> may have\n // loaded annotations into the store already! \n if (store.all().length > 0)\n setAnnotations(store.all());\n\n // Keeps annotations in sync with a React state,\n // so clients can render components the usual React way.\n const onStoreChange = (event: StoreChangeEvent<Annotation>) =>\n setAnnotations(() => store.all());\n\n store.observe(onStoreChange);\n\n // Keep selection in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selection.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 setSelection({ selected: resolved, pointerEvent });\n\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ selected }) => ({\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 }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n return () => {\n store.unobserve(onStoreChange);\n unsubscribeSelection();\n }\n }\n }, [anno]);\n\n return (\n <AnnotoriousContext.Provider value={{ \n anno, \n setAnno,\n annotations, \n selection \n }}>\n {props.children}\n </AnnotoriousContext.Provider>\n )\n\n});\n\nexport const useAnnotator = <T extends Annotator<any, unknown>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno as T;\n}\n\nexport const useAnnotationStore = <T extends Store<Annotation>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.state.store as T | undefined;\n}\n\nconst _useAnnotations = <T extends Annotation>() => {\n const { annotations } = useContext(AnnotoriousContext);\n return annotations as T[];\n}\n\nconst _useAnnotationsDebouced = <T extends Annotation>(debounce: number) => {\n const { annotations } = useContext(AnnotoriousContext);\n return useDebounce(annotations, debounce) as T[];\n}\n\nexport const useAnnotations = <T extends Annotation>(debounce?: number) =>\n debounce ? _useAnnotationsDebouced<T>(debounce) : _useAnnotations<T>();\n\nexport const useSelection = <T extends Annotation>() => {\n const { selection } = useContext(AnnotoriousContext);\n return selection as Selection<T>;\n}\n\nexport const useAnnotatorUser = () => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.getUser();\n}\n\nconst _useViewportState = <T extends Annotation>() => {\n const { anno } = useContext(AnnotoriousContext);\n\n const [inViewport, setInViewport] = useState<T[]>([]);\n\n useEffect(() => {\n if (anno) {\n const { store, viewport } = anno.state;\n\n if (!viewport)\n return;\n\n // Keep viewport annotations in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let viewportStoreObserver: (event: StoreChangeEvent<T>) => void;\n\n const unsubscribeViewport = viewport.subscribe(ids => {\n if (viewportStoreObserver) \n store.unobserve(viewportStoreObserver);\n\n const resolved = ids.map(id => store.getAnnotation(id)) as T[];\n setInViewport(resolved);\n\n viewportStoreObserver = event => {\n const { updated } = event.changes;\n\n setInViewport(annotations => annotations.map(annotation => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? next.newValue : annotation;\n }));\n }\n\n store.observe(viewportStoreObserver, { annotations: ids });\n });\n\n return () => {\n unsubscribeViewport();\n }\n }\n }, [anno]);\n\n return inViewport;\n}\n\nconst _useViewportStateDebounced = <T extends Annotation>(debounce: number) => {\n const inViewport = _useViewportState();\n return useDebounce(inViewport, debounce) as T[];\n}\n\nexport const useViewportState = <T extends Annotation>(debounce?: number) =>\n debounce ? _useViewportStateDebounced<T>(debounce) : _useViewportState<T>();\n"],"names":["AnnotoriousContext","createContext","forwardRef","props","ref","anno","setAnno","useState","annotations","setAnnotations","selection","setSelection","useImperativeHandle","useEffect","store","onStoreChange","event","selectionStoreObserver","unsubscribeSelection","selected","pointerEvent","resolved","id","editable","updated","annotation","next","u","jsx","useSelection","useContext"],"mappings":";;AAyBO,MAAMA,IAAqBC,EAAc;AAAA,EAE9C,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,aAAa,CAAC;AAAA,EAEd,WAAW,EAAE,UAAU,GAAG;AAE5B,CAAC;AAE0BC,EAA+C,CAACC,GAAgCC,MAAQ;AAEjH,QAAM,CA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,EAAS,IAAI,CAAC,EAAE,IAAAG,EAAG,MAAMA,CAAE,EAAG,CAAA;AAAA,MAAA,CACpF;AAED,aAAO,MAAM;AACX,QAAAR,EAAM,UAAUC,CAAa,GACRG;MAAA;AAAA,IAEzB;AAAA,EAAA,GACC,CAACb,CAAI,CAAC,GAGN,gBAAAuB,EAAA5B,EAAmB,UAAnB,EAA4B,OAAO;AAAA,IAClC,MAAAK;AAAA,IACA,SAAAC;AAAA,IACA,aAAAE;AAAA,IACA,WAAAE;AAAA,EACF,GACI,YAAM,SACV,CAAA;AAGJ,CAAC;AAyBM,MAAMmB,IAAe,MAA4B;AACtD,QAAM,EAAE,WAAAnB,EAAA,IAAcoB,EAAW9B,CAAkB;AAC5C,SAAAU;AACT;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as s } from "./annotorious-react-osd.es5.js";
|
|
2
|
+
import { forwardRef as g } from "react";
|
|
3
|
+
import { useDraggable as i } from "./annotorious-react-osd.es11.js";
|
|
4
|
+
const d = g((r, o) => {
|
|
5
|
+
const { children: a, className: t, onDragStart: n, onDragEnd: e } = r;
|
|
6
|
+
return i(o, { onDragStart: n, onDragEnd: e, cancel: "button, .no-drag" }), /* @__PURE__ */ s(
|
|
7
|
+
"div",
|
|
8
|
+
{
|
|
9
|
+
ref: o,
|
|
10
|
+
className: t,
|
|
11
|
+
style: { position: "absolute" },
|
|
12
|
+
children: a
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
d as Draggable
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=annotorious-react-osd.es8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react-osd.es8.js","sources":["../../src/AnnotoriousPopup.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useDraggable } from '@neodrag/react';\n\nexport interface AnnotoriousPopupProps {\n\n selected: { annotation: ImageAnnotation, editable?: boolean }[];\n\n}\n\nexport interface DraggableProps {\n\n children: ReactNode;\n\n className?: string;\n\n onDragStart?(): void;\n\n onDragEnd?(): void;\n\n}\n\nexport const Draggable = forwardRef((props: DraggableProps, ref: React.MutableRefObject<HTMLDivElement>) => {\n\n const { children, className, onDragStart, onDragEnd } = props;\n\n useDraggable(ref, { onDragStart, onDragEnd, cancel: 'button, .no-drag' });\n\n return (\n <div \n ref={ref} \n className={className} \n style={{ position: 'absolute' }}>\n {children}\n </div>\n )\n\n});"],"names":["Draggable","forwardRef","props","ref","children","className","onDragStart","onDragEnd","useDraggable","jsx"],"mappings":";;;AAsBO,MAAMA,IAAYC,EAAW,CAACC,GAAuBC,MAAiD;AAE3G,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,aAAAC,GAAa,WAAAC,MAAcL;AAExDM,SAAAA,EAAaL,GAAK,EAAE,aAAAG,GAAa,WAAAC,GAAW,QAAQ,oBAAoB,GAGtE,gBAAAE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,WAAAE;AAAA,MACA,OAAO,EAAE,UAAU,WAAW;AAAA,MAC7B,UAAAD;AAAA,IAAA;AAAA,EAAA;AAIP,CAAC;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import w from "openseadragon";
|
|
2
|
+
const L = (i, h) => {
|
|
3
|
+
const e = i.element.getBoundingClientRect(), { minX: n, minY: l, maxX: t, maxY: c } = h.target.selector.geometry.bounds, s = i.viewport.imageToViewerElementCoordinates(new w.Point(n, l)), x = i.viewport.imageToViewerElementCoordinates(new w.Point(t, c));
|
|
4
|
+
return {
|
|
5
|
+
x: s.x + e.x,
|
|
6
|
+
right: x.x + e.x,
|
|
7
|
+
y: s.y + e.y,
|
|
8
|
+
bottom: x.y + e.y,
|
|
9
|
+
width: x.x - s.x,
|
|
10
|
+
height: x.y - s.y
|
|
11
|
+
};
|
|
12
|
+
}, T = (i, h, e, n = 5) => {
|
|
13
|
+
const l = i.element.getBoundingClientRect(), t = L(i, h), c = t.y - l.y, s = l.right - t.x, x = l.bottom - t.bottom, d = t.x - l.left, o = e.firstElementChild.getBoundingClientRect(), g = c / o.height, y = s / o.width, a = x / o.height, r = d / o.width, $ = () => {
|
|
14
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.y - n - o.height}px`;
|
|
15
|
+
}, f = () => {
|
|
16
|
+
e.style.left = `${t.right - o.width}px`, e.style.top = `${t.y - n - o.height}px`;
|
|
17
|
+
}, B = () => {
|
|
18
|
+
e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.y}px`;
|
|
19
|
+
}, v = () => {
|
|
20
|
+
e.style.left = `${t.right + n}px`, e.style.top = `${t.y}px`;
|
|
21
|
+
}, R = () => {
|
|
22
|
+
e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.bottom - o.height}px`;
|
|
23
|
+
}, C = () => {
|
|
24
|
+
e.style.left = `${t.x + t.width + n}px`, e.style.top = `${t.bottom - o.height}px`;
|
|
25
|
+
}, A = () => {
|
|
26
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.bottom + n}px`;
|
|
27
|
+
}, E = () => {
|
|
28
|
+
e.style.left = `${t.right - o.width}px`, e.style.top = `${t.bottom + n}px`;
|
|
29
|
+
}, b = [g, y, a, r], m = b.indexOf(Math.max(...b));
|
|
30
|
+
m === 0 ? y > r ? $() : f() : m === 1 ? g > a ? C() : v() : m === 2 ? y > r ? A() : E() : g > a ? R() : B();
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
T as setPosition
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=annotorious-react-osd.es9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotorious-react-osd.es9.js","sources":["../../src/openseadragon/setPosition.ts"],"sourcesContent":["import { ImageAnnotation } from '@annotorious/annotorious';\nimport OpenSeadragon from 'openseadragon';\n\nconst getAnnotationDomRect = (viewer: OpenSeadragon.Viewer, annotation: ImageAnnotation) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n \n // Annotation bounds (image coordinates)\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n // Annotation coordinates - viewer element coordinates\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // Account for viewer element offset\n return {\n x: topLeft.x + viewerBounds.x,\n right: bottomRight.x + viewerBounds.x,\n y: topLeft.y + viewerBounds.y,\n bottom: bottomRight.y + viewerBounds.y,\n width: bottomRight.x - topLeft.x,\n height: bottomRight.y - topLeft.y,\n };\n}\n\nexport const setPosition = (\n viewer: OpenSeadragon.Viewer, \n annotation: ImageAnnotation, \n popup: HTMLElement,\n sideOffset: number = 5\n) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n const annoBounds = getAnnotationDomRect(viewer, annotation);\n\n // Available space above, right, below, left the annotation in the viewport\n const availableAbove = annoBounds.y - viewerBounds.y;\n const availableRight = viewerBounds.right - annoBounds.x;\n const availableBelow = viewerBounds.bottom - annoBounds.bottom;\n const availableLeft = annoBounds.x - viewerBounds.left;\n\n // Popup element bounds\n const popupBounds = popup.firstElementChild.getBoundingClientRect();\n\n // Eight possible base alignment anchor points\n //\n // topleft topright\n // * *\n // leftdown * |---------------------| * rightdown\n // | |\n // | |\n // | |\n // leftup * |---------------------| * rightup\n // * * \n // bottomleft bottomright\n //\n // We'll position the popup at the cardinal direction\n // with the highest ratio: available space vs. popup size.\n const ratioAbove = availableAbove / popupBounds.height;\n const ratioRight = availableRight / popupBounds.width;\n const ratioBelow = availableBelow / popupBounds.height;\n const ratioLeft = availableLeft / popupBounds.width;\n\n const topleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const topright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const leftdown = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n } \n\n const rightdown = () => {\n popup.style.left = `${annoBounds.right + sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n }\n\n const leftup = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const rightup = () => {\n popup.style.left = `${annoBounds.x + annoBounds.width + sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const bottomleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const bottomright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const ratios = [ratioAbove, ratioRight, ratioBelow, ratioLeft];\n const maxIdx = ratios.indexOf(Math.max(...ratios));\n\n if (maxIdx === 0) {\n // Main orientation: above\n if (ratioRight > ratioLeft)\n topleft();\n else \n topright();\n } else if (maxIdx === 1) {\n // Main orientation: right\n if (ratioAbove > ratioBelow)\n rightup();\n else\n rightdown();\n } else if (maxIdx === 2) {\n // Main orientation: below\n if (ratioRight > ratioLeft)\n bottomleft();\n else\n bottomright();\n } else {\n // Main orientation: left\n if (ratioAbove > ratioBelow)\n leftup();\n else \n leftdown();\n }\n}"],"names":["getAnnotationDomRect","viewer","annotation","viewerBounds","minX","minY","maxX","maxY","topLeft","OpenSeadragon","bottomRight","setPosition","popup","sideOffset","annoBounds","availableAbove","availableRight","availableBelow","availableLeft","popupBounds","ratioAbove","ratioRight","ratioBelow","ratioLeft","topleft","topright","leftdown","rightdown","leftup","rightup","bottomleft","bottomright","ratios","maxIdx"],"mappings":";AAGA,MAAMA,IAAuB,CAACC,GAA8BC,MAAgC;A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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/react",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.14",
|
|
4
4
|
"description": "Annotorious React bindings",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "vite",
|
|
11
|
-
"build": "tsc && vite build",
|
|
11
|
+
"build": "tsc && vite build && vite build --config vite.config.osd.js",
|
|
12
12
|
"test": "echo 'Skipping tests in @annotorious/react package'"
|
|
13
13
|
},
|
|
14
14
|
"module": "./dist/annotorious-react.es.js",
|
|
@@ -21,9 +21,19 @@
|
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"import": "./dist/annotorious-react.es.js"
|
|
23
23
|
},
|
|
24
|
-
"./openseadragon":
|
|
24
|
+
"./openseadragon": {
|
|
25
|
+
"types": "./dist/openseadragon/index.d.ts",
|
|
26
|
+
"import": "./dist/openseadragon/annotorious-react-osd.es.js"
|
|
27
|
+
},
|
|
25
28
|
"./annotorious-react.css": "./dist/annotorious-react.css"
|
|
26
29
|
},
|
|
30
|
+
"typesVersions": {
|
|
31
|
+
"*": {
|
|
32
|
+
"openseadragon": [
|
|
33
|
+
"./dist/openseadragon/index.d.ts"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
27
37
|
"devDependencies": {
|
|
28
38
|
"@types/react": "^18.2.15",
|
|
29
39
|
"@types/react-dom": "^18.2.7",
|
|
@@ -35,12 +45,14 @@
|
|
|
35
45
|
},
|
|
36
46
|
"peerDependencies": {
|
|
37
47
|
"@annotorious/annotorious": "*",
|
|
38
|
-
"@annotorious/openseadragon": "*",
|
|
39
48
|
"openseadragon": "^3.0.0 || ^4.0.0",
|
|
40
49
|
"react": "16.8.0 || >=17.x || >=18.x",
|
|
41
50
|
"react-dom": "16.8.0 || >=17.x || >=18.x"
|
|
42
51
|
},
|
|
43
52
|
"peerDependenciesMeta": {
|
|
53
|
+
"@annotorious/openseadragon": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
44
56
|
"openseadragon": {
|
|
45
57
|
"optional": true
|
|
46
58
|
}
|