@app-studio/web 0.8.62 → 0.8.63

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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { UploadProps, UseUploadProps } from './Uploader.props';
3
+ export declare const generateThumbnail: (videoFile: File, setThumbnailUrl: (url: string) => void) => void;
3
4
  export declare const useUpload: ({ maxSize, onFileSelect, validateFile, thumbnail, onError, }: UseUploadProps) => {
4
5
  previewUrl: string | null;
5
6
  thumbnailUrl: string | null;
@@ -6965,6 +6965,26 @@ var MessageLayout = _ref => {
6965
6965
  return visible ? MessageContainer : null;
6966
6966
  };
6967
6967
 
6968
+ var generateThumbnail = (videoFile, setThumbnailUrl) => {
6969
+ var video = document.createElement('video');
6970
+ video.preload = 'metadata';
6971
+ video.onloadedmetadata = () => {
6972
+ video.currentTime = 1;
6973
+ };
6974
+ video.oncanplay = () => {
6975
+ var canvas = document.createElement('canvas');
6976
+ canvas.width = video.videoWidth;
6977
+ canvas.height = video.videoHeight;
6978
+ var ctx = canvas.getContext('2d');
6979
+ if (ctx) {
6980
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
6981
+ var thumbnailDataUrl = canvas.toDataURL('image/jpeg');
6982
+ setThumbnailUrl(thumbnailDataUrl);
6983
+ }
6984
+ URL.revokeObjectURL(video.src);
6985
+ };
6986
+ video.src = URL.createObjectURL(videoFile);
6987
+ };
6968
6988
  var useUpload = _ref => {
6969
6989
  var {
6970
6990
  maxSize = 100 * 1024 * 1024,
@@ -6982,26 +7002,6 @@ var useUpload = _ref => {
6982
7002
  var [errorMessage, setErrorMessage] = React.useState(null);
6983
7003
  var [previewUrl, setPreviewUrl] = React.useState(null);
6984
7004
  var [thumbnailUrl, setThumbnailUrl] = React.useState(thumbnail || null);
6985
- var generateThumbnail = videoFile => {
6986
- var video = document.createElement('video');
6987
- video.preload = 'metadata';
6988
- video.onloadedmetadata = () => {
6989
- video.currentTime = 1;
6990
- };
6991
- video.oncanplay = () => {
6992
- var canvas = document.createElement('canvas');
6993
- canvas.width = video.videoWidth;
6994
- canvas.height = video.videoHeight;
6995
- var ctx = canvas.getContext('2d');
6996
- if (ctx) {
6997
- ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
6998
- var thumbnailDataUrl = canvas.toDataURL('image/jpeg');
6999
- setThumbnailUrl(thumbnailDataUrl);
7000
- }
7001
- URL.revokeObjectURL(video.src);
7002
- };
7003
- video.src = URL.createObjectURL(videoFile);
7004
- };
7005
7005
  var handleFileChange = React.useCallback(event => {
7006
7006
  var _event$target$files;
7007
7007
  var file = (_event$target$files = event.target.files) == null ? void 0 : _event$target$files[0];
@@ -7026,7 +7026,7 @@ var useUpload = _ref => {
7026
7026
  }
7027
7027
  setPreviewUrl(URL.createObjectURL(file));
7028
7028
  if (file.type.startsWith('video/')) {
7029
- generateThumbnail(file);
7029
+ generateThumbnail(file, setThumbnailUrl);
7030
7030
  }
7031
7031
  if (onFileSelect) {
7032
7032
  setSelectedFile(file);
@@ -8191,6 +8191,7 @@ exports.WarningIcon = WarningIcon;
8191
8191
  exports.WifiIcon = WifiIcon;
8192
8192
  exports.XIcon = XIcon;
8193
8193
  exports.YoutubeIcon = YoutubeIcon;
8194
+ exports.generateThumbnail = generateThumbnail;
8194
8195
  exports.hideMessage = hideMessage;
8195
8196
  exports.hideModal = hideModal;
8196
8197
  exports.showMessage = showMessage;