yummies 5.4.7 → 5.4.9
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 +70 -0
- package/async.d.cts +28 -0
- package/async.d.cts.map +1 -0
- package/common.cjs +18 -0
- package/common.d.cts +15 -0
- package/common.d.cts.map +1 -0
- package/common.d.ts +1 -1
- package/common.d.ts.map +1 -1
- package/complex/counter.cjs +21 -0
- package/complex/counter.d.cts +15 -0
- package/complex/counter.d.cts.map +1 -0
- package/complex/global-config.cjs +46 -0
- package/complex/global-config.d.cts +11 -0
- package/complex/global-config.d.cts.map +1 -0
- package/complex/global-config.d.ts +1 -1
- package/complex/global-config.d.ts.map +1 -1
- package/complex/index.cjs +19 -0
- package/complex/index.d.cts +4 -0
- package/complex/index.d.cts.map +1 -0
- package/complex/index.d.ts +3 -3
- package/complex/index.d.ts.map +1 -1
- package/complex/index.js +3 -3
- package/complex/modules-factory.cjs +50 -0
- package/complex/modules-factory.d.cts +49 -0
- package/complex/modules-factory.d.cts.map +1 -0
- package/complex/modules-factory.d.ts +1 -1
- package/complex/modules-factory.d.ts.map +1 -1
- package/cookie.cjs +13 -0
- package/cookie.d.cts +3 -0
- package/cookie.d.cts.map +1 -0
- package/cookie.d.ts +1 -1
- package/cookie.d.ts.map +1 -1
- package/css.cjs +28 -0
- package/css.d.cts +36 -0
- package/css.d.cts.map +1 -0
- package/data.cjs +58 -0
- package/data.d.cts +4 -0
- package/data.d.cts.map +1 -0
- package/date-time.cjs +171 -0
- package/date-time.d.cts +28 -0
- package/date-time.d.cts.map +1 -0
- package/date-time.d.ts +1 -1
- package/date-time.d.ts.map +1 -1
- package/date-time.js +4 -4
- package/device.cjs +28 -0
- package/device.d.cts +8 -0
- package/device.d.cts.map +1 -0
- package/encodings.cjs +270 -0
- package/encodings.d.cts +2 -0
- package/encodings.d.cts.map +1 -0
- package/errors.cjs +34 -0
- package/errors.d.cts +19 -0
- package/errors.d.cts.map +1 -0
- package/errors.d.ts +1 -1
- package/errors.d.ts.map +1 -1
- package/errors.js +1 -1
- package/file.cjs +29 -0
- package/file.d.cts +3 -0
- package/file.d.cts.map +1 -0
- package/format/_exports.cjs +20 -0
- package/format/_exports.d.cts +5 -0
- package/format/_exports.d.cts.map +1 -0
- package/format/_exports.d.ts +4 -4
- package/format/_exports.d.ts.map +1 -1
- package/format/_exports.js +4 -4
- package/format/constants.cjs +6 -0
- package/format/constants.d.cts +4 -0
- package/format/constants.d.cts.map +1 -0
- package/format/index.cjs +40 -0
- package/format/index.d.cts +3 -0
- package/format/index.d.cts.map +1 -0
- package/format/index.d.ts +1 -1
- package/format/index.d.ts.map +1 -1
- package/format/index.js +1 -1
- package/format/number.cjs +48 -0
- package/format/number.d.cts +36 -0
- package/format/number.d.cts.map +1 -0
- package/format/number.d.ts +1 -1
- package/format/number.d.ts.map +1 -1
- package/format/number.js +3 -3
- package/format/percent.cjs +27 -0
- package/format/percent.d.cts +15 -0
- package/format/percent.d.cts.map +1 -0
- package/format/percent.d.ts +2 -2
- package/format/percent.d.ts.map +1 -1
- package/format/percent.js +3 -3
- package/format/skip-spaces.cjs +8 -0
- package/format/skip-spaces.d.cts +5 -0
- package/format/skip-spaces.d.cts.map +1 -0
- package/html.cjs +202 -0
- package/html.d.cts +44 -0
- package/html.d.cts.map +1 -0
- package/html.d.ts +1 -1
- package/html.d.ts.map +1 -1
- package/html.js +1 -1
- package/id.cjs +76 -0
- package/id.d.cts +63 -0
- package/id.d.cts.map +1 -0
- package/imports.cjs +45 -0
- package/imports.d.cts +15 -0
- package/imports.d.cts.map +1 -0
- package/imports.js +1 -1
- package/math.cjs +23 -0
- package/math.d.cts +13 -0
- package/math.d.cts.map +1 -0
- package/math.d.ts +1 -1
- package/math.d.ts.map +1 -1
- package/media.cjs +115 -0
- package/media.d.cts +20 -0
- package/media.d.cts.map +1 -0
- package/media.js +1 -1
- package/mobx/apply-observable.cjs +16 -0
- package/mobx/apply-observable.d.cts +4 -0
- package/mobx/apply-observable.d.cts.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.cjs +16 -0
- package/mobx/create-enhanced-atom.d.cts +11 -0
- package/mobx/create-enhanced-atom.d.cts.map +1 -0
- package/mobx/create-enhanced-atom.d.ts +1 -1
- package/mobx/create-enhanced-atom.d.ts.map +1 -1
- package/mobx/deep-observable-struct.cjs +61 -0
- package/mobx/deep-observable-struct.d.cts +7 -0
- package/mobx/deep-observable-struct.d.cts.map +1 -0
- package/mobx/deep-observable-struct.d.ts +1 -1
- package/mobx/deep-observable-struct.d.ts.map +1 -1
- package/mobx/deep-observable-struct.js +1 -1
- package/mobx/get-mobx-administration.cjs +6 -0
- package/mobx/get-mobx-administration.d.cts +6 -0
- package/mobx/get-mobx-administration.d.cts.map +1 -0
- package/mobx/get-mobx-administration.d.ts +1 -1
- package/mobx/get-mobx-administration.d.ts.map +1 -1
- package/mobx/index.cjs +21 -0
- package/mobx/index.d.cts +6 -0
- package/mobx/index.d.cts.map +1 -0
- package/mobx/index.d.ts +5 -5
- package/mobx/index.d.ts.map +1 -1
- package/mobx/index.js +5 -5
- package/mobx/lazy-observe.cjs +47 -0
- package/mobx/lazy-observe.d.cts +8 -0
- package/mobx/lazy-observe.d.cts.map +1 -0
- package/ms.cjs +22 -0
- package/ms.d.cts +19 -0
- package/ms.d.cts.map +1 -0
- package/number.cjs +16 -0
- package/number.d.cts +8 -0
- package/number.d.cts.map +1 -0
- package/package.json +97 -331
- package/parser/_exports.cjs +19 -0
- package/parser/_exports.d.cts +4 -0
- package/parser/_exports.d.cts.map +1 -0
- package/parser/_exports.d.ts +3 -3
- package/parser/_exports.d.ts.map +1 -1
- package/parser/_exports.js +3 -3
- package/parser/index.cjs +40 -0
- package/parser/index.d.cts +3 -0
- package/parser/index.d.cts.map +1 -0
- package/parser/index.d.ts +1 -1
- package/parser/index.d.ts.map +1 -1
- package/parser/index.js +1 -1
- package/parser/number.cjs +48 -0
- package/parser/number.d.cts +21 -0
- package/parser/number.d.cts.map +1 -0
- package/parser/number.d.ts +1 -1
- package/parser/number.d.ts.map +1 -1
- package/parser/number.js +2 -2
- package/parser/percent.cjs +8 -0
- package/parser/percent.d.cts +4 -0
- package/parser/percent.d.cts.map +1 -0
- package/parser/percent.d.ts +2 -2
- package/parser/percent.d.ts.map +1 -1
- package/parser/percent.js +1 -1
- package/parser/string.cjs +18 -0
- package/parser/string.d.cts +7 -0
- package/parser/string.d.cts.map +1 -0
- package/parser/string.d.ts +1 -1
- package/parser/string.d.ts.map +1 -1
- package/parser/string.js +1 -1
- package/price.cjs +21 -0
- package/price.d.cts +6 -0
- package/price.d.cts.map +1 -0
- package/random.cjs +25 -0
- package/random.d.cts +9 -0
- package/random.d.cts.map +1 -0
- package/react/hooks/index.cjs +37 -0
- package/react/hooks/index.d.cts +22 -0
- package/react/hooks/index.d.cts.map +1 -0
- package/react/hooks/index.d.ts +21 -21
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +21 -21
- package/react/hooks/use-abort-controller.cjs +15 -0
- package/react/hooks/use-abort-controller.d.cts +2 -0
- package/react/hooks/use-abort-controller.d.cts.map +1 -0
- package/react/hooks/use-abort-controller.js +1 -1
- package/react/hooks/use-abort-signal.cjs +8 -0
- package/react/hooks/use-abort-signal.d.cts +2 -0
- package/react/hooks/use-abort-signal.d.cts.map +1 -0
- package/react/hooks/use-abort-signal.js +1 -1
- package/react/hooks/use-click-outside.cjs +17 -0
- package/react/hooks/use-click-outside.d.cts +9 -0
- package/react/hooks/use-click-outside.d.cts.map +1 -0
- package/react/hooks/use-click-outside.js +1 -1
- package/react/hooks/use-constant.cjs +19 -0
- package/react/hooks/use-constant.d.cts +9 -0
- package/react/hooks/use-constant.d.cts.map +1 -0
- package/react/hooks/use-define-ref.cjs +19 -0
- package/react/hooks/use-define-ref.d.cts +10 -0
- package/react/hooks/use-define-ref.d.cts.map +1 -0
- package/react/hooks/use-element-ref.cjs +12 -0
- package/react/hooks/use-element-ref.d.cts +2 -0
- package/react/hooks/use-element-ref.d.cts.map +1 -0
- package/react/hooks/use-event-listener.cjs +17 -0
- package/react/hooks/use-event-listener.d.cts +8 -0
- package/react/hooks/use-event-listener.d.cts.map +1 -0
- package/react/hooks/use-event-listener.js +1 -1
- package/react/hooks/use-event.cjs +23 -0
- package/react/hooks/use-event.d.cts +3 -0
- package/react/hooks/use-event.d.cts.map +1 -0
- package/react/hooks/use-event.d.ts +1 -1
- package/react/hooks/use-event.d.ts.map +1 -1
- package/react/hooks/use-flag.cjs +19 -0
- package/react/hooks/use-flag.d.cts +8 -0
- package/react/hooks/use-flag.d.cts.map +1 -0
- package/react/hooks/use-force-update.cjs +11 -0
- package/react/hooks/use-force-update.d.cts +2 -0
- package/react/hooks/use-force-update.d.cts.map +1 -0
- package/react/hooks/use-initial-height.cjs +15 -0
- package/react/hooks/use-initial-height.d.cts +5 -0
- package/react/hooks/use-initial-height.d.cts.map +1 -0
- package/react/hooks/use-instance.cjs +31 -0
- package/react/hooks/use-instance.d.cts +27 -0
- package/react/hooks/use-instance.d.cts.map +1 -0
- package/react/hooks/use-instance.js +2 -2
- package/react/hooks/use-intersection-observer.cjs +14 -0
- package/react/hooks/use-intersection-observer.d.cts +2 -0
- package/react/hooks/use-intersection-observer.d.cts.map +1 -0
- package/react/hooks/use-last-defined-value.cjs +12 -0
- package/react/hooks/use-last-defined-value.d.cts +2 -0
- package/react/hooks/use-last-defined-value.d.cts.map +1 -0
- package/react/hooks/use-last-value-ref.cjs +12 -0
- package/react/hooks/use-last-value-ref.d.cts +2 -0
- package/react/hooks/use-last-value-ref.d.cts.map +1 -0
- package/react/hooks/use-life-cycle.cjs +14 -0
- package/react/hooks/use-life-cycle.d.cts +5 -0
- package/react/hooks/use-life-cycle.d.cts.map +1 -0
- package/react/hooks/use-life-cycle.js +1 -1
- package/react/hooks/use-resize-observer.cjs +15 -0
- package/react/hooks/use-resize-observer.d.cts +2 -0
- package/react/hooks/use-resize-observer.d.cts.map +1 -0
- package/react/hooks/use-resize-observer.js +1 -1
- package/react/hooks/use-sync-ref.cjs +10 -0
- package/react/hooks/use-sync-ref.d.cts +2 -0
- package/react/hooks/use-sync-ref.d.cts.map +1 -0
- package/react/hooks/use-toggle.cjs +10 -0
- package/react/hooks/use-toggle.d.cts +2 -0
- package/react/hooks/use-toggle.d.cts.map +1 -0
- package/react/hooks/use-value.cjs +12 -0
- package/react/hooks/use-value.d.cts +5 -0
- package/react/hooks/use-value.d.cts.map +1 -0
- package/react/hooks/use-visibility-state.cjs +18 -0
- package/react/hooks/use-visibility-state.d.cts +2 -0
- package/react/hooks/use-visibility-state.d.cts.map +1 -0
- package/react/index.cjs +17 -0
- package/react/index.d.cts +2 -0
- package/react/index.d.cts.map +1 -0
- package/react/index.d.ts +1 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -1
- package/sound.cjs +16 -0
- package/sound.d.cts +7 -0
- package/sound.d.cts.map +1 -0
- package/storage.cjs +48 -0
- package/storage.d.cts +39 -0
- package/storage.d.cts.map +1 -0
- package/text.cjs +53 -0
- package/text.d.cts +15 -0
- package/text.d.cts.map +1 -0
- package/type-guard/_exports.cjs +129 -0
- package/type-guard/_exports.d.cts +86 -0
- package/type-guard/_exports.d.cts.map +1 -0
- package/type-guard/_exports.d.ts +1 -1
- package/type-guard/_exports.d.ts.map +1 -1
- package/type-guard/index.cjs +40 -0
- package/type-guard/index.d.cts +3 -0
- package/type-guard/index.d.cts.map +1 -0
- package/type-guard/index.d.ts +1 -1
- package/type-guard/index.d.ts.map +1 -1
- package/type-guard/index.js +1 -1
- package/utility-types.d.ts +1 -0
- package/utils/types.cjs +2 -0
- package/utils/types.d.cts +395 -0
- package/utils/types.d.cts.map +1 -0
- package/vibrate.cjs +12 -0
- package/vibrate.d.cts +5 -0
- package/vibrate.d.cts.map +1 -0
- package/assets/logo.png +0 -0
- package/assets/logo.pxz +0 -0
package/id.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateStackBasedId = exports.generateLinearNumericId = exports.createLinearNumericIdGenerator = exports.generateNumericShortId = exports.generateNumericId = exports.generateShortId = exports.generateId = void 0;
|
|
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;
|
package/id.d.cts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789
|
|
3
|
+
* Размер 6
|
|
4
|
+
*/
|
|
5
|
+
export declare const generateId: (size?: number) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Использует алфавит abcdefghijklmnopqrstuvwxyz0123456789
|
|
8
|
+
* Размер 4
|
|
9
|
+
*/
|
|
10
|
+
export declare const generateShortId: (size?: number) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Использует алфавит 0123456789
|
|
13
|
+
* Размер 6
|
|
14
|
+
*/
|
|
15
|
+
export declare const generateNumericId: (size?: number) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Использует алфавит 0123456789
|
|
18
|
+
* Размер 4
|
|
19
|
+
*/
|
|
20
|
+
export declare const generateNumericShortId: (size?: number) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Создает функцию, которая будет создавать уникальную строку, уникальность которой основана на порядке вызова этой функции
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* generateLinearNumericId = createLinearNumericIdGenerator(6);
|
|
27
|
+
* generateLinearNumericId() // '000000'
|
|
28
|
+
* generateLinearNumericId() // '000001'
|
|
29
|
+
* ...
|
|
30
|
+
* generateLinearNumericId() // '999999'
|
|
31
|
+
* generateLinearNumericId() // '1000000'
|
|
32
|
+
* ...
|
|
33
|
+
* generateLinearNumericId() // '9999999'
|
|
34
|
+
* generateLinearNumericId() // '10000000'
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param size размер
|
|
38
|
+
* @returns {()=>string}
|
|
39
|
+
*/
|
|
40
|
+
export declare const createLinearNumericIdGenerator: (size?: number) => () => string;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* generateLinearNumericId() // '000000000'
|
|
46
|
+
* generateLinearNumericId() // '000000001'
|
|
47
|
+
* ...
|
|
48
|
+
* generateLinearNumericId() // '999999999'
|
|
49
|
+
* generateLinearNumericId() // '1000000000'
|
|
50
|
+
* ...
|
|
51
|
+
* generateLinearNumericId() // '9999999999'
|
|
52
|
+
* generateLinearNumericId() // '10000000000'
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
export declare const generateLinearNumericId: () => string;
|
|
57
|
+
/**
|
|
58
|
+
* Is not recommended to use.
|
|
59
|
+
*
|
|
60
|
+
* Generates execution stack based pseudo-id (just sliced string from error stack)
|
|
61
|
+
*/
|
|
62
|
+
export declare const generateStackBasedId: () => string;
|
|
63
|
+
//# sourceMappingURL=id.d.ts.map
|
package/id.d.cts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../src/id.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,eAAO,MAAM,UAAU,2BAA8B,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,eAAe,2BAA8B,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2BAA4B,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,2BAA4B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,8BAA8B,GAAI,OAAM,MAAU,iBAK9D,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,cAAmC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,cACoB,CAAC"}
|
package/imports.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
package/imports.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Функция ленивой загрузки модуля, с возможностью вызова доп. попыток
|
|
3
|
+
* @example
|
|
4
|
+
* ```ts
|
|
5
|
+
* fetchLazyModule(() => import("./test.ts"), 3) // начнет загрузку test.ts
|
|
6
|
+
* // Произошла ошибка загрузки test.ts, тогда fetchLazyModule повторно вызовет fn()
|
|
7
|
+
* // Вызывать будет столько раз сколько указано attempts (по умолчанию 3)
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare const fetchLazyModule: <T>(fetchModule: () => Promise<T>, attempts?: number, delay?: number) => Promise<T>;
|
|
11
|
+
export type PackedAsyncModule<T> = Promise<T | {
|
|
12
|
+
default: T;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const unpackAsyncModule: <T>(maybeModule: T | PackedAsyncModule<T>) => Promise<T>;
|
|
15
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../src/imports.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAU,CAAC,EACrC,aAAa,MAAM,OAAO,CAAC,CAAC,CAAC,EAC7B,iBAAY,EACZ,cAAY,KACX,OAAO,CAAC,CAAC,CAkBX,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAE/D,eAAO,MAAM,iBAAiB,GAAU,CAAC,EACvC,aAAa,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,KACpC,OAAO,CAAC,CAAC,CAYX,CAAC"}
|
package/imports.js
CHANGED
package/math.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.percentFrom = void 0;
|
|
4
|
+
exports.degToRad = degToRad;
|
|
5
|
+
exports.radToDeg = radToDeg;
|
|
6
|
+
function degToRad(deg) {
|
|
7
|
+
return deg * (Math.PI / 180);
|
|
8
|
+
}
|
|
9
|
+
function radToDeg(rad) {
|
|
10
|
+
return rad * (180 / Math.PI);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Получить процент от числа
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* percentFrom(500, 2000) // 25
|
|
17
|
+
* percentFrom(1000, 2000) // 50
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
const percentFrom = (value, from) => {
|
|
21
|
+
return ((value ?? 0) / (from ?? 0)) * 100 || 0;
|
|
22
|
+
};
|
|
23
|
+
exports.percentFrom = percentFrom;
|
package/math.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Maybe } from "./utils/types.cjs";
|
|
2
|
+
export declare function degToRad(deg: number): number;
|
|
3
|
+
export declare function radToDeg(rad: number): number;
|
|
4
|
+
/**
|
|
5
|
+
* Получить процент от числа
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* percentFrom(500, 2000) // 25
|
|
9
|
+
* percentFrom(1000, 2000) // 50
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const percentFrom: (value: Maybe<number>, from: Maybe<number>) => number;
|
|
13
|
+
//# sourceMappingURL=math.d.ts.map
|
package/math.d.cts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,0BAAyB;AAE9C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,UAEnC;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,UAEnC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,CAAC,WAEpE,CAAC"}
|
package/math.d.ts
CHANGED
package/math.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,yBAAyB;AAE9C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,UAEnC;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,UAEnC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,CAAC,WAEpE,CAAC"}
|
package/media.cjs
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBase64Image = exports.isHttpUrl = exports.rotateImage = exports.renderImage = exports.imageToBlob = exports.fileToBlob = exports.blobToUrl = void 0;
|
|
4
|
+
exports.blobToBase64 = blobToBase64;
|
|
5
|
+
exports.decodeDataUrl = decodeDataUrl;
|
|
6
|
+
const math_js_1 = require("./math.cjs");
|
|
7
|
+
function blobToBase64(blob) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const reader = new FileReader();
|
|
10
|
+
reader.onloadend = () => resolve(reader.result);
|
|
11
|
+
reader.onerror = reject;
|
|
12
|
+
reader.readAsDataURL(blob);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const blobToUrl = (urlOrBlob) => urlOrBlob instanceof Blob ? URL.createObjectURL(urlOrBlob) : urlOrBlob;
|
|
16
|
+
exports.blobToUrl = blobToUrl;
|
|
17
|
+
const fileToBlob = (file) => {
|
|
18
|
+
return new Blob([file], { type: file.type });
|
|
19
|
+
};
|
|
20
|
+
exports.fileToBlob = fileToBlob;
|
|
21
|
+
const imageToBlob = (imageElement, mimeType = 'image/png') => {
|
|
22
|
+
const canvas = document.createElement('canvas');
|
|
23
|
+
canvas.width = imageElement.naturalWidth || 300;
|
|
24
|
+
canvas.height = imageElement.naturalHeight || 300;
|
|
25
|
+
canvas.getContext('2d').drawImage(imageElement, 0, 0);
|
|
26
|
+
const dataUri = canvas.toDataURL(mimeType, 1);
|
|
27
|
+
const base64data = dataUri.split(',')[1];
|
|
28
|
+
const base64MimeType = dataUri.split(';')[0].slice(5);
|
|
29
|
+
const bytes = globalThis.atob(base64data);
|
|
30
|
+
const buf = new ArrayBuffer(bytes.length);
|
|
31
|
+
const array = new Uint8Array(buf);
|
|
32
|
+
for (let index = 0; index < bytes.length; index++) {
|
|
33
|
+
array[index] = bytes.charCodeAt(index);
|
|
34
|
+
}
|
|
35
|
+
const blob = new Blob([array], { type: base64MimeType });
|
|
36
|
+
return blob;
|
|
37
|
+
};
|
|
38
|
+
exports.imageToBlob = imageToBlob;
|
|
39
|
+
/**
|
|
40
|
+
* Загружает и отрисовывает изображение с использованием Image
|
|
41
|
+
*
|
|
42
|
+
* @returns {Promise<HTMLImageElement>}
|
|
43
|
+
*/
|
|
44
|
+
const renderImage = (urlOrBlob) => new Promise((resolve, reject) => {
|
|
45
|
+
const image = new Image();
|
|
46
|
+
image.src = (0, exports.blobToUrl)(urlOrBlob);
|
|
47
|
+
image.onload = () => resolve(image);
|
|
48
|
+
image.onerror = () => reject();
|
|
49
|
+
});
|
|
50
|
+
exports.renderImage = renderImage;
|
|
51
|
+
function cropImageFromCanvas(context) {
|
|
52
|
+
const canvas = context.canvas;
|
|
53
|
+
let w = canvas.width;
|
|
54
|
+
let h = canvas.height;
|
|
55
|
+
const pix = { x: [], y: [] };
|
|
56
|
+
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
57
|
+
let x;
|
|
58
|
+
let y;
|
|
59
|
+
let index;
|
|
60
|
+
for (y = 0; y < h; y++) {
|
|
61
|
+
for (x = 0; x < w; x++) {
|
|
62
|
+
index = (y * w + x) * 4;
|
|
63
|
+
if (imageData.data[index + 3] > 0) {
|
|
64
|
+
pix.x.push(x);
|
|
65
|
+
pix.y.push(y);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
pix.x.sort((a, b) => a - b);
|
|
70
|
+
pix.y.sort((a, b) => a - b);
|
|
71
|
+
const n = pix.x.length - 1;
|
|
72
|
+
w = 1 + pix.x[n] - pix.x[0];
|
|
73
|
+
h = 1 + pix.y[n] - pix.y[0];
|
|
74
|
+
const cut = context.getImageData(pix.x[0], pix.y[0], w, h);
|
|
75
|
+
canvas.width = w;
|
|
76
|
+
canvas.height = h;
|
|
77
|
+
context.putImageData(cut, 0, 0);
|
|
78
|
+
return canvas;
|
|
79
|
+
}
|
|
80
|
+
// TODO: ломает iphone с огромными изображениями
|
|
81
|
+
const rotateImage = (image, angle) => {
|
|
82
|
+
const maxSize = Math.max(image.width, image.height);
|
|
83
|
+
const canvas = document.createElement('canvas');
|
|
84
|
+
canvas.width = maxSize;
|
|
85
|
+
canvas.height = maxSize;
|
|
86
|
+
const context = canvas.getContext('2d');
|
|
87
|
+
context.save();
|
|
88
|
+
context.translate(canvas.width / 2, canvas.height / 2);
|
|
89
|
+
context.rotate((0, math_js_1.degToRad)(angle));
|
|
90
|
+
context.drawImage(image, -image.width / 2, -image.height / 2);
|
|
91
|
+
context.restore();
|
|
92
|
+
cropImageFromCanvas(context);
|
|
93
|
+
return (0, exports.renderImage)(canvas.toDataURL('image/png'));
|
|
94
|
+
};
|
|
95
|
+
exports.rotateImage = rotateImage;
|
|
96
|
+
/*
|
|
97
|
+
* Returning object which contains base64 data and mime type of passed data url string.
|
|
98
|
+
* */
|
|
99
|
+
function decodeDataUrl(url) {
|
|
100
|
+
const regex = /^data:(.*);base64,\s?(.*)$/;
|
|
101
|
+
const matches = new RegExp(regex).exec(url);
|
|
102
|
+
return {
|
|
103
|
+
mimeType: matches?.[1],
|
|
104
|
+
data: matches?.[2],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const isHttpUrl = (url) => {
|
|
108
|
+
return url.startsWith('https://') || url.startsWith('http://');
|
|
109
|
+
};
|
|
110
|
+
exports.isHttpUrl = isHttpUrl;
|
|
111
|
+
const isBase64Image = (str) => {
|
|
112
|
+
const { mimeType, data } = decodeDataUrl(str);
|
|
113
|
+
return !!(data && mimeType?.startsWith('image/'));
|
|
114
|
+
};
|
|
115
|
+
exports.isBase64Image = isBase64Image;
|
package/media.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare function blobToBase64(blob: Blob): Promise<string>;
|
|
2
|
+
export declare const blobToUrl: (urlOrBlob: string | Blob) => string;
|
|
3
|
+
export declare const fileToBlob: (file: File) => Blob;
|
|
4
|
+
export declare const imageToBlob: (imageElement: HTMLImageElement, mimeType?: string) => Blob;
|
|
5
|
+
/**
|
|
6
|
+
* Загружает и отрисовывает изображение с использованием Image
|
|
7
|
+
*
|
|
8
|
+
* @returns {Promise<HTMLImageElement>}
|
|
9
|
+
*/
|
|
10
|
+
export declare const renderImage: (urlOrBlob: Blob | string) => Promise<HTMLImageElement>;
|
|
11
|
+
export declare const rotateImage: (image: HTMLImageElement, angle: number) => Promise<HTMLImageElement>;
|
|
12
|
+
interface DecodedDataUrl {
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
data?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function decodeDataUrl(url: string): DecodedDataUrl;
|
|
17
|
+
export declare const isHttpUrl: (url: string) => boolean;
|
|
18
|
+
export declare const isBase64Image: (str: string) => boolean;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=media.d.ts.map
|
package/media.d.cts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxD;AAED,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,GAAG,IAAI,WACsB,CAAC;AAEzE,eAAO,MAAM,UAAU,GAAI,MAAM,IAAI,SAEpC,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,cAAc,gBAAgB,EAC9B,WAAU,MAAoB,SAwB/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,WAAW,IAAI,GAAG,MAAM,8BAMhD,CAAC;AAoCL,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB,EAAE,OAAO,MAAM,8BAajE,CAAC;AAEF,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAKD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAQzD;AAED,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,OAEvC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,OAG3C,CAAC"}
|
package/media.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyObservable = void 0;
|
|
4
|
+
const mobx_1 = require("mobx");
|
|
5
|
+
const applyObservable = (context, annotationsArray, useDecorators) => {
|
|
6
|
+
if (useDecorators) {
|
|
7
|
+
annotationsArray.forEach(([field, annotation]) => {
|
|
8
|
+
annotation(context, field);
|
|
9
|
+
});
|
|
10
|
+
(0, mobx_1.makeObservable)(context);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
(0, mobx_1.makeObservable)(context, Object.fromEntries(annotationsArray));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.applyObservable = applyObservable;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyObject } from "../utils/types.cjs";
|
|
2
|
+
export type ObservableAnnotationsArray = [string, any][];
|
|
3
|
+
export declare const applyObservable: (context: AnyObject, annotationsArray: ObservableAnnotationsArray, useDecorators?: boolean) => void;
|
|
4
|
+
//# sourceMappingURL=apply-observable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-observable.d.ts","sourceRoot":"","sources":["../../src/mobx/apply-observable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,2BAA0B;AAEnD,MAAM,MAAM,0BAA0B,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;AAEzD,eAAO,MAAM,eAAe,GAC1B,SAAS,SAAS,EAClB,kBAAkB,0BAA0B,EAC5C,gBAAgB,OAAO,SAWxB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyObject } from
|
|
1
|
+
import type { AnyObject } from "../utils/types.js";
|
|
2
2
|
export type ObservableAnnotationsArray = [string, any][];
|
|
3
3
|
export declare const applyObservable: (context: AnyObject, annotationsArray: ObservableAnnotationsArray, useDecorators?: boolean) => void;
|
|
4
4
|
//# sourceMappingURL=apply-observable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-observable.d.ts","sourceRoot":"","sources":["../../src/mobx/apply-observable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"apply-observable.d.ts","sourceRoot":"","sources":["../../src/mobx/apply-observable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,0BAA0B;AAEnD,MAAM,MAAM,0BAA0B,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;AAEzD,eAAO,MAAM,eAAe,GAC1B,SAAS,SAAS,EAClB,kBAAkB,0BAA0B,EAC5C,gBAAgB,OAAO,SAWxB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEnhancedAtom = void 0;
|
|
4
|
+
const mobx_1 = require("mobx");
|
|
5
|
+
/**
|
|
6
|
+
* Creates an enhanced atom with meta data
|
|
7
|
+
* And bind `reportChanged` and `reportObserved` method to the atom
|
|
8
|
+
*/
|
|
9
|
+
const createEnhancedAtom = (name, onBecomeObservedHandler, onBecomeUnobservedHandler, meta) => {
|
|
10
|
+
const atom = (0, mobx_1.createAtom)(name, onBecomeObservedHandler && (() => onBecomeObservedHandler?.(atom)), onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler?.(atom)));
|
|
11
|
+
atom.meta = meta ?? {};
|
|
12
|
+
atom.reportChanged = atom.reportChanged.bind(atom);
|
|
13
|
+
atom.reportObserved = atom.reportObserved.bind(atom);
|
|
14
|
+
return atom;
|
|
15
|
+
};
|
|
16
|
+
exports.createEnhancedAtom = createEnhancedAtom;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IAtom } from 'mobx';
|
|
2
|
+
import type { AnyObject } from "../utils/types.cjs";
|
|
3
|
+
export interface IEnhancedAtom<TMeta extends AnyObject = AnyObject> extends IAtom {
|
|
4
|
+
meta: TMeta;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates an enhanced atom with meta data
|
|
8
|
+
* And bind `reportChanged` and `reportObserved` method to the atom
|
|
9
|
+
*/
|
|
10
|
+
export declare const createEnhancedAtom: <TMeta extends AnyObject>(name: string, onBecomeObservedHandler?: (atom: IEnhancedAtom<TMeta>) => void, onBecomeUnobservedHandler?: (atom: IEnhancedAtom<TMeta>) => void, meta?: TMeta) => IEnhancedAtom<TMeta>;
|
|
11
|
+
//# sourceMappingURL=create-enhanced-atom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-enhanced-atom.d.ts","sourceRoot":"","sources":["../../src/mobx/create-enhanced-atom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,2BAA0B;AAEnD,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,CAChE,SAAQ,KAAK;IACb,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,SAAS,SAAS,EACxD,MAAM,MAAM,EACZ,0BAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,EAC9D,4BAA4B,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,EAChE,OAAO,KAAK,KACX,aAAa,CAAC,KAAK,CAUrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-enhanced-atom.d.ts","sourceRoot":"","sources":["../../src/mobx/create-enhanced-atom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"create-enhanced-atom.d.ts","sourceRoot":"","sources":["../../src/mobx/create-enhanced-atom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,0BAA0B;AAEnD,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,CAChE,SAAQ,KAAK;IACb,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,SAAS,SAAS,EACxD,MAAM,MAAM,EACZ,0BAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,EAC9D,4BAA4B,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,EAChE,OAAO,KAAK,KACX,aAAa,CAAC,KAAK,CAUrB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeepObservableStruct = void 0;
|
|
4
|
+
const mobx_1 = require("mobx");
|
|
5
|
+
const index_js_1 = require("../type-guard/index.cjs");
|
|
6
|
+
class DeepObservableStruct {
|
|
7
|
+
data;
|
|
8
|
+
constructor(data) {
|
|
9
|
+
this.data = data;
|
|
10
|
+
(0, mobx_1.makeObservable)(this, {
|
|
11
|
+
data: mobx_1.observable.deep,
|
|
12
|
+
set: mobx_1.action,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
set(newData) {
|
|
16
|
+
const stack = Object.keys(this.data).map((key) => [
|
|
17
|
+
key,
|
|
18
|
+
this.data,
|
|
19
|
+
newData,
|
|
20
|
+
]);
|
|
21
|
+
let currentIndex = 0;
|
|
22
|
+
let stackLength = stack.length;
|
|
23
|
+
while (currentIndex < stackLength) {
|
|
24
|
+
const [key, currObservableData, newData] = stack[currentIndex];
|
|
25
|
+
const newValue = newData[key];
|
|
26
|
+
const currValue = currObservableData[key];
|
|
27
|
+
currentIndex++;
|
|
28
|
+
if (key in newData) {
|
|
29
|
+
if (index_js_1.typeGuard.isObject(newValue) && index_js_1.typeGuard.isObject(currValue)) {
|
|
30
|
+
const newValueKeys = Object.keys(newValue);
|
|
31
|
+
Object.keys(currValue).forEach((childKey) => {
|
|
32
|
+
if (!(childKey in newValue)) {
|
|
33
|
+
delete currObservableData[key][childKey];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
newValueKeys.forEach((childKey) => {
|
|
37
|
+
const length = stack.push([
|
|
38
|
+
childKey,
|
|
39
|
+
currObservableData[key],
|
|
40
|
+
newValue,
|
|
41
|
+
]);
|
|
42
|
+
stackLength = length;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else if (newValue !== currValue) {
|
|
46
|
+
currObservableData[key] = newValue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
delete currObservableData[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
Object.keys(newData).forEach((newDataKey) => {
|
|
54
|
+
if (!this.data[newDataKey]) {
|
|
55
|
+
// @ts-expect-error
|
|
56
|
+
this.data[newDataKey] = newData[newDataKey];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DeepObservableStruct = DeepObservableStruct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-observable-struct.d.ts","sourceRoot":"","sources":["../../src/mobx/deep-observable-struct.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,2BAA0B;AAEnD,qBAAa,oBAAoB,CAAC,KAAK,SAAS,SAAS;IACvD,IAAI,EAAE,KAAK,CAAC;gBAEA,IAAI,EAAE,KAAK;IASvB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;CAoD5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-observable-struct.d.ts","sourceRoot":"","sources":["../../src/mobx/deep-observable-struct.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"deep-observable-struct.d.ts","sourceRoot":"","sources":["../../src/mobx/deep-observable-struct.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,0BAA0B;AAEnD,qBAAa,oBAAoB,CAAC,KAAK,SAAS,SAAS;IACvD,IAAI,EAAE,KAAK,CAAC;gBAEA,IAAI,EAAE,KAAK;IASvB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;CAoD5B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMobxAdministration = void 0;
|
|
4
|
+
const mobx_1 = require("mobx");
|
|
5
|
+
const getMobxAdministration = (context) => context[mobx_1.$mobx];
|
|
6
|
+
exports.getMobxAdministration = getMobxAdministration;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AnnotationMapEntry } from 'mobx';
|
|
2
|
+
import type { AnyObject } from "../utils/types.cjs";
|
|
3
|
+
type ObservableObjectAdministration = Parameters<Exclude<AnnotationMapEntry, boolean>['make_']>[0];
|
|
4
|
+
export declare const getMobxAdministration: (context: AnyObject) => ObservableObjectAdministration;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=get-mobx-administration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-mobx-administration.d.ts","sourceRoot":"","sources":["../../src/mobx/get-mobx-administration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,2BAA0B;AAEnD,KAAK,8BAA8B,GAAG,UAAU,CAC9C,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAC9C,CAAC,CAAC,CAAC,CAAC;AAEL,eAAO,MAAM,qBAAqB,GAChC,SAAS,SAAS,KACjB,8BAAgD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnnotationMapEntry } from 'mobx';
|
|
2
|
-
import type { AnyObject } from
|
|
2
|
+
import type { AnyObject } from "../utils/types.js";
|
|
3
3
|
type ObservableObjectAdministration = Parameters<Exclude<AnnotationMapEntry, boolean>['make_']>[0];
|
|
4
4
|
export declare const getMobxAdministration: (context: AnyObject) => ObservableObjectAdministration;
|
|
5
5
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-mobx-administration.d.ts","sourceRoot":"","sources":["../../src/mobx/get-mobx-administration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"get-mobx-administration.d.ts","sourceRoot":"","sources":["../../src/mobx/get-mobx-administration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAA0B;AAEnD,KAAK,8BAA8B,GAAG,UAAU,CAC9C,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAC9C,CAAC,CAAC,CAAC,CAAC;AAEL,eAAO,MAAM,qBAAqB,GAChC,SAAS,SAAS,KACjB,8BAAgD,CAAC"}
|