dbf-mirador 4.2.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.
- package/LICENSE +203 -0
- package/README.md +133 -0
- package/dist/CommentSharp-B0J_-jEq.js +325 -0
- package/dist/CommentSharp-B0J_-jEq.js.map +1 -0
- package/dist/FailedImageContext-aQXnWSHN.js +318 -0
- package/dist/FailedImageContext-aQXnWSHN.js.map +1 -0
- package/dist/PluginHook-CFw_6P5c.js +54 -0
- package/dist/PluginHook-CFw_6P5c.js.map +1 -0
- package/dist/WindowCanvasNavigationControls-CUX723BQ.js +242 -0
- package/dist/WindowCanvasNavigationControls-CUX723BQ.js.map +1 -0
- package/dist/action-types-DjIbTE-A.js +74 -0
- package/dist/action-types-DjIbTE-A.js.map +1 -0
- package/dist/canvas-C8oHvXFN.js +41 -0
- package/dist/canvas-C8oHvXFN.js.map +1 -0
- package/dist/canvases-gRqhr-IH.js +3154 -0
- package/dist/canvases-gRqhr-IH.js.map +1 -0
- package/dist/createSvgIcon-Cwt8YPfm.js +2 -0
- package/dist/getters-COus7Mvg.js +2066 -0
- package/dist/getters-COus7Mvg.js.map +1 -0
- package/dist/index.module-CbBRf_R8.js +403 -0
- package/dist/index.module-CbBRf_R8.js.map +1 -0
- package/dist/mirador.es.js +39600 -0
- package/dist/mirador.es.js.map +1 -0
- package/dist/mirador.min.js +334 -0
- package/dist/mirador.min.js.map +1 -0
- package/dist/react-error-boundary.esm-B_pT-oCS.js +67 -0
- package/dist/react-error-boundary.esm-B_pT-oCS.js.map +1 -0
- package/dist/visuallyHidden-DmYvwNdU.js +98 -0
- package/dist/visuallyHidden-DmYvwNdU.js.map +1 -0
- package/dist/window-zelwU7wz.js +138 -0
- package/dist/window-zelwU7wz.js.map +1 -0
- package/package.json +138 -0
- package/src/components/AccessTokenSender.jsx +34 -0
- package/src/components/AnnotationSettings.jsx +31 -0
- package/src/components/AnnotationsOverlay.jsx +328 -0
- package/src/components/App.jsx +34 -0
- package/src/components/AppProviders.jsx +129 -0
- package/src/components/AttributionPanel.jsx +78 -0
- package/src/components/AudioViewer.jsx +39 -0
- package/src/components/BackgroundPluginArea.jsx +9 -0
- package/src/components/Branding.jsx +33 -0
- package/src/components/CanvasAnnotations.jsx +125 -0
- package/src/components/CanvasInfo.jsx +46 -0
- package/src/components/CanvasLayers.jsx +367 -0
- package/src/components/ChangeThemeDialog.jsx +65 -0
- package/src/components/CollapsibleSection.jsx +53 -0
- package/src/components/CollectionDialog.jsx +236 -0
- package/src/components/CollectionInfo.jsx +48 -0
- package/src/components/CompanionArea.jsx +140 -0
- package/src/components/CompanionWindow.jsx +228 -0
- package/src/components/CompanionWindowFactory.jsx +38 -0
- package/src/components/CompanionWindowSection.jsx +11 -0
- package/src/components/CustomPanel.jsx +22 -0
- package/src/components/ErrorContent.jsx +65 -0
- package/src/components/ErrorDialog.jsx +47 -0
- package/src/components/FullScreenButton.jsx +47 -0
- package/src/components/GalleryView.jsx +36 -0
- package/src/components/GalleryViewThumbnail.jsx +160 -0
- package/src/components/IIIFAuthentication.jsx +144 -0
- package/src/components/IIIFDropTarget.jsx +168 -0
- package/src/components/IIIFIFrameCommunication.jsx +45 -0
- package/src/components/IIIFResourceLabel.jsx +26 -0
- package/src/components/IIIFThumbnail.jsx +214 -0
- package/src/components/ImageFailureMessage.jsx +42 -0
- package/src/components/LabelValueMetadata.jsx +46 -0
- package/src/components/LanguageSettings.jsx +46 -0
- package/src/components/LayersPanel.jsx +24 -0
- package/src/components/LocalePicker.jsx +56 -0
- package/src/components/ManifestForm.jsx +79 -0
- package/src/components/ManifestInfo.jsx +67 -0
- package/src/components/ManifestListItem.jsx +209 -0
- package/src/components/ManifestListItemError.jsx +53 -0
- package/src/components/ManifestRelatedLinks.jsx +154 -0
- package/src/components/MinimalWindow.jsx +104 -0
- package/src/components/MiradorMenuButton.jsx +71 -0
- package/src/components/MosaicRenderPreview.jsx +16 -0
- package/src/components/NestedMenu.jsx +42 -0
- package/src/components/NewBrowserWindow.jsx +34 -0
- package/src/components/OpenSeadragonComponent.jsx +258 -0
- package/src/components/OpenSeadragonTileSource.jsx +105 -0
- package/src/components/OpenSeadragonViewer.jsx +161 -0
- package/src/components/PluginHook.jsx +27 -0
- package/src/components/PrimaryWindow.jsx +115 -0
- package/src/components/SanitizedHtml.jsx +37 -0
- package/src/components/ScrollIndicatedDialogContent.jsx +60 -0
- package/src/components/ScrollTo.jsx +61 -0
- package/src/components/SearchHit.jsx +220 -0
- package/src/components/SearchPanel.jsx +80 -0
- package/src/components/SearchPanelControls.jsx +174 -0
- package/src/components/SearchPanelNavigation.jsx +84 -0
- package/src/components/SearchResults.jsx +138 -0
- package/src/components/SelectCollection.jsx +44 -0
- package/src/components/SidebarIndexItem.jsx +11 -0
- package/src/components/SidebarIndexList.jsx +73 -0
- package/src/components/SidebarIndexTableOfContents.jsx +170 -0
- package/src/components/SidebarIndexThumbnail.jsx +22 -0
- package/src/components/TextViewer.jsx +37 -0
- package/src/components/ThumbnailCanvasGrouping.jsx +122 -0
- package/src/components/ThumbnailNavigation.jsx +231 -0
- package/src/components/VideoViewer.jsx +35 -0
- package/src/components/ViewerInfo.jsx +55 -0
- package/src/components/ViewerNavigation.jsx +72 -0
- package/src/components/Window.jsx +150 -0
- package/src/components/WindowAuthenticationBar.jsx +176 -0
- package/src/components/WindowCanvasNavigationControls.jsx +91 -0
- package/src/components/WindowList.jsx +71 -0
- package/src/components/WindowListButton.jsx +57 -0
- package/src/components/WindowSideBar.jsx +48 -0
- package/src/components/WindowSideBarAnnotationsPanel.jsx +51 -0
- package/src/components/WindowSideBarButtons.jsx +151 -0
- package/src/components/WindowSideBarCanvasPanel.jsx +165 -0
- package/src/components/WindowSideBarCollectionPanel.jsx +179 -0
- package/src/components/WindowSideBarInfoPanel.jsx +67 -0
- package/src/components/WindowThumbnailSettings.jsx +130 -0
- package/src/components/WindowTopBar.jsx +125 -0
- package/src/components/WindowTopBarPluginArea.jsx +8 -0
- package/src/components/WindowTopBarPluginMenu.jsx +78 -0
- package/src/components/WindowTopBarTitle.jsx +73 -0
- package/src/components/WindowTopMenu.jsx +81 -0
- package/src/components/WindowTopMenuButton.jsx +49 -0
- package/src/components/WindowViewSettings.jsx +95 -0
- package/src/components/WindowViewer.jsx +26 -0
- package/src/components/Workspace.jsx +124 -0
- package/src/components/WorkspaceAdd.jsx +221 -0
- package/src/components/WorkspaceAddButton.jsx +73 -0
- package/src/components/WorkspaceArea.jsx +66 -0
- package/src/components/WorkspaceControlPanel.jsx +85 -0
- package/src/components/WorkspaceControlPanelButtons.jsx +20 -0
- package/src/components/WorkspaceDialog.jsx +11 -0
- package/src/components/WorkspaceElastic.jsx +88 -0
- package/src/components/WorkspaceElasticWindow.jsx +79 -0
- package/src/components/WorkspaceExport.jsx +99 -0
- package/src/components/WorkspaceImport.jsx +89 -0
- package/src/components/WorkspaceMenu.jsx +126 -0
- package/src/components/WorkspaceMenuButton.jsx +42 -0
- package/src/components/WorkspaceMosaic.jsx +149 -0
- package/src/components/WorkspaceOptionsButton.jsx +35 -0
- package/src/components/WorkspaceOptionsMenu.jsx +112 -0
- package/src/components/WorkspaceSelectionDialog.jsx +165 -0
- package/src/components/ZoomControls.jsx +57 -0
- package/src/components/icons/BookViewIcon.jsx +14 -0
- package/src/components/icons/CanvasIndexIcon.jsx +14 -0
- package/src/components/icons/GalleryViewIcon.jsx +17 -0
- package/src/components/icons/MiradorIcon.jsx +14 -0
- package/src/components/icons/RestoreZoomIcon.jsx +15 -0
- package/src/components/icons/ThumbnailNavigationBottomIcon.jsx +15 -0
- package/src/components/icons/ThumbnailNavigationRightIcon.jsx +16 -0
- package/src/components/icons/WindowMaxIcon.jsx +15 -0
- package/src/components/icons/WindowMinIcon.jsx +15 -0
- package/src/components/icons/WindowOptionsIcon.jsx +16 -0
- package/src/components/icons/WorkspaceTypeElasticIcon.jsx +157 -0
- package/src/components/icons/WorkspaceTypeMosaicIcon.jsx +162 -0
- package/src/components/icons/index.js +27 -0
- package/src/components/index.js +108 -0
- package/src/config/css-ns.js +10 -0
- package/src/config/index.js +2 -0
- package/src/config/settings.js +607 -0
- package/src/containers/AnnotationSettings.js +27 -0
- package/src/containers/AnnotationsOverlay.js +51 -0
- package/src/containers/AppProviders.js +20 -0
- package/src/containers/AttributionPanel.js +20 -0
- package/src/containers/AudioViewer.js +16 -0
- package/src/containers/BackgroundPluginArea.js +4 -0
- package/src/containers/Branding.js +4 -0
- package/src/containers/CanvasAnnotations.js +32 -0
- package/src/containers/CanvasInfo.js +20 -0
- package/src/containers/CanvasLayers.js +25 -0
- package/src/containers/ChangeThemeDialog.js +29 -0
- package/src/containers/CollapsibleSection.js +3 -0
- package/src/containers/CollectionDialog.js +48 -0
- package/src/containers/CollectionInfo.js +29 -0
- package/src/containers/CompanionArea.js +22 -0
- package/src/containers/CompanionWindow.js +40 -0
- package/src/containers/CompanionWindowFactory.js +23 -0
- package/src/containers/CustomPanel.js +13 -0
- package/src/containers/ErrorContent.js +20 -0
- package/src/containers/ErrorDialog.js +28 -0
- package/src/containers/FullScreenButton.js +22 -0
- package/src/containers/GalleryView.js +23 -0
- package/src/containers/GalleryViewThumbnail.js +51 -0
- package/src/containers/IIIFAuthentication.js +86 -0
- package/src/containers/IIIFThumbnail.js +17 -0
- package/src/containers/LabelValueMetadata.js +14 -0
- package/src/containers/LanguageSettings.js +26 -0
- package/src/containers/LayersPanel.js +16 -0
- package/src/containers/LocalePicker.js +3 -0
- package/src/containers/ManifestForm.js +16 -0
- package/src/containers/ManifestInfo.js +29 -0
- package/src/containers/ManifestListItem.js +52 -0
- package/src/containers/ManifestListItemError.js +15 -0
- package/src/containers/ManifestRelatedLinks.js +28 -0
- package/src/containers/MinimalWindow.js +25 -0
- package/src/containers/MiradorMenuButton.js +7 -0
- package/src/containers/MosaicRenderPreview.js +14 -0
- package/src/containers/OpenSeadragonViewer.js +59 -0
- package/src/containers/PrimaryWindow.js +27 -0
- package/src/containers/SanitizedHtml.js +3 -0
- package/src/containers/ScrollIndicatedDialogContent.js +3 -0
- package/src/containers/SearchHit.js +71 -0
- package/src/containers/SearchPanel.js +23 -0
- package/src/containers/SearchPanelControls.js +36 -0
- package/src/containers/SearchPanelNavigation.js +39 -0
- package/src/containers/SearchResults.js +38 -0
- package/src/containers/SelectCollection.js +24 -0
- package/src/containers/SidebarIndexItem.js +8 -0
- package/src/containers/SidebarIndexList.js +28 -0
- package/src/containers/SidebarIndexTableOfContents.js +31 -0
- package/src/containers/SidebarIndexThumbnail.js +18 -0
- package/src/containers/TextViewer.js +19 -0
- package/src/containers/ThumbnailCanvasGrouping.js +29 -0
- package/src/containers/ThumbnailNavigation.js +48 -0
- package/src/containers/VideoViewer.js +16 -0
- package/src/containers/ViewerInfo.js +30 -0
- package/src/containers/ViewerNavigation.js +31 -0
- package/src/containers/Window.js +45 -0
- package/src/containers/WindowAuthenticationBar.js +7 -0
- package/src/containers/WindowCanvasNavigationControls.js +15 -0
- package/src/containers/WindowList.js +30 -0
- package/src/containers/WindowListButton.js +15 -0
- package/src/containers/WindowSideBar.js +20 -0
- package/src/containers/WindowSideBarAnnotationsPanel.js +23 -0
- package/src/containers/WindowSideBarButtons.js +75 -0
- package/src/containers/WindowSideBarCanvasPanel.js +50 -0
- package/src/containers/WindowSideBarCollectionPanel.js +48 -0
- package/src/containers/WindowSideBarInfoPanel.js +35 -0
- package/src/containers/WindowThumbnailSettings.js +31 -0
- package/src/containers/WindowTopBar.js +39 -0
- package/src/containers/WindowTopBarPluginArea.js +8 -0
- package/src/containers/WindowTopBarPluginMenu.js +7 -0
- package/src/containers/WindowTopBarTitle.js +17 -0
- package/src/containers/WindowTopMenu.js +28 -0
- package/src/containers/WindowTopMenuButton.js +7 -0
- package/src/containers/WindowViewSettings.js +30 -0
- package/src/containers/WindowViewer.js +10 -0
- package/src/containers/Workspace.js +36 -0
- package/src/containers/WorkspaceAdd.js +27 -0
- package/src/containers/WorkspaceAddButton.js +30 -0
- package/src/containers/WorkspaceArea.js +21 -0
- package/src/containers/WorkspaceControlPanel.js +10 -0
- package/src/containers/WorkspaceControlPanelButtons.js +7 -0
- package/src/containers/WorkspaceElastic.js +41 -0
- package/src/containers/WorkspaceElasticWindow.js +36 -0
- package/src/containers/WorkspaceExport.js +18 -0
- package/src/containers/WorkspaceImport.js +19 -0
- package/src/containers/WorkspaceMenu.js +30 -0
- package/src/containers/WorkspaceMenuButton.js +10 -0
- package/src/containers/WorkspaceMosaic.js +32 -0
- package/src/containers/WorkspaceOptionsButton.js +7 -0
- package/src/containers/WorkspaceOptionsMenu.js +3 -0
- package/src/containers/WorkspaceSelectionDialog.js +26 -0
- package/src/containers/ZoomControls.js +26 -0
- package/src/containers/index.js +94 -0
- package/src/contexts/FailedImageContext.js +8 -0
- package/src/contexts/FailedImageProvider.jsx +34 -0
- package/src/contexts/FullScreenContext.js +5 -0
- package/src/contexts/LocaleContext.js +5 -0
- package/src/contexts/OpenSeadragonViewerContext.js +5 -0
- package/src/contexts/WorkspaceContext.js +5 -0
- package/src/contexts/index.js +4 -0
- package/src/extend/PluginContext.js +5 -0
- package/src/extend/PluginProvider.jsx +22 -0
- package/src/extend/index.js +9 -0
- package/src/extend/pluginMapping.js +44 -0
- package/src/extend/pluginPreprocessing.js +45 -0
- package/src/extend/pluginValidation.js +58 -0
- package/src/extend/usePlugins.js +13 -0
- package/src/extend/withPlugins.jsx +46 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useCanvasWorldService.js +10 -0
- package/src/hooks/useThumbnailService.js +8 -0
- package/src/i18n.js +71 -0
- package/src/index.js +18 -0
- package/src/init.js +20 -0
- package/src/lib/AnnotationFactory.js +23 -0
- package/src/lib/AnnotationItem.js +123 -0
- package/src/lib/AnnotationList.js +31 -0
- package/src/lib/AnnotationPage.js +41 -0
- package/src/lib/AnnotationResource.js +122 -0
- package/src/lib/CanvasAnnotationDisplay.js +148 -0
- package/src/lib/CanvasGroupings.js +55 -0
- package/src/lib/CanvasWorld.js +214 -0
- package/src/lib/CompanionWindowRegistry.js +23 -0
- package/src/lib/FullScreenHandle.jsx +76 -0
- package/src/lib/MiradorCanvas.js +211 -0
- package/src/lib/MiradorManifest.js +44 -0
- package/src/lib/MiradorViewer.jsx +53 -0
- package/src/lib/MosaicLayout.js +77 -0
- package/src/lib/OpenSeadragonCanvasOverlay.js +114 -0
- package/src/lib/ThumbnailFactory.js +310 -0
- package/src/lib/TruncatedHit.js +34 -0
- package/src/lib/asArray.js +11 -0
- package/src/lib/htmlRules.js +28 -0
- package/src/lib/iiif.js +12 -0
- package/src/lib/index.js +23 -0
- package/src/lib/readImageMetadata.js +21 -0
- package/src/lib/svgShapesToPath.js +49 -0
- package/src/locales/README.md +60 -0
- package/src/locales/ar/translation.json +141 -0
- package/src/locales/bg/translation.json +164 -0
- package/src/locales/de/translation.json +169 -0
- package/src/locales/en/translation.json +170 -0
- package/src/locales/et/translation.json +164 -0
- package/src/locales/fa/translation.json +164 -0
- package/src/locales/fr/translation.json +158 -0
- package/src/locales/hr/translation.json +164 -0
- package/src/locales/hu/translation.json +166 -0
- package/src/locales/it/translation.json +162 -0
- package/src/locales/ja/translation.json +156 -0
- package/src/locales/kr/translation.json +162 -0
- package/src/locales/lt/translation.json +153 -0
- package/src/locales/nbNo/translation.json +162 -0
- package/src/locales/nl/translation.json +139 -0
- package/src/locales/pl/translation.json +162 -0
- package/src/locales/ptBr/translation.json +133 -0
- package/src/locales/sr/translation.json +155 -0
- package/src/locales/sv/translation.json +157 -0
- package/src/locales/ta/translation.json +167 -0
- package/src/locales/vi/translation.json +156 -0
- package/src/locales/zhCn/translation.json +163 -0
- package/src/locales/zhTw/translation.json +163 -0
- package/src/plugins/OSDReferences.js +15 -0
- package/src/plugins/index.js +1 -0
- package/src/state/actions/action-types.js +76 -0
- package/src/state/actions/annotation.js +123 -0
- package/src/state/actions/auth.js +109 -0
- package/src/state/actions/canvas.js +65 -0
- package/src/state/actions/catalog.js +22 -0
- package/src/state/actions/companionWindow.js +107 -0
- package/src/state/actions/config.js +49 -0
- package/src/state/actions/elasticLayout.js +10 -0
- package/src/state/actions/errors.js +22 -0
- package/src/state/actions/index.js +19 -0
- package/src/state/actions/infoResponse.js +90 -0
- package/src/state/actions/layers.js +14 -0
- package/src/state/actions/manifest.js +65 -0
- package/src/state/actions/search.js +97 -0
- package/src/state/actions/window.js +209 -0
- package/src/state/actions/workspace.js +84 -0
- package/src/state/createPluggableStore.js +24 -0
- package/src/state/createStore.js +33 -0
- package/src/state/index.js +21 -0
- package/src/state/reducers/accessTokens.js +59 -0
- package/src/state/reducers/annotations.js +48 -0
- package/src/state/reducers/auth.js +43 -0
- package/src/state/reducers/catalog.js +30 -0
- package/src/state/reducers/companionWindows.js +49 -0
- package/src/state/reducers/config.js +39 -0
- package/src/state/reducers/elasticLayout.js +29 -0
- package/src/state/reducers/errors.js +51 -0
- package/src/state/reducers/index.js +15 -0
- package/src/state/reducers/infoResponses.js +61 -0
- package/src/state/reducers/layers.js +23 -0
- package/src/state/reducers/manifests.js +52 -0
- package/src/state/reducers/rootReducer.js +44 -0
- package/src/state/reducers/search.js +145 -0
- package/src/state/reducers/utils.js +45 -0
- package/src/state/reducers/viewers.js +42 -0
- package/src/state/reducers/windows.js +185 -0
- package/src/state/reducers/workspace.js +111 -0
- package/src/state/sagas/annotations.js +48 -0
- package/src/state/sagas/app.js +56 -0
- package/src/state/sagas/auth.js +151 -0
- package/src/state/sagas/iiif.js +233 -0
- package/src/state/sagas/index.js +30 -0
- package/src/state/sagas/windows.js +293 -0
- package/src/state/selectors/annotations.js +138 -0
- package/src/state/selectors/auth.js +100 -0
- package/src/state/selectors/canvases.js +260 -0
- package/src/state/selectors/companionWindows.js +182 -0
- package/src/state/selectors/config.js +100 -0
- package/src/state/selectors/getters.js +90 -0
- package/src/state/selectors/index.js +17 -0
- package/src/state/selectors/layers.js +79 -0
- package/src/state/selectors/manifests.js +433 -0
- package/src/state/selectors/ranges.js +147 -0
- package/src/state/selectors/searches.js +249 -0
- package/src/state/selectors/sequences.js +134 -0
- package/src/state/selectors/thumbnails.js +28 -0
- package/src/state/selectors/utils.js +18 -0
- package/src/state/selectors/viewer.js +19 -0
- package/src/state/selectors/windows.js +98 -0
- package/src/state/selectors/workspace.js +52 -0
- package/src/state/selectors/wrappers.js +15 -0
- package/src/styles/react-mosaic-component.js +288 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import update from 'lodash/fp/update';
|
|
2
|
+
import omit from 'lodash/omit';
|
|
3
|
+
import ActionTypes from '../actions/action-types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* windowsReducer
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line complexity
|
|
9
|
+
export const windowsReducer = (state = {}, action) => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case ActionTypes.ADD_WINDOW:
|
|
12
|
+
return { ...state, [action.window.id]: action.window };
|
|
13
|
+
|
|
14
|
+
case ActionTypes.MAXIMIZE_WINDOW:
|
|
15
|
+
return {
|
|
16
|
+
...state,
|
|
17
|
+
[action.windowId]: {
|
|
18
|
+
...state[action.windowId],
|
|
19
|
+
maximized: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
case ActionTypes.MINIMIZE_WINDOW:
|
|
23
|
+
return {
|
|
24
|
+
...state,
|
|
25
|
+
[action.windowId]: {
|
|
26
|
+
...state[action.windowId],
|
|
27
|
+
maximized: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
case ActionTypes.UPDATE_WINDOW:
|
|
32
|
+
if (!state[action.id]) return state;
|
|
33
|
+
|
|
34
|
+
return update(
|
|
35
|
+
[action.id],
|
|
36
|
+
(orig) => ({
|
|
37
|
+
...(orig || {}),
|
|
38
|
+
// drop explicit `undefined` values so they can't clobber existing keys on spread (#3930)
|
|
39
|
+
...Object.fromEntries(Object.entries(action.payload).filter(([, value]) => value !== undefined)),
|
|
40
|
+
}),
|
|
41
|
+
state,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
case ActionTypes.REMOVE_WINDOW:
|
|
45
|
+
return omit(state, [action.windowId]);
|
|
46
|
+
case ActionTypes.TOGGLE_WINDOW_SIDE_BAR:
|
|
47
|
+
return {
|
|
48
|
+
...state,
|
|
49
|
+
[action.windowId]: {
|
|
50
|
+
...state[action.windowId],
|
|
51
|
+
sideBarOpen: !state[action.windowId].sideBarOpen,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
case ActionTypes.SET_WINDOW_VIEW_TYPE:
|
|
55
|
+
return {
|
|
56
|
+
...state,
|
|
57
|
+
[action.windowId]: {
|
|
58
|
+
...state[action.windowId],
|
|
59
|
+
view: action.viewType,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
case ActionTypes.UPDATE_WINDOW_POSITION:
|
|
63
|
+
return {
|
|
64
|
+
...state,
|
|
65
|
+
[action.payload.windowId]: {
|
|
66
|
+
...state[action.payload.windowId],
|
|
67
|
+
x: action.payload.position.x,
|
|
68
|
+
y: action.payload.position.y,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
case ActionTypes.SET_WINDOW_SIZE:
|
|
72
|
+
return {
|
|
73
|
+
...state,
|
|
74
|
+
[action.payload.windowId]: {
|
|
75
|
+
...state[action.payload.windowId],
|
|
76
|
+
height: action.payload.size.height,
|
|
77
|
+
width: action.payload.size.width,
|
|
78
|
+
x: action.payload.size.x,
|
|
79
|
+
y: action.payload.size.y,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
case ActionTypes.SET_CANVAS:
|
|
83
|
+
if (!state[action.windowId]) return state;
|
|
84
|
+
|
|
85
|
+
return update(
|
|
86
|
+
[action.windowId],
|
|
87
|
+
(orig) => ({
|
|
88
|
+
...(orig || {}),
|
|
89
|
+
canvasId: action.canvasId,
|
|
90
|
+
visibleCanvases: action.visibleCanvases || [],
|
|
91
|
+
}),
|
|
92
|
+
state,
|
|
93
|
+
);
|
|
94
|
+
case ActionTypes.ADD_COMPANION_WINDOW:
|
|
95
|
+
return {
|
|
96
|
+
...state,
|
|
97
|
+
[action.windowId]: {
|
|
98
|
+
...state[action.windowId],
|
|
99
|
+
companionWindowIds: state[action.windowId].companionWindowIds.concat([action.id]),
|
|
100
|
+
...(action.payload.position === 'left' ? { companionAreaOpen: true, sideBarPanel: action.payload.content } : {}),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
case ActionTypes.UPDATE_COMPANION_WINDOW:
|
|
104
|
+
if (action.payload.position !== 'left') return state;
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
...state,
|
|
108
|
+
[action.windowId]: {
|
|
109
|
+
...state[action.windowId],
|
|
110
|
+
companionAreaOpen: true,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
case ActionTypes.REMOVE_COMPANION_WINDOW:
|
|
114
|
+
return {
|
|
115
|
+
...state,
|
|
116
|
+
[action.windowId]: {
|
|
117
|
+
...state[action.windowId],
|
|
118
|
+
companionWindowIds: state[action.windowId].companionWindowIds.filter((id) => id !== action.id),
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
case ActionTypes.SELECT_ANNOTATION:
|
|
122
|
+
return {
|
|
123
|
+
...state,
|
|
124
|
+
[action.windowId]: {
|
|
125
|
+
...state[action.windowId],
|
|
126
|
+
selectedAnnotationId: action.annotationId,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
case ActionTypes.DESELECT_ANNOTATION: {
|
|
130
|
+
return {
|
|
131
|
+
...state,
|
|
132
|
+
[action.windowId]: {
|
|
133
|
+
...state[action.windowId],
|
|
134
|
+
selectedAnnotationId: undefined,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
case ActionTypes.HOVER_ANNOTATION:
|
|
139
|
+
return {
|
|
140
|
+
...state,
|
|
141
|
+
[action.windowId]: {
|
|
142
|
+
...state[action.windowId],
|
|
143
|
+
hoveredAnnotationIds: action.annotationIds,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
case ActionTypes.TOGGLE_ANNOTATION_DISPLAY:
|
|
147
|
+
return {
|
|
148
|
+
...state,
|
|
149
|
+
[action.windowId]: {
|
|
150
|
+
...state[action.windowId],
|
|
151
|
+
highlightAllAnnotations: !state[action.windowId].highlightAllAnnotations,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
case ActionTypes.IMPORT_MIRADOR_STATE:
|
|
155
|
+
return action.state.windows || [];
|
|
156
|
+
case ActionTypes.REQUEST_SEARCH:
|
|
157
|
+
return {
|
|
158
|
+
...state,
|
|
159
|
+
[action.windowId]: {
|
|
160
|
+
...state[action.windowId],
|
|
161
|
+
suggestedSearches: undefined,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
case ActionTypes.SHOW_COLLECTION_DIALOG:
|
|
165
|
+
return {
|
|
166
|
+
...state,
|
|
167
|
+
[action.windowId]: {
|
|
168
|
+
...state[action.windowId],
|
|
169
|
+
collectionDialogOn: true,
|
|
170
|
+
collectionManifestId: action.manifestId,
|
|
171
|
+
dialogCollectionPath: action.dialogCollectionPath,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
case ActionTypes.HIDE_COLLECTION_DIALOG:
|
|
175
|
+
return {
|
|
176
|
+
...state,
|
|
177
|
+
[action.windowId]: {
|
|
178
|
+
...state[action.windowId],
|
|
179
|
+
collectionDialogOn: false,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
default:
|
|
183
|
+
return state;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import settings from '../../config/settings';
|
|
2
|
+
import ActionTypes from '../actions/action-types';
|
|
3
|
+
|
|
4
|
+
/** Check if the viewport dimensions are fully specified */
|
|
5
|
+
function hasViewportPosition(viewportPosition) {
|
|
6
|
+
return (
|
|
7
|
+
viewportPosition.x !== undefined &&
|
|
8
|
+
viewportPosition.y !== undefined &&
|
|
9
|
+
viewportPosition.width !== undefined &&
|
|
10
|
+
viewportPosition.height !== undefined
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Check if the containee is fully within the bounds on the container */
|
|
15
|
+
function contains(container, containee) {
|
|
16
|
+
return (
|
|
17
|
+
containee.x - containee.width / 2 > container.x - container.width / 2 &&
|
|
18
|
+
containee.y - containee.height / 2 > container.y - container.height / 2 &&
|
|
19
|
+
containee.x + containee.width / 2 < container.x + container.width / 2 &&
|
|
20
|
+
containee.y + containee.height / 2 < container.y + container.height / 2
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* workspaceReducer
|
|
26
|
+
*/
|
|
27
|
+
export const workspaceReducer = (state = { ...settings.workspace, windowIds: [] }, action) => {
|
|
28
|
+
let newWorkspaceDimensions;
|
|
29
|
+
let viewportPosition;
|
|
30
|
+
let newWindowIds;
|
|
31
|
+
switch (action.type) {
|
|
32
|
+
case ActionTypes.UPDATE_WORKSPACE:
|
|
33
|
+
return {
|
|
34
|
+
...state,
|
|
35
|
+
...action.config,
|
|
36
|
+
};
|
|
37
|
+
case ActionTypes.FOCUS_WINDOW:
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
40
|
+
focusedWindowId: action.windowId,
|
|
41
|
+
viewportPosition: {
|
|
42
|
+
...state.viewportPosition,
|
|
43
|
+
...action.position,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
case ActionTypes.ADD_WINDOW:
|
|
47
|
+
return {
|
|
48
|
+
...state,
|
|
49
|
+
focusedWindowId: action.window.id,
|
|
50
|
+
windowIds: [...(state.windowIds || []), action.window.id],
|
|
51
|
+
};
|
|
52
|
+
case ActionTypes.REMOVE_WINDOW:
|
|
53
|
+
newWindowIds = (state.windowIds || []).filter((v) => v !== action.windowId);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...state,
|
|
57
|
+
focusedWindowId:
|
|
58
|
+
action.windowId === state.focusedWindowId ? newWindowIds[newWindowIds.length - 1] : state.focusedWindowId,
|
|
59
|
+
windowIds: newWindowIds,
|
|
60
|
+
};
|
|
61
|
+
case ActionTypes.SET_WORKSPACE_FULLSCREEN:
|
|
62
|
+
return { ...state, isFullscreenEnabled: action.isFullscreenEnabled };
|
|
63
|
+
case ActionTypes.TOGGLE_ZOOM_CONTROLS:
|
|
64
|
+
return { ...state, showZoomControls: action.showZoomControls };
|
|
65
|
+
case ActionTypes.UPDATE_WORKSPACE_MOSAIC_LAYOUT:
|
|
66
|
+
return { ...state, layout: action.layout };
|
|
67
|
+
case ActionTypes.SET_WORKSPACE_ADD_VISIBILITY:
|
|
68
|
+
return { ...state, isWorkspaceAddVisible: action.isWorkspaceAddVisible };
|
|
69
|
+
case ActionTypes.SET_WORKSPACE_VIEWPORT_POSITION:
|
|
70
|
+
newWorkspaceDimensions = {};
|
|
71
|
+
|
|
72
|
+
viewportPosition = {
|
|
73
|
+
...state.viewportPosition,
|
|
74
|
+
...action.payload.position,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (
|
|
78
|
+
hasViewportPosition(viewportPosition) &&
|
|
79
|
+
!contains(
|
|
80
|
+
{
|
|
81
|
+
height: state.height,
|
|
82
|
+
width: state.width,
|
|
83
|
+
x: 0,
|
|
84
|
+
y: 0,
|
|
85
|
+
},
|
|
86
|
+
viewportPosition,
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
89
|
+
newWorkspaceDimensions = {
|
|
90
|
+
height: state.height * 2,
|
|
91
|
+
width: state.width * 2,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
...state,
|
|
97
|
+
...newWorkspaceDimensions,
|
|
98
|
+
viewportPosition,
|
|
99
|
+
};
|
|
100
|
+
case ActionTypes.SET_CONFIG:
|
|
101
|
+
case ActionTypes.IMPORT_CONFIG:
|
|
102
|
+
case ActionTypes.UPDATE_CONFIG:
|
|
103
|
+
return { ...state, ...action.config.workspace };
|
|
104
|
+
case ActionTypes.IMPORT_MIRADOR_STATE:
|
|
105
|
+
return action.state.workspace || {};
|
|
106
|
+
case ActionTypes.TOGGLE_DRAGGING:
|
|
107
|
+
return { ...state, draggingEnabled: !state.draggingEnabled };
|
|
108
|
+
default:
|
|
109
|
+
return state;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { all, put, select, takeEvery } from 'redux-saga/effects';
|
|
2
|
+
import { requestCanvasAnnotations, receiveAnnotation, requestAnnotation } from '../actions';
|
|
3
|
+
import { getAnnotations, getCanvas, getMiradorCanvasWrapper } from '../selectors';
|
|
4
|
+
import ActionTypes from '../actions/action-types';
|
|
5
|
+
import MiradorCanvas from '../../lib/MiradorCanvas';
|
|
6
|
+
|
|
7
|
+
/** Fetch annotations for a given canvas */
|
|
8
|
+
export function* fetchCanvasAnnotations({ canvasId, windowId }) {
|
|
9
|
+
const canvas = yield select(getCanvas, { canvasId, windowId });
|
|
10
|
+
const annotations = yield select(getAnnotations);
|
|
11
|
+
const getMiradorCanvas = yield select(getMiradorCanvasWrapper);
|
|
12
|
+
const miradorCanvas = getMiradorCanvas(canvas);
|
|
13
|
+
|
|
14
|
+
return yield all([
|
|
15
|
+
// IIIF v2
|
|
16
|
+
...miradorCanvas.annotationListUris
|
|
17
|
+
.filter((uri) => !(annotations[canvas.id] && annotations[canvas.id][uri]))
|
|
18
|
+
.map((uri) => put(requestAnnotation(canvas.id, uri))),
|
|
19
|
+
// IIIF v3
|
|
20
|
+
...miradorCanvas.canvasAnnotationPages
|
|
21
|
+
.filter((annotation) => !(annotations[canvas.id] && annotations[canvas.id][annotation.id]))
|
|
22
|
+
.map((annotation) => {
|
|
23
|
+
// If there are no items, try to retrieve the referenced resource.
|
|
24
|
+
// otherwise the resource should be embedded and just add to the store.
|
|
25
|
+
if (!annotation.items) {
|
|
26
|
+
return put(requestAnnotation(canvas.id, annotation.id));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return put(receiveAnnotation(canvas.id, annotation.id, annotation));
|
|
30
|
+
}),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Fetch annotations for the visible canvases.
|
|
36
|
+
*/
|
|
37
|
+
export function* fetchAnnotations({ visibleCanvases = [], windowId }) {
|
|
38
|
+
// this little indirection allows plugins to also handle the request
|
|
39
|
+
return yield all(visibleCanvases.map((canvasId) => put(requestCanvasAnnotations(windowId, canvasId))));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** */
|
|
43
|
+
export default function* appSaga() {
|
|
44
|
+
yield all([
|
|
45
|
+
takeEvery(ActionTypes.REQUEST_CANVAS_ANNOTATIONS, fetchCanvasAnnotations),
|
|
46
|
+
takeEvery(ActionTypes.SET_CANVAS, fetchAnnotations),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { all, call, put, takeEvery } from 'redux-saga/effects';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
|
+
import { fetchManifests } from './iiif';
|
|
4
|
+
import { fetchWindowManifest } from './windows';
|
|
5
|
+
import { addWindow } from '../actions';
|
|
6
|
+
import ActionTypes from '../actions/action-types';
|
|
7
|
+
|
|
8
|
+
/** */
|
|
9
|
+
export function* importState(action) {
|
|
10
|
+
yield all([
|
|
11
|
+
...Object.entries(action.state.windows || {}).map(([_, window]) =>
|
|
12
|
+
call(fetchWindowManifest, { id: window.id, payload: window }),
|
|
13
|
+
),
|
|
14
|
+
...Object.entries(action.state.manifests || {})
|
|
15
|
+
.filter(([_, manifest]) => !manifest.json)
|
|
16
|
+
.map(([_, manifest]) => call(fetchManifests, manifest.id)),
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Add windows from the imported config */
|
|
21
|
+
export function* importConfig({ config: { thumbnailNavigation, windows } }) {
|
|
22
|
+
if (!windows || windows.length === 0) return;
|
|
23
|
+
|
|
24
|
+
const thunks = yield all(
|
|
25
|
+
windows.map((miradorWindow) => {
|
|
26
|
+
const windowId = `window-${uuid()}`;
|
|
27
|
+
const manifestId = miradorWindow.manifestId || miradorWindow.loadedManifest;
|
|
28
|
+
|
|
29
|
+
return call(addWindow, {
|
|
30
|
+
// these are default values ...
|
|
31
|
+
id: windowId,
|
|
32
|
+
manifestId,
|
|
33
|
+
thumbnailNavigationPosition: thumbnailNavigation && thumbnailNavigation.defaultPosition,
|
|
34
|
+
// ... overridden by values from the window configuration ...
|
|
35
|
+
...miradorWindow,
|
|
36
|
+
});
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
yield all(thunks.map((thunk) => put(thunk)));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** */
|
|
44
|
+
export function* fetchCollectionManifests(action) {
|
|
45
|
+
const { dialogCollectionPath, manifestId } = action;
|
|
46
|
+
yield call(fetchManifests, manifestId, ...dialogCollectionPath);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** */
|
|
50
|
+
export default function* appSaga() {
|
|
51
|
+
yield all([
|
|
52
|
+
takeEvery(ActionTypes.IMPORT_MIRADOR_STATE, importState),
|
|
53
|
+
takeEvery(ActionTypes.IMPORT_CONFIG, importConfig),
|
|
54
|
+
takeEvery(ActionTypes.SHOW_COLLECTION_DIALOG, fetchCollectionManifests),
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { all, call, put, select, takeEvery, delay } from 'redux-saga/effects';
|
|
2
|
+
import { Utils } from 'manifesto.js';
|
|
3
|
+
import ActionTypes from '../actions/action-types';
|
|
4
|
+
import { addAuthenticationRequest, resolveAuthenticationRequest, requestAccessToken, resetAuthenticationState } from '../actions';
|
|
5
|
+
import {
|
|
6
|
+
selectInfoResponses,
|
|
7
|
+
getVisibleCanvases,
|
|
8
|
+
getWindows,
|
|
9
|
+
getConfig,
|
|
10
|
+
getAuth,
|
|
11
|
+
getAccessTokens,
|
|
12
|
+
getMiradorCanvasWrapper,
|
|
13
|
+
} from '../selectors';
|
|
14
|
+
import { fetchInfoResponse } from './iiif';
|
|
15
|
+
|
|
16
|
+
/** */
|
|
17
|
+
export function* refetchInfoResponsesOnLogout({ tokenServiceId }) {
|
|
18
|
+
// delay logout actions to give the cookie service a chance to invalidate our cookies
|
|
19
|
+
// before we reinitialize openseadragon and rerequest images.
|
|
20
|
+
|
|
21
|
+
yield delay(2000);
|
|
22
|
+
yield call(refetchInfoResponses, { serviceId: tokenServiceId });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Figure out what info responses could have used the access token service and:
|
|
27
|
+
* - refetch, if they are currently visible
|
|
28
|
+
* - throw them out (and lazy re-fetch) otherwise
|
|
29
|
+
*/
|
|
30
|
+
export function* refetchInfoResponses({ serviceId }) {
|
|
31
|
+
const windows = yield select(getWindows);
|
|
32
|
+
|
|
33
|
+
const canvases = yield all(Object.keys(windows).map((windowId) => select(getVisibleCanvases, { windowId })));
|
|
34
|
+
|
|
35
|
+
const getMiradorCanvas = yield select(getMiradorCanvasWrapper);
|
|
36
|
+
|
|
37
|
+
const visibleImageApiIds = canvases.flat().flatMap((canvas) => getMiradorCanvas(canvas).imageServiceIds);
|
|
38
|
+
|
|
39
|
+
const infoResponses = yield select(selectInfoResponses);
|
|
40
|
+
/** */
|
|
41
|
+
const haveThisTokenService = (infoResponse) => {
|
|
42
|
+
const services = Utils.getServices(infoResponse);
|
|
43
|
+
return services.some((e) => {
|
|
44
|
+
const infoTokenService =
|
|
45
|
+
Utils.getService(e, 'http://iiif.io/api/auth/1/token') || Utils.getService(e, 'http://iiif.io/api/auth/0/token');
|
|
46
|
+
return infoTokenService && infoTokenService.id === serviceId;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const obsoleteInfoResponses = Object.values(infoResponses).filter((i) => i.json && haveThisTokenService(i.json));
|
|
51
|
+
|
|
52
|
+
yield all(
|
|
53
|
+
obsoleteInfoResponses.map(({ id: infoId }) => {
|
|
54
|
+
if (visibleImageApiIds.includes(infoId)) {
|
|
55
|
+
return call(fetchInfoResponse, { infoId });
|
|
56
|
+
}
|
|
57
|
+
return put({ infoId, type: ActionTypes.REMOVE_INFO_RESPONSE });
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** try to start any non-interactive auth flows */
|
|
63
|
+
export function* doAuthWorkflow({ infoJson, windowId }) {
|
|
64
|
+
const auths = yield select(getAuth);
|
|
65
|
+
const { auth: { serviceProfiles = [] } = {} } = yield select(getConfig);
|
|
66
|
+
const nonInteractiveAuthFlowProfiles = serviceProfiles.filter((p) => p.external || p.kiosk);
|
|
67
|
+
|
|
68
|
+
// try to get an untried, non-interactive auth service
|
|
69
|
+
const authService = Utils.getServices(infoJson)
|
|
70
|
+
.filter((s) => !auths[s.id])
|
|
71
|
+
.find((e) => nonInteractiveAuthFlowProfiles.some((p) => p.profile === e.getProfile()));
|
|
72
|
+
if (!authService) return;
|
|
73
|
+
|
|
74
|
+
const profileConfig = nonInteractiveAuthFlowProfiles.find((p) => p.profile === authService.getProfile());
|
|
75
|
+
|
|
76
|
+
if (profileConfig.kiosk) {
|
|
77
|
+
// start the auth
|
|
78
|
+
yield put(addAuthenticationRequest(windowId, authService.id, authService.getProfile()));
|
|
79
|
+
} else if (profileConfig.external) {
|
|
80
|
+
const tokenService =
|
|
81
|
+
Utils.getService(authService, 'http://iiif.io/api/auth/1/token') ||
|
|
82
|
+
Utils.getService(authService, 'http://iiif.io/api/auth/0/token');
|
|
83
|
+
|
|
84
|
+
if (!tokenService) return;
|
|
85
|
+
// start the auth
|
|
86
|
+
yield put(addAuthenticationRequest(windowId, authService.id, authService.getProfile()));
|
|
87
|
+
// resolve the auth
|
|
88
|
+
yield put(resolveAuthenticationRequest(authService.id, tokenService.id, { ok: true }));
|
|
89
|
+
// start access tokens
|
|
90
|
+
yield put(requestAccessToken(tokenService.id, authService.id));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** */
|
|
95
|
+
export function* rerequestOnAccessTokenFailure({ infoJson, windowId, tokenServiceId }) {
|
|
96
|
+
if (!tokenServiceId) return;
|
|
97
|
+
|
|
98
|
+
// make sure we have an auth service to try
|
|
99
|
+
const authService = Utils.getServices(infoJson).find((service) => {
|
|
100
|
+
const tokenService =
|
|
101
|
+
Utils.getService(service, 'http://iiif.io/api/auth/1/token') ||
|
|
102
|
+
Utils.getService(service, 'http://iiif.io/api/auth/0/token');
|
|
103
|
+
|
|
104
|
+
return tokenService && tokenService.id === tokenServiceId;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (!authService) return;
|
|
108
|
+
|
|
109
|
+
// make sure the token ever worked (and might have expired or needs to be re-upped)
|
|
110
|
+
const accessTokenServices = yield select(getAccessTokens);
|
|
111
|
+
const service = accessTokenServices[tokenServiceId];
|
|
112
|
+
if (!(service && service.success)) return;
|
|
113
|
+
|
|
114
|
+
yield put(requestAccessToken(tokenServiceId, authService.id));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** */
|
|
118
|
+
export function* invalidateInvalidAuth({ serviceId }) {
|
|
119
|
+
const accessTokenServices = yield select(getAccessTokens);
|
|
120
|
+
const authServices = yield select(getAuth);
|
|
121
|
+
|
|
122
|
+
const accessTokenService = accessTokenServices[serviceId];
|
|
123
|
+
if (!accessTokenService) return;
|
|
124
|
+
const authService = authServices[accessTokenService.authId];
|
|
125
|
+
if (!authService) return;
|
|
126
|
+
|
|
127
|
+
if (accessTokenService.success) {
|
|
128
|
+
// if the token ever worked, reset things so we try to get a new cookie
|
|
129
|
+
yield put(
|
|
130
|
+
resetAuthenticationState({
|
|
131
|
+
authServiceId: authService.id,
|
|
132
|
+
tokenServiceId: accessTokenService.id,
|
|
133
|
+
}),
|
|
134
|
+
);
|
|
135
|
+
} else {
|
|
136
|
+
// if the token never worked, mark the auth service as bad so we could
|
|
137
|
+
// try to pick a different service
|
|
138
|
+
yield put(resolveAuthenticationRequest(authService.id, accessTokenService.id, { ok: false }));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** */
|
|
143
|
+
export default function* authSaga() {
|
|
144
|
+
yield all([
|
|
145
|
+
takeEvery(ActionTypes.RECEIVE_DEGRADED_INFO_RESPONSE, rerequestOnAccessTokenFailure),
|
|
146
|
+
takeEvery(ActionTypes.RECEIVE_ACCESS_TOKEN_FAILURE, invalidateInvalidAuth),
|
|
147
|
+
takeEvery(ActionTypes.RECEIVE_DEGRADED_INFO_RESPONSE, doAuthWorkflow),
|
|
148
|
+
takeEvery(ActionTypes.RECEIVE_ACCESS_TOKEN, refetchInfoResponses),
|
|
149
|
+
takeEvery(ActionTypes.RESET_AUTHENTICATION_STATE, refetchInfoResponsesOnLogout),
|
|
150
|
+
]);
|
|
151
|
+
}
|