sanity-plugin-mux-input 2.0.3 → 2.0.5

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.
Files changed (35) hide show
  1. package/lib/_chunks/{Input-aa6d929b.js → Input-235cb658.js} +77 -66
  2. package/lib/_chunks/Input-235cb658.js.map +1 -0
  3. package/lib/_chunks/{Input-4ec3c050.js → Input-b9334416.js} +78 -66
  4. package/lib/_chunks/Input-b9334416.js.map +1 -0
  5. package/lib/_chunks/{Preview-1664b7d5.js → Preview-85174edf.js} +2 -2
  6. package/lib/_chunks/{Preview-1664b7d5.js.map → Preview-85174edf.js.map} +1 -1
  7. package/lib/_chunks/{Preview-43ce9c72.js → Preview-ced24517.js} +2 -2
  8. package/lib/_chunks/{Preview-43ce9c72.js.map → Preview-ced24517.js.map} +1 -1
  9. package/lib/_chunks/{VideoSource.styled-99ffa712.js → VideoSource.styled-11786b3a.js} +3 -3
  10. package/lib/_chunks/VideoSource.styled-11786b3a.js.map +1 -0
  11. package/lib/_chunks/{VideoSource.styled-24577ec8.js → VideoSource.styled-f1b98975.js} +3 -3
  12. package/lib/_chunks/VideoSource.styled-f1b98975.js.map +1 -0
  13. package/lib/_chunks/{index-9933dea2.js → index-5a70abdc.js} +14 -13
  14. package/lib/_chunks/{index-9933dea2.js.map → index-5a70abdc.js.map} +1 -1
  15. package/lib/_chunks/{index-c54f5393.js → index-7260e0df.js} +14 -13
  16. package/lib/_chunks/{index-c54f5393.js.map → index-7260e0df.js.map} +1 -1
  17. package/lib/index.esm.js +1 -1
  18. package/lib/index.js +1 -1
  19. package/package.json +33 -33
  20. package/src/actions/assets.ts +1 -1
  21. package/src/actions/secrets.ts +12 -3
  22. package/src/actions/upload.ts +1 -1
  23. package/src/components/Player.tsx +15 -24
  24. package/src/components/__legacy__Uploader.tsx +1 -1
  25. package/src/hooks/useSaveSecrets.ts +1 -1
  26. package/src/util/generateJwt.ts +1 -1
  27. package/src/util/getAnimatedPosterSrc.ts +1 -1
  28. package/src/util/getPosterSrc.ts +1 -1
  29. package/src/util/getStoryboardSrc.ts +1 -1
  30. package/src/util/getVideoSrc.ts +1 -1
  31. package/src/util/readSecrets.ts +1 -1
  32. package/lib/_chunks/Input-4ec3c050.js.map +0 -1
  33. package/lib/_chunks/Input-aa6d929b.js.map +0 -1
  34. package/lib/_chunks/VideoSource.styled-24577ec8.js.map +0 -1
  35. package/lib/_chunks/VideoSource.styled-99ffa712.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable camelcase */
2
- import type {SanityClient} from '@sanity/client'
2
+ import type {SanityClient} from 'sanity'
3
3
  import {uuid as generateUuid} from '@sanity/uuid'
4
4
  import {type Observable, concat, defer, from, of, throwError} from 'rxjs'
5
5
  import {catchError, mergeMap, mergeMapTo, switchMap} from 'rxjs/operators'
@@ -1,4 +1,4 @@
1
- import {type PlaybackEngine, generatePlayerInitTime, initialize} from '@mux/playback-core'
1
+ import MuxVideo from '@mux/mux-video-react'
2
2
  import {Card, Text} from '@sanity/ui'
3
3
  import {
4
4
  MediaControlBar,
@@ -35,7 +35,7 @@ interface Props extends Pick<MuxInputProps, 'onChange' | 'readOnly'> {
35
35
  setDialogState: SetDialogState
36
36
  }
37
37
 
38
- const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogState}: Props) => {
38
+ const MuxVideoOld = ({asset, buttons, readOnly, onChange, dialogState, setDialogState}: Props) => {
39
39
  const client = useClient()
40
40
  const isLoading = useMemo<boolean | string>(() => {
41
41
  if (asset?.status === 'preparing') {
@@ -88,25 +88,6 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
88
88
  muteRef.current.shadowRoot.appendChild(style.cloneNode(true))
89
89
  }
90
90
  }, [])
91
- const [playerInitTime] = useState(() => generatePlayerInitTime())
92
- const playbackEngineRef = useRef<PlaybackEngine | undefined>(undefined)
93
-
94
- useEffect(() => {
95
- if (isLoading || !videoSrc) {
96
- return
97
- }
98
- const nextPlaybackEngineRef = initialize(
99
- {
100
- src: videoSrc,
101
- playerInitTime,
102
- playerSoftwareName: 'sanity-plugin-mux-input',
103
- playerSoftwareVersion: 'dev-preview',
104
- },
105
- video.current,
106
- playbackEngineRef.current
107
- )
108
- playbackEngineRef.current = nextPlaybackEngineRef
109
- }, [videoSrc, isLoading, playerInitTime])
110
91
 
111
92
  useEffect(() => {
112
93
  if (asset?.status === 'errored') {
@@ -117,6 +98,15 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
117
98
  }
118
99
  }, [asset.data?.errors?.messages, asset?.status, handleCancelUpload])
119
100
 
101
+ const signedToken = useMemo(() => {
102
+ try {
103
+ const url = new URL(videoSrc!)
104
+ return url.searchParams.get('token')
105
+ } catch {
106
+ return false
107
+ }
108
+ }, [videoSrc])
109
+
120
110
  if (error) {
121
111
  // @TODO better error handling
122
112
  throw error
@@ -141,16 +131,17 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
141
131
  <>
142
132
  <VideoContainer shadow={1} tone="transparent" scheme="dark">
143
133
  <MediaController>
144
- <video
134
+ <MuxVideo
145
135
  playsInline
146
136
  ref={video}
137
+ playbackId={`${asset.playbackId}${signedToken ? `?token=${signedToken}` : ''}`}
147
138
  onError={handleError}
148
139
  slot="media"
149
140
  preload="metadata"
150
141
  crossOrigin="anonomous"
151
142
  >
152
143
  <ThumbnailsMetadataTrack asset={asset} />
153
- </video>
144
+ </MuxVideo>
154
145
  <PosterImage asset={asset} />
155
146
  <MediaLoadingIndicator slot="centered-chrome" noAutoHide />
156
147
  <StyledCenterControls slot="centered-chrome">
@@ -193,4 +184,4 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
193
184
  )
194
185
  }
195
186
 
196
- export default MuxVideo
187
+ export default MuxVideoOld
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-nested-ternary */
2
2
  // This component needs to be refactored into a functional component
3
3
 
4
- import type {SanityClient} from '@sanity/client'
4
+ import type {SanityClient} from 'sanity'
5
5
  import React, {Component} from 'react'
6
6
  import {type Observable, Subject} from 'rxjs'
7
7
  import {takeUntil, tap} from 'rxjs/operators'
@@ -1,4 +1,4 @@
1
- import type {SanityClient} from '@sanity/client'
1
+ import type {SanityClient} from 'sanity'
2
2
  import {useCallback} from 'react'
3
3
 
4
4
  import {createSigningKeys, haveValidSigningKeys, saveSecrets, testSecrets} from '../actions/secrets'
@@ -1,4 +1,4 @@
1
- import type {SanityClient} from '@sanity/client'
1
+ import type {SanityClient} from 'sanity'
2
2
  import {suspend} from 'suspend-react'
3
3
 
4
4
  import {readSecrets} from './readSecrets'
@@ -1,4 +1,4 @@
1
- import type {SanityClient} from '@sanity/client'
1
+ import type {SanityClient} from 'sanity'
2
2
 
3
3
  import {generateJwt} from './generateJwt'
4
4
  import {getPlaybackId} from './getPlaybackId'
@@ -1,4 +1,4 @@
1
- import type {SanityClient} from '@sanity/client'
1
+ import type {SanityClient} from 'sanity'
2
2
 
3
3
  import {generateJwt} from './generateJwt'
4
4
  import {getPlaybackId} from './getPlaybackId'
@@ -1,4 +1,4 @@
1
- import type {SanityClient} from '@sanity/client'
1
+ import type {SanityClient} from 'sanity'
2
2
 
3
3
  import {generateJwt} from './generateJwt'
4
4
  import {getPlaybackId} from './getPlaybackId'
@@ -1,4 +1,4 @@
1
- import type {SanityClient} from '@sanity/client'
1
+ import type {SanityClient} from 'sanity'
2
2
 
3
3
  import {generateJwt} from './generateJwt'
4
4
  import {getPlaybackId} from './getPlaybackId'
@@ -4,7 +4,7 @@
4
4
 
5
5
  // @TODO rename to readSigningPair
6
6
 
7
- import type {SanityClient} from '@sanity/client'
7
+ import type {SanityClient} from 'sanity'
8
8
  import {suspend} from 'suspend-react'
9
9
 
10
10
  import {cacheNs} from '../util/constants'