@mlightcad/common 1.2.3 → 1.2.5
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 +1478 -0
- package/dist/common.umd.cjs +1 -0
- package/lib/AcCmColor.d.ts +201 -0
- package/lib/AcCmColor.d.ts.map +1 -0
- package/lib/AcCmColor.js +641 -0
- package/lib/AcCmColor.js.map +1 -0
- package/lib/AcCmColorUtil.d.ts +41 -0
- package/lib/AcCmColorUtil.d.ts.map +1 -0
- package/lib/AcCmColorUtil.js +90 -0
- package/lib/AcCmColorUtil.js.map +1 -0
- package/lib/AcCmErrors.d.ts +56 -0
- package/lib/AcCmErrors.d.ts.map +1 -0
- package/lib/AcCmErrors.js +70 -0
- package/lib/AcCmErrors.js.map +1 -0
- package/lib/AcCmEventDispatcher.d.ts +101 -0
- package/lib/AcCmEventDispatcher.d.ts.map +1 -0
- package/lib/AcCmEventDispatcher.js +97 -0
- package/lib/AcCmEventDispatcher.js.map +1 -0
- package/lib/AcCmEventManager.d.ts +66 -0
- package/lib/AcCmEventManager.d.ts.map +1 -0
- package/lib/AcCmEventManager.js +133 -0
- package/lib/AcCmEventManager.js.map +1 -0
- package/lib/AcCmLodashUtils.d.ts +145 -0
- package/lib/AcCmLodashUtils.d.ts.map +1 -0
- package/lib/AcCmLodashUtils.js +293 -0
- package/lib/AcCmLodashUtils.js.map +1 -0
- package/lib/AcCmLogUtil.d.ts +80 -0
- package/lib/AcCmLogUtil.d.ts.map +1 -0
- package/lib/AcCmLogUtil.js +72 -0
- package/lib/AcCmLogUtil.js.map +1 -0
- package/lib/AcCmObject.d.ts +150 -0
- package/lib/AcCmObject.d.ts.map +1 -0
- package/lib/AcCmObject.js +204 -0
- package/lib/AcCmObject.js.map +1 -0
- package/lib/AcCmPerformanceCollector.d.ts +89 -0
- package/lib/AcCmPerformanceCollector.d.ts.map +1 -0
- package/lib/AcCmPerformanceCollector.js +119 -0
- package/lib/AcCmPerformanceCollector.js.map +1 -0
- package/lib/AcCmStringUtil.d.ts +44 -0
- package/lib/AcCmStringUtil.d.ts.map +1 -0
- package/lib/AcCmStringUtil.js +58 -0
- package/lib/AcCmStringUtil.js.map +1 -0
- package/lib/AcCmTaskScheduler.d.ts +188 -0
- package/lib/AcCmTaskScheduler.d.ts.map +1 -0
- package/lib/AcCmTaskScheduler.js +256 -0
- package/lib/AcCmTaskScheduler.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/loader/AcCmFileLoader.d.ts +95 -0
- package/lib/loader/AcCmFileLoader.d.ts.map +1 -0
- package/lib/loader/AcCmFileLoader.js +275 -0
- package/lib/loader/AcCmFileLoader.js.map +1 -0
- package/lib/loader/AcCmLoader.d.ts +125 -0
- package/lib/loader/AcCmLoader.d.ts.map +1 -0
- package/lib/loader/AcCmLoader.js +116 -0
- package/lib/loader/AcCmLoader.js.map +1 -0
- package/lib/loader/AcCmLoadingManager.d.ts +166 -0
- package/lib/loader/AcCmLoadingManager.d.ts.map +1 -0
- package/lib/loader/AcCmLoadingManager.js +172 -0
- package/lib/loader/AcCmLoadingManager.js.map +1 -0
- package/lib/loader/index.d.ts +3 -0
- package/lib/loader/index.d.ts.map +1 -0
- package/lib/loader/index.js +3 -0
- package/lib/loader/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Utility functions for AutoCAD color index mapping and manipulation.
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to convert between AutoCAD color indices and RGB values,
|
|
5
|
+
* supporting the standard AutoCAD color palette used in DWG files.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmColorUtil
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Utility class for AutoCAD color index operations.
|
|
12
|
+
*
|
|
13
|
+
* Provides static methods to convert between AutoCAD color indices and RGB values,
|
|
14
|
+
* supporting the standard 256-color palette used in AutoCAD files.
|
|
15
|
+
*
|
|
16
|
+
* @class AcCmColorUtil
|
|
17
|
+
* @version 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
export declare class AcCmColorUtil {
|
|
20
|
+
/**
|
|
21
|
+
* Returns the RGB color value for a given AutoCAD color index.
|
|
22
|
+
*
|
|
23
|
+
* @param {number} index - The AutoCAD color index value (0-255).
|
|
24
|
+
* @returns {number} The RGB color value as a 24-bit integer.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Get the RGB value for color index 1 (red)
|
|
29
|
+
* const redColor = AcCmColorUtil.getAcadColor(1); // returns 16711680 (0xFF0000)
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Get special inheritance colors
|
|
35
|
+
* const byBlock = AcCmColorUtil.getAcadColor(0); // "ByBlock" color
|
|
36
|
+
* const byLayer = AcCmColorUtil.getAcadColor(256); // "ByLayer" color
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
static getAcadColor(index: number): number;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=AcCmColorUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmColorUtil.d.ts","sourceRoot":"","sources":["../src/AcCmColorUtil.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8CH;;;;;;;;GAQG;AACH,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM;CAGlC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Utility functions for AutoCAD color index mapping and manipulation.
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to convert between AutoCAD color indices and RGB values,
|
|
5
|
+
* supporting the standard AutoCAD color palette used in DWG files.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmColorUtil
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* AutoCAD color index array mapping index values (1-255) to RGB color values.
|
|
12
|
+
* Each value corresponds to a color. Index 1 is red, that is 16711680 or 0xFF0000.
|
|
13
|
+
* Index 0 and 256, while included in this array, are actually reserved for inheritance
|
|
14
|
+
* values in AutoCAD so they should not be used for index color lookups:
|
|
15
|
+
* - Index 0: "ByBlock" - entity uses color of the block reference
|
|
16
|
+
* - Index 256: "ByLayer" - entity uses color specified in the layer
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
var AUTO_CAD_COLOR_INDEX = [
|
|
21
|
+
0, 16711680, 16776960, 65280, 65535, 255, 16711935, 16777215, 8421504,
|
|
22
|
+
12632256, 16711680, 16744319, 13369344, 13395558, 10027008, 10046540, 8323072,
|
|
23
|
+
8339263, 4980736, 4990502, 16727808, 16752511, 13382400, 13401958, 10036736,
|
|
24
|
+
10051404, 8331008, 8343359, 4985600, 4992806, 16744192, 16760703, 13395456,
|
|
25
|
+
13408614, 10046464, 10056268, 8339200, 8347455, 4990464, 4995366, 16760576,
|
|
26
|
+
16768895, 13408512, 13415014, 10056192, 10061132, 8347392, 8351551, 4995328,
|
|
27
|
+
4997670, 16776960, 16777087, 13421568, 13421670, 10000384, 10000460, 8355584,
|
|
28
|
+
8355647, 5000192, 5000230, 12582656, 14679935, 10079232, 11717734, 7510016,
|
|
29
|
+
8755276, 6258432, 7307071, 3755008, 4344870, 8388352, 12582783, 6736896,
|
|
30
|
+
10079334, 5019648, 7510092, 4161280, 6258495, 2509824, 3755046, 4194048,
|
|
31
|
+
10485631, 3394560, 8375398, 2529280, 6264908, 2064128, 5209919, 1264640,
|
|
32
|
+
3099686, 65280, 8388479, 52224, 6736998, 38912, 5019724, 32512, 4161343,
|
|
33
|
+
19456, 2509862, 65343, 8388511, 52275, 6737023, 38950, 5019743, 32543,
|
|
34
|
+
4161359, 19475, 2509871, 65407, 8388543, 52326, 6737049, 38988, 5019762,
|
|
35
|
+
32575, 4161375, 19494, 2509881, 65471, 8388575, 52377, 6737074, 39026,
|
|
36
|
+
5019781, 32607, 4161391, 19513, 2509890, 65535, 8388607, 52428, 6737100,
|
|
37
|
+
39064, 5019800, 32639, 4161407, 19532, 2509900, 49151, 8380415, 39372,
|
|
38
|
+
6730444, 29336, 5014936, 24447, 4157311, 14668, 2507340, 32767, 8372223,
|
|
39
|
+
26316, 6724044, 19608, 5010072, 16255, 4153215, 9804, 2505036, 16383, 8364031,
|
|
40
|
+
13260, 6717388, 9880, 5005208, 8063, 4149119, 4940, 2502476, 255, 8355839,
|
|
41
|
+
204, 6710988, 152, 5000344, 127, 4145023, 76, 2500172, 4129023, 10452991,
|
|
42
|
+
3342540, 8349388, 2490520, 6245528, 2031743, 5193599, 1245260, 3089996,
|
|
43
|
+
8323327, 12550143, 6684876, 10053324, 4980888, 7490712, 4128895, 6242175,
|
|
44
|
+
2490444, 3745356, 12517631, 14647295, 10027212, 11691724, 7471256, 8735896,
|
|
45
|
+
6226047, 7290751, 3735628, 4335180, 16711935, 16744447, 13369548, 13395660,
|
|
46
|
+
9961624, 9981080, 8323199, 8339327, 4980812, 4990540, 16711871, 16744415,
|
|
47
|
+
13369497, 13395634, 9961586, 9981061, 8323167, 8339311, 4980793, 4990530,
|
|
48
|
+
16711807, 16744383, 13369446, 13395609, 9961548, 9981042, 8323135, 8339295,
|
|
49
|
+
4980774, 4990521, 16711743, 16744351, 13369395, 13395583, 9961510, 9981023,
|
|
50
|
+
8323103, 8339279, 4980755, 4990511, 3355443, 5987163, 8684676, 11382189,
|
|
51
|
+
14079702, 16777215
|
|
52
|
+
];
|
|
53
|
+
/**
|
|
54
|
+
* Utility class for AutoCAD color index operations.
|
|
55
|
+
*
|
|
56
|
+
* Provides static methods to convert between AutoCAD color indices and RGB values,
|
|
57
|
+
* supporting the standard 256-color palette used in AutoCAD files.
|
|
58
|
+
*
|
|
59
|
+
* @class AcCmColorUtil
|
|
60
|
+
* @version 1.0.0
|
|
61
|
+
*/
|
|
62
|
+
var AcCmColorUtil = /** @class */ (function () {
|
|
63
|
+
function AcCmColorUtil() {
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the RGB color value for a given AutoCAD color index.
|
|
67
|
+
*
|
|
68
|
+
* @param {number} index - The AutoCAD color index value (0-255).
|
|
69
|
+
* @returns {number} The RGB color value as a 24-bit integer.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Get the RGB value for color index 1 (red)
|
|
74
|
+
* const redColor = AcCmColorUtil.getAcadColor(1); // returns 16711680 (0xFF0000)
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Get special inheritance colors
|
|
80
|
+
* const byBlock = AcCmColorUtil.getAcadColor(0); // "ByBlock" color
|
|
81
|
+
* const byLayer = AcCmColorUtil.getAcadColor(256); // "ByLayer" color
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
AcCmColorUtil.getAcadColor = function (index) {
|
|
85
|
+
return AUTO_CAD_COLOR_INDEX[index];
|
|
86
|
+
};
|
|
87
|
+
return AcCmColorUtil;
|
|
88
|
+
}());
|
|
89
|
+
export { AcCmColorUtil };
|
|
90
|
+
//# sourceMappingURL=AcCmColorUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmColorUtil.js","sourceRoot":"","sources":["../src/AcCmColorUtil.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;GASG;AACH,IAAM,oBAAoB,GAAG;IAC3B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO;IACr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AO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IAC1E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IACxE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;IACxE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;IAC1E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;IAC1E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ;IACvE,QAAQ,EAAE,QAAQ;CACnB,CAAA;AAED;;;;;;;;GAQG;AACH;IAAA;IAuBA,CAAC;IAtBC;;;;;;;;;;;;;;;;;;OAkBG;IACI,0BAAY,GAAnB,UAAoB,KAAa;QAC/B,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACH,oBAAC;AAAD,CAAC,AAvBD,IAuBC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Standard error definitions for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a centralized collection of commonly used error types
|
|
5
|
+
* with descriptive messages for consistent error handling across the library.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmErrors
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Collection of standard error types used throughout the AutoCAD Common library.
|
|
12
|
+
*
|
|
13
|
+
* Each error getter returns a new instance of the error to prevent shared state issues.
|
|
14
|
+
* Use these predefined errors for consistent error handling and messaging.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { AcCmErrors } from './AcCmErrors'
|
|
19
|
+
*
|
|
20
|
+
* // Throw standard errors
|
|
21
|
+
* throw AcCmErrors.ILLEGAL_PARAMETERS
|
|
22
|
+
* throw AcCmErrors.NOT_IMPLEMENTED
|
|
23
|
+
*
|
|
24
|
+
* // Check error types
|
|
25
|
+
* try {
|
|
26
|
+
* // some operation
|
|
27
|
+
* } catch (error) {
|
|
28
|
+
* if (error.message === AcCmErrors.ZERO_DIVISION.message) {
|
|
29
|
+
* // handle division by zero
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const AcCmErrors: {
|
|
35
|
+
/**
|
|
36
|
+
* Throw error ILLEGAL_PARAMETERS when cannot instantiate from given parameter
|
|
37
|
+
*/
|
|
38
|
+
readonly ILLEGAL_PARAMETERS: ReferenceError;
|
|
39
|
+
/**
|
|
40
|
+
* Throw error ZERO_DIVISION to catch situation of zero division
|
|
41
|
+
*/
|
|
42
|
+
readonly ZERO_DIVISION: Error;
|
|
43
|
+
/**
|
|
44
|
+
* Error to throw from BooleanOperations module in case when fixBoundaryConflicts not capable to fix it
|
|
45
|
+
*/
|
|
46
|
+
readonly UNRESOLVED_BOUNDARY_CONFLICT: Error;
|
|
47
|
+
/**
|
|
48
|
+
* Error to throw from LinkedList:testInfiniteLoop static method
|
|
49
|
+
* in case when circular loop detected in linked list
|
|
50
|
+
*/
|
|
51
|
+
readonly INFINITE_LOOP: Error;
|
|
52
|
+
readonly CANNOT_INVOKE_ABSTRACT_METHOD: Error;
|
|
53
|
+
readonly OPERATION_IS_NOT_SUPPORTED: Error;
|
|
54
|
+
readonly NOT_IMPLEMENTED: Error;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=AcCmErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmErrors.d.ts","sourceRoot":"","sources":["../src/AcCmErrors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;;IAKH;;OAEG;;IAKH;;OAEG;;IAKH;;;OAGG;;;;;CAgBJ,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Standard error definitions for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a centralized collection of commonly used error types
|
|
5
|
+
* with descriptive messages for consistent error handling across the library.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmErrors
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Collection of standard error types used throughout the AutoCAD Common library.
|
|
12
|
+
*
|
|
13
|
+
* Each error getter returns a new instance of the error to prevent shared state issues.
|
|
14
|
+
* Use these predefined errors for consistent error handling and messaging.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { AcCmErrors } from './AcCmErrors'
|
|
19
|
+
*
|
|
20
|
+
* // Throw standard errors
|
|
21
|
+
* throw AcCmErrors.ILLEGAL_PARAMETERS
|
|
22
|
+
* throw AcCmErrors.NOT_IMPLEMENTED
|
|
23
|
+
*
|
|
24
|
+
* // Check error types
|
|
25
|
+
* try {
|
|
26
|
+
* // some operation
|
|
27
|
+
* } catch (error) {
|
|
28
|
+
* if (error.message === AcCmErrors.ZERO_DIVISION.message) {
|
|
29
|
+
* // handle division by zero
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export var AcCmErrors = {
|
|
35
|
+
/**
|
|
36
|
+
* Throw error ILLEGAL_PARAMETERS when cannot instantiate from given parameter
|
|
37
|
+
*/
|
|
38
|
+
get ILLEGAL_PARAMETERS() {
|
|
39
|
+
return new ReferenceError('Illegal Parameters');
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Throw error ZERO_DIVISION to catch situation of zero division
|
|
43
|
+
*/
|
|
44
|
+
get ZERO_DIVISION() {
|
|
45
|
+
return new Error('Zero division');
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Error to throw from BooleanOperations module in case when fixBoundaryConflicts not capable to fix it
|
|
49
|
+
*/
|
|
50
|
+
get UNRESOLVED_BOUNDARY_CONFLICT() {
|
|
51
|
+
return new Error('Unresolved boundary conflict in boolean operation');
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Error to throw from LinkedList:testInfiniteLoop static method
|
|
55
|
+
* in case when circular loop detected in linked list
|
|
56
|
+
*/
|
|
57
|
+
get INFINITE_LOOP() {
|
|
58
|
+
return new Error('Infinite loop');
|
|
59
|
+
},
|
|
60
|
+
get CANNOT_INVOKE_ABSTRACT_METHOD() {
|
|
61
|
+
return new Error('Abstract method cannot be invoked');
|
|
62
|
+
},
|
|
63
|
+
get OPERATION_IS_NOT_SUPPORTED() {
|
|
64
|
+
return new Error('Operation is not supported');
|
|
65
|
+
},
|
|
66
|
+
get NOT_IMPLEMENTED() {
|
|
67
|
+
return new Error('Not implemented yet');
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=AcCmErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmErrors.js","sourceRoot":"","sources":["../src/AcCmErrors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,IAAM,UAAU,GAAG;IACxB;;OAEG;IACH,IAAI,kBAAkB;QACpB,OAAO,IAAI,cAAc,CAAC,oBAAoB,CAAC,CAAA;IACjD,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,4BAA4B;QAC9B,OAAO,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;IACvE,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IACnC,CAAC;IAED,IAAI,6BAA6B;QAC/B,OAAO,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IACvD,CAAC;IAED,IAAI,0BAA0B;QAC5B,OAAO,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACzC,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Event system implementation for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a type-safe event dispatcher system that allows objects to
|
|
5
|
+
* emit and listen to events with proper TypeScript typing support.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmEventDispatcher
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The minimal basic Event that can be dispatched by a {@link AcCmEventDispatcher<>}.
|
|
12
|
+
*
|
|
13
|
+
* @template TEventType - The string literal type of the event.
|
|
14
|
+
*/
|
|
15
|
+
export interface AcCmBaseEvent<TEventType extends string = string> {
|
|
16
|
+
/** The type identifier for this event. */
|
|
17
|
+
readonly type: TEventType;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The minimal expected contract of a fired Event that was dispatched by a {@link AcCmEventDispatcher<>}.
|
|
21
|
+
*
|
|
22
|
+
* @template TEventType - The string literal type of the event.
|
|
23
|
+
* @template TTarget - The type of the object that dispatched the event.
|
|
24
|
+
*/
|
|
25
|
+
export interface AcCmEvent<TEventType extends string = string, TTarget = unknown> {
|
|
26
|
+
/** The type identifier for this event. */
|
|
27
|
+
readonly type: TEventType;
|
|
28
|
+
/** The object that dispatched this event. */
|
|
29
|
+
readonly target: TTarget;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Type definition for event listener functions.
|
|
33
|
+
*
|
|
34
|
+
* @template TEventData - The data payload type for the event.
|
|
35
|
+
* @template TEventType - The string literal type of the event.
|
|
36
|
+
* @template TTarget - The type of the object that dispatched the event.
|
|
37
|
+
*/
|
|
38
|
+
export type AcCmEventListener<TEventData, TEventType extends string, TTarget> = (event: TEventData & AcCmEvent<TEventType, TTarget>) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Type-safe event dispatcher implementation.
|
|
41
|
+
*
|
|
42
|
+
* Provides a robust event system that allows objects to emit and listen to events
|
|
43
|
+
* with full TypeScript type safety. Supports both typed event maps and dynamic events.
|
|
44
|
+
*
|
|
45
|
+
* @template TEventMap - A record type mapping event names to their data payloads.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Define event types
|
|
50
|
+
* interface MyEvents {
|
|
51
|
+
* load: { url: string }
|
|
52
|
+
* error: { message: string }
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // Create dispatcher
|
|
56
|
+
* const dispatcher = new AcCmEventDispatcher<MyEvents>()
|
|
57
|
+
*
|
|
58
|
+
* // Add listeners
|
|
59
|
+
* dispatcher.addEventListener('load', (event) => {
|
|
60
|
+
* console.log(`Loaded: ${event.url}`)
|
|
61
|
+
* })
|
|
62
|
+
*
|
|
63
|
+
* // Dispatch events
|
|
64
|
+
* dispatcher.dispatchEvent({ type: 'load', url: 'test.dwg' })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare class AcCmEventDispatcher<TEventMap extends {} = {}> {
|
|
68
|
+
/**
|
|
69
|
+
* Index a record of all callback functions
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
private _listeners;
|
|
73
|
+
/**
|
|
74
|
+
* Creates {@link AcCmEventDispatcher} object.
|
|
75
|
+
*/
|
|
76
|
+
constructor();
|
|
77
|
+
/**
|
|
78
|
+
* Add a listener to an event type.
|
|
79
|
+
* @param type The type of event to listen to.
|
|
80
|
+
* @param listener The function that gets called when the event is fired.
|
|
81
|
+
*/
|
|
82
|
+
addEventListener<T extends Extract<keyof TEventMap, string>>(type: T, listener: AcCmEventListener<TEventMap[T], T, this>): void;
|
|
83
|
+
/**
|
|
84
|
+
* Check if listener is added to an event type.
|
|
85
|
+
* @param type The type of event to listen to.
|
|
86
|
+
* @param listener The function that gets called when the event is fired.
|
|
87
|
+
*/
|
|
88
|
+
hasEventListener<T extends Extract<keyof TEventMap, string>>(type: T, listener: AcCmEventListener<TEventMap[T], T, this>): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Remove a listener from an event type.
|
|
91
|
+
* @param type The type of the listener that gets removed.
|
|
92
|
+
* @param listener The listener function that gets removed.
|
|
93
|
+
*/
|
|
94
|
+
removeEventListener<T extends Extract<keyof TEventMap, string>>(type: T, listener: AcCmEventListener<TEventMap[T], T, this>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Fire an event type.
|
|
97
|
+
* @param event The event that gets fired.
|
|
98
|
+
*/
|
|
99
|
+
dispatchEvent<T extends Extract<keyof TEventMap, string>>(event: AcCmBaseEvent<T> & TEventMap[T]): void;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=AcCmEventDispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmEventDispatcher.d.ts","sourceRoot":"","sources":["../src/AcCmEventDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM;IAC/D,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS,CACxB,UAAU,SAAS,MAAM,GAAG,MAAM,EAClC,OAAO,GA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AC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GACrC,IAAI;CAkBR"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Event system implementation for the AutoCAD Common library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a type-safe event dispatcher system that allows objects to
|
|
5
|
+
* emit and listen to events with proper TypeScript typing support.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmEventDispatcher
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Type-safe event dispatcher implementation.
|
|
12
|
+
*
|
|
13
|
+
* Provides a robust event system that allows objects to emit and listen to events
|
|
14
|
+
* with full TypeScript type safety. Supports both typed event maps and dynamic events.
|
|
15
|
+
*
|
|
16
|
+
* @template TEventMap - A record type mapping event names to their data payloads.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Define event types
|
|
21
|
+
* interface MyEvents {
|
|
22
|
+
* load: { url: string }
|
|
23
|
+
* error: { message: string }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Create dispatcher
|
|
27
|
+
* const dispatcher = new AcCmEventDispatcher<MyEvents>()
|
|
28
|
+
*
|
|
29
|
+
* // Add listeners
|
|
30
|
+
* dispatcher.addEventListener('load', (event) => {
|
|
31
|
+
* console.log(`Loaded: ${event.url}`)
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* // Dispatch events
|
|
35
|
+
* dispatcher.dispatchEvent({ type: 'load', url: 'test.dwg' })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
// eslint-disable-next-line
|
|
39
|
+
var AcCmEventDispatcher = /** @class */ (function () {
|
|
40
|
+
/**
|
|
41
|
+
* Creates {@link AcCmEventDispatcher} object.
|
|
42
|
+
*/
|
|
43
|
+
function AcCmEventDispatcher() {
|
|
44
|
+
this._listeners = {};
|
|
45
|
+
}
|
|
46
|
+
AcCmEventDispatcher.prototype.addEventListener = function (type, listener) {
|
|
47
|
+
if (this._listeners === undefined)
|
|
48
|
+
this._listeners = {};
|
|
49
|
+
var listeners = this._listeners;
|
|
50
|
+
if (listeners[type] === undefined) {
|
|
51
|
+
listeners[type] = [];
|
|
52
|
+
}
|
|
53
|
+
if (listeners[type].indexOf(listener) === -1) {
|
|
54
|
+
listeners[type].push(listener);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
AcCmEventDispatcher.prototype.hasEventListener = function (type, listener) {
|
|
58
|
+
if (this._listeners === undefined)
|
|
59
|
+
return false;
|
|
60
|
+
var listeners = this._listeners;
|
|
61
|
+
return (listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1);
|
|
62
|
+
};
|
|
63
|
+
AcCmEventDispatcher.prototype.removeEventListener = function (type, listener) {
|
|
64
|
+
if (this._listeners === undefined)
|
|
65
|
+
return;
|
|
66
|
+
var listeners = this._listeners;
|
|
67
|
+
var listenerArray = listeners[type];
|
|
68
|
+
if (listenerArray !== undefined) {
|
|
69
|
+
var index = listenerArray.indexOf(listener);
|
|
70
|
+
if (index !== -1) {
|
|
71
|
+
listenerArray.splice(index, 1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Fire an event type.
|
|
77
|
+
* @param event The event that gets fired.
|
|
78
|
+
*/
|
|
79
|
+
AcCmEventDispatcher.prototype.dispatchEvent = function (event) {
|
|
80
|
+
if (this._listeners === undefined)
|
|
81
|
+
return;
|
|
82
|
+
var listeners = this._listeners;
|
|
83
|
+
var listenerArray = listeners[event.type];
|
|
84
|
+
if (listenerArray !== undefined) {
|
|
85
|
+
// @ts-expect-error add target property
|
|
86
|
+
event.target = this;
|
|
87
|
+
// Make a copy, in case listeners are removed while iterating.
|
|
88
|
+
var array = listenerArray.slice(0);
|
|
89
|
+
for (var i = 0, l = array.length; i < l; i++) {
|
|
90
|
+
array[i].call(this, event);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return AcCmEventDispatcher;
|
|
95
|
+
}());
|
|
96
|
+
export { AcCmEventDispatcher };
|
|
97
|
+
//# sourceMappingURL=AcCmEventDispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmEventDispatcher.js","sourceRoot":"","sources":["../src/AcCmEventDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyCH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,2BAA2B;AAC3B;IAUE;;OAEG;IACH;QACE,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;IACtB,CAAC;IAWD,8CAAgB,GAAhB,UACE,IAAO,EACP,QAA4C;QAE5C,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QAEvD,IAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAA;QAEjC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAClC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,CAAC;QAED,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAC7C,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;IAWD,8CAAgB,GAAhB,UACE,IAAO,EACP,QAA4C;QAE5C,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;YAAE,OAAO,KAAK,CAAA;QAE/C,IAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAA;QAEjC,OAAO,CACL,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAC1E,CAAA;IACH,CAA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
3
|
+
*
|
|
4
|
+
* This module provides a lightweight event management system for handling
|
|
5
|
+
* listeners and dispatching events with type-safe payload support.
|
|
6
|
+
*
|
|
7
|
+
* @module AcCmEventManager
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Simple event manager for handling event listeners and dispatching events.
|
|
12
|
+
*
|
|
13
|
+
* Provides a lightweight alternative to the more complex AcCmEventDispatcher
|
|
14
|
+
* for cases where you need basic event handling with type-safe payloads.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The type of the event payload.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Create an event manager for string payloads
|
|
21
|
+
* const manager = new AcCmEventManager<string>()
|
|
22
|
+
*
|
|
23
|
+
* // Add a listener
|
|
24
|
+
* manager.addEventListener((message) => {
|
|
25
|
+
* console.log('Received:', message)
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // Dispatch an event
|
|
29
|
+
* manager.dispatch('Hello, World!')
|
|
30
|
+
*
|
|
31
|
+
* // For complex payloads
|
|
32
|
+
* interface LoadEvent {
|
|
33
|
+
* url: string
|
|
34
|
+
* progress: number
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* const loadManager = new AcCmEventManager<LoadEvent>()
|
|
38
|
+
* loadManager.addEventListener(({ url, progress }) => {
|
|
39
|
+
* console.log(`Loading ${url}: ${progress}%`)
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class AcCmEventManager<T = unknown> {
|
|
44
|
+
private listeners;
|
|
45
|
+
/**
|
|
46
|
+
* Add the event listener
|
|
47
|
+
* @param listener Input listener to be added
|
|
48
|
+
*/
|
|
49
|
+
addEventListener(listener: (payload: T) => void): void;
|
|
50
|
+
/**
|
|
51
|
+
* Remove the listener
|
|
52
|
+
* @param listener Input listener to be removed
|
|
53
|
+
*/
|
|
54
|
+
removeEventListener(listener: (payload: T) => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* Remove all listeners bound to the target and add one new listener
|
|
57
|
+
* @param listener Input listener to be added
|
|
58
|
+
*/
|
|
59
|
+
replaceEventListener(listener: (payload: T) => void): void;
|
|
60
|
+
/**
|
|
61
|
+
* Notify all listeners
|
|
62
|
+
* @param payload Input payload passed to listener
|
|
63
|
+
*/
|
|
64
|
+
dispatch(payload?: T, ...args: unknown[]): void;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=AcCmEventManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmEventManager.d.ts","sourceRoot":"","sources":["../src/AcCmEventManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,gBAAgB,CAAC,CAAC,GAAG,OAAO;IACvC,OAAO,CAAC,SAAS,CAA+B;IAEhD;;;OAGG;IACI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI;IAItD;;;OAGG;IACI,mBAAmB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI;IAIzD;;;OAGG;IACI,oBAAoB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI;IAK1D;;;OAGG;IACI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;CAMhD"}
|