@annotorious/svelte 3.0.0-rc.3 → 3.0.0-rc.30

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.
Files changed (44) hide show
  1. package/dist/annotorious-svelte.es.js +17 -14
  2. package/dist/annotorious-svelte.es.js.map +1 -1
  3. package/dist/annotorious-svelte.es10.js +2 -2
  4. package/dist/annotorious-svelte.es10.js.map +1 -1
  5. package/dist/annotorious-svelte.es11.js +2 -20662
  6. package/dist/annotorious-svelte.es11.js.map +1 -1
  7. package/dist/annotorious-svelte.es12.js +50 -115
  8. package/dist/annotorious-svelte.es12.js.map +1 -1
  9. package/dist/annotorious-svelte.es13.js +103 -2
  10. package/dist/annotorious-svelte.es13.js.map +1 -1
  11. package/dist/annotorious-svelte.es2.js +30 -25
  12. package/dist/annotorious-svelte.es2.js.map +1 -1
  13. package/dist/annotorious-svelte.es3.js +114 -2
  14. package/dist/annotorious-svelte.es3.js.map +1 -1
  15. package/dist/annotorious-svelte.es4.js +127 -9
  16. package/dist/annotorious-svelte.es4.js.map +1 -1
  17. package/dist/annotorious-svelte.es5.js +66 -1261
  18. package/dist/annotorious-svelte.es5.js.map +1 -1
  19. package/dist/annotorious-svelte.es6.js +37 -106
  20. package/dist/annotorious-svelte.es6.js.map +1 -1
  21. package/dist/annotorious-svelte.es7.js +24 -118
  22. package/dist/annotorious-svelte.es7.js.map +1 -1
  23. package/dist/annotorious-svelte.es8.js +17 -307
  24. package/dist/annotorious-svelte.es8.js.map +1 -1
  25. package/dist/annotorious-svelte.es9.js +110 -7
  26. package/dist/annotorious-svelte.es9.js.map +1 -1
  27. package/dist/index.d.ts +13 -10
  28. package/dist/index.d.ts.map +1 -1
  29. package/package.json +24 -13
  30. package/src/index.ts +39 -21
  31. package/src/osd/OpenSeadragonAnnotator.svelte +2 -2
  32. package/tsconfig.json +2 -2
  33. package/vite.config.js +8 -5
  34. package/dist/annotorious-svelte.es14.js +0 -20
  35. package/dist/annotorious-svelte.es14.js.map +0 -1
  36. package/dist/annotorious-svelte.es15.js +0 -7
  37. package/dist/annotorious-svelte.es15.js.map +0 -1
  38. package/dist/annotorious-svelte.es16.js +0 -11
  39. package/dist/annotorious-svelte.es16.js.map +0 -1
  40. package/dist/annotorious-svelte.es17.js +0 -10
  41. package/dist/annotorious-svelte.es17.js.map +0 -1
  42. package/dist/annotorious-svelte.es18.js +0 -5
  43. package/dist/annotorious-svelte.es18.js.map +0 -1
  44. /package/dist/{style.css → annotorious-svelte.css} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es3.js","sources":["../../annotorious-core/src/state/Selection.ts"],"sourcesContent":["import { writable } from 'svelte/store';\nimport type { Annotation } from '../model';\nimport type { Store } from './Store';\n \nexport type Selection = {\n\n selected: { id: string, editable?: boolean }[],\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport type SelectionState<T extends Annotation> = ReturnType<typeof createSelectionState<T>>;\n\nexport enum PointerSelectAction {\n\n EDIT = 'EDIT', // Make annotation target(s) editable on pointer select\n \n SELECT = 'SELECT', // Just select, but don't make editable\n\n NONE = 'NONE' // Click won't select - annotation is completely inert\n\n}\n\nconst EMPTY: Selection = { selected: [] };\n\nexport const createSelectionState = <T extends Annotation>(\n store: Store<T>,\n selectAction: PointerSelectAction | ((a: Annotation) => PointerSelectAction) = PointerSelectAction.EDIT\n) => {\n const { subscribe, set } = writable<Selection>(EMPTY);\n\n let currentSelection: Selection = EMPTY;\n\n subscribe(updated => currentSelection = updated);\n\n const clear = () => set(EMPTY);\n\n const isEmpty = () => currentSelection.selected?.length === 0;\n\n const isSelected = (annotationOrId: T | string) => {\n if (currentSelection.selected.length === 0)\n return false;\n\n const id = typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id;\n return currentSelection.selected.some(i => i.id === id);\n }\n\n // TODO enable CTRL select\n const clickSelect = (id: string, pointerEvent: PointerEvent) => {\n const annotation = store.getAnnotation(id);\n if (annotation) {\n const action = onPointerSelect(annotation, selectAction);\n if (action === PointerSelectAction.EDIT)\n set({ selected: [{ id, editable: true }], pointerEvent }); \n else if (action === PointerSelectAction.SELECT)\n set({ selected: [{ id }], pointerEvent }); \n else\n set({ selected: [], pointerEvent });\n } else {\n console.warn('Invalid selection: ' + id);\n }\n }\n\n const setSelected = (idOrIds: string | string[], editable: boolean = true) => {\n const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];\n\n // Remove invalid\n const annotations = \n ids.map(id => store.getAnnotation(id)).filter(a => a); \n\n set({ selected: annotations.map(({ id }) => ({ id, editable })) });\n \n if (annotations.length !== ids.length)\n console.warn('Invalid selection', idOrIds);\n }\n\n const removeFromSelection = (ids: string[]) => {\n if (currentSelection.selected.length === 0)\n return false;\n\n const { selected } = currentSelection;\n\n // Checks which of the given annotations are actually in the selection\n const toRemove = selected.filter(({ id }) => ids.includes(id))\n\n if (toRemove.length > 0)\n set({ selected: selected.filter(({ id }) => !ids.includes(id)) });\n }\n\n // Track store delete and update events\n store.observe(({ changes }) =>\n removeFromSelection(changes.deleted.map(a => a.id)));\n\n return { \n clear, \n clickSelect, \n get selected() { return currentSelection ? [...currentSelection.selected ] : null},\n get pointerEvent() { return currentSelection ? currentSelection.pointerEvent : null },\n isEmpty, \n isSelected, \n setSelected, \n subscribe \n };\n\n}\n\nexport const onPointerSelect = (\n annotation: Annotation, \n action?: PointerSelectAction | ((a: Annotation) => PointerSelectAction)\n): PointerSelectAction => (typeof action === 'function') ?\n (action(annotation) || PointerSelectAction.EDIT) : \n (action || PointerSelectAction.EDIT);\n"],"names":["PointerSelectAction"],"mappings":"AAcY,IAAAA,sBAAAA,OAEVA,EAAA,OAAO,QAEPA,EAAA,SAAS,UAETA,EAAA,OAAO,QANGA,IAAAA,KAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"annotorious-svelte.es3.js","sources":["../src/osd/OpenSeadragonAnnotator.svelte"],"sourcesContent":["<script lang=\"ts\">\n import { setContext } from 'svelte';\n import { type SvelteAnnotator, type SvelteAnnotatorState, toSvelteStore } from '@annotorious/core';\n import { createOSDAnnotator, type ImageAnnotation } from '@annotorious/openseadragon';\n import type OpenSeadragon from 'openseadragon';\n\n /** props **/\n export let viewer: OpenSeadragon.Viewer;\n export let opts = {};\n export let anno: SvelteAnnotator<ImageAnnotation> = undefined;\n\n $: init(viewer);\n\n const init = (viewer: OpenSeadragon.Viewer) => {\n if (viewer) {\n const annotator = createOSDAnnotator(viewer, opts);\n\n // Wrap the store for Svelte reactivity\n const svelteStore = toSvelteStore(annotator.state.store);\n\n const shim = {\n ...annotator,\n state: {\n ...annotator.state,\n store: svelteStore\n } as SvelteAnnotatorState<ImageAnnotation>\n } as SvelteAnnotator<ImageAnnotation>\n\n setContext('anno', shim);\n setContext('viewer', viewer);\n\n anno = shim;\n }\n }\n</script>\n\n{#if viewer}\n <slot />\n{/if}\n"],"names":["ctx","create_if_block","viewer","$$props","opts","anno","init","annotator","createOSDAnnotator","svelteStore","toSvelteStore","shim","setContext","$$invalidate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoCKA,EAAM,CAAA,KAAAC,EAAAD,CAAA;AAAA;;;;;;;;;;MAANA,EAAM,CAAA;;;;;;;;;;;;;;;;;6CA7BE,QAAAE,EAA4B,IAAAC,KAC5B,MAAAC,IAAI,GAAA,IAAAD,GACJ,EAAA,MAAAE,IAAyC,OAAS,IAAAF;AAIvD,QAAAG,IAAQ,CAAAJ,MAA4B;QACpCA,GAAM;AACF,YAAAK,IAAYC,EAAmBN,GAAQE,CAAI,GAG3CK,IAAcC,EAAcH,EAAU,MAAM,KAAK,GAEjDI,IAAI;AAAA,WACLJ;AAAA,QACH,YACKA,EAAU,OACb,OAAOE,EAAA;AAAA;AAIX,MAAAG,EAAW,QAAQD,CAAI,GACvBC,EAAW,UAAUV,CAAM,GAE3BW,EAAA,GAAAR,IAAOM,CAAI;AAAA;;;;;;SApBZL,EAAKJ,CAAM;AAAA;;;;;;;;"}
@@ -1,12 +1,130 @@
1
- import n from "./annotorious-svelte.es14.js";
2
- const d = (t, e, o, a) => ({
3
- id: n(),
4
- annotation: t.id,
5
- created: o || /* @__PURE__ */ new Date(),
6
- creator: a,
7
- ...e
8
- });
1
+ import { safe_not_equal as H, noop as v, component_subscribe as I, action_destroyer as T, is_function as X, run_all as Y } from "./annotorious-svelte.es5.js";
2
+ import { empty as q, insert as y, detach as P, element as x, text as G, attr as L, append as R, listen as _, set_data as U } from "./annotorious-svelte.es6.js";
3
+ import { onMount as z } from "./annotorious-svelte.es8.js";
4
+ import { SvelteComponent as B, init as F } from "./annotorious-svelte.es9.js";
5
+ import "./annotorious-svelte.es10.js";
6
+ import { draggable as J } from "./annotorious-svelte.es13.js";
7
+ import b from "openseadragon";
8
+ /* empty css */
9
+ function w(n) {
10
+ let o, e = (
11
+ /*$selection*/
12
+ n[0].selected.map(S).join(", ") + ""
13
+ ), t, s, r, d;
14
+ return {
15
+ c() {
16
+ o = x("div"), t = G(e), L(o, "class", "a9s-popup a9s-osd-popup svelte-1xuxeat");
17
+ },
18
+ m(a, l) {
19
+ y(a, o, l), R(o, t), r || (d = [
20
+ T(s = J.call(null, o, {
21
+ position: { x: (
22
+ /*left*/
23
+ n[1]
24
+ ), y: (
25
+ /*top*/
26
+ n[2]
27
+ ) }
28
+ })),
29
+ _(
30
+ o,
31
+ "neodrag:start",
32
+ /*onDragStart*/
33
+ n[4]
34
+ ),
35
+ _(
36
+ o,
37
+ "neodrag:end",
38
+ /*onDragEnd*/
39
+ n[5]
40
+ )
41
+ ], r = !0);
42
+ },
43
+ p(a, l) {
44
+ l & /*$selection*/
45
+ 1 && e !== (e = /*$selection*/
46
+ a[0].selected.map(S).join(", ") + "") && U(t, e), s && X(s.update) && l & /*left, top*/
47
+ 6 && s.update.call(null, {
48
+ position: { x: (
49
+ /*left*/
50
+ a[1]
51
+ ), y: (
52
+ /*top*/
53
+ a[2]
54
+ ) }
55
+ });
56
+ },
57
+ d(a) {
58
+ a && P(o), r = !1, Y(d);
59
+ }
60
+ };
61
+ }
62
+ function K(n) {
63
+ let o, e = (
64
+ /*$selection*/
65
+ n[0] && w(n)
66
+ );
67
+ return {
68
+ c() {
69
+ e && e.c(), o = q();
70
+ },
71
+ m(t, s) {
72
+ e && e.m(t, s), y(t, o, s);
73
+ },
74
+ p(t, [s]) {
75
+ /*$selection*/
76
+ t[0] ? e ? e.p(t, s) : (e = w(t), e.c(), e.m(o.parentNode, o)) : e && (e.d(1), e = null);
77
+ },
78
+ i: v,
79
+ o: v,
80
+ d(t) {
81
+ t && P(o), e && e.d(t);
82
+ }
83
+ };
84
+ }
85
+ const S = (n) => n.id;
86
+ function Q(n, o, e) {
87
+ let t, { state: s } = o, { viewer: r } = o, d, a, l = !1, p;
88
+ const { selection: u, store: f } = s;
89
+ I(n, u, (i) => e(0, t = i));
90
+ const g = (i) => {
91
+ var c;
92
+ return ((c = i.selected) == null ? void 0 : c.length) > 0;
93
+ }, E = () => {
94
+ l = !0, r.setMouseNavEnabled(!1);
95
+ }, D = () => {
96
+ r.setMouseNavEnabled(!0);
97
+ }, N = () => {
98
+ p && f.unobserve(p), g(t) && (l = !1, m(t), p = (i) => {
99
+ l || m(t);
100
+ }, f.observe(p, {
101
+ annotations: t.selected.map((i) => i.id)
102
+ }));
103
+ }, m = (i) => {
104
+ const c = i.selected[0].id, O = f.getAnnotation(c), { minX: h, minY: k, maxX: C, maxY: M } = O.target.selector.geometry.bounds, V = 14, j = r.viewport.imageToViewerElementCoordinates(new b.Point(h, k)), A = r.viewport.imageToViewerElementCoordinates(new b.Point(C, M));
105
+ e(1, d = A.x + V), e(2, a = j.y);
106
+ };
107
+ return z(() => {
108
+ const i = () => {
109
+ g(t) && !l && m(t);
110
+ };
111
+ return r.addHandler("update-viewport", i), () => {
112
+ r.removeHandler("update-viewport", i);
113
+ };
114
+ }), n.$$set = (i) => {
115
+ "state" in i && e(6, s = i.state), "viewer" in i && e(7, r = i.viewer);
116
+ }, n.$$.update = () => {
117
+ n.$$.dirty & /*$selection*/
118
+ 1 && N();
119
+ }, [t, d, a, u, E, D, s, r];
120
+ }
121
+ class W extends B {
122
+ constructor(o) {
123
+ super(), F(this, o, Q, K, H, { state: 6, viewer: 7 });
124
+ }
125
+ }
126
+ const re = W;
9
127
  export {
10
- d as createBody
128
+ re as default
11
129
  };
12
130
  //# sourceMappingURL=annotorious-svelte.es4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es4.js","sources":["../../annotorious-core/src/utils/annotationUtils.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport type { Annotation, AnnotationBody, User } from '../model';\n\n/**\n * Returns all users listed as creators or updaters in any parts of this\n * annotation.\n */\nexport const getContributors = (annotation: Annotation): User[] => {\n const { creator, updatedBy } = annotation.target;\n\n const bodyCollaborators = annotation.bodies.reduce((users, body) => (\n [...users, body.creator, body.updatedBy]\n ), [] as User[]);\n\n return [\n creator,\n updatedBy,\n ...bodyCollaborators\n ].filter(u => u); // Remove undefined\n}\n\nexport const createBody = (\n annotation: Annotation, \n payload: { [key: string]: any },\n created?: Date,\n creator?: User\n): AnnotationBody => ({\n id: uuidv4(),\n annotation: annotation.id,\n created: created || new Date(),\n creator,\n ...payload\n});"],"names":["createBody","annotation","payload","created","creator","uuidv4"],"mappings":";AAqBO,MAAMA,IAAa,CACxBC,GACAC,GACAC,GACAC,OACoB;AAAA,EACpB,IAAIC,EAAO;AAAA,EACX,YAAYJ,EAAW;AAAA,EACvB,SAASE,KAAW,oBAAI,KAAK;AAAA,EAC7B,SAAAC;AAAA,EACA,GAAGF;AACL;"}
1
+ {"version":3,"file":"annotorious-svelte.es4.js","sources":["../src/osd/OpenSeadragonPopup.svelte"],"sourcesContent":["<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { draggable } from '@neodrag/svelte';\n import OpenSeadragon from 'openseadragon';\n import type { Selection, StoreChangeEvent, SvelteAnnotatorState } from '@annotorious/core';\n import type { ImageAnnotation } from '@annotorious/annotorious';\n\n export let state: SvelteAnnotatorState<ImageAnnotation>;\n\n export let viewer: OpenSeadragon.Viewer;\n\n let left: number;\n\n let top: number;\n\n let dragged = false;\n\n let storeObserver: (event: StoreChangeEvent<ImageAnnotation>) => void;\n\n const { selection, store } = state; \n\n const isSelected = (selection: Selection) => selection.selected?.length > 0;\n\n const onDragStart = () => {\n dragged = true;\n viewer.setMouseNavEnabled(false);\n }\n\n const onDragEnd = () => {\n viewer.setMouseNavEnabled(true);\n }\n\n $: $selection, onSelect();\n\n const onSelect = () => {\n if (storeObserver)\n store.unobserve(storeObserver);\n\n if (isSelected($selection)) {\n dragged = false;\n\n setPosition($selection);\n\n storeObserver = (event: StoreChangeEvent<ImageAnnotation>) => {\n if (!dragged)\n setPosition($selection);\n }\n\n store.observe(storeObserver, { annotations: $selection.selected.map(s => s.id) });\n }\n }\n\n const setPosition = (selection: Selection) => {\n // Note: this demo popup only supports a single selection\n const selectedId = selection.selected[0].id;\n const annotation = store.getAnnotation(selectedId);\n\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n const PADDING = 14;\n\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // [left, top] = defaultStrategy(annotation, lastPointerDown);\n left = bottomRight.x + PADDING;\n top = topLeft.y;\n }\n\n onMount(() => {\n const onUpdateViewport = () => {\n if (isSelected($selection) && !dragged)\n setPosition($selection);\n }\n\n viewer.addHandler('update-viewport', onUpdateViewport);\n\n return () => {\n viewer.removeHandler('update-viewport', onUpdateViewport);\n }\n });\n</script>\n\n{#if $selection}\n <div \n class=\"a9s-popup a9s-osd-popup\"\n use:draggable={{ position: { x: left, y: top }}}\n on:neodrag:start={onDragStart}\n on:neodrag:end={onDragEnd}>\n {$selection.selected.map(s => s.id).join(', ')}\n </div>\n{/if}\n\n<style>\n .a9s-osd-popup {\n background-color: #fff;\n border: 1px solid #a2a2a2;\n height: 250px;\n position: absolute;\n width: 400px;\n z-index: 1;\n }\n</style>"],"names":["t_value","ctx","func","insert","target","div","anchor","dirty","set_data","create_if_block","s","state","$$props","viewer","left","top","dragged","storeObserver","selection","store","isSelected","_a","onDragStart","onDragEnd","onSelect","$selection","setPosition","event","selectedId","annotation","minX","minY","maxX","maxY","PADDING","topLeft","OpenSeadragon","bottomRight","$$invalidate","onMount","onUpdateViewport"],"mappings":";;;;;;;;;SAyFKA;AAAA;AAAA,IAAAC,KAAW,SAAS,IAAeC,CAAA,EAAA,KAAK,IAAI,IAAA;AAAA;;;;;;AAL/C,MAAAC,EAMKC,GAAAC,GAAAC,CAAA;;UAJc,YAAY;AAAA;AAAA,YAAGL,EAAM,CAAA;AAAA,aAAA;AAAA;AAAA,YAAGA,EAAG,CAAA;AAAA,YAAA;AAAA;;;;;UAC1BA,EAAW,CAAA;AAAA,QAAA;AAAA;;;;UACbA,EAAS,CAAA;AAAA,QAAA;AAAA;;;AACxB,MAAAM;AAAA,MAAA,KAAAP,OAAAA;AAAA,MAAAC,KAAW,SAAS,IAAeC,CAAA,EAAA,KAAK,IAAI,IAAA,OAAAM,EAAA,GAAAR,CAAA;;QAH5B,YAAY;AAAA;AAAA,UAAGC,EAAM,CAAA;AAAA,WAAA;AAAA;AAAA,UAAGA,EAAG,CAAA;AAAA,UAAA;AAAA;;;;;;;;;;IAH3CA,EAAU,CAAA,KAAAQ,EAAAR,CAAA;AAAA;;;;;;;;;;MAAVA,EAAU,CAAA;;;;;;;;;UAMc,CAAAS,MAAKA,EAAE;;WAlFvB,OAAAC,EAA4C,IAAAC,KAE5C,QAAAC,EAA4B,IAAAD,GAEnCE,GAEAC,GAEAC,IAAU,IAEVC;UAEI,WAAAC,GAAW,OAAAC,EAAK,IAAKR;;QAEvBS,IAAc,CAAAF,MAAyB;;AAAA,aAAAG,IAAAH,EAAU,aAAV,gBAAAG,EAAoB,UAAS;AAAA,KAEpEC,IAAW,MAAA;AACf,IAAAN,IAAU,IACVH,EAAO,mBAAmB,EAAK;AAAA,KAG3BU,IAAS,MAAA;AACb,IAAAV,EAAO,mBAAmB,EAAI;AAAA,KAK1BW,IAAQ,MAAA;AACR,IAAAP,KACFE,EAAM,UAAUF,CAAa,GAE3BG,EAAWK,CAAU,MACvBT,IAAU,IAEVU,EAAYD,CAAU,GAEtBR,IAAiB,CAAAU,MAAwC;MAClDX,KACHU,EAAYD,CAAU;AAAA,OAG1BN,EAAM,QAAQF,GAAa;AAAA,MAAI,aAAaQ,EAAW,SAAS,IAAI,CAAAf,MAAKA,EAAE,EAAE;AAAA;KAI3EgB,IAAe,CAAAR,MAAoB;AAEjC,UAAAU,IAAaV,EAAU,SAAS,CAAC,EAAE,IACnCW,IAAaV,EAAM,cAAcS,CAAU,GAEzC,EAAA,MAAAE,GAAM,MAAAC,GAAM,MAAAC,GAAM,MAAAC,EAAI,IAAKJ,EAAW,OAAO,SAAS,SAAS,QAEjEK,IAAU,IAEVC,IAAUtB,EAAO,SAAS,gCAAoC,IAAAuB,EAAc,MAAMN,GAAMC,CAAI,CAAA,GAC5FM,IAAcxB,EAAO,SAAS,gCAAoC,IAAAuB,EAAc,MAAMJ,GAAMC,CAAI,CAAA;AAGtG,IAAAK,EAAA,GAAAxB,IAAOuB,EAAY,IAAIH,CAAO,QAC9BnB,IAAMoB,EAAQ,CAAC;AAAA;AAGjB,SAAAI,EAAO,MAAA;UACCC,IAAgB,MAAA;AAChB,MAAApB,EAAWK,CAAU,KAAA,CAAMT,KAC7BU,EAAYD,CAAU;AAAA;AAG1B,WAAAZ,EAAO,WAAW,mBAAmB2B,CAAgB;AAGnD,MAAA3B,EAAO,cAAc,mBAAmB2B,CAAgB;AAAA;;;;;SA9C7ChB,EAAQ;AAAA;;;;;;;;"}