@streamscloud/embeddable 1.1.2
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 +1 -0
- package/dist/advertising/ad-view/cmp.ad-view.svelte +82 -0
- package/dist/advertising/ad-view/cmp.ad-view.svelte.d.ts +8 -0
- package/dist/advertising/ad-view/index.d.ts +2 -0
- package/dist/advertising/ad-view/index.js +1 -0
- package/dist/advertising/ad-view/mapper.d.ts +3 -0
- package/dist/advertising/ad-view/mapper.js +16 -0
- package/dist/advertising/ad-view/operations.generated.d.ts +17 -0
- package/dist/advertising/ad-view/operations.generated.js +46 -0
- package/dist/advertising/ad-view/operations.graphql +14 -0
- package/dist/advertising/ad-view/types.d.ts +10 -0
- package/dist/advertising/ad-view/types.js +1 -0
- package/dist/advertising/index.d.ts +1 -0
- package/dist/advertising/index.js +1 -0
- package/dist/advertising/types.d.ts +5 -0
- package/dist/advertising/types.js +6 -0
- package/dist/core/continuation-token.d.ts +10 -0
- package/dist/core/continuation-token.js +32 -0
- package/dist/core/cursor-result.d.ts +9 -0
- package/dist/core/cursor-result.js +1 -0
- package/dist/core/data-loaders/cursor-data-loader.svelte.d.ts +14 -0
- package/dist/core/data-loaders/cursor-data-loader.svelte.js +35 -0
- package/dist/core/data-loaders/data-loader.d.ts +4 -0
- package/dist/core/data-loaders/data-loader.js +1 -0
- package/dist/core/data-loaders/index.d.ts +2 -0
- package/dist/core/data-loaders/index.js +1 -0
- package/dist/core/deferred.d.ts +6 -0
- package/dist/core/deferred.js +13 -0
- package/dist/core/graphql.d.ts +1 -0
- package/dist/core/graphql.js +10 -0
- package/dist/core/media/image-helper.d.ts +10 -0
- package/dist/core/media/image-helper.js +30 -0
- package/dist/core/media/images-size-detector.service.d.ts +6 -0
- package/dist/core/media/images-size-detector.service.js +15 -0
- package/dist/core/media/index.d.ts +4 -0
- package/dist/core/media/index.js +4 -0
- package/dist/core/media/media-item-url.service.d.ts +2 -0
- package/dist/core/media/media-item-url.service.js +2 -0
- package/dist/core/media/types.d.ts +28 -0
- package/dist/core/media/types.js +19 -0
- package/dist/core/toastr.d.ts +1 -0
- package/dist/core/toastr.js +26 -0
- package/dist/core/transitions/index.d.ts +1 -0
- package/dist/core/transitions/index.js +1 -0
- package/dist/core/transitions/slide-horizontally.d.ts +7 -0
- package/dist/core/transitions/slide-horizontally.js +55 -0
- package/dist/core/utils/array-helper.d.ts +23 -0
- package/dist/core/utils/array-helper.js +148 -0
- package/dist/core/utils/date-helper.d.ts +29 -0
- package/dist/core/utils/date-helper.js +146 -0
- package/dist/core/utils/dom-helper.d.ts +12 -0
- package/dist/core/utils/dom-helper.js +76 -0
- package/dist/core/utils/html-helper.d.ts +40 -0
- package/dist/core/utils/html-helper.js +97 -0
- package/dist/core/utils/index.d.ts +3 -0
- package/dist/core/utils/index.js +3 -0
- package/dist/core/utils/number-helper.d.ts +6 -0
- package/dist/core/utils/number-helper.js +28 -0
- package/dist/core/utils/string-generator.d.ts +2 -0
- package/dist/core/utils/string-generator.js +15 -0
- package/dist/core/utils/string-helper.d.ts +10 -0
- package/dist/core/utils/string-helper.js +53 -0
- package/dist/core/utils/url-helper.d.ts +3 -0
- package/dist/core/utils/url-helper.js +13 -0
- package/dist/core/utils/utils.d.ts +28 -0
- package/dist/core/utils/utils.js +100 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/products/index.d.ts +1 -0
- package/dist/products/index.js +1 -0
- package/dist/products/price-helper.d.ts +4 -0
- package/dist/products/price-helper.js +36 -0
- package/dist/products/product-card/cmp.product-card.svelte +121 -0
- package/dist/products/product-card/cmp.product-card.svelte.d.ts +10 -0
- package/dist/products/product-card/index.d.ts +3 -0
- package/dist/products/product-card/index.js +3 -0
- package/dist/products/product-card/mapper.d.ts +3 -0
- package/dist/products/product-card/mapper.js +14 -0
- package/dist/products/product-card/operations.generated.d.ts +22 -0
- package/dist/products/product-card/operations.generated.js +65 -0
- package/dist/products/product-card/operations.graphql +19 -0
- package/dist/products/product-card/product-card-localization.svelte.d.ts +7 -0
- package/dist/products/product-card/product-card-localization.svelte.js +11 -0
- package/dist/products/product-card/types.d.ts +10 -0
- package/dist/products/product-card/types.js +1 -0
- package/dist/products/types.d.ts +5 -0
- package/dist/products/types.js +6 -0
- package/dist/short-videos/short-video-viewer/cmp.attachments.svelte +71 -0
- package/dist/short-videos/short-video-viewer/cmp.attachments.svelte.d.ts +7 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte +145 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte.d.ts +10 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-heading.svelte +86 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-heading.svelte.d.ts +9 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte +133 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte.d.ts +12 -0
- package/dist/short-videos/short-video-viewer/description.svelte +46 -0
- package/dist/short-videos/short-video-viewer/description.svelte.d.ts +9 -0
- package/dist/short-videos/short-video-viewer/index.d.ts +6 -0
- package/dist/short-videos/short-video-viewer/index.js +4 -0
- package/dist/short-videos/short-video-viewer/mapper.d.ts +3 -0
- package/dist/short-videos/short-video-viewer/mapper.js +28 -0
- package/dist/short-videos/short-video-viewer/operations.generated.d.ts +56 -0
- package/dist/short-videos/short-video-viewer/operations.generated.js +187 -0
- package/dist/short-videos/short-video-viewer/operations.graphql +26 -0
- package/dist/short-videos/short-video-viewer/short-video-details-localization.svelte.d.ts +14 -0
- package/dist/short-videos/short-video-viewer/short-video-details-localization.svelte.js +21 -0
- package/dist/short-videos/short-video-viewer/short-video-viewer-localization.svelte.d.ts +10 -0
- package/dist/short-videos/short-video-viewer/short-video-viewer-localization.svelte.js +13 -0
- package/dist/short-videos/short-video-viewer/types.d.ts +17 -0
- package/dist/short-videos/short-video-viewer/types.js +1 -0
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.d.ts +12 -0
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.js +26 -0
- package/dist/short-videos/short-videos-player/action-button.svelte +38 -0
- package/dist/short-videos/short-videos-player/action-button.svelte.d.ts +10 -0
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte +91 -0
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +13 -0
- package/dist/short-videos/short-videos-player/controls.svelte +215 -0
- package/dist/short-videos/short-videos-player/controls.svelte.d.ts +15 -0
- package/dist/short-videos/short-videos-player/index.d.ts +2 -0
- package/dist/short-videos/short-videos-player/index.js +1 -0
- package/dist/short-videos/short-videos-player/short-videos-player-localization.svelte.d.ts +14 -0
- package/dist/short-videos/short-videos-player/short-videos-player-localization.svelte.js +21 -0
- package/dist/short-videos/short-videos-player/ui-manager.svelte.d.ts +16 -0
- package/dist/short-videos/short-videos-player/ui-manager.svelte.js +25 -0
- package/dist/short-videos/short-videos-player-modal/cmp.short-videos-player-modal.svelte +485 -0
- package/dist/short-videos/short-videos-player-modal/cmp.short-videos-player-modal.svelte.d.ts +3 -0
- package/dist/short-videos/short-videos-player-modal/index.d.ts +79 -0
- package/dist/short-videos/short-videos-player-modal/index.js +78 -0
- package/dist/short-videos/short-videos-player-modal/short-videos-player-modal-state.svelte.d.ts +16 -0
- package/dist/short-videos/short-videos-player-modal/short-videos-player-modal-state.svelte.js +13 -0
- package/dist/streams/components/cmp.stream-page-component.svelte +16 -0
- package/dist/streams/components/cmp.stream-page-component.svelte.d.ts +10 -0
- package/dist/streams/components/components.factory.d.ts +22 -0
- package/dist/streams/components/components.factory.js +34 -0
- package/dist/streams/components/images/cmp.images-component.svelte +7 -0
- package/dist/streams/components/images/cmp.images-component.svelte.d.ts +7 -0
- package/dist/streams/components/images/index.d.ts +2 -0
- package/dist/streams/components/images/index.js +1 -0
- package/dist/streams/components/images/types.d.ts +8 -0
- package/dist/streams/components/images/types.js +5 -0
- package/dist/streams/components/index.d.ts +7 -0
- package/dist/streams/components/index.js +6 -0
- package/dist/streams/components/mapper.d.ts +3 -0
- package/dist/streams/components/mapper.js +43 -0
- package/dist/streams/components/operations.generated.d.ts +178 -0
- package/dist/streams/components/operations.generated.js +653 -0
- package/dist/streams/components/operations.graphql +35 -0
- package/dist/streams/components/product/cmp.product-component.svelte +148 -0
- package/dist/streams/components/product/cmp.product-component.svelte.d.ts +8 -0
- package/dist/streams/components/product/index.d.ts +3 -0
- package/dist/streams/components/product/index.js +2 -0
- package/dist/streams/components/product/mapper.d.ts +3 -0
- package/dist/streams/components/product/mapper.js +14 -0
- package/dist/streams/components/product/operations.generated.d.ts +22 -0
- package/dist/streams/components/product/operations.generated.js +53 -0
- package/dist/streams/components/product/operations.graphql +19 -0
- package/dist/streams/components/product/types.d.ts +10 -0
- package/dist/streams/components/product/types.js +1 -0
- package/dist/streams/components/short-video/cmp.short-video-component.svelte +9 -0
- package/dist/streams/components/short-video/cmp.short-video-component.svelte.d.ts +10 -0
- package/dist/streams/components/short-video/index.d.ts +3 -0
- package/dist/streams/components/short-video/index.js +2 -0
- package/dist/streams/components/short-video/mapper.d.ts +3 -0
- package/dist/streams/components/short-video/mapper.js +4 -0
- package/dist/streams/components/short-video/operations.generated.d.ts +56 -0
- package/dist/streams/components/short-video/operations.generated.js +193 -0
- package/dist/streams/components/short-video/operations.graphql +3 -0
- package/dist/streams/components/short-video/types.d.ts +2 -0
- package/dist/streams/components/short-video/types.js +1 -0
- package/dist/streams/components/stream-components-localization.svelte.d.ts +10 -0
- package/dist/streams/components/stream-components-localization.svelte.js +13 -0
- package/dist/streams/components/types.d.ts +27 -0
- package/dist/streams/components/types.js +6 -0
- package/dist/streams/slots/cmp.stream-component-slot.svelte +35 -0
- package/dist/streams/slots/cmp.stream-component-slot.svelte.d.ts +9 -0
- package/dist/streams/slots/index.d.ts +3 -0
- package/dist/streams/slots/index.js +2 -0
- package/dist/streams/slots/mapper.d.ts +3 -0
- package/dist/streams/slots/mapper.js +18 -0
- package/dist/streams/slots/operations.generated.d.ts +17 -0
- package/dist/streams/slots/operations.generated.js +34 -0
- package/dist/streams/slots/operations.graphql +14 -0
- package/dist/streams/slots/styles-transformer.d.ts +6 -0
- package/dist/streams/slots/styles-transformer.js +12 -0
- package/dist/streams/slots/types.d.ts +16 -0
- package/dist/streams/slots/types.js +1 -0
- package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte +47 -0
- package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte.d.ts +9 -0
- package/dist/streams/stream-page-viewer/index.d.ts +2 -0
- package/dist/streams/stream-page-viewer/index.js +1 -0
- package/dist/streams/stream-page-viewer/mapper.d.ts +3 -0
- package/dist/streams/stream-page-viewer/mapper.js +23 -0
- package/dist/streams/stream-page-viewer/operations.generated.d.ts +113 -0
- package/dist/streams/stream-page-viewer/operations.generated.js +400 -0
- package/dist/streams/stream-page-viewer/operations.graphql +13 -0
- package/dist/streams/stream-page-viewer/stream-page-viewer-localization.svelte.d.ts +10 -0
- package/dist/streams/stream-page-viewer/stream-page-viewer-localization.svelte.js +13 -0
- package/dist/streams/stream-page-viewer/types.d.ts +18 -0
- package/dist/streams/stream-page-viewer/types.js +1 -0
- package/dist/streams/stream-player/action-button.svelte +38 -0
- package/dist/streams/stream-player/action-button.svelte.d.ts +10 -0
- package/dist/streams/stream-player/cmp.stream-player.svelte +141 -0
- package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +16 -0
- package/dist/streams/stream-player/controls.svelte +222 -0
- package/dist/streams/stream-player/controls.svelte.d.ts +14 -0
- package/dist/streams/stream-player/index.d.ts +2 -0
- package/dist/streams/stream-player/index.js +1 -0
- package/dist/streams/stream-player/mapper.d.ts +3 -0
- package/dist/streams/stream-player/mapper.js +15 -0
- package/dist/streams/stream-player/operations.generated.d.ts +161 -0
- package/dist/streams/stream-player/operations.generated.js +559 -0
- package/dist/streams/stream-player/operations.graphql +32 -0
- package/dist/streams/stream-player/stream-overview.svelte +239 -0
- package/dist/streams/stream-player/stream-overview.svelte.d.ts +17 -0
- package/dist/streams/stream-player/stream-player-buffer.svelte.d.ts +25 -0
- package/dist/streams/stream-player/stream-player-buffer.svelte.js +84 -0
- package/dist/streams/stream-player/stream-player-localization.svelte.d.ts +18 -0
- package/dist/streams/stream-player/stream-player-localization.svelte.js +29 -0
- package/dist/streams/stream-player/types.d.ts +12 -0
- package/dist/streams/stream-player/types.js +1 -0
- package/dist/streams/stream-player/ui-manager.svelte.d.ts +17 -0
- package/dist/streams/stream-player/ui-manager.svelte.js +26 -0
- package/dist/streams/stream-player-modal/cmp.stream-player-modal.svelte +486 -0
- package/dist/streams/stream-player-modal/cmp.stream-player-modal.svelte.d.ts +3 -0
- package/dist/streams/stream-player-modal/index.d.ts +79 -0
- package/dist/streams/stream-player-modal/index.js +78 -0
- package/dist/streams/stream-player-modal/stream-player-modal-state.svelte.d.ts +17 -0
- package/dist/streams/stream-player-modal/stream-player-modal-state.svelte.js +14 -0
- package/dist/ui/button/cmp.button.svelte +10 -0
- package/dist/ui/button/cmp.button.svelte.d.ts +16 -0
- package/dist/ui/button/index.d.ts +2 -0
- package/dist/ui/button/index.js +2 -0
- package/dist/ui/button/resources/button-base.svelte +84 -0
- package/dist/ui/button/resources/button-base.svelte.d.ts +13 -0
- package/dist/ui/button/resources/button-theme.svelte +204 -0
- package/dist/ui/button/resources/button-theme.svelte.d.ts +10 -0
- package/dist/ui/button/resources/button-types.d.ts +21 -0
- package/dist/ui/button/resources/button-types.js +23 -0
- package/dist/ui/dynamic-component/cmp.dynamic-component.svelte +5 -0
- package/dist/ui/dynamic-component/cmp.dynamic-component.svelte.d.ts +7 -0
- package/dist/ui/dynamic-component/index.d.ts +2 -0
- package/dist/ui/dynamic-component/index.js +2 -0
- package/dist/ui/dynamic-component/types.svelte.d.ts +11 -0
- package/dist/ui/dynamic-component/types.svelte.js +13 -0
- package/dist/ui/icon/cmp.icon.svelte +113 -0
- package/dist/ui/icon/cmp.icon.svelte.d.ts +8 -0
- package/dist/ui/icon/index.d.ts +2 -0
- package/dist/ui/icon/index.js +2 -0
- package/dist/ui/icon/types.d.ts +9 -0
- package/dist/ui/icon/types.js +10 -0
- package/dist/ui/image/cmp.image-round.svelte +41 -0
- package/dist/ui/image/cmp.image-round.svelte.d.ts +11 -0
- package/dist/ui/image/cmp.image-rounded.svelte +71 -0
- package/dist/ui/image/cmp.image-rounded.svelte.d.ts +11 -0
- package/dist/ui/image/cmp.image-stub.svelte +34 -0
- package/dist/ui/image/cmp.image-stub.svelte.d.ts +18 -0
- package/dist/ui/image/cmp.image.svelte +82 -0
- package/dist/ui/image/cmp.image.svelte.d.ts +13 -0
- package/dist/ui/image/image-state.d.ts +6 -0
- package/dist/ui/image/image-state.js +17 -0
- package/dist/ui/image/index.d.ts +4 -0
- package/dist/ui/image/index.js +4 -0
- package/dist/ui/infinite-scrolling/cmp.infinite-scrolling.svelte +84 -0
- package/dist/ui/infinite-scrolling/cmp.infinite-scrolling.svelte.d.ts +11 -0
- package/dist/ui/infinite-scrolling/index.d.ts +1 -0
- package/dist/ui/infinite-scrolling/index.js +1 -0
- package/dist/ui/line-clamp/cmp.line-clamp.svelte +89 -0
- package/dist/ui/line-clamp/cmp.line-clamp.svelte.d.ts +12 -0
- package/dist/ui/line-clamp/index.d.ts +2 -0
- package/dist/ui/line-clamp/index.js +2 -0
- package/dist/ui/line-clamp/line-clamp-localization.svelte.d.ts +9 -0
- package/dist/ui/line-clamp/line-clamp-localization.svelte.js +15 -0
- package/dist/ui/line-clamp/line-clamp-types.d.ts +3 -0
- package/dist/ui/line-clamp/line-clamp-types.js +1 -0
- package/dist/ui/line-clamp/line-clamp-utils.d.ts +8 -0
- package/dist/ui/line-clamp/line-clamp-utils.js +33 -0
- package/dist/ui/loading/cmp.loading.svelte +97 -0
- package/dist/ui/loading/cmp.loading.svelte.d.ts +9 -0
- package/dist/ui/loading/index.d.ts +1 -0
- package/dist/ui/loading/index.js +1 -0
- package/dist/ui/media-item-view/cmp.media-item-view.svelte +90 -0
- package/dist/ui/media-item-view/cmp.media-item-view.svelte.d.ts +12 -0
- package/dist/ui/media-item-view/index.d.ts +1 -0
- package/dist/ui/media-item-view/index.js +1 -0
- package/dist/ui/media-items-gallery/cmp.media-items-gallery.svelte +277 -0
- package/dist/ui/media-items-gallery/cmp.media-items-gallery.svelte.d.ts +12 -0
- package/dist/ui/media-items-gallery/index.d.ts +1 -0
- package/dist/ui/media-items-gallery/index.js +1 -0
- package/dist/ui/media-items-gallery/types.d.ts +12 -0
- package/dist/ui/media-items-gallery/types.js +35 -0
- package/dist/ui/media-playback/index.d.ts +2 -0
- package/dist/ui/media-playback/index.js +2 -0
- package/dist/ui/media-playback/playback-manager.svelte.d.ts +25 -0
- package/dist/ui/media-playback/playback-manager.svelte.js +62 -0
- package/dist/ui/media-playback/volume-manager.svelte.d.ts +10 -0
- package/dist/ui/media-playback/volume-manager.svelte.js +27 -0
- package/dist/ui/player/cmp.player-slider.svelte +161 -0
- package/dist/ui/player/cmp.player-slider.svelte.d.ts +33 -0
- package/dist/ui/player/index.d.ts +4 -0
- package/dist/ui/player/index.js +3 -0
- package/dist/ui/player/player-buffer.svelte.d.ts +28 -0
- package/dist/ui/player/player-buffer.svelte.js +64 -0
- package/dist/ui/player/prevent-slider-scroll.d.ts +5 -0
- package/dist/ui/player/prevent-slider-scroll.js +11 -0
- package/dist/ui/player/types.d.ts +14 -0
- package/dist/ui/player/types.js +1 -0
- package/dist/ui/progress/cmp.progress.svelte +37 -0
- package/dist/ui/progress/cmp.progress.svelte.d.ts +6 -0
- package/dist/ui/progress/index.d.ts +1 -0
- package/dist/ui/progress/index.js +1 -0
- package/dist/ui/proportional-container/cmp.proportional-container.svelte +39 -0
- package/dist/ui/proportional-container/cmp.proportional-container.svelte.d.ts +8 -0
- package/dist/ui/proportional-container/index.d.ts +1 -0
- package/dist/ui/proportional-container/index.js +1 -0
- package/dist/ui/seek-bar/cmp.seek-bar.svelte +63 -0
- package/dist/ui/seek-bar/cmp.seek-bar.svelte.d.ts +12 -0
- package/dist/ui/seek-bar/index.d.ts +1 -0
- package/dist/ui/seek-bar/index.js +1 -0
- package/dist/ui/shadow-dom/cmp.shadow-dom.svelte +26 -0
- package/dist/ui/shadow-dom/cmp.shadow-dom.svelte.d.ts +7 -0
- package/dist/ui/shadow-dom/index.d.ts +1 -0
- package/dist/ui/shadow-dom/index.js +1 -0
- package/dist/ui/spotlight-layout/cmp.spotlight-layout.svelte +120 -0
- package/dist/ui/spotlight-layout/cmp.spotlight-layout.svelte.d.ts +18 -0
- package/dist/ui/spotlight-layout/index.d.ts +1 -0
- package/dist/ui/spotlight-layout/index.js +1 -0
- package/dist/ui/time-ago/cmp.time-ago.svelte +69 -0
- package/dist/ui/time-ago/cmp.time-ago.svelte.d.ts +9 -0
- package/dist/ui/time-ago/index.d.ts +2 -0
- package/dist/ui/time-ago/index.js +1 -0
- package/dist/ui/time-ago/time-ago-localization.svelte.d.ts +21 -0
- package/dist/ui/time-ago/time-ago-localization.svelte.js +39 -0
- package/dist/ui/video/cmp.video.svelte +377 -0
- package/dist/ui/video/cmp.video.svelte.d.ts +24 -0
- package/dist/ui/video/index.d.ts +1 -0
- package/dist/ui/video/index.js +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script lang="ts">let { ratio, children, left = undefined, right = undefined, on } = $props();
|
|
2
|
+
let containerRef = $state.raw(null);
|
|
3
|
+
let mainSceneRef = $state.raw(null);
|
|
4
|
+
let leftSidebarRef = $state.raw(null);
|
|
5
|
+
let rightSidebarRef = $state.raw(null);
|
|
6
|
+
const notifyDimensionChanged = () => {
|
|
7
|
+
var _a;
|
|
8
|
+
if (!containerRef || !mainSceneRef || !leftSidebarRef || !rightSidebarRef) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
(_a = on === null || on === void 0 ? void 0 : on.dimensionsChanged) === null || _a === void 0 ? void 0 : _a.call(on, {
|
|
12
|
+
mainSceneWidth: mainSceneRef.getBoundingClientRect().width,
|
|
13
|
+
leftSidebarWidth: leftSidebarRef.getBoundingClientRect().width,
|
|
14
|
+
rightSidebarWidth: rightSidebarRef.getBoundingClientRect().width,
|
|
15
|
+
totalWidth: containerRef.getBoundingClientRect().width
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
let computedMainSceneStyle = $state('width: 100%; height: 100%');
|
|
19
|
+
const calcMainSceneSize = () => {
|
|
20
|
+
if (!containerRef) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const { width: parentWidth, height: parentHeight } = containerRef.getBoundingClientRect();
|
|
24
|
+
const parentAspectRatio = parentWidth / parentHeight;
|
|
25
|
+
let width;
|
|
26
|
+
let height;
|
|
27
|
+
let margin;
|
|
28
|
+
if (parentAspectRatio > ratio) {
|
|
29
|
+
// container is wider than main content
|
|
30
|
+
width = `${parentHeight * ratio}px`;
|
|
31
|
+
height = '100%';
|
|
32
|
+
margin = '0 auto';
|
|
33
|
+
}
|
|
34
|
+
else if (parentAspectRatio < ratio) {
|
|
35
|
+
// main content is wider than container
|
|
36
|
+
width = '100%';
|
|
37
|
+
height = `${parentWidth / ratio}px`;
|
|
38
|
+
margin = 'auto 0';
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// fallback case
|
|
42
|
+
width = '100%';
|
|
43
|
+
height = '100%';
|
|
44
|
+
margin = '0';
|
|
45
|
+
}
|
|
46
|
+
computedMainSceneStyle = `--_spotlight-layout--main--width: ${width}; --_spotlight-layout--main--height: ${height}; --_spotlight-layout--main--margin: ${margin};`;
|
|
47
|
+
};
|
|
48
|
+
$effect(() => {
|
|
49
|
+
let mainSceneSizeCalculationObserver = new ResizeObserver(calcMainSceneSize);
|
|
50
|
+
let dimentionsChangedObserver = new ResizeObserver(notifyDimensionChanged);
|
|
51
|
+
if (containerRef && mainSceneRef && leftSidebarRef && rightSidebarRef) {
|
|
52
|
+
mainSceneSizeCalculationObserver.observe(mainSceneRef);
|
|
53
|
+
dimentionsChangedObserver.observe(containerRef);
|
|
54
|
+
dimentionsChangedObserver.observe(mainSceneRef);
|
|
55
|
+
dimentionsChangedObserver.observe(leftSidebarRef);
|
|
56
|
+
dimentionsChangedObserver.observe(rightSidebarRef);
|
|
57
|
+
}
|
|
58
|
+
return () => {
|
|
59
|
+
mainSceneSizeCalculationObserver.disconnect();
|
|
60
|
+
dimentionsChangedObserver.disconnect();
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
export {};
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<div class="spotlight-layout" bind:this={containerRef}>
|
|
67
|
+
<div class="spotlight-layout__sidebar" bind:this={leftSidebarRef}>
|
|
68
|
+
{#if left}
|
|
69
|
+
{@render left()}
|
|
70
|
+
{/if}
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div class="spotlight-layout__main-scene" bind:this={mainSceneRef} style={computedMainSceneStyle}>
|
|
74
|
+
{@render children()}
|
|
75
|
+
</div>
|
|
76
|
+
<div class="spotlight-layout__sidebar" bind:this={rightSidebarRef}>
|
|
77
|
+
{#if right}
|
|
78
|
+
{@render right()}
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<style>@keyframes fadeIn {
|
|
84
|
+
0% {
|
|
85
|
+
opacity: 1;
|
|
86
|
+
}
|
|
87
|
+
50% {
|
|
88
|
+
opacity: 0.4;
|
|
89
|
+
}
|
|
90
|
+
100% {
|
|
91
|
+
opacity: 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
.spotlight-layout {
|
|
95
|
+
width: 100%;
|
|
96
|
+
min-width: 100%;
|
|
97
|
+
max-width: 100%;
|
|
98
|
+
height: 100%;
|
|
99
|
+
min-height: 100%;
|
|
100
|
+
max-height: 100%;
|
|
101
|
+
container-type: inline-size;
|
|
102
|
+
display: flex;
|
|
103
|
+
}
|
|
104
|
+
.spotlight-layout__main-scene {
|
|
105
|
+
width: var(--_spotlight-layout--main--width);
|
|
106
|
+
height: var(--_spotlight-layout--main--height);
|
|
107
|
+
margin: var(--_spotlight-layout--main--margin);
|
|
108
|
+
position: relative;
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
/* Set 'container-type: inline-size;' to reference container*/
|
|
113
|
+
}
|
|
114
|
+
@container (width < 576px) {
|
|
115
|
+
.spotlight-layout__main-scene {
|
|
116
|
+
width: 100%;
|
|
117
|
+
height: 100%;
|
|
118
|
+
margin: 0;
|
|
119
|
+
}
|
|
120
|
+
}</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type Props = {
|
|
3
|
+
ratio: number;
|
|
4
|
+
children: Snippet;
|
|
5
|
+
left?: Snippet;
|
|
6
|
+
right?: Snippet;
|
|
7
|
+
on?: {
|
|
8
|
+
dimensionsChanged?: (dimensions: {
|
|
9
|
+
mainSceneWidth: number;
|
|
10
|
+
leftSidebarWidth: number;
|
|
11
|
+
rightSidebarWidth: number;
|
|
12
|
+
totalWidth: number;
|
|
13
|
+
}) => void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
18
|
+
export default Cmp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SpotlightLayout } from './cmp.spotlight-layout.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SpotlightLayout } from './cmp.spotlight-layout.svelte';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts">import { DateFormatOptions, DateHelper } from '../../core/utils/date-helper';
|
|
2
|
+
import { TimeAgoLocalization } from './time-ago-localization.svelte';
|
|
3
|
+
import { onDestroy } from 'svelte';
|
|
4
|
+
let { date = null, thresholdMinutes = 60 * 24 * 2 /* 2 days */, localization: localizationInit } = $props();
|
|
5
|
+
const localization = $derived(new TimeAgoLocalization(localizationInit));
|
|
6
|
+
let timeSpan = $state.raw(null);
|
|
7
|
+
let timeoutId;
|
|
8
|
+
onDestroy(() => {
|
|
9
|
+
disableTimeout();
|
|
10
|
+
});
|
|
11
|
+
const setRelativeTime = (date) => {
|
|
12
|
+
disableTimeout();
|
|
13
|
+
const dateVal = date ? DateHelper.toDate(date) : new Date();
|
|
14
|
+
const setupAbsDate = () => {
|
|
15
|
+
timeSpan = localization.at(dateVal.toLocaleString(localization.locale, dateVal.getFullYear() === new Date().getFullYear() ? DateFormatOptions.dateFormatWithoutYear : DateFormatOptions.dateFormat), dateVal.toLocaleString(localization.locale, DateFormatOptions.timeFormat));
|
|
16
|
+
};
|
|
17
|
+
const diffSeconds = (+new Date() - +dateVal) / 1000;
|
|
18
|
+
if (diffSeconds > thresholdMinutes * 60) {
|
|
19
|
+
return setupAbsDate();
|
|
20
|
+
}
|
|
21
|
+
const secsInHour = 60 * 60; // 3600
|
|
22
|
+
const secsIn2Hours = secsInHour * 2; // 7200
|
|
23
|
+
const secsInDay = 60 * 60 * 24; // 86400
|
|
24
|
+
const secsIn2Days = secsInDay * 2; // 172800
|
|
25
|
+
let refreshIntervalSec;
|
|
26
|
+
if (diffSeconds < 60) {
|
|
27
|
+
timeSpan = localization.justNow;
|
|
28
|
+
refreshIntervalSec = 5;
|
|
29
|
+
}
|
|
30
|
+
else if (diffSeconds < 120) {
|
|
31
|
+
timeSpan = localization.aMinuteAgo;
|
|
32
|
+
refreshIntervalSec = 5;
|
|
33
|
+
}
|
|
34
|
+
else if (diffSeconds < secsInHour) {
|
|
35
|
+
timeSpan = localization.minutesAgo(Math.floor(diffSeconds / 60));
|
|
36
|
+
refreshIntervalSec = 60;
|
|
37
|
+
}
|
|
38
|
+
else if (diffSeconds < secsIn2Hours) {
|
|
39
|
+
timeSpan = localization.anHourAgo;
|
|
40
|
+
refreshIntervalSec = 60;
|
|
41
|
+
}
|
|
42
|
+
else if (diffSeconds < secsInDay) {
|
|
43
|
+
timeSpan = localization.hoursAgo(Math.floor(diffSeconds / secsInHour));
|
|
44
|
+
refreshIntervalSec = 3600;
|
|
45
|
+
}
|
|
46
|
+
else if (diffSeconds < secsIn2Days) {
|
|
47
|
+
timeSpan = localization.yesterday(dateVal.toLocaleString(localization.locale, DateFormatOptions.timeFormat));
|
|
48
|
+
refreshIntervalSec = 3600;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return setupAbsDate();
|
|
52
|
+
}
|
|
53
|
+
timeoutId = setTimeout(() => setRelativeTime(date), refreshIntervalSec * 1000);
|
|
54
|
+
};
|
|
55
|
+
$effect(() => {
|
|
56
|
+
setRelativeTime(date);
|
|
57
|
+
});
|
|
58
|
+
const disableTimeout = () => {
|
|
59
|
+
if (timeoutId) {
|
|
60
|
+
clearTimeout(timeoutId);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<span>
|
|
66
|
+
{#if timeSpan}
|
|
67
|
+
{timeSpan}
|
|
68
|
+
{/if}
|
|
69
|
+
</span>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ITimeAgoLocalization } from './time-ago-localization.svelte';
|
|
2
|
+
type Props = {
|
|
3
|
+
date: Date | string | null;
|
|
4
|
+
thresholdMinutes?: number;
|
|
5
|
+
localization?: ITimeAgoLocalization;
|
|
6
|
+
};
|
|
7
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
9
|
+
export default Cmp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TimeAgo } from './cmp.time-ago.svelte';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ITimeAgoLocalization {
|
|
2
|
+
locale?: string;
|
|
3
|
+
aMinuteAgo?: string;
|
|
4
|
+
anHourAgo?: string;
|
|
5
|
+
justNow?: string;
|
|
6
|
+
at?: (date: string, time: string) => string;
|
|
7
|
+
hoursAgo?: (hours: number) => string;
|
|
8
|
+
minutesAgo?: (minutes: number) => string;
|
|
9
|
+
yesterday?: (time: string) => string;
|
|
10
|
+
}
|
|
11
|
+
export declare class TimeAgoLocalization {
|
|
12
|
+
locale: string;
|
|
13
|
+
aMinuteAgo: string;
|
|
14
|
+
anHourAgo: string;
|
|
15
|
+
justNow: string;
|
|
16
|
+
at: (date: string, time: string) => string;
|
|
17
|
+
hoursAgo: (hours: number) => string;
|
|
18
|
+
minutesAgo: (minutes: number) => string;
|
|
19
|
+
yesterday: (time: string) => string;
|
|
20
|
+
constructor(init?: ITimeAgoLocalization);
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class TimeAgoLocalization {
|
|
2
|
+
locale = $state('en-US');
|
|
3
|
+
aMinuteAgo = $state('a minute ago');
|
|
4
|
+
anHourAgo = $state('an hour ago');
|
|
5
|
+
justNow = $state('just now');
|
|
6
|
+
at = $state((date, time) => `${date} at ${time}`);
|
|
7
|
+
hoursAgo = $state((hours) => `${hours} hours ago`);
|
|
8
|
+
minutesAgo = $state((minutes) => `${minutes} minutes ago`);
|
|
9
|
+
yesterday = $state((time) => `esterday at ${time}`);
|
|
10
|
+
constructor(init) {
|
|
11
|
+
if (!init) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (init.locale !== undefined) {
|
|
15
|
+
this.locale = init.locale;
|
|
16
|
+
}
|
|
17
|
+
if (init.aMinuteAgo !== undefined) {
|
|
18
|
+
this.aMinuteAgo = init.aMinuteAgo;
|
|
19
|
+
}
|
|
20
|
+
if (init.anHourAgo !== undefined) {
|
|
21
|
+
this.anHourAgo = init.anHourAgo;
|
|
22
|
+
}
|
|
23
|
+
if (init.justNow !== undefined) {
|
|
24
|
+
this.justNow = init.justNow;
|
|
25
|
+
}
|
|
26
|
+
if (init.at !== undefined) {
|
|
27
|
+
this.at = init.at;
|
|
28
|
+
}
|
|
29
|
+
if (init.hoursAgo !== undefined) {
|
|
30
|
+
this.hoursAgo = init.hoursAgo;
|
|
31
|
+
}
|
|
32
|
+
if (init.minutesAgo !== undefined) {
|
|
33
|
+
this.minutesAgo = init.minutesAgo;
|
|
34
|
+
}
|
|
35
|
+
if (init.yesterday !== undefined) {
|
|
36
|
+
this.yesterday = init.yesterday;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
<script lang="ts">var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { randomNanoid } from '../../core/utils/string-generator';
|
|
11
|
+
import { MediaVolumeManager, PlaybackManager } from '../media-playback';
|
|
12
|
+
import { Icon, IconColor } from '../icon';
|
|
13
|
+
import { Progress } from '../progress';
|
|
14
|
+
import { SeekBar } from '../seek-bar';
|
|
15
|
+
import IconPause from '@fluentui/svg-icons/icons/pause_20_regular.svg';
|
|
16
|
+
import IconPlay from '@fluentui/svg-icons/icons/play_20_regular.svg';
|
|
17
|
+
import IconSpeaker from '@fluentui/svg-icons/icons/speaker_2_20_regular.svg';
|
|
18
|
+
import IconSpeakerMute from '@fluentui/svg-icons/icons/speaker_mute_20_regular.svg';
|
|
19
|
+
import { onDestroy, onMount, untrack } from 'svelte';
|
|
20
|
+
import { slide } from 'svelte/transition';
|
|
21
|
+
let { src, poster, id = randomNanoid(), controls = true, autoplay = false, loop = false, inert = false, intersectionContainer, on } = $props();
|
|
22
|
+
onMount(() => {
|
|
23
|
+
var _a;
|
|
24
|
+
PlaybackManager.registerMountedPlayer(id, {
|
|
25
|
+
onPlay: () => {
|
|
26
|
+
play();
|
|
27
|
+
},
|
|
28
|
+
onPause: () => {
|
|
29
|
+
pause();
|
|
30
|
+
},
|
|
31
|
+
onStop: (inRespectToNewlyActivatedVideo) => {
|
|
32
|
+
if (inRespectToNewlyActivatedVideo && autoplay === 'on-appearance') {
|
|
33
|
+
pause();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
stop();
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
onToggle: () => {
|
|
40
|
+
togglePlay();
|
|
41
|
+
},
|
|
42
|
+
onVolumeChange: (volume) => {
|
|
43
|
+
setVolume(volume);
|
|
44
|
+
},
|
|
45
|
+
onMute: () => {
|
|
46
|
+
setMuted(true);
|
|
47
|
+
},
|
|
48
|
+
onUnmute: () => {
|
|
49
|
+
setMuted(false);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
(_a = on === null || on === void 0 ? void 0 : on.loaded) === null || _a === void 0 ? void 0 : _a.call(on, { id, src });
|
|
53
|
+
if (video) {
|
|
54
|
+
intersectionObserver.observe(video);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
onDestroy(() => {
|
|
58
|
+
PlaybackManager.unregisterPlayer(id);
|
|
59
|
+
intersectionObserver.disconnect();
|
|
60
|
+
});
|
|
61
|
+
let video = $state.raw(undefined);
|
|
62
|
+
let showControlsOnHover = $state(false);
|
|
63
|
+
let needShowProgress = $state(false);
|
|
64
|
+
let isVideoPaused = $state(true);
|
|
65
|
+
let percentageCompleted = $state(0);
|
|
66
|
+
let everActivated = $state(false);
|
|
67
|
+
$effect(() => {
|
|
68
|
+
void src;
|
|
69
|
+
untrack(() => {
|
|
70
|
+
if (video === null || video === void 0 ? void 0 : video.src) {
|
|
71
|
+
video.src = src;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
const intersectionObserver = new IntersectionObserver((entries) => {
|
|
76
|
+
if (!video) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const [entry] = entries;
|
|
80
|
+
// handle lazy loading, if the video is not in the viewport, don't load it
|
|
81
|
+
if (entry.isIntersecting && !video.src) {
|
|
82
|
+
video.src = src;
|
|
83
|
+
video.load();
|
|
84
|
+
// Handle one-time autoplay
|
|
85
|
+
if (autoplay === true) {
|
|
86
|
+
const handleCanPlay = () => {
|
|
87
|
+
if (entry.isIntersecting) {
|
|
88
|
+
play();
|
|
89
|
+
autoplay = false;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
video.addEventListener('canplay', handleCanPlay, { once: true });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// the following steps only for video with autoplay on-appearance
|
|
97
|
+
if (autoplay !== 'on-appearance') {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!entry.isIntersecting) {
|
|
101
|
+
stop();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (entry.intersectionRatio < 0.4) {
|
|
105
|
+
pause();
|
|
106
|
+
}
|
|
107
|
+
if (entry.intersectionRatio >= 0.6) {
|
|
108
|
+
const handleCanPlay = () => {
|
|
109
|
+
if (entry.intersectionRatio >= 0.6) {
|
|
110
|
+
play();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
if (video.readyState >= 3) {
|
|
114
|
+
play();
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
video.addEventListener('canplay', handleCanPlay, { once: true });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
root: intersectionContainer,
|
|
122
|
+
rootMargin: '0px',
|
|
123
|
+
threshold: [0.1, 0.4, 0.6]
|
|
124
|
+
});
|
|
125
|
+
const play = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
if (!video) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
yield video.play();
|
|
131
|
+
}
|
|
132
|
+
catch (_a) {
|
|
133
|
+
// can't play video without interaction with document, just ignoring the error
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
// paused - default state for any video element (not started, not playing, ended)
|
|
137
|
+
// If the video is still paused after attempting to play (likely due to autoplay restrictions),
|
|
138
|
+
// we assume it couldn't start due to lack of user interaction.
|
|
139
|
+
// To comply with autoplay policies, we mute the video and attempt to play it again.
|
|
140
|
+
if (video.paused) {
|
|
141
|
+
video.muted = true;
|
|
142
|
+
video.play();
|
|
143
|
+
}
|
|
144
|
+
everActivated = true;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const pause = () => {
|
|
148
|
+
video === null || video === void 0 ? void 0 : video.pause();
|
|
149
|
+
};
|
|
150
|
+
const stop = () => {
|
|
151
|
+
if (!video) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
video.pause();
|
|
155
|
+
video.currentTime = 0;
|
|
156
|
+
video.load();
|
|
157
|
+
};
|
|
158
|
+
const togglePlay = (e) => {
|
|
159
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
160
|
+
if (!video) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (video.paused) {
|
|
164
|
+
play();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
pause();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const toggleMute = (e) => {
|
|
171
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
172
|
+
setMuted(!(video === null || video === void 0 ? void 0 : video.muted));
|
|
173
|
+
};
|
|
174
|
+
const onVolumeChange = (e) => {
|
|
175
|
+
const video = e.target;
|
|
176
|
+
MediaVolumeManager.volumeLevel = video.volume;
|
|
177
|
+
MediaVolumeManager.isMuted = video.muted;
|
|
178
|
+
};
|
|
179
|
+
const onTimeUpdate = (e) => {
|
|
180
|
+
const video = e.target;
|
|
181
|
+
percentageCompleted = video.currentTime / video.duration || 0;
|
|
182
|
+
notifyProgress();
|
|
183
|
+
};
|
|
184
|
+
const onLoaded = (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
+
const video = e.target;
|
|
186
|
+
needShowProgress = video.duration >= 8;
|
|
187
|
+
setVolume(MediaVolumeManager.volumeLevel);
|
|
188
|
+
setMuted(MediaVolumeManager.isMuted);
|
|
189
|
+
});
|
|
190
|
+
const onEnded = () => {
|
|
191
|
+
var _a;
|
|
192
|
+
percentageCompleted = 1;
|
|
193
|
+
notifyProgress();
|
|
194
|
+
(_a = on === null || on === void 0 ? void 0 : on.ended) === null || _a === void 0 ? void 0 : _a.call(on, { id, src });
|
|
195
|
+
if (!loop) {
|
|
196
|
+
everActivated = false;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const onPlay = () => {
|
|
200
|
+
isVideoPaused = false;
|
|
201
|
+
PlaybackManager.setPlayingComponent(id);
|
|
202
|
+
};
|
|
203
|
+
const onPause = () => {
|
|
204
|
+
isVideoPaused = true;
|
|
205
|
+
};
|
|
206
|
+
const setVolume = (level) => {
|
|
207
|
+
MediaVolumeManager.volumeLevel = level;
|
|
208
|
+
if (video) {
|
|
209
|
+
video.volume = level;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const setMuted = (state) => {
|
|
213
|
+
MediaVolumeManager.isMuted = state;
|
|
214
|
+
};
|
|
215
|
+
$effect(() => {
|
|
216
|
+
if (video) {
|
|
217
|
+
video.muted = MediaVolumeManager.isMuted;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const setShowControlsOnHover = (state) => {
|
|
221
|
+
showControlsOnHover = state;
|
|
222
|
+
};
|
|
223
|
+
const notifyProgress = () => {
|
|
224
|
+
var _a;
|
|
225
|
+
(_a = on === null || on === void 0 ? void 0 : on.progress) === null || _a === void 0 ? void 0 : _a.call(on, percentageCompleted);
|
|
226
|
+
};
|
|
227
|
+
const handleSeek = (percent) => {
|
|
228
|
+
if (video) {
|
|
229
|
+
video.currentTime = video.duration * percent;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<div class="video" onmouseenter={() => setShowControlsOnHover(true)} onmouseleave={() => setShowControlsOnHover(false)} role="none" inert={inert}>
|
|
235
|
+
<video
|
|
236
|
+
class="video__video"
|
|
237
|
+
style={everActivated ? `--_video--media-fit: contain;` : ''}
|
|
238
|
+
width="100%"
|
|
239
|
+
controls={controls && everActivated}
|
|
240
|
+
poster={poster}
|
|
241
|
+
loop={loop}
|
|
242
|
+
preload="metadata"
|
|
243
|
+
onvolumechange={onVolumeChange}
|
|
244
|
+
ontimeupdate={onTimeUpdate}
|
|
245
|
+
onloadeddata={onLoaded}
|
|
246
|
+
onended={onEnded}
|
|
247
|
+
onplay={onPlay}
|
|
248
|
+
onpause={onPause}
|
|
249
|
+
playsinline
|
|
250
|
+
bind:this={video}>
|
|
251
|
+
<track src="" kind="captions" />
|
|
252
|
+
</video>
|
|
253
|
+
{#if !controls || !everActivated}
|
|
254
|
+
<div class="video__cover" onclick={togglePlay} onkeydown={() => ({})} role="none">
|
|
255
|
+
{#if isVideoPaused}
|
|
256
|
+
<button type="button" aria-label="play" class="video__playback-button" onclick={togglePlay} onkeydown={() => ({})}>
|
|
257
|
+
<Icon src={IconPlay} color={IconColor.White} />
|
|
258
|
+
</button>
|
|
259
|
+
{:else if showControlsOnHover}
|
|
260
|
+
<button type="button" aria-label="pause" class="video__playback-button video__playback-button--pause" onclick={togglePlay} onkeydown={() => ({})}>
|
|
261
|
+
<Icon src={IconPause} color={IconColor.White} />
|
|
262
|
+
</button>
|
|
263
|
+
{/if}
|
|
264
|
+
{#if showControlsOnHover || MediaVolumeManager.isMuted}
|
|
265
|
+
<button type="button" aria-label={MediaVolumeManager.isMuted ? 'mute' : 'unmute'} class="video__mute-button" onclick={toggleMute}>
|
|
266
|
+
{#if MediaVolumeManager.isMuted}
|
|
267
|
+
<Icon src={IconSpeakerMute} color={IconColor.White} />
|
|
268
|
+
{:else}
|
|
269
|
+
<Icon src={IconSpeaker} color={IconColor.White} />
|
|
270
|
+
{/if}
|
|
271
|
+
</button>
|
|
272
|
+
{/if}
|
|
273
|
+
|
|
274
|
+
<div class="video__progress-container">
|
|
275
|
+
{#if needShowProgress}
|
|
276
|
+
{#if showControlsOnHover}
|
|
277
|
+
<div class="video__seek-bar" onclick={(e) => e.stopPropagation()} onkeydown={() => ({})} role="none" transition:slide>
|
|
278
|
+
<SeekBar value={percentageCompleted} on={{ seek: handleSeek }} />
|
|
279
|
+
</div>
|
|
280
|
+
{/if}
|
|
281
|
+
{#if !showControlsOnHover}
|
|
282
|
+
<div class="video__progress" in:slide>
|
|
283
|
+
<Progress value={percentageCompleted} />
|
|
284
|
+
</div>
|
|
285
|
+
{/if}
|
|
286
|
+
{/if}
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
{/if}
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<style>@keyframes fadeIn {
|
|
293
|
+
0% {
|
|
294
|
+
opacity: 1;
|
|
295
|
+
}
|
|
296
|
+
50% {
|
|
297
|
+
opacity: 0.4;
|
|
298
|
+
}
|
|
299
|
+
100% {
|
|
300
|
+
opacity: 1;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
.video {
|
|
304
|
+
--_video--background-color: var(--video--background-color, #000000);
|
|
305
|
+
--_video--border-radius: var(--video--border-radius, 0);
|
|
306
|
+
--_video--media-fit: var(--video--media-fit, contain);
|
|
307
|
+
--_video--progress--background-color: var(--video--progress--background-color, hsla(0, 0%, 0%, 0.5));
|
|
308
|
+
--_video--progress--back-color: var(--video--progress--back-color);
|
|
309
|
+
--_video--progress--front-color: var(--video--progress--front-color);
|
|
310
|
+
height: 100%;
|
|
311
|
+
min-height: 100%;
|
|
312
|
+
max-height: 100%;
|
|
313
|
+
width: 100%;
|
|
314
|
+
min-width: 100%;
|
|
315
|
+
max-width: 100%;
|
|
316
|
+
cursor: pointer;
|
|
317
|
+
position: relative;
|
|
318
|
+
overflow: hidden;
|
|
319
|
+
border-radius: var(--_video--border-radius);
|
|
320
|
+
background: var(--_video--background-color);
|
|
321
|
+
}
|
|
322
|
+
.video__playback-button {
|
|
323
|
+
position: absolute;
|
|
324
|
+
top: 50%;
|
|
325
|
+
left: 50%;
|
|
326
|
+
transform: translate(-50%, -50%);
|
|
327
|
+
font-size: 2em;
|
|
328
|
+
}
|
|
329
|
+
.video__playback-button--pause {
|
|
330
|
+
/* Set 'container-type: inline-size;' to reference container*/
|
|
331
|
+
}
|
|
332
|
+
@container (width < 576px) {
|
|
333
|
+
.video__playback-button--pause {
|
|
334
|
+
display: none;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
.video__mute-button {
|
|
338
|
+
position: absolute;
|
|
339
|
+
top: 0.625em;
|
|
340
|
+
right: 0.625em;
|
|
341
|
+
font-size: 1em;
|
|
342
|
+
z-index: 1;
|
|
343
|
+
}
|
|
344
|
+
.video__video {
|
|
345
|
+
object-fit: var(--_video--media-fit);
|
|
346
|
+
min-width: 100%;
|
|
347
|
+
min-height: 100%;
|
|
348
|
+
max-width: 100%;
|
|
349
|
+
max-height: 100%;
|
|
350
|
+
}
|
|
351
|
+
.video__cover {
|
|
352
|
+
position: absolute;
|
|
353
|
+
left: 0;
|
|
354
|
+
top: 0;
|
|
355
|
+
width: 100%;
|
|
356
|
+
height: 100%;
|
|
357
|
+
background-color: transparent;
|
|
358
|
+
}
|
|
359
|
+
.video__progress-container {
|
|
360
|
+
position: absolute;
|
|
361
|
+
bottom: 0;
|
|
362
|
+
left: 0;
|
|
363
|
+
right: 0;
|
|
364
|
+
}
|
|
365
|
+
.video__progress {
|
|
366
|
+
margin-bottom: 1px;
|
|
367
|
+
--progress--height: 0.125em;
|
|
368
|
+
--progress--back-color: var(--_video--progress--back-color);
|
|
369
|
+
--progress--front-color: var(--_video--progress--front-color);
|
|
370
|
+
}
|
|
371
|
+
.video__seek-bar {
|
|
372
|
+
padding: 0.625em 0.5em;
|
|
373
|
+
background: var(--_video--progress--background-color);
|
|
374
|
+
cursor: default;
|
|
375
|
+
--seek-bar--back-color: var(--_video--progress--back-color);
|
|
376
|
+
--seek-bar--front-color: var(--_video--progress--front-color);
|
|
377
|
+
}</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
src: string;
|
|
3
|
+
poster: string | null;
|
|
4
|
+
id?: string;
|
|
5
|
+
controls?: boolean;
|
|
6
|
+
autoplay?: true | false | 'on-appearance';
|
|
7
|
+
loop?: boolean;
|
|
8
|
+
intersectionContainer?: HTMLElement;
|
|
9
|
+
inert?: boolean;
|
|
10
|
+
on?: {
|
|
11
|
+
loaded?: (data: {
|
|
12
|
+
id: string;
|
|
13
|
+
src: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
progress?: (value: number) => void;
|
|
16
|
+
ended?: (data: {
|
|
17
|
+
id: string;
|
|
18
|
+
src: string;
|
|
19
|
+
}) => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
23
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
24
|
+
export default Cmp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Video } from './cmp.video.svelte';
|