@real1ty-obsidian-plugins/utils 2.30.0 → 2.31.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/dist/async/async.d.ts +69 -0
- package/dist/async/async.d.ts.map +1 -0
- package/dist/async/async.js +108 -0
- package/dist/async/async.js.map +1 -0
- package/dist/async/batch-operations.d.ts +21 -0
- package/dist/async/batch-operations.d.ts.map +1 -0
- package/dist/async/batch-operations.js +60 -0
- package/dist/async/batch-operations.js.map +1 -0
- package/dist/async/change-notifier.d.ts +13 -0
- package/dist/async/change-notifier.d.ts.map +1 -0
- package/dist/async/change-notifier.js +26 -0
- package/dist/async/change-notifier.js.map +1 -0
- package/dist/async/debounced-notifier.d.ts +26 -0
- package/dist/async/debounced-notifier.d.ts.map +1 -0
- package/dist/async/debounced-notifier.js +50 -0
- package/dist/async/debounced-notifier.js.map +1 -0
- package/dist/async/index.d.ts +5 -0
- package/dist/async/index.d.ts.map +1 -0
- package/dist/async/index.js +5 -0
- package/dist/async/index.js.map +1 -0
- package/dist/components/frontmatter-propagation-modal.d.ts +17 -0
- package/dist/components/frontmatter-propagation-modal.d.ts.map +1 -0
- package/dist/components/frontmatter-propagation-modal.js +85 -0
- package/dist/components/frontmatter-propagation-modal.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/input-managers/base.d.ts +30 -0
- package/dist/components/input-managers/base.d.ts.map +1 -0
- package/dist/components/input-managers/base.js +115 -0
- package/dist/components/input-managers/base.js.map +1 -0
- package/dist/components/input-managers/expression.d.ts +12 -0
- package/dist/components/input-managers/expression.d.ts.map +1 -0
- package/dist/components/input-managers/expression.js +56 -0
- package/dist/components/input-managers/expression.js.map +1 -0
- package/dist/components/input-managers/index.d.ts +4 -0
- package/dist/components/input-managers/index.d.ts.map +1 -0
- package/dist/components/input-managers/index.js +4 -0
- package/dist/components/input-managers/index.js.map +1 -0
- package/dist/components/input-managers/search.d.ts +6 -0
- package/dist/components/input-managers/search.d.ts.map +1 -0
- package/dist/components/input-managers/search.js +16 -0
- package/dist/components/input-managers/search.js.map +1 -0
- package/dist/components/registered-events-component.d.ts +30 -0
- package/dist/components/registered-events-component.d.ts.map +1 -0
- package/dist/components/registered-events-component.js +43 -0
- package/dist/components/registered-events-component.js.map +1 -0
- package/dist/components/whats-new-modal.d.ts +89 -0
- package/dist/components/whats-new-modal.d.ts.map +1 -0
- package/dist/components/whats-new-modal.js +196 -0
- package/dist/components/whats-new-modal.js.map +1 -0
- package/dist/core/color-utils.d.ts +17 -0
- package/dist/core/color-utils.d.ts.map +1 -0
- package/dist/core/color-utils.js +29 -0
- package/dist/core/color-utils.js.map +1 -0
- package/dist/core/css-utils.d.ts +39 -0
- package/dist/core/css-utils.d.ts.map +1 -0
- package/dist/core/css-utils.js +60 -0
- package/dist/core/css-utils.js.map +1 -0
- package/dist/core/evaluator/base.d.ts +22 -0
- package/dist/core/evaluator/base.d.ts.map +1 -0
- package/dist/core/evaluator/base.js +67 -0
- package/dist/core/evaluator/base.js.map +1 -0
- package/dist/core/evaluator/color.d.ts +19 -0
- package/dist/core/evaluator/color.d.ts.map +1 -0
- package/dist/core/evaluator/color.js +25 -0
- package/dist/core/evaluator/color.js.map +1 -0
- package/dist/core/evaluator/excluded.d.ts +32 -0
- package/dist/core/evaluator/excluded.d.ts.map +1 -0
- package/dist/core/evaluator/excluded.js +41 -0
- package/dist/core/evaluator/excluded.js.map +1 -0
- package/dist/core/evaluator/filter.d.ts +15 -0
- package/dist/core/evaluator/filter.d.ts.map +1 -0
- package/dist/core/evaluator/filter.js +27 -0
- package/dist/core/evaluator/filter.js.map +1 -0
- package/dist/core/evaluator/included.d.ts +36 -0
- package/dist/core/evaluator/included.d.ts.map +1 -0
- package/dist/core/evaluator/included.js +51 -0
- package/dist/core/evaluator/included.js.map +1 -0
- package/dist/core/evaluator/index.d.ts +6 -0
- package/dist/core/evaluator/index.d.ts.map +1 -0
- package/dist/core/evaluator/index.js +6 -0
- package/dist/core/evaluator/index.js.map +1 -0
- package/dist/core/expression-utils.d.ts +17 -0
- package/dist/core/expression-utils.d.ts.map +1 -0
- package/dist/core/expression-utils.js +40 -0
- package/dist/core/expression-utils.js.map +1 -0
- package/dist/core/frontmatter-value.d.ts +157 -0
- package/dist/core/frontmatter-value.d.ts.map +1 -0
- package/dist/core/frontmatter-value.js +417 -0
- package/dist/core/frontmatter-value.js.map +1 -0
- package/dist/core/generate.d.ts +7 -0
- package/dist/core/generate.d.ts.map +1 -0
- package/dist/core/generate.js +13 -0
- package/dist/core/generate.js.map +1 -0
- package/dist/core/history.d.ts +12 -0
- package/dist/core/history.d.ts.map +1 -0
- package/dist/core/history.js +39 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/indexer.d.ts +109 -0
- package/dist/core/indexer.d.ts.map +1 -0
- package/dist/core/indexer.js +185 -0
- package/dist/core/indexer.js.map +1 -0
- package/dist/core/property-renderer.d.ts +9 -0
- package/dist/core/property-renderer.d.ts.map +1 -0
- package/dist/core/property-renderer.js +42 -0
- package/dist/core/property-renderer.js.map +1 -0
- package/dist/core/validation.d.ts +13 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +27 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/date/date-recurrence.d.ts +30 -0
- package/dist/date/date-recurrence.d.ts.map +1 -0
- package/dist/date/date-recurrence.js +188 -0
- package/dist/date/date-recurrence.js.map +1 -0
- package/dist/date/date.d.ts +21 -0
- package/dist/date/date.d.ts.map +1 -0
- package/dist/date/date.js +105 -0
- package/dist/date/date.js.map +1 -0
- package/dist/date/index.d.ts +3 -0
- package/dist/date/index.d.ts.map +1 -0
- package/dist/date/index.js +3 -0
- package/dist/date/index.js.map +1 -0
- package/dist/file/child-reference.d.ts +9 -0
- package/dist/file/child-reference.d.ts.map +1 -0
- package/dist/file/child-reference.js +57 -0
- package/dist/file/child-reference.js.map +1 -0
- package/dist/file/file-operations.d.ts +31 -0
- package/dist/file/file-operations.d.ts.map +1 -0
- package/dist/file/file-operations.js +160 -0
- package/dist/file/file-operations.js.map +1 -0
- package/dist/file/file-utils.d.ts +33 -0
- package/dist/file/file-utils.d.ts.map +1 -0
- package/dist/file/file-utils.js +76 -0
- package/dist/file/file-utils.js.map +1 -0
- package/dist/file/file.d.ts +332 -0
- package/dist/file/file.d.ts.map +1 -0
- package/dist/file/file.js +559 -0
- package/dist/file/file.js.map +1 -0
- package/dist/file/frontmatter-diff.d.ts +38 -0
- package/dist/file/frontmatter-diff.d.ts.map +1 -0
- package/dist/file/frontmatter-diff.js +162 -0
- package/dist/file/frontmatter-diff.js.map +1 -0
- package/dist/file/frontmatter-propagation.d.ts +4 -0
- package/dist/file/frontmatter-propagation.d.ts.map +1 -0
- package/dist/file/frontmatter-propagation.js +28 -0
- package/dist/file/frontmatter-propagation.js.map +1 -0
- package/dist/file/frontmatter-serialization.d.ts +21 -0
- package/dist/file/frontmatter-serialization.d.ts.map +1 -0
- package/dist/file/frontmatter-serialization.js +57 -0
- package/dist/file/frontmatter-serialization.js.map +1 -0
- package/dist/file/frontmatter.d.ts +15 -0
- package/dist/file/frontmatter.d.ts.map +1 -0
- package/dist/file/frontmatter.js +68 -0
- package/dist/file/frontmatter.js.map +1 -0
- package/dist/file/index.d.ts +13 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +13 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/link-parser.d.ts +63 -0
- package/dist/file/link-parser.d.ts.map +1 -0
- package/dist/file/link-parser.js +137 -0
- package/dist/file/link-parser.js.map +1 -0
- package/dist/file/property-utils.d.ts +55 -0
- package/dist/file/property-utils.d.ts.map +1 -0
- package/dist/file/property-utils.js +90 -0
- package/dist/file/property-utils.js.map +1 -0
- package/dist/file/templater-service.d.ts +16 -0
- package/dist/file/templater-service.d.ts.map +1 -0
- package/dist/file/templater-service.js +37 -0
- package/dist/file/templater-service.js.map +1 -0
- package/dist/file/templater.d.ts +28 -0
- package/dist/file/templater.d.ts.map +1 -0
- package/dist/file/templater.js +126 -0
- package/dist/file/templater.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs/index.d.ts +2 -0
- package/dist/inputs/index.d.ts.map +1 -0
- package/dist/inputs/index.js +2 -0
- package/dist/inputs/index.js.map +1 -0
- package/dist/inputs/input-filter-manager.d.ts +72 -0
- package/dist/inputs/input-filter-manager.d.ts.map +1 -0
- package/dist/inputs/input-filter-manager.js +140 -0
- package/dist/inputs/input-filter-manager.js.map +1 -0
- package/dist/settings/index.d.ts +3 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +3 -0
- package/dist/settings/index.js.map +1 -0
- package/dist/settings/settings-store.d.ts +20 -0
- package/dist/settings/settings-store.d.ts.map +1 -0
- package/dist/settings/settings-store.js +82 -0
- package/dist/settings/settings-store.js.map +1 -0
- package/dist/settings/settings-ui-builder.d.ts +74 -0
- package/dist/settings/settings-ui-builder.d.ts.map +1 -0
- package/dist/settings/settings-ui-builder.js +436 -0
- package/dist/settings/settings-ui-builder.js.map +1 -0
- package/dist/string/changelog-parser.d.ts +17 -0
- package/dist/string/changelog-parser.d.ts.map +1 -0
- package/dist/string/changelog-parser.js +77 -0
- package/dist/string/changelog-parser.js.map +1 -0
- package/dist/string/filename-utils.d.ts +46 -0
- package/dist/string/filename-utils.d.ts.map +1 -0
- package/dist/string/filename-utils.js +65 -0
- package/dist/string/filename-utils.js.map +1 -0
- package/dist/string/index.d.ts +4 -0
- package/dist/string/index.d.ts.map +1 -0
- package/dist/string/index.js +4 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/string.d.ts +5 -0
- package/dist/string/string.d.ts.map +1 -0
- package/dist/string/string.js +25 -0
- package/dist/string/string.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +6 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mocks/obsidian.d.ts +150 -0
- package/dist/testing/mocks/obsidian.d.ts.map +1 -0
- package/dist/testing/mocks/obsidian.js +226 -0
- package/dist/testing/mocks/obsidian.js.map +1 -0
- package/dist/testing/mocks/utils.d.ts +14 -0
- package/dist/testing/mocks/utils.d.ts.map +1 -0
- package/dist/testing/mocks/utils.js +85 -0
- package/dist/testing/mocks/utils.js.map +1 -0
- package/dist/testing/setup.d.ts +2 -0
- package/dist/testing/setup.d.ts.map +1 -0
- package/dist/testing/setup.js +18 -0
- package/dist/testing/setup.js.map +1 -0
- package/package.json +1 -1
- package/src/components/whats-new-modal.ts +74 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that ensures an async operation runs only once,
|
|
3
|
+
* returning the same promise for concurrent calls.
|
|
4
|
+
*
|
|
5
|
+
* Useful for initialization patterns where you want to ensure
|
|
6
|
+
* expensive async operations (like indexing, API calls, etc.)
|
|
7
|
+
* only happen once even if called multiple times.
|
|
8
|
+
*
|
|
9
|
+
* @param fn The async function to memoize
|
|
10
|
+
* @returns A function that returns the same promise on subsequent calls
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const initializeOnce = onceAsync(async () => {
|
|
15
|
+
* await heavyInitialization();
|
|
16
|
+
* console.log("Initialized!");
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // All these calls will share the same promise
|
|
20
|
+
* await initializeOnce();
|
|
21
|
+
* await initializeOnce(); // Won't run again
|
|
22
|
+
* await initializeOnce(); // Won't run again
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function onceAsync<T>(fn: () => Promise<T>): () => Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a function that ensures an async operation runs only once per key,
|
|
28
|
+
* useful for caching expensive operations with different parameters.
|
|
29
|
+
*
|
|
30
|
+
* @param fn The async function to memoize
|
|
31
|
+
* @returns A function that memoizes results by key
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const fetchUserOnce = onceAsyncKeyed(async (userId: string) => {
|
|
36
|
+
* return await api.getUser(userId);
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Each unique userId will only be fetched once
|
|
40
|
+
* await fetchUserOnce("user1");
|
|
41
|
+
* await fetchUserOnce("user1"); // Returns cached promise
|
|
42
|
+
* await fetchUserOnce("user2"); // New fetch for different key
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function onceAsyncKeyed<TArgs extends readonly unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>): (...args: TArgs) => Promise<TReturn>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a resettable version of onceAsync that can be cleared and re-run.
|
|
48
|
+
*
|
|
49
|
+
* @param fn The async function to memoize
|
|
50
|
+
* @returns Object with execute and reset methods
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const { execute: initialize, reset } = onceAsyncResettable(async () => {
|
|
55
|
+
* await heavyInitialization();
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* await initialize(); // Runs
|
|
59
|
+
* await initialize(); // Cached
|
|
60
|
+
*
|
|
61
|
+
* reset(); // Clear cache
|
|
62
|
+
* await initialize(); // Runs again
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function onceAsyncResettable<T>(fn: () => Promise<T>): {
|
|
66
|
+
execute: () => Promise<T>;
|
|
67
|
+
reset: () => void;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async/async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,CAAC,CAAC,CAcnE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,EAAE,OAAO,EACvE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,GACtC,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAYtC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG;IAC7D,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB,CAmBA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that ensures an async operation runs only once,
|
|
3
|
+
* returning the same promise for concurrent calls.
|
|
4
|
+
*
|
|
5
|
+
* Useful for initialization patterns where you want to ensure
|
|
6
|
+
* expensive async operations (like indexing, API calls, etc.)
|
|
7
|
+
* only happen once even if called multiple times.
|
|
8
|
+
*
|
|
9
|
+
* @param fn The async function to memoize
|
|
10
|
+
* @returns A function that returns the same promise on subsequent calls
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const initializeOnce = onceAsync(async () => {
|
|
15
|
+
* await heavyInitialization();
|
|
16
|
+
* console.log("Initialized!");
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // All these calls will share the same promise
|
|
20
|
+
* await initializeOnce();
|
|
21
|
+
* await initializeOnce(); // Won't run again
|
|
22
|
+
* await initializeOnce(); // Won't run again
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function onceAsync(fn) {
|
|
26
|
+
let promise = null;
|
|
27
|
+
return () => {
|
|
28
|
+
if (!promise) {
|
|
29
|
+
try {
|
|
30
|
+
promise = fn();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
// Convert synchronous errors to rejected promises
|
|
34
|
+
promise = Promise.reject(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return promise;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a function that ensures an async operation runs only once per key,
|
|
42
|
+
* useful for caching expensive operations with different parameters.
|
|
43
|
+
*
|
|
44
|
+
* @param fn The async function to memoize
|
|
45
|
+
* @returns A function that memoizes results by key
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const fetchUserOnce = onceAsyncKeyed(async (userId: string) => {
|
|
50
|
+
* return await api.getUser(userId);
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // Each unique userId will only be fetched once
|
|
54
|
+
* await fetchUserOnce("user1");
|
|
55
|
+
* await fetchUserOnce("user1"); // Returns cached promise
|
|
56
|
+
* await fetchUserOnce("user2"); // New fetch for different key
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function onceAsyncKeyed(fn) {
|
|
60
|
+
const cache = new Map();
|
|
61
|
+
return (...args) => {
|
|
62
|
+
const key = JSON.stringify(args);
|
|
63
|
+
if (!cache.has(key)) {
|
|
64
|
+
cache.set(key, fn(...args));
|
|
65
|
+
}
|
|
66
|
+
return cache.get(key);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a resettable version of onceAsync that can be cleared and re-run.
|
|
71
|
+
*
|
|
72
|
+
* @param fn The async function to memoize
|
|
73
|
+
* @returns Object with execute and reset methods
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const { execute: initialize, reset } = onceAsyncResettable(async () => {
|
|
78
|
+
* await heavyInitialization();
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* await initialize(); // Runs
|
|
82
|
+
* await initialize(); // Cached
|
|
83
|
+
*
|
|
84
|
+
* reset(); // Clear cache
|
|
85
|
+
* await initialize(); // Runs again
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function onceAsyncResettable(fn) {
|
|
89
|
+
let promise = null;
|
|
90
|
+
return {
|
|
91
|
+
execute: () => {
|
|
92
|
+
if (!promise) {
|
|
93
|
+
try {
|
|
94
|
+
promise = fn();
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// Convert synchronous errors to rejected promises
|
|
98
|
+
promise = Promise.reject(error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return promise;
|
|
102
|
+
},
|
|
103
|
+
reset: () => {
|
|
104
|
+
promise = null;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/async/async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,SAAS,CAAI,EAAoB;IAChD,IAAI,OAAO,GAAsB,IAAI,CAAC;IAEtC,OAAO,GAAG,EAAE;QACX,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,IAAI,CAAC;gBACJ,OAAO,GAAG,EAAE,EAAE,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,kDAAkD;gBAClD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC;QACF,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAC7B,EAAwC;IAExC,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;IAElD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IACxB,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,mBAAmB,CAAI,EAAoB;IAI1D,IAAI,OAAO,GAAsB,IAAI,CAAC;IAEtC,OAAO;QACN,OAAO,EAAE,GAAG,EAAE;YACb,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,IAAI,CAAC;oBACJ,OAAO,GAAG,EAAE,EAAE,CAAC;gBAChB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,kDAAkD;oBAClD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC;YACF,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACX,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Creates a function that ensures an async operation runs only once,\n * returning the same promise for concurrent calls.\n *\n * Useful for initialization patterns where you want to ensure\n * expensive async operations (like indexing, API calls, etc.)\n * only happen once even if called multiple times.\n *\n * @param fn The async function to memoize\n * @returns A function that returns the same promise on subsequent calls\n *\n * @example\n * ```typescript\n * const initializeOnce = onceAsync(async () => {\n * await heavyInitialization();\n * console.log(\"Initialized!\");\n * });\n *\n * // All these calls will share the same promise\n * await initializeOnce();\n * await initializeOnce(); // Won't run again\n * await initializeOnce(); // Won't run again\n * ```\n */\nexport function onceAsync<T>(fn: () => Promise<T>): () => Promise<T> {\n\tlet promise: Promise<T> | null = null;\n\n\treturn () => {\n\t\tif (!promise) {\n\t\t\ttry {\n\t\t\t\tpromise = fn();\n\t\t\t} catch (error) {\n\t\t\t\t// Convert synchronous errors to rejected promises\n\t\t\t\tpromise = Promise.reject(error);\n\t\t\t}\n\t\t}\n\t\treturn promise;\n\t};\n}\n\n/**\n * Creates a function that ensures an async operation runs only once per key,\n * useful for caching expensive operations with different parameters.\n *\n * @param fn The async function to memoize\n * @returns A function that memoizes results by key\n *\n * @example\n * ```typescript\n * const fetchUserOnce = onceAsyncKeyed(async (userId: string) => {\n * return await api.getUser(userId);\n * });\n *\n * // Each unique userId will only be fetched once\n * await fetchUserOnce(\"user1\");\n * await fetchUserOnce(\"user1\"); // Returns cached promise\n * await fetchUserOnce(\"user2\"); // New fetch for different key\n * ```\n */\nexport function onceAsyncKeyed<TArgs extends readonly unknown[], TReturn>(\n\tfn: (...args: TArgs) => Promise<TReturn>\n): (...args: TArgs) => Promise<TReturn> {\n\tconst cache = new Map<string, Promise<TReturn>>();\n\n\treturn (...args: TArgs) => {\n\t\tconst key = JSON.stringify(args);\n\n\t\tif (!cache.has(key)) {\n\t\t\tcache.set(key, fn(...args));\n\t\t}\n\n\t\treturn cache.get(key)!;\n\t};\n}\n\n/**\n * Creates a resettable version of onceAsync that can be cleared and re-run.\n *\n * @param fn The async function to memoize\n * @returns Object with execute and reset methods\n *\n * @example\n * ```typescript\n * const { execute: initialize, reset } = onceAsyncResettable(async () => {\n * await heavyInitialization();\n * });\n *\n * await initialize(); // Runs\n * await initialize(); // Cached\n *\n * reset(); // Clear cache\n * await initialize(); // Runs again\n * ```\n */\nexport function onceAsyncResettable<T>(fn: () => Promise<T>): {\n\texecute: () => Promise<T>;\n\treset: () => void;\n} {\n\tlet promise: Promise<T> | null = null;\n\n\treturn {\n\t\texecute: () => {\n\t\t\tif (!promise) {\n\t\t\t\ttry {\n\t\t\t\t\tpromise = fn();\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Convert synchronous errors to rejected promises\n\t\t\t\t\tpromise = Promise.reject(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn promise;\n\t\t},\n\t\treset: () => {\n\t\t\tpromise = null;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface BatchOperationOptions {
|
|
2
|
+
closeAfter?: boolean;
|
|
3
|
+
callOnComplete?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface BatchOperationResult {
|
|
6
|
+
successCount: number;
|
|
7
|
+
errorCount: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function runBatchOperation<T>(items: T[], operationLabel: string, handler: (item: T) => Promise<void>, showResult?: boolean): Promise<BatchOperationResult>;
|
|
10
|
+
export declare function showBatchOperationResult(operation: string, successCount: number, errorCount: number): void;
|
|
11
|
+
/**
|
|
12
|
+
* Executes an async operation with a lock to prevent concurrent execution for the same key.
|
|
13
|
+
* If a lock already exists for the key, waits for it to complete instead of starting a new operation.
|
|
14
|
+
*
|
|
15
|
+
* @param lockMap - Map storing active locks by key
|
|
16
|
+
* @param key - Unique identifier for the lock
|
|
17
|
+
* @param operation - Async function to execute with the lock
|
|
18
|
+
* @returns Promise resolving to the operation's result
|
|
19
|
+
*/
|
|
20
|
+
export declare function withLock<T>(lockMap: Map<string, Promise<T>>, key: string, operation: () => Promise<T>): Promise<T>;
|
|
21
|
+
//# sourceMappingURL=batch-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-operations.d.ts","sourceRoot":"","sources":["../../src/async/batch-operations.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,EAAE,EACV,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EACnC,UAAU,GAAE,OAAc,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAmB/B;AAED,wBAAgB,wBAAwB,CACvC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAChB,IAAI,CAUN;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC/B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAkBZ"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Notice } from "obsidian";
|
|
3
|
+
export function runBatchOperation(items_1, operationLabel_1, handler_1) {
|
|
4
|
+
return __awaiter(this, arguments, void 0, function* (items, operationLabel, handler, showResult = true) {
|
|
5
|
+
let successCount = 0;
|
|
6
|
+
let errorCount = 0;
|
|
7
|
+
for (const item of items) {
|
|
8
|
+
try {
|
|
9
|
+
yield handler(item);
|
|
10
|
+
successCount++;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error(`${operationLabel}: error processing item:`, error);
|
|
14
|
+
errorCount++;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (showResult) {
|
|
18
|
+
showBatchOperationResult(operationLabel, successCount, errorCount);
|
|
19
|
+
}
|
|
20
|
+
return { successCount, errorCount };
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function showBatchOperationResult(operation, successCount, errorCount) {
|
|
24
|
+
if (errorCount === 0) {
|
|
25
|
+
new Notice(`${operation}: ${successCount} item${successCount === 1 ? "" : "s"} processed successfully`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
new Notice(`${operation}: ${successCount} succeeded, ${errorCount} failed. Check console for details.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Executes an async operation with a lock to prevent concurrent execution for the same key.
|
|
33
|
+
* If a lock already exists for the key, waits for it to complete instead of starting a new operation.
|
|
34
|
+
*
|
|
35
|
+
* @param lockMap - Map storing active locks by key
|
|
36
|
+
* @param key - Unique identifier for the lock
|
|
37
|
+
* @param operation - Async function to execute with the lock
|
|
38
|
+
* @returns Promise resolving to the operation's result
|
|
39
|
+
*/
|
|
40
|
+
export function withLock(lockMap, key, operation) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
// Check if there's already an operation in progress for this key
|
|
43
|
+
const existingLock = lockMap.get(key);
|
|
44
|
+
if (existingLock) {
|
|
45
|
+
// Wait for the existing operation to complete instead of starting a new one
|
|
46
|
+
return yield existingLock;
|
|
47
|
+
}
|
|
48
|
+
// Create a new locked operation
|
|
49
|
+
const lockPromise = operation();
|
|
50
|
+
lockMap.set(key, lockPromise);
|
|
51
|
+
try {
|
|
52
|
+
return yield lockPromise;
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
// Always remove the lock when done
|
|
56
|
+
lockMap.delete(key);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=batch-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-operations.js","sourceRoot":"","sources":["../../src/async/batch-operations.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,E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A4E;YAC5E,OAAO,MAAM,YAAY,CAAC;QAC3B,CAAC;QAED,gCAAgC;QAChC,MAAM,WAAW,GAAG,SAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAE9B,IAAI,CAAC;YACJ,OAAO,MAAM,WAAW,CAAC;QAC1B,CAAC;gBAAS,CAAC;YACV,mCAAmC;YACnC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;CAAA","sourcesContent":["import { Notice } from \"obsidian\";\n\nexport interface BatchOperationOptions {\n\tcloseAfter?: boolean;\n\tcallOnComplete?: boolean;\n}\n\nexport interface BatchOperationResult {\n\tsuccessCount: number;\n\terrorCount: number;\n}\n\nexport async function runBatchOperation<T>(\n\titems: T[],\n\toperationLabel: string,\n\thandler: (item: T) => Promise<void>,\n\tshowResult: boolean = true\n): Promise<BatchOperationResult> {\n\tlet successCount = 0;\n\tlet errorCount = 0;\n\n\tfor (const item of items) {\n\t\ttry {\n\t\t\tawait handler(item);\n\t\t\tsuccessCount++;\n\t\t} catch (error) {\n\t\t\tconsole.error(`${operationLabel}: error processing item:`, error);\n\t\t\terrorCount++;\n\t\t}\n\t}\n\n\tif (showResult) {\n\t\tshowBatchOperationResult(operationLabel, successCount, errorCount);\n\t}\n\n\treturn { successCount, errorCount };\n}\n\nexport function showBatchOperationResult(\n\toperation: string,\n\tsuccessCount: number,\n\terrorCount: number\n): void {\n\tif (errorCount === 0) {\n\t\tnew Notice(\n\t\t\t`${operation}: ${successCount} item${successCount === 1 ? \"\" : \"s\"} processed successfully`\n\t\t);\n\t} else {\n\t\tnew Notice(\n\t\t\t`${operation}: ${successCount} succeeded, ${errorCount} failed. Check console for details.`\n\t\t);\n\t}\n}\n\n/**\n * Executes an async operation with a lock to prevent concurrent execution for the same key.\n * If a lock already exists for the key, waits for it to complete instead of starting a new operation.\n *\n * @param lockMap - Map storing active locks by key\n * @param key - Unique identifier for the lock\n * @param operation - Async function to execute with the lock\n * @returns Promise resolving to the operation's result\n */\nexport async function withLock<T>(\n\tlockMap: Map<string, Promise<T>>,\n\tkey: string,\n\toperation: () => Promise<T>\n): Promise<T> {\n\t// Check if there's already an operation in progress for this key\n\tconst existingLock = lockMap.get(key);\n\tif (existingLock) {\n\t\t// Wait for the existing operation to complete instead of starting a new one\n\t\treturn await existingLock;\n\t}\n\n\t// Create a new locked operation\n\tconst lockPromise = operation();\n\tlockMap.set(key, lockPromise);\n\n\ttry {\n\t\treturn await lockPromise;\n\t} finally {\n\t\t// Always remove the lock when done\n\t\tlockMap.delete(key);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Subscription } from "rxjs";
|
|
2
|
+
/**
|
|
3
|
+
* Base class that provides observable change notification capabilities.
|
|
4
|
+
* Eliminates boilerplate for classes that need to notify observers of state changes.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class ChangeNotifier {
|
|
7
|
+
private changeSubject;
|
|
8
|
+
readonly changes$: import("rxjs").Observable<void>;
|
|
9
|
+
protected notifyChange(): void;
|
|
10
|
+
subscribe(observer: () => void): Subscription;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=change-notifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-notifier.d.ts","sourceRoot":"","sources":["../../src/async/change-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAElD;;;GAGG;AACH,8BAAsB,cAAc;IACnC,OAAO,CAAC,aAAa,CAAuB;IAC5C,SAAgB,QAAQ,kCAAqC;IAE7D,SAAS,CAAC,YAAY,IAAI,IAAI;IAQ9B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,YAAY;IAI7C,OAAO,IAAI,IAAI;CAGf"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Subject } from "rxjs";
|
|
2
|
+
/**
|
|
3
|
+
* Base class that provides observable change notification capabilities.
|
|
4
|
+
* Eliminates boilerplate for classes that need to notify observers of state changes.
|
|
5
|
+
*/
|
|
6
|
+
export class ChangeNotifier {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.changeSubject = new Subject();
|
|
9
|
+
this.changes$ = this.changeSubject.asObservable();
|
|
10
|
+
}
|
|
11
|
+
notifyChange() {
|
|
12
|
+
try {
|
|
13
|
+
this.changeSubject.next();
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error("Error notifying change:", error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
subscribe(observer) {
|
|
20
|
+
return this.changes$.subscribe(observer);
|
|
21
|
+
}
|
|
22
|
+
destroy() {
|
|
23
|
+
this.changeSubject.complete();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=change-notifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-notifier.js","sourceRoot":"","sources":["../../src/async/change-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAqB,MAAM,MAAM,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAgB,cAAc;IAApC;QACS,kBAAa,GAAG,IAAI,OAAO,EAAQ,CAAC;QAC5B,aAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;IAiB9D,CAAC;IAfU,YAAY;QACrB,IAAI,CAAC;YACJ,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;IAED,SAAS,CAAC,QAAoB;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO;QACN,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACD","sourcesContent":["import { Subject, type Subscription } from \"rxjs\";\n\n/**\n * Base class that provides observable change notification capabilities.\n * Eliminates boilerplate for classes that need to notify observers of state changes.\n */\nexport abstract class ChangeNotifier {\n\tprivate changeSubject = new Subject<void>();\n\tpublic readonly changes$ = this.changeSubject.asObservable();\n\n\tprotected notifyChange(): void {\n\t\ttry {\n\t\t\tthis.changeSubject.next();\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error notifying change:\", error);\n\t\t}\n\t}\n\n\tsubscribe(observer: () => void): Subscription {\n\t\treturn this.changes$.subscribe(observer);\n\t}\n\n\tdestroy(): void {\n\t\tthis.changeSubject.complete();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChangeNotifier } from "./change-notifier";
|
|
2
|
+
/**
|
|
3
|
+
* Extends ChangeNotifier with debounced notification capabilities.
|
|
4
|
+
* Prevents excessive notifications when many changes happen rapidly by batching them.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class DebouncedNotifier extends ChangeNotifier {
|
|
7
|
+
private refreshTimeout;
|
|
8
|
+
private readonly debounceMs;
|
|
9
|
+
constructor(debounceMs?: number);
|
|
10
|
+
/**
|
|
11
|
+
* Schedules a debounced refresh to prevent excessive notifications.
|
|
12
|
+
* Batches rapid changes into a single notification after inactivity period.
|
|
13
|
+
*/
|
|
14
|
+
protected scheduleRefresh(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Flushes any pending debounced refresh and immediately notifies subscribers.
|
|
17
|
+
* Used after batch operations to ensure immediate updates without waiting for debounce.
|
|
18
|
+
*/
|
|
19
|
+
protected flushPendingRefresh(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if there is a pending debounced refresh scheduled.
|
|
22
|
+
*/
|
|
23
|
+
protected hasPendingRefresh(): boolean;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=debounced-notifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounced-notifier.d.ts","sourceRoot":"","sources":["../../src/async/debounced-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;GAGG;AACH,8BAAsB,iBAAkB,SAAQ,cAAc;IAC7D,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,UAAU,SAAM;IAK5B;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,IAAI;IAUjC;;;OAGG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAQrC;;OAEG;IACH,SAAS,CAAC,iBAAiB,IAAI,OAAO;IAI7B,OAAO,IAAI,IAAI;CAOxB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ChangeNotifier } from "./change-notifier";
|
|
2
|
+
/**
|
|
3
|
+
* Extends ChangeNotifier with debounced notification capabilities.
|
|
4
|
+
* Prevents excessive notifications when many changes happen rapidly by batching them.
|
|
5
|
+
*/
|
|
6
|
+
export class DebouncedNotifier extends ChangeNotifier {
|
|
7
|
+
constructor(debounceMs = 150) {
|
|
8
|
+
super();
|
|
9
|
+
this.refreshTimeout = null;
|
|
10
|
+
this.debounceMs = debounceMs;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Schedules a debounced refresh to prevent excessive notifications.
|
|
14
|
+
* Batches rapid changes into a single notification after inactivity period.
|
|
15
|
+
*/
|
|
16
|
+
scheduleRefresh() {
|
|
17
|
+
if (this.refreshTimeout) {
|
|
18
|
+
clearTimeout(this.refreshTimeout);
|
|
19
|
+
}
|
|
20
|
+
this.refreshTimeout = setTimeout(() => {
|
|
21
|
+
this.notifyChange();
|
|
22
|
+
this.refreshTimeout = null;
|
|
23
|
+
}, this.debounceMs);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Flushes any pending debounced refresh and immediately notifies subscribers.
|
|
27
|
+
* Used after batch operations to ensure immediate updates without waiting for debounce.
|
|
28
|
+
*/
|
|
29
|
+
flushPendingRefresh() {
|
|
30
|
+
if (this.refreshTimeout) {
|
|
31
|
+
clearTimeout(this.refreshTimeout);
|
|
32
|
+
this.refreshTimeout = null;
|
|
33
|
+
this.notifyChange();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks if there is a pending debounced refresh scheduled.
|
|
38
|
+
*/
|
|
39
|
+
hasPendingRefresh() {
|
|
40
|
+
return this.refreshTimeout !== null;
|
|
41
|
+
}
|
|
42
|
+
destroy() {
|
|
43
|
+
if (this.refreshTimeout) {
|
|
44
|
+
clearTimeout(this.refreshTimeout);
|
|
45
|
+
this.refreshTimeout = null;
|
|
46
|
+
}
|
|
47
|
+
super.destroy();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=debounced-notifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounced-notifier.js","sourceRoot":"","sources":["../../src/async/debounced-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAgB,iBAAkB,SAAQ,cAAc;IAI7D,YAAY,UAAU,GAAG,GAAG;QAC3B,KAAK,EAAE,CAAC;QAJD,mBAAc,GAAyC,IAAI,CAAC;QAKnE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACO,eAAe;QACxB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,GAAG,EAAE;YACrC,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;IAED;;;OAGG;IACO,mBAAmB;QAC5B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,IAAI,CAAC,YAAY,EAAE,CAAC;QACrB,CAAC;IACF,CAAC;IAED;;OAEG;IACO,iBAAiB;QAC1B,OAAO,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC;IACrC,CAAC;IAEQ,OAAO;QACf,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACD","sourcesContent":["import { ChangeNotifier } from \"./change-notifier\";\n\n/**\n * Extends ChangeNotifier with debounced notification capabilities.\n * Prevents excessive notifications when many changes happen rapidly by batching them.\n */\nexport abstract class DebouncedNotifier extends ChangeNotifier {\n\tprivate refreshTimeout: ReturnType<typeof setTimeout> | null = null;\n\tprivate readonly debounceMs: number;\n\n\tconstructor(debounceMs = 150) {\n\t\tsuper();\n\t\tthis.debounceMs = debounceMs;\n\t}\n\n\t/**\n\t * Schedules a debounced refresh to prevent excessive notifications.\n\t * Batches rapid changes into a single notification after inactivity period.\n\t */\n\tprotected scheduleRefresh(): void {\n\t\tif (this.refreshTimeout) {\n\t\t\tclearTimeout(this.refreshTimeout);\n\t\t}\n\t\tthis.refreshTimeout = setTimeout(() => {\n\t\t\tthis.notifyChange();\n\t\t\tthis.refreshTimeout = null;\n\t\t}, this.debounceMs);\n\t}\n\n\t/**\n\t * Flushes any pending debounced refresh and immediately notifies subscribers.\n\t * Used after batch operations to ensure immediate updates without waiting for debounce.\n\t */\n\tprotected flushPendingRefresh(): void {\n\t\tif (this.refreshTimeout) {\n\t\t\tclearTimeout(this.refreshTimeout);\n\t\t\tthis.refreshTimeout = null;\n\t\t\tthis.notifyChange();\n\t\t}\n\t}\n\n\t/**\n\t * Checks if there is a pending debounced refresh scheduled.\n\t */\n\tprotected hasPendingRefresh(): boolean {\n\t\treturn this.refreshTimeout !== null;\n\t}\n\n\toverride destroy(): void {\n\t\tif (this.refreshTimeout) {\n\t\t\tclearTimeout(this.refreshTimeout);\n\t\t\tthis.refreshTimeout = null;\n\t\t}\n\t\tsuper.destroy();\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/async/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/async/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./async\";\nexport * from \"./batch-operations\";\nexport * from \"./change-notifier\";\nexport * from \"./debounced-notifier\";\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type App, Modal } from "obsidian";
|
|
2
|
+
import type { FrontmatterDiff } from "../file/frontmatter-diff";
|
|
3
|
+
export interface FrontmatterPropagationModalOptions {
|
|
4
|
+
eventTitle: string;
|
|
5
|
+
diff: FrontmatterDiff;
|
|
6
|
+
instanceCount: number;
|
|
7
|
+
onConfirm: () => void | Promise<void>;
|
|
8
|
+
onCancel?: () => void | Promise<void>;
|
|
9
|
+
cssPrefix?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class FrontmatterPropagationModal extends Modal {
|
|
12
|
+
private options;
|
|
13
|
+
constructor(app: App, options: FrontmatterPropagationModalOptions);
|
|
14
|
+
onOpen(): void;
|
|
15
|
+
onClose(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=frontmatter-propagation-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-propagation-modal.d.ts","sourceRoot":"","sources":["../../src/components/frontmatter-propagation-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,WAAW,kCAAkC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,eAAe,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACrD,OAAO,CAAC,OAAO,CAAqC;gBAExC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,kCAAkC;IAKjE,MAAM,IAAI,IAAI;IAwFd,OAAO,IAAI,IAAI;CAIf"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Modal } from "obsidian";
|
|
2
|
+
import { formatChangeForDisplay } from "../file/frontmatter-diff";
|
|
3
|
+
export class FrontmatterPropagationModal extends Modal {
|
|
4
|
+
constructor(app, options) {
|
|
5
|
+
super(app);
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
onOpen() {
|
|
9
|
+
var _a;
|
|
10
|
+
const { contentEl } = this;
|
|
11
|
+
const prefix = (_a = this.options.cssPrefix) !== null && _a !== void 0 ? _a : "frontmatter-propagation";
|
|
12
|
+
contentEl.empty();
|
|
13
|
+
contentEl.createEl("h2", { text: "Propagate frontmatter changes?" });
|
|
14
|
+
contentEl.createEl("p", {
|
|
15
|
+
text: `The recurring event "${this.options.eventTitle}" has frontmatter changes. Do you want to apply these changes to all ${this.options.instanceCount} physical instances?`,
|
|
16
|
+
});
|
|
17
|
+
const changesContainer = contentEl.createDiv({ cls: `${prefix}-frontmatter-changes` });
|
|
18
|
+
if (this.options.diff.added.length > 0) {
|
|
19
|
+
const addedSection = changesContainer.createDiv({
|
|
20
|
+
cls: `${prefix}-frontmatter-changes-section`,
|
|
21
|
+
});
|
|
22
|
+
addedSection.createEl("h4", { text: "Added properties:" });
|
|
23
|
+
const addedList = addedSection.createEl("ul");
|
|
24
|
+
for (const change of this.options.diff.added) {
|
|
25
|
+
addedList.createEl("li", {
|
|
26
|
+
text: formatChangeForDisplay(change),
|
|
27
|
+
cls: `${prefix}-change-added`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (this.options.diff.modified.length > 0) {
|
|
32
|
+
const modifiedSection = changesContainer.createDiv({ cls: `${prefix}-changes-section` });
|
|
33
|
+
modifiedSection.createEl("h4", { text: "Modified properties:" });
|
|
34
|
+
const modifiedList = modifiedSection.createEl("ul");
|
|
35
|
+
for (const change of this.options.diff.modified) {
|
|
36
|
+
modifiedList.createEl("li", {
|
|
37
|
+
text: formatChangeForDisplay(change),
|
|
38
|
+
cls: `${prefix}-change-modified`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (this.options.diff.deleted.length > 0) {
|
|
43
|
+
const deletedSection = changesContainer.createDiv({ cls: `${prefix}-changes-section` });
|
|
44
|
+
deletedSection.createEl("h4", { text: "Deleted properties:" });
|
|
45
|
+
const deletedList = deletedSection.createEl("ul");
|
|
46
|
+
for (const change of this.options.diff.deleted) {
|
|
47
|
+
deletedList.createEl("li", {
|
|
48
|
+
text: formatChangeForDisplay(change),
|
|
49
|
+
cls: `${prefix}-change-deleted`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const buttonContainer = contentEl.createDiv({ cls: `${prefix}-modal-buttons` });
|
|
54
|
+
const yesButton = buttonContainer.createEl("button", {
|
|
55
|
+
text: "Yes, propagate",
|
|
56
|
+
cls: "mod-cta",
|
|
57
|
+
});
|
|
58
|
+
yesButton.addEventListener("click", () => {
|
|
59
|
+
void Promise.resolve(this.options.onConfirm())
|
|
60
|
+
.then(() => {
|
|
61
|
+
this.close();
|
|
62
|
+
})
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
console.error("Error in onConfirm callback:", error);
|
|
65
|
+
this.close();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
const noButton = buttonContainer.createEl("button", { text: "No, skip" });
|
|
69
|
+
noButton.addEventListener("click", () => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
const result = (_b = (_a = this.options).onCancel) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
72
|
+
if (result instanceof Promise) {
|
|
73
|
+
void result.catch((error) => {
|
|
74
|
+
console.error("Error in onCancel callback:", error);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
this.close();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
onClose() {
|
|
81
|
+
const { contentEl } = this;
|
|
82
|
+
contentEl.empty();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=frontmatter-propagation-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-propagation-modal.js","sourceRoot":"","sources":["../../src/components/frontmatter-propagation-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAWlE,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAGrD,YAAY,GAAQ,EAAE,OAA2C;QAChE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B,SAAS,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACD","sourcesContent":["import { type App, Modal } from \"obsidian\";\n\nimport type { FrontmatterDiff } from \"../file/frontmatter-diff\";\nimport { formatChangeForDisplay } from \"../file/frontmatter-diff\";\n\nexport interface FrontmatterPropagationModalOptions {\n\teventTitle: string;\n\tdiff: FrontmatterDiff;\n\tinstanceCount: number;\n\tonConfirm: () => void | Promise<void>;\n\tonCancel?: () => void | Promise<void>;\n\tcssPrefix?: string;\n}\n\nexport class FrontmatterPropagationModal extends Modal {\n\tprivate options: FrontmatterPropagationModalOptions;\n\n\tconstructor(app: App, options: FrontmatterPropagationModalOptions) {\n\t\tsuper(app);\n\t\tthis.options = options;\n\t}\n\n\tonOpen(): void {\n\t\tconst { contentEl } = this;\n\t\tconst prefix = this.options.cssPrefix ?? \"frontmatter-propagation\";\n\n\t\tcontentEl.empty();\n\n\t\tcontentEl.createEl(\"h2\", { text: \"Propagate frontmatter changes?\" });\n\n\t\tcontentEl.createEl(\"p\", {\n\t\t\ttext: `The recurring event \"${this.options.eventTitle}\" has frontmatter changes. Do you want to apply these changes to all ${this.options.instanceCount} physical instances?`,\n\t\t});\n\n\t\tconst changesContainer = contentEl.createDiv({ cls: `${prefix}-frontmatter-changes` });\n\n\t\tif (this.options.diff.added.length > 0) {\n\t\t\tconst addedSection = changesContainer.createDiv({\n\t\t\t\tcls: `${prefix}-frontmatter-changes-section`,\n\t\t\t});\n\t\t\taddedSection.createEl(\"h4\", { text: \"Added properties:\" });\n\t\t\tconst addedList = addedSection.createEl(\"ul\");\n\n\t\t\tfor (const change of this.options.diff.added) {\n\t\t\t\taddedList.createEl(\"li\", {\n\t\t\t\t\ttext: formatChangeForDisplay(change),\n\t\t\t\t\tcls: `${prefix}-change-added`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (this.options.diff.modified.length > 0) {\n\t\t\tconst modifiedSection = changesContainer.createDiv({ cls: `${prefix}-changes-section` });\n\t\t\tmodifiedSection.createEl(\"h4\", { text: \"Modified properties:\" });\n\t\t\tconst modifiedList = modifiedSection.createEl(\"ul\");\n\n\t\t\tfor (const change of this.options.diff.modified) {\n\t\t\t\tmodifiedList.createEl(\"li\", {\n\t\t\t\t\ttext: formatChangeForDisplay(change),\n\t\t\t\t\tcls: `${prefix}-change-modified`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (this.options.diff.deleted.length > 0) {\n\t\t\tconst deletedSection = changesContainer.createDiv({ cls: `${prefix}-changes-section` });\n\t\t\tdeletedSection.createEl(\"h4\", { text: \"Deleted properties:\" });\n\t\t\tconst deletedList = deletedSection.createEl(\"ul\");\n\n\t\t\tfor (const change of this.options.diff.deleted) {\n\t\t\t\tdeletedList.createEl(\"li\", {\n\t\t\t\t\ttext: formatChangeForDisplay(change),\n\t\t\t\t\tcls: `${prefix}-change-deleted`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst buttonContainer = contentEl.createDiv({ cls: `${prefix}-modal-buttons` });\n\n\t\tconst yesButton = buttonContainer.createEl(\"button\", {\n\t\t\ttext: \"Yes, propagate\",\n\t\t\tcls: \"mod-cta\",\n\t\t});\n\n\t\tyesButton.addEventListener(\"click\", () => {\n\t\t\tvoid Promise.resolve(this.options.onConfirm())\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.close();\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tconsole.error(\"Error in onConfirm callback:\", error);\n\t\t\t\t\tthis.close();\n\t\t\t\t});\n\t\t});\n\n\t\tconst noButton = buttonContainer.createEl(\"button\", { text: \"No, skip\" });\n\n\t\tnoButton.addEventListener(\"click\", () => {\n\t\t\tconst result = this.options.onCancel?.();\n\n\t\t\tif (result instanceof Promise) {\n\t\t\t\tvoid result.catch((error) => {\n\t\t\t\t\tconsole.error(\"Error in onCancel callback:\", error);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.close();\n\t\t});\n\t}\n\n\tonClose(): void {\n\t\tconst { contentEl } = this;\n\t\tcontentEl.empty();\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"./frontmatter-propagation-modal\";\nexport * from \"./input-managers\";\nexport * from \"./registered-events-component\";\nexport * from \"./whats-new-modal\";\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type InputManagerFilterChangeCallback = () => void;
|
|
2
|
+
export declare abstract class InputManager {
|
|
3
|
+
protected parentEl: HTMLElement;
|
|
4
|
+
protected placeholder: string;
|
|
5
|
+
protected cssPrefix: string;
|
|
6
|
+
protected onFilterChange: InputManagerFilterChangeCallback;
|
|
7
|
+
protected containerEl: HTMLElement;
|
|
8
|
+
protected inputEl: HTMLInputElement | null;
|
|
9
|
+
protected debounceTimer: number | null;
|
|
10
|
+
protected currentValue: string;
|
|
11
|
+
protected persistentlyVisible: boolean;
|
|
12
|
+
protected onHide?: () => void;
|
|
13
|
+
protected hiddenClass: string;
|
|
14
|
+
protected debounceMs: number;
|
|
15
|
+
protected cssClass: string;
|
|
16
|
+
constructor(parentEl: HTMLElement, placeholder: string, cssPrefix: string, onFilterChange: InputManagerFilterChangeCallback, initiallyVisible: boolean, onHide?: () => void, debounceMs?: number);
|
|
17
|
+
private render;
|
|
18
|
+
private handleInputChange;
|
|
19
|
+
protected applyFilterImmediately(): void;
|
|
20
|
+
protected updateFilterValue(value: string): void;
|
|
21
|
+
getCurrentValue(): string;
|
|
22
|
+
show(): void;
|
|
23
|
+
hide(): void;
|
|
24
|
+
focus(): void;
|
|
25
|
+
isVisible(): boolean;
|
|
26
|
+
setPersistentlyVisible(value: boolean): void;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
abstract shouldInclude(data: unknown): boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/components/input-managers/base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gCAAgC,GAAG,MAAM,IAAI,CAAC;AAI1D,8BAAsB,YAAY;IAYhC,SAAS,CAAC,QAAQ,EAAE,WAAW;IAC/B,SAAS,CAAC,WAAW,EAAE,MAAM;IAC7B,SAAS,CAAC,SAAS,EAAE,MAAM;IAC3B,SAAS,CAAC,cAAc,EAAE,gCAAgC;IAd3D,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IACnC,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IAClD,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC9C,SAAS,CAAC,YAAY,SAAM;IAC5B,SAAS,CAAC,mBAAmB,UAAS;IACtC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAGhB,QAAQ,EAAE,WAAW,EACrB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,gCAAgC,EAC1D,gBAAgB,EAAE,OAAO,EACzB,MAAM,CAAC,EAAE,MAAM,IAAI,EACnB,UAAU,GAAE,MAA4B;IAmBzC,OAAO,CAAC,MAA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