@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,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function hasPixels(source) {
|
|
3
|
+
if (typeof HTMLImageElement !== "undefined" && source instanceof HTMLImageElement) {
|
|
4
|
+
return source.complete && source.naturalWidth > 0;
|
|
5
|
+
}
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
function bleedInSourcePixels(command, pixelRatio) {
|
|
9
|
+
if (!command.bleed) return { x: 0, y: 0 };
|
|
10
|
+
const m = command.transform;
|
|
11
|
+
const sx = Math.hypot(m.a, m.b) * pixelRatio;
|
|
12
|
+
const sy = Math.hypot(m.c, m.d) * pixelRatio;
|
|
13
|
+
return {
|
|
14
|
+
x: command.bleed.right && sx > 0 ? 1 / sx : 0,
|
|
15
|
+
y: command.bleed.bottom && sy > 0 ? 1 / sy : 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
bleedInSourcePixels,
|
|
20
|
+
hasPixels
|
|
21
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { hasPixels, bleedInSourcePixels } from "../backend.mjs";
|
|
6
|
+
class Canvas2DBackend {
|
|
7
|
+
constructor(canvas, ctx) {
|
|
8
|
+
__publicField(this, "kind", "canvas2d");
|
|
9
|
+
__publicField(this, "canvas");
|
|
10
|
+
__publicField(this, "ctx");
|
|
11
|
+
__publicField(this, "pixelRatio", 1);
|
|
12
|
+
/**
|
|
13
|
+
* Sources drawn before. An accelerated 2D canvas uploads a bitmap to the GPU on its
|
|
14
|
+
* first draw, so the renderer's upload budget applies here too.
|
|
15
|
+
*/
|
|
16
|
+
__publicField(this, "drawn", /* @__PURE__ */ new Set());
|
|
17
|
+
this.canvas = canvas;
|
|
18
|
+
this.ctx = ctx;
|
|
19
|
+
}
|
|
20
|
+
static create(canvas) {
|
|
21
|
+
let ctx = null;
|
|
22
|
+
try {
|
|
23
|
+
ctx = canvas.getContext("2d", { alpha: true });
|
|
24
|
+
} catch {
|
|
25
|
+
ctx = null;
|
|
26
|
+
}
|
|
27
|
+
if (!ctx || typeof ctx.drawImage !== "function") return null;
|
|
28
|
+
return new Canvas2DBackend(canvas, ctx);
|
|
29
|
+
}
|
|
30
|
+
resize(width, height, pixelRatio) {
|
|
31
|
+
this.pixelRatio = pixelRatio;
|
|
32
|
+
const w = Math.max(1, Math.round(width * pixelRatio));
|
|
33
|
+
const h = Math.max(1, Math.round(height * pixelRatio));
|
|
34
|
+
if (this.canvas.width !== w) this.canvas.width = w;
|
|
35
|
+
if (this.canvas.height !== h) this.canvas.height = h;
|
|
36
|
+
}
|
|
37
|
+
begin() {
|
|
38
|
+
const ctx = this.ctx;
|
|
39
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
40
|
+
ctx.globalAlpha = 1;
|
|
41
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
42
|
+
ctx.imageSmoothingEnabled = true;
|
|
43
|
+
ctx.imageSmoothingQuality = "high";
|
|
44
|
+
}
|
|
45
|
+
draw(command) {
|
|
46
|
+
if (!hasPixels(command.source)) return "skipped";
|
|
47
|
+
const ctx = this.ctx;
|
|
48
|
+
const m = command.transform;
|
|
49
|
+
const r = this.pixelRatio;
|
|
50
|
+
const crop = command.crop ?? {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0,
|
|
53
|
+
width: command.width,
|
|
54
|
+
height: command.height
|
|
55
|
+
};
|
|
56
|
+
const bleed = bleedInSourcePixels(command, r);
|
|
57
|
+
ctx.setTransform(r * m.a, r * m.b, r * m.c, r * m.d, r * m.e, r * m.f);
|
|
58
|
+
ctx.globalAlpha = command.opacity;
|
|
59
|
+
ctx.drawImage(
|
|
60
|
+
command.source,
|
|
61
|
+
crop.x,
|
|
62
|
+
crop.y,
|
|
63
|
+
crop.width,
|
|
64
|
+
crop.height,
|
|
65
|
+
crop.x,
|
|
66
|
+
crop.y,
|
|
67
|
+
crop.width + bleed.x,
|
|
68
|
+
crop.height + bleed.y
|
|
69
|
+
);
|
|
70
|
+
this.drawn.add(command.key);
|
|
71
|
+
return "drawn";
|
|
72
|
+
}
|
|
73
|
+
end() {
|
|
74
|
+
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
75
|
+
this.ctx.globalAlpha = 1;
|
|
76
|
+
}
|
|
77
|
+
has(key) {
|
|
78
|
+
return this.drawn.has(key);
|
|
79
|
+
}
|
|
80
|
+
release(key) {
|
|
81
|
+
this.drawn.delete(key);
|
|
82
|
+
}
|
|
83
|
+
dispose() {
|
|
84
|
+
this.drawn.clear();
|
|
85
|
+
this.canvas.width = 0;
|
|
86
|
+
this.canvas.height = 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
Canvas2DBackend
|
|
91
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const MAX_CONTEXTS = 6;
|
|
3
|
+
const holders = /* @__PURE__ */ new Set();
|
|
4
|
+
function claimContext(holder) {
|
|
5
|
+
if (holders.has(holder)) return true;
|
|
6
|
+
while (holders.size >= MAX_CONTEXTS) {
|
|
7
|
+
let idle;
|
|
8
|
+
for (const each of holders) {
|
|
9
|
+
if (each.hiddenSince !== null && (!idle || each.hiddenSince < idle.hiddenSince)) {
|
|
10
|
+
idle = each;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (!idle) return false;
|
|
14
|
+
holders.delete(idle);
|
|
15
|
+
idle.release();
|
|
16
|
+
}
|
|
17
|
+
holders.add(holder);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function returnContext(holder) {
|
|
21
|
+
holders.delete(holder);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
MAX_CONTEXTS,
|
|
25
|
+
claimContext,
|
|
26
|
+
returnContext
|
|
27
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { toCssMatrix, compose, translate } from "../../math/affine.mjs";
|
|
6
|
+
class DomLayers {
|
|
7
|
+
constructor(parent) {
|
|
8
|
+
__publicField(this, "container");
|
|
9
|
+
__publicField(this, "boxes", /* @__PURE__ */ new Map());
|
|
10
|
+
const container = document.createElement("div");
|
|
11
|
+
container.className = "clover-canvas-dom-layer";
|
|
12
|
+
Object.assign(container.style, {
|
|
13
|
+
position: "absolute",
|
|
14
|
+
inset: "0",
|
|
15
|
+
overflow: "hidden",
|
|
16
|
+
pointerEvents: "none"
|
|
17
|
+
});
|
|
18
|
+
parent.appendChild(container);
|
|
19
|
+
this.container = container;
|
|
20
|
+
}
|
|
21
|
+
/** Place every item for this frame, in paint order; anything not listed is removed. */
|
|
22
|
+
sync(items) {
|
|
23
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24
|
+
items.forEach((item, index) => {
|
|
25
|
+
seen.add(item.key);
|
|
26
|
+
const box = this.boxFor(item);
|
|
27
|
+
const crop = item.crop ?? {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
width: item.width,
|
|
31
|
+
height: item.height
|
|
32
|
+
};
|
|
33
|
+
box.style.width = `${crop.width}px`;
|
|
34
|
+
box.style.height = `${crop.height}px`;
|
|
35
|
+
box.style.transform = toCssMatrix(
|
|
36
|
+
compose(item.transform, translate(crop.x, crop.y))
|
|
37
|
+
);
|
|
38
|
+
box.style.opacity = String(item.opacity);
|
|
39
|
+
box.style.zIndex = String(index);
|
|
40
|
+
const el = item.element;
|
|
41
|
+
el.style.width = `${item.width}px`;
|
|
42
|
+
el.style.height = `${item.height}px`;
|
|
43
|
+
el.style.transform = `translate(${-crop.x}px, ${-crop.y}px)`;
|
|
44
|
+
});
|
|
45
|
+
for (const [key, box] of this.boxes) {
|
|
46
|
+
if (!seen.has(key)) {
|
|
47
|
+
box.remove();
|
|
48
|
+
this.boxes.delete(key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
dispose() {
|
|
53
|
+
this.boxes.clear();
|
|
54
|
+
this.container.remove();
|
|
55
|
+
}
|
|
56
|
+
boxFor(item) {
|
|
57
|
+
let box = this.boxes.get(item.key);
|
|
58
|
+
if (box && box.firstChild !== item.element) {
|
|
59
|
+
box.remove();
|
|
60
|
+
box = void 0;
|
|
61
|
+
}
|
|
62
|
+
if (!box) {
|
|
63
|
+
box = document.createElement("div");
|
|
64
|
+
box.className = "clover-canvas-dom-item";
|
|
65
|
+
box.dataset.key = item.key;
|
|
66
|
+
Object.assign(box.style, {
|
|
67
|
+
position: "absolute",
|
|
68
|
+
top: "0",
|
|
69
|
+
left: "0",
|
|
70
|
+
overflow: "hidden",
|
|
71
|
+
transformOrigin: "0 0"
|
|
72
|
+
});
|
|
73
|
+
item.element.classList.add("clover-canvas-dom-media");
|
|
74
|
+
Object.assign(item.element.style, {
|
|
75
|
+
position: "absolute",
|
|
76
|
+
top: "0",
|
|
77
|
+
left: "0",
|
|
78
|
+
maxWidth: "none",
|
|
79
|
+
maxHeight: "none",
|
|
80
|
+
transformOrigin: "0 0"
|
|
81
|
+
});
|
|
82
|
+
box.appendChild(item.element);
|
|
83
|
+
this.container.appendChild(box);
|
|
84
|
+
this.boxes.set(item.key, box);
|
|
85
|
+
}
|
|
86
|
+
return box;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
DomLayers
|
|
91
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
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 { hasPixels, bleedInSourcePixels } from "../backend.mjs";
|
|
6
|
+
import { FRAGMENT_SHADER, VERTEX_SHADER } from "./shaders.mjs";
|
|
7
|
+
import { compose, scale, translate, toClipMat3 } from "../../math/affine.mjs";
|
|
8
|
+
class WebGL2Backend {
|
|
9
|
+
constructor(canvas, gl, callbacks) {
|
|
10
|
+
__publicField(this, "kind", "webgl2");
|
|
11
|
+
__publicField(this, "canvas");
|
|
12
|
+
__publicField(this, "maxTextureSize");
|
|
13
|
+
__publicField(this, "gl");
|
|
14
|
+
__publicField(this, "program", null);
|
|
15
|
+
__publicField(this, "vao", null);
|
|
16
|
+
__publicField(this, "uniforms", { matrix: null, crop: null, opacity: null, texture: null });
|
|
17
|
+
__publicField(this, "textures", /* @__PURE__ */ new Map());
|
|
18
|
+
__publicField(this, "cssWidth", 1);
|
|
19
|
+
__publicField(this, "cssHeight", 1);
|
|
20
|
+
__publicField(this, "pixelRatio", 1);
|
|
21
|
+
__publicField(this, "matrixScratch", new Float32Array(9));
|
|
22
|
+
__publicField(this, "isLost", false);
|
|
23
|
+
__publicField(this, "callbacks");
|
|
24
|
+
/*
|
|
25
|
+
* The browser took the context. Nothing waits for it back: the renderer lets this
|
|
26
|
+
* backend and its canvas go at once (`onLost`), and draws on another.
|
|
27
|
+
*/
|
|
28
|
+
__publicField(this, "handleLost", () => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
this.isLost = true;
|
|
31
|
+
this.textures.clear();
|
|
32
|
+
(_b = (_a = this.callbacks).onLost) == null ? void 0 : _b.call(_a);
|
|
33
|
+
});
|
|
34
|
+
this.canvas = canvas;
|
|
35
|
+
this.gl = gl;
|
|
36
|
+
this.callbacks = callbacks;
|
|
37
|
+
this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) || 4096;
|
|
38
|
+
const program = linkProgram(gl, VERTEX_SHADER, FRAGMENT_SHADER);
|
|
39
|
+
this.program = program;
|
|
40
|
+
this.uniforms = {
|
|
41
|
+
matrix: gl.getUniformLocation(program, "u_matrix"),
|
|
42
|
+
crop: gl.getUniformLocation(program, "u_crop"),
|
|
43
|
+
opacity: gl.getUniformLocation(program, "u_opacity"),
|
|
44
|
+
texture: gl.getUniformLocation(program, "u_texture")
|
|
45
|
+
};
|
|
46
|
+
const vao = gl.createVertexArray();
|
|
47
|
+
gl.bindVertexArray(vao);
|
|
48
|
+
const buffer = gl.createBuffer();
|
|
49
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
50
|
+
gl.bufferData(
|
|
51
|
+
gl.ARRAY_BUFFER,
|
|
52
|
+
new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]),
|
|
53
|
+
gl.STATIC_DRAW
|
|
54
|
+
);
|
|
55
|
+
const location = gl.getAttribLocation(program, "a_position");
|
|
56
|
+
gl.enableVertexAttribArray(location);
|
|
57
|
+
gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0);
|
|
58
|
+
gl.bindVertexArray(null);
|
|
59
|
+
this.vao = vao;
|
|
60
|
+
gl.enable(gl.BLEND);
|
|
61
|
+
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
62
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
63
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
64
|
+
gl.pixelStorei(
|
|
65
|
+
gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
66
|
+
gl.BROWSER_DEFAULT_WEBGL
|
|
67
|
+
);
|
|
68
|
+
canvas.addEventListener("webglcontextlost", this.handleLost);
|
|
69
|
+
}
|
|
70
|
+
/** Returns null when WebGL2 is unavailable, so the caller can fall back. */
|
|
71
|
+
static create(canvas, callbacks = {}) {
|
|
72
|
+
let gl = null;
|
|
73
|
+
try {
|
|
74
|
+
gl = canvas.getContext("webgl2", {
|
|
75
|
+
alpha: true,
|
|
76
|
+
premultipliedAlpha: true,
|
|
77
|
+
antialias: false,
|
|
78
|
+
depth: false,
|
|
79
|
+
stencil: false,
|
|
80
|
+
preserveDrawingBuffer: false
|
|
81
|
+
});
|
|
82
|
+
} catch {
|
|
83
|
+
gl = null;
|
|
84
|
+
}
|
|
85
|
+
if (!gl || typeof gl.createShader !== "function") return null;
|
|
86
|
+
try {
|
|
87
|
+
return new WebGL2Backend(canvas, gl, callbacks);
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
resize(width, height, pixelRatio) {
|
|
93
|
+
this.cssWidth = Math.max(1, width);
|
|
94
|
+
this.cssHeight = Math.max(1, height);
|
|
95
|
+
this.pixelRatio = pixelRatio;
|
|
96
|
+
const w = Math.max(1, Math.round(width * pixelRatio));
|
|
97
|
+
const h = Math.max(1, Math.round(height * pixelRatio));
|
|
98
|
+
if (this.canvas.width !== w) this.canvas.width = w;
|
|
99
|
+
if (this.canvas.height !== h) this.canvas.height = h;
|
|
100
|
+
}
|
|
101
|
+
begin() {
|
|
102
|
+
if (this.isLost) return;
|
|
103
|
+
const gl = this.gl;
|
|
104
|
+
gl.viewport(0, 0, this.canvas.width, this.canvas.height);
|
|
105
|
+
gl.clearColor(0, 0, 0, 0);
|
|
106
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
107
|
+
gl.useProgram(this.program);
|
|
108
|
+
gl.bindVertexArray(this.vao);
|
|
109
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
110
|
+
gl.uniform1i(this.uniforms.texture, 0);
|
|
111
|
+
}
|
|
112
|
+
draw(command) {
|
|
113
|
+
if (this.isLost) return "skipped";
|
|
114
|
+
if (!hasPixels(command.source)) return "skipped";
|
|
115
|
+
const gl = this.gl;
|
|
116
|
+
const entry = this.upload(command);
|
|
117
|
+
if (entry === "tainted") return "tainted";
|
|
118
|
+
if (!entry) return "skipped";
|
|
119
|
+
const crop = command.crop ?? {
|
|
120
|
+
x: 0,
|
|
121
|
+
y: 0,
|
|
122
|
+
width: command.width,
|
|
123
|
+
height: command.height
|
|
124
|
+
};
|
|
125
|
+
const bleed = bleedInSourcePixels(command, this.pixelRatio);
|
|
126
|
+
const quad = compose(
|
|
127
|
+
command.transform,
|
|
128
|
+
translate(crop.x, crop.y),
|
|
129
|
+
scale(crop.width + bleed.x, crop.height + bleed.y)
|
|
130
|
+
);
|
|
131
|
+
gl.uniformMatrix3fv(
|
|
132
|
+
this.uniforms.matrix,
|
|
133
|
+
false,
|
|
134
|
+
toClipMat3(quad, this.cssWidth, this.cssHeight, this.matrixScratch)
|
|
135
|
+
);
|
|
136
|
+
gl.uniform4f(
|
|
137
|
+
this.uniforms.crop,
|
|
138
|
+
crop.x / command.width,
|
|
139
|
+
crop.y / command.height,
|
|
140
|
+
crop.width / command.width,
|
|
141
|
+
crop.height / command.height
|
|
142
|
+
);
|
|
143
|
+
gl.uniform1f(this.uniforms.opacity, command.opacity);
|
|
144
|
+
gl.bindTexture(gl.TEXTURE_2D, entry.texture);
|
|
145
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
146
|
+
return "drawn";
|
|
147
|
+
}
|
|
148
|
+
end() {
|
|
149
|
+
if (this.isLost) return;
|
|
150
|
+
this.gl.bindVertexArray(null);
|
|
151
|
+
}
|
|
152
|
+
has(key) {
|
|
153
|
+
return !this.isLost && this.textures.has(key);
|
|
154
|
+
}
|
|
155
|
+
release(key) {
|
|
156
|
+
const entry = this.textures.get(key);
|
|
157
|
+
if (!entry) return;
|
|
158
|
+
if (!this.isLost) this.gl.deleteTexture(entry.texture);
|
|
159
|
+
this.textures.delete(key);
|
|
160
|
+
}
|
|
161
|
+
dispose() {
|
|
162
|
+
var _a;
|
|
163
|
+
this.canvas.removeEventListener("webglcontextlost", this.handleLost);
|
|
164
|
+
if (!this.isLost) {
|
|
165
|
+
for (const key of [...this.textures.keys()]) this.release(key);
|
|
166
|
+
if (this.program) this.gl.deleteProgram(this.program);
|
|
167
|
+
if (this.vao) this.gl.deleteVertexArray(this.vao);
|
|
168
|
+
}
|
|
169
|
+
this.textures.clear();
|
|
170
|
+
(_a = this.gl.getExtension("WEBGL_lose_context")) == null ? void 0 : _a.loseContext();
|
|
171
|
+
this.isLost = true;
|
|
172
|
+
}
|
|
173
|
+
upload(command) {
|
|
174
|
+
const gl = this.gl;
|
|
175
|
+
const existing = this.textures.get(command.key);
|
|
176
|
+
if (existing && existing.width === command.width && existing.height === command.height) {
|
|
177
|
+
return existing;
|
|
178
|
+
}
|
|
179
|
+
const texture = (existing == null ? void 0 : existing.texture) ?? gl.createTexture();
|
|
180
|
+
if (!texture) return null;
|
|
181
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
182
|
+
try {
|
|
183
|
+
gl.texImage2D(
|
|
184
|
+
gl.TEXTURE_2D,
|
|
185
|
+
0,
|
|
186
|
+
gl.RGBA,
|
|
187
|
+
gl.RGBA,
|
|
188
|
+
gl.UNSIGNED_BYTE,
|
|
189
|
+
command.source
|
|
190
|
+
);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (!existing) gl.deleteTexture(texture);
|
|
193
|
+
if (isSecurityError(error)) return "tainted";
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
gl.generateMipmap(gl.TEXTURE_2D);
|
|
197
|
+
gl.texParameteri(
|
|
198
|
+
gl.TEXTURE_2D,
|
|
199
|
+
gl.TEXTURE_MIN_FILTER,
|
|
200
|
+
gl.LINEAR_MIPMAP_LINEAR
|
|
201
|
+
);
|
|
202
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
203
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
204
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
205
|
+
const entry = {
|
|
206
|
+
texture,
|
|
207
|
+
width: command.width,
|
|
208
|
+
height: command.height
|
|
209
|
+
};
|
|
210
|
+
this.textures.set(command.key, entry);
|
|
211
|
+
return entry;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function linkProgram(gl, vertexSource, fragmentSource) {
|
|
215
|
+
const vertex = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
216
|
+
const fragment = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
217
|
+
const program = gl.createProgram();
|
|
218
|
+
if (!program) throw new Error("Could not create WebGL program");
|
|
219
|
+
gl.attachShader(program, vertex);
|
|
220
|
+
gl.attachShader(program, fragment);
|
|
221
|
+
gl.linkProgram(program);
|
|
222
|
+
gl.deleteShader(vertex);
|
|
223
|
+
gl.deleteShader(fragment);
|
|
224
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
225
|
+
const log = gl.getProgramInfoLog(program);
|
|
226
|
+
gl.deleteProgram(program);
|
|
227
|
+
throw new Error(`Could not link WebGL program: ${log}`);
|
|
228
|
+
}
|
|
229
|
+
return program;
|
|
230
|
+
}
|
|
231
|
+
function compileShader(gl, type, source) {
|
|
232
|
+
const shader = gl.createShader(type);
|
|
233
|
+
if (!shader) throw new Error("Could not create WebGL shader");
|
|
234
|
+
gl.shaderSource(shader, source);
|
|
235
|
+
gl.compileShader(shader);
|
|
236
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
237
|
+
const log = gl.getShaderInfoLog(shader);
|
|
238
|
+
gl.deleteShader(shader);
|
|
239
|
+
throw new Error(`Could not compile WebGL shader: ${log}`);
|
|
240
|
+
}
|
|
241
|
+
return shader;
|
|
242
|
+
}
|
|
243
|
+
function isSecurityError(error) {
|
|
244
|
+
return typeof error === "object" && error !== null && error.name === "SecurityError";
|
|
245
|
+
}
|
|
246
|
+
export {
|
|
247
|
+
WebGL2Backend
|
|
248
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const VERTEX_SHADER = `#version 300 es
|
|
3
|
+
in vec2 a_position;
|
|
4
|
+
uniform mat3 u_matrix;
|
|
5
|
+
uniform vec4 u_crop;
|
|
6
|
+
out vec2 v_uv;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
vec3 clip = u_matrix * vec3(a_position, 1.0);
|
|
10
|
+
gl_Position = vec4(clip.xy, 0.0, 1.0);
|
|
11
|
+
v_uv = u_crop.xy + a_position * u_crop.zw;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
const FRAGMENT_SHADER = `#version 300 es
|
|
15
|
+
precision highp float;
|
|
16
|
+
in vec2 v_uv;
|
|
17
|
+
uniform sampler2D u_texture;
|
|
18
|
+
uniform float u_opacity;
|
|
19
|
+
out vec4 outColor;
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
outColor = texture(u_texture, v_uv) * u_opacity;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
export {
|
|
26
|
+
FRAGMENT_SHADER,
|
|
27
|
+
VERTEX_SHADER
|
|
28
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { apply, compose, rotate, translate, scale } from "../math/affine.mjs";
|
|
3
|
+
import { transformRect, rectCenter } from "../math/rect.mjs";
|
|
4
|
+
function worldToScreen(camera, viewport) {
|
|
5
|
+
return compose(
|
|
6
|
+
translate(viewport.width / 2, viewport.height / 2),
|
|
7
|
+
rotate(camera.rotation),
|
|
8
|
+
scale(camera.zoom),
|
|
9
|
+
translate(-camera.x, -camera.y)
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
function screenToWorld(camera, viewport) {
|
|
13
|
+
return compose(
|
|
14
|
+
translate(camera.x, camera.y),
|
|
15
|
+
scale(1 / camera.zoom),
|
|
16
|
+
rotate(-camera.rotation),
|
|
17
|
+
translate(-viewport.width / 2, -viewport.height / 2)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
function screenPointToWorld(camera, viewport, point) {
|
|
21
|
+
return apply(screenToWorld(camera, viewport), point);
|
|
22
|
+
}
|
|
23
|
+
function worldPointToScreen(camera, viewport, point) {
|
|
24
|
+
return apply(worldToScreen(camera, viewport), point);
|
|
25
|
+
}
|
|
26
|
+
function visibleWorldRect(camera, viewport) {
|
|
27
|
+
return transformRect(screenToWorld(camera, viewport), {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
width: viewport.width,
|
|
31
|
+
height: viewport.height
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function fitCamera(bounds, viewport, rotation = 0, padding = 0) {
|
|
35
|
+
const rotated = transformRect(rotate(rotation), bounds);
|
|
36
|
+
const usableW = Math.max(1, viewport.width * (1 - padding * 2));
|
|
37
|
+
const usableH = Math.max(1, viewport.height * (1 - padding * 2));
|
|
38
|
+
const zoom = Math.min(
|
|
39
|
+
usableW / Math.max(rotated.width, Number.EPSILON),
|
|
40
|
+
usableH / Math.max(rotated.height, Number.EPSILON)
|
|
41
|
+
);
|
|
42
|
+
const center = rectCenter(bounds);
|
|
43
|
+
return { x: center.x, y: center.y, zoom, rotation };
|
|
44
|
+
}
|
|
45
|
+
function anchoredCenter(anchor, screen, zoom, rotation, viewport) {
|
|
46
|
+
const offset = apply(compose(scale(1 / zoom), rotate(-rotation)), {
|
|
47
|
+
x: screen.x - viewport.width / 2,
|
|
48
|
+
y: screen.y - viewport.height / 2
|
|
49
|
+
});
|
|
50
|
+
return { x: anchor.x - offset.x, y: anchor.y - offset.y };
|
|
51
|
+
}
|
|
52
|
+
function sameCamera(a, b) {
|
|
53
|
+
return a.x === b.x && a.y === b.y && a.zoom === b.zoom && a.rotation === b.rotation;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
anchoredCenter,
|
|
57
|
+
fitCamera,
|
|
58
|
+
sameCamera,
|
|
59
|
+
screenPointToWorld,
|
|
60
|
+
screenToWorld,
|
|
61
|
+
visibleWorldRect,
|
|
62
|
+
worldPointToScreen,
|
|
63
|
+
worldToScreen
|
|
64
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { anchoredCenter } from "./Camera.mjs";
|
|
6
|
+
const DEFAULT_TIME_CONSTANT = 0.09;
|
|
7
|
+
const ZOOM_EPSILON = 1e-4;
|
|
8
|
+
const PIXEL_EPSILON = 0.05;
|
|
9
|
+
const ROTATION_EPSILON = 1e-4;
|
|
10
|
+
class CameraAnimator {
|
|
11
|
+
constructor(initial, timeConstant = DEFAULT_TIME_CONSTANT) {
|
|
12
|
+
__publicField(this, "current");
|
|
13
|
+
__publicField(this, "target", null);
|
|
14
|
+
__publicField(this, "timeConstant");
|
|
15
|
+
this.current = { ...initial };
|
|
16
|
+
this.timeConstant = timeConstant;
|
|
17
|
+
}
|
|
18
|
+
/** The state the camera is heading to (or at, when idle). */
|
|
19
|
+
get destination() {
|
|
20
|
+
return this.target ? { ...this.target.state } : { ...this.current };
|
|
21
|
+
}
|
|
22
|
+
/** Jump, canceling any animation. Used by drags, which must track the pointer 1:1. */
|
|
23
|
+
set(state) {
|
|
24
|
+
this.current = { ...state };
|
|
25
|
+
this.target = null;
|
|
26
|
+
}
|
|
27
|
+
animateTo(target, viewport, immediate = false) {
|
|
28
|
+
if (immediate || this.timeConstant === 0) {
|
|
29
|
+
this.set(target.state);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let anchor = target.anchor;
|
|
33
|
+
if (anchor) {
|
|
34
|
+
const landing = anchoredCenter(
|
|
35
|
+
anchor.world,
|
|
36
|
+
anchor.screen,
|
|
37
|
+
target.state.zoom,
|
|
38
|
+
target.state.rotation,
|
|
39
|
+
viewport
|
|
40
|
+
);
|
|
41
|
+
const miss = Math.hypot(landing.x - target.state.x, landing.y - target.state.y) * target.state.zoom;
|
|
42
|
+
if (miss > PIXEL_EPSILON) anchor = void 0;
|
|
43
|
+
}
|
|
44
|
+
this.target = { state: { ...target.state }, anchor };
|
|
45
|
+
}
|
|
46
|
+
stop() {
|
|
47
|
+
this.target = null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Advance by `dt` seconds. Returns true while still moving, so the frame loop knows to
|
|
51
|
+
* keep ticking.
|
|
52
|
+
*/
|
|
53
|
+
step(dt, viewport) {
|
|
54
|
+
const target = this.target;
|
|
55
|
+
if (!target) return false;
|
|
56
|
+
const k = 1 - Math.exp(-Math.max(dt, 0) / this.timeConstant);
|
|
57
|
+
const from = this.current;
|
|
58
|
+
const to = target.state;
|
|
59
|
+
const zoom = Math.exp(
|
|
60
|
+
Math.log(from.zoom) + (Math.log(to.zoom) - Math.log(from.zoom)) * k
|
|
61
|
+
);
|
|
62
|
+
const rotation = from.rotation + (to.rotation - from.rotation) * k;
|
|
63
|
+
let center;
|
|
64
|
+
if (target.anchor) {
|
|
65
|
+
center = anchoredCenter(
|
|
66
|
+
target.anchor.world,
|
|
67
|
+
target.anchor.screen,
|
|
68
|
+
zoom,
|
|
69
|
+
rotation,
|
|
70
|
+
viewport
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
center = {
|
|
74
|
+
x: from.x + (to.x - from.x) * k,
|
|
75
|
+
y: from.y + (to.y - from.y) * k
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
this.current = { x: center.x, y: center.y, zoom, rotation };
|
|
79
|
+
const settled = Math.abs(Math.log(to.zoom / zoom)) < ZOOM_EPSILON && Math.abs(to.rotation - rotation) < ROTATION_EPSILON && Math.hypot(to.x - center.x, to.y - center.y) * zoom < PIXEL_EPSILON;
|
|
80
|
+
if (settled) {
|
|
81
|
+
this.current = { ...to };
|
|
82
|
+
this.target = null;
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
CameraAnimator
|
|
90
|
+
};
|