@annotorious/svelte 3.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/MouseOverTooltip.svelte.d.ts +1 -0
  2. package/dist/annotorious-svelte.es.js +9 -0
  3. package/dist/annotorious-svelte.es.js.map +1 -0
  4. package/dist/annotorious-svelte.es10.js +5 -0
  5. package/dist/annotorious-svelte.es10.js.map +1 -0
  6. package/dist/annotorious-svelte.es11.js +5 -0
  7. package/dist/annotorious-svelte.es11.js.map +1 -0
  8. package/dist/annotorious-svelte.es2.js +128 -0
  9. package/dist/annotorious-svelte.es2.js.map +1 -0
  10. package/dist/annotorious-svelte.es3.js +113 -0
  11. package/dist/annotorious-svelte.es3.js.map +1 -0
  12. package/dist/annotorious-svelte.es4.js +126 -0
  13. package/dist/annotorious-svelte.es4.js.map +1 -0
  14. package/dist/annotorious-svelte.es5.js +316 -0
  15. package/dist/annotorious-svelte.es5.js.map +1 -0
  16. package/dist/annotorious-svelte.es6.js +11 -0
  17. package/dist/annotorious-svelte.es6.js.map +1 -0
  18. package/dist/annotorious-svelte.es7.js +3 -0
  19. package/dist/annotorious-svelte.es7.js.map +1 -0
  20. package/dist/annotorious-svelte.es8.js +20596 -0
  21. package/dist/annotorious-svelte.es8.js.map +1 -0
  22. package/dist/annotorious-svelte.es9.js +123 -0
  23. package/dist/annotorious-svelte.es9.js.map +1 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/osd/OpenSeadragonAnnotator.svelte.d.ts +1 -0
  27. package/dist/osd/OpenSeadragonPopup.svelte.d.ts +1 -0
  28. package/dist/osd/index.d.ts +3 -0
  29. package/dist/osd/index.d.ts.map +1 -0
  30. package/dist/style.css +1 -0
  31. package/package.json +33 -0
  32. package/src/MouseOverTooltip.svelte +55 -0
  33. package/src/index.ts +14 -0
  34. package/src/osd/OpenSeadragonAnnotator.svelte +39 -0
  35. package/src/osd/OpenSeadragonPopup.svelte +103 -0
  36. package/src/osd/index.ts +2 -0
  37. package/test/App.svelte +75 -0
  38. package/test/annotations.json +54 -0
  39. package/test/index.html +24 -0
  40. package/test/index.ts +9 -0
  41. package/tsconfig.json +25 -0
  42. package/vite.config.js +37 -0
@@ -0,0 +1,123 @@
1
+ var F = { dragStart: !0 }, rt = (e, s, i) => Math.min(Math.max(e, s), i), G = (e) => typeof e == "string", dt = ([e, s], i, d) => {
2
+ const u = (y, f) => f === 0 ? 0 : Math.ceil(y / f) * f;
3
+ return [u(i, e), u(d, s)];
4
+ }, ot = (e, s) => e.some((i) => s.some((d) => i.contains(d)));
5
+ function I(e, s) {
6
+ if (e === void 0)
7
+ return;
8
+ if (J(e))
9
+ return e.getBoundingClientRect();
10
+ if (typeof e == "object") {
11
+ const { top: d = 0, left: u = 0, right: y = 0, bottom: f = 0 } = e;
12
+ return { top: d, right: window.innerWidth - y, bottom: window.innerHeight - f, left: u };
13
+ }
14
+ if (e === "parent")
15
+ return s.parentNode.getBoundingClientRect();
16
+ const i = document.querySelector(e);
17
+ if (i === null)
18
+ throw new Error("The selector provided for bound doesn't exists in the document.");
19
+ return i.getBoundingClientRect();
20
+ }
21
+ var H = (e, s, i) => e.style.setProperty(s, i), J = (e) => e instanceof HTMLElement, ut = (e, s = {}) => {
22
+ let i, d, { bounds: u, axis: y = "both", gpuAcceleration: f = !0, legacyTranslate: K = !0, transform: L, applyUserSelectHack: P = !0, disabled: O = !1, ignoreMultitouch: Q = !1, recomputeBounds: x = F, grid: T, position: p, cancel: N, handle: D, defaultClass: M = "neodrag", defaultClassDragging: X = "neodrag-dragging", defaultClassDragged: S = "neodrag-dragged", defaultPosition: it = { x: 0, y: 0 }, onDragStart: at, onDrag: st, onDragEnd: lt } = s, B = !1, b = 0, w = 0, A = 0, C = 0, Y = 0, q = 0, { x: $, y: R } = p ? { x: (p == null ? void 0 : p.x) ?? 0, y: (p == null ? void 0 : p.y) ?? 0 } : it;
23
+ W($, R);
24
+ let g, v, E, k, V, Z = "", ct = !!p;
25
+ x = { ...F, ...x };
26
+ const U = document.body.style, m = e.classList;
27
+ function W(t = b, r = w) {
28
+ if (!L) {
29
+ if (K) {
30
+ let a = `${+t}px, ${+r}px`;
31
+ return H(e, "transform", f ? `translate3d(${a}, 0)` : `translate(${a})`);
32
+ }
33
+ return H(e, "translate", `${+t}px ${+r}px ${f ? "1px" : ""}`);
34
+ }
35
+ const o = L({ offsetX: t, offsetY: r, rootNode: e });
36
+ G(o) && H(e, "transform", o);
37
+ }
38
+ const j = (t, r) => {
39
+ const o = { offsetX: b, offsetY: w, rootNode: e, currentNode: V };
40
+ e.dispatchEvent(new CustomEvent(t, { detail: o })), r == null || r(o);
41
+ }, z = addEventListener;
42
+ z("pointerdown", tt, !1), z("pointerup", et, !1), z("pointermove", nt, !1), H(e, "touch-action", "none");
43
+ const _ = () => {
44
+ let t = e.offsetWidth / v.width;
45
+ return isNaN(t) && (t = 1), t;
46
+ };
47
+ function tt(t) {
48
+ if (O || t.button === 2 || Q && !t.isPrimary)
49
+ return;
50
+ if (x.dragStart && (g = I(u, e)), G(D) && G(N) && D === N)
51
+ throw new Error("`handle` selector can't be same as `cancel` selector");
52
+ if (m.add(M), E = function(n, c) {
53
+ if (!n)
54
+ return [c];
55
+ if (J(n))
56
+ return [n];
57
+ if (Array.isArray(n))
58
+ return n;
59
+ const h = c.querySelectorAll(n);
60
+ if (h === null)
61
+ throw new Error("Selector passed for `handle` option should be child of the element on which the action is applied");
62
+ return Array.from(h.values());
63
+ }(D, e), k = function(n, c) {
64
+ if (!n)
65
+ return [];
66
+ if (J(n))
67
+ return [n];
68
+ if (Array.isArray(n))
69
+ return n;
70
+ const h = c.querySelectorAll(n);
71
+ if (h === null)
72
+ throw new Error("Selector passed for `cancel` option should be child of the element on which the action is applied");
73
+ return Array.from(h.values());
74
+ }(N, e), i = /(both|x)/.test(y), d = /(both|y)/.test(y), ot(k, E))
75
+ throw new Error("Element being dragged can't be a child of the element on which `cancel` is applied");
76
+ const r = t.composedPath()[0];
77
+ if (!E.some((n) => {
78
+ var c;
79
+ return n.contains(r) || ((c = n.shadowRoot) == null ? void 0 : c.contains(r));
80
+ }) || ot(k, [r]))
81
+ return;
82
+ V = E.length === 1 ? e : E.find((n) => n.contains(r)), B = !0, v = e.getBoundingClientRect(), P && (Z = U.userSelect, U.userSelect = "none"), j("neodrag:start", at);
83
+ const { clientX: o, clientY: a } = t, l = _();
84
+ i && (A = o - $ / l), d && (C = a - R / l), g && (Y = o - v.left, q = a - v.top);
85
+ }
86
+ function et() {
87
+ B && (x.dragEnd && (g = I(u, e)), m.remove(X), m.add(S), P && (U.userSelect = Z), j("neodrag:end", lt), i && (A = b), d && (C = w), B = !1);
88
+ }
89
+ function nt(t) {
90
+ if (!B)
91
+ return;
92
+ x.drag && (g = I(u, e)), m.add(X), t.preventDefault(), v = e.getBoundingClientRect();
93
+ let r = t.clientX, o = t.clientY;
94
+ const a = _();
95
+ if (g) {
96
+ const l = { left: g.left + Y, top: g.top + q, right: g.right + Y - v.width, bottom: g.bottom + q - v.height };
97
+ r = rt(r, l.left, l.right), o = rt(o, l.top, l.bottom);
98
+ }
99
+ if (Array.isArray(T)) {
100
+ let [l, n] = T;
101
+ if (isNaN(+l) || l < 0)
102
+ throw new Error("1st argument of `grid` must be a valid positive number");
103
+ if (isNaN(+n) || n < 0)
104
+ throw new Error("2nd argument of `grid` must be a valid positive number");
105
+ let c = r - A, h = o - C;
106
+ [c, h] = dt([l / a, n / a], c, h), r = A + c, o = C + h;
107
+ }
108
+ i && (b = Math.round((r - A) * a)), d && (w = Math.round((o - C) * a)), $ = b, R = w, j("neodrag", st), W();
109
+ }
110
+ return { destroy: () => {
111
+ const t = removeEventListener;
112
+ t("pointerdown", tt, !1), t("pointerup", et, !1), t("pointermove", nt, !1);
113
+ }, update: (t) => {
114
+ var o, a;
115
+ y = t.axis || "both", O = t.disabled ?? !1, Q = t.ignoreMultitouch ?? !1, D = t.handle, u = t.bounds, x = t.recomputeBounds ?? F, N = t.cancel, P = t.applyUserSelectHack ?? !0, T = t.grid, f = t.gpuAcceleration ?? !0, K = t.legacyTranslate ?? !0, L = t.transform;
116
+ const r = m.contains(S);
117
+ m.remove(M, S), M = t.defaultClass ?? "neodrag", X = t.defaultClassDragging ?? "neodrag-dragging", S = t.defaultClassDragged ?? "neodrag-dragged", m.add(M), r && m.add(S), ct && ($ = b = ((o = t.position) == null ? void 0 : o.x) ?? b, R = w = ((a = t.position) == null ? void 0 : a.y) ?? w, W());
118
+ } };
119
+ };
120
+ export {
121
+ ut as draggable
122
+ };
123
+ //# sourceMappingURL=annotorious-svelte.es9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotorious-svelte.es9.js","sources":["../../../node_modules/@neodrag/svelte/dist/min/index.js"],"sourcesContent":["var t={dragStart:!0},e=(t,e,n)=>Math.min(Math.max(t,e),n),n=t=>\"string\"==typeof t,r=([t,e],n,r)=>{const o=(t,e)=>0===e?0:Math.ceil(t/e)*e;return[o(n,t),o(r,e)]};var o=(t,e)=>t.some((t=>e.some((e=>t.contains(e)))));function i(t,e){if(void 0===t)return;if(s(t))return t.getBoundingClientRect();if(\"object\"==typeof t){const{top:e=0,left:n=0,right:r=0,bottom:o=0}=t;return{top:e,right:window.innerWidth-r,bottom:window.innerHeight-o,left:n}}if(\"parent\"===t)return e.parentNode.getBoundingClientRect();const n=document.querySelector(t);if(null===n)throw new Error(\"The selector provided for bound doesn't exists in the document.\");return n.getBoundingClientRect()}var a=(t,e,n)=>t.style.setProperty(e,n),s=t=>t instanceof HTMLElement,d=(d,l={})=>{let c,u,{bounds:f,axis:g=\"both\",gpuAcceleration:h=!0,legacyTranslate:p=!0,transform:m,applyUserSelectHack:y=!0,disabled:b=!1,ignoreMultitouch:w=!1,recomputeBounds:v=t,grid:x,position:E,cancel:S,handle:A,defaultClass:C=\"neodrag\",defaultClassDragging:N=\"neodrag-dragging\",defaultClassDragged:D=\"neodrag-dragged\",defaultPosition:M={x:0,y:0},onDragStart:B,onDrag:$,onDragEnd:R}=l,H=!1,L=0,P=0,T=0,X=0,Y=0,q=0,{x:k,y:U}=E?{x:E?.x??0,y:E?.y??0}:M;Q(k,U);let W,j,z,F,G,I=\"\",J=!!E;v={...t,...v};const K=document.body.style,O=d.classList;function Q(t=L,e=P){if(!m){if(p){let n=`${+t}px, ${+e}px`;return a(d,\"transform\",h?`translate3d(${n}, 0)`:`translate(${n})`)}return a(d,\"translate\",`${+t}px ${+e}px ${h?\"1px\":\"\"}`)}const r=m({offsetX:t,offsetY:e,rootNode:d});n(r)&&a(d,\"transform\",r)}const V=(t,e)=>{const n={offsetX:L,offsetY:P,rootNode:d,currentNode:G};d.dispatchEvent(new CustomEvent(t,{detail:n})),e?.(n)};const Z=addEventListener;Z(\"pointerdown\",tt,!1),Z(\"pointerup\",et,!1),Z(\"pointermove\",nt,!1),a(d,\"touch-action\",\"none\");const _=()=>{let t=d.offsetWidth/j.width;return isNaN(t)&&(t=1),t};function tt(t){if(b)return;if(2===t.button)return;if(w&&!t.isPrimary)return;if(v.dragStart&&(W=i(f,d)),n(A)&&n(S)&&A===S)throw new Error(\"`handle` selector can't be same as `cancel` selector\");if(O.add(C),z=function(t,e){if(!t)return[e];if(s(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `handle` option should be child of the element on which the action is applied\");return Array.from(n.values())}(A,d),F=function(t,e){if(!t)return[];if(s(t))return[t];if(Array.isArray(t))return t;const n=e.querySelectorAll(t);if(null===n)throw new Error(\"Selector passed for `cancel` option should be child of the element on which the action is applied\");return Array.from(n.values())}(S,d),c=/(both|x)/.test(g),u=/(both|y)/.test(g),o(F,z))throw new Error(\"Element being dragged can't be a child of the element on which `cancel` is applied\");const e=t.composedPath()[0];if(!z.some((t=>t.contains(e)||t.shadowRoot?.contains(e)))||o(F,[e]))return;G=1===z.length?d:z.find((t=>t.contains(e))),H=!0,j=d.getBoundingClientRect(),y&&(I=K.userSelect,K.userSelect=\"none\"),V(\"neodrag:start\",B);const{clientX:r,clientY:a}=t,l=_();c&&(T=r-k/l),u&&(X=a-U/l),W&&(Y=r-j.left,q=a-j.top)}function et(){H&&(v.dragEnd&&(W=i(f,d)),O.remove(N),O.add(D),y&&(K.userSelect=I),V(\"neodrag:end\",R),c&&(T=L),u&&(X=P),H=!1)}function nt(t){if(!H)return;v.drag&&(W=i(f,d)),O.add(N),t.preventDefault(),j=d.getBoundingClientRect();let n=t.clientX,o=t.clientY;const a=_();if(W){const t={left:W.left+Y,top:W.top+q,right:W.right+Y-j.width,bottom:W.bottom+q-j.height};n=e(n,t.left,t.right),o=e(o,t.top,t.bottom)}if(Array.isArray(x)){let[t,e]=x;if(isNaN(+t)||t<0)throw new Error(\"1st argument of `grid` must be a valid positive number\");if(isNaN(+e)||e<0)throw new Error(\"2nd argument of `grid` must be a valid positive number\");let i=n-T,s=o-X;[i,s]=r([t/a,e/a],i,s),n=T+i,o=X+s}c&&(L=Math.round((n-T)*a)),u&&(P=Math.round((o-X)*a)),k=L,U=P,V(\"neodrag\",$),Q()}return{destroy:()=>{const t=removeEventListener;t(\"pointerdown\",tt,!1),t(\"pointerup\",et,!1),t(\"pointermove\",nt,!1)},update:e=>{g=e.axis||\"both\",b=e.disabled??!1,w=e.ignoreMultitouch??!1,A=e.handle,f=e.bounds,v=e.recomputeBounds??t,S=e.cancel,y=e.applyUserSelectHack??!0,x=e.grid,h=e.gpuAcceleration??!0,p=e.legacyTranslate??!0,m=e.transform;const n=O.contains(D);O.remove(C,D),C=e.defaultClass??\"neodrag\",N=e.defaultClassDragging??\"neodrag-dragging\",D=e.defaultClassDragged??\"neodrag-dragged\",O.add(C),n&&O.add(D),J&&(k=L=e.position?.x??L,U=P=e.position?.y??P,Q())}}};export{d as draggable};"],"names":["t","e","n","r","o","i","s","a","d","l","c","u","f","g","h","p","m","y","b","w","v","x","E","S","A","C","N","D","M","B","$","R","H","L","P","T","X","k","U","Q","W","j","z","F","G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te';
3
+ export type { SvelteAnnotator, SvelteAnnotatorState } from '@annotorious/core';
4
+ export type { ImageAnnotation } from '@annotorious/annotorious';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AAEtB,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGxE,YAAY,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,eAAe,EAChB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export { SvelteComponentTyped as default } from 'svelte';
@@ -0,0 +1 @@
1
+ export { SvelteComponentTyped as default } from 'svelte';
@@ -0,0 +1,3 @@
1
+ export { default as OpenSeadragonAnnotator } from './OpenSeadragonAnnotator.svelte';
2
+ export { default as OpenSeadragonPopup } from './OpenSeadragonPopup.svelte';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/osd/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .a9s-osd-popup.svelte-1xuxeat{background-color:#fff;border:1px solid #a2a2a2;height:250px;position:absolute;width:400px;z-index:1}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@annotorious/svelte",
3
+ "version": "3.0.0-rc.1",
4
+ "description": "Annotorious Svelte bindings",
5
+ "author": "Rainer Simon",
6
+ "license": "BSD-3-Clause",
7
+ "homepage": "https://annotorious.github.io",
8
+ "type": "module",
9
+ "scripts": {
10
+ "start": "vite",
11
+ "build": "tsc && vite build",
12
+ "test": "echo 'Skipping tests in @annotorious/svelte package'"
13
+ },
14
+ "module": "./dist/annotorious-svelte.es.js",
15
+ "types": "./src/index.ts",
16
+ "svelte": "./src/index.ts",
17
+ "devDependencies": {
18
+ "@annotorious/core": "*",
19
+ "@sveltejs/vite-plugin-svelte": "^2.4.6",
20
+ "@tsconfig/svelte": "^3.0.0",
21
+ "@types/openseadragon": "^3.0.7",
22
+ "svelte": "^3.59.2",
23
+ "svelte-check": "^3.5.2",
24
+ "tslib": "^2.6.2",
25
+ "typescript": "^4.9.5",
26
+ "vite": "^4.4.9",
27
+ "vite-plugin-dts": "^3.6.0"
28
+ },
29
+ "peerDependencies": {
30
+ "openseadragon": "^3.0.0 || ^4.0.0"
31
+ },
32
+ "sideEffects": false
33
+ }
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import { getContext, onMount } from 'svelte';
3
+ import type { ImageAnnotation } from '@annotorious/annotorious';
4
+ import type { SvelteAnnotator } from '@annotorious/core';
5
+
6
+ export let container: Element;
7
+
8
+ const anno = getContext<SvelteAnnotator<ImageAnnotation>>('anno');
9
+
10
+ const { store, hover } = anno.state;
11
+
12
+ let top: number;
13
+
14
+ let left: number;
15
+
16
+ let show = true;
17
+
18
+ $: hovered = $hover ? store.getAnnotation($hover) : undefined;
19
+
20
+ onMount(() => {
21
+ const onPointerEnter = () => {
22
+ show = true;
23
+ }
24
+
25
+ const onPointerMove = (event: PointerEvent) => {
26
+ const { offsetX, offsetY } = event;
27
+ left = offsetX;
28
+ top = offsetY;
29
+ }
30
+
31
+ const onPointerLeave = () => {
32
+ show = false;
33
+ }
34
+
35
+ container.addEventListener('pointerenter', onPointerEnter);
36
+ container.addEventListener('pointermove', onPointerMove);
37
+ container.addEventListener('pointerleave', onPointerLeave);
38
+
39
+ return () => {
40
+ container.removeEventListener('pointerenter', onPointerEnter);
41
+ container.removeEventListener('pointermove', onPointerMove);
42
+ container.removeEventListener('pointerleave', onPointerLeave);
43
+ }
44
+ });
45
+ </script>
46
+
47
+ {#if $hover && show}
48
+ <div
49
+ class="a9s-tooltip"
50
+ style={`left:${left}px; top:${top}px; position: absolute;`}>
51
+
52
+ <slot hovered={hovered} />
53
+
54
+ </div>
55
+ {/if}
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * from './osd';
2
+
3
+ export { default as MouseOverTooltip } from './MouseOverTooltip.svelte';
4
+
5
+ // Re-export essentials from @annotorious/core
6
+ export type {
7
+ SvelteAnnotator,
8
+ SvelteAnnotatorState
9
+ } from '@annotorious/core';
10
+
11
+ // Re-export essentials from @annotorious/annotorious
12
+ export type {
13
+ ImageAnnotation
14
+ } from '@annotorious/annotorious';
@@ -0,0 +1,39 @@
1
+ <script lang="ts">
2
+ import { setContext } from 'svelte';
3
+ import { SvelteAnnotator, SvelteAnnotatorState, toSvelteStore } from '@annotorious/core';
4
+ import { createOSDAnnotator, ImageAnnotation } from '@annotorious/openseadragon';
5
+ import type OpenSeadragon from 'openseadragon';
6
+
7
+ /** props **/
8
+ export let viewer: OpenSeadragon.Viewer;
9
+ export let opts = {};
10
+ export let anno: SvelteAnnotator<ImageAnnotation> = undefined;
11
+
12
+ $: init(viewer);
13
+
14
+ const init = (viewer: OpenSeadragon.Viewer) => {
15
+ if (viewer) {
16
+ const annotator = createOSDAnnotator(viewer, opts);
17
+
18
+ // Wrap the store for Svelte reactivity
19
+ const svelteStore = toSvelteStore(annotator.state.store);
20
+
21
+ const shim = {
22
+ ...annotator,
23
+ state: {
24
+ ...annotator.state,
25
+ store: svelteStore
26
+ } as SvelteAnnotatorState<ImageAnnotation>
27
+ } as SvelteAnnotator<ImageAnnotation>
28
+
29
+ setContext('anno', shim);
30
+ setContext('viewer', viewer);
31
+
32
+ anno = shim;
33
+ }
34
+ }
35
+ </script>
36
+
37
+ {#if viewer}
38
+ <slot />
39
+ {/if}
@@ -0,0 +1,103 @@
1
+ <script lang="ts">
2
+ import { onMount } from 'svelte';
3
+ import { draggable } from '@neodrag/svelte';
4
+ import OpenSeadragon from 'openseadragon';
5
+ import type { Selection, StoreChangeEvent, SvelteAnnotatorState } from '@annotorious/core';
6
+ import type { ImageAnnotation } from '@annotorious/annotorious';
7
+
8
+ export let state: SvelteAnnotatorState<ImageAnnotation>;
9
+
10
+ export let viewer: OpenSeadragon.Viewer;
11
+
12
+ let left: number;
13
+
14
+ let top: number;
15
+
16
+ let dragged = false;
17
+
18
+ let storeObserver: (event: StoreChangeEvent<ImageAnnotation>) => void;
19
+
20
+ const { selection, store } = state;
21
+
22
+ const isSelected = (selection: Selection) => selection.selected?.length > 0;
23
+
24
+ const onDragStart = () => {
25
+ dragged = true;
26
+ viewer.setMouseNavEnabled(false);
27
+ }
28
+
29
+ const onDragEnd = () => {
30
+ viewer.setMouseNavEnabled(true);
31
+ }
32
+
33
+ $: $selection, onSelect();
34
+
35
+ const onSelect = () => {
36
+ if (storeObserver)
37
+ store.unobserve(storeObserver);
38
+
39
+ if (isSelected($selection)) {
40
+ dragged = false;
41
+
42
+ setPosition($selection);
43
+
44
+ storeObserver = (event: StoreChangeEvent<ImageAnnotation>) => {
45
+ if (!dragged)
46
+ setPosition($selection);
47
+ }
48
+
49
+ store.observe(storeObserver, { annotations: $selection.selected.map(s => s.id) });
50
+ }
51
+ }
52
+
53
+ const setPosition = (selection: Selection) => {
54
+ // Note: this demo popup only supports a single selection
55
+ const selectedId = selection.selected[0].id;
56
+ const annotation = store.getAnnotation(selectedId);
57
+
58
+ const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;
59
+
60
+ const PADDING = 14;
61
+
62
+ const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));
63
+ const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));
64
+
65
+ // [left, top] = defaultStrategy(annotation, lastPointerDown);
66
+ left = bottomRight.x + PADDING;
67
+ top = topLeft.y;
68
+ }
69
+
70
+ onMount(() => {
71
+ const onUpdateViewport = () => {
72
+ if (isSelected($selection) && !dragged)
73
+ setPosition($selection);
74
+ }
75
+
76
+ viewer.addHandler('update-viewport', onUpdateViewport);
77
+
78
+ return () => {
79
+ viewer.removeHandler('update-viewport', onUpdateViewport);
80
+ }
81
+ });
82
+ </script>
83
+
84
+ {#if $selection}
85
+ <div
86
+ class="a9s-popup a9s-osd-popup"
87
+ use:draggable={{ position: { x: left, y: top }}}
88
+ on:neodrag:start={onDragStart}
89
+ on:neodrag:end={onDragEnd}>
90
+ {$selection.selected.map(s => s.id).join(', ')}
91
+ </div>
92
+ {/if}
93
+
94
+ <style>
95
+ .a9s-osd-popup {
96
+ background-color: #fff;
97
+ border: 1px solid #a2a2a2;
98
+ height: 250px;
99
+ position: absolute;
100
+ width: 400px;
101
+ z-index: 1;
102
+ }
103
+ </style>
@@ -0,0 +1,2 @@
1
+ export { default as OpenSeadragonAnnotator } from './OpenSeadragonAnnotator.svelte';
2
+ export { default as OpenSeadragonPopup } from './OpenSeadragonPopup.svelte';
@@ -0,0 +1,75 @@
1
+ <script lang="ts">
2
+ import { onMount } from 'svelte';
3
+ import OpenSeadragon from 'openseadragon';
4
+ import { ImageAnnotation, W3CImageFormat } from '@annotorious/annotorious';
5
+ import { OpenSeadragonAnnotator, MouseOverTooltip, SvelteAnnotator } from '@annotorious/svelte';
6
+
7
+ let container: HTMLDivElement;
8
+
9
+ let viewer: OpenSeadragon.Viewer;
10
+
11
+ let anno: SvelteAnnotator<ImageAnnotation>;
12
+
13
+ $: if (anno) anno.loadAnnotations('annotations.json');
14
+
15
+ const IIIF_SAMPLE = {
16
+ "@context" : "http://iiif.io/api/image/2/context.json",
17
+ "protocol" : "http://iiif.io/api/image",
18
+ "width" : 7808,
19
+ "height" : 5941,
20
+ "sizes" : [
21
+ { "width" : 244, "height" : 185 },
22
+ { "width" : 488, "height" : 371 },
23
+ { "width" : 976, "height" : 742 }
24
+ ],
25
+ "tiles" : [
26
+ { "width" : 256, "height" : 256, "scaleFactors" : [ 1, 2, 4, 8, 16, 32 ] }
27
+ ],
28
+ "@id" : "https://iiif.bodleian.ox.ac.uk/iiif/image/af315e66-6a85-445b-9e26-012f729fc49c",
29
+ "profile" : [
30
+ "http://iiif.io/api/image/2/level2.json",
31
+ { "formats" : [ "jpg", "png", "webp" ],
32
+ "qualities" : ["native","color","gray","bitonal"],
33
+ "supports" : ["regionByPct","regionSquare","sizeByForcedWh","sizeByWh","sizeAboveFull","sizeUpscaling","rotationBy90s","mirroring"],
34
+ "maxWidth" : 1000,
35
+ "maxHeight" : 1000
36
+ }
37
+ ]
38
+ };
39
+
40
+ onMount(() => {
41
+ viewer = OpenSeadragon({
42
+ element: container,
43
+ prefixUrl: 'https://cdn.jsdelivr.net/npm/openseadragon@3.1/build/openseadragon/images/',
44
+ tileSources: IIIF_SAMPLE,
45
+ crossOriginPolicy: 'Anonymous',
46
+ gestureSettingsMouse: {
47
+ clickToZoom: false
48
+ }
49
+ });
50
+ });
51
+ </script>
52
+
53
+ <div class="container">
54
+ <div bind:this={container} class="openseadragon" />
55
+
56
+ <OpenSeadragonAnnotator
57
+ viewer={viewer}
58
+ bind:anno={anno}
59
+ opts={{
60
+ adapter: W3CImageFormat('https://iiif.bodleian.ox.ac.uk/iiif/image/af315e66-6a85-445b-9e26-012f729fc49c')
61
+ }}>
62
+
63
+ <MouseOverTooltip container={viewer.element}>
64
+ Hello World
65
+ </MouseOverTooltip>
66
+
67
+ </OpenSeadragonAnnotator>
68
+ </div>
69
+
70
+ <style>
71
+ .container, .openseadragon {
72
+ height: 100%;
73
+ width: 100%;
74
+ }
75
+ </style>
@@ -0,0 +1,54 @@
1
+ [{
2
+ "@context": "http://www.w3.org/ns/anno.jsonld",
3
+ "id": "#a88b22d0-6106-4872-9435-c78b5e89fede",
4
+ "type": "Annotation",
5
+ "body": [{
6
+ "type": "TextualBody",
7
+ "value": "A comment..."
8
+ }],
9
+ "target": {
10
+ "selector": {
11
+ "type": "FragmentSelector",
12
+ "conformsTo": "http://www.w3.org/TR/media-frags/",
13
+ "value": "xywh=pixel:2000,1200,400,370"
14
+ }
15
+ }
16
+ },{
17
+ "@context": "http://www.w3.org/ns/anno.jsonld",
18
+ "id": "#a99b22d0-6106-4872-9435-c78b5e89fede",
19
+ "type": "Annotation",
20
+ "body": [{
21
+ "type": "TextualBody",
22
+ "value": "Another comment..."
23
+ }],
24
+ "target": {
25
+ "selector": {
26
+ "type": "FragmentSelector",
27
+ "conformsTo": "http://www.w3.org/TR/media-frags/",
28
+ "value": "xywh=pixel:4000,2200,500,270"
29
+ }
30
+ }
31
+ }, {
32
+ "@context": "http://www.w3.org/ns/anno.jsonld",
33
+ "id": "#9df313be-4ded-4d0f-b7f6-f6b1a19e733b",
34
+ "type": "Annotation",
35
+ "body": [
36
+ {
37
+ "type": "TextualBody",
38
+ "value": "A comment...",
39
+ "purpose": "commenting",
40
+ "creator": {
41
+ "id": "http://www.example.com/rainer",
42
+ "name": "rainer"
43
+ },
44
+ "created": "2021-08-14T08:13:12.514Z",
45
+ "modified": "2021-08-14T08:13:12.557Z"
46
+ }
47
+ ],
48
+ "target": {
49
+ "selector": {
50
+ "type": "SvgSelector",
51
+ "value": "<svg><polygon points=\"447,213 560,140 563,259\"></polygon></svg>"
52
+ }
53
+ }
54
+ }]
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Annotorious Svelte</title>
7
+ <style>
8
+ html, body, #app {
9
+ height: 100vh;
10
+ margin: 0;
11
+ padding: 0;
12
+ width: 100vw;
13
+ }
14
+
15
+ .a9s-tooltip {
16
+ z-index: 9999;
17
+ }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <div id="app"></div>
22
+ <script type="module" src="./index.ts"></script>
23
+ </body>
24
+ </html>
package/test/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ import App from './App.svelte';
2
+
3
+ import '@annotorious/openseadragon/annotorious-openseadragon.css';
4
+
5
+ const app = new App({
6
+ target: document.getElementById('app')!
7
+ })
8
+
9
+ export default app
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "baseUrl": "src",
5
+ "checkJs": true,
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "ignoreDeprecations": "5.0",
11
+ "importsNotUsedAsValues": "error",
12
+ "incremental": false,
13
+ "isolatedModules": true,
14
+ "module": "ESNext",
15
+ "moduleResolution": "Node",
16
+ "outDir": "./dist",
17
+ "resolveJsonModule": true,
18
+ "skipLibCheck": false,
19
+ "sourceMap": true,
20
+ "target": "ESNext",
21
+ "types": ["svelte"]
22
+ },
23
+ "include": ["./src/**/*", "./test/**/*"],
24
+ "exclude": ["node_modules", "dist"]
25
+ }
package/vite.config.js ADDED
@@ -0,0 +1,37 @@
1
+ import { defineConfig } from 'vite';
2
+ import { svelte } from '@sveltejs/vite-plugin-svelte';
3
+ import sveltePreprocess from 'svelte-preprocess';
4
+ import dts from 'vite-plugin-dts';
5
+
6
+ import * as packageJson from './package.json';
7
+
8
+ export default defineConfig({
9
+ plugins: [
10
+ svelte({ preprocess: sveltePreprocess() }),
11
+ dts({
12
+ insertTypesEntry: true,
13
+ include: ['./src/'],
14
+ entryRoot: './src'
15
+ })
16
+ ],
17
+ server: {
18
+ open: '/test/index.html'
19
+ },
20
+ build: {
21
+ lib: {
22
+ entry: './src/index.ts',
23
+ formats: ['es'],
24
+ fileName: (format) => `annotorious-svelte.${format}.js`
25
+ },
26
+ rollupOptions: {
27
+ external: [...Object.keys(packageJson.peerDependencies)],
28
+ output: {
29
+ preserveModules: true,
30
+ globals: {
31
+ openseadragon: 'OpenSeadragon'
32
+ }
33
+ }
34
+ },
35
+ sourcemap: true
36
+ }
37
+ });