sanity-plugin-mux-input 2.19.1 → 3.0.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/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
19
  mod
20
20
  ));
21
21
  Object.defineProperty(exports, "__esModule", { value: !0 });
22
- var sanity = require("sanity"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), React = require("react"), compact = require("lodash/compact.js"), toLower = require("lodash/toLower.js"), trim = require("lodash/trim.js"), uniq = require("lodash/uniq.js"), words = require("lodash/words.js"), suspendReact = require("suspend-react"), rxjs = require("rxjs"), styledComponents = require("styled-components"), uuid = require("@sanity/uuid"), operators = require("rxjs/operators"), LanguagesList = require("iso-639-1"), MuxPlayer = require("@mux/mux-player-react/lazy"), router = require("sanity/router"), isNumber = require("lodash/isNumber.js"), isString = require("lodash/isString.js"), reactRx = require("react-rx"), useSWR = require("swr"), scrollIntoView = require("scroll-into-view-if-needed"), upchunk = require("@mux/upchunk"), reactIs = require("react-is");
22
+ var sanity = require("sanity"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), React = require("react"), compact = require("lodash/compact.js"), toLower = require("lodash/toLower.js"), trim = require("lodash/trim.js"), uniq = require("lodash/uniq.js"), words = require("lodash/words.js"), suspendReact = require("suspend-react"), rxjs = require("rxjs"), styledComponents = require("styled-components"), uuid = require("@sanity/uuid"), operators = require("rxjs/operators"), LanguagesList = require("iso-639-1"), MuxPlayer = require("@mux/mux-player-react/lazy"), useDevicePixelRatio = require("use-device-pixel-ratio"), router = require("sanity/router"), isNumber = require("lodash/isNumber.js"), isString = require("lodash/isString.js"), reactRx = require("react-rx"), useSWR = require("swr"), scrollIntoView = require("scroll-into-view-if-needed"), upchunk = require("@mux/upchunk"), reactIs = require("react-is");
23
23
  function _interopDefaultCompat(e) {
24
24
  return e && typeof e == "object" && "default" in e ? e : { default: e };
25
25
  }
@@ -147,7 +147,7 @@ function useAssets() {
147
147
  function useDialogState() {
148
148
  return React.useState(!1);
149
149
  }
150
- const PLUGIN_VERSION_QUERY = { sanityVersion: "2.19.1" };
150
+ const PLUGIN_VERSION_QUERY = { sanityVersion: "3.0.1" };
151
151
  function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate, drmConfigId) {
152
152
  const doc = {
153
153
  _id: "secrets.mux",
@@ -391,7 +391,7 @@ const Logo = styledComponents.styled.span`
391
391
  /* @__PURE__ */ jsxRuntime.jsx(Logo, { children: /* @__PURE__ */ jsxRuntime.jsx(MuxLogo, { height: 13 }) }),
392
392
  "API Credentials"
393
393
  ] });
394
- function FormField(props) {
394
+ function FormField$1(props) {
395
395
  const { children, title, description, inputId } = props;
396
396
  return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 1, children: [
397
397
  /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, paddingY: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
@@ -401,7 +401,7 @@ function FormField(props) {
401
401
  /* @__PURE__ */ jsxRuntime.jsx("div", { children })
402
402
  ] });
403
403
  }
404
- var FormField$1 = React.memo(FormField);
404
+ var FormField = React.memo(FormField$1);
405
405
  const fieldNames = ["token", "secretKey", "enableSignedUrls", "drmConfigId"];
406
406
  function ConfigureApiDialog({ secrets, setDialogState }) {
407
407
  const client = useClient(), [state, dispatch] = useSecretsFormState(secrets), hasSecretsInitially = React.useMemo(() => secrets.token && secrets.secretKey, [secrets]), handleClose = React.useCallback(() => setDialogState(!1), [setDialogState]), dirty = React.useMemo(
@@ -498,7 +498,7 @@ function ConfigureApiDialog({ secrets, setDialogState }) {
498
498
  "The credentials will be stored safely in a hidden document only available to editors."
499
499
  ] })
500
500
  ] }) }),
501
- /* @__PURE__ */ jsxRuntime.jsx(FormField$1, { title: "Access Token", inputId: tokenId, children: /* @__PURE__ */ jsxRuntime.jsx(
501
+ /* @__PURE__ */ jsxRuntime.jsx(FormField, { title: "Access Token", inputId: tokenId, children: /* @__PURE__ */ jsxRuntime.jsx(
502
502
  ui.TextInput,
503
503
  {
504
504
  id: tokenId,
@@ -509,7 +509,7 @@ function ConfigureApiDialog({ secrets, setDialogState }) {
509
509
  required: !!state.secretKey || state.enableSignedUrls
510
510
  }
511
511
  ) }),
512
- /* @__PURE__ */ jsxRuntime.jsx(FormField$1, { title: "Secret Key", inputId: secretKeyId, children: /* @__PURE__ */ jsxRuntime.jsx(
512
+ /* @__PURE__ */ jsxRuntime.jsx(FormField, { title: "Secret Key", inputId: secretKeyId, children: /* @__PURE__ */ jsxRuntime.jsx(
513
513
  ui.TextInput,
514
514
  {
515
515
  id: secretKeyId,
@@ -542,7 +542,7 @@ function ConfigureApiDialog({ secrets, setDialogState }) {
542
542
  ] })
543
543
  ] }) }) : null
544
544
  ] }),
545
- /* @__PURE__ */ jsxRuntime.jsx(FormField$1, { title: "DRM Configuration ID", inputId: drmConfigIdId, children: /* @__PURE__ */ jsxRuntime.jsx(
545
+ /* @__PURE__ */ jsxRuntime.jsx(FormField, { title: "DRM Configuration ID", inputId: drmConfigIdId, children: /* @__PURE__ */ jsxRuntime.jsx(
546
546
  ui.TextInput,
547
547
  {
548
548
  id: drmConfigIdId,
@@ -2974,14 +2974,6 @@ function CaptionsDialog({ asset }) {
2974
2974
  const { setDialogState } = useDialogStateContext(), dialogId = `CaptionsDialog${React.useId()}`;
2975
2975
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { id: dialogId, header: "Edit Captions", onClose: () => setDialogState(!1), width: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(TextTracksManager, { asset }) }) });
2976
2976
  }
2977
- function getDevicePixelRatio(options) {
2978
- const {
2979
- defaultDpr = 1,
2980
- maxDpr = 3,
2981
- round = !0
2982
- } = options || {}, dpr = typeof window < "u" && typeof window.devicePixelRatio == "number" ? window.devicePixelRatio : defaultDpr;
2983
- return Math.min(Math.max(1, round ? Math.floor(dpr) : dpr), maxDpr);
2984
- }
2985
2977
  function formatSeconds(seconds) {
2986
2978
  if (typeof seconds != "number" || Number.isNaN(seconds))
2987
2979
  return "";
@@ -3005,7 +2997,7 @@ function EditThumbnailDialog({ asset, currentTime = 0 }) {
3005
2997
  () => formatSecondsToHHMMSS(currentTime)
3006
2998
  ), [nextTime, setNextTime] = React.useState(currentTime), [inputError, setInputError] = React.useState(""), assetWithNewThumbnail = React.useMemo(() => ({ ...asset, thumbTime: nextTime }), [asset, nextTime]), [saving, setSaving] = React.useState(!1), [saveThumbnailError, setSaveThumbnailError] = React.useState(null), handleSave = () => {
3007
2999
  setSaving(!0), client.patch(asset._id).set({ thumbTime: nextTime }).commit({ returnDocuments: !1 }).then(() => void setDialogState(!1)).catch(setSaveThumbnailError).finally(() => void setSaving(!1));
3008
- }, width = 300 * getDevicePixelRatio({ maxDpr: 2 });
3000
+ }, width = 300 * useDevicePixelRatio.getDevicePixelRatio({ maxDpr: 2 });
3009
3001
  if (saveThumbnailError)
3010
3002
  throw saveThumbnailError;
3011
3003
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -3173,7 +3165,7 @@ function VideoPlayer({
3173
3165
  crossOrigin: "anonymous",
3174
3166
  metadata: {
3175
3167
  player_name: "Sanity Admin Dashboard",
3176
- player_version: "2.19.1",
3168
+ player_version: "3.0.1",
3177
3169
  page_type: "Preview Player"
3178
3170
  },
3179
3171
  audio: isAudio,
@@ -3541,7 +3533,7 @@ function useVideoDetails(props) {
3541
3533
  isResyncing
3542
3534
  };
3543
3535
  }
3544
- const AssetInput = (props) => /* @__PURE__ */ jsxRuntime.jsx(FormField$1, { title: props.label, description: props.description, inputId: props.label, children: /* @__PURE__ */ jsxRuntime.jsx(
3536
+ const AssetInput = (props) => /* @__PURE__ */ jsxRuntime.jsx(FormField, { title: props.label, description: props.description, inputId: props.label, children: /* @__PURE__ */ jsxRuntime.jsx(
3545
3537
  ui.TextInput,
3546
3538
  {
3547
3539
  id: props.label,
@@ -4233,7 +4225,7 @@ function a(t) {
4233
4225
  }, []);
4234
4226
  return { ErrorBoundary: (p = h.current, p !== null ? p : (h.current = l(), h.current)), didCatch: i.didCatch, error: i.error, reset: s };
4235
4227
  }
4236
- function ErrorBoundaryCard(props) {
4228
+ function ErrorBoundaryCard$1(props) {
4237
4229
  const { children, schemaType } = props, { push: pushToast } = ui.useToast(), errorRef = React.useRef(null), { ErrorBoundary, didCatch, error, reset } = a({
4238
4230
  onDidCatch: (err, errorInfo) => {
4239
4231
  console.group(err.toString()), console.groupCollapsed("console.error"), console.error(err), console.groupEnd(), err.stack && (console.groupCollapsed("error.stack"), console.log(err.stack), console.groupEnd()), errorInfo?.componentStack && (console.groupCollapsed("errorInfo.componentStack"), console.log(errorInfo.componentStack), console.groupEnd()), console.groupEnd(), pushToast({
@@ -4274,7 +4266,7 @@ function ErrorBoundaryCard(props) {
4274
4266
  /* @__PURE__ */ jsxRuntime.jsx(ui.Inline, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: handleRetry, text: "Retry" }) })
4275
4267
  ] }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children });
4276
4268
  }
4277
- var ErrorBoundaryCard$1 = React.memo(ErrorBoundaryCard);
4269
+ var ErrorBoundaryCard = React.memo(ErrorBoundaryCard$1);
4278
4270
  const InputFallback = () => /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
4279
4271
  ui.Card,
4280
4272
  {
@@ -4870,7 +4862,7 @@ const FileButton = styledComponents.styled(ui.MenuItem)(({ theme }) => {
4870
4862
  background: transparent;
4871
4863
  color: white;
4872
4864
  `, isVideoAsset = (asset) => asset._type === "mux.videoAsset";
4873
- function PlayerActionsMenu(props) {
4865
+ function PlayerActionsMenu$1(props) {
4874
4866
  const { asset, readOnly, dialogState, setDialogState, onChange, onSelect, accept } = props, [open, setOpen] = React.useState(!1), [menuElement, setMenuRef] = React.useState(null), isSigned = React.useMemo(() => getPlaybackPolicy(asset)?.policy === "signed", [asset]), { hasConfigAccess } = useAccessControl(props.config), { resyncAsset, isResyncing } = useResyncAsset({ showToast: !0 }), onReset = React.useCallback(() => onChange(sanity.PatchEvent.from(sanity.unset([]))), [onChange]), handleResync = React.useCallback(async () => {
4875
4867
  setOpen(!1), await resyncAsset(asset);
4876
4868
  }, [resyncAsset, asset]);
@@ -4982,7 +4974,7 @@ function PlayerActionsMenu(props) {
4982
4974
  )
4983
4975
  ] });
4984
4976
  }
4985
- var PlayerActionsMenu$1 = React.memo(PlayerActionsMenu);
4977
+ var PlayerActionsMenu = React.memo(PlayerActionsMenu$1);
4986
4978
  function useFetchFileSize(stagedUpload, maxFileSize) {
4987
4979
  const [fileSize, setFileSize] = React.useState(null), [isLoadingFileSize, setIsLoadingFileSize] = React.useState(!1), [canSkipFileSizeValidation, setCanSkipFileSizeValidation] = React.useState(!1);
4988
4980
  return React.useEffect(() => {
@@ -5691,7 +5683,7 @@ function TextTracksEditor({
5691
5683
  defaultLang
5692
5684
  }) {
5693
5685
  const track = tracks[0];
5694
- return /* @__PURE__ */ jsxRuntime.jsx(sanity.FormField, { title: "Auto-generated subtitle or caption", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
5686
+ return /* @__PURE__ */ jsxRuntime.jsx(sanity.FormField, { title: "Auto-generated subtitle or caption", path: [], children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
5695
5687
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", children: [
5696
5688
  /* @__PURE__ */ jsxRuntime.jsx(
5697
5689
  ui.Checkbox,
@@ -5934,6 +5926,7 @@ const RESOLUTION_TIERS = [
5934
5926
  }) => /* @__PURE__ */ jsxRuntime.jsx(
5935
5927
  sanity.FormField,
5936
5928
  {
5929
+ path: [],
5937
5930
  title: "Resolution Tier",
5938
5931
  description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5939
5932
  "The maximum",
@@ -6009,6 +6002,7 @@ const RESOLUTION_TIERS = [
6009
6002
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
6010
6003
  sanity.FormField,
6011
6004
  {
6005
+ path: [],
6012
6006
  title: "Static Renditions",
6013
6007
  description: "Generate downloadable MP4 or M4A files. Note: Mux will not upscale to produce MP4 renditions - renditions that would cause upscaling are skipped.",
6014
6008
  children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
@@ -6277,6 +6271,7 @@ function UploadConfiguration({
6277
6271
  /* @__PURE__ */ jsxRuntime.jsx(
6278
6272
  sanity.FormField,
6279
6273
  {
6274
+ path: [],
6280
6275
  title: "Video Quality Level",
6281
6276
  description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6282
6277
  "The video quality level informs the cost, quality, and available platform features for the asset.",
@@ -6313,7 +6308,7 @@ function UploadConfiguration({
6313
6308
  }
6314
6309
  ),
6315
6310
  !basicConfig && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6316
- /* @__PURE__ */ jsxRuntime.jsx(sanity.FormField, { title: "Additional Configuration", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
6311
+ /* @__PURE__ */ jsxRuntime.jsx(sanity.FormField, { title: "Additional Configuration", path: [], children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
6317
6312
  /* @__PURE__ */ jsxRuntime.jsx(PlaybackPolicy, { id, config, secrets, dispatch }),
6318
6313
  maxSupportedResolution > 0 && /* @__PURE__ */ jsxRuntime.jsx(
6319
6314
  ResolutionTierSelector,
@@ -6431,6 +6426,7 @@ function WatermarkSection({
6431
6426
  return videoAssetMetadata?.isAudioOnly !== !1 ? null : /* @__PURE__ */ jsxRuntime.jsx(
6432
6427
  sanity.FormField,
6433
6428
  {
6429
+ path: [],
6434
6430
  title: "Watermark",
6435
6431
  description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6436
6432
  "Add a watermark overlay to your video using Mux's native watermark support.",
@@ -6949,7 +6945,7 @@ function Uploader(props) {
6949
6945
  onChange: props.onChange,
6950
6946
  config: props.config,
6951
6947
  buttons: /* @__PURE__ */ jsxRuntime.jsx(
6952
- PlayerActionsMenu$1,
6948
+ PlayerActionsMenu,
6953
6949
  {
6954
6950
  accept: acceptMimeString,
6955
6951
  asset: props.asset,
@@ -6989,12 +6985,12 @@ function Uploader(props) {
6989
6985
  )
6990
6986
  ] });
6991
6987
  }
6992
- const Input = (props) => {
6988
+ const Input$1 = (props) => {
6993
6989
  const client = useClient(), secretDocumentValues = useSecretsDocumentValues(), assetDocumentValues = useAssetDocumentValues(props.value?.asset), poll = useMuxPolling(props.readOnly ? void 0 : assetDocumentValues?.value || void 0), [dialogState, setDialogState] = useDialogState(), { hasConfigAccess } = useAccessControl(props.config), error = secretDocumentValues.error || assetDocumentValues.error || poll.error;
6994
6990
  if (error)
6995
6991
  throw error;
6996
6992
  const isLoading = secretDocumentValues.isLoading || assetDocumentValues.isLoading;
6997
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundaryCard$1, { schemaType: props.schemaType, children: /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(InputFallback, {}), children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(InputFallback, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6993
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundaryCard, { schemaType: props.schemaType, children: /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(InputFallback, {}), children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(InputFallback, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6998
6994
  secretDocumentValues.value.needsSetup && !assetDocumentValues.value ? /* @__PURE__ */ jsxRuntime.jsx(Onboard, { setDialogState, config: props.config }) : /* @__PURE__ */ jsxRuntime.jsx(
6999
6995
  Uploader,
7000
6996
  {
@@ -7018,11 +7014,11 @@ const Input = (props) => {
7018
7014
  )
7019
7015
  ] }) }) }) });
7020
7016
  };
7021
- var Input$1 = React.memo(Input);
7017
+ var Input = React.memo(Input$1);
7022
7018
  function muxVideoCustomRendering(config) {
7023
7019
  return {
7024
7020
  components: {
7025
- input: (props) => /* @__PURE__ */ jsxRuntime.jsx(Input$1, { config: { ...config, ...props.schemaType.options }, ...props })
7021
+ input: (props) => /* @__PURE__ */ jsxRuntime.jsx(Input, { config: { ...config, ...props.schemaType.options }, ...props })
7026
7022
  },
7027
7023
  preview: {
7028
7024
  select: {