@postrun/react 2.6.0 → 2.7.0

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.cjs CHANGED
@@ -984,6 +984,42 @@ function useTikTokCreatorInfo(connectionId) {
984
984
  queryClient
985
985
  );
986
986
  }
987
+
988
+ // src/preview/from-upload.ts
989
+ function previewKind(item) {
990
+ const detected = item.media?.kind;
991
+ if (detected) {
992
+ return detected === "document" ? null : detected;
993
+ }
994
+ const mime = item.file.type;
995
+ if (mime === "image/gif") {
996
+ return "gif";
997
+ }
998
+ if (mime.startsWith("video/")) {
999
+ return "video";
1000
+ }
1001
+ if (mime.startsWith("image/")) {
1002
+ return "image";
1003
+ }
1004
+ return null;
1005
+ }
1006
+ function toPreviewMedia(items) {
1007
+ return items.flatMap((item) => {
1008
+ const kind = previewKind(item);
1009
+ if (!kind) {
1010
+ return [];
1011
+ }
1012
+ return [
1013
+ {
1014
+ kind,
1015
+ file: item.file,
1016
+ width: item.media?.source?.width ?? void 0,
1017
+ height: item.media?.source?.height ?? void 0,
1018
+ alt: item.media?.alt_text ?? void 0
1019
+ }
1020
+ ];
1021
+ });
1022
+ }
987
1023
  function fileKey(file) {
988
1024
  return file ? `${file.name}:${file.size}:${file.lastModified}` : "";
989
1025
  }
@@ -2890,6 +2926,7 @@ exports.mediaKeys = mediaKeys;
2890
2926
  exports.postKeys = postKeys;
2891
2927
  exports.profileKeys = profileKeys;
2892
2928
  exports.tiktokKeys = tiktokKeys;
2929
+ exports.toPreviewMedia = toPreviewMedia;
2893
2930
  exports.useCalendar = useCalendar;
2894
2931
  exports.useConnect = useConnect;
2895
2932
  exports.useConnection = useConnection;