@annotorious/react 3.7.20 → 3.7.22
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-react.es11.js.map +1 -1
- package/dist/annotorious-react.es14.js.map +1 -1
- package/dist/annotorious-react.es16.js +188 -187
- package/dist/annotorious-react.es16.js.map +1 -1
- package/dist/annotorious-react.es17.js +113 -93
- package/dist/annotorious-react.es17.js.map +1 -1
- package/dist/annotorious-react.es20.js +97 -97
- package/dist/annotorious-react.es20.js.map +1 -1
- package/dist/annotorious-react.es24.js +66 -68
- package/dist/annotorious-react.es24.js.map +1 -1
- package/dist/annotorious-react.es25.js +214 -214
- package/dist/annotorious-react.es25.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -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.
|
|
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.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,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,YAA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