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.
Files changed (384) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +133 -0
  3. package/dist/CommentSharp-B0J_-jEq.js +325 -0
  4. package/dist/CommentSharp-B0J_-jEq.js.map +1 -0
  5. package/dist/FailedImageContext-aQXnWSHN.js +318 -0
  6. package/dist/FailedImageContext-aQXnWSHN.js.map +1 -0
  7. package/dist/PluginHook-CFw_6P5c.js +54 -0
  8. package/dist/PluginHook-CFw_6P5c.js.map +1 -0
  9. package/dist/WindowCanvasNavigationControls-CUX723BQ.js +242 -0
  10. package/dist/WindowCanvasNavigationControls-CUX723BQ.js.map +1 -0
  11. package/dist/action-types-DjIbTE-A.js +74 -0
  12. package/dist/action-types-DjIbTE-A.js.map +1 -0
  13. package/dist/canvas-C8oHvXFN.js +41 -0
  14. package/dist/canvas-C8oHvXFN.js.map +1 -0
  15. package/dist/canvases-gRqhr-IH.js +3154 -0
  16. package/dist/canvases-gRqhr-IH.js.map +1 -0
  17. package/dist/createSvgIcon-Cwt8YPfm.js +2 -0
  18. package/dist/getters-COus7Mvg.js +2066 -0
  19. package/dist/getters-COus7Mvg.js.map +1 -0
  20. package/dist/index.module-CbBRf_R8.js +403 -0
  21. package/dist/index.module-CbBRf_R8.js.map +1 -0
  22. package/dist/mirador.es.js +39600 -0
  23. package/dist/mirador.es.js.map +1 -0
  24. package/dist/mirador.min.js +334 -0
  25. package/dist/mirador.min.js.map +1 -0
  26. package/dist/react-error-boundary.esm-B_pT-oCS.js +67 -0
  27. package/dist/react-error-boundary.esm-B_pT-oCS.js.map +1 -0
  28. package/dist/visuallyHidden-DmYvwNdU.js +98 -0
  29. package/dist/visuallyHidden-DmYvwNdU.js.map +1 -0
  30. package/dist/window-zelwU7wz.js +138 -0
  31. package/dist/window-zelwU7wz.js.map +1 -0
  32. package/package.json +138 -0
  33. package/src/components/AccessTokenSender.jsx +34 -0
  34. package/src/components/AnnotationSettings.jsx +31 -0
  35. package/src/components/AnnotationsOverlay.jsx +328 -0
  36. package/src/components/App.jsx +34 -0
  37. package/src/components/AppProviders.jsx +129 -0
  38. package/src/components/AttributionPanel.jsx +78 -0
  39. package/src/components/AudioViewer.jsx +39 -0
  40. package/src/components/BackgroundPluginArea.jsx +9 -0
  41. package/src/components/Branding.jsx +33 -0
  42. package/src/components/CanvasAnnotations.jsx +125 -0
  43. package/src/components/CanvasInfo.jsx +46 -0
  44. package/src/components/CanvasLayers.jsx +367 -0
  45. package/src/components/ChangeThemeDialog.jsx +65 -0
  46. package/src/components/CollapsibleSection.jsx +53 -0
  47. package/src/components/CollectionDialog.jsx +236 -0
  48. package/src/components/CollectionInfo.jsx +48 -0
  49. package/src/components/CompanionArea.jsx +140 -0
  50. package/src/components/CompanionWindow.jsx +228 -0
  51. package/src/components/CompanionWindowFactory.jsx +38 -0
  52. package/src/components/CompanionWindowSection.jsx +11 -0
  53. package/src/components/CustomPanel.jsx +22 -0
  54. package/src/components/ErrorContent.jsx +65 -0
  55. package/src/components/ErrorDialog.jsx +47 -0
  56. package/src/components/FullScreenButton.jsx +47 -0
  57. package/src/components/GalleryView.jsx +36 -0
  58. package/src/components/GalleryViewThumbnail.jsx +160 -0
  59. package/src/components/IIIFAuthentication.jsx +144 -0
  60. package/src/components/IIIFDropTarget.jsx +168 -0
  61. package/src/components/IIIFIFrameCommunication.jsx +45 -0
  62. package/src/components/IIIFResourceLabel.jsx +26 -0
  63. package/src/components/IIIFThumbnail.jsx +214 -0
  64. package/src/components/ImageFailureMessage.jsx +42 -0
  65. package/src/components/LabelValueMetadata.jsx +46 -0
  66. package/src/components/LanguageSettings.jsx +46 -0
  67. package/src/components/LayersPanel.jsx +24 -0
  68. package/src/components/LocalePicker.jsx +56 -0
  69. package/src/components/ManifestForm.jsx +79 -0
  70. package/src/components/ManifestInfo.jsx +67 -0
  71. package/src/components/ManifestListItem.jsx +209 -0
  72. package/src/components/ManifestListItemError.jsx +53 -0
  73. package/src/components/ManifestRelatedLinks.jsx +154 -0
  74. package/src/components/MinimalWindow.jsx +104 -0
  75. package/src/components/MiradorMenuButton.jsx +71 -0
  76. package/src/components/MosaicRenderPreview.jsx +16 -0
  77. package/src/components/NestedMenu.jsx +42 -0
  78. package/src/components/NewBrowserWindow.jsx +34 -0
  79. package/src/components/OpenSeadragonComponent.jsx +258 -0
  80. package/src/components/OpenSeadragonTileSource.jsx +105 -0
  81. package/src/components/OpenSeadragonViewer.jsx +161 -0
  82. package/src/components/PluginHook.jsx +27 -0
  83. package/src/components/PrimaryWindow.jsx +115 -0
  84. package/src/components/SanitizedHtml.jsx +37 -0
  85. package/src/components/ScrollIndicatedDialogContent.jsx +60 -0
  86. package/src/components/ScrollTo.jsx +61 -0
  87. package/src/components/SearchHit.jsx +220 -0
  88. package/src/components/SearchPanel.jsx +80 -0
  89. package/src/components/SearchPanelControls.jsx +174 -0
  90. package/src/components/SearchPanelNavigation.jsx +84 -0
  91. package/src/components/SearchResults.jsx +138 -0
  92. package/src/components/SelectCollection.jsx +44 -0
  93. package/src/components/SidebarIndexItem.jsx +11 -0
  94. package/src/components/SidebarIndexList.jsx +73 -0
  95. package/src/components/SidebarIndexTableOfContents.jsx +170 -0
  96. package/src/components/SidebarIndexThumbnail.jsx +22 -0
  97. package/src/components/TextViewer.jsx +37 -0
  98. package/src/components/ThumbnailCanvasGrouping.jsx +122 -0
  99. package/src/components/ThumbnailNavigation.jsx +231 -0
  100. package/src/components/VideoViewer.jsx +35 -0
  101. package/src/components/ViewerInfo.jsx +55 -0
  102. package/src/components/ViewerNavigation.jsx +72 -0
  103. package/src/components/Window.jsx +150 -0
  104. package/src/components/WindowAuthenticationBar.jsx +176 -0
  105. package/src/components/WindowCanvasNavigationControls.jsx +91 -0
  106. package/src/components/WindowList.jsx +71 -0
  107. package/src/components/WindowListButton.jsx +57 -0
  108. package/src/components/WindowSideBar.jsx +48 -0
  109. package/src/components/WindowSideBarAnnotationsPanel.jsx +51 -0
  110. package/src/components/WindowSideBarButtons.jsx +151 -0
  111. package/src/components/WindowSideBarCanvasPanel.jsx +165 -0
  112. package/src/components/WindowSideBarCollectionPanel.jsx +179 -0
  113. package/src/components/WindowSideBarInfoPanel.jsx +67 -0
  114. package/src/components/WindowThumbnailSettings.jsx +130 -0
  115. package/src/components/WindowTopBar.jsx +125 -0
  116. package/src/components/WindowTopBarPluginArea.jsx +8 -0
  117. package/src/components/WindowTopBarPluginMenu.jsx +78 -0
  118. package/src/components/WindowTopBarTitle.jsx +73 -0
  119. package/src/components/WindowTopMenu.jsx +81 -0
  120. package/src/components/WindowTopMenuButton.jsx +49 -0
  121. package/src/components/WindowViewSettings.jsx +95 -0
  122. package/src/components/WindowViewer.jsx +26 -0
  123. package/src/components/Workspace.jsx +124 -0
  124. package/src/components/WorkspaceAdd.jsx +221 -0
  125. package/src/components/WorkspaceAddButton.jsx +73 -0
  126. package/src/components/WorkspaceArea.jsx +66 -0
  127. package/src/components/WorkspaceControlPanel.jsx +85 -0
  128. package/src/components/WorkspaceControlPanelButtons.jsx +20 -0
  129. package/src/components/WorkspaceDialog.jsx +11 -0
  130. package/src/components/WorkspaceElastic.jsx +88 -0
  131. package/src/components/WorkspaceElasticWindow.jsx +79 -0
  132. package/src/components/WorkspaceExport.jsx +99 -0
  133. package/src/components/WorkspaceImport.jsx +89 -0
  134. package/src/components/WorkspaceMenu.jsx +126 -0
  135. package/src/components/WorkspaceMenuButton.jsx +42 -0
  136. package/src/components/WorkspaceMosaic.jsx +149 -0
  137. package/src/components/WorkspaceOptionsButton.jsx +35 -0
  138. package/src/components/WorkspaceOptionsMenu.jsx +112 -0
  139. package/src/components/WorkspaceSelectionDialog.jsx +165 -0
  140. package/src/components/ZoomControls.jsx +57 -0
  141. package/src/components/icons/BookViewIcon.jsx +14 -0
  142. package/src/components/icons/CanvasIndexIcon.jsx +14 -0
  143. package/src/components/icons/GalleryViewIcon.jsx +17 -0
  144. package/src/components/icons/MiradorIcon.jsx +14 -0
  145. package/src/components/icons/RestoreZoomIcon.jsx +15 -0
  146. package/src/components/icons/ThumbnailNavigationBottomIcon.jsx +15 -0
  147. package/src/components/icons/ThumbnailNavigationRightIcon.jsx +16 -0
  148. package/src/components/icons/WindowMaxIcon.jsx +15 -0
  149. package/src/components/icons/WindowMinIcon.jsx +15 -0
  150. package/src/components/icons/WindowOptionsIcon.jsx +16 -0
  151. package/src/components/icons/WorkspaceTypeElasticIcon.jsx +157 -0
  152. package/src/components/icons/WorkspaceTypeMosaicIcon.jsx +162 -0
  153. package/src/components/icons/index.js +27 -0
  154. package/src/components/index.js +108 -0
  155. package/src/config/css-ns.js +10 -0
  156. package/src/config/index.js +2 -0
  157. package/src/config/settings.js +607 -0
  158. package/src/containers/AnnotationSettings.js +27 -0
  159. package/src/containers/AnnotationsOverlay.js +51 -0
  160. package/src/containers/AppProviders.js +20 -0
  161. package/src/containers/AttributionPanel.js +20 -0
  162. package/src/containers/AudioViewer.js +16 -0
  163. package/src/containers/BackgroundPluginArea.js +4 -0
  164. package/src/containers/Branding.js +4 -0
  165. package/src/containers/CanvasAnnotations.js +32 -0
  166. package/src/containers/CanvasInfo.js +20 -0
  167. package/src/containers/CanvasLayers.js +25 -0
  168. package/src/containers/ChangeThemeDialog.js +29 -0
  169. package/src/containers/CollapsibleSection.js +3 -0
  170. package/src/containers/CollectionDialog.js +48 -0
  171. package/src/containers/CollectionInfo.js +29 -0
  172. package/src/containers/CompanionArea.js +22 -0
  173. package/src/containers/CompanionWindow.js +40 -0
  174. package/src/containers/CompanionWindowFactory.js +23 -0
  175. package/src/containers/CustomPanel.js +13 -0
  176. package/src/containers/ErrorContent.js +20 -0
  177. package/src/containers/ErrorDialog.js +28 -0
  178. package/src/containers/FullScreenButton.js +22 -0
  179. package/src/containers/GalleryView.js +23 -0
  180. package/src/containers/GalleryViewThumbnail.js +51 -0
  181. package/src/containers/IIIFAuthentication.js +86 -0
  182. package/src/containers/IIIFThumbnail.js +17 -0
  183. package/src/containers/LabelValueMetadata.js +14 -0
  184. package/src/containers/LanguageSettings.js +26 -0
  185. package/src/containers/LayersPanel.js +16 -0
  186. package/src/containers/LocalePicker.js +3 -0
  187. package/src/containers/ManifestForm.js +16 -0
  188. package/src/containers/ManifestInfo.js +29 -0
  189. package/src/containers/ManifestListItem.js +52 -0
  190. package/src/containers/ManifestListItemError.js +15 -0
  191. package/src/containers/ManifestRelatedLinks.js +28 -0
  192. package/src/containers/MinimalWindow.js +25 -0
  193. package/src/containers/MiradorMenuButton.js +7 -0
  194. package/src/containers/MosaicRenderPreview.js +14 -0
  195. package/src/containers/OpenSeadragonViewer.js +59 -0
  196. package/src/containers/PrimaryWindow.js +27 -0
  197. package/src/containers/SanitizedHtml.js +3 -0
  198. package/src/containers/ScrollIndicatedDialogContent.js +3 -0
  199. package/src/containers/SearchHit.js +71 -0
  200. package/src/containers/SearchPanel.js +23 -0
  201. package/src/containers/SearchPanelControls.js +36 -0
  202. package/src/containers/SearchPanelNavigation.js +39 -0
  203. package/src/containers/SearchResults.js +38 -0
  204. package/src/containers/SelectCollection.js +24 -0
  205. package/src/containers/SidebarIndexItem.js +8 -0
  206. package/src/containers/SidebarIndexList.js +28 -0
  207. package/src/containers/SidebarIndexTableOfContents.js +31 -0
  208. package/src/containers/SidebarIndexThumbnail.js +18 -0
  209. package/src/containers/TextViewer.js +19 -0
  210. package/src/containers/ThumbnailCanvasGrouping.js +29 -0
  211. package/src/containers/ThumbnailNavigation.js +48 -0
  212. package/src/containers/VideoViewer.js +16 -0
  213. package/src/containers/ViewerInfo.js +30 -0
  214. package/src/containers/ViewerNavigation.js +31 -0
  215. package/src/containers/Window.js +45 -0
  216. package/src/containers/WindowAuthenticationBar.js +7 -0
  217. package/src/containers/WindowCanvasNavigationControls.js +15 -0
  218. package/src/containers/WindowList.js +30 -0
  219. package/src/containers/WindowListButton.js +15 -0
  220. package/src/containers/WindowSideBar.js +20 -0
  221. package/src/containers/WindowSideBarAnnotationsPanel.js +23 -0
  222. package/src/containers/WindowSideBarButtons.js +75 -0
  223. package/src/containers/WindowSideBarCanvasPanel.js +50 -0
  224. package/src/containers/WindowSideBarCollectionPanel.js +48 -0
  225. package/src/containers/WindowSideBarInfoPanel.js +35 -0
  226. package/src/containers/WindowThumbnailSettings.js +31 -0
  227. package/src/containers/WindowTopBar.js +39 -0
  228. package/src/containers/WindowTopBarPluginArea.js +8 -0
  229. package/src/containers/WindowTopBarPluginMenu.js +7 -0
  230. package/src/containers/WindowTopBarTitle.js +17 -0
  231. package/src/containers/WindowTopMenu.js +28 -0
  232. package/src/containers/WindowTopMenuButton.js +7 -0
  233. package/src/containers/WindowViewSettings.js +30 -0
  234. package/src/containers/WindowViewer.js +10 -0
  235. package/src/containers/Workspace.js +36 -0
  236. package/src/containers/WorkspaceAdd.js +27 -0
  237. package/src/containers/WorkspaceAddButton.js +30 -0
  238. package/src/containers/WorkspaceArea.js +21 -0
  239. package/src/containers/WorkspaceControlPanel.js +10 -0
  240. package/src/containers/WorkspaceControlPanelButtons.js +7 -0
  241. package/src/containers/WorkspaceElastic.js +41 -0
  242. package/src/containers/WorkspaceElasticWindow.js +36 -0
  243. package/src/containers/WorkspaceExport.js +18 -0
  244. package/src/containers/WorkspaceImport.js +19 -0
  245. package/src/containers/WorkspaceMenu.js +30 -0
  246. package/src/containers/WorkspaceMenuButton.js +10 -0
  247. package/src/containers/WorkspaceMosaic.js +32 -0
  248. package/src/containers/WorkspaceOptionsButton.js +7 -0
  249. package/src/containers/WorkspaceOptionsMenu.js +3 -0
  250. package/src/containers/WorkspaceSelectionDialog.js +26 -0
  251. package/src/containers/ZoomControls.js +26 -0
  252. package/src/containers/index.js +94 -0
  253. package/src/contexts/FailedImageContext.js +8 -0
  254. package/src/contexts/FailedImageProvider.jsx +34 -0
  255. package/src/contexts/FullScreenContext.js +5 -0
  256. package/src/contexts/LocaleContext.js +5 -0
  257. package/src/contexts/OpenSeadragonViewerContext.js +5 -0
  258. package/src/contexts/WorkspaceContext.js +5 -0
  259. package/src/contexts/index.js +4 -0
  260. package/src/extend/PluginContext.js +5 -0
  261. package/src/extend/PluginProvider.jsx +22 -0
  262. package/src/extend/index.js +9 -0
  263. package/src/extend/pluginMapping.js +44 -0
  264. package/src/extend/pluginPreprocessing.js +45 -0
  265. package/src/extend/pluginValidation.js +58 -0
  266. package/src/extend/usePlugins.js +13 -0
  267. package/src/extend/withPlugins.jsx +46 -0
  268. package/src/hooks/index.js +4 -0
  269. package/src/hooks/useCanvasWorldService.js +10 -0
  270. package/src/hooks/useThumbnailService.js +8 -0
  271. package/src/i18n.js +71 -0
  272. package/src/index.js +18 -0
  273. package/src/init.js +20 -0
  274. package/src/lib/AnnotationFactory.js +23 -0
  275. package/src/lib/AnnotationItem.js +123 -0
  276. package/src/lib/AnnotationList.js +31 -0
  277. package/src/lib/AnnotationPage.js +41 -0
  278. package/src/lib/AnnotationResource.js +122 -0
  279. package/src/lib/CanvasAnnotationDisplay.js +148 -0
  280. package/src/lib/CanvasGroupings.js +55 -0
  281. package/src/lib/CanvasWorld.js +214 -0
  282. package/src/lib/CompanionWindowRegistry.js +23 -0
  283. package/src/lib/FullScreenHandle.jsx +76 -0
  284. package/src/lib/MiradorCanvas.js +211 -0
  285. package/src/lib/MiradorManifest.js +44 -0
  286. package/src/lib/MiradorViewer.jsx +53 -0
  287. package/src/lib/MosaicLayout.js +77 -0
  288. package/src/lib/OpenSeadragonCanvasOverlay.js +114 -0
  289. package/src/lib/ThumbnailFactory.js +310 -0
  290. package/src/lib/TruncatedHit.js +34 -0
  291. package/src/lib/asArray.js +11 -0
  292. package/src/lib/htmlRules.js +28 -0
  293. package/src/lib/iiif.js +12 -0
  294. package/src/lib/index.js +23 -0
  295. package/src/lib/readImageMetadata.js +21 -0
  296. package/src/lib/svgShapesToPath.js +49 -0
  297. package/src/locales/README.md +60 -0
  298. package/src/locales/ar/translation.json +141 -0
  299. package/src/locales/bg/translation.json +164 -0
  300. package/src/locales/de/translation.json +169 -0
  301. package/src/locales/en/translation.json +170 -0
  302. package/src/locales/et/translation.json +164 -0
  303. package/src/locales/fa/translation.json +164 -0
  304. package/src/locales/fr/translation.json +158 -0
  305. package/src/locales/hr/translation.json +164 -0
  306. package/src/locales/hu/translation.json +166 -0
  307. package/src/locales/it/translation.json +162 -0
  308. package/src/locales/ja/translation.json +156 -0
  309. package/src/locales/kr/translation.json +162 -0
  310. package/src/locales/lt/translation.json +153 -0
  311. package/src/locales/nbNo/translation.json +162 -0
  312. package/src/locales/nl/translation.json +139 -0
  313. package/src/locales/pl/translation.json +162 -0
  314. package/src/locales/ptBr/translation.json +133 -0
  315. package/src/locales/sr/translation.json +155 -0
  316. package/src/locales/sv/translation.json +157 -0
  317. package/src/locales/ta/translation.json +167 -0
  318. package/src/locales/vi/translation.json +156 -0
  319. package/src/locales/zhCn/translation.json +163 -0
  320. package/src/locales/zhTw/translation.json +163 -0
  321. package/src/plugins/OSDReferences.js +15 -0
  322. package/src/plugins/index.js +1 -0
  323. package/src/state/actions/action-types.js +76 -0
  324. package/src/state/actions/annotation.js +123 -0
  325. package/src/state/actions/auth.js +109 -0
  326. package/src/state/actions/canvas.js +65 -0
  327. package/src/state/actions/catalog.js +22 -0
  328. package/src/state/actions/companionWindow.js +107 -0
  329. package/src/state/actions/config.js +49 -0
  330. package/src/state/actions/elasticLayout.js +10 -0
  331. package/src/state/actions/errors.js +22 -0
  332. package/src/state/actions/index.js +19 -0
  333. package/src/state/actions/infoResponse.js +90 -0
  334. package/src/state/actions/layers.js +14 -0
  335. package/src/state/actions/manifest.js +65 -0
  336. package/src/state/actions/search.js +97 -0
  337. package/src/state/actions/window.js +209 -0
  338. package/src/state/actions/workspace.js +84 -0
  339. package/src/state/createPluggableStore.js +24 -0
  340. package/src/state/createStore.js +33 -0
  341. package/src/state/index.js +21 -0
  342. package/src/state/reducers/accessTokens.js +59 -0
  343. package/src/state/reducers/annotations.js +48 -0
  344. package/src/state/reducers/auth.js +43 -0
  345. package/src/state/reducers/catalog.js +30 -0
  346. package/src/state/reducers/companionWindows.js +49 -0
  347. package/src/state/reducers/config.js +39 -0
  348. package/src/state/reducers/elasticLayout.js +29 -0
  349. package/src/state/reducers/errors.js +51 -0
  350. package/src/state/reducers/index.js +15 -0
  351. package/src/state/reducers/infoResponses.js +61 -0
  352. package/src/state/reducers/layers.js +23 -0
  353. package/src/state/reducers/manifests.js +52 -0
  354. package/src/state/reducers/rootReducer.js +44 -0
  355. package/src/state/reducers/search.js +145 -0
  356. package/src/state/reducers/utils.js +45 -0
  357. package/src/state/reducers/viewers.js +42 -0
  358. package/src/state/reducers/windows.js +185 -0
  359. package/src/state/reducers/workspace.js +111 -0
  360. package/src/state/sagas/annotations.js +48 -0
  361. package/src/state/sagas/app.js +56 -0
  362. package/src/state/sagas/auth.js +151 -0
  363. package/src/state/sagas/iiif.js +233 -0
  364. package/src/state/sagas/index.js +30 -0
  365. package/src/state/sagas/windows.js +293 -0
  366. package/src/state/selectors/annotations.js +138 -0
  367. package/src/state/selectors/auth.js +100 -0
  368. package/src/state/selectors/canvases.js +260 -0
  369. package/src/state/selectors/companionWindows.js +182 -0
  370. package/src/state/selectors/config.js +100 -0
  371. package/src/state/selectors/getters.js +90 -0
  372. package/src/state/selectors/index.js +17 -0
  373. package/src/state/selectors/layers.js +79 -0
  374. package/src/state/selectors/manifests.js +433 -0
  375. package/src/state/selectors/ranges.js +147 -0
  376. package/src/state/selectors/searches.js +249 -0
  377. package/src/state/selectors/sequences.js +134 -0
  378. package/src/state/selectors/thumbnails.js +28 -0
  379. package/src/state/selectors/utils.js +18 -0
  380. package/src/state/selectors/viewer.js +19 -0
  381. package/src/state/selectors/windows.js +98 -0
  382. package/src/state/selectors/workspace.js +52 -0
  383. package/src/state/selectors/wrappers.js +15 -0
  384. package/src/styles/react-mosaic-component.js +288 -0
@@ -0,0 +1,147 @@
1
+ import { createSelector } from 'reselect';
2
+ import union from 'lodash/union';
3
+ import without from 'lodash/without';
4
+ import { Utils } from 'manifesto.js';
5
+ import { getVisibleCanvasIds } from './canvases';
6
+ import { getCompanionWindow } from './companionWindows';
7
+ import { getSequenceTreeStructure } from './sequences';
8
+
9
+ /** */
10
+ function rangeContainsCanvasId(range, canvasId) {
11
+ const canvasIds = range.getCanvasIds();
12
+ for (let i = 0; i < canvasIds.length; i += 1) {
13
+ if (Utils.normalisedUrlsMatch(canvasIds[i], canvasId)) {
14
+ return true;
15
+ }
16
+ }
17
+ return false;
18
+ }
19
+
20
+ /** */
21
+ function getAllParentIds(node) {
22
+ if (node.parentNode === undefined) {
23
+ return [];
24
+ }
25
+ if (node.parentNode.parentNode === undefined) {
26
+ return [node.parentNode.id];
27
+ }
28
+ return [...getAllParentIds(node.parentNode), node.parentNode.id];
29
+ }
30
+
31
+ /** */
32
+ function getVisibleNodeIdsInSubTree(nodes, canvasIds) {
33
+ return nodes.reduce((nodeIdAcc, node) => {
34
+ const result = [];
35
+ result.push(...nodeIdAcc);
36
+ const nodeContainsVisibleCanvas = canvasIds.reduce(
37
+ (acc, canvasId) => acc || rangeContainsCanvasId(node.data, canvasId),
38
+ false,
39
+ );
40
+ const subTreeVisibleNodeIds = node.nodes.length > 0 ? getVisibleNodeIdsInSubTree(node.nodes, canvasIds) : [];
41
+ result.push(...subTreeVisibleNodeIds);
42
+ if (nodeContainsVisibleCanvas || subTreeVisibleNodeIds.length > 0) {
43
+ result.push({
44
+ containsVisibleCanvas: nodeContainsVisibleCanvas,
45
+ descendantsContainVisibleCanvas: subTreeVisibleNodeIds.length > 0,
46
+ id: node.id,
47
+ leaf: node.nodes.length === 0,
48
+ parentIds: getAllParentIds(node),
49
+ });
50
+ }
51
+ return result;
52
+ }, []);
53
+ }
54
+
55
+ /** */
56
+ const getVisibleLeafAndBranchNodeIds = createSelector([getSequenceTreeStructure, getVisibleCanvasIds], (tree, canvasIds) => {
57
+ if (canvasIds.length === 0 || !tree) return [];
58
+ return getVisibleNodeIdsInSubTree(tree.nodes, canvasIds);
59
+ });
60
+
61
+ /**
62
+ * Returns visible node ids.
63
+ * @param {object} state
64
+ * @param {object} props
65
+ * @param {string} props.windowId
66
+ * @returns {Array}
67
+ */
68
+ export const getVisibleNodeIds = createSelector([getVisibleLeafAndBranchNodeIds], (visibleLeafAndBranchNodeIds) =>
69
+ visibleLeafAndBranchNodeIds.map((item) => item.id),
70
+ );
71
+
72
+ const getVisibleBranchNodeIds = createSelector([getVisibleLeafAndBranchNodeIds], (visibleLeafAndBranchNodeIds) =>
73
+ visibleLeafAndBranchNodeIds.reduce(
74
+ (acc, item) => (item.leaf || !item.descendantsContainVisibleCanvas ? acc : [...acc, item.id]),
75
+ [],
76
+ ),
77
+ );
78
+
79
+ const getCanvasContainingNodeIds = createSelector([getVisibleLeafAndBranchNodeIds], (visibleLeafAndBranchNodeIds) =>
80
+ visibleLeafAndBranchNodeIds.reduce((acc, item) => (item.containsVisibleCanvas ? [...acc, item] : acc), []),
81
+ );
82
+
83
+ /**
84
+ * Returns ids of manually exanded nodes.
85
+ * @param {object} state
86
+ * @param {object} props
87
+ * @param {string} props.companionWindowId
88
+ * @param expanded
89
+ * @returns {Array}
90
+ */
91
+ export function getManuallyExpandedNodeIds(state, { companionWindowId }, expanded) {
92
+ const companionWindow = getCompanionWindow(state, { companionWindowId });
93
+ return companionWindow.tocNodes
94
+ ? Object.keys(companionWindow.tocNodes).reduce(
95
+ (acc, nodeId) => (companionWindow.tocNodes[nodeId].expanded === expanded ? [...acc, nodeId] : acc),
96
+ [],
97
+ )
98
+ : [];
99
+ }
100
+
101
+ /**
102
+ * Returns ids of exanded nodes.
103
+ * @param {object} state
104
+ * @param {object} props
105
+ * @param {string} props.companionWindowId
106
+ * @param {string} props.windowId
107
+ * @returns {Array}
108
+ */
109
+ export function getExpandedNodeIds(state, { companionWindowId, windowId }) {
110
+ const visibleBranchNodeIds = getVisibleBranchNodeIds(state, { companionWindowId, windowId });
111
+ const manuallyExpandedNodeIds = getManuallyExpandedNodeIds(state, { companionWindowId }, true);
112
+ const manuallyClosedNodeIds = getManuallyExpandedNodeIds(state, { companionWindowId }, false);
113
+ return without(union(manuallyExpandedNodeIds, visibleBranchNodeIds), ...manuallyClosedNodeIds);
114
+ }
115
+
116
+ /**
117
+ * Returns id of node to scroll to.
118
+ * @param {object} state
119
+ * @param {object} props
120
+ * @param {string} props.companionWindowId
121
+ * @param {string} props.windowId
122
+ * @param {string} props.manifestid
123
+ * @returns {string}
124
+ */
125
+ export function getNodeIdToScrollTo(state, { ...args }) {
126
+ const canvasContainingNodeIds = getCanvasContainingNodeIds(state, { ...args });
127
+ const collapsedNodeIds = getManuallyExpandedNodeIds(state, args, false);
128
+ if (canvasContainingNodeIds && canvasContainingNodeIds.length > 0) {
129
+ for (let i = 0; i < canvasContainingNodeIds[0].parentIds.length; i += 1) {
130
+ if (collapsedNodeIds.indexOf(canvasContainingNodeIds[0].parentIds[i]) !== -1) {
131
+ return canvasContainingNodeIds[0].parentIds[i];
132
+ }
133
+ }
134
+ return canvasContainingNodeIds[0].id;
135
+ }
136
+ return null;
137
+ }
138
+
139
+ /**
140
+ * Returns the default sidebar variant depending on whether or not ranges exist.
141
+ * @param {object} state
142
+ * @param {string}
143
+ * @returns {string}
144
+ */
145
+ export const getDefaultSidebarVariant = createSelector([getSequenceTreeStructure], (tree) =>
146
+ tree && tree.nodes && tree.nodes.length > 0 ? 'tableOfContents' : 'item',
147
+ );
@@ -0,0 +1,249 @@
1
+ import { createSelector } from 'reselect';
2
+ import { PropertyValue } from 'manifesto.js';
3
+ import AnnotationList from '../../lib/AnnotationList';
4
+ import { getCanvas, getCanvases } from './canvases';
5
+ import { getWindow } from './getters';
6
+ import { getManifestLocale } from './manifests';
7
+ import { miradorSlice, EMPTY_ARRAY, EMPTY_OBJECT } from './utils';
8
+
9
+ /**
10
+ * Get searches from state.
11
+ */
12
+ const getSearches = (state) => miradorSlice(state).searches;
13
+
14
+ /**
15
+ * Returns the search result for a specific window.
16
+ * @param {object} state
17
+ * @param {string} windowId
18
+ * @returns {object}
19
+ */
20
+ export const getSearchForWindow = createSelector([(state, { windowId }) => windowId, getSearches], (windowId, searches) => {
21
+ if (!windowId || !searches) return EMPTY_OBJECT;
22
+
23
+ return searches[windowId];
24
+ });
25
+
26
+ /**
27
+ * Returns the search result for a specific companion window.
28
+ * @param {object} state
29
+ * @param {string} companionWindowId
30
+ * @returns {object|undefined}
31
+ */
32
+ const getSearchForCompanionWindow = createSelector(
33
+ [getSearchForWindow, (state, { companionWindowId }) => companionWindowId],
34
+ (results, companionWindowId) => {
35
+ if (!results || !companionWindowId) return undefined;
36
+ return results[companionWindowId];
37
+ },
38
+ );
39
+
40
+ /**
41
+ * Returns an array of search responses for a specific companion window.
42
+ * @param {object} state
43
+ * @returns {Array}
44
+ */
45
+ const getSearchResponsesForCompanionWindow = createSelector([getSearchForCompanionWindow], (results) => {
46
+ if (!results) return EMPTY_ARRAY;
47
+ return Object.values(results.data);
48
+ });
49
+
50
+ /**
51
+ * Returns the search query for a specific companion window.
52
+ * @param {object} state
53
+ * @param {string} windowId
54
+ * @returns {string|undefined}
55
+ */
56
+ export const getSearchQuery = createSelector([getSearchForCompanionWindow], (results) => results && results.query);
57
+
58
+ /**
59
+ * Returns if search response for a companion window is fetching.
60
+ * @param {object} state
61
+ * @returns {boolean}
62
+ */
63
+ export const getSearchIsFetching = createSelector([getSearchResponsesForCompanionWindow], (results) =>
64
+ results.some((result) => result.isFetching),
65
+ );
66
+
67
+ /**
68
+ * Returns the total number of search results for a companion window.
69
+ * @param {object} state
70
+ * @param {string} windowId
71
+ * @returns {number|undefined}
72
+ */
73
+ export const getSearchNumTotal = createSelector([getSearchForCompanionWindow], (results) => {
74
+ if (!results || !results.data) return undefined;
75
+
76
+ const resultWithWithin = Object.values(results.data).find((result) => !result.isFetching && result.json && result.json.within);
77
+ return resultWithWithin?.json?.within?.total;
78
+ });
79
+
80
+ /**
81
+ * Returns the Id of the next search.
82
+ * @param {object} state
83
+ * @param {string} windowId
84
+ * @returns {number|undefined}
85
+ */
86
+ export const getNextSearchId = createSelector([getSearchForCompanionWindow], (results) => {
87
+ if (!results || !results.data) return undefined;
88
+
89
+ const resultWithAnUnresolvedNext = Object.values(results.data).find(
90
+ (result) => !result.isFetching && result.json && result.json.next && !results.data[result.json.next],
91
+ );
92
+
93
+ return resultWithAnUnresolvedNext && resultWithAnUnresolvedNext.json && resultWithAnUnresolvedNext.json.next;
94
+ });
95
+
96
+ const getSearchHitsForCompanionWindow = createSelector([getSearchResponsesForCompanionWindow], (results) =>
97
+ results.flatMap((result) => {
98
+ if (!result || !result.json || result.isFetching || !result.json.hits) return EMPTY_ARRAY;
99
+
100
+ return result.json.hits;
101
+ }),
102
+ );
103
+
104
+ export const getSearchAnnotationsForCompanionWindow = createSelector(
105
+ [getSearchResponsesForCompanionWindow],
106
+ (results) => results && searchResultsToAnnotation(results),
107
+ );
108
+
109
+ /**
110
+ * Returns sorted search hits based on canvas order.
111
+ * @param {object} state
112
+ * @param {string} manifestId
113
+ * @returns {Array}
114
+ */
115
+ export const getSortedSearchHitsForCompanionWindow = createSelector(
116
+ [getSearchHitsForCompanionWindow, getCanvases, getSearchAnnotationsForCompanionWindow],
117
+ (searchHits, canvases, annotation) => {
118
+ if (!canvases || canvases.length === 0) return EMPTY_ARRAY;
119
+ if (!searchHits || searchHits.length === 0) return EMPTY_ARRAY;
120
+ const canvasIds = canvases.map((canvas) => canvas.id);
121
+
122
+ return [].concat(searchHits).sort((a, b) => {
123
+ const hitA = annotation.resources.find((r) => r.id === a.annotations[0]);
124
+ const hitB = annotation.resources.find((r) => r.id === b.annotations[0]);
125
+ return canvasIds.indexOf(hitA.targetId) - canvasIds.indexOf(hitB.targetId);
126
+ });
127
+ },
128
+ );
129
+
130
+ /** convert search results to an annotation */
131
+ const searchResultsToAnnotation = (results) => {
132
+ const annotations = results
133
+ .map((result) => {
134
+ if (!result || !result.json || result.isFetching || !result.json.resources) return undefined;
135
+ const anno = new AnnotationList(result.json);
136
+ return {
137
+ id: anno.id,
138
+ resources: anno.resources,
139
+ };
140
+ })
141
+ .filter(Boolean);
142
+
143
+ return {
144
+ id: (annotations.find((a) => a.id) || {}).id,
145
+ resources: annotations.flatMap((a) => a.resources),
146
+ };
147
+ };
148
+
149
+ /**
150
+ * Sorts search annotations based on canvas order.
151
+ * @returns {Array}
152
+ */
153
+ export function sortSearchAnnotationsByCanvasOrder(searchAnnotations, canvases) {
154
+ if (!searchAnnotations || !searchAnnotations.resources || searchAnnotations.length === 0) return EMPTY_ARRAY;
155
+ if (!canvases || canvases.length === 0) return EMPTY_ARRAY;
156
+ const canvasIds = canvases.map((canvas) => canvas.id);
157
+
158
+ return []
159
+ .concat(searchAnnotations.resources)
160
+ .sort((annoA, annoB) => canvasIds.indexOf(annoA.targetId) - canvasIds.indexOf(annoB.targetId));
161
+ }
162
+
163
+ /**
164
+ * Returns sorted search annotations for companion window.
165
+ * @param {object} state
166
+ * @param {string} companionWindowId
167
+ * @returns {Array}
168
+ */
169
+ export const getSortedSearchAnnotationsForCompanionWindow = createSelector(
170
+ [getSearchAnnotationsForCompanionWindow, getCanvases],
171
+ (searchAnnotations, canvases) => sortSearchAnnotationsByCanvasOrder(searchAnnotations, canvases),
172
+ );
173
+
174
+ /**
175
+ * Returns sorted search annotations for window.
176
+ * @param {object} state
177
+ * @param {string} windowId
178
+ * @returns {Array}
179
+ */
180
+ export const getSearchAnnotationsForWindow = createSelector([getSearchForWindow], (results) => {
181
+ if (!results) return EMPTY_ARRAY;
182
+ const data = Object.values(results).map((r) => Object.values(r.data));
183
+
184
+ return data.map((d) => searchResultsToAnnotation(d)).filter((a) => a.resources.length > 0);
185
+ });
186
+
187
+ /**
188
+ * Returns ids of selected content search annotations.
189
+ * @param {object} state
190
+ * @param {string} windowId
191
+ * @returns {Array}
192
+ */
193
+ export const getSelectedContentSearchAnnotationIds = createSelector(
194
+ [getWindow, getSearchForCompanionWindow],
195
+ (window, search) => (search && search.selectedContentSearchAnnotationIds) || [],
196
+ );
197
+
198
+ /**
199
+ * Returns resource annotations for search hit.
200
+ * @param {object} state
201
+ * @param {string} windowId
202
+ * @returns {Array}
203
+ */
204
+ export const getResourceAnnotationForSearchHit = createSelector(
205
+ [getSearchAnnotationsForCompanionWindow, (state, { annotationUri }) => annotationUri],
206
+ (annotation, annotationUri) => annotation.resources.find((r) => r.id === annotationUri),
207
+ );
208
+
209
+ /**
210
+ * Returns annotation label.
211
+ * @param {object} state
212
+ * @param {string} windowId
213
+ * @returns {Array}
214
+ */
215
+ export const getResourceAnnotationLabel = createSelector(
216
+ [getResourceAnnotationForSearchHit, getManifestLocale],
217
+ (resourceAnnotation, locale) => {
218
+ if (!(resourceAnnotation && resourceAnnotation.resource && resourceAnnotation.resource.label)) return EMPTY_ARRAY;
219
+
220
+ return PropertyValue.parse(resourceAnnotation.resource.label).getValues(locale);
221
+ },
222
+ );
223
+
224
+ const getAnnotationById = createSelector(
225
+ [getSearchAnnotationsForWindow, (state, { annotationId }) => annotationId],
226
+ (annotations, annotationId) => {
227
+ const resourceAnnotations = annotations.flatMap((a) => a.resources);
228
+ return resourceAnnotations.find((r) => r.id === annotationId);
229
+ },
230
+ );
231
+
232
+ /**
233
+ * Returns annotation label.
234
+ * @param {object} state
235
+ * @param {string} windowId
236
+ * @returns {Array}
237
+ */
238
+ export const getCanvasForAnnotation = createSelector(
239
+ [
240
+ getAnnotationById,
241
+ (state, { windowId }) =>
242
+ (canvasId) =>
243
+ getCanvas(state, { canvasId, windowId }),
244
+ ],
245
+ (annotation, getCanvasById) => {
246
+ const canvasId = annotation && annotation.targetId;
247
+ return canvasId && getCanvasById(canvasId);
248
+ },
249
+ );
@@ -0,0 +1,134 @@
1
+ import { createSelector } from 'reselect';
2
+ import { TreeNode } from 'manifesto.js';
3
+ import { getManifestoInstance } from './manifests';
4
+ import { getWindow } from './getters';
5
+
6
+ /**
7
+ * Returns the sequences for a given windowId
8
+ * @param {object} state
9
+ * @param {object} props
10
+ * @param {string} props.windowId
11
+ * @returns {Array}
12
+ */
13
+ export const getSequences = createSelector([getManifestoInstance], (manifest) => {
14
+ if (!manifest || !manifest.getTopRanges) return null;
15
+
16
+ const topRangesOrRoot = manifest.getTopRanges();
17
+ const v2TopRanges = topRangesOrRoot.filter((r) => r.getProperty('viewingHint') === 'top');
18
+ let v3RangeSequences = [];
19
+
20
+ if (v2TopRanges.length === 0 && topRangesOrRoot.length === 1) {
21
+ v3RangeSequences = topRangesOrRoot[0].getRanges().filter((r) => r.getBehavior() === 'sequence');
22
+ }
23
+
24
+ const sequences = [].concat(
25
+ // v2: multi-sequence manifests, or v3: items
26
+ manifest.getSequences(),
27
+ // v3: all top-level ranges with behavior=sequence
28
+ v3RangeSequences,
29
+ );
30
+
31
+ return sequences;
32
+ });
33
+
34
+ /**
35
+ * Returns the sequence for a given windowId
36
+ * @param {object} state
37
+ * @param {object} props
38
+ * @param {string} props.windowId
39
+ * @returns {Array}
40
+ */
41
+ export const getSequence = createSelector(
42
+ [getSequences, getWindow, (state, { sequenceId }) => sequenceId],
43
+ (sequences, window, sequenceId) => {
44
+ if (!sequences) return null;
45
+
46
+ if (sequenceId || (window && window.sequenceId)) {
47
+ const currentSequence = sequences.find((s) => s.id === (sequenceId || window.sequenceId));
48
+
49
+ if (currentSequence) return currentSequence;
50
+ }
51
+
52
+ return sequences[0];
53
+ },
54
+ );
55
+
56
+ /**
57
+ * Return the canvas index for a certain window.
58
+ * @param {Object} state
59
+ * @param {string} windowId
60
+ * @returns {number}
61
+ */
62
+ export const getCanvasIndex = createSelector(
63
+ [getWindow, getSequence],
64
+ (window, sequence) => ((sequence && window && window.canvasId && sequence.getCanvasById(window.canvasId)) || {}).index || 0,
65
+ );
66
+
67
+ /**
68
+ * Returns the viewing hint for the first sequence in the manifest or the manifest.
69
+ * @param {object} state
70
+ * @param {object} props
71
+ * @param {string} props.manifestId
72
+ * @param {string} props.windowId
73
+ * @returns {number}
74
+ */
75
+ export const getSequenceViewingHint = createSelector([getSequence, getManifestoInstance], (sequence, manifest) => {
76
+ if (!manifest) return null;
77
+ const viewingHint = (sequence && sequence.getViewingHint()) || manifest.getViewingHint();
78
+ if (viewingHint) return viewingHint;
79
+ return null;
80
+ });
81
+
82
+ /**
83
+ * @param {object} state
84
+ * @param {string} windowId
85
+ * @return {string|null}
86
+ */
87
+ export const getSequenceViewingDirection = createSelector(
88
+ [getWindow, getSequence, getManifestoInstance],
89
+ (window, sequence, manifest) => {
90
+ const viewingDirection =
91
+ (window && window.viewingDirection) ||
92
+ (sequence && sequence.getViewingDirection()) ||
93
+ (manifest && manifest.getViewingDirection());
94
+ if (viewingDirection) return viewingDirection;
95
+ return null;
96
+ },
97
+ );
98
+
99
+ /**
100
+ * Returns the behaviors viewing hint for the manifest
101
+ * @param {Object} state
102
+ * @param {Object} props
103
+ * @param {string} props.manifestId
104
+ * @param {string} props.windowId
105
+ * @return {number}
106
+ */
107
+ export const getSequenceBehaviors = createSelector([getSequence, getManifestoInstance], (sequence, manifest) => {
108
+ if (!manifest || !sequence) return [];
109
+ const sequenceBehaviors = sequence && sequence.getProperty('behavior');
110
+
111
+ if (sequenceBehaviors) {
112
+ if (Array.isArray(sequenceBehaviors)) return sequenceBehaviors;
113
+ return [sequenceBehaviors];
114
+ }
115
+
116
+ const behaviors = manifest.getProperty('behavior');
117
+
118
+ if (!behaviors) return [];
119
+ if (Array.isArray(behaviors)) return behaviors;
120
+ return [behaviors];
121
+ });
122
+
123
+ /**
124
+ * Retruns a sequence tree structure.
125
+ * @param {object} state
126
+ * @param {object} props
127
+ * @param {string} props.windowId
128
+ * @returns {object}
129
+ */
130
+ export const getSequenceTreeStructure = createSelector([getSequence, getManifestoInstance], (sequence, manifest) => {
131
+ if (sequence && sequence.getProperty('type') && sequence.isRange()) return sequence.getTree(new TreeNode('root'));
132
+
133
+ return manifest && manifest.getDefaultTree();
134
+ });
@@ -0,0 +1,28 @@
1
+ import { createSelector } from 'reselect';
2
+
3
+ import { getThumbnailsConfig } from './config';
4
+ import { getMiradorCanvasWrapper, getMiradorManifestWrapper } from './wrappers';
5
+
6
+ import { ThumbnailFactory } from '../../lib/ThumbnailFactory';
7
+
8
+ /** memoize thumbnail opts for selector */
9
+ export const getIiifThumbnailOpts = createSelector(
10
+ [getThumbnailsConfig, (state, maxHeight, maxWidth) => maxHeight, (state, maxHeight, maxWidth) => maxWidth],
11
+ (thumbnails, maxHeight, maxWidth) => ({
12
+ maxHeight,
13
+ maxWidth,
14
+ preferredFormats: thumbnails.preferredFormats,
15
+ }),
16
+ );
17
+
18
+ /**
19
+ * Instantiate a thumbnail factory.
20
+ * @param {object} state
21
+ * @param {integer} maxHeight
22
+ * @param {integer} maxWidth
23
+ * @return {object}
24
+ */
25
+ export const getThumbnailFactory = createSelector(
26
+ [getIiifThumbnailOpts, getMiradorCanvasWrapper, getMiradorManifestWrapper],
27
+ (iiifOpts, getMiradorCanvas, getMiradorManifest) => new ThumbnailFactory(iiifOpts, { getMiradorCanvas, getMiradorManifest }),
28
+ );
@@ -0,0 +1,18 @@
1
+ import settings from '../../config/settings';
2
+
3
+ /**
4
+ * Returns Mirador's portion of the global Redux state.
5
+ * If settings.state.slice is set (e.g. 'mirador'), Mirador's state is read from state[slice],
6
+ * allowing Mirador to coexist in a shared Redux store.
7
+ * Otherwise, Mirador is assumed to own the entire Redux state.
8
+ * @param {object} state
9
+ * @returns {object}
10
+ */
11
+ export function miradorSlice(state) {
12
+ if (settings.state.slice) return state[settings.state.slice];
13
+
14
+ return state;
15
+ }
16
+
17
+ export const EMPTY_ARRAY = Object.freeze([]);
18
+ export const EMPTY_OBJECT = Object.freeze({});
@@ -0,0 +1,19 @@
1
+ import { createSelector } from 'reselect';
2
+ import CanvasWorld from '../../lib/CanvasWorld';
3
+
4
+ import { getVisibleCanvases } from './canvases';
5
+ import { getLayersForVisibleCanvases } from './layers';
6
+ import { getSequenceViewingDirection } from './sequences';
7
+ import { getMiradorCanvasWrapper } from './wrappers';
8
+
9
+ /**
10
+ * Instantiate a manifesto instance.
11
+ * @param {object} state
12
+ * @param {string} windowId
13
+ * @return {object}
14
+ */
15
+ export const getCurrentCanvasWorld = createSelector(
16
+ [getVisibleCanvases, getLayersForVisibleCanvases, getSequenceViewingDirection, getMiradorCanvasWrapper],
17
+ (canvases, layers, viewingDirection, getMiradorCanvas) =>
18
+ new CanvasWorld(canvases.map(getMiradorCanvas), layers, viewingDirection),
19
+ );
@@ -0,0 +1,98 @@
1
+ import { createSelector } from 'reselect';
2
+ import { getManifestTitle } from './manifests';
3
+ import { getConfig } from './config';
4
+ import { getWindows, getWindow, getWindowIds } from './getters';
5
+ import { getWorkspaceType } from './workspace';
6
+ import { getSequenceViewingHint, getSequenceBehaviors } from './sequences';
7
+
8
+ /**
9
+ * Returns the window configuration based.
10
+ * @param {object} state
11
+ * @param {string} windowId
12
+ * @returns {object}
13
+ */
14
+ export const getWindowConfig = createSelector([getConfig, getWindow], ({ window: defaultConfig }, windowConfig = {}) => ({
15
+ ...defaultConfig,
16
+ ...windowConfig,
17
+ }));
18
+
19
+ /**
20
+ * Returns the manifest titles for all open windows.
21
+ * @param {object} state
22
+ * @returns {object}
23
+ */
24
+ export function getWindowTitles(state) {
25
+ const result = {};
26
+
27
+ Object.keys(getWindows(state)).forEach((windowId) => {
28
+ result[windowId] = getManifestTitle(state, { windowId });
29
+ });
30
+
31
+ return result;
32
+ }
33
+
34
+ /**
35
+ * Returns an array containing the maximized windowIds.
36
+ * @param {object} state
37
+ * @return {Array}
38
+ */
39
+ export const getMaximizedWindowsIds = createSelector([getWindows], (windows) =>
40
+ Object.values(windows)
41
+ .filter((window) => window.maximized === true)
42
+ .map((window) => window.id),
43
+ );
44
+
45
+ /**
46
+ * Returns type of view in a certain window.
47
+ * @param {object} state
48
+ * @param {object} props
49
+ * @param {string} props.manifestId
50
+ * @param {string} props.windowId
51
+ * @param {string}
52
+ */
53
+ export const getWindowViewType = createSelector(
54
+ [getWindow, getWindowConfig, getSequenceViewingHint, getSequenceBehaviors],
55
+ (window, { views = [], defaultView }, manifestViewingHint, manifestBehaviors) => {
56
+ if (window && window.view) return window.view;
57
+
58
+ const config = (views || []).find(
59
+ (view) => view.behaviors && view.behaviors.some((b) => manifestViewingHint === b || manifestBehaviors.includes(b)),
60
+ );
61
+
62
+ return (config && config.key) || defaultView;
63
+ },
64
+ );
65
+
66
+ /**
67
+ * Returns the window view type for a given window.
68
+ * @param {object} state
69
+ * @param {string} windowId
70
+ * @returns {string} 'single' | 'book' | 'scroll' | 'gallery'
71
+ */
72
+ export const getAllowedWindowViewTypes = createSelector(
73
+ [getSequenceViewingHint, getSequenceBehaviors, getWindowConfig],
74
+ (manifestViewingHint, manifestBehaviors, { views = [], defaultView }) =>
75
+ (views || []).reduce((allowedViews, view) => {
76
+ if (
77
+ view.key === defaultView ||
78
+ !view.behaviors ||
79
+ view.behaviors.some((b) => manifestViewingHint === b || manifestBehaviors.includes(b))
80
+ )
81
+ allowedViews.push(view.key);
82
+ return allowedViews;
83
+ }, []),
84
+ );
85
+
86
+ /**
87
+ * Return the draggability of a window.
88
+ * @param {object} state
89
+ * @param {object} props
90
+ * @returns {boolean}
91
+ */
92
+ export const getWindowDraggability = createSelector(
93
+ [getWorkspaceType, getWindow, (state) => getWindowIds(state).length > 1],
94
+ (workspaceType, window, manyWindows) => {
95
+ if (workspaceType === 'elastic') return true;
96
+ return manyWindows && window && window.maximized === false;
97
+ },
98
+ );