@mlightcad/common 1.3.4 → 1.3.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.
Files changed (3) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +132 -132
  3. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 mlight-lee
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mlight-lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,133 +1,133 @@
1
- # @mlightcad/common
2
-
3
- The common package provides shared utilities and base classes that are used across the RealDWG-Web ecosystem. This package contains fundamental components for color management, event handling, logging, performance monitoring, and file loading operations.
4
-
5
- ## Overview
6
-
7
- This package serves as the foundation for the RealDWG-Web project, providing essential utilities and base classes that mimic AutoCAD ObjectARX's AcCm (Common) classes. It includes color management, event dispatching, logging utilities, performance monitoring, and file loading capabilities.
8
-
9
- ## Key Features
10
-
11
- - **Color Management**: Comprehensive color handling with support for AutoCAD color indices and RGB values
12
- - **Event System**: Event dispatching and management for decoupled communication between components
13
- - **Logging**: Structured logging utilities with different log levels
14
- - **Performance Monitoring**: Tools for collecting and analyzing performance metrics
15
- - **File Loading**: Asynchronous file loading with progress tracking and error handling
16
- - **Task Scheduling**: Background task management and scheduling capabilities
17
-
18
- ## Installation
19
-
20
- ```bash
21
- npm install @mlightcad/common
22
- ```
23
-
24
- ## Key Classes
25
-
26
- ### Color Management
27
- - **AcCmColor**: Represents colors in AutoCAD format with support for color indices and RGB values
28
- - **AcCmColorUtil**: Utility functions for color conversion and manipulation
29
-
30
- ### Event System
31
- - **AcCmEventDispatcher**: Dispatches events to registered listeners
32
- - **AcCmEventManager**: Manages event registration and dispatching across the application
33
-
34
- ### Logging and Utilities
35
- - **AcCmLogUtil**: Structured logging with different log levels (debug, info, warn, error)
36
- - **AcCmStringUtil**: String manipulation and formatting utilities
37
- - **AcCmErrors**: Error handling and custom error types
38
-
39
- ### Performance and Tasks
40
- - **AcCmPerformanceCollector**: Collects and analyzes performance metrics
41
- - **AcCmTaskScheduler**: Manages background tasks and scheduling
42
-
43
- ### File Loading
44
- - **AcCmFileLoader**: Handles asynchronous file loading with progress tracking
45
- - **AcCmLoadingManager**: Manages multiple file loading operations
46
- - **AcCmLoader**: Base class for implementing custom file loaders
47
-
48
- ### Base Classes
49
- - **AcCmObject**: Base class for common objects with event handling capabilities
50
-
51
- ## Usage Examples
52
-
53
- ### Color Management
54
- ```typescript
55
- import { AcCmColor, AcCmColorUtil } from '@mlightcad/common';
56
-
57
- // Create a color from AutoCAD color index
58
- const color = new AcCmColor(1); // Red
59
-
60
- // Create a color from RGB values
61
- const rgbColor = new AcCmColor(255, 0, 0);
62
-
63
- // Convert between formats
64
- const rgb = AcCmColorUtil.toRgb(color);
65
- const index = AcCmColorUtil.toColorIndex(rgbColor);
66
- ```
67
-
68
- ### Event Handling
69
- ```typescript
70
- import { AcCmEventManager, AcCmEventDispatcher } from '@mlightcad/common';
71
-
72
- // Create an event dispatcher
73
- const dispatcher = new AcCmEventDispatcher();
74
-
75
- // Register an event listener
76
- dispatcher.addEventListener('fileLoaded', (event) => {
77
- console.log('File loaded:', event.data);
78
- });
79
-
80
- // Dispatch an event
81
- dispatcher.dispatchEvent('fileLoaded', { fileName: 'drawing.dwg' });
82
- ```
83
-
84
- ### Logging
85
- ```typescript
86
- import { AcCmLogUtil } from '@mlightcad/common';
87
-
88
- // Configure logging
89
- AcCmLogUtil.setLevel('info');
90
-
91
- // Log messages
92
- AcCmLogUtil.info('Application started');
93
- AcCmLogUtil.warn('Deprecated feature used');
94
- AcCmLogUtil.error('Failed to load file', error);
95
- ```
96
-
97
- ### File Loading
98
- ```typescript
99
- import { AcCmFileLoader, AcCmLoadingManager } from '@mlightcad/common';
100
-
101
- // Create a file loader
102
- const loader = new AcCmFileLoader();
103
-
104
- // Load a file with progress tracking
105
- loader.load('drawing.dwg', {
106
- onProgress: (progress) => {
107
- console.log(`Loading: ${progress}%`);
108
- },
109
- onComplete: (data) => {
110
- console.log('File loaded successfully');
111
- },
112
- onError: (error) => {
113
- console.error('Failed to load file:', error);
114
- }
115
- });
116
-
117
- // Use loading manager for multiple files
118
- const manager = new AcCmLoadingManager();
119
- manager.addLoader(loader);
120
- manager.start();
121
- ```
122
-
123
- ## Dependencies
124
-
125
- - **loglevel**: For logging functionality
126
-
127
- ## API Documentation
128
-
129
- For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
130
-
131
- ## Contributing
132
-
1
+ # @mlightcad/common
2
+
3
+ The common package provides shared utilities and base classes that are used across the RealDWG-Web ecosystem. This package contains fundamental components for color management, event handling, logging, performance monitoring, and file loading operations.
4
+
5
+ ## Overview
6
+
7
+ This package serves as the foundation for the RealDWG-Web project, providing essential utilities and base classes that mimic AutoCAD ObjectARX's AcCm (Common) classes. It includes color management, event dispatching, logging utilities, performance monitoring, and file loading capabilities.
8
+
9
+ ## Key Features
10
+
11
+ - **Color Management**: Comprehensive color handling with support for AutoCAD color indices and RGB values
12
+ - **Event System**: Event dispatching and management for decoupled communication between components
13
+ - **Logging**: Structured logging utilities with different log levels
14
+ - **Performance Monitoring**: Tools for collecting and analyzing performance metrics
15
+ - **File Loading**: Asynchronous file loading with progress tracking and error handling
16
+ - **Task Scheduling**: Background task management and scheduling capabilities
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @mlightcad/common
22
+ ```
23
+
24
+ ## Key Classes
25
+
26
+ ### Color Management
27
+ - **AcCmColor**: Represents colors in AutoCAD format with support for color indices and RGB values
28
+ - **AcCmColorUtil**: Utility functions for color conversion and manipulation
29
+
30
+ ### Event System
31
+ - **AcCmEventDispatcher**: Dispatches events to registered listeners
32
+ - **AcCmEventManager**: Manages event registration and dispatching across the application
33
+
34
+ ### Logging and Utilities
35
+ - **AcCmLogUtil**: Structured logging with different log levels (debug, info, warn, error)
36
+ - **AcCmStringUtil**: String manipulation and formatting utilities
37
+ - **AcCmErrors**: Error handling and custom error types
38
+
39
+ ### Performance and Tasks
40
+ - **AcCmPerformanceCollector**: Collects and analyzes performance metrics
41
+ - **AcCmTaskScheduler**: Manages background tasks and scheduling
42
+
43
+ ### File Loading
44
+ - **AcCmFileLoader**: Handles asynchronous file loading with progress tracking
45
+ - **AcCmLoadingManager**: Manages multiple file loading operations
46
+ - **AcCmLoader**: Base class for implementing custom file loaders
47
+
48
+ ### Base Classes
49
+ - **AcCmObject**: Base class for common objects with event handling capabilities
50
+
51
+ ## Usage Examples
52
+
53
+ ### Color Management
54
+ ```typescript
55
+ import { AcCmColor, AcCmColorUtil } from '@mlightcad/common';
56
+
57
+ // Create a color from AutoCAD color index
58
+ const color = new AcCmColor(1); // Red
59
+
60
+ // Create a color from RGB values
61
+ const rgbColor = new AcCmColor(255, 0, 0);
62
+
63
+ // Convert between formats
64
+ const rgb = AcCmColorUtil.toRgb(color);
65
+ const index = AcCmColorUtil.toColorIndex(rgbColor);
66
+ ```
67
+
68
+ ### Event Handling
69
+ ```typescript
70
+ import { AcCmEventManager, AcCmEventDispatcher } from '@mlightcad/common';
71
+
72
+ // Create an event dispatcher
73
+ const dispatcher = new AcCmEventDispatcher();
74
+
75
+ // Register an event listener
76
+ dispatcher.addEventListener('fileLoaded', (event) => {
77
+ console.log('File loaded:', event.data);
78
+ });
79
+
80
+ // Dispatch an event
81
+ dispatcher.dispatchEvent('fileLoaded', { fileName: 'drawing.dwg' });
82
+ ```
83
+
84
+ ### Logging
85
+ ```typescript
86
+ import { AcCmLogUtil } from '@mlightcad/common';
87
+
88
+ // Configure logging
89
+ AcCmLogUtil.setLevel('info');
90
+
91
+ // Log messages
92
+ AcCmLogUtil.info('Application started');
93
+ AcCmLogUtil.warn('Deprecated feature used');
94
+ AcCmLogUtil.error('Failed to load file', error);
95
+ ```
96
+
97
+ ### File Loading
98
+ ```typescript
99
+ import { AcCmFileLoader, AcCmLoadingManager } from '@mlightcad/common';
100
+
101
+ // Create a file loader
102
+ const loader = new AcCmFileLoader();
103
+
104
+ // Load a file with progress tracking
105
+ loader.load('drawing.dwg', {
106
+ onProgress: (progress) => {
107
+ console.log(`Loading: ${progress}%`);
108
+ },
109
+ onComplete: (data) => {
110
+ console.log('File loaded successfully');
111
+ },
112
+ onError: (error) => {
113
+ console.error('Failed to load file:', error);
114
+ }
115
+ });
116
+
117
+ // Use loading manager for multiple files
118
+ const manager = new AcCmLoadingManager();
119
+ manager.addLoader(loader);
120
+ manager.start();
121
+ ```
122
+
123
+ ## Dependencies
124
+
125
+ - **loglevel**: For logging functionality
126
+
127
+ ## API Documentation
128
+
129
+ For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
130
+
131
+ ## Contributing
132
+
133
133
  This package is part of the RealDWG-Web monorepo. Please refer to the main project README for contribution guidelines.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/common",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {