@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,497 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useMemo, useRef, useEffect, useCallback, useLayoutEffect, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { annotationTargets, orderKeys, boxAt } from "./track.mjs";
|
|
6
|
+
import { readBodies } from "../../core/annotation-bodies.mjs";
|
|
7
|
+
import { annotationName } from "../../core/annotation-name.mjs";
|
|
8
|
+
import { parseAnnotationTarget } from "../../core/annotations.mjs";
|
|
9
|
+
import { bodiesOf } from "../../core/painting.mjs";
|
|
10
|
+
import { readLink } from "../../core/link.mjs";
|
|
11
|
+
import { parseTime } from "../../core/ranges.mjs";
|
|
12
|
+
import { localize } from "../../core/value.mjs";
|
|
13
|
+
import { Tip } from "../../ui/Tip.mjs";
|
|
14
|
+
import { overlaysOf } from "../../lib/renderer/overlays/OverlayLayer.mjs";
|
|
15
|
+
const isTimed = (annotation) => "start" in annotation;
|
|
16
|
+
const startOf = (annotation) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return isTimed(annotation) ? annotation.start : (_b = (_a = annotation.track) == null ? void 0 : _a[0]) == null ? void 0 : _b.start;
|
|
19
|
+
};
|
|
20
|
+
const onAt = (annotation, time) => !annotation.track || boxAt(annotation.track, time) !== null;
|
|
21
|
+
function goToTrack(annotation, media) {
|
|
22
|
+
if (onAt(annotation, media.currentTime)) return false;
|
|
23
|
+
media.currentTime = annotation.track[0].start;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
function trackOf(annotation, place, targetIndex) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
const targets = annotationTargets(annotation == null ? void 0 : annotation.target);
|
|
29
|
+
if (!((_a = targets[0]) == null ? void 0 : _a.rect) || !((_b = targets[0]) == null ? void 0 : _b.t)) return null;
|
|
30
|
+
const keys = [];
|
|
31
|
+
for (const target of targets) {
|
|
32
|
+
const time = parseTime((_c = target.t) == null ? void 0 : _c.replace(/^npt:/, ""));
|
|
33
|
+
if (!target.rect || !time) continue;
|
|
34
|
+
const { x, y, w, h } = target.rect;
|
|
35
|
+
const world = place({ x, y, width: w, height: h }, target.id, targetIndex);
|
|
36
|
+
if (world)
|
|
37
|
+
keys.push({ start: time.start, end: time.end ?? Infinity, world });
|
|
38
|
+
}
|
|
39
|
+
return keys.length ? orderKeys(keys) : null;
|
|
40
|
+
}
|
|
41
|
+
function pageOf(label, language) {
|
|
42
|
+
const { text, lang } = localize(label, language);
|
|
43
|
+
return text ? { page: { text, ...lang ? { lang } : {} } } : {};
|
|
44
|
+
}
|
|
45
|
+
function timeAnnotations(annotations, language) {
|
|
46
|
+
var _a;
|
|
47
|
+
const timed = [];
|
|
48
|
+
for (const { annotation, pageLabel, pageId } of annotations) {
|
|
49
|
+
const target = parseAnnotationTarget([annotation == null ? void 0 : annotation.target].flat()[0]);
|
|
50
|
+
const time = parseTime((_a = target == null ? void 0 : target.t) == null ? void 0 : _a.replace(/^npt:/, ""));
|
|
51
|
+
if (!time || target.rect || target.point || target.svg) continue;
|
|
52
|
+
const { text, lang } = annotationLabel(annotation, language);
|
|
53
|
+
timed.push({
|
|
54
|
+
id: annotation.id,
|
|
55
|
+
...text ? { label: text } : {},
|
|
56
|
+
...lang ? { lang } : {},
|
|
57
|
+
...time,
|
|
58
|
+
...pageOf(pageLabel, language),
|
|
59
|
+
...pageId ? { pageId } : {}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return timed;
|
|
63
|
+
}
|
|
64
|
+
const POINT_BOX = 40;
|
|
65
|
+
function placeAnnotations(annotations, place, readSvg = null, language) {
|
|
66
|
+
var _a;
|
|
67
|
+
const placed = [];
|
|
68
|
+
for (const { annotation, targetIndex, pageLabel, pageId } of annotations) {
|
|
69
|
+
const target = parseAnnotationTarget(annotation == null ? void 0 : annotation.target);
|
|
70
|
+
if (!target) continue;
|
|
71
|
+
let rect = null;
|
|
72
|
+
let shape;
|
|
73
|
+
const track = trackOf(annotation, place, targetIndex);
|
|
74
|
+
if (track) {
|
|
75
|
+
const { x, y, w, h } = target.rect;
|
|
76
|
+
rect = { x, y, width: w, height: h };
|
|
77
|
+
} else if (target.rect) {
|
|
78
|
+
const { x, y, w, h } = target.rect;
|
|
79
|
+
rect = { x, y, width: w, height: h };
|
|
80
|
+
} else if (target.point) {
|
|
81
|
+
const { x, y } = target.point;
|
|
82
|
+
rect = {
|
|
83
|
+
x: x - POINT_BOX / 2,
|
|
84
|
+
y: y - POINT_BOX / 2,
|
|
85
|
+
width: POINT_BOX,
|
|
86
|
+
height: POINT_BOX
|
|
87
|
+
};
|
|
88
|
+
shape = { kind: "point" };
|
|
89
|
+
} else if (target.svg && readSvg) {
|
|
90
|
+
const svg = readSvg(target.svg);
|
|
91
|
+
if (svg) {
|
|
92
|
+
rect = svg.box;
|
|
93
|
+
shape = { kind: "svg", svg };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!rect) continue;
|
|
97
|
+
const world = track ? track[0].world : place(rect, target.id, targetIndex);
|
|
98
|
+
if (!world) continue;
|
|
99
|
+
const { text, lang } = annotationLabel(annotation, language);
|
|
100
|
+
const link = readLink(annotation);
|
|
101
|
+
const image = (_a = bodiesOf(annotation).find(
|
|
102
|
+
(body) => (body == null ? void 0 : body.type) === "Image" && /^https?:\/\//i.test(body.id ?? "")
|
|
103
|
+
)) == null ? void 0 : _a.id;
|
|
104
|
+
placed.push({
|
|
105
|
+
id: annotation.id,
|
|
106
|
+
label: text,
|
|
107
|
+
...lang ? { lang } : {},
|
|
108
|
+
world,
|
|
109
|
+
...shape ? { shape } : {},
|
|
110
|
+
...track ? { track } : {},
|
|
111
|
+
...link ? { link } : {},
|
|
112
|
+
...image ? { image } : {},
|
|
113
|
+
...pageOf(pageLabel, language),
|
|
114
|
+
...pageId ? { pageId } : {}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return placed;
|
|
118
|
+
}
|
|
119
|
+
const area = ({ world }) => world.width * world.height;
|
|
120
|
+
const within = (inner, outer) => inner.x >= outer.x && inner.y >= outer.y && inner.x + inner.width <= outer.x + outer.width && inner.y + inner.height <= outer.y + outer.height;
|
|
121
|
+
const unit = (value) => String(Math.round(value * 1e3) / 1e3 || 0);
|
|
122
|
+
function maskUnder(entry, over) {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
const a = entry.world;
|
|
125
|
+
const b = over.world;
|
|
126
|
+
if (((_a = over.shape) == null ? void 0 : _a.kind) === "point" || b.x >= a.x + a.width || b.x + b.width <= a.x || b.y >= a.y + a.height || b.y + b.height <= a.y)
|
|
127
|
+
return null;
|
|
128
|
+
const [w, h] = [a.width, a.height];
|
|
129
|
+
const [x, y] = [b.x - a.x, b.y - a.y];
|
|
130
|
+
const view = `${unit(-w / 10)} ${unit(-h / 10)} ${unit(w * 1.2)} ${unit(h * 1.2)}`;
|
|
131
|
+
const all = `M${unit(-w / 10)} ${unit(-h / 10)}h${unit(w * 1.2)}v${unit(h * 1.2)}h${unit(-w * 1.2)}Z`;
|
|
132
|
+
let body;
|
|
133
|
+
if (((_b = over.shape) == null ? void 0 : _b.kind) === "svg") {
|
|
134
|
+
const { box, shapes } = over.shape.svg;
|
|
135
|
+
const drawn = shapes.map(
|
|
136
|
+
({ tag, attributes }) => `<${tag} ${Object.entries(attributes).map(([name, value]) => `${name}="${value}"`).join(" ")}/>`
|
|
137
|
+
).join("");
|
|
138
|
+
body = `<mask id="m"><path fill="#fff" d="${all}"/><svg x="${unit(x)}" y="${unit(y)}" width="${unit(b.width)}" height="${unit(b.height)}" viewBox="${box.x} ${box.y} ${Math.max(box.width, 1)} ${Math.max(box.height, 1)}" preserveAspectRatio="none" overflow="visible"><g fill="#000">${drawn}</g></svg></mask><path d="${all}" mask="url(#m)"/>`;
|
|
139
|
+
} else {
|
|
140
|
+
body = `<path fill-rule="evenodd" d="${all}M${unit(x)} ${unit(y)}h${unit(b.width)}v${unit(b.height)}h${unit(-b.width)}Z"/>`;
|
|
141
|
+
}
|
|
142
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${view}" preserveAspectRatio="none">${body}</svg>`;
|
|
143
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
144
|
+
}
|
|
145
|
+
const Annotations = ({
|
|
146
|
+
renderer,
|
|
147
|
+
placed,
|
|
148
|
+
sceneVersion,
|
|
149
|
+
active,
|
|
150
|
+
selected,
|
|
151
|
+
onActivate,
|
|
152
|
+
onSelect,
|
|
153
|
+
onFollow,
|
|
154
|
+
media
|
|
155
|
+
}) => {
|
|
156
|
+
const rank = useMemo(() => {
|
|
157
|
+
const ranks = /* @__PURE__ */ new Map();
|
|
158
|
+
[...placed].sort((a, b) => area(b) - area(a)).forEach((entry, index) => ranks.set(entry, index));
|
|
159
|
+
return ranks;
|
|
160
|
+
}, [placed]);
|
|
161
|
+
const current = placed.find((entry) => entry.id === active);
|
|
162
|
+
const sought = useRef(null);
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
const picked = placed.find((entry) => entry.id === selected && entry.track);
|
|
165
|
+
if (!selected) sought.current = null;
|
|
166
|
+
if (!picked || !media || sought.current === selected) return;
|
|
167
|
+
sought.current = selected;
|
|
168
|
+
goToTrack(picked, media);
|
|
169
|
+
}, [placed, selected, media]);
|
|
170
|
+
const depthOf = (entry) => {
|
|
171
|
+
const own = rank.get(entry) ?? 0;
|
|
172
|
+
if (!current) return own;
|
|
173
|
+
if (entry === current) return placed.length;
|
|
174
|
+
return own > (rank.get(current) ?? 0) && !entry.track && !current.track && within(entry.world, current.world) ? placed.length + 1 + own : own;
|
|
175
|
+
};
|
|
176
|
+
const elements = useRef(/* @__PURE__ */ new Map());
|
|
177
|
+
const now = useRef(/* @__PURE__ */ new Map());
|
|
178
|
+
const written = useRef(/* @__PURE__ */ new WeakMap());
|
|
179
|
+
const latest = useRef({ placed, current, depthOf });
|
|
180
|
+
latest.current = { placed, current, depthOf };
|
|
181
|
+
const remask = useCallback((only) => {
|
|
182
|
+
const { placed: placed2, current: current2, depthOf: depthOf2 } = latest.current;
|
|
183
|
+
const at = (entry) => now.current.get(entry.id);
|
|
184
|
+
const over = current2 && at(current2) !== null ? current2 : void 0;
|
|
185
|
+
const apply = (entry) => {
|
|
186
|
+
const element = elements.current.get(entry.id);
|
|
187
|
+
if (!element) return;
|
|
188
|
+
const world = at(entry);
|
|
189
|
+
const mask = over && entry !== over && world !== null && depthOf2(entry) < placed2.length ? maskUnder(
|
|
190
|
+
{ ...entry, world: world ?? entry.world },
|
|
191
|
+
{ ...over, world: at(over) ?? over.world }
|
|
192
|
+
) : null;
|
|
193
|
+
if ((written.current.get(element) ?? "") === (mask ?? "")) return;
|
|
194
|
+
written.current.set(element, mask ?? "");
|
|
195
|
+
if (mask) element.style.setProperty("--clover-annotation-mask", mask);
|
|
196
|
+
else element.style.removeProperty("--clover-annotation-mask");
|
|
197
|
+
};
|
|
198
|
+
if (only && only !== current2) apply(only);
|
|
199
|
+
else placed2.forEach(apply);
|
|
200
|
+
}, []);
|
|
201
|
+
useLayoutEffect(() => remask());
|
|
202
|
+
const register = useCallback((id, element) => {
|
|
203
|
+
if (element) elements.current.set(id, element);
|
|
204
|
+
else elements.current.delete(id);
|
|
205
|
+
}, []);
|
|
206
|
+
const moved = useCallback(
|
|
207
|
+
(entry, world) => {
|
|
208
|
+
now.current.set(entry.id, world);
|
|
209
|
+
remask(entry);
|
|
210
|
+
},
|
|
211
|
+
[remask]
|
|
212
|
+
);
|
|
213
|
+
return createPortal(
|
|
214
|
+
/* @__PURE__ */ jsx(Fragment, { children: placed.map((entry, index) => /* @__PURE__ */ jsx(
|
|
215
|
+
AnnotationButton,
|
|
216
|
+
{
|
|
217
|
+
entry,
|
|
218
|
+
name: entry.label ?? String(index + 1),
|
|
219
|
+
lang: entry.label ? entry.lang : void 0,
|
|
220
|
+
depth: depthOf(entry),
|
|
221
|
+
register,
|
|
222
|
+
onMove: moved,
|
|
223
|
+
renderer,
|
|
224
|
+
active: active === entry.id,
|
|
225
|
+
selected: selected === entry.id,
|
|
226
|
+
onActivate,
|
|
227
|
+
onSelect,
|
|
228
|
+
onFollow,
|
|
229
|
+
media
|
|
230
|
+
},
|
|
231
|
+
`${entry.id}|${sceneVersion}`
|
|
232
|
+
)) }),
|
|
233
|
+
overlaysOf(renderer).container
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
let panning;
|
|
237
|
+
const loadPanning = () => panning ?? (panning = import("./panClearOfControls.mjs"));
|
|
238
|
+
const AnnotationButton = ({
|
|
239
|
+
entry,
|
|
240
|
+
name,
|
|
241
|
+
lang,
|
|
242
|
+
depth,
|
|
243
|
+
register,
|
|
244
|
+
onMove,
|
|
245
|
+
renderer,
|
|
246
|
+
active,
|
|
247
|
+
selected,
|
|
248
|
+
onActivate,
|
|
249
|
+
onSelect,
|
|
250
|
+
onFollow,
|
|
251
|
+
media
|
|
252
|
+
}) => {
|
|
253
|
+
var _a, _b, _c;
|
|
254
|
+
const [element, setElement] = useState(null);
|
|
255
|
+
const { id } = entry;
|
|
256
|
+
const attach = useCallback(
|
|
257
|
+
(node) => {
|
|
258
|
+
setElement(node);
|
|
259
|
+
register(id, node);
|
|
260
|
+
},
|
|
261
|
+
[id, register]
|
|
262
|
+
);
|
|
263
|
+
const { x, y, width, height } = entry.world;
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (!element) return;
|
|
266
|
+
const unpin = overlaysOf(renderer).add(element, { x, y, width, height });
|
|
267
|
+
renderer.invalidate();
|
|
268
|
+
return unpin;
|
|
269
|
+
}, [element, renderer, x, y, width, height]);
|
|
270
|
+
const shown = useFollow(
|
|
271
|
+
element,
|
|
272
|
+
entry.track,
|
|
273
|
+
renderer,
|
|
274
|
+
media,
|
|
275
|
+
() => onActivate(null),
|
|
276
|
+
(world) => onMove(entry, world)
|
|
277
|
+
);
|
|
278
|
+
const { link } = entry;
|
|
279
|
+
const web = link && !link.canvasId && !link.manifestId ? link.id : void 0;
|
|
280
|
+
const follow = link && !web && onFollow ? () => onFollow(entry) : void 0;
|
|
281
|
+
const Hotspot = web ? "a" : "button";
|
|
282
|
+
return /* @__PURE__ */ jsxs(
|
|
283
|
+
Hotspot,
|
|
284
|
+
{
|
|
285
|
+
ref: attach,
|
|
286
|
+
...web ? { href: web, target: "_blank", rel: "noopener noreferrer" } : { type: "button" },
|
|
287
|
+
id: entry.id,
|
|
288
|
+
className: "clover-canvas-annotation",
|
|
289
|
+
hidden: !shown,
|
|
290
|
+
"data-active": active ? "true" : "false",
|
|
291
|
+
"data-shape": ((_a = entry.shape) == null ? void 0 : _a.kind) ?? "rect",
|
|
292
|
+
"data-track": entry.track ? "" : void 0,
|
|
293
|
+
"data-link": web || follow ? "true" : void 0,
|
|
294
|
+
"aria-label": name,
|
|
295
|
+
"aria-current": selected ? "true" : void 0,
|
|
296
|
+
lang,
|
|
297
|
+
style: {
|
|
298
|
+
"--clover-annotation-depth": depth
|
|
299
|
+
},
|
|
300
|
+
onMouseEnter: () => onActivate(entry.id),
|
|
301
|
+
onMouseLeave: () => onActivate(null),
|
|
302
|
+
onFocus: () => {
|
|
303
|
+
onActivate(entry.id);
|
|
304
|
+
void loadPanning();
|
|
305
|
+
},
|
|
306
|
+
onKeyUp: (event) => {
|
|
307
|
+
if (event.key !== "Tab") return;
|
|
308
|
+
const hotspot = event.currentTarget;
|
|
309
|
+
void loadPanning().then(({ panClearOfControls }) => {
|
|
310
|
+
if (document.activeElement === hotspot)
|
|
311
|
+
panClearOfControls(renderer, hotspot);
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
onBlur: () => onActivate(null),
|
|
315
|
+
onKeyDown: scrollNote,
|
|
316
|
+
onClick: (event) => {
|
|
317
|
+
event.stopPropagation();
|
|
318
|
+
if (web) return;
|
|
319
|
+
if (follow) follow();
|
|
320
|
+
else onSelect(entry);
|
|
321
|
+
},
|
|
322
|
+
children: [
|
|
323
|
+
((_b = entry.shape) == null ? void 0 : _b.kind) === "point" && /* @__PURE__ */ jsx("span", { className: "clover-canvas-annotation-point", "aria-hidden": "true" }),
|
|
324
|
+
((_c = entry.shape) == null ? void 0 : _c.kind) === "svg" && /* @__PURE__ */ jsx(ShapeOutline, { svg: entry.shape.svg }),
|
|
325
|
+
/* @__PURE__ */ jsx(Tip, { label: name, scrolls: true, image: entry.image })
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
};
|
|
330
|
+
function useFollow(element, track, renderer, media, onGone, onMove) {
|
|
331
|
+
const follows = Boolean(track) && media !== void 0;
|
|
332
|
+
const [shown, setShown] = useState(
|
|
333
|
+
() => !follows || (media ? boxAt(track, media.currentTime) !== null : false)
|
|
334
|
+
);
|
|
335
|
+
const onGoneRef = useRef(onGone);
|
|
336
|
+
onGoneRef.current = onGone;
|
|
337
|
+
const onMoveRef = useRef(onMove);
|
|
338
|
+
onMoveRef.current = onMove;
|
|
339
|
+
useEffect(() => {
|
|
340
|
+
if (!track || media === void 0) {
|
|
341
|
+
setShown(true);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (!media) {
|
|
345
|
+
setShown(false);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
let last;
|
|
349
|
+
const update = (time) => {
|
|
350
|
+
var _a, _b, _c;
|
|
351
|
+
const box = boxAt(track, time);
|
|
352
|
+
if (box && element) (_a = renderer.overlays) == null ? void 0 : _a.move(element, box);
|
|
353
|
+
onMoveRef.current(box);
|
|
354
|
+
const now2 = box !== null;
|
|
355
|
+
if (now2 === last) return;
|
|
356
|
+
last = now2;
|
|
357
|
+
if (!now2 && element) {
|
|
358
|
+
const hovered = element.matches(":hover");
|
|
359
|
+
if (element.contains(document.activeElement)) {
|
|
360
|
+
(_c = (_b = renderer.overlays) == null ? void 0 : _b.container.parentElement) == null ? void 0 : _c.focus({
|
|
361
|
+
preventScroll: true
|
|
362
|
+
});
|
|
363
|
+
} else if (hovered) onGoneRef.current();
|
|
364
|
+
}
|
|
365
|
+
setShown(now2);
|
|
366
|
+
};
|
|
367
|
+
const video = media;
|
|
368
|
+
const byFrame = () => typeof video.requestVideoFrameCallback === "function" && video.videoWidth > 0;
|
|
369
|
+
let frame = 0;
|
|
370
|
+
let videoFrame = 0;
|
|
371
|
+
const onVideoFrame = (_, { mediaTime }) => {
|
|
372
|
+
update(mediaTime);
|
|
373
|
+
videoFrame = video.requestVideoFrameCallback(onVideoFrame);
|
|
374
|
+
};
|
|
375
|
+
const tick = () => {
|
|
376
|
+
update(media.currentTime);
|
|
377
|
+
frame = requestAnimationFrame(tick);
|
|
378
|
+
};
|
|
379
|
+
const stop = () => {
|
|
380
|
+
cancelAnimationFrame(frame);
|
|
381
|
+
if (videoFrame) video.cancelVideoFrameCallback(videoFrame);
|
|
382
|
+
frame = videoFrame = 0;
|
|
383
|
+
};
|
|
384
|
+
const start = () => {
|
|
385
|
+
stop();
|
|
386
|
+
if (byFrame()) videoFrame = video.requestVideoFrameCallback(onVideoFrame);
|
|
387
|
+
else frame = requestAnimationFrame(tick);
|
|
388
|
+
};
|
|
389
|
+
const now = () => update(media.currentTime);
|
|
390
|
+
const paused = () => media.paused && now();
|
|
391
|
+
const halt = () => {
|
|
392
|
+
stop();
|
|
393
|
+
now();
|
|
394
|
+
};
|
|
395
|
+
const events = [
|
|
396
|
+
["play", start],
|
|
397
|
+
["pause", halt],
|
|
398
|
+
["ended", halt],
|
|
399
|
+
["seeking", now],
|
|
400
|
+
["seeked", now],
|
|
401
|
+
["loadeddata", now],
|
|
402
|
+
["timeupdate", paused]
|
|
403
|
+
];
|
|
404
|
+
events.forEach(
|
|
405
|
+
([type, listener]) => media.addEventListener(type, listener)
|
|
406
|
+
);
|
|
407
|
+
now();
|
|
408
|
+
if (!media.paused) start();
|
|
409
|
+
return () => {
|
|
410
|
+
stop();
|
|
411
|
+
events.forEach(
|
|
412
|
+
([type, listener]) => media.removeEventListener(type, listener)
|
|
413
|
+
);
|
|
414
|
+
};
|
|
415
|
+
}, [element, track, media, renderer]);
|
|
416
|
+
return shown;
|
|
417
|
+
}
|
|
418
|
+
const ShapeOutline = ({ svg }) => {
|
|
419
|
+
const { x, y, width, height } = svg.box;
|
|
420
|
+
const shapes = svg.shapes.map(
|
|
421
|
+
({ tag, attributes }, index) => React.createElement(tag, {
|
|
422
|
+
key: index,
|
|
423
|
+
...attributes,
|
|
424
|
+
vectorEffect: "non-scaling-stroke"
|
|
425
|
+
})
|
|
426
|
+
);
|
|
427
|
+
return /* @__PURE__ */ jsxs(
|
|
428
|
+
"svg",
|
|
429
|
+
{
|
|
430
|
+
className: "clover-canvas-annotation-shape",
|
|
431
|
+
viewBox: `${x} ${y} ${Math.max(width, 1)} ${Math.max(height, 1)}`,
|
|
432
|
+
preserveAspectRatio: "none",
|
|
433
|
+
"aria-hidden": "true",
|
|
434
|
+
focusable: "false",
|
|
435
|
+
children: [
|
|
436
|
+
/* @__PURE__ */ jsx("g", { children: shapes }),
|
|
437
|
+
/* @__PURE__ */ jsx("g", { children: shapes }),
|
|
438
|
+
/* @__PURE__ */ jsx("g", { children: shapes })
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
};
|
|
443
|
+
function annotationLabel(annotation, language) {
|
|
444
|
+
return annotationName(readBodies(annotation), language);
|
|
445
|
+
}
|
|
446
|
+
const SCROLL_KEYS = {
|
|
447
|
+
ArrowDown: () => 32,
|
|
448
|
+
ArrowUp: () => -32,
|
|
449
|
+
PageDown: (tip) => tip.clientHeight - 32,
|
|
450
|
+
PageUp: (tip) => 32 - tip.clientHeight,
|
|
451
|
+
End: (tip) => tip.scrollHeight,
|
|
452
|
+
Home: (tip) => -tip.scrollHeight
|
|
453
|
+
};
|
|
454
|
+
function scrollNote(event) {
|
|
455
|
+
const tip = event.currentTarget.querySelector(
|
|
456
|
+
":scope > .clover-tip"
|
|
457
|
+
);
|
|
458
|
+
const by = SCROLL_KEYS[event.key];
|
|
459
|
+
if (!tip || !by || event.altKey || event.ctrlKey || event.metaKey)
|
|
460
|
+
return false;
|
|
461
|
+
const delta = by(tip);
|
|
462
|
+
const room = delta > 0 ? tip.scrollHeight - tip.clientHeight - tip.scrollTop : tip.scrollTop;
|
|
463
|
+
if (room < 1) return false;
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
tip.scrollBy({ top: delta });
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
function wholeCanvasComments(annotations, canvases) {
|
|
469
|
+
const byCanvas = /* @__PURE__ */ new Map();
|
|
470
|
+
for (const { annotation, targetIndex } of annotations ?? []) {
|
|
471
|
+
const target = parseAnnotationTarget(
|
|
472
|
+
[annotation == null ? void 0 : annotation.target].flat()[0]
|
|
473
|
+
);
|
|
474
|
+
if (target.rect || target.point || target.svg || target.t) continue;
|
|
475
|
+
if (!bodiesOf(annotation).some(
|
|
476
|
+
(body) => typeof (body == null ? void 0 : body.value) === "string" || (body == null ? void 0 : body.type) === "Image"
|
|
477
|
+
))
|
|
478
|
+
continue;
|
|
479
|
+
const canvas = (canvases == null ? void 0 : canvases.find((each) => each.id === target.id)) ?? (target.id ? void 0 : canvases == null ? void 0 : canvases[targetIndex]);
|
|
480
|
+
if (!canvas) continue;
|
|
481
|
+
byCanvas.set(canvas.id, [...byCanvas.get(canvas.id) ?? [], annotation]);
|
|
482
|
+
}
|
|
483
|
+
return byCanvas;
|
|
484
|
+
}
|
|
485
|
+
export {
|
|
486
|
+
annotationLabel,
|
|
487
|
+
Annotations as default,
|
|
488
|
+
goToTrack,
|
|
489
|
+
isTimed,
|
|
490
|
+
maskUnder,
|
|
491
|
+
onAt,
|
|
492
|
+
placeAnnotations,
|
|
493
|
+
scrollNote,
|
|
494
|
+
startOf,
|
|
495
|
+
timeAnnotations,
|
|
496
|
+
wholeCanvasComments
|
|
497
|
+
};
|