sceyt-chat-react-uikit 1.8.8-beta.7 → 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 +1009 -487
- package/index.modern.js +991 -488
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
2
2
|
|
|
3
|
+
function _interopNamespace(e) {
|
|
4
|
+
if (e && e.__esModule) { return e; } else {
|
|
5
|
+
var n = {};
|
|
6
|
+
if (e) {
|
|
7
|
+
Object.keys(e).forEach(function (k) {
|
|
8
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
9
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return e[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
n['default'] = e;
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
3
22
|
var React = require('react');
|
|
4
23
|
var React__default = _interopDefault(React);
|
|
5
24
|
var reactRedux = require('react-redux');
|
|
@@ -14849,198 +14868,677 @@ function calculateSize(width, height, maxWidth, maxHeight) {
|
|
|
14849
14868
|
}
|
|
14850
14869
|
var pica = new Pica();
|
|
14851
14870
|
|
|
14852
|
-
var
|
|
14853
|
-
|
|
14854
|
-
|
|
14871
|
+
var dbg = function dbg() {
|
|
14872
|
+
var _console;
|
|
14873
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14874
|
+
args[_key] = arguments[_key];
|
|
14875
|
+
}
|
|
14876
|
+
return (_console = console).log.apply(_console, ['[VIDEO_FIRST_FRAME]'].concat(args));
|
|
14877
|
+
};
|
|
14878
|
+
var toHex = function toHex(bytes) {
|
|
14879
|
+
return Array.from(bytes).map(function (b) {
|
|
14880
|
+
return b.toString(16).padStart(2, '0');
|
|
14881
|
+
}).join(' ');
|
|
14882
|
+
};
|
|
14883
|
+
var NATIVE_VIDEO_TYPES = new Set(['video/mp4', 'video/webm', 'video/ogg']);
|
|
14884
|
+
var findFourccs = function findFourccs(bytes, fourccs) {
|
|
14885
|
+
var found = [];
|
|
14886
|
+
for (var _iterator = _createForOfIteratorHelperLoose(fourccs), _step; !(_step = _iterator()).done;) {
|
|
14887
|
+
var cc = _step.value;
|
|
14888
|
+
var c0 = cc.charCodeAt(0);
|
|
14889
|
+
var c1 = cc.charCodeAt(1);
|
|
14890
|
+
var c2 = cc.charCodeAt(2);
|
|
14891
|
+
var c3 = cc.charCodeAt(3);
|
|
14892
|
+
for (var i = 0; i <= bytes.length - 4; i++) {
|
|
14893
|
+
if (bytes[i] === c0 && bytes[i + 1] === c1 && bytes[i + 2] === c2 && bytes[i + 3] === c3) {
|
|
14894
|
+
found.push(cc);
|
|
14895
|
+
break;
|
|
14896
|
+
}
|
|
14897
|
+
}
|
|
14855
14898
|
}
|
|
14899
|
+
return found;
|
|
14900
|
+
};
|
|
14901
|
+
var VIDEO_CODEC_FOURCCS = ['avc1', 'avc3', 'hvc1', 'hev1', 'av01', 'vp09', 'mp4v', 'apcn', 'apch', 'ap4h'];
|
|
14902
|
+
var isQuickTimeContainer = function isQuickTimeContainer(info) {
|
|
14903
|
+
return info.isoBrand === 'qt ';
|
|
14904
|
+
};
|
|
14905
|
+
var inspectVideoBlob = function inspectVideoBlob(blob) {
|
|
14856
14906
|
try {
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
URL.revokeObjectURL(video.src);
|
|
14907
|
+
var info = {
|
|
14908
|
+
mimeType: null,
|
|
14909
|
+
isoBrand: null,
|
|
14910
|
+
codecs: []
|
|
14911
|
+
};
|
|
14912
|
+
return Promise.resolve(_catch(function () {
|
|
14913
|
+
return Promise.resolve(blob.slice(0, 16).arrayBuffer()).then(function (_blob$slice$arrayBuff) {
|
|
14914
|
+
var _exit = false;
|
|
14915
|
+
function _temp4(_result) {
|
|
14916
|
+
if (_exit) return _result;
|
|
14917
|
+
if (head.length >= 4 && head[0] === 0x1a && head[1] === 0x45 && head[2] === 0xdf && head[3] === 0xa3) {
|
|
14918
|
+
dbg('sniff: EBML (webm/mkv) detected');
|
|
14919
|
+
info.mimeType = 'video/webm';
|
|
14920
|
+
return info;
|
|
14872
14921
|
}
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
canvas.toBlob(function (blob) {
|
|
14894
|
-
if (!blob) {
|
|
14895
|
-
cleanup();
|
|
14896
|
-
resolve(null);
|
|
14897
|
-
return;
|
|
14922
|
+
if (head.length >= 4 && head[0] === 0x4f && head[1] === 0x67 && head[2] === 0x67 && head[3] === 0x53) {
|
|
14923
|
+
dbg('sniff: Ogg detected');
|
|
14924
|
+
info.mimeType = 'video/ogg';
|
|
14925
|
+
return info;
|
|
14926
|
+
}
|
|
14927
|
+
dbg('sniff: unknown container');
|
|
14928
|
+
return info;
|
|
14929
|
+
}
|
|
14930
|
+
var head = new Uint8Array(_blob$slice$arrayBuff);
|
|
14931
|
+
dbg('sniff: first bytes =', toHex(head));
|
|
14932
|
+
var _temp3 = function () {
|
|
14933
|
+
if (head.length >= 8 && head[4] === 0x66 && head[5] === 0x74 && head[6] === 0x79 && head[7] === 0x70) {
|
|
14934
|
+
info.mimeType = 'video/mp4';
|
|
14935
|
+
info.isoBrand = String.fromCharCode(head[8] || 0, head[9] || 0, head[10] || 0, head[11] || 0);
|
|
14936
|
+
var scanSize = 512 * 1024;
|
|
14937
|
+
return Promise.resolve(blob.slice(0, Math.min(scanSize, blob.size)).arrayBuffer()).then(function (_blob$slice$arrayBuff2) {
|
|
14938
|
+
function _temp2() {
|
|
14939
|
+
dbg('sniff: ISO-BMFF, major brand =', JSON.stringify(info.isoBrand), 'codecs =', info.codecs.join(',') || 'none-found');
|
|
14940
|
+
_exit = true;
|
|
14941
|
+
return info;
|
|
14898
14942
|
}
|
|
14899
|
-
var
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
|
|
14908
|
-
|
|
14909
|
-
|
|
14943
|
+
var headChunk = new Uint8Array(_blob$slice$arrayBuff2);
|
|
14944
|
+
info.codecs = findFourccs(headChunk, VIDEO_CODEC_FOURCCS);
|
|
14945
|
+
var _temp = function () {
|
|
14946
|
+
if (!info.codecs.length && blob.size > scanSize) {
|
|
14947
|
+
return Promise.resolve(blob.slice(Math.max(0, blob.size - scanSize)).arrayBuffer()).then(function (_blob$slice$arrayBuff3) {
|
|
14948
|
+
var tailChunk = new Uint8Array(_blob$slice$arrayBuff3);
|
|
14949
|
+
info.codecs = findFourccs(tailChunk, VIDEO_CODEC_FOURCCS);
|
|
14950
|
+
});
|
|
14951
|
+
}
|
|
14952
|
+
}();
|
|
14953
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
14954
|
+
});
|
|
14910
14955
|
}
|
|
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
|
-
|
|
14938
|
-
|
|
14956
|
+
}();
|
|
14957
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
14958
|
+
});
|
|
14959
|
+
}, function (error) {
|
|
14960
|
+
log.error('Failed to sniff video container:', error);
|
|
14961
|
+
return info;
|
|
14962
|
+
}));
|
|
14963
|
+
} catch (e) {
|
|
14964
|
+
return Promise.reject(e);
|
|
14965
|
+
}
|
|
14966
|
+
};
|
|
14967
|
+
var isFirefox = function isFirefox() {
|
|
14968
|
+
return typeof navigator !== 'undefined' && /firefox/i.test(navigator.userAgent);
|
|
14969
|
+
};
|
|
14970
|
+
|
|
14971
|
+
var dbg$1 = function dbg() {
|
|
14972
|
+
var _console;
|
|
14973
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14974
|
+
args[_key] = arguments[_key];
|
|
14975
|
+
}
|
|
14976
|
+
return (_console = console).log.apply(_console, ['[VIDEO_FIRST_FRAME]'].concat(args));
|
|
14977
|
+
};
|
|
14978
|
+
var REMUX_MAX_BYTES = 200 * 1024 * 1024;
|
|
14979
|
+
var remuxCounter = 0;
|
|
14980
|
+
var remuxToMp4 = function remuxToMp4(blob) {
|
|
14981
|
+
try {
|
|
14982
|
+
if (blob.size > REMUX_MAX_BYTES) {
|
|
14983
|
+
dbg$1('remux: skipped, file too large:', blob.size);
|
|
14984
|
+
log.warn('remuxToMp4: file too large to remux in browser:', blob.size);
|
|
14985
|
+
return Promise.resolve(null);
|
|
14986
|
+
}
|
|
14987
|
+
var id = Date.now() + "_" + remuxCounter++;
|
|
14988
|
+
var inputName = "remux_" + id + "_in.mov";
|
|
14989
|
+
var outputName = "remux_" + id + "_out.mp4";
|
|
14990
|
+
var ffmpeg = null;
|
|
14991
|
+
return Promise.resolve(_finallyRethrows(function () {
|
|
14992
|
+
return _catch(function () {
|
|
14993
|
+
dbg$1('remux: starting ffmpeg -c copy remux, size =', blob.size);
|
|
14994
|
+
return Promise.resolve(Promise.all([Promise.resolve().then(function () { return audioConversion; }), new Promise(function (resolve) { resolve(_interopNamespace(require('@ffmpeg/util'))); })])).then(function (_ref) {
|
|
14995
|
+
var initFFmpeg = _ref[0].initFFmpeg,
|
|
14996
|
+
fetchFile = _ref[1].fetchFile;
|
|
14997
|
+
return Promise.resolve(initFFmpeg()).then(function (_initFFmpeg) {
|
|
14998
|
+
ffmpeg = _initFFmpeg;
|
|
14999
|
+
var _ffmpeg = ffmpeg,
|
|
15000
|
+
_writeFile = _ffmpeg.writeFile;
|
|
15001
|
+
return Promise.resolve(fetchFile(blob)).then(function (_fetchFile) {
|
|
15002
|
+
return Promise.resolve(_writeFile.call(_ffmpeg, inputName, _fetchFile)).then(function () {
|
|
15003
|
+
return Promise.resolve(ffmpeg.exec(['-i', inputName, '-c', 'copy', '-movflags', '+faststart', outputName])).then(function () {
|
|
15004
|
+
return Promise.resolve(ffmpeg.readFile(outputName)).then(function (data) {
|
|
15005
|
+
var bytes;
|
|
15006
|
+
if (data instanceof Uint8Array) {
|
|
15007
|
+
bytes = data;
|
|
15008
|
+
} else if (typeof data === 'string') {
|
|
15009
|
+
var binaryString = atob(data);
|
|
15010
|
+
bytes = new Uint8Array(binaryString.length);
|
|
15011
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
15012
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
15013
|
+
}
|
|
15014
|
+
} else {
|
|
15015
|
+
bytes = new Uint8Array(data);
|
|
15016
|
+
}
|
|
15017
|
+
if (!bytes.length) {
|
|
15018
|
+
dbg$1('remux: ffmpeg produced empty output');
|
|
15019
|
+
return null;
|
|
15020
|
+
}
|
|
15021
|
+
var arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
15022
|
+
dbg$1('remux: done, output size =', bytes.length);
|
|
15023
|
+
return new Blob([arrayBuffer], {
|
|
15024
|
+
type: 'video/mp4'
|
|
15025
|
+
});
|
|
15026
|
+
});
|
|
15027
|
+
});
|
|
15028
|
+
});
|
|
15029
|
+
});
|
|
15030
|
+
});
|
|
15031
|
+
});
|
|
15032
|
+
}, function (error) {
|
|
15033
|
+
dbg$1('remux: FAILED', error);
|
|
15034
|
+
log.error('remuxToMp4: remux failed:', error);
|
|
15035
|
+
return null;
|
|
15036
|
+
});
|
|
15037
|
+
}, function (_wasThrown, _result) {
|
|
15038
|
+
function _temp5() {
|
|
15039
|
+
if (_wasThrown) throw _result;
|
|
15040
|
+
return _result;
|
|
15041
|
+
}
|
|
15042
|
+
var _temp4 = function () {
|
|
15043
|
+
if (ffmpeg) {
|
|
15044
|
+
var _temp3 = function _temp3() {
|
|
15045
|
+
var _temp = _catch(function () {
|
|
15046
|
+
return Promise.resolve(ffmpeg.deleteFile(outputName)).then(function () {});
|
|
15047
|
+
}, function () {});
|
|
15048
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
14939
15049
|
};
|
|
15050
|
+
var _temp2 = _catch(function () {
|
|
15051
|
+
return Promise.resolve(ffmpeg.deleteFile(inputName)).then(function () {});
|
|
15052
|
+
}, function () {});
|
|
15053
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
15054
|
+
}
|
|
15055
|
+
}();
|
|
15056
|
+
return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
|
|
15057
|
+
}));
|
|
15058
|
+
} catch (e) {
|
|
15059
|
+
return Promise.reject(e);
|
|
15060
|
+
}
|
|
15061
|
+
};
|
|
15062
|
+
var remuxVideoFileForUpload = function remuxVideoFileForUpload(file) {
|
|
15063
|
+
try {
|
|
15064
|
+
return Promise.resolve(_catch(function () {
|
|
15065
|
+
return Promise.resolve(inspectVideoBlob(file)).then(function (info) {
|
|
15066
|
+
if (!isQuickTimeContainer(info)) {
|
|
15067
|
+
return file;
|
|
15068
|
+
}
|
|
15069
|
+
dbg$1('upload: QuickTime file picked, remuxing before upload:', file.name);
|
|
15070
|
+
return Promise.resolve(remuxToMp4(file)).then(function (remuxed) {
|
|
15071
|
+
if (!remuxed) {
|
|
15072
|
+
log.warn('remuxVideoFileForUpload: remux failed, uploading original file');
|
|
15073
|
+
return file;
|
|
15074
|
+
}
|
|
15075
|
+
var newName = /\.(mov|qt)$/i.test(file.name) ? file.name.replace(/\.(mov|qt)$/i, '.mp4') : file.name + ".mp4";
|
|
15076
|
+
return new File([remuxed], newName, {
|
|
15077
|
+
type: 'video/mp4',
|
|
15078
|
+
lastModified: file.lastModified
|
|
15079
|
+
});
|
|
15080
|
+
});
|
|
15081
|
+
});
|
|
15082
|
+
}, function (error) {
|
|
15083
|
+
log.error('remuxVideoFileForUpload failed, uploading original file:', error);
|
|
15084
|
+
return file;
|
|
15085
|
+
}));
|
|
15086
|
+
} catch (e) {
|
|
15087
|
+
return Promise.reject(e);
|
|
15088
|
+
}
|
|
15089
|
+
};
|
|
15090
|
+
var ensurePlayableVideoBlob = function ensurePlayableVideoBlob(blob) {
|
|
15091
|
+
try {
|
|
15092
|
+
return Promise.resolve(_catch(function () {
|
|
15093
|
+
return isFirefox() ? Promise.resolve(inspectVideoBlob(blob)).then(function (info) {
|
|
15094
|
+
if (!isQuickTimeContainer(info)) {
|
|
15095
|
+
return blob;
|
|
15096
|
+
}
|
|
15097
|
+
dbg$1('download: QuickTime blob in Firefox, remuxing for playback');
|
|
15098
|
+
return Promise.resolve(remuxToMp4(blob)).then(function (remuxed) {
|
|
15099
|
+
return remuxed || blob;
|
|
15100
|
+
});
|
|
15101
|
+
}) : blob;
|
|
15102
|
+
}, function (error) {
|
|
15103
|
+
log.error('ensurePlayableVideoBlob failed, using original blob:', error);
|
|
15104
|
+
return blob;
|
|
15105
|
+
}));
|
|
15106
|
+
} catch (e) {
|
|
15107
|
+
return Promise.reject(e);
|
|
15108
|
+
}
|
|
15109
|
+
};
|
|
15110
|
+
|
|
15111
|
+
var getFrame = function getFrame(videoSrc, _time) {
|
|
15112
|
+
try {
|
|
15113
|
+
if (!videoSrc) {
|
|
15114
|
+
throw new Error('src not found');
|
|
15115
|
+
}
|
|
15116
|
+
return Promise.resolve(getVideoFirstFrame(videoSrc)).then(function (frameResult) {
|
|
15117
|
+
if (!frameResult) {
|
|
15118
|
+
throw new Error('Failed to extract video frame');
|
|
15119
|
+
}
|
|
15120
|
+
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
15121
|
+
origWidth = frameResult.width,
|
|
15122
|
+
origHeight = frameResult.height;
|
|
15123
|
+
var duration = Number(frameResult.duration.toFixed(0));
|
|
15124
|
+
var _calculateSize = calculateSize(origWidth, origHeight, 100, 100),
|
|
15125
|
+
newWidth = _calculateSize[0],
|
|
15126
|
+
newHeight = _calculateSize[1];
|
|
15127
|
+
return new Promise(function (resolve, reject) {
|
|
15128
|
+
var img = document.createElement('img');
|
|
15129
|
+
img.onload = function () {
|
|
15130
|
+
var canvas = document.createElement('canvas');
|
|
15131
|
+
canvas.width = newWidth;
|
|
15132
|
+
canvas.height = newHeight;
|
|
15133
|
+
var ctx = canvas.getContext('2d');
|
|
15134
|
+
if (!ctx) {
|
|
15135
|
+
URL.revokeObjectURL(frameBlobUrl);
|
|
15136
|
+
reject(new Error('Failed to get canvas context'));
|
|
15137
|
+
return;
|
|
15138
|
+
}
|
|
15139
|
+
ctx.drawImage(img, 0, 0, newWidth, newHeight);
|
|
15140
|
+
var pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
15141
|
+
var binaryThumbHash = rgbaToThumbHash(pixels.width, pixels.height, pixels.data);
|
|
15142
|
+
var thumb = binaryToBase64(binaryThumbHash);
|
|
15143
|
+
URL.revokeObjectURL(frameBlobUrl);
|
|
15144
|
+
resolve({
|
|
15145
|
+
thumb: thumb,
|
|
15146
|
+
width: origWidth,
|
|
15147
|
+
height: origHeight,
|
|
15148
|
+
duration: duration
|
|
15149
|
+
});
|
|
14940
15150
|
};
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
resolve(null);
|
|
15151
|
+
img.onerror = function () {
|
|
15152
|
+
URL.revokeObjectURL(frameBlobUrl);
|
|
15153
|
+
reject(new Error('Failed to load frame image'));
|
|
14945
15154
|
};
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
15155
|
+
img.src = frameBlobUrl;
|
|
15156
|
+
});
|
|
15157
|
+
});
|
|
15158
|
+
} catch (e) {
|
|
15159
|
+
return Promise.reject(e);
|
|
15160
|
+
}
|
|
15161
|
+
};
|
|
15162
|
+
var getVideoFirstFrame = function getVideoFirstFrame(videoSrc, maxWidth, maxHeight, quality) {
|
|
15163
|
+
if (quality === void 0) {
|
|
15164
|
+
quality = 0.8;
|
|
15165
|
+
}
|
|
15166
|
+
try {
|
|
15167
|
+
var _exit3 = false;
|
|
15168
|
+
return Promise.resolve(_catch(function () {
|
|
15169
|
+
function _temp0(_result3) {
|
|
15170
|
+
var _exit4 = false;
|
|
15171
|
+
if (_exit3) return _result3;
|
|
15172
|
+
function _temp8(_result4) {
|
|
15173
|
+
if (_exit4) return _result4;
|
|
15174
|
+
dbg$2('source: remote URL —', videoSrc.slice(0, 150));
|
|
15175
|
+
return Promise.resolve(extractFrameFromUrl(videoSrc, maxWidth, maxHeight, quality)).then(function (direct) {
|
|
15176
|
+
if (direct) {
|
|
15177
|
+
return direct;
|
|
15178
|
+
}
|
|
15179
|
+
dbg$2('source: direct remote load failed, retrying via fetch + relabel');
|
|
15180
|
+
return _catch(function () {
|
|
15181
|
+
return Promise.resolve(fetch(videoSrc)).then(function (response) {
|
|
15182
|
+
return Promise.resolve(response.blob()).then(function (blob) {
|
|
15183
|
+
dbg$2('source: remote fetched, Content-Type =', JSON.stringify(response.headers.get('content-type')), 'blob type =', JSON.stringify(blob.type), 'size =', blob.size);
|
|
15184
|
+
return Promise.resolve(_extractFrameFromBlob2(blob, maxWidth, maxHeight, quality));
|
|
15185
|
+
});
|
|
15186
|
+
});
|
|
15187
|
+
}, function (error) {
|
|
15188
|
+
dbg$2('source: remote fetch retry FAILED', error);
|
|
15189
|
+
log.error('getVideoFirstFrame: fetch retry failed:', error);
|
|
15190
|
+
return null;
|
|
15191
|
+
});
|
|
15192
|
+
});
|
|
15193
|
+
}
|
|
15194
|
+
var _temp7 = function () {
|
|
15195
|
+
if (videoSrc.startsWith('blob:')) {
|
|
15196
|
+
dbg$2('source: blob URL string —', videoSrc.slice(0, 100));
|
|
15197
|
+
return _catch(function () {
|
|
15198
|
+
return Promise.resolve(fetch(videoSrc)).then(function (_fetch) {
|
|
15199
|
+
return Promise.resolve(_fetch.blob()).then(function (blob) {
|
|
15200
|
+
dbg$2('source: blob URL re-fetched, type =', JSON.stringify(blob.type), 'size =', blob.size);
|
|
15201
|
+
return Promise.resolve(_extractFrameFromBlob2(blob, maxWidth, maxHeight, quality)).then(function (_await$_extractFrameF2) {
|
|
15202
|
+
_exit4 = true;
|
|
15203
|
+
return _await$_extractFrameF2;
|
|
15204
|
+
});
|
|
15205
|
+
});
|
|
15206
|
+
});
|
|
15207
|
+
}, function (error) {
|
|
15208
|
+
dbg$2('source: blob URL re-fetch FAILED, falling back to direct', error);
|
|
15209
|
+
log.warn('getVideoFirstFrame: failed to re-fetch blob url, trying directly', error);
|
|
15210
|
+
return Promise.resolve(extractFrameFromUrl(videoSrc, maxWidth, maxHeight, quality)).then(function (_await$extractFrameFr) {
|
|
15211
|
+
_exit4 = true;
|
|
15212
|
+
return _await$extractFrameFr;
|
|
15213
|
+
});
|
|
15214
|
+
});
|
|
15215
|
+
}
|
|
15216
|
+
}();
|
|
15217
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
14949
15218
|
}
|
|
15219
|
+
var _temp9 = function () {
|
|
15220
|
+
if (videoSrc instanceof Blob) {
|
|
15221
|
+
dbg$2('source: Blob, type =', JSON.stringify(videoSrc.type), 'size =', videoSrc.size);
|
|
15222
|
+
return Promise.resolve(_extractFrameFromBlob2(videoSrc, maxWidth, maxHeight, quality)).then(function (_await$_extractFrameF) {
|
|
15223
|
+
_exit3 = true;
|
|
15224
|
+
return _await$_extractFrameF;
|
|
15225
|
+
});
|
|
15226
|
+
}
|
|
15227
|
+
}();
|
|
15228
|
+
return _temp9 && _temp9.then ? _temp9.then(_temp0) : _temp0(_temp9);
|
|
15229
|
+
}, function (error) {
|
|
15230
|
+
log.error('Error in getVideoFirstFrame:', error);
|
|
15231
|
+
return null;
|
|
14950
15232
|
}));
|
|
14951
15233
|
} catch (e) {
|
|
14952
15234
|
return Promise.reject(e);
|
|
14953
15235
|
}
|
|
14954
15236
|
};
|
|
14955
|
-
var
|
|
15237
|
+
var dbg$2 = function dbg() {
|
|
15238
|
+
var _console;
|
|
15239
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15240
|
+
args[_key] = arguments[_key];
|
|
15241
|
+
}
|
|
15242
|
+
return (_console = console).log.apply(_console, ['[VIDEO_FIRST_FRAME]'].concat(args));
|
|
15243
|
+
};
|
|
15244
|
+
var normalizeVideoBlob = function normalizeVideoBlob(blob) {
|
|
14956
15245
|
try {
|
|
14957
|
-
return Promise.resolve(
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
15246
|
+
return Promise.resolve(inspectVideoBlob(blob)).then(function (info) {
|
|
15247
|
+
var baseType = (blob.type || '').split(';')[0].trim().toLowerCase();
|
|
15248
|
+
if (NATIVE_VIDEO_TYPES.has(baseType)) {
|
|
15249
|
+
dbg$2('normalize: declared type is native:', JSON.stringify(blob.type), '→', JSON.stringify(baseType));
|
|
15250
|
+
return {
|
|
15251
|
+
safeBlob: baseType === blob.type ? blob : new Blob([blob], {
|
|
15252
|
+
type: baseType
|
|
15253
|
+
}),
|
|
15254
|
+
info: info
|
|
15255
|
+
};
|
|
14961
15256
|
}
|
|
15257
|
+
var relabeledType = info.mimeType || 'video/mp4';
|
|
15258
|
+
dbg$2('normalize: declared', JSON.stringify(blob.type), '→ relabeled to', JSON.stringify(relabeledType));
|
|
15259
|
+
return {
|
|
15260
|
+
safeBlob: new Blob([blob], {
|
|
15261
|
+
type: relabeledType
|
|
15262
|
+
}),
|
|
15263
|
+
info: info
|
|
15264
|
+
};
|
|
15265
|
+
});
|
|
15266
|
+
} catch (e) {
|
|
15267
|
+
return Promise.reject(e);
|
|
15268
|
+
}
|
|
15269
|
+
};
|
|
15270
|
+
var FRAME_LOAD_TIMEOUT_MS = 8000;
|
|
15271
|
+
var READY_STATES = ['HAVE_NOTHING', 'HAVE_METADATA', 'HAVE_CURRENT_DATA', 'HAVE_FUTURE_DATA', 'HAVE_ENOUGH_DATA'];
|
|
15272
|
+
var NETWORK_STATES = ['NETWORK_EMPTY', 'NETWORK_IDLE', 'NETWORK_LOADING', 'NETWORK_NO_SOURCE'];
|
|
15273
|
+
var describeVideoState = function describeVideoState(video) {
|
|
15274
|
+
var buffered = 'none';
|
|
15275
|
+
try {
|
|
15276
|
+
var ranges = [];
|
|
15277
|
+
for (var i = 0; i < video.buffered.length; i++) {
|
|
15278
|
+
ranges.push(video.buffered.start(i).toFixed(2) + "-" + video.buffered.end(i).toFixed(2));
|
|
15279
|
+
}
|
|
15280
|
+
buffered = ranges.join(',') || 'empty';
|
|
15281
|
+
} catch (e) {
|
|
15282
|
+
buffered = 'unavailable';
|
|
15283
|
+
}
|
|
15284
|
+
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'));
|
|
15285
|
+
};
|
|
15286
|
+
var extractFrameFromUrl = function extractFrameFromUrl(srcUrl, maxWidth, maxHeight, quality) {
|
|
15287
|
+
if (quality === void 0) {
|
|
15288
|
+
quality = 0.8;
|
|
15289
|
+
}
|
|
15290
|
+
return new Promise(function (resolve) {
|
|
15291
|
+
try {
|
|
15292
|
+
dbg$2('extract: start, src =', srcUrl.slice(0, 100));
|
|
14962
15293
|
var video = document.createElement('video');
|
|
14963
|
-
video.preload = '
|
|
15294
|
+
video.preload = 'auto';
|
|
14964
15295
|
video.muted = true;
|
|
14965
15296
|
video.setAttribute('playsinline', 'true');
|
|
14966
|
-
|
|
14967
|
-
|
|
15297
|
+
if (!srcUrl.startsWith('blob:') && !srcUrl.startsWith('data:')) {
|
|
15298
|
+
video.crossOrigin = 'anonymous';
|
|
15299
|
+
}
|
|
15300
|
+
video.style.position = 'fixed';
|
|
15301
|
+
video.style.bottom = '0';
|
|
15302
|
+
video.style.left = '0';
|
|
15303
|
+
video.style.width = '2px';
|
|
15304
|
+
video.style.height = '2px';
|
|
15305
|
+
video.style.opacity = '0';
|
|
15306
|
+
video.style.pointerEvents = 'none';
|
|
15307
|
+
video.style.zIndex = '-1';
|
|
15308
|
+
document.body.appendChild(video);
|
|
15309
|
+
var settled = false;
|
|
15310
|
+
var finishOnce = function finishOnce(result) {
|
|
15311
|
+
if (settled) return;
|
|
15312
|
+
settled = true;
|
|
15313
|
+
clearTimeout(stallTimer);
|
|
15314
|
+
if (video.parentNode) {
|
|
15315
|
+
video.parentNode.removeChild(video);
|
|
15316
|
+
}
|
|
15317
|
+
dbg$2('extract: finished,', result ? 'SUCCESS' : 'NULL');
|
|
15318
|
+
resolve(result);
|
|
15319
|
+
};
|
|
15320
|
+
var stallTimer = setTimeout(function () {
|
|
15321
|
+
dbg$2('extract: TIMEOUT —', describeVideoState(video));
|
|
15322
|
+
log.warn('getVideoFirstFrame: timed out waiting for video to load');
|
|
15323
|
+
finishOnce(null);
|
|
15324
|
+
}, FRAME_LOAD_TIMEOUT_MS);
|
|
15325
|
+
var extractFrame = function extractFrame() {
|
|
14968
15326
|
try {
|
|
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
|
-
|
|
15001
|
-
height: origHeight,
|
|
15002
|
-
duration: duration
|
|
15003
|
-
});
|
|
15004
|
-
};
|
|
15005
|
-
img.onerror = function () {
|
|
15006
|
-
URL.revokeObjectURL(frameResult.frameBlobUrl);
|
|
15007
|
-
reject(new Error('Failed to load frame image'));
|
|
15008
|
-
};
|
|
15009
|
-
img.src = frameResult.frameBlobUrl;
|
|
15327
|
+
dbg$2('extract: extractFrame,', describeVideoState(video));
|
|
15328
|
+
if (video.videoWidth === 0 || video.videoHeight === 0) {
|
|
15329
|
+
finishOnce(null);
|
|
15330
|
+
return;
|
|
15331
|
+
}
|
|
15332
|
+
var width = video.videoWidth;
|
|
15333
|
+
var height = video.videoHeight;
|
|
15334
|
+
var duration = Number.isFinite(video.duration) ? video.duration : 0;
|
|
15335
|
+
var canvasWidth = maxWidth || width / 2;
|
|
15336
|
+
var canvasHeight = maxHeight || height / 2;
|
|
15337
|
+
var canvas = document.createElement('canvas');
|
|
15338
|
+
canvas.width = canvasWidth;
|
|
15339
|
+
canvas.height = canvasHeight;
|
|
15340
|
+
var ctx = canvas.getContext('2d');
|
|
15341
|
+
if (!ctx) {
|
|
15342
|
+
finishOnce(null);
|
|
15343
|
+
return;
|
|
15344
|
+
}
|
|
15345
|
+
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
15346
|
+
canvas.toBlob(function (blob) {
|
|
15347
|
+
if (!blob) {
|
|
15348
|
+
dbg$2('extract: canvas.toBlob returned null');
|
|
15349
|
+
finishOnce(null);
|
|
15350
|
+
return;
|
|
15351
|
+
}
|
|
15352
|
+
var frameBlobUrl = URL.createObjectURL(blob);
|
|
15353
|
+
finishOnce({
|
|
15354
|
+
frameBlobUrl: frameBlobUrl,
|
|
15355
|
+
blob: blob,
|
|
15356
|
+
width: width,
|
|
15357
|
+
height: height,
|
|
15358
|
+
duration: duration
|
|
15010
15359
|
});
|
|
15011
|
-
},
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
|
|
15360
|
+
}, 'image/jpeg', quality);
|
|
15361
|
+
} catch (error) {
|
|
15362
|
+
dbg$2('extract: extractFrame threw', error);
|
|
15363
|
+
log.error('Error extracting video frame:', error);
|
|
15364
|
+
finishOnce(null);
|
|
15016
15365
|
}
|
|
15017
15366
|
};
|
|
15367
|
+
video.addEventListener('loadstart', function () {
|
|
15368
|
+
return dbg$2('event: loadstart,', describeVideoState(video));
|
|
15369
|
+
});
|
|
15370
|
+
video.addEventListener('loadeddata', function () {
|
|
15371
|
+
return dbg$2('event: loadeddata,', describeVideoState(video));
|
|
15372
|
+
});
|
|
15373
|
+
video.addEventListener('canplay', function () {
|
|
15374
|
+
return dbg$2('event: canplay,', describeVideoState(video));
|
|
15375
|
+
});
|
|
15376
|
+
video.addEventListener('canplaythrough', function () {
|
|
15377
|
+
return dbg$2('event: canplaythrough');
|
|
15378
|
+
});
|
|
15379
|
+
video.addEventListener('seeking', function () {
|
|
15380
|
+
return dbg$2('event: seeking, currentTime =', video.currentTime);
|
|
15381
|
+
});
|
|
15382
|
+
video.addEventListener('stalled', function () {
|
|
15383
|
+
return dbg$2('event: stalled,', describeVideoState(video));
|
|
15384
|
+
});
|
|
15385
|
+
video.addEventListener('suspend', function () {
|
|
15386
|
+
return dbg$2('event: suspend,', describeVideoState(video));
|
|
15387
|
+
});
|
|
15388
|
+
video.addEventListener('waiting', function () {
|
|
15389
|
+
return dbg$2('event: waiting,', describeVideoState(video));
|
|
15390
|
+
});
|
|
15391
|
+
video.addEventListener('emptied', function () {
|
|
15392
|
+
return dbg$2('event: emptied,', describeVideoState(video));
|
|
15393
|
+
});
|
|
15394
|
+
video.onloadedmetadata = function () {
|
|
15395
|
+
dbg$2('event: loadedmetadata,', describeVideoState(video));
|
|
15396
|
+
video.currentTime = 0.01;
|
|
15397
|
+
video.onseeked = function () {
|
|
15398
|
+
dbg$2('event: seeked,', describeVideoState(video));
|
|
15399
|
+
video.onseeked = null;
|
|
15400
|
+
var capture = function capture() {
|
|
15401
|
+
return requestAnimationFrame(extractFrame);
|
|
15402
|
+
};
|
|
15403
|
+
video.play().then(function () {
|
|
15404
|
+
dbg$2('play(): resolved');
|
|
15405
|
+
var done = false;
|
|
15406
|
+
var _finish = function finish() {
|
|
15407
|
+
if (done) return;
|
|
15408
|
+
done = true;
|
|
15409
|
+
video.removeEventListener('timeupdate', _finish);
|
|
15410
|
+
video.removeEventListener('ended', _finish);
|
|
15411
|
+
video.pause();
|
|
15412
|
+
capture();
|
|
15413
|
+
};
|
|
15414
|
+
video.addEventListener('timeupdate', _finish);
|
|
15415
|
+
video.addEventListener('ended', _finish);
|
|
15416
|
+
setTimeout(_finish, 500);
|
|
15417
|
+
})["catch"](function (err) {
|
|
15418
|
+
dbg$2('play(): rejected —', err === null || err === void 0 ? void 0 : err.name, err === null || err === void 0 ? void 0 : err.message);
|
|
15419
|
+
capture();
|
|
15420
|
+
});
|
|
15421
|
+
};
|
|
15422
|
+
};
|
|
15018
15423
|
video.onerror = function () {
|
|
15019
|
-
|
|
15424
|
+
dbg$2('event: error,', describeVideoState(video));
|
|
15425
|
+
log.warn('getVideoFirstFrame: video failed to load', video.error);
|
|
15426
|
+
finishOnce(null);
|
|
15020
15427
|
};
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15428
|
+
video.onabort = function () {
|
|
15429
|
+
dbg$2('event: abort,', describeVideoState(video));
|
|
15430
|
+
finishOnce(null);
|
|
15431
|
+
};
|
|
15432
|
+
video.src = srcUrl;
|
|
15433
|
+
dbg$2('extract: src assigned,', describeVideoState(video));
|
|
15434
|
+
} catch (error) {
|
|
15435
|
+
log.error('Error in extractFrameFromUrl:', error);
|
|
15436
|
+
resolve(null);
|
|
15437
|
+
}
|
|
15438
|
+
});
|
|
15439
|
+
};
|
|
15440
|
+
var DATA_URL_MAX_BYTES = 64 * 1024 * 1024;
|
|
15441
|
+
var blobToDataUrl = function blobToDataUrl(blob) {
|
|
15442
|
+
return new Promise(function (resolve, reject) {
|
|
15443
|
+
var reader = new FileReader();
|
|
15444
|
+
reader.onload = function () {
|
|
15445
|
+
return resolve(reader.result);
|
|
15446
|
+
};
|
|
15447
|
+
reader.onerror = function () {
|
|
15448
|
+
return reject(reader.error);
|
|
15449
|
+
};
|
|
15450
|
+
reader.readAsDataURL(blob);
|
|
15451
|
+
});
|
|
15452
|
+
};
|
|
15453
|
+
var _extractFrameFromBlob2 = function extractFrameFromBlob(blob, maxWidth, maxHeight, quality, allowRemux) {
|
|
15454
|
+
if (quality === void 0) {
|
|
15455
|
+
quality = 0.8;
|
|
15024
15456
|
}
|
|
15457
|
+
if (allowRemux === void 0) {
|
|
15458
|
+
allowRemux = true;
|
|
15459
|
+
}
|
|
15460
|
+
return Promise.resolve(normalizeVideoBlob(blob)).then(function (_ref) {
|
|
15461
|
+
var _exit = false;
|
|
15462
|
+
var safeBlob = _ref.safeBlob,
|
|
15463
|
+
info = _ref.info;
|
|
15464
|
+
function _temp6(_result) {
|
|
15465
|
+
var _exit2 = false;
|
|
15466
|
+
if (_exit) return _result;
|
|
15467
|
+
function _temp4(_result2) {
|
|
15468
|
+
if (_exit2) return _result2;
|
|
15469
|
+
if (safeBlob.size > DATA_URL_MAX_BYTES) {
|
|
15470
|
+
dbg$2('fallback: blob too large for data URL fallback, size =', safeBlob.size);
|
|
15471
|
+
return null;
|
|
15472
|
+
}
|
|
15473
|
+
return _catch(function () {
|
|
15474
|
+
dbg$2('fallback: retrying via data URL, size =', safeBlob.size);
|
|
15475
|
+
return Promise.resolve(blobToDataUrl(safeBlob)).then(function (dataUrl) {
|
|
15476
|
+
return Promise.resolve(extractFrameFromUrl(dataUrl, maxWidth, maxHeight, quality));
|
|
15477
|
+
});
|
|
15478
|
+
}, function (error) {
|
|
15479
|
+
dbg$2('fallback: data URL conversion failed', error);
|
|
15480
|
+
log.error('getVideoFirstFrame: data URL fallback failed:', error);
|
|
15481
|
+
return null;
|
|
15482
|
+
});
|
|
15483
|
+
}
|
|
15484
|
+
var url = URL.createObjectURL(safeBlob);
|
|
15485
|
+
var _temp3 = _finallyRethrows(function () {
|
|
15486
|
+
return Promise.resolve(extractFrameFromUrl(url, maxWidth, maxHeight, quality)).then(function (result) {
|
|
15487
|
+
if (result) {
|
|
15488
|
+
_exit2 = true;
|
|
15489
|
+
return result;
|
|
15490
|
+
}
|
|
15491
|
+
});
|
|
15492
|
+
}, function (_wasThrown, _result2) {
|
|
15493
|
+
URL.revokeObjectURL(url);
|
|
15494
|
+
if (_wasThrown) throw _result2;
|
|
15495
|
+
return _result2;
|
|
15496
|
+
});
|
|
15497
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
15498
|
+
}
|
|
15499
|
+
var _temp5 = function () {
|
|
15500
|
+
if (isQuickTimeContainer(info) && isFirefox()) {
|
|
15501
|
+
if (!allowRemux) {
|
|
15502
|
+
dbg$2('skip: remuxed output is still a QuickTime container — giving up');
|
|
15503
|
+
var _temp = null;
|
|
15504
|
+
_exit = true;
|
|
15505
|
+
return _temp;
|
|
15506
|
+
}
|
|
15507
|
+
dbg$2('skip: QuickTime (qt brand) container — Firefox cannot demux this, remuxing. codecs =', info.codecs.join(',') || '?');
|
|
15508
|
+
return Promise.resolve(remuxToMp4(safeBlob)).then(function (remuxed) {
|
|
15509
|
+
if (!remuxed) {
|
|
15510
|
+
log.warn('getVideoFirstFrame: QuickTime container is not supported by Firefox and remux failed');
|
|
15511
|
+
var _temp2 = null;
|
|
15512
|
+
_exit = true;
|
|
15513
|
+
return _temp2;
|
|
15514
|
+
}
|
|
15515
|
+
var _extractFrameFromBlob = _extractFrameFromBlob2(remuxed, maxWidth, maxHeight, quality, false);
|
|
15516
|
+
_exit = true;
|
|
15517
|
+
return _extractFrameFromBlob;
|
|
15518
|
+
});
|
|
15519
|
+
}
|
|
15520
|
+
}();
|
|
15521
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
15522
|
+
});
|
|
15025
15523
|
};
|
|
15026
15524
|
var compressAndCacheImage = function compressAndCacheImage(url, cacheKey, maxWidth, maxHeight, quality) {
|
|
15027
15525
|
try {
|
|
15028
15526
|
return Promise.resolve(_catch(function () {
|
|
15029
15527
|
return Promise.resolve(fetch(url)).then(function (response) {
|
|
15030
15528
|
return response.ok ? Promise.resolve(response.blob()).then(function (blob) {
|
|
15031
|
-
var
|
|
15032
|
-
function
|
|
15033
|
-
if (
|
|
15529
|
+
var _exit5 = false;
|
|
15530
|
+
function _temp10(_result5) {
|
|
15531
|
+
if (_exit5) return _result5;
|
|
15034
15532
|
setAttachmentToCache(cacheKey, response);
|
|
15035
15533
|
return '';
|
|
15036
15534
|
}
|
|
15037
|
-
var
|
|
15535
|
+
var _temp1 = function () {
|
|
15038
15536
|
if (blob.type.startsWith('image/')) {
|
|
15039
15537
|
var file = new File([blob], 'image.jpeg', {
|
|
15040
15538
|
type: blob.type
|
|
15041
15539
|
});
|
|
15042
|
-
return Promise.resolve(resizeImageWithPica(file, maxWidth || 1280, maxHeight || 1080, quality || 1)).then(function (
|
|
15043
|
-
var compressedBlob =
|
|
15540
|
+
return Promise.resolve(resizeImageWithPica(file, maxWidth || 1280, maxHeight || 1080, quality || 1)).then(function (_ref2) {
|
|
15541
|
+
var compressedBlob = _ref2.blob;
|
|
15044
15542
|
var returningUrl = compressedBlob ? URL.createObjectURL(compressedBlob) : '';
|
|
15045
15543
|
if (compressedBlob) {
|
|
15046
15544
|
var compressedResponse = new Response(compressedBlob, {
|
|
@@ -15049,13 +15547,13 @@ var compressAndCacheImage = function compressAndCacheImage(url, cacheKey, maxWid
|
|
|
15049
15547
|
}
|
|
15050
15548
|
});
|
|
15051
15549
|
setAttachmentToCache(cacheKey, compressedResponse);
|
|
15052
|
-
|
|
15550
|
+
_exit5 = true;
|
|
15053
15551
|
return returningUrl;
|
|
15054
15552
|
}
|
|
15055
15553
|
});
|
|
15056
15554
|
}
|
|
15057
15555
|
}();
|
|
15058
|
-
return
|
|
15556
|
+
return _temp1 && _temp1.then ? _temp1.then(_temp10) : _temp10(_temp1);
|
|
15059
15557
|
}) : '';
|
|
15060
15558
|
});
|
|
15061
15559
|
}, function (error) {
|
|
@@ -37191,6 +37689,7 @@ var convertToAac = function convertToAac(file, messageId) {
|
|
|
37191
37689
|
return Promise.reject(e);
|
|
37192
37690
|
}
|
|
37193
37691
|
};
|
|
37692
|
+
var convertMp3ToAac = convertToAac;
|
|
37194
37693
|
var SAFARI_SUPPORTED_TYPES = new Set(['audio/mp4', 'audio/aac', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'audio/aiff']);
|
|
37195
37694
|
var convertAudioForSafari = function convertAudioForSafari(file, messageId) {
|
|
37196
37695
|
try {
|
|
@@ -37212,6 +37711,15 @@ var convertAudioForSafari = function convertAudioForSafari(file, messageId) {
|
|
|
37212
37711
|
}
|
|
37213
37712
|
};
|
|
37214
37713
|
|
|
37714
|
+
var audioConversion = {
|
|
37715
|
+
__proto__: null,
|
|
37716
|
+
isSafari: isSafari,
|
|
37717
|
+
initFFmpeg: initFFmpeg,
|
|
37718
|
+
convertToAac: convertToAac,
|
|
37719
|
+
convertMp3ToAac: convertMp3ToAac,
|
|
37720
|
+
convertAudioForSafari: convertAudioForSafari
|
|
37721
|
+
};
|
|
37722
|
+
|
|
37215
37723
|
var _templateObject$v, _templateObject2$r, _templateObject3$l, _templateObject4$h, _templateObject5$e, _templateObject6$b, _templateObject7$a;
|
|
37216
37724
|
var AudioPlayer = function AudioPlayer(_ref) {
|
|
37217
37725
|
var _file$metadata6, _file$metadata7;
|
|
@@ -38199,80 +38707,82 @@ var Attachment = function Attachment(_ref) {
|
|
|
38199
38707
|
}, messageType);
|
|
38200
38708
|
setDownloadFilePromise(attachment.id, urlPromise);
|
|
38201
38709
|
return Promise.resolve(urlPromise).then(function (result) {
|
|
38202
|
-
function
|
|
38203
|
-
|
|
38204
|
-
|
|
38205
|
-
|
|
38206
|
-
|
|
38207
|
-
|
|
38208
|
-
|
|
38209
|
-
|
|
38210
|
-
|
|
38211
|
-
|
|
38212
|
-
|
|
38213
|
-
|
|
38214
|
-
|
|
38215
|
-
|
|
38216
|
-
setAttachmentToCache(attachment.url + '_original_image_url', new Response(result.Body, {
|
|
38217
|
-
headers: {
|
|
38218
|
-
'Content-Type': 'image/jpeg'
|
|
38710
|
+
function _temp7(body) {
|
|
38711
|
+
function _temp6() {
|
|
38712
|
+
setIsCached(true);
|
|
38713
|
+
setDownloadingFile(false);
|
|
38714
|
+
setAttachmentUrl(downloadingUrl);
|
|
38715
|
+
}
|
|
38716
|
+
var url = URL.createObjectURL(body);
|
|
38717
|
+
setSizeProgress(undefined);
|
|
38718
|
+
var downloadingUrl = url;
|
|
38719
|
+
var _temp5 = function () {
|
|
38720
|
+
if (attachment.type === attachmentTypes.image) {
|
|
38721
|
+
return Promise.resolve(compressAndCacheImage(url, attachment.url, renderWidth, renderHeight)).then(function (compressedUrl) {
|
|
38722
|
+
if (compressedUrl) {
|
|
38723
|
+
downloadingUrl = compressedUrl;
|
|
38219
38724
|
}
|
|
38220
|
-
|
|
38221
|
-
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_image_url', url));
|
|
38222
|
-
});
|
|
38223
|
-
} else {
|
|
38224
|
-
var _temp3 = function _temp3() {
|
|
38225
|
-
if (attachment.type === attachmentTypes.video) {
|
|
38226
|
-
setAttachmentToCache(attachment.url + "_original_video_url", new Response(result.Body, {
|
|
38725
|
+
setAttachmentToCache(attachment.url + '_original_image_url', new Response(result.Body, {
|
|
38227
38726
|
headers: {
|
|
38228
|
-
'Content-Type':
|
|
38727
|
+
'Content-Type': 'image/jpeg'
|
|
38229
38728
|
}
|
|
38230
38729
|
}));
|
|
38231
|
-
dispatch(setUpdateMessageAttachmentAC(attachment.url +
|
|
38232
|
-
}
|
|
38233
|
-
|
|
38234
|
-
|
|
38235
|
-
|
|
38236
|
-
|
|
38237
|
-
|
|
38238
|
-
|
|
38239
|
-
}
|
|
38240
|
-
};
|
|
38241
|
-
var _temp2 = function () {
|
|
38242
|
-
if (attachment.type === attachmentTypes.video) {
|
|
38243
|
-
return Promise.resolve(getVideoFirstFrame(url, renderWidth, renderHeight, 0.8)).then(function (result) {
|
|
38244
|
-
var _temp = function () {
|
|
38245
|
-
if (result) {
|
|
38246
|
-
var frameBlobUrl = result.frameBlobUrl,
|
|
38247
|
-
blob = result.blob;
|
|
38248
|
-
var response = new Response(blob, {
|
|
38730
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_image_url', url));
|
|
38731
|
+
});
|
|
38732
|
+
} else {
|
|
38733
|
+
var _temp4 = function () {
|
|
38734
|
+
if (attachment.type === attachmentTypes.video) {
|
|
38735
|
+
return Promise.resolve(getVideoFirstFrame(body, renderWidth, renderHeight, 0.8)).then(function (frameResult) {
|
|
38736
|
+
function _temp3() {
|
|
38737
|
+
setAttachmentToCache(attachment.url + "_original_video_url", new Response(body, {
|
|
38249
38738
|
headers: {
|
|
38250
|
-
'Content-Type': '
|
|
38739
|
+
'Content-Type': body.type || 'application/octet-stream'
|
|
38251
38740
|
}
|
|
38252
|
-
});
|
|
38253
|
-
|
|
38254
|
-
return Promise.resolve(setAttachmentToCache(key, response)).then(function () {
|
|
38255
|
-
dispatch(setUpdateMessageAttachmentAC(key, frameBlobUrl));
|
|
38256
|
-
});
|
|
38741
|
+
}));
|
|
38742
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url + "_original_video_url", url));
|
|
38257
38743
|
}
|
|
38258
|
-
|
|
38259
|
-
|
|
38260
|
-
|
|
38261
|
-
|
|
38262
|
-
|
|
38263
|
-
|
|
38264
|
-
|
|
38265
|
-
|
|
38266
|
-
|
|
38744
|
+
var _temp2 = function () {
|
|
38745
|
+
if (frameResult) {
|
|
38746
|
+
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
38747
|
+
blob = frameResult.blob;
|
|
38748
|
+
var response = new Response(blob, {
|
|
38749
|
+
headers: {
|
|
38750
|
+
'Content-Type': 'image/jpeg'
|
|
38751
|
+
}
|
|
38752
|
+
});
|
|
38753
|
+
var key = attachment.url;
|
|
38754
|
+
return Promise.resolve(setAttachmentToCache(key, response)).then(function () {
|
|
38755
|
+
dispatch(setUpdateMessageAttachmentAC(key, frameBlobUrl));
|
|
38756
|
+
});
|
|
38757
|
+
}
|
|
38758
|
+
}();
|
|
38759
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
38760
|
+
});
|
|
38761
|
+
} else {
|
|
38762
|
+
setAttachmentToCache(attachment.url, new Response(result.Body, {
|
|
38763
|
+
headers: {
|
|
38764
|
+
'Content-Type': attachment.type || 'application/octet-stream'
|
|
38765
|
+
}
|
|
38766
|
+
}));
|
|
38767
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url, url));
|
|
38768
|
+
}
|
|
38769
|
+
}();
|
|
38770
|
+
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
38771
|
+
}
|
|
38772
|
+
}();
|
|
38773
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
38774
|
+
}
|
|
38775
|
+
var _temp = attachment.type === attachmentTypes.video;
|
|
38776
|
+
return _temp ? Promise.resolve(ensurePlayableVideoBlob(result.Body)).then(_temp7) : _temp7(result.Body);
|
|
38267
38777
|
});
|
|
38268
38778
|
} else {
|
|
38269
|
-
var
|
|
38779
|
+
var _temp9 = function _temp9(_result2) {
|
|
38270
38780
|
if (_exit) return _result2;
|
|
38271
38781
|
setAttachmentUrl(downloadingUrl);
|
|
38272
38782
|
};
|
|
38273
38783
|
var _exit = false;
|
|
38274
38784
|
var downloadingUrl = attachment.url;
|
|
38275
|
-
var
|
|
38785
|
+
var _temp8 = function () {
|
|
38276
38786
|
if (attachment.type === attachmentTypes.image) {
|
|
38277
38787
|
return Promise.resolve(compressAndCacheImage(attachment.url, attachment.url, renderWidth, renderHeight)).then(function (compressedUrl) {
|
|
38278
38788
|
if (compressedUrl) {
|
|
@@ -38283,47 +38793,51 @@ var Attachment = function Attachment(_ref) {
|
|
|
38283
38793
|
} else {
|
|
38284
38794
|
fetch(attachment.url).then(function (response) {
|
|
38285
38795
|
try {
|
|
38286
|
-
return Promise.resolve(response.blob()).then(function (
|
|
38287
|
-
function
|
|
38288
|
-
|
|
38289
|
-
|
|
38290
|
-
|
|
38291
|
-
|
|
38292
|
-
|
|
38293
|
-
|
|
38294
|
-
|
|
38295
|
-
function
|
|
38296
|
-
|
|
38297
|
-
|
|
38298
|
-
'Content-Type': blob.type || 'video/mp4'
|
|
38299
|
-
}
|
|
38300
|
-
}));
|
|
38301
|
-
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_video_url', blobUrl));
|
|
38302
|
-
}
|
|
38303
|
-
var _temp8 = function () {
|
|
38304
|
-
if (frameResult) {
|
|
38305
|
-
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
38306
|
-
frameBlob = frameResult.blob;
|
|
38307
|
-
return Promise.resolve(setAttachmentToCache(attachment.url, new Response(frameBlob, {
|
|
38796
|
+
return Promise.resolve(response.blob()).then(function (rawBlob) {
|
|
38797
|
+
function _temp13(blob) {
|
|
38798
|
+
function _temp12() {
|
|
38799
|
+
setAttachmentUrl(blobUrl);
|
|
38800
|
+
setIsCached(true);
|
|
38801
|
+
}
|
|
38802
|
+
var blobUrl = URL.createObjectURL(blob);
|
|
38803
|
+
var _temp11 = function () {
|
|
38804
|
+
if (attachment.type === attachmentTypes.video) {
|
|
38805
|
+
return Promise.resolve(getVideoFirstFrame(blob, renderWidth, renderHeight, 0.8)).then(function (frameResult) {
|
|
38806
|
+
function _temp10() {
|
|
38807
|
+
setAttachmentToCache(attachment.url + '_original_video_url', new Response(blob, {
|
|
38308
38808
|
headers: {
|
|
38309
|
-
'Content-Type': '
|
|
38809
|
+
'Content-Type': blob.type || 'video/mp4'
|
|
38310
38810
|
}
|
|
38311
|
-
}))
|
|
38312
|
-
|
|
38313
|
-
});
|
|
38811
|
+
}));
|
|
38812
|
+
dispatch(setUpdateMessageAttachmentAC(attachment.url + '_original_video_url', blobUrl));
|
|
38314
38813
|
}
|
|
38315
|
-
|
|
38316
|
-
|
|
38317
|
-
|
|
38318
|
-
|
|
38319
|
-
|
|
38320
|
-
|
|
38321
|
-
|
|
38322
|
-
|
|
38323
|
-
|
|
38324
|
-
|
|
38325
|
-
|
|
38326
|
-
|
|
38814
|
+
var _temp1 = function () {
|
|
38815
|
+
if (frameResult) {
|
|
38816
|
+
var frameBlobUrl = frameResult.frameBlobUrl,
|
|
38817
|
+
frameBlob = frameResult.blob;
|
|
38818
|
+
return Promise.resolve(setAttachmentToCache(attachment.url, new Response(frameBlob, {
|
|
38819
|
+
headers: {
|
|
38820
|
+
'Content-Type': 'image/jpeg'
|
|
38821
|
+
}
|
|
38822
|
+
}))).then(function () {
|
|
38823
|
+
dispatch(setUpdateMessageAttachmentAC(getAttachmentURLWithVersion(attachment.url), frameBlobUrl));
|
|
38824
|
+
});
|
|
38825
|
+
}
|
|
38826
|
+
}();
|
|
38827
|
+
return _temp1 && _temp1.then ? _temp1.then(_temp10) : _temp10(_temp1);
|
|
38828
|
+
});
|
|
38829
|
+
} else {
|
|
38830
|
+
setAttachmentToCache(attachment.url, new Response(blob, {
|
|
38831
|
+
headers: {
|
|
38832
|
+
'Content-Type': blob.type || 'application/octet-stream'
|
|
38833
|
+
}
|
|
38834
|
+
}));
|
|
38835
|
+
}
|
|
38836
|
+
}();
|
|
38837
|
+
return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11);
|
|
38838
|
+
}
|
|
38839
|
+
var _temp0 = attachment.type === attachmentTypes.video;
|
|
38840
|
+
return _temp0 ? Promise.resolve(ensurePlayableVideoBlob(rawBlob)).then(_temp13) : _temp13(rawBlob);
|
|
38327
38841
|
});
|
|
38328
38842
|
} catch (e) {
|
|
38329
38843
|
return Promise.reject(e);
|
|
@@ -38334,7 +38848,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38334
38848
|
_exit = true;
|
|
38335
38849
|
}
|
|
38336
38850
|
}();
|
|
38337
|
-
return
|
|
38851
|
+
return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
|
|
38338
38852
|
}
|
|
38339
38853
|
}());
|
|
38340
38854
|
} catch (e) {
|
|
@@ -38350,9 +38864,9 @@ var Attachment = function Attachment(_ref) {
|
|
|
38350
38864
|
if (!attachment.attachmentUrl && connectionStatus === CONNECTION_STATUS.CONNECTED && attachment.id && !attachmentUrlFromMap && !(attachment.type === attachmentTypes.file || attachment.type === attachmentTypes.link)) {
|
|
38351
38865
|
getAttachmentUrlFromCache(attachment.url).then(function (cachedUrl) {
|
|
38352
38866
|
try {
|
|
38353
|
-
var
|
|
38867
|
+
var _temp16 = function () {
|
|
38354
38868
|
if (attachment.type === attachmentTypes.image && !isPreview) {
|
|
38355
|
-
var
|
|
38869
|
+
var _temp15 = function () {
|
|
38356
38870
|
if (cachedUrl) {
|
|
38357
38871
|
setAttachmentUrl(cachedUrl);
|
|
38358
38872
|
dispatch(setUpdateMessageAttachmentAC(attachment.url, cachedUrl));
|
|
@@ -38360,7 +38874,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38360
38874
|
} else {
|
|
38361
38875
|
setIsCached(false);
|
|
38362
38876
|
setDownloadingFile(true);
|
|
38363
|
-
var
|
|
38877
|
+
var _temp14 = function () {
|
|
38364
38878
|
if (customDownloader) {
|
|
38365
38879
|
customDownloader(attachment.url, false, function (progress) {
|
|
38366
38880
|
var loadedRes = progress.loaded && progress.loaded / progress.total;
|
|
@@ -38412,10 +38926,10 @@ var Attachment = function Attachment(_ref) {
|
|
|
38412
38926
|
});
|
|
38413
38927
|
}
|
|
38414
38928
|
}();
|
|
38415
|
-
if (
|
|
38929
|
+
if (_temp14 && _temp14.then) return _temp14.then(function () {});
|
|
38416
38930
|
}
|
|
38417
38931
|
}();
|
|
38418
|
-
if (
|
|
38932
|
+
if (_temp15 && _temp15.then) return _temp15.then(function () {});
|
|
38419
38933
|
} else {
|
|
38420
38934
|
if (cachedUrl) {
|
|
38421
38935
|
setAttachmentUrl(cachedUrl);
|
|
@@ -38429,7 +38943,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38429
38943
|
}
|
|
38430
38944
|
}
|
|
38431
38945
|
}();
|
|
38432
|
-
return Promise.resolve(
|
|
38946
|
+
return Promise.resolve(_temp16 && _temp16.then ? _temp16.then(function () {}) : void 0);
|
|
38433
38947
|
} catch (e) {
|
|
38434
38948
|
return Promise.reject(e);
|
|
38435
38949
|
}
|
|
@@ -38447,13 +38961,13 @@ var Attachment = function Attachment(_ref) {
|
|
|
38447
38961
|
setProgress(uploadPercent);
|
|
38448
38962
|
}, messageType).then(function (url) {
|
|
38449
38963
|
try {
|
|
38450
|
-
var
|
|
38964
|
+
var _temp18 = function _temp18() {
|
|
38451
38965
|
setAttachmentUrl(downloadingUrl);
|
|
38452
38966
|
dispatch(setUpdateMessageAttachmentAC(attachment.url, attachment.url));
|
|
38453
38967
|
setDownloadingFile(false);
|
|
38454
38968
|
};
|
|
38455
38969
|
var downloadingUrl = url;
|
|
38456
|
-
var
|
|
38970
|
+
var _temp17 = function () {
|
|
38457
38971
|
if (attachment.type === attachmentTypes.image) {
|
|
38458
38972
|
return Promise.resolve(compressAndCacheImage(url, attachment.url, renderWidth, renderHeight)).then(function (compressedUrl) {
|
|
38459
38973
|
if (compressedUrl) {
|
|
@@ -38466,7 +38980,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38466
38980
|
});
|
|
38467
38981
|
}
|
|
38468
38982
|
}();
|
|
38469
|
-
return Promise.resolve(
|
|
38983
|
+
return Promise.resolve(_temp17 && _temp17.then ? _temp17.then(_temp18) : _temp18(_temp17));
|
|
38470
38984
|
} catch (e) {
|
|
38471
38985
|
return Promise.reject(e);
|
|
38472
38986
|
}
|
|
@@ -51384,252 +51898,260 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
51384
51898
|
};
|
|
51385
51899
|
var handleAddAttachment = function handleAddAttachment(file, isMediaAttachment) {
|
|
51386
51900
|
try {
|
|
51387
|
-
var
|
|
51388
|
-
|
|
51389
|
-
|
|
51390
|
-
|
|
51391
|
-
|
|
51392
|
-
|
|
51393
|
-
|
|
51394
|
-
|
|
51395
|
-
|
|
51396
|
-
|
|
51397
|
-
|
|
51398
|
-
|
|
51399
|
-
|
|
51400
|
-
|
|
51401
|
-
|
|
51402
|
-
|
|
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
|
-
|
|
51428
|
-
|
|
51429
|
-
|
|
51430
|
-
|
|
51431
|
-
|
|
51432
|
-
|
|
51433
|
-
|
|
51434
|
-
|
|
51435
|
-
|
|
51436
|
-
|
|
51437
|
-
|
|
51438
|
-
|
|
51439
|
-
|
|
51440
|
-
|
|
51441
|
-
|
|
51442
|
-
|
|
51443
|
-
|
|
51444
|
-
|
|
51445
|
-
}
|
|
51446
|
-
|
|
51447
|
-
|
|
51901
|
+
var _temp4 = function _temp4() {
|
|
51902
|
+
var fileType = file.type.split('/')[0];
|
|
51903
|
+
var tid = uuid.v4();
|
|
51904
|
+
var reader = new FileReader();
|
|
51905
|
+
var handleAttachmentImageForCache = function handleAttachmentImageForCache(attachment) {
|
|
51906
|
+
try {
|
|
51907
|
+
var _attachment$metadata;
|
|
51908
|
+
var url = URL.createObjectURL(attachment.data);
|
|
51909
|
+
dispatch(setUpdateMessageAttachmentAC((attachment === null || attachment === void 0 ? void 0 : (_attachment$metadata = attachment.metadata) === null || _attachment$metadata === void 0 ? void 0 : _attachment$metadata.tmb) || '', url));
|
|
51910
|
+
return Promise.resolve();
|
|
51911
|
+
} catch (e) {
|
|
51912
|
+
return Promise.reject(e);
|
|
51913
|
+
}
|
|
51914
|
+
};
|
|
51915
|
+
var handleAttachmentVideoForCache = function handleAttachmentVideoForCache(attachment) {
|
|
51916
|
+
try {
|
|
51917
|
+
var _calculateRenderedIma = calculateRenderedImageWidth(attachment.metadata.szh || 400, attachment.metadata.szh || 400),
|
|
51918
|
+
newWidth = _calculateRenderedIma[0],
|
|
51919
|
+
newHeight = _calculateRenderedIma[1];
|
|
51920
|
+
return Promise.resolve(getVideoFirstFrame(attachment.data, newWidth, newHeight, 0.8)).then(function (result) {
|
|
51921
|
+
if (result) {
|
|
51922
|
+
var _attachment$metadata2;
|
|
51923
|
+
var frameBlobUrl = result.frameBlobUrl;
|
|
51924
|
+
dispatch(setUpdateMessageAttachmentAC((attachment === null || attachment === void 0 ? void 0 : (_attachment$metadata2 = attachment.metadata) === null || _attachment$metadata2 === void 0 ? void 0 : _attachment$metadata2.tmb) || '', frameBlobUrl));
|
|
51925
|
+
}
|
|
51926
|
+
});
|
|
51927
|
+
} catch (e) {
|
|
51928
|
+
return Promise.reject(e);
|
|
51929
|
+
}
|
|
51930
|
+
};
|
|
51931
|
+
reader.onload = function () {
|
|
51932
|
+
try {
|
|
51933
|
+
setPendingAttachment(tid, {
|
|
51934
|
+
file: file
|
|
51935
|
+
});
|
|
51936
|
+
var _temp0 = function () {
|
|
51937
|
+
if (customUploader) {
|
|
51938
|
+
var _temp6 = function () {
|
|
51939
|
+
if (fileType === 'image') {
|
|
51940
|
+
resizeImage(file).then(function (resizedFile) {
|
|
51941
|
+
try {
|
|
51942
|
+
return Promise.resolve(createImageThumbnail(file)).then(function (_ref4) {
|
|
51943
|
+
var _resizedFile$blob;
|
|
51944
|
+
var thumbnail = _ref4.thumbnail,
|
|
51945
|
+
imageWidth = _ref4.imageWidth,
|
|
51946
|
+
imageHeight = _ref4.imageHeight;
|
|
51947
|
+
var attachment = {
|
|
51948
|
+
data: file,
|
|
51949
|
+
upload: false,
|
|
51950
|
+
type: isMediaAttachment ? fileType : 'file',
|
|
51951
|
+
attachmentUrl: URL.createObjectURL(resizedFile.blob),
|
|
51952
|
+
tid: tid,
|
|
51953
|
+
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,
|
|
51954
|
+
metadata: {
|
|
51955
|
+
szw: imageWidth,
|
|
51956
|
+
szh: imageHeight,
|
|
51957
|
+
tmb: thumbnail
|
|
51958
|
+
}
|
|
51959
|
+
};
|
|
51960
|
+
handleAttachmentImageForCache(attachment);
|
|
51961
|
+
setAttachments(function (prevState) {
|
|
51962
|
+
return [].concat(prevState, [attachment]);
|
|
51963
|
+
});
|
|
51964
|
+
});
|
|
51965
|
+
} catch (e) {
|
|
51966
|
+
return Promise.reject(e);
|
|
51967
|
+
}
|
|
51968
|
+
});
|
|
51969
|
+
} else {
|
|
51970
|
+
var _temp1 = function () {
|
|
51971
|
+
if (fileType === 'video') {
|
|
51972
|
+
return Promise.resolve(getFrame(file, 0)).then(function (_ref5) {
|
|
51973
|
+
var thumb = _ref5.thumb,
|
|
51974
|
+
width = _ref5.width,
|
|
51975
|
+
height = _ref5.height,
|
|
51976
|
+
duration = _ref5.duration;
|
|
51977
|
+
var attachment = {
|
|
51978
|
+
data: file,
|
|
51979
|
+
upload: false,
|
|
51980
|
+
type: isMediaAttachment ? fileType : 'file',
|
|
51981
|
+
attachmentUrl: URL.createObjectURL(file),
|
|
51982
|
+
tid: tid,
|
|
51983
|
+
size: file.size,
|
|
51984
|
+
metadata: {
|
|
51985
|
+
szw: width,
|
|
51986
|
+
szh: height,
|
|
51987
|
+
tmb: thumb,
|
|
51988
|
+
dur: duration
|
|
51989
|
+
}
|
|
51990
|
+
};
|
|
51991
|
+
handleAttachmentVideoForCache(attachment);
|
|
51992
|
+
setAttachments(function (prevState) {
|
|
51993
|
+
return [].concat(prevState, [attachment]);
|
|
51994
|
+
});
|
|
51995
|
+
});
|
|
51996
|
+
} else {
|
|
51448
51997
|
setAttachments(function (prevState) {
|
|
51449
|
-
return [].concat(prevState, [
|
|
51998
|
+
return [].concat(prevState, [{
|
|
51999
|
+
data: file,
|
|
52000
|
+
upload: false,
|
|
52001
|
+
type: 'file',
|
|
52002
|
+
tid: tid,
|
|
52003
|
+
size: file.size
|
|
52004
|
+
}]);
|
|
51450
52005
|
});
|
|
51451
|
-
}
|
|
51452
|
-
}
|
|
51453
|
-
|
|
51454
|
-
|
|
51455
|
-
|
|
51456
|
-
|
|
51457
|
-
|
|
51458
|
-
|
|
51459
|
-
|
|
51460
|
-
|
|
51461
|
-
|
|
51462
|
-
|
|
51463
|
-
|
|
51464
|
-
|
|
51465
|
-
|
|
51466
|
-
|
|
51467
|
-
|
|
51468
|
-
|
|
51469
|
-
|
|
51470
|
-
|
|
51471
|
-
|
|
51472
|
-
|
|
51473
|
-
|
|
51474
|
-
|
|
51475
|
-
|
|
52006
|
+
}
|
|
52007
|
+
}();
|
|
52008
|
+
if (_temp1 && _temp1.then) return _temp1.then(function () {});
|
|
52009
|
+
}
|
|
52010
|
+
}();
|
|
52011
|
+
if (_temp6 && _temp6.then) return _temp6.then(function () {});
|
|
52012
|
+
} else {
|
|
52013
|
+
var _temp9 = function () {
|
|
52014
|
+
if (fileType === 'image') {
|
|
52015
|
+
var _temp7 = function () {
|
|
52016
|
+
if (isMediaAttachment) {
|
|
52017
|
+
return Promise.resolve(createImageThumbnail(file)).then(function (_ref6) {
|
|
52018
|
+
var thumbnail = _ref6.thumbnail,
|
|
52019
|
+
imageWidth = _ref6.imageWidth,
|
|
52020
|
+
imageHeight = _ref6.imageHeight;
|
|
52021
|
+
var metas = {
|
|
52022
|
+
thumbnail: thumbnail,
|
|
52023
|
+
imageWidth: imageWidth,
|
|
52024
|
+
imageHeight: imageHeight
|
|
52025
|
+
};
|
|
52026
|
+
if (file.type === 'image/gif') {
|
|
52027
|
+
setAttachments(function (prevState) {
|
|
52028
|
+
return [].concat(prevState, [{
|
|
52029
|
+
data: file,
|
|
52030
|
+
upload: true,
|
|
52031
|
+
attachmentUrl: URL.createObjectURL(file),
|
|
52032
|
+
tid: tid,
|
|
52033
|
+
type: fileType,
|
|
52034
|
+
size: file.size,
|
|
52035
|
+
metadata: JSON.stringify({
|
|
52036
|
+
tmb: metas.thumbnail,
|
|
52037
|
+
szw: metas.imageWidth,
|
|
52038
|
+
szh: metas.imageHeight
|
|
52039
|
+
})
|
|
52040
|
+
}]);
|
|
52041
|
+
});
|
|
52042
|
+
} else {
|
|
52043
|
+
resizeImage(file).then(function (resizedFileData) {
|
|
52044
|
+
try {
|
|
52045
|
+
var resizedFile = new File([resizedFileData.blob], resizedFileData.file.name);
|
|
52046
|
+
var attachment = {
|
|
52047
|
+
data: resizedFile,
|
|
52048
|
+
upload: true,
|
|
52049
|
+
attachmentUrl: URL.createObjectURL(resizedFile),
|
|
52050
|
+
tid: tid,
|
|
52051
|
+
type: fileType,
|
|
52052
|
+
size: resizedFile.size,
|
|
52053
|
+
metadata: JSON.stringify({
|
|
52054
|
+
tmb: metas.thumbnail,
|
|
52055
|
+
szw: resizedFileData.newWidth,
|
|
52056
|
+
szh: resizedFileData.newHeight
|
|
52057
|
+
})
|
|
52058
|
+
};
|
|
52059
|
+
handleAttachmentImageForCache(attachment);
|
|
52060
|
+
setAttachments(function (prevState) {
|
|
52061
|
+
return [].concat(prevState, [attachment]);
|
|
52062
|
+
});
|
|
52063
|
+
return Promise.resolve();
|
|
52064
|
+
} catch (e) {
|
|
52065
|
+
return Promise.reject(e);
|
|
52066
|
+
}
|
|
52067
|
+
});
|
|
51476
52068
|
}
|
|
51477
|
-
};
|
|
51478
|
-
handleAttachmentVideoForCache(attachment);
|
|
51479
|
-
setAttachments(function (prevState) {
|
|
51480
|
-
return [].concat(prevState, [attachment]);
|
|
51481
52069
|
});
|
|
51482
|
-
}
|
|
51483
|
-
|
|
51484
|
-
|
|
51485
|
-
return [].concat(prevState, [{
|
|
51486
|
-
data: file,
|
|
51487
|
-
upload: false,
|
|
51488
|
-
type: 'file',
|
|
51489
|
-
tid: tid,
|
|
51490
|
-
size: file.size
|
|
51491
|
-
}]);
|
|
51492
|
-
});
|
|
51493
|
-
}
|
|
51494
|
-
}();
|
|
51495
|
-
if (_temp9 && _temp9.then) return _temp9.then(function () {});
|
|
51496
|
-
}
|
|
51497
|
-
}();
|
|
51498
|
-
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
51499
|
-
} else {
|
|
51500
|
-
var _temp7 = function () {
|
|
51501
|
-
if (fileType === 'image') {
|
|
51502
|
-
var _temp5 = function () {
|
|
51503
|
-
if (isMediaAttachment) {
|
|
51504
|
-
return Promise.resolve(createImageThumbnail(file)).then(function (_ref6) {
|
|
51505
|
-
var thumbnail = _ref6.thumbnail,
|
|
51506
|
-
imageWidth = _ref6.imageWidth,
|
|
51507
|
-
imageHeight = _ref6.imageHeight;
|
|
51508
|
-
var metas = {
|
|
51509
|
-
thumbnail: thumbnail,
|
|
51510
|
-
imageWidth: imageWidth,
|
|
51511
|
-
imageHeight: imageHeight
|
|
51512
|
-
};
|
|
51513
|
-
if (file.type === 'image/gif') {
|
|
52070
|
+
} else {
|
|
52071
|
+
return Promise.resolve(createImageThumbnail(file, undefined, 50, 50)).then(function (_ref7) {
|
|
52072
|
+
var thumbnail = _ref7.thumbnail;
|
|
51514
52073
|
setAttachments(function (prevState) {
|
|
51515
52074
|
return [].concat(prevState, [{
|
|
51516
52075
|
data: file,
|
|
52076
|
+
type: 'file',
|
|
51517
52077
|
upload: true,
|
|
51518
52078
|
attachmentUrl: URL.createObjectURL(file),
|
|
51519
52079
|
tid: tid,
|
|
51520
|
-
type: fileType,
|
|
51521
52080
|
size: file.size,
|
|
51522
52081
|
metadata: JSON.stringify({
|
|
51523
|
-
tmb:
|
|
51524
|
-
szw: metas.imageWidth,
|
|
51525
|
-
szh: metas.imageHeight
|
|
52082
|
+
tmb: thumbnail
|
|
51526
52083
|
})
|
|
51527
52084
|
}]);
|
|
51528
52085
|
});
|
|
51529
|
-
}
|
|
51530
|
-
|
|
51531
|
-
|
|
51532
|
-
|
|
51533
|
-
|
|
51534
|
-
|
|
51535
|
-
|
|
51536
|
-
|
|
51537
|
-
|
|
51538
|
-
|
|
51539
|
-
|
|
51540
|
-
|
|
51541
|
-
|
|
51542
|
-
|
|
51543
|
-
|
|
51544
|
-
|
|
51545
|
-
|
|
51546
|
-
handleAttachmentImageForCache(attachment);
|
|
51547
|
-
setAttachments(function (prevState) {
|
|
51548
|
-
return [].concat(prevState, [attachment]);
|
|
51549
|
-
});
|
|
51550
|
-
return Promise.resolve();
|
|
51551
|
-
} catch (e) {
|
|
51552
|
-
return Promise.reject(e);
|
|
51553
|
-
}
|
|
52086
|
+
});
|
|
52087
|
+
}
|
|
52088
|
+
}();
|
|
52089
|
+
if (_temp7 && _temp7.then) return _temp7.then(function () {});
|
|
52090
|
+
} else {
|
|
52091
|
+
var _temp10 = function () {
|
|
52092
|
+
if (fileType === 'video') {
|
|
52093
|
+
return Promise.resolve(getFrame(file, 0)).then(function (_ref8) {
|
|
52094
|
+
var thumb = _ref8.thumb,
|
|
52095
|
+
width = _ref8.width,
|
|
52096
|
+
height = _ref8.height,
|
|
52097
|
+
duration = _ref8.duration;
|
|
52098
|
+
var metas = JSON.stringify({
|
|
52099
|
+
tmb: thumb,
|
|
52100
|
+
width: width,
|
|
52101
|
+
height: height,
|
|
52102
|
+
dur: duration
|
|
51554
52103
|
});
|
|
51555
|
-
|
|
51556
|
-
});
|
|
51557
|
-
} else {
|
|
51558
|
-
return Promise.resolve(createImageThumbnail(file, undefined, 50, 50)).then(function (_ref7) {
|
|
51559
|
-
var thumbnail = _ref7.thumbnail;
|
|
51560
|
-
setAttachments(function (prevState) {
|
|
51561
|
-
return [].concat(prevState, [{
|
|
52104
|
+
var attachment = {
|
|
51562
52105
|
data: file,
|
|
51563
|
-
type: '
|
|
52106
|
+
type: 'video',
|
|
51564
52107
|
upload: true,
|
|
52108
|
+
size: file.size,
|
|
51565
52109
|
attachmentUrl: URL.createObjectURL(file),
|
|
51566
52110
|
tid: tid,
|
|
51567
|
-
|
|
51568
|
-
|
|
51569
|
-
|
|
51570
|
-
|
|
51571
|
-
|
|
51572
|
-
|
|
51573
|
-
});
|
|
51574
|
-
}
|
|
51575
|
-
}();
|
|
51576
|
-
if (_temp5 && _temp5.then) return _temp5.then(function () {});
|
|
51577
|
-
} else {
|
|
51578
|
-
var _temp0 = function () {
|
|
51579
|
-
if (fileType === 'video') {
|
|
51580
|
-
return Promise.resolve(getFrame(URL.createObjectURL(file), 0)).then(function (_ref8) {
|
|
51581
|
-
var thumb = _ref8.thumb,
|
|
51582
|
-
width = _ref8.width,
|
|
51583
|
-
height = _ref8.height,
|
|
51584
|
-
duration = _ref8.duration;
|
|
51585
|
-
var metas = JSON.stringify({
|
|
51586
|
-
tmb: thumb,
|
|
51587
|
-
width: width,
|
|
51588
|
-
height: height,
|
|
51589
|
-
dur: duration
|
|
52111
|
+
metadata: metas
|
|
52112
|
+
};
|
|
52113
|
+
handleAttachmentVideoForCache(attachment);
|
|
52114
|
+
setAttachments(function (prevState) {
|
|
52115
|
+
return [].concat(prevState, [attachment]);
|
|
52116
|
+
});
|
|
51590
52117
|
});
|
|
51591
|
-
|
|
51592
|
-
data: file,
|
|
51593
|
-
type: 'video',
|
|
51594
|
-
upload: true,
|
|
51595
|
-
size: file.size,
|
|
51596
|
-
attachmentUrl: URL.createObjectURL(file),
|
|
51597
|
-
tid: tid,
|
|
51598
|
-
metadata: metas
|
|
51599
|
-
};
|
|
51600
|
-
handleAttachmentVideoForCache(attachment);
|
|
52118
|
+
} else {
|
|
51601
52119
|
setAttachments(function (prevState) {
|
|
51602
|
-
return [].concat(prevState, [
|
|
52120
|
+
return [].concat(prevState, [{
|
|
52121
|
+
data: file,
|
|
52122
|
+
upload: true,
|
|
52123
|
+
type: 'file',
|
|
52124
|
+
size: file.size,
|
|
52125
|
+
tid: tid
|
|
52126
|
+
}]);
|
|
51603
52127
|
});
|
|
51604
|
-
}
|
|
51605
|
-
}
|
|
51606
|
-
|
|
51607
|
-
|
|
51608
|
-
|
|
51609
|
-
|
|
51610
|
-
|
|
51611
|
-
|
|
51612
|
-
|
|
51613
|
-
|
|
51614
|
-
|
|
51615
|
-
|
|
51616
|
-
|
|
51617
|
-
|
|
51618
|
-
|
|
51619
|
-
|
|
51620
|
-
|
|
51621
|
-
}
|
|
51622
|
-
}();
|
|
51623
|
-
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
|
|
51624
|
-
} catch (e) {
|
|
51625
|
-
return Promise.reject(e);
|
|
51626
|
-
}
|
|
51627
|
-
};
|
|
51628
|
-
reader.onerror = function (e) {
|
|
51629
|
-
log.info(' error on read file onError', e);
|
|
52128
|
+
}
|
|
52129
|
+
}();
|
|
52130
|
+
if (_temp10 && _temp10.then) return _temp10.then(function () {});
|
|
52131
|
+
}
|
|
52132
|
+
}();
|
|
52133
|
+
if (_temp9 && _temp9.then) return _temp9.then(function () {});
|
|
52134
|
+
}
|
|
52135
|
+
}();
|
|
52136
|
+
return Promise.resolve(_temp0 && _temp0.then ? _temp0.then(function () {}) : void 0);
|
|
52137
|
+
} catch (e) {
|
|
52138
|
+
return Promise.reject(e);
|
|
52139
|
+
}
|
|
52140
|
+
};
|
|
52141
|
+
reader.onerror = function (e) {
|
|
52142
|
+
log.info(' error on read file onError', e);
|
|
52143
|
+
};
|
|
52144
|
+
reader.readAsBinaryString(file);
|
|
51630
52145
|
};
|
|
51631
|
-
|
|
51632
|
-
|
|
52146
|
+
var customUploader = getCustomUploader();
|
|
52147
|
+
var _temp3 = function () {
|
|
52148
|
+
if (file.type.split('/')[0] === 'video') {
|
|
52149
|
+
return Promise.resolve(remuxVideoFileForUpload(file)).then(function (_remuxVideoFileForUpl) {
|
|
52150
|
+
file = _remuxVideoFileForUpl;
|
|
52151
|
+
});
|
|
52152
|
+
}
|
|
52153
|
+
}();
|
|
52154
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
|
|
51633
52155
|
} catch (e) {
|
|
51634
52156
|
return Promise.reject(e);
|
|
51635
52157
|
}
|
|
@@ -51688,14 +52210,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
51688
52210
|
}
|
|
51689
52211
|
}
|
|
51690
52212
|
}
|
|
51691
|
-
var
|
|
52213
|
+
var _temp11 = function () {
|
|
51692
52214
|
if (allowUpload) {
|
|
51693
52215
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
|
|
51694
52216
|
} else {
|
|
51695
52217
|
showFileUploadError(errorMessage);
|
|
51696
52218
|
}
|
|
51697
52219
|
}();
|
|
51698
|
-
return Promise.resolve(
|
|
52220
|
+
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(function () {}) : void 0);
|
|
51699
52221
|
} catch (e) {
|
|
51700
52222
|
return Promise.reject(e);
|
|
51701
52223
|
}
|