sanity-plugin-mux-input 2.14.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -24
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +1057 -470
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1059 -472
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/_exports/index.ts +1 -0
- package/src/actions/secrets.ts +6 -1
- package/src/actions/upload.ts +1 -1
- package/src/components/ConfigureApi.tsx +51 -5
- package/src/components/EditCaptionDialog.tsx +2 -2
- package/src/components/InputBrowser.tsx +8 -2
- package/src/components/PageSelector.tsx +4 -7
- package/src/components/Player.styled.tsx +7 -2
- package/src/components/PlayerActionsMenu.tsx +15 -1
- package/src/components/ResyncMetadata.tsx +152 -73
- package/src/components/SelectAsset.tsx +9 -3
- package/src/components/StudioTool.tsx +2 -2
- package/src/components/TextTracksManager.tsx +11 -55
- package/src/components/UploadConfiguration.tsx +104 -343
- package/src/components/Uploader.tsx +18 -7
- package/src/components/VideoDetails/VideoDetails.tsx +55 -19
- package/src/components/VideoDetails/useVideoDetails.ts +15 -1
- package/src/components/VideoInBrowser.tsx +53 -6
- package/src/components/VideoPlayer.tsx +120 -47
- package/src/components/VideoThumbnail.tsx +84 -72
- package/src/components/VideosBrowser.tsx +7 -5
- package/src/components/uploadConfiguration/PlaybackPolicy.tsx +95 -6
- package/src/components/uploadConfiguration/PlaybackPolicyOption.tsx +26 -10
- package/src/components/uploadConfiguration/ResolutionTierSelector.tsx +71 -0
- package/src/components/uploadConfiguration/StaticRenditionSelector.tsx +179 -0
- package/src/context/DrmPlaybackWarningContext.tsx +93 -0
- package/src/hooks/useFetchFileSize.ts +54 -0
- package/src/hooks/useMediaMetadata.ts +100 -0
- package/src/hooks/useResyncAsset.ts +110 -0
- package/src/hooks/useResyncMuxMetadata.ts +33 -0
- package/src/hooks/useSaveSecrets.ts +10 -3
- package/src/hooks/useSecretsDocumentValues.ts +9 -1
- package/src/hooks/useSecretsFormState.ts +6 -3
- package/src/schema.ts +5 -0
- package/src/util/addKeysToMuxData.ts +30 -0
- package/src/util/asserters.ts +14 -0
- package/src/util/createUrlParamsObject.ts +7 -3
- package/src/util/generateJwt.ts +11 -2
- package/src/util/getPlaybackPolicy.ts +63 -4
- package/src/util/getStoryboardSrc.ts +7 -3
- package/src/util/getVideoMetadata.ts +1 -0
- package/src/util/getVideoSrc.ts +9 -9
- package/src/util/readSecrets.ts +3 -1
- package/src/util/textTracks.ts +6 -3
- package/src/util/tryWithSuspend.ts +22 -0
- package/src/util/types.ts +27 -2
- package/src/util/getPlaybackId.ts +0 -9
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
import {Box, Button, Card, Dialog, Flex, Heading, Spinner, Stack, Text, useToast} from '@sanity/ui'
|
|
11
11
|
import {useEffect, useId, useMemo, useState} from 'react'
|
|
12
12
|
|
|
13
|
-
import {deleteTextTrack
|
|
13
|
+
import {deleteTextTrack} from '../actions/assets'
|
|
14
14
|
import {useClient} from '../hooks/useClient'
|
|
15
|
+
import {useResyncAsset} from '../hooks/useResyncAsset'
|
|
15
16
|
import {downloadVttFile} from '../util/textTracks'
|
|
16
17
|
import type {MuxTextTrack, VideoAssetDocument} from '../util/types'
|
|
17
18
|
import AddCaptionDialog from './AddCaptionDialog'
|
|
@@ -203,6 +204,7 @@ export default function TextTracksManager({
|
|
|
203
204
|
const client = useClient()
|
|
204
205
|
const toast = useToast()
|
|
205
206
|
const dialogId = `DeleteCaptionDialog${useId()}`
|
|
207
|
+
const {resyncAsset} = useResyncAsset()
|
|
206
208
|
const [downloadingTrackId, setDownloadingTrackId] = useState<string | null>(null)
|
|
207
209
|
const [deletingTrackId, setDeletingTrackId] = useState<string | null>(null)
|
|
208
210
|
const [addedTracks, setAddedTracks] = useState<MuxTextTrack[]>([])
|
|
@@ -216,27 +218,6 @@ export default function TextTracksManager({
|
|
|
216
218
|
|
|
217
219
|
const MAX_VISIBLE_TRACKS = 4
|
|
218
220
|
|
|
219
|
-
useEffect(() => {
|
|
220
|
-
if (!asset.assetId || !asset._id) return
|
|
221
|
-
|
|
222
|
-
const assetId = asset.assetId
|
|
223
|
-
const documentId = asset._id
|
|
224
|
-
|
|
225
|
-
const refreshAsset = async () => {
|
|
226
|
-
try {
|
|
227
|
-
const response = await getAsset(client, assetId)
|
|
228
|
-
await client
|
|
229
|
-
.patch(documentId)
|
|
230
|
-
.set({data: response.data, status: response.data.status})
|
|
231
|
-
.commit()
|
|
232
|
-
} catch (error) {
|
|
233
|
-
console.error('Failed to refresh asset data:', error)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
refreshAsset()
|
|
238
|
-
}, [asset.assetId, asset._id, client])
|
|
239
|
-
|
|
240
221
|
const realTracks: MuxTextTrack[] = propTracks
|
|
241
222
|
? propTracks
|
|
242
223
|
: asset.data?.tracks?.filter((track): track is MuxTextTrack => track.type === 'text') || []
|
|
@@ -344,20 +325,13 @@ export default function TextTracksManager({
|
|
|
344
325
|
return undefined
|
|
345
326
|
}
|
|
346
327
|
|
|
347
|
-
const assetId = asset.assetId
|
|
348
|
-
const documentId = asset._id
|
|
349
|
-
|
|
350
328
|
const interval = setInterval(async () => {
|
|
351
329
|
try {
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
.patch(documentId)
|
|
355
|
-
.set({data: response.data, status: response.data.status})
|
|
356
|
-
.commit()
|
|
330
|
+
const muxData = await resyncAsset(asset)
|
|
331
|
+
if (!muxData) return
|
|
357
332
|
|
|
358
333
|
const fetchedTracks =
|
|
359
|
-
|
|
360
|
-
[]
|
|
334
|
+
muxData.tracks?.filter((track): track is MuxTextTrack => track.type === 'text') || []
|
|
361
335
|
|
|
362
336
|
const isMockTrackReplaced = (
|
|
363
337
|
mockTrack: MuxTextTrack,
|
|
@@ -444,7 +418,7 @@ export default function TextTracksManager({
|
|
|
444
418
|
}, 3000) // Poll every 3 seconds
|
|
445
419
|
|
|
446
420
|
return () => clearInterval(interval)
|
|
447
|
-
}, [allTracks, asset
|
|
421
|
+
}, [allTracks, asset, resyncAsset])
|
|
448
422
|
|
|
449
423
|
const visibleTracks = allTracks
|
|
450
424
|
.filter(
|
|
@@ -506,17 +480,8 @@ export default function TextTracksManager({
|
|
|
506
480
|
}
|
|
507
481
|
await deleteTextTrack(client, asset.assetId, track.id)
|
|
508
482
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
const response = await getAsset(client, asset.assetId)
|
|
512
|
-
await client
|
|
513
|
-
.patch(asset._id)
|
|
514
|
-
.set({data: response.data, status: response.data.status})
|
|
515
|
-
.commit()
|
|
516
|
-
} catch (refreshError) {
|
|
517
|
-
console.error('Failed to refresh asset data:', refreshError)
|
|
518
|
-
}
|
|
519
|
-
}
|
|
483
|
+
// Refresh asset data after deletion
|
|
484
|
+
await resyncAsset(asset)
|
|
520
485
|
|
|
521
486
|
toast.push({
|
|
522
487
|
title: 'Successfully deleted caption track',
|
|
@@ -600,17 +565,8 @@ export default function TextTracksManager({
|
|
|
600
565
|
|
|
601
566
|
setTrackToEdit(null)
|
|
602
567
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const response = await getAsset(client, asset.assetId)
|
|
606
|
-
await client
|
|
607
|
-
.patch(asset._id)
|
|
608
|
-
.set({data: response.data, status: response.data.status})
|
|
609
|
-
.commit()
|
|
610
|
-
} catch (refreshError) {
|
|
611
|
-
console.error('Failed to refresh asset data:', refreshError)
|
|
612
|
-
}
|
|
613
|
-
}
|
|
568
|
+
// Refresh asset data after update
|
|
569
|
+
await resyncAsset(asset)
|
|
614
570
|
}
|
|
615
571
|
|
|
616
572
|
const getTrackSourceLabel = (track: MuxTextTrack) => {
|