@annotorious/annotorious 3.7.12 → 3.7.13
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.es.js +1561 -1542
- package/dist/annotorious.es.js.map +1 -1
- package/dist/annotorious.js +1 -1
- package/dist/annotorious.js.map +1 -1
- package/dist/state/ImageAnnotationStore.d.ts +2 -1
- package/dist/state/SvelteStore.d.ts +20 -0
- package/dist/state/index.d.ts +1 -0
- package/package.json +4 -4
- package/src/state/ImageAnnotationStore.ts +2 -1
- package/src/state/ImageAnnotatorState.ts +1 -1
- package/src/state/SvelteStore.ts +52 -0
- package/src/state/index.ts +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Annotation, Filter, Store
|
|
1
|
+
import { Annotation, Filter, Store } from '@annotorious/core';
|
|
2
|
+
import { SvelteAnnotatorState, SvelteStore } from './SvelteStore';
|
|
2
3
|
export type ImageAnnotationStore<I extends Annotation> = Store<I> & {
|
|
3
4
|
getAt(x: number, y: number, filter?: Filter<I>, buffer?: number): I | undefined;
|
|
4
5
|
getIntersecting(x: number, y: number, width: number, height: number): I[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Annotation, Annotator, AnnotatorState, Store } from '@annotorious/core';
|
|
2
|
+
type Subscriber<T extends Annotation> = (annotation: T[]) => void;
|
|
3
|
+
export interface SvelteStore<T extends Annotation> extends Store<T> {
|
|
4
|
+
subscribe(onChange: Subscriber<T>): void;
|
|
5
|
+
}
|
|
6
|
+
export interface SvelteAnnotatorState<I extends Annotation, E extends unknown> extends AnnotatorState<I, E> {
|
|
7
|
+
store: SvelteStore<I>;
|
|
8
|
+
}
|
|
9
|
+
export interface SvelteAnnotator<I extends Annotation, E extends unknown> extends Annotator<I, E> {
|
|
10
|
+
state: SvelteAnnotatorState<I, E>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A simple wrapper around the event-based store implementation
|
|
14
|
+
* that adds a Svelte shim, for use with the reactive '$' notation.
|
|
15
|
+
* Other frameworks might not actually need this. But it's pretty
|
|
16
|
+
* convenient for everyone using Svelte, as well as for the
|
|
17
|
+
* basic (Svelte-based) Annotorious standard implementation.
|
|
18
|
+
*/
|
|
19
|
+
export declare const toSvelteStore: <T extends Annotation = Annotation>(store: Store<T>) => SvelteStore<T>;
|
|
20
|
+
export {};
|
package/dist/state/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/annotorious",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.13",
|
|
4
4
|
"description": "Add image annotation functionality to any web page with a few lines of JavaScript",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
41
41
|
"@tsconfig/svelte": "^5.0.5",
|
|
42
42
|
"@types/rbush": "^4.0.0",
|
|
43
|
-
"jsdom": "^27.
|
|
43
|
+
"jsdom": "^27.1.0",
|
|
44
44
|
"svelte": "^4.2.20",
|
|
45
45
|
"svelte-preprocess": "^6.0.3",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
|
-
"vite": "^5.4.
|
|
47
|
+
"vite": "^5.4.21",
|
|
48
48
|
"vite-plugin-dts": "^4.5.4",
|
|
49
49
|
"vitest": "^3.2.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@annotorious/core": "3.7.
|
|
52
|
+
"@annotorious/core": "3.7.13",
|
|
53
53
|
"dequal": "^2.0.3",
|
|
54
54
|
"rbush": "^4.0.1",
|
|
55
55
|
"simplify-js": "^1.2.4",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Annotation, Filter, Store
|
|
1
|
+
import type { Annotation, Filter, Store } from '@annotorious/core';
|
|
2
|
+
import type { SvelteAnnotatorState, SvelteStore } from './SvelteStore';
|
|
2
3
|
|
|
3
4
|
export type ImageAnnotationStore<I extends Annotation> = Store<I> & {
|
|
4
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ImageAnnotation, ImageAnnotationTarget } from '../model';
|
|
2
2
|
import type { AnnotoriousOpts } from '../AnnotoriousOpts';
|
|
3
3
|
import { createSpatialTree } from './spatialTree';
|
|
4
|
+
import { toSvelteStore } from './SvelteStore';
|
|
4
5
|
import {
|
|
5
6
|
createViewportState,
|
|
6
|
-
toSvelteStore,
|
|
7
7
|
type Annotation,
|
|
8
8
|
type AnnotatorState,
|
|
9
9
|
type Filter,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Annotation, Annotator, AnnotatorState, Store, StoreChangeEvent } from '@annotorious/core';
|
|
2
|
+
|
|
3
|
+
type Subscriber<T extends Annotation> = (annotation: T[]) => void;
|
|
4
|
+
|
|
5
|
+
export interface SvelteStore<T extends Annotation> extends Store<T> {
|
|
6
|
+
|
|
7
|
+
subscribe(onChange: Subscriber<T>): void;
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SvelteAnnotatorState<I extends Annotation, E extends unknown> extends AnnotatorState<I, E> {
|
|
12
|
+
|
|
13
|
+
store: SvelteStore<I>
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SvelteAnnotator<I extends Annotation, E extends unknown> extends Annotator<I, E> {
|
|
18
|
+
|
|
19
|
+
state: SvelteAnnotatorState<I, E>
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A simple wrapper around the event-based store implementation
|
|
25
|
+
* that adds a Svelte shim, for use with the reactive '$' notation.
|
|
26
|
+
* Other frameworks might not actually need this. But it's pretty
|
|
27
|
+
* convenient for everyone using Svelte, as well as for the
|
|
28
|
+
* basic (Svelte-based) Annotorious standard implementation.
|
|
29
|
+
*/
|
|
30
|
+
export const toSvelteStore = <T extends Annotation = Annotation>(store: Store<T>): SvelteStore<T> => {
|
|
31
|
+
|
|
32
|
+
const subscribe = (onChange: Subscriber<T>) => {
|
|
33
|
+
|
|
34
|
+
// Register a store observer on behalf of the subscriber
|
|
35
|
+
const shim = (event: StoreChangeEvent<T>) => onChange(event.state);
|
|
36
|
+
store.observe(shim);
|
|
37
|
+
|
|
38
|
+
// Immediately call the subscriber function with the
|
|
39
|
+
// current store value, according to the Svelte contract.
|
|
40
|
+
// https://stackoverflow.com/questions/68220955/how-does-svelte-unsubscribe-actually-work
|
|
41
|
+
onChange(store.all());
|
|
42
|
+
|
|
43
|
+
// Return the unsubscribe function
|
|
44
|
+
return () => store.unobserve(shim);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
...store,
|
|
49
|
+
subscribe
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
package/src/state/index.ts
CHANGED