sanity-plugin-mux-input 2.3.6 → 2.4.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/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +93 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -119
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/actions/upload.ts +1 -1
- package/src/components/FileInputArea.tsx +1 -1
- package/src/components/Input.tsx +1 -1
- package/src/components/InputBrowser.tsx +1 -1
- package/src/components/InputError.tsx +1 -1
- package/src/components/MuxLogo.tsx +1 -1
- package/src/components/Onboard.tsx +1 -1
- package/src/components/PlayerActionsMenu.tsx +5 -6
- package/src/components/SelectAsset.tsx +1 -1
- package/src/components/SelectSortOptions.tsx +1 -1
- package/src/components/UploadPlaceholder.tsx +2 -3
- package/src/components/VideoDetails/VideoDetails.tsx +7 -0
- package/src/components/VideoThumbnail.tsx +2 -2
- package/src/util/getPlaybackPolicy.ts +7 -2
- package/src/util/getVideoMetadata.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useClient as useClient$1, createHookFromObservableFactory, useDocumentStore, collate, useDocumentValues, truncateString, useFormattedDuration, SanityDefaultPreview, useTimeAgo, TextWithTone, isRecord, getPreviewStateObservable, getPreviewValueWithFallback, DocumentPreviewPresence, useDocumentPreviewStore, useSchema, useDocumentPresence, PreviewCard, 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
3
|
import { ErrorOutlineIcon, RetrieveIcon, RetryIcon, CheckmarkCircleIcon, SortIcon, WarningOutlineIcon, EditIcon, PublishIcon, DocumentIcon, TrashIcon, CheckmarkIcon, RevertIcon, SearchIcon, ClockIcon, CropIcon, CalendarIcon, TagIcon, LockIcon, PlayIcon, PlugIcon, UploadIcon, ResetIcon, EllipsisHorizontalIcon, TranslateIcon, DocumentVideoIcon } from "@sanity/icons";
|
|
4
|
-
import { Card, Box, Spinner, Stack, Text, Checkbox, Button, Dialog, Flex, Heading, Code, MenuButton, Menu, MenuItem, Tooltip, Inline, useToast, TabList, Tab, TabPanel, TextInput, Label as Label$1, Grid,
|
|
4
|
+
import { Card, Box, Spinner, Stack, Text, Checkbox, Button, Dialog, Flex, Heading, Code, MenuButton, Menu, MenuItem, Tooltip, Inline, useToast, TabList, Tab, TabPanel, TextInput, Label as Label$1, Grid, useClickOutsideEvent, Popover, MenuDivider, Autocomplete, Radio, rem } from "@sanity/ui";
|
|
5
5
|
import React, { useState, useMemo, useEffect, useRef, useId, memo, isValidElement, useCallback, useReducer, PureComponent, createElement, forwardRef, Suspense } from "react";
|
|
6
6
|
import compact from "lodash/compact.js";
|
|
7
7
|
import toLower from "lodash/toLower.js";
|
|
@@ -195,25 +195,24 @@ const name = "mux-input", cacheNs = "sanity-plugin-mux-input", muxSecretsDocumen
|
|
|
195
195
|
path$1
|
|
196
196
|
), cache = useMemo(() => {
|
|
197
197
|
const exists = !!value, secrets = {
|
|
198
|
-
token:
|
|
199
|
-
secretKey:
|
|
200
|
-
enableSignedUrls:
|
|
201
|
-
signingKeyId:
|
|
202
|
-
signingKeyPrivate:
|
|
198
|
+
token: value?.token || null,
|
|
199
|
+
secretKey: value?.secretKey || null,
|
|
200
|
+
enableSignedUrls: value?.enableSignedUrls || !1,
|
|
201
|
+
signingKeyId: value?.signingKeyId || null,
|
|
202
|
+
signingKeyPrivate: value?.signingKeyPrivate || null
|
|
203
203
|
};
|
|
204
204
|
return {
|
|
205
205
|
isInitialSetup: !exists,
|
|
206
|
-
needsSetup: !
|
|
206
|
+
needsSetup: !secrets?.token || !secrets?.secretKey,
|
|
207
207
|
secrets
|
|
208
208
|
};
|
|
209
209
|
}, [value]);
|
|
210
210
|
return { error, isLoading, value: cache };
|
|
211
211
|
};
|
|
212
212
|
function useImportMuxAssets() {
|
|
213
|
-
var _a;
|
|
214
213
|
const documentStore = useDocumentStore(), client = useClient$1({
|
|
215
214
|
apiVersion: SANITY_API_VERSION
|
|
216
|
-
}), [assetsInSanity, assetsInSanityLoading] = useAssetsInSanity(documentStore), secretDocumentValues = useSecretsDocumentValues(), hasSecrets = !!
|
|
215
|
+
}), [assetsInSanity, assetsInSanityLoading] = useAssetsInSanity(documentStore), secretDocumentValues = useSecretsDocumentValues(), hasSecrets = !!secretDocumentValues.value.secrets?.secretKey, [importError, setImportError] = useState(), [importState, setImportState] = useState("closed"), dialogOpen = importState !== "closed", muxAssets = useMuxAssets({
|
|
217
216
|
secrets: secretDocumentValues.value.secrets,
|
|
218
217
|
enabled: hasSecrets && dialogOpen
|
|
219
218
|
}), missingAssets = useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((a2) => !assetExistsInSanity(a2, assetsInSanity)) : void 0, [assetsInSanity, muxAssets.data]), [selectedAssets, setSelectedAssets] = useState([]), closeDialog = () => {
|
|
@@ -247,8 +246,7 @@ function useImportMuxAssets() {
|
|
|
247
246
|
};
|
|
248
247
|
}
|
|
249
248
|
function muxAssetToSanityDocument(asset) {
|
|
250
|
-
|
|
251
|
-
const playbackId = (_a = (asset.playback_ids || []).find((p) => p.id)) == null ? void 0 : _a.id;
|
|
249
|
+
const playbackId = (asset.playback_ids || []).find((p) => p.id)?.id;
|
|
252
250
|
if (playbackId)
|
|
253
251
|
return {
|
|
254
252
|
_id: uuid(),
|
|
@@ -285,9 +283,8 @@ function useInView(options = {}) {
|
|
|
285
283
|
return useEffect(() => {
|
|
286
284
|
if (!ref.current) return;
|
|
287
285
|
const observer = new IntersectionObserver(([entry], obs) => {
|
|
288
|
-
var _a;
|
|
289
286
|
const nowInView = entry.isIntersecting && obs.thresholds.some((threshold) => entry.intersectionRatio >= threshold);
|
|
290
|
-
setInView(nowInView),
|
|
287
|
+
setInView(nowInView), options?.onChange?.(nowInView);
|
|
291
288
|
}, options), toObserve = ref.current;
|
|
292
289
|
return observer.observe(toObserve), () => {
|
|
293
290
|
toObserve && observer.unobserve(toObserve);
|
|
@@ -310,11 +307,11 @@ function readSecrets(client) {
|
|
|
310
307
|
{ _id }
|
|
311
308
|
);
|
|
312
309
|
return {
|
|
313
|
-
token:
|
|
314
|
-
secretKey:
|
|
315
|
-
enableSignedUrls: !!
|
|
316
|
-
signingKeyId:
|
|
317
|
-
signingKeyPrivate:
|
|
310
|
+
token: data?.token || null,
|
|
311
|
+
secretKey: data?.secretKey || null,
|
|
312
|
+
enableSignedUrls: !!data?.enableSignedUrls || !1,
|
|
313
|
+
signingKeyId: data?.signingKeyId || null,
|
|
314
|
+
signingKeyPrivate: data?.signingKeyPrivate || null
|
|
318
315
|
};
|
|
319
316
|
}, [cacheNs, _id, projectId, dataset]);
|
|
320
317
|
}
|
|
@@ -326,7 +323,7 @@ function generateJwt(client, playbackId, aud, payload) {
|
|
|
326
323
|
throw new TypeError("Missing `signingKeyPrivate`.\n Check your plugin's configuration");
|
|
327
324
|
const { default: sign } = suspend(() => import("jsonwebtoken-esm/sign"), ["jsonwebtoken-esm/sign"]);
|
|
328
325
|
return sign(
|
|
329
|
-
payload ? JSON.parse(JSON.stringify(payload, (_, v) => v
|
|
326
|
+
payload ? JSON.parse(JSON.stringify(payload, (_, v) => v ?? void 0)) : {},
|
|
330
327
|
atob(signingKeyPrivate),
|
|
331
328
|
{
|
|
332
329
|
algorithm: "RS256",
|
|
@@ -339,13 +336,12 @@ function generateJwt(client, playbackId, aud, payload) {
|
|
|
339
336
|
);
|
|
340
337
|
}
|
|
341
338
|
function getPlaybackId(asset) {
|
|
342
|
-
if (!
|
|
339
|
+
if (!asset?.playbackId)
|
|
343
340
|
throw console.error("Asset is missing a playbackId", { asset }), new TypeError("Missing playbackId");
|
|
344
341
|
return asset.playbackId;
|
|
345
342
|
}
|
|
346
343
|
function getPlaybackPolicy(asset) {
|
|
347
|
-
|
|
348
|
-
return (_d = (_c = (_b = (_a = asset.data) == null ? void 0 : _a.playback_ids) == null ? void 0 : _b[0]) == null ? void 0 : _c.policy) != null ? _d : "public";
|
|
344
|
+
return asset.data?.playback_ids?.find((playbackId) => asset.playbackId === playbackId.id)?.policy ?? "public";
|
|
349
345
|
}
|
|
350
346
|
function getAnimatedPosterSrc({
|
|
351
347
|
asset,
|
|
@@ -358,7 +354,7 @@ function getAnimatedPosterSrc({
|
|
|
358
354
|
}) {
|
|
359
355
|
const params = { height, width, start, end, fps }, playbackId = getPlaybackId(asset);
|
|
360
356
|
let searchParams = new URLSearchParams(
|
|
361
|
-
JSON.parse(JSON.stringify(params, (_, v) => v
|
|
357
|
+
JSON.parse(JSON.stringify(params, (_, v) => v ?? void 0))
|
|
362
358
|
);
|
|
363
359
|
if (getPlaybackPolicy(asset) === "signed") {
|
|
364
360
|
const token = generateJwt(client, playbackId, "g", params);
|
|
@@ -389,7 +385,7 @@ function VideoThumbnail({
|
|
|
389
385
|
status !== "error" && setStatus("error");
|
|
390
386
|
return;
|
|
391
387
|
}
|
|
392
|
-
}, [asset, client,
|
|
388
|
+
}, [asset, client, posterWidth, status]);
|
|
393
389
|
function handleLoad() {
|
|
394
390
|
setStatus("loaded");
|
|
395
391
|
}
|
|
@@ -474,7 +470,6 @@ function MissingAsset({
|
|
|
474
470
|
selectAsset,
|
|
475
471
|
selected
|
|
476
472
|
}) {
|
|
477
|
-
var _a;
|
|
478
473
|
const duration = useFormattedDuration(asset.duration * 1e3);
|
|
479
474
|
return /* @__PURE__ */ jsx(
|
|
480
475
|
Card,
|
|
@@ -503,7 +498,7 @@ function MissingAsset({
|
|
|
503
498
|
assetId: asset.id,
|
|
504
499
|
data: asset,
|
|
505
500
|
filename: asset.id,
|
|
506
|
-
playbackId:
|
|
501
|
+
playbackId: asset.playback_ids.find((p) => p.id)?.id
|
|
507
502
|
},
|
|
508
503
|
width: 150
|
|
509
504
|
}
|
|
@@ -534,8 +529,7 @@ function MissingAsset({
|
|
|
534
529
|
);
|
|
535
530
|
}
|
|
536
531
|
function ImportVideosDialog(props) {
|
|
537
|
-
|
|
538
|
-
const { importState } = props, canTriggerImport = (importState === "idle" || importState === "error") && props.selectedAssets.length > 0, isImporting = importState === "importing", noAssetsToImport = ((_a = props.missingAssets) == null ? void 0 : _a.length) === 0 && !props.muxAssets.loading && !props.assetsInSanityLoading;
|
|
532
|
+
const { importState } = props, canTriggerImport = (importState === "idle" || importState === "error") && props.selectedAssets.length > 0, isImporting = importState === "importing", noAssetsToImport = props.missingAssets?.length === 0 && !props.muxAssets.loading && !props.assetsInSanityLoading;
|
|
539
533
|
return /* @__PURE__ */ jsx(
|
|
540
534
|
Dialog,
|
|
541
535
|
{
|
|
@@ -567,7 +561,7 @@ function ImportVideosDialog(props) {
|
|
|
567
561
|
fontSize: 2,
|
|
568
562
|
padding: 3,
|
|
569
563
|
mode: "ghost",
|
|
570
|
-
text:
|
|
564
|
+
text: props.selectedAssets?.length > 0 ? `Import ${props.selectedAssets.length} video(s)` : "No video(s) selected",
|
|
571
565
|
tone: "positive",
|
|
572
566
|
onClick: props.importAssets,
|
|
573
567
|
iconRight: isImporting && Spinner,
|
|
@@ -773,10 +767,9 @@ function VideoPlayer({
|
|
|
773
767
|
children,
|
|
774
768
|
...props
|
|
775
769
|
}) {
|
|
776
|
-
var _a, _b;
|
|
777
770
|
const client = useClient(), isAudio = assetIsAudio(asset), { src: videoSrc, error } = useMemo(() => {
|
|
778
771
|
try {
|
|
779
|
-
const src =
|
|
772
|
+
const src = asset?.playbackId && getVideoSrc({ client, asset });
|
|
780
773
|
return src ? { src } : { error: new TypeError("Asset has no playback ID") };
|
|
781
774
|
} catch (error2) {
|
|
782
775
|
return { error: error2 };
|
|
@@ -787,7 +780,7 @@ function VideoPlayer({
|
|
|
787
780
|
} catch {
|
|
788
781
|
return !1;
|
|
789
782
|
}
|
|
790
|
-
}, [videoSrc]), [width, height] = (
|
|
783
|
+
}, [videoSrc]), [width, height] = (asset?.data?.aspect_ratio ?? "16:9").split(":").map(Number), targetAspectRatio = props.forceAspectRatio || (Number.isNaN(width) ? 16 / 9 : width / height);
|
|
791
784
|
let aspectRatio = Math.max(MIN_ASPECT_RATIO, targetAspectRatio);
|
|
792
785
|
return isAudio && (aspectRatio = props.forceAspectRatio ? (
|
|
793
786
|
// Make it wider when forcing aspect ratio to balance with videos' rendering height (audio players overflow a bit)
|
|
@@ -805,7 +798,7 @@ function VideoPlayer({
|
|
|
805
798
|
crossOrigin: "anonymous",
|
|
806
799
|
metadata: {
|
|
807
800
|
player_name: "Sanity Admin Dashboard",
|
|
808
|
-
player_version: "2.
|
|
801
|
+
player_version: "2.4.0",
|
|
809
802
|
page_type: "Preview Player"
|
|
810
803
|
},
|
|
811
804
|
audio: isAudio,
|
|
@@ -838,8 +831,7 @@ function VideoPlayer({
|
|
|
838
831
|
] });
|
|
839
832
|
}
|
|
840
833
|
function assetIsAudio(asset) {
|
|
841
|
-
|
|
842
|
-
return ((_a = asset.data) == null ? void 0 : _a.max_stored_resolution) === "Audio only";
|
|
834
|
+
return asset.data?.max_stored_resolution === "Audio only";
|
|
843
835
|
}
|
|
844
836
|
function deleteAssetOnMux(client, assetId) {
|
|
845
837
|
const { dataset } = client.config();
|
|
@@ -854,13 +846,13 @@ async function deleteAsset({
|
|
|
854
846
|
asset,
|
|
855
847
|
deleteOnMux
|
|
856
848
|
}) {
|
|
857
|
-
if (!
|
|
849
|
+
if (!asset?._id) return !0;
|
|
858
850
|
try {
|
|
859
851
|
await client.delete(asset._id);
|
|
860
852
|
} catch {
|
|
861
853
|
return "failed-sanity";
|
|
862
854
|
}
|
|
863
|
-
if (deleteOnMux && asset
|
|
855
|
+
if (deleteOnMux && asset?.assetId)
|
|
864
856
|
try {
|
|
865
857
|
await deleteAssetOnMux(client, asset.assetId);
|
|
866
858
|
} catch {
|
|
@@ -970,7 +962,7 @@ function DocumentPreviewInRool(props) {
|
|
|
970
962
|
return (linkProps) => /* @__PURE__ */ jsx(IntentLink, { intent: "edit", params: { id: props.documentPair.id }, children: linkProps.children });
|
|
971
963
|
}
|
|
972
964
|
function DocumentPreview(props) {
|
|
973
|
-
const { schemaType, documentPair } = props, doc =
|
|
965
|
+
const { 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)), PreviewComponent = useMemo(() => doc ? !schemaType || !hasSchemaType ? /* @__PURE__ */ jsx(MissingSchemaType, { value: doc }) : /* @__PURE__ */ jsx(
|
|
974
966
|
PaneItemPreview,
|
|
975
967
|
{
|
|
976
968
|
documentPreviewStore,
|
|
@@ -1006,14 +998,13 @@ const Container = styled(Box)`
|
|
|
1006
998
|
font-size: ${(props) => props.theme.sanity.fonts.text.sizes[1]};
|
|
1007
999
|
}
|
|
1008
1000
|
`, VideoReferences = (props) => {
|
|
1009
|
-
var _a;
|
|
1010
1001
|
const schema = useSchema();
|
|
1011
1002
|
if (!props.isLoaded)
|
|
1012
1003
|
return /* @__PURE__ */ jsx(SpinnerBox, {});
|
|
1013
|
-
if (!
|
|
1004
|
+
if (!props.references?.length)
|
|
1014
1005
|
return /* @__PURE__ */ jsx(Card, { border: !0, radius: 3, padding: 3, children: /* @__PURE__ */ jsx(Text, { size: 2, children: "No documents are using this video" }) });
|
|
1015
1006
|
const documentPairs = collate(props.references || []);
|
|
1016
|
-
return /* @__PURE__ */ jsx(Container, { children: documentPairs
|
|
1007
|
+
return /* @__PURE__ */ jsx(Container, { children: documentPairs?.map((documentPair) => {
|
|
1017
1008
|
const schemaType = schema.get(documentPair.type);
|
|
1018
1009
|
return /* @__PURE__ */ jsx(
|
|
1019
1010
|
Card,
|
|
@@ -1046,7 +1037,7 @@ function DeleteDialog({
|
|
|
1046
1037
|
}) {
|
|
1047
1038
|
const client = useClient(), [state, setState] = useState("checkingReferences"), [deleteOnMux, setDeleteOnMux] = useState(!0), toast = useToast();
|
|
1048
1039
|
useEffect(() => {
|
|
1049
|
-
state !== "checkingReferences" || referencesLoading || setState(references
|
|
1040
|
+
state !== "checkingReferences" || referencesLoading || setState(references?.length ? "cantDelete" : "confirm");
|
|
1050
1041
|
}, [state, references, referencesLoading]);
|
|
1051
1042
|
async function confirmDelete() {
|
|
1052
1043
|
if (state !== "confirm") return;
|
|
@@ -1088,7 +1079,7 @@ function DeleteDialog({
|
|
|
1088
1079
|
/* @__PURE__ */ jsx(Heading, { size: 2, children: "Video can't be deleted" }),
|
|
1089
1080
|
/* @__PURE__ */ jsxs(Text, { size: 2, style: { marginBottom: "2rem" }, children: [
|
|
1090
1081
|
"There are ",
|
|
1091
|
-
references
|
|
1082
|
+
references?.length,
|
|
1092
1083
|
" document",
|
|
1093
1084
|
references && references.length > 0 && "s",
|
|
1094
1085
|
" ",
|
|
@@ -1167,16 +1158,16 @@ function formatSeconds(seconds) {
|
|
|
1167
1158
|
return hrs > 0 && (ret += "" + hrs + ":" + (mins < 10 ? "0" : "")), ret += "" + mins + ":" + (secs < 10 ? "0" : ""), ret += "" + secs, ret;
|
|
1168
1159
|
}
|
|
1169
1160
|
function getVideoMetadata(doc) {
|
|
1170
|
-
|
|
1171
|
-
const id = doc.assetId || doc._id || "", date = (_a = doc.data) != null && _a.created_at ? new Date(Number(doc.data.created_at) * 1e3) : new Date(doc._createdAt || doc._updatedAt || Date.now());
|
|
1161
|
+
const id = doc.assetId || doc._id || "", date = doc.data?.created_at ? new Date(Number(doc.data.created_at) * 1e3) : new Date(doc._createdAt || doc._updatedAt || Date.now());
|
|
1172
1162
|
return {
|
|
1173
1163
|
title: doc.filename || id.slice(0, 12),
|
|
1174
1164
|
id,
|
|
1165
|
+
playbackId: doc.playbackId,
|
|
1175
1166
|
createdAt: date,
|
|
1176
|
-
duration:
|
|
1177
|
-
aspect_ratio:
|
|
1178
|
-
max_stored_resolution:
|
|
1179
|
-
max_stored_frame_rate:
|
|
1167
|
+
duration: doc.data?.duration ? formatSeconds(doc.data?.duration) : void 0,
|
|
1168
|
+
aspect_ratio: doc.data?.aspect_ratio,
|
|
1169
|
+
max_stored_resolution: doc.data?.max_stored_resolution,
|
|
1170
|
+
max_stored_frame_rate: doc.data?.max_stored_frame_rate
|
|
1180
1171
|
};
|
|
1181
1172
|
}
|
|
1182
1173
|
function useVideoDetails(props) {
|
|
@@ -1415,7 +1406,7 @@ const AssetInput = (props) => /* @__PURE__ */ jsx(FormField$1, { title: props.la
|
|
|
1415
1406
|
}
|
|
1416
1407
|
),
|
|
1417
1408
|
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
1418
|
-
|
|
1409
|
+
displayInfo?.duration && /* @__PURE__ */ jsx(
|
|
1419
1410
|
IconInfo,
|
|
1420
1411
|
{
|
|
1421
1412
|
text: `Duration: ${displayInfo.duration}`,
|
|
@@ -1423,7 +1414,7 @@ const AssetInput = (props) => /* @__PURE__ */ jsx(FormField$1, { title: props.la
|
|
|
1423
1414
|
size: 2
|
|
1424
1415
|
}
|
|
1425
1416
|
),
|
|
1426
|
-
|
|
1417
|
+
displayInfo?.max_stored_resolution && /* @__PURE__ */ jsx(
|
|
1427
1418
|
IconInfo,
|
|
1428
1419
|
{
|
|
1429
1420
|
text: `Max Resolution: ${displayInfo.max_stored_resolution}`,
|
|
@@ -1431,7 +1422,7 @@ const AssetInput = (props) => /* @__PURE__ */ jsx(FormField$1, { title: props.la
|
|
|
1431
1422
|
size: 2
|
|
1432
1423
|
}
|
|
1433
1424
|
),
|
|
1434
|
-
|
|
1425
|
+
displayInfo?.max_stored_frame_rate && /* @__PURE__ */ jsx(
|
|
1435
1426
|
IconInfo,
|
|
1436
1427
|
{
|
|
1437
1428
|
text: `Frame rate: ${displayInfo.max_stored_frame_rate}`,
|
|
@@ -1439,7 +1430,7 @@ const AssetInput = (props) => /* @__PURE__ */ jsx(FormField$1, { title: props.la
|
|
|
1439
1430
|
size: 2
|
|
1440
1431
|
}
|
|
1441
1432
|
),
|
|
1442
|
-
|
|
1433
|
+
displayInfo?.aspect_ratio && /* @__PURE__ */ jsx(
|
|
1443
1434
|
IconInfo,
|
|
1444
1435
|
{
|
|
1445
1436
|
text: `Aspect Ratio: ${displayInfo.aspect_ratio}`,
|
|
@@ -1463,7 +1454,15 @@ const AssetInput = (props) => /* @__PURE__ */ jsx(FormField$1, { title: props.la
|
|
|
1463
1454
|
}
|
|
1464
1455
|
),
|
|
1465
1456
|
/* @__PURE__ */ jsx(IconInfo, { text: `Mux ID:
|
|
1466
|
-
${displayInfo.id}`, icon: TagIcon, size: 2 })
|
|
1457
|
+
${displayInfo.id}`, icon: TagIcon, size: 2 }),
|
|
1458
|
+
displayInfo?.playbackId && /* @__PURE__ */ jsx(
|
|
1459
|
+
IconInfo,
|
|
1460
|
+
{
|
|
1461
|
+
text: `Playback ID: ${displayInfo.playbackId}`,
|
|
1462
|
+
icon: TagIcon,
|
|
1463
|
+
size: 2
|
|
1464
|
+
}
|
|
1465
|
+
)
|
|
1467
1466
|
] })
|
|
1468
1467
|
] })
|
|
1469
1468
|
}
|
|
@@ -1510,7 +1509,7 @@ ${displayInfo.id}`, icon: TagIcon, size: 2 })
|
|
|
1510
1509
|
}
|
|
1511
1510
|
),
|
|
1512
1511
|
/* @__PURE__ */ jsxs(Inline, { space: 3, children: [
|
|
1513
|
-
|
|
1512
|
+
displayInfo?.duration && /* @__PURE__ */ jsx(IconInfo, { text: displayInfo.duration, icon: ClockIcon, size: 1, muted: !0 }),
|
|
1514
1513
|
/* @__PURE__ */ jsx(
|
|
1515
1514
|
IconInfo,
|
|
1516
1515
|
{
|
|
@@ -1586,7 +1585,7 @@ function VideoInBrowser({
|
|
|
1586
1585
|
onEdit,
|
|
1587
1586
|
asset
|
|
1588
1587
|
}) {
|
|
1589
|
-
const [renderVideo, setRenderVideo] = useState(!1), select = React.useCallback(() => onSelect
|
|
1588
|
+
const [renderVideo, setRenderVideo] = useState(!1), select = React.useCallback(() => onSelect?.(asset), [onSelect, asset]), edit = React.useCallback(() => onEdit?.(asset), [onEdit, asset]);
|
|
1590
1589
|
if (!asset)
|
|
1591
1590
|
return null;
|
|
1592
1591
|
const playbackPolicy = getPlaybackPolicy(asset);
|
|
@@ -1707,7 +1706,7 @@ function VideoInBrowser({
|
|
|
1707
1706
|
}
|
|
1708
1707
|
function VideosBrowser({ onSelect }) {
|
|
1709
1708
|
const { assets, isLoading, searchQuery, setSearchQuery, setSort, sort } = useAssets(), [editedAsset, setEditedAsset] = useState(null), freshEditedAsset = useMemo(
|
|
1710
|
-
() => assets.find((a2) => a2._id ===
|
|
1709
|
+
() => assets.find((a2) => a2._id === editedAsset?._id) || editedAsset,
|
|
1711
1710
|
[editedAsset, assets]
|
|
1712
1711
|
), placement = onSelect ? "input" : "tool";
|
|
1713
1712
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1728,7 +1727,7 @@ function VideosBrowser({ onSelect }) {
|
|
|
1728
1727
|
placement === "tool" && /* @__PURE__ */ jsx(ImportVideosFromMux, {})
|
|
1729
1728
|
] }),
|
|
1730
1729
|
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
1731
|
-
|
|
1730
|
+
assets?.length > 0 && /* @__PURE__ */ jsxs(Label$1, { muted: !0, children: [
|
|
1732
1731
|
assets.length,
|
|
1733
1732
|
" video",
|
|
1734
1733
|
assets.length > 1 ? "s" : null,
|
|
@@ -1788,16 +1787,12 @@ function useDialogState() {
|
|
|
1788
1787
|
return useState(!1);
|
|
1789
1788
|
}
|
|
1790
1789
|
const useMuxPolling = (asset) => {
|
|
1791
|
-
var _a, _b;
|
|
1792
1790
|
const client = useClient(), projectId = useProjectId(), dataset = useDataset(), shouldFetch = useMemo(
|
|
1793
|
-
() =>
|
|
1794
|
-
|
|
1795
|
-
return !!(asset != null && asset.assetId) && ((asset == null ? void 0 : asset.status) === "preparing" || ((_b2 = (_a2 = asset == null ? void 0 : asset.data) == null ? void 0 : _a2.static_renditions) == null ? void 0 : _b2.status) === "preparing");
|
|
1796
|
-
},
|
|
1797
|
-
[asset == null ? void 0 : asset.assetId, (_b = (_a = asset == null ? void 0 : asset.data) == null ? void 0 : _a.static_renditions) == null ? void 0 : _b.status, asset == null ? void 0 : asset.status]
|
|
1791
|
+
() => !!asset?.assetId && (asset?.status === "preparing" || asset?.data?.static_renditions?.status === "preparing"),
|
|
1792
|
+
[asset?.assetId, asset?.data?.static_renditions?.status, asset?.status]
|
|
1798
1793
|
);
|
|
1799
1794
|
return useSWR(
|
|
1800
|
-
shouldFetch ? `/${projectId}/addons/mux/assets/${dataset}/data/${asset
|
|
1795
|
+
shouldFetch ? `/${projectId}/addons/mux/assets/${dataset}/data/${asset?.assetId}` : null,
|
|
1801
1796
|
async () => {
|
|
1802
1797
|
const { data } = await client.request({
|
|
1803
1798
|
url: `/addons/mux/assets/${dataset}/data/${asset.assetId}`,
|
|
@@ -1870,16 +1865,14 @@ const useSaveSecrets = (client, secrets) => useCallback(
|
|
|
1870
1865
|
}) => {
|
|
1871
1866
|
let { signingKeyId, signingKeyPrivate } = secrets;
|
|
1872
1867
|
try {
|
|
1873
|
-
await saveSecrets(
|
|
1868
|
+
if (await saveSecrets(
|
|
1874
1869
|
client,
|
|
1875
1870
|
token,
|
|
1876
1871
|
secretKey,
|
|
1877
1872
|
enableSignedUrls,
|
|
1878
1873
|
signingKeyId,
|
|
1879
1874
|
signingKeyPrivate
|
|
1880
|
-
)
|
|
1881
|
-
const valid = await testSecrets(client);
|
|
1882
|
-
if (!(valid != null && valid.status) && token && secretKey)
|
|
1875
|
+
), !(await testSecrets(client))?.status && token && secretKey)
|
|
1883
1876
|
throw new Error("Invalid secrets");
|
|
1884
1877
|
} catch (err) {
|
|
1885
1878
|
throw console.error("Error while trying to save secrets:", err), err;
|
|
@@ -1900,7 +1893,7 @@ const useSaveSecrets = (client, secrets) => useCallback(
|
|
|
1900
1893
|
signingKeyPrivate
|
|
1901
1894
|
);
|
|
1902
1895
|
} catch (err) {
|
|
1903
|
-
throw console.log("Error while creating and saving signing key:", err
|
|
1896
|
+
throw console.log("Error while creating and saving signing key:", err?.message), err;
|
|
1904
1897
|
}
|
|
1905
1898
|
return {
|
|
1906
1899
|
token,
|
|
@@ -1918,13 +1911,13 @@ function init({ token, secretKey, enableSignedUrls }) {
|
|
|
1918
1911
|
error: null,
|
|
1919
1912
|
// Form inputs don't set the state back to null when clearing a field, but uses empty strings
|
|
1920
1913
|
// This ensures the `dirty` check works correctly
|
|
1921
|
-
token: token
|
|
1922
|
-
secretKey: secretKey
|
|
1923
|
-
enableSignedUrls: enableSignedUrls
|
|
1914
|
+
token: token ?? "",
|
|
1915
|
+
secretKey: secretKey ?? "",
|
|
1916
|
+
enableSignedUrls: enableSignedUrls ?? !1
|
|
1924
1917
|
};
|
|
1925
1918
|
}
|
|
1926
1919
|
function reducer(state, action) {
|
|
1927
|
-
switch (action
|
|
1920
|
+
switch (action?.type) {
|
|
1928
1921
|
case "submit":
|
|
1929
1922
|
return { ...state, submitting: !0, error: null };
|
|
1930
1923
|
case "error":
|
|
@@ -1934,7 +1927,7 @@ function reducer(state, action) {
|
|
|
1934
1927
|
case "change":
|
|
1935
1928
|
return { ...state, [action.payload.name]: action.payload.value };
|
|
1936
1929
|
default:
|
|
1937
|
-
throw new Error(`Unknown action type: ${action
|
|
1930
|
+
throw new Error(`Unknown action type: ${action?.type}`);
|
|
1938
1931
|
}
|
|
1939
1932
|
}
|
|
1940
1933
|
const useSecretsFormState = (secrets) => useReducer(reducer, secrets, init), ids = [
|
|
@@ -2537,7 +2530,6 @@ const Logo = styled.span`
|
|
|
2537
2530
|
"API Credentials"
|
|
2538
2531
|
] }), fieldNames = ["token", "secretKey", "enableSignedUrls"];
|
|
2539
2532
|
function ConfigureApi({ secrets, setDialogState }) {
|
|
2540
|
-
var _a, _b;
|
|
2541
2533
|
const client = useClient(), [state, dispatch] = useSecretsFormState(secrets), hasSecretsInitially = useMemo(() => secrets.token && secrets.secretKey, [secrets]), handleClose = useCallback(() => setDialogState(!1), [setDialogState]), dirty = useMemo(
|
|
2542
2534
|
() => secrets.token !== state.token || secrets.secretKey !== state.secretKey || secrets.enableSignedUrls !== state.enableSignedUrls,
|
|
2543
2535
|
[secrets, state]
|
|
@@ -2629,7 +2621,7 @@ function ConfigureApi({ secrets, setDialogState }) {
|
|
|
2629
2621
|
ref: firstField,
|
|
2630
2622
|
onChange: handleChangeToken,
|
|
2631
2623
|
type: "text",
|
|
2632
|
-
value:
|
|
2624
|
+
value: state.token ?? "",
|
|
2633
2625
|
required: !!state.secretKey || state.enableSignedUrls
|
|
2634
2626
|
}
|
|
2635
2627
|
) }),
|
|
@@ -2639,7 +2631,7 @@ function ConfigureApi({ secrets, setDialogState }) {
|
|
|
2639
2631
|
id: secretKeyId,
|
|
2640
2632
|
onChange: handleChangeSecretKey,
|
|
2641
2633
|
type: "text",
|
|
2642
|
-
value:
|
|
2634
|
+
value: state.secretKey ?? "",
|
|
2643
2635
|
required: !!state.token || state.enableSignedUrls
|
|
2644
2636
|
}
|
|
2645
2637
|
) }),
|
|
@@ -2737,7 +2729,7 @@ function a(t) {
|
|
|
2737
2729
|
function ErrorBoundaryCard(props) {
|
|
2738
2730
|
const { children, schemaType } = props, { push: pushToast } = useToast(), errorRef = useRef(null), { ErrorBoundary, didCatch, error, reset } = a({
|
|
2739
2731
|
onDidCatch: (err, errorInfo) => {
|
|
2740
|
-
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
|
|
2732
|
+
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({
|
|
2741
2733
|
status: "error",
|
|
2742
2734
|
title: "Plugin crashed",
|
|
2743
2735
|
description: /* @__PURE__ */ jsx(Flex, { align: "center", children: /* @__PURE__ */ jsxs(Inline, { space: 1, children: [
|
|
@@ -2771,7 +2763,7 @@ function ErrorBoundaryCard(props) {
|
|
|
2771
2763
|
/* @__PURE__ */ jsx("code", { children: name }),
|
|
2772
2764
|
" plugin crashed"
|
|
2773
2765
|
] }),
|
|
2774
|
-
|
|
2766
|
+
error?.message && /* @__PURE__ */ jsx(Card, { padding: 3, tone: "critical", shadow: 1, radius: 2, children: /* @__PURE__ */ jsx(Text, { children: error.message }) }),
|
|
2775
2767
|
/* @__PURE__ */ jsx(Inline, { children: /* @__PURE__ */ jsx(Button, { onClick: handleRetry, text: "Retry" }) })
|
|
2776
2768
|
] }) }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { children });
|
|
2777
2769
|
}
|
|
@@ -3052,7 +3044,7 @@ function walk(entry) {
|
|
|
3052
3044
|
function SelectAssets({ asset: selectedAsset, onChange, setDialogState }) {
|
|
3053
3045
|
const handleSelect = useCallback(
|
|
3054
3046
|
(chosenAsset) => {
|
|
3055
|
-
chosenAsset
|
|
3047
|
+
chosenAsset?._id || onChange(PatchEvent.from([unset(["asset"])])), chosenAsset._id !== selectedAsset?._id && onChange(
|
|
3056
3048
|
PatchEvent.from([
|
|
3057
3049
|
setIfMissing({ asset: {}, _type: "mux.video" }),
|
|
3058
3050
|
set({ _type: "reference", _weak: !0, _ref: chosenAsset._id }, ["asset"])
|
|
@@ -3162,24 +3154,18 @@ const TopControls = styled.div`
|
|
|
3162
3154
|
}
|
|
3163
3155
|
) : null
|
|
3164
3156
|
] }) }), Player = ({ asset, buttons, readOnly, onChange }) => {
|
|
3165
|
-
|
|
3166
|
-
const isLoading = useMemo(() => (asset == null ? void 0 : asset.status) === "preparing" ? "Preparing the video" : (asset == null ? void 0 : asset.status) === "waiting_for_upload" ? "Waiting for upload to start" : (asset == null ? void 0 : asset.status) === "waiting" ? "Processing upload" : !((asset == null ? void 0 : asset.status) === "ready" || typeof (asset == null ? void 0 : asset.status) > "u"), [asset]), isPreparingStaticRenditions = useMemo(() => {
|
|
3167
|
-
var _a2, _b2;
|
|
3168
|
-
return ((_b2 = (_a2 = asset == null ? void 0 : asset.data) == null ? void 0 : _a2.static_renditions) == null ? void 0 : _b2.status) === "preparing";
|
|
3169
|
-
}, [(_b = (_a = asset == null ? void 0 : asset.data) == null ? void 0 : _a.static_renditions) == null ? void 0 : _b.status]), playRef = useRef(null), muteRef = useRef(null), handleCancelUpload = useCancelUpload(asset, onChange);
|
|
3157
|
+
const isLoading = useMemo(() => asset?.status === "preparing" ? "Preparing the video" : asset?.status === "waiting_for_upload" ? "Waiting for upload to start" : asset?.status === "waiting" ? "Processing upload" : !(asset?.status === "ready" || typeof asset?.status > "u"), [asset]), isPreparingStaticRenditions = useMemo(() => asset?.data?.static_renditions?.status === "preparing", [asset?.data?.static_renditions?.status]), playRef = useRef(null), muteRef = useRef(null), handleCancelUpload = useCancelUpload(asset, onChange);
|
|
3170
3158
|
return useEffect(() => {
|
|
3171
|
-
var _a2, _b2;
|
|
3172
3159
|
const style = document.createElement("style");
|
|
3173
|
-
style.innerHTML = "button svg { vertical-align: middle; }",
|
|
3160
|
+
style.innerHTML = "button svg { vertical-align: middle; }", playRef.current?.shadowRoot && playRef.current.shadowRoot.appendChild(style), muteRef?.current?.shadowRoot && muteRef.current.shadowRoot.appendChild(style.cloneNode(!0));
|
|
3174
3161
|
}, []), useEffect(() => {
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
}, [(_d = (_c = asset.data) == null ? void 0 : _c.errors) == null ? void 0 : _d.messages, asset == null ? void 0 : asset.status, handleCancelUpload]), !asset || !asset.status ? null : isLoading ? /* @__PURE__ */ jsx(
|
|
3162
|
+
if (asset?.status === "errored")
|
|
3163
|
+
throw handleCancelUpload(), new Error(asset.data?.errors?.messages?.join(" "));
|
|
3164
|
+
}, [asset.data?.errors?.messages, asset?.status, handleCancelUpload]), !asset || !asset.status ? null : isLoading ? /* @__PURE__ */ jsx(
|
|
3179
3165
|
UploadProgress,
|
|
3180
3166
|
{
|
|
3181
3167
|
progress: 100,
|
|
3182
|
-
filename: asset
|
|
3168
|
+
filename: asset?.filename,
|
|
3183
3169
|
text: isLoading !== !0 && isLoading || "Waiting for Mux to complete the upload",
|
|
3184
3170
|
onCancel: readOnly ? void 0 : () => handleCancelUpload()
|
|
3185
3171
|
}
|
|
@@ -3298,9 +3284,9 @@ function PlayerActionsMenu(props) {
|
|
|
3298
3284
|
const { asset, readOnly, dialogState, setDialogState, onChange, onSelect } = props, [open, setOpen] = useState(!1), [menuElement, setMenuRef] = useState(null), isSigned = useMemo(() => getPlaybackPolicy(asset) === "signed", [asset]), onReset = useCallback(() => onChange(PatchEvent.from(unset([]))), [onChange]);
|
|
3299
3285
|
return useEffect(() => {
|
|
3300
3286
|
open && dialogState && setOpen(!1);
|
|
3301
|
-
}, [dialogState, open]),
|
|
3302
|
-
|
|
3303
|
-
[menuElement]
|
|
3287
|
+
}, [dialogState, open]), useClickOutsideEvent(
|
|
3288
|
+
() => setOpen(!1),
|
|
3289
|
+
() => [menuElement]
|
|
3304
3290
|
), /* @__PURE__ */ jsxs(Inline, { space: 1, padding: 2, children: [
|
|
3305
3291
|
isSigned && /* @__PURE__ */ jsx(
|
|
3306
3292
|
Tooltip,
|
|
@@ -3442,7 +3428,7 @@ function TextTracksEditor({
|
|
|
3442
3428
|
{
|
|
3443
3429
|
id: "include-autogenerated-track",
|
|
3444
3430
|
style: { display: "block" },
|
|
3445
|
-
checked: !!
|
|
3431
|
+
checked: !!track?.language_code,
|
|
3446
3432
|
onChange: () => {
|
|
3447
3433
|
dispatch(track ? { action: "track", id: track._id, subAction: "delete" } : {
|
|
3448
3434
|
action: "track",
|
|
@@ -3478,10 +3464,7 @@ function TextTracksEditor({
|
|
|
3478
3464
|
placeholder: "Select language",
|
|
3479
3465
|
filterOption: (query, option) => option.label.toLowerCase().indexOf(query.toLowerCase()) > -1 || option.value.toLowerCase().indexOf(query.toLowerCase()) > -1,
|
|
3480
3466
|
openButton: !0,
|
|
3481
|
-
renderValue: (value) =>
|
|
3482
|
-
var _a;
|
|
3483
|
-
return ((_a = SUBTITLE_LANGUAGES[track.type].find((l) => l.value === value)) == null ? void 0 : _a.label) || value;
|
|
3484
|
-
},
|
|
3467
|
+
renderValue: (value) => SUBTITLE_LANGUAGES[track.type].find((l) => l.value === value)?.label || value,
|
|
3485
3468
|
renderOption: (option) => /* @__PURE__ */ jsx(Card, { "data-as": "button", padding: 3, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxs(Text, { size: 2, textOverflow: "ellipsis", children: [
|
|
3486
3469
|
option.label,
|
|
3487
3470
|
" (",
|
|
@@ -3518,14 +3501,13 @@ function UploadConfiguration({
|
|
|
3518
3501
|
] : []
|
|
3519
3502
|
).current, [config, dispatch] = useReducer(
|
|
3520
3503
|
(prev, action) => {
|
|
3521
|
-
var _a;
|
|
3522
3504
|
switch (action.action) {
|
|
3523
3505
|
case "encoding_tier":
|
|
3524
3506
|
return action.value === "baseline" ? Object.assign({}, prev, {
|
|
3525
3507
|
encoding_tier: action.value,
|
|
3526
3508
|
mp4_support: "none",
|
|
3527
3509
|
max_resolution_tier: "1080p",
|
|
3528
|
-
text_tracks:
|
|
3510
|
+
text_tracks: prev.text_tracks?.filter(({ type }) => type !== "autogenerated")
|
|
3529
3511
|
}) : Object.assign({}, prev, {
|
|
3530
3512
|
encoding_tier: action.value,
|
|
3531
3513
|
mp4_support: pluginConfig.mp4_support,
|
|
@@ -3537,6 +3519,7 @@ function UploadConfiguration({
|
|
|
3537
3519
|
case "normalize_audio":
|
|
3538
3520
|
case "signed":
|
|
3539
3521
|
return Object.assign({}, prev, { [action.action]: action.value });
|
|
3522
|
+
// Updating individual tracks
|
|
3540
3523
|
case "track": {
|
|
3541
3524
|
const text_tracks = [...prev.text_tracks], target_track_i = text_tracks.findIndex(({ _id: _id2 }) => _id2 === action.id);
|
|
3542
3525
|
switch (action.subAction) {
|
|
@@ -3853,10 +3836,7 @@ const ctrlKey = 17, cmdKey = 91, UploadCardWithFocusRing = withFocusRing(Card),
|
|
|
3853
3836
|
onSelect && onSelect(event.target.files);
|
|
3854
3837
|
},
|
|
3855
3838
|
[onSelect]
|
|
3856
|
-
), handleButtonClick = useCallback(() =>
|
|
3857
|
-
var _a;
|
|
3858
|
-
return (_a = inputRef.current) == null ? void 0 : _a.click();
|
|
3859
|
-
}, []);
|
|
3839
|
+
), handleButtonClick = useCallback(() => inputRef.current?.click(), []);
|
|
3860
3840
|
return /* @__PURE__ */ jsxs(Label, { htmlFor: inputId, children: [
|
|
3861
3841
|
/* @__PURE__ */ jsx(
|
|
3862
3842
|
HiddenInput,
|
|
@@ -3945,7 +3925,6 @@ const INITIAL_STATE = {
|
|
|
3945
3925
|
error: null
|
|
3946
3926
|
};
|
|
3947
3927
|
function Uploader(props) {
|
|
3948
|
-
var _a;
|
|
3949
3928
|
const toast = useToast(), containerRef = useRef(null), dragEnteredEls = useRef([]), [dragState, setDragState] = useState(null), cancelUploadButton = useRef(
|
|
3950
3929
|
(() => {
|
|
3951
3930
|
const events$ = new Subject();
|
|
@@ -3956,7 +3935,6 @@ function Uploader(props) {
|
|
|
3956
3935
|
})()
|
|
3957
3936
|
).current, uploadRef = useRef(null), [state, dispatch] = useReducer(
|
|
3958
3937
|
(prev, action) => {
|
|
3959
|
-
var _a2, _b;
|
|
3960
3938
|
switch (action.action) {
|
|
3961
3939
|
case "stageUpload":
|
|
3962
3940
|
return Object.assign({}, INITIAL_STATE, { stagedUpload: action.input });
|
|
@@ -3981,9 +3959,9 @@ function Uploader(props) {
|
|
|
3981
3959
|
});
|
|
3982
3960
|
case "reset":
|
|
3983
3961
|
case "complete":
|
|
3984
|
-
return
|
|
3962
|
+
return uploadRef.current?.unsubscribe(), uploadRef.current = null, INITIAL_STATE;
|
|
3985
3963
|
case "error":
|
|
3986
|
-
return
|
|
3964
|
+
return uploadRef.current?.unsubscribe(), uploadRef.current = null, Object.assign({}, INITIAL_STATE, { error: action.error });
|
|
3987
3965
|
default:
|
|
3988
3966
|
return prev;
|
|
3989
3967
|
}
|
|
@@ -4019,8 +3997,7 @@ function Uploader(props) {
|
|
|
4019
3997
|
takeUntil(
|
|
4020
3998
|
cancelUploadButton.observable.pipe(
|
|
4021
3999
|
tap(() => {
|
|
4022
|
-
|
|
4023
|
-
(_a2 = state.uploadStatus) != null && _a2.uuid && props.client.delete(state.uploadStatus.uuid);
|
|
4000
|
+
state.uploadStatus?.uuid && props.client.delete(state.uploadStatus.uuid);
|
|
4024
4001
|
})
|
|
4025
4002
|
)
|
|
4026
4003
|
)
|
|
@@ -4074,10 +4051,9 @@ function Uploader(props) {
|
|
|
4074
4051
|
}, handleDragOver = (event) => {
|
|
4075
4052
|
event.preventDefault(), event.stopPropagation();
|
|
4076
4053
|
}, handleDragEnter = (event) => {
|
|
4077
|
-
var _a2, _b;
|
|
4078
4054
|
event.stopPropagation(), dragEnteredEls.current.push(event.target);
|
|
4079
|
-
const type =
|
|
4080
|
-
setDragState(type
|
|
4055
|
+
const type = event.dataTransfer.items?.[0]?.type;
|
|
4056
|
+
setDragState(type?.startsWith("video/") ? "valid" : "invalid");
|
|
4081
4057
|
}, handleDragLeave = (event) => {
|
|
4082
4058
|
event.stopPropagation();
|
|
4083
4059
|
const idx = dragEnteredEls.current.indexOf(event.target);
|
|
@@ -4099,7 +4075,7 @@ function Uploader(props) {
|
|
|
4099
4075
|
{
|
|
4100
4076
|
onCancel: cancelUploadButton.handleClick,
|
|
4101
4077
|
progress: uploadStatus.progress,
|
|
4102
|
-
filename:
|
|
4078
|
+
filename: uploadStatus.file?.name || uploadStatus.url
|
|
4103
4079
|
}
|
|
4104
4080
|
);
|
|
4105
4081
|
}
|
|
@@ -4167,8 +4143,7 @@ function Uploader(props) {
|
|
|
4167
4143
|
] });
|
|
4168
4144
|
}
|
|
4169
4145
|
const Input = (props) => {
|
|
4170
|
-
|
|
4171
|
-
const client = useClient(), secretDocumentValues = useSecretsDocumentValues(), assetDocumentValues = useAssetDocumentValues((_a = props.value) == null ? void 0 : _a.asset), poll = useMuxPolling(props.readOnly ? void 0 : (assetDocumentValues == null ? void 0 : assetDocumentValues.value) || void 0), [dialogState, setDialogState] = useDialogState(), error = secretDocumentValues.error || assetDocumentValues.error || poll.error;
|
|
4146
|
+
const client = useClient(), secretDocumentValues = useSecretsDocumentValues(), assetDocumentValues = useAssetDocumentValues(props.value?.asset), poll = useMuxPolling(props.readOnly ? void 0 : assetDocumentValues?.value || void 0), [dialogState, setDialogState] = useDialogState(), error = secretDocumentValues.error || assetDocumentValues.error || poll.error;
|
|
4172
4147
|
if (error)
|
|
4173
4148
|
throw error;
|
|
4174
4149
|
const isLoading = secretDocumentValues.isLoading || assetDocumentValues.isLoading;
|