@annotorious/svelte 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.
Files changed (42) hide show
  1. package/dist/annotorious-svelte.es.js +14 -17
  2. package/dist/annotorious-svelte.es.js.map +1 -1
  3. package/dist/annotorious-svelte.es10.js +2 -26
  4. package/dist/annotorious-svelte.es10.js.map +1 -1
  5. package/dist/annotorious-svelte.es11.js +20640 -89
  6. package/dist/annotorious-svelte.es11.js.map +1 -1
  7. package/dist/annotorious-svelte.es12.js +122 -2
  8. package/dist/annotorious-svelte.es12.js.map +1 -1
  9. package/dist/annotorious-svelte.es13.js +2 -2
  10. package/dist/annotorious-svelte.es13.js.map +1 -1
  11. package/dist/annotorious-svelte.es14.js +16 -27435
  12. package/dist/annotorious-svelte.es14.js.map +1 -1
  13. package/dist/annotorious-svelte.es15.js +3 -119
  14. package/dist/annotorious-svelte.es15.js.map +1 -1
  15. package/dist/annotorious-svelte.es16.js +10 -1
  16. package/dist/annotorious-svelte.es16.js.map +1 -1
  17. package/dist/annotorious-svelte.es17.js +6 -55
  18. package/dist/annotorious-svelte.es17.js.map +1 -1
  19. package/dist/annotorious-svelte.es18.js +5 -0
  20. package/dist/annotorious-svelte.es18.js.map +1 -0
  21. package/dist/annotorious-svelte.es2.js +25 -30
  22. package/dist/annotorious-svelte.es2.js.map +1 -1
  23. package/dist/annotorious-svelte.es3.js +2 -95
  24. package/dist/annotorious-svelte.es3.js.map +1 -1
  25. package/dist/annotorious-svelte.es4.js +8 -4238
  26. package/dist/annotorious-svelte.es4.js.map +1 -1
  27. package/dist/annotorious-svelte.es5.js +1263 -86
  28. package/dist/annotorious-svelte.es5.js.map +1 -1
  29. package/dist/annotorious-svelte.es6.js +87 -104
  30. package/dist/annotorious-svelte.es6.js.map +1 -1
  31. package/dist/annotorious-svelte.es7.js +118 -92
  32. package/dist/annotorious-svelte.es7.js.map +1 -1
  33. package/dist/annotorious-svelte.es8.js +303 -31
  34. package/dist/annotorious-svelte.es8.js.map +1 -1
  35. package/dist/annotorious-svelte.es9.js +8 -31
  36. package/dist/annotorious-svelte.es9.js.map +1 -1
  37. package/dist/index.d.ts +8 -11
  38. package/dist/index.d.ts.map +1 -1
  39. package/package.json +11 -22
  40. package/src/index.ts +21 -40
  41. package/vite.config.js +0 -1
  42. /package/dist/{annotorious-svelte.css → style.css} +0 -0
@@ -1,20 +1,17 @@
1
- import { default as c } from "./annotorious-svelte.es2.js";
2
- import { Origin as i, PointerSelectAction as d, createAnonymousGuest as u, createBody as g, defaultColorProvider as l } from "./annotorious-svelte.es3.js";
3
- import { createImageAnnotator as e, ShapeType as o, W3CImageFormat as t } from "./annotorious-svelte.es4.js";
4
- import { default as A } from "./annotorious-svelte.es5.js";
5
- import { default as y } from "./annotorious-svelte.es6.js";
6
- const r = e, n = o, p = t;
1
+ import { default as l } from "./annotorious-svelte.es2.js";
2
+ import { PointerSelectAction as o } from "./annotorious-svelte.es3.js";
3
+ import { createBody as e } from "./annotorious-svelte.es4.js";
4
+ import { ShapeType as t, W3CImageFormat as r } from "./annotorious-svelte.es5.js";
5
+ import { default as u } from "./annotorious-svelte.es6.js";
6
+ import { default as g } from "./annotorious-svelte.es7.js";
7
+ const c = o, m = e, s = t, i = r;
7
8
  export {
8
- c as MouseOverTooltip,
9
- A as OpenSeadragonAnnotator,
10
- y as OpenSeadragonPopup,
11
- i as Origin,
12
- d as PointerSelectAction,
13
- n as ShapeType,
14
- p as W3CImageFormat,
15
- u as createAnonymousGuest,
16
- g as createBody,
17
- r as createImageAnnotator,
18
- l as defaultColorProvider
9
+ l as MouseOverTooltip,
10
+ u as OpenSeadragonAnnotator,
11
+ g as OpenSeadragonPopup,
12
+ c as PointerSelectAction,
13
+ s as ShapeType,
14
+ i as W3CImageFormat,
15
+ m as createBody
19
16
  };
20
17
  //# sourceMappingURL=annotorious-svelte.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es.js","sources":["../src/index.ts"],"sourcesContent":["export * from './osd';\n\nexport { default as MouseOverTooltip } from './MouseOverTooltip.svelte';\n\n// Essential re-exports from @annotorious/core\nexport type {\n Annotation,\n AnnotationBody,\n AnnotationTarget,\n Annotator,\n AnnotatorState,\n Appearance,\n AppearanceProvider,\n Color,\n DrawingStyle,\n Filter,\n FormatAdapter,\n HoverState,\n LifecycleEvents,\n ParseResult,\n PresentUser,\n Purpose,\n Selection,\n SelectionState,\n Store,\n StoreChangeEvent,\n StoreObserver,\n SvelteAnnotator,\n SvelteAnnotatorState,\n User,\n W3CAnnotation,\n W3CAnnotationBody,\n W3CAnnotationTarget\n} from '@annotorious/core';\n\nimport {\n createAnonymousGuest as _createAnonymousGuest, \n createBody as _createBody,\n defaultColorProvider as _defaultColorProvider,\n Origin as _Origin,\n PointerSelectAction as _PointerSelectAction\n} from '@annotorious/core';\n\nexport { _createAnonymousGuest as createAnonymousGuest };\nexport { _createBody as createBody };\nexport { _defaultColorProvider as defaultColorProvider };\nexport { _Origin as Origin };\nexport { _PointerSelectAction as PointerSelectAction };\n\n// Essential re-exports from @annotorious/annotorious \nexport type {\n AnnotoriousOpts,\n DrawingMode,\n DrawingTool,\n ImageAnnotator as AnnotoriousImageAnnotator,\n ImageAnnotation,\n ImageAnnotator,\n ImageAnnotatorState,\n Polygon,\n PolygonGeometry,\n Rectangle,\n RectangleGeometry,\n Shape\n} from '@annotorious/annotorious';\n\nimport { \n createImageAnnotator as _createImageAnnotator,\n ShapeType as _ShapeType,\n W3CImageFormat as _W3CImageFormat\n} from '@annotorious/annotorious';\n\nexport const createImageAnnotator = _createImageAnnotator;\nexport const ShapeType = _ShapeType;\nexport const W3CImageFormat = _W3CImageFormat;\n\n// Essential re-exports from @annotorious/openseadragon \nexport type {\n OpenSeadragonAnnotator as AnnotoriousOpenSeadragonAnnotator\n} from '@annotorious/openseadragon';\n\nexport type { Viewer } from 'openseadragon';\n"],"names":["createImageAnnotator","_createImageAnnotator","ShapeType","_ShapeType","W3CImageFormat","_W3CImageFormat"],"mappings":";;;;;AAuEO,MAAMA,IAAuBC,GACvBC,IAAYC,GACZC,IAAiBC;"}
1
+ {"version":3,"file":"annotorious-svelte.es.js","sources":["../src/index.ts"],"sourcesContent":["export * from './osd';\n\nexport { default as MouseOverTooltip } from './MouseOverTooltip.svelte';\n\n// Essential re-exports from @annotorious/core\nexport type {\n Annotation,\n AnnotationBody,\n AnnotationTarget,\n Annotator,\n AnnotatorState,\n Color,\n DrawingStyle,\n FormatAdapter,\n ParseResult,\n User,\n W3CAnnotation,\n W3CAnnotationBody,\n W3CAnnotationTarget,\n W3CSelector\n} from '@annotorious/core/src/model';\n\nexport type { \n HoverState,\n Selection,\n SelectionState,\n Store,\n StoreChangeEvent,\n StoreObserver,\n SvelteAnnotator,\n SvelteAnnotatorState\n} from '@annotorious/core/src/state';\n\nimport {\n PointerSelectAction as _PointerSelectAction\n} from '@annotorious/core/src/state';\n\nexport const PointerSelectAction = _PointerSelectAction;\n\nimport {\n createBody as _createBody\n} from '@annotorious/core/src/utils';\n\nexport const createBody = _createBody;\n\n// Essential re-exports from @annotorious/annotorious \nexport type {\n ImageAnnotator,\n ImageAnnotation,\n ImageAnnotatorState,\n Polygon,\n Rectangle,\n Shape\n} from '@annotorious/annotorious';\n\nimport { \n ShapeType as _ShapeType,\n W3CImageFormat as _W3CImageFormat\n} from '@annotorious/annotorious';\n\nexport const ShapeType = _ShapeType;\nexport const W3CImageFormat = _W3CImageFormat;"],"names":["PointerSelectAction","_PointerSelectAction","createBody","_createBody","ShapeType","_ShapeType","W3CImageFormat","_W3CImageFormat"],"mappings":";;;;;;AAqCO,MAAMA,IAAsBC,GAMtBC,IAAaC,GAiBbC,IAAYC,GACZC,IAAiBC;"}
@@ -1,27 +1,3 @@
1
- let t;
2
- function r(n) {
3
- t = n;
4
- }
5
- function o() {
6
- if (!t)
7
- throw new Error("Function called outside component initialization");
8
- return t;
9
- }
10
- function u(n) {
11
- o().$$.on_mount.push(n);
12
- }
13
- function c(n, e) {
14
- return o().$$.context.set(n, e), e;
15
- }
16
- function i(n) {
17
- return o().$$.context.get(n);
18
- }
19
- export {
20
- t as current_component,
21
- i as getContext,
22
- o as get_current_component,
23
- u as onMount,
24
- c as setContext,
25
- r as set_current_component
26
- };
1
+ import { nanoid as o } from "./annotorious-svelte.es18.js";
2
+ o();
27
3
  //# sourceMappingURL=annotorious-svelte.es10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es10.js","sources":["../../../node_modules/svelte/src/runtime/internal/lifecycle.js"],"sourcesContent":["import { custom_event } from './dom.js';\n\nexport let current_component;\n\n/** @returns {void} */\nexport function set_current_component(component) {\n\tcurrent_component = component;\n}\n\nexport function get_current_component() {\n\tif (!current_component) throw new Error('Function called outside component initialization');\n\treturn current_component;\n}\n\n/**\n * Schedules a callback to run immediately before the component is updated after any state change.\n *\n * The first time the callback runs will be before the initial `onMount`\n *\n * https://svelte.dev/docs/svelte#beforeupdate\n * @param {() => any} fn\n * @returns {void}\n */\nexport function beforeUpdate(fn) {\n\tget_current_component().$$.before_update.push(fn);\n}\n\n/**\n * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.\n * It must be called during the component's initialisation (but doesn't need to live *inside* the component;\n * it can be called from an external module).\n *\n * If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted.\n *\n * `onMount` does not run inside a [server-side component](https://svelte.dev/docs#run-time-server-side-component-api).\n *\n * https://svelte.dev/docs/svelte#onmount\n * @template T\n * @param {() => import('./private.js').NotFunction<T> | Promise<import('./private.js').NotFunction<T>> | (() => any)} fn\n * @returns {void}\n */\nexport function onMount(fn) {\n\tget_current_component().$$.on_mount.push(fn);\n}\n\n/**\n * Schedules a callback to run immediately after the component has been updated.\n *\n * The first time the callback runs will be after the initial `onMount`\n *\n * https://svelte.dev/docs/svelte#afterupdate\n * @param {() => any} fn\n * @returns {void}\n */\nexport function afterUpdate(fn) {\n\tget_current_component().$$.after_update.push(fn);\n}\n\n/**\n * Schedules a callback to run immediately before the component is unmounted.\n *\n * Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the\n * only one that runs inside a server-side component.\n *\n * https://svelte.dev/docs/svelte#ondestroy\n * @param {() => any} fn\n * @returns {void}\n */\nexport function onDestroy(fn) {\n\tget_current_component().$$.on_destroy.push(fn);\n}\n\n/**\n * Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname).\n * Event dispatchers are functions that can take two arguments: `name` and `detail`.\n *\n * Component events created with `createEventDispatcher` create a\n * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).\n * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).\n * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)\n * property and can contain any type of data.\n *\n * The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument:\n * ```ts\n * const dispatch = createEventDispatcher<{\n * loaded: never; // does not take a detail argument\n * change: string; // takes a detail argument of type string, which is required\n * optional: number | null; // takes an optional detail argument of type number\n * }>();\n * ```\n *\n * https://svelte.dev/docs/svelte#createeventdispatcher\n * @template {Record<string, any>} [EventMap=any]\n * @returns {import('./public.js').EventDispatcher<EventMap>}\n */\nexport function createEventDispatcher() {\n\tconst component = get_current_component();\n\treturn (type, detail, { cancelable = false } = {}) => {\n\t\tconst callbacks = component.$$.callbacks[type];\n\t\tif (callbacks) {\n\t\t\t// TODO are there situations where events could be dispatched\n\t\t\t// in a server (non-DOM) environment?\n\t\t\tconst event = custom_event(/** @type {string} */ (type), detail, { cancelable });\n\t\t\tcallbacks.slice().forEach((fn) => {\n\t\t\t\tfn.call(component, event);\n\t\t\t});\n\t\t\treturn !event.defaultPrevented;\n\t\t}\n\t\treturn true;\n\t};\n}\n\n/**\n * Associates an arbitrary `context` object with the current component and the specified `key`\n * and returns that object. The context is then available to children of the component\n * (including slotted content) with `getContext`.\n *\n * Like lifecycle functions, this must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#setcontext\n * @template T\n * @param {any} key\n * @param {T} context\n * @returns {T}\n */\nexport function setContext(key, context) {\n\tget_current_component().$$.context.set(key, context);\n\treturn context;\n}\n\n/**\n * Retrieves the context that belongs to the closest parent component with the specified `key`.\n * Must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#getcontext\n * @template T\n * @param {any} key\n * @returns {T}\n */\nexport function getContext(key) {\n\treturn get_current_component().$$.context.get(key);\n}\n\n/**\n * Retrieves the whole context map that belongs to the closest parent component.\n * Must be called during component initialisation. Useful, for example, if you\n * programmatically create a component and want to pass the existing context to it.\n *\n * https://svelte.dev/docs/svelte#getallcontexts\n * @template {Map<any, any>} [T=Map<any, any>]\n * @returns {T}\n */\nexport function getAllContexts() {\n\treturn get_current_component().$$.context;\n}\n\n/**\n * Checks whether a given `key` has been set in the context of a parent component.\n * Must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#hascontext\n * @param {any} key\n * @returns {boolean}\n */\nexport function hasContext(key) {\n\treturn get_current_component().$$.context.has(key);\n}\n\n// TODO figure out if we still want to support\n// shorthand events, or if we want to implement\n// a real bubbling mechanism\n/**\n * @param component\n * @param event\n * @returns {void}\n */\nexport function bubble(component, event) {\n\tconst callbacks = component.$$.callbacks[event.type];\n\tif (callbacks) {\n\t\t// @ts-ignore\n\t\tcallbacks.slice().forEach((fn) => fn.call(this, event));\n\t}\n}\n"],"names":["current_component","set_current_component","component","get_current_component","onMount","fn","setContext","key","context","getContext"],"mappings":"AAEU,IAACA;AAGJ,SAASC,EAAsBC,GAAW;AAChD,EAAAF,IAAoBE;AACrB;AAEO,SAASC,IAAwB;AACvC,MAAI,CAACH;AAAmB,UAAM,IAAI,MAAM,kDAAkD;AAC1F,SAAOA;AACR;AA6BO,SAASI,EAAQC,GAAI;AAC3B,EAAAF,EAAuB,EAAC,GAAG,SAAS,KAAKE,CAAE;AAC5C;AAkFO,SAASC,EAAWC,GAAKC,GAAS;AACxC,SAAAL,EAAqB,EAAG,GAAG,QAAQ,IAAII,GAAKC,CAAO,GAC5CA;AACR;AAWO,SAASC,EAAWF,GAAK;AAC/B,SAAOJ,EAAuB,EAAC,GAAG,QAAQ,IAAII,CAAG;AAClD;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"annotorious-svelte.es10.js","sources":["../../annotorious-core/src/presence/PresenceState.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport { createNanoEvents, type Unsubscribe } from 'nanoevents';\nimport type { User } from '../model';\nimport type { PresentUser } from './PresentUser';\nimport type { PresenceEvents } from './PresenceEvents';\nimport { createDefaultAppearenceProvider } from './AppearanceProvider';\nimport type { AppearanceProvider } from './AppearanceProvider';\n\nexport interface PresenceState {\n\n // Get users currently present to this room\n getPresentUsers(): PresentUser[];\n\n // Notify of a given present user's activity on the given annotations\n notifyActivity(presenceKey: string, annotationIds: string[]): void;\n\n // Add a listener for the given presence event\n on<E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]): Unsubscribe;\n\n // Initial sync - which users are present under which keys\n syncUsers(state: { presenceKey: string, user: User }[]): void;\n\n // Update the selection state for the given prresent user\n updateSelection(presenceKey: string, selection: string[] | null): void;\n\n}\n\nconst isListEqual = (listA: any[], listB: any[]) => \n listA.every(a => listA.includes(a)) && listB.every(b => listA.includes(b));\n\n// This client's presence key\nexport const PRESENCE_KEY = nanoid();\n\nexport const createPresenceState = (\n appearanceProvider: AppearanceProvider = createDefaultAppearenceProvider()\n): PresenceState => {\n\n const emitter = createNanoEvents<PresenceEvents>();\n\n const presentUsers = new Map<string, PresentUser>();\n\n const selectionStates = new Map<string, string[]>();\n\n const addUser = (presenceKey: string, user: User) => {\n if (presentUsers.has(presenceKey)) {\n console.warn('Attempt to add user that is already present', presenceKey, user);\n return; \n }\n\n const appearance = appearanceProvider.addUser(presenceKey, user);\n\n presentUsers.set(presenceKey, { \n ...user,\n presenceKey,\n appearance\n });\n }\n\n const removeUser = (presenceKey: string) => {\n const user = presentUsers.get(presenceKey);\n if (!user) {\n console.warn('Attempt to remove user that is not present', presenceKey);\n return;\n }\n\n appearanceProvider.removeUser(user);\n\n presentUsers.delete(presenceKey);\n }\n\n const syncUsers = (state: { presenceKey: string, user: User }[]) => {\n // const keys = new Set(others.map(s => s.presenceKey));\n const keys = new Set(state.map(s => s.presenceKey));\n\n // These users need to be added to the presentUsers list\n // const toAdd = others.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n const toAdd = state.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n\n // These users need to be dropped from the list\n const toRemove = Array.from(presentUsers.values()).filter(presentUser =>\n !keys.has(presentUser.presenceKey));\n\n toAdd.forEach(({ presenceKey, user }) => addUser(presenceKey, user));\n\n toRemove.forEach(user => {\n const { presenceKey } = user;\n\n // If this user has a selection, fire deselect event\n if (selectionStates.has(presenceKey))\n emitter.emit('selectionChange', user, null);\n\n removeUser(presenceKey)\n });\n\n if (toAdd.length > 0 || toRemove.length > 0)\n emitter.emit('presence', getPresentUsers());\n }\n\n const notifyActivity = (presenceKey: string, annotationIds: string[]) => { \n const user = presentUsers.get(presenceKey);\n \n if (!user) {\n console.warn('Activity notification from user that is not present');\n return;\n }\n\n const currentSelection = selectionStates.get(presenceKey);\n\n // Was there a selection change we might have missed?\n if (!currentSelection || !isListEqual(currentSelection, annotationIds)) {\n selectionStates.set(presenceKey, annotationIds);\n emitter.emit('selectionChange', user, annotationIds);\n }\n }\n\n const updateSelection = (presenceKey: string, selection: string[] | null) => {\n const from = presentUsers.get(presenceKey);\n if (!from) {\n console.warn('Selection change for user that is not present', presenceKey);\n return;\n }\n\n if (selection)\n selectionStates.set(presenceKey, selection);\n else \n selectionStates.delete(presenceKey);\n\n emitter.emit('selectionChange', from, selection);\n }\n\n const getPresentUsers = () =>\n [...Array.from(presentUsers.values())];\n \n const on = <E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]) =>\n emitter.on(event, callback);\n\n return {\n getPresentUsers,\n notifyActivity,\n on,\n syncUsers,\n updateSelection\n }\n\n}"],"names":["nanoid"],"mappings":";AA+B4BA,EAAO;"}