@nulib/clover 0.0.0-stage → 4.0.0-beta.0
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 +9 -0
- package/README.md +120 -2
- package/dist/components/Annotations/Annotations.mjs +674 -0
- package/dist/components/Annotations/EntryBodies.mjs +52 -0
- package/dist/components/Annotations/languages.mjs +43 -0
- package/dist/components/Body/Body.mjs +51 -0
- package/dist/components/Body/BodyAlert.mjs +25 -0
- package/dist/components/Body/Caption.mjs +90 -0
- package/dist/components/Body/CaptionDetails.mjs +50 -0
- package/dist/components/Body/Pending.mjs +9 -0
- package/dist/components/Body/glyphs.mjs +66 -0
- package/dist/components/Body/renderers.mjs +30 -0
- package/dist/components/Body/useControlsVisibility.mjs +204 -0
- package/dist/components/Body/useNearViewport.mjs +27 -0
- package/dist/components/Canvas/AnnotationMenu.mjs +128 -0
- package/dist/components/Canvas/AnnotationState.mjs +338 -0
- package/dist/components/Canvas/Annotations.mjs +497 -0
- package/dist/components/Canvas/CanvasView.mjs +669 -0
- package/dist/components/Canvas/ChoiceMenu.mjs +77 -0
- package/dist/components/Canvas/Connected.mjs +228 -0
- package/dist/components/Canvas/ControlMenu.mjs +67 -0
- package/dist/components/Canvas/Controls.mjs +233 -0
- package/dist/components/Canvas/FrameAnimation.mjs +344 -0
- package/dist/components/Canvas/LoadedCanvas.mjs +177 -0
- package/dist/components/Canvas/Placeholder.mjs +105 -0
- package/dist/components/Canvas/fromManifest.mjs +44 -0
- package/dist/components/Canvas/index.mjs +19 -0
- package/dist/components/Canvas/layout.mjs +369 -0
- package/dist/components/Canvas/media/MediaBody.mjs +285 -0
- package/dist/components/Canvas/media/Player.mjs +193 -0
- package/dist/components/Canvas/media/Transport.mjs +511 -0
- package/dist/components/Canvas/media/TransportButton.mjs +39 -0
- package/dist/components/Canvas/media/useBarHeight.mjs +28 -0
- package/dist/components/Canvas/media/useCaptionTracks.mjs +131 -0
- package/dist/components/Canvas/media/useMediaController.mjs +77 -0
- package/dist/components/Canvas/media/useMediaElement.mjs +100 -0
- package/dist/components/Canvas/panClearOfControls.mjs +92 -0
- package/dist/components/Canvas/rendererSurface.mjs +6 -0
- package/dist/components/Canvas/surface.mjs +5 -0
- package/dist/components/Canvas/track.mjs +43 -0
- package/dist/components/Canvas/useSvgReader.mjs +23 -0
- package/dist/components/Collection/Collection.mjs +76 -0
- package/dist/components/CollectionSelect/CollectionSelect.mjs +114 -0
- package/dist/components/Contents/Contents.mjs +120 -0
- package/dist/components/Download/Download.mjs +105 -0
- package/dist/components/Items/Item.mjs +184 -0
- package/dist/components/Items/Items.mjs +455 -0
- package/dist/components/Items/Pager.mjs +190 -0
- package/dist/components/Items/StandaloneItems.mjs +80 -0
- package/dist/components/Items/clamped.mjs +90 -0
- package/dist/components/Label/Label.mjs +39 -0
- package/dist/components/Map/LoadedMap.mjs +26 -0
- package/dist/components/Map/Map.mjs +38 -0
- package/dist/components/Map/MapView.mjs +538 -0
- package/dist/components/Map/basemap.mjs +50 -0
- package/dist/components/Map/overlayImage.mjs +17 -0
- package/dist/components/Panel/About.mjs +143 -0
- package/dist/components/Panel/Panel.mjs +259 -0
- package/dist/components/Panel/PanelToggle.mjs +43 -0
- package/dist/components/Panel/PartOfManifest.mjs +52 -0
- package/dist/components/Primitives/Primitives.mjs +263 -0
- package/dist/components/Primitives/resource.mjs +11 -0
- package/dist/components/Provider/Provider.mjs +174 -0
- package/dist/components/Root/Announcer.mjs +58 -0
- package/dist/components/Root/Root.mjs +29 -0
- package/dist/components/Root/useRootState.mjs +188 -0
- package/dist/components/Scene/Connected.mjs +48 -0
- package/dist/components/Scene/Loaded.mjs +56 -0
- package/dist/components/Scene/RotatePad.mjs +204 -0
- package/dist/components/Scene/Scene.mjs +20 -0
- package/dist/components/Scene/SceneView.mjs +539 -0
- package/dist/components/Scene/cloverEngine.mjs +105 -0
- package/dist/components/Scene/engine.mjs +141 -0
- package/dist/components/Scene/engines.mjs +23 -0
- package/dist/components/Scene/gestures.mjs +74 -0
- package/dist/components/Scene/models.mjs +78 -0
- package/dist/components/Scene/orbit.mjs +60 -0
- package/dist/components/Search/Search.mjs +246 -0
- package/dist/components/Split/Split.mjs +203 -0
- package/dist/components/Split/splitting.mjs +203 -0
- package/dist/components/Status/Status.mjs +47 -0
- package/dist/components/Timeline/Connected.mjs +25 -0
- package/dist/components/Timeline/Timeline.mjs +40 -0
- package/dist/components/Timeline/playerSurface.mjs +84 -0
- package/dist/components/Transcript/Transcript.mjs +377 -0
- package/dist/components/Viewer/Viewer.mjs +19 -0
- package/dist/core/annotation-bodies.mjs +29 -0
- package/dist/core/annotation-collection.mjs +55 -0
- package/dist/core/annotation-name.mjs +31 -0
- package/dist/core/annotation-sets.mjs +155 -0
- package/dist/core/annotations-content.mjs +27 -0
- package/dist/core/annotations.mjs +73 -0
- package/dist/core/clover.mjs +393 -0
- package/dist/core/content-state-reader.mjs +82 -0
- package/dist/core/content-state.mjs +43 -0
- package/dist/core/direction.mjs +12 -0
- package/dist/core/geo-detect.mjs +30 -0
- package/dist/core/geo.mjs +283 -0
- package/dist/core/items.mjs +74 -0
- package/dist/core/keep-fragments.mjs +40 -0
- package/dist/core/link.mjs +28 -0
- package/dist/core/load.mjs +176 -0
- package/dist/core/map-config.mjs +12 -0
- package/dist/core/markdown.mjs +139 -0
- package/dist/core/pages.mjs +51 -0
- package/dist/core/painted-bodies.mjs +20 -0
- package/dist/core/painting.mjs +17 -0
- package/dist/core/presentation.mjs +27 -0
- package/dist/core/ranges.mjs +133 -0
- package/dist/core/region.mjs +32 -0
- package/dist/core/request.mjs +40 -0
- package/dist/core/sanitize.mjs +72 -0
- package/dist/core/search-service.mjs +22 -0
- package/dist/core/search.mjs +154 -0
- package/dist/core/selectors.mjs +94 -0
- package/dist/core/sequence.mjs +70 -0
- package/dist/core/show-link.mjs +16 -0
- package/dist/core/store.mjs +40 -0
- package/dist/core/svg-shape.mjs +183 -0
- package/dist/core/text.mjs +36 -0
- package/dist/core/thumbnail.mjs +55 -0
- package/dist/core/value.mjs +39 -0
- package/dist/core/vtt.mjs +111 -0
- package/dist/hooks/useFullscreen.mjs +21 -0
- package/dist/hooks/useFullscreenSupported.mjs +11 -0
- package/dist/hooks/useLoaded.mjs +27 -0
- package/dist/hooks/useWithinFullscreen.mjs +24 -0
- package/dist/i18n/config.mjs +170 -0
- package/dist/i18n/hostLanguage.mjs +6 -0
- package/dist/i18n/locales/en.json.mjs +5 -0
- package/dist/i18n/locales/es.json.mjs +5 -0
- package/dist/i18n/locales/fi.json.mjs +5 -0
- package/dist/i18n/locales/fr.json.mjs +5 -0
- package/dist/i18n/locales/index.mjs +13 -0
- package/dist/i18n/locales/nb.json.mjs +5 -0
- package/dist/i18n/locales/nn.json.mjs +5 -0
- package/dist/i18n/locales/no.json.mjs +5 -0
- package/dist/i18n/locales/pt.json.mjs +5 -0
- package/dist/i18n/reader.mjs +13 -0
- package/dist/i18n/useCloverTranslation.mjs +28 -0
- package/dist/index.d.mts +2204 -0
- package/dist/index.mjs +133 -0
- package/dist/lib/asArray.mjs +5 -0
- package/dist/lib/classnames.mjs +5 -0
- package/dist/lib/fullscreen.mjs +65 -0
- package/dist/lib/gltf/bounds.mjs +44 -0
- package/dist/lib/gltf/load.mjs +156 -0
- package/dist/lib/gltf/mat4.mjs +150 -0
- package/dist/lib/gltf/renderer.mjs +342 -0
- package/dist/lib/gltf/shaders.mjs +192 -0
- package/dist/lib/hls.mjs +6 -0
- package/dist/lib/pointer.mjs +38 -0
- package/dist/lib/renderer/CanvasRenderer.mjs +857 -0
- package/dist/lib/renderer/backends/backend.mjs +21 -0
- package/dist/lib/renderer/backends/canvas2d/Canvas2DBackend.mjs +91 -0
- package/dist/lib/renderer/backends/contexts.mjs +27 -0
- package/dist/lib/renderer/backends/dom/DomLayers.mjs +91 -0
- package/dist/lib/renderer/backends/webgl2/WebGL2Backend.mjs +248 -0
- package/dist/lib/renderer/backends/webgl2/shaders.mjs +28 -0
- package/dist/lib/renderer/camera/Camera.mjs +64 -0
- package/dist/lib/renderer/camera/CameraAnimator.mjs +90 -0
- package/dist/lib/renderer/input/GestureController.mjs +252 -0
- package/dist/lib/renderer/io/TileCache.mjs +207 -0
- package/dist/lib/renderer/io/decode.mjs +156 -0
- package/dist/lib/renderer/loop/FrameLoop.mjs +50 -0
- package/dist/lib/renderer/math/affine.mjs +68 -0
- package/dist/lib/renderer/math/rect.mjs +45 -0
- package/dist/lib/renderer/overlays/Navigator.mjs +141 -0
- package/dist/lib/renderer/overlays/OverlayLayer.mjs +94 -0
- package/dist/lib/renderer/scene/planFrame.mjs +168 -0
- package/dist/lib/renderer/scene/regions.mjs +30 -0
- package/dist/lib/renderer/scene/sceneItem.mjs +114 -0
- package/dist/lib/renderer/scene/uploadBudget.mjs +30 -0
- package/dist/lib/renderer/sources/imageService.mjs +160 -0
- package/dist/lib/renderer/sources/sizedImage.mjs +38 -0
- package/dist/lib/renderer/sources/tilePyramid.mjs +172 -0
- package/dist/lib/time.mjs +21 -0
- package/dist/map/index.d.mts +184 -0
- package/dist/map/index.mjs +16 -0
- package/dist/react/context.mjs +46 -0
- package/dist/react/hooks.mjs +69 -0
- package/dist/react/language.mjs +30 -0
- package/dist/styles.css +1 -0
- package/dist/templates/default/Default.mjs +229 -0
- package/dist/templates/document/Document.mjs +286 -0
- package/dist/templates/document/DocumentPanel.mjs +9 -0
- package/dist/templates/document/Sheets.mjs +360 -0
- package/dist/templates/gallery/Gallery.mjs +62 -0
- package/dist/templates/index.d.mts +273 -0
- package/dist/templates/index.mjs +11 -0
- package/dist/templates/shared/Lightbox.mjs +111 -0
- package/dist/templates/shared/LightboxBody.mjs +9 -0
- package/dist/templates/shared/dragToClose.mjs +129 -0
- package/dist/templates/shared/useDragToClose.mjs +35 -0
- package/dist/templates/shared/useDrawer.mjs +113 -0
- package/dist/templates/shared/useFollowFocus.mjs +24 -0
- package/dist/templates/shared/useSlide.mjs +52 -0
- package/dist/templates/shared/useSpine.mjs +26 -0
- package/dist/templates.css +1 -0
- package/dist/three/index.d.mts +6 -0
- package/dist/three/index.mjs +8 -0
- package/dist/ui/Button.mjs +53 -0
- package/dist/ui/ControlCluster.mjs +87 -0
- package/dist/ui/Cue.mjs +13 -0
- package/dist/ui/ErrorBoundary.mjs +26 -0
- package/dist/ui/ExitFullscreen.mjs +46 -0
- package/dist/ui/FieldPill.mjs +153 -0
- package/dist/ui/HideToggle.mjs +57 -0
- package/dist/ui/Loading.mjs +20 -0
- package/dist/ui/Markup.mjs +95 -0
- package/dist/ui/ReadMore.mjs +84 -0
- package/dist/ui/Sections.mjs +448 -0
- package/dist/ui/Steps.mjs +84 -0
- package/dist/ui/Tip.mjs +196 -0
- package/dist/ui/bringIntoView.mjs +27 -0
- package/dist/ui/controlGlyphs.mjs +120 -0
- package/dist/ui/heading.mjs +19 -0
- package/dist/ui/languageCode.mjs +8 -0
- package/dist/ui/mediaIcons.mjs +104 -0
- package/dist/ui/useClusterReach.mjs +50 -0
- package/dist/ui/useContainerName.mjs +19 -0
- package/dist/ui/useOneOpen.mjs +22 -0
- package/dist/ui/useRovingFocus.mjs +64 -0
- package/dist/ui/useScrollTrack.mjs +150 -0
- package/dist/ui/useUniqueId.mjs +10 -0
- package/dist/ui/visuallyHidden.mjs +15 -0
- package/dist/web-components/About-uKa1wfDr.mjs +1 -0
- package/dist/web-components/AnnotationMenu-BGIYRXW6.mjs +1 -0
- package/dist/web-components/AnnotationState-D2UIgIEC.mjs +1 -0
- package/dist/web-components/Annotations-BhwAv3ah.mjs +1 -0
- package/dist/web-components/Annotations-C_tBJHo3.mjs +2 -0
- package/dist/web-components/Body-DMEERFuB.mjs +1 -0
- package/dist/web-components/BodyAlert-BP8voSLv.mjs +1 -0
- package/dist/web-components/Button-Cl02BFDd.mjs +1 -0
- package/dist/web-components/Camera-Dw51CAfF.mjs +1 -0
- package/dist/web-components/Canvas2DBackend-RRN2bEkc.mjs +1 -0
- package/dist/web-components/CanvasView-B8lMMSou.mjs +1 -0
- package/dist/web-components/CaptionDetails-KLMDv-ec.mjs +1 -0
- package/dist/web-components/ChoiceMenu-CXrVOmJl.mjs +1 -0
- package/dist/web-components/Collection-DL4Ui4hF.mjs +1 -0
- package/dist/web-components/CollectionSelect-DL-bbpwJ.mjs +1 -0
- package/dist/web-components/Connected-B0S1HXQb.mjs +1 -0
- package/dist/web-components/Connected-BcjRA5si.mjs +1 -0
- package/dist/web-components/Connected-Q7iizBb8.mjs +1 -0
- package/dist/web-components/Contents-ZC8TiGaW.mjs +1 -0
- package/dist/web-components/ControlMenu-DIoU797-.mjs +1 -0
- package/dist/web-components/Cue-CJxnDMEy.mjs +1 -0
- package/dist/web-components/Document-DHBRAFEK.mjs +1 -0
- package/dist/web-components/DocumentPanel-CqvE2pu9.mjs +1 -0
- package/dist/web-components/DomLayers-BsR2AOy-.mjs +1 -0
- package/dist/web-components/Download-DBksL1C0.mjs +1 -0
- package/dist/web-components/EntryBodies-VwEkTVrw.mjs +1 -0
- package/dist/web-components/ErrorBoundary-Cy9PGoZv.mjs +1 -0
- package/dist/web-components/FieldPill-DCJBz6Vj.mjs +1 -0
- package/dist/web-components/FrameAnimation-DRbmgGpF.mjs +1 -0
- package/dist/web-components/Gallery-BM7-VJkB.mjs +1 -0
- package/dist/web-components/HideToggle-BdYgG7us.mjs +1 -0
- package/dist/web-components/Items-_1Jz3FMs.mjs +1 -0
- package/dist/web-components/Label-CAiJ49eA.mjs +1 -0
- package/dist/web-components/LightboxBody-DyhUZiDf.mjs +1 -0
- package/dist/web-components/Loaded-wQurAeJz.mjs +1 -0
- package/dist/web-components/LoadedCanvas-DWz5IK5m.mjs +1 -0
- package/dist/web-components/LoadedMap-DIeW313M.mjs +1 -0
- package/dist/web-components/Loading-BmA--pzr.mjs +1 -0
- package/dist/web-components/Map-DzVGblIS.mjs +1 -0
- package/dist/web-components/MapView-BJaN7VBI.mjs +1 -0
- package/dist/web-components/Markup-D91DbxLk.mjs +2 -0
- package/dist/web-components/MediaBody-BYcVPo2X.mjs +1 -0
- package/dist/web-components/MediaBody-FEzH8VVw.mjs +1 -0
- package/dist/web-components/Navigator-CIJFA3q1.mjs +1 -0
- package/dist/web-components/Pager-BGwCurxE.mjs +1 -0
- package/dist/web-components/Panel-B-GXOkzF.mjs +1 -0
- package/dist/web-components/PanelToggle-BYjV2t1j.mjs +1 -0
- package/dist/web-components/PartOfManifest-ClbGepVM.mjs +1 -0
- package/dist/web-components/Pending-BspZajh5.mjs +1 -0
- package/dist/web-components/Primitives-CTh59wvs.mjs +1 -0
- package/dist/web-components/Provider-C6rIiDXH.mjs +1 -0
- package/dist/web-components/ReadMore-BJ2i-0uN.mjs +1 -0
- package/dist/web-components/Root-DkkYDtur.mjs +1 -0
- package/dist/web-components/Scene-B_PU_TiX.mjs +1 -0
- package/dist/web-components/SceneView-qcW_sT3j.mjs +1 -0
- package/dist/web-components/Search-UOneIUcP.mjs +1 -0
- package/dist/web-components/Sections-we9U9fXq.mjs +2 -0
- package/dist/web-components/StandaloneItems-DU8oCFc_.mjs +1 -0
- package/dist/web-components/Status-Cs5ZvFvL.mjs +1 -0
- package/dist/web-components/Timeline-WtYZ1bIJ.mjs +1 -0
- package/dist/web-components/Tip-C8J3qsIK.mjs +1 -0
- package/dist/web-components/Transcript-CRL2zToL.mjs +1 -0
- package/dist/web-components/annotation-collection-ZPyvpLFc.mjs +1 -0
- package/dist/web-components/annotations-content-BZChKhJZ.mjs +1 -0
- package/dist/web-components/assets/maplibre-gl-worker-kTz9OPxr.js +13831 -0
- package/dist/web-components/body-UntgrmoV.mjs +1 -0
- package/dist/web-components/bringIntoView-CQH5ZgMM.mjs +1 -0
- package/dist/web-components/canvas-d_U4v_mh.mjs +1 -0
- package/dist/web-components/classnames-DukgfdpI.mjs +1 -0
- package/dist/web-components/cloverEngine-Dbv-26NP.mjs +164 -0
- package/dist/web-components/content-state-reader-DjdKWjit.mjs +1 -0
- package/dist/web-components/contexts-ByL3eA_T.mjs +1 -0
- package/dist/web-components/controls-qRYf2jO2.mjs +1 -0
- package/dist/web-components/custom-elements.json +2739 -0
- package/dist/web-components/dragToClose-C-Pf1IeO.mjs +1 -0
- package/dist/web-components/engine-D8JLgzqq.mjs +4228 -0
- package/dist/web-components/engines-BwVb9R_A.mjs +1 -0
- package/dist/web-components/es-BwMkoRod.mjs +1 -0
- package/dist/web-components/fi-gPFOn9RK.mjs +1 -0
- package/dist/web-components/fr-DUHmgdJo.mjs +1 -0
- package/dist/web-components/fromManifest-UrMJgktp.mjs +1 -0
- package/dist/web-components/glyphs-BoX0a88P.mjs +1 -0
- package/dist/web-components/heading-Cjt0f-Eu.mjs +1 -0
- package/dist/web-components/hls-CdKrthkC.mjs +40 -0
- package/dist/web-components/hooks-Dp8pjU8l.mjs +1 -0
- package/dist/web-components/imageService-C3yg9DxB.mjs +1 -0
- package/dist/web-components/index-DWxMuwDL.mjs +1 -0
- package/dist/web-components/index.d.mts +604 -0
- package/dist/web-components/index.mjs +1 -0
- package/dist/web-components/index.umd.js +18 -0
- package/dist/web-components/items--Tu7ZM3L.mjs +1 -0
- package/dist/web-components/items-W2vrwArM.mjs +1 -0
- package/dist/web-components/keep-fragments-B5nlv2ck.mjs +1 -0
- package/dist/web-components/label-CYQ7tVl6.mjs +1 -0
- package/dist/web-components/languageCode-cCpiU0b0.mjs +1 -0
- package/dist/web-components/layout-KL0V-iJu.mjs +1 -0
- package/dist/web-components/link-DRRTY4lY.mjs +1 -0
- package/dist/web-components/logo-CnQUCB3Y.mjs +1 -0
- package/dist/web-components/maplibre-gl-CQ4OueXY.mjs +823 -0
- package/dist/web-components/markdown-CCYJwzFn.mjs +5 -0
- package/dist/web-components/models-BP2qp9nT.mjs +1 -0
- package/dist/web-components/nb-BSvnQ6jd.mjs +1 -0
- package/dist/web-components/nn-Dg2_HdZu.mjs +1 -0
- package/dist/web-components/no-BSvnQ6jd.mjs +1 -0
- package/dist/web-components/nodes-Bf-Fb7e5.mjs +1 -0
- package/dist/web-components/overlayImage-DdPs2EGY.mjs +1 -0
- package/dist/web-components/panClearOfControls-ac9uf-Qs.mjs +1 -0
- package/dist/web-components/panel-CiqEFDzv.mjs +1 -0
- package/dist/web-components/part-CUBY90_b.mjs +1 -0
- package/dist/web-components/playerSurface-i2TJz-F4.mjs +1 -0
- package/dist/web-components/provider-LUmAQSoP.mjs +1 -0
- package/dist/web-components/pt-B3J80JgO.mjs +1 -0
- package/dist/web-components/read-more-BaaO77el.mjs +1 -0
- package/dist/web-components/rendererSurface-DAvatpMF.mjs +22 -0
- package/dist/web-components/renderers-Bg4QqawN.mjs +1 -0
- package/dist/web-components/resource-DzIvB_4m.mjs +1 -0
- package/dist/web-components/sanitize-Dc7nOsgO.mjs +3 -0
- package/dist/web-components/search-DgcgsI3I.mjs +1 -0
- package/dist/web-components/shared-J3w3gnXD.mjs +1 -0
- package/dist/web-components/show-link-DWRRXSBy.mjs +1 -0
- package/dist/web-components/sizedImage-DfjlV2-i.mjs +1 -0
- package/dist/web-components/split-m-_XivaW.mjs +1 -0
- package/dist/web-components/splitting-BnQUxxgH.mjs +1 -0
- package/dist/web-components/status-DDS7jLNd.mjs +1 -0
- package/dist/web-components/styles-Ypl9KrSK.mjs +1 -0
- package/dist/web-components/svg-shape-DLY3g7oq.mjs +1 -0
- package/dist/web-components/text-BTAkxEfQ.mjs +5 -0
- package/dist/web-components/three.mjs +1 -0
- package/dist/web-components/thumbnail-BZvLSwWW.mjs +1 -0
- package/dist/web-components/time-B9GZoYcm.mjs +1 -0
- package/dist/web-components/tip-BXByhOJ9.mjs +1 -0
- package/dist/web-components/toggle-AS72kq6v.mjs +1 -0
- package/dist/web-components/upgrader-XNxI-5jo.mjs +1 -0
- package/dist/web-components/useContainerName-DCbE5JXi.mjs +1 -0
- package/dist/web-components/useNearViewport-CyoK3l8W.mjs +1 -0
- package/dist/web-components/useScrollTrack-dLFWnT8N.mjs +1 -0
- package/dist/web-components/viewer/AnnotationMenu-Dd4tnzNV.mjs +1 -0
- package/dist/web-components/viewer/AnnotationState-DZaSy5lH.mjs +1 -0
- package/dist/web-components/viewer/Annotations-D1h-Yi5J.mjs +1 -0
- package/dist/web-components/viewer/Annotations-sj79EMen.mjs +2 -0
- package/dist/web-components/viewer/Canvas2DBackend-CkvI0wUT.mjs +1 -0
- package/dist/web-components/viewer/CaptionDetails-B_JdNjJ7.mjs +1 -0
- package/dist/web-components/viewer/ChoiceMenu-xa51a1DV.mjs +1 -0
- package/dist/web-components/viewer/Collection-CxuLCspj.mjs +1 -0
- package/dist/web-components/viewer/Connected-BSUBc3Ci.mjs +1 -0
- package/dist/web-components/viewer/Connected-CPIxNjF2.mjs +1 -0
- package/dist/web-components/viewer/Contents-DNh9mnsF.mjs +1 -0
- package/dist/web-components/viewer/ControlMenu-DdgIvBdf.mjs +1 -0
- package/dist/web-components/viewer/Cue-90H9_dXz.mjs +1 -0
- package/dist/web-components/viewer/Document-CNCpzkiN.mjs +1 -0
- package/dist/web-components/viewer/DocumentPanel-BdG4TVLE.mjs +1 -0
- package/dist/web-components/viewer/DomLayers-Dybz_aJv.mjs +1 -0
- package/dist/web-components/viewer/EntryBodies-DGXjFP3N.mjs +1 -0
- package/dist/web-components/viewer/FieldPill-Icmd98OY.mjs +1 -0
- package/dist/web-components/viewer/FrameAnimation-DJZN3Rd4.mjs +1 -0
- package/dist/web-components/viewer/Gallery-CEp3-bh2.mjs +1 -0
- package/dist/web-components/viewer/HideToggle-DB6HTmAO.mjs +1 -0
- package/dist/web-components/viewer/LightboxBody-ClQ4yrTh.mjs +1 -0
- package/dist/web-components/viewer/MapView-BVSdybIC.mjs +1 -0
- package/dist/web-components/viewer/MediaBody-BBbSMT1i.mjs +1 -0
- package/dist/web-components/viewer/MediaBody-BzMXMHIF.mjs +1 -0
- package/dist/web-components/viewer/Navigator-Duc69Yes.mjs +1 -0
- package/dist/web-components/viewer/PartOfManifest-X9_q-2t6.mjs +1 -0
- package/dist/web-components/viewer/Search-S4N5QU4R.mjs +1 -0
- package/dist/web-components/viewer/StandaloneItems-BO4VyWRW.mjs +1 -0
- package/dist/web-components/viewer/Transcript-BbDaS064.mjs +1 -0
- package/dist/web-components/viewer/annotation-collection-BjZ1DAHq.mjs +1 -0
- package/dist/web-components/viewer/annotations-content-jn3n5Y2-.mjs +1 -0
- package/dist/web-components/viewer/cloverEngine-CjuYjUhI.mjs +164 -0
- package/dist/web-components/viewer/content-state-reader-CPiShIjP.mjs +1 -0
- package/dist/web-components/viewer/host-yWi4R1bP.mjs +1 -0
- package/dist/web-components/viewer/index.d.mts +7 -0
- package/dist/web-components/viewer/index.mjs +1 -0
- package/dist/web-components/viewer/index.umd.js +18 -0
- package/dist/web-components/viewer/link-CwE-fg5G.mjs +1 -0
- package/dist/web-components/viewer/overlayImage-BpOgqsZ0.mjs +1 -0
- package/dist/web-components/viewer/renderers-L-IlGI1r.mjs +1 -0
- package/dist/web-components/viewer/search-DWkwRPo_.mjs +1 -0
- package/dist/web-components/viewer/styles-BRCkEU3w.mjs +1 -0
- package/dist/web-components/viewer/viewer--TreVlJ_.mjs +28 -0
- package/dist/web-components/viewer/vtt-1ZJwtElI.mjs +5 -0
- package/dist/web-components/viewer-DyV864Qe.mjs +1 -0
- package/dist/web-components/vtt-GFssZH8Y.mjs +5 -0
- package/package.json +110 -4
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
3
|
+
import { bodiesOf, isPainting } from "./painting.mjs";
|
|
4
|
+
import { selectSequence } from "./selectors.mjs";
|
|
5
|
+
import { toPlainText } from "./text.mjs";
|
|
6
|
+
import { localize } from "./value.mjs";
|
|
7
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
8
|
+
const GEOMETRIES = /* @__PURE__ */ new Set([
|
|
9
|
+
"Point",
|
|
10
|
+
"MultiPoint",
|
|
11
|
+
"LineString",
|
|
12
|
+
"MultiLineString",
|
|
13
|
+
"Polygon",
|
|
14
|
+
"MultiPolygon",
|
|
15
|
+
"GeometryCollection"
|
|
16
|
+
]);
|
|
17
|
+
const STYLE_KEYS = [
|
|
18
|
+
"fill",
|
|
19
|
+
"fill-opacity",
|
|
20
|
+
"stroke",
|
|
21
|
+
"stroke-width",
|
|
22
|
+
"stroke-opacity",
|
|
23
|
+
"marker-color"
|
|
24
|
+
];
|
|
25
|
+
function featuresOf(geo) {
|
|
26
|
+
const value = geo;
|
|
27
|
+
if (!value || typeof value !== "object") return [];
|
|
28
|
+
if (value.type === "FeatureCollection") {
|
|
29
|
+
return asArray(value.features).filter(
|
|
30
|
+
(feature) => feature == null ? void 0 : feature.geometry
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (value.type === "Feature") return value.geometry ? [value] : [];
|
|
34
|
+
if (GEOMETRIES.has(value.type)) return [{ type: "Feature", geometry: value }];
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
function flatten(feature, owner, language) {
|
|
38
|
+
const own = feature.properties ?? {};
|
|
39
|
+
const properties = {};
|
|
40
|
+
for (const key of STYLE_KEYS) {
|
|
41
|
+
const value = own[key];
|
|
42
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
43
|
+
properties[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const ownTitle = localize(own.label, language);
|
|
47
|
+
const title = ownTitle.text ? ownTitle : localize(owner.label, language);
|
|
48
|
+
if (title.text) {
|
|
49
|
+
properties.title = toPlainText(title.text);
|
|
50
|
+
if (title.lang) properties.titleLang = title.lang;
|
|
51
|
+
}
|
|
52
|
+
if (owner.canvasId) properties.canvasId = owner.canvasId;
|
|
53
|
+
return {
|
|
54
|
+
type: "Feature",
|
|
55
|
+
...feature.id != null ? { id: feature.id } : {},
|
|
56
|
+
geometry: feature.geometry,
|
|
57
|
+
properties
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const GEOREFERENCING = "georeferencing";
|
|
61
|
+
const motivations = (annotation) => asArray(annotation == null ? void 0 : annotation.motivation);
|
|
62
|
+
function annotationsOf(canvas) {
|
|
63
|
+
return asArray(canvas.annotations).flatMap(
|
|
64
|
+
(page) => asArray(page == null ? void 0 : page.items)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const navPlaces = /* @__PURE__ */ new WeakMap();
|
|
68
|
+
function navPlaceOf(manifest, collection = null, language) {
|
|
69
|
+
if (!manifest) return NO_FEATURES;
|
|
70
|
+
const key = `${language ?? ""}|${(collection == null ? void 0 : collection.id) ?? ""}`;
|
|
71
|
+
let byKey = navPlaces.get(manifest);
|
|
72
|
+
if (!byKey) navPlaces.set(manifest, byKey = /* @__PURE__ */ new Map());
|
|
73
|
+
const cached = byKey.get(key);
|
|
74
|
+
if (cached) return cached;
|
|
75
|
+
const features = [];
|
|
76
|
+
const add = (geo, owner) => features.push(...featuresOf(geo).map((f) => flatten(f, owner, language)));
|
|
77
|
+
const c = collection;
|
|
78
|
+
if (c == null ? void 0 : c.navPlace) add(c.navPlace, { label: c.label });
|
|
79
|
+
const m = manifest;
|
|
80
|
+
if (m.navPlace) add(m.navPlace, { label: m.label });
|
|
81
|
+
for (const canvas of selectSequence(manifest).canvases) {
|
|
82
|
+
if (canvas.navPlace) {
|
|
83
|
+
add(canvas.navPlace, { label: canvas.label, canvasId: canvas.id });
|
|
84
|
+
}
|
|
85
|
+
for (const annotation of annotationsOf(canvas)) {
|
|
86
|
+
if (motivations(annotation).includes(GEOREFERENCING)) continue;
|
|
87
|
+
const canvasId = parseAnnotationTarget(asArray(annotation.target)[0]).id || canvas.id;
|
|
88
|
+
const owner = { label: annotation.label ?? canvas.label, canvasId };
|
|
89
|
+
if (annotation.navPlace) add(annotation.navPlace, owner);
|
|
90
|
+
for (const body of bodiesOf(annotation)) {
|
|
91
|
+
if ((body == null ? void 0 : body.type) === "Feature" || (body == null ? void 0 : body.type) === "FeatureCollection") {
|
|
92
|
+
add(body, owner);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const result = features.length ? { type: "FeatureCollection", features } : NO_FEATURES;
|
|
98
|
+
byKey.set(key, result);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
const NO_FEATURES = {
|
|
102
|
+
type: "FeatureCollection",
|
|
103
|
+
features: []
|
|
104
|
+
};
|
|
105
|
+
const NO_GEOREFERENCES = [];
|
|
106
|
+
function readMask(svg) {
|
|
107
|
+
var _a;
|
|
108
|
+
if (typeof svg !== "string") return void 0;
|
|
109
|
+
const points = (_a = /points\s*=\s*["']([^"']+)["']/i.exec(svg)) == null ? void 0 : _a[1];
|
|
110
|
+
if (!points) return void 0;
|
|
111
|
+
const numbers = points.trim().split(/[\s,]+/).map(Number);
|
|
112
|
+
const mask = [];
|
|
113
|
+
for (let i = 0; i + 1 < numbers.length; i += 2) {
|
|
114
|
+
mask.push([numbers[i], numbers[i + 1]]);
|
|
115
|
+
}
|
|
116
|
+
return mask.length >= 3 && mask.every((p) => p.every(Number.isFinite)) ? mask : void 0;
|
|
117
|
+
}
|
|
118
|
+
function paintedImage(canvas) {
|
|
119
|
+
for (const page of asArray(canvas == null ? void 0 : canvas.items)) {
|
|
120
|
+
for (const annotation of asArray(page == null ? void 0 : page.items)) {
|
|
121
|
+
if (!isPainting(annotation)) continue;
|
|
122
|
+
const body = bodiesOf(annotation).find(
|
|
123
|
+
(item) => (item == null ? void 0 : item.type) === "Image" || (item == null ? void 0 : item.service)
|
|
124
|
+
);
|
|
125
|
+
if (body) return body;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
function readGeoreference(annotation, canvas) {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
if (!motivations(annotation).includes(GEOREFERENCING)) return null;
|
|
133
|
+
const body = bodiesOf(annotation).find(
|
|
134
|
+
(item) => (item == null ? void 0 : item.type) === "FeatureCollection"
|
|
135
|
+
);
|
|
136
|
+
const points = [];
|
|
137
|
+
for (const feature of featuresOf(body)) {
|
|
138
|
+
const resource = (_a = feature.properties) == null ? void 0 : _a.resourceCoords;
|
|
139
|
+
const geo = ((_b = feature.geometry) == null ? void 0 : _b.type) === "Point" && feature.geometry.coordinates;
|
|
140
|
+
if (!Array.isArray(resource) || !Array.isArray(geo)) continue;
|
|
141
|
+
const point = {
|
|
142
|
+
resource: [Number(resource[0]), Number(resource[1])],
|
|
143
|
+
geo: [Number(geo[0]), Number(geo[1])]
|
|
144
|
+
};
|
|
145
|
+
if ([...point.resource, ...point.geo].every(Number.isFinite)) {
|
|
146
|
+
points.push(point);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (points.length < 3) return null;
|
|
150
|
+
const target = asArray(annotation.target)[0];
|
|
151
|
+
const source = typeof target === "string" ? { id: target } : typeof (target == null ? void 0 : target.source) === "string" ? { id: target.source } : (target == null ? void 0 : target.source) ?? target ?? {};
|
|
152
|
+
const sourceId = String(source.id ?? source["@id"] ?? "").split("#")[0];
|
|
153
|
+
const sourceType = String(source.type ?? source["@type"] ?? "");
|
|
154
|
+
const isService = /ImageService/.test(sourceType);
|
|
155
|
+
const width = Number(source.width ?? (canvas == null ? void 0 : canvas.width));
|
|
156
|
+
const height = Number(source.height ?? (canvas == null ? void 0 : canvas.height));
|
|
157
|
+
if (!(width > 0 && height > 0)) return null;
|
|
158
|
+
const image = isService ? { service: [{ id: sourceId, type: sourceType, profile: source.profile }] } : paintedImage(canvas);
|
|
159
|
+
if (!image) return null;
|
|
160
|
+
const selector = asArray(target == null ? void 0 : target.selector).find(
|
|
161
|
+
(item) => (item == null ? void 0 : item.type) === "SvgSelector"
|
|
162
|
+
);
|
|
163
|
+
const mask = readMask(selector == null ? void 0 : selector.value);
|
|
164
|
+
const whole = (mask == null ? void 0 : mask.length) === 4 && mask.every(
|
|
165
|
+
([x, y]) => (x === 0 || x === width) && (y === 0 || y === height)
|
|
166
|
+
);
|
|
167
|
+
const label = annotation.label ?? (canvas == null ? void 0 : canvas.label);
|
|
168
|
+
return {
|
|
169
|
+
id: String(annotation.id ?? sourceId),
|
|
170
|
+
...isService || !sourceId ? {} : { canvasId: (canvas == null ? void 0 : canvas.id) ?? sourceId },
|
|
171
|
+
points,
|
|
172
|
+
width,
|
|
173
|
+
height,
|
|
174
|
+
...mask && !whole ? { mask } : {},
|
|
175
|
+
...label ? { label } : {},
|
|
176
|
+
image
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const georeferences = /* @__PURE__ */ new WeakMap();
|
|
180
|
+
function georeferencesOf(manifest) {
|
|
181
|
+
if (!manifest) return NO_GEOREFERENCES;
|
|
182
|
+
const cached = georeferences.get(manifest);
|
|
183
|
+
if (cached) return cached;
|
|
184
|
+
const found = [];
|
|
185
|
+
for (const canvas of selectSequence(manifest).canvases) {
|
|
186
|
+
for (const annotation of annotationsOf(canvas)) {
|
|
187
|
+
const georeference = readGeoreference(annotation, canvas);
|
|
188
|
+
if (georeference) found.push(georeference);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const result = found.length ? found : NO_GEOREFERENCES;
|
|
192
|
+
georeferences.set(manifest, result);
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
const toMercator = ([lng, lat]) => [
|
|
196
|
+
lng * Math.PI / 180,
|
|
197
|
+
Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))
|
|
198
|
+
];
|
|
199
|
+
const fromMercator = ([x, y]) => [
|
|
200
|
+
x * 180 / Math.PI,
|
|
201
|
+
(2 * Math.atan(Math.exp(y)) - Math.PI / 2) * 180 / Math.PI
|
|
202
|
+
];
|
|
203
|
+
function solve3(m, b) {
|
|
204
|
+
const det = (a) => a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) - a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
|
|
205
|
+
const d = det(m);
|
|
206
|
+
if (Math.abs(d) < 1e-12) return null;
|
|
207
|
+
return [0, 1, 2].map(
|
|
208
|
+
(column) => det(m.map((row, i) => row.map((v, j) => j === column ? b[i] : v))) / d
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
function affineTransform(points) {
|
|
212
|
+
if (points.length < 3) return null;
|
|
213
|
+
const ata = [
|
|
214
|
+
[0, 0, 0],
|
|
215
|
+
[0, 0, 0],
|
|
216
|
+
[0, 0, 0]
|
|
217
|
+
];
|
|
218
|
+
const atx = [0, 0, 0];
|
|
219
|
+
const aty = [0, 0, 0];
|
|
220
|
+
for (const { resource, geo } of points) {
|
|
221
|
+
const row = [resource[0], resource[1], 1];
|
|
222
|
+
const [mx, my] = toMercator(geo);
|
|
223
|
+
for (let i = 0; i < 3; i++) {
|
|
224
|
+
for (let j = 0; j < 3; j++) ata[i][j] += row[i] * row[j];
|
|
225
|
+
atx[i] += row[i] * mx;
|
|
226
|
+
aty[i] += row[i] * my;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const fx = solve3(ata, atx);
|
|
230
|
+
const fy = solve3(ata, aty);
|
|
231
|
+
if (!fx || !fy) return null;
|
|
232
|
+
return ([x, y]) => fromMercator([
|
|
233
|
+
fx[0] * x + fx[1] * y + fx[2],
|
|
234
|
+
fy[0] * x + fy[1] * y + fy[2]
|
|
235
|
+
]);
|
|
236
|
+
}
|
|
237
|
+
function cornersOf(georeference) {
|
|
238
|
+
const transform = affineTransform(georeference.points);
|
|
239
|
+
if (!transform) return null;
|
|
240
|
+
const { width: w, height: h } = georeference;
|
|
241
|
+
return [
|
|
242
|
+
transform([0, 0]),
|
|
243
|
+
transform([w, 0]),
|
|
244
|
+
transform([w, h]),
|
|
245
|
+
transform([0, h])
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
function positionsOf(geometry) {
|
|
249
|
+
if (!geometry) return [];
|
|
250
|
+
if (geometry.type === "GeometryCollection") {
|
|
251
|
+
return (geometry.geometries ?? []).flatMap(positionsOf);
|
|
252
|
+
}
|
|
253
|
+
const flat = [];
|
|
254
|
+
const walk = (value) => {
|
|
255
|
+
if (!Array.isArray(value)) return;
|
|
256
|
+
if (typeof value[0] === "number" && typeof value[1] === "number") {
|
|
257
|
+
flat.push([value[0], value[1]]);
|
|
258
|
+
} else value.forEach(walk);
|
|
259
|
+
};
|
|
260
|
+
walk(geometry.coordinates);
|
|
261
|
+
return flat;
|
|
262
|
+
}
|
|
263
|
+
function boundsOf(features, overlays = []) {
|
|
264
|
+
const positions = [
|
|
265
|
+
...features.flatMap((feature) => positionsOf(feature.geometry)),
|
|
266
|
+
...overlays.flatMap((overlay) => cornersOf(overlay) ?? [])
|
|
267
|
+
].filter(([lng, lat]) => Number.isFinite(lng) && Number.isFinite(lat));
|
|
268
|
+
if (!positions.length) return null;
|
|
269
|
+
const lngs = positions.map(([lng]) => lng);
|
|
270
|
+
const lats = positions.map(([, lat]) => lat);
|
|
271
|
+
return [
|
|
272
|
+
[Math.min(...lngs), Math.min(...lats)],
|
|
273
|
+
[Math.max(...lngs), Math.max(...lats)]
|
|
274
|
+
];
|
|
275
|
+
}
|
|
276
|
+
export {
|
|
277
|
+
affineTransform,
|
|
278
|
+
boundsOf,
|
|
279
|
+
cornersOf,
|
|
280
|
+
georeferencesOf,
|
|
281
|
+
navPlaceOf,
|
|
282
|
+
readGeoreference
|
|
283
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { selectSequence } from "./selectors.mjs";
|
|
3
|
+
import { localize } from "./value.mjs";
|
|
4
|
+
import { paintedBodies } from "./painted-bodies.mjs";
|
|
5
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
6
|
+
function paintedType(container) {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = paintedBodies(container).find(({ body }) => body.type)) == null ? void 0 : _a.body.type;
|
|
9
|
+
}
|
|
10
|
+
function part(resource) {
|
|
11
|
+
const media = paintedType(resource) ?? (resource.type === "Timeline" ? "Sound" : void 0);
|
|
12
|
+
return {
|
|
13
|
+
id: resource.id,
|
|
14
|
+
type: resource.type,
|
|
15
|
+
label: resource.label,
|
|
16
|
+
resource,
|
|
17
|
+
duration: Number(resource.duration) || void 0,
|
|
18
|
+
media
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const viewItems = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
function itemsOfManifest(manifest) {
|
|
23
|
+
if (!manifest) return [];
|
|
24
|
+
let items = viewItems.get(manifest);
|
|
25
|
+
if (!items) {
|
|
26
|
+
const { canvases, views } = selectSequence(manifest);
|
|
27
|
+
items = views.map((view) => {
|
|
28
|
+
const parts = view.map((index) => part(canvases[index]));
|
|
29
|
+
return {
|
|
30
|
+
id: parts[0].id,
|
|
31
|
+
parts,
|
|
32
|
+
// A spread is named by its pages: "Frontispiece – Title page".
|
|
33
|
+
label: parts.length === 1 ? parts[0].label : {
|
|
34
|
+
none: [
|
|
35
|
+
parts.map((p) => localize(p.label).text).filter(Boolean).join(" – ")
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
viewItems.set(manifest, items);
|
|
41
|
+
}
|
|
42
|
+
return items;
|
|
43
|
+
}
|
|
44
|
+
const memberItems = /* @__PURE__ */ new WeakMap();
|
|
45
|
+
function itemsOfCollection(collection) {
|
|
46
|
+
if (!collection) return [];
|
|
47
|
+
let items = memberItems.get(collection);
|
|
48
|
+
if (!items) {
|
|
49
|
+
items = asArray(collection.items).filter((member) => member == null ? void 0 : member.id).map((member) => {
|
|
50
|
+
var _a;
|
|
51
|
+
return {
|
|
52
|
+
id: member.id,
|
|
53
|
+
parts: [part(member)],
|
|
54
|
+
label: member.label,
|
|
55
|
+
summary: member.summary,
|
|
56
|
+
href: ((_a = asArray(member.homepage)[0]) == null ? void 0 : _a.id) ?? member.id
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
memberItems.set(collection, items);
|
|
60
|
+
}
|
|
61
|
+
return items;
|
|
62
|
+
}
|
|
63
|
+
function itemsOf(resource) {
|
|
64
|
+
if (!resource) return [];
|
|
65
|
+
if (Array.isArray(resource)) {
|
|
66
|
+
return itemsOfCollection({ items: resource });
|
|
67
|
+
}
|
|
68
|
+
return resource.type === "Collection" ? itemsOfCollection(resource) : itemsOfManifest(resource);
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
itemsOf,
|
|
72
|
+
itemsOfCollection,
|
|
73
|
+
itemsOfManifest
|
|
74
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const fragmented = (target) => Boolean(target) && typeof target === "object" && !Array.isArray(target) && typeof target.id === "string" && target.id.includes("#") && target.type !== "SpecificResource";
|
|
3
|
+
function needs(value) {
|
|
4
|
+
if (Array.isArray(value)) return value.some(needs);
|
|
5
|
+
if (!value || typeof value !== "object") return false;
|
|
6
|
+
for (const [key, child] of Object.entries(value)) {
|
|
7
|
+
if (key === "target") {
|
|
8
|
+
const targets = Array.isArray(child) ? child : [child];
|
|
9
|
+
if (targets.some(fragmented)) return true;
|
|
10
|
+
}
|
|
11
|
+
if (needs(child)) return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
function asSpecificResource(target) {
|
|
16
|
+
const { id, ...rest } = target;
|
|
17
|
+
const [source, fragment] = id.split("#");
|
|
18
|
+
return {
|
|
19
|
+
type: "SpecificResource",
|
|
20
|
+
source: { ...rest, id: source },
|
|
21
|
+
selector: { type: "FragmentSelector", value: fragment }
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function rewrite(value) {
|
|
25
|
+
if (Array.isArray(value)) return value.map(rewrite);
|
|
26
|
+
if (!value || typeof value !== "object") return value;
|
|
27
|
+
const out = {};
|
|
28
|
+
for (const [key, child] of Object.entries(value)) {
|
|
29
|
+
out[key] = key === "target" ? Array.isArray(child) ? child.map(
|
|
30
|
+
(each) => fragmented(each) ? asSpecificResource(each) : rewrite(each)
|
|
31
|
+
) : fragmented(child) ? asSpecificResource(child) : rewrite(child) : rewrite(child);
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
function keepFragments(resource) {
|
|
36
|
+
return needs(resource) ? rewrite(resource) : resource;
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
keepFragments
|
|
40
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
3
|
+
import { bodiesOf } from "./painting.mjs";
|
|
4
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
5
|
+
function readLink(annotation) {
|
|
6
|
+
if (!asArray(annotation == null ? void 0 : annotation.motivation).includes("linking")) return void 0;
|
|
7
|
+
for (const body of bodiesOf(annotation)) {
|
|
8
|
+
if ((body == null ? void 0 : body.type) === "TextualBody" || typeof (body == null ? void 0 : body.value) === "string")
|
|
9
|
+
continue;
|
|
10
|
+
const source = (body == null ? void 0 : body.type) === "SpecificResource" ? body.source : body;
|
|
11
|
+
const id = typeof source === "string" ? source : source == null ? void 0 : source.id;
|
|
12
|
+
if (typeof id !== "string" || !id) continue;
|
|
13
|
+
if ((source == null ? void 0 : source.type) === "Canvas") {
|
|
14
|
+
const part = asArray(source.partOf).find(
|
|
15
|
+
(each) => (each == null ? void 0 : each.id) && (!each.type || each.type === "Manifest")
|
|
16
|
+
);
|
|
17
|
+
const canvasId = parseAnnotationTarget(id).id;
|
|
18
|
+
return { id, canvasId, ...part ? { manifestId: part.id } : {} };
|
|
19
|
+
}
|
|
20
|
+
if ((source == null ? void 0 : source.type) === "Manifest" || (source == null ? void 0 : source.type) === "Collection")
|
|
21
|
+
return { id, manifestId: id };
|
|
22
|
+
if (/^https?:\/\//i.test(id)) return { id };
|
|
23
|
+
}
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
readLink
|
|
28
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
import { isContentState } from "./content-state.mjs";
|
|
6
|
+
import { preloadUpgrader, toPresentation4 } from "./presentation.mjs";
|
|
7
|
+
import { fetchJson } from "./request.mjs";
|
|
8
|
+
const readContentState = () => import("./content-state-reader.mjs");
|
|
9
|
+
const DESCRIPTIVE = [
|
|
10
|
+
"summary",
|
|
11
|
+
"metadata",
|
|
12
|
+
"requiredStatement",
|
|
13
|
+
"rights",
|
|
14
|
+
"provider",
|
|
15
|
+
"homepage",
|
|
16
|
+
"seeAlso",
|
|
17
|
+
"rendering",
|
|
18
|
+
"thumbnail",
|
|
19
|
+
"navDate",
|
|
20
|
+
"partOf"
|
|
21
|
+
];
|
|
22
|
+
function loneCanvas(canvas) {
|
|
23
|
+
const manifest = {
|
|
24
|
+
"@context": P4_CONTEXT,
|
|
25
|
+
id: canvas.id,
|
|
26
|
+
type: "Manifest",
|
|
27
|
+
label: canvas.label ?? { none: [""] },
|
|
28
|
+
items: [canvas]
|
|
29
|
+
};
|
|
30
|
+
for (const key of DESCRIPTIVE) {
|
|
31
|
+
if (canvas[key] !== void 0 && key !== "label")
|
|
32
|
+
manifest[key] = canvas[key];
|
|
33
|
+
}
|
|
34
|
+
return manifest;
|
|
35
|
+
}
|
|
36
|
+
const isLoneCanvas = (manifest) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return Boolean(manifest) && ((_b = (_a = manifest.items) == null ? void 0 : _a[0]) == null ? void 0 : _b.id) === manifest.id;
|
|
39
|
+
};
|
|
40
|
+
const ANNOTATIONS = /^(oa:)?Annotation(Page|Collection)$/;
|
|
41
|
+
class CloverContentError extends Error {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
__publicField(this, "name", "CloverContentError");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const P4_CONTEXT = "http://iiif.io/api/presentation/4/context.json";
|
|
48
|
+
const isUrl = (value) => /^https?:\/\//i.test(value);
|
|
49
|
+
async function dereference(resource, { request, signal }) {
|
|
50
|
+
const embedded = Array.isArray(resource.items) && resource.items.length > 0;
|
|
51
|
+
if (embedded || !resource.id) return resource;
|
|
52
|
+
return await fetchJson(request, resource.id, signal);
|
|
53
|
+
}
|
|
54
|
+
const MAX_COLLECTION_PAGES = 50;
|
|
55
|
+
async function withMembers(collection, options) {
|
|
56
|
+
const json = collection;
|
|
57
|
+
if (Array.isArray(json.items) && json.items.length) return collection;
|
|
58
|
+
if (!json.first) return collection;
|
|
59
|
+
const items = [];
|
|
60
|
+
const seen = /* @__PURE__ */ new Set();
|
|
61
|
+
let next = json.first;
|
|
62
|
+
for (let page = 0; next && page < MAX_COLLECTION_PAGES; page++) {
|
|
63
|
+
const reference = typeof next === "string" ? { id: next } : next;
|
|
64
|
+
if (seen.has(reference.id ?? reference)) break;
|
|
65
|
+
seen.add(reference.id ?? reference);
|
|
66
|
+
const fetched = reference.items ? reference : await fetchJson(options.request, reference.id, options.signal);
|
|
67
|
+
const upgraded = await toPresentation4({
|
|
68
|
+
"@context": fetched["@context"] ?? json["@context"],
|
|
69
|
+
...fetched,
|
|
70
|
+
type: "Collection"
|
|
71
|
+
});
|
|
72
|
+
items.push(...upgraded.items ?? []);
|
|
73
|
+
next = fetched.next;
|
|
74
|
+
}
|
|
75
|
+
return { ...json, items };
|
|
76
|
+
}
|
|
77
|
+
async function loadManifest(member, options = {}) {
|
|
78
|
+
return toPresentation4(await dereference(member, options));
|
|
79
|
+
}
|
|
80
|
+
async function firstManifest(collection, options, depth = 0) {
|
|
81
|
+
for (const item of collection.items ?? []) {
|
|
82
|
+
if (item.type === "Manifest") {
|
|
83
|
+
return toPresentation4(await dereference(item, options));
|
|
84
|
+
}
|
|
85
|
+
if (item.type === "Collection" && depth < 8) {
|
|
86
|
+
const nested = await withMembers(
|
|
87
|
+
await toPresentation4(await dereference(item, options)),
|
|
88
|
+
options
|
|
89
|
+
);
|
|
90
|
+
const found = await firstManifest(nested, options, depth + 1);
|
|
91
|
+
if (found) return found;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
async function fetchResource(input, { request, signal } = {}) {
|
|
97
|
+
void preloadUpgrader();
|
|
98
|
+
const json = typeof input === "string" ? await fetchJson(request, input.trim(), signal) : input;
|
|
99
|
+
const resource = await toPresentation4(json);
|
|
100
|
+
return resource.type === "Collection" ? withMembers(resource, { request, signal }) : resource;
|
|
101
|
+
}
|
|
102
|
+
async function loadContent(input, options = {}) {
|
|
103
|
+
var _a;
|
|
104
|
+
const { request, signal } = options;
|
|
105
|
+
void preloadUpgrader();
|
|
106
|
+
let target;
|
|
107
|
+
let member;
|
|
108
|
+
let annotation;
|
|
109
|
+
let json;
|
|
110
|
+
const followContentState = async (state) => {
|
|
111
|
+
const { resolveContentState } = await readContentState();
|
|
112
|
+
const resolved = resolveContentState(state);
|
|
113
|
+
if (!resolved) throw new CloverContentError("Unreadable content state");
|
|
114
|
+
target = resolved.target ?? target;
|
|
115
|
+
member = resolved.manifestId ?? member;
|
|
116
|
+
annotation = resolved.annotation ?? annotation;
|
|
117
|
+
return fetchJson(request, resolved.id, signal);
|
|
118
|
+
};
|
|
119
|
+
if (typeof input === "string") {
|
|
120
|
+
if (isUrl(input.trim())) {
|
|
121
|
+
json = await fetchJson(request, input.trim(), signal);
|
|
122
|
+
} else {
|
|
123
|
+
const { decodeContentState } = await readContentState();
|
|
124
|
+
const state = decodeContentState(input);
|
|
125
|
+
if (!state) throw new CloverContentError("Unreadable iiifContent");
|
|
126
|
+
json = isContentState(state) ? await followContentState(state) : state;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
json = input;
|
|
130
|
+
}
|
|
131
|
+
if (isContentState(json)) {
|
|
132
|
+
json = await followContentState(json);
|
|
133
|
+
}
|
|
134
|
+
if (ANNOTATIONS.test(String((json == null ? void 0 : json.type) ?? ""))) {
|
|
135
|
+
const { annotationsContent } = await import("./annotations-content.mjs");
|
|
136
|
+
return annotationsContent(json, options);
|
|
137
|
+
}
|
|
138
|
+
const resource = await toPresentation4(json);
|
|
139
|
+
(_a = signal == null ? void 0 : signal.throwIfAborted) == null ? void 0 : _a.call(signal);
|
|
140
|
+
switch (resource.type) {
|
|
141
|
+
case "Manifest":
|
|
142
|
+
return { manifest: resource, target, annotation };
|
|
143
|
+
case "Collection": {
|
|
144
|
+
const collection = await withMembers(resource, options);
|
|
145
|
+
const pick = options.manifestId ?? member;
|
|
146
|
+
const chosen = pick ? (collection.items ?? []).find(
|
|
147
|
+
(item) => item.id === pick && item.type === "Manifest"
|
|
148
|
+
) : void 0;
|
|
149
|
+
const manifest = chosen ? await loadManifest(chosen, options) : await firstManifest(collection, options);
|
|
150
|
+
if (!manifest) {
|
|
151
|
+
throw new CloverContentError("The Collection holds no Manifest");
|
|
152
|
+
}
|
|
153
|
+
return { manifest, collection, target, annotation };
|
|
154
|
+
}
|
|
155
|
+
case "Canvas":
|
|
156
|
+
case "Timeline":
|
|
157
|
+
case "Scene": {
|
|
158
|
+
const container = resource;
|
|
159
|
+
target ?? (target = { canvasId: container.id });
|
|
160
|
+
return { manifest: loneCanvas(container), target, annotation };
|
|
161
|
+
}
|
|
162
|
+
default:
|
|
163
|
+
throw new CloverContentError(
|
|
164
|
+
`Cannot show a ${String(resource.type ?? "resource without a type")}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
CloverContentError,
|
|
170
|
+
fetchResource,
|
|
171
|
+
isLoneCanvas,
|
|
172
|
+
loadContent,
|
|
173
|
+
loadManifest,
|
|
174
|
+
loneCanvas,
|
|
175
|
+
withMembers
|
|
176
|
+
};
|