@app-studio/web 0.8.61 → 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);
@@ -7110,8 +7110,7 @@ var Uploader = _ref2 => {
7110
7110
  thumbnailUrl,
7111
7111
  videoRef,
7112
7112
  videoProps,
7113
- imageProps,
7114
- iconProps
7113
+ imageProps
7115
7114
  } = _ref6;
7116
7115
  console.log('thumbnailUrl', thumbnailUrl);
7117
7116
  return /*#__PURE__*/React__default.createElement(appStudio.View, {
@@ -7133,14 +7132,7 @@ var Uploader = _ref2 => {
7133
7132
  width: "100%",
7134
7133
  height: "100%",
7135
7134
  objectFit: "cover"
7136
- }, imageProps)), /*#__PURE__*/React__default.createElement(PlayIcon, Object.assign({
7137
- position: "absolute",
7138
- top: "50%",
7139
- left: "50%",
7140
- color: "white",
7141
- size: '20%',
7142
- transform: "translate(-50%, -50%)"
7143
- }, iconProps)));
7135
+ }, imageProps)));
7144
7136
  },
7145
7137
  renderImage = _ref7 => {
7146
7138
  var {
@@ -8199,6 +8191,7 @@ exports.WarningIcon = WarningIcon;
8199
8191
  exports.WifiIcon = WifiIcon;
8200
8192
  exports.XIcon = XIcon;
8201
8193
  exports.YoutubeIcon = YoutubeIcon;
8194
+ exports.generateThumbnail = generateThumbnail;
8202
8195
  exports.hideMessage = hideMessage;
8203
8196
  exports.hideModal = hideModal;
8204
8197
  exports.showMessage = showMessage;