sanity-plugin-mux-input 3.0.4 → 4.0.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 (130) hide show
  1. package/README.md +0 -2
  2. package/dist/index.d.ts +134 -193
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +2893 -4417
  5. package/dist/index.js.map +1 -1
  6. package/package.json +33 -43
  7. package/dist/index.cjs +0 -7270
  8. package/dist/index.cjs.map +0 -1
  9. package/dist/index.d.cts +0 -347
  10. package/sanity.json +0 -8
  11. package/src/_exports/index.ts +0 -73
  12. package/src/actions/assets.ts +0 -152
  13. package/src/actions/secrets.ts +0 -111
  14. package/src/actions/upload.ts +0 -310
  15. package/src/clients/upChunkObservable.ts +0 -54
  16. package/src/components/AddCaptionDialog.tsx +0 -440
  17. package/src/components/CaptionsDialog.tsx +0 -23
  18. package/src/components/ConfigureApi.styled.tsx +0 -19
  19. package/src/components/ConfigureApi.tsx +0 -296
  20. package/src/components/DraggableWatermark.tsx +0 -877
  21. package/src/components/EditCaptionDialog.tsx +0 -510
  22. package/src/components/EditThumbnailDialog.tsx +0 -122
  23. package/src/components/ErrorBoundaryCard.tsx +0 -96
  24. package/src/components/FileInputButton.tsx +0 -54
  25. package/src/components/FileInputMenuItem.styled.tsx +0 -36
  26. package/src/components/FileInputMenuItem.tsx +0 -85
  27. package/src/components/FormField.tsx +0 -38
  28. package/src/components/IconInfo.tsx +0 -22
  29. package/src/components/ImportVideosFromMux.tsx +0 -342
  30. package/src/components/Input.styled.tsx +0 -22
  31. package/src/components/Input.tsx +0 -78
  32. package/src/components/InputBrowser.tsx +0 -41
  33. package/src/components/InputError.tsx +0 -17
  34. package/src/components/MuxLogo.tsx +0 -42
  35. package/src/components/Onboard.tsx +0 -65
  36. package/src/components/PageSelector.tsx +0 -54
  37. package/src/components/Player.styled.tsx +0 -55
  38. package/src/components/Player.tsx +0 -117
  39. package/src/components/PlayerActionsMenu.tsx +0 -190
  40. package/src/components/ResyncMetadata.tsx +0 -280
  41. package/src/components/SelectAsset.tsx +0 -39
  42. package/src/components/SelectSortOptions.tsx +0 -45
  43. package/src/components/SpinnerBox.tsx +0 -16
  44. package/src/components/StudioTool.tsx +0 -24
  45. package/src/components/TextTracksEditor.tsx +0 -117
  46. package/src/components/TextTracksManager.tsx +0 -737
  47. package/src/components/UploadConfiguration.tsx +0 -694
  48. package/src/components/UploadPlaceholder.tsx +0 -88
  49. package/src/components/UploadProgress.tsx +0 -80
  50. package/src/components/Uploader.styled.tsx +0 -66
  51. package/src/components/Uploader.tsx +0 -498
  52. package/src/components/VideoDetails/DeleteDialog.tsx +0 -147
  53. package/src/components/VideoDetails/VideoDetails.tsx +0 -358
  54. package/src/components/VideoDetails/VideoReferences.tsx +0 -63
  55. package/src/components/VideoDetails/useVideoDetails.ts +0 -103
  56. package/src/components/VideoInBrowser.tsx +0 -245
  57. package/src/components/VideoMetadata.tsx +0 -45
  58. package/src/components/VideoPlayer.tsx +0 -235
  59. package/src/components/VideoThumbnail.tsx +0 -138
  60. package/src/components/VideosBrowser.tsx +0 -100
  61. package/src/components/documentPreview/DocumentPreview.tsx +0 -83
  62. package/src/components/documentPreview/DraftStatus.tsx +0 -34
  63. package/src/components/documentPreview/MissingSchemaType.tsx +0 -32
  64. package/src/components/documentPreview/PaneItemPreview.tsx +0 -74
  65. package/src/components/documentPreview/PublishedStatus.tsx +0 -35
  66. package/src/components/documentPreview/TimeAgo.tsx +0 -12
  67. package/src/components/documentPreview/paneItemTypes.ts +0 -7
  68. package/src/components/icons/Audio.tsx +0 -13
  69. package/src/components/icons/Resolution.tsx +0 -12
  70. package/src/components/icons/StopWatch.tsx +0 -20
  71. package/src/components/icons/ToolIcon.tsx +0 -19
  72. package/src/components/uploadConfiguration/PlaybackPolicy.tsx +0 -133
  73. package/src/components/uploadConfiguration/PlaybackPolicyOption.tsx +0 -76
  74. package/src/components/uploadConfiguration/PlaybackPolicyWarning.tsx +0 -29
  75. package/src/components/uploadConfiguration/ResolutionTierSelector.tsx +0 -72
  76. package/src/components/uploadConfiguration/StaticRenditionSelector.tsx +0 -180
  77. package/src/components/withFocusRing/helpers.ts +0 -24
  78. package/src/components/withFocusRing/index.ts +0 -1
  79. package/src/components/withFocusRing/withFocusRing.ts +0 -30
  80. package/src/context/DialogStateContext.tsx +0 -36
  81. package/src/context/DrmPlaybackWarningContext.tsx +0 -93
  82. package/src/hooks/useAccessControl.ts +0 -13
  83. package/src/hooks/useAssetDocumentValues.ts +0 -11
  84. package/src/hooks/useAssets.ts +0 -68
  85. package/src/hooks/useCancelUpload.ts +0 -22
  86. package/src/hooks/useClient.ts +0 -8
  87. package/src/hooks/useDialogState.ts +0 -11
  88. package/src/hooks/useDocReferences.ts +0 -21
  89. package/src/hooks/useFetchFileSize.ts +0 -54
  90. package/src/hooks/useImportMuxAssets.ts +0 -132
  91. package/src/hooks/useInView.ts +0 -42
  92. package/src/hooks/useMediaMetadata.ts +0 -103
  93. package/src/hooks/useMuxAssets.ts +0 -179
  94. package/src/hooks/useMuxPolling.ts +0 -49
  95. package/src/hooks/useResyncAsset.ts +0 -110
  96. package/src/hooks/useResyncMuxMetadata.ts +0 -176
  97. package/src/hooks/useSaveSecrets.ts +0 -78
  98. package/src/hooks/useSecretsDocumentValues.ts +0 -38
  99. package/src/hooks/useSecretsFormState.ts +0 -47
  100. package/src/plugin.tsx +0 -31
  101. package/src/sanity-ui.d.ts +0 -5
  102. package/src/schema.ts +0 -196
  103. package/src/util/addKeysToMuxData.ts +0 -30
  104. package/src/util/areSecretsSignable.ts +0 -5
  105. package/src/util/asserters.ts +0 -36
  106. package/src/util/assetTitlePlaceholder.ts +0 -31
  107. package/src/util/constants.ts +0 -15
  108. package/src/util/convertWatermarkToMux.ts +0 -160
  109. package/src/util/createSearchFilter.ts +0 -76
  110. package/src/util/createUrlParamsObject.ts +0 -29
  111. package/src/util/extractFiles.ts +0 -67
  112. package/src/util/formatBytes.ts +0 -32
  113. package/src/util/formatDriveShareLink.ts +0 -64
  114. package/src/util/formatSeconds.ts +0 -49
  115. package/src/util/generateJwt.ts +0 -57
  116. package/src/util/getAnimatedPosterSrc.ts +0 -26
  117. package/src/util/getPlaybackPolicy.ts +0 -69
  118. package/src/util/getPosterSrc.ts +0 -28
  119. package/src/util/getStoryboardSrc.ts +0 -27
  120. package/src/util/getVideoMetadata.ts +0 -23
  121. package/src/util/getVideoSrc.ts +0 -23
  122. package/src/util/isSigned.ts +0 -20
  123. package/src/util/parsers.ts +0 -5
  124. package/src/util/pluginVersion.ts +0 -1
  125. package/src/util/readSecrets.ts +0 -38
  126. package/src/util/roundPxString.ts +0 -16
  127. package/src/util/textTracks.ts +0 -222
  128. package/src/util/tryWithSuspend.ts +0 -22
  129. package/src/util/types.ts +0 -596
  130. package/v2-incompatible.js +0 -11
package/src/util/types.ts DELETED
@@ -1,596 +0,0 @@
1
- import type MuxPlayerElement from '@mux/mux-player'
2
- import type {ObjectInputProps, PreviewLayoutKey, PreviewProps, SchemaType} from 'sanity'
3
- import type {PartialDeep} from 'type-fest'
4
-
5
- /**
6
- * Standard static rendition options available for plugin configuration defaults
7
- */
8
- export type StandardRendition = 'highest' | 'audio-only'
9
-
10
- /**
11
- * All static rendition resolution options supported by Mux
12
- */
13
- export type StaticRenditionResolution =
14
- | 'highest'
15
- | 'audio-only'
16
- | '270p'
17
- | '360p'
18
- | '480p'
19
- | '540p'
20
- | '720p'
21
- | '1080p'
22
- | '1440p'
23
- | '2160p'
24
-
25
- export interface MuxInputConfig {
26
- /**
27
- * Enable static renditions by default. Can be overwritten on a per-asset basis.
28
- * Supports:
29
- * - Standard mode: 'highest' (up to 4K MP4) and/or 'audio-only' (M4A)
30
- * - Advanced mode: Specific resolutions ('270p', '360p', '480p', '540p', '720p', '1080p', '1440p', '2160p') and/or 'audio-only'
31
- *
32
- * **Important**: 'highest' cannot be mixed with specific resolutions. If both are provided, only 'highest' will be used.
33
- *
34
- * @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions}
35
- * @defaultValue []
36
- */
37
- static_renditions: StaticRenditionResolution[]
38
-
39
- /**
40
- * @deprecated Use `static_renditions` instead. This field is kept for backward compatibility.
41
- * Enable static renditions by setting this to 'standard'. Can be overwritten on a per-asset basis.
42
- * Requires `"video_quality": "plus"`
43
- * @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
44
- * @defaultValue 'none'
45
- */
46
- mp4_support: 'none' | 'standard'
47
-
48
- /**
49
- * Max resolution tier can be used to control the maximum resolution_tier your asset is encoded, stored, and streamed at.
50
- * Requires `"video_quality": "plus"`
51
- * @see {@link https://docs.mux.com/guides/stream-videos-in-4k}
52
- * @defaultValue '1080p'
53
- */
54
- max_resolution_tier: '2160p' | '1440p' | '1080p'
55
-
56
- /**
57
- * @deprecated Use {@link video_quality}
58
- * <br>
59
- * The encoding tier informs the cost, quality, and available platform features for the asset.
60
- * @see {@link https://docs.mux.com/guides/use-encoding-tiers}
61
- * @defaultValue 'smart'
62
- */
63
- encoding_tier?: 'baseline' | 'smart'
64
-
65
- /**
66
- * The video quality level informs the cost, quality, and available platform features for the asset.
67
- * @see {@link https://www.mux.com/docs/guides/use-video-quality-levels}
68
- * @defaultValue 'plus'
69
- */
70
- video_quality: 'basic' | 'plus' | 'premium'
71
-
72
- /**
73
- * Normalize the audio track loudness level.
74
- * @see {@link https://docs.mux.com/guides/adjust-audio-levels#how-to-turn-on-audio-normalization}
75
- * @defaultValue false
76
- */
77
- normalize_audio: boolean
78
-
79
- /**
80
- * Enables signed URLs by default, if you configured them with your API token.
81
- * @see {@link https://docs.mux.com/guides/secure-video-playback}
82
- * @defaultValue false
83
- */
84
- defaultSigned?: boolean
85
-
86
- /**
87
- * Enables public URLs by default.
88
- * @defaultValue true
89
- */
90
- defaultPublic?: boolean
91
-
92
- /**
93
- * Enables DRM Protection by default, if you configured your DRM Configuration Id.
94
- * @see {@link https://www.mux.com/docs/guides/protect-videos-with-drm}
95
- * @defaultValue true
96
- */
97
- defaultDrm?: boolean
98
-
99
- /**
100
- * Auto-generate captions for these languages by default.
101
- * Requires `"video_quality": "plus"`
102
- *
103
- * @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
104
- * @deprecated use `defaultAutogeneratedSubtitleLang` instead. Only a single autogenerated
105
- */
106
- defaultAutogeneratedSubtitleLangs?: SupportedMuxLanguage[]
107
-
108
- /**
109
- * Auto-generate captions for this language by default. Users can still
110
- * Requires `"video_quality": "plus"`
111
- *
112
- * @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
113
- */
114
- defaultAutogeneratedSubtitleLang?: SupportedMuxLanguage
115
-
116
- /**
117
- * Whether or not to allow content editors to override asset upload
118
- * configuration settings when uploading a video to Mux.
119
- *
120
- * @see {@link https://docs.mux.com/guides/secure-video-playback}
121
- * @defaultValue false
122
- */
123
- disableUploadConfig?: boolean
124
-
125
- /**
126
- * Whether or not to allow content editors to add text tracks alongside their
127
- * asset when uploading a video to Mux.
128
- *
129
- * @see {@link https://docs.mux.com/guides/secure-video-playback}
130
- * @defaultValue false
131
- */
132
- disableTextTrackConfig?: boolean
133
-
134
- /**
135
- * Whether or not to show the playback warning when trying to watch DRM content for the first time.
136
- *
137
- * @defaultValue false
138
- */
139
- disableDrmPlaybackWarning?: boolean
140
-
141
- /**
142
- * The mime types that are accepted by the input.
143
- *
144
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept}
145
- * @defaultValue ['video/*','audio/*']
146
-
147
- */
148
- acceptedMimeTypes?: ('audio/*' | 'video/*')[]
149
-
150
- /**
151
- * Maximum file size allowed for video uploads in bytes.
152
- * If not specified, no file size validation will be performed.
153
- *
154
- * @example 1024 * 1024 * 1024 // 1 GB
155
- * @defaultValue undefined
156
- */
157
- maxAssetFileSize?: number
158
-
159
- /**
160
- * Maximum video duration allowed in seconds.
161
- * If not specified, no duration validation will be performed.
162
- *
163
- * @example 2 * 60 * 60 // 2 hours
164
- * @defaultValue undefined
165
- */
166
- maxAssetDuration?: number
167
-
168
- /**
169
- * HLS.js configuration options to be passed to the Mux Player.
170
- * These options allow you to customize the underlying HLS.js playback engine behavior.
171
- *
172
- * @see {@link https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning}
173
- * @defaultValue undefined
174
- * @example
175
- * ```ts
176
- * {
177
- * maxBufferLength: 30,
178
- * lowLatencyMode: true,
179
- * capLevelToPlayerSize: true
180
- * }
181
- * ```
182
- */
183
- hlsConfig?: MuxPlayerElement['_hlsConfig']
184
- }
185
-
186
- export interface PluginConfig extends MuxInputConfig {
187
- /**
188
- * How the videos browser should appear as a studio tool in Sanity's top navigation
189
- *
190
- * Pass `false` if you want to disable it.
191
- * @defaultValue {title: 'Videos', icon: VideoIcon}
192
- **/
193
- tool:
194
- | false
195
- | {
196
- title?: string
197
- icon?: React.ComponentType
198
- }
199
-
200
- /**
201
- * The roles that are allowed to configure the plugin.
202
- *
203
- * If not set, all roles will be allowed to configure the plugin.
204
- * @defaultValue []
205
- */
206
- allowedRolesForConfiguration: string[]
207
- }
208
-
209
- export const SUPPORTED_MUX_LANGUAGES = [
210
- {label: 'English', code: 'en', state: 'Stable'},
211
- {label: 'Spanish', code: 'es', state: 'Stable'},
212
- {label: 'Italian', code: 'it', state: 'Stable'},
213
- {label: 'Portuguese', code: 'pt', state: 'Stable'},
214
- {label: 'German', code: 'de', state: 'Stable'},
215
- {label: 'French', code: 'fr', state: 'Stable'},
216
- {label: 'Polish', code: 'pl', state: 'Beta'},
217
- {label: 'Russian', code: 'ru', state: 'Beta'},
218
- {label: 'Dutch', code: 'nl', state: 'Beta'},
219
- {label: 'Catalan', code: 'ca', state: 'Beta'},
220
- {label: 'Turkish', code: 'tr', state: 'Beta'},
221
- {label: 'Swedish', code: 'sv', state: 'Beta'},
222
- {label: 'Ukrainian', code: 'uk', state: 'Beta'},
223
- {label: 'Norwegian', code: 'no', state: 'Beta'},
224
- {label: 'Finnish', code: 'fi', state: 'Beta'},
225
- {label: 'Slovak', code: 'sk', state: 'Beta'},
226
- {label: 'Greek', code: 'el', state: 'Beta'},
227
- {label: 'Czech', code: 'cs', state: 'Beta'},
228
- {label: 'Croatian', code: 'hr', state: 'Beta'},
229
- {label: 'Danish', code: 'da', state: 'Beta'},
230
- {label: 'Romanian', code: 'ro', state: 'Beta'},
231
- {label: 'Bulgarian', code: 'bg', state: 'Beta'},
232
- ] as const
233
-
234
- export const VIDEO_QUALITY_LEVELS = [
235
- {label: 'Basic', value: 'basic'},
236
- {label: 'Plus', value: 'plus'},
237
- {label: 'Premium', value: 'premium'},
238
- ] as const
239
-
240
- export const SUPPORTED_MUX_LANGUAGES_VALUES = SUPPORTED_MUX_LANGUAGES.map((l) => l.code)
241
-
242
- export type SupportedMuxLanguage = (typeof SUPPORTED_MUX_LANGUAGES_VALUES)[number]
243
-
244
- export interface TextTrack {
245
- _id: string
246
- name: string
247
- }
248
-
249
- export interface AutogeneratedTextTrack extends TextTrack {
250
- type: 'autogenerated'
251
- language_code: SupportedMuxLanguage
252
- }
253
-
254
- export interface CustomTextTrack extends TextTrack {
255
- type: 'subtitles' | 'captions'
256
- language_code: string
257
- file: {
258
- contents: string
259
- type: string
260
- name: string
261
- size: number
262
- }
263
- }
264
-
265
- export function isCustomTextTrack(track: Partial<UploadTextTrack>): track is CustomTextTrack {
266
- return track.type !== 'autogenerated'
267
- }
268
-
269
- export function isAutogeneratedTrack(
270
- track: Partial<UploadTextTrack>
271
- ): track is AutogeneratedTextTrack {
272
- return track.type === 'autogenerated'
273
- }
274
-
275
- export type UploadTextTrack = AutogeneratedTextTrack | CustomTextTrack
276
-
277
- /**
278
- * Watermark configuration for UI (draggable position)
279
- */
280
- export interface WatermarkConfig {
281
- enabled: boolean
282
- imageUrl?: string
283
- /**
284
- * Aspect ratio (width / height) of the watermark image.
285
- * Used to convert between our center-based UI coords and Mux overlay margins.
286
- */
287
- imageAspectRatio?: number
288
- /**
289
- * Optional explicit Mux `overlay_settings`.
290
- * When set, these values should be used as-is for the upload request and preview.
291
- * @see {@link https://www.mux.com/docs/guides/add-watermarks-to-your-videos}
292
- */
293
- overlay_settings?: MuxOverlaySettings
294
- position?: {
295
- x: number // percentage (0-100)
296
- y: number // percentage (0-100)
297
- }
298
- size?: number // percentage of video width (0-100)
299
- opacity?: number // 0-1 (converted to percentage string for Mux API)
300
- }
301
-
302
- /**
303
- * Mux overlay_settings format for watermark API
304
- * @see {@link https://www.mux.com/docs/guides/add-watermarks-to-your-videos}
305
- */
306
- export interface MuxOverlaySettings {
307
- vertical_align: 'top' | 'middle' | 'bottom'
308
- vertical_margin: string // percentage (e.g., "10%") or pixels (e.g., "40px")
309
- horizontal_align: 'left' | 'center' | 'right'
310
- horizontal_margin: string // percentage (e.g., "10%") or pixels (e.g., "40px")
311
- width?: string // percentage (e.g., "25%") or pixels (e.g., "80px")
312
- height?: string // percentage or pixels
313
- opacity?: string // percentage string (e.g., "90%")
314
- }
315
-
316
- export interface UploadConfig extends Pick<
317
- MuxInputConfig,
318
- 'max_resolution_tier' | 'normalize_audio' | 'video_quality'
319
- > {
320
- static_renditions: StaticRenditionResolution[]
321
- text_tracks: UploadTextTrack[]
322
- signed_policy: boolean
323
- public_policy: boolean
324
- watermark?: WatermarkConfig
325
- drm_policy: boolean
326
- }
327
-
328
- /**
329
- * Data sent to Mux to create a new asset.
330
- * @docs {@link https://docs.mux.com/api-reference#video/operation/create-direct-upload}
331
- */
332
- export interface MuxNewAssetSettings extends Pick<
333
- MuxInputConfig,
334
- 'max_resolution_tier' | 'normalize_audio' | 'video_quality'
335
- > {
336
- /** Static renditions configuration for downloadable files */
337
- static_renditions?: {resolution: StaticRenditionResolution}[]
338
- /** An array of objects that each describe an input file to be used to create the asset.*/
339
- input?: {
340
- /** The URL of the file that Mux should download and use. */
341
- url?: string
342
- /** Generate subtitle tracks using automatic speech recognition with this configuration. This may only be provided for the first input object (the main input file). */
343
- generated_subtitles?: {
344
- /** A name for this subtitle track. */
345
- name: string
346
- /** Arbitrary metadata set for the subtitle track. Max 255 characters. */
347
- passthrough?: string
348
- /** The language to generate subtitles in. */
349
- language_code: SupportedMuxLanguage
350
- }[]
351
- /** The time offset in seconds from the beginning of the video indicating the clip's starting marker. */
352
- start_time?: number
353
- /** The time offset in seconds from the beginning of the video indicating the clip's ending marker. */
354
- end_time?: number
355
- /** This parameter is required for text type tracks. */
356
- type?: 'video' | 'audio' | 'text'
357
- /** Type of text track. This parameter only supports subtitles value. */
358
- text_type?: 'subtitles'
359
- /** The language code value must be a valid BCP 47 specification compliant value. */
360
- language_code?: string
361
- /** The name of the track containing a human-readable description. This value must be unique within each group of text or audio track types. */
362
- name?: string
363
- /** Indicates the track provides Subtitles for the Deaf or Hard-of-hearing (SDH). */
364
- closed_captions?: boolean
365
- /** This optional parameter should be used tracks with type of text and text_type set to subtitles. */
366
- passthrough?: string
367
- /** Overlay settings for watermarks. Used when adding a watermark image as a second input. */
368
- overlay_settings?: MuxOverlaySettings
369
- }[]
370
-
371
- /** An array of playback policy names that you want applied to this asset and available through playback_ids. */
372
- playback_policy?: PlaybackPolicy[]
373
-
374
- /** An array of playback policy objects that you want applied to this asset and available through playback_ids. advanced_playback_policies must be used instead of playback_policies when creating a DRM playback ID. */
375
- advanced_playback_policies: AdvancedPlaybackPolicy[]
376
-
377
- /** Arbitrary user-supplied metadata that will be included in the asset details and related webhooks. */
378
- passthrough?: string
379
- }
380
-
381
- /** Used by advanced_playback_policies, allows to define DRM config. */
382
- export type AdvancedPlaybackPolicy = {
383
- policy: PlaybackPolicy
384
- drm_configuration_id?: string
385
- }
386
-
387
- export interface Secrets {
388
- token: string | null
389
- secretKey: string | null
390
- enableSignedUrls: boolean
391
- signingKeyId: string | null
392
- signingKeyPrivate: string | null
393
- drmConfigId: string | null
394
- }
395
-
396
- // This narrowed type indicates that there may be assets that are signed, and we have the secrets to access them
397
- // enabledSignedUrls might be false but that's only relevant for future uploads and their playback policy
398
- export interface SignableSecrets extends Omit<Secrets, 'signingKeyId' | 'signingKeyPrivate'> {
399
- signingKeyId: string
400
- signingKeyPrivate: string
401
- }
402
-
403
- export type MuxImageOrigin = `https://image.mux.com`
404
- export type MuxThumbnailUrl = `${MuxImageOrigin}/${string}/thumbnail.png?${string}`
405
- export type MuxAnimatedThumbnailUrl = `${MuxImageOrigin}/${string}/animated.gif?${string}`
406
- export type MuxStoryboardUrl = `${MuxImageOrigin}/${string}/storyboard.vtt?${string}`
407
- export type MuxVideoOrigin = `https://stream.mux.com`
408
- export type MuxVideoUrl = `${MuxVideoOrigin}/${string}.m3u8?${string}`
409
- export type MuxApiUrl = MuxThumbnailUrl | MuxAnimatedThumbnailUrl | MuxStoryboardUrl | MuxVideoUrl
410
-
411
- // 'preserve' by default
412
- // @url: https://docs.mux.com/guides/video/get-images-from-a-video#thumbnail-query-string-parameters
413
- export type FitMode = 'preserve' | 'crop' | 'smartcrop' | 'pad'
414
-
415
- export interface ThumbnailOptions {
416
- fit_mode?: FitMode
417
- height?: number
418
- time?: number
419
- width?: number
420
- }
421
-
422
- export interface AnimatedThumbnailOptions {
423
- // Starting time code for the animation, if no end is set it'll have a 5s duration
424
- // The start and end timecodes uses `asset.thumbTime` to create an iOS `Live Photo` effect by showing you the 5 secodnds before, and after, the thumb time`
425
- start?: number
426
- // End code, can't be longer than 10s after the start code
427
- end?: number
428
- // Max 640px, 320px by default
429
- width?: number
430
- // Preserves aspect ratio, like width, you can't set both the height and width, max 640
431
- height?: number
432
- // The fps is 15 by default, but can go up to 30
433
- fps?: number
434
- }
435
-
436
- export interface AssetThumbnailOptions {
437
- asset: Pick<VideoAssetDocument, 'playbackId' | 'data' | 'thumbTime' | 'filename' | 'assetId'>
438
- }
439
-
440
- export type PlaybackPolicy = 'signed' | 'public' | 'drm'
441
-
442
- export interface MuxErrors {
443
- type: string
444
- messages: string[]
445
- }
446
-
447
- export interface MuxPlaybackId {
448
- id: string
449
- policy: PlaybackPolicy
450
- }
451
-
452
- export interface MuxVideoTrack {
453
- type: 'video'
454
- id: string
455
- max_width: number
456
- max_height: number
457
- // if the fps can't be reliably determined, this will be -1
458
- max_frame_rate: -1 | number
459
- // top-level duration is always set, while track level duration is not
460
- duration?: number
461
- }
462
- export interface MuxAudioTrack {
463
- type: 'audio'
464
- id: string
465
- duration?: number
466
- max_channels: number
467
- max_channel_layout: 'stereo' | string
468
- }
469
- export interface MuxTextTrack {
470
- type: 'text'
471
- id: string
472
- text_type?: 'subtitles'
473
- // https://docs.mux.com/api-reference/video#operation/list-assets:~:text=text%20type%20tracks.-,tracks%5B%5D.,text_source,-string
474
- text_source?:
475
- | 'uploaded'
476
- | 'embedded'
477
- | 'generated_live'
478
- | 'generated_live_final'
479
- | 'generated_vod'
480
- // BCP 47 language code
481
- language_code?: 'en' | 'en-US' | string
482
- // The name of the track containing a human-readable description. The hls manifest will associate a subtitle text track with this value
483
- name?: 'English' | string
484
- closed_captions?: boolean
485
- // Max 255 characters
486
- passthrough?: string
487
- status: 'preparing' | 'ready' | 'errored'
488
- error?: {
489
- type: string
490
- messages?: string[]
491
- }
492
- }
493
- export type MuxTrack = MuxVideoTrack | MuxAudioTrack | MuxTextTrack
494
- // Typings lifted from https://docs.mux.com/api-reference/video#tag/assets
495
- export interface MuxAsset {
496
- id: string
497
- /** In seconds (instead of JS's default milliseconds) */
498
- created_at: string
499
- status: 'preparing' | 'ready' | 'errored'
500
- duration: number
501
- max_stored_resolution: 'Audio only' | 'SD' | 'HD' | 'FHD' | 'UHD'
502
- // if the fps can't be reliably determined, this will be -1
503
- max_stored_frame_rate: -1 | number
504
- // The aspect ratio of the asset in the form of width:height, for example 16:9
505
- aspect_ratio: `${number}:${number}`
506
- playback_ids: MuxPlaybackId[]
507
- tracks: MuxTrack[]
508
- errors?: MuxErrors
509
- upload_id: string
510
- is_live?: boolean
511
- // We use passthrough to set the mux.videoAsset._id of the asset that originally uploaded the video
512
- passthrough: string
513
- live_stream_id?: string
514
- master?: {
515
- status: 'ready' | 'preparing' | 'errored'
516
- // Temporary URL to master MP4, expires after 24 hours
517
- url: string
518
- }
519
- master_access: 'temporary' | 'none'
520
- mp4_support: 'standard' | 'none'
521
- // Asset Identifier of the video used as the source for creating the clip.
522
- source_asset_id?: string
523
- // Normalize the audio track loudness level. This parameter is only applicable to on-demand (not live) assets., default false
524
- normalize_audio?: boolean
525
- // The object does not exist if no static renditions have been requested
526
- static_renditions?: {
527
- status: 'ready' | 'preparing' | 'disabled' | 'errored'
528
- files: {
529
- name: string
530
- ext: 'mp4' | 'm4a'
531
- height: number
532
- width: number
533
- bitrate: number
534
- filesize: string
535
- type: 'standard' | 'advanced'
536
- status: 'ready' | 'preparing' | 'skipped' | 'errored'
537
- resolution_tier?: string
538
- resolution?: string
539
- id: string
540
- passthrough?: string
541
- }[]
542
- }
543
- recording_times?: {
544
- started_at: string
545
- duration: number
546
- type: 'content' | 'slate'
547
- }[]
548
- // https://docs.mux.com/guides/video/minimize-processing-time
549
- non_standard_input_reasons?: {
550
- video_codec?: string
551
- audio_codec?: string
552
- video_gop_size?: 'high'
553
- video_frame_rate?: string
554
- video_resolution?: string
555
- video_bitrate?: 'high'
556
- pixel_aspect_ratio?: string
557
- video_edit_list?: 'non-standard'
558
- audio_edit_list?: 'non-standard'
559
- unexpected_media_file_parameters?: 'non-standard'
560
- test?: boolean
561
- }
562
- meta?: {
563
- title?: string
564
- }
565
- }
566
-
567
- export interface VideoAssetDocument {
568
- _id: string
569
- _type: 'mux.videoAsset'
570
- _createdAt: string
571
- _updatedAt?: string
572
- status?: string
573
- assetId?: string
574
- playbackId?: string
575
- filename?: string
576
- thumbTime?: number
577
- // Docs for what goes in `data` https://docs.mux.com/api-reference/video#tag/assets
578
- data?: PartialDeep<MuxAsset>
579
- }
580
-
581
- export type Reference = {_type: 'reference'; _ref: string}
582
-
583
- // @TODO add Reference, and ReferenceSchemaType in the generic
584
- export type MuxInputProps = ObjectInputProps<{
585
- asset?: Reference
586
- }>
587
-
588
- export interface MuxInputPreviewProps extends Omit<PreviewProps<PreviewLayoutKey>, 'value'> {
589
- schemaType: SchemaType
590
- value?: {
591
- asset?: Reference
592
- } | null
593
- }
594
-
595
- /** Whether the VideosBrowser was opened from a field in a document, or from the standalone studio tool */
596
- export type PluginPlacement = 'input' | 'tool'
@@ -1,11 +0,0 @@
1
- const {showIncompatiblePluginDialog} = require('@sanity/incompatible-plugin')
2
- const {name, version, sanityExchangeUrl} = require('./package.json')
3
-
4
- export default showIncompatiblePluginDialog({
5
- name: name,
6
- versions: {
7
- v3: version,
8
- v2: '^1.1.8',
9
- },
10
- sanityExchangeUrl,
11
- })