sanity-plugin-mux-input 4.1.7 → 4.1.9
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.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -34
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "sanity";
|
|
1
2
|
import MuxPlayerElement from "@mux/mux-player";
|
|
2
3
|
import { PartialDeep } from "type-fest";
|
|
3
4
|
/**
|
|
@@ -109,9 +110,9 @@ interface MuxInputConfig {
|
|
|
109
110
|
/**
|
|
110
111
|
* The mime types that are accepted by the input.
|
|
111
112
|
*
|
|
112
|
-
|
|
113
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept}
|
|
113
114
|
* @defaultValue ['video/*','audio/*']
|
|
114
|
-
|
|
115
|
+
*/
|
|
115
116
|
acceptedMimeTypes?: ('audio/*' | 'video/*')[];
|
|
116
117
|
/**
|
|
117
118
|
* Maximum file size allowed for video uploads in bytes.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/util/types.ts","../src/_exports/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/util/types.ts","../src/_exports/index.ts"],"mappings":";;;;;;KAOY;UAYK;;;;;;;;;;;;EAYf,mBAAmB;;;;;;;;EASnB;;;;;;;EAQA;;;;;;;;EASA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;;;;;EAOA;;;;;;;;EASA,oCAAoC;;;;;;;EAQpC,mCAAmC;;;;;;;;EASnC;;;;;;;;EASA;;;;;;EAOA;;;;;;;EASA;;;;;;;;EASA;;;;;;;;EASA;;;;;;;;;;;;;;;;EAiBA,YAAY;;UAGG,qBAAqB;;;;;;;EAOpC;IAGM;IACA,OAAO,MAAM;;;;;;;;EASnB;;cA4BW;KAED,+BAA+B;KA6L/B;UAEK;EACf;EACA;;UAGe;EACf;EACA,QAAQ;;UAGO;EACf;EACA;EACA;EACA;EAEA;EAEA;;UAEe;EACf;EACA;EACA;EACA;EACA;;UAEe;EACf;EACA;EACA;EAEA;EAOA;EAEA;EACA;EAEA;EACA;EACA;IACE;IACA;;;KAGQ,WAAW,gBAAgB,gBAAgB;UAEtC;EACf;;EAEA;EACA;EACA;EACA;EACA;EAEA;EAEA;EACA,cAAc;EACd,QAAQ;EACR,SAAS;EACT;EACA;EAEA;EACA;EACA;IACE;IAGA;;EAEF;EACA;EAEA;EAEA;EAEA;IACE;IACA;MACE;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;;;EAGJ;IACE;IACA;IACA;;EAGF;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEF;IACE;;;UAIa;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,OAAO,YAAY;;cCviBR,eAAe;cAiCf,2BAAQ,cAAA,QAAA"}
|
package/dist/index.js
CHANGED
|
@@ -342,7 +342,7 @@ function useAssets() {
|
|
|
342
342
|
function useDialogState() {
|
|
343
343
|
return useState(!1);
|
|
344
344
|
}
|
|
345
|
-
const PLUGIN_VERSION_QUERY = { sanityVersion: "4.1.
|
|
345
|
+
const PLUGIN_VERSION_QUERY = { sanityVersion: "4.1.9" };
|
|
346
346
|
function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate, drmConfigId) {
|
|
347
347
|
let doc = {
|
|
348
348
|
_id: "secrets.mux",
|
|
@@ -884,7 +884,7 @@ function generateAssetPlaceholder(assetId) {
|
|
|
884
884
|
* @returns true if the filename is empty or matches the placeholder format
|
|
885
885
|
*/
|
|
886
886
|
function isEmptyOrPlaceholderTitle(filename, assetId) {
|
|
887
|
-
return !filename || filename.trim() === ""
|
|
887
|
+
return !filename || filename.trim() === "" || filename === generateAssetPlaceholder(assetId);
|
|
888
888
|
}
|
|
889
889
|
function parseMuxDate(date) {
|
|
890
890
|
return /* @__PURE__ */ new Date(Number(date) * 1e3);
|
|
@@ -1112,7 +1112,7 @@ function muxAssetToSanityDocument(asset) {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
const useAssetsInSanity = createHookFromObservableFactory((documentStore) => documentStore.listenQuery("*[_type == \"mux.videoAsset\"] {\n \"uploadId\": coalesce(uploadId, data.upload_id),\n \"assetId\": coalesce(assetId, data.id),\n }", {}, { apiVersion: SANITY_API_VERSION }));
|
|
1114
1114
|
function assetExistsInSanity(asset, existingAssets) {
|
|
1115
|
-
return asset.status === "ready"
|
|
1115
|
+
return asset.status === "ready" && existingAssets.some((existing) => existing.assetId === asset.id || existing.uploadId === asset.upload_id);
|
|
1116
1116
|
}
|
|
1117
1117
|
function useInView(ref, options = {}) {
|
|
1118
1118
|
let [inView, setInView] = useState(!1);
|
|
@@ -3716,7 +3716,11 @@ function EditThumbnailDialog({ asset, currentTime = 0 }) {
|
|
|
3716
3716
|
placeholder: "hh:mm:ss",
|
|
3717
3717
|
onChange: (event) => {
|
|
3718
3718
|
let value = event.currentTarget.value;
|
|
3719
|
-
setTimeFormatted(value), isValidTimeFormat(value)
|
|
3719
|
+
if (setTimeFormatted(value), isValidTimeFormat(value)) {
|
|
3720
|
+
setInputError("");
|
|
3721
|
+
let totalSeconds = getSecondsFromTimeFormat(value);
|
|
3722
|
+
setNextTime(totalSeconds);
|
|
3723
|
+
} else setInputError("Invalid time format");
|
|
3720
3724
|
},
|
|
3721
3725
|
customValidity: inputError
|
|
3722
3726
|
})]
|
|
@@ -3861,7 +3865,7 @@ function VideoPlayer({ asset, thumbnailWidth = 250, children, hlsConfig, ...prop
|
|
|
3861
3865
|
crossOrigin: "anonymous",
|
|
3862
3866
|
metadata: {
|
|
3863
3867
|
player_name: "Sanity Admin Dashboard",
|
|
3864
|
-
player_version: "4.1.
|
|
3868
|
+
player_version: "4.1.9",
|
|
3865
3869
|
page_type: "Preview Player"
|
|
3866
3870
|
},
|
|
3867
3871
|
audio: isAudio,
|
|
@@ -3998,15 +4002,8 @@ function PaneItemPreview(props) {
|
|
|
3998
4002
|
function getIconWithFallback(icon, schemaType, defaultIcon) {
|
|
3999
4003
|
return icon === !1 ? !1 : icon || schemaType && schemaType.icon || defaultIcon || !1;
|
|
4000
4004
|
}
|
|
4001
|
-
function DocumentPreviewLink(props) {
|
|
4002
|
-
return (linkProps) => /* @__PURE__ */ jsx(IntentLink, {
|
|
4003
|
-
intent: "edit",
|
|
4004
|
-
params: { id: props.documentPair.id },
|
|
4005
|
-
children: linkProps.children
|
|
4006
|
-
});
|
|
4007
|
-
}
|
|
4008
4005
|
function DocumentPreview(props) {
|
|
4009
|
-
let { schemaType, documentPair } = props, doc = documentPair?.draft || documentPair?.published, id = documentPair.id || "", documentPreviewStore = useDocumentPreviewStore(), schema = useSchema(), documentPresence = useDocumentPresence(id), hasSchemaType = !!(schemaType && schemaType.name && schema.get(schemaType.name)),
|
|
4006
|
+
let { schemaType, documentPair } = props, doc = documentPair?.draft || documentPair?.published, id = documentPair.id || "", documentPreviewStore = useDocumentPreviewStore(), schema = useSchema(), documentPresence = useDocumentPresence(id), hasSchemaType = !!(schemaType && schemaType.name && schema.get(schemaType.name)), children = useMemo(() => doc ? !schemaType || !hasSchemaType ? /* @__PURE__ */ jsx(MissingSchemaType, { value: doc }) : /* @__PURE__ */ jsx(PaneItemPreview, {
|
|
4010
4007
|
documentPreviewStore,
|
|
4011
4008
|
icon: getIconWithFallback(void 0, schemaType, DocumentIcon),
|
|
4012
4009
|
schemaType,
|
|
@@ -4022,13 +4019,15 @@ function DocumentPreview(props) {
|
|
|
4022
4019
|
]);
|
|
4023
4020
|
return /* @__PURE__ */ jsx(PreviewCard, {
|
|
4024
4021
|
__unstable_focusRing: !0,
|
|
4025
|
-
as:
|
|
4022
|
+
as: IntentLink,
|
|
4023
|
+
intent: "edit",
|
|
4024
|
+
params: { id: props.documentPair.id },
|
|
4026
4025
|
"data-as": "a",
|
|
4027
4026
|
"data-ui": "PaneItem",
|
|
4028
4027
|
padding: 2,
|
|
4029
4028
|
radius: 2,
|
|
4030
4029
|
tone: "inherit",
|
|
4031
|
-
children
|
|
4030
|
+
children
|
|
4032
4031
|
});
|
|
4033
4032
|
}
|
|
4034
4033
|
const Container = styled(Box).withConfig({
|
|
@@ -4036,7 +4035,18 @@ const Container = styled(Box).withConfig({
|
|
|
4036
4035
|
componentId: "sc-tqydu5-0"
|
|
4037
4036
|
})`*{color:${(props) => props.theme.sanity.color.base.fg};}a{text-decoration:none;}h2{font-size:${(props) => props.theme.sanity.fonts.text.sizes[1]};}`, VideoReferences = (props) => {
|
|
4038
4037
|
let schema = useSchema();
|
|
4039
|
-
|
|
4038
|
+
if (!props.isLoaded) return /* @__PURE__ */ jsx(SpinnerBox, {});
|
|
4039
|
+
if (!props.references?.length) return /* @__PURE__ */ jsx(Card, {
|
|
4040
|
+
border: !0,
|
|
4041
|
+
radius: 3,
|
|
4042
|
+
padding: 3,
|
|
4043
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
4044
|
+
size: 2,
|
|
4045
|
+
children: "No documents are using this video"
|
|
4046
|
+
})
|
|
4047
|
+
});
|
|
4048
|
+
let documentPairs = collate(props.references || []);
|
|
4049
|
+
return /* @__PURE__ */ jsx(Container, { children: documentPairs?.map((documentPair) => /* @__PURE__ */ jsx(Card, {
|
|
4040
4050
|
marginBottom: 2,
|
|
4041
4051
|
padding: 2,
|
|
4042
4052
|
radius: 2,
|
|
@@ -4046,15 +4056,7 @@ const Container = styled(Box).withConfig({
|
|
|
4046
4056
|
documentPair,
|
|
4047
4057
|
schemaType: schema.get(documentPair.type)
|
|
4048
4058
|
}) })
|
|
4049
|
-
}, documentPair.id)) })
|
|
4050
|
-
border: !0,
|
|
4051
|
-
radius: 3,
|
|
4052
|
-
padding: 3,
|
|
4053
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
4054
|
-
size: 2,
|
|
4055
|
-
children: "No documents are using this video"
|
|
4056
|
-
})
|
|
4057
|
-
}) : /* @__PURE__ */ jsx(SpinnerBox, {});
|
|
4059
|
+
}, documentPair.id)) });
|
|
4058
4060
|
};
|
|
4059
4061
|
function DeleteDialog({ asset, references, referencesLoading, cancelDelete, succeededDeleting }) {
|
|
4060
4062
|
let client = useClient$1(), [state, setState] = useState("checkingReferences"), [deleteOnMux, setDeleteOnMux] = useState(!0), toast = useToast();
|
|
@@ -5349,11 +5351,12 @@ const StyledDialog = styled(Dialog).withConfig({
|
|
|
5349
5351
|
componentId: "sc-z1aqru-0"
|
|
5350
5352
|
})`> div[data-ui='DialogCard'] > div[data-ui='Card']{height:100%;}`;
|
|
5351
5353
|
function InputBrowser({ setDialogState, asset, onChange, config }) {
|
|
5354
|
+
let id = `InputBrowser${useId()}`, handleClose = useCallback(() => setDialogState(!1), [setDialogState]);
|
|
5352
5355
|
return /* @__PURE__ */ jsx(StyledDialog, {
|
|
5353
5356
|
__unstable_autoFocus: !0,
|
|
5354
5357
|
header: "Select video",
|
|
5355
|
-
id
|
|
5356
|
-
onClose:
|
|
5358
|
+
id,
|
|
5359
|
+
onClose: handleClose,
|
|
5357
5360
|
width: 2,
|
|
5358
5361
|
children: /* @__PURE__ */ jsx(SelectAssets, {
|
|
5359
5362
|
config,
|
|
@@ -5997,7 +6000,8 @@ function WatermarkControls({ watermark, onChange, onValidationChange, previewCon
|
|
|
5997
6000
|
}
|
|
5998
6001
|
setIsValidating(!0), setIsValid(null), setUrlError(null), validationTimeoutRef.current = setTimeout(() => {
|
|
5999
6002
|
try {
|
|
6000
|
-
|
|
6003
|
+
let pathname = new URL(url).pathname.toLowerCase();
|
|
6004
|
+
if (isValidExtension(pathname)) {
|
|
6001
6005
|
setIsValid(!0), setUrlError(null), onValidationChange?.(null);
|
|
6002
6006
|
let img = new Image();
|
|
6003
6007
|
img.onload = () => {
|
|
@@ -6264,10 +6268,12 @@ function WatermarkControls({ watermark, onChange, onValidationChange, previewCon
|
|
|
6264
6268
|
text: "Manual",
|
|
6265
6269
|
mode: mode === "manual" ? "default" : "ghost",
|
|
6266
6270
|
onClick: () => {
|
|
6267
|
-
setMode("manual")
|
|
6271
|
+
setMode("manual");
|
|
6272
|
+
let overlay = convertWatermarkToMuxOverlay({
|
|
6268
6273
|
...watermark,
|
|
6269
6274
|
enabled: !0
|
|
6270
|
-
})
|
|
6275
|
+
});
|
|
6276
|
+
updateOverlaySettings(overlay ?? {});
|
|
6271
6277
|
}
|
|
6272
6278
|
})]
|
|
6273
6279
|
})]
|
|
@@ -7441,7 +7447,9 @@ function withFocusRing(component) {
|
|
|
7441
7447
|
}
|
|
7442
7448
|
const UploadCardWithFocusRing = withFocusRing(Card);
|
|
7443
7449
|
function UploadCard({ children, tone, onPaste, onDrop, onDragEnter, onDragLeave, onDragOver, ref }) {
|
|
7444
|
-
let inputRef = useRef(null)
|
|
7450
|
+
let inputRef = useRef(null), handleKeyDown = useCallback((event) => {
|
|
7451
|
+
event.target.closest("#vtt-url") || (event.ctrlKey || event.metaKey) && event.key === "v" && inputRef.current.focus();
|
|
7452
|
+
}, []);
|
|
7445
7453
|
return /* @__PURE__ */ jsxs(UploadCardWithFocusRing, {
|
|
7446
7454
|
tone,
|
|
7447
7455
|
ref,
|
|
@@ -7449,9 +7457,7 @@ function UploadCard({ children, tone, onPaste, onDrop, onDragEnter, onDragLeave,
|
|
|
7449
7457
|
radius: 2,
|
|
7450
7458
|
shadow: 0,
|
|
7451
7459
|
tabIndex: 0,
|
|
7452
|
-
onKeyDown:
|
|
7453
|
-
event.target.closest("#vtt-url") || (event.ctrlKey || event.metaKey) && event.key === "v" && inputRef.current.focus();
|
|
7454
|
-
}, []),
|
|
7460
|
+
onKeyDown: handleKeyDown,
|
|
7455
7461
|
onPaste,
|
|
7456
7462
|
onDrop,
|
|
7457
7463
|
onDragEnter,
|