@ankhorage/zora 28.2.0 → 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 +11 -0
- package/README.md +1 -1
- package/dist/capabilities/index.js +76 -2
- package/dist/capabilities/index.js.map +7 -5
- package/dist/constants/authoring.d.ts +5 -3
- package/dist/constants/authoring.d.ts.map +1 -1
- package/dist/constants/authoring.js +4 -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/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 +4 -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 +4 -0
- package/dist/features/registry/componentMeta.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 +3 -0
- package/dist/readerFree.d.ts.map +1 -1
- package/dist/readerFree.js +2 -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/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 +7 -3
- package/src/constants/authoring.ts +4 -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/registry/ZORA_BASE_COMPONENT_REGISTRY.ts +4 -0
- package/src/features/registry/componentMeta.test.ts +16 -0
- package/src/features/registry/componentMeta.ts +4 -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 +13 -0
- package/src/types/audio.ts +16 -0
- package/src/types/video.ts +28 -0
- package/web-dist/chunks/{Accordion-4v920xz8.js → Accordion-01bsg7zt.js} +1 -1
- package/web-dist/chunks/{Accordion-pvfmhrm0.js → Accordion-17s33h1a.js} +1 -1
- package/web-dist/chunks/{Accordion-vyw2bzye.js → Accordion-2wggrer7.js} +2 -2
- package/web-dist/chunks/{Accordion-bjq32vq2.js → Accordion-2xb252py.js} +3 -3
- package/web-dist/chunks/{Accordion-kr1reyt9.js → Accordion-2xkxthf1.js} +7 -7
- package/web-dist/chunks/{Accordion-fc058wqp.js → Accordion-2ys50fc8.js} +1 -1
- package/web-dist/chunks/{Accordion-7zhdzn00.js → Accordion-379mgrse.js} +1 -1
- package/web-dist/chunks/{Accordion-xeyw6ndr.js → Accordion-38xvj0cq.js} +4 -4
- package/web-dist/chunks/{Accordion-8gfgaq01.js → Accordion-4zb6dcys.js} +1 -1
- package/web-dist/chunks/{Accordion-nrwc0rx2.js → Accordion-5mga7hty.js} +1 -1
- package/web-dist/chunks/{Accordion-3qvtv4g6.js → Accordion-5qz4j8tt.js} +6 -6
- package/web-dist/chunks/{Accordion-4zbh7wfn.js → Accordion-5rwztz14.js} +1 -1
- package/web-dist/chunks/{Accordion-frfh3nz6.js → Accordion-9qg7cjt8.js} +2 -2
- package/web-dist/chunks/{Accordion-g07r4t2f.js → Accordion-a1mgdfg7.js} +1 -1
- package/web-dist/chunks/{Accordion-dcm6ywt2.js → Accordion-axe7nsht.js} +1 -1
- package/web-dist/chunks/{Accordion-e2b9yja2.js → Accordion-bd9vzpbz.js} +6 -6
- package/web-dist/chunks/{Accordion-csz7sgjm.js → Accordion-bp9y7738.js} +6 -6
- package/web-dist/chunks/{Accordion-64w34bgd.js → Accordion-bzgy9sg3.js} +2 -2
- package/web-dist/chunks/{Accordion-r30bwg03.js → Accordion-e0vm82xr.js} +2 -2
- package/web-dist/chunks/{Accordion-em4ktbkk.js → Accordion-f1vargnk.js} +4 -4
- package/web-dist/chunks/{Accordion-k6v7p2na.js → Accordion-f8a49gy8.js} +1 -1
- package/web-dist/chunks/{Accordion-g5c5sqn7.js → Accordion-f8zpd80k.js} +4 -4
- package/web-dist/chunks/{Accordion-22z6y8kw.js → Accordion-gnbt6w4q.js} +3 -3
- package/web-dist/chunks/{Accordion-s1qjbbb0.js → Accordion-hdyzyw8q.js} +1 -1
- package/web-dist/chunks/{Accordion-q0cbpr2d.js → Accordion-htm3j8r8.js} +4 -4
- package/web-dist/chunks/{Accordion-mh3bhcb4.js → Accordion-kdb9g5b1.js} +3 -3
- package/web-dist/chunks/{Accordion-zsd0ar2p.js → Accordion-nmpzv3b0.js} +3 -3
- package/web-dist/chunks/{Accordion-b8ncebyz.js → Accordion-pdjhezmz.js} +1 -1
- package/web-dist/chunks/{Accordion-zqa9mt13.js → Accordion-q683s6kd.js} +2 -2
- package/web-dist/chunks/{Accordion-30284ah1.js → Accordion-r75ep5pg.js} +4 -4
- package/web-dist/chunks/{Accordion-rmakadh6.js → Accordion-rq311z1k.js} +4 -4
- package/web-dist/chunks/{Accordion-w28mb1ed.js → Accordion-rtamzg9j.js} +1 -1
- package/web-dist/chunks/{Accordion-nv1evygk.js → Accordion-sh79sr5g.js} +1 -1
- package/web-dist/chunks/{Accordion-t93g1wq3.js → Accordion-t9n4ey2r.js} +1 -1
- package/web-dist/chunks/{Accordion-zanzeryt.js → Accordion-tqagt6cz.js} +1 -1
- package/web-dist/chunks/{Accordion-0n3y5ry1.js → Accordion-v6vhyv31.js} +1 -1
- package/web-dist/chunks/{Accordion-6pkteb8k.js → Accordion-vb52sts9.js} +3 -3
- package/web-dist/chunks/{Accordion-rwjbwm18.js → Accordion-vkqqktc5.js} +1 -1
- package/web-dist/chunks/{Accordion-9zwdqhf2.js → Accordion-za0jcjgn.js} +2 -2
- 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 +3 -3
- package/web-dist/components/accordion-item/AccordionItem.js +3 -3
- package/web-dist/components/app-bar/AppBar.js +7 -7
- package/web-dist/components/app-header/AppHeader.js +7 -7
- package/web-dist/components/app-shell/AppShell.js +2 -2
- 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 +11 -11
- package/web-dist/components/avatar/Avatar.js +3 -3
- package/web-dist/components/avatar-group/AvatarGroup.js +3 -3
- package/web-dist/components/badge/Badge.js +2 -2
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +10 -10
- package/web-dist/components/bottom-sheet/BottomSheet.js +4 -4
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +4 -4
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +4 -4
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +4 -4
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +4 -4
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +4 -4
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +4 -4
- package/web-dist/components/button/Button.js +4 -4
- package/web-dist/components/button-group/ButtonGroup.js +4 -4
- package/web-dist/components/calendar/Calendar.js +5 -5
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +10 -10
- package/web-dist/components/card/Card.js +9 -9
- package/web-dist/components/chat-list-item/ChatListItem.js +6 -6
- package/web-dist/components/checkbox/Checkbox.js +4 -4
- package/web-dist/components/checkbox-group/CheckboxGroup.js +4 -4
- package/web-dist/components/chip/Chip.js +4 -4
- package/web-dist/components/chip-group/ChipGroup.js +4 -4
- package/web-dist/components/collection-editor/CollectionEditor.js +9 -9
- package/web-dist/components/color-hue-scale/ColorHueScale.js +14 -14
- package/web-dist/components/color-picker/ColorPicker.js +14 -14
- package/web-dist/components/color-tone/ColorTone.js +14 -14
- package/web-dist/components/color-wheel/ColorWheel.js +14 -14
- package/web-dist/components/content-rail/ContentRail.js +4 -4
- package/web-dist/components/data-table/DataTable.js +15 -15
- package/web-dist/components/date-picker/DatePicker.js +9 -9
- package/web-dist/components/dialog/Dialog.js +4 -4
- package/web-dist/components/divider/Divider.js +2 -2
- package/web-dist/components/empty-state/EmptyState.js +10 -10
- package/web-dist/components/explorer/Explorer.js +4 -4
- package/web-dist/components/field/Field.js +4 -4
- package/web-dist/components/file-explorer/FileExplorer.js +4 -4
- package/web-dist/components/flat-list/FlatList.js +5 -5
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +11 -11
- package/web-dist/components/form/Form.js +7 -7
- package/web-dist/components/form-actions/FormActions.js +7 -7
- package/web-dist/components/form-error/FormError.js +7 -7
- package/web-dist/components/game/Game.js +3 -3
- package/web-dist/components/game-entity/GameEntity.js +3 -3
- package/web-dist/components/game-field/GameField.js +3 -3
- package/web-dist/components/game-input-zone/GameInputZone.js +3 -3
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +3 -3
- package/web-dist/components/game-overlay/GameOverlay.js +3 -3
- package/web-dist/components/gradient/Gradient.js +3 -3
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +3 -3
- package/web-dist/components/grid/Grid.js +2 -2
- package/web-dist/components/hero/Hero.js +9 -9
- package/web-dist/components/icon-button/IconButton.js +4 -4
- package/web-dist/components/image/Image.js +3 -3
- package/web-dist/components/list/List.js +5 -5
- package/web-dist/components/list-item/ListItem.js +5 -5
- package/web-dist/components/list-section/ListSection.js +5 -5
- package/web-dist/components/master-detail/MasterDetail.js +2 -2
- package/web-dist/components/media-card/MediaCard.js +9 -9
- package/web-dist/components/media-explorer/MediaExplorer.js +4 -4
- package/web-dist/components/message-bubble/MessageBubble.js +6 -6
- package/web-dist/components/metric-card/MetricCard.js +9 -9
- package/web-dist/components/missing-element/MissingElement.js +3 -3
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +11 -11
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +11 -11
- package/web-dist/components/otp-form/OtpForm.js +11 -11
- package/web-dist/components/pagination/Pagination.js +4 -4
- package/web-dist/components/palette-item/PaletteItem.js +9 -9
- package/web-dist/components/popover-menu/PopoverMenu.js +4 -4
- package/web-dist/components/post-card/PostCard.js +9 -9
- package/web-dist/components/product-card/ProductCard.js +9 -9
- package/web-dist/components/progress/Progress.js +3 -3
- package/web-dist/components/progress-ring/ProgressRing.js +3 -3
- package/web-dist/components/radio/Radio.js +4 -4
- package/web-dist/components/radio-group/RadioGroup.js +4 -4
- package/web-dist/components/rating/Rating.js +2 -2
- package/web-dist/components/reader/Reader.js +10 -10
- package/web-dist/components/scan-overlay/ScanOverlay.js +10 -10
- package/web-dist/components/screen/Screen.js +2 -2
- package/web-dist/components/screen-section/ScreenSection.js +3 -3
- package/web-dist/components/scroll-view/ScrollView.js +2 -2
- package/web-dist/components/search-input/SearchInput.js +5 -5
- package/web-dist/components/section-header/SectionHeader.js +3 -3
- package/web-dist/components/section-list/SectionList.js +5 -5
- package/web-dist/components/select/Select.js +9 -9
- package/web-dist/components/sign-in-form/SignInForm.js +11 -11
- package/web-dist/components/sign-up-form/SignUpForm.js +11 -11
- package/web-dist/components/skeleton/Skeleton.js +12 -12
- package/web-dist/components/skeleton-card/SkeletonCard.js +12 -12
- package/web-dist/components/skeleton-list/SkeletonList.js +12 -12
- package/web-dist/components/skeleton-text/SkeletonText.js +12 -12
- package/web-dist/components/surface/Surface.js +3 -3
- package/web-dist/components/switch/Switch.js +2 -2
- package/web-dist/components/tab/Tab.js +2 -2
- package/web-dist/components/tab-list/TabList.js +2 -2
- package/web-dist/components/tab-panel/TabPanel.js +2 -2
- package/web-dist/components/tabs/Tabs.js +2 -2
- package/web-dist/components/text-input/TextInput.js +5 -5
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +4 -4
- package/web-dist/components/time-picker/TimePicker.js +8 -8
- package/web-dist/components/timeline/Timeline.js +3 -3
- package/web-dist/components/toast/Toast.js +4 -4
- package/web-dist/components/toast-provider/ToastProvider.js +4 -4
- package/web-dist/components/toolbar/Toolbar.js +9 -9
- package/web-dist/components/tree-item/TreeItem.js +6 -6
- package/web-dist/components/uploader/Uploader.js +12 -12
- 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/components/view/View.js +2 -2
- package/web-dist/manifest.json +753 -675
- package/web-dist/runtime/ZoraProvider.js +3 -3
- /package/web-dist/chunks/{Accordion-5kaxyqy1.js → Accordion-ww4f12ty.js} +0 -0
|
@@ -240,6 +240,7 @@ describe('ZORA_COMPONENT_META invariants', () => {
|
|
|
240
240
|
test('direct manifest node leaf/container rules', () => {
|
|
241
241
|
const expectedLeafNodes = new Set([
|
|
242
242
|
'ActivityIndicator',
|
|
243
|
+
'Audio',
|
|
243
244
|
'AuthScreen',
|
|
244
245
|
'ForgotPasswordForm',
|
|
245
246
|
'OAuthProviderButton',
|
|
@@ -303,6 +304,7 @@ describe('ZORA_COMPONENT_META invariants', () => {
|
|
|
303
304
|
'PokerTrainingTable',
|
|
304
305
|
'Timeline',
|
|
305
306
|
'Link',
|
|
307
|
+
'Video',
|
|
306
308
|
]);
|
|
307
309
|
|
|
308
310
|
const expectedContainerNodes = new Set([
|
|
@@ -458,6 +460,20 @@ describe('ZORA_COMPONENT_META invariants', () => {
|
|
|
458
460
|
expect(ZORA_COMPONENT_META.Image.props.alt?.authoring).toEqual({ authority: 'instance' });
|
|
459
461
|
});
|
|
460
462
|
|
|
463
|
+
test('Video is a direct manifest leaf with canonical video and poster media metadata', () => {
|
|
464
|
+
expect(ZORA_COMPONENT_META.Video.directManifestNode).toBe(true);
|
|
465
|
+
expect(ZORA_COMPONENT_META.Video.allowedChildren).toEqual([]);
|
|
466
|
+
expect(ZORA_COMPONENT_META.Video.props.source).toMatchObject({
|
|
467
|
+
type: 'media',
|
|
468
|
+
mediaKinds: ['video'],
|
|
469
|
+
});
|
|
470
|
+
expect(ZORA_COMPONENT_META.Video.props.poster).toMatchObject({
|
|
471
|
+
type: 'media',
|
|
472
|
+
mediaKinds: ['image'],
|
|
473
|
+
});
|
|
474
|
+
expect(ZORA_COMPONENT_META.Video.props.aspectRatio?.default).toBe(16 / 9);
|
|
475
|
+
});
|
|
476
|
+
|
|
461
477
|
test('RadioGroup is a direct manifest leaf with card presentation and normalized value events', () => {
|
|
462
478
|
const radioGroup = ZORA_COMPONENT_META.RadioGroup;
|
|
463
479
|
|
|
@@ -4,6 +4,7 @@ import { accordionMeta } from '../accordion/accordionMeta';
|
|
|
4
4
|
import { activityIndicatorMeta } from '../activity-indicator/activityIndicatorMeta';
|
|
5
5
|
import { appBarMeta } from '../app-bar/appBarMeta';
|
|
6
6
|
import { appHeaderMeta } from '../app-header/appHeaderMeta';
|
|
7
|
+
import { audioMeta } from '../audio/audioMeta';
|
|
7
8
|
import { authScreenMeta } from '../auth/authScreenMeta';
|
|
8
9
|
import { forgotPasswordFormMeta } from '../auth/forgotPasswordFormMeta';
|
|
9
10
|
import { oauthProviderButtonMeta } from '../auth/oauthProviderButtonMeta';
|
|
@@ -114,12 +115,14 @@ import { treeItemMeta, treeViewMeta } from '../tree-view/meta';
|
|
|
114
115
|
import { headingMeta } from '../typography/headingMeta';
|
|
115
116
|
import { textMeta } from '../typography/textMeta';
|
|
116
117
|
import { uploaderMeta } from '../uploader/uploaderMeta';
|
|
118
|
+
import { videoMeta } from '../video/videoMeta';
|
|
117
119
|
import { finalizeFeatureMetadata } from './finalizeFeatureMetadata';
|
|
118
120
|
|
|
119
121
|
export const ZORA_COMPONENT_META: ZoraComponentMetaRegistry = finalizeFeatureMetadata({
|
|
120
122
|
Accordion: accordionMeta,
|
|
121
123
|
AccordionItem: accordionItemMeta,
|
|
122
124
|
ActivityIndicator: activityIndicatorMeta,
|
|
125
|
+
Audio: audioMeta,
|
|
123
126
|
View: viewMeta,
|
|
124
127
|
ScrollView: scrollViewMeta,
|
|
125
128
|
Grid: gridMeta,
|
|
@@ -187,6 +190,7 @@ export const ZORA_COMPONENT_META: ZoraComponentMetaRegistry = finalizeFeatureMet
|
|
|
187
190
|
ToastProvider: toastProviderMeta,
|
|
188
191
|
Toolbar: toolbarMeta,
|
|
189
192
|
Uploader: uploaderMeta,
|
|
193
|
+
Video: videoMeta,
|
|
190
194
|
BottomSheet: bottomSheetMeta,
|
|
191
195
|
FlatList: flatListMeta,
|
|
192
196
|
SectionList: sectionListMeta,
|
|
@@ -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 {
|