sanity-plugin-mux-input 2.12.0 → 2.13.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Sanity.io
3
+ Copyright (c) 2026 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -219,6 +219,7 @@ export default defineConfig({
219
219
  ```
220
220
 
221
221
  **Standard mode options:**
222
+
222
223
  - `'highest'`: Produces an MP4 file with video resolution up to 4K (2160p)
223
224
  - `'audio-only'`: Produces an M4A (audio-only MP4) file
224
225
 
@@ -239,10 +240,12 @@ export default defineConfig({
239
240
  ```
240
241
 
241
242
  **Advanced mode options:**
243
+
242
244
  - Specific resolutions: `'270p'`, `'360p'`, `'480p'`, `'540p'`, `'720p'`, `'1080p'`, `'1440p'`, `'2160p'`
243
245
  - `'audio-only'`: M4A file
244
246
 
245
247
  **Important notes:**
248
+
246
249
  - You cannot mix `'highest'` with specific resolutions (e.g., `['highest', '1080p']` is invalid)
247
250
  - Mux will not upscale videos - renditions requiring upscaling are automatically skipped
248
251
  - When uploading new assets, editors can choose different rendition settings on a per-video basis
@@ -309,6 +312,136 @@ export default defineConfig({
309
312
 
310
313
  If your videos are always spoken in a specific language and you want to include captions by default, you can use `disableTextTrackConfig: true` together with `defaultAutogeneratedSubtitleLang` to transcribe captions for every uploaded asset without needing user interaction.
311
314
 
315
+ ### Accepted File Types
316
+
317
+ By default, the plugin accepts both video and audio files (`['video/*', 'audio/*']`). You can configure which file types are accepted either globally at the plugin level or per-field at the schema level.
318
+
319
+ #### Plugin-level configuration
320
+
321
+ Configure accepted file types for all `mux.video` fields globally:
322
+
323
+ ```js
324
+ import {muxInput} from 'sanity-plugin-mux-input'
325
+
326
+ export default defineConfig({
327
+ plugins: [
328
+ muxInput({
329
+ acceptedMimeTypes: ['video/*'], // Only accept video files
330
+ // or
331
+ acceptedMimeTypes: ['audio/*'], // Only accept audio files
332
+ // or
333
+ acceptedMimeTypes: ['video/*', 'audio/*'], // Accept both (default)
334
+ }),
335
+ ],
336
+ })
337
+ ```
338
+
339
+ #### Schema-level configuration
340
+
341
+ You can also configure `acceptedMimeTypes` for individual fields in your schema, which will override the plugin-level configuration:
342
+
343
+ ```js
344
+ import { defineField, defineType } from "sanity";
345
+
346
+ export default defineType({
347
+ name: "muxTest",
348
+ title: "Mux Files",
349
+ type: "document",
350
+ fields: [
351
+ defineField({
352
+ name: "audioFile",
353
+ title: "Audio File",
354
+ type: "mux.video",
355
+ options: {
356
+ acceptedMimeTypes: ["audio/*"],
357
+ },
358
+ }),
359
+ defineField({
360
+ name: "videoFile",
361
+ title: "Video File",
362
+ type: "mux.video",
363
+ options: {
364
+ acceptedMimeTypes: ["video/*"],
365
+ },
366
+ }),
367
+ defineField({
368
+ name: "either",
369
+ title: "Either File",
370
+ type: "mux.video",
371
+ }),
372
+ ],
373
+ });
374
+ ```
375
+
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
+
378
+ 📌 **Note**: This option accepts an array of MIME type patterns. The valid values are:
379
+ - `'video/*'` - Accepts all video file types
380
+ - `'audio/*'` - Accepts all audio file types
381
+
382
+ For more information on the `accept` attribute, refer to the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept).
383
+
384
+ ### File size and duration validation
385
+
386
+ You can configure maximum file size and video duration limits to prevent users from uploading videos that exceed your requirements. These validations run before the upload starts, providing immediate feedback to users.
387
+
388
+ #### Plugin-level configuration
389
+
390
+ Set validation limits for all `mux.video` fields globally:
391
+
392
+ ```js
393
+ import {muxInput} from 'sanity-plugin-mux-input'
394
+
395
+ export default defineConfig({
396
+ plugins: [
397
+ muxInput({
398
+ maxAssetFileSize: 1024 * 1024 * 1024, // 1 GB in bytes
399
+ maxAssetDuration: 2 * 60 * 60, // 2 hours in seconds
400
+ }),
401
+ ],
402
+ })
403
+ ```
404
+
405
+ #### Schema-level configuration
406
+
407
+ You can override the global limits for specific fields, allowing different validation rules for different use cases:
408
+
409
+ ```js
410
+ import { defineType, defineField } from "sanity";
411
+
412
+ export default defineType({
413
+ name: "muxTest",
414
+ title: "Mux Files",
415
+ type: "document",
416
+ fields: [
417
+ defineField({
418
+ name: "shortVideo",
419
+ title: "Short Video (max 1 minute)",
420
+ type: "mux.video",
421
+ options: {
422
+ maxAssetFileSize: 100 * 1024 * 1024, // 100 MB
423
+ maxAssetDuration: 60, // 1 minute
424
+ },
425
+ }),
426
+ defineField({
427
+ name: 'longVideo',
428
+ title: 'Long Video (max 2 hours)',
429
+ type: 'mux.video',
430
+ options: {
431
+ maxAssetFileSize: 1024 * 1024 * 1024, // 1 GB
432
+ maxAssetDuration: 2 * 60 * 60, // 2 hours
433
+ },
434
+ }),
435
+ defineField({
436
+ name: 'unlimitedVideo',
437
+ title: 'Unlimited Video',
438
+ type: 'mux.video',
439
+ // Uses plugin defaults or no validation if not configured
440
+ }),
441
+ ]
442
+ })
443
+ ```
444
+
312
445
  ## Contributing
313
446
 
314
447
  Issues are actively monitored and PRs are welcome. When developing this plugin the easiest setup is:
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import type MuxPlayerElement from '@mux/mux-player'
1
2
  import type {PartialDeep} from 'type-fest'
2
3
  import {Plugin as Plugin_2} from 'sanity'
3
4
 
@@ -172,6 +173,46 @@ declare interface MuxInputConfig {
172
173
  * @defaultValue false
173
174
  */
174
175
  disableTextTrackConfig?: boolean
176
+ /**
177
+ * The mime types that are accepted by the input.
178
+ *
179
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept}
180
+ * @defaultValue ['video/*','audio/*']
181
+
182
+ */
183
+ acceptedMimeTypes?: ('audio/*' | 'video/*')[]
184
+ /**
185
+ * Maximum file size allowed for video uploads in bytes.
186
+ * If not specified, no file size validation will be performed.
187
+ *
188
+ * @example 1024 * 1024 * 1024 // 1 GB
189
+ * @defaultValue undefined
190
+ */
191
+ maxAssetFileSize?: number
192
+ /**
193
+ * Maximum video duration allowed in seconds.
194
+ * If not specified, no duration validation will be performed.
195
+ *
196
+ * @example 2 * 60 * 60 // 2 hours
197
+ * @defaultValue undefined
198
+ */
199
+ maxAssetDuration?: number
200
+ /**
201
+ * HLS.js configuration options to be passed to the Mux Player.
202
+ * These options allow you to customize the underlying HLS.js playback engine behavior.
203
+ *
204
+ * @see {@link https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning}
205
+ * @defaultValue undefined
206
+ * @example
207
+ * ```ts
208
+ * {
209
+ * maxBufferLength: 30,
210
+ * lowLatencyMode: true,
211
+ * capLevelToPlayerSize: true
212
+ * }
213
+ * ```
214
+ */
215
+ hlsConfig?: MuxPlayerElement['_hlsConfig']
175
216
  }
176
217
 
177
218
  declare interface MuxPlaybackId {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type MuxPlayerElement from '@mux/mux-player'
1
2
  import type {PartialDeep} from 'type-fest'
2
3
  import {Plugin as Plugin_2} from 'sanity'
3
4
 
@@ -172,6 +173,46 @@ declare interface MuxInputConfig {
172
173
  * @defaultValue false
173
174
  */
174
175
  disableTextTrackConfig?: boolean
176
+ /**
177
+ * The mime types that are accepted by the input.
178
+ *
179
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept}
180
+ * @defaultValue ['video/*','audio/*']
181
+
182
+ */
183
+ acceptedMimeTypes?: ('audio/*' | 'video/*')[]
184
+ /**
185
+ * Maximum file size allowed for video uploads in bytes.
186
+ * If not specified, no file size validation will be performed.
187
+ *
188
+ * @example 1024 * 1024 * 1024 // 1 GB
189
+ * @defaultValue undefined
190
+ */
191
+ maxAssetFileSize?: number
192
+ /**
193
+ * Maximum video duration allowed in seconds.
194
+ * If not specified, no duration validation will be performed.
195
+ *
196
+ * @example 2 * 60 * 60 // 2 hours
197
+ * @defaultValue undefined
198
+ */
199
+ maxAssetDuration?: number
200
+ /**
201
+ * HLS.js configuration options to be passed to the Mux Player.
202
+ * These options allow you to customize the underlying HLS.js playback engine behavior.
203
+ *
204
+ * @see {@link https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning}
205
+ * @defaultValue undefined
206
+ * @example
207
+ * ```ts
208
+ * {
209
+ * maxBufferLength: 30,
210
+ * lowLatencyMode: true,
211
+ * capLevelToPlayerSize: true
212
+ * }
213
+ * ```
214
+ */
215
+ hlsConfig?: MuxPlayerElement['_hlsConfig']
175
216
  }
176
217
 
177
218
  declare interface MuxPlaybackId {