@annotorious/react 3.0.0-rc.20 → 3.0.0-rc.3
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/Annotorious.d.ts +28 -3
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/AnnotoriousPlugin.d.ts +6 -7
- package/dist/AnnotoriousPlugin.d.ts.map +1 -1
- package/dist/ImageAnnotator.d.ts.map +1 -1
- package/dist/annotorious-react.css +1 -1
- package/dist/annotorious-react.es.js +50 -33
- package/dist/annotorious-react.es.js.map +1 -1
- package/dist/annotorious-react.es10.js +3 -29
- package/dist/annotorious-react.es10.js.map +1 -1
- package/dist/annotorious-react.es11.js +27 -36
- package/dist/annotorious-react.es11.js.map +1 -1
- package/dist/annotorious-react.es12.js +20 -16
- package/dist/annotorious-react.es12.js.map +1 -1
- package/dist/annotorious-react.es13.js +54 -6
- package/dist/annotorious-react.es13.js.map +1 -1
- package/dist/annotorious-react.es14.js +17 -8
- package/dist/annotorious-react.es14.js.map +1 -1
- package/dist/annotorious-react.es15.js +21 -152
- package/dist/annotorious-react.es15.js.map +1 -1
- package/dist/annotorious-react.es16.js +2 -27436
- package/dist/annotorious-react.es16.js.map +1 -1
- package/dist/annotorious-react.es17.js +2 -32
- package/dist/annotorious-react.es17.js.map +1 -1
- package/dist/annotorious-react.es18.js +3859 -2
- package/dist/annotorious-react.es18.js.map +1 -1
- package/dist/annotorious-react.es19.js +29 -30
- package/dist/annotorious-react.es19.js.map +1 -1
- package/dist/annotorious-react.es2.js +32 -32
- package/dist/annotorious-react.es2.js.map +1 -1
- package/dist/annotorious-react.es20.js +35 -598
- package/dist/annotorious-react.es20.js.map +1 -1
- package/dist/annotorious-react.es21.js +16 -2
- package/dist/annotorious-react.es21.js.map +1 -1
- package/dist/annotorious-react.es22.js +4 -2
- package/dist/annotorious-react.es22.js.map +1 -1
- package/dist/annotorious-react.es23.js +11 -0
- package/dist/annotorious-react.es23.js.map +1 -0
- package/dist/annotorious-react.es24.js +156 -0
- package/dist/annotorious-react.es24.js.map +1 -0
- package/dist/annotorious-react.es25.js +9 -0
- package/dist/annotorious-react.es25.js.map +1 -0
- package/dist/annotorious-react.es26.js +20665 -0
- package/dist/annotorious-react.es26.js.map +1 -0
- package/dist/annotorious-react.es27.js +35 -0
- package/dist/annotorious-react.es27.js.map +1 -0
- package/dist/annotorious-react.es28.js +5 -0
- package/dist/annotorious-react.es28.js.map +1 -0
- package/dist/annotorious-react.es29.js +33 -0
- package/dist/annotorious-react.es29.js.map +1 -0
- package/dist/annotorious-react.es3.js +7 -7
- package/dist/annotorious-react.es3.js.map +1 -1
- package/dist/annotorious-react.es30.js +602 -0
- package/dist/annotorious-react.es30.js.map +1 -0
- package/dist/annotorious-react.es31.js +5 -0
- package/dist/annotorious-react.es31.js.map +1 -0
- package/dist/annotorious-react.es32.js +5 -0
- package/dist/annotorious-react.es32.js.map +1 -0
- package/dist/annotorious-react.es33.js +20 -0
- package/dist/annotorious-react.es33.js.map +1 -0
- package/dist/annotorious-react.es34.js +30 -0
- package/dist/annotorious-react.es34.js.map +1 -0
- package/dist/annotorious-react.es35.js +19 -0
- package/dist/annotorious-react.es35.js.map +1 -0
- package/dist/annotorious-react.es36.js +24 -0
- package/dist/annotorious-react.es36.js.map +1 -0
- package/dist/annotorious-react.es37.js +19 -0
- package/dist/annotorious-react.es37.js.map +1 -0
- package/dist/annotorious-react.es38.js +7 -0
- package/dist/annotorious-react.es38.js.map +1 -0
- package/dist/annotorious-react.es39.js +11 -0
- package/dist/annotorious-react.es39.js.map +1 -0
- package/dist/annotorious-react.es4.js +8 -8
- package/dist/annotorious-react.es4.js.map +1 -1
- package/dist/annotorious-react.es40.js +10 -0
- package/dist/annotorious-react.es40.js.map +1 -0
- package/dist/annotorious-react.es5.js +10 -10
- package/dist/annotorious-react.es5.js.map +1 -1
- package/dist/annotorious-react.es6.js +4 -1
- package/dist/annotorious-react.es6.js.map +1 -1
- package/dist/annotorious-react.es7.js +4 -1
- package/dist/annotorious-react.es7.js.map +1 -1
- package/dist/annotorious-react.es8.js +46 -85
- package/dist/annotorious-react.es8.js.map +1 -1
- package/dist/annotorious-react.es9.js +10 -4237
- package/dist/annotorious-react.es9.js.map +1 -1
- package/dist/index.d.ts +10 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
- package/dist/openseadragon/setPosition.d.ts.map +1 -1
- package/package.json +8 -16
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
const L = (h, x) => {
|
|
3
|
-
const { minX: e, minY: n, maxX: i, maxY: t } = x.target.selector.geometry.bounds, l = h.viewport.imageToViewerElementCoordinates(new b.Point(e, n)), s = h.viewport.imageToViewerElementCoordinates(new b.Point(i, t));
|
|
4
|
-
return {
|
|
5
|
-
x: l.x,
|
|
6
|
-
right: s.x,
|
|
7
|
-
y: l.y,
|
|
8
|
-
bottom: s.y,
|
|
9
|
-
width: s.x - l.x,
|
|
10
|
-
height: s.y - l.y
|
|
11
|
-
};
|
|
12
|
-
}, T = (h, x, e, n = 5) => {
|
|
13
|
-
const i = h.element.getBoundingClientRect(), t = L(h, x), l = t.y - i.y, s = i.right - t.x, w = i.bottom - t.bottom, $ = t.x - i.left, o = e.firstElementChild.getBoundingClientRect(), c = l / o.height, a = s / o.width, g = w / o.height, r = $ / o.width, d = () => {
|
|
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
|
-
}, v = () => {
|
|
18
|
-
e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.y}px`;
|
|
19
|
-
}, B = () => {
|
|
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
|
-
}, m = [c, a, g, r], y = m.indexOf(Math.max(...m));
|
|
30
|
-
y === 0 ? a > r ? d() : f() : y === 1 ? c > g ? C() : B() : y === 2 ? a > r ? A() : E() : c > g ? R() : v();
|
|
31
|
-
};
|
|
1
|
+
var L = /* @__PURE__ */ ((E) => (E.LOCAL = "LOCAL", E.REMOTE = "REMOTE", E))(L || {});
|
|
32
2
|
export {
|
|
33
|
-
|
|
3
|
+
L as Origin
|
|
34
4
|
};
|
|
35
5
|
//# sourceMappingURL=annotorious-react.es17.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es17.js","sources":["
|
|
1
|
+
{"version":3,"file":"annotorious-react.es17.js","sources":["../../annotorious-core/src/state/StoreObserver.ts"],"sourcesContent":["import type { Annotation, AnnotationBody, AnnotationTarget } from '../model';\nimport { diffAnnotations } from '../utils';\n\n/** Interface for listening to changes in the annotation store **/\nexport interface StoreObserver<T extends Annotation> { \n\n onChange: { (event: StoreChangeEvent<T>): void };\n\n options: StoreObserveOptions;\n\n}\n\n/** A change event fired when the store state changes **/\nexport interface StoreChangeEvent<T extends Annotation> {\n\n origin: Origin;\n\n changes: ChangeSet<T>;\n\n state: T[];\n\n}\n\nexport interface ChangeSet<T extends Annotation> {\n\n created?: T[];\n\n deleted?: T[];\n\n updated?: Update<T>[];\n\n}\n\nexport interface Update<T extends Annotation> {\n\n oldValue: T;\n\n newValue: T;\n\n bodiesCreated?: AnnotationBody[];\n\n bodiesDeleted?: AnnotationBody[];\n\n bodiesUpdated?: Array<{ oldBody: AnnotationBody, newBody: AnnotationBody }>;\n\n targetUpdated?: { oldTarget: AnnotationTarget, newTarget: AnnotationTarget};\n\n}\n\n/** Options to control which events the observer wants to get notified about **/\nexport interface StoreObserveOptions {\n\n // Observe changes on targets, bodies or both?\n ignore?: Ignore;\n\n // Observe changes on one more specific annotations\n annotations?: string | string[];\n\n // Observer changes only for a specific origin\n origin?: Origin\n\n}\n\n/** Allows the observer to ignore certain event types **/\nexport enum Ignore { \n\n // Don't notify this observer for changes that involve bodies only\n BODY_ONLY = 'BODY_ONLY',\n\n // Don't notify for changes on targets only\n TARGET_ONLY = 'TARGET_ONLY'\n\n}\n\n/** Allows the observer to listen only for events that originated locally or from a remote source **/\nexport enum Origin { \n \n LOCAL = 'LOCAL', \n \n REMOTE = 'REMOTE' \n\n}\n\n/** Tests if this observer should be notified about this event **/\nexport const shouldNotify = <T extends Annotation>(observer: StoreObserver<T>, event: StoreChangeEvent<T>) => {\n const { changes, origin } = event;\n\n const isRelevantOrigin = \n !observer.options.origin || observer.options.origin === origin;\n\n if (!isRelevantOrigin)\n return false;\n\n if (observer.options.ignore) {\n const { ignore } = observer.options;\n\n // Shorthand\n const has = (arg: any[]) => arg?.length > 0;\n\n const hasAnnotationChanges =\n has(changes.created) || has(changes.deleted);\n\n if (!hasAnnotationChanges) {\n const hasBodyChanges =\n changes.updated?.some(u => has(u.bodiesCreated) || has(u.bodiesDeleted) || has(u.bodiesUpdated));\n \n const hasTargetChanges = \n changes.updated?.some(u => u.targetUpdated);\n\n if (ignore === Ignore.BODY_ONLY && hasBodyChanges && !hasTargetChanges)\n return false;\n\n if (ignore === Ignore.TARGET_ONLY && hasTargetChanges && !hasBodyChanges)\n return false;\n }\n }\n\n if (observer.options.annotations) {\n // This observer has a filter set on specific annotations - check affected\n const affectedAnnotations = new Set([\n ...changes.created.map(a => a.id),\n ...changes.deleted.map(a => a.id),\n ...changes.updated.map(({ oldValue }) => oldValue.id)\n ]);\n\n const observed = Array.isArray(observer.options.annotations) ?\n observer.options.annotations : [ observer.options.annotations ];\n\n return Boolean(observed.find(id => affectedAnnotations.has(id)));\n } else {\n return true;\n }\n\n}\n\nexport const mergeChanges = <T extends Annotation>(changes: ChangeSet<T>, toMerge: ChangeSet<T>) => {\n\n const previouslyCreatedIds = new Set((changes.created || []).map(a => a.id));\n const previouslyUpdatedIds = new Set((changes.updated || []).map(({ newValue })=> newValue.id));\n\n const createdIds = new Set((toMerge.created || []).map(a => a.id));\n const deletedIds = new Set((toMerge.deleted || []).map(a => a.id));\n const updatedIds = new Set((toMerge.updated || []).map(({ oldValue }) => oldValue.id));\n\n // Updates that will be merged into create or previous update events\n const mergeableUpdates = new Set((toMerge.updated || [])\n .filter(({ oldValue }) => previouslyCreatedIds.has(oldValue.id) || previouslyUpdatedIds.has(oldValue.id))\n .map(({ oldValue }) => oldValue.id ));\n\n // * created *\n // - drop created that were then deleted\n // - merge any updates on created\n // - append newly created\n const created = [\n ...(changes.created || [])\n .filter(a => !deletedIds.has(a.id))\n .map(a => updatedIds.has(a.id) \n ? toMerge.updated.find(({ oldValue }) => oldValue.id === a.id).newValue\n : a),\n ...(toMerge.created || [])\n ];\n\n // * deleted *\n // - drop deleted that were later re-created (redo action!)\n // - append newly deleted, but remove any that delete annotations \n // that were created in the same round\n const deleted = [\n ...(changes.deleted || [])\n .filter(a => !createdIds.has(a.id)),\n ...(toMerge.deleted || []) \n .filter(a => !previouslyCreatedIds.has(a.id))\n ] \n\n // * updated *\n // - drop updates on deleted annotations\n // - merge any updates that override previous ones\n // - append new updates, but remove any that were merged\n const updated = [\n ...(changes.updated || [])\n .filter(({ newValue }) => !deletedIds.has(newValue.id))\n .map(update => {\n const { oldValue, newValue } = update;\n if (updatedIds.has(newValue.id)) {\n const updated = toMerge.updated.find(u => u.oldValue.id === newValue.id).newValue;\n return diffAnnotations(oldValue, updated);\n } else {\n return update;\n }\n }),\n ...(toMerge.updated || []).filter(({ oldValue }) => !mergeableUpdates.has(oldValue.id))\n ]\n\n return { created, deleted, updated };\n}"],"names":["Origin"],"mappings":"AA2EY,IAAAA,sBAAAA,OAEVA,EAAA,QAAQ,SAERA,EAAA,SAAS,UAJCA,IAAAA,KAAA,CAAA,CAAA;"}
|