sanity-plugin-mux-input 2.3.3 → 2.3.4
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/lib/index.cjs +58 -18
- package/lib/index.cjs.map +1 -1
- package/lib/index.esm.js +58 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +58 -19
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/lib/index.cjs
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 : (
|
|
@@ -217,7 +217,7 @@ function useImportMuxAssets() {
|
|
|
217
217
|
}), [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({
|
|
218
218
|
secrets: secretDocumentValues.value.secrets,
|
|
219
219
|
enabled: hasSecrets && dialogOpen
|
|
220
|
-
}), missingAssets = React.useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((
|
|
220
|
+
}), missingAssets = React.useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((a2) => !assetExistsInSanity(a2, assetsInSanity)) : void 0, [assetsInSanity, muxAssets.data]), [selectedAssets, setSelectedAssets] = React.useState([]), closeDialog = () => {
|
|
221
221
|
importState !== "importing" && setImportState("closed");
|
|
222
222
|
}, openDialog = () => {
|
|
223
223
|
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
|
))
|
|
@@ -801,7 +801,7 @@ function VideoPlayer({
|
|
|
801
801
|
crossOrigin: "anonymous",
|
|
802
802
|
metadata: {
|
|
803
803
|
player_name: "Sanity Admin Dashboard",
|
|
804
|
-
player_version: "2.3.
|
|
804
|
+
player_version: "2.3.4",
|
|
805
805
|
page_type: "Preview Player"
|
|
806
806
|
},
|
|
807
807
|
style: {
|
|
@@ -1678,7 +1678,7 @@ function VideoInBrowser({
|
|
|
1678
1678
|
}
|
|
1679
1679
|
function VideosBrowser({ onSelect }) {
|
|
1680
1680
|
const { assets, isLoading, searchQuery, setSearchQuery, setSort, sort } = useAssets(), [editedAsset, setEditedAsset] = React.useState(null), freshEditedAsset = React.useMemo(
|
|
1681
|
-
() => assets.find((
|
|
1681
|
+
() => assets.find((a2) => a2._id === (editedAsset == null ? void 0 : editedAsset._id)) || editedAsset,
|
|
1682
1682
|
[editedAsset, assets]
|
|
1683
1683
|
), placement = onSelect ? "input" : "tool";
|
|
1684
1684
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -1930,7 +1930,7 @@ const useSecretsFormState = (secrets) => React.useReducer(reducer, secrets, init
|
|
|
1930
1930
|
"r"
|
|
1931
1931
|
];
|
|
1932
1932
|
function MuxLogo({ height = 26 }) {
|
|
1933
|
-
const id = React.useId(), [titleId,
|
|
1933
|
+
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(
|
|
1934
1934
|
() => ids.map((field) => `${id}-${field}`),
|
|
1935
1935
|
[id]
|
|
1936
1936
|
);
|
|
@@ -1949,7 +1949,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
1949
1949
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1950
1950
|
"linearGradient",
|
|
1951
1951
|
{
|
|
1952
|
-
id:
|
|
1952
|
+
id: c2,
|
|
1953
1953
|
spreadMethod: "pad",
|
|
1954
1954
|
gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
|
|
1955
1955
|
gradientUnits: "userSpaceOnUse",
|
|
@@ -2331,7 +2331,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2331
2331
|
]
|
|
2332
2332
|
}
|
|
2333
2333
|
),
|
|
2334
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id:
|
|
2334
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: a2, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2335
2335
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: b, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M423.64 242h164.999V77H423.64Z" }) }),
|
|
2336
2336
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: e, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2337
2337
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: f, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M311.3 242h93.031V77H311.3Z" }) }),
|
|
@@ -2339,7 +2339,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2339
2339
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: n, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2340
2340
|
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: o, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M69.067 242H169.12V141.947H69.067Z" }) })
|
|
2341
2341
|
] }),
|
|
2342
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: `url(#${
|
|
2342
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: `url(#${a2})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2343
2343
|
"g",
|
|
2344
2344
|
{
|
|
2345
2345
|
style: {
|
|
@@ -2350,7 +2350,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2350
2350
|
"path",
|
|
2351
2351
|
{
|
|
2352
2352
|
style: {
|
|
2353
|
-
fill: `url(#${
|
|
2353
|
+
fill: `url(#${c2})`,
|
|
2354
2354
|
stroke: "none"
|
|
2355
2355
|
},
|
|
2356
2356
|
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"
|
|
@@ -2664,9 +2664,49 @@ function ConfigureApi({ secrets, setDialogState }) {
|
|
|
2664
2664
|
}
|
|
2665
2665
|
);
|
|
2666
2666
|
}
|
|
2667
|
-
var ConfigureApi$1 = React.memo(ConfigureApi)
|
|
2667
|
+
var ConfigureApi$1 = React.memo(ConfigureApi), c = function(r) {
|
|
2668
|
+
var t, e;
|
|
2669
|
+
function n(t2) {
|
|
2670
|
+
var e2;
|
|
2671
|
+
return (e2 = r.call(this, t2) || this).state = { hasError: !1, error: null }, e2;
|
|
2672
|
+
}
|
|
2673
|
+
e = r, (t = n).prototype = Object.create(e.prototype), t.prototype.constructor = t, t.__proto__ = e, n.getDerivedStateFromError = function(r2) {
|
|
2674
|
+
return { hasError: !0, error: r2 };
|
|
2675
|
+
};
|
|
2676
|
+
var o = n.prototype;
|
|
2677
|
+
return o.componentDidCatch = function(r2, t2) {
|
|
2678
|
+
return this.props.onDidCatch(r2, t2);
|
|
2679
|
+
}, o.render = function() {
|
|
2680
|
+
var r2 = this.state, t2 = this.props, e2 = t2.render, n2 = t2.children, o2 = t2.renderError;
|
|
2681
|
+
return r2.hasError ? o2 ? o2({ error: r2.error }) : null : e2 ? e2() : n2 || null;
|
|
2682
|
+
}, n;
|
|
2683
|
+
}(React.PureComponent), u = function(r, t) {
|
|
2684
|
+
switch (t.type) {
|
|
2685
|
+
case "catch":
|
|
2686
|
+
return { didCatch: !0, error: t.error };
|
|
2687
|
+
case "reset":
|
|
2688
|
+
return { didCatch: !1, error: null };
|
|
2689
|
+
default:
|
|
2690
|
+
return r;
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2693
|
+
function a(t) {
|
|
2694
|
+
var a2 = React.useReducer(u, { didCatch: !1, error: null }), i = a2[0], d = a2[1], h = React.useRef(null);
|
|
2695
|
+
function l() {
|
|
2696
|
+
return e = function(r, e2) {
|
|
2697
|
+
d({ type: "catch", error: r }), t && t.onDidCatch && t.onDidCatch(r, e2);
|
|
2698
|
+
}, function(t2) {
|
|
2699
|
+
return React__default.default.createElement(c, { onDidCatch: e, children: t2.children, render: t2.render, renderError: t2.renderError });
|
|
2700
|
+
};
|
|
2701
|
+
var e;
|
|
2702
|
+
}
|
|
2703
|
+
var p, s = React.useCallback(function() {
|
|
2704
|
+
h.current = l(), d({ type: "reset" });
|
|
2705
|
+
}, []);
|
|
2706
|
+
return { ErrorBoundary: (p = h.current, p !== null ? p : (h.current = l(), h.current)), didCatch: i.didCatch, error: i.error, reset: s };
|
|
2707
|
+
}
|
|
2668
2708
|
function ErrorBoundaryCard(props) {
|
|
2669
|
-
const { children, schemaType } = props, { push: pushToast } = ui.useToast(), errorRef = React.useRef(null), { ErrorBoundary, didCatch, error, reset } =
|
|
2709
|
+
const { children, schemaType } = props, { push: pushToast } = ui.useToast(), errorRef = React.useRef(null), { ErrorBoundary, didCatch, error, reset } = a({
|
|
2670
2710
|
onDidCatch: (err, errorInfo) => {
|
|
2671
2711
|
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({
|
|
2672
2712
|
status: "error",
|
|
@@ -3312,12 +3352,12 @@ function formatBytes(bytes, si = !1, dp = 1) {
|
|
|
3312
3352
|
if (Math.abs(bytes) < thresh)
|
|
3313
3353
|
return bytes + " B";
|
|
3314
3354
|
const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
3315
|
-
let
|
|
3355
|
+
let u2 = -1;
|
|
3316
3356
|
const r = 10 ** dp;
|
|
3317
3357
|
do
|
|
3318
|
-
bytes /= thresh, ++
|
|
3319
|
-
while (Math.round(Math.abs(bytes) * r) / r >= thresh &&
|
|
3320
|
-
return bytes.toFixed(dp) + " " + units[
|
|
3358
|
+
bytes /= thresh, ++u2;
|
|
3359
|
+
while (Math.round(Math.abs(bytes) * r) / r >= thresh && u2 < units.length - 1);
|
|
3360
|
+
return bytes.toFixed(dp) + " " + units[u2];
|
|
3321
3361
|
}
|
|
3322
3362
|
const SUPPORTED_MUX_LANGUAGES = [
|
|
3323
3363
|
{ label: "English", code: "en", state: "Stable" },
|