sanity-plugin-mux-input 2.3.5 → 2.3.6
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 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -7
- package/src/actions/upload.ts +1 -1
- package/src/components/FileInputArea.tsx +4 -3
- package/src/components/Uploader.tsx +1 -1
- package/src/components/VideoDetails/VideoDetails.tsx +1 -1
- package/src/components/VideoThumbnail.tsx +1 -1
- package/src/components/documentPreview/PaneItemPreview.tsx +10 -7
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { useClient as useClient$1, createHookFromObservableFactory, useDocumentS
|
|
|
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
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, useClickOutside, Popover, MenuDivider, Autocomplete, Radio, rem } from "@sanity/ui";
|
|
5
|
-
import React, { useState, useMemo, useEffect, useRef, useId, memo, isValidElement, useCallback, useReducer, createElement, forwardRef, Suspense } from "react";
|
|
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";
|
|
8
8
|
import trim from "lodash/trim.js";
|
|
@@ -18,10 +18,9 @@ import { usePaneRouter } from "sanity/desk";
|
|
|
18
18
|
import { IntentLink } from "sanity/router";
|
|
19
19
|
import isNumber from "lodash/isNumber.js";
|
|
20
20
|
import isString from "lodash/isString.js";
|
|
21
|
-
import {
|
|
21
|
+
import { useObservable } from "react-rx";
|
|
22
22
|
import useSWR from "swr";
|
|
23
23
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
24
|
-
import { useErrorBoundary } from "use-error-boundary";
|
|
25
24
|
import { UpChunk } from "@mux/upchunk";
|
|
26
25
|
import { isValidElementType } from "react-is";
|
|
27
26
|
import LanguagesList from "iso-639-1";
|
|
@@ -144,7 +143,7 @@ function accumulateIntermediateState(currentState, pageResult) {
|
|
|
144
143
|
...currentData,
|
|
145
144
|
...("data" in pageResult && pageResult.data || []).filter(
|
|
146
145
|
// De-duplicate assets for safety
|
|
147
|
-
(asset) => !currentData.some((
|
|
146
|
+
(asset) => !currentData.some((a2) => a2.id === asset.id)
|
|
148
147
|
)
|
|
149
148
|
],
|
|
150
149
|
error: "error" in pageResult ? pageResult.error : (
|
|
@@ -217,7 +216,7 @@ function useImportMuxAssets() {
|
|
|
217
216
|
}), [assetsInSanity, assetsInSanityLoading] = useAssetsInSanity(documentStore), secretDocumentValues = useSecretsDocumentValues(), hasSecrets = !!((_a = secretDocumentValues.value.secrets) != null && _a.secretKey), [importError, setImportError] = useState(), [importState, setImportState] = useState("closed"), dialogOpen = importState !== "closed", muxAssets = useMuxAssets({
|
|
218
217
|
secrets: secretDocumentValues.value.secrets,
|
|
219
218
|
enabled: hasSecrets && dialogOpen
|
|
220
|
-
}), missingAssets = useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((
|
|
219
|
+
}), missingAssets = useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((a2) => !assetExistsInSanity(a2, assetsInSanity)) : void 0, [assetsInSanity, muxAssets.data]), [selectedAssets, setSelectedAssets] = useState([]), closeDialog = () => {
|
|
221
220
|
importState !== "importing" && setImportState("closed");
|
|
222
221
|
}, openDialog = () => {
|
|
223
222
|
importState === "closed" && setImportState("idle");
|
|
@@ -654,9 +653,9 @@ function ImportVideosDialog(props) {
|
|
|
654
653
|
{
|
|
655
654
|
asset,
|
|
656
655
|
selectAsset: (selected) => {
|
|
657
|
-
selected ? props.setSelectedAssets([...props.selectedAssets, asset]) : props.setSelectedAssets(props.selectedAssets.filter((
|
|
656
|
+
selected ? props.setSelectedAssets([...props.selectedAssets, asset]) : props.setSelectedAssets(props.selectedAssets.filter((a2) => a2.id !== asset.id));
|
|
658
657
|
},
|
|
659
|
-
selected: props.selectedAssets.some((
|
|
658
|
+
selected: props.selectedAssets.some((a2) => a2.id === asset.id)
|
|
660
659
|
},
|
|
661
660
|
asset.id
|
|
662
661
|
))
|
|
@@ -806,7 +805,7 @@ function VideoPlayer({
|
|
|
806
805
|
crossOrigin: "anonymous",
|
|
807
806
|
metadata: {
|
|
808
807
|
player_name: "Sanity Admin Dashboard",
|
|
809
|
-
player_version: "2.3.
|
|
808
|
+
player_version: "2.3.6",
|
|
810
809
|
page_type: "Preview Player"
|
|
811
810
|
},
|
|
812
811
|
audio: isAudio,
|
|
@@ -930,10 +929,14 @@ function PublishedStatus(props) {
|
|
|
930
929
|
);
|
|
931
930
|
}
|
|
932
931
|
function PaneItemPreview(props) {
|
|
933
|
-
const { icon, layout, presence, schemaType, value } = props, title = isRecord(value.title) && isValidElement(value.title) || isString(value.title) || isNumber(value.title) ? value.title : null,
|
|
932
|
+
const { icon, layout, presence, schemaType, value } = props, title = isRecord(value.title) && isValidElement(value.title) || isString(value.title) || isNumber(value.title) ? value.title : null, observable = useMemo(
|
|
934
933
|
() => getPreviewStateObservable(props.documentPreviewStore, schemaType, value._id, title),
|
|
935
|
-
[props.documentPreviewStore, schemaType, value._id
|
|
936
|
-
),
|
|
934
|
+
[props.documentPreviewStore, schemaType, title, value._id]
|
|
935
|
+
), { draft, published, isLoading } = useObservable(observable, {
|
|
936
|
+
draft: null,
|
|
937
|
+
published: null,
|
|
938
|
+
isLoading: !0
|
|
939
|
+
}), status = isLoading ? null : /* @__PURE__ */ jsxs(Inline, { space: 4, children: [
|
|
937
940
|
presence && presence.length > 0 && /* @__PURE__ */ jsx(DocumentPreviewPresence, { presence }),
|
|
938
941
|
/* @__PURE__ */ jsx(PublishedStatus, { document: published }),
|
|
939
942
|
/* @__PURE__ */ jsx(DraftStatus, { document: draft })
|
|
@@ -1704,7 +1707,7 @@ function VideoInBrowser({
|
|
|
1704
1707
|
}
|
|
1705
1708
|
function VideosBrowser({ onSelect }) {
|
|
1706
1709
|
const { assets, isLoading, searchQuery, setSearchQuery, setSort, sort } = useAssets(), [editedAsset, setEditedAsset] = useState(null), freshEditedAsset = useMemo(
|
|
1707
|
-
() => assets.find((
|
|
1710
|
+
() => assets.find((a2) => a2._id === (editedAsset == null ? void 0 : editedAsset._id)) || editedAsset,
|
|
1708
1711
|
[editedAsset, assets]
|
|
1709
1712
|
), placement = onSelect ? "input" : "tool";
|
|
1710
1713
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1956,7 +1959,7 @@ const useSecretsFormState = (secrets) => useReducer(reducer, secrets, init), ids
|
|
|
1956
1959
|
"r"
|
|
1957
1960
|
];
|
|
1958
1961
|
function MuxLogo({ height = 26 }) {
|
|
1959
|
-
const id = useId(), [titleId,
|
|
1962
|
+
const id = useId(), [titleId, a2, b, c2, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = useMemo(
|
|
1960
1963
|
() => ids.map((field) => `${id}-${field}`),
|
|
1961
1964
|
[id]
|
|
1962
1965
|
);
|
|
@@ -1975,7 +1978,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
1975
1978
|
/* @__PURE__ */ jsxs(
|
|
1976
1979
|
"linearGradient",
|
|
1977
1980
|
{
|
|
1978
|
-
id:
|
|
1981
|
+
id: c2,
|
|
1979
1982
|
spreadMethod: "pad",
|
|
1980
1983
|
gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
|
|
1981
1984
|
gradientUnits: "userSpaceOnUse",
|
|
@@ -2357,7 +2360,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2357
2360
|
]
|
|
2358
2361
|
}
|
|
2359
2362
|
),
|
|
2360
|
-
/* @__PURE__ */ jsx("clipPath", { id:
|
|
2363
|
+
/* @__PURE__ */ jsx("clipPath", { id: a2, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2361
2364
|
/* @__PURE__ */ jsx("clipPath", { id: b, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M423.64 242h164.999V77H423.64Z" }) }),
|
|
2362
2365
|
/* @__PURE__ */ jsx("clipPath", { id: e, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2363
2366
|
/* @__PURE__ */ jsx("clipPath", { id: f, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M311.3 242h93.031V77H311.3Z" }) }),
|
|
@@ -2365,7 +2368,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2365
2368
|
/* @__PURE__ */ jsx("clipPath", { id: n, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2366
2369
|
/* @__PURE__ */ jsx("clipPath", { id: o, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M69.067 242H169.12V141.947H69.067Z" }) })
|
|
2367
2370
|
] }),
|
|
2368
|
-
/* @__PURE__ */ jsx("g", { clipPath: `url(#${
|
|
2371
|
+
/* @__PURE__ */ jsx("g", { clipPath: `url(#${a2})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsx(
|
|
2369
2372
|
"g",
|
|
2370
2373
|
{
|
|
2371
2374
|
style: {
|
|
@@ -2376,7 +2379,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2376
2379
|
"path",
|
|
2377
2380
|
{
|
|
2378
2381
|
style: {
|
|
2379
|
-
fill: `url(#${
|
|
2382
|
+
fill: `url(#${c2})`,
|
|
2380
2383
|
stroke: "none"
|
|
2381
2384
|
},
|
|
2382
2385
|
d: "M558.674 82.142c6.855-6.855 17.969-6.855 24.824 0 6.854 6.855 6.854 17.969 0 24.823L453.605 236.858c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
|
|
@@ -2690,9 +2693,49 @@ function ConfigureApi({ secrets, setDialogState }) {
|
|
|
2690
2693
|
}
|
|
2691
2694
|
);
|
|
2692
2695
|
}
|
|
2693
|
-
var ConfigureApi$1 = memo(ConfigureApi)
|
|
2696
|
+
var ConfigureApi$1 = memo(ConfigureApi), c = function(r) {
|
|
2697
|
+
var t, e;
|
|
2698
|
+
function n(t2) {
|
|
2699
|
+
var e2;
|
|
2700
|
+
return (e2 = r.call(this, t2) || this).state = { hasError: !1, error: null }, e2;
|
|
2701
|
+
}
|
|
2702
|
+
e = r, (t = n).prototype = Object.create(e.prototype), t.prototype.constructor = t, t.__proto__ = e, n.getDerivedStateFromError = function(r2) {
|
|
2703
|
+
return { hasError: !0, error: r2 };
|
|
2704
|
+
};
|
|
2705
|
+
var o = n.prototype;
|
|
2706
|
+
return o.componentDidCatch = function(r2, t2) {
|
|
2707
|
+
return this.props.onDidCatch(r2, t2);
|
|
2708
|
+
}, o.render = function() {
|
|
2709
|
+
var r2 = this.state, t2 = this.props, e2 = t2.render, n2 = t2.children, o2 = t2.renderError;
|
|
2710
|
+
return r2.hasError ? o2 ? o2({ error: r2.error }) : null : e2 ? e2() : n2 || null;
|
|
2711
|
+
}, n;
|
|
2712
|
+
}(PureComponent), u = function(r, t) {
|
|
2713
|
+
switch (t.type) {
|
|
2714
|
+
case "catch":
|
|
2715
|
+
return { didCatch: !0, error: t.error };
|
|
2716
|
+
case "reset":
|
|
2717
|
+
return { didCatch: !1, error: null };
|
|
2718
|
+
default:
|
|
2719
|
+
return r;
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
function a(t) {
|
|
2723
|
+
var a2 = useReducer(u, { didCatch: !1, error: null }), i = a2[0], d = a2[1], h = useRef(null);
|
|
2724
|
+
function l() {
|
|
2725
|
+
return e = function(r, e2) {
|
|
2726
|
+
d({ type: "catch", error: r }), t && t.onDidCatch && t.onDidCatch(r, e2);
|
|
2727
|
+
}, function(t2) {
|
|
2728
|
+
return React.createElement(c, { onDidCatch: e, children: t2.children, render: t2.render, renderError: t2.renderError });
|
|
2729
|
+
};
|
|
2730
|
+
var e;
|
|
2731
|
+
}
|
|
2732
|
+
var p, s = useCallback(function() {
|
|
2733
|
+
h.current = l(), d({ type: "reset" });
|
|
2734
|
+
}, []);
|
|
2735
|
+
return { ErrorBoundary: (p = h.current, p !== null ? p : (h.current = l(), h.current)), didCatch: i.didCatch, error: i.error, reset: s };
|
|
2736
|
+
}
|
|
2694
2737
|
function ErrorBoundaryCard(props) {
|
|
2695
|
-
const { children, schemaType } = props, { push: pushToast } = useToast(), errorRef = useRef(null), { ErrorBoundary, didCatch, error, reset } =
|
|
2738
|
+
const { children, schemaType } = props, { push: pushToast } = useToast(), errorRef = useRef(null), { ErrorBoundary, didCatch, error, reset } = a({
|
|
2696
2739
|
onDidCatch: (err, errorInfo) => {
|
|
2697
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 != null && errorInfo.componentStack && (console.groupCollapsed("errorInfo.componentStack"), console.log(errorInfo.componentStack), console.groupEnd()), console.groupEnd(), pushToast({
|
|
2698
2741
|
status: "error",
|
|
@@ -3338,12 +3381,12 @@ function formatBytes(bytes, si = !1, dp = 1) {
|
|
|
3338
3381
|
if (Math.abs(bytes) < thresh)
|
|
3339
3382
|
return bytes + " B";
|
|
3340
3383
|
const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
3341
|
-
let
|
|
3384
|
+
let u2 = -1;
|
|
3342
3385
|
const r = 10 ** dp;
|
|
3343
3386
|
do
|
|
3344
|
-
bytes /= thresh, ++
|
|
3345
|
-
while (Math.round(Math.abs(bytes) * r) / r >= thresh &&
|
|
3346
|
-
return bytes.toFixed(dp) + " " + units[
|
|
3387
|
+
bytes /= thresh, ++u2;
|
|
3388
|
+
while (Math.round(Math.abs(bytes) * r) / r >= thresh && u2 < units.length - 1);
|
|
3389
|
+
return bytes.toFixed(dp) + " " + units[u2];
|
|
3347
3390
|
}
|
|
3348
3391
|
const SUPPORTED_MUX_LANGUAGES = [
|
|
3349
3392
|
{ label: "English", code: "en", state: "Stable" },
|