sanity-plugin-mux-input 2.13.0 → 2.15.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 (56) hide show
  1. package/README.md +25 -24
  2. package/dist/index.d.mts +35 -2
  3. package/dist/index.d.ts +35 -2
  4. package/dist/index.js +2176 -461
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +2178 -463
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +1 -1
  9. package/src/_exports/index.ts +1 -0
  10. package/src/actions/assets.ts +75 -0
  11. package/src/actions/secrets.ts +6 -1
  12. package/src/actions/upload.ts +1 -1
  13. package/src/components/AddCaptionDialog.tsx +421 -0
  14. package/src/components/CaptionsDialog.tsx +23 -0
  15. package/src/components/ConfigureApi.tsx +51 -5
  16. package/src/components/EditCaptionDialog.tsx +508 -0
  17. package/src/components/InputBrowser.tsx +8 -2
  18. package/src/components/Onboard.tsx +2 -2
  19. package/src/components/PageSelector.tsx +54 -0
  20. package/src/components/Player.styled.tsx +7 -2
  21. package/src/components/PlayerActionsMenu.tsx +14 -6
  22. package/src/components/SelectAsset.tsx +9 -3
  23. package/src/components/StudioTool.tsx +2 -2
  24. package/src/components/TextTracksManager.tsx +781 -0
  25. package/src/components/UploadConfiguration.tsx +104 -343
  26. package/src/components/Uploader.styled.tsx +8 -15
  27. package/src/components/Uploader.tsx +25 -7
  28. package/src/components/VideoDetails/VideoDetails.tsx +43 -7
  29. package/src/components/VideoInBrowser.tsx +53 -6
  30. package/src/components/VideoPlayer.tsx +122 -47
  31. package/src/components/VideoThumbnail.tsx +84 -72
  32. package/src/components/VideosBrowser.tsx +15 -5
  33. package/src/components/uploadConfiguration/PlaybackPolicy.tsx +95 -6
  34. package/src/components/uploadConfiguration/PlaybackPolicyOption.tsx +26 -10
  35. package/src/components/uploadConfiguration/ResolutionTierSelector.tsx +71 -0
  36. package/src/components/uploadConfiguration/StaticRenditionSelector.tsx +179 -0
  37. package/src/context/DrmPlaybackWarningContext.tsx +93 -0
  38. package/src/hooks/useAccessControl.ts +1 -0
  39. package/src/hooks/useDialogState.ts +1 -1
  40. package/src/hooks/useFetchFileSize.ts +54 -0
  41. package/src/hooks/useMediaMetadata.ts +100 -0
  42. package/src/hooks/useSaveSecrets.ts +10 -3
  43. package/src/hooks/useSecretsDocumentValues.ts +9 -1
  44. package/src/hooks/useSecretsFormState.ts +6 -3
  45. package/src/util/asserters.ts +14 -0
  46. package/src/util/createUrlParamsObject.ts +7 -3
  47. package/src/util/generateJwt.ts +11 -2
  48. package/src/util/getPlaybackPolicy.ts +63 -4
  49. package/src/util/getStoryboardSrc.ts +7 -3
  50. package/src/util/getVideoMetadata.ts +4 -1
  51. package/src/util/getVideoSrc.ts +9 -9
  52. package/src/util/readSecrets.ts +3 -1
  53. package/src/util/textTracks.ts +222 -0
  54. package/src/util/tryWithSuspend.ts +22 -0
  55. package/src/util/types.ts +39 -6
  56. package/src/util/getPlaybackId.ts +0 -9
package/README.md CHANGED
@@ -341,41 +341,42 @@ export default defineConfig({
341
341
  You can also configure `acceptedMimeTypes` for individual fields in your schema, which will override the plugin-level configuration:
342
342
 
343
343
  ```js
344
- import { defineField, defineType } from "sanity";
344
+ import {defineField, defineType} from 'sanity'
345
345
 
346
346
  export default defineType({
347
- name: "muxTest",
348
- title: "Mux Files",
349
- type: "document",
347
+ name: 'muxTest',
348
+ title: 'Mux Files',
349
+ type: 'document',
350
350
  fields: [
351
351
  defineField({
352
- name: "audioFile",
353
- title: "Audio File",
354
- type: "mux.video",
352
+ name: 'audioFile',
353
+ title: 'Audio File',
354
+ type: 'mux.video',
355
355
  options: {
356
- acceptedMimeTypes: ["audio/*"],
356
+ acceptedMimeTypes: ['audio/*'],
357
357
  },
358
358
  }),
359
359
  defineField({
360
- name: "videoFile",
361
- title: "Video File",
362
- type: "mux.video",
360
+ name: 'videoFile',
361
+ title: 'Video File',
362
+ type: 'mux.video',
363
363
  options: {
364
- acceptedMimeTypes: ["video/*"],
364
+ acceptedMimeTypes: ['video/*'],
365
365
  },
366
366
  }),
367
367
  defineField({
368
- name: "either",
369
- title: "Either File",
370
- type: "mux.video",
368
+ name: 'either',
369
+ title: 'Either File',
370
+ type: 'mux.video',
371
371
  }),
372
372
  ],
373
- });
373
+ })
374
374
  ```
375
375
 
376
376
  The `acceptedMimeTypes` option controls the `accept` attribute on the file input, which filters which file types users can select when uploading. This affects both the file picker dialog and drag-and-drop file validation.
377
377
 
378
378
  📌 **Note**: This option accepts an array of MIME type patterns. The valid values are:
379
+
379
380
  - `'video/*'` - Accepts all video file types
380
381
  - `'audio/*'` - Accepts all audio file types
381
382
 
@@ -407,17 +408,17 @@ export default defineConfig({
407
408
  You can override the global limits for specific fields, allowing different validation rules for different use cases:
408
409
 
409
410
  ```js
410
- import { defineType, defineField } from "sanity";
411
+ import {defineType, defineField} from 'sanity'
411
412
 
412
413
  export default defineType({
413
- name: "muxTest",
414
- title: "Mux Files",
415
- type: "document",
414
+ name: 'muxTest',
415
+ title: 'Mux Files',
416
+ type: 'document',
416
417
  fields: [
417
418
  defineField({
418
- name: "shortVideo",
419
- title: "Short Video (max 1 minute)",
420
- type: "mux.video",
419
+ name: 'shortVideo',
420
+ title: 'Short Video (max 1 minute)',
421
+ type: 'mux.video',
421
422
  options: {
422
423
  maxAssetFileSize: 100 * 1024 * 1024, // 100 MB
423
424
  maxAssetDuration: 60, // 1 minute
@@ -438,7 +439,7 @@ export default defineType({
438
439
  type: 'mux.video',
439
440
  // Uses plugin defaults or no validation if not configured
440
441
  }),
441
- ]
442
+ ],
442
443
  })
443
444
  ```
444
445
 
package/dist/index.d.mts CHANGED
@@ -142,6 +142,12 @@ declare interface MuxInputConfig {
142
142
  * @defaultValue true
143
143
  */
144
144
  defaultPublic?: boolean
145
+ /**
146
+ * Enables DRM Protection by default, if you configured your DRM Configuration Id.
147
+ * @see {@link https://www.mux.com/docs/guides/protect-videos-with-drm}
148
+ * @defaultValue true
149
+ */
150
+ defaultDrm?: boolean
145
151
  /**
146
152
  * Auto-generate captions for these languages by default.
147
153
  * Requires `"video_quality": "plus"`
@@ -173,6 +179,12 @@ declare interface MuxInputConfig {
173
179
  * @defaultValue false
174
180
  */
175
181
  disableTextTrackConfig?: boolean
182
+ /**
183
+ * Whether or not to show the playback warning when trying to watch DRM content for the first time.
184
+ *
185
+ * @defaultValue false
186
+ */
187
+ disableDrmPlaybackWarning?: boolean
176
188
  /**
177
189
  * The mime types that are accepted by the input.
178
190
  *
@@ -220,7 +232,28 @@ declare interface MuxPlaybackId {
220
232
  policy: PlaybackPolicy
221
233
  }
222
234
 
223
- declare type MuxTrack = MuxVideoTrack | MuxAudioTrack
235
+ declare interface MuxTextTrack {
236
+ type: 'text'
237
+ id: string
238
+ text_type?: 'subtitles'
239
+ text_source?:
240
+ | 'uploaded'
241
+ | 'embedded'
242
+ | 'generated_live'
243
+ | 'generated_live_final'
244
+ | 'generated_vod'
245
+ language_code?: 'en' | 'en-US' | string
246
+ name?: 'English' | string
247
+ closed_captions?: boolean
248
+ passthrough?: string
249
+ status: 'preparing' | 'ready' | 'errored'
250
+ error?: {
251
+ type: string
252
+ messages?: string[]
253
+ }
254
+ }
255
+
256
+ declare type MuxTrack = MuxVideoTrack | MuxAudioTrack | MuxTextTrack
224
257
 
225
258
  declare interface MuxVideoTrack {
226
259
  type: 'video'
@@ -231,7 +264,7 @@ declare interface MuxVideoTrack {
231
264
  duration?: number
232
265
  }
233
266
 
234
- declare type PlaybackPolicy = 'signed' | 'public'
267
+ declare type PlaybackPolicy = 'signed' | 'public' | 'drm'
235
268
 
236
269
  declare interface PluginConfig extends MuxInputConfig {
237
270
  /**
package/dist/index.d.ts CHANGED
@@ -142,6 +142,12 @@ declare interface MuxInputConfig {
142
142
  * @defaultValue true
143
143
  */
144
144
  defaultPublic?: boolean
145
+ /**
146
+ * Enables DRM Protection by default, if you configured your DRM Configuration Id.
147
+ * @see {@link https://www.mux.com/docs/guides/protect-videos-with-drm}
148
+ * @defaultValue true
149
+ */
150
+ defaultDrm?: boolean
145
151
  /**
146
152
  * Auto-generate captions for these languages by default.
147
153
  * Requires `"video_quality": "plus"`
@@ -173,6 +179,12 @@ declare interface MuxInputConfig {
173
179
  * @defaultValue false
174
180
  */
175
181
  disableTextTrackConfig?: boolean
182
+ /**
183
+ * Whether or not to show the playback warning when trying to watch DRM content for the first time.
184
+ *
185
+ * @defaultValue false
186
+ */
187
+ disableDrmPlaybackWarning?: boolean
176
188
  /**
177
189
  * The mime types that are accepted by the input.
178
190
  *
@@ -220,7 +232,28 @@ declare interface MuxPlaybackId {
220
232
  policy: PlaybackPolicy
221
233
  }
222
234
 
223
- declare type MuxTrack = MuxVideoTrack | MuxAudioTrack
235
+ declare interface MuxTextTrack {
236
+ type: 'text'
237
+ id: string
238
+ text_type?: 'subtitles'
239
+ text_source?:
240
+ | 'uploaded'
241
+ | 'embedded'
242
+ | 'generated_live'
243
+ | 'generated_live_final'
244
+ | 'generated_vod'
245
+ language_code?: 'en' | 'en-US' | string
246
+ name?: 'English' | string
247
+ closed_captions?: boolean
248
+ passthrough?: string
249
+ status: 'preparing' | 'ready' | 'errored'
250
+ error?: {
251
+ type: string
252
+ messages?: string[]
253
+ }
254
+ }
255
+
256
+ declare type MuxTrack = MuxVideoTrack | MuxAudioTrack | MuxTextTrack
224
257
 
225
258
  declare interface MuxVideoTrack {
226
259
  type: 'video'
@@ -231,7 +264,7 @@ declare interface MuxVideoTrack {
231
264
  duration?: number
232
265
  }
233
266
 
234
- declare type PlaybackPolicy = 'signed' | 'public'
267
+ declare type PlaybackPolicy = 'signed' | 'public' | 'drm'
235
268
 
236
269
  declare interface PluginConfig extends MuxInputConfig {
237
270
  /**