@wener/utils 1.1.50 → 1.1.53
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/lib/arrays/MaybeArray.js +58 -8
- package/lib/arrays/arrayFromAsync.js +254 -6
- package/lib/asyncs/AsyncInterval.js +145 -9
- package/lib/asyncs/MaybePromise.js +0 -2
- package/lib/asyncs/Promises.js +95 -48
- package/lib/asyncs/createAsyncIterator.js +313 -23
- package/lib/asyncs/createLazyPromise.js +72 -31
- package/lib/asyncs/createLazyPromise.test.js +367 -0
- package/lib/asyncs/firstOfAsyncIterator.js +6 -6
- package/lib/asyncs/generatorOfStream.js +125 -14
- package/lib/asyncs/isIterator.js +1 -3
- package/lib/asyncs/isPromise.js +2 -4
- package/lib/asyncs/isThenable.js +0 -2
- package/lib/asyncs/nextOfAsyncIterator.js +15 -9
- package/lib/asyncs/promiseOfCallback.js +2 -4
- package/lib/asyncs/timeout.js +122 -13
- package/lib/browsers/copy.js +7 -8
- package/lib/browsers/download.js +215 -40
- package/lib/browsers/getFileFromDataTransfer.js +17 -14
- package/lib/browsers/loaders.js +251 -18
- package/lib/crypto/base.js +3 -3
- package/lib/crypto/getNodeCrypto.js +3 -5
- package/lib/crypto/hashing.js +236 -30
- package/lib/crypto/hashing.test.js +323 -0
- package/lib/crypto/md5.bench.js +11 -11
- package/lib/crypto/md5.d.js +0 -2
- package/lib/crypto/md5.js +0 -2
- package/lib/crypto/md5.test.js +7 -0
- package/lib/crypto/pem/pem.js +197 -35
- package/lib/crypto/pem/pem.test.js +104 -0
- package/lib/crypto/randomUUIDv7.js +0 -2
- package/lib/crypto/ulid.js +84 -48
- package/lib/crypto/ulid.test.js +115 -0
- package/lib/emitter/types.js +0 -2
- package/lib/errors/DetailError.js +297 -0
- package/lib/errors/Errors.js +2 -202
- package/lib/errors/Errors.mod.js +206 -0
- package/lib/errors/Errors.test.js +24 -0
- package/lib/fetch/HttpStatus.js +1 -3
- package/lib/fetch/createFetchWith.js +188 -19
- package/lib/fetch/createFetchWithLogging.js +17 -16
- package/lib/fetch/createFetchWithRetry.js +40 -24
- package/lib/fetch/dumpRequest.js +467 -41
- package/lib/fetch/dumpRequest.test.js +384 -0
- package/lib/fetch/dumpResponse.js +271 -16
- package/lib/fetch/dumpResponse.test.js +393 -0
- package/lib/fetch/http.types.js +0 -2
- package/lib/fetch/index.js +5 -7
- package/lib/fetch/isTextContentType.js +5 -0
- package/lib/fetch/resolveRequest.js +7 -0
- package/lib/fetch/types.js +0 -2
- package/lib/i18n/createTranslate.js +40 -20
- package/lib/i18n/createTranslate.test.js +177 -0
- package/lib/index.js +75 -75
- package/lib/io/AbstractEncoding.js +0 -2
- package/lib/io/ArrayBuffer.test-d.js +4 -6
- package/lib/io/ArrayBuffers.base64.test.js +60 -0
- package/lib/io/ArrayBuffers.js +2 -334
- package/lib/io/ArrayBuffers.mod.js +531 -0
- package/lib/io/ArrayBuffers.test.js +77 -0
- package/lib/io/Buffer.js +190 -20
- package/lib/io/Buffer.test.js +22 -0
- package/lib/io/ByteBuffer.js +752 -441
- package/lib/io/ByteBuffer.test.js +184 -0
- package/lib/io/base64.js +17 -19
- package/lib/io/dump.js +16 -16
- package/lib/io/isBuffer.js +2 -3
- package/lib/io/isBuffer.test.js +8 -0
- package/lib/io/isTransferable.js +16 -8
- package/lib/io/isTransferable.test.js +17 -0
- package/lib/io/parseDataUri.js +288 -40
- package/lib/io/parseDataUri.test.js +286 -0
- package/lib/io/types.js +1 -0
- package/lib/langs/AsyncCloser.js +276 -0
- package/lib/langs/Closer.js +100 -0
- package/lib/langs/MaybeFunction.js +38 -5
- package/lib/langs/classOf.js +0 -2
- package/lib/langs/deepEqual.js +82 -22
- package/lib/langs/deepEqual.test.js +11 -0
- package/lib/langs/deepFreeze.js +28 -9
- package/lib/langs/getGlobalStates.js +19 -7
- package/lib/langs/getObjectId.js +4 -6
- package/lib/langs/ifPresent.js +3 -0
- package/lib/langs/isClass.js +0 -2
- package/lib/langs/isDefined.js +0 -2
- package/lib/langs/isEmptyObject.js +1 -3
- package/lib/langs/isFunction.js +0 -2
- package/lib/langs/isNil.js +3 -0
- package/lib/langs/isPlainObject.js +2 -4
- package/lib/langs/langs.test.js +126 -0
- package/lib/langs/memoize.js +11 -7
- package/lib/langs/mixin.js +7 -4
- package/lib/langs/mixin.test.js +135 -0
- package/lib/langs/parseBoolean.js +11 -8
- package/lib/langs/shallowClone.js +5 -3
- package/lib/langs/shallowEqual.js +8 -6
- package/lib/libs/ms.js +28 -26
- package/lib/libs/ms.test.js +301 -0
- package/lib/logger/const.js +15 -0
- package/lib/logger/index.js +1 -0
- package/lib/logger/types.js +1 -0
- package/lib/maths/clamp.js +81 -12
- package/lib/maths/clamp.test.js +186 -0
- package/lib/maths/createRandom.test.js +36 -0
- package/lib/maths/random.js +162 -13
- package/lib/modules/isModule.js +0 -2
- package/lib/modules/parseModuleId.js +14 -15
- package/lib/modules/parseModuleId.test.js +153 -0
- package/lib/objects/computeIfAbsent.js +8 -3
- package/lib/objects/get.js +26 -8
- package/lib/objects/get.test-d.js +23 -25
- package/lib/objects/merge/index.js +1 -3
- package/lib/objects/merge/isMergeableObject.js +5 -3
- package/lib/objects/merge/merge.js +82 -26
- package/lib/objects/merge/merge.test.js +1397 -0
- package/lib/objects/parseObjectPath.js +47 -15
- package/lib/objects/parseObjectPath.test.js +138 -0
- package/lib/objects/set.js +25 -19
- package/lib/objects/set.test.js +522 -0
- package/lib/schema/typebox/index.js +2 -3
- package/lib/schema/typebox/typebox.js +6 -6
- package/lib/scripts/getGenerateContext.js +386 -76
- package/lib/server/crypto/md5.js +0 -2
- package/lib/server/fetch/createFetchWithProxy.js +2 -4
- package/lib/server/fetch/createFetchWithProxyByNodeFetch.js +258 -31
- package/lib/server/fetch/createFetchWithProxyByUndici.js +307 -49
- package/lib/server/getPackageDir.js +2 -3
- package/lib/server/index.js +5 -7
- package/lib/server/jsdom.js +1 -3
- package/lib/server/node-fetch.js +2 -4
- package/lib/server/polyfill/polyfillBrowser.js +163 -9
- package/lib/server/polyfill/polyfillBrowser.test.js +164 -0
- package/lib/server/polyfill/polyfillCrypto.js +157 -9
- package/lib/server/polyfill/polyfillFetch.js +13 -13
- package/lib/server/polyfill/polyfillJsDom.js +264 -58
- package/lib/server/polyfill/polyfillWebSocket.js +11 -11
- package/lib/server/ws.js +1 -3
- package/lib/strings/bytes.test.js +327 -0
- package/lib/strings/camelCase.js +23 -14
- package/lib/strings/formatBytes.js +29 -20
- package/lib/strings/parseBytes.js +54 -0
- package/lib/strings/renderTemplate.js +17 -12
- package/lib/strings/renderTemplate.test.js +104 -0
- package/lib/typedoc.js +2 -4
- package/lib/types.d.js +0 -2
- package/lib/validations/asserts.js +0 -2
- package/lib/validations/isUUID.js +0 -2
- package/lib/validations/isUUID.test.js +87 -0
- package/lib/validations/parseTimestamp.js +12 -7
- package/lib/validations/parseTimestamp.test.js +6 -0
- package/lib/{runtime → web}/getGlobalThis.js +3 -4
- package/lib/web/getRandomValues.js +44 -0
- package/lib/web/randomUUID.js +15 -0
- package/lib/web/requestIdleCallback.js +17 -0
- package/lib/{runtime → web}/structuredClone.js +35 -28
- package/lib/web/structuredClone.test.js +81 -0
- package/package.json +10 -18
- package/src/arrays/MaybeArray.ts +22 -22
- package/src/arrays/arrayFromAsync.ts +3 -3
- package/src/asyncs/AsyncInterval.ts +8 -8
- package/src/asyncs/Promises.ts +51 -51
- package/src/asyncs/createAsyncIterator.ts +34 -34
- package/src/asyncs/createLazyPromise.test.ts +73 -73
- package/src/asyncs/createLazyPromise.ts +68 -73
- package/src/asyncs/firstOfAsyncIterator.ts +5 -5
- package/src/asyncs/generatorOfStream.ts +12 -12
- package/src/asyncs/isIterator.ts +1 -1
- package/src/asyncs/isThenable.ts +2 -2
- package/src/asyncs/nextOfAsyncIterator.ts +20 -20
- package/src/asyncs/promiseOfCallback.ts +13 -13
- package/src/asyncs/timeout.ts +23 -23
- package/src/browsers/copy.ts +48 -48
- package/src/browsers/download.ts +38 -36
- package/src/browsers/getFileFromDataTransfer.ts +35 -35
- package/src/browsers/loaders.ts +49 -49
- package/src/crypto/base.ts +3 -3
- package/src/crypto/getNodeCrypto.ts +3 -3
- package/src/crypto/hashing.test.ts +34 -48
- package/src/crypto/hashing.ts +67 -67
- package/src/crypto/md5.bench.ts +20 -24
- package/src/crypto/md5.test.ts +3 -3
- package/src/crypto/pem/pem.test.ts +26 -42
- package/src/crypto/pem/pem.ts +65 -65
- package/src/crypto/ulid.test.ts +32 -32
- package/src/crypto/ulid.ts +117 -117
- package/src/emitter/types.ts +6 -6
- package/src/errors/DetailError.ts +151 -0
- package/src/errors/Errors.mod.ts +104 -0
- package/src/errors/Errors.test.ts +15 -15
- package/src/errors/Errors.ts +1 -247
- package/src/fetch/HttpStatus.ts +77 -77
- package/src/fetch/createFetchWith.ts +27 -27
- package/src/fetch/createFetchWithLogging.ts +13 -16
- package/src/fetch/createFetchWithRetry.ts +80 -80
- package/src/fetch/dumpRequest.test.ts +176 -0
- package/src/fetch/dumpRequest.ts +149 -52
- package/src/fetch/dumpResponse.test.ts +160 -0
- package/src/fetch/dumpResponse.ts +48 -20
- package/src/fetch/http.types.ts +35 -35
- package/src/fetch/isTextContentType.ts +12 -0
- package/src/fetch/resolveRequest.ts +1 -0
- package/src/fetch/types.ts +2 -2
- package/src/i18n/createTranslate.test.ts +90 -113
- package/src/i18n/createTranslate.ts +55 -55
- package/src/index.ts +26 -27
- package/src/io/AbstractEncoding.ts +12 -12
- package/src/io/ArrayBuffer.test-d.ts +1 -1
- package/src/io/ArrayBuffers.base64.test.ts +52 -52
- package/src/io/ArrayBuffers.mod.ts +670 -0
- package/src/io/ArrayBuffers.test.ts +14 -14
- package/src/io/ArrayBuffers.ts +1 -446
- package/src/io/Buffer.test.ts +17 -17
- package/src/io/Buffer.ts +17 -17
- package/src/io/ByteBuffer.test.ts +37 -37
- package/src/io/ByteBuffer.ts +574 -566
- package/src/io/base64.ts +46 -44
- package/src/io/dump.ts +22 -22
- package/src/io/isBuffer.test.ts +2 -2
- package/src/io/isBuffer.ts +1 -1
- package/src/io/isTransferable.test.ts +4 -4
- package/src/io/isTransferable.ts +30 -30
- package/src/io/parseDataUri.test.ts +22 -27
- package/src/io/parseDataUri.ts +57 -57
- package/src/io/types.ts +13 -0
- package/src/langs/AsyncCloser.ts +45 -0
- package/src/langs/Closer.ts +39 -0
- package/src/langs/MaybeFunction.ts +5 -5
- package/src/langs/classOf.ts +1 -1
- package/src/langs/deepEqual.test.ts +1 -12
- package/src/langs/deepEqual.ts +82 -82
- package/src/langs/deepFreeze.ts +11 -11
- package/src/langs/getGlobalStates.ts +21 -11
- package/src/langs/getObjectId.ts +10 -13
- package/src/langs/ifPresent.ts +3 -0
- package/src/langs/isClass.ts +1 -1
- package/src/langs/isDefined.ts +1 -1
- package/src/langs/isEmptyObject.ts +1 -1
- package/src/langs/isFunction.ts +1 -1
- package/src/langs/isNil.ts +3 -0
- package/src/langs/isPlainObject.ts +4 -4
- package/src/langs/langs.test.ts +18 -18
- package/src/langs/memoize.ts +21 -21
- package/src/langs/mixin.test.ts +22 -26
- package/src/langs/mixin.ts +6 -9
- package/src/langs/parseBoolean.ts +30 -26
- package/src/langs/shallowClone.ts +11 -11
- package/src/langs/shallowEqual.ts +19 -19
- package/src/libs/ms.test.ts +274 -274
- package/src/libs/ms.ts +137 -137
- package/src/logger/const.ts +18 -0
- package/src/logger/index.ts +2 -0
- package/src/logger/types.ts +10 -0
- package/src/maths/clamp.test.ts +18 -18
- package/src/maths/clamp.ts +17 -17
- package/src/maths/createRandom.test.ts +12 -0
- package/src/maths/random.ts +50 -14
- package/src/modules/isModule.ts +4 -4
- package/src/modules/parseModuleId.test.ts +61 -68
- package/src/modules/parseModuleId.ts +29 -43
- package/src/objects/computeIfAbsent.ts +10 -10
- package/src/objects/get.test-d.ts +33 -51
- package/src/objects/get.ts +31 -31
- package/src/objects/merge/isMergeableObject.ts +5 -5
- package/src/objects/merge/merge.test.ts +658 -880
- package/src/objects/merge/merge.ts +84 -84
- package/src/objects/parseObjectPath.test.ts +13 -13
- package/src/objects/parseObjectPath.ts +25 -25
- package/src/objects/set.test.ts +271 -366
- package/src/objects/set.ts +36 -36
- package/src/schema/typebox/typebox.ts +20 -26
- package/src/scripts/getGenerateContext.ts +82 -80
- package/src/server/crypto/md5.ts +1 -1
- package/src/server/fetch/createFetchWithProxyByNodeFetch.ts +30 -33
- package/src/server/fetch/createFetchWithProxyByUndici.ts +64 -70
- package/src/server/getPackageDir.ts +7 -7
- package/src/server/polyfill/polyfillBrowser.test.ts +10 -10
- package/src/server/polyfill/polyfillBrowser.ts +3 -3
- package/src/server/polyfill/polyfillCrypto.ts +7 -7
- package/src/server/polyfill/polyfillFetch.ts +11 -21
- package/src/server/polyfill/polyfillJsDom.ts +60 -72
- package/src/server/polyfill/polyfillWebSocket.ts +15 -15
- package/src/strings/bytes.test.ts +69 -0
- package/src/strings/camelCase.ts +58 -63
- package/src/strings/formatBytes.ts +50 -29
- package/src/strings/parseBytes.ts +66 -0
- package/src/strings/renderTemplate.test.ts +10 -17
- package/src/strings/renderTemplate.ts +19 -22
- package/src/types.d.ts +9 -9
- package/src/validations/asserts.ts +8 -8
- package/src/validations/isUUID.test.ts +9 -9
- package/src/validations/isUUID.ts +1 -1
- package/src/validations/parseTimestamp.test.ts +2 -2
- package/src/validations/parseTimestamp.ts +21 -21
- package/src/{runtime → web}/getGlobalThis.ts +6 -6
- package/src/web/getRandomValues.ts +41 -0
- package/src/web/randomUUID.ts +19 -0
- package/src/web/requestIdleCallback.ts +11 -0
- package/src/{runtime → web}/structuredClone.test.ts +8 -8
- package/src/web/structuredClone.ts +88 -0
- package/tsconfig.json +35 -34
- package/lib/arrays/MaybeArray.js.map +0 -1
- package/lib/arrays/arrayFromAsync.js.map +0 -1
- package/lib/asyncs/AsyncInterval.js.map +0 -1
- package/lib/asyncs/MaybePromise.js.map +0 -1
- package/lib/asyncs/Promises.js.map +0 -1
- package/lib/asyncs/createAsyncIterator.js.map +0 -1
- package/lib/asyncs/createLazyPromise.js.map +0 -1
- package/lib/asyncs/firstOfAsyncIterator.js.map +0 -1
- package/lib/asyncs/generatorOfStream.js.map +0 -1
- package/lib/asyncs/isIterator.js.map +0 -1
- package/lib/asyncs/isPromise.js.map +0 -1
- package/lib/asyncs/isThenable.js.map +0 -1
- package/lib/asyncs/nextOfAsyncIterator.js.map +0 -1
- package/lib/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/asyncs/timeout.js.map +0 -1
- package/lib/browsers/copy.js.map +0 -1
- package/lib/browsers/download.js.map +0 -1
- package/lib/browsers/getFileFromDataTransfer.js.map +0 -1
- package/lib/browsers/loaders.js.map +0 -1
- package/lib/cn/division/DivisionCode.js +0 -209
- package/lib/cn/division/DivisionCode.js.map +0 -1
- package/lib/cn/division/binarySearch.js +0 -27
- package/lib/cn/division/binarySearch.js.map +0 -1
- package/lib/cn/formatChineseAmount.js +0 -77
- package/lib/cn/formatChineseAmount.js.map +0 -1
- package/lib/cn/id/Mod11.js +0 -43
- package/lib/cn/id/Mod11.js.map +0 -1
- package/lib/cn/id/ResidentIdNumber.js +0 -98
- package/lib/cn/id/ResidentIdNumber.js.map +0 -1
- package/lib/cn/id/types.js +0 -8
- package/lib/cn/id/types.js.map +0 -1
- package/lib/cn/index.js +0 -14
- package/lib/cn/index.js.map +0 -1
- package/lib/cn/parseChineseNumber.js +0 -94
- package/lib/cn/parseChineseNumber.js.map +0 -1
- package/lib/cn/pinyin/cartesianProduct.js +0 -22
- package/lib/cn/pinyin/cartesianProduct.js.map +0 -1
- package/lib/cn/pinyin/data.json +0 -413
- package/lib/cn/pinyin/loader.js +0 -15
- package/lib/cn/pinyin/loader.js.map +0 -1
- package/lib/cn/pinyin/preload.js +0 -4
- package/lib/cn/pinyin/preload.js.map +0 -1
- package/lib/cn/pinyin/toPinyinPure.js +0 -32
- package/lib/cn/pinyin/toPinyinPure.js.map +0 -1
- package/lib/cn/pinyin/transform.js +0 -14
- package/lib/cn/pinyin/transform.js.map +0 -1
- package/lib/cn/types.js +0 -3
- package/lib/cn/types.js.map +0 -1
- package/lib/cn/uscc/Mod31.js +0 -49
- package/lib/cn/uscc/Mod31.js.map +0 -1
- package/lib/cn/uscc/USCC.js +0 -94
- package/lib/cn/uscc/USCC.js.map +0 -1
- package/lib/cn/uscc/isUSCC.js +0 -8
- package/lib/cn/uscc/isUSCC.js.map +0 -1
- package/lib/crypto/base.js.map +0 -1
- package/lib/crypto/getNodeCrypto.js.map +0 -1
- package/lib/crypto/getRandomValues.js +0 -36
- package/lib/crypto/getRandomValues.js.map +0 -1
- package/lib/crypto/hashing.js.map +0 -1
- package/lib/crypto/md5.bench.js.map +0 -1
- package/lib/crypto/md5.d.js.map +0 -1
- package/lib/crypto/md5.js.map +0 -1
- package/lib/crypto/pem/pem.js.map +0 -1
- package/lib/crypto/randomUUID.js +0 -16
- package/lib/crypto/randomUUID.js.map +0 -1
- package/lib/crypto/randomUUIDv7.js.map +0 -1
- package/lib/crypto/ulid.js.map +0 -1
- package/lib/emitter/types.js.map +0 -1
- package/lib/errors/Errors.js.map +0 -1
- package/lib/fetch/HttpStatus.js.map +0 -1
- package/lib/fetch/createFetchWith.js.map +0 -1
- package/lib/fetch/createFetchWithLogging.js.map +0 -1
- package/lib/fetch/createFetchWithRetry.js.map +0 -1
- package/lib/fetch/dumpRequest.js.map +0 -1
- package/lib/fetch/dumpResponse.js.map +0 -1
- package/lib/fetch/http.types.js.map +0 -1
- package/lib/fetch/index.js.map +0 -1
- package/lib/fetch/types.js.map +0 -1
- package/lib/i18n/createTranslate.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/io/AbstractEncoding.js.map +0 -1
- package/lib/io/ArrayBuffer.test-d.js.map +0 -1
- package/lib/io/ArrayBuffers.js.map +0 -1
- package/lib/io/Buffer.js.map +0 -1
- package/lib/io/ByteBuffer.js.map +0 -1
- package/lib/io/base64.js.map +0 -1
- package/lib/io/dump.js.map +0 -1
- package/lib/io/isBuffer.js.map +0 -1
- package/lib/io/isTransferable.js.map +0 -1
- package/lib/io/parseDataUri.js.map +0 -1
- package/lib/langs/MaybeFunction.js.map +0 -1
- package/lib/langs/classOf.js.map +0 -1
- package/lib/langs/deepEqual.js.map +0 -1
- package/lib/langs/deepFreeze.js.map +0 -1
- package/lib/langs/getGlobalStates.js.map +0 -1
- package/lib/langs/getObjectId.js.map +0 -1
- package/lib/langs/isClass.js.map +0 -1
- package/lib/langs/isDefined.js.map +0 -1
- package/lib/langs/isEmptyObject.js.map +0 -1
- package/lib/langs/isFunction.js.map +0 -1
- package/lib/langs/isNullish.js +0 -5
- package/lib/langs/isNullish.js.map +0 -1
- package/lib/langs/isPlainObject.js.map +0 -1
- package/lib/langs/memoize.js.map +0 -1
- package/lib/langs/mixin.js.map +0 -1
- package/lib/langs/parseBoolean.js.map +0 -1
- package/lib/langs/shallowClone.js.map +0 -1
- package/lib/langs/shallowEqual.js.map +0 -1
- package/lib/libs/ms.js.map +0 -1
- package/lib/logging/Logger.js +0 -5
- package/lib/logging/Logger.js.map +0 -1
- package/lib/logging/createChildLogger.js +0 -16
- package/lib/logging/createChildLogger.js.map +0 -1
- package/lib/logging/createLogger.js +0 -63
- package/lib/logging/createLogger.js.map +0 -1
- package/lib/logging/createNoopLogger.js +0 -13
- package/lib/logging/createNoopLogger.js.map +0 -1
- package/lib/logging/slog.js +0 -143
- package/lib/logging/slog.js.map +0 -1
- package/lib/maths/clamp.js.map +0 -1
- package/lib/maths/random.js.map +0 -1
- package/lib/mitt/index.js +0 -77
- package/lib/mitt/index.js.map +0 -1
- package/lib/modules/isModule.js.map +0 -1
- package/lib/modules/parseModuleId.js.map +0 -1
- package/lib/objects/computeIfAbsent.js.map +0 -1
- package/lib/objects/get.js.map +0 -1
- package/lib/objects/get.test-d.js.map +0 -1
- package/lib/objects/merge/index.js.map +0 -1
- package/lib/objects/merge/isMergeableObject.js.map +0 -1
- package/lib/objects/merge/merge.js.map +0 -1
- package/lib/objects/parseObjectPath.js.map +0 -1
- package/lib/objects/set.js.map +0 -1
- package/lib/runtime/AsyncCloser.js +0 -40
- package/lib/runtime/AsyncCloser.js.map +0 -1
- package/lib/runtime/Closer.js +0 -34
- package/lib/runtime/Closer.js.map +0 -1
- package/lib/runtime/getGlobalThis.js.map +0 -1
- package/lib/runtime/structuredClone.js.map +0 -1
- package/lib/schema/typebox/index.js.map +0 -1
- package/lib/schema/typebox/typebox.js.map +0 -1
- package/lib/scripts/getGenerateContext.js.map +0 -1
- package/lib/server/crypto/md5.js.map +0 -1
- package/lib/server/fetch/createFetchWithProxy.js.map +0 -1
- package/lib/server/fetch/createFetchWithProxyByNodeFetch.js.map +0 -1
- package/lib/server/fetch/createFetchWithProxyByUndici.js.map +0 -1
- package/lib/server/getPackageDir.js.map +0 -1
- package/lib/server/index.js.map +0 -1
- package/lib/server/jsdom.js.map +0 -1
- package/lib/server/node-fetch.js.map +0 -1
- package/lib/server/polyfill/polyfillBrowser.js.map +0 -1
- package/lib/server/polyfill/polyfillCrypto.js.map +0 -1
- package/lib/server/polyfill/polyfillFetch.js.map +0 -1
- package/lib/server/polyfill/polyfillJsDom.js.map +0 -1
- package/lib/server/polyfill/polyfillWebSocket.js.map +0 -1
- package/lib/server/ws.js.map +0 -1
- package/lib/strings/camelCase.js.map +0 -1
- package/lib/strings/formatBytes.js.map +0 -1
- package/lib/strings/renderTemplate.js.map +0 -1
- package/lib/typedoc.js.map +0 -1
- package/lib/types.d.js.map +0 -1
- package/lib/validations/asserts.js.map +0 -1
- package/lib/validations/isUUID.js.map +0 -1
- package/lib/validations/parseTimestamp.js.map +0 -1
- package/src/cn/README.md +0 -3
- package/src/cn/division/DivisionCode.ts +0 -155
- package/src/cn/division/binarySearch.test.ts +0 -64
- package/src/cn/division/binarySearch.ts +0 -25
- package/src/cn/division/division.test.ts +0 -6
- package/src/cn/formatChineseAmount.ts +0 -61
- package/src/cn/id/Mod11.ts +0 -26
- package/src/cn/id/ResidentIdNumber.ts +0 -126
- package/src/cn/id/id.test.ts +0 -20
- package/src/cn/id/types.ts +0 -26
- package/src/cn/index.ts +0 -17
- package/src/cn/parseChineseNumber.test.ts +0 -159
- package/src/cn/parseChineseNumber.ts +0 -97
- package/src/cn/pinyin/cartesianProduct.test.ts +0 -64
- package/src/cn/pinyin/cartesianProduct.ts +0 -24
- package/src/cn/pinyin/data.json +0 -413
- package/src/cn/pinyin/loader.ts +0 -12
- package/src/cn/pinyin/preload.ts +0 -3
- package/src/cn/pinyin/toPinyin.test.ts +0 -12
- package/src/cn/pinyin/toPinyinPure.ts +0 -43
- package/src/cn/pinyin/transform.ts +0 -12
- package/src/cn/scripts/gen.test.ts +0 -131
- package/src/cn/types.ts +0 -11
- package/src/cn/uscc/Mod31.ts +0 -38
- package/src/cn/uscc/USCC.ts +0 -94
- package/src/cn/uscc/isUSCC.ts +0 -8
- package/src/cn/uscc/uscc.test.ts +0 -16
- package/src/crypto/getRandomValues.ts +0 -41
- package/src/crypto/randomUUID.ts +0 -19
- package/src/langs/isNullish.ts +0 -3
- package/src/logging/Logger.ts +0 -25
- package/src/logging/createChildLogger.ts +0 -16
- package/src/logging/createLogger.ts +0 -50
- package/src/logging/createNoopLogger.ts +0 -13
- package/src/logging/logger.test.ts +0 -36
- package/src/logging/slog.test.ts +0 -8
- package/src/logging/slog.ts +0 -221
- package/src/mitt/README.md +0 -1
- package/src/mitt/index.ts +0 -114
- package/src/runtime/AsyncCloser.ts +0 -45
- package/src/runtime/Closer.ts +0 -39
- package/src/runtime/structuredClone.ts +0 -88
package/lib/asyncs/timeout.js
CHANGED
|
@@ -1,7 +1,112 @@
|
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
|
+
}
|
|
7
|
+
function _call_super(_this, derived, args) {
|
|
8
|
+
derived = _get_prototype_of(derived);
|
|
9
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
10
|
+
}
|
|
11
|
+
function _class_call_check(instance, Constructor) {
|
|
12
|
+
if (!(instance instanceof Constructor)) {
|
|
13
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _construct(Parent, args, Class) {
|
|
17
|
+
if (_is_native_reflect_construct()) {
|
|
18
|
+
_construct = Reflect.construct;
|
|
19
|
+
} else {
|
|
20
|
+
_construct = function construct(Parent, args, Class) {
|
|
21
|
+
var a = [
|
|
22
|
+
null
|
|
23
|
+
];
|
|
24
|
+
a.push.apply(a, args);
|
|
25
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
26
|
+
var instance = new Constructor();
|
|
27
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
28
|
+
return instance;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return _construct.apply(null, arguments);
|
|
32
|
+
}
|
|
33
|
+
function _get_prototype_of(o) {
|
|
34
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
35
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
36
|
+
};
|
|
37
|
+
return _get_prototype_of(o);
|
|
38
|
+
}
|
|
39
|
+
function _inherits(subClass, superClass) {
|
|
40
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
41
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
42
|
+
}
|
|
43
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
44
|
+
constructor: {
|
|
45
|
+
value: subClass,
|
|
46
|
+
writable: true,
|
|
47
|
+
configurable: true
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
51
|
+
}
|
|
52
|
+
function _is_native_function(fn) {
|
|
53
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
54
|
+
}
|
|
55
|
+
function _possible_constructor_return(self, call) {
|
|
56
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
57
|
+
return call;
|
|
58
|
+
}
|
|
59
|
+
return _assert_this_initialized(self);
|
|
60
|
+
}
|
|
61
|
+
function _set_prototype_of(o, p) {
|
|
62
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
63
|
+
o.__proto__ = p;
|
|
64
|
+
return o;
|
|
65
|
+
};
|
|
66
|
+
return _set_prototype_of(o, p);
|
|
67
|
+
}
|
|
68
|
+
function _type_of(obj) {
|
|
69
|
+
"@swc/helpers - typeof";
|
|
70
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
71
|
+
}
|
|
72
|
+
function _wrap_native_super(Class) {
|
|
73
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
74
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
75
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
76
|
+
if (typeof Class !== "function") {
|
|
77
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
78
|
+
}
|
|
79
|
+
if (typeof _cache !== "undefined") {
|
|
80
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
81
|
+
_cache.set(Class, Wrapper);
|
|
82
|
+
}
|
|
83
|
+
function Wrapper() {
|
|
84
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
85
|
+
}
|
|
86
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
87
|
+
constructor: {
|
|
88
|
+
value: Wrapper,
|
|
89
|
+
enumerable: false,
|
|
90
|
+
writable: true,
|
|
91
|
+
configurable: true
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return _set_prototype_of(Wrapper, Class);
|
|
95
|
+
};
|
|
96
|
+
return _wrap_native_super(Class);
|
|
97
|
+
}
|
|
98
|
+
function _is_native_reflect_construct() {
|
|
99
|
+
try {
|
|
100
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
101
|
+
} catch (_) {}
|
|
102
|
+
return (_is_native_reflect_construct = function() {
|
|
103
|
+
return !!result;
|
|
104
|
+
})();
|
|
105
|
+
}
|
|
1
106
|
export function timeout(pending, ms) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
107
|
+
var error = new TimeoutError();
|
|
108
|
+
var timeout;
|
|
109
|
+
var ac;
|
|
5
110
|
if (typeof pending === 'function') {
|
|
6
111
|
ac = new AbortController();
|
|
7
112
|
pending = pending({
|
|
@@ -10,20 +115,24 @@ export function timeout(pending, ms) {
|
|
|
10
115
|
}
|
|
11
116
|
return Promise.race([
|
|
12
117
|
pending,
|
|
13
|
-
new Promise((_resolve, reject)
|
|
14
|
-
timeout = setTimeout(()
|
|
15
|
-
ac
|
|
118
|
+
new Promise(function(_resolve, reject) {
|
|
119
|
+
timeout = setTimeout(function() {
|
|
120
|
+
ac === null || ac === void 0 ? void 0 : ac.abort(error);
|
|
16
121
|
reject(error);
|
|
17
122
|
}, ms);
|
|
18
123
|
})
|
|
19
|
-
]).finally(()
|
|
124
|
+
]).finally(function() {
|
|
20
125
|
clearTimeout(timeout);
|
|
21
126
|
});
|
|
22
127
|
}
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
128
|
+
export var TimeoutError = /*#__PURE__*/ function(Error1) {
|
|
129
|
+
"use strict";
|
|
130
|
+
_inherits(TimeoutError, Error1);
|
|
131
|
+
function TimeoutError() {
|
|
132
|
+
_class_call_check(this, TimeoutError);
|
|
133
|
+
return _call_super(this, TimeoutError, [
|
|
134
|
+
'TimeoutError'
|
|
135
|
+
]);
|
|
26
136
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=timeout.js.map
|
|
137
|
+
return TimeoutError;
|
|
138
|
+
}(_wrap_native_super(Error));
|
package/lib/browsers/copy.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var _copy;
|
|
2
2
|
// https://gist.github.com/rproenca/64781c6a1329b48a455b645d361a9aa3
|
|
3
3
|
function initCopy() {
|
|
4
|
-
|
|
4
|
+
var textArea;
|
|
5
5
|
function isIOS() {
|
|
6
6
|
return navigator.userAgent.match(/ipad|iphone/i);
|
|
7
7
|
}
|
|
@@ -11,13 +11,13 @@ function initCopy() {
|
|
|
11
11
|
document.body.appendChild(textArea);
|
|
12
12
|
}
|
|
13
13
|
function selectText() {
|
|
14
|
-
|
|
14
|
+
var range, selection;
|
|
15
15
|
if (isIOS()) {
|
|
16
16
|
range = document.createRange();
|
|
17
17
|
range.selectNodeContents(textArea);
|
|
18
18
|
selection = window.getSelection();
|
|
19
19
|
if (selection === null) {
|
|
20
|
-
console.error(
|
|
20
|
+
console.error("no selection");
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
selection.removeAllRanges();
|
|
@@ -31,7 +31,7 @@ function initCopy() {
|
|
|
31
31
|
document.execCommand('copy');
|
|
32
32
|
document.body.removeChild(textArea);
|
|
33
33
|
}
|
|
34
|
-
_copy = (text)
|
|
34
|
+
_copy = function(text) {
|
|
35
35
|
createTextArea(text);
|
|
36
36
|
selectText();
|
|
37
37
|
copyToClipboard();
|
|
@@ -41,7 +41,8 @@ function initCopy() {
|
|
|
41
41
|
* Write text to clipboard
|
|
42
42
|
* @param content content
|
|
43
43
|
*/ export function copy(content) {
|
|
44
|
-
|
|
44
|
+
var _window_navigator_clipboard, _window_navigator;
|
|
45
|
+
if ((_window_navigator = window.navigator) === null || _window_navigator === void 0 ? void 0 : (_window_navigator_clipboard = _window_navigator.clipboard) === null || _window_navigator_clipboard === void 0 ? void 0 : _window_navigator_clipboard.writeText) {
|
|
45
46
|
return window.navigator.clipboard.writeText(content);
|
|
46
47
|
}
|
|
47
48
|
if (!_copy) {
|
|
@@ -49,5 +50,3 @@ function initCopy() {
|
|
|
49
50
|
}
|
|
50
51
|
return _copy(content);
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=copy.js.map
|
package/lib/browsers/download.js
CHANGED
|
@@ -1,50 +1,225 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _instanceof(left, right) {
|
|
31
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
32
|
+
return !!right[Symbol.hasInstance](left);
|
|
33
|
+
} else {
|
|
34
|
+
return left instanceof right;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function _ts_generator(thisArg, body) {
|
|
38
|
+
var f, y, t, _ = {
|
|
39
|
+
label: 0,
|
|
40
|
+
sent: function() {
|
|
41
|
+
if (t[0] & 1) throw t[1];
|
|
42
|
+
return t[1];
|
|
43
|
+
},
|
|
44
|
+
trys: [],
|
|
45
|
+
ops: []
|
|
46
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
47
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
48
|
+
return this;
|
|
49
|
+
}), g;
|
|
50
|
+
function verb(n) {
|
|
51
|
+
return function(v) {
|
|
52
|
+
return step([
|
|
53
|
+
n,
|
|
54
|
+
v
|
|
55
|
+
]);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function step(op) {
|
|
59
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
60
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
61
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
62
|
+
if (y = 0, t) op = [
|
|
63
|
+
op[0] & 2,
|
|
64
|
+
t.value
|
|
65
|
+
];
|
|
66
|
+
switch(op[0]){
|
|
67
|
+
case 0:
|
|
68
|
+
case 1:
|
|
69
|
+
t = op;
|
|
70
|
+
break;
|
|
71
|
+
case 4:
|
|
72
|
+
_.label++;
|
|
73
|
+
return {
|
|
74
|
+
value: op[1],
|
|
75
|
+
done: false
|
|
76
|
+
};
|
|
77
|
+
case 5:
|
|
78
|
+
_.label++;
|
|
79
|
+
y = op[1];
|
|
80
|
+
op = [
|
|
81
|
+
0
|
|
82
|
+
];
|
|
83
|
+
continue;
|
|
84
|
+
case 7:
|
|
85
|
+
op = _.ops.pop();
|
|
86
|
+
_.trys.pop();
|
|
87
|
+
continue;
|
|
88
|
+
default:
|
|
89
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
90
|
+
_ = 0;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
94
|
+
_.label = op[1];
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
98
|
+
_.label = t[1];
|
|
99
|
+
t = op;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
if (t && _.label < t[2]) {
|
|
103
|
+
_.label = t[2];
|
|
104
|
+
_.ops.push(op);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (t[2]) _.ops.pop();
|
|
108
|
+
_.trys.pop();
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
op = body.call(thisArg, _);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
op = [
|
|
114
|
+
6,
|
|
115
|
+
e
|
|
116
|
+
];
|
|
117
|
+
y = 0;
|
|
118
|
+
} finally{
|
|
119
|
+
f = t = 0;
|
|
120
|
+
}
|
|
121
|
+
if (op[0] & 5) throw op[1];
|
|
122
|
+
return {
|
|
123
|
+
value: op[0] ? op[1] : void 0,
|
|
124
|
+
done: true
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
1
128
|
/**
|
|
2
129
|
* Trigger browser download
|
|
3
130
|
* @param filename download as filename
|
|
4
131
|
* @param data data or url to download
|
|
5
132
|
* @param type content type
|
|
6
133
|
* @param raw if true, data is treated as raw data, not url
|
|
7
|
-
*/ export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
134
|
+
*/ export function download(_0, _1) {
|
|
135
|
+
return _async_to_generator(function(filename, data) {
|
|
136
|
+
var _ref, _ref_type, type, _ref_raw, raw, a, closer;
|
|
137
|
+
var _arguments = arguments;
|
|
138
|
+
return _ts_generator(this, function(_state) {
|
|
139
|
+
switch(_state.label){
|
|
140
|
+
case 0:
|
|
141
|
+
_ref = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {}, _ref_type = _ref.type, type = _ref_type === void 0 ? 'application/octet-stream' : _ref_type, _ref_raw = _ref.raw, raw = _ref_raw === void 0 ? false : _ref_raw;
|
|
142
|
+
a = document.createElement('a');
|
|
143
|
+
closer = function() {
|
|
144
|
+
return null;
|
|
145
|
+
};
|
|
146
|
+
_state.label = 1;
|
|
147
|
+
case 1:
|
|
148
|
+
_state.trys.push([
|
|
149
|
+
1,
|
|
150
|
+
,
|
|
151
|
+
6,
|
|
152
|
+
7
|
|
153
|
+
]);
|
|
154
|
+
a.download = filename;
|
|
155
|
+
if (!(typeof data === 'string' && /^(https?:|data:)/.test(data) && !raw)) return [
|
|
156
|
+
3,
|
|
157
|
+
4
|
|
158
|
+
];
|
|
159
|
+
a.href = data;
|
|
160
|
+
if (!/^https?:/.test(data)) return [
|
|
161
|
+
3,
|
|
162
|
+
3
|
|
163
|
+
];
|
|
164
|
+
if (!(new URL(data).origin !== location.origin)) return [
|
|
165
|
+
3,
|
|
166
|
+
3
|
|
167
|
+
];
|
|
18
168
|
// 非同源
|
|
19
169
|
a.href = '';
|
|
20
|
-
|
|
21
|
-
|
|
170
|
+
return [
|
|
171
|
+
4,
|
|
172
|
+
fetch(data).then(function(res) {
|
|
173
|
+
return res.blob();
|
|
174
|
+
})
|
|
175
|
+
];
|
|
176
|
+
case 2:
|
|
177
|
+
data = _state.sent();
|
|
178
|
+
_state.label = 3;
|
|
179
|
+
case 3:
|
|
180
|
+
return [
|
|
181
|
+
3,
|
|
182
|
+
5
|
|
183
|
+
];
|
|
184
|
+
case 4:
|
|
185
|
+
if (typeof data === 'string') {
|
|
186
|
+
data = new TextEncoder().encode(data);
|
|
187
|
+
}
|
|
188
|
+
_state.label = 5;
|
|
189
|
+
case 5:
|
|
190
|
+
if (_instanceof(data, Uint8Array)) {
|
|
191
|
+
data = new Blob([
|
|
192
|
+
data
|
|
193
|
+
], {
|
|
194
|
+
type: type
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
{
|
|
198
|
+
if (_instanceof(data, File) || _instanceof(data, Blob) || _instanceof(data, MediaSource)) {
|
|
199
|
+
a.href = URL.createObjectURL(data);
|
|
200
|
+
closer = function() {
|
|
201
|
+
URL.revokeObjectURL(a.href);
|
|
202
|
+
};
|
|
203
|
+
} else {
|
|
204
|
+
console.error("invalid download data", data);
|
|
205
|
+
throw new Error("can not download ".concat(data && Object.getPrototypeOf(data)));
|
|
206
|
+
}
|
|
207
|
+
a.click();
|
|
208
|
+
}
|
|
209
|
+
return [
|
|
210
|
+
3,
|
|
211
|
+
7
|
|
212
|
+
];
|
|
213
|
+
case 6:
|
|
214
|
+
closer();
|
|
215
|
+
return [
|
|
216
|
+
7
|
|
217
|
+
];
|
|
218
|
+
case 7:
|
|
219
|
+
return [
|
|
220
|
+
2
|
|
221
|
+
];
|
|
22
222
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
if (data instanceof Uint8Array) {
|
|
27
|
-
data = new Blob([
|
|
28
|
-
data
|
|
29
|
-
], {
|
|
30
|
-
type
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
{
|
|
34
|
-
if (data instanceof File || data instanceof Blob || data instanceof MediaSource) {
|
|
35
|
-
a.href = URL.createObjectURL(data);
|
|
36
|
-
closer = ()=>{
|
|
37
|
-
URL.revokeObjectURL(a.href);
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
console.error(`invalid download data`, data);
|
|
41
|
-
throw new Error(`can not download ${data && Object.getPrototypeOf(data)}`);
|
|
42
|
-
}
|
|
43
|
-
a.click();
|
|
44
|
-
}
|
|
45
|
-
} finally{
|
|
46
|
-
closer();
|
|
47
|
-
}
|
|
223
|
+
});
|
|
224
|
+
}).apply(this, arguments);
|
|
48
225
|
}
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=download.js.map
|
|
@@ -2,13 +2,16 @@ export function getFileFromDataTransfer(dataTransfer) {
|
|
|
2
2
|
if (!dataTransfer) {
|
|
3
3
|
return {};
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
var _dataTransfer_items;
|
|
6
|
+
var items = (_dataTransfer_items = dataTransfer.items) !== null && _dataTransfer_items !== void 0 ? _dataTransfer_items : [];
|
|
6
7
|
if (items.length >= 2 && items[0].kind === 'string' && items[1].kind === 'file') {
|
|
8
|
+
var _dataTransfer_files;
|
|
7
9
|
// name, file
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
var text = dataTransfer.getData('text');
|
|
11
|
+
var _items__getAsFile;
|
|
12
|
+
var file = (_items__getAsFile = items[1].getAsFile()) !== null && _items__getAsFile !== void 0 ? _items__getAsFile : (_dataTransfer_files = dataTransfer.files) === null || _dataTransfer_files === void 0 ? void 0 : _dataTransfer_files.item(0);
|
|
10
13
|
if (!file) {
|
|
11
|
-
console.error(
|
|
14
|
+
console.error("no file ".concat(text), items[1]);
|
|
12
15
|
return {};
|
|
13
16
|
}
|
|
14
17
|
// let type = file.type;
|
|
@@ -20,26 +23,26 @@ export function getFileFromDataTransfer(dataTransfer) {
|
|
|
20
23
|
// file = new File([blob], text, {type});
|
|
21
24
|
// }
|
|
22
25
|
return {
|
|
23
|
-
file,
|
|
26
|
+
file: file,
|
|
24
27
|
name: text
|
|
25
28
|
};
|
|
26
29
|
} else if (items[0].kind === 'file') {
|
|
27
|
-
|
|
28
|
-
if (!
|
|
29
|
-
console.error(
|
|
30
|
+
var file1 = items[0].getAsFile();
|
|
31
|
+
if (!file1) {
|
|
32
|
+
console.error("no file", items[0]);
|
|
30
33
|
return {};
|
|
31
34
|
}
|
|
32
35
|
return {
|
|
33
|
-
file,
|
|
34
|
-
name:
|
|
36
|
+
file: file1,
|
|
37
|
+
name: file1.name
|
|
35
38
|
};
|
|
36
39
|
} else {
|
|
37
|
-
console.debug(
|
|
40
|
+
console.debug("file item not match", Array.from(items).map(function(v) {
|
|
41
|
+
return {
|
|
38
42
|
type: v.type,
|
|
39
43
|
kind: v.kind
|
|
40
|
-
}
|
|
44
|
+
};
|
|
45
|
+
}));
|
|
41
46
|
}
|
|
42
47
|
return {};
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=getFileFromDataTransfer.js.map
|