sanity-plugin-mux-input 2.2.0 → 2.2.2

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.js CHANGED
@@ -44,7 +44,7 @@ function tokenize(string) {
44
44
  function toGroqParams(terms) {
45
45
  const params = {};
46
46
  return terms.reduce((acc, term, i) => {
47
- acc["t".concat(i)] = "*".concat(term, "*");
47
+ acc["t".concat(i)] = "".concat(term, "*");
48
48
  return acc;
49
49
  }, params);
50
50
  }
@@ -61,7 +61,7 @@ function extractTermsFromQuery(query) {
61
61
  const remainingTerms = uniq(compact(tokenize(toLower(unquotedQuery))));
62
62
  return [...quotedTerms, ...remainingTerms];
63
63
  }
64
- const SEARCH_PATHS = ["filename", "assetId", "_id"];
64
+ const SEARCH_PATHS = ["filename"];
65
65
  function createConstraints(terms) {
66
66
  const constraints = terms.map((_term, i) => SEARCH_PATHS.map(joinedPath => "".concat(joinedPath, " match $t").concat(i))).filter(constraint => constraint.length > 0);
67
67
  return constraints.map(constraint => "(".concat(constraint.join(" || "), ")"));
@@ -101,9 +101,9 @@ const useAssetDocuments = createHookFromObservableFactory(_ref => {
101
101
  } = _ref;
102
102
  const search = createSearchFilter(searchQuery);
103
103
  const filter = ['_type == "mux.videoAsset"', ...search.filter].filter(Boolean).join(" && ");
104
- const query = ASSET_SORT_OPTIONS[sort].groq;
104
+ const sortFragment = ASSET_SORT_OPTIONS[sort].groq;
105
105
  return documentStore.listenQuery( /* groq */
106
- "*[".concat(filter, "] | order(").concat(query, ")"), search.params, {
106
+ "*[".concat(filter, "] | order(").concat(sortFragment, ")"), search.params, {
107
107
  apiVersion: SANITY_API_VERSION
108
108
  });
109
109
  });
@@ -182,7 +182,7 @@ const cacheNs = "sanity-plugin-mux-input";
182
182
  const muxSecretsDocumentId = "secrets.mux";
183
183
  const DIALOGS_Z_INDEX = 6e4;
184
184
  const THUMBNAIL_ASPECT_RATIO = 16 / 9;
185
- const MIN_ASPECT_RATIO = 1;
185
+ const MIN_ASPECT_RATIO = 5 / 4;
186
186
  function FormField(props) {
187
187
  const {
188
188
  children,
@@ -339,7 +339,7 @@ function getVideoSrc(_ref3) {
339
339
  return "https://stream.mux.com/".concat(playbackId, ".m3u8?").concat(searchParams);
340
340
  }
341
341
  var name = "sanity-plugin-mux-input";
342
- var version = "2.2.0";
342
+ var version = "2.2.2";
343
343
  var description = "An input component that integrates Sanity Studio with Mux video encoding/hosting service.";
344
344
  var keywords = ["sanity", "video", "mux", "input", "plugin", "sanity-plugin", "media"];
345
345
  var homepage = "https://github.com/sanity-io/sanity-plugin-mux-input#readme";
@@ -400,7 +400,7 @@ var dependencies = {
400
400
  "scroll-into-view-if-needed": "^3",
401
401
  "suspend-react": "^0.1.0",
402
402
  swr: "^2.1.0",
403
- "type-fest": "^3.6.1",
403
+ "type-fest": "^4.0.0",
404
404
  "use-error-boundary": "^2.0.6"
405
405
  };
406
406
  var devDependencies = {
@@ -420,16 +420,16 @@ var devDependencies = {
420
420
  "eslint-config-react-app": "^7.0.1",
421
421
  "eslint-config-sanity": "^6.0.0",
422
422
  "eslint-plugin-import": "^2.28.0",
423
- "eslint-plugin-prettier": "^4.2.1",
423
+ "eslint-plugin-prettier": "^5.0.0",
424
424
  "eslint-plugin-react": "^7.33.1",
425
425
  "eslint-plugin-react-hooks": "^4.6.0",
426
426
  "eslint-plugin-simple-import-sort": "^10.0.0",
427
427
  husky: "^8.0.3",
428
428
  "lint-staged": "^13.2.3",
429
429
  next: "^13.4.12",
430
- "next-sanity": "^4.3.3",
430
+ "next-sanity": "^5.1.6",
431
431
  "npm-run-all": "^4.1.5",
432
- prettier: "^2.8.8",
432
+ prettier: "^3.0.1",
433
433
  "prettier-plugin-packagejson": "^2.4.5",
434
434
  react: "^18.2.0",
435
435
  "react-dom": "^18.2.0",
@@ -449,7 +449,8 @@ var engines = {
449
449
  node: ">=14"
450
450
  };
451
451
  var publishConfig = {
452
- access: "public"
452
+ access: "public",
453
+ provenance: true
453
454
  };
454
455
  var sanityExchangeUrl = "https://www.sanity.io/plugins/sanity-plugin-mux-input";
455
456
  var pluginPkg = {
@@ -768,29 +769,28 @@ function DocumentPreview(props) {
768
769
  children: PreviewComponent
769
770
  });
770
771
  }
771
- var __freeze$b = Object.freeze;
772
- var __defProp$c = Object.defineProperty;
773
- var __template$b = (cooked, raw) => __freeze$b(__defProp$c(cooked, "raw", {
774
- value: __freeze$b(raw || cooked.slice())
772
+ var __freeze$c = Object.freeze;
773
+ var __defProp$d = Object.defineProperty;
774
+ var __template$c = (cooked, raw) => __freeze$c(__defProp$d(cooked, "raw", {
775
+ value: __freeze$c(raw || cooked.slice())
775
776
  }));
776
- var _a$b;
777
- const Container = styled(Box)(_a$b || (_a$b = __template$b(["\n * {\n color: ", ";\n }\n a {\n text-decoration: none;\n }\n h2 {\n font-size: ", ";\n }\n"])), props => props.theme.sanity.color.base.fg, props => props.theme.sanity.fonts.text.sizes[1]);
778
- const FileReferences = props => {
777
+ var _a$c;
778
+ const Container = styled(Box)(_a$c || (_a$c = __template$c(["\n * {\n color: ", ";\n }\n a {\n text-decoration: none;\n }\n h2 {\n font-size: ", ";\n }\n"])), props => props.theme.sanity.color.base.fg, props => props.theme.sanity.fonts.text.sizes[1]);
779
+ const VideoReferences = props => {
779
780
  var _a2;
780
781
  const schema = useSchema();
781
782
  if (!props.isLoaded) {
782
783
  return /* @__PURE__ */jsx(SpinnerBox, {});
783
784
  }
784
785
  if (!((_a2 = props.references) == null ? void 0 : _a2.length)) {
785
- return /* @__PURE__ */jsx(Text, {
786
- size: 2,
787
- weight: "bold",
788
- muted: true,
789
- style: {
790
- marginTop: "1.5rem",
791
- textAlign: "center"
792
- },
793
- children: "No documents are using this file"
786
+ return /* @__PURE__ */jsx(Card, {
787
+ border: true,
788
+ radius: 3,
789
+ padding: 3,
790
+ children: /* @__PURE__ */jsx(Text, {
791
+ size: 2,
792
+ children: "No documents are using this video"
793
+ })
794
794
  });
795
795
  }
796
796
  const documentPairs = collate(props.references || []);
@@ -863,9 +863,9 @@ function DeleteDialog(_ref7) {
863
863
  }
864
864
  }
865
865
  return /* @__PURE__ */jsx(Dialog, {
866
- header: "Delete file",
866
+ header: "Delete video",
867
867
  zOffset: DIALOGS_Z_INDEX,
868
- id: "deleting-file-details-dialog",
868
+ id: "deleting-video-details-dialog",
869
869
  onClose: cancelDelete,
870
870
  onClickOutside: cancelDelete,
871
871
  width: 1,
@@ -879,7 +879,7 @@ function DeleteDialog(_ref7) {
879
879
  icon: TrashIcon,
880
880
  fontSize: 2,
881
881
  padding: 3,
882
- text: "Delete file",
882
+ text: "Delete video",
883
883
  tone: "critical",
884
884
  onClick: confirmDelete,
885
885
  disabled: ["processing_deletion", "checkingReferences", "cantDelete"].some(s => s === state)
@@ -899,7 +899,7 @@ function DeleteDialog(_ref7) {
899
899
  children: [state === "checkingReferences" && /* @__PURE__ */jsxs(Fragment, {
900
900
  children: [/* @__PURE__ */jsx(Heading, {
901
901
  size: 2,
902
- children: "Checking if file can be deleted"
902
+ children: "Checking if video can be deleted"
903
903
  }), /* @__PURE__ */jsx(SpinnerBox, {})]
904
904
  }), state === "cantDelete" && /* @__PURE__ */jsxs(Fragment, {
905
905
  children: [/* @__PURE__ */jsx(Heading, {
@@ -910,8 +910,8 @@ function DeleteDialog(_ref7) {
910
910
  style: {
911
911
  marginBottom: "2rem"
912
912
  },
913
- children: ["There are ", references == null ? void 0 : references.length, " document", references && references.length > 0 && "s", " ", "pointing to this file. Remove their references to this file or delete them before proceeding."]
914
- }), /* @__PURE__ */jsx(FileReferences, {
913
+ children: ["There are ", references == null ? void 0 : references.length, " document", references && references.length > 0 && "s", " ", "pointing to this video. Remove their references to this file or delete them before proceeding."]
914
+ }), /* @__PURE__ */jsx(VideoReferences, {
915
915
  references,
916
916
  isLoaded: !referencesLoading,
917
917
  placement
@@ -919,7 +919,7 @@ function DeleteDialog(_ref7) {
919
919
  }), state === "confirm" && /* @__PURE__ */jsxs(Fragment, {
920
920
  children: [/* @__PURE__ */jsx(Heading, {
921
921
  size: 2,
922
- children: "Are you sure you want to delete this file?"
922
+ children: "Are you sure you want to delete this video?"
923
923
  }), /* @__PURE__ */jsx(Text, {
924
924
  size: 2,
925
925
  children: "This action is irreversible"
@@ -955,7 +955,7 @@ function DeleteDialog(_ref7) {
955
955
  }), state === "processing_deletion" && /* @__PURE__ */jsxs(Fragment, {
956
956
  children: [/* @__PURE__ */jsx(Heading, {
957
957
  size: 2,
958
- children: "Deleting file..."
958
+ children: "Deleting video..."
959
959
  }), /* @__PURE__ */jsx(SpinnerBox, {})]
960
960
  }), state === "error_deleting" && /* @__PURE__ */jsxs(Fragment, {
961
961
  children: [/* @__PURE__ */jsx(Heading, {
@@ -963,7 +963,7 @@ function DeleteDialog(_ref7) {
963
963
  children: "Something went wrong!"
964
964
  }), /* @__PURE__ */jsx(Text, {
965
965
  size: 2,
966
- children: "Try deleting the file again by clicking the button below"
966
+ children: "Try deleting the video again by clicking the button below"
967
967
  })]
968
968
  })]
969
969
  })
@@ -1010,7 +1010,7 @@ function getVideoMetadata(doc) {
1010
1010
  max_stored_frame_rate: (_f = doc.data) == null ? void 0 : _f.max_stored_frame_rate
1011
1011
  };
1012
1012
  }
1013
- function useFileDetails(props) {
1013
+ function useVideoDetails(props) {
1014
1014
  const documentStore = useDocumentStore();
1015
1015
  const toast = useToast();
1016
1016
  const client = useClient();
@@ -1051,9 +1051,11 @@ function useFileDetails(props) {
1051
1051
  filename
1052
1052
  }));
1053
1053
  toast.push({
1054
- title: "File name updated",
1054
+ title: "Video title updated",
1055
+ description: "New title: ".concat(filename),
1055
1056
  status: "success"
1056
1057
  });
1058
+ props.closeDialog();
1057
1059
  } catch (error) {
1058
1060
  toast.push({
1059
1061
  title: "Failed updating file name",
@@ -1104,7 +1106,7 @@ const VideoDetails = props => {
1104
1106
  handleClose,
1105
1107
  confirmClose,
1106
1108
  saveChanges
1107
- } = useFileDetails(props);
1109
+ } = useVideoDetails(props);
1108
1110
  const isSaving = state === "saving";
1109
1111
  const [containerHeight, setContainerHeight] = useState(null);
1110
1112
  const contentsRef = React.useRef(null);
@@ -1115,13 +1117,10 @@ const VideoDetails = props => {
1115
1117
  return /* @__PURE__ */jsxs(Dialog, {
1116
1118
  header: displayInfo.title,
1117
1119
  zOffset: DIALOGS_Z_INDEX,
1118
- id: "file-details-dialog",
1120
+ id: "video-details-dialog",
1119
1121
  onClose: handleClose,
1120
1122
  onClickOutside: handleClose,
1121
1123
  width: 2,
1122
- style: {
1123
- minHeight: "50vh"
1124
- },
1125
1124
  position: "fixed",
1126
1125
  footer: /* @__PURE__ */jsx(Card, {
1127
1126
  padding: 3,
@@ -1162,7 +1161,7 @@ const VideoDetails = props => {
1162
1161
  }), state === "closing" && /* @__PURE__ */jsx(Dialog, {
1163
1162
  header: "You have unsaved changes",
1164
1163
  zOffset: DIALOGS_Z_INDEX,
1165
- id: "closing-file-details-dialog",
1164
+ id: "closing-video-details-dialog",
1166
1165
  onClose: () => confirmClose(false),
1167
1166
  onClickOutside: () => confirmClose(false),
1168
1167
  width: 1,
@@ -1242,11 +1241,11 @@ const VideoDetails = props => {
1242
1241
  label: "Details",
1243
1242
  onClick: () => setTab("details"),
1244
1243
  selected: tab === "details"
1245
- }), references && references.length > 0 && /* @__PURE__ */jsx(Tab, {
1244
+ }), /* @__PURE__ */jsx(Tab, {
1246
1245
  "aria-controls": "references-panel",
1247
1246
  icon: SearchIcon,
1248
1247
  id: "references-tab",
1249
- label: "Used by (".concat(references.length, ")"),
1248
+ label: "Used by ".concat(references ? "(".concat(references.length, ")") : ""),
1250
1249
  onClick: () => setTab("references"),
1251
1250
  selected: tab === "references"
1252
1251
  })]
@@ -1257,8 +1256,8 @@ const VideoDetails = props => {
1257
1256
  children: /* @__PURE__ */jsxs(Stack, {
1258
1257
  space: 4,
1259
1258
  children: [/* @__PURE__ */jsx(AssetInput, {
1260
- label: "File name",
1261
- description: "Not visible to users. Useful for finding files later.",
1259
+ label: "Video title or file name",
1260
+ description: "Not visible to users. Useful for finding videos later.",
1262
1261
  value: filename || "",
1263
1262
  onInput: e => setFilename(e.currentTarget.value),
1264
1263
  disabled: state !== "idle"
@@ -1298,7 +1297,7 @@ const VideoDetails = props => {
1298
1297
  "aria-labelledby": "references-tab",
1299
1298
  id: "references-panel",
1300
1299
  hidden: tab !== "references",
1301
- children: /* @__PURE__ */jsx(FileReferences, {
1300
+ children: /* @__PURE__ */jsx(VideoReferences, {
1302
1301
  references,
1303
1302
  isLoaded: !referencesLoading,
1304
1303
  placement: props.placement
@@ -1390,13 +1389,13 @@ function getAnimatedPosterSrc(_ref10) {
1390
1389
  }
1391
1390
  return "https://image.mux.com/".concat(playbackId, "/animated.gif?").concat(searchParams);
1392
1391
  }
1393
- var __freeze$a = Object.freeze;
1394
- var __defProp$b = Object.defineProperty;
1395
- var __template$a = (cooked, raw) => __freeze$a(__defProp$b(cooked, "raw", {
1396
- value: __freeze$a(raw || cooked.slice())
1392
+ var __freeze$b = Object.freeze;
1393
+ var __defProp$c = Object.defineProperty;
1394
+ var __template$b = (cooked, raw) => __freeze$b(__defProp$c(cooked, "raw", {
1395
+ value: __freeze$b(raw || cooked.slice())
1397
1396
  }));
1398
- var _a$a;
1399
- const Image = styled.img(_a$a || (_a$a = __template$a(["\n transition: opacity 0.175s ease-out 0s;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center center;\n"])));
1397
+ var _a$b;
1398
+ const Image = styled.img(_a$b || (_a$b = __template$b(["\n transition: opacity 0.175s ease-out 0s;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center center;\n"])));
1400
1399
  const STATUS_TO_TONE = {
1401
1400
  loading: "transparent",
1402
1401
  error: "critical",
@@ -1476,13 +1475,13 @@ function VideoThumbnail(_ref11) {
1476
1475
  }) : null
1477
1476
  });
1478
1477
  }
1479
- var __freeze$9 = Object.freeze;
1480
- var __defProp$a = Object.defineProperty;
1481
- var __template$9 = (cooked, raw) => __freeze$9(__defProp$a(cooked, "raw", {
1482
- value: __freeze$9(raw || cooked.slice())
1478
+ var __freeze$a = Object.freeze;
1479
+ var __defProp$b = Object.defineProperty;
1480
+ var __template$a = (cooked, raw) => __freeze$a(__defProp$b(cooked, "raw", {
1481
+ value: __freeze$a(raw || cooked.slice())
1483
1482
  }));
1484
- var _a$9;
1485
- const PlayButton = styled.button(_a$9 || (_a$9 = __template$9(["\n display: block;\n padding: 0;\n margin: 0;\n border: none;\n border-radius: 0.1875rem;\n position: relative;\n cursor: pointer;\n\n &::after {\n content: '';\n background: var(--card-fg-color);\n opacity: 0;\n display: block;\n position: absolute;\n inset: 0;\n z-index: 10;\n transition: 0.15s ease-out;\n border-radius: inherit;\n }\n\n > div[data-play] {\n z-index: 11;\n opacity: 0;\n transition: 0.15s 0.05s ease-out;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n width: auto;\n height: 30%;\n aspect-ratio: 1;\n border-radius: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n > svg {\n display: block;\n width: 70%;\n height: auto;\n // Visual balance to center-align the icon\n transform: translateX(5%);\n }\n }\n\n &:hover,\n &:focus {\n &::after {\n opacity: 0.3;\n }\n > div[data-play] {\n opacity: 1;\n }\n }\n"])));
1483
+ var _a$a;
1484
+ const PlayButton = styled.button(_a$a || (_a$a = __template$a(["\n display: block;\n padding: 0;\n margin: 0;\n border: none;\n border-radius: 0.1875rem;\n position: relative;\n cursor: pointer;\n\n &::after {\n content: '';\n background: var(--card-fg-color);\n opacity: 0;\n display: block;\n position: absolute;\n inset: 0;\n z-index: 10;\n transition: 0.15s ease-out;\n border-radius: inherit;\n }\n\n > div[data-play] {\n z-index: 11;\n opacity: 0;\n transition: 0.15s 0.05s ease-out;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n width: auto;\n height: 30%;\n aspect-ratio: 1;\n border-radius: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n > svg {\n display: block;\n width: 70%;\n height: auto;\n // Visual balance to center-align the icon\n transform: translateX(5%);\n }\n }\n\n &:hover,\n &:focus {\n &::after {\n opacity: 0.3;\n }\n > div[data-play] {\n opacity: 1;\n }\n }\n"])));
1486
1485
  function VideoInBrowser(_ref12) {
1487
1486
  let {
1488
1487
  onSelect,
@@ -1606,6 +1605,9 @@ function VideosBrowser(_ref13) {
1606
1605
  children: [/* @__PURE__ */jsxs(Stack, {
1607
1606
  padding: 4,
1608
1607
  space: 4,
1608
+ style: {
1609
+ minHeight: "50vh"
1610
+ },
1609
1611
  children: [/* @__PURE__ */jsx(Flex, {
1610
1612
  justify: "space-between",
1611
1613
  align: "center",
@@ -1616,7 +1618,7 @@ function VideosBrowser(_ref13) {
1616
1618
  value: searchQuery,
1617
1619
  icon: SearchIcon,
1618
1620
  onInput: e => setSearchQuery(e.currentTarget.value),
1619
- placeholder: "Search files"
1621
+ placeholder: "Search videos"
1620
1622
  }), /* @__PURE__ */jsx(SelectSortOptions, {
1621
1623
  setSort,
1622
1624
  sort
@@ -1639,13 +1641,15 @@ function VideosBrowser(_ref13) {
1639
1641
  }, asset._id))
1640
1642
  })]
1641
1643
  }), isLoading && /* @__PURE__ */jsx(SpinnerBox, {}), !isLoading && assets.length === 0 && /* @__PURE__ */jsx(Card, {
1642
- padding: 2,
1644
+ padding: 4,
1643
1645
  marginY: 4,
1644
1646
  border: true,
1645
1647
  radius: 2,
1648
+ tone: "transparent",
1646
1649
  children: /* @__PURE__ */jsx(Text, {
1647
1650
  align: "center",
1648
1651
  muted: true,
1652
+ size: 3,
1649
1653
  children: searchQuery ? 'No videos found for "'.concat(searchQuery, '"') : "No videos in this dataset"
1650
1654
  })
1651
1655
  })]
@@ -2114,6 +2118,13 @@ function SelectAssets(_ref14) {
2114
2118
  onSelect: handleSelect
2115
2119
  });
2116
2120
  }
2121
+ var __freeze$9 = Object.freeze;
2122
+ var __defProp$a = Object.defineProperty;
2123
+ var __template$9 = (cooked, raw) => __freeze$9(__defProp$a(cooked, "raw", {
2124
+ value: __freeze$9(raw || cooked.slice())
2125
+ }));
2126
+ var _a$9;
2127
+ const StyledDialog = styled(Dialog)(_a$9 || (_a$9 = __template$9(["\n > div[data-ui='DialogCard'] > div[data-ui='Card'] {\n height: 100%;\n }\n"])));
2117
2128
  function InputBrowser(_ref15) {
2118
2129
  let {
2119
2130
  setDialogState,
@@ -2122,7 +2133,7 @@ function InputBrowser(_ref15) {
2122
2133
  } = _ref15;
2123
2134
  const id = "InputBrowser".concat(useId());
2124
2135
  const handleClose = useCallback(() => setDialogState(false), [setDialogState]);
2125
- return /* @__PURE__ */jsx(Dialog, {
2136
+ return /* @__PURE__ */jsx(StyledDialog, {
2126
2137
  __unstable_autoFocus: true,
2127
2138
  header: "Select video",
2128
2139
  id,
@@ -2283,7 +2294,7 @@ const Player = _ref17 => {
2283
2294
  return /* @__PURE__ */jsx(UploadProgress, {
2284
2295
  progress: 100,
2285
2296
  filename: asset == null ? void 0 : asset.filename,
2286
- text: isLoading !== true && isLoading || "Waiting for Mux to complete the file",
2297
+ text: isLoading !== true && isLoading || "Waiting for Mux to complete the upload",
2287
2298
  onCancel: readOnly ? void 0 : () => handleCancelUpload()
2288
2299
  });
2289
2300
  }