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.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"), styledComponents = require("styled-components"), uuid = require("@sanity/uuid"), rxjs = require("rxjs"), operators = require("rxjs/operators"), suspendReact = require("suspend-react"), MuxPlayer = require("@mux/mux-player-react"), desk = require("sanity/desk"), 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"),
|
|
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"), styledComponents = require("styled-components"), uuid = require("@sanity/uuid"), rxjs = require("rxjs"), operators = require("rxjs/operators"), suspendReact = require("suspend-react"), MuxPlayer = require("@mux/mux-player-react"), desk = require("sanity/desk"), 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"), LanguagesList = require("iso-639-1");
|
|
23
23
|
function _interopDefaultCompat(e) {
|
|
24
24
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
25
25
|
}
|
|
@@ -143,7 +143,7 @@ function accumulateIntermediateState(currentState, pageResult) {
|
|
|
143
143
|
...currentData,
|
|
144
144
|
...("data" in pageResult && pageResult.data || []).filter(
|
|
145
145
|
// De-duplicate assets for safety
|
|
146
|
-
(asset) => !currentData.some((
|
|
146
|
+
(asset) => !currentData.some((a2) => a2.id === asset.id)
|
|
147
147
|
)
|
|
148
148
|
],
|
|
149
149
|
error: "error" in pageResult ? pageResult.error : (
|
|
@@ -216,7 +216,7 @@ function useImportMuxAssets() {
|
|
|
216
216
|
}), [assetsInSanity, assetsInSanityLoading] = useAssetsInSanity(documentStore), secretDocumentValues = useSecretsDocumentValues(), hasSecrets = !!((_a = secretDocumentValues.value.secrets) != null && _a.secretKey), [importError, setImportError] = React.useState(), [importState, setImportState] = React.useState("closed"), dialogOpen = importState !== "closed", muxAssets = useMuxAssets({
|
|
217
217
|
secrets: secretDocumentValues.value.secrets,
|
|
218
218
|
enabled: hasSecrets && dialogOpen
|
|
219
|
-
}), missingAssets = React.useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((
|
|
219
|
+
}), missingAssets = React.useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((a2) => !assetExistsInSanity(a2, assetsInSanity)) : void 0, [assetsInSanity, muxAssets.data]), [selectedAssets, setSelectedAssets] = React.useState([]), closeDialog = () => {
|
|
220
220
|
importState !== "importing" && setImportState("closed");
|
|
221
221
|
}, openDialog = () => {
|
|
222
222
|
importState === "closed" && setImportState("idle");
|
|
@@ -653,9 +653,9 @@ function ImportVideosDialog(props) {
|
|
|
653
653
|
{
|
|
654
654
|
asset,
|
|
655
655
|
selectAsset: (selected) => {
|
|
656
|
-
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));
|
|
657
657
|
},
|
|
658
|
-
selected: props.selectedAssets.some((
|
|
658
|
+
selected: props.selectedAssets.some((a2) => a2.id === asset.id)
|
|
659
659
|
},
|
|
660
660
|
asset.id
|
|
661
661
|
))
|
|
@@ -805,7 +805,7 @@ function VideoPlayer({
|
|
|
805
805
|
crossOrigin: "anonymous",
|
|
806
806
|
metadata: {
|
|
807
807
|
player_name: "Sanity Admin Dashboard",
|
|
808
|
-
player_version: "2.3.
|
|
808
|
+
player_version: "2.3.6",
|
|
809
809
|
page_type: "Preview Player"
|
|
810
810
|
},
|
|
811
811
|
audio: isAudio,
|
|
@@ -929,10 +929,14 @@ function PublishedStatus(props) {
|
|
|
929
929
|
);
|
|
930
930
|
}
|
|
931
931
|
function PaneItemPreview(props) {
|
|
932
|
-
const { icon, layout, presence, schemaType, value } = props, title = sanity.isRecord(value.title) && React.isValidElement(value.title) || isString__default.default(value.title) || isNumber__default.default(value.title) ? value.title : null,
|
|
932
|
+
const { icon, layout, presence, schemaType, value } = props, title = sanity.isRecord(value.title) && React.isValidElement(value.title) || isString__default.default(value.title) || isNumber__default.default(value.title) ? value.title : null, observable = React.useMemo(
|
|
933
933
|
() => sanity.getPreviewStateObservable(props.documentPreviewStore, schemaType, value._id, title),
|
|
934
|
-
[props.documentPreviewStore, schemaType, value._id
|
|
935
|
-
),
|
|
934
|
+
[props.documentPreviewStore, schemaType, title, value._id]
|
|
935
|
+
), { draft, published, isLoading } = reactRx.useObservable(observable, {
|
|
936
|
+
draft: null,
|
|
937
|
+
published: null,
|
|
938
|
+
isLoading: !0
|
|
939
|
+
}), status = isLoading ? null : /* @__PURE__ */ jsxRuntime.jsxs(ui.Inline, { space: 4, children: [
|
|
936
940
|
presence && presence.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(sanity.DocumentPreviewPresence, { presence }),
|
|
937
941
|
/* @__PURE__ */ jsxRuntime.jsx(PublishedStatus, { document: published }),
|
|
938
942
|
/* @__PURE__ */ jsxRuntime.jsx(DraftStatus, { document: draft })
|
|
@@ -1703,7 +1707,7 @@ function VideoInBrowser({
|
|
|
1703
1707
|
}
|
|
1704
1708
|
function VideosBrowser({ onSelect }) {
|
|
1705
1709
|
const { assets, isLoading, searchQuery, setSearchQuery, setSort, sort } = useAssets(), [editedAsset, setEditedAsset] = React.useState(null), freshEditedAsset = React.useMemo(
|
|
1706
|
-
() => assets.find((
|
|
1710
|
+
() => assets.find((a2) => a2._id === (editedAsset == null ? void 0 : editedAsset._id)) || editedAsset,
|
|
1707
1711
|
[editedAsset, assets]
|
|
1708
1712
|
), placement = onSelect ? "input" : "tool";
|
|
1709
1713
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -1955,7 +1959,7 @@ const useSecretsFormState = (secrets) => React.useReducer(reducer, secrets, init
|
|
|
1955
1959
|
"r"
|
|
1956
1960
|
];
|
|
1957
1961
|
function MuxLogo({ height = 26 }) {
|
|
1958
|
-
const id = React.useId(), [titleId,
|
|
1962
|
+
const id = React.useId(), [titleId, a2, b, c2, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = React.useMemo(
|
|
1959
1963
|
() => ids.map((field) => `${id}-${field}`),
|
|
1960
1964
|
[id]
|
|
1961
1965
|
);
|
|
@@ -1974,7 +1978,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
1974
1978
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1975
1979
|
"linearGradient",
|
|
1976
1980
|
{
|
|
1977
|
-
id:
|
|
1981
|
+
id: c2,
|
|
1978
1982
|
spreadMethod: "pad",
|
|
1979
1983
|
gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
|
|
1980
1984
|
gradientUnits: "userSpaceOnUse",
|
|
@@ -2356,7 +2360,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2356
2360
|
]
|
|
2357
2361
|
}
|
|
2358
2362
|
),
|
|
2359
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id:
|
|
2363
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: a2, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2360
2364
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: b, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M423.64 242h164.999V77H423.64Z" }) }),
|
|
2361
2365
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: e, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2362
2366
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: f, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M311.3 242h93.031V77H311.3Z" }) }),
|
|
@@ -2364,7 +2368,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2364
2368
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: n, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2365
2369
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: o, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M69.067 242H169.12V141.947H69.067Z" }) })
|
|
2366
2370
|
] }),
|
|
2367
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: `url(#${
|
|
2371
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: `url(#${a2})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2368
2372
|
"g",
|
|
2369
2373
|
{
|
|
2370
2374
|
style: {
|
|
@@ -2375,7 +2379,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2375
2379
|
"path",
|
|
2376
2380
|
{
|
|
2377
2381
|
style: {
|
|
2378
|
-
fill: `url(#${
|
|
2382
|
+
fill: `url(#${c2})`,
|
|
2379
2383
|
stroke: "none"
|
|
2380
2384
|
},
|
|
2381
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"
|
|
@@ -2689,9 +2693,49 @@ function ConfigureApi({ secrets, setDialogState }) {
|
|
|
2689
2693
|
}
|
|
2690
2694
|
);
|
|
2691
2695
|
}
|
|
2692
|
-
var ConfigureApi$1 = React.memo(ConfigureApi)
|
|
2696
|
+
var ConfigureApi$1 = React.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
|
+
}(React.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 = React.useReducer(u, { didCatch: !1, error: null }), i = a2[0], d = a2[1], h = React.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__default.default.createElement(c, { onDidCatch: e, children: t2.children, render: t2.render, renderError: t2.renderError });
|
|
2729
|
+
};
|
|
2730
|
+
var e;
|
|
2731
|
+
}
|
|
2732
|
+
var p, s = React.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
|
+
}
|
|
2693
2737
|
function ErrorBoundaryCard(props) {
|
|
2694
|
-
const { children, schemaType } = props, { push: pushToast } = ui.useToast(), errorRef = React.useRef(null), { ErrorBoundary, didCatch, error, reset } =
|
|
2738
|
+
const { children, schemaType } = props, { push: pushToast } = ui.useToast(), errorRef = React.useRef(null), { ErrorBoundary, didCatch, error, reset } = a({
|
|
2695
2739
|
onDidCatch: (err, errorInfo) => {
|
|
2696
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({
|
|
2697
2741
|
status: "error",
|
|
@@ -3337,12 +3381,12 @@ function formatBytes(bytes, si = !1, dp = 1) {
|
|
|
3337
3381
|
if (Math.abs(bytes) < thresh)
|
|
3338
3382
|
return bytes + " B";
|
|
3339
3383
|
const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
3340
|
-
let
|
|
3384
|
+
let u2 = -1;
|
|
3341
3385
|
const r = 10 ** dp;
|
|
3342
3386
|
do
|
|
3343
|
-
bytes /= thresh, ++
|
|
3344
|
-
while (Math.round(Math.abs(bytes) * r) / r >= thresh &&
|
|
3345
|
-
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];
|
|
3346
3390
|
}
|
|
3347
3391
|
const SUPPORTED_MUX_LANGUAGES = [
|
|
3348
3392
|
{ label: "English", code: "en", state: "Stable" },
|