@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,139 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const BULLET = /^\s*[-*+]\s+/;
|
|
3
|
+
const NUMBER = /^\s*(\d+)[.)]\s+/;
|
|
4
|
+
const HEADING = /^(#{1,6})\s+(\S.*?)(?:\s+#+)?\s*$/;
|
|
5
|
+
const GROUPS = Symbol.for("clover.markdown.groups");
|
|
6
|
+
const nextGroup = () => {
|
|
7
|
+
const page = globalThis;
|
|
8
|
+
return page[GROUPS] = (page[GROUPS] ?? 0) + 1;
|
|
9
|
+
};
|
|
10
|
+
const escape = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
11
|
+
function inline(text, notes) {
|
|
12
|
+
const links = [];
|
|
13
|
+
const marked = escape(text).replace(
|
|
14
|
+
/\[([^\]]+)\]\((https?:\/\/[^\s)]+|mailto:[^\s)]+)\)/g,
|
|
15
|
+
(_, label, url) => {
|
|
16
|
+
links.push(url);
|
|
17
|
+
return `\0${links.length - 1}${label}`;
|
|
18
|
+
}
|
|
19
|
+
).replace(/\[\^([^\]]+)\]/g, (match, key) => {
|
|
20
|
+
const number = notes.get(key);
|
|
21
|
+
return number ? `<sup>${number}</sup>` : match;
|
|
22
|
+
}).replace(/\*\*([^*]+)\*\*|__([^_]+)__/g, (_, a, b) => `<b>${a ?? b}</b>`).replace(
|
|
23
|
+
/\*([^*\s][^*]*)\*|_([^_\s][^_]*)_/g,
|
|
24
|
+
(_, a, b) => `<i>${a ?? b}</i>`
|
|
25
|
+
).replace(/( {2,}|\\)\n/g, "<br>").replace(/\n/g, " ");
|
|
26
|
+
return marked.replace(
|
|
27
|
+
/\u0000(\d+)\u0001([^\u0002]*)\u0002/g,
|
|
28
|
+
(_, index, label) => `<a href="${links[Number(index)]}">${label}</a>`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function blocksOf(body) {
|
|
32
|
+
const blocks = [];
|
|
33
|
+
for (const chunk of body.split(/\n(?:[ \t]*\n)+/)) {
|
|
34
|
+
let last;
|
|
35
|
+
for (const line of chunk.split("\n")) {
|
|
36
|
+
if (!line.trim()) continue;
|
|
37
|
+
const heading = HEADING.exec(line);
|
|
38
|
+
const number = NUMBER.exec(line);
|
|
39
|
+
const item = BULLET.test(line) || number && ((last == null ? void 0 : last.kind) !== "paragraph" || Number(number[1]) === 1);
|
|
40
|
+
if (heading) {
|
|
41
|
+
last = { kind: "heading", depth: heading[1].length, text: heading[2] };
|
|
42
|
+
blocks.push(last);
|
|
43
|
+
} else if (item && (last == null ? void 0 : last.kind) !== "list") {
|
|
44
|
+
last = { kind: "list", lines: [line] };
|
|
45
|
+
blocks.push(last);
|
|
46
|
+
} else if (last && last.kind !== "heading") {
|
|
47
|
+
last.lines.push(line);
|
|
48
|
+
} else {
|
|
49
|
+
last = { kind: "paragraph", lines: [line] };
|
|
50
|
+
blocks.push(last);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return blocks;
|
|
55
|
+
}
|
|
56
|
+
function list(lines, notes) {
|
|
57
|
+
const items = [];
|
|
58
|
+
for (const line of lines) {
|
|
59
|
+
const bullet = BULLET.exec(line);
|
|
60
|
+
const number = bullet ? null : NUMBER.exec(line);
|
|
61
|
+
const marker = bullet ?? number;
|
|
62
|
+
if (marker) {
|
|
63
|
+
items.push({
|
|
64
|
+
indent: line.replace(/\t/g, " ").search(/\S/),
|
|
65
|
+
tag: bullet ? "ul" : "ol",
|
|
66
|
+
start: number ? Number(number[1]) : 1,
|
|
67
|
+
text: line.slice(marker[0].length)
|
|
68
|
+
});
|
|
69
|
+
} else items[items.length - 1].text += `
|
|
70
|
+
${line.trimStart()}`;
|
|
71
|
+
}
|
|
72
|
+
let html = "";
|
|
73
|
+
const open = [];
|
|
74
|
+
const close = () => html += `</li></${open.pop().tag}>`;
|
|
75
|
+
for (const item of items) {
|
|
76
|
+
while (open.length > 1 && item.indent <= open[open.length - 2].indent)
|
|
77
|
+
close();
|
|
78
|
+
const top = open[open.length - 1];
|
|
79
|
+
const sibling = top && item.indent <= top.indent;
|
|
80
|
+
if (sibling && item.tag === top.tag) html += "</li><li>";
|
|
81
|
+
else {
|
|
82
|
+
if (sibling) close();
|
|
83
|
+
const start = item.tag === "ol" && item.start !== 1 ? ` start="${item.start}"` : "";
|
|
84
|
+
html += `<${item.tag}${start}><li>`;
|
|
85
|
+
open.push({ indent: sibling ? top.indent : item.indent, tag: item.tag });
|
|
86
|
+
}
|
|
87
|
+
html += inline(item.text.trim(), notes);
|
|
88
|
+
}
|
|
89
|
+
while (open.length) close();
|
|
90
|
+
return html;
|
|
91
|
+
}
|
|
92
|
+
function markdownToHtml(markdown, { headingLevel = 3 } = {}) {
|
|
93
|
+
const notes = /* @__PURE__ */ new Map();
|
|
94
|
+
const definitions = [];
|
|
95
|
+
const body = markdown.replace(/\r\n?/g, "\n").replace(/^\[\^([^\]]+)\]:\s*(.*)$/gm, (_, key, text) => {
|
|
96
|
+
notes.set(key, notes.size + 1);
|
|
97
|
+
definitions.push([key, text]);
|
|
98
|
+
return "";
|
|
99
|
+
});
|
|
100
|
+
const base = Math.max(headingLevel, 1);
|
|
101
|
+
const above = [];
|
|
102
|
+
const open = [];
|
|
103
|
+
const html = [];
|
|
104
|
+
for (const block of blocksOf(body)) {
|
|
105
|
+
if (block.kind === "heading") {
|
|
106
|
+
while (above.length && above[above.length - 1] >= block.depth)
|
|
107
|
+
above.pop();
|
|
108
|
+
while (open.length && open[open.length - 1] >= block.depth) {
|
|
109
|
+
open.pop();
|
|
110
|
+
html.push("</div>");
|
|
111
|
+
}
|
|
112
|
+
const level = base + above.length;
|
|
113
|
+
above.push(block.depth);
|
|
114
|
+
const text = `<b>${inline(block.text, notes)}</b>`;
|
|
115
|
+
if (level <= 6) {
|
|
116
|
+
html.push(`<p role="heading" aria-level="${level}">${text}</p>`);
|
|
117
|
+
} else {
|
|
118
|
+
const id = `clover-md-${nextGroup()}`;
|
|
119
|
+
open.push(block.depth);
|
|
120
|
+
html.push(
|
|
121
|
+
`<div role="group" aria-labelledby="${id}"><p id="${id}">${text}</p>`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
} else if (block.kind === "list") html.push(list(block.lines, notes));
|
|
125
|
+
else html.push(`<p>${inline(block.lines.join("\n").trim(), notes)}</p>`);
|
|
126
|
+
}
|
|
127
|
+
while (open.pop() !== void 0) html.push("</div>");
|
|
128
|
+
if (definitions.length) {
|
|
129
|
+
html.push(
|
|
130
|
+
`<p><small>${definitions.map(
|
|
131
|
+
([key, text]) => `<sup>${notes.get(key)}</sup> ${inline(text, notes)}`
|
|
132
|
+
).join("<br>")}</small></p>`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return html.join("");
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
markdownToHtml
|
|
139
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isPresentation4, toPresentation4 } from "./presentation.mjs";
|
|
3
|
+
import { fetchJson } from "./request.mjs";
|
|
4
|
+
const isReference = (page) => Boolean(page == null ? void 0 : page.id) && page.type === "AnnotationPage" && !page.items;
|
|
5
|
+
function referencedPages(canvases) {
|
|
6
|
+
const found = [];
|
|
7
|
+
for (const canvas of canvases) {
|
|
8
|
+
for (const list of ["items", "annotations"]) {
|
|
9
|
+
for (const page of canvas[list] ?? []) {
|
|
10
|
+
if (isReference(page)) found.push([canvas.id, list, page.id]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return found;
|
|
15
|
+
}
|
|
16
|
+
async function fetchPage(id, canvasId, request, signal) {
|
|
17
|
+
return upgradePage(await fetchJson(request, id, signal), canvasId);
|
|
18
|
+
}
|
|
19
|
+
async function upgradePage(json, canvasId = "urn:clover:annotation-page") {
|
|
20
|
+
var _a;
|
|
21
|
+
const page = json;
|
|
22
|
+
if (isPresentation4(page)) return page;
|
|
23
|
+
const canvas = await toPresentation4({
|
|
24
|
+
"@context": page["@context"] ?? "http://iiif.io/api/presentation/3/context.json",
|
|
25
|
+
id: canvasId,
|
|
26
|
+
type: "Canvas",
|
|
27
|
+
items: [{ ...page, "@context": void 0 }]
|
|
28
|
+
});
|
|
29
|
+
return ((_a = canvas.items) == null ? void 0 : _a[0]) ?? page;
|
|
30
|
+
}
|
|
31
|
+
function embedPage(manifest, canvasId, list, page) {
|
|
32
|
+
let changed = false;
|
|
33
|
+
const items = (manifest.items ?? []).map(
|
|
34
|
+
(canvas) => {
|
|
35
|
+
if (canvas.id !== canvasId || !Array.isArray(canvas[list])) return canvas;
|
|
36
|
+
const pages = canvas[list].map((existing) => {
|
|
37
|
+
if (existing.id !== page.id || !isReference(existing)) return existing;
|
|
38
|
+
changed = true;
|
|
39
|
+
return page;
|
|
40
|
+
});
|
|
41
|
+
return changed ? { ...canvas, [list]: pages } : canvas;
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
return changed ? { ...manifest, items } : manifest;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
embedPage,
|
|
48
|
+
fetchPage,
|
|
49
|
+
referencedPages,
|
|
50
|
+
upgradePage
|
|
51
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isPainting, bodiesOf } from "./painting.mjs";
|
|
3
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
4
|
+
function paintedBodies(container) {
|
|
5
|
+
const painted = [];
|
|
6
|
+
for (const page of asArray(container == null ? void 0 : container.items))
|
|
7
|
+
for (const annotation of asArray(page == null ? void 0 : page.items)) {
|
|
8
|
+
if (!isPainting(annotation)) continue;
|
|
9
|
+
for (let body of bodiesOf(annotation)) {
|
|
10
|
+
if ((body == null ? void 0 : body.type) === "Choice") body = asArray(body.items)[0];
|
|
11
|
+
if ((body == null ? void 0 : body.type) === "SpecificResource")
|
|
12
|
+
body = typeof body.source === "string" ? { id: body.source } : body.source;
|
|
13
|
+
if (body) painted.push({ body, annotation });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return painted;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
paintedBodies
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
3
|
+
const GROUPS = ["Independents", "Composite", "List"];
|
|
4
|
+
function bodiesOf(annotation) {
|
|
5
|
+
return asArray(annotation == null ? void 0 : annotation.body).flatMap(
|
|
6
|
+
(body) => GROUPS.includes(body == null ? void 0 : body.type) ? asArray(body.items) : [body]
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function isPainting(annotation) {
|
|
10
|
+
const motivations = asArray(annotation == null ? void 0 : annotation.motivation);
|
|
11
|
+
return !motivations.length || motivations.includes("painting");
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
GROUPS,
|
|
15
|
+
bodiesOf,
|
|
16
|
+
isPainting
|
|
17
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const PRESENTATION_4 = /iiif\.io\/api\/presentation\/4\/context\.json/;
|
|
3
|
+
function isPresentation4(resource) {
|
|
4
|
+
const context = resource == null ? void 0 : resource["@context"];
|
|
5
|
+
const contexts = Array.isArray(context) ? context : [context];
|
|
6
|
+
return contexts.some(
|
|
7
|
+
(value) => typeof value === "string" && PRESENTATION_4.test(value)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
let upgrader = null;
|
|
11
|
+
function preloadUpgrader() {
|
|
12
|
+
upgrader ?? (upgrader = import("@iiif/parser/presentation-4/upgrader"));
|
|
13
|
+
return upgrader;
|
|
14
|
+
}
|
|
15
|
+
async function toPresentation4(resource) {
|
|
16
|
+
if (isPresentation4(resource)) return resource;
|
|
17
|
+
const [{ upgradeToPresentation4 }, { keepFragments }] = await Promise.all([
|
|
18
|
+
preloadUpgrader(),
|
|
19
|
+
import("./keep-fragments.mjs")
|
|
20
|
+
]);
|
|
21
|
+
return upgradeToPresentation4(keepFragments(resource));
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
isPresentation4,
|
|
25
|
+
preloadUpgrader,
|
|
26
|
+
toPresentation4
|
|
27
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
3
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
4
|
+
function parseTime(t) {
|
|
5
|
+
if (!t) return void 0;
|
|
6
|
+
const [rawStart, rawEnd] = t.split(",");
|
|
7
|
+
const start = Number(rawStart);
|
|
8
|
+
if (rawStart === "" || Number.isNaN(start)) return void 0;
|
|
9
|
+
if (rawEnd === void 0 || rawEnd === "") return { start };
|
|
10
|
+
const end = Number(rawEnd);
|
|
11
|
+
return Number.isNaN(end) ? { start } : { start, end };
|
|
12
|
+
}
|
|
13
|
+
function rangeItemTarget(item) {
|
|
14
|
+
if (typeof item === "string") return restoreFragment(item);
|
|
15
|
+
const json = item;
|
|
16
|
+
if ((json == null ? void 0 : json.type) === "SpecificResource") return json;
|
|
17
|
+
return typeof (json == null ? void 0 : json.id) === "string" ? restoreFragment(json.id) : json;
|
|
18
|
+
}
|
|
19
|
+
const restoreFragment = (id) => id.replace(/\/((?:t|xywh)=[^/#]*)$/, "#$1");
|
|
20
|
+
const memo = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
const NONE = [];
|
|
22
|
+
function chaptersOf(manifest, canvasId, duration) {
|
|
23
|
+
if (!manifest || !canvasId) return NONE;
|
|
24
|
+
let byCanvas = memo.get(manifest);
|
|
25
|
+
if (!byCanvas) memo.set(manifest, byCanvas = /* @__PURE__ */ new Map());
|
|
26
|
+
const key = `${canvasId}|${duration ?? ""}`;
|
|
27
|
+
const cached = byCanvas.get(key);
|
|
28
|
+
if (cached) return cached;
|
|
29
|
+
const found = [];
|
|
30
|
+
const visited = /* @__PURE__ */ new Set();
|
|
31
|
+
const walk = (range) => {
|
|
32
|
+
if (!range || visited.has(range.id ?? range)) return;
|
|
33
|
+
visited.add(range.id ?? range);
|
|
34
|
+
for (const item of asArray(range.items)) {
|
|
35
|
+
if ((item == null ? void 0 : item.type) === "Range") {
|
|
36
|
+
walk(item);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const parsed = parseAnnotationTarget(rangeItemTarget(item));
|
|
40
|
+
if (parsed.id.split("#")[0] !== canvasId) continue;
|
|
41
|
+
const time = parseTime(parsed.t);
|
|
42
|
+
if (time)
|
|
43
|
+
found.push({
|
|
44
|
+
...range.id ? { id: range.id } : {},
|
|
45
|
+
label: range.label,
|
|
46
|
+
...time
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
for (const structure of asArray(manifest.structures)) {
|
|
51
|
+
walk(structure);
|
|
52
|
+
}
|
|
53
|
+
found.sort((a, b) => a.start - b.start);
|
|
54
|
+
const chapters = found.length ? found.map((chapter, index) => {
|
|
55
|
+
var _a;
|
|
56
|
+
return {
|
|
57
|
+
...chapter,
|
|
58
|
+
end: chapter.end ?? ((_a = found[index + 1]) == null ? void 0 : _a.start) ?? duration
|
|
59
|
+
};
|
|
60
|
+
}) : NONE;
|
|
61
|
+
byCanvas.set(key, chapters);
|
|
62
|
+
return chapters;
|
|
63
|
+
}
|
|
64
|
+
const tocs = /* @__PURE__ */ new WeakMap();
|
|
65
|
+
const NO_TOC = [];
|
|
66
|
+
function tableOfContents(manifest) {
|
|
67
|
+
if (!manifest) return NO_TOC;
|
|
68
|
+
const cached = tocs.get(manifest);
|
|
69
|
+
if (cached) return cached;
|
|
70
|
+
const visited = /* @__PURE__ */ new Set();
|
|
71
|
+
const build = (range) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
if (!range || visited.has(range.id ?? range)) return [];
|
|
74
|
+
visited.add(range.id ?? range);
|
|
75
|
+
const children = [];
|
|
76
|
+
const canvasIds = [];
|
|
77
|
+
let first;
|
|
78
|
+
for (const item of asArray(range.items)) {
|
|
79
|
+
if ((item == null ? void 0 : item.type) === "Range") {
|
|
80
|
+
const built = build(item);
|
|
81
|
+
children.push(...built);
|
|
82
|
+
built.forEach((child) => canvasIds.push(...child.canvasIds));
|
|
83
|
+
} else {
|
|
84
|
+
const parsed = parseAnnotationTarget(rangeItemTarget(item));
|
|
85
|
+
if (!parsed.id) continue;
|
|
86
|
+
first ?? (first = parsed);
|
|
87
|
+
canvasIds.push(parsed.id);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const behavior = asArray(range.behavior);
|
|
91
|
+
if (behavior.includes("no-nav")) return children;
|
|
92
|
+
const start = first ?? void 0;
|
|
93
|
+
const node = {
|
|
94
|
+
id: range.id ?? `range-${visited.size}`,
|
|
95
|
+
label: range.label,
|
|
96
|
+
canvasId: (start == null ? void 0 : start.id) ?? ((_a = children[0]) == null ? void 0 : _a.canvasId),
|
|
97
|
+
canvasIds: [...new Set(canvasIds)],
|
|
98
|
+
children
|
|
99
|
+
};
|
|
100
|
+
const time = parseTime(start == null ? void 0 : start.t);
|
|
101
|
+
if (time) node.time = time;
|
|
102
|
+
else if (!start && ((_b = children[0]) == null ? void 0 : _b.time)) node.time = children[0].time;
|
|
103
|
+
if (start == null ? void 0 : start.rect) node.region = start.rect;
|
|
104
|
+
return [node];
|
|
105
|
+
};
|
|
106
|
+
const roots = asArray(manifest.structures).flatMap(
|
|
107
|
+
build
|
|
108
|
+
);
|
|
109
|
+
const nodes = roots.length === 1 && roots[0].children.length ? roots[0].children : roots;
|
|
110
|
+
const result = nodes.length ? nodes : NO_TOC;
|
|
111
|
+
tocs.set(manifest, result);
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
function currentContents(nodes, canvasId, time) {
|
|
115
|
+
let best = null;
|
|
116
|
+
const walk = (node, depth) => {
|
|
117
|
+
if (canvasId && node.canvasIds.includes(canvasId)) {
|
|
118
|
+
const within = !node.time || time !== void 0 && time >= node.time.start && (node.time.end === void 0 || time < node.time.end);
|
|
119
|
+
if (within && (!best || depth >= best.depth))
|
|
120
|
+
best = { id: node.id, depth };
|
|
121
|
+
}
|
|
122
|
+
node.children.forEach((child) => walk(child, depth + 1));
|
|
123
|
+
};
|
|
124
|
+
nodes.forEach((node) => walk(node, 0));
|
|
125
|
+
return best ? best.id : null;
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
chaptersOf,
|
|
129
|
+
currentContents,
|
|
130
|
+
parseTime,
|
|
131
|
+
rangeItemTarget,
|
|
132
|
+
tableOfContents
|
|
133
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
3
|
+
import { findImageServiceId } from "../lib/renderer/sources/imageService.mjs";
|
|
4
|
+
import { isPainting } from "./painting.mjs";
|
|
5
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
6
|
+
function regionSource(canvas, rect) {
|
|
7
|
+
for (const page of asArray(canvas == null ? void 0 : canvas.items)) {
|
|
8
|
+
for (const annotation of asArray(page == null ? void 0 : page.items)) {
|
|
9
|
+
if (!isPainting(annotation)) continue;
|
|
10
|
+
for (const body of asArray(annotation == null ? void 0 : annotation.body)) {
|
|
11
|
+
if ((body == null ? void 0 : body.type) !== "Image" || !body.width || !body.height) continue;
|
|
12
|
+
const service = findImageServiceId(body.service);
|
|
13
|
+
if (!service) continue;
|
|
14
|
+
const target = parseAnnotationTarget(
|
|
15
|
+
asArray(annotation.target)[0]
|
|
16
|
+
).rect ?? { x: 0, y: 0, w: canvas.width, h: canvas.height };
|
|
17
|
+
const left = (rect.x - target.x) / target.w;
|
|
18
|
+
const top = (rect.y - target.y) / target.h;
|
|
19
|
+
const x = Math.max(0, left);
|
|
20
|
+
const y = Math.max(0, top);
|
|
21
|
+
const width = Math.min(1, left + rect.w / target.w) - x;
|
|
22
|
+
const height = Math.min(1, top + rect.h / target.h) - y;
|
|
23
|
+
if (!(width > 0 && height > 0)) continue;
|
|
24
|
+
return { service, region: { x, y, width, height } };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
regionSource
|
|
32
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function cloverFetch(request, url, init = {}) {
|
|
3
|
+
const run = (request == null ? void 0 : request.fetch) ?? globalThis.fetch;
|
|
4
|
+
return run(url, {
|
|
5
|
+
credentials: (request == null ? void 0 : request.credentials) ?? "same-origin",
|
|
6
|
+
...init,
|
|
7
|
+
headers: { ...init.headers, ...request == null ? void 0 : request.headers }
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
const sendsCredentials = (request) => (request == null ? void 0 : request.credentials) === "include";
|
|
11
|
+
const requestKey = (request) => JSON.stringify([request == null ? void 0 : request.credentials, request == null ? void 0 : request.headers]);
|
|
12
|
+
class CloverRequestError extends Error {
|
|
13
|
+
constructor(message, url, status) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.url = url;
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.name = "CloverRequestError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function fetchJson(request, url, signal) {
|
|
21
|
+
const response = await cloverFetch(request, url, {
|
|
22
|
+
signal,
|
|
23
|
+
headers: { Accept: "application/ld+json, application/json" }
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new CloverRequestError(
|
|
27
|
+
`${url} answered ${response.status}`,
|
|
28
|
+
url,
|
|
29
|
+
response.status
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return response.json();
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
CloverRequestError,
|
|
36
|
+
cloverFetch,
|
|
37
|
+
fetchJson,
|
|
38
|
+
requestKey,
|
|
39
|
+
sendsCredentials
|
|
40
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import DOMPurify from "dompurify";
|
|
3
|
+
const TAGS = ["a", "b", "br", "i", "img", "p", "small", "span", "sub", "sup"];
|
|
4
|
+
const ATTRIBUTES = ["href", "alt", "src", "height", "width", "lang", "dir"];
|
|
5
|
+
const URI_SAFE = ["height", "width", "lang", "dir"];
|
|
6
|
+
const URI = /^(?:https?|mailto):/i;
|
|
7
|
+
const CONFIG = {
|
|
8
|
+
ALLOWED_TAGS: TAGS,
|
|
9
|
+
ALLOWED_ATTR: ATTRIBUTES,
|
|
10
|
+
ADD_URI_SAFE_ATTR: URI_SAFE,
|
|
11
|
+
ALLOWED_URI_REGEXP: URI,
|
|
12
|
+
// Only the attributes listed: DOMPurify otherwise keeps every `aria-*` and `data-*`.
|
|
13
|
+
ALLOW_ARIA_ATTR: false,
|
|
14
|
+
ALLOW_DATA_ATTR: false
|
|
15
|
+
};
|
|
16
|
+
const MARKDOWN_CONFIG = {
|
|
17
|
+
...CONFIG,
|
|
18
|
+
ALLOWED_TAGS: [...TAGS, "ul", "ol", "li", "div"],
|
|
19
|
+
ALLOWED_ATTR: [
|
|
20
|
+
...ATTRIBUTES,
|
|
21
|
+
"role",
|
|
22
|
+
"aria-level",
|
|
23
|
+
"start",
|
|
24
|
+
"id",
|
|
25
|
+
"aria-labelledby"
|
|
26
|
+
],
|
|
27
|
+
ADD_URI_SAFE_ATTR: [
|
|
28
|
+
...URI_SAFE,
|
|
29
|
+
"aria-level",
|
|
30
|
+
"start",
|
|
31
|
+
"id",
|
|
32
|
+
"aria-labelledby"
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
const GROUP_ID = /^clover-md-\d+$/;
|
|
36
|
+
const MARKDOWN_VALUES = {
|
|
37
|
+
role: [
|
|
38
|
+
["P", /^heading$/],
|
|
39
|
+
["DIV", /^group$/]
|
|
40
|
+
],
|
|
41
|
+
"aria-level": [["P", /^[1-6]$/]],
|
|
42
|
+
start: [["OL", /^\d+$/]],
|
|
43
|
+
id: [["P", GROUP_ID]],
|
|
44
|
+
"aria-labelledby": [["DIV", GROUP_ID]]
|
|
45
|
+
};
|
|
46
|
+
let purify = null;
|
|
47
|
+
function purifier() {
|
|
48
|
+
if (purify) return purify;
|
|
49
|
+
purify = DOMPurify(window);
|
|
50
|
+
purify.addHook("afterSanitizeAttributes", (node) => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
for (const name of ["src", "href"]) {
|
|
53
|
+
const value = (_a = node.getAttribute) == null ? void 0 : _a.call(node, name);
|
|
54
|
+
if (value && !URI.test(value.trim())) node.removeAttribute(name);
|
|
55
|
+
}
|
|
56
|
+
for (const [name, allowed] of Object.entries(MARKDOWN_VALUES)) {
|
|
57
|
+
const value = (_b = node.getAttribute) == null ? void 0 : _b.call(node, name);
|
|
58
|
+
if (value != null && !allowed.some(
|
|
59
|
+
([tag, pattern]) => node.nodeName === tag && pattern.test(value)
|
|
60
|
+
))
|
|
61
|
+
node.removeAttribute(name);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return purify;
|
|
65
|
+
}
|
|
66
|
+
function sanitizeHTML(html, { markdown = false } = {}) {
|
|
67
|
+
if (typeof window === "undefined") return html;
|
|
68
|
+
return purifier().sanitize(html, markdown ? MARKDOWN_CONFIG : CONFIG);
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
sanitizeHTML
|
|
72
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
3
|
+
const SEARCH_SET_ID = "content-search";
|
|
4
|
+
const VERSION = /\/search\/([0-2])\//;
|
|
5
|
+
function searchServiceOf(manifest) {
|
|
6
|
+
if (!manifest) return null;
|
|
7
|
+
let found = null;
|
|
8
|
+
for (const service of asArray(manifest.service)) {
|
|
9
|
+
const id = (service == null ? void 0 : service.id) ?? (service == null ? void 0 : service["@id"]);
|
|
10
|
+
if (typeof id !== "string") continue;
|
|
11
|
+
const type = String(service.type ?? service["@type"] ?? "");
|
|
12
|
+
const hint = [service.profile, service["@context"]].flat().map((value) => String(value ?? "")).join(" ");
|
|
13
|
+
const version = type === "SearchService2" ? 2 : type === "SearchService1" ? 1 : VERSION.test(hint) ? Number(VERSION.exec(hint)[1]) >= 2 ? 2 : 1 : null;
|
|
14
|
+
if (version === 2) return { id, version };
|
|
15
|
+
if (version === 1) found ?? (found = { id, version });
|
|
16
|
+
}
|
|
17
|
+
return found;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
SEARCH_SET_ID,
|
|
21
|
+
searchServiceOf
|
|
22
|
+
};
|