@nulib/clover 0.0.0-stage → 4.0.0-beta.1
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 +539 -0
- package/dist/components/Map/basemap.mjs +50 -0
- package/dist/components/Map/maplibre-worker.mjs +7 -0
- package/dist/components/Map/overlayImage.mjs +17 -0
- package/dist/components/Map/worker.mjs +22 -0
- package/dist/components/Panel/About.mjs +148 -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 +210 -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 +76 -0
- package/dist/core/keep-fragments.mjs +40 -0
- package/dist/core/link.mjs +28 -0
- package/dist/core/load.mjs +183 -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 +2215 -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 +195 -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 +276 -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-DbrFSVBm.mjs +1 -0
- package/dist/web-components/AnnotationMenu-EBjIQpQl.mjs +1 -0
- package/dist/web-components/AnnotationState-DQTaO6Gz.mjs +1 -0
- package/dist/web-components/Annotations-Cb9U7HJ_.mjs +2 -0
- package/dist/web-components/Annotations-Dl0SgHBS.mjs +1 -0
- package/dist/web-components/Body-DxSz3iST.mjs +1 -0
- package/dist/web-components/BodyAlert-C8EOXz24.mjs +1 -0
- package/dist/web-components/Button-uWgfvqsL.mjs +1 -0
- package/dist/web-components/Camera-cdCqKMup.mjs +1 -0
- package/dist/web-components/Canvas2DBackend-CnLEHRs4.mjs +1 -0
- package/dist/web-components/CanvasView-BI3YzNdK.mjs +1 -0
- package/dist/web-components/CaptionDetails-B80ZhZ7v.mjs +1 -0
- package/dist/web-components/ChoiceMenu-DCp7-co7.mjs +1 -0
- package/dist/web-components/Collection-B1Le2_TU.mjs +1 -0
- package/dist/web-components/CollectionSelect-BL_jQog-.mjs +1 -0
- package/dist/web-components/Connected-BxqaRL9o.mjs +1 -0
- package/dist/web-components/Connected-DCBI-j9H.mjs +1 -0
- package/dist/web-components/Connected-DkhfVWxd.mjs +1 -0
- package/dist/web-components/Contents-zYEGHLfe.mjs +1 -0
- package/dist/web-components/ControlMenu-CAHiLAtl.mjs +1 -0
- package/dist/web-components/Cue-BT2V9VAq.mjs +1 -0
- package/dist/web-components/Document-BdCjGnJN.mjs +1 -0
- package/dist/web-components/DocumentPanel-X_Rta0Wu.mjs +1 -0
- package/dist/web-components/DomLayers-BD4QPbl6.mjs +1 -0
- package/dist/web-components/Download-DqU-goFi.mjs +1 -0
- package/dist/web-components/EntryBodies-DXAQH0vR.mjs +1 -0
- package/dist/web-components/ErrorBoundary-chQaO-Up.mjs +1 -0
- package/dist/web-components/FieldPill-CyEssPVm.mjs +1 -0
- package/dist/web-components/FrameAnimation-Bb0pOoRl.mjs +1 -0
- package/dist/web-components/Gallery-BXU3TcT3.mjs +1 -0
- package/dist/web-components/HideToggle-BwMrOBMu.mjs +1 -0
- package/dist/web-components/Items-DRj1UEpC.mjs +1 -0
- package/dist/web-components/Label-D6aVJB9s.mjs +1 -0
- package/dist/web-components/LightboxBody-BzXQGMDn.mjs +1 -0
- package/dist/web-components/Loaded-D5xmFRSo.mjs +1 -0
- package/dist/web-components/LoadedCanvas-DOjtxLSe.mjs +1 -0
- package/dist/web-components/LoadedMap-DouDS2lO.mjs +1 -0
- package/dist/web-components/Loading-CBKfwsML.mjs +1 -0
- package/dist/web-components/Map-Bcgp_R8H.mjs +1 -0
- package/dist/web-components/MapView-CD5zkTs8.mjs +1 -0
- package/dist/web-components/Markup-C1hMA8wk.mjs +2 -0
- package/dist/web-components/MediaBody-B_Gii4we.mjs +1 -0
- package/dist/web-components/MediaBody-BfrKIPte.mjs +1 -0
- package/dist/web-components/Navigator-BSJbEbuJ.mjs +1 -0
- package/dist/web-components/Pager-Di_2hHM3.mjs +1 -0
- package/dist/web-components/Panel-DbsC8A9V.mjs +1 -0
- package/dist/web-components/PanelToggle-mUDw73zI.mjs +1 -0
- package/dist/web-components/PartOfManifest-7eOwURrF.mjs +1 -0
- package/dist/web-components/Pending-BPOQ2z1L.mjs +1 -0
- package/dist/web-components/Primitives-XQO3m1wG.mjs +1 -0
- package/dist/web-components/Provider-B61118lU.mjs +1 -0
- package/dist/web-components/ReadMore-BJH-qqte.mjs +1 -0
- package/dist/web-components/Root-Dj277K6p.mjs +1 -0
- package/dist/web-components/Scene-BTWpLeec.mjs +1 -0
- package/dist/web-components/SceneView-BYo7WmPt.mjs +1 -0
- package/dist/web-components/Search-ZV8FFN4p.mjs +1 -0
- package/dist/web-components/Sections-ejwu1_Sm.mjs +2 -0
- package/dist/web-components/StandaloneItems-BYaiyCca.mjs +1 -0
- package/dist/web-components/Status-YbQK2KzY.mjs +1 -0
- package/dist/web-components/Timeline-ByyVSd7B.mjs +1 -0
- package/dist/web-components/Tip-IO11xX4x.mjs +1 -0
- package/dist/web-components/Transcript-D0gUxUoA.mjs +1 -0
- package/dist/web-components/annotation-collection-Csv7WIlm.mjs +1 -0
- package/dist/web-components/annotations-content-BS_OFz5Z.mjs +1 -0
- package/dist/web-components/assets/maplibre-gl-worker-kTz9OPxr.js +13831 -0
- package/dist/web-components/body-CKjwwFep.mjs +1 -0
- package/dist/web-components/bringIntoView-CQH5ZgMM.mjs +1 -0
- package/dist/web-components/canvas-CIzpp-Uz.mjs +1 -0
- package/dist/web-components/classnames-DukgfdpI.mjs +1 -0
- package/dist/web-components/cloverEngine-B4LinbSt.mjs +164 -0
- package/dist/web-components/content-state-reader-D1BkpICh.mjs +1 -0
- package/dist/web-components/contexts-ByL3eA_T.mjs +1 -0
- package/dist/web-components/controls-Dj2BybWb.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-BSt8LTso.mjs +4228 -0
- package/dist/web-components/engines-CC0OEsVE.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-BhemHaoA.mjs +1 -0
- package/dist/web-components/glyphs-drROkef9.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-BXzQSllm.mjs +1 -0
- package/dist/web-components/imageService-dsdmcegU.mjs +1 -0
- package/dist/web-components/index-B7nZdqLg.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-CB2Uk7ts.mjs +1 -0
- package/dist/web-components/items-jfQ5XzEj.mjs +1 -0
- package/dist/web-components/keep-fragments-B5nlv2ck.mjs +1 -0
- package/dist/web-components/label-Vbg_cMOJ.mjs +1 -0
- package/dist/web-components/languageCode-cCpiU0b0.mjs +1 -0
- package/dist/web-components/layout-mMHI0lsj.mjs +1 -0
- package/dist/web-components/link-ZRnv5NFR.mjs +1 -0
- package/dist/web-components/logo-Boy6u4m2.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-D1EE_CmH.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-B7JRwBgl.mjs +1 -0
- package/dist/web-components/overlayImage-0OgQl1TL.mjs +1 -0
- package/dist/web-components/panClearOfControls-ac9uf-Qs.mjs +1 -0
- package/dist/web-components/panel-CjXfre-g.mjs +1 -0
- package/dist/web-components/part-cUiPs2-y.mjs +1 -0
- package/dist/web-components/playerSurface-CU5XxI1j.mjs +1 -0
- package/dist/web-components/provider-C1wKfdjb.mjs +1 -0
- package/dist/web-components/pt-B3J80JgO.mjs +1 -0
- package/dist/web-components/read-more-DNHNtG-a.mjs +1 -0
- package/dist/web-components/rendererSurface-DhIlOjGT.mjs +22 -0
- package/dist/web-components/renderers-BMSWEFUR.mjs +1 -0
- package/dist/web-components/resource-DLHocQ1C.mjs +1 -0
- package/dist/web-components/sanitize-Dc7nOsgO.mjs +3 -0
- package/dist/web-components/search-CLy2Wj01.mjs +1 -0
- package/dist/web-components/shared-YUjOSBKO.mjs +1 -0
- package/dist/web-components/show-link-CyzYE1eS.mjs +1 -0
- package/dist/web-components/sizedImage-uv_NlE0l.mjs +1 -0
- package/dist/web-components/split-CYuMjp89.mjs +1 -0
- package/dist/web-components/splitting-BnQUxxgH.mjs +1 -0
- package/dist/web-components/status-Ms5L0ghK.mjs +1 -0
- package/dist/web-components/styles-CyuM_fB1.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-c2K_iQsD.mjs +1 -0
- package/dist/web-components/time-B9GZoYcm.mjs +1 -0
- package/dist/web-components/tip-dWhupWSr.mjs +1 -0
- package/dist/web-components/toggle-BQTjR1I3.mjs +1 -0
- package/dist/web-components/upgrader-XNxI-5jo.mjs +1 -0
- package/dist/web-components/useContainerName-BpJ3IWY0.mjs +1 -0
- package/dist/web-components/useNearViewport-CtLyYg9n.mjs +1 -0
- package/dist/web-components/useScrollTrack-WbG28FPD.mjs +1 -0
- package/dist/web-components/viewer/AnnotationMenu-ZKyBeyUU.mjs +1 -0
- package/dist/web-components/viewer/AnnotationState-DO33zokc.mjs +1 -0
- package/dist/web-components/viewer/Annotations-BOjhr5ks.mjs +1 -0
- package/dist/web-components/viewer/Annotations-DkLueFLK.mjs +2 -0
- package/dist/web-components/viewer/Canvas2DBackend-CAmzJD5P.mjs +1 -0
- package/dist/web-components/viewer/CaptionDetails-DOJlUtOn.mjs +1 -0
- package/dist/web-components/viewer/ChoiceMenu-BDq6H34G.mjs +1 -0
- package/dist/web-components/viewer/Collection-By3puO0V.mjs +1 -0
- package/dist/web-components/viewer/Connected-DZNO2CPf.mjs +1 -0
- package/dist/web-components/viewer/Connected-ESg5y49m.mjs +1 -0
- package/dist/web-components/viewer/Contents-B_FqDwTW.mjs +1 -0
- package/dist/web-components/viewer/ControlMenu-DdQl-dTf.mjs +1 -0
- package/dist/web-components/viewer/Cue-BTRHfiWQ.mjs +1 -0
- package/dist/web-components/viewer/Document-B9_PyD2w.mjs +1 -0
- package/dist/web-components/viewer/DocumentPanel-CtEJVPoE.mjs +1 -0
- package/dist/web-components/viewer/DomLayers-DRdQSEtN.mjs +1 -0
- package/dist/web-components/viewer/EntryBodies-CJuTRcTq.mjs +1 -0
- package/dist/web-components/viewer/FieldPill-06uwrNwE.mjs +1 -0
- package/dist/web-components/viewer/FrameAnimation-3dcDHf5q.mjs +1 -0
- package/dist/web-components/viewer/Gallery-BYasTqZc.mjs +1 -0
- package/dist/web-components/viewer/HideToggle-BxkNMX-T.mjs +1 -0
- package/dist/web-components/viewer/LightboxBody-CXMc1xOH.mjs +1 -0
- package/dist/web-components/viewer/MapView-DCerrRRV.mjs +1 -0
- package/dist/web-components/viewer/MediaBody-BdkJcyGy.mjs +1 -0
- package/dist/web-components/viewer/MediaBody-waF4KvHp.mjs +1 -0
- package/dist/web-components/viewer/Navigator-CKwDgG2x.mjs +1 -0
- package/dist/web-components/viewer/PartOfManifest-DalHJFwC.mjs +1 -0
- package/dist/web-components/viewer/Search-Di_QQfDb.mjs +1 -0
- package/dist/web-components/viewer/StandaloneItems-B9J6nnWn.mjs +1 -0
- package/dist/web-components/viewer/Transcript-aHOixfna.mjs +1 -0
- package/dist/web-components/viewer/annotation-collection-I2UkdobR.mjs +1 -0
- package/dist/web-components/viewer/annotations-content-D-i4j9pD.mjs +1 -0
- package/dist/web-components/viewer/cloverEngine-CynoKdta.mjs +164 -0
- package/dist/web-components/viewer/content-state-reader-D7GIMcKK.mjs +1 -0
- package/dist/web-components/viewer/host-DlCltI_c.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-BX-wzj1u.mjs +1 -0
- package/dist/web-components/viewer/overlayImage-CHqn1fG8.mjs +1 -0
- package/dist/web-components/viewer/renderers-C_wdmw9v.mjs +1 -0
- package/dist/web-components/viewer/search-BHLyNxZ6.mjs +1 -0
- package/dist/web-components/viewer/styles-BRCkEU3w.mjs +1 -0
- package/dist/web-components/viewer/viewer-ipqAA-xQ.mjs +28 -0
- package/dist/web-components/viewer/vtt-XiS_-5Ao.mjs +5 -0
- package/dist/web-components/viewer-DEHIsIHd.mjs +1 -0
- package/dist/web-components/vtt-DYAOuQoK.mjs +5 -0
- package/dist/web-components/worker-CjXN0dku.mjs +1 -0
- package/package.json +111 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
3
|
+
import { fetchJson } from "./request.mjs";
|
|
4
|
+
import { SEARCH_SET_ID } from "./search-service.mjs";
|
|
5
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
6
|
+
const MAX_PAGES = 10;
|
|
7
|
+
async function searchInto(store, service, query, request, signal) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const manifestId = (_a = store.get().manifest) == null ? void 0 : _a.id;
|
|
10
|
+
try {
|
|
11
|
+
const { hits, set } = await search(service, query, { request, signal });
|
|
12
|
+
if (signal.aborted || ((_b = store.get().manifest) == null ? void 0 : _b.id) !== manifestId) return;
|
|
13
|
+
store.set({ search: { query, status: "ready", hits, set } });
|
|
14
|
+
} catch {
|
|
15
|
+
if (signal.aborted) return;
|
|
16
|
+
store.set({ search: { query, status: "error", hits: [], set: null } });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function search(service, query, { request, signal } = {}) {
|
|
20
|
+
const url = new URL(service.id);
|
|
21
|
+
url.searchParams.set("q", query);
|
|
22
|
+
const pages = [];
|
|
23
|
+
let next = url.toString();
|
|
24
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25
|
+
while (next && pages.length < MAX_PAGES && !seen.has(next)) {
|
|
26
|
+
seen.add(next);
|
|
27
|
+
const page = await fetchJson(request, next, signal);
|
|
28
|
+
pages.push(page);
|
|
29
|
+
next = nextPage(page);
|
|
30
|
+
}
|
|
31
|
+
return readResults(pages, query);
|
|
32
|
+
}
|
|
33
|
+
function targetV1(on) {
|
|
34
|
+
var _a;
|
|
35
|
+
const value = asArray(on)[0];
|
|
36
|
+
if (typeof value === "string" || !value) return value;
|
|
37
|
+
const full = value.full ?? value["@id"];
|
|
38
|
+
const fragment = (_a = asArray(value.selector)[0]) == null ? void 0 : _a.value;
|
|
39
|
+
return typeof fragment === "string" && typeof full === "string" ? `${full}#${fragment}` : full;
|
|
40
|
+
}
|
|
41
|
+
function nextPage(page) {
|
|
42
|
+
var _a;
|
|
43
|
+
const next = page.next ?? ((_a = page.within) == null ? void 0 : _a.next);
|
|
44
|
+
const id = typeof next === "string" ? next : (next == null ? void 0 : next.id) ?? (next == null ? void 0 : next["@id"]);
|
|
45
|
+
return typeof id === "string" ? id : null;
|
|
46
|
+
}
|
|
47
|
+
function readResults(pages, query) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const entries = [];
|
|
50
|
+
const hits = [];
|
|
51
|
+
for (const page of pages) {
|
|
52
|
+
const v1 = Array.isArray(page.resources);
|
|
53
|
+
const annotations = v1 ? page.resources : asArray(page.items);
|
|
54
|
+
const byId = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const annotation of annotations) {
|
|
56
|
+
const id = annotation.id ?? annotation["@id"];
|
|
57
|
+
const raw = v1 ? targetV1(annotation.on) : asArray(annotation.target)[0];
|
|
58
|
+
const target = parseAnnotationTarget(raw);
|
|
59
|
+
if (!id || !target.id) continue;
|
|
60
|
+
const text = v1 ? (_a = annotation.resource) == null ? void 0 : _a.chars : asArray(annotation.body).map((body) => body == null ? void 0 : body.value).find((value) => typeof value === "string");
|
|
61
|
+
const entry = {
|
|
62
|
+
id,
|
|
63
|
+
setId: SEARCH_SET_ID,
|
|
64
|
+
canvasId: target.id,
|
|
65
|
+
target,
|
|
66
|
+
motivation: ["highlighting"],
|
|
67
|
+
bodies: [{ value: String(text ?? query) }],
|
|
68
|
+
// One shape for the Canvas whichever version answered: a highlighting annotation.
|
|
69
|
+
annotation: {
|
|
70
|
+
id,
|
|
71
|
+
type: "Annotation",
|
|
72
|
+
motivation: ["highlighting"],
|
|
73
|
+
body: { type: "TextualBody", value: String(text ?? query) },
|
|
74
|
+
target: raw
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
byId.set(id, entry);
|
|
78
|
+
entries.push(entry);
|
|
79
|
+
}
|
|
80
|
+
const grouped = v1 ? readHitsV1(page, byId) : readHitsV2(page, byId);
|
|
81
|
+
const listed = new Set(grouped.flatMap((hit) => hit.entryIds));
|
|
82
|
+
hits.push(...grouped);
|
|
83
|
+
for (const entry of byId.values()) {
|
|
84
|
+
if (listed.has(entry.id)) continue;
|
|
85
|
+
hits.push({
|
|
86
|
+
id: entry.id,
|
|
87
|
+
canvasId: entry.canvasId,
|
|
88
|
+
entryIds: [entry.id],
|
|
89
|
+
match: ((_b = entry.bodies[0]) == null ? void 0 : _b.value) ?? query
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
query,
|
|
95
|
+
hits,
|
|
96
|
+
set: {
|
|
97
|
+
id: SEARCH_SET_ID,
|
|
98
|
+
label: { none: [query] },
|
|
99
|
+
source: "search",
|
|
100
|
+
entries
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function readHitsV1(page, byId) {
|
|
105
|
+
var _a;
|
|
106
|
+
const hits = [];
|
|
107
|
+
for (const hit of asArray(page.hits)) {
|
|
108
|
+
const entryIds = asArray(hit.annotations).filter(
|
|
109
|
+
(id) => byId.has(id)
|
|
110
|
+
);
|
|
111
|
+
if (!entryIds.length) continue;
|
|
112
|
+
hits.push({
|
|
113
|
+
id: entryIds.join(" "),
|
|
114
|
+
canvasId: byId.get(entryIds[0]).canvasId,
|
|
115
|
+
entryIds,
|
|
116
|
+
before: hit.before,
|
|
117
|
+
match: String(hit.match ?? ((_a = byId.get(entryIds[0]).bodies[0]) == null ? void 0 : _a.value) ?? ""),
|
|
118
|
+
after: hit.after
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return hits;
|
|
122
|
+
}
|
|
123
|
+
function readHitsV2(page, byId) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
const hits = [];
|
|
126
|
+
for (const group of asArray(page.annotations)) {
|
|
127
|
+
for (const annotation of asArray(group == null ? void 0 : group.items)) {
|
|
128
|
+
const motivation = asArray(annotation == null ? void 0 : annotation.motivation);
|
|
129
|
+
if (!motivation.includes("contextualizing")) continue;
|
|
130
|
+
for (const target of asArray(annotation.target)) {
|
|
131
|
+
const source = typeof (target == null ? void 0 : target.source) === "string" ? target.source : (_a = target == null ? void 0 : target.source) == null ? void 0 : _a.id;
|
|
132
|
+
const entry = source ? byId.get(source) : void 0;
|
|
133
|
+
if (!entry) continue;
|
|
134
|
+
const quote = asArray(target.selector).find(
|
|
135
|
+
(selector) => (selector == null ? void 0 : selector.type) === "TextQuoteSelector"
|
|
136
|
+
);
|
|
137
|
+
hits.push({
|
|
138
|
+
id: `${annotation.id ?? source}#${source}`,
|
|
139
|
+
canvasId: entry.canvasId,
|
|
140
|
+
entryIds: [entry.id],
|
|
141
|
+
before: quote == null ? void 0 : quote.prefix,
|
|
142
|
+
match: String((quote == null ? void 0 : quote.exact) ?? ((_b = entry.bodies[0]) == null ? void 0 : _b.value) ?? ""),
|
|
143
|
+
after: quote == null ? void 0 : quote.suffix
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return hits;
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
readResults,
|
|
152
|
+
search,
|
|
153
|
+
searchInto
|
|
154
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveDirection, groupViews, resolveBehavior, viewOf } from "./sequence.mjs";
|
|
3
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
4
|
+
const sequences = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const EMPTY = { canvases: [], views: [], direction: "left-to-right" };
|
|
6
|
+
function selectSequence(manifest) {
|
|
7
|
+
if (!manifest) return EMPTY;
|
|
8
|
+
let sequence = sequences.get(manifest);
|
|
9
|
+
if (!sequence) {
|
|
10
|
+
const canvases = (manifest.items ?? []).filter(
|
|
11
|
+
// `Body` draws each with its own part: `Canvas`, `Timeline` or `Scene`.
|
|
12
|
+
(item) => (item == null ? void 0 : item.type) === "Canvas" || (item == null ? void 0 : item.type) === "Timeline" || (item == null ? void 0 : item.type) === "Scene"
|
|
13
|
+
);
|
|
14
|
+
sequence = {
|
|
15
|
+
canvases,
|
|
16
|
+
views: groupViews(
|
|
17
|
+
canvases,
|
|
18
|
+
resolveBehavior(manifest.behavior)
|
|
19
|
+
),
|
|
20
|
+
direction: resolveDirection(
|
|
21
|
+
manifest.viewingDirection
|
|
22
|
+
)
|
|
23
|
+
};
|
|
24
|
+
sequences.set(manifest, sequence);
|
|
25
|
+
}
|
|
26
|
+
return sequence;
|
|
27
|
+
}
|
|
28
|
+
const byId = /* @__PURE__ */ new WeakMap();
|
|
29
|
+
function selectCanvas(manifest, id) {
|
|
30
|
+
if (!id) return null;
|
|
31
|
+
const sequence = selectSequence(manifest);
|
|
32
|
+
let canvases = byId.get(sequence);
|
|
33
|
+
if (!canvases) {
|
|
34
|
+
canvases = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const canvas of sequence.canvases)
|
|
36
|
+
if (!canvases.has(canvas.id)) canvases.set(canvas.id, canvas);
|
|
37
|
+
byId.set(sequence, canvases);
|
|
38
|
+
}
|
|
39
|
+
return canvases.get(id) ?? null;
|
|
40
|
+
}
|
|
41
|
+
function selectPosition(manifest, canvasId) {
|
|
42
|
+
const { canvases, views } = selectSequence(manifest);
|
|
43
|
+
const index = canvases.findIndex((canvas) => canvas.id === canvasId);
|
|
44
|
+
return index === -1 ? 0 : viewOf(views, index);
|
|
45
|
+
}
|
|
46
|
+
const visible = /* @__PURE__ */ new WeakMap();
|
|
47
|
+
const NONE = [];
|
|
48
|
+
function selectVisibleCanvases(manifest, canvasId) {
|
|
49
|
+
if (!manifest) return NONE;
|
|
50
|
+
const position = selectPosition(manifest, canvasId);
|
|
51
|
+
let byView = visible.get(manifest);
|
|
52
|
+
if (!byView) visible.set(manifest, byView = /* @__PURE__ */ new Map());
|
|
53
|
+
let canvases = byView.get(position);
|
|
54
|
+
if (!canvases) {
|
|
55
|
+
const sequence = selectSequence(manifest);
|
|
56
|
+
canvases = (sequence.views[position] ?? []).map(
|
|
57
|
+
(index) => sequence.canvases[index]
|
|
58
|
+
);
|
|
59
|
+
byView.set(position, canvases);
|
|
60
|
+
}
|
|
61
|
+
return canvases;
|
|
62
|
+
}
|
|
63
|
+
function canvasOfView(manifest, view) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
const { canvases, views } = selectSequence(manifest);
|
|
66
|
+
const index = (_a = views[view]) == null ? void 0 : _a[0];
|
|
67
|
+
return index === void 0 ? null : ((_b = canvases[index]) == null ? void 0 : _b.id) ?? null;
|
|
68
|
+
}
|
|
69
|
+
function selectStart(manifest) {
|
|
70
|
+
const start = manifest == null ? void 0 : manifest.start;
|
|
71
|
+
if (!start) return null;
|
|
72
|
+
const parsed = parseAnnotationTarget(start);
|
|
73
|
+
if (!parsed.id) return null;
|
|
74
|
+
const target = { canvasId: parsed.id };
|
|
75
|
+
if (parsed.rect) target.region = parsed.rect;
|
|
76
|
+
const time = parsed.t ? Number(parsed.t.split(",")[0]) : NaN;
|
|
77
|
+
if (Number.isFinite(time)) target.time = time;
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
const hasBehavior = (resource, value) => {
|
|
81
|
+
const behavior = resource == null ? void 0 : resource.behavior;
|
|
82
|
+
return Array.isArray(behavior) ? behavior.includes(value) : behavior === value;
|
|
83
|
+
};
|
|
84
|
+
const partOfCollection = (manifest) => [(manifest == null ? void 0 : manifest.partOf) ?? []].flat().find((part) => (part == null ? void 0 : part.id) && part.type === "Collection");
|
|
85
|
+
export {
|
|
86
|
+
canvasOfView,
|
|
87
|
+
hasBehavior,
|
|
88
|
+
partOfCollection,
|
|
89
|
+
selectCanvas,
|
|
90
|
+
selectPosition,
|
|
91
|
+
selectSequence,
|
|
92
|
+
selectStart,
|
|
93
|
+
selectVisibleCanvases
|
|
94
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
3
|
+
const DIRECTIONS = [
|
|
4
|
+
"left-to-right",
|
|
5
|
+
"right-to-left",
|
|
6
|
+
"top-to-bottom",
|
|
7
|
+
"bottom-to-top"
|
|
8
|
+
];
|
|
9
|
+
function resolveDirection(declared) {
|
|
10
|
+
return DIRECTIONS.includes(declared) ? declared : "left-to-right";
|
|
11
|
+
}
|
|
12
|
+
const LAYOUT_BEHAVIORS = [
|
|
13
|
+
"individuals",
|
|
14
|
+
"paged",
|
|
15
|
+
"continuous",
|
|
16
|
+
"unordered"
|
|
17
|
+
];
|
|
18
|
+
function resolveBehavior(declared) {
|
|
19
|
+
const match = asArray(declared).find(
|
|
20
|
+
(value) => LAYOUT_BEHAVIORS.includes(value)
|
|
21
|
+
);
|
|
22
|
+
return match ?? "individuals";
|
|
23
|
+
}
|
|
24
|
+
function groupViews(canvases, behavior) {
|
|
25
|
+
if (!canvases.length) return [];
|
|
26
|
+
if (behavior === "continuous") return [canvases.map((_, index) => index)];
|
|
27
|
+
if (behavior !== "paged") return canvases.map((_, index) => [index]);
|
|
28
|
+
const views = [];
|
|
29
|
+
let pending = [];
|
|
30
|
+
let offset = 0;
|
|
31
|
+
let closeNextPair = false;
|
|
32
|
+
const flush = () => {
|
|
33
|
+
if (pending.length) views.push(pending);
|
|
34
|
+
pending = [];
|
|
35
|
+
};
|
|
36
|
+
canvases.forEach((canvas, index) => {
|
|
37
|
+
const own = asArray(canvas.behavior);
|
|
38
|
+
if (own.includes("non-paged")) {
|
|
39
|
+
if (index === offset) offset++;
|
|
40
|
+
flush();
|
|
41
|
+
views.push([index]);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (index === offset || own.includes("facing-pages")) {
|
|
45
|
+
if (pending.length) closeNextPair = true;
|
|
46
|
+
flush();
|
|
47
|
+
views.push([index]);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
pending.push(index);
|
|
51
|
+
if (closeNextPair) {
|
|
52
|
+
flush();
|
|
53
|
+
closeNextPair = false;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (pending.length > 1) flush();
|
|
57
|
+
});
|
|
58
|
+
flush();
|
|
59
|
+
return views;
|
|
60
|
+
}
|
|
61
|
+
function viewOf(views, canvasIndex) {
|
|
62
|
+
const found = views.findIndex((view) => view.includes(canvasIndex));
|
|
63
|
+
return found === -1 ? 0 : found;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
groupViews,
|
|
67
|
+
resolveBehavior,
|
|
68
|
+
resolveDirection,
|
|
69
|
+
viewOf
|
|
70
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { selectSequence } from "./selectors.mjs";
|
|
3
|
+
function showLink(clover, link) {
|
|
4
|
+
const shown = clover.store.get().manifest;
|
|
5
|
+
const here = link.canvasId && selectSequence(shown).canvases.some(
|
|
6
|
+
(canvas) => canvas.id === link.canvasId
|
|
7
|
+
);
|
|
8
|
+
if (here) clover.goTo(link.canvasId);
|
|
9
|
+
else if (link.manifestId && link.manifestId !== (shown == null ? void 0 : shown.id))
|
|
10
|
+
void clover.goToManifest(link.manifestId, link.canvasId);
|
|
11
|
+
else return false;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
showLink
|
|
16
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function createStore(initial) {
|
|
3
|
+
let state = initial;
|
|
4
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
return {
|
|
6
|
+
get: () => state,
|
|
7
|
+
set(patch) {
|
|
8
|
+
const next = typeof patch === "function" ? patch(state) : patch;
|
|
9
|
+
const changed = Object.keys(next).some(
|
|
10
|
+
(key) => !Object.is(next[key], state[key])
|
|
11
|
+
);
|
|
12
|
+
if (!changed) return;
|
|
13
|
+
state = { ...state, ...next };
|
|
14
|
+
listeners.forEach((listener) => listener());
|
|
15
|
+
},
|
|
16
|
+
subscribe(listener) {
|
|
17
|
+
listeners.add(listener);
|
|
18
|
+
return () => listeners.delete(listener);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function createChannel(initial) {
|
|
23
|
+
let value = initial;
|
|
24
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
25
|
+
return {
|
|
26
|
+
get: () => value,
|
|
27
|
+
emit(next) {
|
|
28
|
+
value = next;
|
|
29
|
+
listeners.forEach((listener) => listener(next));
|
|
30
|
+
},
|
|
31
|
+
subscribe(listener) {
|
|
32
|
+
listeners.add(listener);
|
|
33
|
+
return () => listeners.delete(listener);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
createChannel,
|
|
39
|
+
createStore
|
|
40
|
+
};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const NUMBER = /^-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;
|
|
3
|
+
const POINTS = /^[\d\s.,eE+-]*$/;
|
|
4
|
+
const PATH = /^[\d\s.,eE+\-MmLlHhVvCcSsQqTtAaZz]*$/;
|
|
5
|
+
const GEOMETRY = {
|
|
6
|
+
path: ["d"],
|
|
7
|
+
polygon: ["points"],
|
|
8
|
+
polyline: ["points"],
|
|
9
|
+
rect: ["x", "y", "width", "height", "rx", "ry"],
|
|
10
|
+
circle: ["cx", "cy", "r"],
|
|
11
|
+
ellipse: ["cx", "cy", "rx", "ry"],
|
|
12
|
+
line: ["x1", "y1", "x2", "y2"]
|
|
13
|
+
};
|
|
14
|
+
function readSvgShape(svg) {
|
|
15
|
+
var _a;
|
|
16
|
+
if (typeof DOMParser === "undefined" || !svg) return null;
|
|
17
|
+
let doc;
|
|
18
|
+
try {
|
|
19
|
+
doc = new DOMParser().parseFromString(svg, "image/svg+xml");
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (doc.querySelector("parsererror")) return null;
|
|
24
|
+
const shapes = [];
|
|
25
|
+
const points = [];
|
|
26
|
+
for (const element of Array.from(
|
|
27
|
+
doc.querySelectorAll(Object.keys(GEOMETRY).join(","))
|
|
28
|
+
)) {
|
|
29
|
+
const tag = element.localName;
|
|
30
|
+
const attributes = {};
|
|
31
|
+
for (const name of GEOMETRY[tag]) {
|
|
32
|
+
const value = (_a = element.getAttribute(name)) == null ? void 0 : _a.trim();
|
|
33
|
+
if (value == null || value === "") continue;
|
|
34
|
+
const valid = name === "d" ? PATH.test(value) : name === "points" ? POINTS.test(value) : NUMBER.test(value);
|
|
35
|
+
if (valid) attributes[name] = value;
|
|
36
|
+
}
|
|
37
|
+
const extent = extentOf(tag, attributes);
|
|
38
|
+
if (!extent.length) continue;
|
|
39
|
+
shapes.push({ tag, attributes });
|
|
40
|
+
points.push(...extent);
|
|
41
|
+
}
|
|
42
|
+
if (!shapes.length) return null;
|
|
43
|
+
const xs = points.map(([x2]) => x2);
|
|
44
|
+
const ys = points.map(([, y2]) => y2);
|
|
45
|
+
const x = Math.min(...xs);
|
|
46
|
+
const y = Math.min(...ys);
|
|
47
|
+
const width = Math.max(...xs) - x;
|
|
48
|
+
const height = Math.max(...ys) - y;
|
|
49
|
+
if (![x, y, width, height].every(Number.isFinite)) return null;
|
|
50
|
+
return { box: { x, y, width, height }, shapes };
|
|
51
|
+
}
|
|
52
|
+
const num = (attributes, name) => Number(attributes[name] ?? 0);
|
|
53
|
+
function extentOf(tag, attributes) {
|
|
54
|
+
switch (tag) {
|
|
55
|
+
case "polygon":
|
|
56
|
+
case "polyline": {
|
|
57
|
+
const values = (attributes.points ?? "").trim().split(/[\s,]+/).filter(Boolean).map(Number);
|
|
58
|
+
const pairs = [];
|
|
59
|
+
for (let i = 0; i + 1 < values.length; i += 2) {
|
|
60
|
+
pairs.push([values[i], values[i + 1]]);
|
|
61
|
+
}
|
|
62
|
+
return pairs.length >= 2 ? pairs : [];
|
|
63
|
+
}
|
|
64
|
+
case "rect": {
|
|
65
|
+
const [x, y, w, h] = ["x", "y", "width", "height"].map(
|
|
66
|
+
(n) => num(attributes, n)
|
|
67
|
+
);
|
|
68
|
+
return w > 0 && h > 0 ? [
|
|
69
|
+
[x, y],
|
|
70
|
+
[x + w, y + h]
|
|
71
|
+
] : [];
|
|
72
|
+
}
|
|
73
|
+
case "circle": {
|
|
74
|
+
const [cx, cy, r] = ["cx", "cy", "r"].map((n) => num(attributes, n));
|
|
75
|
+
return r > 0 ? [
|
|
76
|
+
[cx - r, cy - r],
|
|
77
|
+
[cx + r, cy + r]
|
|
78
|
+
] : [];
|
|
79
|
+
}
|
|
80
|
+
case "ellipse": {
|
|
81
|
+
const [cx, cy, rx, ry] = ["cx", "cy", "rx", "ry"].map(
|
|
82
|
+
(n) => num(attributes, n)
|
|
83
|
+
);
|
|
84
|
+
return rx > 0 && ry > 0 ? [
|
|
85
|
+
[cx - rx, cy - ry],
|
|
86
|
+
[cx + rx, cy + ry]
|
|
87
|
+
] : [];
|
|
88
|
+
}
|
|
89
|
+
case "line":
|
|
90
|
+
return [
|
|
91
|
+
[num(attributes, "x1"), num(attributes, "y1")],
|
|
92
|
+
[num(attributes, "x2"), num(attributes, "y2")]
|
|
93
|
+
];
|
|
94
|
+
case "path":
|
|
95
|
+
return pathExtent(attributes.d ?? "");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function pathExtent(d) {
|
|
99
|
+
const tokens = d.match(
|
|
100
|
+
/[MmLlHhVvCcSsQqTtAaZz]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi
|
|
101
|
+
);
|
|
102
|
+
if (!tokens) return [];
|
|
103
|
+
const out = [];
|
|
104
|
+
let x = 0;
|
|
105
|
+
let y = 0;
|
|
106
|
+
let startX = 0;
|
|
107
|
+
let startY = 0;
|
|
108
|
+
let command = "";
|
|
109
|
+
let i = 0;
|
|
110
|
+
const next = () => Number(tokens[i++]);
|
|
111
|
+
const hasNumber = () => i < tokens.length && !/[a-z]/i.test(tokens[i]);
|
|
112
|
+
while (i < tokens.length) {
|
|
113
|
+
if (/[a-z]/i.test(tokens[i])) command = tokens[i++];
|
|
114
|
+
else if (!command) return [];
|
|
115
|
+
const relative = command === command.toLowerCase();
|
|
116
|
+
const upper = command.toUpperCase();
|
|
117
|
+
const at = (dx, dy) => relative ? [x + dx, y + dy] : [dx, dy];
|
|
118
|
+
if (upper === "Z") {
|
|
119
|
+
x = startX;
|
|
120
|
+
y = startY;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (!hasNumber()) return out;
|
|
124
|
+
switch (upper) {
|
|
125
|
+
case "M":
|
|
126
|
+
case "L":
|
|
127
|
+
case "T": {
|
|
128
|
+
[x, y] = at(next(), next());
|
|
129
|
+
if (upper === "M") {
|
|
130
|
+
startX = x;
|
|
131
|
+
startY = y;
|
|
132
|
+
command = relative ? "l" : "L";
|
|
133
|
+
}
|
|
134
|
+
out.push([x, y]);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "H":
|
|
138
|
+
x = relative ? x + next() : next();
|
|
139
|
+
out.push([x, y]);
|
|
140
|
+
break;
|
|
141
|
+
case "V":
|
|
142
|
+
y = relative ? y + next() : next();
|
|
143
|
+
out.push([x, y]);
|
|
144
|
+
break;
|
|
145
|
+
case "C": {
|
|
146
|
+
const c1 = at(next(), next());
|
|
147
|
+
const c2 = at(next(), next());
|
|
148
|
+
[x, y] = at(next(), next());
|
|
149
|
+
out.push(c1, c2, [x, y]);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case "S":
|
|
153
|
+
case "Q": {
|
|
154
|
+
const c = at(next(), next());
|
|
155
|
+
[x, y] = at(next(), next());
|
|
156
|
+
out.push(c, [x, y]);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "A": {
|
|
160
|
+
const rx = Math.abs(next());
|
|
161
|
+
const ry = Math.abs(next());
|
|
162
|
+
i += 3;
|
|
163
|
+
const from = [x, y];
|
|
164
|
+
[x, y] = at(next(), next());
|
|
165
|
+
out.push(
|
|
166
|
+
[Math.min(from[0], x) - rx, Math.min(from[1], y) - ry],
|
|
167
|
+
[Math.max(from[0], x) + rx, Math.max(from[1], y) + ry]
|
|
168
|
+
);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
if (out.some(([px, py]) => !Number.isFinite(px) || !Number.isFinite(py))) {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
pathExtent,
|
|
182
|
+
readSvgShape
|
|
183
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const ENTITIES = {
|
|
3
|
+
amp: "&",
|
|
4
|
+
lt: "<",
|
|
5
|
+
gt: ">",
|
|
6
|
+
quot: '"',
|
|
7
|
+
apos: "'",
|
|
8
|
+
nbsp: " "
|
|
9
|
+
};
|
|
10
|
+
function toPlainText(html) {
|
|
11
|
+
return html.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (match, entity) => {
|
|
12
|
+
if (entity[0] === "#") {
|
|
13
|
+
const code = entity[1] === "x" || entity[1] === "X" ? parseInt(entity.slice(2), 16) : parseInt(entity.slice(1), 10);
|
|
14
|
+
return code > 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
|
|
15
|
+
}
|
|
16
|
+
return ENTITIES[entity.toLowerCase()] ?? match;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const hasMarkup = (value) => /<[a-z!/]|&(#x?[0-9a-f]+|[a-z]+);/i.test(value);
|
|
20
|
+
function readAs(format, value = "") {
|
|
21
|
+
const type = format == null ? void 0 : format.split(";")[0].trim().toLowerCase();
|
|
22
|
+
if (type) {
|
|
23
|
+
return type === "text/html" ? "html" : type === "text/markdown" ? "markdown" : "plain";
|
|
24
|
+
}
|
|
25
|
+
const text = value.trim();
|
|
26
|
+
return text.startsWith("<") && text.endsWith(">") ? "html" : "plain";
|
|
27
|
+
}
|
|
28
|
+
function markdownToPlainText(markdown) {
|
|
29
|
+
return markdown.replace(/\r\n?/g, "\n").replace(/^\[\^[^\]]+\]:[ \t]*/gm, "").replace(/\[\^[^\]]+\]/g, "").replace(/^#{1,6}[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/gm, "$1").replace(/^[ \t]*(?:[-*+]|\d+[.)])[ \t]+/gm, "").replace(/\[([^\]]+)\]\((?:https?:\/\/|mailto:)[^\s)]+\)/g, "$1").replace(/\*\*([^*]+)\*\*|__([^_]+)__/g, (_, a, b) => a ?? b).replace(/\*([^*\s][^*]*)\*|_([^_\s][^_]*)_/g, (_, a, b) => a ?? b).replace(/\\\n/g, "\n").replace(/\n\s*\n/g, "\n").trim();
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
hasMarkup,
|
|
33
|
+
markdownToPlainText,
|
|
34
|
+
readAs,
|
|
35
|
+
toPlainText
|
|
36
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { fetchInfo, findImageServiceId } from "../lib/renderer/sources/imageService.mjs";
|
|
3
|
+
import { sizedImageUrl } from "../lib/renderer/sources/sizedImage.mjs";
|
|
4
|
+
import { paintedBodies } from "./painted-bodies.mjs";
|
|
5
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
6
|
+
function firstPaintedImage(container) {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = paintedBodies(container).find(
|
|
9
|
+
({ body }) => body.type === "Image" || body.id && !body.type
|
|
10
|
+
)) == null ? void 0 : _a.body;
|
|
11
|
+
}
|
|
12
|
+
function regionShare(region, { width, height }) {
|
|
13
|
+
if (region === "full") return { x: 0, y: 0, width: 1, height: 1 };
|
|
14
|
+
const match = /^(pct:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)$/.exec(region);
|
|
15
|
+
if (!match) return null;
|
|
16
|
+
const [x, y, w, h] = match.slice(2).map(Number);
|
|
17
|
+
const [across, down] = match[1] ? [100, 100] : [width, height];
|
|
18
|
+
return { x: x / across, y: y / down, width: w / across, height: h / down };
|
|
19
|
+
}
|
|
20
|
+
function imageSource(image, region = "full") {
|
|
21
|
+
if (!image) return null;
|
|
22
|
+
const service = findImageServiceId(image.service);
|
|
23
|
+
if (service) {
|
|
24
|
+
return region === "full" ? { service, fallback: image.id } : { service, region, fallback: image.id };
|
|
25
|
+
}
|
|
26
|
+
return image.id ? { src: image.id } : null;
|
|
27
|
+
}
|
|
28
|
+
function thumbnailSource(resource) {
|
|
29
|
+
const value = resource;
|
|
30
|
+
if (!value) return null;
|
|
31
|
+
return imageSource(asArray(value.thumbnail)[0]) ?? imageSource(firstPaintedImage(value)) ?? imageSource(firstPaintedImage(value.placeholderContainer)) ?? imageSource(firstPaintedImage(value.accompanyingContainer));
|
|
32
|
+
}
|
|
33
|
+
function stillSource(resource) {
|
|
34
|
+
const value = resource;
|
|
35
|
+
if (!value) return null;
|
|
36
|
+
return imageSource(firstPaintedImage(value)) ?? imageSource(firstPaintedImage(value.placeholderContainer)) ?? imageSource(firstPaintedImage(value.accompanyingContainer)) ?? imageSource(asArray(value.thumbnail)[0]);
|
|
37
|
+
}
|
|
38
|
+
async function resolveThumbnail(source, size = 200, request) {
|
|
39
|
+
if (source.src) return source.src;
|
|
40
|
+
if (!source.service) return source.fallback;
|
|
41
|
+
try {
|
|
42
|
+
const info = await fetchInfo(source.service, { request });
|
|
43
|
+
const share = typeof source.region === "string" ? regionShare(source.region, info) : source.region;
|
|
44
|
+
if (share === null) return source.fallback;
|
|
45
|
+
return sizedImageUrl(info, size, share) ?? source.fallback;
|
|
46
|
+
} catch {
|
|
47
|
+
return source.fallback;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
imageSource,
|
|
52
|
+
resolveThumbnail,
|
|
53
|
+
stillSource,
|
|
54
|
+
thumbnailSource
|
|
55
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { readerLanguages } from "../i18n/reader.mjs";
|
|
3
|
+
const baseOf = (tag) => tag.indexOf("-") === -1 ? null : tag.slice(0, tag.indexOf("-"));
|
|
4
|
+
function closestLanguage(language, tags, fallbacks = []) {
|
|
5
|
+
if (!tags.length) return void 0;
|
|
6
|
+
if (tags.length === 1) return tags[0];
|
|
7
|
+
const none = () => tags.includes("none") ? "none" : tags.includes("@none") ? "@none" : tags[0];
|
|
8
|
+
if (!language) return tags.includes("none") ? "none" : tags[0];
|
|
9
|
+
if (tags.includes(language)) return language;
|
|
10
|
+
const base = baseOf(language);
|
|
11
|
+
if (base && tags.includes(base)) return base;
|
|
12
|
+
const fallback = fallbacks.find((tag) => tags.includes(tag));
|
|
13
|
+
if (fallback) return fallback;
|
|
14
|
+
const regional = tags.findIndex((tag) => baseOf(tag) === language);
|
|
15
|
+
if (regional !== -1) return tags[regional];
|
|
16
|
+
for (const tag of fallbacks) {
|
|
17
|
+
const fallbackBase = baseOf(tag);
|
|
18
|
+
if (fallbackBase && tags.includes(fallbackBase)) return fallbackBase;
|
|
19
|
+
}
|
|
20
|
+
return none();
|
|
21
|
+
}
|
|
22
|
+
function localize(value, language, separator = ", ") {
|
|
23
|
+
if (!value) return { text: "" };
|
|
24
|
+
if (typeof value === "string") return { text: value };
|
|
25
|
+
const tags = Object.keys(value).filter((tag2) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = value[tag2]) == null ? void 0 : _a.length;
|
|
28
|
+
});
|
|
29
|
+
if (!tags.length) return { text: "" };
|
|
30
|
+
const [first, ...rest] = language ? [language] : readerLanguages();
|
|
31
|
+
const tag = closestLanguage(first, tags, rest) ?? tags[0];
|
|
32
|
+
const entry = value[tag];
|
|
33
|
+
const text = Array.isArray(entry) ? entry.join(separator) : String(entry);
|
|
34
|
+
return { text, lang: tag === "none" ? void 0 : tag };
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
closestLanguage,
|
|
38
|
+
localize
|
|
39
|
+
};
|