util-helpers 4.20.2 → 4.20.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util-helpers.js +17 -12
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +1 -1
- package/esm/compressImage.js +2 -2
- package/esm/getImageInfo.js +2 -2
- package/esm/index.js +1 -1
- package/esm/loadImageWithBlob.js +12 -6
- package/lib/VERSION.js +1 -1
- package/lib/compressImage.js +2 -2
- package/lib/getImageInfo.js +2 -2
- package/lib/index.js +1 -1
- package/lib/loadImageWithBlob.js +12 -6
- package/package.json +1 -1
- package/types/compressImage.d.ts +3 -1
- package/types/getImageInfo.d.ts +3 -1
- package/types/loadImageWithBlob.d.ts +3 -1
package/dist/util-helpers.js
CHANGED
|
@@ -1371,36 +1371,41 @@
|
|
|
1371
1371
|
}
|
|
1372
1372
|
|
|
1373
1373
|
var SuccessResponseStatus = [200, 304];
|
|
1374
|
-
function getBlob(img) {
|
|
1374
|
+
function getBlob(img, ajaxOptions) {
|
|
1375
1375
|
return new Promise(function (resolve, reject) {
|
|
1376
1376
|
if (isBlob(img)) {
|
|
1377
1377
|
resolve(img);
|
|
1378
1378
|
}
|
|
1379
1379
|
else {
|
|
1380
|
-
ajax(img, { responseType: 'blob' })
|
|
1380
|
+
ajax(img, __assign({ responseType: 'blob' }, ajaxOptions))
|
|
1381
1381
|
.then(function (ev) {
|
|
1382
1382
|
var responseStatus = ev.target.status;
|
|
1383
1383
|
if (SuccessResponseStatus.indexOf(responseStatus) !== -1) {
|
|
1384
1384
|
resolve(ev.target.response);
|
|
1385
1385
|
}
|
|
1386
1386
|
else {
|
|
1387
|
-
|
|
1387
|
+
var err = new Error("[loadImageWithBlob] The image does not support get requests, responseStatus ".concat(responseStatus, ", '").concat(img, "'."));
|
|
1388
|
+
console.error(err);
|
|
1389
|
+
reject(err);
|
|
1388
1390
|
}
|
|
1389
1391
|
})
|
|
1390
|
-
.catch(
|
|
1392
|
+
.catch(function (err) {
|
|
1393
|
+
console.error(new Error("[loadImageWithBlob] Failed to request image. ".concat(err)));
|
|
1394
|
+
reject(err);
|
|
1395
|
+
});
|
|
1391
1396
|
}
|
|
1392
1397
|
});
|
|
1393
1398
|
}
|
|
1394
1399
|
var cacheImage$2;
|
|
1395
1400
|
var cacheResult$2;
|
|
1396
|
-
function loadImageWithBlob(img, useCache) {
|
|
1401
|
+
function loadImageWithBlob(img, useCache, ajaxOptions) {
|
|
1397
1402
|
if (useCache === void 0) { useCache = true; }
|
|
1398
1403
|
return new Promise(function (resolve, reject) {
|
|
1399
1404
|
if (useCache && cacheImage$2 === img && cacheResult$2) {
|
|
1400
1405
|
resolve(cacheResult$2);
|
|
1401
1406
|
}
|
|
1402
1407
|
else {
|
|
1403
|
-
getBlob(img)
|
|
1408
|
+
getBlob(img, ajaxOptions)
|
|
1404
1409
|
.then(function (blob) {
|
|
1405
1410
|
var url = createObjectURL(blob);
|
|
1406
1411
|
var image = new Image();
|
|
@@ -1435,8 +1440,8 @@
|
|
|
1435
1440
|
function compressImage(img, options) {
|
|
1436
1441
|
if (options === void 0) { options = {}; }
|
|
1437
1442
|
return new Promise(function (resolve, reject) {
|
|
1438
|
-
var width = options.width, height = options.height, rotate = options.rotate, _a = options.offset, offset = _a === void 0 ? [0, 0] : _a, _b = options.cacheImage, cacheImage = _b === void 0 ? true : _b, _c = options.background, background = _c === void 0 ? '#fff' : _c, canvasWidth = options.canvasWidth, canvasHeight = options.canvasHeight, _d = options.format, format = _d === void 0 ? 'blob' : _d, _e = options.type, type = _e === void 0 ? 'image/jpeg' : _e, _f = options.quality, quality = _f === void 0 ? 0.8 : _f, beforeCompress = options.beforeCompress, beforeDraw = options.beforeDraw, afterDraw = options.afterDraw;
|
|
1439
|
-
loadImageWithBlob(img, cacheImage)
|
|
1443
|
+
var width = options.width, height = options.height, rotate = options.rotate, _a = options.offset, offset = _a === void 0 ? [0, 0] : _a, _b = options.cacheImage, cacheImage = _b === void 0 ? true : _b, _c = options.background, background = _c === void 0 ? '#fff' : _c, canvasWidth = options.canvasWidth, canvasHeight = options.canvasHeight, _d = options.format, format = _d === void 0 ? 'blob' : _d, _e = options.type, type = _e === void 0 ? 'image/jpeg' : _e, _f = options.quality, quality = _f === void 0 ? 0.8 : _f, beforeCompress = options.beforeCompress, beforeDraw = options.beforeDraw, afterDraw = options.afterDraw, ajaxOptions = options.ajaxOptions;
|
|
1444
|
+
loadImageWithBlob(img, cacheImage, ajaxOptions)
|
|
1440
1445
|
.then(function (_a) {
|
|
1441
1446
|
var image = _a.image, blob = _a.blob;
|
|
1442
1447
|
var numWidth = toNumber(width);
|
|
@@ -1569,14 +1574,14 @@
|
|
|
1569
1574
|
}
|
|
1570
1575
|
var cacheImage$1;
|
|
1571
1576
|
var cacheResult$1;
|
|
1572
|
-
function getImageInfo(img, useCache) {
|
|
1577
|
+
function getImageInfo(img, useCache, ajaxOptions) {
|
|
1573
1578
|
if (useCache === void 0) { useCache = true; }
|
|
1574
1579
|
return new Promise(function (resolve, reject) {
|
|
1575
1580
|
if (useCache && cacheImage$1 === img && cacheResult$1) {
|
|
1576
1581
|
resolve(cacheResult$1);
|
|
1577
1582
|
}
|
|
1578
1583
|
else {
|
|
1579
|
-
loadImageWithBlob(img, false)
|
|
1584
|
+
loadImageWithBlob(img, false, ajaxOptions)
|
|
1580
1585
|
.then(function (_a) {
|
|
1581
1586
|
var image = _a.image, blob = _a.blob;
|
|
1582
1587
|
var width = image.width, height = image.height;
|
|
@@ -1971,9 +1976,9 @@
|
|
|
1971
1976
|
return internalFindTreeSelect(tree, predicate, childrenField);
|
|
1972
1977
|
}
|
|
1973
1978
|
|
|
1974
|
-
var VERSION = "4.20.
|
|
1979
|
+
var VERSION = "4.20.4";
|
|
1975
1980
|
|
|
1976
|
-
var version = "4.20.
|
|
1981
|
+
var version = "4.20.4";
|
|
1977
1982
|
|
|
1978
1983
|
exports.VERSION = VERSION;
|
|
1979
1984
|
exports.ajax = ajax;
|