@mlightcad/common 1.1.1 → 1.1.2
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/common.js +201 -12
- package/lib/AcCmColor.d.ts +162 -3
- package/lib/AcCmColor.d.ts.map +1 -1
- package/lib/AcCmColor.js +187 -9
- package/lib/AcCmColor.js.map +1 -1
- package/lib/AcCmColorUtil.d.ts +35 -3
- package/lib/AcCmColorUtil.d.ts.map +1 -1
- package/lib/AcCmColorUtil.js +43 -7
- package/lib/AcCmColorUtil.js.map +1 -1
- package/lib/AcCmErrors.d.ts +33 -0
- package/lib/AcCmErrors.d.ts.map +1 -1
- package/lib/AcCmErrors.js +33 -0
- package/lib/AcCmErrors.js.map +1 -1
- package/lib/AcCmEventDispatcher.d.ts +53 -0
- package/lib/AcCmEventDispatcher.d.ts.map +1 -1
- package/lib/AcCmEventDispatcher.js +37 -0
- package/lib/AcCmEventDispatcher.js.map +1 -1
- package/lib/AcCmEventManager.d.ts +40 -1
- package/lib/AcCmEventManager.d.ts.map +1 -1
- package/lib/AcCmEventManager.js +40 -1
- package/lib/AcCmEventManager.js.map +1 -1
- package/lib/AcCmLodashUtils.d.ts +125 -18
- package/lib/AcCmLodashUtils.d.ts.map +1 -1
- package/lib/AcCmLodashUtils.js +127 -20
- package/lib/AcCmLodashUtils.js.map +1 -1
- package/lib/AcCmLogUtil.d.ts +51 -2
- package/lib/AcCmLogUtil.d.ts.map +1 -1
- package/lib/AcCmLogUtil.js +51 -2
- package/lib/AcCmLogUtil.js.map +1 -1
- package/lib/AcCmObject.d.ts +58 -4
- package/lib/AcCmObject.d.ts.map +1 -1
- package/lib/AcCmObject.js +31 -2
- package/lib/AcCmObject.js.map +1 -1
- package/lib/AcCmPerformanceCollector.d.ts +22 -1
- package/lib/AcCmPerformanceCollector.d.ts.map +1 -1
- package/lib/AcCmPerformanceCollector.js +9 -0
- package/lib/AcCmPerformanceCollector.js.map +1 -1
- package/lib/AcCmStringUtil.d.ts +37 -4
- package/lib/AcCmStringUtil.d.ts.map +1 -1
- package/lib/AcCmStringUtil.js +37 -4
- package/lib/AcCmStringUtil.js.map +1 -1
- package/lib/AcCmTaskScheduler.d.ts +84 -15
- package/lib/AcCmTaskScheduler.d.ts.map +1 -1
- package/lib/AcCmTaskScheduler.js +71 -7
- package/lib/AcCmTaskScheduler.js.map +1 -1
- package/lib/loader/AcCmFileLoader.d.ts +45 -8
- package/lib/loader/AcCmFileLoader.d.ts.map +1 -1
- package/lib/loader/AcCmFileLoader.js +52 -2
- package/lib/loader/AcCmFileLoader.js.map +1 -1
- package/lib/loader/AcCmLoader.d.ts +34 -1
- package/lib/loader/AcCmLoader.d.ts.map +1 -1
- package/lib/loader/AcCmLoader.js +29 -1
- package/lib/loader/AcCmLoader.js.map +1 -1
- package/lib/loader/AcCmLoadingManager.d.ts +64 -17
- package/lib/loader/AcCmLoadingManager.d.ts.map +1 -1
- package/lib/loader/AcCmLoadingManager.js +43 -4
- package/lib/loader/AcCmLoadingManager.js.map +1 -1
- package/package.json +1 -1
package/lib/AcCmLogUtil.d.ts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Logging utilities for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a centralized logging interface using the loglevel library,
|
|
5
|
+
* with configurable log levels for development and production environments.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmLogUtil
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
1
10
|
import * as loglevel from 'loglevel';
|
|
11
|
+
/**
|
|
12
|
+
* Flag indicating whether debug mode is enabled.
|
|
13
|
+
* When true, sets log level to 'debug'; otherwise sets to 'warn'.
|
|
14
|
+
*
|
|
15
|
+
* @constant {boolean}
|
|
16
|
+
*/
|
|
2
17
|
export declare const DEBUG_MODE = true;
|
|
18
|
+
/**
|
|
19
|
+
* The main logging instance from the loglevel library.
|
|
20
|
+
* Provides standard logging methods: trace, debug, info, warn, error.
|
|
21
|
+
*
|
|
22
|
+
* @constant {loglevel.Logger}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { log } from './AcCmLogUtil'
|
|
27
|
+
*
|
|
28
|
+
* log.debug('Debug message')
|
|
29
|
+
* log.info('Info message')
|
|
30
|
+
* log.warn('Warning message')
|
|
31
|
+
* log.error('Error message')
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
3
34
|
export declare const log: {
|
|
4
35
|
default: loglevel.RootLogger;
|
|
5
36
|
noConflict(): any;
|
|
@@ -24,8 +55,26 @@ export declare const log: {
|
|
|
24
55
|
rebuild(): void;
|
|
25
56
|
};
|
|
26
57
|
/**
|
|
27
|
-
* Sets log level.
|
|
28
|
-
*
|
|
58
|
+
* Sets the log level for the logging system.
|
|
59
|
+
*
|
|
60
|
+
* Valid log levels are: 'trace', 'debug', 'info', 'warn', 'error', 'silent'.
|
|
61
|
+
* If an invalid level is provided, the level will default to 'error' and an error will be logged.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} level - The log level to set.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import { setLogLevel } from './AcCmLogUtil'
|
|
68
|
+
*
|
|
69
|
+
* // Set to debug level for development
|
|
70
|
+
* setLogLevel('debug')
|
|
71
|
+
*
|
|
72
|
+
* // Set to error level for production
|
|
73
|
+
* setLogLevel('error')
|
|
74
|
+
*
|
|
75
|
+
* // Silent all logging
|
|
76
|
+
* setLogLevel('silent')
|
|
77
|
+
* ```
|
|
29
78
|
*/
|
|
30
79
|
export declare const setLogLevel: (level: string) => void;
|
|
31
80
|
//# sourceMappingURL=AcCmLogUtil.d.ts.map
|
package/lib/AcCmLogUtil.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmLogUtil.d.ts","sourceRoot":"","sources":["../src/AcCmLogUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAEpC,eAAO,MAAM,UAAU,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"AcCmLogUtil.d.ts","sourceRoot":"","sources":["../src/AcCmLogUtil.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,OAAO,CAAA;AAE9B;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAA;AAQ3B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,SAOxC,CAAA"}
|
package/lib/AcCmLogUtil.js
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Logging utilities for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a centralized logging interface using the loglevel library,
|
|
5
|
+
* with configurable log levels for development and production environments.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmLogUtil
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
1
10
|
import * as loglevel from 'loglevel';
|
|
11
|
+
/**
|
|
12
|
+
* Flag indicating whether debug mode is enabled.
|
|
13
|
+
* When true, sets log level to 'debug'; otherwise sets to 'warn'.
|
|
14
|
+
*
|
|
15
|
+
* @constant {boolean}
|
|
16
|
+
*/
|
|
2
17
|
export var DEBUG_MODE = true;
|
|
18
|
+
/**
|
|
19
|
+
* The main logging instance from the loglevel library.
|
|
20
|
+
* Provides standard logging methods: trace, debug, info, warn, error.
|
|
21
|
+
*
|
|
22
|
+
* @constant {loglevel.Logger}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { log } from './AcCmLogUtil'
|
|
27
|
+
*
|
|
28
|
+
* log.debug('Debug message')
|
|
29
|
+
* log.info('Info message')
|
|
30
|
+
* log.warn('Warning message')
|
|
31
|
+
* log.error('Error message')
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
3
34
|
export var log = loglevel;
|
|
4
35
|
if (DEBUG_MODE) {
|
|
5
36
|
log.setLevel('debug');
|
|
@@ -8,8 +39,26 @@ else {
|
|
|
8
39
|
log.setLevel('warn');
|
|
9
40
|
}
|
|
10
41
|
/**
|
|
11
|
-
* Sets log level.
|
|
12
|
-
*
|
|
42
|
+
* Sets the log level for the logging system.
|
|
43
|
+
*
|
|
44
|
+
* Valid log levels are: 'trace', 'debug', 'info', 'warn', 'error', 'silent'.
|
|
45
|
+
* If an invalid level is provided, the level will default to 'error' and an error will be logged.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} level - The log level to set.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { setLogLevel } from './AcCmLogUtil'
|
|
52
|
+
*
|
|
53
|
+
* // Set to debug level for development
|
|
54
|
+
* setLogLevel('debug')
|
|
55
|
+
*
|
|
56
|
+
* // Set to error level for production
|
|
57
|
+
* setLogLevel('error')
|
|
58
|
+
*
|
|
59
|
+
* // Silent all logging
|
|
60
|
+
* setLogLevel('silent')
|
|
61
|
+
* ```
|
|
13
62
|
*/
|
|
14
63
|
export var setLogLevel = function (level) {
|
|
15
64
|
try {
|
package/lib/AcCmLogUtil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmLogUtil.js","sourceRoot":"","sources":["../src/AcCmLogUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAEpC,MAAM,CAAC,IAAM,UAAU,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"AcCmLogUtil.js","sourceRoot":"","sources":["../src/AcCmLogUtil.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,IAAM,UAAU,GAAG,IAAI,CAAA;AAE9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,IAAM,GAAG,GAAG,QAAQ,CAAA;AAE3B,IAAI,UAAU,EAAE,CAAC;IACf,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;KAAM,CAAC;IACN,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACtB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAAa;IACvC,IAAI,CAAC;QACH,GAAG,CAAC,QAAQ,CAAC,KAA8B,CAAC,CAAA;IAC9C,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QACrB,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACf,CAAC;AACH,CAAC,CAAA"}
|
package/lib/AcCmObject.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Object model implementation for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a reactive object model with attribute management,
|
|
5
|
+
* change tracking, and event notification. Inspired by Backbone.js Model
|
|
6
|
+
* but with TypeScript support and reduced dependencies.
|
|
7
|
+
*
|
|
8
|
+
* @module AcCmObject
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
1
11
|
import { AcCmEventManager } from './AcCmEventManager';
|
|
2
12
|
export type AcCmAttributes = Record<string, any>;
|
|
3
13
|
/**
|
|
@@ -50,19 +60,63 @@ export declare class AcCmObject<T extends AcCmAttributes = any> {
|
|
|
50
60
|
*/
|
|
51
61
|
constructor(attributes?: Partial<T>, defaultAttrs?: Partial<T>);
|
|
52
62
|
/**
|
|
53
|
-
*
|
|
63
|
+
* Gets the value of an attribute.
|
|
64
|
+
*
|
|
65
|
+
* For strongly-typed access to attributes, use the `get` method privately in public getter properties.
|
|
66
|
+
*
|
|
67
|
+
* @template A - The key type extending string keys of T.
|
|
68
|
+
* @param {A} key - The attribute key to retrieve.
|
|
69
|
+
* @returns {T[A] | undefined} The attribute value or undefined if not set.
|
|
70
|
+
*
|
|
54
71
|
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Get a single attribute value
|
|
74
|
+
* const name = obj.get('name')
|
|
75
|
+
* const visible = obj.get('visible')
|
|
76
|
+
*
|
|
77
|
+
* // Check if attribute exists
|
|
78
|
+
* if (obj.get('name') !== undefined) {
|
|
79
|
+
* console.log('Name is set')
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* // For strongly-typed subclasses
|
|
55
83
|
* get name(): string {
|
|
56
|
-
*
|
|
84
|
+
* return super.get("name")
|
|
57
85
|
* }
|
|
86
|
+
* ```
|
|
58
87
|
*/
|
|
59
88
|
get<A extends AcCmStringKey<T>>(key: A): T[A] | undefined;
|
|
60
89
|
/**
|
|
61
|
-
*
|
|
90
|
+
* Sets one or more attributes on the object.
|
|
91
|
+
*
|
|
92
|
+
* For strongly-typed assignment of attributes, use the `set` method privately in public setter properties.
|
|
93
|
+
* Triggers change events unless the `silent` option is specified.
|
|
94
|
+
*
|
|
95
|
+
* @template A - The key type extending string keys of T.
|
|
96
|
+
* @param {A | Partial<T>} key - The attribute key or an object of key-value pairs.
|
|
97
|
+
* @param {T[A] | AcCmObjectOptions} [val] - The value to set or options when key is an object.
|
|
98
|
+
* @param {AcCmObjectOptions} [options] - Options for the set operation.
|
|
99
|
+
* @returns {this} The current instance for method chaining.
|
|
100
|
+
*
|
|
62
101
|
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* // Set a single attribute
|
|
104
|
+
* obj.set('name', 'MyEntity')
|
|
105
|
+
*
|
|
106
|
+
* // Set multiple attributes
|
|
107
|
+
* obj.set({ name: 'MyEntity', visible: true })
|
|
108
|
+
*
|
|
109
|
+
* // Set with options
|
|
110
|
+
* obj.set('name', 'MyEntity', { silent: true })
|
|
111
|
+
*
|
|
112
|
+
* // Unset an attribute
|
|
113
|
+
* obj.set('name', undefined, { unset: true })
|
|
114
|
+
*
|
|
115
|
+
* // For strongly-typed subclasses
|
|
63
116
|
* set name(value: string) {
|
|
64
|
-
*
|
|
117
|
+
* super.set("name", value)
|
|
65
118
|
* }
|
|
119
|
+
* ```
|
|
66
120
|
*/
|
|
67
121
|
set<A extends AcCmStringKey<T>>(key: A, val?: T[A], options?: AcCmObjectOptions): this;
|
|
68
122
|
set(key: Partial<T>, options?: AcCmObjectOptions): this;
|
package/lib/AcCmObject.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmObject.d.ts","sourceRoot":"","sources":["../src/AcCmObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIrD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAA;AAE/C;;GAEG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC,SAAS,cAAc;IAClE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;IACrB,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,mCAAmC,CAAC,CAAC,SAAS,cAAc,CAC3E,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,SAAS,CAAC,EAAE,GAAG,CAAA;CAChB;AAED;;;;;;;;;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G,IAAI,GAAG,SAAS;IAKrE;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC,CAAC,CAAC;IAIhC;;OAEG;IACH,KAAK;CAIN"}
|
package/lib/AcCmObject.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Object model implementation for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a reactive object model with attribute management,
|
|
5
|
+
* change tracking, and event notification. Inspired by Backbone.js Model
|
|
6
|
+
* but with TypeScript support and reduced dependencies.
|
|
7
|
+
*
|
|
8
|
+
* @module AcCmObject
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
1
11
|
import { AcCmEventManager } from './AcCmEventManager';
|
|
2
12
|
import { clone, defaults, has, isEmpty, isEqual } from './AcCmLodashUtils';
|
|
3
13
|
/**
|
|
@@ -34,11 +44,30 @@ var AcCmObject = /** @class */ (function () {
|
|
|
34
44
|
this.changed = {};
|
|
35
45
|
}
|
|
36
46
|
/**
|
|
37
|
-
*
|
|
47
|
+
* Gets the value of an attribute.
|
|
48
|
+
*
|
|
49
|
+
* For strongly-typed access to attributes, use the `get` method privately in public getter properties.
|
|
50
|
+
*
|
|
51
|
+
* @template A - The key type extending string keys of T.
|
|
52
|
+
* @param {A} key - The attribute key to retrieve.
|
|
53
|
+
* @returns {T[A] | undefined} The attribute value or undefined if not set.
|
|
54
|
+
*
|
|
38
55
|
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Get a single attribute value
|
|
58
|
+
* const name = obj.get('name')
|
|
59
|
+
* const visible = obj.get('visible')
|
|
60
|
+
*
|
|
61
|
+
* // Check if attribute exists
|
|
62
|
+
* if (obj.get('name') !== undefined) {
|
|
63
|
+
* console.log('Name is set')
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // For strongly-typed subclasses
|
|
39
67
|
* get name(): string {
|
|
40
|
-
*
|
|
68
|
+
* return super.get("name")
|
|
41
69
|
* }
|
|
70
|
+
* ```
|
|
42
71
|
*/
|
|
43
72
|
AcCmObject.prototype.get = function (key) {
|
|
44
73
|
return this.attributes[key];
|
package/lib/AcCmObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmObject.js","sourceRoot":"","sources":["../src/AcCmObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAiC1E;;;;;;;;;GASG;AACH,8DAA8D;AAC9D;IAaE;;;;;OAKG;IACH,oBAAY,UAAuB,EAAE,YAAyB;QAf9C,WAAM,GAAG;YACvB,WAAW,EAAE,IAAI,gBAAgB,EAA0C;YAC3E,YAAY,EAAE,IAAI,gBAAgB,EAAiC;SACpE,CAAA;QAEO,cAAS,GAAY,KAAK,CAAA;QAC1B,wBAAmB,GAAe,EAAE,CAAA;QACpC,aAAQ,GAAY,KAAK,CAAA;QAS/B,IAAM,KAAK,GAAG,UAAU,IAAI,EAAE,CAAA;QAC9B,IAAI,YAAY,EAAE,CAAC;YACjB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;QAC/B,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;IACnB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"AcCmObject.js","sourceRoot":"","sources":["../src/AcCmObject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAiC1E;;;;;;;;;GASG;AACH,8DAA8D;AAC9D;IAaE;;;;;OAKG;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,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QAC9D,IAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAA;QACvE,IAAM,OAAO,GAAe,EAAE,CAAA;QAC9B,KAAK,IAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,IAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;YACtB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;gBAAE,SAAQ;YACrC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;QACrB,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;OAEG;IACH,6BAAQ,GAAR,UAAqC,GAAM;QACzC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,mBAAmB;YAAE,OAAO,IAAI,CAAA;QACzD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;IACtC,CAAC;IAED;;OAEG;IACH,uCAAkB,GAAlB;QACE,OAAO,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL;QACE,IAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACpC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;IACH,iBAAC;AAAD,CAAC,AAtOD,IAsOC"}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Performance monitoring and collection system for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a singleton-based performance collector that can store,
|
|
5
|
+
* retrieve, and format performance metrics for debugging and optimization purposes.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmPerformanceCollector
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
1
10
|
/**
|
|
2
11
|
* A performance entry containing a unique name, associated data,
|
|
3
12
|
* and a method to format the data into a human-readable string.
|
|
4
13
|
*
|
|
5
|
-
* @template T The type of the performance data.
|
|
14
|
+
* @template T - The type of the performance data.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Create a custom performance entry
|
|
19
|
+
* const loadTimeEntry: AcCmPerformanceEntry<number> = {
|
|
20
|
+
* name: 'file-load-time',
|
|
21
|
+
* data: 1250, // milliseconds
|
|
22
|
+
* format() {
|
|
23
|
+
* return `File loaded in ${this.data}ms`
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
6
27
|
*/
|
|
7
28
|
export interface AcCmPerformanceEntry<T> {
|
|
8
29
|
/** Unique name of this performance entry. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmPerformanceCollector.d.ts","sourceRoot":"","sources":["../src/AcCmPerformanceCollector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AcCmPerformanceCollector.d.ts","sourceRoot":"","sources":["../src/AcCmPerformanceCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAA;IAEZ,uCAAuC;IACvC,IAAI,EAAE,CAAC,CAAA;IAEP;;;OAGG;IACH,MAAM,IAAI,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,8BAA8B;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IAEjD,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAwD;IAEvE;;OAEG;IACH,OAAO;IAEP;;;OAGG;WACW,WAAW,IAAI,wBAAwB;IAOrD;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAIvD;;OAEG;IACI,QAAQ,IAAI,IAAI;IAOvB;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;OAGG;IACI,MAAM,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE;IAIhD;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,SAAS;IAIxE;;;;OAIG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGrC"}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Performance monitoring and collection system for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a singleton-based performance collector that can store,
|
|
5
|
+
* retrieve, and format performance metrics for debugging and optimization purposes.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmPerformanceCollector
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
1
10
|
var __values = (this && this.__values) || function(o) {
|
|
2
11
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
12
|
if (m) return m.call(o);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmPerformanceCollector.js","sourceRoot":"","sources":["../src/AcCmPerformanceCollector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AcCmPerformanceCollector.js","sourceRoot":"","sources":["../src/AcCmPerformanceCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH;;;GAGG;AACH;IAOE;;OAEG;IACH;QANA,6DAA6D;QACrD,YAAO,GAA+C,IAAI,GAAG,EAAE,CAAA;IAKhD,CAAC;IAExB;;;OAGG;IACW,oCAAW,GAAzB;QACE,IAAI,CAAC,wBAAwB,CAAC,QAAQ,EAAE,CAAC;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|
|
3
|
+
*
|
|
4
|
+
* This module provides utility functions for common string operations,
|
|
5
|
+
* including formatting and conversion utilities.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmStringUtil
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Utility class providing static methods for string operations and formatting.
|
|
12
|
+
*
|
|
13
|
+
* Contains helper functions for data formatting, size conversions, and other
|
|
14
|
+
* string manipulation tasks commonly needed in AutoCAD file processing.
|
|
15
|
+
*
|
|
16
|
+
* @class AcTrStringUtil
|
|
17
|
+
* @version 1.0.0
|
|
18
|
+
*/
|
|
1
19
|
export declare class AcTrStringUtil {
|
|
2
20
|
/**
|
|
3
|
-
* Converts a byte count to a human-readable string using
|
|
21
|
+
* Converts a byte count to a human-readable string using appropriate size units.
|
|
4
22
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
23
|
+
* Automatically selects the most appropriate unit (B, KB, MB, GB, TB) based on the size
|
|
24
|
+
* and formats the result with the specified number of decimal places.
|
|
25
|
+
*
|
|
26
|
+
* @param {number} bytes - The number of bytes to format.
|
|
27
|
+
* @param {number} [decimals=2] - Number of decimal places to include in the result.
|
|
28
|
+
* @returns {string} A formatted string with the appropriate unit.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { AcTrStringUtil } from './AcCmStringUtil'
|
|
33
|
+
*
|
|
34
|
+
* // Format different byte sizes
|
|
35
|
+
* AcTrStringUtil.formatBytes(0) // "0 B"
|
|
36
|
+
* AcTrStringUtil.formatBytes(1024) // "1 KB"
|
|
37
|
+
* AcTrStringUtil.formatBytes(1024 * 1024) // "1 MB"
|
|
38
|
+
* AcTrStringUtil.formatBytes(1536, 1) // "1.5 KB"
|
|
39
|
+
* AcTrStringUtil.formatBytes(2048000, 0) // "2 MB"
|
|
40
|
+
* ```
|
|
8
41
|
*/
|
|
9
42
|
static formatBytes(bytes: number, decimals?: number): string;
|
|
10
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmStringUtil.d.ts","sourceRoot":"","sources":["../src/AcCmStringUtil.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;IACzB
|
|
1
|
+
{"version":3,"file":"AcCmStringUtil.d.ts","sourceRoot":"","sources":["../src/AcCmStringUtil.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM;CAYxD"}
|
package/lib/AcCmStringUtil.js
CHANGED
|
@@ -1,12 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview String manipulation utilities for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides utility functions for common string operations,
|
|
5
|
+
* including formatting and conversion utilities.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmStringUtil
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Utility class providing static methods for string operations and formatting.
|
|
12
|
+
*
|
|
13
|
+
* Contains helper functions for data formatting, size conversions, and other
|
|
14
|
+
* string manipulation tasks commonly needed in AutoCAD file processing.
|
|
15
|
+
*
|
|
16
|
+
* @class AcTrStringUtil
|
|
17
|
+
* @version 1.0.0
|
|
18
|
+
*/
|
|
1
19
|
var AcTrStringUtil = /** @class */ (function () {
|
|
2
20
|
function AcTrStringUtil() {
|
|
3
21
|
}
|
|
4
22
|
/**
|
|
5
|
-
* Converts a byte count to a human-readable string using
|
|
23
|
+
* Converts a byte count to a human-readable string using appropriate size units.
|
|
6
24
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
25
|
+
* Automatically selects the most appropriate unit (B, KB, MB, GB, TB) based on the size
|
|
26
|
+
* and formats the result with the specified number of decimal places.
|
|
27
|
+
*
|
|
28
|
+
* @param {number} bytes - The number of bytes to format.
|
|
29
|
+
* @param {number} [decimals=2] - Number of decimal places to include in the result.
|
|
30
|
+
* @returns {string} A formatted string with the appropriate unit.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { AcTrStringUtil } from './AcCmStringUtil'
|
|
35
|
+
*
|
|
36
|
+
* // Format different byte sizes
|
|
37
|
+
* AcTrStringUtil.formatBytes(0) // "0 B"
|
|
38
|
+
* AcTrStringUtil.formatBytes(1024) // "1 KB"
|
|
39
|
+
* AcTrStringUtil.formatBytes(1024 * 1024) // "1 MB"
|
|
40
|
+
* AcTrStringUtil.formatBytes(1536, 1) // "1.5 KB"
|
|
41
|
+
* AcTrStringUtil.formatBytes(2048000, 0) // "2 MB"
|
|
42
|
+
* ```
|
|
10
43
|
*/
|
|
11
44
|
AcTrStringUtil.formatBytes = function (bytes, decimals) {
|
|
12
45
|
if (decimals === void 0) { decimals = 2; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmStringUtil.js","sourceRoot":"","sources":["../src/AcCmStringUtil.ts"],"names":[],"mappings":"AAAA;IAAA;
|
|
1
|
+
{"version":3,"file":"AcCmStringUtil.js","sourceRoot":"","sources":["../src/AcCmStringUtil.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AACH;IAAA;IAmCA,CAAC;IAlCC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,0BAAW,GAAlB,UAAmB,KAAa,EAAE,QAAY;QAAZ,yBAAA,EAAA,YAAY;QAC5C,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;QAE7B,IAAM,CAAC,GAAG,IAAI,CAAA;QACd,IAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;QAChC,IAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAE3C,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACnD,IAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAEpC,OAAO,UAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,cAAI,KAAK,CAAC,CAAC,CAAC,CAAE,CAAA;IACvD,CAAC;IACH,qBAAC;AAAD,CAAC,AAnCD,IAmCC"}
|
|
@@ -1,42 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Task scheduling and execution system for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a type-safe task scheduler that can execute a chain of named tasks
|
|
5
|
+
* in sequence, with progress reporting, error handling, and data flow between tasks.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmTaskScheduler
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
1
10
|
/**
|
|
2
11
|
* Represents a named unit of work with an asynchronous or synchronous execution function.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* Tasks can be chained together in a scheduler to create complex workflows with
|
|
14
|
+
* proper data flow and error handling.
|
|
15
|
+
*
|
|
16
|
+
* @template TIn - Input type for the task.
|
|
17
|
+
* @template TOut - Output type for the task.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* class LoadFileTask extends AcCmTask<string, ArrayBuffer> {
|
|
22
|
+
* constructor() {
|
|
23
|
+
* super('LoadFile')
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* async run(url: string): Promise<ArrayBuffer> {
|
|
27
|
+
* const response = await fetch(url)
|
|
28
|
+
* return response.arrayBuffer()
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
5
32
|
*/
|
|
6
33
|
export declare class AcCmTask<TIn, TOut> {
|
|
7
34
|
/**
|
|
8
35
|
* Name of the task (for logging/debugging purposes)
|
|
9
36
|
*/
|
|
10
37
|
readonly name: string;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new task with the specified name.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} name - The name identifier for this task.
|
|
42
|
+
*/
|
|
11
43
|
constructor(name: string);
|
|
12
44
|
/**
|
|
13
|
-
* Executes the task.
|
|
45
|
+
* Executes the task with the given input.
|
|
46
|
+
*
|
|
47
|
+
* This method must be implemented by subclasses to define the actual work
|
|
48
|
+
* performed by the task. Can return either a synchronous result or a Promise.
|
|
49
|
+
*
|
|
50
|
+
* @param {TIn} _input - The input data for the task.
|
|
51
|
+
* @returns {TOut | Promise<TOut>} The task result, either synchronous or asynchronous.
|
|
52
|
+
* @throws {Error} When the method is not implemented by a subclass.
|
|
14
53
|
*/
|
|
15
54
|
run(_input: TIn): TOut | Promise<TOut>;
|
|
16
55
|
}
|
|
17
56
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
57
|
+
* Callback function that reports progress after a task completes.
|
|
58
|
+
*
|
|
59
|
+
* @param {number} progress - A number between 0 and 1 indicating task completion.
|
|
60
|
+
* @param {AcCmTask<unknown, unknown>} task - The task that was just completed.
|
|
21
61
|
*/
|
|
22
62
|
type AcCmProgressCallback = (progress: number, task: AcCmTask<unknown, unknown>) => void;
|
|
23
63
|
/**
|
|
24
|
-
* Callback function to handle final output.
|
|
64
|
+
* Callback function to handle the final output after all tasks complete successfully.
|
|
65
|
+
*
|
|
66
|
+
* @template T - The type of the final result.
|
|
67
|
+
* @param {T} finalResult - The final result from the task chain.
|
|
25
68
|
*/
|
|
26
69
|
export type AcCmCompleteCallback<T> = (finalResult: T) => void;
|
|
27
70
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param task
|
|
71
|
+
* Callback function that handles errors during task execution.
|
|
72
|
+
*
|
|
73
|
+
* @param {unknown} error - The error that was thrown.
|
|
74
|
+
* @param {number} taskIndex - Index of the failed task in the task queue.
|
|
75
|
+
* @param {AcCmTask<unknown, unknown>} task - The task that failed.
|
|
32
76
|
*/
|
|
33
77
|
type AcCmErrorCallback = (error: unknown, taskIndex: number, task: AcCmTask<unknown, unknown>) => void;
|
|
34
78
|
/**
|
|
35
|
-
* Type-safe task scheduler that executes a chain of named tasks in order
|
|
36
|
-
*
|
|
79
|
+
* Type-safe task scheduler that executes a chain of named tasks in order.
|
|
80
|
+
*
|
|
81
|
+
* The scheduler passes results between tasks, reports progress, and stops
|
|
82
|
+
* execution on the first failure. Supports both synchronous and asynchronous tasks.
|
|
83
|
+
*
|
|
84
|
+
* @template TInitial - Initial input type for the first task.
|
|
85
|
+
* @template TFinal - Final output type from the last task.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Create scheduler with string input and object output
|
|
90
|
+
* const scheduler = new AcCmTaskScheduler<string, ParsedData>()
|
|
91
|
+
*
|
|
92
|
+
* // Add tasks
|
|
93
|
+
* scheduler.addTask(new LoadFileTask())
|
|
94
|
+
* scheduler.addTask(new ParseDataTask())
|
|
95
|
+
* scheduler.addTask(new ValidateDataTask())
|
|
96
|
+
*
|
|
97
|
+
* // Set callbacks
|
|
98
|
+
* scheduler.setProgressCallback((progress, task) => {
|
|
99
|
+
* console.log(`${task.name}: ${(progress * 100).toFixed(1)}%`)
|
|
100
|
+
* })
|
|
101
|
+
*
|
|
102
|
+
* scheduler.setCompleteCallback((result) => {
|
|
103
|
+
* console.log('All tasks completed:', result)
|
|
104
|
+
* })
|
|
37
105
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
106
|
+
* // Execute
|
|
107
|
+
* await scheduler.execute('file.dwg')
|
|
108
|
+
* ```
|
|
40
109
|
*/
|
|
41
110
|
export declare class AcCmTaskScheduler<TInitial, TFinal = TInitial> {
|
|
42
111
|
private tasks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmTaskScheduler.d.ts","sourceRoot":"","sources":["../src/AcCmTaskScheduler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AcCmTaskScheduler.d.ts","sourceRoot":"","sources":["../src/AcCmTaskScheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,QAAQ,CAAC,GAAG,EAAE,IAAI;IAC7B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;;;OAIG;gBACS,IAAI,EAAE,MAAM;IAIxB;;;;;;;;;OASG;IACH,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvC;AAED;;;;;GAKG;AACH,KAAK,oBAAoB,GAAG,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,KAC7B,IAAI,CAAA;AAET;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,CAAA;AAE9D;;;;;;GAMG;AACH,KAAK,iBAAiB,GAAG,CACvB,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,KAC7B,IAAI,CAAA;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ;IACxD,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,UAAU,CAA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