sanity-plugin-mux-input 2.2.3 → 2.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.
Files changed (53) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +154 -22
  3. package/lib/index.cjs +4002 -3669
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +210 -0
  6. package/lib/index.d.ts +109 -25
  7. package/lib/index.esm.js +4384 -0
  8. package/lib/index.esm.js.map +1 -0
  9. package/lib/index.js +3967 -3621
  10. package/lib/index.js.map +1 -1
  11. package/package.json +47 -51
  12. package/src/_exports/index.ts +32 -0
  13. package/src/actions/upload.ts +35 -40
  14. package/src/clients/upChunkObservable.ts +5 -1
  15. package/src/components/ConfigureApi.tsx +0 -1
  16. package/src/components/FileInputArea.tsx +92 -0
  17. package/src/components/FileInputButton.tsx +3 -2
  18. package/src/components/FileInputMenuItem.styled.tsx +2 -2
  19. package/src/components/FileInputMenuItem.tsx +2 -10
  20. package/src/components/ImportVideosFromMux.tsx +317 -0
  21. package/src/components/Input.tsx +3 -3
  22. package/src/components/PlayerActionsMenu.tsx +14 -12
  23. package/src/components/SelectAsset.tsx +1 -1
  24. package/src/components/StudioTool.tsx +11 -6
  25. package/src/components/TextTracksEditor.tsx +214 -0
  26. package/src/components/UploadConfiguration.tsx +390 -0
  27. package/src/components/UploadPlaceholder.tsx +41 -55
  28. package/src/components/Uploader.styled.tsx +0 -1
  29. package/src/components/Uploader.tsx +384 -0
  30. package/src/components/VideoDetails/DeleteDialog.tsx +20 -24
  31. package/src/components/VideoDetails/VideoDetails.tsx +8 -1
  32. package/src/components/VideoMetadata.tsx +4 -1
  33. package/src/components/VideoPlayer.tsx +33 -5
  34. package/src/components/VideoThumbnail.tsx +21 -7
  35. package/src/components/VideosBrowser.tsx +6 -3
  36. package/src/components/withFocusRing/withFocusRing.ts +20 -22
  37. package/src/hooks/useClient.ts +1 -1
  38. package/src/hooks/useImportMuxAssets.ts +127 -0
  39. package/src/hooks/useMuxAssets.ts +168 -0
  40. package/src/plugin.tsx +5 -5
  41. package/src/util/asserters.ts +9 -0
  42. package/src/util/createSearchFilter.ts +5 -7
  43. package/src/util/formatBytes.ts +32 -0
  44. package/src/util/generateJwt.ts +7 -6
  45. package/src/util/getAnimatedPosterSrc.ts +1 -1
  46. package/src/util/getPlaybackId.ts +1 -1
  47. package/src/util/getPlaybackPolicy.ts +1 -1
  48. package/src/util/getVideoMetadata.ts +2 -1
  49. package/src/util/parsers.ts +5 -0
  50. package/src/util/types.ts +195 -12
  51. package/lib/index.cjs.js +0 -5
  52. package/src/components/__legacy__Uploader.tsx +0 -280
  53. package/src/index.ts +0 -29
@@ -0,0 +1,210 @@
1
+ /// <reference types="react" />
2
+
3
+ import type {PartialDeep} from 'type-fest'
4
+ import {Plugin as Plugin_2} from 'sanity'
5
+
6
+ export declare const defaultConfig: PluginConfig
7
+
8
+ declare interface MuxAsset {
9
+ id: string
10
+ /** In seconds (instead of JS's default milliseconds) */
11
+ created_at: string
12
+ status: 'preparing' | 'ready' | 'errored'
13
+ duration: number
14
+ max_stored_resolution: 'Audio only' | 'SD' | 'HD' | 'FHD' | 'UHD'
15
+ max_stored_frame_rate: -1 | number
16
+ aspect_ratio: `${number}:${number}`
17
+ playback_ids: MuxPlaybackId[]
18
+ tracks: MuxTrack[]
19
+ errors?: MuxErrors
20
+ upload_id: string
21
+ is_live?: boolean
22
+ passthrough: string
23
+ live_stream_id?: string
24
+ master?: {
25
+ status: 'ready' | 'preparing' | 'errored'
26
+ url: string
27
+ }
28
+ master_access: 'temporary' | 'none'
29
+ mp4_support: 'standard' | 'none'
30
+ source_asset_id?: string
31
+ normalize_audio?: boolean
32
+ static_renditions?: {
33
+ status: 'ready' | 'preparing' | 'disabled' | 'errored'
34
+ files: {
35
+ name: 'low.mp4' | 'medium.mp4' | 'high.mp4' | 'audio.m4a'
36
+ ext: 'mp4' | 'm4a'
37
+ height: number
38
+ width: number
39
+ bitrate: number
40
+ filesize: number
41
+ }[]
42
+ }
43
+ recording_times?: {
44
+ started_at: string
45
+ duration: number
46
+ type: 'content' | 'slate'
47
+ }[]
48
+ non_standard_input_reasons?: {
49
+ video_codec?: string
50
+ audio_codec?: string
51
+ video_gop_size?: 'high'
52
+ video_frame_rate?: string
53
+ video_resolution?: string
54
+ video_bitrate?: 'high'
55
+ pixel_aspect_ratio?: string
56
+ video_edit_list?: 'non-standard'
57
+ audio_edit_list?: 'non-standard'
58
+ unexpected_media_file_parameters?: 'non-standard'
59
+ test?: boolean
60
+ }
61
+ }
62
+
63
+ declare interface MuxAudioTrack {
64
+ type: 'audio'
65
+ id: string
66
+ duration?: number
67
+ max_channels: number
68
+ max_channel_layout: 'stereo' | string
69
+ }
70
+
71
+ declare interface MuxErrors {
72
+ type: string
73
+ messages: string[]
74
+ }
75
+
76
+ export declare const muxInput: Plugin_2<void | Partial<PluginConfig>>
77
+
78
+ declare interface MuxInputConfig {
79
+ /**
80
+ * Enable static renditions by setting this to 'standard'. Can be overwritten on a per-asset basis.
81
+ * Requires `"encoding_tier": "smart"`
82
+ * @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
83
+ * @defaultValue 'none'
84
+ */
85
+ mp4_support: 'none' | 'standard'
86
+ /**
87
+ * Max resolution tier can be used to control the maximum resolution_tier your asset is encoded, stored, and streamed at.
88
+ * Requires `"encoding_tier": "smart"`
89
+ * @see {@link https://docs.mux.com/guides/stream-videos-in-4k}
90
+ * @defaultValue '1080p'
91
+ */
92
+ max_resolution_tier: '2160p' | '1440p' | '1080p'
93
+ /**
94
+ * The encoding tier informs the cost, quality, and available platform features for the asset.
95
+ * @see {@link https://docs.mux.com/guides/use-encoding-tiers}
96
+ * @defaultValue 'smart'
97
+ */
98
+ encoding_tier: 'baseline' | 'smart'
99
+ /**
100
+ * Normalize the audio track loudness level.
101
+ * @see {@link https://docs.mux.com/guides/adjust-audio-levels#how-to-turn-on-audio-normalization}
102
+ * @defaultValue false
103
+ */
104
+ normalize_audio: boolean
105
+ /**
106
+ * Enables signed URLs by default, if you configured them with your API token.
107
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
108
+ * @defaultValue false
109
+ */
110
+ defaultSigned?: boolean
111
+ /**
112
+ * Auto-generate captions for these languages by default.
113
+ * Requires `"encoding_tier": "smart"`
114
+ *
115
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
116
+ * @defaultValue false
117
+ */
118
+ defaultAutogeneratedSubtitleLangs?: SupportedMuxLanguage[]
119
+ /**
120
+ * Whether or not to allow content editors to override asset upload
121
+ * configuration settings when uploading a video to Mux.
122
+ *
123
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
124
+ * @defaultValue false
125
+ */
126
+ disableUploadConfig?: boolean
127
+ /**
128
+ * Whether or not to allow content editors to add text tracks alongside their
129
+ * asset when uploading a video to Mux.
130
+ *
131
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
132
+ * @defaultValue false
133
+ */
134
+ disableTextTrackConfig?: boolean
135
+ }
136
+
137
+ declare interface MuxPlaybackId {
138
+ id: string
139
+ policy: PlaybackPolicy
140
+ }
141
+
142
+ declare type MuxTrack = MuxVideoTrack | MuxAudioTrack
143
+
144
+ declare interface MuxVideoTrack {
145
+ type: 'video'
146
+ id: string
147
+ max_width: number
148
+ max_height: number
149
+ max_frame_rate: -1 | number
150
+ duration?: number
151
+ }
152
+
153
+ declare type PlaybackPolicy = 'signed' | 'public'
154
+
155
+ declare interface PluginConfig extends MuxInputConfig {
156
+ /**
157
+ * How the videos browser should appear as a studio tool in Sanity's top navigation
158
+ *
159
+ * Pass `false` if you want to disable it.
160
+ * @defaultValue {title: 'Videos', icon: VideoIcon}
161
+ **/
162
+ tool:
163
+ | false
164
+ | {
165
+ title?: string
166
+ icon?: React.ComponentType
167
+ }
168
+ }
169
+
170
+ declare const SUPPORTED_MUX_LANGUAGES_VALUES: (
171
+ | 'en'
172
+ | 'es'
173
+ | 'it'
174
+ | 'pt'
175
+ | 'de'
176
+ | 'fr'
177
+ | 'pl'
178
+ | 'ru'
179
+ | 'nl'
180
+ | 'ca'
181
+ | 'tr'
182
+ | 'sv'
183
+ | 'uk'
184
+ | 'no'
185
+ | 'fi'
186
+ | 'sk'
187
+ | 'el'
188
+ | 'cs'
189
+ | 'hr'
190
+ | 'da'
191
+ | 'ro'
192
+ | 'bg'
193
+ )[]
194
+
195
+ declare type SupportedMuxLanguage = (typeof SUPPORTED_MUX_LANGUAGES_VALUES)[number]
196
+
197
+ export declare interface VideoAssetDocument {
198
+ _id: string
199
+ _type: 'mux.videoAsset'
200
+ _createdAt: string
201
+ _updatedAt?: string
202
+ status?: string
203
+ assetId?: string
204
+ playbackId?: string
205
+ filename?: string
206
+ thumbTime?: number
207
+ data?: PartialDeep<MuxAsset>
208
+ }
209
+
210
+ export {}
package/lib/index.d.ts CHANGED
@@ -2,32 +2,12 @@
2
2
 
3
3
  import type {PartialDeep} from 'type-fest'
4
4
  import {Plugin as Plugin_2} from 'sanity'
5
- import type {SanityDocument} from 'sanity'
6
5
 
7
- declare interface Config {
8
- /**
9
- * Enable static renditions by setting this to 'standard'
10
- * @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
11
- * @defaultValue 'none'
12
- */
13
- mp4_support: 'none' | 'standard'
14
- /**
15
- * How the videos browser should appear as a studio tool in Sanity's top navigation
16
- *
17
- * Pass `false` if you want to disable it.
18
- **/
19
- tool?:
20
- | false
21
- | {
22
- title?: string
23
- icon?: React.ComponentType
24
- }
25
- }
26
-
27
- export declare const defaultConfig: Config
6
+ export declare const defaultConfig: PluginConfig
28
7
 
29
8
  declare interface MuxAsset {
30
9
  id: string
10
+ /** In seconds (instead of JS's default milliseconds) */
31
11
  created_at: string
32
12
  status: 'preparing' | 'ready' | 'errored'
33
13
  duration: number
@@ -93,7 +73,66 @@ declare interface MuxErrors {
93
73
  messages: string[]
94
74
  }
95
75
 
96
- export declare const muxInput: Plugin_2<void | Partial<Config>>
76
+ export declare const muxInput: Plugin_2<void | Partial<PluginConfig>>
77
+
78
+ declare interface MuxInputConfig {
79
+ /**
80
+ * Enable static renditions by setting this to 'standard'. Can be overwritten on a per-asset basis.
81
+ * Requires `"encoding_tier": "smart"`
82
+ * @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
83
+ * @defaultValue 'none'
84
+ */
85
+ mp4_support: 'none' | 'standard'
86
+ /**
87
+ * Max resolution tier can be used to control the maximum resolution_tier your asset is encoded, stored, and streamed at.
88
+ * Requires `"encoding_tier": "smart"`
89
+ * @see {@link https://docs.mux.com/guides/stream-videos-in-4k}
90
+ * @defaultValue '1080p'
91
+ */
92
+ max_resolution_tier: '2160p' | '1440p' | '1080p'
93
+ /**
94
+ * The encoding tier informs the cost, quality, and available platform features for the asset.
95
+ * @see {@link https://docs.mux.com/guides/use-encoding-tiers}
96
+ * @defaultValue 'smart'
97
+ */
98
+ encoding_tier: 'baseline' | 'smart'
99
+ /**
100
+ * Normalize the audio track loudness level.
101
+ * @see {@link https://docs.mux.com/guides/adjust-audio-levels#how-to-turn-on-audio-normalization}
102
+ * @defaultValue false
103
+ */
104
+ normalize_audio: boolean
105
+ /**
106
+ * Enables signed URLs by default, if you configured them with your API token.
107
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
108
+ * @defaultValue false
109
+ */
110
+ defaultSigned?: boolean
111
+ /**
112
+ * Auto-generate captions for these languages by default.
113
+ * Requires `"encoding_tier": "smart"`
114
+ *
115
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
116
+ * @defaultValue false
117
+ */
118
+ defaultAutogeneratedSubtitleLangs?: SupportedMuxLanguage[]
119
+ /**
120
+ * Whether or not to allow content editors to override asset upload
121
+ * configuration settings when uploading a video to Mux.
122
+ *
123
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
124
+ * @defaultValue false
125
+ */
126
+ disableUploadConfig?: boolean
127
+ /**
128
+ * Whether or not to allow content editors to add text tracks alongside their
129
+ * asset when uploading a video to Mux.
130
+ *
131
+ * @see {@link https://docs.mux.com/guides/secure-video-playback}
132
+ * @defaultValue false
133
+ */
134
+ disableTextTrackConfig?: boolean
135
+ }
97
136
 
98
137
  declare interface MuxPlaybackId {
99
138
  id: string
@@ -113,8 +152,53 @@ declare interface MuxVideoTrack {
113
152
 
114
153
  declare type PlaybackPolicy = 'signed' | 'public'
115
154
 
116
- export declare interface VideoAssetDocument extends SanityDocument {
117
- type?: 'mux.videoAsset'
155
+ declare interface PluginConfig extends MuxInputConfig {
156
+ /**
157
+ * How the videos browser should appear as a studio tool in Sanity's top navigation
158
+ *
159
+ * Pass `false` if you want to disable it.
160
+ * @defaultValue {title: 'Videos', icon: VideoIcon}
161
+ **/
162
+ tool:
163
+ | false
164
+ | {
165
+ title?: string
166
+ icon?: React.ComponentType
167
+ }
168
+ }
169
+
170
+ declare const SUPPORTED_MUX_LANGUAGES_VALUES: (
171
+ | 'en'
172
+ | 'es'
173
+ | 'it'
174
+ | 'pt'
175
+ | 'de'
176
+ | 'fr'
177
+ | 'pl'
178
+ | 'ru'
179
+ | 'nl'
180
+ | 'ca'
181
+ | 'tr'
182
+ | 'sv'
183
+ | 'uk'
184
+ | 'no'
185
+ | 'fi'
186
+ | 'sk'
187
+ | 'el'
188
+ | 'cs'
189
+ | 'hr'
190
+ | 'da'
191
+ | 'ro'
192
+ | 'bg'
193
+ )[]
194
+
195
+ declare type SupportedMuxLanguage = (typeof SUPPORTED_MUX_LANGUAGES_VALUES)[number]
196
+
197
+ export declare interface VideoAssetDocument {
198
+ _id: string
199
+ _type: 'mux.videoAsset'
200
+ _createdAt: string
201
+ _updatedAt?: string
118
202
  status?: string
119
203
  assetId?: string
120
204
  playbackId?: string