@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,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const IDENTITY = Object.freeze({
|
|
3
|
+
a: 1,
|
|
4
|
+
b: 0,
|
|
5
|
+
c: 0,
|
|
6
|
+
d: 1,
|
|
7
|
+
e: 0,
|
|
8
|
+
f: 0
|
|
9
|
+
});
|
|
10
|
+
function translate(x, y) {
|
|
11
|
+
return { a: 1, b: 0, c: 0, d: 1, e: x, f: y };
|
|
12
|
+
}
|
|
13
|
+
function scale(x, y = x) {
|
|
14
|
+
return { a: x, b: 0, c: 0, d: y, e: 0, f: 0 };
|
|
15
|
+
}
|
|
16
|
+
function rotate(radians) {
|
|
17
|
+
const cos = Math.cos(radians);
|
|
18
|
+
const sin = Math.sin(radians);
|
|
19
|
+
return { a: cos, b: sin, c: -sin, d: cos, e: 0, f: 0 };
|
|
20
|
+
}
|
|
21
|
+
function multiply(m, n) {
|
|
22
|
+
return {
|
|
23
|
+
a: m.a * n.a + m.c * n.b,
|
|
24
|
+
b: m.b * n.a + m.d * n.b,
|
|
25
|
+
c: m.a * n.c + m.c * n.d,
|
|
26
|
+
d: m.b * n.c + m.d * n.d,
|
|
27
|
+
e: m.a * n.e + m.c * n.f + m.e,
|
|
28
|
+
f: m.b * n.e + m.d * n.f + m.f
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function compose(...transforms) {
|
|
32
|
+
return transforms.reduce((acc, t) => multiply(acc, t), IDENTITY);
|
|
33
|
+
}
|
|
34
|
+
function apply(m, p) {
|
|
35
|
+
return { x: m.a * p.x + m.c * p.y + m.e, y: m.b * p.x + m.d * p.y + m.f };
|
|
36
|
+
}
|
|
37
|
+
function toCssMatrix(m) {
|
|
38
|
+
return `matrix(${[m.a, m.b, m.c, m.d, m.e, m.f].map(roundCss).join(",")})`;
|
|
39
|
+
}
|
|
40
|
+
function toClipMat3(m, width, height, out = new Float32Array(9)) {
|
|
41
|
+
const sx = 2 / width;
|
|
42
|
+
const sy = -2 / height;
|
|
43
|
+
out[0] = m.a * sx;
|
|
44
|
+
out[1] = m.b * sy;
|
|
45
|
+
out[2] = 0;
|
|
46
|
+
out[3] = m.c * sx;
|
|
47
|
+
out[4] = m.d * sy;
|
|
48
|
+
out[5] = 0;
|
|
49
|
+
out[6] = m.e * sx - 1;
|
|
50
|
+
out[7] = m.f * sy + 1;
|
|
51
|
+
out[8] = 1;
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
function roundCss(value) {
|
|
55
|
+
const rounded = Math.round(value * 1e6) / 1e6;
|
|
56
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
IDENTITY,
|
|
60
|
+
apply,
|
|
61
|
+
compose,
|
|
62
|
+
multiply,
|
|
63
|
+
rotate,
|
|
64
|
+
scale,
|
|
65
|
+
toClipMat3,
|
|
66
|
+
toCssMatrix,
|
|
67
|
+
translate
|
|
68
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { apply } from "./affine.mjs";
|
|
3
|
+
function rectCenter(rect) {
|
|
4
|
+
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
|
|
5
|
+
}
|
|
6
|
+
function union(rects) {
|
|
7
|
+
if (!rects.length) return null;
|
|
8
|
+
let minX = Infinity;
|
|
9
|
+
let minY = Infinity;
|
|
10
|
+
let maxX = -Infinity;
|
|
11
|
+
let maxY = -Infinity;
|
|
12
|
+
for (const r of rects) {
|
|
13
|
+
minX = Math.min(minX, r.x);
|
|
14
|
+
minY = Math.min(minY, r.y);
|
|
15
|
+
maxX = Math.max(maxX, r.x + r.width);
|
|
16
|
+
maxY = Math.max(maxY, r.y + r.height);
|
|
17
|
+
}
|
|
18
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
19
|
+
}
|
|
20
|
+
function intersects(a, b) {
|
|
21
|
+
return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
|
|
22
|
+
}
|
|
23
|
+
function transformRect(m, rect) {
|
|
24
|
+
const corners = [
|
|
25
|
+
apply(m, { x: rect.x, y: rect.y }),
|
|
26
|
+
apply(m, { x: rect.x + rect.width, y: rect.y }),
|
|
27
|
+
apply(m, { x: rect.x, y: rect.y + rect.height }),
|
|
28
|
+
apply(m, { x: rect.x + rect.width, y: rect.y + rect.height })
|
|
29
|
+
];
|
|
30
|
+
const xs = corners.map((p) => p.x);
|
|
31
|
+
const ys = corners.map((p) => p.y);
|
|
32
|
+
const x = Math.min(...xs);
|
|
33
|
+
const y = Math.min(...ys);
|
|
34
|
+
return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
|
|
35
|
+
}
|
|
36
|
+
function clamp(value, min, max) {
|
|
37
|
+
return Math.min(Math.max(value, min), max);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
clamp,
|
|
41
|
+
intersects,
|
|
42
|
+
rectCenter,
|
|
43
|
+
transformRect,
|
|
44
|
+
union
|
|
45
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Canvas2DBackend } from "../backends/canvas2d/Canvas2DBackend.mjs";
|
|
6
|
+
import { fitCamera, worldPointToScreen, screenPointToWorld } from "../camera/Camera.mjs";
|
|
7
|
+
import { planFrame } from "../scene/planFrame.mjs";
|
|
8
|
+
class Navigator {
|
|
9
|
+
constructor(element, onNavigate) {
|
|
10
|
+
__publicField(this, "canvas");
|
|
11
|
+
__publicField(this, "region");
|
|
12
|
+
__publicField(this, "painter");
|
|
13
|
+
__publicField(this, "camera", null);
|
|
14
|
+
__publicField(this, "size", { width: 0, height: 0 });
|
|
15
|
+
__publicField(this, "drawnVersion", -1);
|
|
16
|
+
__publicField(this, "resized", true);
|
|
17
|
+
__publicField(this, "dragging", null);
|
|
18
|
+
__publicField(this, "observer", null);
|
|
19
|
+
__publicField(this, "onPointerDown", (event) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
if (event.pointerType === "mouse" && event.button !== 0) return;
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
this.dragging = event.pointerId;
|
|
25
|
+
(_b = (_a = this.element).setPointerCapture) == null ? void 0 : _b.call(_a, event.pointerId);
|
|
26
|
+
const world = this.worldAt(event);
|
|
27
|
+
if (world) this.onNavigate(world, false);
|
|
28
|
+
});
|
|
29
|
+
__publicField(this, "onPointerMove", (event) => {
|
|
30
|
+
if (this.dragging !== event.pointerId) return;
|
|
31
|
+
const world = this.worldAt(event);
|
|
32
|
+
if (world) this.onNavigate(world, true);
|
|
33
|
+
});
|
|
34
|
+
__publicField(this, "onPointerUp", (event) => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
if (this.dragging !== event.pointerId) return;
|
|
37
|
+
this.dragging = null;
|
|
38
|
+
(_b = (_a = this.element).releasePointerCapture) == null ? void 0 : _b.call(_a, event.pointerId);
|
|
39
|
+
});
|
|
40
|
+
this.element = element;
|
|
41
|
+
this.onNavigate = onNavigate;
|
|
42
|
+
this.canvas = document.createElement("canvas");
|
|
43
|
+
this.canvas.className = "clover-canvas-navigator-image";
|
|
44
|
+
this.canvas.setAttribute("aria-hidden", "true");
|
|
45
|
+
this.region = document.createElement("div");
|
|
46
|
+
this.region.className = "clover-canvas-navigator-region";
|
|
47
|
+
element.append(this.canvas, this.region);
|
|
48
|
+
this.painter = Canvas2DBackend.create(this.canvas);
|
|
49
|
+
this.measure();
|
|
50
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
51
|
+
this.observer = new ResizeObserver(() => this.measure());
|
|
52
|
+
this.observer.observe(element);
|
|
53
|
+
}
|
|
54
|
+
element.addEventListener("pointerdown", this.onPointerDown);
|
|
55
|
+
element.addEventListener("pointermove", this.onPointerMove);
|
|
56
|
+
element.addEventListener("pointerup", this.onPointerUp);
|
|
57
|
+
element.addEventListener("pointercancel", this.onPointerUp);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @param version bumps whenever the scene or its loaded tiles change
|
|
61
|
+
*/
|
|
62
|
+
render(items, world, visible, pixelRatio, getTile, version) {
|
|
63
|
+
if (!world) return;
|
|
64
|
+
const { width, height } = this.size;
|
|
65
|
+
this.camera = fitCamera(world, this.size);
|
|
66
|
+
if (this.painter && (this.resized || version !== this.drawnVersion)) {
|
|
67
|
+
this.drawnVersion = version;
|
|
68
|
+
this.resized = false;
|
|
69
|
+
this.painter.resize(width, height, pixelRatio);
|
|
70
|
+
const plan = planFrame({
|
|
71
|
+
items,
|
|
72
|
+
camera: this.camera,
|
|
73
|
+
viewport: this.size,
|
|
74
|
+
pixelRatio,
|
|
75
|
+
getTile
|
|
76
|
+
});
|
|
77
|
+
this.painter.begin();
|
|
78
|
+
for (const draw of plan.draws) {
|
|
79
|
+
this.painter.draw({
|
|
80
|
+
key: draw.url,
|
|
81
|
+
source: draw.image.source,
|
|
82
|
+
width: draw.image.width,
|
|
83
|
+
height: draw.image.height,
|
|
84
|
+
transform: draw.transform,
|
|
85
|
+
crop: draw.crop,
|
|
86
|
+
opacity: 1,
|
|
87
|
+
bleed: draw.bleed
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
this.painter.end();
|
|
91
|
+
}
|
|
92
|
+
const a = worldPointToScreen(this.camera, this.size, {
|
|
93
|
+
x: visible.x,
|
|
94
|
+
y: visible.y
|
|
95
|
+
});
|
|
96
|
+
const b = worldPointToScreen(this.camera, this.size, {
|
|
97
|
+
x: visible.x + visible.width,
|
|
98
|
+
y: visible.y + visible.height
|
|
99
|
+
});
|
|
100
|
+
const left = Math.max(0, Math.min(a.x, b.x));
|
|
101
|
+
const top = Math.max(0, Math.min(a.y, b.y));
|
|
102
|
+
const right = Math.min(width, Math.max(a.x, b.x));
|
|
103
|
+
const bottom = Math.min(height, Math.max(a.y, b.y));
|
|
104
|
+
Object.assign(this.region.style, {
|
|
105
|
+
transform: `translate(${left}px, ${top}px)`,
|
|
106
|
+
width: `${Math.max(0, right - left)}px`,
|
|
107
|
+
height: `${Math.max(0, bottom - top)}px`
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
measure() {
|
|
111
|
+
const rect = this.element.getBoundingClientRect();
|
|
112
|
+
const width = Math.max(1, rect.width);
|
|
113
|
+
const height = Math.max(1, rect.height);
|
|
114
|
+
if (width === this.size.width && height === this.size.height) return;
|
|
115
|
+
this.size = { width, height };
|
|
116
|
+
this.resized = true;
|
|
117
|
+
}
|
|
118
|
+
dispose() {
|
|
119
|
+
var _a, _b;
|
|
120
|
+
(_a = this.observer) == null ? void 0 : _a.disconnect();
|
|
121
|
+
const el = this.element;
|
|
122
|
+
el.removeEventListener("pointerdown", this.onPointerDown);
|
|
123
|
+
el.removeEventListener("pointermove", this.onPointerMove);
|
|
124
|
+
el.removeEventListener("pointerup", this.onPointerUp);
|
|
125
|
+
el.removeEventListener("pointercancel", this.onPointerUp);
|
|
126
|
+
(_b = this.painter) == null ? void 0 : _b.dispose();
|
|
127
|
+
this.canvas.remove();
|
|
128
|
+
this.region.remove();
|
|
129
|
+
}
|
|
130
|
+
worldAt(event) {
|
|
131
|
+
if (!this.camera) return null;
|
|
132
|
+
const rect = this.element.getBoundingClientRect();
|
|
133
|
+
return screenPointToWorld(this.camera, this.size, {
|
|
134
|
+
x: event.clientX - rect.left,
|
|
135
|
+
y: event.clientY - rect.top
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
Navigator
|
|
141
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
import { worldPointToScreen } from "../camera/Camera.mjs";
|
|
6
|
+
const overlaysOf = (renderer) => renderer.overlays ?? (renderer.overlays = new OverlayLayer(renderer.host));
|
|
7
|
+
class OverlayLayer {
|
|
8
|
+
constructor(parent) {
|
|
9
|
+
__publicField(this, "container");
|
|
10
|
+
__publicField(this, "overlays", /* @__PURE__ */ new Map());
|
|
11
|
+
/** The view last positioned in, so one element can be moved between frames. */
|
|
12
|
+
__publicField(this, "view");
|
|
13
|
+
const container = document.createElement("div");
|
|
14
|
+
container.className = "clover-canvas-overlays";
|
|
15
|
+
Object.assign(container.style, {
|
|
16
|
+
position: "absolute",
|
|
17
|
+
inset: "0",
|
|
18
|
+
overflow: "clip",
|
|
19
|
+
pointerEvents: "none"
|
|
20
|
+
});
|
|
21
|
+
parent.appendChild(container);
|
|
22
|
+
this.container = container;
|
|
23
|
+
}
|
|
24
|
+
/** Pin `element` to `rect` (world units). Returns a function that unpins it. */
|
|
25
|
+
add(element, rect) {
|
|
26
|
+
this.overlays.set(element, rect);
|
|
27
|
+
element.classList.add("clover-canvas-overlay");
|
|
28
|
+
Object.assign(element.style, {
|
|
29
|
+
position: "absolute",
|
|
30
|
+
top: "0",
|
|
31
|
+
left: "0",
|
|
32
|
+
pointerEvents: "auto"
|
|
33
|
+
});
|
|
34
|
+
if (element.parentElement !== this.container) {
|
|
35
|
+
this.container.appendChild(element);
|
|
36
|
+
}
|
|
37
|
+
return () => {
|
|
38
|
+
this.overlays.delete(element);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Pin `element`, already added, to another `rect` and place it there now, in the view
|
|
43
|
+
* last drawn: a hotspot following a recording, moved frame by frame with no frame of
|
|
44
|
+
* the renderer's. Nothing, for an element not pinned.
|
|
45
|
+
*/
|
|
46
|
+
move(element, rect) {
|
|
47
|
+
if (!this.overlays.has(element)) return;
|
|
48
|
+
this.overlays.set(element, rect);
|
|
49
|
+
if (this.view) this.position(...this.view, element);
|
|
50
|
+
}
|
|
51
|
+
/** Place every element pinned, or `only` that one, in the view. */
|
|
52
|
+
position(camera, viewport, only) {
|
|
53
|
+
this.view = [camera, viewport];
|
|
54
|
+
const degrees = camera.rotation * 180 / Math.PI;
|
|
55
|
+
const upright = Math.cos(camera.rotation) > 0.9999;
|
|
56
|
+
const ratio = upright ? window.devicePixelRatio || 1 : 0;
|
|
57
|
+
const snap = (value) => ratio ? Math.round(value * ratio) / ratio : value;
|
|
58
|
+
for (const [element, rect] of this.overlays) {
|
|
59
|
+
if (only && element !== only) continue;
|
|
60
|
+
const center = worldPointToScreen(camera, viewport, {
|
|
61
|
+
x: rect.x + rect.width / 2,
|
|
62
|
+
y: rect.y + rect.height / 2
|
|
63
|
+
});
|
|
64
|
+
const left = snap(center.x - rect.width * camera.zoom / 2);
|
|
65
|
+
const top = snap(center.y - rect.height * camera.zoom / 2);
|
|
66
|
+
const width = snap(rect.width * camera.zoom);
|
|
67
|
+
const height = snap(rect.height * camera.zoom);
|
|
68
|
+
element.style.width = `${width}px`;
|
|
69
|
+
element.style.height = `${height}px`;
|
|
70
|
+
element.style.transform = `translate(${left}px, ${top}px)` + (degrees ? ` rotate(${degrees}deg)` : "");
|
|
71
|
+
const { style, dataset } = element;
|
|
72
|
+
if (upright) {
|
|
73
|
+
style.setProperty("--clover-overlay-x", `${center.x}px`);
|
|
74
|
+
style.setProperty("--clover-overlay-top", `${top}px`);
|
|
75
|
+
style.setProperty("--clover-overlay-bottom", `${top + height}px`);
|
|
76
|
+
const room = center.y > viewport.height / 2 ? "above" : "below";
|
|
77
|
+
if (dataset.overlayRoom !== room) dataset.overlayRoom = room;
|
|
78
|
+
} else {
|
|
79
|
+
style.removeProperty("--clover-overlay-x");
|
|
80
|
+
style.removeProperty("--clover-overlay-top");
|
|
81
|
+
style.removeProperty("--clover-overlay-bottom");
|
|
82
|
+
delete dataset.overlayRoom;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
dispose() {
|
|
87
|
+
this.overlays.clear();
|
|
88
|
+
this.container.remove();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
OverlayLayer,
|
|
93
|
+
overlaysOf
|
|
94
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { worldToScreen, visibleWorldRect } from "../camera/Camera.mjs";
|
|
3
|
+
import { compose, translate, scale } from "../math/affine.mjs";
|
|
4
|
+
import { intersects } from "../math/rect.mjs";
|
|
5
|
+
import { pixelsToWorld } from "./sceneItem.mjs";
|
|
6
|
+
import { tilesInRegion, chooseLevel } from "../sources/tilePyramid.mjs";
|
|
7
|
+
const TARGET_BAND = 1e7;
|
|
8
|
+
const IN_FLIGHT_BAND = 15e6;
|
|
9
|
+
const OVERVIEW_BAND = 2e7;
|
|
10
|
+
const IN_FLIGHT_LEVELS = 2;
|
|
11
|
+
function planFrame(input) {
|
|
12
|
+
const { items, camera, viewport, pixelRatio, getTile, destination } = input;
|
|
13
|
+
const view = worldToScreen(camera, viewport);
|
|
14
|
+
const draws = [];
|
|
15
|
+
const wants = [];
|
|
16
|
+
const levels = [];
|
|
17
|
+
const want = (pyramid, address, priority) => {
|
|
18
|
+
const tile = pyramid.tile(address);
|
|
19
|
+
wants.push({ url: tile.url, fallbackUrl: tile.fallbackUrl, priority });
|
|
20
|
+
};
|
|
21
|
+
for (const item of items) {
|
|
22
|
+
const { pyramid, clip, rect } = item;
|
|
23
|
+
const k = pixelsToWorld(item);
|
|
24
|
+
if (input.wantOverview) {
|
|
25
|
+
for (const address of tilesInRegion(pyramid, 0, clip)) {
|
|
26
|
+
want(pyramid, address, OVERVIEW_BAND);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const here = itemView(item, camera, viewport, pixelRatio);
|
|
30
|
+
const there = destination ? itemView(item, destination, viewport, pixelRatio) : here;
|
|
31
|
+
levels.push((here == null ? void 0 : here.target) ?? -1);
|
|
32
|
+
if (!here && !there) continue;
|
|
33
|
+
const distanceFrom = (center) => (address) => {
|
|
34
|
+
const r = pyramid.tile(address).region;
|
|
35
|
+
return Math.hypot(
|
|
36
|
+
r.x + r.width / 2 - center.x,
|
|
37
|
+
r.y + r.height / 2 - center.y
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
if (there) {
|
|
41
|
+
const distance2 = distanceFrom(there.center);
|
|
42
|
+
for (const address of tilesInRegion(pyramid, 0, there.area)) {
|
|
43
|
+
want(pyramid, address, distance2(address) / 1e3);
|
|
44
|
+
}
|
|
45
|
+
if (there.target > 0) {
|
|
46
|
+
for (const address of tilesInRegion(
|
|
47
|
+
pyramid,
|
|
48
|
+
there.target,
|
|
49
|
+
there.area
|
|
50
|
+
)) {
|
|
51
|
+
want(pyramid, address, TARGET_BAND + distance2(address));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!here) continue;
|
|
56
|
+
const { area, target } = here;
|
|
57
|
+
const distance = distanceFrom(here.center);
|
|
58
|
+
const coarse = tilesInRegion(pyramid, 0, area);
|
|
59
|
+
const fine = target === 0 ? [] : tilesInRegion(pyramid, target, area);
|
|
60
|
+
if (there !== here) {
|
|
61
|
+
for (const address of coarse) {
|
|
62
|
+
want(pyramid, address, distance(address) / 1e3);
|
|
63
|
+
}
|
|
64
|
+
const inFlight = target - IN_FLIGHT_LEVELS;
|
|
65
|
+
if (inFlight > 0) {
|
|
66
|
+
for (const address of tilesInRegion(pyramid, inFlight, area)) {
|
|
67
|
+
want(pyramid, address, IN_FLIGHT_BAND + distance(address));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (item.spec.hidden) continue;
|
|
72
|
+
const targetTiles = target === 0 ? coarse : fine;
|
|
73
|
+
const complete = targetTiles.every(
|
|
74
|
+
(a) => getTile(pyramid.tile(a).url) !== void 0
|
|
75
|
+
);
|
|
76
|
+
const paintLevels = complete ? [target] : Array.from({ length: target + 1 }, (_, i) => i);
|
|
77
|
+
const itemToScreen = compose(
|
|
78
|
+
view,
|
|
79
|
+
translate(rect.x, rect.y),
|
|
80
|
+
scale(k.x, k.y),
|
|
81
|
+
translate(-clip.x, -clip.y)
|
|
82
|
+
);
|
|
83
|
+
for (const level of paintLevels) {
|
|
84
|
+
const addresses = level === 0 ? coarse : level === target ? fine : tilesInRegion(pyramid, level, area);
|
|
85
|
+
const multiTile = pyramid.levels[level].cols * pyramid.levels[level].rows > 1;
|
|
86
|
+
for (const address of addresses) {
|
|
87
|
+
const tile = pyramid.tile(address);
|
|
88
|
+
const image = getTile(tile.url);
|
|
89
|
+
if (!image) continue;
|
|
90
|
+
const draw = placeTile(
|
|
91
|
+
item,
|
|
92
|
+
tile.region,
|
|
93
|
+
image,
|
|
94
|
+
itemToScreen,
|
|
95
|
+
multiTile
|
|
96
|
+
);
|
|
97
|
+
if (draw) draws.push({ ...draw, url: tile.url });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
wants.sort((a, b) => a.priority - b.priority);
|
|
102
|
+
return { draws, wants: dedupeWants(wants), levels };
|
|
103
|
+
}
|
|
104
|
+
function itemView(item, camera, viewport, pixelRatio) {
|
|
105
|
+
const { pyramid, clip, rect } = item;
|
|
106
|
+
const visible = visibleWorldRect(camera, viewport);
|
|
107
|
+
if (!intersects(visible, rect)) return null;
|
|
108
|
+
const k = pixelsToWorld(item);
|
|
109
|
+
const x0 = Math.max(visible.x, rect.x);
|
|
110
|
+
const y0 = Math.max(visible.y, rect.y);
|
|
111
|
+
const x1 = Math.min(visible.x + visible.width, rect.x + rect.width);
|
|
112
|
+
const y1 = Math.min(visible.y + visible.height, rect.y + rect.height);
|
|
113
|
+
const imagePerDevice = 1 / (k.x * camera.zoom * pixelRatio);
|
|
114
|
+
return {
|
|
115
|
+
area: {
|
|
116
|
+
x: clip.x + (x0 - rect.x) / k.x,
|
|
117
|
+
y: clip.y + (y0 - rect.y) / k.y,
|
|
118
|
+
width: (x1 - x0) / k.x,
|
|
119
|
+
height: (y1 - y0) / k.y
|
|
120
|
+
},
|
|
121
|
+
center: {
|
|
122
|
+
x: clip.x + (camera.x - rect.x) / k.x,
|
|
123
|
+
y: clip.y + (camera.y - rect.y) / k.y
|
|
124
|
+
},
|
|
125
|
+
target: chooseLevel(pyramid, imagePerDevice)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function placeTile(item, region, image, itemToScreen, multiTile) {
|
|
129
|
+
const { clip } = item;
|
|
130
|
+
const ix0 = Math.max(region.x, clip.x);
|
|
131
|
+
const iy0 = Math.max(region.y, clip.y);
|
|
132
|
+
const ix1 = Math.min(region.x + region.width, clip.x + clip.width);
|
|
133
|
+
const iy1 = Math.min(region.y + region.height, clip.y + clip.height);
|
|
134
|
+
if (ix1 <= ix0 || iy1 <= iy0) return null;
|
|
135
|
+
const sx = image.width / region.width;
|
|
136
|
+
const sy = image.height / region.height;
|
|
137
|
+
const eps = 1e-6;
|
|
138
|
+
return {
|
|
139
|
+
item,
|
|
140
|
+
image,
|
|
141
|
+
transform: compose(
|
|
142
|
+
itemToScreen,
|
|
143
|
+
translate(region.x, region.y),
|
|
144
|
+
scale(1 / sx, 1 / sy)
|
|
145
|
+
),
|
|
146
|
+
crop: {
|
|
147
|
+
x: (ix0 - region.x) * sx,
|
|
148
|
+
y: (iy0 - region.y) * sy,
|
|
149
|
+
width: (ix1 - ix0) * sx,
|
|
150
|
+
height: (iy1 - iy0) * sy
|
|
151
|
+
},
|
|
152
|
+
bleed: {
|
|
153
|
+
right: multiTile && ix1 < clip.x + clip.width - eps,
|
|
154
|
+
bottom: multiTile && iy1 < clip.y + clip.height - eps
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function dedupeWants(wants) {
|
|
159
|
+
const seen = /* @__PURE__ */ new Set();
|
|
160
|
+
return wants.filter((want) => {
|
|
161
|
+
if (seen.has(want.url)) return false;
|
|
162
|
+
seen.add(want.url);
|
|
163
|
+
return true;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
planFrame
|
|
168
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function parseRegion(region, width, height) {
|
|
3
|
+
if (!region) return null;
|
|
4
|
+
let value = region.trim().replace(/^xywh=/, "");
|
|
5
|
+
let percent = false;
|
|
6
|
+
if (value.startsWith("pct:")) {
|
|
7
|
+
percent = true;
|
|
8
|
+
value = value.slice(4);
|
|
9
|
+
} else if (value.startsWith("pixel:")) {
|
|
10
|
+
value = value.slice(6);
|
|
11
|
+
}
|
|
12
|
+
const parts = value.split(",").map(Number);
|
|
13
|
+
if (parts.length !== 4 || parts.some((n) => !Number.isFinite(n))) return null;
|
|
14
|
+
let [x, y, w, h] = parts;
|
|
15
|
+
if (percent) {
|
|
16
|
+
x = x / 100 * width;
|
|
17
|
+
y = y / 100 * height;
|
|
18
|
+
w = w / 100 * width;
|
|
19
|
+
h = h / 100 * height;
|
|
20
|
+
}
|
|
21
|
+
const x0 = Math.max(0, x);
|
|
22
|
+
const y0 = Math.max(0, y);
|
|
23
|
+
const x1 = Math.min(width, x + w);
|
|
24
|
+
const y1 = Math.min(height, y + h);
|
|
25
|
+
if (x1 <= x0 || y1 <= y0) return null;
|
|
26
|
+
return { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
parseRegion
|
|
30
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { union } from "../math/rect.mjs";
|
|
3
|
+
import { parseRegion } from "./regions.mjs";
|
|
4
|
+
import { fetchInfo } from "../sources/imageService.mjs";
|
|
5
|
+
import { servicePyramid, staticPyramid, tilesInRegion } from "../sources/tilePyramid.mjs";
|
|
6
|
+
async function prepareItem(spec, context) {
|
|
7
|
+
if (spec.media) return prepareMedia(spec, spec.media);
|
|
8
|
+
let pyramid = null;
|
|
9
|
+
let serviceError = null;
|
|
10
|
+
if (spec.service) {
|
|
11
|
+
try {
|
|
12
|
+
pyramid = servicePyramid(
|
|
13
|
+
await fetchInfo(spec.service, context.infoOptions)
|
|
14
|
+
);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
serviceError = error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!pyramid) {
|
|
20
|
+
if (!spec.url) throw serviceError ?? new Error("Image has no source");
|
|
21
|
+
const image = await context.loadStatic(spec.url);
|
|
22
|
+
context.cache.seed(spec.url, image);
|
|
23
|
+
pyramid = staticPyramid(spec.url, image.naturalWidth, image.naturalHeight);
|
|
24
|
+
}
|
|
25
|
+
const size = spec.width && spec.height && spec.width > 0 && spec.height > 0 ? { width: spec.width, height: spec.height } : { width: pyramid.width, height: pyramid.height };
|
|
26
|
+
const contentClip = parseRegion(spec.region, size.width, size.height) ?? {
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 0,
|
|
29
|
+
width: size.width,
|
|
30
|
+
height: size.height
|
|
31
|
+
};
|
|
32
|
+
const toPixelsX = pyramid.width / size.width;
|
|
33
|
+
const toPixelsY = pyramid.height / size.height;
|
|
34
|
+
const clip = {
|
|
35
|
+
x: contentClip.x * toPixelsX,
|
|
36
|
+
y: contentClip.y * toPixelsY,
|
|
37
|
+
width: contentClip.width * toPixelsX,
|
|
38
|
+
height: contentClip.height * toPixelsY
|
|
39
|
+
};
|
|
40
|
+
const item = {
|
|
41
|
+
id: spec.id,
|
|
42
|
+
spec,
|
|
43
|
+
pyramid,
|
|
44
|
+
size,
|
|
45
|
+
clip,
|
|
46
|
+
contentClip,
|
|
47
|
+
rect: { x: 0, y: 0, width: contentClip.width, height: contentClip.height }
|
|
48
|
+
};
|
|
49
|
+
await context.cache.prefetch(
|
|
50
|
+
tilesInRegion(pyramid, 0, clip).map((address) => {
|
|
51
|
+
const tile = pyramid.tile(address);
|
|
52
|
+
return { url: tile.url, fallbackUrl: tile.fallbackUrl };
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
return item;
|
|
56
|
+
}
|
|
57
|
+
const MEDIA_KEY_PREFIX = "media:";
|
|
58
|
+
function prepareMedia(spec, media) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const width = spec.width || ((_a = spec.placement) == null ? void 0 : _a.width) || media.element.videoWidth || 1600;
|
|
61
|
+
const height = spec.height || ((_b = spec.placement) == null ? void 0 : _b.height) || media.element.videoHeight || 900;
|
|
62
|
+
const key = `${MEDIA_KEY_PREFIX}${spec.id}`;
|
|
63
|
+
const size = { width, height };
|
|
64
|
+
const clip = { x: 0, y: 0, width, height };
|
|
65
|
+
return {
|
|
66
|
+
id: spec.id,
|
|
67
|
+
spec,
|
|
68
|
+
pyramid: staticPyramid(key, width, height),
|
|
69
|
+
media: {
|
|
70
|
+
kind: "media",
|
|
71
|
+
source: media.element,
|
|
72
|
+
width,
|
|
73
|
+
height,
|
|
74
|
+
naturalWidth: width,
|
|
75
|
+
naturalHeight: height
|
|
76
|
+
},
|
|
77
|
+
size,
|
|
78
|
+
clip,
|
|
79
|
+
contentClip: clip,
|
|
80
|
+
rect: { ...clip }
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function layoutItems(items) {
|
|
84
|
+
if (!items.length) return null;
|
|
85
|
+
if (items.every((item) => item.spec.placement)) {
|
|
86
|
+
for (const item of items) item.rect = { ...item.spec.placement };
|
|
87
|
+
return union(items.map((item) => item.rect));
|
|
88
|
+
}
|
|
89
|
+
const height = items[0].contentClip.height;
|
|
90
|
+
let x = 0;
|
|
91
|
+
for (const item of items) {
|
|
92
|
+
const width = item.contentClip.width * height / item.contentClip.height;
|
|
93
|
+
item.rect = { x, y: 0, width, height };
|
|
94
|
+
x += width;
|
|
95
|
+
}
|
|
96
|
+
return { x: 0, y: 0, width: x, height };
|
|
97
|
+
}
|
|
98
|
+
function pixelsToWorld(item) {
|
|
99
|
+
return {
|
|
100
|
+
x: item.rect.width / item.clip.width,
|
|
101
|
+
y: item.rect.height / item.clip.height
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function sameSpec(a, b) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return a.service === b.service && a.url === b.url && a.width === b.width && a.height === b.height && a.region === b.region && ((_a = a.media) == null ? void 0 : _a.element) === ((_b = b.media) == null ? void 0 : _b.element) && JSON.stringify(a.placement) === JSON.stringify(b.placement);
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
MEDIA_KEY_PREFIX,
|
|
110
|
+
layoutItems,
|
|
111
|
+
pixelsToWorld,
|
|
112
|
+
prepareItem,
|
|
113
|
+
sameSpec
|
|
114
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const UPLOAD_BUDGET_BYTES = 2 * 1024 * 1024;
|
|
3
|
+
function uploadBudget(getTile, isResident, bytes = UPLOAD_BUDGET_BYTES) {
|
|
4
|
+
const admitted = /* @__PURE__ */ new Set();
|
|
5
|
+
let remaining = bytes;
|
|
6
|
+
let deferred = false;
|
|
7
|
+
return {
|
|
8
|
+
get deferred() {
|
|
9
|
+
return deferred;
|
|
10
|
+
},
|
|
11
|
+
getTile(url) {
|
|
12
|
+
const image = getTile(url);
|
|
13
|
+
if (!image || image.kind === "media" || image.opaque || admitted.has(url) || isResident(url)) {
|
|
14
|
+
return image;
|
|
15
|
+
}
|
|
16
|
+
const size = image.width * image.height * 4;
|
|
17
|
+
if (admitted.size > 0 && size > remaining) {
|
|
18
|
+
deferred = true;
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
remaining -= size;
|
|
22
|
+
admitted.add(url);
|
|
23
|
+
return image;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
UPLOAD_BUDGET_BYTES,
|
|
29
|
+
uploadBudget
|
|
30
|
+
};
|