@nulib/clover 4.0.0-beta.0 → 4.0.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/README.md +7 -7
- package/dist/components/Annotations/Annotations.mjs +165 -204
- package/dist/components/Annotations/EntryBodies.mjs +28 -3
- package/dist/components/Annotations/languages.mjs +1 -17
- package/dist/components/Body/BodyAlert.mjs +2 -1
- package/dist/components/Body/Caption.mjs +2 -1
- package/dist/components/Body/CaptionDetails.mjs +2 -1
- package/dist/components/Body/glyphs.mjs +9 -0
- package/dist/components/Canvas/AnnotationMenu.mjs +76 -60
- package/dist/components/Canvas/AnnotationState.mjs +9 -2
- package/dist/components/Canvas/Annotations.mjs +16 -7
- package/dist/components/Canvas/CanvasView.mjs +173 -32
- package/dist/components/Canvas/ChoiceMenu.mjs +51 -31
- package/dist/components/Canvas/Connected.mjs +38 -4
- package/dist/components/Canvas/ControlMenu.mjs +6 -4
- package/dist/components/Canvas/Controls.mjs +17 -1
- package/dist/components/Canvas/FrameAnimation.mjs +568 -167
- package/dist/components/Canvas/LoadedCanvas.mjs +5 -3
- package/dist/components/Canvas/PlaceBox.mjs +74 -0
- package/dist/components/Canvas/Placeholder.mjs +2 -1
- package/dist/components/Canvas/fromManifest.mjs +2 -1
- package/dist/components/Canvas/layout.mjs +121 -32
- package/dist/components/Canvas/media/MediaBody.mjs +32 -6
- package/dist/components/Canvas/media/Player.mjs +11 -25
- package/dist/components/Canvas/media/Transport.mjs +94 -61
- package/dist/components/Canvas/media/TransportButton.mjs +2 -1
- package/dist/components/Canvas/media/placeMenu.mjs +19 -0
- package/dist/components/Canvas/media/seekGaps.mjs +43 -0
- package/dist/components/Canvas/media/sequence.mjs +96 -0
- package/dist/components/Canvas/media/useMediaElement.mjs +22 -3
- package/dist/components/Collection/Collection.mjs +2 -1
- package/dist/components/CollectionSelect/CollectionSelect.mjs +5 -2
- package/dist/components/Contents/Contents.mjs +163 -34
- package/dist/components/Download/Download.mjs +34 -38
- package/dist/components/Download/downloads.mjs +40 -0
- package/dist/components/Items/AnnotationItems.mjs +165 -0
- package/dist/components/Items/CountMenu.mjs +89 -0
- package/dist/components/Items/Item.mjs +24 -17
- package/dist/components/Items/Items.mjs +65 -37
- package/dist/components/Items/Pager.mjs +39 -79
- package/dist/components/Items/PagerLayout.mjs +41 -0
- package/dist/components/Items/Position.mjs +103 -0
- package/dist/components/Items/StandaloneItems.mjs +12 -4
- package/dist/components/Items/TargetItems.mjs +202 -0
- package/dist/components/Label/Label.mjs +2 -1
- package/dist/components/Map/MapView.mjs +375 -64
- package/dist/components/Map/maplibre-worker.mjs +7 -0
- package/dist/components/Map/worker.mjs +22 -0
- package/dist/components/Panel/About.mjs +50 -16
- package/dist/components/Panel/AboutActions.mjs +117 -0
- package/dist/components/Panel/Panel.mjs +58 -18
- package/dist/components/Panel/PartOfManifest.mjs +4 -3
- package/dist/components/Panel/ReadingLanguages.mjs +20 -0
- package/dist/components/Primitives/Primitives.mjs +18 -3
- package/dist/components/Provider/Provider.mjs +19 -5
- package/dist/components/Root/Announcer.mjs +3 -2
- package/dist/components/Root/Root.mjs +5 -2
- package/dist/components/Root/useRootState.mjs +14 -2
- package/dist/components/Scene/SceneView.mjs +23 -6
- package/dist/components/Search/Search.mjs +3 -2
- package/dist/components/Split/Split.mjs +13 -3
- package/dist/components/Status/Status.mjs +10 -2
- package/dist/components/Timeline/playerSurface.mjs +2 -1
- package/dist/components/Transcript/Transcript.mjs +42 -23
- package/dist/core/annotation-bodies.mjs +25 -5
- package/dist/core/annotation-collection.mjs +3 -2
- package/dist/core/annotation-name.mjs +12 -9
- package/dist/core/annotation-sets.mjs +139 -10
- package/dist/core/annotations-content.mjs +8 -1
- package/dist/core/annotations.mjs +8 -1
- package/dist/core/choice-key.mjs +5 -0
- package/dist/core/clover.mjs +105 -20
- package/dist/core/content-state-reader.mjs +33 -2
- package/dist/core/dates-format.mjs +30 -0
- package/dist/core/dates.mjs +19 -0
- package/dist/core/geo.mjs +46 -5
- package/dist/core/image-layers.mjs +96 -0
- package/dist/core/items.mjs +7 -3
- package/dist/core/language-choice.mjs +30 -0
- package/dist/core/link.mjs +15 -1
- package/dist/core/load.mjs +14 -5
- package/dist/core/pages.mjs +20 -1
- package/dist/core/presentation.mjs +6 -4
- package/dist/core/range-regions.mjs +70 -0
- package/dist/core/ranges.mjs +52 -18
- package/dist/core/region.mjs +7 -2
- package/dist/core/sanitize.mjs +86 -1
- package/dist/core/save-file.mjs +33 -0
- package/dist/core/selectors.mjs +12 -0
- package/dist/core/upgrade.mjs +23 -0
- package/dist/core/value.mjs +11 -23
- package/dist/hooks/useFullscreenExit.mjs +26 -0
- package/dist/hooks/useHighContrast.mjs +27 -0
- package/dist/i18n/autonym.mjs +11 -0
- package/dist/i18n/config.mjs +3 -8
- package/dist/{core → i18n}/direction.mjs +5 -1
- package/dist/i18n/languages.mjs +44 -0
- package/dist/i18n/locales/en.json.mjs +1 -1
- package/dist/i18n/locales/es.json.mjs +1 -1
- package/dist/i18n/locales/fi.json.mjs +1 -1
- package/dist/i18n/locales/fr.json.mjs +1 -1
- package/dist/i18n/locales/nb.json.mjs +1 -1
- package/dist/i18n/locales/nn.json.mjs +1 -1
- package/dist/i18n/locales/no.json.mjs +1 -1
- package/dist/i18n/locales/pt.json.mjs +1 -1
- package/dist/{ui → i18n}/useContainerName.mjs +5 -4
- package/dist/{react/language.mjs → i18n/useRootLanguage.mjs} +2 -2
- package/dist/index.d.mts +415 -64
- package/dist/index.mjs +6 -2
- package/dist/lib/fullscreen.mjs +6 -1
- package/dist/lib/renderer/CanvasRenderer.mjs +28 -5
- package/dist/lib/renderer/math/affine.mjs +14 -0
- package/dist/lib/renderer/scene/planFrame.mjs +12 -12
- package/dist/lib/renderer/scene/regions.mjs +11 -1
- package/dist/lib/renderer/scene/sceneItem.mjs +72 -9
- package/dist/lib/time.mjs +10 -0
- package/dist/map/index.d.mts +40 -7
- package/dist/react/fetchManifest.mjs +19 -0
- package/dist/react/hooks.mjs +7 -1
- package/dist/react/readingLanguages.mjs +16 -0
- package/dist/react/usePagesReached.mjs +42 -0
- package/dist/styles.css +1 -1
- package/dist/templates/default/Default.mjs +87 -9
- package/dist/templates/document/Document.mjs +5 -1
- package/dist/templates/index.d.mts +26 -5
- package/dist/templates.css +1 -1
- package/dist/ui/BodyUnloadable.mjs +34 -0
- package/dist/ui/Button.mjs +2 -1
- package/dist/ui/Chevron.mjs +34 -0
- package/dist/ui/ControlCluster.mjs +6 -3
- package/dist/ui/EntryThumbnail.mjs +60 -0
- package/dist/ui/ExitFullscreen.mjs +2 -1
- package/dist/ui/FieldPill.mjs +5 -4
- package/dist/ui/HideToggle.mjs +2 -1
- package/dist/ui/LanguageChoice.mjs +45 -0
- package/dist/ui/ListEnd.mjs +29 -0
- package/dist/ui/Markup.mjs +27 -8
- package/dist/ui/NavDate.mjs +29 -0
- package/dist/ui/ReadMore.mjs +4 -3
- package/dist/ui/Sections.mjs +19 -28
- package/dist/ui/Steps.mjs +4 -3
- package/dist/ui/Tip.mjs +9 -4
- package/dist/web-components/About-DhOGPFaI.mjs +1 -0
- package/dist/web-components/AnnotationItems-CNP4CJiT.mjs +1 -0
- package/dist/web-components/AnnotationMenu-BCwwwfbb.mjs +1 -0
- package/dist/web-components/AnnotationState-CavxnAAq.mjs +1 -0
- package/dist/web-components/Annotations-DDjSrBL5.mjs +2 -0
- package/dist/web-components/Annotations-rBmeI5sR.mjs +1 -0
- package/dist/web-components/Body-DaY1UJIy.mjs +1 -0
- package/dist/web-components/BodyAlert-COKp19lq.mjs +1 -0
- package/dist/web-components/BodyUnloadable-DcTM7hHF.mjs +1 -0
- package/dist/web-components/Button-DLFYqtz9.mjs +1 -0
- package/dist/web-components/{Camera-Dw51CAfF.mjs → Camera-Cp5ma-6C.mjs} +1 -1
- package/dist/web-components/{Canvas2DBackend-RRN2bEkc.mjs → Canvas2DBackend-3PToh87Z.mjs} +1 -1
- package/dist/web-components/CanvasView-BWQ4SK2b.mjs +2 -0
- package/dist/web-components/CaptionDetails-DSziiuQV.mjs +1 -0
- package/dist/web-components/Chevron-r-_hUPn8.mjs +1 -0
- package/dist/web-components/ChoiceMenu-DTuEEUeM.mjs +1 -0
- package/dist/web-components/Collection-B9swJtPW.mjs +1 -0
- package/dist/web-components/CollectionSelect-CBWUbqQi.mjs +1 -0
- package/dist/web-components/Connected-B2d6EoFl.mjs +1 -0
- package/dist/web-components/Connected-BSRM9FJY.mjs +1 -0
- package/dist/web-components/Connected-BnpxYeJN.mjs +1 -0
- package/dist/web-components/Contents-D7FPxSH-.mjs +1 -0
- package/dist/web-components/ControlMenu-Crtho2cs.mjs +1 -0
- package/dist/web-components/CountMenu-DyTp_J4k.mjs +1 -0
- package/dist/web-components/Cue-CbZaGwZh.mjs +1 -0
- package/dist/web-components/Document-BfltLWZZ.mjs +1 -0
- package/dist/web-components/DocumentPanel-ZSe40cV4.mjs +1 -0
- package/dist/web-components/{DomLayers-BsR2AOy-.mjs → DomLayers-CTGub6wo.mjs} +1 -1
- package/dist/web-components/Download-BOYNIb7C.mjs +1 -0
- package/dist/web-components/EntryBodies-Bfd2Z42z.mjs +1 -0
- package/dist/web-components/EntryThumbnail-DQE8ajI9.mjs +1 -0
- package/dist/web-components/FieldPill-D5DNJWLy.mjs +1 -0
- package/dist/web-components/FrameAnimation-IfR1czfc.mjs +1 -0
- package/dist/web-components/Gallery-DD06BDQo.mjs +1 -0
- package/dist/web-components/HideToggle-DL911R1Z.mjs +1 -0
- package/dist/web-components/Items-BHzT9A73.mjs +1 -0
- package/dist/web-components/Label-KabnxuMN.mjs +1 -0
- package/dist/web-components/LanguageChoice-DT1UPiDn.mjs +1 -0
- package/dist/web-components/LightboxBody-BhRhdXo6.mjs +1 -0
- package/dist/web-components/ListEnd-CbwNlty-.mjs +1 -0
- package/dist/web-components/{Loaded-wQurAeJz.mjs → Loaded-BWfEBJyg.mjs} +1 -1
- package/dist/web-components/LoadedCanvas-CdZ5WOWz.mjs +1 -0
- package/dist/web-components/LoadedMap-DQyQVRVQ.mjs +1 -0
- package/dist/web-components/{Loading-BmA--pzr.mjs → Loading-zw74TdAz.mjs} +1 -1
- package/dist/web-components/{Map-DzVGblIS.mjs → Map--dJhk0_0.mjs} +1 -1
- package/dist/web-components/MapView-duA5WGsu.mjs +3 -0
- package/dist/web-components/Markup-D-kioDf9.mjs +2 -0
- package/dist/web-components/MediaBody-CoOiVXcv.mjs +1 -0
- package/dist/web-components/MediaBody-d8ErTuwT.mjs +1 -0
- package/dist/web-components/NavDate-BQHuyLOC.mjs +1 -0
- package/dist/web-components/{Navigator-CIJFA3q1.mjs → Navigator-B3U21_ti.mjs} +1 -1
- package/dist/web-components/Pager-DnJknq92.mjs +1 -0
- package/dist/web-components/PagerLayout-CvOmKtSW.mjs +1 -0
- package/dist/web-components/Panel-CIdjOznL.mjs +1 -0
- package/dist/web-components/{PanelToggle-BYjV2t1j.mjs → PanelToggle-CFtWIeWv.mjs} +1 -1
- package/dist/web-components/PartOfManifest-F87jIrf9.mjs +1 -0
- package/dist/web-components/{Pending-BspZajh5.mjs → Pending-CYAQajKu.mjs} +1 -1
- package/dist/web-components/PlaceBox-BtIbIotm.mjs +1 -0
- package/dist/web-components/Placeholder-TIyj4ZjR.mjs +1 -0
- package/dist/web-components/Position-BkWBRBfW.mjs +1 -0
- package/dist/web-components/Primitives-BmODPlnK.mjs +1 -0
- package/dist/web-components/Provider-C8se8i4I.mjs +1 -0
- package/dist/web-components/ReadMore-BwGFsLS2.mjs +1 -0
- package/dist/web-components/Root-CAJB0-Mh.mjs +1 -0
- package/dist/web-components/Scene-Ctcdt7CD.mjs +1 -0
- package/dist/web-components/SceneView-B6bEx_7x.mjs +1 -0
- package/dist/web-components/Search-CbmK9vLp.mjs +1 -0
- package/dist/web-components/Sections-Dy5_pkyQ.mjs +2 -0
- package/dist/web-components/StandaloneItems-BmUnBp0H.mjs +1 -0
- package/dist/web-components/Status-Dww3Pyf4.mjs +1 -0
- package/dist/web-components/Steps-o_UprQfZ.mjs +1 -0
- package/dist/web-components/TargetItems-BBOGDubv.mjs +1 -0
- package/dist/web-components/Timeline-CfIF4APc.mjs +1 -0
- package/dist/web-components/Tip-BbexILXs.mjs +1 -0
- package/dist/web-components/Transcript-ZVXM3ZDA.mjs +1 -0
- package/dist/web-components/annotation-collection-7SS1ELcO.mjs +1 -0
- package/dist/web-components/annotation-name-CYkZopdd.mjs +1 -0
- package/dist/web-components/annotations-content-Bdtn50sf.mjs +1 -0
- package/dist/web-components/body-CkOBHlJ0.mjs +1 -0
- package/dist/web-components/canvas-CWf_Fag8.mjs +1 -0
- package/dist/web-components/choice-key-BUNebLKe.mjs +1 -0
- package/dist/web-components/{cloverEngine-Dbv-26NP.mjs → cloverEngine-6djEHNCD.mjs} +2 -2
- package/dist/web-components/content-state-reader-Ahh6artg.mjs +1 -0
- package/dist/web-components/{controls-qRYf2jO2.mjs → controls-BJrZVQkS.mjs} +1 -1
- package/dist/web-components/custom-elements.json +109 -13
- package/dist/web-components/dates-DR3gfcON.mjs +1 -0
- package/dist/web-components/downloads-CqVWo-yn.mjs +1 -0
- package/dist/web-components/{engine-D8JLgzqq.mjs → engine-B-sscpLa.mjs} +1 -1
- package/dist/web-components/{engines-BwVb9R_A.mjs → engines-DfCHjbt3.mjs} +1 -1
- package/dist/web-components/es-BYfHUZ7P.mjs +1 -0
- package/dist/web-components/fetchManifest-BIzne1Pj.mjs +1 -0
- package/dist/web-components/fi-B5y2qr8T.mjs +1 -0
- package/dist/web-components/fr-ChezCx6V.mjs +1 -0
- package/dist/web-components/fromManifest-gg5Wx14y.mjs +1 -0
- package/dist/web-components/glyphs-JYl2STEr.mjs +1 -0
- package/dist/web-components/hooks-x7rO95CS.mjs +1 -0
- package/dist/web-components/image-layers-BjbeyHBS.mjs +1 -0
- package/dist/web-components/{imageService-C3yg9DxB.mjs → imageService-0eTvQ-3h.mjs} +1 -1
- package/dist/web-components/index-BZ7b9k0N.mjs +1 -0
- package/dist/web-components/index.d.mts +95 -10
- package/dist/web-components/index.mjs +1 -1
- package/dist/web-components/items-CnAIl9fS.mjs +1 -0
- package/dist/web-components/items-F6hJgdAS.mjs +1 -0
- package/dist/web-components/label-CI88KH2_.mjs +1 -0
- package/dist/web-components/layout-De1MOSYe.mjs +1 -0
- package/dist/web-components/link-GEdiEwlR.mjs +1 -0
- package/dist/web-components/logo-Ckwj7FlP.mjs +1 -0
- package/dist/web-components/models-59cEeiAA.mjs +1 -0
- package/dist/web-components/nb-8J22f9Td.mjs +1 -0
- package/dist/web-components/nn-Dv1EvzI1.mjs +1 -0
- package/dist/web-components/no-8J22f9Td.mjs +1 -0
- package/dist/web-components/{nodes-Bf-Fb7e5.mjs → nodes-CTw9OqlA.mjs} +1 -1
- package/dist/web-components/{overlayImage-DdPs2EGY.mjs → overlayImage-BMt4UTlR.mjs} +1 -1
- package/dist/web-components/{panel-CiqEFDzv.mjs → panel-C17Rl9Ya.mjs} +1 -1
- package/dist/web-components/part-CXts97_M.mjs +1 -0
- package/dist/web-components/playerSurface-HYwEwPK6.mjs +1 -0
- package/dist/web-components/presentation-2-C-U79S_T.mjs +1 -0
- package/dist/web-components/{provider-LUmAQSoP.mjs → provider-BpxorEiq.mjs} +1 -1
- package/dist/web-components/pt-DWYQkATt.mjs +1 -0
- package/dist/web-components/range-regions-BGQy4E9U.mjs +1 -0
- package/dist/web-components/read-more-BDM_6CVc.mjs +1 -0
- package/dist/web-components/readingLanguages-fs_HqvqQ.mjs +1 -0
- package/dist/web-components/rendererSurface-C0aKlE0v.mjs +22 -0
- package/dist/web-components/{renderers-Bg4QqawN.mjs → renderers-CiB74bQh.mjs} +1 -1
- package/dist/web-components/{resource-DzIvB_4m.mjs → resource-CRbpf9pX.mjs} +1 -1
- package/dist/web-components/sanitize-qIOeyIww.mjs +3 -0
- package/dist/web-components/save-file-CCuZEuQr.mjs +1 -0
- package/dist/web-components/search-CkM0O0Z1.mjs +1 -0
- package/dist/web-components/sequence-C28xoNmD.mjs +1 -0
- package/dist/web-components/shared-MTsMddHx.mjs +1 -0
- package/dist/web-components/{show-link-DWRRXSBy.mjs → show-link-BXm7SNIC.mjs} +1 -1
- package/dist/web-components/{sizedImage-DfjlV2-i.mjs → sizedImage-k4Q-eyOB.mjs} +1 -1
- package/dist/web-components/{split-m-_XivaW.mjs → split-Hp6z-v4h.mjs} +1 -1
- package/dist/web-components/{status-DDS7jLNd.mjs → status-BmtuKfAG.mjs} +1 -1
- package/dist/web-components/styles-CZV1nbBQ.mjs +1 -0
- package/dist/web-components/three.mjs +1 -1
- package/dist/web-components/thumbnail-Dp7a8oom.mjs +1 -0
- package/dist/web-components/{tip-BXByhOJ9.mjs → tip-C-oovDZK.mjs} +1 -1
- package/dist/web-components/{toggle-AS72kq6v.mjs → toggle-C7ODWDEZ.mjs} +1 -1
- package/dist/web-components/upgrade-eNW0DPXq.mjs +1 -0
- package/dist/web-components/upgrader-BlbMUEH6.mjs +1 -0
- package/dist/web-components/useContainerName-CrOmY-km.mjs +1 -0
- package/dist/web-components/useNearViewport-BqXi9Gn4.mjs +1 -0
- package/dist/web-components/{useScrollTrack-dLFWnT8N.mjs → useScrollTrack-CEsOU2yT.mjs} +1 -1
- package/dist/web-components/viewer/AnnotationItems-CyhVcRFc.mjs +1 -0
- package/dist/web-components/viewer/AnnotationMenu-DPOSehBo.mjs +1 -0
- package/dist/web-components/viewer/AnnotationState-Bjztkobn.mjs +1 -0
- package/dist/web-components/viewer/Annotations-Dh_8Tzi0.mjs +2 -0
- package/dist/web-components/viewer/Annotations-wwuOCxzI.mjs +1 -0
- package/dist/web-components/viewer/{Canvas2DBackend-CkvI0wUT.mjs → Canvas2DBackend-BTK6ZJh0.mjs} +1 -1
- package/dist/web-components/viewer/CaptionDetails-BwCTovy_.mjs +1 -0
- package/dist/web-components/viewer/ChoiceMenu-DQ1x572Y.mjs +1 -0
- package/dist/web-components/viewer/Collection-DSBxCmXw.mjs +1 -0
- package/dist/web-components/viewer/Connected-CL3N8F2J.mjs +1 -0
- package/dist/web-components/viewer/Connected-DTk1jlyI.mjs +1 -0
- package/dist/web-components/viewer/Contents-DrXckx7d.mjs +1 -0
- package/dist/web-components/viewer/ControlMenu-Bp91s-g_.mjs +1 -0
- package/dist/web-components/viewer/CountMenu-4u6U6yqb.mjs +1 -0
- package/dist/web-components/viewer/Cue-C-aF8peC.mjs +1 -0
- package/dist/web-components/viewer/Document-BN1rICu3.mjs +1 -0
- package/dist/web-components/viewer/DocumentPanel-CEesxdeY.mjs +1 -0
- package/dist/web-components/viewer/{DomLayers-Dybz_aJv.mjs → DomLayers-CGkDtemL.mjs} +1 -1
- package/dist/web-components/viewer/Download-CawEl9MN.mjs +1 -0
- package/dist/web-components/viewer/EntryBodies-nYHMwSSM.mjs +1 -0
- package/dist/web-components/viewer/EntryThumbnail-DrO_0SzR.mjs +1 -0
- package/dist/web-components/viewer/FieldPill-DFXGWrvB.mjs +1 -0
- package/dist/web-components/viewer/FrameAnimation-CZfzpxaD.mjs +1 -0
- package/dist/web-components/viewer/Gallery-MWHtvjti.mjs +1 -0
- package/dist/web-components/viewer/HideToggle-DP5kHzWM.mjs +1 -0
- package/dist/web-components/viewer/LanguageChoice-C50T7dPI.mjs +1 -0
- package/dist/web-components/viewer/{LightboxBody-ClQ4yrTh.mjs → LightboxBody-C2T7IC29.mjs} +1 -1
- package/dist/web-components/viewer/ListEnd-BDuOx__m.mjs +1 -0
- package/dist/web-components/viewer/MapView-BN9wXQKV.mjs +3 -0
- package/dist/web-components/viewer/MediaBody-CEyswliX.mjs +1 -0
- package/dist/web-components/viewer/MediaBody-Dw3DWDjc.mjs +1 -0
- package/dist/web-components/viewer/NavDate-C2-wwLuB.mjs +1 -0
- package/dist/web-components/viewer/{Navigator-Duc69Yes.mjs → Navigator-C3jghOd3.mjs} +1 -1
- package/dist/web-components/viewer/PagerLayout-Cg2NpqoD.mjs +1 -0
- package/dist/web-components/viewer/PartOfManifest-D22yMgCf.mjs +1 -0
- package/dist/web-components/viewer/PlaceBox-Dckw4Sfk.mjs +1 -0
- package/dist/web-components/viewer/Placeholder-NYVWYg5Q.mjs +1 -0
- package/dist/web-components/viewer/Search-DC259m4f.mjs +1 -0
- package/dist/web-components/viewer/StandaloneItems-E4kpMne9.mjs +1 -0
- package/dist/web-components/viewer/Steps-Bw32X5xO.mjs +1 -0
- package/dist/web-components/viewer/TargetItems-DLhUH1Gq.mjs +1 -0
- package/dist/web-components/viewer/Transcript-D_VGJQxn.mjs +1 -0
- package/dist/web-components/viewer/annotation-collection-DZHa18ir.mjs +1 -0
- package/dist/web-components/viewer/annotation-name-BaNdW2Xk.mjs +1 -0
- package/dist/web-components/viewer/annotations-content-CbA3eOIC.mjs +1 -0
- package/dist/web-components/viewer/{cloverEngine-CjuYjUhI.mjs → cloverEngine-C04bCSFR.mjs} +2 -2
- package/dist/web-components/viewer/content-state-reader-C7UBMOq3.mjs +1 -0
- package/dist/web-components/viewer/fetchManifest-C2Yxg3x9.mjs +1 -0
- package/dist/web-components/viewer/{host-yWi4R1bP.mjs → host-CZeyjCKR.mjs} +1 -1
- package/dist/web-components/viewer/image-layers-B09fporZ.mjs +1 -0
- package/dist/web-components/viewer/index.mjs +1 -1
- package/dist/web-components/viewer/link-DssZ0Z2N.mjs +1 -0
- package/dist/web-components/viewer/overlayImage-BR3eJCKq.mjs +1 -0
- package/dist/web-components/viewer/range-regions-By6L5JOK.mjs +1 -0
- package/dist/web-components/viewer/{renderers-L-IlGI1r.mjs → renderers-DLoqv3QO.mjs} +1 -1
- package/dist/web-components/viewer/save-file-CJT5p5Hg.mjs +1 -0
- package/dist/web-components/viewer/{search-DWkwRPo_.mjs → search-PhOwMKHi.mjs} +1 -1
- package/dist/web-components/viewer/styles-NZLnZPAC.mjs +1 -0
- package/dist/web-components/viewer/viewer-D30YHqyF.mjs +29 -0
- package/dist/web-components/viewer/{vtt-1ZJwtElI.mjs → vtt-1Pk7Dhsj.mjs} +1 -1
- package/dist/web-components/viewer-CH7re5OO.mjs +1 -0
- package/dist/web-components/{vtt-GFssZH8Y.mjs → vtt-CacHieeN.mjs} +1 -1
- package/dist/web-components/worker-CjXN0dku.mjs +1 -0
- package/package.json +10 -5
- package/dist/i18n/reader.mjs +0 -13
- package/dist/web-components/About-uKa1wfDr.mjs +0 -1
- package/dist/web-components/AnnotationMenu-BGIYRXW6.mjs +0 -1
- package/dist/web-components/AnnotationState-D2UIgIEC.mjs +0 -1
- package/dist/web-components/Annotations-BhwAv3ah.mjs +0 -1
- package/dist/web-components/Annotations-C_tBJHo3.mjs +0 -2
- package/dist/web-components/Body-DMEERFuB.mjs +0 -1
- package/dist/web-components/BodyAlert-BP8voSLv.mjs +0 -1
- package/dist/web-components/Button-Cl02BFDd.mjs +0 -1
- package/dist/web-components/CanvasView-B8lMMSou.mjs +0 -1
- package/dist/web-components/CaptionDetails-KLMDv-ec.mjs +0 -1
- package/dist/web-components/ChoiceMenu-CXrVOmJl.mjs +0 -1
- package/dist/web-components/Collection-DL4Ui4hF.mjs +0 -1
- package/dist/web-components/CollectionSelect-DL-bbpwJ.mjs +0 -1
- package/dist/web-components/Connected-B0S1HXQb.mjs +0 -1
- package/dist/web-components/Connected-BcjRA5si.mjs +0 -1
- package/dist/web-components/Connected-Q7iizBb8.mjs +0 -1
- package/dist/web-components/Contents-ZC8TiGaW.mjs +0 -1
- package/dist/web-components/ControlMenu-DIoU797-.mjs +0 -1
- package/dist/web-components/Cue-CJxnDMEy.mjs +0 -1
- package/dist/web-components/Document-DHBRAFEK.mjs +0 -1
- package/dist/web-components/DocumentPanel-CqvE2pu9.mjs +0 -1
- package/dist/web-components/Download-DBksL1C0.mjs +0 -1
- package/dist/web-components/EntryBodies-VwEkTVrw.mjs +0 -1
- package/dist/web-components/ErrorBoundary-Cy9PGoZv.mjs +0 -1
- package/dist/web-components/FieldPill-DCJBz6Vj.mjs +0 -1
- package/dist/web-components/FrameAnimation-DRbmgGpF.mjs +0 -1
- package/dist/web-components/Gallery-BM7-VJkB.mjs +0 -1
- package/dist/web-components/HideToggle-BdYgG7us.mjs +0 -1
- package/dist/web-components/Items-_1Jz3FMs.mjs +0 -1
- package/dist/web-components/Label-CAiJ49eA.mjs +0 -1
- package/dist/web-components/LightboxBody-DyhUZiDf.mjs +0 -1
- package/dist/web-components/LoadedCanvas-DWz5IK5m.mjs +0 -1
- package/dist/web-components/LoadedMap-DIeW313M.mjs +0 -1
- package/dist/web-components/MapView-BJaN7VBI.mjs +0 -1
- package/dist/web-components/Markup-D91DbxLk.mjs +0 -2
- package/dist/web-components/MediaBody-BYcVPo2X.mjs +0 -1
- package/dist/web-components/MediaBody-FEzH8VVw.mjs +0 -1
- package/dist/web-components/Pager-BGwCurxE.mjs +0 -1
- package/dist/web-components/Panel-B-GXOkzF.mjs +0 -1
- package/dist/web-components/PartOfManifest-ClbGepVM.mjs +0 -1
- package/dist/web-components/Primitives-CTh59wvs.mjs +0 -1
- package/dist/web-components/Provider-C6rIiDXH.mjs +0 -1
- package/dist/web-components/ReadMore-BJ2i-0uN.mjs +0 -1
- package/dist/web-components/Root-DkkYDtur.mjs +0 -1
- package/dist/web-components/Scene-B_PU_TiX.mjs +0 -1
- package/dist/web-components/SceneView-qcW_sT3j.mjs +0 -1
- package/dist/web-components/Search-UOneIUcP.mjs +0 -1
- package/dist/web-components/Sections-we9U9fXq.mjs +0 -2
- package/dist/web-components/StandaloneItems-DU8oCFc_.mjs +0 -1
- package/dist/web-components/Status-Cs5ZvFvL.mjs +0 -1
- package/dist/web-components/Timeline-WtYZ1bIJ.mjs +0 -1
- package/dist/web-components/Tip-C8J3qsIK.mjs +0 -1
- package/dist/web-components/Transcript-CRL2zToL.mjs +0 -1
- package/dist/web-components/annotation-collection-ZPyvpLFc.mjs +0 -1
- package/dist/web-components/annotations-content-BZChKhJZ.mjs +0 -1
- package/dist/web-components/body-UntgrmoV.mjs +0 -1
- package/dist/web-components/canvas-d_U4v_mh.mjs +0 -1
- package/dist/web-components/content-state-reader-DjdKWjit.mjs +0 -1
- package/dist/web-components/es-BwMkoRod.mjs +0 -1
- package/dist/web-components/fi-gPFOn9RK.mjs +0 -1
- package/dist/web-components/fr-DUHmgdJo.mjs +0 -1
- package/dist/web-components/fromManifest-UrMJgktp.mjs +0 -1
- package/dist/web-components/glyphs-BoX0a88P.mjs +0 -1
- package/dist/web-components/hooks-Dp8pjU8l.mjs +0 -1
- package/dist/web-components/index-DWxMuwDL.mjs +0 -1
- package/dist/web-components/items--Tu7ZM3L.mjs +0 -1
- package/dist/web-components/items-W2vrwArM.mjs +0 -1
- package/dist/web-components/keep-fragments-B5nlv2ck.mjs +0 -1
- package/dist/web-components/label-CYQ7tVl6.mjs +0 -1
- package/dist/web-components/layout-KL0V-iJu.mjs +0 -1
- package/dist/web-components/link-DRRTY4lY.mjs +0 -1
- package/dist/web-components/logo-CnQUCB3Y.mjs +0 -1
- package/dist/web-components/models-BP2qp9nT.mjs +0 -1
- package/dist/web-components/nb-BSvnQ6jd.mjs +0 -1
- package/dist/web-components/nn-Dg2_HdZu.mjs +0 -1
- package/dist/web-components/no-BSvnQ6jd.mjs +0 -1
- package/dist/web-components/part-CUBY90_b.mjs +0 -1
- package/dist/web-components/playerSurface-i2TJz-F4.mjs +0 -1
- package/dist/web-components/pt-B3J80JgO.mjs +0 -1
- package/dist/web-components/read-more-BaaO77el.mjs +0 -1
- package/dist/web-components/rendererSurface-DAvatpMF.mjs +0 -22
- package/dist/web-components/sanitize-Dc7nOsgO.mjs +0 -3
- package/dist/web-components/search-DgcgsI3I.mjs +0 -1
- package/dist/web-components/shared-J3w3gnXD.mjs +0 -1
- package/dist/web-components/styles-Ypl9KrSK.mjs +0 -1
- package/dist/web-components/thumbnail-BZvLSwWW.mjs +0 -1
- package/dist/web-components/time-B9GZoYcm.mjs +0 -1
- package/dist/web-components/upgrader-XNxI-5jo.mjs +0 -1
- package/dist/web-components/useContainerName-DCbE5JXi.mjs +0 -1
- package/dist/web-components/useNearViewport-CyoK3l8W.mjs +0 -1
- package/dist/web-components/viewer/AnnotationMenu-Dd4tnzNV.mjs +0 -1
- package/dist/web-components/viewer/AnnotationState-DZaSy5lH.mjs +0 -1
- package/dist/web-components/viewer/Annotations-D1h-Yi5J.mjs +0 -1
- package/dist/web-components/viewer/Annotations-sj79EMen.mjs +0 -2
- package/dist/web-components/viewer/CaptionDetails-B_JdNjJ7.mjs +0 -1
- package/dist/web-components/viewer/ChoiceMenu-xa51a1DV.mjs +0 -1
- package/dist/web-components/viewer/Collection-CxuLCspj.mjs +0 -1
- package/dist/web-components/viewer/Connected-BSUBc3Ci.mjs +0 -1
- package/dist/web-components/viewer/Connected-CPIxNjF2.mjs +0 -1
- package/dist/web-components/viewer/Contents-DNh9mnsF.mjs +0 -1
- package/dist/web-components/viewer/ControlMenu-DdgIvBdf.mjs +0 -1
- package/dist/web-components/viewer/Cue-90H9_dXz.mjs +0 -1
- package/dist/web-components/viewer/Document-CNCpzkiN.mjs +0 -1
- package/dist/web-components/viewer/DocumentPanel-BdG4TVLE.mjs +0 -1
- package/dist/web-components/viewer/EntryBodies-DGXjFP3N.mjs +0 -1
- package/dist/web-components/viewer/FieldPill-Icmd98OY.mjs +0 -1
- package/dist/web-components/viewer/FrameAnimation-DJZN3Rd4.mjs +0 -1
- package/dist/web-components/viewer/Gallery-CEp3-bh2.mjs +0 -1
- package/dist/web-components/viewer/HideToggle-DB6HTmAO.mjs +0 -1
- package/dist/web-components/viewer/MapView-BVSdybIC.mjs +0 -1
- package/dist/web-components/viewer/MediaBody-BBbSMT1i.mjs +0 -1
- package/dist/web-components/viewer/MediaBody-BzMXMHIF.mjs +0 -1
- package/dist/web-components/viewer/PartOfManifest-X9_q-2t6.mjs +0 -1
- package/dist/web-components/viewer/Search-S4N5QU4R.mjs +0 -1
- package/dist/web-components/viewer/StandaloneItems-BO4VyWRW.mjs +0 -1
- package/dist/web-components/viewer/Transcript-BbDaS064.mjs +0 -1
- package/dist/web-components/viewer/annotation-collection-BjZ1DAHq.mjs +0 -1
- package/dist/web-components/viewer/annotations-content-jn3n5Y2-.mjs +0 -1
- package/dist/web-components/viewer/content-state-reader-CPiShIjP.mjs +0 -1
- package/dist/web-components/viewer/link-CwE-fg5G.mjs +0 -1
- package/dist/web-components/viewer/overlayImage-BpOgqsZ0.mjs +0 -1
- package/dist/web-components/viewer/styles-BRCkEU3w.mjs +0 -1
- package/dist/web-components/viewer/viewer--TreVlJ_.mjs +0 -28
- package/dist/web-components/viewer-DyV864Qe.mjs +0 -1
- /package/dist/{ui → i18n}/languageCode.mjs +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { readPage } from "./annotation-sets.mjs";
|
|
3
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
4
|
+
import { choiceKey } from "./choice-key.mjs";
|
|
5
|
+
import { isPainting } from "./painting.mjs";
|
|
6
|
+
import { selectSequence } from "./selectors.mjs";
|
|
7
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
8
|
+
function imageLayers(manifest) {
|
|
9
|
+
const byId = /* @__PURE__ */ new Map();
|
|
10
|
+
for (const canvas of selectSequence(manifest).canvases)
|
|
11
|
+
readLayers(canvas, byId);
|
|
12
|
+
return [...byId.values()];
|
|
13
|
+
}
|
|
14
|
+
function readLayers(canvas, byId) {
|
|
15
|
+
asArray(canvas.items).forEach(
|
|
16
|
+
(page, p) => asArray(page == null ? void 0 : page.items).forEach((painting, a) => {
|
|
17
|
+
if (!isPainting(painting)) return;
|
|
18
|
+
const at = parseAnnotationTarget(asArray(painting.target)[0]).rect ?? {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0,
|
|
21
|
+
w: Number(canvas.width) || 0,
|
|
22
|
+
h: Number(canvas.height) || 0
|
|
23
|
+
};
|
|
24
|
+
asArray(painting.body).forEach((body, b) => {
|
|
25
|
+
const choice = (body == null ? void 0 : body.type) === "Choice";
|
|
26
|
+
const items = choice ? asArray(body.items) : [body];
|
|
27
|
+
items.forEach((image, i) => {
|
|
28
|
+
for (const own of asArray(image == null ? void 0 : image.annotations)) {
|
|
29
|
+
if (!Array.isArray(own == null ? void 0 : own.items) || typeof (image == null ? void 0 : image.id) !== "string")
|
|
30
|
+
continue;
|
|
31
|
+
const id = own.id ?? `${image.id}#annotations`;
|
|
32
|
+
const layer = choice ? {
|
|
33
|
+
key: choiceKey(canvas.id, painting.id, p, a, b),
|
|
34
|
+
item: i,
|
|
35
|
+
image: image.id
|
|
36
|
+
} : void 0;
|
|
37
|
+
const entries = readPage(own, id, canvas.id).map((entry) => {
|
|
38
|
+
const region = imageRegion(entry.annotation, image);
|
|
39
|
+
const x = Math.round(at.x + region.x * (at.w / region.width));
|
|
40
|
+
const y = Math.round(at.y + region.y * (at.h / region.height));
|
|
41
|
+
const w = Math.round(region.w * (at.w / region.width));
|
|
42
|
+
const h = Math.round(region.h * (at.h / region.height));
|
|
43
|
+
const target = `${canvas.id}#xywh=${x},${y},${w},${h}`;
|
|
44
|
+
return {
|
|
45
|
+
...entry,
|
|
46
|
+
canvasId: canvas.id,
|
|
47
|
+
target: parseAnnotationTarget(target),
|
|
48
|
+
annotation: { ...entry.annotation, target },
|
|
49
|
+
...layer ? { layer } : {}
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
if (!entries.length) continue;
|
|
53
|
+
let set = byId.get(id);
|
|
54
|
+
if (!set) {
|
|
55
|
+
set = {
|
|
56
|
+
id,
|
|
57
|
+
label: own.label ?? image.label,
|
|
58
|
+
source: "manifest",
|
|
59
|
+
entries: []
|
|
60
|
+
};
|
|
61
|
+
byId.set(id, set);
|
|
62
|
+
}
|
|
63
|
+
set.entries.push(...entries);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function imageRegion(annotation, image) {
|
|
71
|
+
const width = Number(image.width) || 1;
|
|
72
|
+
const height = Number(image.height) || 1;
|
|
73
|
+
const all = { x: 0, y: 0, w: width, h: height, width, height };
|
|
74
|
+
const target = asArray(annotation == null ? void 0 : annotation.target)[0];
|
|
75
|
+
const selectors = typeof target === "object" ? asArray(target == null ? void 0 : target.selector) : [];
|
|
76
|
+
const api = selectors.find((each) => (each == null ? void 0 : each.type) === "ImageApiSelector");
|
|
77
|
+
const value = typeof (api == null ? void 0 : api.region) === "string" ? api.region : void 0;
|
|
78
|
+
if (value) {
|
|
79
|
+
const match = /^(pct:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)$/.exec(value);
|
|
80
|
+
if (!match) return all;
|
|
81
|
+
const [x, y, w, h] = match.slice(2).map(Number);
|
|
82
|
+
return match[1] ? {
|
|
83
|
+
x: x / 100 * width,
|
|
84
|
+
y: y / 100 * height,
|
|
85
|
+
w: w / 100 * width,
|
|
86
|
+
h: h / 100 * height,
|
|
87
|
+
width,
|
|
88
|
+
height
|
|
89
|
+
} : { x, y, w, h, width, height };
|
|
90
|
+
}
|
|
91
|
+
const rect = parseAnnotationTarget(target).rect;
|
|
92
|
+
return rect ? { ...rect, width, height } : all;
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
imageLayers
|
|
96
|
+
};
|
package/dist/core/items.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { selectSequence } from "./selectors.mjs";
|
|
3
|
-
import { localize } from "./value.mjs";
|
|
3
|
+
import { hrefLangOf, localize } from "./value.mjs";
|
|
4
4
|
import { paintedBodies } from "./painted-bodies.mjs";
|
|
5
5
|
import { asArray } from "../lib/asArray.mjs";
|
|
6
6
|
function paintedType(container) {
|
|
@@ -53,7 +53,9 @@ function itemsOfCollection(collection) {
|
|
|
53
53
|
parts: [part(member)],
|
|
54
54
|
label: member.label,
|
|
55
55
|
summary: member.summary,
|
|
56
|
-
|
|
56
|
+
...typeof member.navDate === "string" ? { navDate: member.navDate } : {},
|
|
57
|
+
href: ((_a = asArray(member.homepage)[0]) == null ? void 0 : _a.id) ?? member.id,
|
|
58
|
+
...hrefLangOf(asArray(member.homepage)[0]) ? { hrefLang: hrefLangOf(asArray(member.homepage)[0]) } : {}
|
|
57
59
|
};
|
|
58
60
|
});
|
|
59
61
|
memberItems.set(collection, items);
|
|
@@ -63,7 +65,9 @@ function itemsOfCollection(collection) {
|
|
|
63
65
|
function itemsOf(resource) {
|
|
64
66
|
if (!resource) return [];
|
|
65
67
|
if (Array.isArray(resource)) {
|
|
66
|
-
return itemsOfCollection({
|
|
68
|
+
return itemsOfCollection({
|
|
69
|
+
items: resource
|
|
70
|
+
});
|
|
67
71
|
}
|
|
68
72
|
return resource.type === "Collection" ? itemsOfCollection(resource) : itemsOfManifest(resource);
|
|
69
73
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { languageToRead } from "../i18n/languages.mjs";
|
|
3
|
+
import { localize } from "./value.mjs";
|
|
4
|
+
function startingLanguage(languages, language, picked) {
|
|
5
|
+
if (picked && languages.includes(picked)) return picked;
|
|
6
|
+
if (!languages.length) return void 0;
|
|
7
|
+
const tag = languageToRead(languages, language);
|
|
8
|
+
return tag === "none" ? languages[0] : tag;
|
|
9
|
+
}
|
|
10
|
+
const keysOf = (value) => value && typeof value === "object" && !Array.isArray(value) ? Object.keys(value).filter(
|
|
11
|
+
(tag) => tag !== "none" && tag !== "@none" && localize({ [tag]: value[tag] }).text
|
|
12
|
+
) : [];
|
|
13
|
+
function descriptionLanguages(manifest) {
|
|
14
|
+
if (!manifest) return [];
|
|
15
|
+
const pairs = [
|
|
16
|
+
...Array.isArray(manifest.metadata) ? manifest.metadata : [],
|
|
17
|
+
manifest.requiredStatement
|
|
18
|
+
].filter(Boolean);
|
|
19
|
+
const maps = [
|
|
20
|
+
manifest.label,
|
|
21
|
+
manifest.summary,
|
|
22
|
+
...pairs.flatMap((pair) => [pair == null ? void 0 : pair.label, pair == null ? void 0 : pair.value])
|
|
23
|
+
];
|
|
24
|
+
const tags = maps.map(keysOf).filter((each) => each.length > 1);
|
|
25
|
+
return [...new Set(tags.flat())];
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
descriptionLanguages,
|
|
29
|
+
startingLanguage
|
|
30
|
+
};
|
package/dist/core/link.mjs
CHANGED
|
@@ -23,6 +23,20 @@ function readLink(annotation) {
|
|
|
23
23
|
}
|
|
24
24
|
return void 0;
|
|
25
25
|
}
|
|
26
|
+
function readTagSource(annotation) {
|
|
27
|
+
const motivation = asArray(annotation == null ? void 0 : annotation.motivation);
|
|
28
|
+
if (!motivation.includes("tagging") && !motivation.includes("identifying"))
|
|
29
|
+
return void 0;
|
|
30
|
+
for (const body of bodiesOf(annotation)) {
|
|
31
|
+
if ((body == null ? void 0 : body.type) === "TextualBody" || typeof (body == null ? void 0 : body.value) === "string")
|
|
32
|
+
continue;
|
|
33
|
+
const source = (body == null ? void 0 : body.type) === "SpecificResource" ? body.source : body;
|
|
34
|
+
const id = typeof source === "string" ? source : source == null ? void 0 : source.id;
|
|
35
|
+
if (typeof id === "string" && /^https?:\/\//i.test(id)) return { id };
|
|
36
|
+
}
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
26
39
|
export {
|
|
27
|
-
readLink
|
|
40
|
+
readLink,
|
|
41
|
+
readTagSource
|
|
28
42
|
};
|
package/dist/core/load.mjs
CHANGED
|
@@ -84,7 +84,9 @@ async function firstManifest(collection, options, depth = 0) {
|
|
|
84
84
|
}
|
|
85
85
|
if (item.type === "Collection" && depth < 8) {
|
|
86
86
|
const nested = await withMembers(
|
|
87
|
-
await toPresentation4(
|
|
87
|
+
await toPresentation4(
|
|
88
|
+
await dereference(item, options)
|
|
89
|
+
),
|
|
88
90
|
options
|
|
89
91
|
);
|
|
90
92
|
const found = await firstManifest(nested, options, depth + 1);
|
|
@@ -96,7 +98,9 @@ async function firstManifest(collection, options, depth = 0) {
|
|
|
96
98
|
async function fetchResource(input, { request, signal } = {}) {
|
|
97
99
|
void preloadUpgrader();
|
|
98
100
|
const json = typeof input === "string" ? await fetchJson(request, input.trim(), signal) : input;
|
|
99
|
-
const resource = await toPresentation4(
|
|
101
|
+
const resource = await toPresentation4(
|
|
102
|
+
json
|
|
103
|
+
);
|
|
100
104
|
return resource.type === "Collection" ? withMembers(resource, { request, signal }) : resource;
|
|
101
105
|
}
|
|
102
106
|
async function loadContent(input, options = {}) {
|
|
@@ -106,6 +110,7 @@ async function loadContent(input, options = {}) {
|
|
|
106
110
|
let target;
|
|
107
111
|
let member;
|
|
108
112
|
let annotation;
|
|
113
|
+
let targets;
|
|
109
114
|
let json;
|
|
110
115
|
const followContentState = async (state) => {
|
|
111
116
|
const { resolveContentState } = await readContentState();
|
|
@@ -114,6 +119,7 @@ async function loadContent(input, options = {}) {
|
|
|
114
119
|
target = resolved.target ?? target;
|
|
115
120
|
member = resolved.manifestId ?? member;
|
|
116
121
|
annotation = resolved.annotation ?? annotation;
|
|
122
|
+
targets = resolved.targets ?? targets;
|
|
117
123
|
return fetchJson(request, resolved.id, signal);
|
|
118
124
|
};
|
|
119
125
|
if (typeof input === "string") {
|
|
@@ -139,9 +145,12 @@ async function loadContent(input, options = {}) {
|
|
|
139
145
|
(_a = signal == null ? void 0 : signal.throwIfAborted) == null ? void 0 : _a.call(signal);
|
|
140
146
|
switch (resource.type) {
|
|
141
147
|
case "Manifest":
|
|
142
|
-
return { manifest: resource, target, annotation };
|
|
148
|
+
return { manifest: resource, target, annotation, targets };
|
|
143
149
|
case "Collection": {
|
|
144
|
-
const collection = await withMembers(
|
|
150
|
+
const collection = await withMembers(
|
|
151
|
+
resource,
|
|
152
|
+
options
|
|
153
|
+
);
|
|
145
154
|
const pick = options.manifestId ?? member;
|
|
146
155
|
const chosen = pick ? (collection.items ?? []).find(
|
|
147
156
|
(item) => item.id === pick && item.type === "Manifest"
|
|
@@ -150,7 +159,7 @@ async function loadContent(input, options = {}) {
|
|
|
150
159
|
if (!manifest) {
|
|
151
160
|
throw new CloverContentError("The Collection holds no Manifest");
|
|
152
161
|
}
|
|
153
|
-
return { manifest, collection, target, annotation };
|
|
162
|
+
return { manifest, collection, target, annotation, targets };
|
|
154
163
|
}
|
|
155
164
|
case "Canvas":
|
|
156
165
|
case "Timeline":
|
package/dist/core/pages.mjs
CHANGED
|
@@ -28,6 +28,25 @@ async function upgradePage(json, canvasId = "urn:clover:annotation-page") {
|
|
|
28
28
|
});
|
|
29
29
|
return ((_a = canvas.items) == null ? void 0 : _a[0]) ?? page;
|
|
30
30
|
}
|
|
31
|
+
function withReference(page, reference) {
|
|
32
|
+
const own = page;
|
|
33
|
+
const given = reference;
|
|
34
|
+
const listed = (value) => Array.isArray(value) ? value : value ? [value] : [];
|
|
35
|
+
const parts = listed(own.partOf);
|
|
36
|
+
const told = listed(given.partOf);
|
|
37
|
+
const partOf = [
|
|
38
|
+
...parts.map((part) => ({
|
|
39
|
+
...told.find((each) => each.id && each.id === part.id),
|
|
40
|
+
...part
|
|
41
|
+
})),
|
|
42
|
+
...told.filter((each) => !parts.some((part) => part.id === each.id))
|
|
43
|
+
];
|
|
44
|
+
return {
|
|
45
|
+
...page,
|
|
46
|
+
...own.label === void 0 && given.label !== void 0 && { label: given.label },
|
|
47
|
+
...partOf.length && { partOf }
|
|
48
|
+
};
|
|
49
|
+
}
|
|
31
50
|
function embedPage(manifest, canvasId, list, page) {
|
|
32
51
|
let changed = false;
|
|
33
52
|
const items = (manifest.items ?? []).map(
|
|
@@ -36,7 +55,7 @@ function embedPage(manifest, canvasId, list, page) {
|
|
|
36
55
|
const pages = canvas[list].map((existing) => {
|
|
37
56
|
if (existing.id !== page.id || !isReference(existing)) return existing;
|
|
38
57
|
changed = true;
|
|
39
|
-
return page;
|
|
58
|
+
return withReference(page, existing);
|
|
40
59
|
});
|
|
41
60
|
return changed ? { ...canvas, [list]: pages } : canvas;
|
|
42
61
|
}
|
|
@@ -9,16 +9,18 @@ function isPresentation4(resource) {
|
|
|
9
9
|
}
|
|
10
10
|
let upgrader = null;
|
|
11
11
|
function preloadUpgrader() {
|
|
12
|
-
upgrader ?? (upgrader = import("@iiif/parser/presentation-4/upgrader")
|
|
12
|
+
upgrader ?? (upgrader = import("@iiif/parser/presentation-4/upgrader").then(
|
|
13
|
+
({ upgradePresentation3To4 }) => upgradePresentation3To4
|
|
14
|
+
));
|
|
13
15
|
return upgrader;
|
|
14
16
|
}
|
|
15
17
|
async function toPresentation4(resource) {
|
|
16
18
|
if (isPresentation4(resource)) return resource;
|
|
17
|
-
const [
|
|
19
|
+
const [toFour, { upgrade }] = await Promise.all([
|
|
18
20
|
preloadUpgrader(),
|
|
19
|
-
import("./
|
|
21
|
+
import("./upgrade.mjs")
|
|
20
22
|
]);
|
|
21
|
-
return
|
|
23
|
+
return await upgrade(resource, toFour);
|
|
22
24
|
}
|
|
23
25
|
export {
|
|
24
26
|
isPresentation4,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CONTENTS_SET_ID, regionEntryId } from "./annotation-sets.mjs";
|
|
3
|
+
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
4
|
+
import { rangeItemTarget } from "./ranges.mjs";
|
|
5
|
+
import { asArray } from "../lib/asArray.mjs";
|
|
6
|
+
const bodiesOf = (label) => label && typeof label === "object" ? Object.entries(label).flatMap(
|
|
7
|
+
([language, values]) => asArray(values).filter((value) => typeof value === "string").map((value) => ({
|
|
8
|
+
value,
|
|
9
|
+
...language !== "none" ? { language } : {}
|
|
10
|
+
}))
|
|
11
|
+
) : typeof label === "string" ? [{ value: label }] : [];
|
|
12
|
+
const regionSets = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function contentsSet(manifest) {
|
|
14
|
+
if (!manifest) return null;
|
|
15
|
+
if (regionSets.has(manifest)) return regionSets.get(manifest);
|
|
16
|
+
const entries = [];
|
|
17
|
+
const visited = /* @__PURE__ */ new Set();
|
|
18
|
+
const walk = (range) => {
|
|
19
|
+
if (!range || visited.has(range.id ?? range)) return;
|
|
20
|
+
visited.add(range.id ?? range);
|
|
21
|
+
const drawn = typeof range.id === "string" && !asArray(range.behavior).includes("no-nav");
|
|
22
|
+
const bodies = bodiesOf(range.label);
|
|
23
|
+
const total = asArray(range.items).filter(
|
|
24
|
+
(item) => (item == null ? void 0 : item.type) !== "Range" && parseAnnotationTarget(rangeItemTarget(item)).id
|
|
25
|
+
).length;
|
|
26
|
+
let index = 0;
|
|
27
|
+
for (const item of asArray(range.items)) {
|
|
28
|
+
if ((item == null ? void 0 : item.type) === "Range") {
|
|
29
|
+
walk(item);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const parsed = parseAnnotationTarget(rangeItemTarget(item));
|
|
33
|
+
if (!parsed.id) continue;
|
|
34
|
+
const at = index++;
|
|
35
|
+
if (!drawn || !parsed.rect) continue;
|
|
36
|
+
const { x, y, w, h } = parsed.rect;
|
|
37
|
+
const id = regionEntryId(range.id, at);
|
|
38
|
+
entries.push({
|
|
39
|
+
id,
|
|
40
|
+
setId: CONTENTS_SET_ID,
|
|
41
|
+
canvasId: parsed.id,
|
|
42
|
+
target: { id: parsed.id, rect: parsed.rect },
|
|
43
|
+
motivation: ["highlighting"],
|
|
44
|
+
bodies,
|
|
45
|
+
...total > 1 ? { place: { index: at + 1, total } } : {},
|
|
46
|
+
annotation: {
|
|
47
|
+
id,
|
|
48
|
+
type: "Annotation",
|
|
49
|
+
motivation: ["highlighting"],
|
|
50
|
+
// Its text in each language its Range names it in, as the hotspot reads one.
|
|
51
|
+
...bodies.length && {
|
|
52
|
+
body: bodies.map(({ value, language }) => ({
|
|
53
|
+
type: "TextualBody",
|
|
54
|
+
value,
|
|
55
|
+
...language ? { language } : {}
|
|
56
|
+
}))
|
|
57
|
+
},
|
|
58
|
+
target: `${parsed.id}#xywh=${x},${y},${w},${h}`
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
asArray(manifest.structures).forEach(walk);
|
|
64
|
+
const set = entries.length ? { id: CONTENTS_SET_ID, source: "contents", entries } : null;
|
|
65
|
+
regionSets.set(manifest, set);
|
|
66
|
+
return set;
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
contentsSet
|
|
70
|
+
};
|
package/dist/core/ranges.mjs
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { parseAnnotationTarget } from "./annotations.mjs";
|
|
3
3
|
import { asArray } from "../lib/asArray.mjs";
|
|
4
|
-
|
|
5
|
-
if (!t) return void 0;
|
|
6
|
-
const [rawStart, rawEnd] = t.split(",");
|
|
7
|
-
const start = Number(rawStart);
|
|
8
|
-
if (rawStart === "" || Number.isNaN(start)) return void 0;
|
|
9
|
-
if (rawEnd === void 0 || rawEnd === "") return { start };
|
|
10
|
-
const end = Number(rawEnd);
|
|
11
|
-
return Number.isNaN(end) ? { start } : { start, end };
|
|
12
|
-
}
|
|
4
|
+
import { parseTime } from "../lib/time.mjs";
|
|
13
5
|
function rangeItemTarget(item) {
|
|
14
6
|
if (typeof item === "string") return restoreFragment(item);
|
|
15
7
|
const json = item;
|
|
@@ -17,6 +9,10 @@ function rangeItemTarget(item) {
|
|
|
17
9
|
return typeof (json == null ? void 0 : json.id) === "string" ? restoreFragment(json.id) : json;
|
|
18
10
|
}
|
|
19
11
|
const restoreFragment = (id) => id.replace(/\/((?:t|xywh)=[^/#]*)$/, "#$1");
|
|
12
|
+
function rangeThumbnail(range) {
|
|
13
|
+
const first = asArray(range.thumbnail)[0];
|
|
14
|
+
return first && typeof first === "object" ? { thumbnail: first } : {};
|
|
15
|
+
}
|
|
20
16
|
const memo = /* @__PURE__ */ new WeakMap();
|
|
21
17
|
const NONE = [];
|
|
22
18
|
function chaptersOf(manifest, canvasId, duration) {
|
|
@@ -31,11 +27,13 @@ function chaptersOf(manifest, canvasId, duration) {
|
|
|
31
27
|
const walk = (range) => {
|
|
32
28
|
if (!range || visited.has(range.id ?? range)) return;
|
|
33
29
|
visited.add(range.id ?? range);
|
|
30
|
+
const listed = !asArray(range.behavior).includes("no-nav");
|
|
34
31
|
for (const item of asArray(range.items)) {
|
|
35
32
|
if ((item == null ? void 0 : item.type) === "Range") {
|
|
36
33
|
walk(item);
|
|
37
34
|
continue;
|
|
38
35
|
}
|
|
36
|
+
if (!listed) continue;
|
|
39
37
|
const parsed = parseAnnotationTarget(rangeItemTarget(item));
|
|
40
38
|
if (parsed.id.split("#")[0] !== canvasId) continue;
|
|
41
39
|
const time = parseTime(parsed.t);
|
|
@@ -43,7 +41,8 @@ function chaptersOf(manifest, canvasId, duration) {
|
|
|
43
41
|
found.push({
|
|
44
42
|
...range.id ? { id: range.id } : {},
|
|
45
43
|
label: range.label,
|
|
46
|
-
...time
|
|
44
|
+
...time,
|
|
45
|
+
...rangeThumbnail(range)
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
};
|
|
@@ -67,6 +66,12 @@ function tableOfContents(manifest) {
|
|
|
67
66
|
if (!manifest) return NO_TOC;
|
|
68
67
|
const cached = tocs.get(manifest);
|
|
69
68
|
if (cached) return cached;
|
|
69
|
+
const order = new Map(
|
|
70
|
+
asArray(manifest.items).map((canvas, index) => [
|
|
71
|
+
canvas == null ? void 0 : canvas.id,
|
|
72
|
+
index
|
|
73
|
+
])
|
|
74
|
+
);
|
|
70
75
|
const visited = /* @__PURE__ */ new Set();
|
|
71
76
|
const build = (range) => {
|
|
72
77
|
var _a, _b;
|
|
@@ -74,6 +79,7 @@ function tableOfContents(manifest) {
|
|
|
74
79
|
visited.add(range.id ?? range);
|
|
75
80
|
const children = [];
|
|
76
81
|
const canvasIds = [];
|
|
82
|
+
const parts = [];
|
|
77
83
|
let first;
|
|
78
84
|
for (const item of asArray(range.items)) {
|
|
79
85
|
if ((item == null ? void 0 : item.type) === "Range") {
|
|
@@ -85,6 +91,7 @@ function tableOfContents(manifest) {
|
|
|
85
91
|
if (!parsed.id) continue;
|
|
86
92
|
first ?? (first = parsed);
|
|
87
93
|
canvasIds.push(parsed.id);
|
|
94
|
+
parts.push(parsed);
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
const behavior = asArray(range.behavior);
|
|
@@ -95,12 +102,20 @@ function tableOfContents(manifest) {
|
|
|
95
102
|
label: range.label,
|
|
96
103
|
canvasId: (start == null ? void 0 : start.id) ?? ((_a = children[0]) == null ? void 0 : _a.canvasId),
|
|
97
104
|
canvasIds: [...new Set(canvasIds)],
|
|
105
|
+
...behavior.includes("sequence") ? { sequence: true } : {},
|
|
106
|
+
...rangeThumbnail(range),
|
|
98
107
|
children
|
|
99
108
|
};
|
|
100
109
|
const time = parseTime(start == null ? void 0 : start.t);
|
|
101
110
|
if (time) node.time = time;
|
|
102
111
|
else if (!start && ((_b = children[0]) == null ? void 0 : _b.time)) node.time = children[0].time;
|
|
103
112
|
if (start == null ? void 0 : start.rect) node.region = start.rect;
|
|
113
|
+
const ordered = behavior.includes("sequence") && parts.length > 1 && !parts.some((part) => part.t);
|
|
114
|
+
if (ordered || worthStepping(parts, order))
|
|
115
|
+
node.parts = parts.map((part) => ({
|
|
116
|
+
canvasId: part.id,
|
|
117
|
+
...part.rect ? { region: part.rect } : {}
|
|
118
|
+
}));
|
|
104
119
|
return [node];
|
|
105
120
|
};
|
|
106
121
|
const roots = asArray(manifest.structures).flatMap(
|
|
@@ -111,18 +126,37 @@ function tableOfContents(manifest) {
|
|
|
111
126
|
tocs.set(manifest, result);
|
|
112
127
|
return result;
|
|
113
128
|
}
|
|
114
|
-
function
|
|
129
|
+
function worthStepping(parts, order) {
|
|
130
|
+
if (!parts.length || parts.some((part) => part.t)) return false;
|
|
131
|
+
if (parts.some((part) => part.rect)) return true;
|
|
132
|
+
return parts.some(
|
|
133
|
+
(part, index) => index > 0 && order.get(part.id) !== (order.get(parts[index - 1].id) ?? NaN) + 1
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
function currentContents(nodes, canvasId, time, chosen) {
|
|
115
137
|
let best = null;
|
|
116
|
-
|
|
138
|
+
let inChosen = null;
|
|
139
|
+
const deeper = (than, node, depth) => !than || depth > than.depth || // The later of two alike; of two sequences, the first, the default.
|
|
140
|
+
depth === than.depth && !(than.sequence && node.sequence);
|
|
141
|
+
const walk = (node, depth, within) => {
|
|
142
|
+
const under = within || node.id === chosen;
|
|
117
143
|
if (canvasId && node.canvasIds.includes(canvasId)) {
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
|
|
144
|
+
const covers = !node.time || time !== void 0 && time >= node.time.start && (node.time.end === void 0 || time < node.time.end);
|
|
145
|
+
if (covers) {
|
|
146
|
+
const found = {
|
|
147
|
+
id: node.id,
|
|
148
|
+
depth,
|
|
149
|
+
...node.sequence ? { sequence: true } : {}
|
|
150
|
+
};
|
|
151
|
+
if (deeper(best, node, depth)) best = found;
|
|
152
|
+
if (under && deeper(inChosen, node, depth)) inChosen = found;
|
|
153
|
+
}
|
|
121
154
|
}
|
|
122
|
-
node.children.forEach((child) => walk(child, depth + 1));
|
|
155
|
+
node.children.forEach((child) => walk(child, depth + 1, under));
|
|
123
156
|
};
|
|
124
|
-
nodes.forEach((node) => walk(node, 0));
|
|
125
|
-
|
|
157
|
+
nodes.forEach((node) => walk(node, 0, false));
|
|
158
|
+
const result = inChosen ?? best;
|
|
159
|
+
return result ? result.id : null;
|
|
126
160
|
}
|
|
127
161
|
export {
|
|
128
162
|
chaptersOf,
|
package/dist/core/region.mjs
CHANGED
|
@@ -3,11 +3,16 @@ import { parseAnnotationTarget } from "./annotations.mjs";
|
|
|
3
3
|
import { findImageServiceId } from "../lib/renderer/sources/imageService.mjs";
|
|
4
4
|
import { isPainting } from "./painting.mjs";
|
|
5
5
|
import { asArray } from "../lib/asArray.mjs";
|
|
6
|
-
function regionSource(canvas, rect) {
|
|
6
|
+
function regionSource(canvas, rect, image) {
|
|
7
7
|
for (const page of asArray(canvas == null ? void 0 : canvas.items)) {
|
|
8
8
|
for (const annotation of asArray(page == null ? void 0 : page.items)) {
|
|
9
9
|
if (!isPainting(annotation)) continue;
|
|
10
|
-
|
|
10
|
+
const bodies = asArray(annotation == null ? void 0 : annotation.body).flatMap(
|
|
11
|
+
(body) => (body == null ? void 0 : body.type) === "Choice" ? asArray(body.items).filter(
|
|
12
|
+
(item, index) => image ? (item == null ? void 0 : item.id) === image : index === 0
|
|
13
|
+
) : image && (body == null ? void 0 : body.id) !== image ? [] : [body]
|
|
14
|
+
);
|
|
15
|
+
for (const body of bodies) {
|
|
11
16
|
if ((body == null ? void 0 : body.type) !== "Image" || !body.width || !body.height) continue;
|
|
12
17
|
const service = findImageServiceId(body.service);
|
|
13
18
|
if (!service) continue;
|
package/dist/core/sanitize.mjs
CHANGED
|
@@ -43,12 +43,97 @@ const MARKDOWN_VALUES = {
|
|
|
43
43
|
id: [["P", GROUP_ID]],
|
|
44
44
|
"aria-labelledby": [["DIV", GROUP_ID]]
|
|
45
45
|
};
|
|
46
|
+
const BLOCKS = /* @__PURE__ */ new Set([
|
|
47
|
+
"address",
|
|
48
|
+
"article",
|
|
49
|
+
"aside",
|
|
50
|
+
"blockquote",
|
|
51
|
+
"dd",
|
|
52
|
+
"details",
|
|
53
|
+
"div",
|
|
54
|
+
"dl",
|
|
55
|
+
"dt",
|
|
56
|
+
"fieldset",
|
|
57
|
+
"figcaption",
|
|
58
|
+
"figure",
|
|
59
|
+
"footer",
|
|
60
|
+
"form",
|
|
61
|
+
"h1",
|
|
62
|
+
"h2",
|
|
63
|
+
"h3",
|
|
64
|
+
"h4",
|
|
65
|
+
"h5",
|
|
66
|
+
"h6",
|
|
67
|
+
"header",
|
|
68
|
+
"hr",
|
|
69
|
+
"li",
|
|
70
|
+
"main",
|
|
71
|
+
"nav",
|
|
72
|
+
"ol",
|
|
73
|
+
"p",
|
|
74
|
+
"pre",
|
|
75
|
+
"section",
|
|
76
|
+
"summary",
|
|
77
|
+
"table",
|
|
78
|
+
"tbody",
|
|
79
|
+
"td",
|
|
80
|
+
"tfoot",
|
|
81
|
+
"th",
|
|
82
|
+
"thead",
|
|
83
|
+
"tr",
|
|
84
|
+
"ul"
|
|
85
|
+
]);
|
|
86
|
+
function tidy(html) {
|
|
87
|
+
var _a;
|
|
88
|
+
if (!html) return html;
|
|
89
|
+
const box = document.createElement("template");
|
|
90
|
+
box.innerHTML = html;
|
|
91
|
+
for (const image of box.content.querySelectorAll("img:not([src])"))
|
|
92
|
+
image.remove();
|
|
93
|
+
for (const paragraph of box.content.querySelectorAll("p"))
|
|
94
|
+
if (!((_a = paragraph.textContent) == null ? void 0 : _a.trim()) && !paragraph.querySelector("img, br"))
|
|
95
|
+
paragraph.remove();
|
|
96
|
+
const walker = document.createTreeWalker(box.content, NodeFilter.SHOW_TEXT);
|
|
97
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode())
|
|
98
|
+
node.nodeValue = node.nodeValue.replace(/[ \t\n\r\f]{2,}/g, " ");
|
|
99
|
+
return box.innerHTML.replace(/^[ \t\n\r\f]+|[ \t\n\r\f]+$/g, "");
|
|
100
|
+
}
|
|
46
101
|
let purify = null;
|
|
102
|
+
const titles = /* @__PURE__ */ new WeakMap();
|
|
103
|
+
function nameOfLink(image) {
|
|
104
|
+
var _a;
|
|
105
|
+
const link = image.closest("a");
|
|
106
|
+
if (!(link == null ? void 0 : link.getAttribute("href"))) return void 0;
|
|
107
|
+
const named = ((_a = link.textContent) == null ? void 0 : _a.trim()) || [...link.querySelectorAll("img")].some(
|
|
108
|
+
(other) => other.getAttribute("alt")
|
|
109
|
+
);
|
|
110
|
+
if (named) return void 0;
|
|
111
|
+
const title = titles.get(link);
|
|
112
|
+
if (title) return title;
|
|
113
|
+
try {
|
|
114
|
+
const url = new URL(link.getAttribute("href"));
|
|
115
|
+
return (url.protocol === "mailto:" ? url.pathname : url.host) || void 0;
|
|
116
|
+
} catch {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
47
120
|
function purifier() {
|
|
48
121
|
if (purify) return purify;
|
|
49
122
|
purify = DOMPurify(window);
|
|
123
|
+
purify.addHook("uponSanitizeAttribute", (node, data) => {
|
|
124
|
+
if (node.nodeName === "A" && data.attrName === "title" && data.attrValue.trim())
|
|
125
|
+
titles.set(node, data.attrValue.trim());
|
|
126
|
+
});
|
|
127
|
+
purify.addHook("uponSanitizeElement", (node, data) => {
|
|
128
|
+
if (data.allowedTags[data.tagName] || !BLOCKS.has(data.tagName)) return;
|
|
129
|
+
if (node.nodeType !== 1) return;
|
|
130
|
+
node.prepend(" ");
|
|
131
|
+
node.append(" ");
|
|
132
|
+
});
|
|
50
133
|
purify.addHook("afterSanitizeAttributes", (node) => {
|
|
51
134
|
var _a, _b;
|
|
135
|
+
if (node.nodeName === "IMG" && !node.hasAttribute("alt"))
|
|
136
|
+
node.setAttribute("alt", nameOfLink(node) ?? "");
|
|
52
137
|
for (const name of ["src", "href"]) {
|
|
53
138
|
const value = (_a = node.getAttribute) == null ? void 0 : _a.call(node, name);
|
|
54
139
|
if (value && !URI.test(value.trim())) node.removeAttribute(name);
|
|
@@ -65,7 +150,7 @@ function purifier() {
|
|
|
65
150
|
}
|
|
66
151
|
function sanitizeHTML(html, { markdown = false } = {}) {
|
|
67
152
|
if (typeof window === "undefined") return html;
|
|
68
|
-
return purifier().sanitize(html, markdown ? MARKDOWN_CONFIG : CONFIG);
|
|
153
|
+
return tidy(purifier().sanitize(html, markdown ? MARKDOWN_CONFIG : CONFIG));
|
|
69
154
|
}
|
|
70
155
|
export {
|
|
71
156
|
sanitizeHTML
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cloverFetch } from "./request.mjs";
|
|
3
|
+
function fileName(url) {
|
|
4
|
+
try {
|
|
5
|
+
const last = new URL(url).pathname.split("/").filter(Boolean).pop();
|
|
6
|
+
return last ? decodeURIComponent(last) : "download";
|
|
7
|
+
} catch {
|
|
8
|
+
return "download";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function saveFile(url, request) {
|
|
12
|
+
try {
|
|
13
|
+
const response = await cloverFetch(request, url, {
|
|
14
|
+
referrerPolicy: "no-referrer"
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) return false;
|
|
17
|
+
const href = URL.createObjectURL(await response.blob());
|
|
18
|
+
const link = document.createElement("a");
|
|
19
|
+
link.href = href;
|
|
20
|
+
link.download = fileName(url);
|
|
21
|
+
document.body.append(link);
|
|
22
|
+
link.click();
|
|
23
|
+
link.remove();
|
|
24
|
+
setTimeout(() => URL.revokeObjectURL(href), 1e4);
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
fileName,
|
|
32
|
+
saveFile
|
|
33
|
+
};
|