@scaleflex/widget-image-editor 4.8.11 → 4.8.12

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.
Files changed (3) hide show
  1. package/lib/b64ToBlob.js +27 -13
  2. package/package.json +5 -5
  3. package/LICENSE +0 -21
package/lib/b64ToBlob.js CHANGED
@@ -1,19 +1,33 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ // Converts base64 data URI to Blob in memory (avoids XHR/fetch to data: URIs which violates CSP connect-src)
1
8
  var b64toBlob = function b64toBlob(b64Data) {
2
9
  return new Promise(function (resolve, reject) {
3
- var xhr = new XMLHttpRequest();
4
- xhr.responseType = 'blob';
5
- xhr.open('GET', b64Data);
6
- xhr.send();
7
- xhr.onload = function () {
8
- if (xhr.status >= 200 && xhr.status < 300) {
9
- resolve(xhr.response);
10
- } else {
11
- reject(new Error("Error while loading base64 image. (".concat(xhr.status, ": ").concat(xhr.error, ")")));
10
+ try {
11
+ // Extract MIME type and base64 content from data URI
12
+ var _b64Data$split = b64Data.split(','),
13
+ _b64Data$split2 = _slicedToArray(_b64Data$split, 2),
14
+ header = _b64Data$split2[0],
15
+ base64 = _b64Data$split2[1];
16
+ var mimeMatch = header.match(/:(.*?);/);
17
+ var mime = mimeMatch ? mimeMatch[1] : 'application/octet-stream';
18
+
19
+ // Decode base64 to binary and convert to typed array
20
+ var byteString = atob(base64);
21
+ var uint8Array = new Uint8Array(byteString.length);
22
+ for (var i = 0; i < byteString.length; i++) {
23
+ uint8Array[i] = byteString.charCodeAt(i);
12
24
  }
13
- };
14
- xhr.onerror = function () {
15
- reject(new Error("Error while loading base64 image. (".concat(xhr.status, ": ").concat(xhr.error, ")")));
16
- };
25
+ resolve(new Blob([uint8Array], {
26
+ type: mime
27
+ }));
28
+ } catch (err) {
29
+ reject(new Error("Error while converting base64 to blob: ".concat(err.message)));
30
+ }
17
31
  });
18
32
  };
19
33
  export default b64toBlob;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/widget-image-editor",
3
- "version": "4.8.11",
3
+ "version": "4.8.12",
4
4
  "description": "FilerobotImageEditor integration with Scaleflex",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -15,9 +15,9 @@
15
15
  "dependencies": {
16
16
  "@scaleflex/icons": "^3.0.0-beta.11",
17
17
  "@scaleflex/ui": "^3.0.0-beta.11",
18
- "@scaleflex/widget-common": "^4.8.11",
19
- "@scaleflex/widget-icons": "^4.8.11",
20
- "@scaleflex/widget-utils": "^4.8.11",
18
+ "@scaleflex/widget-common": "^4.8.12",
19
+ "@scaleflex/widget-icons": "^4.8.12",
20
+ "@scaleflex/widget-utils": "^4.8.12",
21
21
  "react-filerobot-image-editor": "5.0.0-beta.93",
22
22
  "react-filerobot-video-editor": "1.1.3"
23
23
  },
@@ -35,5 +35,5 @@
35
35
  "react-konva": ">=19.0.3",
36
36
  "react-redux": "^8.1.1"
37
37
  },
38
- "gitHead": "4e66456d033b9d9829c3c76a8c29b020dcacae2e"
38
+ "gitHead": "c8eaaf5f9228b824d45de4027640e7eb5517fbb8"
39
39
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 scaleflex
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.