sceyt-chat-react-uikit 1.8.8-beta.6 → 1.8.8-beta.8
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/index.js +1114 -544
- package/index.modern.js +1096 -546
- package/messageUtils/index.d.ts +5 -1
- package/messageUtils/index.test.d.ts +1 -0
- package/package.json +1 -1
package/index.modern.js
CHANGED
|
@@ -12,7 +12,7 @@ import { createPortal } from 'react-dom';
|
|
|
12
12
|
import Cropper from 'react-easy-crop';
|
|
13
13
|
import { CircularProgressbar } from 'react-circular-progressbar';
|
|
14
14
|
import { FFmpeg } from '@ffmpeg/ffmpeg';
|
|
15
|
-
import {
|
|
15
|
+
import { toBlobURL, fetchFile } from '@ffmpeg/util';
|
|
16
16
|
import { $applyNodeReplacement, TextNode, $createTextNode, $getSelection, $isRangeSelection, $isTextNode, FORMAT_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, $getRoot, $createParagraphNode, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, PASTE_COMMAND, COMMAND_PRIORITY_NORMAL } from 'lexical';
|
|
17
17
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
18
18
|
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
@@ -14848,198 +14848,677 @@ function calculateSize(width, height, maxWidth, maxHeight) {
|
|
|
14848
14848
|
}
|
|
14849
14849
|
var pica = new Pica();
|
|
14850
14850
|
|
|
14851
|
-
var
|
|
14852
|
-
|
|
14853
|
-
|
|
14851
|
+
var dbg = function dbg() {
|
|
14852
|
+
var _console;
|
|
14853
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14854
|
+
args[_key] = arguments[_key];
|
|
14855
|
+
}
|
|
14856
|
+
return (_console = console).log.apply(_console, ['[VIDEO_FIRST_FRAME]'].concat(args));
|
|
14857
|
+
};
|
|
14858
|
+
var toHex = function toHex(bytes) {
|
|
14859
|
+
return Array.from(bytes).map(function (b) {
|
|
14860
|
+
return b.toString(16).padStart(2, '0');
|
|
14861
|
+
}).join(' ');
|
|
14862
|
+
};
|
|
14863
|
+
var NATIVE_VIDEO_TYPES = new Set(['video/mp4', 'video/webm', 'video/ogg']);
|
|
14864
|
+
var findFourccs = function findFourccs(bytes, fourccs) {
|
|
14865
|
+
var found = [];
|
|
14866
|
+
for (var _iterator = _createForOfIteratorHelperLoose(fourccs), _step; !(_step = _iterator()).done;) {
|
|
14867
|
+
var cc = _step.value;
|
|
14868
|
+
var c0 = cc.charCodeAt(0);
|
|
14869
|
+
var c1 = cc.charCodeAt(1);
|
|
14870
|
+
var c2 = cc.charCodeAt(2);
|
|
14871
|
+
var c3 = cc.charCodeAt(3);
|
|
14872
|
+
for (var i = 0; i <= bytes.length - 4; i++) {
|
|
14873
|
+
if (bytes[i] === c0 && bytes[i + 1] === c1 && bytes[i + 2] === c2 && bytes[i + 3] === c3) {
|
|
14874
|
+
found.push(cc);
|
|
14875
|
+
break;
|
|
14876
|
+
}
|
|
14877
|
+
}
|
|
14854
14878
|
}
|
|
14879
|
+
return found;
|
|
14880
|
+
};
|
|
14881
|
+
var VIDEO_CODEC_FOURCCS = ['avc1', 'avc3', 'hvc1', 'hev1', 'av01', 'vp09', 'mp4v', 'apcn', 'apch', 'ap4h'];
|
|
14882
|
+
var isQuickTimeContainer = function isQuickTimeContainer(info) {
|
|
14883
|
+
return info.isoBrand === 'qt ';
|
|
14884
|
+
};
|
|
14885
|
+
var inspectVideoBlob = function inspectVideoBlob(blob) {
|
|
14855
14886
|
try {
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
URL.revokeObjectURL(video.src);
|
|
14887
|
+
var info = {
|
|
14888
|
+
mimeType: null,
|
|
14889
|
+
isoBrand: null,
|
|
14890
|
+
codecs: []
|
|
14891
|
+
};
|
|
14892
|
+
return Promise.resolve(_catch(function () {
|
|
14893
|
+
return Promise.resolve(blob.slice(0, 16).arrayBuffer()).then(function (_blob$slice$arrayBuff) {
|
|
14894
|
+
var _exit = false;
|
|
14895
|
+
function _temp4(_result) {
|
|
14896
|
+
if (_exit) return _result;
|
|
14897
|
+
if (head.length >= 4 && head[0] === 0x1a && head[1] === 0x45 && head[2] === 0xdf && head[3] === 0xa3) {
|
|
14898
|
+
dbg('sniff: EBML (webm/mkv) detected');
|
|
14899
|
+
info.mimeType = 'video/webm';
|
|
14900
|
+
return info;
|
|
14871
14901
|
}
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
canvas.toBlob(function (blob) {
|
|
14893
|
-
if (!blob) {
|
|
14894
|
-
cleanup();
|
|
14895
|
-
resolve(null);
|
|
14896
|
-
return;
|
|
14902
|
+
if (head.length >= 4 && head[0] === 0x4f && head[1] === 0x67 && head[2] === 0x67 && head[3] === 0x53) {
|
|
14903
|
+
dbg('sniff: Ogg detected');
|
|
14904
|
+
info.mimeType = 'video/ogg';
|
|
14905
|
+
return info;
|
|
14906
|
+
}
|
|
14907
|
+
dbg('sniff: unknown container');
|
|
14908
|
+
return info;
|
|
14909
|
+
}
|
|
14910
|
+
var head = new Uint8Array(_blob$slice$arrayBuff);
|
|
14911
|
+
dbg('sniff: first bytes =', toHex(head));
|
|
14912
|
+
var _temp3 = function () {
|
|
14913
|
+
if (head.length >= 8 && head[4] === 0x66 && head[5] === 0x74 && head[6] === 0x79 && head[7] === 0x70) {
|
|
14914
|
+
info.mimeType = 'video/mp4';
|
|
14915
|
+
info.isoBrand = String.fromCharCode(head[8] || 0, head[9] || 0, head[10] || 0, head[11] || 0);
|
|
14916
|
+
var scanSize = 512 * 1024;
|
|
14917
|
+
return Promise.resolve(blob.slice(0, Math.min(scanSize, blob.size)).arrayBuffer()).then(function (_blob$slice$arrayBuff2) {
|
|
14918
|
+
function _temp2() {
|
|
14919
|
+
dbg('sniff: ISO-BMFF, major brand =', JSON.stringify(info.isoBrand), 'codecs =', info.codecs.join(',') || 'none-found');
|
|
14920
|
+
_exit = true;
|
|
14921
|
+
return info;
|
|
14897
14922
|
}
|
|
14898
|
-
var
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
|
|
14908
|
-
|
|
14923
|
+
var headChunk = new Uint8Array(_blob$slice$arrayBuff2);
|
|
14924
|
+
info.codecs = findFourccs(headChunk, VIDEO_CODEC_FOURCCS);
|
|
14925
|
+
var _temp = function () {
|
|
14926
|
+
if (!info.codecs.length && blob.size > scanSize) {
|
|
14927
|
+
return Promise.resolve(blob.slice(Math.max(0, blob.size - scanSize)).arrayBuffer()).then(function (_blob$slice$arrayBuff3) {
|
|
14928
|
+
var tailChunk = new Uint8Array(_blob$slice$arrayBuff3);
|
|
14929
|
+
info.codecs = findFourccs(tailChunk, VIDEO_CODEC_FOURCCS);
|
|
14930
|
+
});
|
|
14931
|
+
}
|
|
14932
|
+
}();
|
|
14933
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
14934
|
+
});
|
|
14909
14935
|
}
|
|
14910
|
-
};
|
|
14911
|
-
|
|
14912
|
-
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14936
|
+
}();
|
|
14937
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
14938
|
+
});
|
|
14939
|
+
}, function (error) {
|
|
14940
|
+
log.error('Failed to sniff video container:', error);
|
|
14941
|
+
return info;
|
|
14942
|
+
}));
|
|
14943
|
+
} catch (e) {
|
|
14944
|
+
return Promise.reject(e);
|
|
14945
|
+
}
|
|
14946
|
+
};
|
|
14947
|
+
var isFirefox = function isFirefox() {
|
|
14948
|
+
return typeof navigator !== 'undefined' && /firefox/i.test(navigator.userAgent);
|
|
14949
|
+
};
|
|
14950
|
+
|
|
14951
|
+
var dbg$1 = function dbg() {
|
|
14952
|
+
var _console;
|
|
14953
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14954
|
+
args[_key] = arguments[_key];
|
|
14955
|
+
}
|
|
14956
|
+
return (_console = console).log.apply(_console, ['[VIDEO_FIRST_FRAME]'].concat(args));
|
|
14957
|
+
};
|
|
14958
|
+
var REMUX_MAX_BYTES = 200 * 1024 * 1024;
|
|
14959
|
+
var remuxCounter = 0;
|
|
14960
|
+
var remuxToMp4 = function remuxToMp4(blob) {
|
|
14961
|
+
try {
|
|
14962
|
+
if (blob.size > REMUX_MAX_BYTES) {
|
|
14963
|
+
dbg$1('remux: skipped, file too large:', blob.size);
|
|
14964
|
+
log.warn('remuxToMp4: file too large to remux in browser:', blob.size);
|
|
14965
|
+
return Promise.resolve(null);
|
|
14966
|
+
}
|
|
14967
|
+
var id = Date.now() + "_" + remuxCounter++;
|
|
14968
|
+
var inputName = "remux_" + id + "_in.mov";
|
|
14969
|
+
var outputName = "remux_" + id + "_out.mp4";
|
|
14970
|
+
var ffmpeg = null;
|
|
14971
|
+
return Promise.resolve(_finallyRethrows(function () {
|
|
14972
|
+
return _catch(function () {
|
|
14973
|
+
dbg$1('remux: starting ffmpeg -c copy remux, size =', blob.size);
|
|
14974
|
+
return Promise.resolve(Promise.all([Promise.resolve().then(function () { return audioConversion; }), import('@ffmpeg/util')])).then(function (_ref) {
|
|
14975
|
+
var initFFmpeg = _ref[0].initFFmpeg,
|
|
14976
|
+
fetchFile = _ref[1].fetchFile;
|
|
14977
|
+
return Promise.resolve(initFFmpeg()).then(function (_initFFmpeg) {
|
|
14978
|
+
ffmpeg = _initFFmpeg;
|
|
14979
|
+
var _ffmpeg = ffmpeg,
|
|
14980
|
+
_writeFile = _ffmpeg.writeFile;
|
|
14981
|
+
return Promise.resolve(fetchFile(blob)).then(function (_fetchFile) {
|
|
14982
|
+
return Promise.resolve(_writeFile.call(_ffmpeg, inputName, _fetchFile)).then(function () {
|
|
14983
|
+
return Promise.resolve(ffmpeg.exec(['-i', inputName, '-c', 'copy', '-movflags', '+faststart', outputName])).then(function () {
|
|
14984
|
+
return Promise.resolve(ffmpeg.readFile(outputName)).then(function (data) {
|
|
14985
|
+
var bytes;
|
|
14986
|
+
if (data instanceof Uint8Array) {
|
|
14987
|
+
bytes = data;
|
|
14988
|
+
} else if (typeof data === 'string') {
|
|
14989
|
+
var binaryString = atob(data);
|
|
14990
|
+
bytes = new Uint8Array(binaryString.length);
|
|
14991
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
14992
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
14993
|
+
}
|
|
14994
|
+
} else {
|
|
14995
|
+
bytes = new Uint8Array(data);
|
|
14996
|
+
}
|
|
14997
|
+
if (!bytes.length) {
|
|
14998
|
+
dbg$1('remux: ffmpeg produced empty output');
|
|
14999
|
+
return null;
|
|
15000
|
+
}
|
|
15001
|
+
var arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
15002
|
+
dbg$1('remux: done, output size =', bytes.length);
|
|
15003
|
+
return new Blob([arrayBuffer], {
|
|
15004
|
+
type: 'video/mp4'
|
|
15005
|
+
});
|
|
15006
|
+
});
|
|
15007
|
+
});
|
|
15008
|
+
});
|
|
15009
|
+
});
|
|
15010
|
+
});
|
|
15011
|
+
});
|
|
15012
|
+
}, function (error) {
|
|
15013
|
+
dbg$1('remux: FAILED', error);
|
|
15014
|
+
log.error('remuxToMp4: remux failed:', error);
|
|
15015
|
+
return null;
|
|
15016
|
+
});
|
|
15017
|
+
}, function (_wasThrown, _result) {
|
|
15018
|
+
function _temp5() {
|
|
15019
|
+
if (_wasThrown) throw _result;
|
|
15020
|
+
return _result;
|
|
15021
|
+
}
|
|
15022
|
+
var _temp4 = function () {
|
|
15023
|
+
if (ffmpeg) {
|
|
15024
|
+
var _temp3 = function _temp3() {
|
|
15025
|
+
var _temp = _catch(function () {
|
|
15026
|
+
return Promise.resolve(ffmpeg.deleteFile(outputName)).then(function () {});
|
|
15027
|
+
}, function () {});
|
|
15028
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
14938
15029
|
};
|
|
15030
|
+
var _temp2 = _catch(function () {
|
|
15031
|
+
return Promise.resolve(ffmpeg.deleteFile(inputName)).then(function () {});
|
|
15032
|
+
}, function () {});
|
|
15033
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
15034
|
+
}
|
|
15035
|
+
}();
|
|
15036
|
+
return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
|
|
15037
|
+
}));
|
|
15038
|
+
} catch (e) {
|
|
15039
|
+
return Promise.reject(e);
|
|
15040
|
+
}
|
|
15041
|
+
};
|
|
15042
|
+
var remuxVideoFileForUpload = function remuxVideoFileForUpload(file) {
|
|
15043
|
+
try {
|
|
15044
|
+
return Promise.resolve(_catch(function () {
|
|
15045
|
+
return Promise.resolve(inspectVideoBlob(file)).then(function (info) {
|
|
15046
|
+
if (!isQuickTimeContainer(info)) {
|
|
15047
|
+
return file;
|
|
15048
|
+
}
|
|
15049
|
+
dbg$1('upload: QuickTime file picked, remuxing before upload:', file.name);
|
|
15050
|
+
return Promise.resolve(remuxToMp4(file)).then(function (remuxed) {
|
|
15051
|
+
if (!remuxed) {
|
|
15052
|
+
log.warn('remuxVideoFileForUpload: remux failed, uploading original file');
|
|
15053
|
+
return file;
|
|
15054
|
+
}
|
|
15055
|
+
var newName = /\.(mov|qt)$/i.test(file.name) ? file.name.replace(/\.(mov|qt)$/i, '.mp4') : file.name + ".mp4";
|
|
15056
|
+
return new File([remuxed], newName, {
|
|
15057
|
+
type: 'video/mp4',
|
|
15058
|
+
lastModified: file.lastModified
|
|
15059
|
+
});
|
|
15060
|
+
});
|
|
15061
|
+
});
|
|
15062
|
+
}, function (error) {
|
|
15063
|
+
log.error('remuxVideoFileForUpload failed, uploading original file:', error);
|
|
15064
|
+
return file;
|
|
15065
|
+
}));
|
|
15066
|
+
} catch (e) {
|
|
15067
|
+
return Promise.reject(e);
|
|
15068
|
+
}
|
|
15069
|
+
};
|
|
15070
|
+
var ensurePlayableVideoBlob = function ensurePlayableVideoBlob(blob) {
|
|
15071
|
+
try {
|
|
15072
|
+
return Promise.resolve(_catch(function () {
|
|
15073
|
+
return isFirefox() ? Promise.resolve(inspectVideoBlob(blob)).then(function (info) {
|
|
15074
|
+
if (!isQuickTimeContainer(info)) {
|
|
15075
|
+
return blob;
|
|
15076
|
+
}
|
|
15077
|
+
dbg$1('download: QuickTime blob in Firefox, remuxing for playback');
|
|
15078
|
+
return Promise.resolve(remuxToMp4(blob)).then(function (remuxed) {
|
|
15079
|
+
return remuxed || blob;
|
|
15080
|
+
});
|
|
15081
|
+
}) : blob;
|
|
15082
|
+
}, function (error) {
|
|
15083
|
+
log.error('ensurePlayableVideoBlob failed, using original blob:', error);
|
|
15084
|
+
return blob;
|
|
15085
|
+
}));
|
|
15086
|
+
} catch (e) {
|
|
15087
|
+
return Promise.reject(e);
|
|
15088
|
+
}
|
|
15089
|
+
};
|
|
15090
|
+
|
|
15091
|
+
var getFrame = function getFrame(videoSrc, _time) {
|
|
15092
|
+
try {
|
|
15093
|
+
if (!videoSrc) {
|
|
15094
|
+
throw new Error('src not found');
|
|
15095
|
+
}
|
|
15096
|
+
return Promise.resolve(getVideoFirstFrame(videoSrc)).then(function (frameResult) {
|
|
15097
|
+
if (!frameResult) {
|
|
15098
|
+
throw new Error('Failed to extract video frame');
|
|
15099
|
+
}
|
|
15100
|
+
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
15101
|
+
origWidth = frameResult.width,
|
|
15102
|
+
origHeight = frameResult.height;
|
|
15103
|
+
var duration = Number(frameResult.duration.toFixed(0));
|
|
15104
|
+
var _calculateSize = calculateSize(origWidth, origHeight, 100, 100),
|
|
15105
|
+
newWidth = _calculateSize[0],
|
|
15106
|
+
newHeight = _calculateSize[1];
|
|
15107
|
+
return new Promise(function (resolve, reject) {
|
|
15108
|
+
var img = document.createElement('img');
|
|
15109
|
+
img.onload = function () {
|
|
15110
|
+
var canvas = document.createElement('canvas');
|
|
15111
|
+
canvas.width = newWidth;
|
|
15112
|
+
canvas.height = newHeight;
|
|
15113
|
+
var ctx = canvas.getContext('2d');
|
|
15114
|
+
if (!ctx) {
|
|
15115
|
+
URL.revokeObjectURL(frameBlobUrl);
|
|
15116
|
+
reject(new Error('Failed to get canvas context'));
|
|
15117
|
+
return;
|
|
15118
|
+
}
|
|
15119
|
+
ctx.drawImage(img, 0, 0, newWidth, newHeight);
|
|
15120
|
+
var pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
15121
|
+
var binaryThumbHash = rgbaToThumbHash(pixels.width, pixels.height, pixels.data);
|
|
15122
|
+
var thumb = binaryToBase64(binaryThumbHash);
|
|
15123
|
+
URL.revokeObjectURL(frameBlobUrl);
|
|
15124
|
+
resolve({
|
|
15125
|
+
thumb: thumb,
|
|
15126
|
+
width: origWidth,
|
|
15127
|
+
height: origHeight,
|
|
15128
|
+
duration: duration
|
|
15129
|
+
});
|
|
14939
15130
|
};
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
resolve(null);
|
|
15131
|
+
img.onerror = function () {
|
|
15132
|
+
URL.revokeObjectURL(frameBlobUrl);
|
|
15133
|
+
reject(new Error('Failed to load frame image'));
|
|
14944
15134
|
};
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
15135
|
+
img.src = frameBlobUrl;
|
|
15136
|
+
});
|
|
15137
|
+
});
|
|
15138
|
+
} catch (e) {
|
|
15139
|
+
return Promise.reject(e);
|
|
15140
|
+
}
|
|
15141
|
+
};
|
|
15142
|
+
var getVideoFirstFrame = function getVideoFirstFrame(videoSrc, maxWidth, maxHeight, quality) {
|
|
15143
|
+
if (quality === void 0) {
|
|
15144
|
+
quality = 0.8;
|
|
15145
|
+
}
|
|
15146
|
+
try {
|
|
15147
|
+
var _exit3 = false;
|
|
15148
|
+
return Promise.resolve(_catch(function () {
|
|
15149
|
+
function _temp0(_result3) {
|
|
15150
|
+
var _exit4 = false;
|
|
15151
|
+
if (_exit3) return _result3;
|
|
15152
|
+
function _temp8(_result4) {
|
|
15153
|
+
if (_exit4) return _result4;
|
|
15154
|
+
dbg$2('source: remote URL —', videoSrc.slice(0, 150));
|
|
15155
|
+
return Promise.resolve(extractFrameFromUrl(videoSrc, maxWidth, maxHeight, quality)).then(function (direct) {
|
|
15156
|
+
if (direct) {
|
|
15157
|
+
return direct;
|
|
15158
|
+
}
|
|
15159
|
+
dbg$2('source: direct remote load failed, retrying via fetch + relabel');
|
|
15160
|
+
return _catch(function () {
|
|
15161
|
+
return Promise.resolve(fetch(videoSrc)).then(function (response) {
|
|
15162
|
+
return Promise.resolve(response.blob()).then(function (blob) {
|
|
15163
|
+
dbg$2('source: remote fetched, Content-Type =', JSON.stringify(response.headers.get('content-type')), 'blob type =', JSON.stringify(blob.type), 'size =', blob.size);
|
|
15164
|
+
return Promise.resolve(_extractFrameFromBlob2(blob, maxWidth, maxHeight, quality));
|
|
15165
|
+
});
|
|
15166
|
+
});
|
|
15167
|
+
}, function (error) {
|
|
15168
|
+
dbg$2('source: remote fetch retry FAILED', error);
|
|
15169
|
+
log.error('getVideoFirstFrame: fetch retry failed:', error);
|
|
15170
|
+
return null;
|
|
15171
|
+
});
|
|
15172
|
+
});
|
|
15173
|
+
}
|
|
15174
|
+
var _temp7 = function () {
|
|
15175
|
+
if (videoSrc.startsWith('blob:')) {
|
|
15176
|
+
dbg$2('source: blob URL string —', videoSrc.slice(0, 100));
|
|
15177
|
+
return _catch(function () {
|
|
15178
|
+
return Promise.resolve(fetch(videoSrc)).then(function (_fetch) {
|
|
15179
|
+
return Promise.resolve(_fetch.blob()).then(function (blob) {
|
|
15180
|
+
dbg$2('source: blob URL re-fetched, type =', JSON.stringify(blob.type), 'size =', blob.size);
|
|
15181
|
+
return Promise.resolve(_extractFrameFromBlob2(blob, maxWidth, maxHeight, quality)).then(function (_await$_extractFrameF2) {
|
|
15182
|
+
_exit4 = true;
|
|
15183
|
+
return _await$_extractFrameF2;
|
|
15184
|
+
});
|
|
15185
|
+
});
|
|
15186
|
+
});
|
|
15187
|
+
}, function (error) {
|
|
15188
|
+
dbg$2('source: blob URL re-fetch FAILED, falling back to direct', error);
|
|
15189
|
+
log.warn('getVideoFirstFrame: failed to re-fetch blob url, trying directly', error);
|
|
15190
|
+
return Promise.resolve(extractFrameFromUrl(videoSrc, maxWidth, maxHeight, quality)).then(function (_await$extractFrameFr) {
|
|
15191
|
+
_exit4 = true;
|
|
15192
|
+
return _await$extractFrameFr;
|
|
15193
|
+
});
|
|
15194
|
+
});
|
|
15195
|
+
}
|
|
15196
|
+
}();
|
|
15197
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
14948
15198
|
}
|
|
15199
|
+
var _temp9 = function () {
|
|
15200
|
+
if (videoSrc instanceof Blob) {
|
|
15201
|
+
dbg$2('source: Blob, type =', JSON.stringify(videoSrc.type), 'size =', videoSrc.size);
|
|
15202
|
+
return Promise.resolve(_extractFrameFromBlob2(videoSrc, maxWidth, maxHeight, quality)).then(function (_await$_extractFrameF) {
|
|
15203
|
+
_exit3 = true;
|
|
15204
|
+
return _await$_extractFrameF;
|
|
15205
|
+
});
|
|
15206
|
+
}
|
|
15207
|
+
}();
|
|
15208
|
+
return _temp9 && _temp9.then ? _temp9.then(_temp0) : _temp0(_temp9);
|
|
15209
|
+
}, function (error) {
|
|
15210
|
+
log.error('Error in getVideoFirstFrame:', error);
|
|
15211
|
+
return null;
|
|
14949
15212
|
}));
|
|
14950
15213
|
} catch (e) {
|
|
14951
15214
|
return Promise.reject(e);
|
|
14952
15215
|
}
|
|
14953
15216
|
};
|
|
14954
|
-
var
|
|
15217
|
+
var dbg$2 = function dbg() {
|
|
15218
|
+
var _console;
|
|
15219
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15220
|
+
args[_key] = arguments[_key];
|
|
15221
|
+
}
|
|
15222
|
+
return (_console = console).log.apply(_console, ['[VIDEO_FIRST_FRAME]'].concat(args));
|
|
15223
|
+
};
|
|
15224
|
+
var normalizeVideoBlob = function normalizeVideoBlob(blob) {
|
|
14955
15225
|
try {
|
|
14956
|
-
return Promise.resolve(
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
15226
|
+
return Promise.resolve(inspectVideoBlob(blob)).then(function (info) {
|
|
15227
|
+
var baseType = (blob.type || '').split(';')[0].trim().toLowerCase();
|
|
15228
|
+
if (NATIVE_VIDEO_TYPES.has(baseType)) {
|
|
15229
|
+
dbg$2('normalize: declared type is native:', JSON.stringify(blob.type), '→', JSON.stringify(baseType));
|
|
15230
|
+
return {
|
|
15231
|
+
safeBlob: baseType === blob.type ? blob : new Blob([blob], {
|
|
15232
|
+
type: baseType
|
|
15233
|
+
}),
|
|
15234
|
+
info: info
|
|
15235
|
+
};
|
|
14960
15236
|
}
|
|
15237
|
+
var relabeledType = info.mimeType || 'video/mp4';
|
|
15238
|
+
dbg$2('normalize: declared', JSON.stringify(blob.type), '→ relabeled to', JSON.stringify(relabeledType));
|
|
15239
|
+
return {
|
|
15240
|
+
safeBlob: new Blob([blob], {
|
|
15241
|
+
type: relabeledType
|
|
15242
|
+
}),
|
|
15243
|
+
info: info
|
|
15244
|
+
};
|
|
15245
|
+
});
|
|
15246
|
+
} catch (e) {
|
|
15247
|
+
return Promise.reject(e);
|
|
15248
|
+
}
|
|
15249
|
+
};
|
|
15250
|
+
var FRAME_LOAD_TIMEOUT_MS = 8000;
|
|
15251
|
+
var READY_STATES = ['HAVE_NOTHING', 'HAVE_METADATA', 'HAVE_CURRENT_DATA', 'HAVE_FUTURE_DATA', 'HAVE_ENOUGH_DATA'];
|
|
15252
|
+
var NETWORK_STATES = ['NETWORK_EMPTY', 'NETWORK_IDLE', 'NETWORK_LOADING', 'NETWORK_NO_SOURCE'];
|
|
15253
|
+
var describeVideoState = function describeVideoState(video) {
|
|
15254
|
+
var buffered = 'none';
|
|
15255
|
+
try {
|
|
15256
|
+
var ranges = [];
|
|
15257
|
+
for (var i = 0; i < video.buffered.length; i++) {
|
|
15258
|
+
ranges.push(video.buffered.start(i).toFixed(2) + "-" + video.buffered.end(i).toFixed(2));
|
|
15259
|
+
}
|
|
15260
|
+
buffered = ranges.join(',') || 'empty';
|
|
15261
|
+
} catch (e) {
|
|
15262
|
+
buffered = 'unavailable';
|
|
15263
|
+
}
|
|
15264
|
+
return "readyState=" + (READY_STATES[video.readyState] || video.readyState) + " " + ("networkState=" + (NETWORK_STATES[video.networkState] || video.networkState) + " ") + ("currentTime=" + video.currentTime + " duration=" + video.duration + " ") + ("videoWidth=" + video.videoWidth + " videoHeight=" + video.videoHeight + " ") + ("buffered=[" + buffered + "] error=" + (video.error ? video.error.code + ":" + video.error.message : 'null'));
|
|
15265
|
+
};
|
|
15266
|
+
var extractFrameFromUrl = function extractFrameFromUrl(srcUrl, maxWidth, maxHeight, quality) {
|
|
15267
|
+
if (quality === void 0) {
|
|
15268
|
+
quality = 0.8;
|
|
15269
|
+
}
|
|
15270
|
+
return new Promise(function (resolve) {
|
|
15271
|
+
try {
|
|
15272
|
+
dbg$2('extract: start, src =', srcUrl.slice(0, 100));
|
|
14961
15273
|
var video = document.createElement('video');
|
|
14962
|
-
video.preload = '
|
|
15274
|
+
video.preload = 'auto';
|
|
14963
15275
|
video.muted = true;
|
|
14964
15276
|
video.setAttribute('playsinline', 'true');
|
|
14965
|
-
|
|
14966
|
-
|
|
15277
|
+
if (!srcUrl.startsWith('blob:') && !srcUrl.startsWith('data:')) {
|
|
15278
|
+
video.crossOrigin = 'anonymous';
|
|
15279
|
+
}
|
|
15280
|
+
video.style.position = 'fixed';
|
|
15281
|
+
video.style.bottom = '0';
|
|
15282
|
+
video.style.left = '0';
|
|
15283
|
+
video.style.width = '2px';
|
|
15284
|
+
video.style.height = '2px';
|
|
15285
|
+
video.style.opacity = '0';
|
|
15286
|
+
video.style.pointerEvents = 'none';
|
|
15287
|
+
video.style.zIndex = '-1';
|
|
15288
|
+
document.body.appendChild(video);
|
|
15289
|
+
var settled = false;
|
|
15290
|
+
var finishOnce = function finishOnce(result) {
|
|
15291
|
+
if (settled) return;
|
|
15292
|
+
settled = true;
|
|
15293
|
+
clearTimeout(stallTimer);
|
|
15294
|
+
if (video.parentNode) {
|
|
15295
|
+
video.parentNode.removeChild(video);
|
|
15296
|
+
}
|
|
15297
|
+
dbg$2('extract: finished,', result ? 'SUCCESS' : 'NULL');
|
|
15298
|
+
resolve(result);
|
|
15299
|
+
};
|
|
15300
|
+
var stallTimer = setTimeout(function () {
|
|
15301
|
+
dbg$2('extract: TIMEOUT —', describeVideoState(video));
|
|
15302
|
+
log.warn('getVideoFirstFrame: timed out waiting for video to load');
|
|
15303
|
+
finishOnce(null);
|
|
15304
|
+
}, FRAME_LOAD_TIMEOUT_MS);
|
|
15305
|
+
var extractFrame = function extractFrame() {
|
|
14967
15306
|
try {
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
height: origHeight,
|
|
15001
|
-
duration: duration
|
|
15002
|
-
});
|
|
15003
|
-
};
|
|
15004
|
-
img.onerror = function () {
|
|
15005
|
-
URL.revokeObjectURL(frameResult.frameBlobUrl);
|
|
15006
|
-
reject(new Error('Failed to load frame image'));
|
|
15007
|
-
};
|
|
15008
|
-
img.src = frameResult.frameBlobUrl;
|
|
15307
|
+
dbg$2('extract: extractFrame,', describeVideoState(video));
|
|
15308
|
+
if (video.videoWidth === 0 || video.videoHeight === 0) {
|
|
15309
|
+
finishOnce(null);
|
|
15310
|
+
return;
|
|
15311
|
+
}
|
|
15312
|
+
var width = video.videoWidth;
|
|
15313
|
+
var height = video.videoHeight;
|
|
15314
|
+
var duration = Number.isFinite(video.duration) ? video.duration : 0;
|
|
15315
|
+
var canvasWidth = maxWidth || width / 2;
|
|
15316
|
+
var canvasHeight = maxHeight || height / 2;
|
|
15317
|
+
var canvas = document.createElement('canvas');
|
|
15318
|
+
canvas.width = canvasWidth;
|
|
15319
|
+
canvas.height = canvasHeight;
|
|
15320
|
+
var ctx = canvas.getContext('2d');
|
|
15321
|
+
if (!ctx) {
|
|
15322
|
+
finishOnce(null);
|
|
15323
|
+
return;
|
|
15324
|
+
}
|
|
15325
|
+
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
15326
|
+
canvas.toBlob(function (blob) {
|
|
15327
|
+
if (!blob) {
|
|
15328
|
+
dbg$2('extract: canvas.toBlob returned null');
|
|
15329
|
+
finishOnce(null);
|
|
15330
|
+
return;
|
|
15331
|
+
}
|
|
15332
|
+
var frameBlobUrl = URL.createObjectURL(blob);
|
|
15333
|
+
finishOnce({
|
|
15334
|
+
frameBlobUrl: frameBlobUrl,
|
|
15335
|
+
blob: blob,
|
|
15336
|
+
width: width,
|
|
15337
|
+
height: height,
|
|
15338
|
+
duration: duration
|
|
15009
15339
|
});
|
|
15010
|
-
},
|
|
15011
|
-
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
|
|
15340
|
+
}, 'image/jpeg', quality);
|
|
15341
|
+
} catch (error) {
|
|
15342
|
+
dbg$2('extract: extractFrame threw', error);
|
|
15343
|
+
log.error('Error extracting video frame:', error);
|
|
15344
|
+
finishOnce(null);
|
|
15015
15345
|
}
|
|
15016
15346
|
};
|
|
15347
|
+
video.addEventListener('loadstart', function () {
|
|
15348
|
+
return dbg$2('event: loadstart,', describeVideoState(video));
|
|
15349
|
+
});
|
|
15350
|
+
video.addEventListener('loadeddata', function () {
|
|
15351
|
+
return dbg$2('event: loadeddata,', describeVideoState(video));
|
|
15352
|
+
});
|
|
15353
|
+
video.addEventListener('canplay', function () {
|
|
15354
|
+
return dbg$2('event: canplay,', describeVideoState(video));
|
|
15355
|
+
});
|
|
15356
|
+
video.addEventListener('canplaythrough', function () {
|
|
15357
|
+
return dbg$2('event: canplaythrough');
|
|
15358
|
+
});
|
|
15359
|
+
video.addEventListener('seeking', function () {
|
|
15360
|
+
return dbg$2('event: seeking, currentTime =', video.currentTime);
|
|
15361
|
+
});
|
|
15362
|
+
video.addEventListener('stalled', function () {
|
|
15363
|
+
return dbg$2('event: stalled,', describeVideoState(video));
|
|
15364
|
+
});
|
|
15365
|
+
video.addEventListener('suspend', function () {
|
|
15366
|
+
return dbg$2('event: suspend,', describeVideoState(video));
|
|
15367
|
+
});
|
|
15368
|
+
video.addEventListener('waiting', function () {
|
|
15369
|
+
return dbg$2('event: waiting,', describeVideoState(video));
|
|
15370
|
+
});
|
|
15371
|
+
video.addEventListener('emptied', function () {
|
|
15372
|
+
return dbg$2('event: emptied,', describeVideoState(video));
|
|
15373
|
+
});
|
|
15374
|
+
video.onloadedmetadata = function () {
|
|
15375
|
+
dbg$2('event: loadedmetadata,', describeVideoState(video));
|
|
15376
|
+
video.currentTime = 0.01;
|
|
15377
|
+
video.onseeked = function () {
|
|
15378
|
+
dbg$2('event: seeked,', describeVideoState(video));
|
|
15379
|
+
video.onseeked = null;
|
|
15380
|
+
var capture = function capture() {
|
|
15381
|
+
return requestAnimationFrame(extractFrame);
|
|
15382
|
+
};
|
|
15383
|
+
video.play().then(function () {
|
|
15384
|
+
dbg$2('play(): resolved');
|
|
15385
|
+
var done = false;
|
|
15386
|
+
var _finish = function finish() {
|
|
15387
|
+
if (done) return;
|
|
15388
|
+
done = true;
|
|
15389
|
+
video.removeEventListener('timeupdate', _finish);
|
|
15390
|
+
video.removeEventListener('ended', _finish);
|
|
15391
|
+
video.pause();
|
|
15392
|
+
capture();
|
|
15393
|
+
};
|
|
15394
|
+
video.addEventListener('timeupdate', _finish);
|
|
15395
|
+
video.addEventListener('ended', _finish);
|
|
15396
|
+
setTimeout(_finish, 500);
|
|
15397
|
+
})["catch"](function (err) {
|
|
15398
|
+
dbg$2('play(): rejected —', err === null || err === void 0 ? void 0 : err.name, err === null || err === void 0 ? void 0 : err.message);
|
|
15399
|
+
capture();
|
|
15400
|
+
});
|
|
15401
|
+
};
|
|
15402
|
+
};
|
|
15017
15403
|
video.onerror = function () {
|
|
15018
|
-
|
|
15404
|
+
dbg$2('event: error,', describeVideoState(video));
|
|
15405
|
+
log.warn('getVideoFirstFrame: video failed to load', video.error);
|
|
15406
|
+
finishOnce(null);
|
|
15019
15407
|
};
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
|
|
15408
|
+
video.onabort = function () {
|
|
15409
|
+
dbg$2('event: abort,', describeVideoState(video));
|
|
15410
|
+
finishOnce(null);
|
|
15411
|
+
};
|
|
15412
|
+
video.src = srcUrl;
|
|
15413
|
+
dbg$2('extract: src assigned,', describeVideoState(video));
|
|
15414
|
+
} catch (error) {
|
|
15415
|
+
log.error('Error in extractFrameFromUrl:', error);
|
|
15416
|
+
resolve(null);
|
|
15417
|
+
}
|
|
15418
|
+
});
|
|
15419
|
+
};
|
|
15420
|
+
var DATA_URL_MAX_BYTES = 64 * 1024 * 1024;
|
|
15421
|
+
var blobToDataUrl = function blobToDataUrl(blob) {
|
|
15422
|
+
return new Promise(function (resolve, reject) {
|
|
15423
|
+
var reader = new FileReader();
|
|
15424
|
+
reader.onload = function () {
|
|
15425
|
+
return resolve(reader.result);
|
|
15426
|
+
};
|
|
15427
|
+
reader.onerror = function () {
|
|
15428
|
+
return reject(reader.error);
|
|
15429
|
+
};
|
|
15430
|
+
reader.readAsDataURL(blob);
|
|
15431
|
+
});
|
|
15432
|
+
};
|
|
15433
|
+
var _extractFrameFromBlob2 = function extractFrameFromBlob(blob, maxWidth, maxHeight, quality, allowRemux) {
|
|
15434
|
+
if (quality === void 0) {
|
|
15435
|
+
quality = 0.8;
|
|
15023
15436
|
}
|
|
15437
|
+
if (allowRemux === void 0) {
|
|
15438
|
+
allowRemux = true;
|
|
15439
|
+
}
|
|
15440
|
+
return Promise.resolve(normalizeVideoBlob(blob)).then(function (_ref) {
|
|
15441
|
+
var _exit = false;
|
|
15442
|
+
var safeBlob = _ref.safeBlob,
|
|
15443
|
+
info = _ref.info;
|
|
15444
|
+
function _temp6(_result) {
|
|
15445
|
+
var _exit2 = false;
|
|
15446
|
+
if (_exit) return _result;
|
|
15447
|
+
function _temp4(_result2) {
|
|
15448
|
+
if (_exit2) return _result2;
|
|
15449
|
+
if (safeBlob.size > DATA_URL_MAX_BYTES) {
|
|
15450
|
+
dbg$2('fallback: blob too large for data URL fallback, size =', safeBlob.size);
|
|
15451
|
+
return null;
|
|
15452
|
+
}
|
|
15453
|
+
return _catch(function () {
|
|
15454
|
+
dbg$2('fallback: retrying via data URL, size =', safeBlob.size);
|
|
15455
|
+
return Promise.resolve(blobToDataUrl(safeBlob)).then(function (dataUrl) {
|
|
15456
|
+
return Promise.resolve(extractFrameFromUrl(dataUrl, maxWidth, maxHeight, quality));
|
|
15457
|
+
});
|
|
15458
|
+
}, function (error) {
|
|
15459
|
+
dbg$2('fallback: data URL conversion failed', error);
|
|
15460
|
+
log.error('getVideoFirstFrame: data URL fallback failed:', error);
|
|
15461
|
+
return null;
|
|
15462
|
+
});
|
|
15463
|
+
}
|
|
15464
|
+
var url = URL.createObjectURL(safeBlob);
|
|
15465
|
+
var _temp3 = _finallyRethrows(function () {
|
|
15466
|
+
return Promise.resolve(extractFrameFromUrl(url, maxWidth, maxHeight, quality)).then(function (result) {
|
|
15467
|
+
if (result) {
|
|
15468
|
+
_exit2 = true;
|
|
15469
|
+
return result;
|
|
15470
|
+
}
|
|
15471
|
+
});
|
|
15472
|
+
}, function (_wasThrown, _result2) {
|
|
15473
|
+
URL.revokeObjectURL(url);
|
|
15474
|
+
if (_wasThrown) throw _result2;
|
|
15475
|
+
return _result2;
|
|
15476
|
+
});
|
|
15477
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
15478
|
+
}
|
|
15479
|
+
var _temp5 = function () {
|
|
15480
|
+
if (isQuickTimeContainer(info) && isFirefox()) {
|
|
15481
|
+
if (!allowRemux) {
|
|
15482
|
+
dbg$2('skip: remuxed output is still a QuickTime container — giving up');
|
|
15483
|
+
var _temp = null;
|
|
15484
|
+
_exit = true;
|
|
15485
|
+
return _temp;
|
|
15486
|
+
}
|
|
15487
|
+
dbg$2('skip: QuickTime (qt brand) container — Firefox cannot demux this, remuxing. codecs =', info.codecs.join(',') || '?');
|
|
15488
|
+
return Promise.resolve(remuxToMp4(safeBlob)).then(function (remuxed) {
|
|
15489
|
+
if (!remuxed) {
|
|
15490
|
+
log.warn('getVideoFirstFrame: QuickTime container is not supported by Firefox and remux failed');
|
|
15491
|
+
var _temp2 = null;
|
|
15492
|
+
_exit = true;
|
|
15493
|
+
return _temp2;
|
|
15494
|
+
}
|
|
15495
|
+
var _extractFrameFromBlob = _extractFrameFromBlob2(remuxed, maxWidth, maxHeight, quality, false);
|
|
15496
|
+
_exit = true;
|
|
15497
|
+
return _extractFrameFromBlob;
|
|
15498
|
+
});
|
|
15499
|
+
}
|
|
15500
|
+
}();
|
|
15501
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
15502
|
+
});
|
|
15024
15503
|
};
|
|
15025
15504
|
var compressAndCacheImage = function compressAndCacheImage(url, cacheKey, maxWidth, maxHeight, quality) {
|
|
15026
15505
|
try {
|
|
15027
15506
|
return Promise.resolve(_catch(function () {
|
|
15028
15507
|
return Promise.resolve(fetch(url)).then(function (response) {
|
|
15029
15508
|
return response.ok ? Promise.resolve(response.blob()).then(function (blob) {
|
|
15030
|
-
var
|
|
15031
|
-
function
|
|
15032
|
-
if (
|
|
15509
|
+
var _exit5 = false;
|
|
15510
|
+
function _temp10(_result5) {
|
|
15511
|
+
if (_exit5) return _result5;
|
|
15033
15512
|
setAttachmentToCache(cacheKey, response);
|
|
15034
15513
|
return '';
|
|
15035
15514
|
}
|
|
15036
|
-
var
|
|
15515
|
+
var _temp1 = function () {
|
|
15037
15516
|
if (blob.type.startsWith('image/')) {
|
|
15038
15517
|
var file = new File([blob], 'image.jpeg', {
|
|
15039
15518
|
type: blob.type
|
|
15040
15519
|
});
|
|
15041
|
-
return Promise.resolve(resizeImageWithPica(file, maxWidth || 1280, maxHeight || 1080, quality || 1)).then(function (
|
|
15042
|
-
var compressedBlob =
|
|
15520
|
+
return Promise.resolve(resizeImageWithPica(file, maxWidth || 1280, maxHeight || 1080, quality || 1)).then(function (_ref2) {
|
|
15521
|
+
var compressedBlob = _ref2.blob;
|
|
15043
15522
|
var returningUrl = compressedBlob ? URL.createObjectURL(compressedBlob) : '';
|
|
15044
15523
|
if (compressedBlob) {
|
|
15045
15524
|
var compressedResponse = new Response(compressedBlob, {
|
|
@@ -15048,13 +15527,13 @@ var compressAndCacheImage = function compressAndCacheImage(url, cacheKey, maxWid
|
|
|
15048
15527
|
}
|
|
15049
15528
|
});
|
|
15050
15529
|
setAttachmentToCache(cacheKey, compressedResponse);
|
|
15051
|
-
|
|
15530
|
+
_exit5 = true;
|
|
15052
15531
|
return returningUrl;
|
|
15053
15532
|
}
|
|
15054
15533
|
});
|
|
15055
15534
|
}
|
|
15056
15535
|
}();
|
|
15057
|
-
return
|
|
15536
|
+
return _temp1 && _temp1.then ? _temp1.then(_temp10) : _temp10(_temp1);
|
|
15058
15537
|
}) : '';
|
|
15059
15538
|
});
|
|
15060
15539
|
}, function (error) {
|
|
@@ -20942,7 +21421,7 @@ function loadMorePollVotes(action) {
|
|
|
20942
21421
|
}
|
|
20943
21422
|
var REFRESH_WINDOW_HALF = 30;
|
|
20944
21423
|
function refreshCacheAroundMessage(action) {
|
|
20945
|
-
var _action$payload0, channelId, messageId, _action$payload0$appl, applyVisibleWindow, connectionState, activeChannelId, activeMessages, activeConfirmedMessages, centerMessageIndex, refreshAnchorId, previousLimit, nextLimit, SceytChatClient, messageQueryBuilder, messageQuery, prevResult, pivotId, nextResult, loadedMessages, firstId, lastId, activeById, changed, filteredPendingMessages, _t53, _t54, _t55;
|
|
21424
|
+
var _action$payload0, channelId, messageId, _action$payload0$appl, applyVisibleWindow, connectionState, activeChannelId, activeMessages, activeConfirmedMessages, centerMessageIndex, refreshAnchorId, previousLimit, nextLimit, SceytChatClient, messageQueryBuilder, messageQuery, prevResult, pivotId, nextResult, loadedMessages, firstId, lastId, currentActiveMessages, currentActiveConfirmedMessages, activeById, changed, filteredPendingMessages, _t53, _t54, _t55;
|
|
20946
21425
|
return _regenerator().w(function (_context63) {
|
|
20947
21426
|
while (1) switch (_context63.p = _context63.n) {
|
|
20948
21427
|
case 0:
|
|
@@ -21044,8 +21523,18 @@ function refreshCacheAroundMessage(action) {
|
|
|
21044
21523
|
_context63.n = 13;
|
|
21045
21524
|
return call(loadOGMetadataForLinkMessages, loadedMessages, true);
|
|
21046
21525
|
case 13:
|
|
21526
|
+
currentActiveMessages = store.getState().MessageReducer.activeChannelMessages || [];
|
|
21527
|
+
currentActiveConfirmedMessages = currentActiveMessages.filter(function (message) {
|
|
21528
|
+
return !!message.id;
|
|
21529
|
+
});
|
|
21530
|
+
if (sameConfirmedWindow(currentActiveConfirmedMessages, activeConfirmedMessages)) {
|
|
21531
|
+
_context63.n = 14;
|
|
21532
|
+
break;
|
|
21533
|
+
}
|
|
21534
|
+
return _context63.a(2);
|
|
21535
|
+
case 14:
|
|
21047
21536
|
if (!sameConfirmedWindow(activeConfirmedMessages, loadedMessages)) {
|
|
21048
|
-
_context63.n =
|
|
21537
|
+
_context63.n = 16;
|
|
21049
21538
|
break;
|
|
21050
21539
|
}
|
|
21051
21540
|
activeById = new Map(activeConfirmedMessages.map(function (currentMessage) {
|
|
@@ -21058,44 +21547,44 @@ function refreshCacheAroundMessage(action) {
|
|
|
21058
21547
|
return JSON.stringify(existing) !== JSON.stringify(loaded);
|
|
21059
21548
|
});
|
|
21060
21549
|
if (!(changed.length > 0)) {
|
|
21061
|
-
_context63.n =
|
|
21550
|
+
_context63.n = 15;
|
|
21062
21551
|
break;
|
|
21063
21552
|
}
|
|
21064
|
-
_context63.n =
|
|
21553
|
+
_context63.n = 15;
|
|
21065
21554
|
return put(patchMessagesAC(changed));
|
|
21066
|
-
case 14:
|
|
21067
|
-
return _context63.a(2);
|
|
21068
21555
|
case 15:
|
|
21556
|
+
return _context63.a(2);
|
|
21557
|
+
case 16:
|
|
21069
21558
|
if (applyVisibleWindow) {
|
|
21070
|
-
_context63.n =
|
|
21559
|
+
_context63.n = 17;
|
|
21071
21560
|
break;
|
|
21072
21561
|
}
|
|
21073
21562
|
return _context63.a(2);
|
|
21074
|
-
case 16:
|
|
21075
|
-
_context63.n = 17;
|
|
21076
|
-
return put(setMessagesAC(JSON.parse(JSON.stringify(loadedMessages)), channelId));
|
|
21077
21563
|
case 17:
|
|
21564
|
+
_context63.n = 18;
|
|
21565
|
+
return put(setMessagesAC(JSON.parse(JSON.stringify(loadedMessages)), channelId));
|
|
21566
|
+
case 18:
|
|
21078
21567
|
filteredPendingMessages = getFilteredPendingMessages(channelId, loadedMessages);
|
|
21079
21568
|
if (!(filteredPendingMessages.length > 0)) {
|
|
21080
|
-
_context63.n =
|
|
21569
|
+
_context63.n = 20;
|
|
21081
21570
|
break;
|
|
21082
21571
|
}
|
|
21083
|
-
_context63.n = 18;
|
|
21084
|
-
return put(addMessagesAC(filteredPendingMessages, MESSAGE_LOAD_DIRECTION.NEXT));
|
|
21085
|
-
case 18:
|
|
21086
21572
|
_context63.n = 19;
|
|
21087
|
-
return
|
|
21573
|
+
return put(addMessagesAC(filteredPendingMessages, MESSAGE_LOAD_DIRECTION.NEXT));
|
|
21088
21574
|
case 19:
|
|
21089
|
-
_context63.n =
|
|
21090
|
-
|
|
21575
|
+
_context63.n = 20;
|
|
21576
|
+
return call(loadOGMetadataForLinkMessages, filteredPendingMessages, true);
|
|
21091
21577
|
case 20:
|
|
21092
|
-
_context63.
|
|
21578
|
+
_context63.n = 22;
|
|
21579
|
+
break;
|
|
21580
|
+
case 21:
|
|
21581
|
+
_context63.p = 21;
|
|
21093
21582
|
_t55 = _context63.v;
|
|
21094
21583
|
log.error('error in refreshCacheAroundMessage', _t55);
|
|
21095
|
-
case
|
|
21584
|
+
case 22:
|
|
21096
21585
|
return _context63.a(2);
|
|
21097
21586
|
}
|
|
21098
|
-
}, _marked57, null, [[0,
|
|
21587
|
+
}, _marked57, null, [[0, 21]]);
|
|
21099
21588
|
}
|
|
21100
21589
|
function MessageSaga() {
|
|
21101
21590
|
return _regenerator().w(function (_context64) {
|
|
@@ -21988,6 +22477,42 @@ var MessageStatusIcon = function MessageStatusIcon(_ref) {
|
|
|
21988
22477
|
});
|
|
21989
22478
|
}
|
|
21990
22479
|
};
|
|
22480
|
+
function extractUrlMatches(text) {
|
|
22481
|
+
var results = [];
|
|
22482
|
+
var protocolRegex = /https?:\/\/\S+/g;
|
|
22483
|
+
var m;
|
|
22484
|
+
while ((m = protocolRegex.exec(text)) !== null) {
|
|
22485
|
+
results.push({
|
|
22486
|
+
text: m[0],
|
|
22487
|
+
url: m[0],
|
|
22488
|
+
index: m.index
|
|
22489
|
+
});
|
|
22490
|
+
}
|
|
22491
|
+
var linkifyResults = new LinkifyIt().match(text);
|
|
22492
|
+
if (linkifyResults) {
|
|
22493
|
+
for (var _iterator = _createForOfIteratorHelperLoose(linkifyResults), _step; !(_step = _iterator()).done;) {
|
|
22494
|
+
var lm = _step.value;
|
|
22495
|
+
if (lm.schema === '') {
|
|
22496
|
+
results.push({
|
|
22497
|
+
text: lm.text,
|
|
22498
|
+
url: lm.url.replace(/^http:\/\//, 'https://'),
|
|
22499
|
+
index: lm.index
|
|
22500
|
+
});
|
|
22501
|
+
}
|
|
22502
|
+
}
|
|
22503
|
+
}
|
|
22504
|
+
results.sort(function (a, b) {
|
|
22505
|
+
return a.index - b.index;
|
|
22506
|
+
});
|
|
22507
|
+
return results.length > 0 ? results.map(function (_ref2) {
|
|
22508
|
+
var text = _ref2.text,
|
|
22509
|
+
url = _ref2.url;
|
|
22510
|
+
return {
|
|
22511
|
+
text: text,
|
|
22512
|
+
url: url
|
|
22513
|
+
};
|
|
22514
|
+
}) : null;
|
|
22515
|
+
}
|
|
21991
22516
|
var linkifyTextPart = function linkifyTextPart(textPart, match, target, isInviteLink, onInviteLinkClick) {
|
|
21992
22517
|
if (target === void 0) {
|
|
21993
22518
|
target = '_blank';
|
|
@@ -22036,26 +22561,25 @@ var linkifyTextPart = function linkifyTextPart(textPart, match, target, isInvite
|
|
|
22036
22561
|
});
|
|
22037
22562
|
return newMessageText || textPart;
|
|
22038
22563
|
};
|
|
22039
|
-
var MessageTextFormat = function MessageTextFormat(
|
|
22040
|
-
var text =
|
|
22041
|
-
message =
|
|
22042
|
-
contactsMap =
|
|
22043
|
-
getFromContacts =
|
|
22044
|
-
isLastMessage =
|
|
22045
|
-
asSampleText =
|
|
22046
|
-
accentColor =
|
|
22047
|
-
textSecondary =
|
|
22048
|
-
onMentionNameClick =
|
|
22049
|
-
shouldOpenUserProfileForMention =
|
|
22050
|
-
unsupportedMessage =
|
|
22051
|
-
|
|
22052
|
-
target =
|
|
22053
|
-
|
|
22054
|
-
isInviteLink =
|
|
22055
|
-
onInviteLinkClick =
|
|
22564
|
+
var MessageTextFormat = function MessageTextFormat(_ref3) {
|
|
22565
|
+
var text = _ref3.text,
|
|
22566
|
+
message = _ref3.message,
|
|
22567
|
+
contactsMap = _ref3.contactsMap,
|
|
22568
|
+
getFromContacts = _ref3.getFromContacts,
|
|
22569
|
+
isLastMessage = _ref3.isLastMessage,
|
|
22570
|
+
asSampleText = _ref3.asSampleText,
|
|
22571
|
+
accentColor = _ref3.accentColor,
|
|
22572
|
+
textSecondary = _ref3.textSecondary,
|
|
22573
|
+
onMentionNameClick = _ref3.onMentionNameClick,
|
|
22574
|
+
shouldOpenUserProfileForMention = _ref3.shouldOpenUserProfileForMention,
|
|
22575
|
+
unsupportedMessage = _ref3.unsupportedMessage,
|
|
22576
|
+
_ref3$target = _ref3.target,
|
|
22577
|
+
target = _ref3$target === void 0 ? '_blank' : _ref3$target,
|
|
22578
|
+
_ref3$isInviteLink = _ref3.isInviteLink,
|
|
22579
|
+
isInviteLink = _ref3$isInviteLink === void 0 ? false : _ref3$isInviteLink,
|
|
22580
|
+
onInviteLinkClick = _ref3.onInviteLinkClick;
|
|
22056
22581
|
try {
|
|
22057
22582
|
var messageText = [];
|
|
22058
|
-
var linkify = new LinkifyIt();
|
|
22059
22583
|
var messageBodyAttributes = message.bodyAttributes && JSON.parse(JSON.stringify(message.bodyAttributes));
|
|
22060
22584
|
if (unsupportedMessage) {
|
|
22061
22585
|
return 'This message is not supported. Update your app to view this message.';
|
|
@@ -22068,12 +22592,12 @@ var MessageTextFormat = function MessageTextFormat(_ref2) {
|
|
|
22068
22592
|
var attributeOffset = attribute.offset;
|
|
22069
22593
|
try {
|
|
22070
22594
|
var firstPart = "" + (textPart ? textPart === null || textPart === void 0 ? void 0 : textPart.substring(nextPartIndex || 0, attributeOffset) : '');
|
|
22071
|
-
var firstPartMatch = firstPart ?
|
|
22595
|
+
var firstPartMatch = firstPart ? extractUrlMatches(firstPart) : null;
|
|
22072
22596
|
if (!isLastMessage && !asSampleText && firstPartMatch) {
|
|
22073
22597
|
firstPart = linkifyTextPart(firstPart, firstPartMatch, target, isInviteLink, onInviteLinkClick);
|
|
22074
22598
|
}
|
|
22075
22599
|
var secondPart = "" + (textPart ? textPart === null || textPart === void 0 ? void 0 : textPart.substring(attributeOffset + attribute.length) : '');
|
|
22076
|
-
var secondPartMatch = secondPart ?
|
|
22600
|
+
var secondPartMatch = secondPart ? extractUrlMatches(secondPart) : null;
|
|
22077
22601
|
if (!isLastMessage && !asSampleText && secondPartMatch) {
|
|
22078
22602
|
secondPart = linkifyTextPart(secondPart, secondPartMatch, target, isInviteLink, onInviteLinkClick);
|
|
22079
22603
|
}
|
|
@@ -22133,7 +22657,7 @@ var MessageTextFormat = function MessageTextFormat(_ref2) {
|
|
|
22133
22657
|
} else {
|
|
22134
22658
|
nextPartIndex = attributeOffset + attribute.length;
|
|
22135
22659
|
var _textPart = "" + text.slice(attributeOffset, attributeOffset + attribute.length);
|
|
22136
|
-
var match =
|
|
22660
|
+
var match = extractUrlMatches(_textPart);
|
|
22137
22661
|
var newTextPart = _textPart;
|
|
22138
22662
|
if (!isLastMessage && !asSampleText && match) {
|
|
22139
22663
|
newTextPart = linkifyTextPart(_textPart, match, target, isInviteLink, onInviteLinkClick);
|
|
@@ -22150,7 +22674,7 @@ var MessageTextFormat = function MessageTextFormat(_ref2) {
|
|
|
22150
22674
|
}
|
|
22151
22675
|
});
|
|
22152
22676
|
} else {
|
|
22153
|
-
var match =
|
|
22677
|
+
var match = extractUrlMatches(text);
|
|
22154
22678
|
if (!isLastMessage && !asSampleText && match) {
|
|
22155
22679
|
messageText = linkifyTextPart(text, match, target, isInviteLink, onInviteLinkClick);
|
|
22156
22680
|
}
|
|
@@ -37145,6 +37669,7 @@ var convertToAac = function convertToAac(file, messageId) {
|
|
|
37145
37669
|
return Promise.reject(e);
|
|
37146
37670
|
}
|
|
37147
37671
|
};
|
|
37672
|
+
var convertMp3ToAac = convertToAac;
|
|
37148
37673
|
var SAFARI_SUPPORTED_TYPES = new Set(['audio/mp4', 'audio/aac', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'audio/aiff']);
|
|
37149
37674
|
var convertAudioForSafari = function convertAudioForSafari(file, messageId) {
|
|
37150
37675
|
try {
|
|
@@ -37166,6 +37691,15 @@ var convertAudioForSafari = function convertAudioForSafari(file, messageId) {
|
|
|
37166
37691
|
}
|
|
37167
37692
|
};
|
|
37168
37693
|
|
|
37694
|
+
var audioConversion = {
|
|
37695
|
+
__proto__: null,
|
|
37696
|
+
isSafari: isSafari,
|
|
37697
|
+
initFFmpeg: initFFmpeg,
|
|
37698
|
+
convertToAac: convertToAac,
|
|
37699
|
+
convertMp3ToAac: convertMp3ToAac,
|
|
37700
|
+
convertAudioForSafari: convertAudioForSafari
|
|
37701
|
+
};
|
|
37702
|
+
|
|
37169
37703
|
var _templateObject$v, _templateObject2$r, _templateObject3$l, _templateObject4$h, _templateObject5$e, _templateObject6$b, _templateObject7$a;
|
|
37170
37704
|
var AudioPlayer = function AudioPlayer(_ref) {
|
|
37171
37705
|
var _file$metadata6, _file$metadata7;
|
|
@@ -38153,80 +38687,82 @@ var Attachment = function Attachment(_ref) {
|
|
|
38153
38687
|
}, messageType);
|
|
38154
38688
|
setDownloadFilePromise(attachment.id, urlPromise);
|
|
38155
38689
|
return Promise.resolve(urlPromise).then(function (result) {
|
|
38156
|
-
function
|
|
38157
|
-
|
|
38158
|
-
|
|
38159
|
-
|
|
38160
|
-
|
|
38161
|
-
|
|
38162
|
-
|
|
38163
|
-
|
|
38164
|
-
|
|
38165
|
-
|
|
38166
|
-
|
|
38167
|
-
|
|
38168
|
-
|
|
38169
|
-
|
|
38170
|
-
setAttachmentToCache(attachment.url + '_original_image_url', new Response(result.Body, {
|
|
38171
|
-
headers: {
|
|
38172
|
-
'Content-Type': 'image/jpeg'
|
|
38690
|
+
function _temp7(body) {
|
|
38691
|
+
function _temp6() {
|
|
38692
|
+
setIsCached(true);
|
|
38693
|
+
setDownloadingFile(false);
|
|
38694
|
+
setAttachmentUrl(downloadingUrl);
|
|
38695
|
+
}
|
|
38696
|
+
var url = URL.createObjectURL(body);
|
|
38697
|
+
setSizeProgress(undefined);
|
|
38698
|
+
var downloadingUrl = url;
|
|
38699
|
+
var _temp5 = function () {
|
|
38700
|
+
if (attachment.type === attachmentTypes.image) {
|
|
38701
|
+
return Promise.resolve(compressAndCacheImage(url, attachment.url, renderWidth, renderHeight)).then(function (compressedUrl) {
|
|
38702
|
+
if (compressedUrl) {
|
|
38703
|
+
downloadingUrl = compressedUrl;
|
|
38173
38704
|
}
|
|
38174
|
-
|
|
38175
|
-
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_image_url', url));
|
|
38176
|
-
});
|
|
38177
|
-
} else {
|
|
38178
|
-
var _temp3 = function _temp3() {
|
|
38179
|
-
if (attachment.type === attachmentTypes.video) {
|
|
38180
|
-
setAttachmentToCache(attachment.url + "_original_video_url", new Response(result.Body, {
|
|
38705
|
+
setAttachmentToCache(attachment.url + '_original_image_url', new Response(result.Body, {
|
|
38181
38706
|
headers: {
|
|
38182
|
-
'Content-Type':
|
|
38707
|
+
'Content-Type': 'image/jpeg'
|
|
38183
38708
|
}
|
|
38184
38709
|
}));
|
|
38185
|
-
dispatch(setUpdateMessageAttachmentAC(attachment.url +
|
|
38186
|
-
}
|
|
38187
|
-
|
|
38188
|
-
|
|
38189
|
-
|
|
38190
|
-
|
|
38191
|
-
|
|
38192
|
-
|
|
38193
|
-
}
|
|
38194
|
-
};
|
|
38195
|
-
var _temp2 = function () {
|
|
38196
|
-
if (attachment.type === attachmentTypes.video) {
|
|
38197
|
-
return Promise.resolve(getVideoFirstFrame(url, renderWidth, renderHeight, 0.8)).then(function (result) {
|
|
38198
|
-
var _temp = function () {
|
|
38199
|
-
if (result) {
|
|
38200
|
-
var frameBlobUrl = result.frameBlobUrl,
|
|
38201
|
-
blob = result.blob;
|
|
38202
|
-
var response = new Response(blob, {
|
|
38710
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_image_url', url));
|
|
38711
|
+
});
|
|
38712
|
+
} else {
|
|
38713
|
+
var _temp4 = function () {
|
|
38714
|
+
if (attachment.type === attachmentTypes.video) {
|
|
38715
|
+
return Promise.resolve(getVideoFirstFrame(body, renderWidth, renderHeight, 0.8)).then(function (frameResult) {
|
|
38716
|
+
function _temp3() {
|
|
38717
|
+
setAttachmentToCache(attachment.url + "_original_video_url", new Response(body, {
|
|
38203
38718
|
headers: {
|
|
38204
|
-
'Content-Type': '
|
|
38719
|
+
'Content-Type': body.type || 'application/octet-stream'
|
|
38205
38720
|
}
|
|
38206
|
-
});
|
|
38207
|
-
|
|
38208
|
-
return Promise.resolve(setAttachmentToCache(key, response)).then(function () {
|
|
38209
|
-
dispatch(setUpdateMessageAttachmentAC(key, frameBlobUrl));
|
|
38210
|
-
});
|
|
38721
|
+
}));
|
|
38722
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url + "_original_video_url", url));
|
|
38211
38723
|
}
|
|
38212
|
-
|
|
38213
|
-
|
|
38214
|
-
|
|
38215
|
-
|
|
38216
|
-
|
|
38217
|
-
|
|
38218
|
-
|
|
38219
|
-
|
|
38220
|
-
|
|
38724
|
+
var _temp2 = function () {
|
|
38725
|
+
if (frameResult) {
|
|
38726
|
+
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
38727
|
+
blob = frameResult.blob;
|
|
38728
|
+
var response = new Response(blob, {
|
|
38729
|
+
headers: {
|
|
38730
|
+
'Content-Type': 'image/jpeg'
|
|
38731
|
+
}
|
|
38732
|
+
});
|
|
38733
|
+
var key = attachment.url;
|
|
38734
|
+
return Promise.resolve(setAttachmentToCache(key, response)).then(function () {
|
|
38735
|
+
dispatch(setUpdateMessageAttachmentAC(key, frameBlobUrl));
|
|
38736
|
+
});
|
|
38737
|
+
}
|
|
38738
|
+
}();
|
|
38739
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
38740
|
+
});
|
|
38741
|
+
} else {
|
|
38742
|
+
setAttachmentToCache(attachment.url, new Response(result.Body, {
|
|
38743
|
+
headers: {
|
|
38744
|
+
'Content-Type': attachment.type || 'application/octet-stream'
|
|
38745
|
+
}
|
|
38746
|
+
}));
|
|
38747
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url, url));
|
|
38748
|
+
}
|
|
38749
|
+
}();
|
|
38750
|
+
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
38751
|
+
}
|
|
38752
|
+
}();
|
|
38753
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
38754
|
+
}
|
|
38755
|
+
var _temp = attachment.type === attachmentTypes.video;
|
|
38756
|
+
return _temp ? Promise.resolve(ensurePlayableVideoBlob(result.Body)).then(_temp7) : _temp7(result.Body);
|
|
38221
38757
|
});
|
|
38222
38758
|
} else {
|
|
38223
|
-
var
|
|
38759
|
+
var _temp9 = function _temp9(_result2) {
|
|
38224
38760
|
if (_exit) return _result2;
|
|
38225
38761
|
setAttachmentUrl(downloadingUrl);
|
|
38226
38762
|
};
|
|
38227
38763
|
var _exit = false;
|
|
38228
38764
|
var downloadingUrl = attachment.url;
|
|
38229
|
-
var
|
|
38765
|
+
var _temp8 = function () {
|
|
38230
38766
|
if (attachment.type === attachmentTypes.image) {
|
|
38231
38767
|
return Promise.resolve(compressAndCacheImage(attachment.url, attachment.url, renderWidth, renderHeight)).then(function (compressedUrl) {
|
|
38232
38768
|
if (compressedUrl) {
|
|
@@ -38237,47 +38773,51 @@ var Attachment = function Attachment(_ref) {
|
|
|
38237
38773
|
} else {
|
|
38238
38774
|
fetch(attachment.url).then(function (response) {
|
|
38239
38775
|
try {
|
|
38240
|
-
return Promise.resolve(response.blob()).then(function (
|
|
38241
|
-
function
|
|
38242
|
-
|
|
38243
|
-
|
|
38244
|
-
|
|
38245
|
-
|
|
38246
|
-
|
|
38247
|
-
|
|
38248
|
-
|
|
38249
|
-
function
|
|
38250
|
-
|
|
38251
|
-
|
|
38252
|
-
'Content-Type': blob.type || 'video/mp4'
|
|
38253
|
-
}
|
|
38254
|
-
}));
|
|
38255
|
-
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_video_url', blobUrl));
|
|
38256
|
-
}
|
|
38257
|
-
var _temp8 = function () {
|
|
38258
|
-
if (frameResult) {
|
|
38259
|
-
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
38260
|
-
frameBlob = frameResult.blob;
|
|
38261
|
-
return Promise.resolve(setAttachmentToCache(attachment.url, new Response(frameBlob, {
|
|
38776
|
+
return Promise.resolve(response.blob()).then(function (rawBlob) {
|
|
38777
|
+
function _temp13(blob) {
|
|
38778
|
+
function _temp12() {
|
|
38779
|
+
setAttachmentUrl(blobUrl);
|
|
38780
|
+
setIsCached(true);
|
|
38781
|
+
}
|
|
38782
|
+
var blobUrl = URL.createObjectURL(blob);
|
|
38783
|
+
var _temp11 = function () {
|
|
38784
|
+
if (attachment.type === attachmentTypes.video) {
|
|
38785
|
+
return Promise.resolve(getVideoFirstFrame(blob, renderWidth, renderHeight, 0.8)).then(function (frameResult) {
|
|
38786
|
+
function _temp10() {
|
|
38787
|
+
setAttachmentToCache(attachment.url + '_original_video_url', new Response(blob, {
|
|
38262
38788
|
headers: {
|
|
38263
|
-
'Content-Type': '
|
|
38789
|
+
'Content-Type': blob.type || 'video/mp4'
|
|
38264
38790
|
}
|
|
38265
|
-
}))
|
|
38266
|
-
|
|
38267
|
-
});
|
|
38791
|
+
}));
|
|
38792
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_video_url', blobUrl));
|
|
38268
38793
|
}
|
|
38269
|
-
|
|
38270
|
-
|
|
38271
|
-
|
|
38272
|
-
|
|
38273
|
-
|
|
38274
|
-
|
|
38275
|
-
|
|
38276
|
-
|
|
38277
|
-
|
|
38278
|
-
|
|
38279
|
-
|
|
38280
|
-
|
|
38794
|
+
var _temp1 = function () {
|
|
38795
|
+
if (frameResult) {
|
|
38796
|
+
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
38797
|
+
frameBlob = frameResult.blob;
|
|
38798
|
+
return Promise.resolve(setAttachmentToCache(attachment.url, new Response(frameBlob, {
|
|
38799
|
+
headers: {
|
|
38800
|
+
'Content-Type': 'image/jpeg'
|
|
38801
|
+
}
|
|
38802
|
+
}))).then(function () {
|
|
38803
|
+
dispatch(setUpdateMessageAttachmentAC(getAttachmentURLWithVersion(attachment.url), frameBlobUrl));
|
|
38804
|
+
});
|
|
38805
|
+
}
|
|
38806
|
+
}();
|
|
38807
|
+
return _temp1 && _temp1.then ? _temp1.then(_temp10) : _temp10(_temp1);
|
|
38808
|
+
});
|
|
38809
|
+
} else {
|
|
38810
|
+
setAttachmentToCache(attachment.url, new Response(blob, {
|
|
38811
|
+
headers: {
|
|
38812
|
+
'Content-Type': blob.type || 'application/octet-stream'
|
|
38813
|
+
}
|
|
38814
|
+
}));
|
|
38815
|
+
}
|
|
38816
|
+
}();
|
|
38817
|
+
return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11);
|
|
38818
|
+
}
|
|
38819
|
+
var _temp0 = attachment.type === attachmentTypes.video;
|
|
38820
|
+
return _temp0 ? Promise.resolve(ensurePlayableVideoBlob(rawBlob)).then(_temp13) : _temp13(rawBlob);
|
|
38281
38821
|
});
|
|
38282
38822
|
} catch (e) {
|
|
38283
38823
|
return Promise.reject(e);
|
|
@@ -38288,7 +38828,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38288
38828
|
_exit = true;
|
|
38289
38829
|
}
|
|
38290
38830
|
}();
|
|
38291
|
-
return
|
|
38831
|
+
return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
|
|
38292
38832
|
}
|
|
38293
38833
|
}());
|
|
38294
38834
|
} catch (e) {
|
|
@@ -38304,9 +38844,9 @@ var Attachment = function Attachment(_ref) {
|
|
|
38304
38844
|
if (!attachment.attachmentUrl && connectionStatus === CONNECTION_STATUS.CONNECTED && attachment.id && !attachmentUrlFromMap && !(attachment.type === attachmentTypes.file || attachment.type === attachmentTypes.link)) {
|
|
38305
38845
|
getAttachmentUrlFromCache(attachment.url).then(function (cachedUrl) {
|
|
38306
38846
|
try {
|
|
38307
|
-
var
|
|
38847
|
+
var _temp16 = function () {
|
|
38308
38848
|
if (attachment.type === attachmentTypes.image && !isPreview) {
|
|
38309
|
-
var
|
|
38849
|
+
var _temp15 = function () {
|
|
38310
38850
|
if (cachedUrl) {
|
|
38311
38851
|
setAttachmentUrl(cachedUrl);
|
|
38312
38852
|
dispatch(setUpdateMessageAttachmentAC(attachment.url, cachedUrl));
|
|
@@ -38314,7 +38854,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38314
38854
|
} else {
|
|
38315
38855
|
setIsCached(false);
|
|
38316
38856
|
setDownloadingFile(true);
|
|
38317
|
-
var
|
|
38857
|
+
var _temp14 = function () {
|
|
38318
38858
|
if (customDownloader) {
|
|
38319
38859
|
customDownloader(attachment.url, false, function (progress) {
|
|
38320
38860
|
var loadedRes = progress.loaded && progress.loaded / progress.total;
|
|
@@ -38366,10 +38906,10 @@ var Attachment = function Attachment(_ref) {
|
|
|
38366
38906
|
});
|
|
38367
38907
|
}
|
|
38368
38908
|
}();
|
|
38369
|
-
if (
|
|
38909
|
+
if (_temp14 && _temp14.then) return _temp14.then(function () {});
|
|
38370
38910
|
}
|
|
38371
38911
|
}();
|
|
38372
|
-
if (
|
|
38912
|
+
if (_temp15 && _temp15.then) return _temp15.then(function () {});
|
|
38373
38913
|
} else {
|
|
38374
38914
|
if (cachedUrl) {
|
|
38375
38915
|
setAttachmentUrl(cachedUrl);
|
|
@@ -38383,7 +38923,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38383
38923
|
}
|
|
38384
38924
|
}
|
|
38385
38925
|
}();
|
|
38386
|
-
return Promise.resolve(
|
|
38926
|
+
return Promise.resolve(_temp16 && _temp16.then ? _temp16.then(function () {}) : void 0);
|
|
38387
38927
|
} catch (e) {
|
|
38388
38928
|
return Promise.reject(e);
|
|
38389
38929
|
}
|
|
@@ -38401,13 +38941,13 @@ var Attachment = function Attachment(_ref) {
|
|
|
38401
38941
|
setProgress(uploadPercent);
|
|
38402
38942
|
}, messageType).then(function (url) {
|
|
38403
38943
|
try {
|
|
38404
|
-
var
|
|
38944
|
+
var _temp18 = function _temp18() {
|
|
38405
38945
|
setAttachmentUrl(downloadingUrl);
|
|
38406
38946
|
dispatch(setUpdateMessageAttachmentAC(attachment.url, attachment.url));
|
|
38407
38947
|
setDownloadingFile(false);
|
|
38408
38948
|
};
|
|
38409
38949
|
var downloadingUrl = url;
|
|
38410
|
-
var
|
|
38950
|
+
var _temp17 = function () {
|
|
38411
38951
|
if (attachment.type === attachmentTypes.image) {
|
|
38412
38952
|
return Promise.resolve(compressAndCacheImage(url, attachment.url, renderWidth, renderHeight)).then(function (compressedUrl) {
|
|
38413
38953
|
if (compressedUrl) {
|
|
@@ -38420,7 +38960,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38420
38960
|
});
|
|
38421
38961
|
}
|
|
38422
38962
|
}();
|
|
38423
|
-
return Promise.resolve(
|
|
38963
|
+
return Promise.resolve(_temp17 && _temp17.then ? _temp17.then(_temp18) : _temp18(_temp17));
|
|
38424
38964
|
} catch (e) {
|
|
38425
38965
|
return Promise.reject(e);
|
|
38426
38966
|
}
|
|
@@ -44669,6 +45209,7 @@ function useChatController(_ref5) {
|
|
|
44669
45209
|
restoreRef.current = null;
|
|
44670
45210
|
pendingNewestCountRef.current = 0;
|
|
44671
45211
|
setPendingNewestCount(0);
|
|
45212
|
+
unreadRestoreCompletedRef.current = true;
|
|
44672
45213
|
var container = scrollRef.current;
|
|
44673
45214
|
var currentChannelId = (_channelRef$current = channelRef.current) === null || _channelRef$current === void 0 ? void 0 : _channelRef$current.id;
|
|
44674
45215
|
var pendingLatestServerSync = ((_pendingLatestJumpRef = pendingLatestJumpRef.current) === null || _pendingLatestJumpRef === void 0 ? void 0 : _pendingLatestJumpRef.channelId) === currentChannelId && ((_pendingLatestJumpRef2 = pendingLatestJumpRef.current) === null || _pendingLatestJumpRef2 === void 0 ? void 0 : _pendingLatestJumpRef2.needsServerSync);
|
|
@@ -45535,6 +46076,7 @@ function useChatController(_ref5) {
|
|
|
45535
46076
|
restoreRef.current = null;
|
|
45536
46077
|
viewIsAtLatestRef.current = true;
|
|
45537
46078
|
setIsViewingLatest(true);
|
|
46079
|
+
lockJumpScrolling(true, 'latest');
|
|
45538
46080
|
scrollToLatestEdge(container, 'smooth');
|
|
45539
46081
|
rememberLatestEdge();
|
|
45540
46082
|
return;
|
|
@@ -45595,7 +46137,7 @@ function useChatController(_ref5) {
|
|
|
45595
46137
|
}
|
|
45596
46138
|
rememberLatestEdge();
|
|
45597
46139
|
}
|
|
45598
|
-
}, [channel.id, unreadMessageId, isActiveEdgeRequestCurrent, dispatch, messages, unreadScrollTo, clearJumpBlur, hasNext, isScrollInteractionActive]);
|
|
46140
|
+
}, [channel.id, unreadMessageId, isActiveEdgeRequestCurrent, dispatch, messages, unreadScrollTo, clearJumpBlur, hasNext, isScrollInteractionActive, lockJumpScrolling]);
|
|
45599
46141
|
useEffect(function () {
|
|
45600
46142
|
if (!unreadScrollTo || !unreadMessageId || !messages.length || unreadRestoreCompletedRef.current) {
|
|
45601
46143
|
return;
|
|
@@ -50750,10 +51292,10 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
50750
51292
|
editorState.read(function () {
|
|
50751
51293
|
var root = $getRoot();
|
|
50752
51294
|
var textContent = root.getTextContent();
|
|
50753
|
-
var
|
|
50754
|
-
|
|
50755
|
-
|
|
50756
|
-
|
|
51295
|
+
var protocolMatch = /https?:\/\/\S+/.exec(textContent);
|
|
51296
|
+
var linkifyMatchResult = !protocolMatch ? linkify.match(textContent) : null;
|
|
51297
|
+
var firstUrl = protocolMatch ? protocolMatch[0] : linkifyMatchResult !== null && linkifyMatchResult !== void 0 && linkifyMatchResult[0] ? linkifyMatchResult[0].schema === '' ? linkifyMatchResult[0].url.replace(/^http:\/\//, 'https://') : linkifyMatchResult[0].url : null;
|
|
51298
|
+
if (firstUrl) {
|
|
50757
51299
|
if (firstUrl !== detectedUrl) {
|
|
50758
51300
|
closePreviewWithAnimation(function () {
|
|
50759
51301
|
if (!dismissedUrls.has(firstUrl)) {
|
|
@@ -50913,11 +51455,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
50913
51455
|
}
|
|
50914
51456
|
var linkAttachment;
|
|
50915
51457
|
if (messageTexToSend) {
|
|
50916
|
-
var
|
|
50917
|
-
var
|
|
50918
|
-
|
|
50919
|
-
|
|
50920
|
-
|
|
51458
|
+
var _LinkifyIt$match;
|
|
51459
|
+
var protocolMatch = /https?:\/\/\S+/.exec(messageTexToSend);
|
|
51460
|
+
var linkifyMatchResult = !protocolMatch ? (_LinkifyIt$match = new LinkifyIt().match(messageTexToSend)) === null || _LinkifyIt$match === void 0 ? void 0 : _LinkifyIt$match[0] : null;
|
|
51461
|
+
var url = protocolMatch ? protocolMatch[0] : linkifyMatchResult ? linkifyMatchResult.schema === '' ? linkifyMatchResult.url.replace(/^http:\/\//, 'https://') : linkifyMatchResult.url : null;
|
|
51462
|
+
if (url) {
|
|
50921
51463
|
var urlMetadata = oGMetadata === null || oGMetadata === void 0 ? void 0 : oGMetadata[url];
|
|
50922
51464
|
var metadata = {};
|
|
50923
51465
|
if (urlMetadata) {
|
|
@@ -51032,11 +51574,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
51032
51574
|
if (messageTexToSend) {
|
|
51033
51575
|
var linkAttachment;
|
|
51034
51576
|
if (messageTexToSend) {
|
|
51035
|
-
var
|
|
51036
|
-
var
|
|
51037
|
-
|
|
51038
|
-
|
|
51039
|
-
|
|
51577
|
+
var _LinkifyIt$match2;
|
|
51578
|
+
var protocolMatch = /https?:\/\/\S+/.exec(messageTexToSend);
|
|
51579
|
+
var linkifyMatchResult = !protocolMatch ? (_LinkifyIt$match2 = new LinkifyIt().match(messageTexToSend)) === null || _LinkifyIt$match2 === void 0 ? void 0 : _LinkifyIt$match2[0] : null;
|
|
51580
|
+
var url = protocolMatch ? protocolMatch[0] : linkifyMatchResult ? linkifyMatchResult.schema === '' ? linkifyMatchResult.url.replace(/^http:\/\//, 'https://') : linkifyMatchResult.url : null;
|
|
51581
|
+
if (url) {
|
|
51040
51582
|
var urlMetadata = oGMetadata === null || oGMetadata === void 0 ? void 0 : oGMetadata[url];
|
|
51041
51583
|
var metadata = {};
|
|
51042
51584
|
if (urlMetadata) {
|
|
@@ -51336,252 +51878,260 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
51336
51878
|
};
|
|
51337
51879
|
var handleAddAttachment = function handleAddAttachment(file, isMediaAttachment) {
|
|
51338
51880
|
try {
|
|
51339
|
-
var
|
|
51340
|
-
|
|
51341
|
-
|
|
51342
|
-
|
|
51343
|
-
|
|
51344
|
-
|
|
51345
|
-
|
|
51346
|
-
|
|
51347
|
-
|
|
51348
|
-
|
|
51349
|
-
|
|
51350
|
-
|
|
51351
|
-
|
|
51352
|
-
|
|
51353
|
-
|
|
51354
|
-
|
|
51355
|
-
|
|
51356
|
-
|
|
51357
|
-
|
|
51358
|
-
|
|
51359
|
-
|
|
51360
|
-
|
|
51361
|
-
|
|
51362
|
-
|
|
51363
|
-
|
|
51364
|
-
}
|
|
51365
|
-
})
|
|
51366
|
-
|
|
51367
|
-
|
|
51368
|
-
}
|
|
51369
|
-
|
|
51370
|
-
|
|
51371
|
-
|
|
51372
|
-
|
|
51373
|
-
|
|
51374
|
-
|
|
51375
|
-
|
|
51376
|
-
|
|
51377
|
-
|
|
51378
|
-
|
|
51379
|
-
|
|
51380
|
-
|
|
51381
|
-
|
|
51382
|
-
|
|
51383
|
-
|
|
51384
|
-
|
|
51385
|
-
|
|
51386
|
-
|
|
51387
|
-
|
|
51388
|
-
|
|
51389
|
-
|
|
51390
|
-
|
|
51391
|
-
|
|
51392
|
-
|
|
51393
|
-
|
|
51394
|
-
|
|
51395
|
-
|
|
51396
|
-
|
|
51397
|
-
}
|
|
51398
|
-
|
|
51399
|
-
|
|
51881
|
+
var _temp4 = function _temp4() {
|
|
51882
|
+
var fileType = file.type.split('/')[0];
|
|
51883
|
+
var tid = v4();
|
|
51884
|
+
var reader = new FileReader();
|
|
51885
|
+
var handleAttachmentImageForCache = function handleAttachmentImageForCache(attachment) {
|
|
51886
|
+
try {
|
|
51887
|
+
var _attachment$metadata;
|
|
51888
|
+
var url = URL.createObjectURL(attachment.data);
|
|
51889
|
+
dispatch(setUpdateMessageAttachmentAC((attachment === null || attachment === void 0 ? void 0 : (_attachment$metadata = attachment.metadata) === null || _attachment$metadata === void 0 ? void 0 : _attachment$metadata.tmb) || '', url));
|
|
51890
|
+
return Promise.resolve();
|
|
51891
|
+
} catch (e) {
|
|
51892
|
+
return Promise.reject(e);
|
|
51893
|
+
}
|
|
51894
|
+
};
|
|
51895
|
+
var handleAttachmentVideoForCache = function handleAttachmentVideoForCache(attachment) {
|
|
51896
|
+
try {
|
|
51897
|
+
var _calculateRenderedIma = calculateRenderedImageWidth(attachment.metadata.szh || 400, attachment.metadata.szh || 400),
|
|
51898
|
+
newWidth = _calculateRenderedIma[0],
|
|
51899
|
+
newHeight = _calculateRenderedIma[1];
|
|
51900
|
+
return Promise.resolve(getVideoFirstFrame(attachment.data, newWidth, newHeight, 0.8)).then(function (result) {
|
|
51901
|
+
if (result) {
|
|
51902
|
+
var _attachment$metadata2;
|
|
51903
|
+
var frameBlobUrl = result.frameBlobUrl;
|
|
51904
|
+
dispatch(setUpdateMessageAttachmentAC((attachment === null || attachment === void 0 ? void 0 : (_attachment$metadata2 = attachment.metadata) === null || _attachment$metadata2 === void 0 ? void 0 : _attachment$metadata2.tmb) || '', frameBlobUrl));
|
|
51905
|
+
}
|
|
51906
|
+
});
|
|
51907
|
+
} catch (e) {
|
|
51908
|
+
return Promise.reject(e);
|
|
51909
|
+
}
|
|
51910
|
+
};
|
|
51911
|
+
reader.onload = function () {
|
|
51912
|
+
try {
|
|
51913
|
+
setPendingAttachment(tid, {
|
|
51914
|
+
file: file
|
|
51915
|
+
});
|
|
51916
|
+
var _temp0 = function () {
|
|
51917
|
+
if (customUploader) {
|
|
51918
|
+
var _temp6 = function () {
|
|
51919
|
+
if (fileType === 'image') {
|
|
51920
|
+
resizeImage(file).then(function (resizedFile) {
|
|
51921
|
+
try {
|
|
51922
|
+
return Promise.resolve(createImageThumbnail(file)).then(function (_ref4) {
|
|
51923
|
+
var _resizedFile$blob;
|
|
51924
|
+
var thumbnail = _ref4.thumbnail,
|
|
51925
|
+
imageWidth = _ref4.imageWidth,
|
|
51926
|
+
imageHeight = _ref4.imageHeight;
|
|
51927
|
+
var attachment = {
|
|
51928
|
+
data: file,
|
|
51929
|
+
upload: false,
|
|
51930
|
+
type: isMediaAttachment ? fileType : 'file',
|
|
51931
|
+
attachmentUrl: URL.createObjectURL(resizedFile.blob),
|
|
51932
|
+
tid: tid,
|
|
51933
|
+
size: isMediaAttachment ? resizedFile !== null && resizedFile !== void 0 && resizedFile.blob ? resizedFile === null || resizedFile === void 0 ? void 0 : (_resizedFile$blob = resizedFile.blob) === null || _resizedFile$blob === void 0 ? void 0 : _resizedFile$blob.size : file.size : file.size,
|
|
51934
|
+
metadata: {
|
|
51935
|
+
szw: imageWidth,
|
|
51936
|
+
szh: imageHeight,
|
|
51937
|
+
tmb: thumbnail
|
|
51938
|
+
}
|
|
51939
|
+
};
|
|
51940
|
+
handleAttachmentImageForCache(attachment);
|
|
51941
|
+
setAttachments(function (prevState) {
|
|
51942
|
+
return [].concat(prevState, [attachment]);
|
|
51943
|
+
});
|
|
51944
|
+
});
|
|
51945
|
+
} catch (e) {
|
|
51946
|
+
return Promise.reject(e);
|
|
51947
|
+
}
|
|
51948
|
+
});
|
|
51949
|
+
} else {
|
|
51950
|
+
var _temp1 = function () {
|
|
51951
|
+
if (fileType === 'video') {
|
|
51952
|
+
return Promise.resolve(getFrame(file, 0)).then(function (_ref5) {
|
|
51953
|
+
var thumb = _ref5.thumb,
|
|
51954
|
+
width = _ref5.width,
|
|
51955
|
+
height = _ref5.height,
|
|
51956
|
+
duration = _ref5.duration;
|
|
51957
|
+
var attachment = {
|
|
51958
|
+
data: file,
|
|
51959
|
+
upload: false,
|
|
51960
|
+
type: isMediaAttachment ? fileType : 'file',
|
|
51961
|
+
attachmentUrl: URL.createObjectURL(file),
|
|
51962
|
+
tid: tid,
|
|
51963
|
+
size: file.size,
|
|
51964
|
+
metadata: {
|
|
51965
|
+
szw: width,
|
|
51966
|
+
szh: height,
|
|
51967
|
+
tmb: thumb,
|
|
51968
|
+
dur: duration
|
|
51969
|
+
}
|
|
51970
|
+
};
|
|
51971
|
+
handleAttachmentVideoForCache(attachment);
|
|
51972
|
+
setAttachments(function (prevState) {
|
|
51973
|
+
return [].concat(prevState, [attachment]);
|
|
51974
|
+
});
|
|
51975
|
+
});
|
|
51976
|
+
} else {
|
|
51400
51977
|
setAttachments(function (prevState) {
|
|
51401
|
-
return [].concat(prevState, [
|
|
51978
|
+
return [].concat(prevState, [{
|
|
51979
|
+
data: file,
|
|
51980
|
+
upload: false,
|
|
51981
|
+
type: 'file',
|
|
51982
|
+
tid: tid,
|
|
51983
|
+
size: file.size
|
|
51984
|
+
}]);
|
|
51402
51985
|
});
|
|
51403
|
-
}
|
|
51404
|
-
}
|
|
51405
|
-
|
|
51406
|
-
|
|
51407
|
-
|
|
51408
|
-
|
|
51409
|
-
|
|
51410
|
-
|
|
51411
|
-
|
|
51412
|
-
|
|
51413
|
-
|
|
51414
|
-
|
|
51415
|
-
|
|
51416
|
-
|
|
51417
|
-
|
|
51418
|
-
|
|
51419
|
-
|
|
51420
|
-
|
|
51421
|
-
|
|
51422
|
-
|
|
51423
|
-
|
|
51424
|
-
|
|
51425
|
-
|
|
51426
|
-
|
|
51427
|
-
|
|
51986
|
+
}
|
|
51987
|
+
}();
|
|
51988
|
+
if (_temp1 && _temp1.then) return _temp1.then(function () {});
|
|
51989
|
+
}
|
|
51990
|
+
}();
|
|
51991
|
+
if (_temp6 && _temp6.then) return _temp6.then(function () {});
|
|
51992
|
+
} else {
|
|
51993
|
+
var _temp9 = function () {
|
|
51994
|
+
if (fileType === 'image') {
|
|
51995
|
+
var _temp7 = function () {
|
|
51996
|
+
if (isMediaAttachment) {
|
|
51997
|
+
return Promise.resolve(createImageThumbnail(file)).then(function (_ref6) {
|
|
51998
|
+
var thumbnail = _ref6.thumbnail,
|
|
51999
|
+
imageWidth = _ref6.imageWidth,
|
|
52000
|
+
imageHeight = _ref6.imageHeight;
|
|
52001
|
+
var metas = {
|
|
52002
|
+
thumbnail: thumbnail,
|
|
52003
|
+
imageWidth: imageWidth,
|
|
52004
|
+
imageHeight: imageHeight
|
|
52005
|
+
};
|
|
52006
|
+
if (file.type === 'image/gif') {
|
|
52007
|
+
setAttachments(function (prevState) {
|
|
52008
|
+
return [].concat(prevState, [{
|
|
52009
|
+
data: file,
|
|
52010
|
+
upload: true,
|
|
52011
|
+
attachmentUrl: URL.createObjectURL(file),
|
|
52012
|
+
tid: tid,
|
|
52013
|
+
type: fileType,
|
|
52014
|
+
size: file.size,
|
|
52015
|
+
metadata: JSON.stringify({
|
|
52016
|
+
tmb: metas.thumbnail,
|
|
52017
|
+
szw: metas.imageWidth,
|
|
52018
|
+
szh: metas.imageHeight
|
|
52019
|
+
})
|
|
52020
|
+
}]);
|
|
52021
|
+
});
|
|
52022
|
+
} else {
|
|
52023
|
+
resizeImage(file).then(function (resizedFileData) {
|
|
52024
|
+
try {
|
|
52025
|
+
var resizedFile = new File([resizedFileData.blob], resizedFileData.file.name);
|
|
52026
|
+
var attachment = {
|
|
52027
|
+
data: resizedFile,
|
|
52028
|
+
upload: true,
|
|
52029
|
+
attachmentUrl: URL.createObjectURL(resizedFile),
|
|
52030
|
+
tid: tid,
|
|
52031
|
+
type: fileType,
|
|
52032
|
+
size: resizedFile.size,
|
|
52033
|
+
metadata: JSON.stringify({
|
|
52034
|
+
tmb: metas.thumbnail,
|
|
52035
|
+
szw: resizedFileData.newWidth,
|
|
52036
|
+
szh: resizedFileData.newHeight
|
|
52037
|
+
})
|
|
52038
|
+
};
|
|
52039
|
+
handleAttachmentImageForCache(attachment);
|
|
52040
|
+
setAttachments(function (prevState) {
|
|
52041
|
+
return [].concat(prevState, [attachment]);
|
|
52042
|
+
});
|
|
52043
|
+
return Promise.resolve();
|
|
52044
|
+
} catch (e) {
|
|
52045
|
+
return Promise.reject(e);
|
|
52046
|
+
}
|
|
52047
|
+
});
|
|
51428
52048
|
}
|
|
51429
|
-
};
|
|
51430
|
-
handleAttachmentVideoForCache(attachment);
|
|
51431
|
-
setAttachments(function (prevState) {
|
|
51432
|
-
return [].concat(prevState, [attachment]);
|
|
51433
52049
|
});
|
|
51434
|
-
}
|
|
51435
|
-
|
|
51436
|
-
|
|
51437
|
-
return [].concat(prevState, [{
|
|
51438
|
-
data: file,
|
|
51439
|
-
upload: false,
|
|
51440
|
-
type: 'file',
|
|
51441
|
-
tid: tid,
|
|
51442
|
-
size: file.size
|
|
51443
|
-
}]);
|
|
51444
|
-
});
|
|
51445
|
-
}
|
|
51446
|
-
}();
|
|
51447
|
-
if (_temp9 && _temp9.then) return _temp9.then(function () {});
|
|
51448
|
-
}
|
|
51449
|
-
}();
|
|
51450
|
-
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
51451
|
-
} else {
|
|
51452
|
-
var _temp7 = function () {
|
|
51453
|
-
if (fileType === 'image') {
|
|
51454
|
-
var _temp5 = function () {
|
|
51455
|
-
if (isMediaAttachment) {
|
|
51456
|
-
return Promise.resolve(createImageThumbnail(file)).then(function (_ref6) {
|
|
51457
|
-
var thumbnail = _ref6.thumbnail,
|
|
51458
|
-
imageWidth = _ref6.imageWidth,
|
|
51459
|
-
imageHeight = _ref6.imageHeight;
|
|
51460
|
-
var metas = {
|
|
51461
|
-
thumbnail: thumbnail,
|
|
51462
|
-
imageWidth: imageWidth,
|
|
51463
|
-
imageHeight: imageHeight
|
|
51464
|
-
};
|
|
51465
|
-
if (file.type === 'image/gif') {
|
|
52050
|
+
} else {
|
|
52051
|
+
return Promise.resolve(createImageThumbnail(file, undefined, 50, 50)).then(function (_ref7) {
|
|
52052
|
+
var thumbnail = _ref7.thumbnail;
|
|
51466
52053
|
setAttachments(function (prevState) {
|
|
51467
52054
|
return [].concat(prevState, [{
|
|
51468
52055
|
data: file,
|
|
52056
|
+
type: 'file',
|
|
51469
52057
|
upload: true,
|
|
51470
52058
|
attachmentUrl: URL.createObjectURL(file),
|
|
51471
52059
|
tid: tid,
|
|
51472
|
-
type: fileType,
|
|
51473
52060
|
size: file.size,
|
|
51474
52061
|
metadata: JSON.stringify({
|
|
51475
|
-
tmb:
|
|
51476
|
-
szw: metas.imageWidth,
|
|
51477
|
-
szh: metas.imageHeight
|
|
52062
|
+
tmb: thumbnail
|
|
51478
52063
|
})
|
|
51479
52064
|
}]);
|
|
51480
52065
|
});
|
|
51481
|
-
}
|
|
51482
|
-
|
|
51483
|
-
|
|
51484
|
-
|
|
51485
|
-
|
|
51486
|
-
|
|
51487
|
-
|
|
51488
|
-
|
|
51489
|
-
|
|
51490
|
-
|
|
51491
|
-
|
|
51492
|
-
|
|
51493
|
-
|
|
51494
|
-
|
|
51495
|
-
|
|
51496
|
-
|
|
51497
|
-
|
|
51498
|
-
handleAttachmentImageForCache(attachment);
|
|
51499
|
-
setAttachments(function (prevState) {
|
|
51500
|
-
return [].concat(prevState, [attachment]);
|
|
51501
|
-
});
|
|
51502
|
-
return Promise.resolve();
|
|
51503
|
-
} catch (e) {
|
|
51504
|
-
return Promise.reject(e);
|
|
51505
|
-
}
|
|
52066
|
+
});
|
|
52067
|
+
}
|
|
52068
|
+
}();
|
|
52069
|
+
if (_temp7 && _temp7.then) return _temp7.then(function () {});
|
|
52070
|
+
} else {
|
|
52071
|
+
var _temp10 = function () {
|
|
52072
|
+
if (fileType === 'video') {
|
|
52073
|
+
return Promise.resolve(getFrame(file, 0)).then(function (_ref8) {
|
|
52074
|
+
var thumb = _ref8.thumb,
|
|
52075
|
+
width = _ref8.width,
|
|
52076
|
+
height = _ref8.height,
|
|
52077
|
+
duration = _ref8.duration;
|
|
52078
|
+
var metas = JSON.stringify({
|
|
52079
|
+
tmb: thumb,
|
|
52080
|
+
width: width,
|
|
52081
|
+
height: height,
|
|
52082
|
+
dur: duration
|
|
51506
52083
|
});
|
|
51507
|
-
|
|
51508
|
-
});
|
|
51509
|
-
} else {
|
|
51510
|
-
return Promise.resolve(createImageThumbnail(file, undefined, 50, 50)).then(function (_ref7) {
|
|
51511
|
-
var thumbnail = _ref7.thumbnail;
|
|
51512
|
-
setAttachments(function (prevState) {
|
|
51513
|
-
return [].concat(prevState, [{
|
|
52084
|
+
var attachment = {
|
|
51514
52085
|
data: file,
|
|
51515
|
-
type: '
|
|
52086
|
+
type: 'video',
|
|
51516
52087
|
upload: true,
|
|
52088
|
+
size: file.size,
|
|
51517
52089
|
attachmentUrl: URL.createObjectURL(file),
|
|
51518
52090
|
tid: tid,
|
|
51519
|
-
|
|
51520
|
-
|
|
51521
|
-
|
|
51522
|
-
|
|
51523
|
-
|
|
51524
|
-
|
|
51525
|
-
});
|
|
51526
|
-
}
|
|
51527
|
-
}();
|
|
51528
|
-
if (_temp5 && _temp5.then) return _temp5.then(function () {});
|
|
51529
|
-
} else {
|
|
51530
|
-
var _temp0 = function () {
|
|
51531
|
-
if (fileType === 'video') {
|
|
51532
|
-
return Promise.resolve(getFrame(URL.createObjectURL(file), 0)).then(function (_ref8) {
|
|
51533
|
-
var thumb = _ref8.thumb,
|
|
51534
|
-
width = _ref8.width,
|
|
51535
|
-
height = _ref8.height,
|
|
51536
|
-
duration = _ref8.duration;
|
|
51537
|
-
var metas = JSON.stringify({
|
|
51538
|
-
tmb: thumb,
|
|
51539
|
-
width: width,
|
|
51540
|
-
height: height,
|
|
51541
|
-
dur: duration
|
|
52091
|
+
metadata: metas
|
|
52092
|
+
};
|
|
52093
|
+
handleAttachmentVideoForCache(attachment);
|
|
52094
|
+
setAttachments(function (prevState) {
|
|
52095
|
+
return [].concat(prevState, [attachment]);
|
|
52096
|
+
});
|
|
51542
52097
|
});
|
|
51543
|
-
|
|
51544
|
-
data: file,
|
|
51545
|
-
type: 'video',
|
|
51546
|
-
upload: true,
|
|
51547
|
-
size: file.size,
|
|
51548
|
-
attachmentUrl: URL.createObjectURL(file),
|
|
51549
|
-
tid: tid,
|
|
51550
|
-
metadata: metas
|
|
51551
|
-
};
|
|
51552
|
-
handleAttachmentVideoForCache(attachment);
|
|
52098
|
+
} else {
|
|
51553
52099
|
setAttachments(function (prevState) {
|
|
51554
|
-
return [].concat(prevState, [
|
|
52100
|
+
return [].concat(prevState, [{
|
|
52101
|
+
data: file,
|
|
52102
|
+
upload: true,
|
|
52103
|
+
type: 'file',
|
|
52104
|
+
size: file.size,
|
|
52105
|
+
tid: tid
|
|
52106
|
+
}]);
|
|
51555
52107
|
});
|
|
51556
|
-
}
|
|
51557
|
-
}
|
|
51558
|
-
|
|
51559
|
-
|
|
51560
|
-
|
|
51561
|
-
|
|
51562
|
-
|
|
51563
|
-
|
|
51564
|
-
|
|
51565
|
-
|
|
51566
|
-
|
|
51567
|
-
|
|
51568
|
-
|
|
51569
|
-
|
|
51570
|
-
|
|
51571
|
-
|
|
51572
|
-
|
|
51573
|
-
}
|
|
51574
|
-
}();
|
|
51575
|
-
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
|
|
51576
|
-
} catch (e) {
|
|
51577
|
-
return Promise.reject(e);
|
|
51578
|
-
}
|
|
51579
|
-
};
|
|
51580
|
-
reader.onerror = function (e) {
|
|
51581
|
-
log.info(' error on read file onError', e);
|
|
52108
|
+
}
|
|
52109
|
+
}();
|
|
52110
|
+
if (_temp10 && _temp10.then) return _temp10.then(function () {});
|
|
52111
|
+
}
|
|
52112
|
+
}();
|
|
52113
|
+
if (_temp9 && _temp9.then) return _temp9.then(function () {});
|
|
52114
|
+
}
|
|
52115
|
+
}();
|
|
52116
|
+
return Promise.resolve(_temp0 && _temp0.then ? _temp0.then(function () {}) : void 0);
|
|
52117
|
+
} catch (e) {
|
|
52118
|
+
return Promise.reject(e);
|
|
52119
|
+
}
|
|
52120
|
+
};
|
|
52121
|
+
reader.onerror = function (e) {
|
|
52122
|
+
log.info(' error on read file onError', e);
|
|
52123
|
+
};
|
|
52124
|
+
reader.readAsBinaryString(file);
|
|
51582
52125
|
};
|
|
51583
|
-
|
|
51584
|
-
|
|
52126
|
+
var customUploader = getCustomUploader();
|
|
52127
|
+
var _temp3 = function () {
|
|
52128
|
+
if (file.type.split('/')[0] === 'video') {
|
|
52129
|
+
return Promise.resolve(remuxVideoFileForUpload(file)).then(function (_remuxVideoFileForUpl) {
|
|
52130
|
+
file = _remuxVideoFileForUpl;
|
|
52131
|
+
});
|
|
52132
|
+
}
|
|
52133
|
+
}();
|
|
52134
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
|
|
51585
52135
|
} catch (e) {
|
|
51586
52136
|
return Promise.reject(e);
|
|
51587
52137
|
}
|
|
@@ -51640,14 +52190,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
51640
52190
|
}
|
|
51641
52191
|
}
|
|
51642
52192
|
}
|
|
51643
|
-
var
|
|
52193
|
+
var _temp11 = function () {
|
|
51644
52194
|
if (allowUpload) {
|
|
51645
52195
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
|
|
51646
52196
|
} else {
|
|
51647
52197
|
showFileUploadError(errorMessage);
|
|
51648
52198
|
}
|
|
51649
52199
|
}();
|
|
51650
|
-
return Promise.resolve(
|
|
52200
|
+
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(function () {}) : void 0);
|
|
51651
52201
|
} catch (e) {
|
|
51652
52202
|
return Promise.reject(e);
|
|
51653
52203
|
}
|
|
@@ -57991,5 +58541,5 @@ var unBlockUsers = function unBlockUsers(userIds, callback) {
|
|
|
57991
58541
|
});
|
|
57992
58542
|
};
|
|
57993
58543
|
|
|
57994
|
-
export { Attachment$1 as Attachment, Avatar, Channel, ChannelDetailsContainer as ChannelDetails, ChannelList, ChannelSearch, Chat, ChatHeader, CreateChannel, DropDown, EmojisPopup, ForwardMessagePopup, FrequentlyEmojis, MESSAGE_TYPE, MessagesContainer as MessageList, MessageStatusIcon, MessageTextFormat, MessagesScrollToBottomButton, MessagesScrollToUnreadMentionsButton, MessagesSearch, OGMetadata, PollMessage, SceytChatContainer as SceytChat, SendMessageInput as SendMessage, THEME_COLORS, blockUsers, createOrGetDirectChannel, handleGetMessage, handleSendMessage, switchChannelActiveChannel, unBlockUsers };
|
|
58544
|
+
export { Attachment$1 as Attachment, Avatar, Channel, ChannelDetailsContainer as ChannelDetails, ChannelList, ChannelSearch, Chat, ChatHeader, CreateChannel, DropDown, EmojisPopup, ForwardMessagePopup, FrequentlyEmojis, MESSAGE_TYPE, MessagesContainer as MessageList, MessageStatusIcon, MessageTextFormat, MessagesScrollToBottomButton, MessagesScrollToUnreadMentionsButton, MessagesSearch, OGMetadata, PollMessage, SceytChatContainer as SceytChat, SendMessageInput as SendMessage, THEME_COLORS, blockUsers, createOrGetDirectChannel, extractUrlMatches, handleGetMessage, handleSendMessage, switchChannelActiveChannel, unBlockUsers };
|
|
57995
58545
|
//# sourceMappingURL=index.modern.js.map
|