@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,1807 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
require_registry,
|
|
4
|
+
Platform_default,
|
|
5
|
+
init_src
|
|
6
|
+
} from "./Accordion-f1vargnk.js";
|
|
7
|
+
import {
|
|
8
|
+
require_cjs
|
|
9
|
+
} from "./Accordion-xgpzh4wq.js";
|
|
10
|
+
import {
|
|
11
|
+
__toESM,
|
|
12
|
+
__esm
|
|
13
|
+
} from "./Accordion-nh0cs9hq.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/expo-asset/build/AssetSourceResolver.js
|
|
16
|
+
function getScaledAssetPath(asset) {
|
|
17
|
+
const scale = AssetSourceResolver.pickScale(asset.scales, import_react_native.PixelRatio.get());
|
|
18
|
+
const scaleSuffix = scale === 1 ? "" : "@" + scale + "x";
|
|
19
|
+
const type = !asset.type ? "" : `.${asset.type}`;
|
|
20
|
+
if (__DEV__) {
|
|
21
|
+
return asset.httpServerLocation + "/" + asset.name + scaleSuffix + type;
|
|
22
|
+
} else {
|
|
23
|
+
return asset.httpServerLocation.replace(/\.\.\//g, "_") + "/" + asset.name + scaleSuffix + type;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class AssetSourceResolver {
|
|
28
|
+
serverUrl;
|
|
29
|
+
jsbundleUrl;
|
|
30
|
+
asset;
|
|
31
|
+
constructor(serverUrl, jsbundleUrl, asset) {
|
|
32
|
+
this.serverUrl = serverUrl || "https://expo.dev";
|
|
33
|
+
this.jsbundleUrl = null;
|
|
34
|
+
this.asset = asset;
|
|
35
|
+
}
|
|
36
|
+
isLoadedFromServer() {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
isLoadedFromFileSystem() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
defaultAsset() {
|
|
43
|
+
return this.assetServerURL();
|
|
44
|
+
}
|
|
45
|
+
assetServerURL() {
|
|
46
|
+
const fromUrl = new URL(getScaledAssetPath(this.asset), this.serverUrl);
|
|
47
|
+
fromUrl.searchParams.set("platform", Platform_default.OS);
|
|
48
|
+
fromUrl.searchParams.set("hash", this.asset.hash);
|
|
49
|
+
return this.fromSource(fromUrl.toString().replace(fromUrl.origin, ""));
|
|
50
|
+
}
|
|
51
|
+
fromSource(source) {
|
|
52
|
+
return {
|
|
53
|
+
__packager_asset: true,
|
|
54
|
+
width: this.asset.width ?? undefined,
|
|
55
|
+
height: this.asset.height ?? undefined,
|
|
56
|
+
uri: source,
|
|
57
|
+
scale: AssetSourceResolver.pickScale(this.asset.scales, import_react_native.PixelRatio.get())
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
static pickScale(scales, deviceScale) {
|
|
61
|
+
for (const scale of scales) {
|
|
62
|
+
if (scale >= deviceScale) {
|
|
63
|
+
return scale;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return scales[scales.length - 1] || 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
var import_react_native;
|
|
70
|
+
var init_AssetSourceResolver = __esm(() => {
|
|
71
|
+
init_src();
|
|
72
|
+
import_react_native = __toESM(require_cjs());
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// node_modules/expo-asset/build/PlatformUtils.web.js
|
|
76
|
+
function getManifest2() {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
var IS_ENV_WITH_LOCAL_ASSETS = false, manifestBaseUrl = null;
|
|
80
|
+
var init_PlatformUtils_web = () => {};
|
|
81
|
+
|
|
82
|
+
// node_modules/expo-asset/build/AssetSources.js
|
|
83
|
+
function selectAssetSource(meta) {
|
|
84
|
+
const scale = AssetSourceResolver.pickScale(meta.scales, import_react_native2.PixelRatio.get());
|
|
85
|
+
const index = meta.scales.findIndex((s) => s === scale);
|
|
86
|
+
const hash = meta.fileHashes?.[index] ?? meta.fileHashes?.[0] ?? meta.hash;
|
|
87
|
+
const uri = meta.fileUris ? meta.fileUris[index] ?? meta.fileUris[0] : meta.uri;
|
|
88
|
+
if (uri) {
|
|
89
|
+
return { uri: resolveUri(uri), hash };
|
|
90
|
+
}
|
|
91
|
+
const fileScale = scale === 1 ? "" : `@${scale}x`;
|
|
92
|
+
const fileExtension = meta.type ? `.${encodeURIComponent(meta.type)}` : "";
|
|
93
|
+
const suffix = `/${encodeURIComponent(meta.name)}${fileScale}${fileExtension}`;
|
|
94
|
+
const params = new URLSearchParams({
|
|
95
|
+
platform: Platform_default.OS,
|
|
96
|
+
hash: meta.hash
|
|
97
|
+
});
|
|
98
|
+
if (/^https?:\/\//.test(meta.httpServerLocation)) {
|
|
99
|
+
const uri = meta.httpServerLocation + suffix + "?" + params;
|
|
100
|
+
return { uri, hash };
|
|
101
|
+
}
|
|
102
|
+
const manifest2 = getManifest2();
|
|
103
|
+
const scheme = manifestBaseUrl?.startsWith("https://") ? "https://" : "http://";
|
|
104
|
+
const devServerUrl = manifest2?.extra?.expoGo?.developer ? scheme + manifest2.extra.expoGo.debuggerHost : null;
|
|
105
|
+
if (devServerUrl) {
|
|
106
|
+
const baseUrl = new URL(meta.httpServerLocation + suffix, devServerUrl);
|
|
107
|
+
baseUrl.searchParams.set("platform", Platform_default.OS);
|
|
108
|
+
baseUrl.searchParams.set("hash", meta.hash);
|
|
109
|
+
return {
|
|
110
|
+
uri: baseUrl.href,
|
|
111
|
+
hash
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (import_react_native2.NativeModules["ExponentKernel"]) {
|
|
115
|
+
return { uri: `https://classic-assets.eascdn.net/~assets/${encodeURIComponent(hash)}`, hash };
|
|
116
|
+
}
|
|
117
|
+
return { uri: "", hash };
|
|
118
|
+
}
|
|
119
|
+
function resolveUri(uri) {
|
|
120
|
+
return manifestBaseUrl ? new URL(uri, manifestBaseUrl).href : uri;
|
|
121
|
+
}
|
|
122
|
+
var import_react_native2;
|
|
123
|
+
var init_AssetSources = __esm(() => {
|
|
124
|
+
init_src();
|
|
125
|
+
init_AssetSourceResolver();
|
|
126
|
+
init_PlatformUtils_web();
|
|
127
|
+
import_react_native2 = __toESM(require_cjs());
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// node_modules/expo-asset/build/AssetUris.js
|
|
131
|
+
function getFilename(url) {
|
|
132
|
+
const { pathname, searchParams } = new URL(url, "https://e");
|
|
133
|
+
if (__DEV__) {
|
|
134
|
+
if (searchParams.has("unstable_path")) {
|
|
135
|
+
const encodedFilePath = decodeURIComponent(searchParams.get("unstable_path"));
|
|
136
|
+
return getBasename(encodedFilePath);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return getBasename(pathname);
|
|
140
|
+
}
|
|
141
|
+
function getBasename(pathname) {
|
|
142
|
+
return pathname.substring(pathname.lastIndexOf("/") + 1);
|
|
143
|
+
}
|
|
144
|
+
function getFileExtension(url) {
|
|
145
|
+
const filename = getFilename(url);
|
|
146
|
+
const dotIndex = filename.lastIndexOf(".");
|
|
147
|
+
return dotIndex > 0 ? filename.substring(dotIndex) : "";
|
|
148
|
+
}
|
|
149
|
+
var init_AssetUris = () => {};
|
|
150
|
+
|
|
151
|
+
// node_modules/expo-asset/build/ExpoAsset.web.js
|
|
152
|
+
async function downloadAsync(url, _hash, _type) {
|
|
153
|
+
return url;
|
|
154
|
+
}
|
|
155
|
+
var init_ExpoAsset_web = () => {};
|
|
156
|
+
|
|
157
|
+
// node_modules/expo-asset/build/ImageAssets.js
|
|
158
|
+
function isImageType(type) {
|
|
159
|
+
return /^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(type);
|
|
160
|
+
}
|
|
161
|
+
function getImageInfoAsync(url) {
|
|
162
|
+
if (typeof window === "undefined") {
|
|
163
|
+
return Promise.resolve({ name: getFilename(url), width: 0, height: 0 });
|
|
164
|
+
}
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
166
|
+
const img = new Image;
|
|
167
|
+
img.onerror = reject;
|
|
168
|
+
img.onload = () => {
|
|
169
|
+
resolve({
|
|
170
|
+
name: getFilename(url),
|
|
171
|
+
width: img.naturalWidth,
|
|
172
|
+
height: img.naturalHeight
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
img.src = url;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
var init_ImageAssets = __esm(() => {
|
|
179
|
+
init_AssetUris();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// node_modules/expo-asset/build/LocalAssets.web.js
|
|
183
|
+
function getLocalAssetUri(hash, type) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
var init_LocalAssets_web = () => {};
|
|
187
|
+
|
|
188
|
+
// node_modules/expo-asset/build/resolveAssetSource.js
|
|
189
|
+
function setCustomSourceTransformer(transformer) {
|
|
190
|
+
_customSourceTransformer = transformer;
|
|
191
|
+
}
|
|
192
|
+
function resolveAssetSource(source) {
|
|
193
|
+
if (typeof source === "object") {
|
|
194
|
+
return source;
|
|
195
|
+
}
|
|
196
|
+
const asset = import_registry.getAssetByID(source);
|
|
197
|
+
if (!asset) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const resolver = new AssetSourceResolver("https://expo.dev", null, asset);
|
|
201
|
+
if (_customSourceTransformer) {
|
|
202
|
+
return _customSourceTransformer(resolver);
|
|
203
|
+
}
|
|
204
|
+
return resolver.defaultAsset();
|
|
205
|
+
}
|
|
206
|
+
var import_registry, _customSourceTransformer, resolveAssetSource_default, pickScale;
|
|
207
|
+
var init_resolveAssetSource = __esm(() => {
|
|
208
|
+
init_AssetSourceResolver();
|
|
209
|
+
import_registry = __toESM(require_registry());
|
|
210
|
+
Object.defineProperty(resolveAssetSource, "setCustomSourceTransformer", {
|
|
211
|
+
get() {
|
|
212
|
+
return setCustomSourceTransformer;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
resolveAssetSource_default = resolveAssetSource;
|
|
216
|
+
({ pickScale } = AssetSourceResolver);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// node_modules/expo-asset/build/Asset.js
|
|
220
|
+
var import_registry2, ANDROID_EMBEDDED_URL_BASE_RESOURCE = "file:///android_res/", Asset;
|
|
221
|
+
var init_Asset = __esm(() => {
|
|
222
|
+
init_src();
|
|
223
|
+
init_AssetSources();
|
|
224
|
+
init_AssetUris();
|
|
225
|
+
init_ExpoAsset_web();
|
|
226
|
+
init_ImageAssets();
|
|
227
|
+
init_LocalAssets_web();
|
|
228
|
+
init_PlatformUtils_web();
|
|
229
|
+
init_resolveAssetSource();
|
|
230
|
+
import_registry2 = __toESM(require_registry());
|
|
231
|
+
Asset = class Asset {
|
|
232
|
+
static byHash = {};
|
|
233
|
+
static byUri = {};
|
|
234
|
+
name;
|
|
235
|
+
type;
|
|
236
|
+
hash = null;
|
|
237
|
+
uri;
|
|
238
|
+
localUri = null;
|
|
239
|
+
width = null;
|
|
240
|
+
height = null;
|
|
241
|
+
downloading = false;
|
|
242
|
+
downloaded = false;
|
|
243
|
+
_downloadCallbacks = [];
|
|
244
|
+
constructor({ name, type, hash = null, uri, width, height }) {
|
|
245
|
+
this.name = name;
|
|
246
|
+
this.type = type;
|
|
247
|
+
this.hash = hash;
|
|
248
|
+
this.uri = uri;
|
|
249
|
+
if (typeof width === "number") {
|
|
250
|
+
this.width = width;
|
|
251
|
+
}
|
|
252
|
+
if (typeof height === "number") {
|
|
253
|
+
this.height = height;
|
|
254
|
+
}
|
|
255
|
+
if (hash) {
|
|
256
|
+
this.localUri = getLocalAssetUri(hash, type);
|
|
257
|
+
if (this.localUri?.startsWith(ANDROID_EMBEDDED_URL_BASE_RESOURCE)) {
|
|
258
|
+
this.uri = this.localUri;
|
|
259
|
+
this.localUri = null;
|
|
260
|
+
} else if (this.localUri) {
|
|
261
|
+
this.downloaded = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (Platform_default.OS === "web") {
|
|
265
|
+
if (!name) {
|
|
266
|
+
this.name = getFilename(uri);
|
|
267
|
+
}
|
|
268
|
+
if (!type) {
|
|
269
|
+
this.type = getFileExtension(uri);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
static loadAsync(moduleId) {
|
|
274
|
+
const moduleIds = Array.isArray(moduleId) ? moduleId : [moduleId];
|
|
275
|
+
return Promise.all(moduleIds.map((moduleId) => Asset.fromModule(moduleId).downloadAsync()));
|
|
276
|
+
}
|
|
277
|
+
static fromModule(virtualAssetModule) {
|
|
278
|
+
if (typeof virtualAssetModule === "string") {
|
|
279
|
+
return Asset.fromURI(virtualAssetModule);
|
|
280
|
+
}
|
|
281
|
+
if (typeof virtualAssetModule === "object" && "uri" in virtualAssetModule && typeof virtualAssetModule.uri === "string") {
|
|
282
|
+
const extension = getFileExtension(virtualAssetModule.uri);
|
|
283
|
+
return new Asset({
|
|
284
|
+
name: "",
|
|
285
|
+
type: extension.startsWith(".") ? extension.substring(1) : extension,
|
|
286
|
+
hash: null,
|
|
287
|
+
uri: virtualAssetModule.uri,
|
|
288
|
+
width: virtualAssetModule.width,
|
|
289
|
+
height: virtualAssetModule.height
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const meta = import_registry2.getAssetByID(virtualAssetModule);
|
|
293
|
+
if (!meta) {
|
|
294
|
+
throw new Error(`Module "${virtualAssetModule}" is missing from the asset registry`);
|
|
295
|
+
}
|
|
296
|
+
if (!IS_ENV_WITH_LOCAL_ASSETS) {
|
|
297
|
+
const { uri } = resolveAssetSource_default(virtualAssetModule);
|
|
298
|
+
const asset = new Asset({
|
|
299
|
+
name: meta.name,
|
|
300
|
+
type: meta.type,
|
|
301
|
+
hash: meta.hash,
|
|
302
|
+
uri,
|
|
303
|
+
width: meta.width,
|
|
304
|
+
height: meta.height
|
|
305
|
+
});
|
|
306
|
+
if (Platform_default.OS === "android" && !uri.includes(":") && (meta.width || meta.height)) {
|
|
307
|
+
asset.localUri = asset.uri;
|
|
308
|
+
asset.downloaded = true;
|
|
309
|
+
}
|
|
310
|
+
Asset.byHash[meta.hash] = asset;
|
|
311
|
+
return asset;
|
|
312
|
+
}
|
|
313
|
+
return Asset.fromMetadata(meta);
|
|
314
|
+
}
|
|
315
|
+
static fromMetadata(meta) {
|
|
316
|
+
const metaHash = meta.hash;
|
|
317
|
+
const assetByHash = Asset.byHash[metaHash];
|
|
318
|
+
if (assetByHash) {
|
|
319
|
+
return assetByHash;
|
|
320
|
+
}
|
|
321
|
+
const { uri, hash } = selectAssetSource(meta);
|
|
322
|
+
const asset = new Asset({
|
|
323
|
+
name: meta.name,
|
|
324
|
+
type: meta.type,
|
|
325
|
+
hash,
|
|
326
|
+
uri,
|
|
327
|
+
width: meta.width,
|
|
328
|
+
height: meta.height
|
|
329
|
+
});
|
|
330
|
+
Asset.byHash[metaHash] = asset;
|
|
331
|
+
return asset;
|
|
332
|
+
}
|
|
333
|
+
static fromURI(uri) {
|
|
334
|
+
if (Asset.byUri[uri]) {
|
|
335
|
+
return Asset.byUri[uri];
|
|
336
|
+
}
|
|
337
|
+
let type = "";
|
|
338
|
+
if (uri.indexOf(";base64") > -1) {
|
|
339
|
+
type = uri.split(";")[0]?.split("/")[1] ?? "";
|
|
340
|
+
} else {
|
|
341
|
+
const extension = getFileExtension(uri);
|
|
342
|
+
type = extension.startsWith(".") ? extension.substring(1) : extension;
|
|
343
|
+
}
|
|
344
|
+
const asset = new Asset({
|
|
345
|
+
name: "",
|
|
346
|
+
type,
|
|
347
|
+
hash: null,
|
|
348
|
+
uri
|
|
349
|
+
});
|
|
350
|
+
Asset.byUri[uri] = asset;
|
|
351
|
+
return asset;
|
|
352
|
+
}
|
|
353
|
+
async downloadAsync() {
|
|
354
|
+
if (this.downloaded) {
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
if (this.downloading) {
|
|
358
|
+
await new Promise((resolve, reject) => {
|
|
359
|
+
this._downloadCallbacks.push({ resolve, reject });
|
|
360
|
+
});
|
|
361
|
+
return this;
|
|
362
|
+
}
|
|
363
|
+
this.downloading = true;
|
|
364
|
+
try {
|
|
365
|
+
if (Platform_default.OS === "web") {
|
|
366
|
+
if (isImageType(this.type)) {
|
|
367
|
+
const { width, height, name } = await getImageInfoAsync(this.uri);
|
|
368
|
+
this.width = width;
|
|
369
|
+
this.height = height;
|
|
370
|
+
this.name = name;
|
|
371
|
+
} else {
|
|
372
|
+
this.name = getFilename(this.uri);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
this.localUri = await downloadAsync(this.uri, this.hash, this.type);
|
|
376
|
+
this.downloaded = true;
|
|
377
|
+
this._downloadCallbacks.forEach(({ resolve }) => resolve());
|
|
378
|
+
} catch (e) {
|
|
379
|
+
this._downloadCallbacks.forEach(({ reject }) => reject(e));
|
|
380
|
+
throw e;
|
|
381
|
+
} finally {
|
|
382
|
+
this.downloading = false;
|
|
383
|
+
this._downloadCallbacks = [];
|
|
384
|
+
}
|
|
385
|
+
return this;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// node_modules/expo-asset/build/Asset.fx.js
|
|
391
|
+
var init_Asset_fx = __esm(() => {
|
|
392
|
+
init_Asset();
|
|
393
|
+
init_PlatformUtils_web();
|
|
394
|
+
init_resolveAssetSource();
|
|
395
|
+
if (IS_ENV_WITH_LOCAL_ASSETS) {
|
|
396
|
+
const setTransformer = resolveAssetSource_default.setCustomSourceTransformer || setCustomSourceTransformer;
|
|
397
|
+
setTransformer(function expoAssetTransformer(resolver) {
|
|
398
|
+
try {
|
|
399
|
+
if ("fileHashes" in resolver.asset && resolver.asset.fileHashes) {
|
|
400
|
+
const asset = Asset.fromMetadata(resolver.asset);
|
|
401
|
+
if (asset.uri.startsWith(ANDROID_EMBEDDED_URL_BASE_RESOURCE)) {
|
|
402
|
+
return resolver.resourceIdentifierWithoutScale();
|
|
403
|
+
}
|
|
404
|
+
return resolver.fromSource(asset.downloaded ? asset.localUri : asset.uri);
|
|
405
|
+
} else {
|
|
406
|
+
return resolver.defaultAsset();
|
|
407
|
+
}
|
|
408
|
+
} catch {
|
|
409
|
+
return resolver.defaultAsset();
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// node_modules/expo-asset/build/AssetHooks.js
|
|
416
|
+
import { useEffect, useState } from "react";
|
|
417
|
+
var init_AssetHooks = __esm(() => {
|
|
418
|
+
init_Asset();
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// node_modules/expo-asset/build/index.js
|
|
422
|
+
var init_build = __esm(() => {
|
|
423
|
+
init_Asset_fx();
|
|
424
|
+
init_Asset();
|
|
425
|
+
init_AssetHooks();
|
|
426
|
+
});
|
|
427
|
+
// node_modules/expo-audio/build/ExpoAudio.web.js
|
|
428
|
+
import { useEffect as useEffect3, useMemo } from "react";
|
|
429
|
+
|
|
430
|
+
// node_modules/expo-audio/build/AudioEventKeys.js
|
|
431
|
+
var PLAYBACK_STATUS_UPDATE = "playbackStatusUpdate";
|
|
432
|
+
var AUDIO_SAMPLE_UPDATE = "audioSampleUpdate";
|
|
433
|
+
var RECORDING_STATUS_UPDATE = "recordingStatusUpdate";
|
|
434
|
+
var PLAYLIST_STATUS_UPDATE = "playlistStatusUpdate";
|
|
435
|
+
var TRACK_CHANGED = "trackChanged";
|
|
436
|
+
|
|
437
|
+
// node_modules/expo-audio/build/AudioUtils.web.js
|
|
438
|
+
init_build();
|
|
439
|
+
var nextId = (() => {
|
|
440
|
+
let id = 0;
|
|
441
|
+
return () => String(id++);
|
|
442
|
+
})();
|
|
443
|
+
var audioContext = null;
|
|
444
|
+
function getAudioContext() {
|
|
445
|
+
if (!audioContext) {
|
|
446
|
+
audioContext = new AudioContext;
|
|
447
|
+
}
|
|
448
|
+
return audioContext;
|
|
449
|
+
}
|
|
450
|
+
function getUserMedia(constraints) {
|
|
451
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
452
|
+
return navigator.mediaDevices.getUserMedia(constraints);
|
|
453
|
+
}
|
|
454
|
+
const getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || function() {
|
|
455
|
+
const error = new Error("Permission unimplemented");
|
|
456
|
+
error.code = 0;
|
|
457
|
+
error.name = "NotAllowedError";
|
|
458
|
+
throw error;
|
|
459
|
+
};
|
|
460
|
+
return new Promise((resolve, reject) => {
|
|
461
|
+
getUserMedia.call(navigator, constraints, resolve, reject);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
function safeDuration(duration) {
|
|
465
|
+
return isNaN(duration) || !isFinite(duration) ? 0 : duration;
|
|
466
|
+
}
|
|
467
|
+
function getStatusFromMedia(media, id) {
|
|
468
|
+
const isPlaying = !!(media.currentTime > 0 && !media.paused && !media.ended && media.readyState > 2);
|
|
469
|
+
const status = {
|
|
470
|
+
id,
|
|
471
|
+
isLoaded: true,
|
|
472
|
+
duration: safeDuration(media.duration),
|
|
473
|
+
currentTime: media.currentTime,
|
|
474
|
+
playbackState: "",
|
|
475
|
+
timeControlStatus: isPlaying ? "playing" : "paused",
|
|
476
|
+
reasonForWaitingToPlay: "",
|
|
477
|
+
playing: isPlaying,
|
|
478
|
+
didJustFinish: media.ended,
|
|
479
|
+
isBuffering: false,
|
|
480
|
+
playbackRate: media.playbackRate,
|
|
481
|
+
shouldCorrectPitch: true,
|
|
482
|
+
mute: media.muted,
|
|
483
|
+
loop: media.loop,
|
|
484
|
+
isLive: media.duration === Infinity,
|
|
485
|
+
currentOffsetFromLive: null,
|
|
486
|
+
error: null
|
|
487
|
+
};
|
|
488
|
+
return status;
|
|
489
|
+
}
|
|
490
|
+
var preloadCache = new Map;
|
|
491
|
+
function getSourceUri(source) {
|
|
492
|
+
if (typeof source === "string") {
|
|
493
|
+
return source;
|
|
494
|
+
}
|
|
495
|
+
if (typeof source === "number") {
|
|
496
|
+
const asset = Asset.fromModule(source);
|
|
497
|
+
return asset.uri;
|
|
498
|
+
}
|
|
499
|
+
if (typeof source?.assetId === "number" && !source?.uri) {
|
|
500
|
+
const asset = Asset.fromModule(source.assetId);
|
|
501
|
+
return asset.uri;
|
|
502
|
+
}
|
|
503
|
+
return source?.uri ?? undefined;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// node_modules/expo-audio/build/MediaSessionController.web.js
|
|
507
|
+
var SKIP_SECONDS = 10;
|
|
508
|
+
|
|
509
|
+
class MediaSessionController {
|
|
510
|
+
activePlayer = null;
|
|
511
|
+
metadata = null;
|
|
512
|
+
options = null;
|
|
513
|
+
setActivePlayer(player, metadata, options) {
|
|
514
|
+
if (!navigator.mediaSession)
|
|
515
|
+
return;
|
|
516
|
+
if (this.activePlayer && this.activePlayer !== player) {
|
|
517
|
+
this.clear(this.activePlayer);
|
|
518
|
+
}
|
|
519
|
+
this.activePlayer = player;
|
|
520
|
+
this.metadata = metadata ?? null;
|
|
521
|
+
this.options = options ?? null;
|
|
522
|
+
this._applyMetadata();
|
|
523
|
+
this._applyActionHandlers();
|
|
524
|
+
this.updatePlaybackState(player);
|
|
525
|
+
this.updatePositionState(player);
|
|
526
|
+
}
|
|
527
|
+
updateMetadata(player, metadata) {
|
|
528
|
+
if (!navigator.mediaSession)
|
|
529
|
+
return;
|
|
530
|
+
if (this.activePlayer !== player)
|
|
531
|
+
return;
|
|
532
|
+
this.metadata = metadata;
|
|
533
|
+
this._applyMetadata();
|
|
534
|
+
}
|
|
535
|
+
clear(player) {
|
|
536
|
+
if (!navigator.mediaSession)
|
|
537
|
+
return;
|
|
538
|
+
if (this.activePlayer !== player)
|
|
539
|
+
return;
|
|
540
|
+
this.activePlayer = null;
|
|
541
|
+
this.metadata = null;
|
|
542
|
+
this.options = null;
|
|
543
|
+
navigator.mediaSession.metadata = null;
|
|
544
|
+
navigator.mediaSession.playbackState = "none";
|
|
545
|
+
const actions = [
|
|
546
|
+
"play",
|
|
547
|
+
"pause",
|
|
548
|
+
"seekto",
|
|
549
|
+
"seekforward",
|
|
550
|
+
"seekbackward",
|
|
551
|
+
"previoustrack",
|
|
552
|
+
"nexttrack"
|
|
553
|
+
];
|
|
554
|
+
for (const action of actions) {
|
|
555
|
+
this._setHandler(action, null);
|
|
556
|
+
}
|
|
557
|
+
try {
|
|
558
|
+
navigator.mediaSession.setPositionState();
|
|
559
|
+
} catch {}
|
|
560
|
+
}
|
|
561
|
+
updatePlaybackState(player) {
|
|
562
|
+
if (!navigator.mediaSession)
|
|
563
|
+
return;
|
|
564
|
+
if (this.activePlayer !== player)
|
|
565
|
+
return;
|
|
566
|
+
navigator.mediaSession.playbackState = player.playing ? "playing" : "paused";
|
|
567
|
+
}
|
|
568
|
+
updatePositionState(player) {
|
|
569
|
+
if (!navigator.mediaSession)
|
|
570
|
+
return;
|
|
571
|
+
if (this.activePlayer !== player)
|
|
572
|
+
return;
|
|
573
|
+
const duration = player.duration;
|
|
574
|
+
if (!Number.isFinite(duration) || duration <= 0)
|
|
575
|
+
return;
|
|
576
|
+
const position = Math.min(Math.max(player.currentTime, 0), duration);
|
|
577
|
+
const playbackRate = player.playbackRate || 1;
|
|
578
|
+
try {
|
|
579
|
+
navigator.mediaSession.setPositionState({
|
|
580
|
+
duration,
|
|
581
|
+
playbackRate,
|
|
582
|
+
position
|
|
583
|
+
});
|
|
584
|
+
} catch {}
|
|
585
|
+
}
|
|
586
|
+
isActive(player) {
|
|
587
|
+
return this.activePlayer === player;
|
|
588
|
+
}
|
|
589
|
+
getActiveState(player) {
|
|
590
|
+
if (this.activePlayer !== player)
|
|
591
|
+
return null;
|
|
592
|
+
return { metadata: this.metadata, options: this.options };
|
|
593
|
+
}
|
|
594
|
+
_applyMetadata() {
|
|
595
|
+
if (!this.metadata) {
|
|
596
|
+
navigator.mediaSession.metadata = null;
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const { title, artist, albumTitle, artworkUrl } = this.metadata;
|
|
600
|
+
const artwork = artworkUrl ? [{ src: artworkUrl }] : [];
|
|
601
|
+
navigator.mediaSession.metadata = new MediaMetadata({
|
|
602
|
+
title: title ?? "",
|
|
603
|
+
artist: artist ?? "",
|
|
604
|
+
album: albumTitle ?? "",
|
|
605
|
+
artwork
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
_setHandler(action, handler) {
|
|
609
|
+
try {
|
|
610
|
+
navigator.mediaSession.setActionHandler(action, handler);
|
|
611
|
+
} catch {}
|
|
612
|
+
}
|
|
613
|
+
_applyActionHandlers() {
|
|
614
|
+
const player = this.activePlayer;
|
|
615
|
+
if (!player)
|
|
616
|
+
return;
|
|
617
|
+
this._setHandler("play", () => {
|
|
618
|
+
player.play();
|
|
619
|
+
});
|
|
620
|
+
this._setHandler("pause", () => {
|
|
621
|
+
player.pause();
|
|
622
|
+
});
|
|
623
|
+
this._setHandler("seekto", (details) => {
|
|
624
|
+
if (details.seekTime != null) {
|
|
625
|
+
player.seekTo(details.seekTime);
|
|
626
|
+
this.updatePositionState(player);
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
const seekForward = (details) => {
|
|
630
|
+
const skipTime = details.seekOffset ?? SKIP_SECONDS;
|
|
631
|
+
const newTime = Math.min(player.currentTime + skipTime, player.duration || 0);
|
|
632
|
+
player.seekTo(newTime);
|
|
633
|
+
this.updatePositionState(player);
|
|
634
|
+
};
|
|
635
|
+
const seekBackward = (details) => {
|
|
636
|
+
const skipTime = details.seekOffset ?? SKIP_SECONDS;
|
|
637
|
+
const newTime = Math.max(player.currentTime - skipTime, 0);
|
|
638
|
+
player.seekTo(newTime);
|
|
639
|
+
this.updatePositionState(player);
|
|
640
|
+
};
|
|
641
|
+
if (this.options?.showSeekForward === true) {
|
|
642
|
+
this._setHandler("seekforward", seekForward);
|
|
643
|
+
this._setHandler("nexttrack", seekForward);
|
|
644
|
+
} else {
|
|
645
|
+
this._setHandler("seekforward", null);
|
|
646
|
+
this._setHandler("nexttrack", null);
|
|
647
|
+
}
|
|
648
|
+
if (this.options?.showSeekBackward === true) {
|
|
649
|
+
this._setHandler("seekbackward", seekBackward);
|
|
650
|
+
this._setHandler("previoustrack", seekBackward);
|
|
651
|
+
} else {
|
|
652
|
+
this._setHandler("seekbackward", null);
|
|
653
|
+
this._setHandler("previoustrack", null);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
var mediaSessionController = new MediaSessionController;
|
|
658
|
+
|
|
659
|
+
// node_modules/expo-audio/build/AudioPlayer.web.js
|
|
660
|
+
var activePlayers = new Set;
|
|
661
|
+
var hasWarnedIOSVolume = false;
|
|
662
|
+
function isIOSSafari() {
|
|
663
|
+
return /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
class AudioPlayerWeb extends globalThis.expo.SharedObject {
|
|
667
|
+
constructor(source, options = {}) {
|
|
668
|
+
super();
|
|
669
|
+
const { updateInterval = 500, crossOrigin } = options;
|
|
670
|
+
this.src = source;
|
|
671
|
+
this.interval = Math.max(updateInterval, 1);
|
|
672
|
+
this.crossOrigin = crossOrigin;
|
|
673
|
+
this.media = this._createMediaElement();
|
|
674
|
+
activePlayers.add(this);
|
|
675
|
+
}
|
|
676
|
+
id = nextId();
|
|
677
|
+
isAudioSamplingSupported = false;
|
|
678
|
+
isBuffering = false;
|
|
679
|
+
shouldCorrectPitch = false;
|
|
680
|
+
src = null;
|
|
681
|
+
media;
|
|
682
|
+
interval = 500;
|
|
683
|
+
isPlaying = false;
|
|
684
|
+
loaded = false;
|
|
685
|
+
crossOrigin;
|
|
686
|
+
analyser = null;
|
|
687
|
+
sourceNode = null;
|
|
688
|
+
samplingFrameId = null;
|
|
689
|
+
samplingEnabled = false;
|
|
690
|
+
samplingBuffer = null;
|
|
691
|
+
get playing() {
|
|
692
|
+
return this.isPlaying;
|
|
693
|
+
}
|
|
694
|
+
get muted() {
|
|
695
|
+
return this.media.muted;
|
|
696
|
+
}
|
|
697
|
+
set muted(value) {
|
|
698
|
+
this.media.muted = value;
|
|
699
|
+
}
|
|
700
|
+
get loop() {
|
|
701
|
+
return this.media.loop;
|
|
702
|
+
}
|
|
703
|
+
set loop(value) {
|
|
704
|
+
this.media.loop = value;
|
|
705
|
+
}
|
|
706
|
+
get duration() {
|
|
707
|
+
return safeDuration(this.media.duration);
|
|
708
|
+
}
|
|
709
|
+
get currentTime() {
|
|
710
|
+
return this.media.currentTime;
|
|
711
|
+
}
|
|
712
|
+
get paused() {
|
|
713
|
+
return this.media.paused;
|
|
714
|
+
}
|
|
715
|
+
get isLoaded() {
|
|
716
|
+
return this.loaded;
|
|
717
|
+
}
|
|
718
|
+
get playbackRate() {
|
|
719
|
+
return this.media.playbackRate;
|
|
720
|
+
}
|
|
721
|
+
set playbackRate(value) {
|
|
722
|
+
this.media.playbackRate = value;
|
|
723
|
+
}
|
|
724
|
+
get volume() {
|
|
725
|
+
return this.media.volume;
|
|
726
|
+
}
|
|
727
|
+
set volume(value) {
|
|
728
|
+
if (!hasWarnedIOSVolume && isIOSSafari()) {
|
|
729
|
+
hasWarnedIOSVolume = true;
|
|
730
|
+
console.warn("expo-audio: Programmatic volume control is not supported in browsers on iOS. " + "Apple requires volume to be controlled exclusively by the device physical buttons.");
|
|
731
|
+
}
|
|
732
|
+
this.media.volume = value;
|
|
733
|
+
}
|
|
734
|
+
get currentStatus() {
|
|
735
|
+
return getStatusFromMedia(this.media, this.id);
|
|
736
|
+
}
|
|
737
|
+
play() {
|
|
738
|
+
if (!isAudioActive) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
this.media.play();
|
|
742
|
+
this.isPlaying = true;
|
|
743
|
+
this.startSampling();
|
|
744
|
+
}
|
|
745
|
+
pause() {
|
|
746
|
+
this.media.pause();
|
|
747
|
+
this.isPlaying = false;
|
|
748
|
+
this.stopSampling();
|
|
749
|
+
}
|
|
750
|
+
replace(source) {
|
|
751
|
+
const wasPlaying = this.isPlaying;
|
|
752
|
+
const wasSampling = this.samplingEnabled;
|
|
753
|
+
const mediaSessionState = mediaSessionController.getActiveState(this);
|
|
754
|
+
this.remove();
|
|
755
|
+
this.src = source;
|
|
756
|
+
this.isPlaying = false;
|
|
757
|
+
this.loaded = false;
|
|
758
|
+
this.media = this._createMediaElement();
|
|
759
|
+
if (wasSampling) {
|
|
760
|
+
this.setAudioSamplingEnabled(true);
|
|
761
|
+
}
|
|
762
|
+
if (mediaSessionState) {
|
|
763
|
+
mediaSessionController.setActivePlayer(this, mediaSessionState.metadata ?? undefined, mediaSessionState.options ?? undefined);
|
|
764
|
+
}
|
|
765
|
+
if (wasPlaying) {
|
|
766
|
+
this.play();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
async seekTo(seconds, toleranceMillisBefore, toleranceMillisAfter) {
|
|
770
|
+
this.media.currentTime = seconds;
|
|
771
|
+
}
|
|
772
|
+
setAudioSamplingEnabled(enabled) {
|
|
773
|
+
if (enabled) {
|
|
774
|
+
if (!this.media.crossOrigin && this._isCrossOrigin()) {
|
|
775
|
+
this.isAudioSamplingSupported = false;
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
if (this.analyser) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const ctx = getAudioContext();
|
|
782
|
+
if (ctx.state === "suspended") {
|
|
783
|
+
ctx.resume();
|
|
784
|
+
}
|
|
785
|
+
if (!this.sourceNode) {
|
|
786
|
+
this.sourceNode = ctx.createMediaElementSource(this.media);
|
|
787
|
+
}
|
|
788
|
+
this.analyser = ctx.createAnalyser();
|
|
789
|
+
this.analyser.fftSize = 2048;
|
|
790
|
+
this.sourceNode.disconnect();
|
|
791
|
+
this.sourceNode.connect(this.analyser);
|
|
792
|
+
this.analyser.connect(ctx.destination);
|
|
793
|
+
this.samplingBuffer = new Float32Array(this.analyser.frequencyBinCount);
|
|
794
|
+
this.samplingEnabled = true;
|
|
795
|
+
if (this.isPlaying) {
|
|
796
|
+
this.startSampling();
|
|
797
|
+
}
|
|
798
|
+
this.isAudioSamplingSupported = true;
|
|
799
|
+
} else {
|
|
800
|
+
this.stopSampling();
|
|
801
|
+
if (this.analyser) {
|
|
802
|
+
this.analyser.disconnect();
|
|
803
|
+
this.analyser = null;
|
|
804
|
+
}
|
|
805
|
+
if (this.sourceNode) {
|
|
806
|
+
const ctx = getAudioContext();
|
|
807
|
+
this.sourceNode.disconnect();
|
|
808
|
+
this.sourceNode.connect(ctx.destination);
|
|
809
|
+
}
|
|
810
|
+
this.samplingBuffer = null;
|
|
811
|
+
this.samplingEnabled = false;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
startSampling() {
|
|
815
|
+
if (!this.samplingEnabled || !this.analyser || !this.samplingBuffer) {
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const sampleLoop = () => {
|
|
819
|
+
if (!this.analyser || !this.samplingBuffer) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
this.analyser.getFloatTimeDomainData(this.samplingBuffer);
|
|
823
|
+
this.emit(AUDIO_SAMPLE_UPDATE, {
|
|
824
|
+
channels: [{ frames: Array.from(this.samplingBuffer) }],
|
|
825
|
+
timestamp: this.media.currentTime
|
|
826
|
+
});
|
|
827
|
+
this.samplingFrameId = requestAnimationFrame(sampleLoop);
|
|
828
|
+
};
|
|
829
|
+
this.samplingFrameId = requestAnimationFrame(sampleLoop);
|
|
830
|
+
}
|
|
831
|
+
stopSampling() {
|
|
832
|
+
if (this.samplingFrameId != null) {
|
|
833
|
+
cancelAnimationFrame(this.samplingFrameId);
|
|
834
|
+
this.samplingFrameId = null;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
setPlaybackRate(second, pitchCorrectionQuality) {
|
|
838
|
+
this.media.playbackRate = second;
|
|
839
|
+
this.shouldCorrectPitch = pitchCorrectionQuality === "high";
|
|
840
|
+
this.media.preservesPitch = this.shouldCorrectPitch;
|
|
841
|
+
mediaSessionController.updatePositionState(this);
|
|
842
|
+
}
|
|
843
|
+
remove() {
|
|
844
|
+
mediaSessionController.clear(this);
|
|
845
|
+
this.stopSampling();
|
|
846
|
+
if (this.analyser) {
|
|
847
|
+
this.analyser.disconnect();
|
|
848
|
+
this.analyser = null;
|
|
849
|
+
}
|
|
850
|
+
if (this.sourceNode) {
|
|
851
|
+
this.sourceNode.disconnect();
|
|
852
|
+
this.sourceNode = null;
|
|
853
|
+
}
|
|
854
|
+
this.samplingEnabled = false;
|
|
855
|
+
this.media.pause();
|
|
856
|
+
this.media.ontimeupdate = null;
|
|
857
|
+
this.media.onplay = null;
|
|
858
|
+
this.media.onpause = null;
|
|
859
|
+
this.media.onseeked = null;
|
|
860
|
+
this.media.onended = null;
|
|
861
|
+
this.media.onloadeddata = null;
|
|
862
|
+
this.media.onerror = null;
|
|
863
|
+
this.media.removeAttribute("src");
|
|
864
|
+
this.media.load();
|
|
865
|
+
activePlayers.delete(this);
|
|
866
|
+
}
|
|
867
|
+
release() {
|
|
868
|
+
this.remove();
|
|
869
|
+
}
|
|
870
|
+
setActiveForLockScreen(active, metadata, options) {
|
|
871
|
+
if (active) {
|
|
872
|
+
mediaSessionController.setActivePlayer(this, metadata, options);
|
|
873
|
+
} else {
|
|
874
|
+
mediaSessionController.clear(this);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
updateLockScreenMetadata(metadata) {
|
|
878
|
+
mediaSessionController.updateMetadata(this, metadata);
|
|
879
|
+
}
|
|
880
|
+
clearLockScreenControls() {
|
|
881
|
+
mediaSessionController.clear(this);
|
|
882
|
+
}
|
|
883
|
+
_isCrossOrigin() {
|
|
884
|
+
try {
|
|
885
|
+
return new URL(this.media.src).origin !== window.location.origin;
|
|
886
|
+
} catch {
|
|
887
|
+
return false;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
_createMediaElement() {
|
|
891
|
+
const newSource = getSourceUri(this.src);
|
|
892
|
+
const cachedUri = newSource && preloadCache.has(newSource) ? preloadCache.get(newSource).blobUrl : newSource;
|
|
893
|
+
const media = new Audio(cachedUri);
|
|
894
|
+
if (this.crossOrigin !== undefined) {
|
|
895
|
+
media.crossOrigin = this.crossOrigin;
|
|
896
|
+
}
|
|
897
|
+
let lastEmitTime = 0;
|
|
898
|
+
const intervalSec = this.interval / 1000;
|
|
899
|
+
media.ontimeupdate = () => {
|
|
900
|
+
const now = media.currentTime;
|
|
901
|
+
if (now < lastEmitTime) {
|
|
902
|
+
lastEmitTime = now;
|
|
903
|
+
}
|
|
904
|
+
if (now - lastEmitTime >= intervalSec) {
|
|
905
|
+
lastEmitTime = now;
|
|
906
|
+
this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));
|
|
907
|
+
mediaSessionController.updatePositionState(this);
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
media.onplay = () => {
|
|
911
|
+
this.isPlaying = true;
|
|
912
|
+
lastEmitTime = media.currentTime;
|
|
913
|
+
this.emit(PLAYBACK_STATUS_UPDATE, {
|
|
914
|
+
...getStatusFromMedia(media, this.id),
|
|
915
|
+
playing: this.isPlaying
|
|
916
|
+
});
|
|
917
|
+
mediaSessionController.updatePlaybackState(this);
|
|
918
|
+
mediaSessionController.updatePositionState(this);
|
|
919
|
+
};
|
|
920
|
+
media.onpause = () => {
|
|
921
|
+
this.isPlaying = false;
|
|
922
|
+
lastEmitTime = media.currentTime;
|
|
923
|
+
this.emit(PLAYBACK_STATUS_UPDATE, {
|
|
924
|
+
...getStatusFromMedia(media, this.id),
|
|
925
|
+
playing: this.isPlaying
|
|
926
|
+
});
|
|
927
|
+
mediaSessionController.updatePlaybackState(this);
|
|
928
|
+
mediaSessionController.updatePositionState(this);
|
|
929
|
+
};
|
|
930
|
+
media.onseeked = () => {
|
|
931
|
+
lastEmitTime = media.currentTime;
|
|
932
|
+
this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));
|
|
933
|
+
mediaSessionController.updatePositionState(this);
|
|
934
|
+
};
|
|
935
|
+
media.onended = () => {
|
|
936
|
+
lastEmitTime = 0;
|
|
937
|
+
mediaSessionController.updatePlaybackState(this);
|
|
938
|
+
};
|
|
939
|
+
media.onloadeddata = () => {
|
|
940
|
+
this.loaded = true;
|
|
941
|
+
lastEmitTime = media.currentTime;
|
|
942
|
+
this.emit(PLAYBACK_STATUS_UPDATE, {
|
|
943
|
+
...getStatusFromMedia(media, this.id),
|
|
944
|
+
isLoaded: this.loaded
|
|
945
|
+
});
|
|
946
|
+
mediaSessionController.updatePositionState(this);
|
|
947
|
+
};
|
|
948
|
+
media.onerror = () => {
|
|
949
|
+
this.loaded = false;
|
|
950
|
+
this.isPlaying = false;
|
|
951
|
+
const errorMessage = media.error ? `Playback error (code ${media.error.code})` : "Unknown playback error";
|
|
952
|
+
this.emit(PLAYBACK_STATUS_UPDATE, {
|
|
953
|
+
...getStatusFromMedia(media, this.id),
|
|
954
|
+
isLoaded: false,
|
|
955
|
+
playing: false,
|
|
956
|
+
error: errorMessage
|
|
957
|
+
});
|
|
958
|
+
};
|
|
959
|
+
return media;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
// node_modules/expo-audio/build/utils/resolveSource.js
|
|
963
|
+
init_build();
|
|
964
|
+
function createSourceFromAsset(asset, extras = {}) {
|
|
965
|
+
const uri = asset.localUri ?? asset.uri;
|
|
966
|
+
const result = { uri };
|
|
967
|
+
if (asset.name) {
|
|
968
|
+
result.name = asset.name;
|
|
969
|
+
}
|
|
970
|
+
if (extras.assetId != null) {
|
|
971
|
+
result.assetId = extras.assetId;
|
|
972
|
+
}
|
|
973
|
+
if (extras.headers) {
|
|
974
|
+
result.headers = extras.headers;
|
|
975
|
+
}
|
|
976
|
+
return result;
|
|
977
|
+
}
|
|
978
|
+
function resolveSource(source) {
|
|
979
|
+
if (source == null) {
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
if (source instanceof Asset) {
|
|
983
|
+
return createSourceFromAsset(source);
|
|
984
|
+
}
|
|
985
|
+
if (typeof source === "string") {
|
|
986
|
+
return { uri: source };
|
|
987
|
+
}
|
|
988
|
+
if (typeof source === "number") {
|
|
989
|
+
const asset = Asset.fromModule(source);
|
|
990
|
+
return createSourceFromAsset(asset, { assetId: source });
|
|
991
|
+
}
|
|
992
|
+
if (typeof source === "object") {
|
|
993
|
+
if ("assetId" in source && typeof source.assetId === "number") {
|
|
994
|
+
const asset = Asset.fromModule(source.assetId);
|
|
995
|
+
return {
|
|
996
|
+
...source,
|
|
997
|
+
uri: asset.localUri ?? asset.uri
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
if ("uri" in source && typeof source.uri === "string") {
|
|
1001
|
+
return source;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
return source ?? null;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// node_modules/expo-audio/build/AudioPlaylist.web.js
|
|
1008
|
+
function getSourceInfo(source) {
|
|
1009
|
+
const resolved = resolveSource(source);
|
|
1010
|
+
if (resolved && typeof resolved === "object") {
|
|
1011
|
+
return {
|
|
1012
|
+
uri: resolved.uri,
|
|
1013
|
+
name: resolved.name
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
return { uri: getSourceUri(source) };
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
class AudioPlaylistWeb extends globalThis.expo.SharedObject {
|
|
1020
|
+
constructor(initialSources = [], updateInterval = 500, loopMode = "none", crossOrigin) {
|
|
1021
|
+
super();
|
|
1022
|
+
this._updateInterval = Math.max(updateInterval, 1);
|
|
1023
|
+
this._loopMode = loopMode;
|
|
1024
|
+
this._crossOrigin = crossOrigin;
|
|
1025
|
+
for (const source of initialSources) {
|
|
1026
|
+
this._sources.push(source);
|
|
1027
|
+
this._sourceInfos.push(getSourceInfo(source));
|
|
1028
|
+
}
|
|
1029
|
+
if (this._sources.length > 0) {
|
|
1030
|
+
const source = this._sources[0];
|
|
1031
|
+
if (source) {
|
|
1032
|
+
this._currentMedia = this._createMediaElement(source);
|
|
1033
|
+
}
|
|
1034
|
+
this._preloadNext();
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
id = nextId();
|
|
1038
|
+
_sources = [];
|
|
1039
|
+
_sourceInfos = [];
|
|
1040
|
+
_currentIndex = 0;
|
|
1041
|
+
_currentMedia = null;
|
|
1042
|
+
_nextMedia = null;
|
|
1043
|
+
_updateInterval = 500;
|
|
1044
|
+
_loopMode = "none";
|
|
1045
|
+
_isPlaying = false;
|
|
1046
|
+
_isLoaded = false;
|
|
1047
|
+
_isBuffering = false;
|
|
1048
|
+
_volume = 1;
|
|
1049
|
+
_muted = false;
|
|
1050
|
+
_playbackRate = 1;
|
|
1051
|
+
_crossOrigin;
|
|
1052
|
+
_knownDuration = 0;
|
|
1053
|
+
get currentIndex() {
|
|
1054
|
+
return this._currentIndex;
|
|
1055
|
+
}
|
|
1056
|
+
get trackCount() {
|
|
1057
|
+
return this._sources.length;
|
|
1058
|
+
}
|
|
1059
|
+
get sources() {
|
|
1060
|
+
return [...this._sourceInfos];
|
|
1061
|
+
}
|
|
1062
|
+
get playing() {
|
|
1063
|
+
return this._isPlaying;
|
|
1064
|
+
}
|
|
1065
|
+
get muted() {
|
|
1066
|
+
return this._muted;
|
|
1067
|
+
}
|
|
1068
|
+
set muted(value) {
|
|
1069
|
+
this._muted = value;
|
|
1070
|
+
if (this._currentMedia) {
|
|
1071
|
+
this._currentMedia.muted = value;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
get isLoaded() {
|
|
1075
|
+
return this._isLoaded;
|
|
1076
|
+
}
|
|
1077
|
+
get isBuffering() {
|
|
1078
|
+
return this._isBuffering;
|
|
1079
|
+
}
|
|
1080
|
+
get currentTime() {
|
|
1081
|
+
return this._currentMedia?.currentTime ?? 0;
|
|
1082
|
+
}
|
|
1083
|
+
get duration() {
|
|
1084
|
+
return this._knownDuration;
|
|
1085
|
+
}
|
|
1086
|
+
get volume() {
|
|
1087
|
+
return this._volume;
|
|
1088
|
+
}
|
|
1089
|
+
set volume(value) {
|
|
1090
|
+
this._volume = value;
|
|
1091
|
+
if (this._currentMedia) {
|
|
1092
|
+
this._currentMedia.volume = value;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
get playbackRate() {
|
|
1096
|
+
return this._playbackRate;
|
|
1097
|
+
}
|
|
1098
|
+
set playbackRate(value) {
|
|
1099
|
+
this._playbackRate = value;
|
|
1100
|
+
if (this._currentMedia) {
|
|
1101
|
+
this._currentMedia.playbackRate = value;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
get loop() {
|
|
1105
|
+
return this._loopMode;
|
|
1106
|
+
}
|
|
1107
|
+
set loop(value) {
|
|
1108
|
+
this._loopMode = value;
|
|
1109
|
+
this._emitStatus();
|
|
1110
|
+
}
|
|
1111
|
+
get currentStatus() {
|
|
1112
|
+
return this._getStatus();
|
|
1113
|
+
}
|
|
1114
|
+
play() {
|
|
1115
|
+
if (!this._currentMedia || this._sources.length === 0) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
this._currentMedia.play();
|
|
1119
|
+
this._isPlaying = true;
|
|
1120
|
+
}
|
|
1121
|
+
pause() {
|
|
1122
|
+
if (this._currentMedia) {
|
|
1123
|
+
this._currentMedia.pause();
|
|
1124
|
+
this._isPlaying = false;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
next() {
|
|
1128
|
+
if (this._sources.length === 0)
|
|
1129
|
+
return;
|
|
1130
|
+
const previousIndex = this._currentIndex;
|
|
1131
|
+
let nextIndex = this._currentIndex + 1;
|
|
1132
|
+
if (nextIndex >= this._sources.length) {
|
|
1133
|
+
if (this._loopMode === "all") {
|
|
1134
|
+
nextIndex = 0;
|
|
1135
|
+
} else {
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
this._transitionToTrack(nextIndex, previousIndex);
|
|
1140
|
+
}
|
|
1141
|
+
previous() {
|
|
1142
|
+
if (this._sources.length === 0)
|
|
1143
|
+
return;
|
|
1144
|
+
const previousIndex = this._currentIndex;
|
|
1145
|
+
let prevIndex = this._currentIndex - 1;
|
|
1146
|
+
if (prevIndex < 0) {
|
|
1147
|
+
if (this._loopMode === "all") {
|
|
1148
|
+
prevIndex = this._sources.length - 1;
|
|
1149
|
+
} else {
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
this._transitionToTrack(prevIndex, previousIndex);
|
|
1154
|
+
}
|
|
1155
|
+
skipTo(index) {
|
|
1156
|
+
if (index < 0 || index >= this._sources.length) {
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
if (index === this._currentIndex) {
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
const previousIndex = this._currentIndex;
|
|
1163
|
+
this._transitionToTrack(index, previousIndex);
|
|
1164
|
+
}
|
|
1165
|
+
async seekTo(seconds) {
|
|
1166
|
+
if (this._currentMedia) {
|
|
1167
|
+
this._currentMedia.currentTime = seconds;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
add(source) {
|
|
1171
|
+
this._sources.push(source);
|
|
1172
|
+
this._sourceInfos.push(getSourceInfo(source));
|
|
1173
|
+
if (this._sources.length === 1) {
|
|
1174
|
+
this._currentMedia = this._createMediaElement(source);
|
|
1175
|
+
} else {
|
|
1176
|
+
this._preloadNext();
|
|
1177
|
+
}
|
|
1178
|
+
this._emitStatus();
|
|
1179
|
+
}
|
|
1180
|
+
insert(source, index) {
|
|
1181
|
+
if (index < 0)
|
|
1182
|
+
index = 0;
|
|
1183
|
+
if (index > this._sources.length)
|
|
1184
|
+
index = this._sources.length;
|
|
1185
|
+
this._sources.splice(index, 0, source);
|
|
1186
|
+
this._sourceInfos.splice(index, 0, getSourceInfo(source));
|
|
1187
|
+
if (index <= this._currentIndex && this._sources.length > 1) {
|
|
1188
|
+
this._currentIndex++;
|
|
1189
|
+
}
|
|
1190
|
+
if (this._sources.length === 1) {
|
|
1191
|
+
this._currentMedia = this._createMediaElement(source);
|
|
1192
|
+
} else {
|
|
1193
|
+
this._preloadNext();
|
|
1194
|
+
}
|
|
1195
|
+
this._emitStatus();
|
|
1196
|
+
}
|
|
1197
|
+
remove(index) {
|
|
1198
|
+
if (index < 0 || index >= this._sources.length) {
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
const wasCurrentTrack = index === this._currentIndex;
|
|
1202
|
+
const wasPlaying = this._isPlaying;
|
|
1203
|
+
this._sources.splice(index, 1);
|
|
1204
|
+
this._sourceInfos.splice(index, 1);
|
|
1205
|
+
if (this._sources.length === 0) {
|
|
1206
|
+
this._cleanupMedia(this._currentMedia);
|
|
1207
|
+
this._currentMedia = null;
|
|
1208
|
+
this._cleanupMedia(this._nextMedia);
|
|
1209
|
+
this._nextMedia = null;
|
|
1210
|
+
this._currentIndex = 0;
|
|
1211
|
+
this._isPlaying = false;
|
|
1212
|
+
this._isLoaded = false;
|
|
1213
|
+
this._knownDuration = 0;
|
|
1214
|
+
} else if (wasCurrentTrack) {
|
|
1215
|
+
this._cleanupMedia(this._currentMedia);
|
|
1216
|
+
if (this._currentIndex >= this._sources.length) {
|
|
1217
|
+
this._currentIndex = this._sources.length - 1;
|
|
1218
|
+
}
|
|
1219
|
+
this._knownDuration = 0;
|
|
1220
|
+
const source = this._sources[this._currentIndex];
|
|
1221
|
+
if (source) {
|
|
1222
|
+
this._currentMedia = this._createMediaElement(source);
|
|
1223
|
+
if (wasPlaying) {
|
|
1224
|
+
this._currentMedia.play();
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
this._preloadNext();
|
|
1228
|
+
} else if (index < this._currentIndex) {
|
|
1229
|
+
this._currentIndex--;
|
|
1230
|
+
this._preloadNext();
|
|
1231
|
+
} else {
|
|
1232
|
+
this._preloadNext();
|
|
1233
|
+
}
|
|
1234
|
+
this._emitStatus();
|
|
1235
|
+
}
|
|
1236
|
+
clear() {
|
|
1237
|
+
this._cleanupMedia(this._currentMedia);
|
|
1238
|
+
this._currentMedia = null;
|
|
1239
|
+
this._cleanupMedia(this._nextMedia);
|
|
1240
|
+
this._nextMedia = null;
|
|
1241
|
+
this._sources = [];
|
|
1242
|
+
this._sourceInfos = [];
|
|
1243
|
+
this._currentIndex = 0;
|
|
1244
|
+
this._isPlaying = false;
|
|
1245
|
+
this._isLoaded = false;
|
|
1246
|
+
this._knownDuration = 0;
|
|
1247
|
+
this._emitStatus();
|
|
1248
|
+
}
|
|
1249
|
+
destroy() {
|
|
1250
|
+
this.clear();
|
|
1251
|
+
}
|
|
1252
|
+
_transitionToTrack(newIndex, previousIndex) {
|
|
1253
|
+
const wasPlaying = this._isPlaying;
|
|
1254
|
+
if (this._currentMedia) {
|
|
1255
|
+
this._currentMedia.pause();
|
|
1256
|
+
this._cleanupMedia(this._currentMedia);
|
|
1257
|
+
}
|
|
1258
|
+
this._currentIndex = newIndex;
|
|
1259
|
+
this._isLoaded = false;
|
|
1260
|
+
this._isBuffering = true;
|
|
1261
|
+
this._knownDuration = 0;
|
|
1262
|
+
const isNextSequential = newIndex === (previousIndex + 1) % this._sources.length;
|
|
1263
|
+
if (this._nextMedia && isNextSequential) {
|
|
1264
|
+
this._currentMedia = this._nextMedia;
|
|
1265
|
+
this._attachMediaHandlers(this._currentMedia);
|
|
1266
|
+
this._nextMedia = null;
|
|
1267
|
+
} else {
|
|
1268
|
+
this._cleanupMedia(this._nextMedia);
|
|
1269
|
+
this._nextMedia = null;
|
|
1270
|
+
const source = this._sources[newIndex];
|
|
1271
|
+
if (source) {
|
|
1272
|
+
this._currentMedia = this._createMediaElement(source);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (this._currentMedia && wasPlaying) {
|
|
1276
|
+
this._currentMedia.play();
|
|
1277
|
+
this._isPlaying = true;
|
|
1278
|
+
}
|
|
1279
|
+
this._preloadNext();
|
|
1280
|
+
this.emit(TRACK_CHANGED, { previousIndex, currentIndex: newIndex });
|
|
1281
|
+
this._emitStatus();
|
|
1282
|
+
}
|
|
1283
|
+
_preloadNext() {
|
|
1284
|
+
if (this._nextMedia) {
|
|
1285
|
+
this._cleanupMedia(this._nextMedia);
|
|
1286
|
+
this._nextMedia = null;
|
|
1287
|
+
}
|
|
1288
|
+
if (this._sources.length <= 1 || this._loopMode === "single") {
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
let nextIndex = this._currentIndex + 1;
|
|
1292
|
+
if (nextIndex >= this._sources.length) {
|
|
1293
|
+
if (this._loopMode === "all") {
|
|
1294
|
+
nextIndex = 0;
|
|
1295
|
+
} else {
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
const source = this._sources[nextIndex];
|
|
1300
|
+
if (source) {
|
|
1301
|
+
const uri = getSourceUri(source);
|
|
1302
|
+
if (uri) {
|
|
1303
|
+
this._nextMedia = new Audio(uri);
|
|
1304
|
+
if (this._crossOrigin !== undefined) {
|
|
1305
|
+
this._nextMedia.crossOrigin = this._crossOrigin;
|
|
1306
|
+
}
|
|
1307
|
+
this._nextMedia.preload = "auto";
|
|
1308
|
+
this._nextMedia.volume = this._volume;
|
|
1309
|
+
this._nextMedia.muted = this._muted;
|
|
1310
|
+
this._nextMedia.playbackRate = this._playbackRate;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
_cleanupMedia(media) {
|
|
1315
|
+
if (!media)
|
|
1316
|
+
return;
|
|
1317
|
+
media.pause();
|
|
1318
|
+
media.ontimeupdate = null;
|
|
1319
|
+
media.onplay = null;
|
|
1320
|
+
media.onpause = null;
|
|
1321
|
+
media.onseeked = null;
|
|
1322
|
+
media.onended = null;
|
|
1323
|
+
media.onloadedmetadata = null;
|
|
1324
|
+
media.onloadeddata = null;
|
|
1325
|
+
media.onwaiting = null;
|
|
1326
|
+
media.oncanplaythrough = null;
|
|
1327
|
+
media.onerror = null;
|
|
1328
|
+
media.removeAttribute("src");
|
|
1329
|
+
media.load();
|
|
1330
|
+
}
|
|
1331
|
+
_attachMediaHandlers(media) {
|
|
1332
|
+
let lastEmitTime = 0;
|
|
1333
|
+
const intervalSec = this._updateInterval / 1000;
|
|
1334
|
+
if (media.readyState >= 1) {
|
|
1335
|
+
const duration = media.duration;
|
|
1336
|
+
if (!isNaN(duration) && isFinite(duration)) {
|
|
1337
|
+
this._knownDuration = duration;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
media.ontimeupdate = () => {
|
|
1341
|
+
const now = media.currentTime;
|
|
1342
|
+
if (now < lastEmitTime) {
|
|
1343
|
+
lastEmitTime = now;
|
|
1344
|
+
}
|
|
1345
|
+
if (now - lastEmitTime >= intervalSec) {
|
|
1346
|
+
lastEmitTime = now;
|
|
1347
|
+
this._emitStatus();
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
media.onplay = () => {
|
|
1351
|
+
this._isPlaying = true;
|
|
1352
|
+
lastEmitTime = media.currentTime;
|
|
1353
|
+
this._emitStatus();
|
|
1354
|
+
};
|
|
1355
|
+
media.onpause = () => {
|
|
1356
|
+
if (!media.ended) {
|
|
1357
|
+
this._isPlaying = false;
|
|
1358
|
+
}
|
|
1359
|
+
lastEmitTime = media.currentTime;
|
|
1360
|
+
this._emitStatus();
|
|
1361
|
+
};
|
|
1362
|
+
media.onseeked = () => {
|
|
1363
|
+
lastEmitTime = media.currentTime;
|
|
1364
|
+
this._emitStatus();
|
|
1365
|
+
};
|
|
1366
|
+
media.onended = () => {
|
|
1367
|
+
lastEmitTime = 0;
|
|
1368
|
+
this._handleTrackEnded();
|
|
1369
|
+
};
|
|
1370
|
+
media.onloadedmetadata = () => {
|
|
1371
|
+
const duration = media.duration;
|
|
1372
|
+
if (!isNaN(duration) && isFinite(duration)) {
|
|
1373
|
+
this._knownDuration = duration;
|
|
1374
|
+
this._emitStatus();
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
media.onloadeddata = () => {
|
|
1378
|
+
this._isLoaded = true;
|
|
1379
|
+
this._isBuffering = false;
|
|
1380
|
+
lastEmitTime = media.currentTime;
|
|
1381
|
+
this._emitStatus();
|
|
1382
|
+
};
|
|
1383
|
+
media.onwaiting = () => {
|
|
1384
|
+
this._isBuffering = true;
|
|
1385
|
+
this._emitStatus();
|
|
1386
|
+
};
|
|
1387
|
+
media.oncanplaythrough = () => {
|
|
1388
|
+
this._isBuffering = false;
|
|
1389
|
+
this._emitStatus();
|
|
1390
|
+
};
|
|
1391
|
+
media.onerror = () => {
|
|
1392
|
+
this._isLoaded = false;
|
|
1393
|
+
this._isBuffering = false;
|
|
1394
|
+
this._isPlaying = false;
|
|
1395
|
+
this._emitStatus();
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
_createMediaElement(source) {
|
|
1399
|
+
const uri = getSourceUri(source);
|
|
1400
|
+
const media = new Audio(uri);
|
|
1401
|
+
if (this._crossOrigin !== undefined) {
|
|
1402
|
+
media.crossOrigin = this._crossOrigin;
|
|
1403
|
+
}
|
|
1404
|
+
media.volume = this._volume;
|
|
1405
|
+
media.muted = this._muted;
|
|
1406
|
+
media.playbackRate = this._playbackRate;
|
|
1407
|
+
this._attachMediaHandlers(media);
|
|
1408
|
+
return media;
|
|
1409
|
+
}
|
|
1410
|
+
_handleTrackEnded() {
|
|
1411
|
+
if (this._loopMode === "single") {
|
|
1412
|
+
if (this._currentMedia) {
|
|
1413
|
+
this._currentMedia.currentTime = 0;
|
|
1414
|
+
this._currentMedia.play();
|
|
1415
|
+
}
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
const isLastTrack = this._currentIndex >= this._sources.length - 1;
|
|
1419
|
+
if (isLastTrack) {
|
|
1420
|
+
if (this._loopMode === "all") {
|
|
1421
|
+
this._transitionToTrack(0, this._currentIndex);
|
|
1422
|
+
} else {
|
|
1423
|
+
this._isPlaying = false;
|
|
1424
|
+
this.emit(PLAYLIST_STATUS_UPDATE, {
|
|
1425
|
+
...this._getStatus(),
|
|
1426
|
+
didJustFinish: true
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
} else {
|
|
1430
|
+
this._transitionToTrack(this._currentIndex + 1, this._currentIndex);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
_getStatus() {
|
|
1434
|
+
return {
|
|
1435
|
+
id: this.id,
|
|
1436
|
+
currentIndex: this._currentIndex,
|
|
1437
|
+
trackCount: this._sources.length,
|
|
1438
|
+
currentTime: this._currentMedia?.currentTime ?? 0,
|
|
1439
|
+
duration: this._knownDuration,
|
|
1440
|
+
playing: this._isPlaying,
|
|
1441
|
+
isBuffering: this._isBuffering,
|
|
1442
|
+
isLoaded: this._isLoaded,
|
|
1443
|
+
playbackRate: this._playbackRate,
|
|
1444
|
+
muted: this._muted,
|
|
1445
|
+
volume: this._volume,
|
|
1446
|
+
loop: this._loopMode,
|
|
1447
|
+
didJustFinish: false
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
_emitStatus() {
|
|
1451
|
+
this.emit(PLAYLIST_STATUS_UPDATE, this._getStatus());
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
// node_modules/expo-audio/build/RecordingConstants.js
|
|
1455
|
+
var IOSOutputFormat;
|
|
1456
|
+
(function(IOSOutputFormat) {
|
|
1457
|
+
IOSOutputFormat["LINEARPCM"] = "lpcm";
|
|
1458
|
+
IOSOutputFormat["AC3"] = "ac-3";
|
|
1459
|
+
IOSOutputFormat["60958AC3"] = "cac3";
|
|
1460
|
+
IOSOutputFormat["APPLEIMA4"] = "ima4";
|
|
1461
|
+
IOSOutputFormat["MPEG4AAC"] = "aac ";
|
|
1462
|
+
IOSOutputFormat["MPEG4CELP"] = "celp";
|
|
1463
|
+
IOSOutputFormat["MPEG4HVXC"] = "hvxc";
|
|
1464
|
+
IOSOutputFormat["MPEG4TWINVQ"] = "twvq";
|
|
1465
|
+
IOSOutputFormat["MACE3"] = "MAC3";
|
|
1466
|
+
IOSOutputFormat["MACE6"] = "MAC6";
|
|
1467
|
+
IOSOutputFormat["ULAW"] = "ulaw";
|
|
1468
|
+
IOSOutputFormat["ALAW"] = "alaw";
|
|
1469
|
+
IOSOutputFormat["QDESIGN"] = "QDMC";
|
|
1470
|
+
IOSOutputFormat["QDESIGN2"] = "QDM2";
|
|
1471
|
+
IOSOutputFormat["QUALCOMM"] = "Qclp";
|
|
1472
|
+
IOSOutputFormat["MPEGLAYER1"] = ".mp1";
|
|
1473
|
+
IOSOutputFormat["MPEGLAYER2"] = ".mp2";
|
|
1474
|
+
IOSOutputFormat["MPEGLAYER3"] = ".mp3";
|
|
1475
|
+
IOSOutputFormat["APPLELOSSLESS"] = "alac";
|
|
1476
|
+
IOSOutputFormat["MPEG4AAC_HE"] = "aach";
|
|
1477
|
+
IOSOutputFormat["MPEG4AAC_LD"] = "aacl";
|
|
1478
|
+
IOSOutputFormat["MPEG4AAC_ELD"] = "aace";
|
|
1479
|
+
IOSOutputFormat["MPEG4AAC_ELD_SBR"] = "aacf";
|
|
1480
|
+
IOSOutputFormat["MPEG4AAC_ELD_V2"] = "aacg";
|
|
1481
|
+
IOSOutputFormat["MPEG4AAC_HE_V2"] = "aacp";
|
|
1482
|
+
IOSOutputFormat["MPEG4AAC_SPATIAL"] = "aacs";
|
|
1483
|
+
IOSOutputFormat["AMR"] = "samr";
|
|
1484
|
+
IOSOutputFormat["AMR_WB"] = "sawb";
|
|
1485
|
+
IOSOutputFormat["AUDIBLE"] = "AUDB";
|
|
1486
|
+
IOSOutputFormat["ILBC"] = "ilbc";
|
|
1487
|
+
IOSOutputFormat[IOSOutputFormat["DVIINTELIMA"] = 1836253201] = "DVIINTELIMA";
|
|
1488
|
+
IOSOutputFormat[IOSOutputFormat["MICROSOFTGSM"] = 1836253233] = "MICROSOFTGSM";
|
|
1489
|
+
IOSOutputFormat["AES3"] = "aes3";
|
|
1490
|
+
IOSOutputFormat["ENHANCEDAC3"] = "ec-3";
|
|
1491
|
+
})(IOSOutputFormat || (IOSOutputFormat = {}));
|
|
1492
|
+
var AudioQuality;
|
|
1493
|
+
(function(AudioQuality) {
|
|
1494
|
+
AudioQuality[AudioQuality["MIN"] = 0] = "MIN";
|
|
1495
|
+
AudioQuality[AudioQuality["LOW"] = 32] = "LOW";
|
|
1496
|
+
AudioQuality[AudioQuality["MEDIUM"] = 64] = "MEDIUM";
|
|
1497
|
+
AudioQuality[AudioQuality["HIGH"] = 96] = "HIGH";
|
|
1498
|
+
AudioQuality[AudioQuality["MAX"] = 127] = "MAX";
|
|
1499
|
+
})(AudioQuality || (AudioQuality = {}));
|
|
1500
|
+
var HIGH_QUALITY = {
|
|
1501
|
+
extension: ".m4a",
|
|
1502
|
+
sampleRate: 44100,
|
|
1503
|
+
numberOfChannels: 2,
|
|
1504
|
+
bitRate: 128000,
|
|
1505
|
+
android: {
|
|
1506
|
+
outputFormat: "mpeg4",
|
|
1507
|
+
audioEncoder: "aac"
|
|
1508
|
+
},
|
|
1509
|
+
ios: {
|
|
1510
|
+
outputFormat: IOSOutputFormat.MPEG4AAC,
|
|
1511
|
+
audioQuality: AudioQuality.MAX,
|
|
1512
|
+
linearPCMBitDepth: 16,
|
|
1513
|
+
linearPCMIsBigEndian: false,
|
|
1514
|
+
linearPCMIsFloat: false
|
|
1515
|
+
},
|
|
1516
|
+
web: {
|
|
1517
|
+
mimeType: "audio/webm",
|
|
1518
|
+
bitsPerSecond: 128000
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
var LOW_QUALITY = {
|
|
1522
|
+
extension: ".m4a",
|
|
1523
|
+
sampleRate: 44100,
|
|
1524
|
+
numberOfChannels: 2,
|
|
1525
|
+
bitRate: 64000,
|
|
1526
|
+
android: {
|
|
1527
|
+
extension: ".3gp",
|
|
1528
|
+
outputFormat: "3gp",
|
|
1529
|
+
audioEncoder: "amr_nb"
|
|
1530
|
+
},
|
|
1531
|
+
ios: {
|
|
1532
|
+
audioQuality: AudioQuality.MIN,
|
|
1533
|
+
outputFormat: IOSOutputFormat.MPEG4AAC,
|
|
1534
|
+
linearPCMBitDepth: 16,
|
|
1535
|
+
linearPCMIsBigEndian: false,
|
|
1536
|
+
linearPCMIsFloat: false
|
|
1537
|
+
},
|
|
1538
|
+
web: {
|
|
1539
|
+
mimeType: "audio/webm",
|
|
1540
|
+
bitsPerSecond: 128000
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
var RecordingPresets = {
|
|
1544
|
+
HIGH_QUALITY,
|
|
1545
|
+
LOW_QUALITY
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
// node_modules/expo-audio/build/AudioRecorder.web.js
|
|
1549
|
+
class AudioRecorderWeb extends globalThis.expo.SharedObject {
|
|
1550
|
+
constructor(options) {
|
|
1551
|
+
super();
|
|
1552
|
+
this.options = options;
|
|
1553
|
+
}
|
|
1554
|
+
async setup() {
|
|
1555
|
+
this.mediaRecorder = await this.createMediaRecorder(this.options);
|
|
1556
|
+
}
|
|
1557
|
+
id = nextId();
|
|
1558
|
+
currentTime = 0;
|
|
1559
|
+
uri = null;
|
|
1560
|
+
options;
|
|
1561
|
+
mediaRecorder = null;
|
|
1562
|
+
mediaRecorderUptimeOfLastStartResume = 0;
|
|
1563
|
+
mediaRecorderIsRecording = false;
|
|
1564
|
+
timeoutIds = [];
|
|
1565
|
+
cachedInputs = [];
|
|
1566
|
+
selectedDeviceId = null;
|
|
1567
|
+
stream = null;
|
|
1568
|
+
handleDeviceChange = null;
|
|
1569
|
+
analyser = null;
|
|
1570
|
+
analyserBuffer = null;
|
|
1571
|
+
analyserSource = null;
|
|
1572
|
+
meteringEnabled = false;
|
|
1573
|
+
get isRecording() {
|
|
1574
|
+
return this.mediaRecorder?.state === "recording";
|
|
1575
|
+
}
|
|
1576
|
+
record(options) {
|
|
1577
|
+
if (this.mediaRecorder === null) {
|
|
1578
|
+
throw new Error("Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.");
|
|
1579
|
+
}
|
|
1580
|
+
this.clearTimeouts();
|
|
1581
|
+
const { forDuration } = options || {};
|
|
1582
|
+
this.startActualRecording();
|
|
1583
|
+
if (forDuration !== undefined) {
|
|
1584
|
+
this.timeoutIds.push(setTimeout(() => {
|
|
1585
|
+
this.stop();
|
|
1586
|
+
}, forDuration * 1000));
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
startActualRecording() {
|
|
1590
|
+
if (this.mediaRecorder?.state === "paused") {
|
|
1591
|
+
this.mediaRecorder.resume();
|
|
1592
|
+
} else {
|
|
1593
|
+
this.mediaRecorder?.start();
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
getAvailableInputs() {
|
|
1597
|
+
return this.cachedInputs;
|
|
1598
|
+
}
|
|
1599
|
+
getCurrentInput() {
|
|
1600
|
+
const deviceId = this.selectedDeviceId ?? this.stream?.getAudioTracks()[0]?.getSettings().deviceId;
|
|
1601
|
+
const matched = this.cachedInputs.find((input) => input.uid === deviceId);
|
|
1602
|
+
if (matched) {
|
|
1603
|
+
return Promise.resolve(matched);
|
|
1604
|
+
}
|
|
1605
|
+
return Promise.resolve(this.cachedInputs[0] ?? {
|
|
1606
|
+
type: "Default",
|
|
1607
|
+
name: "Default",
|
|
1608
|
+
uid: "Default"
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
async prepareToRecordAsync() {
|
|
1612
|
+
return this.setup();
|
|
1613
|
+
}
|
|
1614
|
+
getStatus() {
|
|
1615
|
+
const status = {
|
|
1616
|
+
canRecord: this.mediaRecorder?.state === "recording" || this.mediaRecorder?.state === "inactive",
|
|
1617
|
+
isRecording: this.mediaRecorder?.state === "recording",
|
|
1618
|
+
durationMillis: this.getAudioRecorderDurationMillis(),
|
|
1619
|
+
mediaServicesDidReset: false,
|
|
1620
|
+
url: this.uri
|
|
1621
|
+
};
|
|
1622
|
+
if (this.meteringEnabled && this.mediaRecorderIsRecording) {
|
|
1623
|
+
status.metering = this.getMeteringLevel();
|
|
1624
|
+
}
|
|
1625
|
+
return status;
|
|
1626
|
+
}
|
|
1627
|
+
pause() {
|
|
1628
|
+
if (this.mediaRecorder === null) {
|
|
1629
|
+
throw new Error("Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.");
|
|
1630
|
+
}
|
|
1631
|
+
this.mediaRecorder?.pause();
|
|
1632
|
+
}
|
|
1633
|
+
recordForDuration(seconds) {
|
|
1634
|
+
this.record({ forDuration: seconds });
|
|
1635
|
+
}
|
|
1636
|
+
setInput(input) {
|
|
1637
|
+
if (!this.cachedInputs.some((cached) => cached.uid === input)) {
|
|
1638
|
+
throw new Error(`No audio input device found for uid: ${input}`);
|
|
1639
|
+
}
|
|
1640
|
+
this.selectedDeviceId = input;
|
|
1641
|
+
}
|
|
1642
|
+
startRecordingAtTime(seconds) {
|
|
1643
|
+
this.record({ atTime: seconds });
|
|
1644
|
+
}
|
|
1645
|
+
async stop() {
|
|
1646
|
+
if (this.mediaRecorder === null) {
|
|
1647
|
+
throw new Error("Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.");
|
|
1648
|
+
}
|
|
1649
|
+
const dataPromise = new Promise((resolve) => this.mediaRecorder?.addEventListener("dataavailable", (e) => resolve(e.data)));
|
|
1650
|
+
this.mediaRecorder?.stop();
|
|
1651
|
+
this.mediaRecorder = null;
|
|
1652
|
+
const data = await dataPromise;
|
|
1653
|
+
const url = URL.createObjectURL(data);
|
|
1654
|
+
this.uri = url;
|
|
1655
|
+
this.emit(RECORDING_STATUS_UPDATE, {
|
|
1656
|
+
id: this.id,
|
|
1657
|
+
isFinished: true,
|
|
1658
|
+
hasError: false,
|
|
1659
|
+
error: null,
|
|
1660
|
+
url
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
clearTimeouts() {
|
|
1664
|
+
this.timeoutIds.forEach((id) => clearTimeout(id));
|
|
1665
|
+
}
|
|
1666
|
+
async createMediaRecorder(options) {
|
|
1667
|
+
if (typeof navigator !== "undefined" && !navigator.mediaDevices) {
|
|
1668
|
+
throw new Error("No media devices available");
|
|
1669
|
+
}
|
|
1670
|
+
this.mediaRecorderUptimeOfLastStartResume = 0;
|
|
1671
|
+
this.currentTime = 0;
|
|
1672
|
+
const audioConstraints = this.selectedDeviceId ? { deviceId: { exact: this.selectedDeviceId } } : true;
|
|
1673
|
+
const stream = await getUserMedia({ audio: audioConstraints });
|
|
1674
|
+
this.stream = stream;
|
|
1675
|
+
await this.updateCachedInputs();
|
|
1676
|
+
this.handleDeviceChange = () => {
|
|
1677
|
+
this.updateCachedInputs();
|
|
1678
|
+
};
|
|
1679
|
+
navigator.mediaDevices.addEventListener("devicechange", this.handleDeviceChange);
|
|
1680
|
+
if (options.isMeteringEnabled) {
|
|
1681
|
+
const ctx = getAudioContext();
|
|
1682
|
+
if (ctx.state === "suspended") {
|
|
1683
|
+
ctx.resume();
|
|
1684
|
+
}
|
|
1685
|
+
this.analyserSource = ctx.createMediaStreamSource(stream);
|
|
1686
|
+
this.analyser = ctx.createAnalyser();
|
|
1687
|
+
this.analyser.fftSize = 2048;
|
|
1688
|
+
this.analyserSource.connect(this.analyser);
|
|
1689
|
+
this.analyserBuffer = new Float32Array(this.analyser.frequencyBinCount);
|
|
1690
|
+
this.meteringEnabled = true;
|
|
1691
|
+
}
|
|
1692
|
+
const defaults = RecordingPresets.HIGH_QUALITY.web;
|
|
1693
|
+
const mediaRecorderOptions = {};
|
|
1694
|
+
const mimeType = options.mimeType ?? defaults.mimeType;
|
|
1695
|
+
if (mimeType && MediaRecorder.isTypeSupported(mimeType)) {
|
|
1696
|
+
mediaRecorderOptions.mimeType = mimeType;
|
|
1697
|
+
}
|
|
1698
|
+
if (options.bitsPerSecond) {
|
|
1699
|
+
mediaRecorderOptions.bitsPerSecond = options.bitsPerSecond;
|
|
1700
|
+
} else if (options.bitRate) {
|
|
1701
|
+
mediaRecorderOptions.audioBitsPerSecond = options.bitRate;
|
|
1702
|
+
} else {
|
|
1703
|
+
mediaRecorderOptions.bitsPerSecond = defaults.bitsPerSecond;
|
|
1704
|
+
}
|
|
1705
|
+
const mediaRecorder = new MediaRecorder(stream, mediaRecorderOptions);
|
|
1706
|
+
mediaRecorder.addEventListener("pause", () => {
|
|
1707
|
+
this.currentTime = this.getAudioRecorderDurationMillis();
|
|
1708
|
+
this.mediaRecorderIsRecording = false;
|
|
1709
|
+
});
|
|
1710
|
+
mediaRecorder.addEventListener("resume", () => {
|
|
1711
|
+
this.mediaRecorderUptimeOfLastStartResume = Date.now();
|
|
1712
|
+
this.mediaRecorderIsRecording = true;
|
|
1713
|
+
});
|
|
1714
|
+
mediaRecorder.addEventListener("start", () => {
|
|
1715
|
+
this.mediaRecorderUptimeOfLastStartResume = Date.now();
|
|
1716
|
+
this.currentTime = 0;
|
|
1717
|
+
this.mediaRecorderIsRecording = true;
|
|
1718
|
+
});
|
|
1719
|
+
mediaRecorder?.addEventListener("stop", () => {
|
|
1720
|
+
this.currentTime = 0;
|
|
1721
|
+
this.mediaRecorderIsRecording = false;
|
|
1722
|
+
this.stream = null;
|
|
1723
|
+
if (this.analyserSource) {
|
|
1724
|
+
this.analyserSource.disconnect();
|
|
1725
|
+
this.analyserSource = null;
|
|
1726
|
+
}
|
|
1727
|
+
if (this.analyser) {
|
|
1728
|
+
this.analyser.disconnect();
|
|
1729
|
+
this.analyser = null;
|
|
1730
|
+
this.analyserBuffer = null;
|
|
1731
|
+
}
|
|
1732
|
+
if (this.handleDeviceChange) {
|
|
1733
|
+
navigator.mediaDevices?.removeEventListener("devicechange", this.handleDeviceChange);
|
|
1734
|
+
this.handleDeviceChange = null;
|
|
1735
|
+
}
|
|
1736
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
1737
|
+
});
|
|
1738
|
+
return mediaRecorder;
|
|
1739
|
+
}
|
|
1740
|
+
async updateCachedInputs() {
|
|
1741
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
1742
|
+
this.cachedInputs = devices.filter((device) => device.kind === "audioinput").map((device) => ({
|
|
1743
|
+
uid: device.deviceId,
|
|
1744
|
+
name: device.label || "Unknown Device",
|
|
1745
|
+
type: device.deviceId === "default" ? "Default" : "Unknown"
|
|
1746
|
+
}));
|
|
1747
|
+
}
|
|
1748
|
+
getMeteringLevel() {
|
|
1749
|
+
if (!this.analyser || !this.analyserBuffer) {
|
|
1750
|
+
return -160;
|
|
1751
|
+
}
|
|
1752
|
+
this.analyser.getFloatTimeDomainData(this.analyserBuffer);
|
|
1753
|
+
let sumSquares = 0;
|
|
1754
|
+
for (const sample of this.analyserBuffer) {
|
|
1755
|
+
sumSquares += sample * sample;
|
|
1756
|
+
}
|
|
1757
|
+
const rms = Math.sqrt(sumSquares / this.analyserBuffer.length);
|
|
1758
|
+
if (rms === 0) {
|
|
1759
|
+
return -160;
|
|
1760
|
+
}
|
|
1761
|
+
return 20 * Math.log10(rms);
|
|
1762
|
+
}
|
|
1763
|
+
getAudioRecorderDurationMillis() {
|
|
1764
|
+
let duration = this.currentTime;
|
|
1765
|
+
if (this.mediaRecorderIsRecording && this.mediaRecorderUptimeOfLastStartResume > 0) {
|
|
1766
|
+
duration += Date.now() - this.mediaRecorderUptimeOfLastStartResume;
|
|
1767
|
+
}
|
|
1768
|
+
return duration;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
// node_modules/expo-audio/build/AudioModule.web.js
|
|
1773
|
+
var isAudioActive = true;
|
|
1774
|
+
async function preloadAsync(source) {
|
|
1775
|
+
const uri = getSourceUri(source);
|
|
1776
|
+
if (!uri || preloadCache.has(uri))
|
|
1777
|
+
return;
|
|
1778
|
+
const headers = source && typeof source === "object" && !Array.isArray(source) ? source.headers : undefined;
|
|
1779
|
+
const response = await fetch(uri, headers ? { headers } : undefined);
|
|
1780
|
+
const blob = await response.blob();
|
|
1781
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
1782
|
+
const audio = new Audio(blobUrl);
|
|
1783
|
+
audio.preload = "auto";
|
|
1784
|
+
preloadCache.set(uri, { blobUrl, audio });
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
// node_modules/expo-audio/build/utils/useAudioRecorderState.js
|
|
1788
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
1789
|
+
|
|
1790
|
+
// node_modules/expo-audio/build/ExpoAudio.web.js
|
|
1791
|
+
function createAudioPlayer(source = null, options = {}) {
|
|
1792
|
+
const { downloadFirst = false } = options;
|
|
1793
|
+
const initialSource = downloadFirst ? null : resolveSource(source);
|
|
1794
|
+
const player = new AudioPlayerWeb(initialSource, options);
|
|
1795
|
+
if (downloadFirst && source) {
|
|
1796
|
+
const resolved = resolveSource(source);
|
|
1797
|
+
if (resolved) {
|
|
1798
|
+
preloadAsync(resolved).finally(() => {
|
|
1799
|
+
player.replace(resolved);
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
return player;
|
|
1804
|
+
}
|
|
1805
|
+
export {
|
|
1806
|
+
createAudioPlayer
|
|
1807
|
+
};
|