@ringcentral-integration/utils 0.0.1
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/LICENSE +17 -0
- package/README.md +9 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/package.json +26 -0
- package/src/decorators/index.js +17 -0
- package/src/decorators/index.js.map +1 -0
- package/src/decorators/time.js +81 -0
- package/src/decorators/time.js.map +1 -0
- package/src/index.js +28 -0
- package/src/index.js.map +1 -0
- package/src/utils/MultiPartUTF8FormData.js +239 -0
- package/src/utils/MultiPartUTF8FormData.js.map +1 -0
- package/src/utils/base64Handler.js +96 -0
- package/src/utils/base64Handler.js.map +1 -0
- package/src/utils/blobHandler.js +44 -0
- package/src/utils/blobHandler.js.map +1 -0
- package/src/utils/downloadFile.js +95 -0
- package/src/utils/downloadFile.js.map +1 -0
- package/src/utils/empty.js +16 -0
- package/src/utils/empty.js.map +1 -0
- package/src/utils/fileHandler/constant.js +37 -0
- package/src/utils/fileHandler/constant.js.map +1 -0
- package/src/utils/fileHandler/fileHandler.js +65 -0
- package/src/utils/fileHandler/fileHandler.js.map +1 -0
- package/src/utils/fileHandler/index.js +17 -0
- package/src/utils/fileHandler/index.js.map +1 -0
- package/src/utils/format.js +14 -0
- package/src/utils/format.js.map +1 -0
- package/src/utils/getTranslateFn.js +98 -0
- package/src/utils/getTranslateFn.js.map +1 -0
- package/src/utils/index.js +204 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/invertObj.js +26 -0
- package/src/utils/invertObj.js.map +1 -0
- package/src/utils/isElectron.js +13 -0
- package/src/utils/isElectron.js.map +1 -0
- package/src/utils/isSafari.js +10 -0
- package/src/utils/isSafari.js.map +1 -0
- package/src/utils/loadImage.js +24 -0
- package/src/utils/loadImage.js.map +1 -0
- package/src/utils/polling.js +107 -0
- package/src/utils/polling.js.map +1 -0
- package/src/utils/sleep.js +48 -0
- package/src/utils/sleep.js.map +1 -0
- package/src/utils/stopEvent.js +20 -0
- package/src/utils/stopEvent.js.map +1 -0
- package/src/utils/stringHandler/index.js +17 -0
- package/src/utils/stringHandler/index.js.map +1 -0
- package/src/utils/stringHandler/isASCII.js +12 -0
- package/src/utils/stringHandler/isASCII.js.map +1 -0
- package/src/utils/waitUntil.js +70 -0
- package/src/utils/waitUntil.js.map +1 -0
- package/src/utils/waitUntilTo.js +99 -0
- package/src/utils/waitUntilTo.js.map +1 -0
- package/src/webpackPlugins/NoChunkChecker/NoChunkChecker.js +56 -0
- package/src/webpackPlugins/NoChunkChecker/NoChunkChecker.js.map +1 -0
- package/src/webpackPlugins/NoChunkChecker/index.js +17 -0
- package/src/webpackPlugins/NoChunkChecker/index.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 RingCentral, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
7
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
8
|
+
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
11
|
+
of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
14
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
15
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
16
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
17
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _src = require("./src");
|
|
7
|
+
Object.keys(_src).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _src[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _src[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_src","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from './src';\n"],"mappings":";;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,IAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,IAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,IAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ringcentral-integration/utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Base utils package for RingCentral integration products.",
|
|
5
|
+
"homepage": "https://github.com/ringcentral/ringcentral-js-widgets/tree/master/packages/core#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/ringcentral/ringcentral-js-widgets/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/ringcentral/ringcentral-js-widgets.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "RingCentral Integration Team",
|
|
15
|
+
"main": "index.js",
|
|
16
|
+
"directories": {
|
|
17
|
+
"lib": "lib"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"string-template": "^1.0.0"
|
|
21
|
+
},
|
|
22
|
+
"common": true,
|
|
23
|
+
"ci": {
|
|
24
|
+
"@ringcentral-integration/utils": "**"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _time = require("./time");
|
|
7
|
+
Object.keys(_time).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _time[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _time[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_time","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["src/decorators/index.ts"],"sourcesContent":["export * from './time';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.to-string");
|
|
4
|
+
require("core-js/modules/es.promise");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.time = void 0;
|
|
9
|
+
require("regenerator-runtime/runtime");
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
|
+
/**
|
|
13
|
+
* let you can calculate the time when run that method,
|
|
14
|
+
*
|
|
15
|
+
* ### that time not calculate in `process.env.NODE_ENV !== 'production'`
|
|
16
|
+
* @param title
|
|
17
|
+
*/
|
|
18
|
+
var time = function time(title) {
|
|
19
|
+
// eslint-disable-next-line func-names
|
|
20
|
+
return function (target, name, descriptor) {
|
|
21
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
22
|
+
if (typeof descriptor.value !== 'function' && typeof descriptor.initializer !== 'function') {
|
|
23
|
+
throw new Error("@time decorated '".concat(name, "' is not a method"));
|
|
24
|
+
}
|
|
25
|
+
var fn = descriptor.value;
|
|
26
|
+
var initializer = descriptor.initializer;
|
|
27
|
+
// eslint-disable-next-line func-names
|
|
28
|
+
var trackedFn = /*#__PURE__*/function () {
|
|
29
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
30
|
+
var _len,
|
|
31
|
+
args,
|
|
32
|
+
_key,
|
|
33
|
+
result,
|
|
34
|
+
_args = arguments;
|
|
35
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
36
|
+
while (1) {
|
|
37
|
+
switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
if (typeof initializer === 'function') {
|
|
40
|
+
fn = initializer.call(this);
|
|
41
|
+
}
|
|
42
|
+
if (!(typeof fn !== 'function')) {
|
|
43
|
+
_context.next = 3;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
throw new Error("@time decorated '".concat(name, "' is not a function"));
|
|
47
|
+
case 3:
|
|
48
|
+
console.time("[Time Decorator] ".concat(title, ": "));
|
|
49
|
+
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
50
|
+
args[_key] = _args[_key];
|
|
51
|
+
}
|
|
52
|
+
_context.next = 7;
|
|
53
|
+
return fn.apply(this, args);
|
|
54
|
+
case 7:
|
|
55
|
+
result = _context.sent;
|
|
56
|
+
console.timeEnd("[Time Decorator] ".concat(title, ": "));
|
|
57
|
+
return _context.abrupt("return", result);
|
|
58
|
+
case 10:
|
|
59
|
+
case "end":
|
|
60
|
+
return _context.stop();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, _callee, this);
|
|
64
|
+
}));
|
|
65
|
+
return function trackedFn() {
|
|
66
|
+
return _ref.apply(this, arguments);
|
|
67
|
+
};
|
|
68
|
+
}();
|
|
69
|
+
|
|
70
|
+
// the any type is just to be compatible with babel and tsc.
|
|
71
|
+
return {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
value: trackedFn
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return descriptor;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.time = time;
|
|
81
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.js","names":["time","title","target","name","descriptor","process","env","NODE_ENV","value","initializer","Error","concat","fn","trackedFn","_ref","_asyncToGenerator","regeneratorRuntime","mark","_callee","_len","args","_key","result","_args","arguments","wrap","_callee$","_context","prev","next","call","console","length","Array","apply","sent","timeEnd","abrupt","stop","enumerable","configurable","exports"],"sources":["src/decorators/time.ts"],"sourcesContent":["/**\n * let you can calculate the time when run that method,\n *\n * ### that time not calculate in `process.env.NODE_ENV !== 'production'`\n * @param title\n */\nexport const time = (title: string) => {\n // eslint-disable-next-line func-names\n return function (target: any, name: string, descriptor?: any) {\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof descriptor.value !== 'function' &&\n typeof descriptor.initializer !== 'function'\n ) {\n throw new Error(`@time decorated '${name}' is not a method`);\n }\n let fn: (...args: any) => any = descriptor.value;\n const initializer = descriptor.initializer;\n // eslint-disable-next-line func-names\n const trackedFn = async function (this: any, ...args: any) {\n if (typeof initializer === 'function') {\n fn = initializer.call(this);\n }\n if (typeof fn !== 'function') {\n throw new Error(`@time decorated '${name}' is not a function`);\n }\n console.time(`[Time Decorator] ${title}: `);\n const result = await fn.apply(this, args);\n console.timeEnd(`[Time Decorator] ${title}: `);\n return result;\n };\n\n // the any type is just to be compatible with babel and tsc.\n return {\n enumerable: true,\n configurable: true,\n value: trackedFn,\n } as any;\n }\n\n return descriptor;\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,IAAI,GAAG,SAAPA,IAAIA,CAAIC,KAAa,EAAK;EACrC;EACA,OAAO,UAAUC,MAAW,EAAEC,IAAY,EAAEC,UAAgB,EAAE;IAC5D,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,Y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C;gBAAA;kBAAnCE,MAAM,GAAAK,QAAA,CAAAQ,IAAA;kBACZJ,OAAO,CAACK,OAAO,qBAAAzB,MAAA,CAAqBV,KAAK,OAAI,CAAC;kBAAC,OAAA0B,QAAA,CAAAU,MAAA,WACxCf,MAAM;gBAAA;gBAAA;kBAAA,OAAAK,QAAA,CAAAW,IAAA;cAAA;YAAA;UAAA,GAAApB,OAAA;QAAA,CACd;QAAA,gBAXKL,SAASA,CAAA;UAAA,OAAAC,IAAA,CAAAoB,KAAA,OAAAV,SAAA;QAAA;MAAA,GAWd;;MAED;MACA,OAAO;QACLe,UAAU,EAAE,IAAI;QAChBC,YAAY,EAAE,IAAI;QAClBhC,KAAK,EAAEK;MACT,CAAC;IACH;IAEA,OAAOT,UAAU;EACnB,CAAC;AACH,CAAC;AAACqC,OAAA,CAAAzC,IAAA,GAAAA,IAAA"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _decorators = require("./decorators");
|
|
7
|
+
Object.keys(_decorators).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _decorators[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _decorators[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _utils = require("./utils");
|
|
18
|
+
Object.keys(_utils).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _utils[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_decorators","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_utils"],"sources":["src/index.ts"],"sourcesContent":["export * from './decorators';\nexport * from './utils';\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol");
|
|
4
|
+
require("core-js/modules/es.symbol.description");
|
|
5
|
+
require("core-js/modules/es.symbol.to-primitive");
|
|
6
|
+
require("core-js/modules/es.array.concat");
|
|
7
|
+
require("core-js/modules/es.array.flat");
|
|
8
|
+
require("core-js/modules/es.array.is-array");
|
|
9
|
+
require("core-js/modules/es.array.iterator");
|
|
10
|
+
require("core-js/modules/es.array.join");
|
|
11
|
+
require("core-js/modules/es.array.map");
|
|
12
|
+
require("core-js/modules/es.array.unscopables.flat");
|
|
13
|
+
require("core-js/modules/es.date.to-primitive");
|
|
14
|
+
require("core-js/modules/es.date.to-string");
|
|
15
|
+
require("core-js/modules/es.function.name");
|
|
16
|
+
require("core-js/modules/es.number.constructor");
|
|
17
|
+
require("core-js/modules/es.object.entries");
|
|
18
|
+
require("core-js/modules/es.object.to-string");
|
|
19
|
+
require("core-js/modules/es.promise");
|
|
20
|
+
require("core-js/modules/es.regexp.exec");
|
|
21
|
+
require("core-js/modules/es.regexp.to-string");
|
|
22
|
+
require("core-js/modules/es.string.iterator");
|
|
23
|
+
require("core-js/modules/es.string.split");
|
|
24
|
+
require("core-js/modules/web.dom-collections.iterator");
|
|
25
|
+
Object.defineProperty(exports, "__esModule", {
|
|
26
|
+
value: true
|
|
27
|
+
});
|
|
28
|
+
exports.MultiPartUTF8FormData = void 0;
|
|
29
|
+
require("regenerator-runtime/runtime");
|
|
30
|
+
var _base64Handler = require("./base64Handler");
|
|
31
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
32
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
+
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."); }
|
|
34
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
35
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
36
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
38
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
39
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
40
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
41
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
42
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
43
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
44
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
45
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
46
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
47
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
48
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
49
|
+
/**
|
|
50
|
+
* make you can send custom form data with `filename*=`
|
|
51
|
+
*/
|
|
52
|
+
var MultiPartUTF8FormData = /*#__PURE__*/function () {
|
|
53
|
+
function MultiPartUTF8FormData(dataList) {
|
|
54
|
+
_classCallCheck(this, MultiPartUTF8FormData);
|
|
55
|
+
this.dataList = dataList;
|
|
56
|
+
this._boundary = "----Boundary".concat(Math.random().toString(35).substring(2));
|
|
57
|
+
}
|
|
58
|
+
_createClass(MultiPartUTF8FormData, [{
|
|
59
|
+
key: "getData",
|
|
60
|
+
value: function () {
|
|
61
|
+
var _getData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
62
|
+
var contentType,
|
|
63
|
+
formDataStringList,
|
|
64
|
+
wrappedBoundary,
|
|
65
|
+
outputRowData,
|
|
66
|
+
_args = arguments;
|
|
67
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
68
|
+
while (1) {
|
|
69
|
+
switch (_context.prev = _context.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
contentType = _args.length > 0 && _args[0] !== undefined ? _args[0] : 'multipart/form-data';
|
|
72
|
+
_context.next = 3;
|
|
73
|
+
return this.getFormStringList();
|
|
74
|
+
case 3:
|
|
75
|
+
formDataStringList = _context.sent;
|
|
76
|
+
wrappedBoundary = "--".concat(this._boundary);
|
|
77
|
+
outputRowData = "".concat(formDataStringList.map(function (body) {
|
|
78
|
+
return "".concat(wrappedBoundary, "\r\n").concat(body);
|
|
79
|
+
}).join('\r\n'));
|
|
80
|
+
return _context.abrupt("return", {
|
|
81
|
+
contentType: "".concat(contentType, "; boundary=").concat(this._boundary),
|
|
82
|
+
formData: "".concat(outputRowData, "\r\n").concat(wrappedBoundary, "--")
|
|
83
|
+
});
|
|
84
|
+
case 7:
|
|
85
|
+
case "end":
|
|
86
|
+
return _context.stop();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, _callee, this);
|
|
90
|
+
}));
|
|
91
|
+
function getData() {
|
|
92
|
+
return _getData.apply(this, arguments);
|
|
93
|
+
}
|
|
94
|
+
return getData;
|
|
95
|
+
}()
|
|
96
|
+
}, {
|
|
97
|
+
key: "getFormStringList",
|
|
98
|
+
value: function () {
|
|
99
|
+
var _getFormStringList = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
100
|
+
var _this = this;
|
|
101
|
+
var result;
|
|
102
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
103
|
+
while (1) {
|
|
104
|
+
switch (_context4.prev = _context4.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
_context4.next = 2;
|
|
107
|
+
return Promise.all([].concat(_toConsumableArray(Object.entries(this.dataList.fields || {}).map( /*#__PURE__*/function () {
|
|
108
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref) {
|
|
109
|
+
var _ref3, key, value;
|
|
110
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) {
|
|
112
|
+
switch (_context2.prev = _context2.next) {
|
|
113
|
+
case 0:
|
|
114
|
+
_ref3 = _slicedToArray(_ref, 2), key = _ref3[0], value = _ref3[1];
|
|
115
|
+
if (!(_typeof(value) === 'object')) {
|
|
116
|
+
_context2.next = 3;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
return _context2.abrupt("return", _this.getJsonFormString({
|
|
120
|
+
key: key,
|
|
121
|
+
source: JSON.stringify(value)
|
|
122
|
+
}));
|
|
123
|
+
case 3:
|
|
124
|
+
return _context2.abrupt("return", _this.getJsonFormString({
|
|
125
|
+
key: key,
|
|
126
|
+
source: value
|
|
127
|
+
}));
|
|
128
|
+
case 4:
|
|
129
|
+
case "end":
|
|
130
|
+
return _context2.stop();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, _callee2);
|
|
134
|
+
}));
|
|
135
|
+
return function (_x) {
|
|
136
|
+
return _ref2.apply(this, arguments);
|
|
137
|
+
};
|
|
138
|
+
}())), _toConsumableArray(Object.entries(this.dataList.files || {}).map( /*#__PURE__*/function () {
|
|
139
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
140
|
+
var _ref6, key, value;
|
|
141
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
142
|
+
while (1) {
|
|
143
|
+
switch (_context3.prev = _context3.next) {
|
|
144
|
+
case 0:
|
|
145
|
+
_ref6 = _slicedToArray(_ref4, 2), key = _ref6[0], value = _ref6[1];
|
|
146
|
+
if (!Array.isArray(value)) {
|
|
147
|
+
_context3.next = 3;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
return _context3.abrupt("return", Promise.all(value.map(function (file) {
|
|
151
|
+
return _this.processFile(key, file);
|
|
152
|
+
})));
|
|
153
|
+
case 3:
|
|
154
|
+
return _context3.abrupt("return", _this.processFile(key, value));
|
|
155
|
+
case 4:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context3.stop();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}, _callee3);
|
|
161
|
+
}));
|
|
162
|
+
return function (_x2) {
|
|
163
|
+
return _ref5.apply(this, arguments);
|
|
164
|
+
};
|
|
165
|
+
}()))));
|
|
166
|
+
case 2:
|
|
167
|
+
result = _context4.sent;
|
|
168
|
+
return _context4.abrupt("return", result.flat());
|
|
169
|
+
case 4:
|
|
170
|
+
case "end":
|
|
171
|
+
return _context4.stop();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, _callee4, this);
|
|
175
|
+
}));
|
|
176
|
+
function getFormStringList() {
|
|
177
|
+
return _getFormStringList.apply(this, arguments);
|
|
178
|
+
}
|
|
179
|
+
return getFormStringList;
|
|
180
|
+
}()
|
|
181
|
+
}, {
|
|
182
|
+
key: "processFile",
|
|
183
|
+
value: function () {
|
|
184
|
+
var _processFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(key, file) {
|
|
185
|
+
var base64;
|
|
186
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
187
|
+
while (1) {
|
|
188
|
+
switch (_context5.prev = _context5.next) {
|
|
189
|
+
case 0:
|
|
190
|
+
_context5.next = 2;
|
|
191
|
+
return (0, _base64Handler.fileToBase64)(file);
|
|
192
|
+
case 2:
|
|
193
|
+
base64 = _context5.sent;
|
|
194
|
+
return _context5.abrupt("return", this.getBase64FormString({
|
|
195
|
+
key: key,
|
|
196
|
+
source: base64,
|
|
197
|
+
filename: file instanceof File ? file.name : 'blob',
|
|
198
|
+
type: file.type
|
|
199
|
+
}));
|
|
200
|
+
case 4:
|
|
201
|
+
case "end":
|
|
202
|
+
return _context5.stop();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}, _callee5, this);
|
|
206
|
+
}));
|
|
207
|
+
function processFile(_x3, _x4) {
|
|
208
|
+
return _processFile.apply(this, arguments);
|
|
209
|
+
}
|
|
210
|
+
return processFile;
|
|
211
|
+
}()
|
|
212
|
+
}, {
|
|
213
|
+
key: "getJsonFormString",
|
|
214
|
+
value: function getJsonFormString(_ref7) {
|
|
215
|
+
var key = _ref7.key,
|
|
216
|
+
source = _ref7.source,
|
|
217
|
+
_ref7$type = _ref7.type,
|
|
218
|
+
type = _ref7$type === void 0 ? 'application/json' : _ref7$type;
|
|
219
|
+
return ["Content-Disposition: form-data; name=\"".concat(key, "\""), "Content-type: ".concat(type), '', "".concat(source)].join('\r\n');
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "getBase64FormString",
|
|
223
|
+
value: function getBase64FormString(_ref8) {
|
|
224
|
+
var key = _ref8.key,
|
|
225
|
+
source = _ref8.source,
|
|
226
|
+
_ref8$filename = _ref8.filename,
|
|
227
|
+
filename = _ref8$filename === void 0 ? 'blob' : _ref8$filename,
|
|
228
|
+
_ref8$type = _ref8.type,
|
|
229
|
+
type = _ref8$type === void 0 ? 'application/octet-stream' : _ref8$type;
|
|
230
|
+
var encodedFileName = encodeURI(filename);
|
|
231
|
+
var contentType = type;
|
|
232
|
+
var dataUrl = source.split('base64,')[1];
|
|
233
|
+
return ["Content-Disposition: form-data; name=\"".concat(key, "\"; filename*=\"UTF-8''").concat(encodedFileName, "\"; filename=\"").concat(encodedFileName, "\""), "Content-Type: ".concat(contentType), 'Content-Transfer-Encoding: base64', '', dataUrl].join('\r\n');
|
|
234
|
+
}
|
|
235
|
+
}]);
|
|
236
|
+
return MultiPartUTF8FormData;
|
|
237
|
+
}();
|
|
238
|
+
exports.MultiPartUTF8FormData = MultiPartUTF8FormData;
|
|
239
|
+
//# sourceMappingURL=MultiPartUTF8FormData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiPartUTF8FormData.js","names":["_base64Handler","require","_typeof","obj","Symbol","iterator","constructor","prototype","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","_i","_s","_e","_x","_r","_arr","_n","_d","call","next","Object","done","push","value","length","err","Array","isArray","_toConsumableArray","_arrayWithoutHoles","_iterableToArray","_nonIterableSpread","o","minLen","_arrayLikeToArray","n","toString","slice","name","from","test","iter","len","arr2","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","error","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","undefined","_classCallCheck","instance","Constructor","_defineProperties","target","props","descriptor","enumerable","configurable","writable","defineProperty","_toPropertyKey","_createClass","protoProps","staticProps","_toPrimitive","String","input","hint","prim","toPrimitive","res","Number","MultiPartUTF8FormData","dataList","_boundary","concat","Math","random","substring","_getData","regeneratorRuntime","mark","_callee","contentType","formDataStringList","wrappedBoundary","outputRowData","_args","wrap","_callee$","_context","prev","getFormStringList","sent","map","body","join","abrupt","formData","stop","getData","_getFormStringList","_callee4","_this","result","_callee4$","_context4","all","entries","fields","_ref2","_callee2","_ref","_ref3","_callee2$","_context2","getJsonFormString","source","JSON","stringify","files","_ref5","_callee3","_ref4","_ref6","_callee3$","_context3","file","processFile","_x2","flat","_processFile","_callee5","base64","_callee5$","_context5","fileToBase64","getBase64FormString","filename","File","type","_x3","_x4","_ref7","_ref7$type","_ref8","_ref8$filename","_ref8$type","encodedFileName","encodeURI","dataUrl","split","exports"],"sources":["src/utils/MultiPartUTF8FormData.ts"],"sourcesContent":["import { fileToBase64 } from './base64Handler';\n\ntype MultiPartDataType = {\n key: string;\n source: string;\n filename?: string;\n type?: string;\n};\n\nexport type MultiPartUTF8FormDataOptions = {\n fields?: Record<string, any>;\n files?: Record<string, File | Blob | File[] | Blob[]>;\n};\n\n/**\n * make you can send custom form data with `filename*=`\n */\nexport class MultiPartUTF8FormData {\n private _boundary = `----Boundary${Math.random().toString(35).substring(2)}`;\n\n constructor(private dataList: MultiPartUTF8FormDataOptions) {}\n\n async getData(contentType = 'multipart/form-data') {\n const formDataStringList = await this.getFormStringList();\n const wrappedBoundary = `--${this._boundary}`;\n const outputRowData = `${formDataStringList\n .map((body) => `${wrappedBoundary}\\r\\n${body}`)\n .join('\\r\\n')}`;\n\n return {\n contentType: `${contentType}; boundary=${this._boundary}`,\n formData: `${outputRowData}\\r\\n${wrappedBoundary}--`,\n };\n }\n\n private async getFormStringList() {\n const result = await Promise.all([\n ...Object.entries(this.dataList.fields || {}).map(\n async ([key, value]) => {\n if (typeof value === 'object') {\n return this.getJsonFormString({\n key,\n source: JSON.stringify(value),\n });\n }\n\n return this.getJsonFormString({\n key,\n source: value,\n });\n },\n ),\n ...Object.entries(this.dataList.files || {}).map(async ([key, value]) => {\n if (Array.isArray(value)) {\n return Promise.all(value.map((file) => this.processFile(key, file)));\n }\n\n return this.processFile(key, value);\n }),\n ]);\n\n return result.flat();\n }\n\n private async processFile(key: string, file: File | Blob) {\n const base64 = await fileToBase64(file);\n\n return this.getBase64FormString({\n key,\n source: base64,\n filename: file instanceof File ? file.name : 'blob',\n type: file.type,\n });\n }\n\n private getJsonFormString({\n key,\n source,\n type = 'application/json',\n }: MultiPartDataType) {\n return [\n `Content-Disposition: form-data; name=\"${key}\"`,\n `Content-type: ${type}`,\n '',\n `${source}`,\n ].join('\\r\\n');\n }\n\n private getBase64FormString({\n key,\n source,\n filename = 'blob',\n type = 'application/octet-stream',\n }: MultiPartDataType) {\n const encodedFileName = encodeURI(filename);\n const contentType = type;\n const dataUrl = source.split('base64,')[1];\n\n return [\n `Content-Disposition: form-data; name=\"${key}\"; filename*=\"UTF-8''${encodedFileName}\"; filename=\"${encodedFileName}\"`,\n `Content-Type: ${contentType}`,\n 'Content-Transfer-Encoding: base64',\n '',\n dataUrl,\n ].join('\\r\\n');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.array.iterator");
|
|
4
|
+
require("core-js/modules/es.array-buffer.constructor");
|
|
5
|
+
require("core-js/modules/es.array-buffer.slice");
|
|
6
|
+
require("core-js/modules/es.object.to-string");
|
|
7
|
+
require("core-js/modules/es.promise");
|
|
8
|
+
require("core-js/modules/es.regexp.exec");
|
|
9
|
+
require("core-js/modules/es.string.replace");
|
|
10
|
+
require("core-js/modules/es.string.split");
|
|
11
|
+
require("core-js/modules/es.typed-array.uint8-array");
|
|
12
|
+
require("core-js/modules/es.typed-array.copy-within");
|
|
13
|
+
require("core-js/modules/es.typed-array.every");
|
|
14
|
+
require("core-js/modules/es.typed-array.fill");
|
|
15
|
+
require("core-js/modules/es.typed-array.filter");
|
|
16
|
+
require("core-js/modules/es.typed-array.find");
|
|
17
|
+
require("core-js/modules/es.typed-array.find-index");
|
|
18
|
+
require("core-js/modules/es.typed-array.for-each");
|
|
19
|
+
require("core-js/modules/es.typed-array.includes");
|
|
20
|
+
require("core-js/modules/es.typed-array.index-of");
|
|
21
|
+
require("core-js/modules/es.typed-array.iterator");
|
|
22
|
+
require("core-js/modules/es.typed-array.join");
|
|
23
|
+
require("core-js/modules/es.typed-array.last-index-of");
|
|
24
|
+
require("core-js/modules/es.typed-array.map");
|
|
25
|
+
require("core-js/modules/es.typed-array.reduce");
|
|
26
|
+
require("core-js/modules/es.typed-array.reduce-right");
|
|
27
|
+
require("core-js/modules/es.typed-array.reverse");
|
|
28
|
+
require("core-js/modules/es.typed-array.set");
|
|
29
|
+
require("core-js/modules/es.typed-array.slice");
|
|
30
|
+
require("core-js/modules/es.typed-array.some");
|
|
31
|
+
require("core-js/modules/es.typed-array.sort");
|
|
32
|
+
require("core-js/modules/es.typed-array.subarray");
|
|
33
|
+
require("core-js/modules/es.typed-array.to-locale-string");
|
|
34
|
+
require("core-js/modules/es.typed-array.to-string");
|
|
35
|
+
Object.defineProperty(exports, "__esModule", {
|
|
36
|
+
value: true
|
|
37
|
+
});
|
|
38
|
+
exports.base64ToBlob = base64ToBlob;
|
|
39
|
+
exports.base64ToFile = base64ToFile;
|
|
40
|
+
exports.decodeBase64DataUrl = decodeBase64DataUrl;
|
|
41
|
+
exports.fileToBinary = exports.fileToBase64 = void 0;
|
|
42
|
+
exports.isBase64DataUrl = isBase64DataUrl;
|
|
43
|
+
var REGEXP_BASE64_DATA_URL = /^(data:\w+\/[a-zA-Z+\-.]+;base64,)?(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/i;
|
|
44
|
+
function isBase64DataUrl(value) {
|
|
45
|
+
return REGEXP_BASE64_DATA_URL.test(value);
|
|
46
|
+
}
|
|
47
|
+
function decodeBase64DataUrl(dataURL) {
|
|
48
|
+
if (isBase64DataUrl(dataURL)) {
|
|
49
|
+
return atob(dataURL.split('base64,')[1]);
|
|
50
|
+
}
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
var fileToBase64 = function fileToBase64(file) {
|
|
54
|
+
return new Promise(function (resolve, reject) {
|
|
55
|
+
var reader = new FileReader();
|
|
56
|
+
reader.onload = function (e) {
|
|
57
|
+
resolve(e.target.result);
|
|
58
|
+
};
|
|
59
|
+
reader.onerror = function (err) {
|
|
60
|
+
reject(err);
|
|
61
|
+
};
|
|
62
|
+
reader.readAsDataURL(file);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
exports.fileToBase64 = fileToBase64;
|
|
66
|
+
var fileToBinary = function fileToBinary(file) {
|
|
67
|
+
return new Promise(function (resolve, reject) {
|
|
68
|
+
var reader = new FileReader();
|
|
69
|
+
reader.onload = function (e) {
|
|
70
|
+
resolve(e.target.result);
|
|
71
|
+
};
|
|
72
|
+
reader.onerror = function (err) {
|
|
73
|
+
reject(err);
|
|
74
|
+
};
|
|
75
|
+
reader.readAsBinaryString(file);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
exports.fileToBinary = fileToBinary;
|
|
79
|
+
function base64ToBlob(base64Image) {
|
|
80
|
+
var split = base64Image.split(',');
|
|
81
|
+
var type = split[0].replace('data:', '').replace(';base64', '');
|
|
82
|
+
var byteString = atob(split[1]);
|
|
83
|
+
var ab = new ArrayBuffer(byteString.length);
|
|
84
|
+
var ia = new Uint8Array(ab);
|
|
85
|
+
for (var i = 0; i < byteString.length; i += 1) {
|
|
86
|
+
ia[i] = byteString.charCodeAt(i);
|
|
87
|
+
}
|
|
88
|
+
return new Blob([ab], {
|
|
89
|
+
type: type
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function base64ToFile(base64Image, filename) {
|
|
93
|
+
var blob = base64ToBlob(base64Image);
|
|
94
|
+
return new File([blob], filename);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=base64Handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64Handler.js","names":["REGEXP_BASE64_DATA_URL","isBase64DataUrl","value","test","decodeBase64DataUrl","dataURL","atob","split","fileToBase64","file","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","err","readAsDataURL","exports","fileToBinary","readAsBinaryString","base64ToBlob","base64Image","type","replace","byteString","ab","ArrayBuffer","length","ia","Uint8Array","i","charCodeAt","Blob","base64ToFile","filename","blob","File"],"sources":["src/utils/base64Handler.ts"],"sourcesContent":["const REGEXP_BASE64_DATA_URL =\n /^(data:\\w+\\/[a-zA-Z+\\-.]+;base64,)?(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/i;\n\nexport function isBase64DataUrl(value: string) {\n return REGEXP_BASE64_DATA_URL.test(value);\n}\n\nexport function decodeBase64DataUrl(dataURL: string) {\n if (isBase64DataUrl(dataURL)) {\n return atob(dataURL.split('base64,')[1]);\n }\n\n return '';\n}\n\nexport const fileToBase64 = (file: File | Blob) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n resolve(e.target!.result as string);\n };\n\n reader.onerror = (err) => {\n reject(err);\n };\n\n reader.readAsDataURL(file);\n });\n};\n\nexport const fileToBinary = (file: File | Blob) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n resolve(e.target!.result as string);\n };\n\n reader.onerror = (err) => {\n reject(err);\n };\n\n reader.readAsBinaryString(file);\n });\n};\n\nexport function base64ToBlob(base64Image: string) {\n const split = base64Image.split(',');\n const type = split[0].replace('data:', '').replace(';base64', '');\n const byteString = atob(split[1]);\n const ab = new ArrayBuffer(byteString.length);\n const ia = new Uint8Array(ab);\n for (let i = 0; i < byteString.length; i += 1) {\n ia[i] = byteString.charCodeAt(i);\n }\n return new Blob([ab], { type });\n}\n\nexport function base64ToFile(base64Image: string, filename: string) {\n const blob = base64ToBlob(base64Image);\n\n return new File([blob], filename);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,sBAAsB,GAC1B,qGAAqG;AAEhG,SAASC,eAAeA,CAACC,KAAa,EAAE;EAC7C,OAAOF,sBAAsB,CAACG,IAAI,CAACD,KAAK,CAAC;AAC3C;AAEO,SAASE,mBAAmBA,CAACC,OAAe,EAAE;EACnD,IAAIJ,eAAe,CAACI,OAAO,CAAC,EAAE;IAC5B,OAAOC,IAAI,CAACD,OAAO,CAACE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;EAC1C;EAEA,OAAO,EAAE;AACX;AAEO,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,IAAiB,EAAK;EACjD,OAAO,IAAIC,OAAO,CAAS,UAACC,OAAO,EAAEC,MAAM,EAAK;IAC9C,IAAMC,MAAM,GAAG,IAAIC,UAAU,CAAC,CAAC;IAC/BD,MAAM,CAACE,MAAM,GAAG,UAACC,CAAC,EAAK;MACrBL,OAAO,CAACK,CAAC,CAACC,MAAM,CAAEC,MAAgB,CAAC;I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