sanity-plugin-mux-input 2.10.0 → 2.10.1
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/README.md +8 -8
- package/dist/index.d.mts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +32 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/_exports/index.ts +13 -1
- package/src/components/UploadConfiguration.tsx +28 -28
- package/src/schema.ts +4 -0
- package/src/util/types.ts +20 -10
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ For reference, here's an example `mux.videoAsset` document:
|
|
|
122
122
|
thumbTime: 65.82,
|
|
123
123
|
// Full Mux asset data:
|
|
124
124
|
data: {
|
|
125
|
-
|
|
125
|
+
video_quality: 'plus',
|
|
126
126
|
max_resolution_tier: '1080p',
|
|
127
127
|
aspect_ratio: '16:9',
|
|
128
128
|
created_at: '1706645034',
|
|
@@ -228,25 +228,25 @@ export default defineConfig({
|
|
|
228
228
|
|
|
229
229
|
When uploading new assets, editors can still choose a lower resolution for each video than configured globally. This option controls the maximum resolution encoded or processed for the uploaded video. The option is particularly important to manage costs when uploaded videos are higher than `1080p` resolution. More information on the feature is available on Mux's [docs](https://docs.mux.com/guides/stream-videos-in-4k). Also, read more on this feature announcement on Mux's [blog](https://www.mux.com/blog/more-pixels-fewer-problems-introducing-4k-support-for-mux-video).
|
|
230
230
|
|
|
231
|
-
###
|
|
231
|
+
### Video Quality Level (plus or basic)
|
|
232
232
|
|
|
233
|
-
The [
|
|
233
|
+
The [video quality level](https://docs.mux.com/guides/use-video-quality-levels) informs the cost, quality, and available platform features for the asset. You can choose between `plus` and `basic` at the plugin configuration. Defaults to `plus`.
|
|
234
234
|
|
|
235
235
|
```js
|
|
236
236
|
import {muxInput} from 'sanity-plugin-mux-input'
|
|
237
237
|
|
|
238
238
|
export default defineConfig({
|
|
239
|
-
plugins: [muxInput({
|
|
239
|
+
plugins: [muxInput({video_quality: 'basic'})],
|
|
240
240
|
})
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
If `
|
|
243
|
+
If `video_quality: 'plus'`, editors can still choose to use the `basic` video quality level on a per-video basis when uploading new assets.
|
|
244
244
|
|
|
245
|
-
More information on the feature is available on Mux's [documentation](https://
|
|
245
|
+
More information on the feature is available on Mux's [documentation](https://www.mux.com/docs/guides/use-video-quality-levels). Also, read more on the feature announcement on Mux's [blog](https://www.mux.com/blog/our-next-pricing-lever-baseline-on-demand-assets-with-free-video-encoding)
|
|
246
246
|
|
|
247
247
|
### Auto-generated subtitles and captions
|
|
248
248
|
|
|
249
|
-
If you'
|
|
249
|
+
If you are using 'plus' video quality level, you can use Mux's [auto-generated subtitles](https://docs.mux.com/guides/video/auto-generated-subtitles) feature. Unless you pass `disableTextTrackConfig: true` to the configuration, users will be able to choose a language to auto-generate subtitles for uploaded videos. Refer to Mux's documentation for the list of supported languages.
|
|
250
250
|
|
|
251
251
|
You can also define a default language for the upload configuration form:
|
|
252
252
|
|
|
@@ -256,7 +256,7 @@ import {muxInput} from 'sanity-plugin-mux-input'
|
|
|
256
256
|
export default defineConfig({
|
|
257
257
|
plugins: [
|
|
258
258
|
muxInput({
|
|
259
|
-
|
|
259
|
+
video_quality: 'plus',
|
|
260
260
|
defaultAutogeneratedSubtitleLang: 'en', // choose from one of the supported languages
|
|
261
261
|
}),
|
|
262
262
|
],
|
package/dist/index.d.mts
CHANGED
|
@@ -79,24 +79,32 @@ export declare const muxInput: Plugin_2<void | Partial<PluginConfig>>
|
|
|
79
79
|
declare interface MuxInputConfig {
|
|
80
80
|
/**
|
|
81
81
|
* Enable static renditions by setting this to 'standard'. Can be overwritten on a per-asset basis.
|
|
82
|
-
* Requires `"
|
|
82
|
+
* Requires `"video_quality": "plus"`
|
|
83
83
|
* @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
|
|
84
84
|
* @defaultValue 'none'
|
|
85
85
|
*/
|
|
86
86
|
mp4_support: 'none' | 'standard'
|
|
87
87
|
/**
|
|
88
88
|
* Max resolution tier can be used to control the maximum resolution_tier your asset is encoded, stored, and streamed at.
|
|
89
|
-
* Requires `"
|
|
89
|
+
* Requires `"video_quality": "plus"`
|
|
90
90
|
* @see {@link https://docs.mux.com/guides/stream-videos-in-4k}
|
|
91
91
|
* @defaultValue '1080p'
|
|
92
92
|
*/
|
|
93
93
|
max_resolution_tier: '2160p' | '1440p' | '1080p'
|
|
94
94
|
/**
|
|
95
|
+
* @deprecated Use {@link video_quality}
|
|
96
|
+
* <br>
|
|
95
97
|
* The encoding tier informs the cost, quality, and available platform features for the asset.
|
|
96
98
|
* @see {@link https://docs.mux.com/guides/use-encoding-tiers}
|
|
97
99
|
* @defaultValue 'smart'
|
|
98
100
|
*/
|
|
99
|
-
encoding_tier
|
|
101
|
+
encoding_tier?: 'baseline' | 'smart'
|
|
102
|
+
/**
|
|
103
|
+
* The video quality level informs the cost, quality, and available platform features for the asset.
|
|
104
|
+
* @see {@link https://www.mux.com/docs/guides/use-video-quality-levels}
|
|
105
|
+
* @defaultValue 'plus'
|
|
106
|
+
*/
|
|
107
|
+
video_quality: 'basic' | 'plus' | 'premium'
|
|
100
108
|
/**
|
|
101
109
|
* Normalize the audio track loudness level.
|
|
102
110
|
* @see {@link https://docs.mux.com/guides/adjust-audio-levels#how-to-turn-on-audio-normalization}
|
|
@@ -111,7 +119,7 @@ declare interface MuxInputConfig {
|
|
|
111
119
|
defaultSigned?: boolean
|
|
112
120
|
/**
|
|
113
121
|
* Auto-generate captions for these languages by default.
|
|
114
|
-
* Requires `"
|
|
122
|
+
* Requires `"video_quality": "plus"`
|
|
115
123
|
*
|
|
116
124
|
* @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
|
|
117
125
|
* @deprecated use `defaultAutogeneratedSubtitleLang` instead. Only a single autogenerated
|
|
@@ -119,7 +127,7 @@ declare interface MuxInputConfig {
|
|
|
119
127
|
defaultAutogeneratedSubtitleLangs?: SupportedMuxLanguage[]
|
|
120
128
|
/**
|
|
121
129
|
* Auto-generate captions for this language by default. Users can still
|
|
122
|
-
* Requires `"
|
|
130
|
+
* Requires `"video_quality": "plus"`
|
|
123
131
|
*
|
|
124
132
|
* @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
|
|
125
133
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -79,24 +79,32 @@ export declare const muxInput: Plugin_2<void | Partial<PluginConfig>>
|
|
|
79
79
|
declare interface MuxInputConfig {
|
|
80
80
|
/**
|
|
81
81
|
* Enable static renditions by setting this to 'standard'. Can be overwritten on a per-asset basis.
|
|
82
|
-
* Requires `"
|
|
82
|
+
* Requires `"video_quality": "plus"`
|
|
83
83
|
* @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
|
|
84
84
|
* @defaultValue 'none'
|
|
85
85
|
*/
|
|
86
86
|
mp4_support: 'none' | 'standard'
|
|
87
87
|
/**
|
|
88
88
|
* Max resolution tier can be used to control the maximum resolution_tier your asset is encoded, stored, and streamed at.
|
|
89
|
-
* Requires `"
|
|
89
|
+
* Requires `"video_quality": "plus"`
|
|
90
90
|
* @see {@link https://docs.mux.com/guides/stream-videos-in-4k}
|
|
91
91
|
* @defaultValue '1080p'
|
|
92
92
|
*/
|
|
93
93
|
max_resolution_tier: '2160p' | '1440p' | '1080p'
|
|
94
94
|
/**
|
|
95
|
+
* @deprecated Use {@link video_quality}
|
|
96
|
+
* <br>
|
|
95
97
|
* The encoding tier informs the cost, quality, and available platform features for the asset.
|
|
96
98
|
* @see {@link https://docs.mux.com/guides/use-encoding-tiers}
|
|
97
99
|
* @defaultValue 'smart'
|
|
98
100
|
*/
|
|
99
|
-
encoding_tier
|
|
101
|
+
encoding_tier?: 'baseline' | 'smart'
|
|
102
|
+
/**
|
|
103
|
+
* The video quality level informs the cost, quality, and available platform features for the asset.
|
|
104
|
+
* @see {@link https://www.mux.com/docs/guides/use-video-quality-levels}
|
|
105
|
+
* @defaultValue 'plus'
|
|
106
|
+
*/
|
|
107
|
+
video_quality: 'basic' | 'plus' | 'premium'
|
|
100
108
|
/**
|
|
101
109
|
* Normalize the audio track loudness level.
|
|
102
110
|
* @see {@link https://docs.mux.com/guides/adjust-audio-levels#how-to-turn-on-audio-normalization}
|
|
@@ -111,7 +119,7 @@ declare interface MuxInputConfig {
|
|
|
111
119
|
defaultSigned?: boolean
|
|
112
120
|
/**
|
|
113
121
|
* Auto-generate captions for these languages by default.
|
|
114
|
-
* Requires `"
|
|
122
|
+
* Requires `"video_quality": "plus"`
|
|
115
123
|
*
|
|
116
124
|
* @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
|
|
117
125
|
* @deprecated use `defaultAutogeneratedSubtitleLang` instead. Only a single autogenerated
|
|
@@ -119,7 +127,7 @@ declare interface MuxInputConfig {
|
|
|
119
127
|
defaultAutogeneratedSubtitleLangs?: SupportedMuxLanguage[]
|
|
120
128
|
/**
|
|
121
129
|
* Auto-generate captions for this language by default. Users can still
|
|
122
|
-
* Requires `"
|
|
130
|
+
* Requires `"video_quality": "plus"`
|
|
123
131
|
*
|
|
124
132
|
* @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
|
|
125
133
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1523,7 +1523,7 @@ function VideoPlayer({
|
|
|
1523
1523
|
crossOrigin: "anonymous",
|
|
1524
1524
|
metadata: {
|
|
1525
1525
|
player_name: "Sanity Admin Dashboard",
|
|
1526
|
-
player_version: "2.10.
|
|
1526
|
+
player_version: "2.10.1",
|
|
1527
1527
|
page_type: "Preview Player"
|
|
1528
1528
|
},
|
|
1529
1529
|
audio: isAudio,
|
|
@@ -3332,9 +3332,10 @@ function PlaybackPolicy({
|
|
|
3332
3332
|
noPolicySelected && /* @__PURE__ */ jsxRuntime.jsx(PlaybackPolicyWarning, {})
|
|
3333
3333
|
] });
|
|
3334
3334
|
}
|
|
3335
|
-
const
|
|
3336
|
-
{ value: "
|
|
3337
|
-
{ value: "
|
|
3335
|
+
const VIDEO_QUALITY_LEVELS = [
|
|
3336
|
+
{ value: "basic", label: "Basic" },
|
|
3337
|
+
{ value: "plus", label: "Plus" },
|
|
3338
|
+
{ value: "premium", label: "Premium" }
|
|
3338
3339
|
], RESOLUTION_TIERS = [
|
|
3339
3340
|
{ value: "1080p", label: "1080p" },
|
|
3340
3341
|
{ value: "1440p", label: "1440p (2k)" },
|
|
@@ -3348,7 +3349,7 @@ function UploadConfiguration({
|
|
|
3348
3349
|
onClose
|
|
3349
3350
|
}) {
|
|
3350
3351
|
const id = React.useId(), autoTextTracks = React.useRef(
|
|
3351
|
-
pluginConfig.
|
|
3352
|
+
pluginConfig.video_quality === "plus" && pluginConfig.defaultAutogeneratedSubtitleLang ? [
|
|
3352
3353
|
{
|
|
3353
3354
|
_id: uuid.uuid(),
|
|
3354
3355
|
type: "autogenerated",
|
|
@@ -3359,16 +3360,16 @@ function UploadConfiguration({
|
|
|
3359
3360
|
).current, [config, dispatch] = React.useReducer(
|
|
3360
3361
|
(prev, action) => {
|
|
3361
3362
|
switch (action.action) {
|
|
3362
|
-
case "
|
|
3363
|
-
return action.value === "
|
|
3364
|
-
|
|
3363
|
+
case "video_quality":
|
|
3364
|
+
return action.value === "basic" ? Object.assign({}, prev, {
|
|
3365
|
+
video_quality: action.value,
|
|
3365
3366
|
mp4_support: "none",
|
|
3366
3367
|
max_resolution_tier: "1080p",
|
|
3367
3368
|
text_tracks: prev.text_tracks?.filter(({ type }) => type !== "autogenerated"),
|
|
3368
3369
|
public_policy: !0,
|
|
3369
3370
|
signed_policy: !1
|
|
3370
3371
|
}) : Object.assign({}, prev, {
|
|
3371
|
-
|
|
3372
|
+
video_quality: action.value,
|
|
3372
3373
|
mp4_support: pluginConfig.mp4_support,
|
|
3373
3374
|
max_resolution_tier: pluginConfig.max_resolution_tier,
|
|
3374
3375
|
text_tracks: [...autoTextTracks, ...prev.text_tracks || []]
|
|
@@ -3410,7 +3411,7 @@ function UploadConfiguration({
|
|
|
3410
3411
|
}
|
|
3411
3412
|
},
|
|
3412
3413
|
{
|
|
3413
|
-
|
|
3414
|
+
video_quality: pluginConfig.video_quality,
|
|
3414
3415
|
max_resolution_tier: pluginConfig.max_resolution_tier,
|
|
3415
3416
|
mp4_support: pluginConfig.mp4_support,
|
|
3416
3417
|
signed_policy: secrets.enableSignedUrls && pluginConfig.defaultSigned,
|
|
@@ -3422,7 +3423,7 @@ function UploadConfiguration({
|
|
|
3422
3423
|
if (React.useEffect(() => {
|
|
3423
3424
|
skipConfig && startUpload(formatUploadConfig(config));
|
|
3424
3425
|
}, []), skipConfig) return null;
|
|
3425
|
-
const maxSupportedResolution = RESOLUTION_TIERS.findIndex(
|
|
3426
|
+
const basicConfig = config.video_quality !== "plus" && config.video_quality !== "premium", maxSupportedResolution = RESOLUTION_TIERS.findIndex(
|
|
3426
3427
|
(rt) => rt.value === pluginConfig.max_resolution_tier
|
|
3427
3428
|
);
|
|
3428
3429
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3458,9 +3459,9 @@ function UploadConfiguration({
|
|
|
3458
3459
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3459
3460
|
sanity.FormField,
|
|
3460
3461
|
{
|
|
3461
|
-
title: "
|
|
3462
|
+
title: "Video Quality Level",
|
|
3462
3463
|
description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3463
|
-
"The
|
|
3464
|
+
"The video quality level informs the cost, quality, and available platform features for the asset.",
|
|
3464
3465
|
" ",
|
|
3465
3466
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3466
3467
|
"a",
|
|
@@ -3472,16 +3473,16 @@ function UploadConfiguration({
|
|
|
3472
3473
|
}
|
|
3473
3474
|
)
|
|
3474
3475
|
] }),
|
|
3475
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 3, children:
|
|
3476
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 3, children: VIDEO_QUALITY_LEVELS.map(({ value, label }) => {
|
|
3476
3477
|
const inputId = `${id}--encodingtier-${value}`;
|
|
3477
3478
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, children: [
|
|
3478
3479
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3479
3480
|
ui.Radio,
|
|
3480
3481
|
{
|
|
3481
|
-
checked: config.
|
|
3482
|
+
checked: config.video_quality === value,
|
|
3482
3483
|
name: "asset-encodingtier",
|
|
3483
3484
|
onChange: (e) => dispatch({
|
|
3484
|
-
action: "
|
|
3485
|
+
action: "video_quality",
|
|
3485
3486
|
value: e.currentTarget.value
|
|
3486
3487
|
}),
|
|
3487
3488
|
value,
|
|
@@ -3493,7 +3494,7 @@ function UploadConfiguration({
|
|
|
3493
3494
|
}) })
|
|
3494
3495
|
}
|
|
3495
3496
|
),
|
|
3496
|
-
|
|
3497
|
+
!basicConfig && maxSupportedResolution > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3497
3498
|
sanity.FormField,
|
|
3498
3499
|
{
|
|
3499
3500
|
title: "Resolution Tier",
|
|
@@ -3533,9 +3534,9 @@ function UploadConfiguration({
|
|
|
3533
3534
|
}) })
|
|
3534
3535
|
}
|
|
3535
3536
|
),
|
|
3536
|
-
|
|
3537
|
+
!basicConfig && /* @__PURE__ */ jsxRuntime.jsx(sanity.FormField, { title: "Additional Configuration", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
3537
3538
|
/* @__PURE__ */ jsxRuntime.jsx(PlaybackPolicy, { id, config, secrets, dispatch }),
|
|
3538
|
-
|
|
3539
|
+
!basicConfig && /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, padding: [0, 2], children: [
|
|
3539
3540
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3540
3541
|
ui.Checkbox,
|
|
3541
3542
|
{
|
|
@@ -3554,7 +3555,7 @@ function UploadConfiguration({
|
|
|
3554
3555
|
] })
|
|
3555
3556
|
] }) })
|
|
3556
3557
|
] }),
|
|
3557
|
-
!disableTextTrackConfig &&
|
|
3558
|
+
!disableTextTrackConfig && !basicConfig && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3558
3559
|
TextTracksEditor,
|
|
3559
3560
|
{
|
|
3560
3561
|
tracks: config.text_tracks,
|
|
@@ -3565,7 +3566,7 @@ function UploadConfiguration({
|
|
|
3565
3566
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3566
3567
|
ui.Button,
|
|
3567
3568
|
{
|
|
3568
|
-
disabled:
|
|
3569
|
+
disabled: !basicConfig && !config.public_policy && !config.signed_policy,
|
|
3569
3570
|
icon: icons.UploadIcon,
|
|
3570
3571
|
text: "Upload",
|
|
3571
3572
|
tone: "positive",
|
|
@@ -3606,7 +3607,7 @@ function formatUploadConfig(config) {
|
|
|
3606
3607
|
mp4_support: config.mp4_support,
|
|
3607
3608
|
playback_policy: setPlaybackPolicy(config),
|
|
3608
3609
|
max_resolution_tier: config.max_resolution_tier,
|
|
3609
|
-
|
|
3610
|
+
video_quality: config.video_quality,
|
|
3610
3611
|
normalize_audio: config.normalize_audio
|
|
3611
3612
|
};
|
|
3612
3613
|
}
|
|
@@ -4147,6 +4148,10 @@ const muxVideoSchema = {
|
|
|
4147
4148
|
type: "string",
|
|
4148
4149
|
name: "encoding_tier"
|
|
4149
4150
|
},
|
|
4151
|
+
{
|
|
4152
|
+
type: "string",
|
|
4153
|
+
name: "video_quality"
|
|
4154
|
+
},
|
|
4150
4155
|
{
|
|
4151
4156
|
type: "string",
|
|
4152
4157
|
name: "master_access"
|
|
@@ -4225,13 +4230,17 @@ const muxVideoSchema = {
|
|
|
4225
4230
|
muxVideoAsset
|
|
4226
4231
|
], defaultConfig = {
|
|
4227
4232
|
mp4_support: "none",
|
|
4228
|
-
|
|
4233
|
+
video_quality: "plus",
|
|
4229
4234
|
max_resolution_tier: "1080p",
|
|
4230
4235
|
normalize_audio: !1,
|
|
4231
4236
|
defaultSigned: !1,
|
|
4232
4237
|
tool: DEFAULT_TOOL_CONFIG,
|
|
4233
4238
|
allowedRolesForConfiguration: []
|
|
4234
4239
|
}, muxInput = sanity.definePlugin((userConfig) => {
|
|
4240
|
+
if (typeof userConfig == "object" && "encoding_tier" in userConfig) {
|
|
4241
|
+
const deprecated_encoding_tier = userConfig.encoding_tier;
|
|
4242
|
+
userConfig.video_quality || (deprecated_encoding_tier === "baseline" && (userConfig.video_quality = "basic"), deprecated_encoding_tier === "smart" && (userConfig.video_quality = "plus"));
|
|
4243
|
+
}
|
|
4235
4244
|
const config = { ...defaultConfig, ...userConfig || {} };
|
|
4236
4245
|
return {
|
|
4237
4246
|
name: "mux-input",
|