@annotorious/react 3.7.19 → 3.7.21

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.
@@ -6,8 +6,8 @@ import { ImageAnnotator as I } from "./annotorious-react.es5.js";
6
6
  /* empty css */
7
7
  import { Origin as y, UserSelectAction as P, createAnonymousGuest as V, createBody as F, defaultColorProvider as v } from "@annotorious/core";
8
8
  import { ShapeType as z, W3CImageFormat as G, boundsFromPoints as W, chainStyles as h, computeStyle as H, createImageAnnotator as T, parseFragmentSelector as U, parseSVGSelector as b, parseW3CImageAnnotation as B, serializeFragmentSelector as j, serializeSVGSelector as k, serializeW3CImageAnnotation as q } from "@annotorious/annotorious";
9
- import { OpenSeadragonAnnotator as E, OpenSeadragonAnnotatorContext as J, useViewer as K } from "./annotorious-react.es8.js";
10
- import { OpenSeadragonAnnotationPopup as M } from "./annotorious-react.es9.js";
9
+ import { OpenSeadragonAnnotationPopup as E } from "./annotorious-react.es8.js";
10
+ import { OpenSeadragonAnnotator as K, OpenSeadragonAnnotatorContext as L, useViewer as M } from "./annotorious-react.es9.js";
11
11
  import { OpenSeadragonHoverTooltip as Q } from "./annotorious-react.es10.js";
12
12
  import { OpenSeadragonViewer as X } from "./annotorious-react.es11.js";
13
13
  export {
@@ -16,9 +16,9 @@ export {
16
16
  x as AnnotoriousPlugin,
17
17
  d as ImageAnnotationPopup,
18
18
  I as ImageAnnotator,
19
- M as OpenSeadragonAnnotationPopup,
20
- E as OpenSeadragonAnnotator,
21
- J as OpenSeadragonAnnotatorContext,
19
+ E as OpenSeadragonAnnotationPopup,
20
+ K as OpenSeadragonAnnotator,
21
+ L as OpenSeadragonAnnotatorContext,
22
22
  Q as OpenSeadragonHoverTooltip,
23
23
  X as OpenSeadragonViewer,
24
24
  y as Origin,
@@ -46,7 +46,7 @@ export {
46
46
  A as useAnnotatorUser,
47
47
  S as useHover,
48
48
  l as useSelection,
49
- K as useViewer,
49
+ M as useViewer,
50
50
  g as useViewportState
51
51
  };
52
52
  //# sourceMappingURL=annotorious-react.es.js.map
@@ -2,7 +2,7 @@ import { jsx as h } from "react/jsx-runtime";
2
2
  import { useMemo as S, useState as m, useEffect as g } from "react";
3
3
  import { createPortal as y } from "react-dom";
4
4
  import { useAnnotator as A, useSelection as F } from "./annotorious-react.es2.js";
5
- import { useViewer as H } from "./annotorious-react.es8.js";
5
+ import { useViewer as H } from "./annotorious-react.es9.js";
6
6
  const l = 10, w = (n) => {
7
7
  const a = n.offsetX || l, v = n.offsetY || l, o = A(), r = F(), p = S(() => r.selected.length > 0, [r]), t = H(), [s, u] = m(), [i, c] = m();
8
8
  return g(() => {
@@ -2,7 +2,7 @@ import { jsx as y } from "react/jsx-runtime";
2
2
  import { forwardRef as C, useRef as p, useContext as O, useLayoutEffect as w, useImperativeHandle as R } from "react";
3
3
  import g from "openseadragon";
4
4
  import { dequal as m } from "./annotorious-react.es12.js";
5
- import { OpenSeadragonAnnotatorContext as h } from "./annotorious-react.es8.js";
5
+ import { OpenSeadragonAnnotatorContext as h } from "./annotorious-react.es9.js";
6
6
  const x = (c, f) => {
7
7
  if (!c) return !1;
8
8
  const { tileSources: a, ...e } = c, { tileSources: o, ...n } = f, s = !m(a, o), l = !m(e, n);
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es11.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useImperativeHandle, useLayoutEffect, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { dequal } from 'dequal/lite';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\n/**\n * If the only thing that changes about the options are the tileSources, \n * there's no need to destroy and re-create the viewer, which can introduce\n * dangerous race conditions and break interop with plugins. (Changing \n * tileSources is probably the main use case by far.)\n */\nconst onlyTileSourcesChanged = (prev: OpenSeadragon.Options | undefined, next: OpenSeadragon.Options): boolean => {\n if (!prev) return false;\n\n const { tileSources: prevTiles, ...prevRest } = prev;\n const { tileSources: nextTiles, ...nextRest } = next;\n\n const tileSourcesChanged = !dequal(prevTiles, nextTiles);\n const otherOptionsChanged = !dequal(prevRest, nextRest);\n\n return tileSourcesChanged && !otherOptionsChanged;\n };\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n const viewerRef = useRef<OpenSeadragon.Viewer | undefined>(null);\n const prevOptionsRef = useRef<OpenSeadragon.Options>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n // Init and destroy the OSD viewer on mount/unmount\n useLayoutEffect(() => { \n if (element.current && !viewerRef.current) {\n const v = OpenSeadragon({...options, element: element.current });\n viewerRef.current = v;\n prevOptionsRef.current = options;\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n if (setViewer)\n setViewer(undefined);\n\n v.destroy();\n viewerRef.current = undefined;\n }\n }\n }, []);\n\n useLayoutEffect(() => { \n const v = viewerRef.current;\n const prev = prevOptionsRef.current;\n if (!v || !prev) return; \n\n if (onlyTileSourcesChanged(prev, options)) { \n const tileSources = \n Array.isArray(options.tileSources) ? options.tileSources : [options.tileSources];\n \n v.world.removeAll();\n\n tileSources.forEach((tileSource, index) => {\n const tileConfig = (typeof tileSource === 'object') && 'tileSource' in tileSource\n // Special case: handling nested notation\n // https://github.com/openseadragon/openseadragon/issues/2659#issuecomment-2583944426\n ? tileSource : { tileSource }\n \n v.addTiledImage({\n ...tileConfig,\n index,\n success: () => {\n if (index === 0) {\n v.viewport.goHome();\n }\n }\n } as OpenSeadragon.TiledImageOptions);\n });\n\n prevOptionsRef.current = options;\n } else if (!dequal(prev, options)) {\n console.warn('Forced re-creation of OpenSeadragon viewer. Beware of race conditions!');\n \n if (setViewer)\n setViewer(undefined);\n \n v.destroy();\n\n if (element.current) {\n const newViewer = OpenSeadragon({...options, element: element.current });\n viewerRef.current = newViewer;\n prevOptionsRef.current = options;\n\n if (setViewer)\n setViewer(newViewer);\n }\n }\n }, [options]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["onlyTileSourcesChanged","prev","next","prevTiles","prevRest","nextTiles","nextRest","tileSourcesChanged","dequal","otherOptionsChanged","OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewerRef","prevOptionsRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useLayoutEffect","v","OpenSeadragon","tileSources","tileSource","index","tileConfig","newViewer","useImperativeHandle","jsx"],"mappings":";;;;;AAmBA,MAAMA,IAAyB,CAACC,GAAyCC,MAAyC;AAC9G,MAAI,CAACD,EAAM,QAAO;AAElB,QAAM,EAAE,aAAaE,GAAW,GAAGC,MAAaH,GAC1C,EAAE,aAAaI,GAAW,GAAGC,MAAaJ,GAE1CK,IAAqB,CAACC,EAAOL,GAAWE,CAAS,GACjDI,IAAsB,CAACD,EAAOJ,GAAUE,CAAQ;AAEtD,SAAOC,KAAsB,CAACE;AAChC,GAEWC,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEtI,QAAM,EAAE,WAAAC,GAAW,SAAAC,EAAA,IAAYH,GAEzBI,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAyC,IAAI,GACzDE,IAAiBF,EAA8B,IAAI,GAEnD,EAAE,QAAAG,GAAQ,WAAAC,MAAcC,EAAWC,CAA6B;AAGtE,SAAAC,EAAgB,MAAM;AACpB,QAAIR,EAAQ,WAAW,CAACE,EAAU,SAAS;AACzC,YAAMO,IAAIC,EAAc,EAAC,GAAGX,GAAS,SAASC,EAAQ,SAAS;AAC/D,aAAAE,EAAU,UAAUO,GACpBN,EAAe,UAAUJ,GAIrBM,KACFA,EAAUI,CAAC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.tsx"],"sourcesContent":["import { forwardRef, useContext, useImperativeHandle, useLayoutEffect, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { dequal } from 'dequal/lite';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\n/**\n * If the only thing that changes about the options are the tileSources, \n * there's no need to destroy and re-create the viewer, which can introduce\n * dangerous race conditions and break interop with plugins. (Changing \n * tileSources is probably the main use case by far.)\n */\nconst onlyTileSourcesChanged = (prev: OpenSeadragon.Options | undefined, next: OpenSeadragon.Options): boolean => {\n if (!prev) return false;\n\n const { tileSources: prevTiles, ...prevRest } = prev;\n const { tileSources: nextTiles, ...nextRest } = next;\n\n const tileSourcesChanged = !dequal(prevTiles, nextTiles);\n const otherOptionsChanged = !dequal(prevRest, nextRest);\n\n return tileSourcesChanged && !otherOptionsChanged;\n };\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n const viewerRef = useRef<OpenSeadragon.Viewer | undefined>(null);\n const prevOptionsRef = useRef<OpenSeadragon.Options>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n // Init and destroy the OSD viewer on mount/unmount\n useLayoutEffect(() => { \n if (element.current && !viewerRef.current) {\n const v = OpenSeadragon({...options, element: element.current });\n viewerRef.current = v;\n prevOptionsRef.current = options;\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n if (setViewer)\n setViewer(undefined);\n\n v.destroy();\n viewerRef.current = undefined;\n }\n }\n }, []);\n\n useLayoutEffect(() => { \n const v = viewerRef.current;\n const prev = prevOptionsRef.current;\n if (!v || !prev) return; \n\n if (onlyTileSourcesChanged(prev, options)) { \n const tileSources = \n Array.isArray(options.tileSources) ? options.tileSources : [options.tileSources];\n \n v.world.removeAll();\n\n tileSources.forEach((tileSource, index) => {\n const tileConfig = (typeof tileSource === 'object') && 'tileSource' in tileSource\n // Special case: handling nested notation\n // https://github.com/openseadragon/openseadragon/issues/2659#issuecomment-2583944426\n ? tileSource : { tileSource }\n \n v.addTiledImage({\n ...tileConfig,\n index,\n success: () => {\n if (index === 0) {\n v.viewport.goHome();\n }\n }\n } as OpenSeadragon.TileSourceSpecifier);\n });\n\n prevOptionsRef.current = options;\n } else if (!dequal(prev, options)) {\n console.warn('Forced re-creation of OpenSeadragon viewer. Beware of race conditions!');\n \n if (setViewer)\n setViewer(undefined);\n \n v.destroy();\n\n if (element.current) {\n const newViewer = OpenSeadragon({...options, element: element.current });\n viewerRef.current = newViewer;\n prevOptionsRef.current = options;\n\n if (setViewer)\n setViewer(newViewer);\n }\n }\n }, [options]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["onlyTileSourcesChanged","prev","next","prevTiles","prevRest","nextTiles","nextRest","tileSourcesChanged","dequal","otherOptionsChanged","OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewerRef","prevOptionsRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useLayoutEffect","v","OpenSeadragon","tileSources","tileSource","index","tileConfig","newViewer","useImperativeHandle","jsx"],"mappings":";;;;;AAmBA,MAAMA,IAAyB,CAACC,GAAyCC,MAAyC;AAC9G,MAAI,CAACD,EAAM,QAAO;AAElB,QAAM,EAAE,aAAaE,GAAW,GAAGC,MAAaH,GAC1C,EAAE,aAAaI,GAAW,GAAGC,MAAaJ,GAE1CK,IAAqB,CAACC,EAAOL,GAAWE,CAAS,GACjDI,IAAsB,CAACD,EAAOJ,GAAUE,CAAQ;AAEtD,SAAOC,KAAsB,CAACE;AAChC,GAEWC,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEtI,QAAM,EAAE,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