sanity-plugin-mux-input 2.0.3 → 2.0.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.
Files changed (34) hide show
  1. package/lib/_chunks/{Input-aa6d929b.js → Input-4e0aa2ef.js} +64 -48
  2. package/lib/_chunks/Input-4e0aa2ef.js.map +1 -0
  3. package/lib/_chunks/{Input-4ec3c050.js → Input-7fb0dcd2.js} +64 -48
  4. package/lib/_chunks/Input-7fb0dcd2.js.map +1 -0
  5. package/lib/_chunks/{Preview-43ce9c72.js → Preview-3e4c2ec9.js} +2 -2
  6. package/lib/_chunks/{Preview-43ce9c72.js.map → Preview-3e4c2ec9.js.map} +1 -1
  7. package/lib/_chunks/{Preview-1664b7d5.js → Preview-e6f7e765.js} +2 -2
  8. package/lib/_chunks/{Preview-1664b7d5.js.map → Preview-e6f7e765.js.map} +1 -1
  9. package/lib/_chunks/{VideoSource.styled-99ffa712.js → VideoSource.styled-70d38762.js} +3 -3
  10. package/lib/_chunks/VideoSource.styled-70d38762.js.map +1 -0
  11. package/lib/_chunks/{VideoSource.styled-24577ec8.js → VideoSource.styled-e880b6e4.js} +3 -3
  12. package/lib/_chunks/VideoSource.styled-e880b6e4.js.map +1 -0
  13. package/lib/_chunks/{index-c54f5393.js → index-a9d40189.js} +14 -13
  14. package/lib/_chunks/{index-c54f5393.js.map → index-a9d40189.js.map} +1 -1
  15. package/lib/_chunks/{index-9933dea2.js → index-adfcd166.js} +14 -13
  16. package/lib/_chunks/{index-9933dea2.js.map → index-adfcd166.js.map} +1 -1
  17. package/lib/index.esm.js +1 -1
  18. package/lib/index.js +1 -1
  19. package/package.json +6 -6
  20. package/src/actions/assets.ts +1 -1
  21. package/src/actions/secrets.ts +12 -3
  22. package/src/actions/upload.ts +1 -1
  23. package/src/components/__legacy__Uploader.tsx +1 -1
  24. package/src/hooks/useSaveSecrets.ts +1 -1
  25. package/src/util/generateJwt.ts +1 -1
  26. package/src/util/getAnimatedPosterSrc.ts +1 -1
  27. package/src/util/getPosterSrc.ts +1 -1
  28. package/src/util/getStoryboardSrc.ts +1 -1
  29. package/src/util/getVideoSrc.ts +1 -1
  30. package/src/util/readSecrets.ts +1 -1
  31. package/lib/_chunks/Input-4ec3c050.js.map +0 -1
  32. package/lib/_chunks/Input-aa6d929b.js.map +0 -1
  33. package/lib/_chunks/VideoSource.styled-24577ec8.js.map +0 -1
  34. package/lib/_chunks/VideoSource.styled-99ffa712.js.map +0 -1
@@ -1,20 +1,11 @@
1
- const _excluded = ["icon", "id", "accept", "capture", "fontSize", "multiple", "onSelect", "padding", "space", "textAlign", "text", "disabled"],
2
- _excluded2 = ["onSelect"];
3
1
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
4
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
4
  import React, { useState, useMemo, memo, useRef, useLayoutEffect, useCallback, useId, useEffect, isValidElement, createElement, forwardRef, Component, useReducer } from 'react';
14
- import { useClient, VideoThumbnail, AnimatedVideoThumbnail, ThumbGrid, CardLoadMore, getPlaybackId, getPlaybackPolicy, generateJwt, getPosterSrc, _id, useAssetDocumentValues } from './VideoSource.styled-24577ec8.js';
5
+ import { useClient, VideoThumbnail, AnimatedVideoThumbnail, ThumbGrid, CardLoadMore, getPlaybackId, getPlaybackPolicy, generateJwt, getPosterSrc, _id, useAssetDocumentValues } from './VideoSource.styled-e880b6e4.js';
15
6
  import { useProjectId, useDataset, useDocumentValues, PatchEvent, setIfMissing, set, unset, LinearProgress } from 'sanity';
16
7
  import useSWR from 'swr';
17
- import { muxSecretsDocumentId, cacheNs, InputFallback } from './index-c54f5393.js';
8
+ import { muxSecretsDocumentId, cacheNs, InputFallback } from './index-a9d40189.js';
18
9
  import { Observable, defer, concat, of, throwError, from, Subject } from 'rxjs';
19
10
  import { switchMap, mergeMap, catchError, mergeMapTo, takeUntil, tap } from 'rxjs/operators';
20
11
  import { uuid } from '@sanity/uuid';
@@ -94,7 +85,9 @@ function createUpChunkObservable(uuid, uploadUrl, source) {
94
85
  endpoint: uploadUrl,
95
86
  file: source,
96
87
  dynamicChunkSize: true
88
+ // changes the chunk size based on network speeds
97
89
  });
90
+
98
91
  const successHandler = () => {
99
92
  subscriber.next({
100
93
  type: "success",
@@ -297,14 +290,23 @@ function uploadFile(config, client, file) {
297
290
  },
298
291
  body
299
292
  })).pipe(mergeMap(result => {
300
- return createUpChunkObservable(uuid$1, result.upload.url, file).pipe(mergeMap(event => {
293
+ return createUpChunkObservable(uuid$1, result.upload.url, file).pipe(
294
+ // eslint-disable-next-line no-warning-comments
295
+ // @TODO type the observable events
296
+ // eslint-disable-next-line max-nested-callbacks
297
+ mergeMap(event => {
301
298
  if (event.type !== "success") {
302
299
  return of(event);
303
300
  }
304
- return from(updateAssetDocumentFromUpload(client, uuid$1)).pipe(mergeMap(doc => of(_objectSpread(_objectSpread({}, event), {}, {
301
+ return from(updateAssetDocumentFromUpload(client, uuid$1)).pipe(
302
+ // eslint-disable-next-line max-nested-callbacks
303
+ mergeMap(doc => of({
304
+ ...event,
305
305
  asset: doc
306
- }))));
307
- }), catchError(err => {
306
+ })));
307
+ }),
308
+ // eslint-disable-next-line max-nested-callbacks
309
+ catchError(err => {
308
310
  return cancelUpload(client, uuid$1).pipe(mergeMapTo(throwError(err)));
309
311
  }));
310
312
  })));
@@ -745,7 +747,8 @@ const PER_PAGE = 200;
745
747
  function createQuery() {
746
748
  let start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
747
749
  let end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PER_PAGE;
748
- return "*[_type == \"mux.videoAsset\"] | order(_updatedAt desc) [".concat(start, "...").concat(end, "]");
750
+ return (/* groq */"*[_type == \"mux.videoAsset\"] | order(_updatedAt desc) [".concat(start, "...").concat(end, "]")
751
+ );
749
752
  }
750
753
  function SelectAssets(_ref3) {
751
754
  let {
@@ -852,7 +855,8 @@ function EditThumbnailDialog(_ref6) {
852
855
  const client = useClient();
853
856
  const dialogId = "EditThumbnailDialog".concat(useId());
854
857
  const nextTime = useMemo(() => getCurrentTime(), [getCurrentTime]);
855
- const assetWithNewThumbnail = useMemo(() => _objectSpread(_objectSpread({}, asset), {}, {
858
+ const assetWithNewThumbnail = useMemo(() => ({
859
+ ...asset,
856
860
  thumbTime: nextTime
857
861
  }), [asset, nextTime]);
858
862
  const [saving, setSaving] = useState(false);
@@ -1214,20 +1218,20 @@ const FileButton = styled(MenuItem)(_ref12 => {
1214
1218
  });
1215
1219
  const FileInputMenuItem = React.forwardRef(function FileInputMenuItem2(props, forwardedRef) {
1216
1220
  const {
1217
- icon,
1218
- id: idProp,
1219
- accept,
1220
- capture,
1221
- fontSize,
1222
- multiple,
1223
- onSelect,
1224
- padding = 3,
1225
- space = 3,
1226
- textAlign,
1227
- text,
1228
- disabled
1229
- } = props,
1230
- rest = _objectWithoutProperties(props, _excluded);
1221
+ icon,
1222
+ id: idProp,
1223
+ accept,
1224
+ capture,
1225
+ fontSize,
1226
+ multiple,
1227
+ onSelect,
1228
+ padding = 3,
1229
+ space = 3,
1230
+ textAlign,
1231
+ text,
1232
+ disabled,
1233
+ ...rest
1234
+ } = props;
1231
1235
  const idHook = useId();
1232
1236
  const id = idProp || idHook;
1233
1237
  const handleChange = React.useCallback(event => {
@@ -1252,7 +1256,8 @@ const FileInputMenuItem = React.forwardRef(function FileInputMenuItem2(props, fo
1252
1256
  children: text
1253
1257
  })]
1254
1258
  });
1255
- return /* @__PURE__ */jsxs(FileButton, _objectSpread(_objectSpread({}, rest), {}, {
1259
+ return /* @__PURE__ */jsxs(FileButton, {
1260
+ ...rest,
1256
1261
  htmlFor: id,
1257
1262
  padding: 0,
1258
1263
  fontSize: 2,
@@ -1269,7 +1274,7 @@ const FileInputMenuItem = React.forwardRef(function FileInputMenuItem2(props, fo
1269
1274
  value: "",
1270
1275
  disabled
1271
1276
  })]
1272
- }));
1277
+ });
1273
1278
  });
1274
1279
  const LockCard = styled(Card)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0.6;\n mix-blend-mode: screen;\n background: transparent;\n"])));
1275
1280
  const LockButton = styled(Button)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n background: transparent;\n color: white;\n"])));
@@ -1439,9 +1444,9 @@ const HiddenInput = styled.input(_templateObject15 || (_templateObject15 = _tagg
1439
1444
  const Label = styled.label(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n position: relative;\n"])));
1440
1445
  const FileInputButton = _ref14 => {
1441
1446
  let {
1442
- onSelect
1443
- } = _ref14,
1444
- props = _objectWithoutProperties(_ref14, _excluded2);
1447
+ onSelect,
1448
+ ...props
1449
+ } = _ref14;
1445
1450
  const inputId = "FileSelect".concat(useId());
1446
1451
  const inputRef = useRef(null);
1447
1452
  const handleSelect = useCallback(event => {
@@ -1463,14 +1468,15 @@ const FileInputButton = _ref14 => {
1463
1468
  id: inputId,
1464
1469
  onChange: handleSelect,
1465
1470
  value: ""
1466
- }), /* @__PURE__ */jsx(Button, _objectSpread({
1471
+ }), /* @__PURE__ */jsx(Button, {
1467
1472
  onClick: handleButtonClick,
1468
1473
  mode: "default",
1469
1474
  tone: "primary",
1470
1475
  style: {
1471
1476
  width: "100%"
1472
- }
1473
- }, props))]
1477
+ },
1478
+ ...props
1479
+ })]
1474
1480
  });
1475
1481
  };
1476
1482
  const UploadCard = styled(Card)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n && {\n border-style: dashed;\n }\n"])));
@@ -1571,6 +1577,8 @@ class MuxVideoInputUploader extends Component {
1571
1577
  };
1572
1578
  this.dragEnteredEls = [];
1573
1579
  this.ctrlDown = false;
1580
+ // eslint-disable-next-line no-warning-comments
1581
+ // @TODO add proper typings for the return values of uploadFile and uploadUrl
1574
1582
  this.upload = null;
1575
1583
  this.container = React.createRef();
1576
1584
  this.handleProgress = evt => {
@@ -1610,6 +1618,8 @@ class MuxVideoInputUploader extends Component {
1610
1618
  }
1611
1619
  });
1612
1620
  };
1621
+ // eslint-disable-next-line no-warning-comments
1622
+ // @TODO add proper typings for the Observable events
1613
1623
  this.handleUploadEvent = event => {
1614
1624
  switch (event.type) {
1615
1625
  case "success":
@@ -1840,6 +1850,8 @@ function init(_ref16) {
1840
1850
  return {
1841
1851
  submitting: false,
1842
1852
  error: null,
1853
+ // Form inputs don't set the state back to null when clearing a field, but uses empty strings
1854
+ // This ensures the `dirty` check works correctly
1843
1855
  token: token != null ? token : "",
1844
1856
  secretKey: secretKey != null ? secretKey : "",
1845
1857
  enableSignedUrls: enableSignedUrls != null ? enableSignedUrls : false
@@ -1848,21 +1860,24 @@ function init(_ref16) {
1848
1860
  function reducer(state, action) {
1849
1861
  switch (action == null ? void 0 : action.type) {
1850
1862
  case "submit":
1851
- return _objectSpread(_objectSpread({}, state), {}, {
1863
+ return {
1864
+ ...state,
1852
1865
  submitting: true,
1853
1866
  error: null
1854
- });
1867
+ };
1855
1868
  case "error":
1856
- return _objectSpread(_objectSpread({}, state), {}, {
1869
+ return {
1870
+ ...state,
1857
1871
  submitting: false,
1858
1872
  error: action.payload
1859
- });
1873
+ };
1860
1874
  case "reset":
1861
1875
  return init(action.payload);
1862
1876
  case "change":
1863
- return _objectSpread(_objectSpread({}, state), {}, {
1877
+ return {
1878
+ ...state,
1864
1879
  [action.payload.name]: action.payload.value
1865
- });
1880
+ };
1866
1881
  default:
1867
1882
  throw new Error("Unknown action type: ".concat(action == null ? void 0 : action.type));
1868
1883
  }
@@ -2615,7 +2630,8 @@ const Input = props => {
2615
2630
  children: isLoading ? /* @__PURE__ */jsx(InputFallback, {}) : /* @__PURE__ */jsxs(Fragment, {
2616
2631
  children: [secretDocumentValues.value.needsSetup && !assetDocumentValues.value ? /* @__PURE__ */jsx(Onboard, {
2617
2632
  setDialogState
2618
- }) : /* @__PURE__ */jsx(MuxVideoInputUploader, _objectSpread(_objectSpread({}, props), {}, {
2633
+ }) : /* @__PURE__ */jsx(MuxVideoInputUploader, {
2634
+ ...props,
2619
2635
  config: props.config,
2620
2636
  onChange: props.onChange,
2621
2637
  client,
@@ -2624,7 +2640,7 @@ const Input = props => {
2624
2640
  dialogState,
2625
2641
  setDialogState,
2626
2642
  needsSetup: secretDocumentValues.value.needsSetup
2627
- })), dialogState === "secrets" && /* @__PURE__ */jsx(ConfigureApi$1, {
2643
+ }), dialogState === "secrets" && /* @__PURE__ */jsx(ConfigureApi$1, {
2628
2644
  setDialogState,
2629
2645
  secrets: secretDocumentValues.value.secrets
2630
2646
  })]
@@ -2633,4 +2649,4 @@ const Input = props => {
2633
2649
  };
2634
2650
  var Input$1 = memo(Input);
2635
2651
  export { Input$1 as default };
2636
- //# sourceMappingURL=Input-aa6d929b.js.map
2652
+ //# sourceMappingURL=Input-4e0aa2ef.js.map