sanity-plugin-mux-input 4.1.1 → 4.1.3
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 +65 -31
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useClient as useClient$1, createHookFromObservableFactory, useDocumentStore, collate, useDocumentValues, truncateString, useFormattedDuration, SanityDefaultPreview, useTimeAgo, TextWithTone, isRecord, getPreviewStateObservable, DocumentPreviewPresence, getPreviewValueWithFallback, useDocumentPreviewStore, useSchema, useDocumentPresence, PreviewCard, useCurrentUser, isReference, useProjectId, useDataset, PatchEvent, unset, setIfMissing, set, LinearProgress, FormField as FormField$2, definePlugin } from "sanity";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { SearchIcon } from "@sanity/icons/Search";
|
|
4
4
|
import { Dialog, Stack, Card, Text, Button, useTheme_v2, Flex, Box, TextInput, Checkbox, Code, Inline, Spinner, Heading, Label as Label$1, Radio, MenuButton, Menu, MenuItem, useToast, Autocomplete, Tooltip, TabList, Tab, TabPanel, Grid, useClickOutsideEvent, Popover, MenuDivider, rem } from "@sanity/ui";
|
|
5
5
|
import { createContext, useState, useCallback, useMemo, useContext, useReducer, useId, memo, useRef, useEffect, Suspense, isValidElement } from "react";
|
|
6
6
|
import compact from "lodash/compact.js";
|
|
@@ -11,20 +11,54 @@ import words from "lodash/words.js";
|
|
|
11
11
|
import { suspend, clear, preload } from "suspend-react";
|
|
12
12
|
import { defer, timer, of, Observable, concat, throwError, from, Subject } from "rxjs";
|
|
13
13
|
import { styled, css } from "styled-components";
|
|
14
|
+
import { CheckmarkCircleIcon } from "@sanity/icons/CheckmarkCircle";
|
|
15
|
+
import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
|
|
16
|
+
import { InfoOutlineIcon } from "@sanity/icons/InfoOutline";
|
|
17
|
+
import { RetrieveIcon } from "@sanity/icons/Retrieve";
|
|
18
|
+
import { RetryIcon } from "@sanity/icons/Retry";
|
|
14
19
|
import { uuid } from "@sanity/uuid";
|
|
15
20
|
import { expand, concatMap, tap, switchMap, mergeMap, catchError, mergeMapTo, takeUntil } from "rxjs/operators";
|
|
21
|
+
import { ChevronLeftIcon } from "@sanity/icons/ChevronLeft";
|
|
22
|
+
import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
|
|
23
|
+
import { SyncIcon } from "@sanity/icons/Sync";
|
|
24
|
+
import { SortIcon } from "@sanity/icons/Sort";
|
|
25
|
+
import { CalendarIcon } from "@sanity/icons/Calendar";
|
|
26
|
+
import { CheckmarkIcon } from "@sanity/icons/Checkmark";
|
|
27
|
+
import { ClockIcon } from "@sanity/icons/Clock";
|
|
28
|
+
import { CropIcon } from "@sanity/icons/Crop";
|
|
29
|
+
import { EditIcon } from "@sanity/icons/Edit";
|
|
30
|
+
import { RevertIcon } from "@sanity/icons/Revert";
|
|
31
|
+
import { TagIcon } from "@sanity/icons/Tag";
|
|
32
|
+
import { TrashIcon } from "@sanity/icons/Trash";
|
|
33
|
+
import { DownloadIcon } from "@sanity/icons/Download";
|
|
34
|
+
import { AddIcon } from "@sanity/icons/Add";
|
|
35
|
+
import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
|
|
36
|
+
import { ChevronUpIcon } from "@sanity/icons/ChevronUp";
|
|
37
|
+
import { TranslateIcon } from "@sanity/icons/Translate";
|
|
38
|
+
import { UploadIcon } from "@sanity/icons/Upload";
|
|
16
39
|
import LanguagesList from "iso-639-1";
|
|
17
40
|
import MuxPlayer from "@mux/mux-player-react/lazy";
|
|
18
41
|
import { getDevicePixelRatio } from "use-device-pixel-ratio";
|
|
42
|
+
import { DocumentIcon } from "@sanity/icons/Document";
|
|
19
43
|
import { IntentLink } from "sanity/router";
|
|
44
|
+
import { WarningOutlineIcon } from "@sanity/icons/WarningOutline";
|
|
20
45
|
import isNumber from "lodash/isNumber.js";
|
|
21
46
|
import isString from "lodash/isString.js";
|
|
22
47
|
import { useObservable } from "react-rx";
|
|
48
|
+
import { PublishIcon } from "@sanity/icons/Publish";
|
|
49
|
+
import { LockIcon } from "@sanity/icons/Lock";
|
|
50
|
+
import { PlayIcon } from "@sanity/icons/Play";
|
|
23
51
|
import useSWR from "swr";
|
|
24
52
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
25
53
|
import { useErrorBoundary } from "use-error-boundary";
|
|
54
|
+
import { PlugIcon } from "@sanity/icons/Plug";
|
|
26
55
|
import { UpChunk } from "@mux/upchunk";
|
|
56
|
+
import { EllipsisHorizontalIcon } from "@sanity/icons/EllipsisHorizontal";
|
|
57
|
+
import { ImageIcon } from "@sanity/icons/Image";
|
|
58
|
+
import { ResetIcon } from "@sanity/icons/Reset";
|
|
27
59
|
import { isValidElementType } from "react-is";
|
|
60
|
+
import { DocumentVideoIcon } from "@sanity/icons/DocumentVideo";
|
|
61
|
+
import { WarningFilledIcon } from "@sanity/icons/WarningFilled";
|
|
28
62
|
const ToolIcon = () => /* @__PURE__ */ jsx("svg", { stroke: "currentColor", fill: "currentColor", strokeWidth: "0", viewBox: "0 0 24 24", height: "1em", width: "1em", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M21 3H3c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2zm0 14H3V5h18v12zm-5-6l-7 4V7z" }) }), LOCAL_STORAGE_HAS_SHOWN_WARNING_KEY = "mux-plugin-has-shown-drm-playback-warning", DrmPlaybackWarningContext = createContext({
|
|
29
63
|
hasShownWarning: !1,
|
|
30
64
|
setHasWarnedAboutDrmPlayback: () => null
|
|
@@ -142,7 +176,7 @@ function useDialogState() {
|
|
|
142
176
|
const PLUGIN_VERSION_QUERY = {
|
|
143
177
|
sanityVersion: (
|
|
144
178
|
// @ts-expect-error - this constant is search/replaced so must be exact, not accessed with an index signature
|
|
145
|
-
"4.1.
|
|
179
|
+
"4.1.3"
|
|
146
180
|
)
|
|
147
181
|
};
|
|
148
182
|
function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate, drmConfigId) {
|
|
@@ -363,10 +397,10 @@ function MuxLogo({
|
|
|
363
397
|
/* @__PURE__ */ jsx("path", { d: "M437.511,468.521c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m23.915,-463.762c-23.348,-9.672 -50.226,-4.327 -68.096,13.544l-143.331,143.329l-143.33,-143.329c-17.871,-17.871 -44.747,-23.216 -68.096,-13.544c-23.349,9.671 -38.574,32.455 -38.574,57.729l0,375.026c0,34.51 27.977,62.486 62.487,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-224.173l80.843,80.844c24.404,24.402 63.965,24.402 88.369,-0l80.843,-80.844l0,224.173c0,34.51 27.976,62.486 62.486,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-375.026c0,-25.274 -15.224,-48.058 -38.573,-57.729", style: pathStyle })
|
|
364
398
|
] }) });
|
|
365
399
|
}
|
|
366
|
-
const Logo = styled.span.withConfig({
|
|
400
|
+
const Logo = /* @__PURE__ */ styled.span.withConfig({
|
|
367
401
|
displayName: "Logo",
|
|
368
402
|
componentId: "sc-1tybprx-0"
|
|
369
|
-
})
|
|
403
|
+
})(["display:inline-block;height:0.8em;margin-right:1em;transform:translate(0.3em,-0.2em);"]), Header = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
370
404
|
/* @__PURE__ */ jsx(Logo, { children: /* @__PURE__ */ jsx(MuxLogo, { height: 13 }) }),
|
|
371
405
|
"API Credentials"
|
|
372
406
|
] });
|
|
@@ -931,10 +965,10 @@ function tryWithSuspend(block, onError) {
|
|
|
931
965
|
return onError ? onError(errorOrPromise) : void 0;
|
|
932
966
|
}
|
|
933
967
|
}
|
|
934
|
-
const Image$1 = styled.img.withConfig({
|
|
968
|
+
const Image$1 = /* @__PURE__ */ styled.img.withConfig({
|
|
935
969
|
displayName: "Image",
|
|
936
970
|
componentId: "sc-ul2n6m-0"
|
|
937
|
-
})
|
|
971
|
+
})(["transition:opacity 0.175s ease-out 0s;display:block;width:100%;height:100%;object-fit:contain;object-position:center center;"]), STATUS_TO_TONE = {
|
|
938
972
|
loading: "transparent",
|
|
939
973
|
error: "critical",
|
|
940
974
|
loaded: "default"
|
|
@@ -995,10 +1029,10 @@ function VideoThumbnail({
|
|
|
995
1029
|
} })
|
|
996
1030
|
] }) : null }) });
|
|
997
1031
|
}
|
|
998
|
-
const MissingAssetCheckbox = styled(Checkbox).withConfig({
|
|
1032
|
+
const MissingAssetCheckbox = /* @__PURE__ */ styled(Checkbox).withConfig({
|
|
999
1033
|
displayName: "MissingAssetCheckbox",
|
|
1000
1034
|
componentId: "sc-b02pvs-0"
|
|
1001
|
-
})
|
|
1035
|
+
})(["position:static !important;input::after{content:'';position:absolute;inset:0;display:block;cursor:pointer;z-index:1000;}"]);
|
|
1002
1036
|
function MissingAsset({
|
|
1003
1037
|
asset,
|
|
1004
1038
|
selectAsset,
|
|
@@ -2730,7 +2764,7 @@ function VideoPlayer({
|
|
|
2730
2764
|
/* @__PURE__ */ jsx(MuxPlayer, { poster: isAudio ? void 0 : poster, ref: muxPlayer, ...props, playsInline: !0, playbackId, tokens, preload: "metadata", crossOrigin: "anonymous", metadata: {
|
|
2731
2765
|
player_name: "Sanity Admin Dashboard",
|
|
2732
2766
|
// @ts-expect-error - this constant is search/replaced so must be exact, not accessed with an index signature
|
|
2733
|
-
player_version: "4.1.
|
|
2767
|
+
player_version: "4.1.3",
|
|
2734
2768
|
page_type: "Preview Player"
|
|
2735
2769
|
}, audio: isAudio, _hlsConfig: hlsConfig, style: {
|
|
2736
2770
|
...!isAudio && {
|
|
@@ -2873,10 +2907,10 @@ function DocumentPreview(props) {
|
|
|
2873
2907
|
}
|
|
2874
2908
|
);
|
|
2875
2909
|
}
|
|
2876
|
-
const Container = styled(Box).withConfig({
|
|
2910
|
+
const Container = /* @__PURE__ */ styled(Box).withConfig({
|
|
2877
2911
|
displayName: "Container",
|
|
2878
2912
|
componentId: "sc-a58zkj-0"
|
|
2879
|
-
})
|
|
2913
|
+
})(["*{color:", ";}a{text-decoration:none;}h2{font-size:", ";}"], (props) => props.theme.sanity.color.base.fg, (props) => props.theme.sanity.fonts.text.sizes[1]), VideoReferences = (props) => {
|
|
2880
2914
|
const schema = useSchema();
|
|
2881
2915
|
if (!props.isLoaded)
|
|
2882
2916
|
return /* @__PURE__ */ jsx(SpinnerBox, {});
|
|
@@ -3177,10 +3211,10 @@ ${displayInfo.id}`, icon: TagIcon, size: 2 }),
|
|
|
3177
3211
|
displayInfo.title != displayInfo.id.slice(0, 12) && /* @__PURE__ */ jsx(IconInfo, { text: displayInfo.id.slice(0, 12), icon: TagIcon, size: 1, muted: !0 })
|
|
3178
3212
|
] })
|
|
3179
3213
|
] });
|
|
3180
|
-
}, PlayButton = styled.button.withConfig({
|
|
3214
|
+
}, PlayButton = /* @__PURE__ */ styled.button.withConfig({
|
|
3181
3215
|
displayName: "PlayButton",
|
|
3182
3216
|
componentId: "sc-8aoab-0"
|
|
3183
|
-
})
|
|
3217
|
+
})(["display:block;padding:0;margin:0;border:none;border-radius:0.1875rem;position:relative;cursor:pointer;&::after{content:'';background:var(--card-fg-color);opacity:0;display:block;position:absolute;inset:0;z-index:10;transition:0.15s ease-out;border-radius:inherit;}> div[data-play]{z-index:11;opacity:0;transition:0.15s 0.05s ease-out;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);color:var(--card-fg-color);background:var(--card-bg-color);width:auto;height:30%;aspect-ratio:1;border-radius:100%;display:flex;justify-content:center;align-items:center;box-sizing:border-box;> svg{display:block;width:70%;height:auto;transform:translateX(5%);}}&:hover,&:focus{&::after{opacity:0.3;}> div[data-play]{opacity:1;}}"]);
|
|
3184
3218
|
function VideoInBrowser({
|
|
3185
3219
|
onSelect,
|
|
3186
3220
|
onEdit,
|
|
@@ -3731,10 +3765,10 @@ function SelectAssets({
|
|
|
3731
3765
|
}, [onChange, setDialogState, selectedAsset]);
|
|
3732
3766
|
return /* @__PURE__ */ jsx(VideosBrowser, { onSelect: handleSelect, config });
|
|
3733
3767
|
}
|
|
3734
|
-
const StyledDialog = styled(Dialog).withConfig({
|
|
3768
|
+
const StyledDialog = /* @__PURE__ */ styled(Dialog).withConfig({
|
|
3735
3769
|
displayName: "StyledDialog",
|
|
3736
3770
|
componentId: "sc-w5w8ee-0"
|
|
3737
|
-
})
|
|
3771
|
+
})(["> div[data-ui='DialogCard'] > div[data-ui='Card']{height:100%;}"]);
|
|
3738
3772
|
function InputBrowser({
|
|
3739
3773
|
setDialogState,
|
|
3740
3774
|
asset,
|
|
@@ -3749,22 +3783,22 @@ const useCancelUpload = (asset, onChange) => {
|
|
|
3749
3783
|
return useCallback(() => {
|
|
3750
3784
|
asset && (onChange(PatchEvent.from(unset())), asset.assetId && deleteAssetOnMux(client, asset.assetId), asset._id && client.delete(asset._id));
|
|
3751
3785
|
}, [asset, client, onChange]);
|
|
3752
|
-
}, TopControls = styled.div.withConfig({
|
|
3786
|
+
}, TopControls = /* @__PURE__ */ styled.div.withConfig({
|
|
3753
3787
|
displayName: "TopControls",
|
|
3754
3788
|
componentId: "sc-1drlf9e-0"
|
|
3755
|
-
})
|
|
3789
|
+
})(["position:absolute;top:0;right:0;justify-content:flex-end;button{height:auto;}"]), CardWrapper = /* @__PURE__ */ styled(Card).withConfig({
|
|
3756
3790
|
displayName: "CardWrapper",
|
|
3757
3791
|
componentId: "sc-1mfzr0o-0"
|
|
3758
|
-
})
|
|
3792
|
+
})(["min-height:82px;box-sizing:border-box;"]), FlexWrapper = /* @__PURE__ */ styled(Flex).withConfig({
|
|
3759
3793
|
displayName: "FlexWrapper",
|
|
3760
3794
|
componentId: "sc-1mfzr0o-1"
|
|
3761
|
-
})
|
|
3795
|
+
})(["text-overflow:ellipsis;overflow:hidden;"]), LeftSection = /* @__PURE__ */ styled(Stack).withConfig({
|
|
3762
3796
|
displayName: "LeftSection",
|
|
3763
3797
|
componentId: "sc-1mfzr0o-2"
|
|
3764
|
-
})
|
|
3798
|
+
})(["position:relative;width:60%;"]), CodeWrapper = /* @__PURE__ */ styled(Code).withConfig({
|
|
3765
3799
|
displayName: "CodeWrapper",
|
|
3766
3800
|
componentId: "sc-1mfzr0o-3"
|
|
3767
|
-
})
|
|
3801
|
+
})(["position:relative;width:100%;code{overflow:hidden;text-overflow:ellipsis;position:relative;max-width:200px;}"]), UploadProgress = ({
|
|
3768
3802
|
progress = 100,
|
|
3769
3803
|
onCancel,
|
|
3770
3804
|
filename,
|
|
@@ -3894,13 +3928,13 @@ function FileInputMenuItem(props) {
|
|
|
3894
3928
|
/* @__PURE__ */ jsx("input", { "data-testid": "file-button-input", accept, capture, id, multiple, onChange: handleChange, type: "file", value: "", disabled })
|
|
3895
3929
|
] });
|
|
3896
3930
|
}
|
|
3897
|
-
const LockCard = styled(Card).withConfig({
|
|
3931
|
+
const LockCard = /* @__PURE__ */ styled(Card).withConfig({
|
|
3898
3932
|
displayName: "LockCard",
|
|
3899
3933
|
componentId: "sc-aimiq6-0"
|
|
3900
|
-
})
|
|
3934
|
+
})(["position:absolute;top:0;left:0;opacity:0.6;mix-blend-mode:screen;background:transparent;"]), LockButton = /* @__PURE__ */ styled(Button).withConfig({
|
|
3901
3935
|
displayName: "LockButton",
|
|
3902
3936
|
componentId: "sc-aimiq6-1"
|
|
3903
|
-
})
|
|
3937
|
+
})(["background:transparent;color:white;"]), isVideoAsset = (asset) => asset._type === "mux.videoAsset";
|
|
3904
3938
|
function PlayerActionsMenu$1(props) {
|
|
3905
3939
|
const {
|
|
3906
3940
|
asset,
|
|
@@ -4069,13 +4103,13 @@ function formatBytes(bytes, si = !1, dp = 1) {
|
|
|
4069
4103
|
while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
|
|
4070
4104
|
return bytes.toFixed(dp) + " " + units[u];
|
|
4071
4105
|
}
|
|
4072
|
-
const RangeInput = styled.input.withConfig({
|
|
4106
|
+
const RangeInput = /* @__PURE__ */ styled.input.withConfig({
|
|
4073
4107
|
displayName: "RangeInput",
|
|
4074
4108
|
componentId: "sc-8lzhot-0"
|
|
4075
|
-
})
|
|
4109
|
+
})(["width:100%;height:4px;border-radius:2px;background:var(--card-border-color);outline:none;-webkit-appearance:none;appearance:none;&::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;border-radius:50%;background:var(--card-focus-ring-color,#2276fc);cursor:pointer;border:2px solid white;box-shadow:0 1px 3px rgba(0,0,0,0.2);}&::-moz-range-thumb{width:16px;height:16px;border-radius:50%;background:var(--card-focus-ring-color,#2276fc);cursor:pointer;border:2px solid white;box-shadow:0 1px 3px rgba(0,0,0,0.2);}&:hover::-webkit-slider-thumb{background:var(--card-focus-ring-color,#1a5fc7);}&:hover::-moz-range-thumb{background:var(--card-focus-ring-color,#1a5fc7);}"]), WatermarkOverlay = /* @__PURE__ */ styled.div.withConfig({
|
|
4076
4110
|
displayName: "WatermarkOverlay",
|
|
4077
4111
|
componentId: "sc-8lzhot-1"
|
|
4078
|
-
})
|
|
4112
|
+
})(["position:absolute;max-width:200px;opacity:", ";cursor:move;user-select:none;z-index:10;pointer-events:auto;img{width:100%;height:auto;display:block;pointer-events:none;}&:hover{outline:2px dashed rgba(255,255,255,0.8);outline-offset:4px;}"], (props) => props.$opacity);
|
|
4079
4113
|
function DraggableWatermark({
|
|
4080
4114
|
watermark,
|
|
4081
4115
|
onChange,
|
|
@@ -5257,18 +5291,18 @@ function UploadCard({
|
|
|
5257
5291
|
children
|
|
5258
5292
|
] });
|
|
5259
5293
|
}
|
|
5260
|
-
const HiddenInput$1 = styled.input.attrs({
|
|
5294
|
+
const HiddenInput$1 = /* @__PURE__ */ styled.input.attrs({
|
|
5261
5295
|
type: "text"
|
|
5262
5296
|
}).withConfig({
|
|
5263
5297
|
displayName: "HiddenInput",
|
|
5264
5298
|
componentId: "sc-1u4yc6p-0"
|
|
5265
|
-
})
|
|
5299
|
+
})(["position:absolute;border:0;color:white;opacity:0;&:focus{outline:none;}"]), HiddenInput = /* @__PURE__ */ styled.input.withConfig({
|
|
5266
5300
|
displayName: "HiddenInput",
|
|
5267
5301
|
componentId: "sc-15tkwq4-0"
|
|
5268
|
-
})
|
|
5302
|
+
})(["overflow:hidden;width:0.1px;height:0.1px;opacity:0;position:absolute;z-index:-1;"]), Label = /* @__PURE__ */ styled.label.withConfig({
|
|
5269
5303
|
displayName: "Label",
|
|
5270
5304
|
componentId: "sc-15tkwq4-1"
|
|
5271
|
-
})
|
|
5305
|
+
})(["position:relative;"]), FileInputButton = ({
|
|
5272
5306
|
onSelect,
|
|
5273
5307
|
accept,
|
|
5274
5308
|
...props
|