@wener/utils 1.0.0 → 1.1.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/README.md +5 -3
- package/jest.config.js +7 -5
- package/lib/cjs/arrays/MaybeArray.js +45 -33
- package/lib/cjs/arrays/index.js +17 -5
- package/lib/cjs/asyncs/AsyncInterval.js +32 -25
- package/lib/cjs/asyncs/LazyPromise.js +41 -24
- package/lib/cjs/asyncs/MaybePromise.js +15 -3
- package/lib/cjs/asyncs/generatorOfStream.js +33 -28
- package/lib/cjs/asyncs/index.js +23 -11
- package/lib/cjs/asyncs/isPromise.js +23 -6
- package/lib/cjs/asyncs/promiseOfCallback.js +34 -19
- package/lib/cjs/asyncs/sleep.js +23 -5
- package/lib/cjs/asyncs/timeout.js +42 -28
- package/lib/cjs/browsers/copy.js +71 -0
- package/lib/cjs/browsers/download.js +44 -33
- package/lib/cjs/browsers/getFileFromDataTransfer.js +48 -0
- package/lib/cjs/browsers/index.js +20 -8
- package/lib/cjs/browsers/loaders.js +48 -35
- package/lib/cjs/formats/formatBytes.js +36 -0
- package/lib/cjs/index.js +35 -13
- package/lib/cjs/io/index.js +17 -5
- package/lib/cjs/io/isBuffer.js +23 -10
- package/lib/cjs/isomorphics/getGlobalThis.js +32 -27
- package/lib/cjs/maths/index.js +17 -5
- package/lib/cjs/maths/random.js +34 -19
- package/lib/cjs/shim/urljoin.js +70 -0
- package/lib/cjs/shim/urljoin.test.js +4 -0
- package/lib/cjs/strings/camelCase.js +70 -68
- package/lib/cjs/strings/index.js +18 -7
- package/lib/cjs/strings/templates.js +26 -18
- package/lib/cjs/validations/asserts.js +25 -14
- package/lib/cjs/validations/index.js +20 -8
- package/lib/cjs/validations/isClass.js +23 -6
- package/lib/cjs/validations/isDefined.js +23 -6
- package/lib/cjs/validations/isEmptyObject.js +26 -9
- package/lib/esm/arrays/MaybeArray.js +29 -29
- package/lib/esm/arrays/index.js +1 -2
- package/lib/esm/asyncs/AsyncInterval.js +14 -21
- package/lib/esm/asyncs/LazyPromise.js +23 -21
- package/lib/esm/asyncs/MaybePromise.js +0 -1
- package/lib/esm/asyncs/generatorOfStream.js +14 -24
- package/lib/esm/asyncs/index.js +7 -8
- package/lib/esm/asyncs/isPromise.js +5 -3
- package/lib/esm/asyncs/promiseOfCallback.js +16 -16
- package/lib/esm/asyncs/sleep.js +4 -2
- package/lib/esm/asyncs/timeout.js +24 -25
- package/lib/{cjs/browsers/clipboard.d.ts → esm/browsers/copy.d.ts} +0 -0
- package/lib/esm/browsers/copy.js +52 -0
- package/lib/esm/browsers/download.js +25 -29
- package/lib/esm/browsers/getFileFromDataTransfer.d.ts +4 -0
- package/lib/esm/browsers/getFileFromDataTransfer.js +29 -0
- package/lib/esm/browsers/index.d.ts +2 -2
- package/lib/esm/browsers/index.js +4 -5
- package/lib/esm/browsers/loaders.js +31 -32
- package/lib/esm/formats/formatBytes.d.ts +11 -0
- package/lib/esm/formats/formatBytes.js +17 -0
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +15 -10
- package/lib/esm/io/index.js +1 -2
- package/lib/esm/io/isBuffer.js +5 -7
- package/lib/esm/isomorphics/getGlobalThis.d.ts +1 -1
- package/lib/esm/isomorphics/getGlobalThis.js +13 -24
- package/lib/esm/maths/index.js +1 -2
- package/lib/esm/maths/random.d.ts +2 -2
- package/lib/esm/maths/random.js +15 -15
- package/lib/{cjs/strings → esm/shim}/urljoin.d.ts +1 -0
- package/lib/esm/shim/urljoin.js +51 -0
- package/lib/{cjs/strings → esm/shim}/urljoin.test.d.ts +0 -0
- package/lib/esm/shim/urljoin.test.js +4 -0
- package/lib/esm/strings/camelCase.js +52 -64
- package/lib/esm/strings/index.d.ts +0 -1
- package/lib/esm/strings/index.js +2 -4
- package/lib/esm/strings/templates.d.ts +1 -1
- package/lib/esm/strings/templates.js +7 -14
- package/lib/esm/validations/asserts.js +8 -11
- package/lib/esm/validations/index.js +4 -5
- package/lib/esm/validations/isClass.js +5 -3
- package/lib/esm/validations/isDefined.js +5 -3
- package/lib/esm/validations/isEmptyObject.js +8 -6
- package/package.json +23 -32
- package/src/arrays/MaybeArray.ts +5 -2
- package/src/asyncs/timeout.ts +1 -1
- package/src/browsers/{clipboard.ts → copy.ts} +0 -0
- package/src/browsers/{transfers.ts → getFileFromDataTransfer.ts} +12 -7
- package/src/browsers/index.ts +2 -2
- package/src/browsers/loaders.ts +1 -1
- package/src/formats/formatBytes.ts +30 -0
- package/src/index.ts +4 -2
- package/src/isomorphics/getGlobalThis.ts +2 -4
- package/src/maths/random.ts +5 -5
- package/src/shim/urljoin.test.ts +5 -0
- package/src/{strings → shim}/urljoin.ts +18 -5
- package/src/strings/index.ts +0 -1
- package/src/strings/templates.ts +2 -4
- package/tsconfig.json +15 -4
- package/dist/wener-utils.cjs +0 -882
- package/dist/wener-utils.cjs.map +0 -1
- package/dist/wener-utils.esm.js +0 -849
- package/dist/wener-utils.esm.js.map +0 -1
- package/dist/wener-utils.system.js +0 -887
- package/dist/wener-utils.system.js.map +0 -1
- package/dist/wener-utils.umd.js +0 -886
- package/dist/wener-utils.umd.js.map +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -10
- package/lib/cjs/arrays/MaybeArray.d.ts +0 -5
- package/lib/cjs/arrays/MaybeArray.js.map +0 -1
- package/lib/cjs/arrays/index.d.ts +0 -1
- package/lib/cjs/arrays/index.js.map +0 -1
- package/lib/cjs/asyncs/AsyncInterval.d.ts +0 -3
- package/lib/cjs/asyncs/AsyncInterval.js.map +0 -1
- package/lib/cjs/asyncs/LazyPromise.d.ts +0 -5
- package/lib/cjs/asyncs/LazyPromise.js.map +0 -1
- package/lib/cjs/asyncs/MaybePromise.d.ts +0 -1
- package/lib/cjs/asyncs/MaybePromise.js.map +0 -1
- package/lib/cjs/asyncs/generatorOfStream.d.ts +0 -1
- package/lib/cjs/asyncs/generatorOfStream.js.map +0 -1
- package/lib/cjs/asyncs/index.d.ts +0 -7
- package/lib/cjs/asyncs/index.js.map +0 -1
- package/lib/cjs/asyncs/isPromise.d.ts +0 -1
- package/lib/cjs/asyncs/isPromise.js.map +0 -1
- package/lib/cjs/asyncs/promiseOfCallback.d.ts +0 -1
- package/lib/cjs/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/cjs/asyncs/sleep.d.ts +0 -1
- package/lib/cjs/asyncs/sleep.js.map +0 -1
- package/lib/cjs/asyncs/timeout.d.ts +0 -4
- package/lib/cjs/asyncs/timeout.js.map +0 -1
- package/lib/cjs/browsers/clipboard.js +0 -56
- package/lib/cjs/browsers/clipboard.js.map +0 -1
- package/lib/cjs/browsers/download.d.ts +0 -4
- package/lib/cjs/browsers/download.js.map +0 -1
- package/lib/cjs/browsers/index.d.ts +0 -4
- package/lib/cjs/browsers/index.js.map +0 -1
- package/lib/cjs/browsers/loaders.d.ts +0 -6
- package/lib/cjs/browsers/loaders.js.map +0 -1
- package/lib/cjs/browsers/transfers.d.ts +0 -4
- package/lib/cjs/browsers/transfers.js +0 -38
- package/lib/cjs/browsers/transfers.js.map +0 -1
- package/lib/cjs/envs/index.d.ts +0 -1
- package/lib/cjs/envs/index.js +0 -5
- package/lib/cjs/envs/index.js.map +0 -1
- package/lib/cjs/envs/isDev.d.ts +0 -1
- package/lib/cjs/envs/isDev.js +0 -8
- package/lib/cjs/envs/isDev.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -9
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/io/index.d.ts +0 -1
- package/lib/cjs/io/index.js.map +0 -1
- package/lib/cjs/io/isBuffer.d.ts +0 -2
- package/lib/cjs/io/isBuffer.js.map +0 -1
- package/lib/cjs/isomorphics/getGlobalThis.d.ts +0 -9
- package/lib/cjs/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/cjs/isomorphics/index.d.ts +0 -1
- package/lib/cjs/isomorphics/index.js +0 -5
- package/lib/cjs/isomorphics/index.js.map +0 -1
- package/lib/cjs/maths/index.d.ts +0 -1
- package/lib/cjs/maths/index.js.map +0 -1
- package/lib/cjs/maths/random.d.ts +0 -3
- package/lib/cjs/maths/random.js.map +0 -1
- package/lib/cjs/strings/camelCase.d.ts +0 -4
- package/lib/cjs/strings/camelCase.js.map +0 -1
- package/lib/cjs/strings/index.d.ts +0 -3
- package/lib/cjs/strings/index.js.map +0 -1
- package/lib/cjs/strings/templates.d.ts +0 -7
- package/lib/cjs/strings/templates.js.map +0 -1
- package/lib/cjs/strings/urljoin.js +0 -61
- package/lib/cjs/strings/urljoin.js.map +0 -1
- package/lib/cjs/strings/urljoin.test.js +0 -7
- package/lib/cjs/strings/urljoin.test.js.map +0 -1
- package/lib/cjs/validations/asserts.d.ts +0 -2
- package/lib/cjs/validations/asserts.js.map +0 -1
- package/lib/cjs/validations/index.d.ts +0 -4
- package/lib/cjs/validations/index.js.map +0 -1
- package/lib/cjs/validations/isClass.d.ts +0 -1
- package/lib/cjs/validations/isClass.js.map +0 -1
- package/lib/cjs/validations/isDefined.d.ts +0 -1
- package/lib/cjs/validations/isDefined.js.map +0 -1
- package/lib/cjs/validations/isEmptyObject.d.ts +0 -1
- package/lib/cjs/validations/isEmptyObject.js.map +0 -1
- package/lib/esm/arrays/MaybeArray.js.map +0 -1
- package/lib/esm/arrays/index.js.map +0 -1
- package/lib/esm/asyncs/AsyncInterval.js.map +0 -1
- package/lib/esm/asyncs/LazyPromise.js.map +0 -1
- package/lib/esm/asyncs/MaybePromise.js.map +0 -1
- package/lib/esm/asyncs/generatorOfStream.js.map +0 -1
- package/lib/esm/asyncs/index.js.map +0 -1
- package/lib/esm/asyncs/isPromise.js.map +0 -1
- package/lib/esm/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/esm/asyncs/sleep.js.map +0 -1
- package/lib/esm/asyncs/timeout.js.map +0 -1
- package/lib/esm/browsers/clipboard.d.ts +0 -1
- package/lib/esm/browsers/clipboard.js +0 -52
- package/lib/esm/browsers/clipboard.js.map +0 -1
- package/lib/esm/browsers/download.js.map +0 -1
- package/lib/esm/browsers/index.js.map +0 -1
- package/lib/esm/browsers/loaders.js.map +0 -1
- package/lib/esm/browsers/transfers.d.ts +0 -4
- package/lib/esm/browsers/transfers.js +0 -34
- package/lib/esm/browsers/transfers.js.map +0 -1
- package/lib/esm/envs/index.d.ts +0 -1
- package/lib/esm/envs/index.js +0 -2
- package/lib/esm/envs/index.js.map +0 -1
- package/lib/esm/envs/isDev.d.ts +0 -1
- package/lib/esm/envs/isDev.js +0 -5
- package/lib/esm/envs/isDev.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/io/index.js.map +0 -1
- package/lib/esm/io/isBuffer.js.map +0 -1
- package/lib/esm/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/esm/isomorphics/index.d.ts +0 -1
- package/lib/esm/isomorphics/index.js +0 -2
- package/lib/esm/isomorphics/index.js.map +0 -1
- package/lib/esm/maths/index.js.map +0 -1
- package/lib/esm/maths/random.js.map +0 -1
- package/lib/esm/strings/camelCase.js.map +0 -1
- package/lib/esm/strings/index.js.map +0 -1
- package/lib/esm/strings/templates.js.map +0 -1
- package/lib/esm/strings/urljoin.d.ts +0 -1
- package/lib/esm/strings/urljoin.js +0 -57
- package/lib/esm/strings/urljoin.js.map +0 -1
- package/lib/esm/strings/urljoin.test.d.ts +0 -1
- package/lib/esm/strings/urljoin.test.js +0 -5
- package/lib/esm/strings/urljoin.test.js.map +0 -1
- package/lib/esm/validations/asserts.js.map +0 -1
- package/lib/esm/validations/index.js.map +0 -1
- package/lib/esm/validations/isClass.js.map +0 -1
- package/lib/esm/validations/isDefined.js.map +0 -1
- package/lib/esm/validations/isEmptyObject.js.map +0 -1
- package/lib/esnext/arrays/MaybeArray.d.ts +0 -5
- package/lib/esnext/arrays/MaybeArray.js +0 -33
- package/lib/esnext/arrays/MaybeArray.js.map +0 -1
- package/lib/esnext/arrays/index.d.ts +0 -1
- package/lib/esnext/arrays/index.js +0 -2
- package/lib/esnext/arrays/index.js.map +0 -1
- package/lib/esnext/asyncs/AsyncInterval.d.ts +0 -3
- package/lib/esnext/asyncs/AsyncInterval.js +0 -23
- package/lib/esnext/asyncs/AsyncInterval.js.map +0 -1
- package/lib/esnext/asyncs/LazyPromise.d.ts +0 -5
- package/lib/esnext/asyncs/LazyPromise.js +0 -22
- package/lib/esnext/asyncs/LazyPromise.js.map +0 -1
- package/lib/esnext/asyncs/MaybePromise.d.ts +0 -1
- package/lib/esnext/asyncs/MaybePromise.js +0 -1
- package/lib/esnext/asyncs/MaybePromise.js.map +0 -1
- package/lib/esnext/asyncs/generatorOfStream.d.ts +0 -1
- package/lib/esnext/asyncs/generatorOfStream.js +0 -26
- package/lib/esnext/asyncs/generatorOfStream.js.map +0 -1
- package/lib/esnext/asyncs/index.d.ts +0 -7
- package/lib/esnext/asyncs/index.js +0 -8
- package/lib/esnext/asyncs/index.js.map +0 -1
- package/lib/esnext/asyncs/isPromise.d.ts +0 -1
- package/lib/esnext/asyncs/isPromise.js +0 -4
- package/lib/esnext/asyncs/isPromise.js.map +0 -1
- package/lib/esnext/asyncs/promiseOfCallback.d.ts +0 -1
- package/lib/esnext/asyncs/promiseOfCallback.js +0 -18
- package/lib/esnext/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/esnext/asyncs/sleep.d.ts +0 -1
- package/lib/esnext/asyncs/sleep.js +0 -2
- package/lib/esnext/asyncs/sleep.js.map +0 -1
- package/lib/esnext/asyncs/timeout.d.ts +0 -4
- package/lib/esnext/asyncs/timeout.js +0 -26
- package/lib/esnext/asyncs/timeout.js.map +0 -1
- package/lib/esnext/browsers/clipboard.d.ts +0 -1
- package/lib/esnext/browsers/clipboard.js +0 -52
- package/lib/esnext/browsers/clipboard.js.map +0 -1
- package/lib/esnext/browsers/download.d.ts +0 -4
- package/lib/esnext/browsers/download.js +0 -32
- package/lib/esnext/browsers/download.js.map +0 -1
- package/lib/esnext/browsers/index.d.ts +0 -4
- package/lib/esnext/browsers/index.js +0 -5
- package/lib/esnext/browsers/index.js.map +0 -1
- package/lib/esnext/browsers/loaders.d.ts +0 -6
- package/lib/esnext/browsers/loaders.js +0 -36
- package/lib/esnext/browsers/loaders.js.map +0 -1
- package/lib/esnext/browsers/transfers.d.ts +0 -4
- package/lib/esnext/browsers/transfers.js +0 -34
- package/lib/esnext/browsers/transfers.js.map +0 -1
- package/lib/esnext/envs/index.d.ts +0 -1
- package/lib/esnext/envs/index.js +0 -2
- package/lib/esnext/envs/index.js.map +0 -1
- package/lib/esnext/envs/isDev.d.ts +0 -1
- package/lib/esnext/envs/isDev.js +0 -5
- package/lib/esnext/envs/isDev.js.map +0 -1
- package/lib/esnext/index.d.ts +0 -9
- package/lib/esnext/index.js +0 -10
- package/lib/esnext/index.js.map +0 -1
- package/lib/esnext/io/index.d.ts +0 -1
- package/lib/esnext/io/index.js +0 -2
- package/lib/esnext/io/index.js.map +0 -1
- package/lib/esnext/io/isBuffer.d.ts +0 -2
- package/lib/esnext/io/isBuffer.js +0 -8
- package/lib/esnext/io/isBuffer.js.map +0 -1
- package/lib/esnext/isomorphics/getGlobalThis.d.ts +0 -9
- package/lib/esnext/isomorphics/getGlobalThis.js +0 -25
- package/lib/esnext/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/esnext/isomorphics/index.d.ts +0 -1
- package/lib/esnext/isomorphics/index.js +0 -2
- package/lib/esnext/isomorphics/index.js.map +0 -1
- package/lib/esnext/maths/index.d.ts +0 -1
- package/lib/esnext/maths/index.js +0 -2
- package/lib/esnext/maths/index.js.map +0 -1
- package/lib/esnext/maths/random.d.ts +0 -3
- package/lib/esnext/maths/random.js +0 -17
- package/lib/esnext/maths/random.js.map +0 -1
- package/lib/esnext/strings/camelCase.d.ts +0 -4
- package/lib/esnext/strings/camelCase.js +0 -69
- package/lib/esnext/strings/camelCase.js.map +0 -1
- package/lib/esnext/strings/index.d.ts +0 -3
- package/lib/esnext/strings/index.js +0 -4
- package/lib/esnext/strings/index.js.map +0 -1
- package/lib/esnext/strings/templates.d.ts +0 -7
- package/lib/esnext/strings/templates.js +0 -15
- package/lib/esnext/strings/templates.js.map +0 -1
- package/lib/esnext/strings/urljoin.d.ts +0 -1
- package/lib/esnext/strings/urljoin.js +0 -57
- package/lib/esnext/strings/urljoin.js.map +0 -1
- package/lib/esnext/strings/urljoin.test.d.ts +0 -1
- package/lib/esnext/strings/urljoin.test.js +0 -5
- package/lib/esnext/strings/urljoin.test.js.map +0 -1
- package/lib/esnext/validations/asserts.d.ts +0 -2
- package/lib/esnext/validations/asserts.js +0 -13
- package/lib/esnext/validations/asserts.js.map +0 -1
- package/lib/esnext/validations/index.d.ts +0 -4
- package/lib/esnext/validations/index.js +0 -5
- package/lib/esnext/validations/index.js.map +0 -1
- package/lib/esnext/validations/isClass.d.ts +0 -1
- package/lib/esnext/validations/isClass.js +0 -4
- package/lib/esnext/validations/isClass.js.map +0 -1
- package/lib/esnext/validations/isDefined.d.ts +0 -1
- package/lib/esnext/validations/isDefined.js +0 -4
- package/lib/esnext/validations/isDefined.js.map +0 -1
- package/lib/esnext/validations/isEmptyObject.d.ts +0 -1
- package/lib/esnext/validations/isEmptyObject.js +0 -7
- package/lib/esnext/validations/isEmptyObject.js.map +0 -1
- package/rollup.config.ts +0 -85
- package/src/envs/index.ts +0 -1
- package/src/envs/isDev.ts +0 -3
- package/src/isomorphics/index.ts +0 -1
- package/src/strings/urljoin.test.ts +0 -5
|
@@ -1,887 +0,0 @@
|
|
|
1
|
-
System.register(['lodash'], function (exports) {
|
|
2
|
-
'use strict';
|
|
3
|
-
var get;
|
|
4
|
-
return {
|
|
5
|
-
setters: [function (module) {
|
|
6
|
-
get = module.get;
|
|
7
|
-
}],
|
|
8
|
-
execute: function () {
|
|
9
|
-
|
|
10
|
-
exports({
|
|
11
|
-
arrayOfMaybeArray: arrayOfMaybeArray,
|
|
12
|
-
assert: assert,
|
|
13
|
-
assertIsDefined: assertIsDefined,
|
|
14
|
-
camelCase: camelCase,
|
|
15
|
-
clearAsyncInterval: clearAsyncInterval,
|
|
16
|
-
copy: copy,
|
|
17
|
-
createLazyPromise: createLazyPromise,
|
|
18
|
-
createRandom: createRandom,
|
|
19
|
-
download: download,
|
|
20
|
-
firstOfMaybeArray: firstOfMaybeArray,
|
|
21
|
-
getFile: getFile,
|
|
22
|
-
isBuffer: isBuffer,
|
|
23
|
-
isClass: isClass,
|
|
24
|
-
isDefined: isDefined,
|
|
25
|
-
isEmptyObject: isEmptyObject,
|
|
26
|
-
isPromise: isPromise,
|
|
27
|
-
lastOfMaybeArray: lastOfMaybeArray,
|
|
28
|
-
loadScripts: loadScripts,
|
|
29
|
-
loadStyles: loadStyles,
|
|
30
|
-
objectOfMaybeArray: objectOfMaybeArray,
|
|
31
|
-
pascalCase: pascalCase,
|
|
32
|
-
promiseOfCallback: promiseOfCallback,
|
|
33
|
-
setAsyncInterval: setAsyncInterval,
|
|
34
|
-
templateString: templateString,
|
|
35
|
-
timeout: timeout,
|
|
36
|
-
urljoin: urljoin
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
40
|
-
try {
|
|
41
|
-
var info = gen[key](arg);
|
|
42
|
-
var value = info.value;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
reject(error);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (info.done) {
|
|
49
|
-
resolve(value);
|
|
50
|
-
} else {
|
|
51
|
-
Promise.resolve(value).then(_next, _throw);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function _asyncToGenerator(fn) {
|
|
56
|
-
return function () {
|
|
57
|
-
var self = this,
|
|
58
|
-
args = arguments;
|
|
59
|
-
return new Promise(function (resolve, reject) {
|
|
60
|
-
var gen = fn.apply(self, args);
|
|
61
|
-
|
|
62
|
-
function _next(value) {
|
|
63
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function _throw(err) {
|
|
67
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
_next(undefined);
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function _classCallCheck(instance, Constructor) {
|
|
76
|
-
if (!(instance instanceof Constructor)) {
|
|
77
|
-
throw new TypeError("Cannot call a class as a function");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function _inherits(subClass, superClass) {
|
|
82
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
83
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
87
|
-
constructor: {
|
|
88
|
-
value: subClass,
|
|
89
|
-
writable: true,
|
|
90
|
-
configurable: true
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function _getPrototypeOf(o) {
|
|
97
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
98
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
99
|
-
};
|
|
100
|
-
return _getPrototypeOf(o);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function _setPrototypeOf(o, p) {
|
|
104
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
105
|
-
o.__proto__ = p;
|
|
106
|
-
return o;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
return _setPrototypeOf(o, p);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function _isNativeReflectConstruct() {
|
|
113
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
114
|
-
if (Reflect.construct.sham) return false;
|
|
115
|
-
if (typeof Proxy === "function") return true;
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
|
119
|
-
return true;
|
|
120
|
-
} catch (e) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function _construct(Parent, args, Class) {
|
|
126
|
-
if (_isNativeReflectConstruct()) {
|
|
127
|
-
_construct = Reflect.construct;
|
|
128
|
-
} else {
|
|
129
|
-
_construct = function _construct(Parent, args, Class) {
|
|
130
|
-
var a = [null];
|
|
131
|
-
a.push.apply(a, args);
|
|
132
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
133
|
-
var instance = new Constructor();
|
|
134
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
135
|
-
return instance;
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return _construct.apply(null, arguments);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function _isNativeFunction(fn) {
|
|
143
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function _wrapNativeSuper(Class) {
|
|
147
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
148
|
-
|
|
149
|
-
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
150
|
-
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
151
|
-
|
|
152
|
-
if (typeof Class !== "function") {
|
|
153
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (typeof _cache !== "undefined") {
|
|
157
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
158
|
-
|
|
159
|
-
_cache.set(Class, Wrapper);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function Wrapper() {
|
|
163
|
-
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
167
|
-
constructor: {
|
|
168
|
-
value: Wrapper,
|
|
169
|
-
enumerable: false,
|
|
170
|
-
writable: true,
|
|
171
|
-
configurable: true
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
return _setPrototypeOf(Wrapper, Class);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
return _wrapNativeSuper(Class);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function _assertThisInitialized(self) {
|
|
181
|
-
if (self === void 0) {
|
|
182
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return self;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function _possibleConstructorReturn(self, call) {
|
|
189
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
190
|
-
return call;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return _assertThisInitialized(self);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function _createSuper(Derived) {
|
|
197
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
198
|
-
|
|
199
|
-
return function _createSuperInternal() {
|
|
200
|
-
var Super = _getPrototypeOf(Derived),
|
|
201
|
-
result;
|
|
202
|
-
|
|
203
|
-
if (hasNativeReflectConstruct) {
|
|
204
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
205
|
-
|
|
206
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
207
|
-
} else {
|
|
208
|
-
result = Super.apply(this, arguments);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return _possibleConstructorReturn(this, result);
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function _slicedToArray(arr, i) {
|
|
216
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function _arrayWithHoles(arr) {
|
|
220
|
-
if (Array.isArray(arr)) return arr;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function _iterableToArrayLimit(arr, i) {
|
|
224
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
225
|
-
var _arr = [];
|
|
226
|
-
var _n = true;
|
|
227
|
-
var _d = false;
|
|
228
|
-
var _e = undefined;
|
|
229
|
-
|
|
230
|
-
try {
|
|
231
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
232
|
-
_arr.push(_s.value);
|
|
233
|
-
|
|
234
|
-
if (i && _arr.length === i) break;
|
|
235
|
-
}
|
|
236
|
-
} catch (err) {
|
|
237
|
-
_d = true;
|
|
238
|
-
_e = err;
|
|
239
|
-
} finally {
|
|
240
|
-
try {
|
|
241
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
242
|
-
} finally {
|
|
243
|
-
if (_d) throw _e;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return _arr;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
251
|
-
if (!o) return;
|
|
252
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
253
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
254
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
255
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
256
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function _arrayLikeToArray(arr, len) {
|
|
260
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
261
|
-
|
|
262
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
263
|
-
|
|
264
|
-
return arr2;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function _nonIterableRest() {
|
|
268
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function objectOfMaybeArray(o) {
|
|
272
|
-
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
273
|
-
var picker = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : firstOfMaybeArray;
|
|
274
|
-
|
|
275
|
-
if (keys === null) {
|
|
276
|
-
return Object.fromEntries(Object.entries(o).map(function (_ref) {
|
|
277
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
278
|
-
k = _ref2[0],
|
|
279
|
-
v = _ref2[1];
|
|
280
|
-
|
|
281
|
-
return [k, picker(v)];
|
|
282
|
-
}));
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return Object.fromEntries(keys.map(function (v) {
|
|
286
|
-
return [v, picker(v)];
|
|
287
|
-
}));
|
|
288
|
-
}
|
|
289
|
-
function firstOfMaybeArray(v) {
|
|
290
|
-
if (Array.isArray(v)) {
|
|
291
|
-
return v[0];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return v;
|
|
295
|
-
}
|
|
296
|
-
function lastOfMaybeArray(v) {
|
|
297
|
-
if (Array.isArray(v)) {
|
|
298
|
-
return v[v.length - 1];
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return v;
|
|
302
|
-
}
|
|
303
|
-
function arrayOfMaybeArray(v) {
|
|
304
|
-
if (Array.isArray(v)) {
|
|
305
|
-
return v;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (v === null || v === undefined) {
|
|
309
|
-
return [];
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return [v];
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function createLazyPromise() {
|
|
316
|
-
var holder = {
|
|
317
|
-
resolve: function resolve(_) {
|
|
318
|
-
throw new Error('pending resolve');
|
|
319
|
-
},
|
|
320
|
-
reject: function reject(_) {
|
|
321
|
-
throw new Error('pending reject');
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
return Object.assign(new Promise(function (resolve, reject) {
|
|
325
|
-
holder.reject = reject;
|
|
326
|
-
holder.resolve = resolve;
|
|
327
|
-
}), {
|
|
328
|
-
resolve: function resolve(v) {
|
|
329
|
-
holder.resolve(v);
|
|
330
|
-
},
|
|
331
|
-
reject: function reject(v) {
|
|
332
|
-
holder.resolve(v);
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function setAsyncInterval(cb, interval) {
|
|
338
|
-
var initial = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : interval;
|
|
339
|
-
var id;
|
|
340
|
-
|
|
341
|
-
var handler = /*#__PURE__*/function () {
|
|
342
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
343
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
344
|
-
while (1) {
|
|
345
|
-
switch (_context.prev = _context.next) {
|
|
346
|
-
case 0:
|
|
347
|
-
_context.next = 2;
|
|
348
|
-
return cb();
|
|
349
|
-
|
|
350
|
-
case 2:
|
|
351
|
-
id = setTimeout(handler, interval);
|
|
352
|
-
|
|
353
|
-
case 3:
|
|
354
|
-
case "end":
|
|
355
|
-
return _context.stop();
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}, _callee);
|
|
359
|
-
}));
|
|
360
|
-
|
|
361
|
-
return function handler() {
|
|
362
|
-
return _ref.apply(this, arguments);
|
|
363
|
-
};
|
|
364
|
-
}();
|
|
365
|
-
|
|
366
|
-
id = setTimeout(handler, initial);
|
|
367
|
-
return function () {
|
|
368
|
-
return id;
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function clearAsyncInterval(v) {
|
|
372
|
-
clearTimeout(v === null || v === void 0 ? void 0 : v());
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
var sleep = exports('sleep', function sleep(ms) {
|
|
376
|
-
return new Promise(function (resolve) {
|
|
377
|
-
return setTimeout(resolve, ms);
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
function timeout(v, ms) {
|
|
382
|
-
var error = new TimeoutError();
|
|
383
|
-
var timeout;
|
|
384
|
-
return Promise.race([v, new Promise(function (resolve, reject) {
|
|
385
|
-
timeout = setTimeout(function () {
|
|
386
|
-
return reject(error);
|
|
387
|
-
}, ms);
|
|
388
|
-
})]).then(function (v) {
|
|
389
|
-
clearTimeout(timeout);
|
|
390
|
-
return v;
|
|
391
|
-
}, function (e) {
|
|
392
|
-
clearTimeout(timeout);
|
|
393
|
-
throw e;
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
var TimeoutError = exports('TimeoutError', /*#__PURE__*/function (_Error) {
|
|
397
|
-
_inherits(TimeoutError, _Error);
|
|
398
|
-
|
|
399
|
-
var _super = _createSuper(TimeoutError);
|
|
400
|
-
|
|
401
|
-
function TimeoutError() {
|
|
402
|
-
_classCallCheck(this, TimeoutError);
|
|
403
|
-
|
|
404
|
-
return _super.call(this, 'TimeoutError');
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return TimeoutError;
|
|
408
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error)));
|
|
409
|
-
|
|
410
|
-
function isPromise(v) {
|
|
411
|
-
return v && (v instanceof Promise || v.then && v["catch"]);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
function promiseOfCallback(fun) {
|
|
415
|
-
return new Promise(function (resolve, reject) {
|
|
416
|
-
try {
|
|
417
|
-
fun(function (e, v) {
|
|
418
|
-
if (e) {
|
|
419
|
-
reject(e);
|
|
420
|
-
} else {
|
|
421
|
-
resolve(v);
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
} catch (e) {
|
|
425
|
-
reject(e);
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function assert(condition, msg) {
|
|
431
|
-
// if (!condition) {
|
|
432
|
-
// throw new AssertionError(msg);
|
|
433
|
-
// }
|
|
434
|
-
console.assert(!condition, msg);
|
|
435
|
-
}
|
|
436
|
-
function assertIsDefined(val) {
|
|
437
|
-
// if (val === undefined || val === null) {
|
|
438
|
-
// throw new AssertionError(`Expected 'val' to be defined, but received ${val}`);
|
|
439
|
-
// }
|
|
440
|
-
console.assert(val === undefined || val === null, 'Expected defined');
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function isDefined(v) {
|
|
444
|
-
return v !== null && v !== undefined;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
function isEmptyObject(o) {
|
|
448
|
-
if (o === null || o === undefined) {
|
|
449
|
-
return true;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return o.constructor === Object && Object.keys(o).length === 0;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
function isClass(func) {
|
|
456
|
-
return typeof func === 'function' && /^class\s/.test(Function.prototype.toString.call(func));
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// https://github.com/sindresorhus/camelcase/blob/master/index.js
|
|
460
|
-
function preserveCamelCase(string) {
|
|
461
|
-
var isLastCharLower = false;
|
|
462
|
-
var isLastCharUpper = false;
|
|
463
|
-
var isLastLastCharUpper = false;
|
|
464
|
-
|
|
465
|
-
for (var i = 0; i < string.length; i++) {
|
|
466
|
-
var character = string[i];
|
|
467
|
-
|
|
468
|
-
if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
|
|
469
|
-
string = string.slice(0, i) + '-' + string.slice(i);
|
|
470
|
-
isLastCharLower = false;
|
|
471
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
472
|
-
isLastCharUpper = true;
|
|
473
|
-
i++;
|
|
474
|
-
} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) {
|
|
475
|
-
string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
|
|
476
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
477
|
-
isLastCharUpper = false;
|
|
478
|
-
isLastCharLower = true;
|
|
479
|
-
} else {
|
|
480
|
-
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
|
|
481
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
482
|
-
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
return string;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function pascalCase(input) {
|
|
490
|
-
return camelCase(input, {
|
|
491
|
-
pascalCase: true
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
function camelCase(input) {
|
|
495
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
496
|
-
pascalCase: false
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
if (!(typeof input === 'string' || Array.isArray(input))) {
|
|
500
|
-
throw new TypeError('Expected the input to be `string | string[]`');
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
var postProcess = function postProcess(x) {
|
|
504
|
-
return options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x;
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
if (Array.isArray(input)) {
|
|
508
|
-
input = input.map(function (x) {
|
|
509
|
-
return x.trim();
|
|
510
|
-
}).filter(function (x) {
|
|
511
|
-
return x.length;
|
|
512
|
-
}).join('-');
|
|
513
|
-
} else {
|
|
514
|
-
input = input.trim();
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
if (input.length === 0) {
|
|
518
|
-
return '';
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (input.length === 1) {
|
|
522
|
-
return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
var hasUpperCase = input !== input.toLowerCase();
|
|
526
|
-
|
|
527
|
-
if (hasUpperCase) {
|
|
528
|
-
input = preserveCamelCase(input);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
input = input.replace(/^[_.\- ]+/, '').toLowerCase().replace(/[_.\- ]+(\w|$)/g, function (_, p1) {
|
|
532
|
-
return p1.toUpperCase();
|
|
533
|
-
}).replace(/\d+(\w|$)/g, function (m) {
|
|
534
|
-
return m.toUpperCase();
|
|
535
|
-
});
|
|
536
|
-
return postProcess(input);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* 替换类似于 JS 的模板字符串
|
|
541
|
-
*
|
|
542
|
-
* @example
|
|
543
|
-
* templateString('My name is ${name}',{name:'wener'})
|
|
544
|
-
*/
|
|
545
|
-
|
|
546
|
-
function templateString(template, variables) {
|
|
547
|
-
return template.replace(/\${(.*?)}/g, function (_, g) {
|
|
548
|
-
// variables[g.trim()]
|
|
549
|
-
// 支持路径 - 例如 a.b[0]
|
|
550
|
-
return get(variables, g.trim());
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/// see https://github.com/jfromaniello/url-join
|
|
555
|
-
function urljoin() {
|
|
556
|
-
var resultArray = [];
|
|
557
|
-
|
|
558
|
-
for (var _len = arguments.length, strArray = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
559
|
-
strArray[_key] = arguments[_key];
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
if (strArray.length === 0) {
|
|
563
|
-
return '';
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
if (typeof strArray[0] !== 'string') {
|
|
567
|
-
throw new TypeError('Url must be a string. Received ' + strArray[0]);
|
|
568
|
-
} // If the first part is a plain protocol, we combine it with the next part.
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
|
|
572
|
-
var first = strArray.shift();
|
|
573
|
-
strArray[0] = first + strArray[0];
|
|
574
|
-
} // There must be two or three slashes in the file protocol, two slashes in anything else.
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
if (strArray[0].match(/^file:\/\/\//)) {
|
|
578
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
|
|
579
|
-
} else {
|
|
580
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
for (var i = 0; i < strArray.length; i++) {
|
|
584
|
-
var component = strArray[i];
|
|
585
|
-
|
|
586
|
-
if (typeof component !== 'string') {
|
|
587
|
-
throw new TypeError('Url must be a string. Received ' + component);
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
if (component === '') {
|
|
591
|
-
continue;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
if (i > 0) {
|
|
595
|
-
// Removing the starting slashes for each component but the first.
|
|
596
|
-
component = component.replace(/^[/]+/, '');
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
if (i < strArray.length - 1) {
|
|
600
|
-
// Removing the ending slashes for each component but the last.
|
|
601
|
-
component = component.replace(/[/]+$/, '');
|
|
602
|
-
} else {
|
|
603
|
-
// For the last component we will combine multiple slashes to a single one.
|
|
604
|
-
component = component.replace(/[/]+$/, '/');
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
resultArray.push(component);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
var str = resultArray.join('/'); // Each input component is now separated by a single slash except the possible first plain protocol part.
|
|
611
|
-
// remove trailing slash before parameters or hash
|
|
612
|
-
|
|
613
|
-
str = str.replace(/\/(\?|&|#[^!])/g, '$1'); // replace ? in parameters with &
|
|
614
|
-
|
|
615
|
-
var parts = str.split('?');
|
|
616
|
-
str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
|
|
617
|
-
return str;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/// javascript pseudo random
|
|
621
|
-
function createRandom() {
|
|
622
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
623
|
-
_ref$seed = _ref.seed,
|
|
624
|
-
seed = _ref$seed === void 0 ? 0 : _ref$seed;
|
|
625
|
-
|
|
626
|
-
if (typeof seed === 'string') {
|
|
627
|
-
var s = seed;
|
|
628
|
-
var sum = 0;
|
|
629
|
-
|
|
630
|
-
for (var i = 0; i < s.length; i++) {
|
|
631
|
-
sum += s.charCodeAt(i);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
seed = sum;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
return function () {
|
|
638
|
-
var x = Math.sin(seed++) * 10000;
|
|
639
|
-
return x - Math.floor(x);
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// https://github.com/feross/is-buffer/blob/master/index.js
|
|
644
|
-
function isBuffer(obj) {
|
|
645
|
-
return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
var isDev = exports('isDev', function isDev() {
|
|
649
|
-
var _process, _process$env;
|
|
650
|
-
|
|
651
|
-
return typeof process !== 'undefined' && (((_process = process) === null || _process === void 0 ? void 0 : (_process$env = _process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) || '').startsWith('dev');
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
// https://gist.github.com/rproenca/64781c6a1329b48a455b645d361a9aa3
|
|
655
|
-
var _copy;
|
|
656
|
-
|
|
657
|
-
function initCopy() {
|
|
658
|
-
var textArea;
|
|
659
|
-
|
|
660
|
-
function isIOS() {
|
|
661
|
-
return navigator.userAgent.match(/ipad|iphone/i);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
function createTextArea(text) {
|
|
665
|
-
textArea = document.createElement('textArea');
|
|
666
|
-
textArea.value = text;
|
|
667
|
-
document.body.appendChild(textArea);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
function selectText() {
|
|
671
|
-
var range, selection;
|
|
672
|
-
|
|
673
|
-
if (isIOS()) {
|
|
674
|
-
range = document.createRange();
|
|
675
|
-
range.selectNodeContents(textArea);
|
|
676
|
-
selection = window.getSelection();
|
|
677
|
-
|
|
678
|
-
if (selection === null) {
|
|
679
|
-
console.error("no selection");
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
selection.removeAllRanges();
|
|
684
|
-
selection.addRange(range);
|
|
685
|
-
textArea.setSelectionRange(0, 999999);
|
|
686
|
-
} else {
|
|
687
|
-
textArea.select();
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function copyToClipboard() {
|
|
692
|
-
document.execCommand('copy');
|
|
693
|
-
document.body.removeChild(textArea);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
_copy = function _copy(text) {
|
|
697
|
-
createTextArea(text);
|
|
698
|
-
selectText();
|
|
699
|
-
copyToClipboard();
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
function copy(text) {
|
|
704
|
-
var _window$navigator, _window$navigator$cli;
|
|
705
|
-
|
|
706
|
-
if ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : (_window$navigator$cli = _window$navigator.clipboard) === null || _window$navigator$cli === void 0 ? void 0 : _window$navigator$cli.writeText) {
|
|
707
|
-
window.navigator.clipboard.writeText(text);
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
if (!_copy) {
|
|
712
|
-
initCopy();
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
_copy(text);
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
function download(filename, data) {
|
|
719
|
-
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
720
|
-
_ref$type = _ref.type,
|
|
721
|
-
type = _ref$type === void 0 ? 'application/octet-stream' : _ref$type,
|
|
722
|
-
_ref$raw = _ref.raw,
|
|
723
|
-
raw = _ref$raw === void 0 ? false : _ref$raw;
|
|
724
|
-
|
|
725
|
-
var a = document.createElement('a');
|
|
726
|
-
|
|
727
|
-
var closer = function closer() {
|
|
728
|
-
return null;
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
try {
|
|
732
|
-
a.download = filename; // console.info(`downloading ${name}`, data);
|
|
733
|
-
// url or data url
|
|
734
|
-
|
|
735
|
-
if (typeof data === 'string' && /^(https?:|data:)/.test(data) && !raw) {
|
|
736
|
-
a.href = data;
|
|
737
|
-
} else if (typeof data === 'string') {
|
|
738
|
-
data = new TextEncoder().encode(data);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
if (data instanceof Uint8Array) {
|
|
742
|
-
data = new Blob([data], {
|
|
743
|
-
type: type
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
if (data instanceof File || data instanceof Blob || data instanceof MediaSource) {
|
|
748
|
-
a.href = URL.createObjectURL(data);
|
|
749
|
-
|
|
750
|
-
closer = function closer() {
|
|
751
|
-
return URL.revokeObjectURL(a.href);
|
|
752
|
-
};
|
|
753
|
-
} else {
|
|
754
|
-
console.error("invalid download data", data);
|
|
755
|
-
throw new Error("can not download ".concat(Object.getPrototypeOf(data)));
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
a.click();
|
|
759
|
-
} finally {
|
|
760
|
-
closer();
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
function load(el, resolve, reject, options) {
|
|
765
|
-
el.onload = resolve;
|
|
766
|
-
|
|
767
|
-
el.onerror = function (e) {
|
|
768
|
-
el.remove();
|
|
769
|
-
reject(e);
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
var _ref = options || {},
|
|
773
|
-
_ref$attributes = _ref.attributes,
|
|
774
|
-
attributes = _ref$attributes === void 0 ? {} : _ref$attributes;
|
|
775
|
-
|
|
776
|
-
Object.entries(attributes).forEach(function (_ref2) {
|
|
777
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
778
|
-
k = _ref3[0],
|
|
779
|
-
v = _ref3[1];
|
|
780
|
-
|
|
781
|
-
return el.setAttribute(k, v);
|
|
782
|
-
});
|
|
783
|
-
document.head.appendChild(el);
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
function loadScripts(src, options) {
|
|
787
|
-
// todo quote ?
|
|
788
|
-
if (document.querySelector("script[src=\"".concat(src, "\"]"))) {
|
|
789
|
-
return Promise.resolve();
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
return new Promise(function (resolve, reject) {
|
|
793
|
-
var el = document.createElement('script');
|
|
794
|
-
el.src = src;
|
|
795
|
-
load(el, resolve, reject, options);
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
|
-
function loadStyles(href, options) {
|
|
799
|
-
if (document.querySelector("link[href=\"".concat(href, "\"]"))) {
|
|
800
|
-
return Promise.resolve();
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
return new Promise(function (resolve, reject) {
|
|
804
|
-
var el = document.createElement('link');
|
|
805
|
-
el.rel = 'stylesheet';
|
|
806
|
-
el.href = href;
|
|
807
|
-
load(el, resolve, reject, options);
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
function getFile(dataTransfer) {
|
|
812
|
-
var _dataTransfer$items;
|
|
813
|
-
|
|
814
|
-
var items = (_dataTransfer$items = dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.items) !== null && _dataTransfer$items !== void 0 ? _dataTransfer$items : [];
|
|
815
|
-
|
|
816
|
-
if (items.length >= 2 && items[0].kind === 'string' && items[1].kind === 'file') {
|
|
817
|
-
var _items$1$getAsFile, _dataTransfer$files;
|
|
818
|
-
|
|
819
|
-
var text = dataTransfer.getData('text');
|
|
820
|
-
var file = (_items$1$getAsFile = items[1].getAsFile()) !== null && _items$1$getAsFile !== void 0 ? _items$1$getAsFile : (_dataTransfer$files = dataTransfer.files) === null || _dataTransfer$files === void 0 ? void 0 : _dataTransfer$files.item(0);
|
|
821
|
-
|
|
822
|
-
if (!file) {
|
|
823
|
-
console.error("no file ".concat(text), items[1]);
|
|
824
|
-
return null;
|
|
825
|
-
} // let type = file.type;
|
|
826
|
-
// // fix type
|
|
827
|
-
// type = type;
|
|
828
|
-
// // NOTE paste file can not parse by libs
|
|
829
|
-
// if (type !== file.type) {
|
|
830
|
-
// const blob = file.slice(0, file.size);
|
|
831
|
-
// file = new File([blob], text, {type});
|
|
832
|
-
// }
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
return {
|
|
836
|
-
file: file,
|
|
837
|
-
filename: text
|
|
838
|
-
};
|
|
839
|
-
} else if (items[0].kind === 'file') {
|
|
840
|
-
var _file = items[0].getAsFile();
|
|
841
|
-
|
|
842
|
-
if (!_file) {
|
|
843
|
-
console.error("no file", items[0]);
|
|
844
|
-
return null;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
return {
|
|
848
|
-
file: _file,
|
|
849
|
-
filename: _file.name
|
|
850
|
-
};
|
|
851
|
-
} else {
|
|
852
|
-
console.debug("file item not match", Array.from(items).map(function (v) {
|
|
853
|
-
return {
|
|
854
|
-
type: v.type,
|
|
855
|
-
kind: v.kind
|
|
856
|
-
};
|
|
857
|
-
}));
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
return null;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
var _this = undefined;
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* isomorphic globalThis
|
|
867
|
-
*
|
|
868
|
-
* globalThis supported by ff 65, chrome 71, node 12, babel
|
|
869
|
-
*
|
|
870
|
-
* @see https://caniuse.com/#search=globalThis
|
|
871
|
-
* @see https://v8.dev/features/globalthis
|
|
872
|
-
*/
|
|
873
|
-
var getGlobalThis = exports('getGlobalThis', function getGlobalThis() {
|
|
874
|
-
if (typeof globalThis !== 'undefined') return globalThis;
|
|
875
|
-
if (typeof self !== 'undefined') return self;
|
|
876
|
-
if (typeof window !== 'undefined') return window;
|
|
877
|
-
if (typeof global !== 'undefined') return global; // eslint-disable-next-line
|
|
878
|
-
// @ts-ignore
|
|
879
|
-
|
|
880
|
-
if (typeof _this !== 'undefined') return _this;
|
|
881
|
-
throw new Error('Unable to locate global `this`');
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
|
-
});
|
|
887
|
-
//# sourceMappingURL=wener-utils.system.js.map
|