yummies 5.7.1 → 5.9.0
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/async.cjs +2 -70
- package/async.cjs.map +1 -0
- package/async.js +26 -59
- package/async.js.map +1 -0
- package/common.cjs +2 -18
- package/common.cjs.map +1 -0
- package/common.d.ts +1 -1
- package/common.d.ts.map +1 -1
- package/common.js +5 -13
- package/common.js.map +1 -0
- package/complex/global-config.d.ts +1 -1
- package/complex/global-config.d.ts.map +1 -1
- package/complex/index.d.ts +3 -3
- package/complex/index.d.ts.map +1 -1
- package/complex/modules-factory.d.ts +1 -1
- package/complex/modules-factory.d.ts.map +1 -1
- package/complex.cjs +2 -0
- package/complex.cjs.map +1 -0
- package/complex.js +66 -0
- package/complex.js.map +1 -0
- package/cookie.cjs +2 -13
- package/cookie.cjs.map +1 -0
- package/cookie.d.ts +1 -1
- package/cookie.d.ts.map +1 -1
- package/cookie.js +4 -8
- package/cookie.js.map +1 -0
- package/css.cjs +2 -64
- package/css.cjs.map +1 -0
- package/css.d.ts +1 -1
- package/css.js +24 -54
- package/css.js.map +1 -0
- package/data.cjs +2 -58
- package/data.cjs.map +1 -0
- package/data.js +32 -50
- package/data.js.map +1 -0
- package/date-time.cjs +2 -171
- package/date-time.cjs.map +1 -0
- package/date-time.d.ts +2 -3
- package/date-time.d.ts.map +1 -1
- package/date-time.js +311 -156
- package/date-time.js.map +1 -0
- package/device.cjs +2 -28
- package/device.cjs.map +1 -0
- package/device.js +23 -20
- package/device.js.map +1 -0
- package/encodings.cjs +2 -270
- package/encodings.cjs.map +1 -0
- package/encodings.js +269 -265
- package/encodings.js.map +1 -0
- package/errors.cjs +2 -34
- package/errors.cjs.map +1 -0
- package/errors.d.ts +1 -1
- package/errors.d.ts.map +1 -1
- package/errors.js +8 -29
- package/errors.js.map +1 -0
- package/file.cjs +2 -29
- package/file.cjs.map +1 -0
- package/file.js +19 -23
- package/file.js.map +1 -0
- package/format/_exports.d.ts +4 -4
- package/format/_exports.d.ts.map +1 -1
- package/format/index.d.ts +1 -1
- package/format/index.d.ts.map +1 -1
- package/format/number.d.ts +1 -1
- package/format/number.d.ts.map +1 -1
- package/format/percent.d.ts +2 -2
- package/format/percent.d.ts.map +1 -1
- package/format.cjs +2 -0
- package/format.cjs.map +1 -0
- package/format.js +27 -0
- package/format.js.map +1 -0
- package/html.cjs +2 -202
- package/html.cjs.map +1 -0
- package/html.d.ts +2 -2
- package/html.d.ts.map +1 -1
- package/html.js +120 -177
- package/html.js.map +1 -0
- package/id.cjs +3 -76
- package/id.cjs.map +1 -0
- package/id.js +15 -70
- package/id.js.map +1 -0
- package/imports.cjs +2 -45
- package/imports.cjs.map +1 -0
- package/imports.js +22 -37
- package/imports.js.map +1 -0
- package/math.cjs +2 -23
- package/math.cjs.map +1 -0
- package/math.d.ts +1 -1
- package/math.d.ts.map +1 -1
- package/math.js +10 -14
- package/math.js.map +1 -0
- package/media.cjs +2 -115
- package/media.cjs.map +1 -0
- package/media.js +54 -96
- package/media.js.map +1 -0
- package/mobx/apply-observable.d.ts +1 -1
- package/mobx/apply-observable.d.ts.map +1 -1
- package/mobx/create-enhanced-atom.d.ts +2 -2
- package/mobx/create-enhanced-atom.d.ts.map +1 -1
- package/mobx/deep-observable-struct.d.ts +1 -1
- package/mobx/deep-observable-struct.d.ts.map +1 -1
- package/mobx/get-mobx-administration.d.ts +2 -2
- package/mobx/get-mobx-administration.d.ts.map +1 -1
- package/mobx/index.d.ts +5 -5
- package/mobx/index.d.ts.map +1 -1
- package/mobx.cjs +2 -0
- package/mobx.cjs.map +1 -0
- package/mobx.js +89 -0
- package/mobx.js.map +1 -0
- package/ms.cjs +2 -22
- package/ms.cjs.map +1 -0
- package/ms.js +12 -17
- package/ms.js.map +1 -0
- package/number.cjs +2 -16
- package/number.cjs.map +1 -0
- package/number.js +9 -12
- package/number.js.map +1 -0
- package/package.json +101 -70
- package/parser/_exports.d.ts +3 -3
- package/parser/_exports.d.ts.map +1 -1
- package/parser/index.d.ts +1 -1
- package/parser/index.d.ts.map +1 -1
- package/parser/number.d.ts +1 -1
- package/parser/number.d.ts.map +1 -1
- package/parser/percent.d.ts +2 -2
- package/parser/percent.d.ts.map +1 -1
- package/parser/string.d.ts +1 -1
- package/parser/string.d.ts.map +1 -1
- package/parser.cjs +2 -0
- package/parser.cjs.map +1 -0
- package/parser.js +15 -0
- package/parser.js.map +1 -0
- package/price.cjs +2 -21
- package/price.cjs.map +1 -0
- package/price.js +13 -16
- package/price.js.map +1 -0
- package/random.cjs +2 -25
- package/random.cjs.map +1 -0
- package/random.js +11 -13
- package/random.js.map +1 -0
- package/react/hooks/index.d.ts +21 -21
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/use-click-outside.d.ts +1 -1
- package/react/hooks/use-define-ref.d.ts +1 -1
- package/react/hooks/use-element-ref.d.ts +1 -1
- package/react/hooks/use-event.d.ts +1 -1
- package/react/hooks/use-event.d.ts.map +1 -1
- package/react/hooks/use-initial-height.d.ts +1 -1
- package/react/hooks/use-last-value-ref.d.ts +1 -1
- package/react/hooks/use-resize-observer.d.ts +1 -1
- package/react/hooks/use-sync-ref.d.ts +1 -1
- package/react/hooks/use-toggle.d.ts +1 -1
- package/react/hooks/use-value.d.ts +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.d.ts.map +1 -1
- package/react.cjs +2 -0
- package/react.cjs.map +1 -0
- package/react.js +152 -0
- package/react.js.map +1 -0
- package/sound.cjs +2 -16
- package/sound.cjs.map +1 -0
- package/sound.js +7 -11
- package/sound.js.map +1 -0
- package/text.cjs +2 -53
- package/text.cjs.map +1 -0
- package/text.js +20 -46
- package/text.js.map +1 -0
- package/type-guard/_exports.d.ts +1 -1
- package/type-guard/_exports.d.ts.map +1 -1
- package/type-guard/index.d.ts +1 -1
- package/type-guard/index.d.ts.map +1 -1
- package/type-guard.cjs +2 -0
- package/type-guard.cjs.map +1 -0
- package/type-guard.js +5 -0
- package/type-guard.js.map +1 -0
- package/utility-types.cjs +2 -0
- package/utility-types.cjs.map +1 -0
- package/utility-types.d.ts.map +1 -0
- package/utility-types.js +2 -0
- package/utility-types.js.map +1 -0
- package/utils/types.cjs +1 -1
- package/utils/types.cjs.map +1 -0
- package/utils/types.js +2 -1
- package/utils/types.js.map +1 -0
- package/vibrate.cjs +2 -12
- package/vibrate.cjs.map +1 -0
- package/vibrate.js +6 -7
- package/vibrate.js.map +1 -0
- package/~index-C3wKHvHr.js +80 -0
- package/~index-C3wKHvHr.js.map +1 -0
- package/~index-PKNbSTT-.js +2 -0
- package/~index-PKNbSTT-.js.map +1 -0
- package/~number-B1MpW9GU.js +2 -0
- package/~number-B1MpW9GU.js.map +1 -0
- package/~number-DX076ykA.js +2 -0
- package/~number-DX076ykA.js.map +1 -0
- package/~number-EWff2XI6.js +25 -0
- package/~number-EWff2XI6.js.map +1 -0
- package/~number-baxVnzrJ.js +32 -0
- package/~number-baxVnzrJ.js.map +1 -0
- package/async.d.cts +0 -28
- package/async.d.cts.map +0 -1
- package/common.d.cts +0 -15
- package/common.d.cts.map +0 -1
- package/complex/counter.cjs +0 -21
- package/complex/counter.d.cts +0 -15
- package/complex/counter.d.cts.map +0 -1
- package/complex/counter.js +0 -17
- package/complex/global-config.cjs +0 -46
- package/complex/global-config.d.cts +0 -11
- package/complex/global-config.d.cts.map +0 -1
- package/complex/global-config.js +0 -41
- package/complex/index.cjs +0 -19
- package/complex/index.d.cts +0 -4
- package/complex/index.d.cts.map +0 -1
- package/complex/index.js +0 -3
- package/complex/modules-factory.cjs +0 -50
- package/complex/modules-factory.d.cts +0 -49
- package/complex/modules-factory.d.cts.map +0 -1
- package/complex/modules-factory.js +0 -46
- package/cookie.d.cts +0 -3
- package/cookie.d.cts.map +0 -1
- package/css.d.cts +0 -42
- package/css.d.cts.map +0 -1
- package/data.d.cts +0 -4
- package/data.d.cts.map +0 -1
- package/date-time.d.cts +0 -28
- package/date-time.d.cts.map +0 -1
- package/device.d.cts +0 -8
- package/device.d.cts.map +0 -1
- package/encodings.d.cts +0 -2
- package/encodings.d.cts.map +0 -1
- package/errors.d.cts +0 -19
- package/errors.d.cts.map +0 -1
- package/file.d.cts +0 -3
- package/file.d.cts.map +0 -1
- package/format/_exports.cjs +0 -20
- package/format/_exports.d.cts +0 -5
- package/format/_exports.d.cts.map +0 -1
- package/format/_exports.js +0 -4
- package/format/constants.cjs +0 -6
- package/format/constants.d.cts +0 -4
- package/format/constants.d.cts.map +0 -1
- package/format/constants.js +0 -3
- package/format/index.cjs +0 -40
- package/format/index.d.cts +0 -3
- package/format/index.d.cts.map +0 -1
- package/format/index.js +0 -4
- package/format/number.cjs +0 -48
- package/format/number.d.cts +0 -36
- package/format/number.d.cts.map +0 -1
- package/format/number.js +0 -44
- package/format/percent.cjs +0 -27
- package/format/percent.d.cts +0 -15
- package/format/percent.d.cts.map +0 -1
- package/format/percent.js +0 -23
- package/format/skip-spaces.cjs +0 -8
- package/format/skip-spaces.d.cts +0 -5
- package/format/skip-spaces.d.cts.map +0 -1
- package/format/skip-spaces.js +0 -4
- package/html.d.cts +0 -44
- package/html.d.cts.map +0 -1
- package/id.d.cts +0 -63
- package/id.d.cts.map +0 -1
- package/imports.d.cts +0 -15
- package/imports.d.cts.map +0 -1
- package/math.d.cts +0 -13
- package/math.d.cts.map +0 -1
- package/media.d.cts +0 -20
- package/media.d.cts.map +0 -1
- package/mobx/apply-observable.cjs +0 -16
- package/mobx/apply-observable.d.cts +0 -4
- package/mobx/apply-observable.d.cts.map +0 -1
- package/mobx/apply-observable.js +0 -12
- package/mobx/create-enhanced-atom.cjs +0 -16
- package/mobx/create-enhanced-atom.d.cts +0 -11
- package/mobx/create-enhanced-atom.d.cts.map +0 -1
- package/mobx/create-enhanced-atom.js +0 -12
- package/mobx/deep-observable-struct.cjs +0 -61
- package/mobx/deep-observable-struct.d.cts +0 -7
- package/mobx/deep-observable-struct.d.cts.map +0 -1
- package/mobx/deep-observable-struct.js +0 -57
- package/mobx/get-mobx-administration.cjs +0 -6
- package/mobx/get-mobx-administration.d.cts +0 -6
- package/mobx/get-mobx-administration.d.cts.map +0 -1
- package/mobx/get-mobx-administration.js +0 -2
- package/mobx/index.cjs +0 -21
- package/mobx/index.d.cts +0 -6
- package/mobx/index.d.cts.map +0 -1
- package/mobx/index.js +0 -5
- package/mobx/lazy-observe.cjs +0 -66
- package/mobx/lazy-observe.d.cts +0 -14
- package/mobx/lazy-observe.d.cts.map +0 -1
- package/mobx/lazy-observe.js +0 -62
- package/ms.d.cts +0 -19
- package/ms.d.cts.map +0 -1
- package/number.d.cts +0 -8
- package/number.d.cts.map +0 -1
- package/parser/_exports.cjs +0 -19
- package/parser/_exports.d.cts +0 -4
- package/parser/_exports.d.cts.map +0 -1
- package/parser/_exports.js +0 -3
- package/parser/index.cjs +0 -40
- package/parser/index.d.cts +0 -3
- package/parser/index.d.cts.map +0 -1
- package/parser/index.js +0 -4
- package/parser/number.cjs +0 -48
- package/parser/number.d.cts +0 -21
- package/parser/number.d.cts.map +0 -1
- package/parser/number.js +0 -44
- package/parser/percent.cjs +0 -8
- package/parser/percent.d.cts +0 -4
- package/parser/percent.d.cts.map +0 -1
- package/parser/percent.js +0 -4
- package/parser/string.cjs +0 -18
- package/parser/string.d.cts +0 -7
- package/parser/string.d.cts.map +0 -1
- package/parser/string.js +0 -14
- package/price.d.cts +0 -6
- package/price.d.cts.map +0 -1
- package/random.d.cts +0 -9
- package/random.d.cts.map +0 -1
- package/react/hooks/index.cjs +0 -37
- package/react/hooks/index.d.cts +0 -22
- package/react/hooks/index.d.cts.map +0 -1
- package/react/hooks/index.js +0 -21
- package/react/hooks/use-abort-controller.cjs +0 -15
- package/react/hooks/use-abort-controller.d.cts +0 -2
- package/react/hooks/use-abort-controller.d.cts.map +0 -1
- package/react/hooks/use-abort-controller.js +0 -11
- package/react/hooks/use-abort-signal.cjs +0 -8
- package/react/hooks/use-abort-signal.d.cts +0 -2
- package/react/hooks/use-abort-signal.d.cts.map +0 -1
- package/react/hooks/use-abort-signal.js +0 -4
- package/react/hooks/use-click-outside.cjs +0 -17
- package/react/hooks/use-click-outside.d.cts +0 -9
- package/react/hooks/use-click-outside.d.cts.map +0 -1
- package/react/hooks/use-click-outside.js +0 -13
- package/react/hooks/use-constant.cjs +0 -19
- package/react/hooks/use-constant.d.cts +0 -9
- package/react/hooks/use-constant.d.cts.map +0 -1
- package/react/hooks/use-constant.js +0 -15
- package/react/hooks/use-define-ref.cjs +0 -19
- package/react/hooks/use-define-ref.d.cts +0 -10
- package/react/hooks/use-define-ref.d.cts.map +0 -1
- package/react/hooks/use-define-ref.js +0 -15
- package/react/hooks/use-element-ref.cjs +0 -12
- package/react/hooks/use-element-ref.d.cts +0 -2
- package/react/hooks/use-element-ref.d.cts.map +0 -1
- package/react/hooks/use-element-ref.js +0 -8
- package/react/hooks/use-event-listener.cjs +0 -17
- package/react/hooks/use-event-listener.d.cts +0 -8
- package/react/hooks/use-event-listener.d.cts.map +0 -1
- package/react/hooks/use-event-listener.js +0 -13
- package/react/hooks/use-event.cjs +0 -23
- package/react/hooks/use-event.d.cts +0 -3
- package/react/hooks/use-event.d.cts.map +0 -1
- package/react/hooks/use-event.js +0 -19
- package/react/hooks/use-flag.cjs +0 -19
- package/react/hooks/use-flag.d.cts +0 -8
- package/react/hooks/use-flag.d.cts.map +0 -1
- package/react/hooks/use-flag.js +0 -15
- package/react/hooks/use-force-update.cjs +0 -11
- package/react/hooks/use-force-update.d.cts +0 -2
- package/react/hooks/use-force-update.d.cts.map +0 -1
- package/react/hooks/use-force-update.js +0 -7
- package/react/hooks/use-initial-height.cjs +0 -15
- package/react/hooks/use-initial-height.d.cts +0 -5
- package/react/hooks/use-initial-height.d.cts.map +0 -1
- package/react/hooks/use-initial-height.js +0 -11
- package/react/hooks/use-instance.cjs +0 -31
- package/react/hooks/use-instance.d.cts +0 -27
- package/react/hooks/use-instance.d.cts.map +0 -1
- package/react/hooks/use-instance.js +0 -27
- package/react/hooks/use-intersection-observer.cjs +0 -14
- package/react/hooks/use-intersection-observer.d.cts +0 -2
- package/react/hooks/use-intersection-observer.d.cts.map +0 -1
- package/react/hooks/use-intersection-observer.js +0 -10
- package/react/hooks/use-last-defined-value.cjs +0 -12
- package/react/hooks/use-last-defined-value.d.cts +0 -2
- package/react/hooks/use-last-defined-value.d.cts.map +0 -1
- package/react/hooks/use-last-defined-value.js +0 -8
- package/react/hooks/use-last-value-ref.cjs +0 -12
- package/react/hooks/use-last-value-ref.d.cts +0 -2
- package/react/hooks/use-last-value-ref.d.cts.map +0 -1
- package/react/hooks/use-last-value-ref.js +0 -8
- package/react/hooks/use-life-cycle.cjs +0 -14
- package/react/hooks/use-life-cycle.d.cts +0 -5
- package/react/hooks/use-life-cycle.d.cts.map +0 -1
- package/react/hooks/use-life-cycle.js +0 -10
- package/react/hooks/use-resize-observer.cjs +0 -15
- package/react/hooks/use-resize-observer.d.cts +0 -2
- package/react/hooks/use-resize-observer.d.cts.map +0 -1
- package/react/hooks/use-resize-observer.js +0 -11
- package/react/hooks/use-sync-ref.cjs +0 -10
- package/react/hooks/use-sync-ref.d.cts +0 -2
- package/react/hooks/use-sync-ref.d.cts.map +0 -1
- package/react/hooks/use-sync-ref.js +0 -6
- package/react/hooks/use-toggle.cjs +0 -10
- package/react/hooks/use-toggle.d.cts +0 -2
- package/react/hooks/use-toggle.d.cts.map +0 -1
- package/react/hooks/use-toggle.js +0 -6
- package/react/hooks/use-value.cjs +0 -12
- package/react/hooks/use-value.d.cts +0 -5
- package/react/hooks/use-value.d.cts.map +0 -1
- package/react/hooks/use-value.js +0 -8
- package/react/hooks/use-visibility-state.cjs +0 -18
- package/react/hooks/use-visibility-state.d.cts +0 -2
- package/react/hooks/use-visibility-state.d.cts.map +0 -1
- package/react/hooks/use-visibility-state.js +0 -14
- package/react/index.cjs +0 -17
- package/react/index.d.cts +0 -2
- package/react/index.d.cts.map +0 -1
- package/react/index.js +0 -1
- package/sound.d.cts +0 -7
- package/sound.d.cts.map +0 -1
- package/storage.cjs +0 -48
- package/storage.d.cts +0 -39
- package/storage.d.cts.map +0 -1
- package/storage.js +0 -43
- package/text.d.cts +0 -15
- package/text.d.cts.map +0 -1
- package/type-guard/_exports.cjs +0 -129
- package/type-guard/_exports.d.cts +0 -86
- package/type-guard/_exports.d.cts.map +0 -1
- package/type-guard/_exports.js +0 -125
- package/type-guard/index.cjs +0 -40
- package/type-guard/index.d.cts +0 -3
- package/type-guard/index.d.cts.map +0 -1
- package/type-guard/index.js +0 -4
- package/utils/types.d.cts +0 -395
- package/utils/types.d.cts.map +0 -1
- package/vibrate.d.cts +0 -5
- package/vibrate.d.cts.map +0 -1
package/html.js
CHANGED
|
@@ -1,182 +1,125 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { blobToUrl } from "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
d.style.color = color;
|
|
13
|
-
document.body.append(d);
|
|
14
|
-
const rgbcolor = globalThis.getComputedStyle(d).color;
|
|
15
|
-
const match = /rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*\d+[.d+]*)*\)/g.exec(rgbcolor);
|
|
16
|
-
d.remove();
|
|
17
|
-
if (!match)
|
|
18
|
-
return null;
|
|
19
|
-
return `${match[1]}, ${match[2]}, ${match[3]}`;
|
|
1
|
+
import l from "dompurify";
|
|
2
|
+
import { blobToUrl as a } from "yummies/media";
|
|
3
|
+
const u = (t) => {
|
|
4
|
+
if (!t) return null;
|
|
5
|
+
const e = document.createElement("div");
|
|
6
|
+
e.style.color = t, document.body.append(e);
|
|
7
|
+
const o = globalThis.getComputedStyle(e).color, n = /rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*\d+[.d+]*)*\)/g.exec(o);
|
|
8
|
+
return e.remove(), n ? `${n[1]}, ${n[2]}, ${n[3]}` : null;
|
|
9
|
+
}, m = (t, e) => {
|
|
10
|
+
const o = a(t), n = document.createElement("a");
|
|
11
|
+
n.href = o, n.download = e ?? "file", n.target = "_blank", document.body.append(n), n.click(), n.remove();
|
|
20
12
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
a.href = url;
|
|
25
|
-
a.download = fileName ?? 'file';
|
|
26
|
-
a.target = '_blank';
|
|
27
|
-
document.body.append(a);
|
|
28
|
-
a.click();
|
|
29
|
-
a.remove();
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Surrounds string in an anchor tag
|
|
33
|
-
*/
|
|
34
|
-
export function wrapTextToTagLink(link) {
|
|
35
|
-
const descr = String(link).replace(/^(https?:\/{0,2})?(w{3}\.)?/, 'www.');
|
|
36
|
-
if (!/^https?:\/{2}/.test(link))
|
|
37
|
-
link = `http://${link}`;
|
|
38
|
-
return `<a href=${link} target="_blank">${descr}</a>`;
|
|
13
|
+
function h(t) {
|
|
14
|
+
const e = String(t).replace(/^(https?:\/{0,2})?(w{3}\.)?/, "www.");
|
|
15
|
+
return /^https?:\/{2}/.test(t) || (t = `http://${t}`), `<a href=${t} target="_blank">${e}</a>`;
|
|
39
16
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
17
|
+
const p = (t) => {
|
|
18
|
+
let e = 0, o = t;
|
|
19
|
+
for (; o != null; )
|
|
20
|
+
e += o.offsetTop, o = o.parentElement;
|
|
21
|
+
return e;
|
|
22
|
+
}, g = (t) => (t.preventDefault(), t.stopPropagation(), !1), f = (t) => {
|
|
23
|
+
const e = document.body, o = window.innerHeight, n = t.getBoundingClientRect(), r = e.scrollHeight / o, s = Math.min(
|
|
24
|
+
Math.max(n.top / o, 1),
|
|
25
|
+
r
|
|
26
|
+
);
|
|
27
|
+
window.scroll({
|
|
28
|
+
top: s * o,
|
|
29
|
+
behavior: "smooth"
|
|
30
|
+
});
|
|
31
|
+
}, i = {
|
|
32
|
+
ALLOWED_TAGS: [
|
|
33
|
+
"a",
|
|
34
|
+
"article",
|
|
35
|
+
"b",
|
|
36
|
+
"blockquote",
|
|
37
|
+
"br",
|
|
38
|
+
"caption",
|
|
39
|
+
"code",
|
|
40
|
+
"del",
|
|
41
|
+
"details",
|
|
42
|
+
"div",
|
|
43
|
+
"em",
|
|
44
|
+
"h1",
|
|
45
|
+
"h2",
|
|
46
|
+
"h3",
|
|
47
|
+
"h4",
|
|
48
|
+
"h5",
|
|
49
|
+
"h6",
|
|
50
|
+
"hr",
|
|
51
|
+
"i",
|
|
52
|
+
"img",
|
|
53
|
+
"ins",
|
|
54
|
+
"kbd",
|
|
55
|
+
"li",
|
|
56
|
+
"main",
|
|
57
|
+
"ol",
|
|
58
|
+
"p",
|
|
59
|
+
"pre",
|
|
60
|
+
"section",
|
|
61
|
+
"span",
|
|
62
|
+
"strong",
|
|
63
|
+
"sub",
|
|
64
|
+
"summary",
|
|
65
|
+
"sup",
|
|
66
|
+
"table",
|
|
67
|
+
"tbody",
|
|
68
|
+
"td",
|
|
69
|
+
"th",
|
|
70
|
+
"thead",
|
|
71
|
+
"tr",
|
|
72
|
+
"u",
|
|
73
|
+
"ul"
|
|
74
|
+
],
|
|
75
|
+
ALLOWED_ATTR: ["href", "target", "name", "src", "class"]
|
|
76
|
+
}, b = (t, e) => l.sanitize(t || "", {
|
|
77
|
+
...i,
|
|
78
|
+
...e
|
|
79
|
+
}), w = (t, e) => {
|
|
80
|
+
let o = t;
|
|
81
|
+
if (!e) return !1;
|
|
82
|
+
for (; o != null; ) {
|
|
83
|
+
if (o === e)
|
|
84
|
+
return !0;
|
|
85
|
+
o = o.parentElement;
|
|
86
|
+
}
|
|
87
|
+
return !1;
|
|
88
|
+
}, T = (t, e) => {
|
|
89
|
+
if (document.startViewTransition && !e?.disabled)
|
|
90
|
+
return document.startViewTransition(t);
|
|
91
|
+
t();
|
|
92
|
+
}, y = () => {
|
|
93
|
+
const t = document.createElement("div");
|
|
94
|
+
t.style.visibility = "hidden", t.style.width = "100px", t.style.overflow = "scroll", document.body.append(t);
|
|
95
|
+
const e = document.createElement("div");
|
|
96
|
+
e.style.width = "100%", t.append(e);
|
|
97
|
+
const o = t.offsetWidth - e.offsetWidth;
|
|
98
|
+
return t.parentNode?.removeChild(t), o;
|
|
116
99
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return false;
|
|
121
|
-
while (node != null) {
|
|
122
|
-
if (node === parent) {
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
node = node.parentElement;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Executes a function within a view transition if supported by the browser.
|
|
133
|
-
*
|
|
134
|
-
* @param {VoidFunction} fn - The function to be executed.
|
|
135
|
-
* @returns {ViewTransition} - The result of the executed function.
|
|
136
|
-
*
|
|
137
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition | MDN: Document.startViewTransition}
|
|
138
|
-
*/
|
|
139
|
-
export const startViewTransitionSafety = (fn, params) => {
|
|
140
|
-
if (document.startViewTransition && !params?.disabled) {
|
|
141
|
-
return document.startViewTransition(fn);
|
|
142
|
-
}
|
|
143
|
-
fn();
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* Вычисляет размер скроллбара
|
|
147
|
-
*/
|
|
148
|
-
export const calcScrollbarWidth = () => {
|
|
149
|
-
const outer = document.createElement('div');
|
|
150
|
-
outer.style.visibility = 'hidden';
|
|
151
|
-
outer.style.width = '100px';
|
|
152
|
-
outer.style.overflow = 'scroll';
|
|
153
|
-
document.body.append(outer);
|
|
154
|
-
const inner = document.createElement('div');
|
|
155
|
-
inner.style.width = '100%';
|
|
156
|
-
outer.append(inner);
|
|
157
|
-
const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
|
|
158
|
-
outer.parentNode?.removeChild(outer);
|
|
159
|
-
return scrollbarWidth;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Calculates the inner height of an HTML element, accounting for padding.
|
|
163
|
-
*/
|
|
164
|
-
export function getElementInnerHeight(element) {
|
|
165
|
-
const { clientHeight } = element;
|
|
166
|
-
const { paddingTop, paddingBottom } = getComputedStyle(element);
|
|
167
|
-
return (clientHeight -
|
|
168
|
-
Number.parseFloat(paddingTop) -
|
|
169
|
-
Number.parseFloat(paddingBottom));
|
|
100
|
+
function v(t) {
|
|
101
|
+
const { clientHeight: e } = t, { paddingTop: o, paddingBottom: n } = getComputedStyle(t);
|
|
102
|
+
return e - Number.parseFloat(o) - Number.parseFloat(n);
|
|
170
103
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
export function getElementInnerWidth(el) {
|
|
175
|
-
const { clientWidth } = el;
|
|
176
|
-
const { paddingLeft, paddingRight } = getComputedStyle(el);
|
|
177
|
-
return (clientWidth -
|
|
178
|
-
Number.parseFloat(paddingLeft) -
|
|
179
|
-
Number.parseFloat(paddingRight));
|
|
104
|
+
function E(t) {
|
|
105
|
+
const { clientWidth: e } = t, { paddingLeft: o, paddingRight: n } = getComputedStyle(t);
|
|
106
|
+
return e - Number.parseFloat(o) - Number.parseFloat(n);
|
|
180
107
|
}
|
|
181
|
-
|
|
182
|
-
export
|
|
108
|
+
const C = () => !!globalThis.matchMedia?.("(prefers-color-scheme: dark)")?.matches, S = () => !!globalThis.matchMedia?.("(prefers-color-scheme: light)")?.matches;
|
|
109
|
+
export {
|
|
110
|
+
y as calcScrollbarWidth,
|
|
111
|
+
w as checkElementHasParent,
|
|
112
|
+
p as collectOffsetTop,
|
|
113
|
+
m as downloadUsingAnchor,
|
|
114
|
+
u as getComputedColor,
|
|
115
|
+
v as getElementInnerHeight,
|
|
116
|
+
E as getElementInnerWidth,
|
|
117
|
+
f as globalScrollIntoViewForY,
|
|
118
|
+
C as isPrefersDarkTheme,
|
|
119
|
+
S as isPrefersLightTheme,
|
|
120
|
+
b as sanitizeHtml,
|
|
121
|
+
g as skipEvent,
|
|
122
|
+
T as startViewTransitionSafety,
|
|
123
|
+
h as wrapTextToTagLink
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=html.js.map
|
package/html.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sources":["../src/html.ts"],"sourcesContent":["import DOMPurify, { type Config as DOMPurifyConfig } from 'dompurify';\nimport { blobToUrl } from 'yummies/media';\nimport type { Maybe } from 'yummies/utils/types';\n\n/**\n * Вытаскивает RGB из любого цвета\n *\n * Не рекомендуется к использованию так как вызывает reflow\n */\nexport const getComputedColor = (color?: string): string | null => {\n if (!color) return null;\n\n const d = document.createElement('div');\n d.style.color = color;\n document.body.append(d);\n const rgbcolor = globalThis.getComputedStyle(d).color;\n const match =\n /rgba?\\((\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(,\\s*\\d+[.d+]*)*\\)/g.exec(rgbcolor);\n\n d.remove();\n\n if (!match) return null;\n\n return `${match[1]}, ${match[2]}, ${match[3]}`;\n};\n\nexport const downloadUsingAnchor = (\n urlOrBlob: string | Blob,\n fileName?: string,\n) => {\n const url = blobToUrl(urlOrBlob);\n\n const a = document.createElement('a');\n a.href = url;\n\n a.download = fileName ?? 'file';\n\n a.target = '_blank';\n\n document.body.append(a);\n\n a.click();\n\n a.remove();\n};\n\n/**\n * Surrounds string in an anchor tag\n */\nexport function wrapTextToTagLink(link: string) {\n const descr = String(link).replace(/^(https?:\\/{0,2})?(w{3}\\.)?/, 'www.');\n if (!/^https?:\\/{2}/.test(link)) link = `http://${link}`;\n return `<a href=${link} target=\"_blank\">${descr}</a>`;\n}\n\nexport const collectOffsetTop = (element: HTMLElement | null) => {\n let offsetTop = 0;\n let node = element;\n\n while (node != null) {\n offsetTop += node.offsetTop;\n node = node.parentElement;\n }\n\n return offsetTop;\n};\n\nexport const skipEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n\n return false;\n};\n\nexport const globalScrollIntoViewForY = (node: HTMLElement) => {\n const scrollContainer = document.body;\n const pageHeight = window.innerHeight;\n const nodeBounding = node.getBoundingClientRect();\n const scrollPagesCount = scrollContainer.scrollHeight / pageHeight;\n\n const scrollPageNumber = Math.min(\n Math.max(nodeBounding.top / pageHeight, 1),\n scrollPagesCount,\n );\n\n window.scroll({\n top: scrollPageNumber * pageHeight,\n behavior: 'smooth',\n });\n};\n\nconst sanitizeDefaults: DOMPurifyConfig = {\n ALLOWED_TAGS: [\n 'a',\n 'article',\n 'b',\n 'blockquote',\n 'br',\n 'caption',\n 'code',\n 'del',\n 'details',\n 'div',\n 'em',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'i',\n 'img',\n 'ins',\n 'kbd',\n 'li',\n 'main',\n 'ol',\n 'p',\n 'pre',\n 'section',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'th',\n 'thead',\n 'tr',\n 'u',\n 'ul',\n ],\n ALLOWED_ATTR: ['href', 'target', 'name', 'src', 'class'],\n};\n\nexport const sanitizeHtml = (html: Maybe<string>, config?: DOMPurifyConfig) => {\n return DOMPurify.sanitize(html || '', {\n ...sanitizeDefaults,\n ...config,\n });\n};\n\nexport const checkElementHasParent = (\n element: HTMLElement | null,\n parent: Maybe<HTMLElement>,\n) => {\n let node = element;\n\n if (!parent) return false;\n\n while (node != null) {\n if (node === parent) {\n return true;\n } else {\n node = node.parentElement;\n }\n }\n\n return false;\n};\n\n/**\n * Executes a function within a view transition if supported by the browser.\n *\n * @param {VoidFunction} fn - The function to be executed.\n * @returns {ViewTransition} - The result of the executed function.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition | MDN: Document.startViewTransition}\n */\nexport const startViewTransitionSafety = (\n fn: VoidFunction,\n params?: { disabled?: boolean },\n) => {\n if (document.startViewTransition && !params?.disabled) {\n return document.startViewTransition(fn);\n }\n fn();\n};\n\n/**\n * Вычисляет размер скроллбара\n */\nexport const calcScrollbarWidth = () => {\n const outer = document.createElement('div');\n\n outer.style.visibility = 'hidden';\n outer.style.width = '100px';\n outer.style.overflow = 'scroll';\n\n document.body.append(outer);\n\n const inner = document.createElement('div');\n inner.style.width = '100%';\n\n outer.append(inner);\n\n const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;\n\n outer.parentNode?.removeChild(outer);\n\n return scrollbarWidth;\n};\n\n/**\n * Calculates the inner height of an HTML element, accounting for padding.\n */\nexport function getElementInnerHeight(element: HTMLElement) {\n const { clientHeight } = element;\n const { paddingTop, paddingBottom } = getComputedStyle(element);\n return (\n clientHeight -\n Number.parseFloat(paddingTop) -\n Number.parseFloat(paddingBottom)\n );\n}\n\n/**\n * Calculates the inner width of an HTML element, accounting for padding.\n */\nexport function getElementInnerWidth(el: HTMLElement) {\n const { clientWidth } = el;\n const { paddingLeft, paddingRight } = getComputedStyle(el);\n return (\n clientWidth -\n Number.parseFloat(paddingLeft) -\n Number.parseFloat(paddingRight)\n );\n}\n\nexport const isPrefersDarkTheme = () =>\n !!globalThis.matchMedia?.('(prefers-color-scheme: dark)')?.matches;\n\nexport const isPrefersLightTheme = () =>\n !!globalThis.matchMedia?.('(prefers-color-scheme: light)')?.matches;\n"],"names":["getComputedColor","color","d","rgbcolor","match","downloadUsingAnchor","urlOrBlob","fileName","url","blobToUrl","a","wrapTextToTagLink","link","descr","collectOffsetTop","element","offsetTop","node","skipEvent","e","globalScrollIntoViewForY","scrollContainer","pageHeight","nodeBounding","scrollPagesCount","scrollPageNumber","sanitizeDefaults","sanitizeHtml","html","config","DOMPurify","checkElementHasParent","parent","startViewTransitionSafety","fn","params","calcScrollbarWidth","outer","inner","scrollbarWidth","getElementInnerHeight","clientHeight","paddingTop","paddingBottom","getElementInnerWidth","el","clientWidth","paddingLeft","paddingRight","isPrefersDarkTheme","isPrefersLightTheme"],"mappings":";;AASO,MAAMA,IAAmB,CAACC,MAAkC;AACjE,MAAI,CAACA,EAAO,QAAO;AAEnB,QAAMC,IAAI,SAAS,cAAc,KAAK;AACtC,EAAAA,EAAE,MAAM,QAAQD,GAChB,SAAS,KAAK,OAAOC,CAAC;AACtB,QAAMC,IAAW,WAAW,iBAAiBD,CAAC,EAAE,OAC1CE,IACJ,6DAA6D,KAAKD,CAAQ;AAI5E,SAFAD,EAAE,OAAA,GAEGE,IAEE,GAAGA,EAAM,CAAC,CAAC,KAAKA,EAAM,CAAC,CAAC,KAAKA,EAAM,CAAC,CAAC,KAFzB;AAGrB,GAEaC,IAAsB,CACjCC,GACAC,MACG;AACH,QAAMC,IAAMC,EAAUH,CAAS,GAEzBI,IAAI,SAAS,cAAc,GAAG;AACpC,EAAAA,EAAE,OAAOF,GAETE,EAAE,WAAWH,KAAY,QAEzBG,EAAE,SAAS,UAEX,SAAS,KAAK,OAAOA,CAAC,GAEtBA,EAAE,MAAA,GAEFA,EAAE,OAAA;AACJ;AAKO,SAASC,EAAkBC,GAAc;AAC9C,QAAMC,IAAQ,OAAOD,CAAI,EAAE,QAAQ,+BAA+B,MAAM;AACxE,SAAK,gBAAgB,KAAKA,CAAI,MAAGA,IAAO,UAAUA,CAAI,KAC/C,WAAWA,CAAI,oBAAoBC,CAAK;AACjD;AAEO,MAAMC,IAAmB,CAACC,MAAgC;AAC/D,MAAIC,IAAY,GACZC,IAAOF;AAEX,SAAOE,KAAQ;AACb,IAAAD,KAAaC,EAAK,WAClBA,IAAOA,EAAK;AAGd,SAAOD;AACT,GAEaE,IAAY,CAACC,OACxBA,EAAE,eAAA,GACFA,EAAE,gBAAA,GAEK,KAGIC,IAA2B,CAACH,MAAsB;AAC7D,QAAMI,IAAkB,SAAS,MAC3BC,IAAa,OAAO,aACpBC,IAAeN,EAAK,sBAAA,GACpBO,IAAmBH,EAAgB,eAAeC,GAElDG,IAAmB,KAAK;AAAA,IAC5B,KAAK,IAAIF,EAAa,MAAMD,GAAY,CAAC;AAAA,IACzCE;AAAA,EAAA;AAGF,SAAO,OAAO;AAAA,IACZ,KAAKC,IAAmBH;AAAA,IACxB,UAAU;AAAA,EAAA,CACX;AACH,GAEMI,IAAoC;AAAA,EACxC,cAAc;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,cAAc,CAAC,QAAQ,UAAU,QAAQ,OAAO,OAAO;AACzD,GAEaC,IAAe,CAACC,GAAqBC,MACzCC,EAAU,SAASF,KAAQ,IAAI;AAAA,EACpC,GAAGF;AAAA,EACH,GAAGG;AAAA,CACJ,GAGUE,IAAwB,CACnChB,GACAiB,MACG;AACH,MAAIf,IAAOF;AAEX,MAAI,CAACiB,EAAQ,QAAO;AAEpB,SAAOf,KAAQ,QAAM;AACnB,QAAIA,MAASe;AACX,aAAO;AAEP,IAAAf,IAAOA,EAAK;AAAA,EAEhB;AAEA,SAAO;AACT,GAUagB,IAA4B,CACvCC,GACAC,MACG;AACH,MAAI,SAAS,uBAAuB,CAACA,GAAQ;AAC3C,WAAO,SAAS,oBAAoBD,CAAE;AAExC,EAAAA,EAAA;AACF,GAKaE,IAAqB,MAAM;AACtC,QAAMC,IAAQ,SAAS,cAAc,KAAK;AAE1C,EAAAA,EAAM,MAAM,aAAa,UACzBA,EAAM,MAAM,QAAQ,SACpBA,EAAM,MAAM,WAAW,UAEvB,SAAS,KAAK,OAAOA,CAAK;AAE1B,QAAMC,IAAQ,SAAS,cAAc,KAAK;AAC1C,EAAAA,EAAM,MAAM,QAAQ,QAEpBD,EAAM,OAAOC,CAAK;AAElB,QAAMC,IAAiBF,EAAM,cAAcC,EAAM;AAEjD,SAAAD,EAAM,YAAY,YAAYA,CAAK,GAE5BE;AACT;AAKO,SAASC,EAAsBzB,GAAsB;AAC1D,QAAM,EAAE,cAAA0B,MAAiB1B,GACnB,EAAE,YAAA2B,GAAY,eAAAC,MAAkB,iBAAiB5B,CAAO;AAC9D,SACE0B,IACA,OAAO,WAAWC,CAAU,IAC5B,OAAO,WAAWC,CAAa;AAEnC;AAKO,SAASC,EAAqBC,GAAiB;AACpD,QAAM,EAAE,aAAAC,MAAgBD,GAClB,EAAE,aAAAE,GAAa,cAAAC,MAAiB,iBAAiBH,CAAE;AACzD,SACEC,IACA,OAAO,WAAWC,CAAW,IAC7B,OAAO,WAAWC,CAAY;AAElC;AAEO,MAAMC,IAAqB,MAChC,CAAC,CAAC,WAAW,aAAa,8BAA8B,GAAG,SAEhDC,IAAsB,MACjC,CAAC,CAAC,WAAW,aAAa,+BAA+B,GAAG;"}
|
package/id.cjs
CHANGED
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const nanoid_1 = require("nanoid");
|
|
5
|
-
const DIGITS = '0123456789';
|
|
6
|
-
const LATIN_CHARS = 'abcdefghijklmnopqrstuvwxyz';
|
|
7
|
-
const ALPHABET = `${LATIN_CHARS}${DIGITS}`;
|
|
8
|
-
/**
|
|
9
|
-
* Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789
|
|
10
|
-
* Размер 6
|
|
11
|
-
*/
|
|
12
|
-
exports.generateId = (0, nanoid_1.customAlphabet)(ALPHABET, 6);
|
|
13
|
-
/**
|
|
14
|
-
* Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789
|
|
15
|
-
* Размер 4
|
|
16
|
-
*/
|
|
17
|
-
exports.generateShortId = (0, nanoid_1.customAlphabet)(ALPHABET, 4);
|
|
18
|
-
/**
|
|
19
|
-
* Использует алфавит 0123456789
|
|
20
|
-
* Размер 6
|
|
21
|
-
*/
|
|
22
|
-
exports.generateNumericId = (0, nanoid_1.customAlphabet)(DIGITS, 6);
|
|
23
|
-
/**
|
|
24
|
-
* Использует алфавит 0123456789
|
|
25
|
-
* Размер 4
|
|
26
|
-
*/
|
|
27
|
-
exports.generateNumericShortId = (0, nanoid_1.customAlphabet)(DIGITS, 4);
|
|
28
|
-
/**
|
|
29
|
-
* Создает функцию, которая будет создавать уникальную строку, уникальность которой основана на порядке вызова этой функции
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* generateLinearNumericId = createLinearNumericIdGenerator(6);
|
|
34
|
-
* generateLinearNumericId() // '000000'
|
|
35
|
-
* generateLinearNumericId() // '000001'
|
|
36
|
-
* ...
|
|
37
|
-
* generateLinearNumericId() // '999999'
|
|
38
|
-
* generateLinearNumericId() // '1000000'
|
|
39
|
-
* ...
|
|
40
|
-
* generateLinearNumericId() // '9999999'
|
|
41
|
-
* generateLinearNumericId() // '10000000'
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @param size размер
|
|
45
|
-
* @returns {()=>string}
|
|
46
|
-
*/
|
|
47
|
-
const createLinearNumericIdGenerator = (size = 9) => {
|
|
48
|
-
let lastCount = 0;
|
|
49
|
-
return () => {
|
|
50
|
-
return (lastCount++).toString().padStart(size, '0');
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
exports.createLinearNumericIdGenerator = createLinearNumericIdGenerator;
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* generateLinearNumericId() // '000000000'
|
|
59
|
-
* generateLinearNumericId() // '000000001'
|
|
60
|
-
* ...
|
|
61
|
-
* generateLinearNumericId() // '999999999'
|
|
62
|
-
* generateLinearNumericId() // '1000000000'
|
|
63
|
-
* ...
|
|
64
|
-
* generateLinearNumericId() // '9999999999'
|
|
65
|
-
* generateLinearNumericId() // '10000000000'
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
*/
|
|
69
|
-
exports.generateLinearNumericId = (0, exports.createLinearNumericIdGenerator)();
|
|
70
|
-
/**
|
|
71
|
-
* Is not recommended to use.
|
|
72
|
-
*
|
|
73
|
-
* Generates execution stack based pseudo-id (just sliced string from error stack)
|
|
74
|
-
*/
|
|
75
|
-
const generateStackBasedId = () => new Error().stack.split('\n').slice(1, 4).join('');
|
|
76
|
-
exports.generateStackBasedId = generateStackBasedId;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("nanoid"),t="0123456789",o="abcdefghijklmnopqrstuvwxyz",r=`${o}${t}`,s=e.customAlphabet(r,6),i=e.customAlphabet(r,4),d=e.customAlphabet(t,6),u=e.customAlphabet(t,4),n=(a=9)=>{let c=0;return()=>(c++).toString().padStart(a,"0")},I=n(),g=()=>new Error().stack.split(`
|
|
2
|
+
`).slice(1,4).join("");exports.createLinearNumericIdGenerator=n;exports.generateId=s;exports.generateLinearNumericId=I;exports.generateNumericId=d;exports.generateNumericShortId=u;exports.generateShortId=i;exports.generateStackBasedId=g;
|
|
3
|
+
//# sourceMappingURL=id.cjs.map
|
package/id.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.cjs","sources":["../src/id.ts"],"sourcesContent":["import { customAlphabet } from 'nanoid';\n\nconst DIGITS = '0123456789';\nconst LATIN_CHARS = 'abcdefghijklmnopqrstuvwxyz';\n\nconst ALPHABET = `${LATIN_CHARS}${DIGITS}`;\n\n/**\n * Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789\n * Размер 6\n */\nexport const generateId = customAlphabet(ALPHABET, 6);\n\n/**\n * Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789\n * Размер 4\n */\nexport const generateShortId = customAlphabet(ALPHABET, 4);\n\n/**\n * Использует алфавит 0123456789\n * Размер 6\n */\nexport const generateNumericId = customAlphabet(DIGITS, 6);\n\n/**\n * Использует алфавит 0123456789\n * Размер 4\n */\nexport const generateNumericShortId = customAlphabet(DIGITS, 4);\n\n/**\n * Создает функцию, которая будет создавать уникальную строку, уникальность которой основана на порядке вызова этой функции\n *\n * @example\n * ```ts\n * generateLinearNumericId = createLinearNumericIdGenerator(6);\n * generateLinearNumericId() // '000000'\n * generateLinearNumericId() // '000001'\n * ...\n * generateLinearNumericId() // '999999'\n * generateLinearNumericId() // '1000000'\n * ...\n * generateLinearNumericId() // '9999999'\n * generateLinearNumericId() // '10000000'\n * ```\n *\n * @param size размер\n * @returns {()=>string}\n */\nexport const createLinearNumericIdGenerator = (size: number = 9) => {\n let lastCount = 0;\n return () => {\n return (lastCount++).toString().padStart(size, '0');\n };\n};\n\n/**\n *\n * @example\n * ```ts\n * generateLinearNumericId() // '000000000'\n * generateLinearNumericId() // '000000001'\n * ...\n * generateLinearNumericId() // '999999999'\n * generateLinearNumericId() // '1000000000'\n * ...\n * generateLinearNumericId() // '9999999999'\n * generateLinearNumericId() // '10000000000'\n * ```\n *\n */\nexport const generateLinearNumericId = createLinearNumericIdGenerator();\n\n/**\n * Is not recommended to use.\n *\n * Generates execution stack based pseudo-id (just sliced string from error stack)\n */\nexport const generateStackBasedId = () =>\n new Error().stack!.split('\\n').slice(1, 4).join('');\n"],"names":["DIGITS","LATIN_CHARS","ALPHABET","generateId","customAlphabet","generateShortId","generateNumericId","generateNumericShortId","createLinearNumericIdGenerator","size","lastCount","generateLinearNumericId","generateStackBasedId"],"mappings":"0GAEMA,EAAS,aACTC,EAAc,6BAEdC,EAAW,GAAGD,CAAW,GAAGD,CAAM,GAM3BG,EAAaC,EAAAA,eAAeF,EAAU,CAAC,EAMvCG,EAAkBD,EAAAA,eAAeF,EAAU,CAAC,EAM5CI,EAAoBF,EAAAA,eAAeJ,EAAQ,CAAC,EAM5CO,EAAyBH,EAAAA,eAAeJ,EAAQ,CAAC,EAqBjDQ,EAAiC,CAACC,EAAe,IAAM,CAClE,IAAIC,EAAY,EAChB,MAAO,KACGA,KAAa,SAAA,EAAW,SAASD,EAAM,GAAG,CAEtD,EAiBaE,EAA0BH,EAAA,EAO1BI,EAAuB,IAClC,IAAI,MAAA,EAAQ,MAAO,MAAM;AAAA,CAAI,EAAE,MAAM,EAAG,CAAC,EAAE,KAAK,EAAE"}
|
package/id.js
CHANGED
|
@@ -1,71 +1,16 @@
|
|
|
1
|
-
import { customAlphabet } from
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Использует алфавит 0123456789
|
|
17
|
-
* Размер 6
|
|
18
|
-
*/
|
|
19
|
-
export const generateNumericId = customAlphabet(DIGITS, 6);
|
|
20
|
-
/**
|
|
21
|
-
* Использует алфавит 0123456789
|
|
22
|
-
* Размер 4
|
|
23
|
-
*/
|
|
24
|
-
export const generateNumericShortId = customAlphabet(DIGITS, 4);
|
|
25
|
-
/**
|
|
26
|
-
* Создает функцию, которая будет создавать уникальную строку, уникальность которой основана на порядке вызова этой функции
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* generateLinearNumericId = createLinearNumericIdGenerator(6);
|
|
31
|
-
* generateLinearNumericId() // '000000'
|
|
32
|
-
* generateLinearNumericId() // '000001'
|
|
33
|
-
* ...
|
|
34
|
-
* generateLinearNumericId() // '999999'
|
|
35
|
-
* generateLinearNumericId() // '1000000'
|
|
36
|
-
* ...
|
|
37
|
-
* generateLinearNumericId() // '9999999'
|
|
38
|
-
* generateLinearNumericId() // '10000000'
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @param size размер
|
|
42
|
-
* @returns {()=>string}
|
|
43
|
-
*/
|
|
44
|
-
export const createLinearNumericIdGenerator = (size = 9) => {
|
|
45
|
-
let lastCount = 0;
|
|
46
|
-
return () => {
|
|
47
|
-
return (lastCount++).toString().padStart(size, '0');
|
|
48
|
-
};
|
|
1
|
+
import { customAlphabet as e } from "nanoid";
|
|
2
|
+
const t = "0123456789", c = "abcdefghijklmnopqrstuvwxyz", r = `${c}${t}`, i = e(r, 6), d = e(r, 4), I = e(t, 6), u = e(t, 4), a = (n = 9) => {
|
|
3
|
+
let o = 0;
|
|
4
|
+
return () => (o++).toString().padStart(n, "0");
|
|
5
|
+
}, g = a(), m = () => new Error().stack.split(`
|
|
6
|
+
`).slice(1, 4).join("");
|
|
7
|
+
export {
|
|
8
|
+
a as createLinearNumericIdGenerator,
|
|
9
|
+
i as generateId,
|
|
10
|
+
g as generateLinearNumericId,
|
|
11
|
+
I as generateNumericId,
|
|
12
|
+
u as generateNumericShortId,
|
|
13
|
+
d as generateShortId,
|
|
14
|
+
m as generateStackBasedId
|
|
49
15
|
};
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* generateLinearNumericId() // '000000000'
|
|
55
|
-
* generateLinearNumericId() // '000000001'
|
|
56
|
-
* ...
|
|
57
|
-
* generateLinearNumericId() // '999999999'
|
|
58
|
-
* generateLinearNumericId() // '1000000000'
|
|
59
|
-
* ...
|
|
60
|
-
* generateLinearNumericId() // '9999999999'
|
|
61
|
-
* generateLinearNumericId() // '10000000000'
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
export const generateLinearNumericId = createLinearNumericIdGenerator();
|
|
66
|
-
/**
|
|
67
|
-
* Is not recommended to use.
|
|
68
|
-
*
|
|
69
|
-
* Generates execution stack based pseudo-id (just sliced string from error stack)
|
|
70
|
-
*/
|
|
71
|
-
export const generateStackBasedId = () => new Error().stack.split('\n').slice(1, 4).join('');
|
|
16
|
+
//# sourceMappingURL=id.js.map
|
package/id.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","sources":["../src/id.ts"],"sourcesContent":["import { customAlphabet } from 'nanoid';\n\nconst DIGITS = '0123456789';\nconst LATIN_CHARS = 'abcdefghijklmnopqrstuvwxyz';\n\nconst ALPHABET = `${LATIN_CHARS}${DIGITS}`;\n\n/**\n * Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789\n * Размер 6\n */\nexport const generateId = customAlphabet(ALPHABET, 6);\n\n/**\n * Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789\n * Размер 4\n */\nexport const generateShortId = customAlphabet(ALPHABET, 4);\n\n/**\n * Использует алфавит 0123456789\n * Размер 6\n */\nexport const generateNumericId = customAlphabet(DIGITS, 6);\n\n/**\n * Использует алфавит 0123456789\n * Размер 4\n */\nexport const generateNumericShortId = customAlphabet(DIGITS, 4);\n\n/**\n * Создает функцию, которая будет создавать уникальную строку, уникальность которой основана на порядке вызова этой функции\n *\n * @example\n * ```ts\n * generateLinearNumericId = createLinearNumericIdGenerator(6);\n * generateLinearNumericId() // '000000'\n * generateLinearNumericId() // '000001'\n * ...\n * generateLinearNumericId() // '999999'\n * generateLinearNumericId() // '1000000'\n * ...\n * generateLinearNumericId() // '9999999'\n * generateLinearNumericId() // '10000000'\n * ```\n *\n * @param size размер\n * @returns {()=>string}\n */\nexport const createLinearNumericIdGenerator = (size: number = 9) => {\n let lastCount = 0;\n return () => {\n return (lastCount++).toString().padStart(size, '0');\n };\n};\n\n/**\n *\n * @example\n * ```ts\n * generateLinearNumericId() // '000000000'\n * generateLinearNumericId() // '000000001'\n * ...\n * generateLinearNumericId() // '999999999'\n * generateLinearNumericId() // '1000000000'\n * ...\n * generateLinearNumericId() // '9999999999'\n * generateLinearNumericId() // '10000000000'\n * ```\n *\n */\nexport const generateLinearNumericId = createLinearNumericIdGenerator();\n\n/**\n * Is not recommended to use.\n *\n * Generates execution stack based pseudo-id (just sliced string from error stack)\n */\nexport const generateStackBasedId = () =>\n new Error().stack!.split('\\n').slice(1, 4).join('');\n"],"names":["DIGITS","LATIN_CHARS","ALPHABET","generateId","customAlphabet","generateShortId","generateNumericId","generateNumericShortId","createLinearNumericIdGenerator","size","lastCount","generateLinearNumericId","generateStackBasedId"],"mappings":";AAEA,MAAMA,IAAS,cACTC,IAAc,8BAEdC,IAAW,GAAGD,CAAW,GAAGD,CAAM,IAM3BG,IAAaC,EAAeF,GAAU,CAAC,GAMvCG,IAAkBD,EAAeF,GAAU,CAAC,GAM5CI,IAAoBF,EAAeJ,GAAQ,CAAC,GAM5CO,IAAyBH,EAAeJ,GAAQ,CAAC,GAqBjDQ,IAAiC,CAACC,IAAe,MAAM;AAClE,MAAIC,IAAY;AAChB,SAAO,OACGA,KAAa,SAAA,EAAW,SAASD,GAAM,GAAG;AAEtD,GAiBaE,IAA0BH,EAAA,GAO1BI,IAAuB,MAClC,IAAI,MAAA,EAAQ,MAAO,MAAM;AAAA,CAAI,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE;"}
|
package/imports.cjs
CHANGED
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.unpackAsyncModule = exports.fetchLazyModule = void 0;
|
|
4
|
-
const async_js_1 = require("./async.cjs");
|
|
5
|
-
/**
|
|
6
|
-
* Функция ленивой загрузки модуля, с возможностью вызова доп. попыток
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* fetchLazyModule(() => import("./test.ts"), 3) // начнет загрузку test.ts
|
|
10
|
-
* // Произошла ошибка загрузки test.ts, тогда fetchLazyModule повторно вызовет fn()
|
|
11
|
-
* // Вызывать будет столько раз сколько указано attempts (по умолчанию 3)
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
const fetchLazyModule = async (fetchModule, attempts = 3, delay = 1000) => {
|
|
15
|
-
const attemptsArray = Array.from({
|
|
16
|
-
length: attempts,
|
|
17
|
-
}).fill(fetchModule);
|
|
18
|
-
let lastError = null;
|
|
19
|
-
for await (const attempt of attemptsArray) {
|
|
20
|
-
try {
|
|
21
|
-
if (lastError !== null) {
|
|
22
|
-
await (0, async_js_1.sleep)(delay);
|
|
23
|
-
}
|
|
24
|
-
return await attempt();
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
lastError = error;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
throw lastError;
|
|
31
|
-
};
|
|
32
|
-
exports.fetchLazyModule = fetchLazyModule;
|
|
33
|
-
const unpackAsyncModule = async (maybeModule) => {
|
|
34
|
-
if (maybeModule instanceof Promise) {
|
|
35
|
-
const data = (await maybeModule);
|
|
36
|
-
if (data.default) {
|
|
37
|
-
return data.default;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return maybeModule;
|
|
44
|
-
};
|
|
45
|
-
exports.unpackAsyncModule = unpackAsyncModule;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("yummies/async"),l=async(t,e=3,a=1e3)=>{const n=Array.from({length:e}).fill(t);let r=null;for await(const c of n)try{return r!==null&&await s.sleep(a),await c()}catch(o){r=o}throw r},u=async t=>{if(t instanceof Promise){const e=await t;return e.default?e.default:e}return t};exports.fetchLazyModule=l;exports.unpackAsyncModule=u;
|
|
2
|
+
//# sourceMappingURL=imports.cjs.map
|
package/imports.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.cjs","sources":["../src/imports.ts"],"sourcesContent":["import { sleep } from 'yummies/async';\n\n/**\n * Функция ленивой загрузки модуля, с возможностью вызова доп. попыток\n * @example\n * ```ts\n * fetchLazyModule(() => import(\"./test.ts\"), 3) // начнет загрузку test.ts\n * // Произошла ошибка загрузки test.ts, тогда fetchLazyModule повторно вызовет fn()\n * // Вызывать будет столько раз сколько указано attempts (по умолчанию 3)\n * ```\n */\nexport const fetchLazyModule = async <T>(\n fetchModule: () => Promise<T>,\n attempts = 3,\n delay = 1000,\n): Promise<T> => {\n const attemptsArray = Array.from<typeof fetchModule>({\n length: attempts,\n }).fill(fetchModule);\n\n let lastError: null | Error = null;\n\n for await (const attempt of attemptsArray) {\n try {\n if (lastError !== null) {\n await sleep(delay);\n }\n return await attempt();\n } catch (error) {\n lastError = error as Error;\n }\n }\n throw lastError;\n};\n\nexport type PackedAsyncModule<T> = Promise<T | { default: T }>;\n\nexport const unpackAsyncModule = async <T>(\n maybeModule: T | PackedAsyncModule<T>,\n): Promise<T> => {\n if (maybeModule instanceof Promise) {\n const data = (await maybeModule) as any;\n\n if ((data as any).default) {\n return (data as any).default;\n } else {\n return data;\n }\n }\n\n return maybeModule;\n};\n"],"names":["fetchLazyModule","fetchModule","attempts","delay","attemptsArray","lastError","attempt","sleep","error","unpackAsyncModule","maybeModule","data"],"mappings":"iHAWaA,EAAkB,MAC7BC,EACAC,EAAW,EACXC,EAAQ,MACO,CACf,MAAMC,EAAgB,MAAM,KAAyB,CACnD,OAAQF,CAAA,CACT,EAAE,KAAKD,CAAW,EAEnB,IAAII,EAA0B,KAE9B,gBAAiBC,KAAWF,EAC1B,GAAI,CACF,OAAIC,IAAc,MAChB,MAAME,EAAAA,MAAMJ,CAAK,EAEZ,MAAMG,EAAA,CACf,OAASE,EAAO,CACdH,EAAYG,CACd,CAEF,MAAMH,CACR,EAIaI,EAAoB,MAC/BC,GACe,CACf,GAAIA,aAAuB,QAAS,CAClC,MAAMC,EAAQ,MAAMD,EAEpB,OAAKC,EAAa,QACRA,EAAa,QAEdA,CAEX,CAEA,OAAOD,CACT"}
|
package/imports.js
CHANGED
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import { sleep } from "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const attemptsArray = Array.from({
|
|
13
|
-
length: attempts,
|
|
14
|
-
}).fill(fetchModule);
|
|
15
|
-
let lastError = null;
|
|
16
|
-
for await (const attempt of attemptsArray) {
|
|
17
|
-
try {
|
|
18
|
-
if (lastError !== null) {
|
|
19
|
-
await sleep(delay);
|
|
20
|
-
}
|
|
21
|
-
return await attempt();
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
lastError = error;
|
|
25
|
-
}
|
|
1
|
+
import { sleep as c } from "yummies/async";
|
|
2
|
+
const f = async (t, r = 3, e = 1e3) => {
|
|
3
|
+
const n = Array.from({
|
|
4
|
+
length: r
|
|
5
|
+
}).fill(t);
|
|
6
|
+
let a = null;
|
|
7
|
+
for await (const o of n)
|
|
8
|
+
try {
|
|
9
|
+
return a !== null && await c(e), await o();
|
|
10
|
+
} catch (s) {
|
|
11
|
+
a = s;
|
|
26
12
|
}
|
|
27
|
-
|
|
13
|
+
throw a;
|
|
14
|
+
}, i = async (t) => {
|
|
15
|
+
if (t instanceof Promise) {
|
|
16
|
+
const r = await t;
|
|
17
|
+
return r.default ? r.default : r;
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
28
20
|
};
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (data.default) {
|
|
33
|
-
return data.default;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return data;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return maybeModule;
|
|
21
|
+
export {
|
|
22
|
+
f as fetchLazyModule,
|
|
23
|
+
i as unpackAsyncModule
|
|
40
24
|
};
|
|
25
|
+
//# sourceMappingURL=imports.js.map
|
package/imports.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sources":["../src/imports.ts"],"sourcesContent":["import { sleep } from 'yummies/async';\n\n/**\n * Функция ленивой загрузки модуля, с возможностью вызова доп. попыток\n * @example\n * ```ts\n * fetchLazyModule(() => import(\"./test.ts\"), 3) // начнет загрузку test.ts\n * // Произошла ошибка загрузки test.ts, тогда fetchLazyModule повторно вызовет fn()\n * // Вызывать будет столько раз сколько указано attempts (по умолчанию 3)\n * ```\n */\nexport const fetchLazyModule = async <T>(\n fetchModule: () => Promise<T>,\n attempts = 3,\n delay = 1000,\n): Promise<T> => {\n const attemptsArray = Array.from<typeof fetchModule>({\n length: attempts,\n }).fill(fetchModule);\n\n let lastError: null | Error = null;\n\n for await (const attempt of attemptsArray) {\n try {\n if (lastError !== null) {\n await sleep(delay);\n }\n return await attempt();\n } catch (error) {\n lastError = error as Error;\n }\n }\n throw lastError;\n};\n\nexport type PackedAsyncModule<T> = Promise<T | { default: T }>;\n\nexport const unpackAsyncModule = async <T>(\n maybeModule: T | PackedAsyncModule<T>,\n): Promise<T> => {\n if (maybeModule instanceof Promise) {\n const data = (await maybeModule) as any;\n\n if ((data as any).default) {\n return (data as any).default;\n } else {\n return data;\n }\n }\n\n return maybeModule;\n};\n"],"names":["fetchLazyModule","fetchModule","attempts","delay","attemptsArray","lastError","attempt","sleep","error","unpackAsyncModule","maybeModule","data"],"mappings":";AAWO,MAAMA,IAAkB,OAC7BC,GACAC,IAAW,GACXC,IAAQ,QACO;AACf,QAAMC,IAAgB,MAAM,KAAyB;AAAA,IACnD,QAAQF;AAAA,EAAA,CACT,EAAE,KAAKD,CAAW;AAEnB,MAAII,IAA0B;AAE9B,mBAAiBC,KAAWF;AAC1B,QAAI;AACF,aAAIC,MAAc,QAChB,MAAME,EAAMJ,CAAK,GAEZ,MAAMG,EAAA;AAAA,IACf,SAASE,GAAO;AACd,MAAAH,IAAYG;AAAA,IACd;AAEF,QAAMH;AACR,GAIaI,IAAoB,OAC/BC,MACe;AACf,MAAIA,aAAuB,SAAS;AAClC,UAAMC,IAAQ,MAAMD;AAEpB,WAAKC,EAAa,UACRA,EAAa,UAEdA;AAAA,EAEX;AAEA,SAAOD;AACT;"}
|