@ankhorage/zora 28.1.5 → 28.3.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/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/dist/capabilities/index.js +159 -2
- package/dist/capabilities/index.js.map +8 -5
- package/dist/constants/authoring.d.ts +6 -3
- package/dist/constants/authoring.d.ts.map +1 -1
- package/dist/constants/authoring.js +6 -0
- package/dist/constants/authoring.js.map +1 -1
- package/dist/features/accordion/accordionItemMeta.d.ts +1 -1
- package/dist/features/audio/adapters/inbound/Audio.d.ts +5 -0
- package/dist/features/audio/adapters/inbound/Audio.d.ts.map +1 -0
- package/dist/features/audio/adapters/inbound/Audio.js +80 -0
- package/dist/features/audio/adapters/inbound/Audio.js.map +1 -0
- package/dist/features/audio/audioMeta.d.ts +22 -0
- package/dist/features/audio/audioMeta.d.ts.map +1 -0
- package/dist/features/audio/audioMeta.js +18 -0
- package/dist/features/audio/audioMeta.js.map +1 -0
- package/dist/features/audio/composition/AudioController.d.ts +13 -0
- package/dist/features/audio/composition/AudioController.d.ts.map +1 -0
- package/dist/features/audio/composition/AudioController.js +2 -0
- package/dist/features/audio/composition/AudioController.js.map +1 -0
- package/dist/features/audio/composition/useAudioController.d.ts +5 -0
- package/dist/features/audio/composition/useAudioController.d.ts.map +1 -0
- package/dist/features/audio/composition/useAudioController.js +22 -0
- package/dist/features/audio/composition/useAudioController.js.map +1 -0
- package/dist/features/audio/composition/useAudioController.web.d.ts +5 -0
- package/dist/features/audio/composition/useAudioController.web.d.ts.map +1 -0
- package/dist/features/audio/composition/useAudioController.web.js +80 -0
- package/dist/features/audio/composition/useAudioController.web.js.map +1 -0
- package/dist/features/audio/public.d.ts +3 -0
- package/dist/features/audio/public.d.ts.map +1 -0
- package/dist/features/audio/public.js +2 -0
- package/dist/features/audio/public.js.map +1 -0
- package/dist/features/bottom-sheet/bottomSheetMeta.d.ts +1 -1
- package/dist/features/card/cardMeta.d.ts +1 -1
- package/dist/features/card/mediaCardMeta.d.ts +1 -1
- package/dist/features/card/postCardMeta.d.ts +1 -1
- package/dist/features/chat/messageBubbleMeta.d.ts +1 -1
- package/dist/features/dialog/dialogMeta.d.ts +2 -2
- package/dist/features/gradient/gradientMeta.d.ts +1 -1
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +1 -1
- package/dist/features/layout/gridMeta.d.ts +1 -1
- package/dist/features/layout/screenMeta.d.ts +1 -1
- package/dist/features/layout/scrollViewMeta.d.ts +1 -1
- package/dist/features/layout/viewMeta.d.ts +1 -1
- package/dist/features/link/adapters/inbound/Link.d.ts +2 -0
- package/dist/features/link/adapters/inbound/Link.d.ts.map +1 -0
- package/dist/features/link/adapters/inbound/Link.js +2 -0
- package/dist/features/link/adapters/inbound/Link.js.map +1 -0
- package/dist/features/link/adapters/inbound/Link.native.d.ts +5 -0
- package/dist/features/link/adapters/inbound/Link.native.d.ts.map +1 -0
- package/dist/features/link/adapters/inbound/Link.native.js +29 -0
- package/dist/features/link/adapters/inbound/Link.native.js.map +1 -0
- package/dist/features/link/adapters/inbound/Link.web.d.ts +5 -0
- package/dist/features/link/adapters/inbound/Link.web.d.ts.map +1 -0
- package/dist/features/link/adapters/inbound/Link.web.js +34 -0
- package/dist/features/link/adapters/inbound/Link.web.js.map +1 -0
- package/dist/features/link/linkMeta.d.ts +116 -0
- package/dist/features/link/linkMeta.d.ts.map +1 -0
- package/dist/features/link/linkMeta.js +82 -0
- package/dist/features/link/linkMeta.js.map +1 -0
- package/dist/features/link/public.d.ts +3 -0
- package/dist/features/link/public.d.ts.map +1 -0
- package/dist/features/link/public.js +2 -0
- package/dist/features/link/public.js.map +1 -0
- package/dist/features/link/utils/linkThemeRecipeMeta.d.ts +25 -0
- package/dist/features/link/utils/linkThemeRecipeMeta.d.ts.map +1 -0
- package/dist/features/link/utils/linkThemeRecipeMeta.js +26 -0
- package/dist/features/link/utils/linkThemeRecipeMeta.js.map +1 -0
- package/dist/features/list/flatListMeta.d.ts +1 -1
- package/dist/features/list/sectionListMeta.d.ts +1 -1
- package/dist/features/master-detail/masterDetailMeta.d.ts +1 -1
- package/dist/features/reader/meta.d.ts +2 -2
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.d.ts.map +1 -1
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js +6 -0
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js.map +1 -1
- package/dist/features/registry/bindableComponentMeta.d.ts +2 -2
- package/dist/features/registry/componentMeta.d.ts.map +1 -1
- package/dist/features/registry/componentMeta.js +6 -0
- package/dist/features/registry/componentMeta.js.map +1 -1
- package/dist/features/registry/themeRecipeMeta.d.ts.map +1 -1
- package/dist/features/registry/themeRecipeMeta.js +2 -0
- package/dist/features/registry/themeRecipeMeta.js.map +1 -1
- package/dist/features/scanner/meta.d.ts +2 -2
- package/dist/features/section/screenSectionMeta.d.ts +1 -1
- package/dist/features/surface/surfaceMeta.d.ts +1 -1
- package/dist/features/tabs/tabPanelMeta.d.ts +1 -1
- package/dist/features/video/adapters/inbound/Video.d.ts +2 -0
- package/dist/features/video/adapters/inbound/Video.d.ts.map +1 -0
- package/dist/features/video/adapters/inbound/Video.js +2 -0
- package/dist/features/video/adapters/inbound/Video.js.map +1 -0
- package/dist/features/video/adapters/inbound/Video.native.d.ts +5 -0
- package/dist/features/video/adapters/inbound/Video.native.d.ts.map +1 -0
- package/dist/features/video/adapters/inbound/Video.native.js +160 -0
- package/dist/features/video/adapters/inbound/Video.native.js.map +1 -0
- package/dist/features/video/adapters/inbound/Video.web.d.ts +5 -0
- package/dist/features/video/adapters/inbound/Video.web.d.ts.map +1 -0
- package/dist/features/video/adapters/inbound/Video.web.js +30 -0
- package/dist/features/video/adapters/inbound/Video.web.js.map +1 -0
- package/dist/features/video/public.d.ts +3 -0
- package/dist/features/video/public.d.ts.map +1 -0
- package/dist/features/video/public.js +2 -0
- package/dist/features/video/public.js.map +1 -0
- package/dist/features/video/videoMeta.d.ts +64 -0
- package/dist/features/video/videoMeta.d.ts.map +1 -0
- package/dist/features/video/videoMeta.js +50 -0
- package/dist/features/video/videoMeta.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/readerFree.d.ts +5 -0
- package/dist/readerFree.d.ts.map +1 -1
- package/dist/readerFree.js +3 -0
- package/dist/readerFree.js.map +1 -1
- package/dist/types/audio.d.ts +15 -0
- package/dist/types/audio.d.ts.map +1 -0
- package/dist/types/audio.js +2 -0
- package/dist/types/audio.js.map +1 -0
- package/dist/types/link.d.ts +23 -0
- package/dist/types/link.d.ts.map +1 -0
- package/dist/types/link.js +2 -0
- package/dist/types/link.js.map +1 -0
- package/dist/types/video.d.ts +24 -0
- package/dist/types/video.d.ts.map +1 -0
- package/dist/types/video.js +2 -0
- package/dist/types/video.js.map +1 -0
- package/package.json +41 -3
- package/src/constants/authoring.ts +6 -0
- package/src/features/audio/adapters/inbound/Audio.tsx +158 -0
- package/src/features/audio/audioMeta.ts +20 -0
- package/src/features/audio/composition/AudioController.ts +12 -0
- package/src/features/audio/composition/useAudioController.ts +27 -0
- package/src/features/audio/composition/useAudioController.web.ts +106 -0
- package/src/features/audio/public.test.ts +37 -0
- package/src/features/audio/public.ts +2 -0
- package/src/features/link/Link.test.tsx +48 -0
- package/src/features/link/adapters/inbound/Link.native.tsx +62 -0
- package/src/features/link/adapters/inbound/Link.tsx +1 -0
- package/src/features/link/adapters/inbound/Link.web.tsx +67 -0
- package/src/features/link/linkMeta.ts +83 -0
- package/src/features/link/public.ts +2 -0
- package/src/features/link/utils/linkThemeRecipeMeta.ts +27 -0
- package/src/features/registry/ZORA_BASE_COMPONENT_REGISTRY.ts +6 -0
- package/src/features/registry/componentMeta.test.ts +31 -0
- package/src/features/registry/componentMeta.ts +6 -0
- package/src/features/registry/themeRecipeMeta.test.ts +1 -0
- package/src/features/registry/themeRecipeMeta.ts +2 -0
- package/src/features/video/adapters/inbound/Video.native.tsx +296 -0
- package/src/features/video/adapters/inbound/Video.test.tsx +188 -0
- package/src/features/video/adapters/inbound/Video.tsx +1 -0
- package/src/features/video/adapters/inbound/Video.web.tsx +70 -0
- package/src/features/video/public.ts +7 -0
- package/src/features/video/videoMeta.ts +51 -0
- package/src/index.ts +2 -0
- package/src/readerFree.ts +15 -0
- package/src/types/audio.ts +16 -0
- package/src/types/link.ts +26 -0
- package/src/types/video.ts +28 -0
- package/web-dist/authoring/index.js +27 -0
- package/web-dist/chunks/{Accordion-15sxxjym.js → Accordion-17s33h1a.js} +1 -1
- package/web-dist/chunks/{Accordion-qrt9xz0h.js → Accordion-2wggrer7.js} +2 -2
- package/web-dist/chunks/{Accordion-9k7ktksc.js → Accordion-2xkxthf1.js} +3 -3
- package/web-dist/chunks/{Accordion-qkkeyr18.js → Accordion-2ys50fc8.js} +1 -1
- package/web-dist/chunks/{Accordion-xfkg7dcw.js → Accordion-379mgrse.js} +1 -1
- package/web-dist/chunks/{Accordion-xb9zhdhp.js → Accordion-38xvj0cq.js} +2 -2
- package/web-dist/chunks/{Accordion-q11svb96.js → Accordion-5qz4j8tt.js} +5 -5
- package/web-dist/chunks/{Accordion-8c4w7366.js → Accordion-5rwztz14.js} +1 -1
- package/web-dist/chunks/{Accordion-afpjg1d6.js → Accordion-8skz71ct.js} +1 -1
- package/web-dist/chunks/{Accordion-27yg9ktv.js → Accordion-9qg7cjt8.js} +1 -1
- package/web-dist/chunks/{Accordion-wb9pmykz.js → Accordion-a1mgdfg7.js} +1 -1
- package/web-dist/chunks/{Accordion-vzq344av.js → Accordion-axe7nsht.js} +1 -1
- package/web-dist/chunks/{Accordion-46n609yq.js → Accordion-bd9vzpbz.js} +2 -2
- package/web-dist/chunks/{Accordion-gnxmybxx.js → Accordion-bp9y7738.js} +4 -4
- package/web-dist/chunks/{Accordion-5cjhz94e.js → Accordion-bzgy9sg3.js} +2 -2
- package/web-dist/chunks/{Accordion-f4919ghm.js → Accordion-e0vm82xr.js} +1 -1
- package/web-dist/chunks/{Accordion-jmxe6kw0.js → Accordion-f1vargnk.js} +1 -1
- package/web-dist/chunks/{Accordion-de8srt4x.js → Accordion-f8zpd80k.js} +3 -3
- package/web-dist/chunks/{Accordion-qsppnx7g.js → Accordion-gnbt6w4q.js} +1 -1
- package/web-dist/chunks/{Accordion-h1q243zq.js → Accordion-htm3j8r8.js} +3 -3
- package/web-dist/chunks/{Accordion-01zvarrn.js → Accordion-kdb9g5b1.js} +1 -1
- package/web-dist/chunks/{Accordion-78tknqmc.js → Accordion-nmpzv3b0.js} +2 -2
- package/web-dist/chunks/{Accordion-22cda3h5.js → Accordion-r75ep5pg.js} +2 -2
- package/web-dist/chunks/{Accordion-34b3rwbc.js → Accordion-rq311z1k.js} +3 -3
- package/web-dist/chunks/{Accordion-epv5yhch.js → Accordion-tqagt6cz.js} +1 -1
- package/web-dist/chunks/{Accordion-0xaq2k2h.js → Accordion-vb52sts9.js} +1 -1
- package/web-dist/chunks/{Accordion-b8w0f8s0.js → Accordion-za0jcjgn.js} +1 -1
- package/web-dist/chunks/Video.native-97x0098j.js +905 -0
- package/web-dist/chunks/index-cnnsfz6n.js +1807 -0
- package/web-dist/components/accordion/Accordion.js +2 -2
- package/web-dist/components/accordion-item/AccordionItem.js +2 -2
- package/web-dist/components/app-bar/AppBar.js +4 -4
- package/web-dist/components/app-header/AppHeader.js +4 -4
- package/web-dist/components/audio/Audio.d.ts +7 -0
- package/web-dist/components/audio/Audio.dependency-0.d.ts +27 -0
- package/web-dist/components/audio/Audio.dependency-1.d.ts +3 -0
- package/web-dist/components/audio/Audio.js +264 -0
- package/web-dist/components/audio/Audio.types-0.d.ts +18 -0
- package/web-dist/components/audio/index.d.ts +2 -0
- package/web-dist/components/audio/index.js +2 -0
- package/web-dist/components/auth-screen/AuthScreen.js +6 -6
- package/web-dist/components/avatar/Avatar.js +2 -2
- package/web-dist/components/avatar-group/AvatarGroup.js +2 -2
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +5 -5
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +2 -2
- package/web-dist/components/button/Button.js +1 -1
- package/web-dist/components/button-group/ButtonGroup.js +1 -1
- package/web-dist/components/calendar/Calendar.js +3 -3
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +5 -5
- package/web-dist/components/card/Card.js +4 -4
- package/web-dist/components/chat-list-item/ChatListItem.js +3 -3
- package/web-dist/components/checkbox/Checkbox.js +2 -2
- package/web-dist/components/checkbox-group/CheckboxGroup.js +2 -2
- package/web-dist/components/chip/Chip.js +2 -2
- package/web-dist/components/chip-group/ChipGroup.js +2 -2
- package/web-dist/components/collection-editor/CollectionEditor.js +4 -4
- package/web-dist/components/color-hue-scale/ColorHueScale.js +6 -6
- package/web-dist/components/color-picker/ColorPicker.js +6 -6
- package/web-dist/components/color-tone/ColorTone.js +6 -6
- package/web-dist/components/color-wheel/ColorWheel.js +6 -6
- package/web-dist/components/content-rail/ContentRail.js +2 -2
- package/web-dist/components/data-table/DataTable.js +10 -10
- package/web-dist/components/date-picker/DatePicker.js +4 -4
- package/web-dist/components/dialog/Dialog.js +2 -2
- package/web-dist/components/empty-state/EmptyState.js +5 -5
- package/web-dist/components/explorer/Explorer.js +2 -2
- package/web-dist/components/field/Field.js +2 -2
- package/web-dist/components/file-explorer/FileExplorer.js +2 -2
- package/web-dist/components/flat-list/FlatList.js +3 -3
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +6 -6
- package/web-dist/components/form/Form.js +4 -4
- package/web-dist/components/form-actions/FormActions.js +4 -4
- package/web-dist/components/form-error/FormError.js +4 -4
- package/web-dist/components/heading/Heading.js +1 -1
- package/web-dist/components/hero/Hero.js +4 -4
- package/web-dist/components/icon-button/IconButton.js +1 -1
- package/web-dist/components/link/Link.d.ts +7 -0
- package/web-dist/components/link/Link.dependency-0.d.ts +27 -0
- package/web-dist/components/link/Link.dependency-1.d.ts +3 -0
- package/web-dist/components/link/Link.dependency-2.d.ts +7 -0
- package/web-dist/components/link/Link.dependency-3.d.ts +5 -0
- package/web-dist/components/link/Link.js +95 -0
- package/web-dist/components/link/Link.types-0.d.ts +28 -0
- package/web-dist/components/link/index.d.ts +2 -0
- package/web-dist/components/link/index.js +2 -0
- package/web-dist/components/list/List.js +3 -3
- package/web-dist/components/list-item/ListItem.js +3 -3
- package/web-dist/components/list-section/ListSection.js +3 -3
- package/web-dist/components/media-card/MediaCard.js +4 -4
- package/web-dist/components/media-explorer/MediaExplorer.js +2 -2
- package/web-dist/components/message-bubble/MessageBubble.js +3 -3
- package/web-dist/components/metric-card/MetricCard.js +4 -4
- package/web-dist/components/missing-element/MissingElement.js +1 -1
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +6 -6
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +6 -6
- package/web-dist/components/otp-form/OtpForm.js +6 -6
- package/web-dist/components/pagination/Pagination.js +2 -2
- package/web-dist/components/palette-item/PaletteItem.js +4 -4
- package/web-dist/components/popover-menu/PopoverMenu.js +1 -1
- package/web-dist/components/post-card/PostCard.js +4 -4
- package/web-dist/components/product-card/ProductCard.js +4 -4
- package/web-dist/components/progress/Progress.js +2 -2
- package/web-dist/components/progress-ring/ProgressRing.js +2 -2
- package/web-dist/components/radio/Radio.js +2 -2
- package/web-dist/components/radio-group/RadioGroup.js +2 -2
- package/web-dist/components/reader/Reader.js +6 -6
- package/web-dist/components/scan-overlay/ScanOverlay.js +5 -5
- package/web-dist/components/screen-section/ScreenSection.js +2 -2
- package/web-dist/components/search-input/SearchInput.js +2 -2
- package/web-dist/components/section-header/SectionHeader.js +2 -2
- package/web-dist/components/section-list/SectionList.js +3 -3
- package/web-dist/components/select/Select.js +3 -3
- package/web-dist/components/sign-in-form/SignInForm.js +6 -6
- package/web-dist/components/sign-up-form/SignUpForm.js +6 -6
- package/web-dist/components/skeleton/Skeleton.js +7 -7
- package/web-dist/components/skeleton-card/SkeletonCard.js +7 -7
- package/web-dist/components/skeleton-list/SkeletonList.js +7 -7
- package/web-dist/components/skeleton-text/SkeletonText.js +7 -7
- package/web-dist/components/text/Text.js +1 -1
- package/web-dist/components/text-input/TextInput.js +2 -2
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +1 -1
- package/web-dist/components/time-picker/TimePicker.js +3 -3
- package/web-dist/components/timeline/Timeline.js +1 -1
- package/web-dist/components/toast/Toast.js +2 -2
- package/web-dist/components/toast-provider/ToastProvider.js +2 -2
- package/web-dist/components/toolbar/Toolbar.js +4 -4
- package/web-dist/components/tree-item/TreeItem.js +4 -4
- package/web-dist/components/uploader/Uploader.js +7 -7
- package/web-dist/components/video/Video.d.ts +7 -0
- package/web-dist/components/video/Video.dependency-0.d.ts +27 -0
- package/web-dist/components/video/Video.dependency-1.d.ts +3 -0
- package/web-dist/components/video/Video.dependency-2.d.ts +9 -0
- package/web-dist/components/video/Video.dependency-3.d.ts +23 -0
- package/web-dist/components/video/Video.js +80 -0
- package/web-dist/components/video/Video.types-0.d.ts +29 -0
- package/web-dist/components/video/index.d.ts +2 -0
- package/web-dist/components/video/index.js +2 -0
- package/web-dist/manifest.json +399 -294
- package/web-dist/runtime/ZoraProvider.js +1 -1
- /package/web-dist/chunks/{Accordion-7bd6zq4s.js → Accordion-2xb252py.js} +0 -0
- /package/web-dist/chunks/{Accordion-q046ws5p.js → Accordion-q683s6kd.js} +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type PlayingChangeEventPayload,
|
|
3
|
+
type SourceLoadEventPayload,
|
|
4
|
+
type TimeUpdateEventPayload,
|
|
5
|
+
useVideoPlayer,
|
|
6
|
+
VideoView,
|
|
7
|
+
type VolumeChangeEventPayload,
|
|
8
|
+
} from 'expo-video';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Pressable } from 'react-native';
|
|
11
|
+
|
|
12
|
+
import type { VideoProps } from '../../../../types/video';
|
|
13
|
+
import { IconButton } from '../../../button/public';
|
|
14
|
+
import { Image } from '../../../image/public';
|
|
15
|
+
import { View } from '../../../layout/public';
|
|
16
|
+
import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope';
|
|
17
|
+
import { useZoraTheme } from '../../../theme/composition/useZoraTheme';
|
|
18
|
+
import { Text } from '../../../typography/public';
|
|
19
|
+
|
|
20
|
+
/*** Renders Expo-backed video playback through ZORA's portable source and themed controls. */
|
|
21
|
+
export const Video = withZoraThemeScope(VideoInner);
|
|
22
|
+
|
|
23
|
+
/*** Configures the adapter-private Expo player for the ZORA control surface. */
|
|
24
|
+
function configureVideoPlayer(player: ReturnType<typeof useVideoPlayer>, volume: number): void {
|
|
25
|
+
player.timeUpdateEventInterval = 0.25;
|
|
26
|
+
setVideoPlayerVolume(player, volume);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*** Renders one Video player and synchronizes its themed controls with Expo playback state. */
|
|
30
|
+
function VideoInner({
|
|
31
|
+
themeId: _themeId,
|
|
32
|
+
mode: _mode,
|
|
33
|
+
interactionPolicy,
|
|
34
|
+
source,
|
|
35
|
+
poster,
|
|
36
|
+
aspectRatio = 16 / 9,
|
|
37
|
+
contentFit = 'contain',
|
|
38
|
+
volume = 1,
|
|
39
|
+
accessibilityLabel = 'Video player',
|
|
40
|
+
testID,
|
|
41
|
+
}: VideoProps) {
|
|
42
|
+
const { theme } = useZoraTheme();
|
|
43
|
+
const videoRef = React.useRef<VideoView>(null);
|
|
44
|
+
const player = useVideoPlayer(source ?? null, (nextPlayer) =>
|
|
45
|
+
configureVideoPlayer(nextPlayer, volume),
|
|
46
|
+
);
|
|
47
|
+
const playbackEvents = useVideoPlayerEvents(player);
|
|
48
|
+
const [renderedSource, setRenderedSource] = React.useState<VideoProps['source']>(null);
|
|
49
|
+
const [progressWidth, setProgressWidth] = React.useState(0);
|
|
50
|
+
const currentTime = playbackEvents.timeUpdate?.currentTime ?? player.currentTime;
|
|
51
|
+
const duration = playbackEvents.sourceLoad?.duration ?? player.duration;
|
|
52
|
+
const isPlaying = playbackEvents.playingChange?.isPlaying ?? player.playing;
|
|
53
|
+
const currentVolume = playbackEvents.volumeChange?.volume ?? player.volume;
|
|
54
|
+
const canInteract = interactionPolicy !== 'passive' && source !== null && source !== undefined;
|
|
55
|
+
const safeAspectRatio = isPositiveFiniteNumber(aspectRatio) ? aspectRatio : 16 / 9;
|
|
56
|
+
const safeDuration = isPositiveFiniteNumber(duration) ? duration : 0;
|
|
57
|
+
const safeCurrentTime = clamp(currentTime, 0, safeDuration);
|
|
58
|
+
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
setVideoPlayerVolume(player, volume);
|
|
61
|
+
}, [player, volume]);
|
|
62
|
+
|
|
63
|
+
const togglePlayback = () => {
|
|
64
|
+
if (player.playing) {
|
|
65
|
+
player.pause();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
player.play();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const seekToProgress = (locationX: number) => {
|
|
73
|
+
if (progressWidth <= 0 || safeDuration === 0) return;
|
|
74
|
+
setVideoPlayerCurrentTime(player, clamp(locationX / progressWidth, 0, 1) * safeDuration);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const changeVolume = (difference: number) => {
|
|
78
|
+
setVideoPlayerVolume(player, currentVolume + difference);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const enterFullscreen = () => {
|
|
82
|
+
void videoRef.current?.enterFullscreen().catch(() => undefined);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<View
|
|
87
|
+
bg={theme.semantics.surface.raised}
|
|
88
|
+
borderColor={theme.semantics.neutral.divider}
|
|
89
|
+
borderWidth={1}
|
|
90
|
+
radius="m"
|
|
91
|
+
testID={testID}
|
|
92
|
+
overflow="hidden"
|
|
93
|
+
>
|
|
94
|
+
<View bg={theme.semantics.neutral.surface} style={{ aspectRatio: safeAspectRatio }}>
|
|
95
|
+
<VideoView
|
|
96
|
+
contentFit={contentFit}
|
|
97
|
+
fullscreenOptions={{ enable: true }}
|
|
98
|
+
nativeControls={false}
|
|
99
|
+
onFirstFrameRender={() => setRenderedSource(source ?? null)}
|
|
100
|
+
player={player}
|
|
101
|
+
ref={videoRef}
|
|
102
|
+
style={{ height: '100%', width: '100%' }}
|
|
103
|
+
/>
|
|
104
|
+
{poster && renderedSource !== source ? (
|
|
105
|
+
<View
|
|
106
|
+
style={{ bottom: 0, left: 0, position: 'absolute', right: 0, top: 0 }}
|
|
107
|
+
pointerEvents="none"
|
|
108
|
+
>
|
|
109
|
+
<Image
|
|
110
|
+
alt=""
|
|
111
|
+
aspectRatio={safeAspectRatio}
|
|
112
|
+
fit={contentFit === 'fill' ? 'stretch' : contentFit}
|
|
113
|
+
source={poster}
|
|
114
|
+
/>
|
|
115
|
+
</View>
|
|
116
|
+
) : null}
|
|
117
|
+
</View>
|
|
118
|
+
<View gap="s" p="m">
|
|
119
|
+
<Pressable
|
|
120
|
+
accessibilityLabel="Seek video"
|
|
121
|
+
accessibilityRole="adjustable"
|
|
122
|
+
accessibilityValue={{ max: safeDuration, min: 0, now: safeCurrentTime }}
|
|
123
|
+
disabled={!canInteract || safeDuration === 0}
|
|
124
|
+
onLayout={(event) => setProgressWidth(event.nativeEvent.layout.width)}
|
|
125
|
+
onPress={(event) => seekToProgress(event.nativeEvent.locationX)}
|
|
126
|
+
>
|
|
127
|
+
<View
|
|
128
|
+
bg={theme.semantics.neutral.surface}
|
|
129
|
+
borderColor={theme.semantics.neutral.divider}
|
|
130
|
+
borderWidth={1}
|
|
131
|
+
radius="full"
|
|
132
|
+
style={{ height: 8, overflow: 'hidden' }}
|
|
133
|
+
>
|
|
134
|
+
<View
|
|
135
|
+
bg={theme.semantics.action.primary.base}
|
|
136
|
+
style={{
|
|
137
|
+
height: '100%',
|
|
138
|
+
width: `${resolveProgressPercent(safeCurrentTime, safeDuration)}%`,
|
|
139
|
+
}}
|
|
140
|
+
/>
|
|
141
|
+
</View>
|
|
142
|
+
</Pressable>
|
|
143
|
+
<View align="center" direction="row" justify="space-between" wrap="nowrap">
|
|
144
|
+
<Text accessibilityLiveRegion="polite" emphasis="muted" variant="caption">
|
|
145
|
+
{formatVideoTime(safeCurrentTime)} / {formatVideoTime(safeDuration)}
|
|
146
|
+
</Text>
|
|
147
|
+
<View align="center" direction="row" gap="xs" wrap="nowrap">
|
|
148
|
+
<IconButton
|
|
149
|
+
disabled={!canInteract}
|
|
150
|
+
icon={{ name: 'play-skip-back' }}
|
|
151
|
+
interactionPolicy={interactionPolicy}
|
|
152
|
+
label="Seek back 10 seconds"
|
|
153
|
+
onPress={() => player.seekBy(-10)}
|
|
154
|
+
size="s"
|
|
155
|
+
/>
|
|
156
|
+
<IconButton
|
|
157
|
+
disabled={!canInteract}
|
|
158
|
+
icon={{ name: isPlaying ? 'pause' : 'play' }}
|
|
159
|
+
interactionPolicy={interactionPolicy}
|
|
160
|
+
label={isPlaying ? 'Pause video' : 'Play video'}
|
|
161
|
+
onPress={togglePlayback}
|
|
162
|
+
size="m"
|
|
163
|
+
/>
|
|
164
|
+
<IconButton
|
|
165
|
+
disabled={!canInteract}
|
|
166
|
+
icon={{ name: 'play-skip-forward' }}
|
|
167
|
+
interactionPolicy={interactionPolicy}
|
|
168
|
+
label="Seek forward 10 seconds"
|
|
169
|
+
onPress={() => player.seekBy(10)}
|
|
170
|
+
size="s"
|
|
171
|
+
/>
|
|
172
|
+
</View>
|
|
173
|
+
<View align="center" direction="row" gap="xs" wrap="nowrap">
|
|
174
|
+
<IconButton
|
|
175
|
+
disabled={!canInteract || currentVolume <= 0}
|
|
176
|
+
icon={{ name: 'volume-low' }}
|
|
177
|
+
interactionPolicy={interactionPolicy}
|
|
178
|
+
label="Lower volume"
|
|
179
|
+
onPress={() => changeVolume(-0.1)}
|
|
180
|
+
size="s"
|
|
181
|
+
/>
|
|
182
|
+
<IconButton
|
|
183
|
+
disabled={!canInteract || currentVolume >= 1}
|
|
184
|
+
icon={{ name: 'volume-high' }}
|
|
185
|
+
interactionPolicy={interactionPolicy}
|
|
186
|
+
label="Raise volume"
|
|
187
|
+
onPress={() => changeVolume(0.1)}
|
|
188
|
+
size="s"
|
|
189
|
+
/>
|
|
190
|
+
<IconButton
|
|
191
|
+
disabled={!canInteract}
|
|
192
|
+
icon={{ name: 'expand' }}
|
|
193
|
+
interactionPolicy={interactionPolicy}
|
|
194
|
+
label={`Enter fullscreen ${accessibilityLabel}`}
|
|
195
|
+
onPress={enterFullscreen}
|
|
196
|
+
size="s"
|
|
197
|
+
/>
|
|
198
|
+
</View>
|
|
199
|
+
</View>
|
|
200
|
+
</View>
|
|
201
|
+
</View>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/*** Clamps a finite numeric value to its inclusive playback range. */
|
|
206
|
+
function clamp(value: number, minimum: number, maximum: number): number {
|
|
207
|
+
if (!Number.isFinite(value)) return minimum;
|
|
208
|
+
return Math.min(Math.max(value, minimum), maximum);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/*** Updates the Expo adapter's private current-time property with a safe playback position. */
|
|
212
|
+
function setVideoPlayerCurrentTime(
|
|
213
|
+
player: ReturnType<typeof useVideoPlayer>,
|
|
214
|
+
currentTime: number,
|
|
215
|
+
): void {
|
|
216
|
+
player.currentTime = currentTime;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/*** Updates the Expo adapter's private volume property with a normalized value. */
|
|
220
|
+
function setVideoPlayerVolume(player: ReturnType<typeof useVideoPlayer>, volume: number): void {
|
|
221
|
+
player.volume = clamp(volume, 0, 1);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/*** Formats a playback duration in seconds as a readable elapsed-time label. */
|
|
225
|
+
function formatVideoTime(value: number): string {
|
|
226
|
+
const totalSeconds = Math.floor(Math.max(0, Number.isFinite(value) ? value : 0));
|
|
227
|
+
const seconds = totalSeconds % 60;
|
|
228
|
+
const minutes = Math.floor(totalSeconds / 60) % 60;
|
|
229
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
230
|
+
const minuteLabel = hours > 0 ? String(minutes).padStart(2, '0') : String(minutes);
|
|
231
|
+
const secondLabel = String(seconds).padStart(2, '0');
|
|
232
|
+
|
|
233
|
+
return hours > 0 ? `${hours}:${minuteLabel}:${secondLabel}` : `${minuteLabel}:${secondLabel}`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/*** Identifies finite dimensions and durations that can be used by the playback UI. */
|
|
237
|
+
function isPositiveFiniteNumber(value: number): boolean {
|
|
238
|
+
return Number.isFinite(value) && value > 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/*** Converts elapsed playback to a percentage suitable for the visual progress track. */
|
|
242
|
+
function resolveProgressPercent(currentTime: number, duration: number): number {
|
|
243
|
+
if (duration <= 0) return 0;
|
|
244
|
+
return clamp((currentTime / duration) * 100, 0, 100);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/*** Keeps Expo player events synchronized with the themed control surface. */
|
|
248
|
+
function useVideoPlayerEvents(player: ReturnType<typeof useVideoPlayer>): VideoPlaybackEvents {
|
|
249
|
+
const [events, setEvents] = React.useState<VideoPlaybackEvents>({
|
|
250
|
+
player: null,
|
|
251
|
+
playingChange: null,
|
|
252
|
+
sourceLoad: null,
|
|
253
|
+
timeUpdate: null,
|
|
254
|
+
volumeChange: null,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
React.useEffect(() => {
|
|
258
|
+
const timeUpdate = player.addListener('timeUpdate', (value) => {
|
|
259
|
+
setEvents((current) => ({ ...current, player, timeUpdate: value }));
|
|
260
|
+
});
|
|
261
|
+
const sourceLoad = player.addListener('sourceLoad', (value) => {
|
|
262
|
+
setEvents((current) => ({ ...current, player, sourceLoad: value }));
|
|
263
|
+
});
|
|
264
|
+
const playingChange = player.addListener('playingChange', (value) => {
|
|
265
|
+
setEvents((current) => ({ ...current, player, playingChange: value }));
|
|
266
|
+
});
|
|
267
|
+
const volumeChange = player.addListener('volumeChange', (value) => {
|
|
268
|
+
setEvents((current) => ({ ...current, player, volumeChange: value }));
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
return () => {
|
|
272
|
+
timeUpdate.remove();
|
|
273
|
+
sourceLoad.remove();
|
|
274
|
+
playingChange.remove();
|
|
275
|
+
volumeChange.remove();
|
|
276
|
+
};
|
|
277
|
+
}, [player]);
|
|
278
|
+
|
|
279
|
+
return events.player === player ? events : EMPTY_VIDEO_PLAYBACK_EVENTS;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
interface VideoPlaybackEvents {
|
|
283
|
+
readonly player: ReturnType<typeof useVideoPlayer> | null;
|
|
284
|
+
readonly playingChange: PlayingChangeEventPayload | null;
|
|
285
|
+
readonly sourceLoad: SourceLoadEventPayload | null;
|
|
286
|
+
readonly timeUpdate: TimeUpdateEventPayload | null;
|
|
287
|
+
readonly volumeChange: VolumeChangeEventPayload | null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const EMPTY_VIDEO_PLAYBACK_EVENTS: VideoPlaybackEvents = {
|
|
291
|
+
player: null,
|
|
292
|
+
playingChange: null,
|
|
293
|
+
sourceLoad: null,
|
|
294
|
+
timeUpdate: null,
|
|
295
|
+
volumeChange: null,
|
|
296
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { afterAll, expect, mock, test } from 'bun:test';
|
|
2
|
+
import { Window } from 'happy-dom';
|
|
3
|
+
import React, { act } from 'react';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
|
|
6
|
+
const browser = new Window();
|
|
7
|
+
const globals = ['window', 'document', 'Node', 'navigator', 'IS_REACT_ACT_ENVIRONMENT'] as const;
|
|
8
|
+
const previousGlobals = globals.map(
|
|
9
|
+
(key) => [key, Object.getOwnPropertyDescriptor(globalThis, key)] as const,
|
|
10
|
+
);
|
|
11
|
+
Object.assign(globalThis, {
|
|
12
|
+
IS_REACT_ACT_ENVIRONMENT: true,
|
|
13
|
+
Node: browser.Node,
|
|
14
|
+
document: browser.document,
|
|
15
|
+
navigator: browser.navigator,
|
|
16
|
+
window: browser,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const calls = { fullscreen: 0, pause: 0, play: 0, seeks: [] as number[] };
|
|
20
|
+
const player = {
|
|
21
|
+
addListener: () => ({ remove: () => undefined }),
|
|
22
|
+
currentTime: 15,
|
|
23
|
+
duration: 120,
|
|
24
|
+
pause: () => {
|
|
25
|
+
calls.pause += 1;
|
|
26
|
+
},
|
|
27
|
+
play: () => {
|
|
28
|
+
calls.play += 1;
|
|
29
|
+
},
|
|
30
|
+
playing: false,
|
|
31
|
+
seekBy: (seconds: number) => calls.seeks.push(seconds),
|
|
32
|
+
timeUpdateEventInterval: 0,
|
|
33
|
+
volume: 0.5,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
await mock.module('expo-video', () => ({
|
|
37
|
+
VideoView: React.forwardRef((_props, ref) => {
|
|
38
|
+
React.useImperativeHandle(ref, () => ({
|
|
39
|
+
enterFullscreen: () => {
|
|
40
|
+
calls.fullscreen += 1;
|
|
41
|
+
return Promise.resolve();
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
return <video data-testid="expo-video" />;
|
|
45
|
+
}),
|
|
46
|
+
useVideoPlayer: (source: string | null, configure: (value: typeof player) => void) => {
|
|
47
|
+
configure(player);
|
|
48
|
+
return source === null ? { ...player, currentTime: 0, duration: 0 } : player;
|
|
49
|
+
},
|
|
50
|
+
}));
|
|
51
|
+
await mock.module('react-native', () => ({
|
|
52
|
+
Pressable: ({
|
|
53
|
+
accessibilityLabel,
|
|
54
|
+
children,
|
|
55
|
+
disabled,
|
|
56
|
+
onPress,
|
|
57
|
+
}: {
|
|
58
|
+
accessibilityLabel?: string;
|
|
59
|
+
children?: React.ReactNode;
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
onPress?: () => void;
|
|
62
|
+
}) => (
|
|
63
|
+
<button aria-label={accessibilityLabel} disabled={disabled} onClick={onPress}>
|
|
64
|
+
{children}
|
|
65
|
+
</button>
|
|
66
|
+
),
|
|
67
|
+
}));
|
|
68
|
+
await mock.module('../../../button/public', () => ({
|
|
69
|
+
IconButton: ({
|
|
70
|
+
disabled,
|
|
71
|
+
label,
|
|
72
|
+
onPress,
|
|
73
|
+
}: {
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
label: string;
|
|
76
|
+
onPress?: () => void;
|
|
77
|
+
}) => (
|
|
78
|
+
<button aria-label={label} disabled={disabled} onClick={onPress}>
|
|
79
|
+
{label}
|
|
80
|
+
</button>
|
|
81
|
+
),
|
|
82
|
+
}));
|
|
83
|
+
await mock.module('../../../image/public', () => ({
|
|
84
|
+
Image: ({ source }: { source?: string }) => <img alt="" src={source} />,
|
|
85
|
+
}));
|
|
86
|
+
await mock.module('../../../layout/public', () => ({
|
|
87
|
+
View: ({ children, testID }: { children?: React.ReactNode; testID?: string }) => (
|
|
88
|
+
<div data-testid={testID}>{children}</div>
|
|
89
|
+
),
|
|
90
|
+
}));
|
|
91
|
+
await mock.module('../../../theme/adapters/inbound/withZoraThemeScope', () => ({
|
|
92
|
+
withZoraThemeScope: <P,>(Component: React.ComponentType<P>) => Component,
|
|
93
|
+
}));
|
|
94
|
+
await mock.module('../../../theme/composition/useZoraTheme', () => ({
|
|
95
|
+
useZoraTheme: () => ({
|
|
96
|
+
theme: {
|
|
97
|
+
semantics: {
|
|
98
|
+
action: { primary: { base: '#123456' } },
|
|
99
|
+
neutral: { divider: '#999999', surface: '#eeeeee' },
|
|
100
|
+
surface: { raised: '#ffffff' },
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
}));
|
|
105
|
+
await mock.module('../../../typography/public', () => ({
|
|
106
|
+
Text: ({ children }: { children?: React.ReactNode }) => <span>{children}</span>,
|
|
107
|
+
}));
|
|
108
|
+
|
|
109
|
+
const { Video } = await import('./Video');
|
|
110
|
+
const { Video: WebVideo } = await import('./Video.web');
|
|
111
|
+
|
|
112
|
+
afterAll(() => {
|
|
113
|
+
browser.close();
|
|
114
|
+
for (const [key, descriptor] of previousGlobals) {
|
|
115
|
+
if (descriptor) Object.defineProperty(globalThis, key, descriptor);
|
|
116
|
+
else Reflect.deleteProperty(globalThis, key);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('renders themed playback controls and delegates transport to expo-video', async () => {
|
|
121
|
+
const host = document.createElement('div');
|
|
122
|
+
document.body.append(host);
|
|
123
|
+
const root = createRoot(host);
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
await act(() =>
|
|
127
|
+
Promise.resolve().then(() => root.render(<Video source="https://example.test/video.mp4" />)),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
expect(player.timeUpdateEventInterval).toBe(0.25);
|
|
131
|
+
expect(host.textContent).toContain('0:15 / 2:00');
|
|
132
|
+
expect(host.querySelector('[data-testid="expo-video"]')).not.toBeNull();
|
|
133
|
+
|
|
134
|
+
host.querySelector<HTMLButtonElement>('[aria-label="Play video"]')?.click();
|
|
135
|
+
host.querySelector<HTMLButtonElement>('[aria-label="Seek back 10 seconds"]')?.click();
|
|
136
|
+
host.querySelector<HTMLButtonElement>('[aria-label="Seek forward 10 seconds"]')?.click();
|
|
137
|
+
host.querySelector<HTMLButtonElement>('[aria-label="Lower volume"]')?.click();
|
|
138
|
+
host.querySelector<HTMLButtonElement>('[aria-label="Enter fullscreen Video player"]')?.click();
|
|
139
|
+
|
|
140
|
+
expect(calls.play).toBe(1);
|
|
141
|
+
expect(calls.seeks).toEqual([-10, 10]);
|
|
142
|
+
expect(player.volume).toBeCloseTo(0.9);
|
|
143
|
+
expect(calls.fullscreen).toBe(1);
|
|
144
|
+
} finally {
|
|
145
|
+
await act(() => Promise.resolve().then(() => root.unmount()));
|
|
146
|
+
host.remove();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('keeps playback controls passive after the web adapter loads the video implementation', async () => {
|
|
151
|
+
const host = document.createElement('div');
|
|
152
|
+
document.body.append(host);
|
|
153
|
+
const root = createRoot(host);
|
|
154
|
+
const initialCalls = { ...calls, seeks: [...calls.seeks] };
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
await act(() =>
|
|
158
|
+
Promise.resolve().then(() =>
|
|
159
|
+
root.render(
|
|
160
|
+
<WebVideo interactionPolicy="passive" source="https://example.test/video.mp4" />,
|
|
161
|
+
),
|
|
162
|
+
),
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
await act(() => Promise.resolve());
|
|
166
|
+
|
|
167
|
+
const controls = [
|
|
168
|
+
'Seek video',
|
|
169
|
+
'Seek back 10 seconds',
|
|
170
|
+
'Play video',
|
|
171
|
+
'Seek forward 10 seconds',
|
|
172
|
+
'Lower volume',
|
|
173
|
+
'Raise volume',
|
|
174
|
+
'Enter fullscreen Video player',
|
|
175
|
+
];
|
|
176
|
+
const buttons = controls.map((label) =>
|
|
177
|
+
host.querySelector<HTMLButtonElement>(`[aria-label="${label}"]`),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
expect(buttons.every((button) => button?.disabled === true)).toBe(true);
|
|
181
|
+
for (const button of buttons) button?.click();
|
|
182
|
+
|
|
183
|
+
expect(calls).toEqual(initialCalls);
|
|
184
|
+
} finally {
|
|
185
|
+
await act(() => Promise.resolve().then(() => root.unmount()));
|
|
186
|
+
host.remove();
|
|
187
|
+
}
|
|
188
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Video } from './Video.native';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { VideoProps } from '../../../../types/video';
|
|
4
|
+
import { Image } from '../../../image/public';
|
|
5
|
+
import { View } from '../../../layout/public';
|
|
6
|
+
import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope';
|
|
7
|
+
import { useZoraTheme } from '../../../theme/composition/useZoraTheme';
|
|
8
|
+
|
|
9
|
+
/*** Defers Expo Video's browser runtime until after hydration while preserving a themed poster shell. */
|
|
10
|
+
export const Video = withZoraThemeScope(VideoWebInner);
|
|
11
|
+
|
|
12
|
+
/*** Renders the SSR-safe video poster, then loads the Expo-backed adapter in a browser runtime. */
|
|
13
|
+
function VideoWebInner({
|
|
14
|
+
themeId: _themeId,
|
|
15
|
+
mode: _mode,
|
|
16
|
+
interactionPolicy,
|
|
17
|
+
poster,
|
|
18
|
+
aspectRatio = 16 / 9,
|
|
19
|
+
contentFit = 'contain',
|
|
20
|
+
...props
|
|
21
|
+
}: VideoProps) {
|
|
22
|
+
const { theme } = useZoraTheme();
|
|
23
|
+
const [NativeVideo, setNativeVideo] = React.useState<React.ComponentType<VideoProps> | null>(
|
|
24
|
+
null,
|
|
25
|
+
);
|
|
26
|
+
const safeAspectRatio = Number.isFinite(aspectRatio) && aspectRatio > 0 ? aspectRatio : 16 / 9;
|
|
27
|
+
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
let active = true;
|
|
30
|
+
void import('./Video.native').then(({ Video: LoadedVideo }) => {
|
|
31
|
+
if (active) setNativeVideo(() => LoadedVideo);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
active = false;
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
if (NativeVideo) {
|
|
40
|
+
return (
|
|
41
|
+
<NativeVideo
|
|
42
|
+
{...props}
|
|
43
|
+
aspectRatio={safeAspectRatio}
|
|
44
|
+
contentFit={contentFit}
|
|
45
|
+
interactionPolicy={interactionPolicy}
|
|
46
|
+
poster={poster}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<View
|
|
53
|
+
bg={theme.semantics.neutral.surface}
|
|
54
|
+
borderColor={theme.semantics.neutral.divider}
|
|
55
|
+
borderWidth={1}
|
|
56
|
+
overflow="hidden"
|
|
57
|
+
radius="m"
|
|
58
|
+
style={{ aspectRatio: safeAspectRatio }}
|
|
59
|
+
>
|
|
60
|
+
{poster ? (
|
|
61
|
+
<Image
|
|
62
|
+
alt=""
|
|
63
|
+
aspectRatio={safeAspectRatio}
|
|
64
|
+
fit={contentFit === 'fill' ? 'stretch' : contentFit}
|
|
65
|
+
source={poster}
|
|
66
|
+
/>
|
|
67
|
+
) : null}
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ZoraComponentMeta } from '../../types/authoring';
|
|
2
|
+
|
|
3
|
+
export const videoMeta = {
|
|
4
|
+
name: 'Video',
|
|
5
|
+
category: 'component',
|
|
6
|
+
description: 'Plays an authored video with themed transport controls.',
|
|
7
|
+
directManifestNode: true,
|
|
8
|
+
allowedChildren: [],
|
|
9
|
+
blueprint: {
|
|
10
|
+
label: 'Video',
|
|
11
|
+
defaultProps: { aspectRatio: 16 / 9, contentFit: 'contain', volume: 1 },
|
|
12
|
+
},
|
|
13
|
+
props: {
|
|
14
|
+
source: {
|
|
15
|
+
type: 'media',
|
|
16
|
+
category: 'Content',
|
|
17
|
+
label: 'Video source',
|
|
18
|
+
mediaKinds: ['video'],
|
|
19
|
+
authoring: { authority: 'instance' },
|
|
20
|
+
},
|
|
21
|
+
poster: {
|
|
22
|
+
type: 'media',
|
|
23
|
+
category: 'Content',
|
|
24
|
+
label: 'Poster image',
|
|
25
|
+
mediaKinds: ['image'],
|
|
26
|
+
authoring: { authority: 'instance' },
|
|
27
|
+
},
|
|
28
|
+
aspectRatio: {
|
|
29
|
+
type: 'number',
|
|
30
|
+
category: 'Layout',
|
|
31
|
+
label: 'Aspect ratio',
|
|
32
|
+
default: 16 / 9,
|
|
33
|
+
authoring: { authority: 'instance' },
|
|
34
|
+
},
|
|
35
|
+
contentFit: {
|
|
36
|
+
type: 'enum',
|
|
37
|
+
category: 'Layout',
|
|
38
|
+
label: 'Content fit',
|
|
39
|
+
enum: ['contain', 'cover', 'fill'],
|
|
40
|
+
default: 'contain',
|
|
41
|
+
authoring: { authority: 'instance' },
|
|
42
|
+
},
|
|
43
|
+
volume: {
|
|
44
|
+
type: 'number',
|
|
45
|
+
category: 'Playback',
|
|
46
|
+
label: 'Volume',
|
|
47
|
+
default: 1,
|
|
48
|
+
authoring: { authority: 'instance' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
} as const satisfies ZoraComponentMeta;
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,8 @@ export {
|
|
|
14
14
|
AuthoringSelectionAdapter,
|
|
15
15
|
ThemeEditorAdapter,
|
|
16
16
|
} from './authoring';
|
|
17
|
+
export type { AudioManifestProps, AudioProps, AudioResolvedSource } from './features/audio/public';
|
|
18
|
+
export { Audio } from './features/audio/public';
|
|
17
19
|
export type { CarouselProps, CarouselSlide, CarouselTransition } from './features/carousel/public';
|
|
18
20
|
export { Carousel } from './features/carousel/public';
|
|
19
21
|
export type {
|
package/src/readerFree.ts
CHANGED
|
@@ -14,6 +14,12 @@ export {
|
|
|
14
14
|
export type { AppBarMode, AppBarOverflowMenu, AppBarProps } from './features/app-bar/public';
|
|
15
15
|
export { AppBar } from './features/app-bar/public';
|
|
16
16
|
export { AppHeader, type AppHeaderProps } from './features/app-header/public';
|
|
17
|
+
export {
|
|
18
|
+
Audio,
|
|
19
|
+
type AudioManifestProps,
|
|
20
|
+
type AudioProps,
|
|
21
|
+
type AudioResolvedSource,
|
|
22
|
+
} from './features/audio/public';
|
|
17
23
|
export type {
|
|
18
24
|
AuthFormBaseProps,
|
|
19
25
|
AuthIdentifierKind,
|
|
@@ -331,6 +337,8 @@ export type {
|
|
|
331
337
|
ViewProps,
|
|
332
338
|
} from './features/layout/public';
|
|
333
339
|
export { AppShell, Divider, Grid, Screen, ScrollView, View } from './features/layout/public';
|
|
340
|
+
export type { LinkPressEvent, LinkProps, LinkTarget } from './features/link/public';
|
|
341
|
+
export { Link } from './features/link/public';
|
|
334
342
|
export type {
|
|
335
343
|
ManifestListProps,
|
|
336
344
|
ManifestListSection,
|
|
@@ -568,4 +576,11 @@ export type {
|
|
|
568
576
|
ValidateUploadAssetInput,
|
|
569
577
|
} from './features/uploader/public';
|
|
570
578
|
export { Uploader, validateUploadAsset } from './features/uploader/public';
|
|
579
|
+
export type {
|
|
580
|
+
VideoContentFit,
|
|
581
|
+
VideoManifestProps,
|
|
582
|
+
VideoProps,
|
|
583
|
+
VideoResolvedSource,
|
|
584
|
+
} from './features/video/public';
|
|
585
|
+
export { Video } from './features/video/public';
|
|
571
586
|
export type { ZoraComponentRegistry } from './types/registry';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MediaAssetReference } from '@ankhorage/contracts';
|
|
2
|
+
|
|
3
|
+
import type { ZoraBaseProps } from './base';
|
|
4
|
+
|
|
5
|
+
/** A runtime-resolved single audio source supported by the Expo audio adapter. */
|
|
6
|
+
export type AudioResolvedSource = string | number | { readonly uri: string };
|
|
7
|
+
|
|
8
|
+
/** Portable Audio props accepted by an AppManifest node. */
|
|
9
|
+
export interface AudioManifestProps {
|
|
10
|
+
readonly source: MediaAssetReference;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Props for ZORA's themed single-source Audio playback control. */
|
|
14
|
+
export interface AudioProps extends ZoraBaseProps {
|
|
15
|
+
readonly source: AudioResolvedSource | null;
|
|
16
|
+
}
|