@nmmty/lazycanvas 0.6.0 → 0.6.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.
Files changed (59) hide show
  1. package/dist/helpers/index.d.ts +3 -0
  2. package/dist/helpers/index.js +19 -0
  3. package/dist/index.d.ts +5 -12
  4. package/dist/index.js +5 -31
  5. package/dist/structures/LazyCanvas.d.ts +12 -16
  6. package/dist/structures/LazyCanvas.js +24 -27
  7. package/dist/structures/components/BaseLayer.d.ts +17 -25
  8. package/dist/structures/components/BaseLayer.js +16 -18
  9. package/dist/structures/components/BezierLayer.d.ts +29 -21
  10. package/dist/structures/components/BezierLayer.js +22 -20
  11. package/dist/structures/components/ClearLayer.d.ts +15 -15
  12. package/dist/structures/components/ClearLayer.js +14 -14
  13. package/dist/structures/components/Group.d.ts +10 -11
  14. package/dist/structures/components/Group.js +9 -10
  15. package/dist/structures/components/ImageLayer.d.ts +15 -15
  16. package/dist/structures/components/ImageLayer.js +11 -11
  17. package/dist/structures/components/LineLayer.d.ts +28 -20
  18. package/dist/structures/components/LineLayer.js +21 -19
  19. package/dist/structures/components/MorphLayer.d.ts +29 -21
  20. package/dist/structures/components/MorphLayer.js +19 -17
  21. package/dist/structures/components/Path2DLayer.d.ts +21 -72
  22. package/dist/structures/components/Path2DLayer.js +4 -108
  23. package/dist/structures/components/QuadraticLayer.d.ts +30 -22
  24. package/dist/structures/components/QuadraticLayer.js +23 -21
  25. package/dist/structures/components/TextLayer.d.ts +54 -41
  26. package/dist/structures/components/TextLayer.js +165 -69
  27. package/dist/structures/helpers/Exporter.d.ts +9 -9
  28. package/dist/structures/helpers/Exporter.js +9 -9
  29. package/dist/structures/helpers/Font.d.ts +4 -4
  30. package/dist/structures/helpers/Font.js +4 -4
  31. package/dist/structures/helpers/Gradient.d.ts +15 -10
  32. package/dist/structures/helpers/Gradient.js +14 -9
  33. package/dist/structures/helpers/Link.d.ts +5 -5
  34. package/dist/structures/helpers/Link.js +5 -5
  35. package/dist/structures/helpers/Pattern.d.ts +5 -5
  36. package/dist/structures/helpers/Pattern.js +5 -5
  37. package/dist/structures/helpers/index.d.ts +7 -7
  38. package/dist/structures/helpers/readers/JSONReader.d.ts +12 -12
  39. package/dist/structures/helpers/readers/JSONReader.js +12 -12
  40. package/dist/structures/helpers/readers/YAMLReader.d.ts +4 -4
  41. package/dist/structures/helpers/readers/YAMLReader.js +4 -4
  42. package/dist/structures/managers/AnimationManager.d.ts +11 -11
  43. package/dist/structures/managers/AnimationManager.js +11 -11
  44. package/dist/structures/managers/FontsManager.d.ts +14 -15
  45. package/dist/structures/managers/FontsManager.js +14 -15
  46. package/dist/structures/managers/LayersManager.d.ts +15 -15
  47. package/dist/structures/managers/LayersManager.js +19 -19
  48. package/dist/structures/managers/PluginManager.d.ts +11 -9
  49. package/dist/structures/managers/PluginManager.js +9 -8
  50. package/dist/structures/managers/RenderManager.d.ts +10 -10
  51. package/dist/structures/managers/RenderManager.js +10 -10
  52. package/dist/structures/managers/index.d.ts +5 -0
  53. package/dist/structures/managers/index.js +21 -0
  54. package/dist/types/index.d.ts +0 -1
  55. package/dist/types/index.js +0 -1
  56. package/dist/types/types.d.ts +7 -1
  57. package/dist/utils/utils.d.ts +5 -5
  58. package/dist/utils/utils.js +8 -2
  59. package/package.json +1 -2
@@ -19,8 +19,8 @@ class FontsManager {
19
19
  debug;
20
20
  /**
21
21
  * Constructs a new FontsManager instance.
22
- * @param opts {Object} - Optional settings for the FontsManager.
23
- * @param opts.debug {boolean} - Whether debugging is enabled.
22
+ * @param {Object} [opts] - Optional settings for the FontsManager.
23
+ * @param {boolean} [opts.debug] - Whether debugging is enabled.
24
24
  */
25
25
  constructor(opts) {
26
26
  this.map = new Map();
@@ -29,7 +29,7 @@ class FontsManager {
29
29
  }
30
30
  /**
31
31
  * Loads fonts into the manager from a given font list.
32
- * @param fontList {IFonts} - The fonts to load into the manager.
32
+ * @param {IFonts} [fontList] - The fonts to load into the manager.
33
33
  * @returns {this} The current instance for chaining.
34
34
  */
35
35
  loadFonts(fontList) {
@@ -46,9 +46,8 @@ class FontsManager {
46
46
  /**
47
47
  * Replace base fonts with custom fonts by special file.
48
48
  * Use this method before loading fonts by `FontManager`.
49
- * The file should be generated by the following instructions in MD file.
50
- * @see https://github.com/NMMTY/LazyCanvas/blob/main/scripts/FontsGenerate.md
51
- * @param fonts {Font[]} - The fonts to add to the manager.
49
+ * The file should be generated by the following instructions in [MD file](https://github.com/NMMTY/LazyCanvas/blob/main/scripts/FontsGenerate.md).
50
+ * @param {Font[]} [fonts] - The fonts to add to the manager.
52
51
  * @returns {this} The current instance for chaining.
53
52
  * @throws {LazyError} If required font properties are missing or the font already exists.
54
53
  */
@@ -76,7 +75,7 @@ class FontsManager {
76
75
  }
77
76
  /**
78
77
  * Removes fonts from the manager.
79
- * @param array {Array<{ family: string, weight: string }>} - The family and weight of the fonts to remove.
78
+ * @param {Array<{ family: string, weight: string }>} [array] - The family and weight of the fonts to remove.
80
79
  * @returns {this} The current instance for chaining.
81
80
  */
82
81
  remove(...array) {
@@ -95,8 +94,8 @@ class FontsManager {
95
94
  }
96
95
  /**
97
96
  * Retrieves a font or fonts from the manager.
98
- * @param family {string} - The family of the font to retrieve.
99
- * @param weight {string} - The weight of the font to retrieve (optional).
97
+ * @param {string} [family] - The family of the font to retrieve.
98
+ * @param {string} [weight] - The weight of the font to retrieve (optional).
100
99
  * @returns {Font | Font[] | undefined} The retrieved font(s) or undefined if not found.
101
100
  */
102
101
  get(family, weight) {
@@ -106,8 +105,8 @@ class FontsManager {
106
105
  }
107
106
  /**
108
107
  * Checks if a font exists in the manager.
109
- * @param family {string} - The family of the font to check.
110
- * @param weight {string} - The weight of the font to check (optional).
108
+ * @param {string} [family] - The family of the font to check.
109
+ * @param {string} [weight] - The weight of the font to check (optional).
111
110
  * @returns {boolean} True if the font exists, false otherwise.
112
111
  */
113
112
  has(family, weight) {
@@ -145,8 +144,8 @@ class FontsManager {
145
144
  }
146
145
  /**
147
146
  * Iterates over the fonts in the manager.
148
- * @param callbackfn {Function} - The function to execute on each font.
149
- * @param thisArg {any} - The `this` context to use (optional).
147
+ * @param {Function} [callbackfn] - The function to execute on each font.
148
+ * @param {any} [thisArg] - The `this` context to use (optional).
150
149
  * @returns {this} The current instance for chaining.
151
150
  */
152
151
  forEach(callbackfn, thisArg) {
@@ -162,7 +161,7 @@ class FontsManager {
162
161
  }
163
162
  /**
164
163
  * Populates the font map from a JSON object.
165
- * @param json {object} - The JSON object to populate the map from.
164
+ * @param {object} [json] - The JSON object to populate the map from.
166
165
  * @returns {this} The current instance for chaining.
167
166
  */
168
167
  fromJSON(json) {
@@ -178,7 +177,7 @@ class FontsManager {
178
177
  }
179
178
  /**
180
179
  * Populates the font map from an array of fonts.
181
- * @param array {Font[]} - The array of fonts to populate the map from.
180
+ * @param {Font[]} [array] - The array of fonts to populate the map from.
182
181
  * @returns {this} The current instance for chaining.
183
182
  */
184
183
  fromArray(array) {
@@ -8,7 +8,7 @@ export interface ILayersManager {
8
8
  /**
9
9
  * The LazyCanvas instance associated with this manager.
10
10
  */
11
- lazycanvas: LazyCanvas;
11
+ lazyCanvas: LazyCanvas;
12
12
  /**
13
13
  * A map storing layers or groups with their IDs as keys.
14
14
  */
@@ -25,7 +25,7 @@ export declare class LayersManager implements ILayersManager {
25
25
  /**
26
26
  * The LazyCanvas instance associated with this manager.
27
27
  */
28
- lazycanvas: LazyCanvas;
28
+ lazyCanvas: LazyCanvas;
29
29
  /**
30
30
  * A map storing layers or groups with their IDs as keys.
31
31
  */
@@ -36,23 +36,23 @@ export declare class LayersManager implements ILayersManager {
36
36
  debug: boolean;
37
37
  /**
38
38
  * Constructs a new LayersManager instance.
39
- * @param lazycanvas {LazyCanvas} - The LazyCanvas instance to associate with this manager.
40
- * @param opts {Object} - Optional settings for the LayersManager.
41
- * @param opts.debug {boolean} - Whether debugging is enabled.
39
+ * @param {LazyCanvas} [lazyCanvas] - The LazyCanvas instance to associate with this manager.
40
+ * @param {Object} [opts] - Optional settings for the LayersManager.
41
+ * @param {boolean} [opts.debug] - Whether debugging is enabled.
42
42
  */
43
- constructor(lazycanvas: LazyCanvas, opts?: {
43
+ constructor(lazyCanvas: LazyCanvas, opts?: {
44
44
  debug?: boolean;
45
45
  });
46
46
  /**
47
47
  * Adds layers or groups to the map.
48
- * @param layers {Array<AnyLayer | Group>} - The layers or groups to add to the map.
48
+ * @param {Array<AnyLayer | Group>} [layers] - The layers or groups to add to the map.
49
49
  * @returns {this} The current instance for chaining.
50
50
  * @throws {LazyError} If a layer with the same ID already exists.
51
51
  */
52
52
  add(...layers: Array<AnyLayer | Group>): this;
53
53
  /**
54
54
  * Removes layers or groups from the map by their IDs.
55
- * @param ids {string[]} - The IDs of the layers or groups to remove.
55
+ * @param {string[]} [ids] - The IDs of the layers or groups to remove.
56
56
  * @returns {this} The current instance for chaining.
57
57
  */
58
58
  remove(...ids: string[]): this;
@@ -63,14 +63,14 @@ export declare class LayersManager implements ILayersManager {
63
63
  clear(): this;
64
64
  /**
65
65
  * Retrieves a layer or group from the map by its ID.
66
- * @param id {string} - The ID of the layer or group to retrieve.
67
- * @param cross {boolean} - Whether to search within groups for the ID.
66
+ * @param {string} [id] - The ID of the layer or group to retrieve.
67
+ * @param {boolean} [cross] - Whether to search within groups for the ID.
68
68
  * @returns {AnyLayer | Group | undefined} The retrieved layer or group, or undefined if not found.
69
69
  */
70
70
  get(id: string, cross?: boolean): AnyLayer | Group | undefined;
71
71
  /**
72
72
  * Checks if a layer or group exists in the map by its ID.
73
- * @param id {string} - The ID of the layer or group to check.
73
+ * @param {string} [id] - The ID of the layer or group to check.
74
74
  * @returns {boolean} True if the layer or group exists, false otherwise.
75
75
  */
76
76
  has(id: string): boolean;
@@ -96,7 +96,7 @@ export declare class LayersManager implements ILayersManager {
96
96
  entries(): IterableIterator<[string, AnyLayer | Group]>;
97
97
  /**
98
98
  * Executes a callback function for each layer or group in the map.
99
- * @param callbackfn {Function} - The callback function to execute.
99
+ * @param {Function} [callbackfn] - The callback function to execute.
100
100
  * @returns {this} The current instance for chaining.
101
101
  */
102
102
  forEach(callbackfn: (value: AnyLayer | Group, key: string, map: Map<string, AnyLayer | Group>) => void): this;
@@ -107,7 +107,7 @@ export declare class LayersManager implements ILayersManager {
107
107
  toJSON(): object;
108
108
  /**
109
109
  * Populates the map from a JSON object.
110
- * @param json {object} - The JSON object to populate the map from.
110
+ * @param {object} [json] - The JSON object to populate the map from.
111
111
  * @returns {this} The current instance for chaining.
112
112
  */
113
113
  fromJSON(json: object): this;
@@ -118,7 +118,7 @@ export declare class LayersManager implements ILayersManager {
118
118
  toArray(): Array<AnyLayer | Group>;
119
119
  /**
120
120
  * Populates the map from an array of layers and groups.
121
- * @param array {Array<AnyLayer | Group>} - The array of layers and groups to populate the map from.
121
+ * @param {Array<AnyLayer | Group>} [array] - The array of layers and groups to populate the map from.
122
122
  * @returns {this} The current instance for chaining.
123
123
  */
124
124
  fromArray(array: Array<AnyLayer | Group>): this;
@@ -129,7 +129,7 @@ export declare class LayersManager implements ILayersManager {
129
129
  sort(): void;
130
130
  /**
131
131
  * Searches for a layer or group by its ID, including within groups.
132
- * @param id {string} - The ID of the layer or group to search for.
132
+ * @param {string} [id] - The ID of the layer or group to search for.
133
133
  * @returns {AnyLayer | Group | undefined} The found layer or group, or undefined if not found.
134
134
  */
135
135
  private crossSearch;
@@ -10,7 +10,7 @@ class LayersManager {
10
10
  /**
11
11
  * The LazyCanvas instance associated with this manager.
12
12
  */
13
- lazycanvas;
13
+ lazyCanvas;
14
14
  /**
15
15
  * A map storing layers or groups with their IDs as keys.
16
16
  */
@@ -21,18 +21,18 @@ class LayersManager {
21
21
  debug;
22
22
  /**
23
23
  * Constructs a new LayersManager instance.
24
- * @param lazycanvas {LazyCanvas} - The LazyCanvas instance to associate with this manager.
25
- * @param opts {Object} - Optional settings for the LayersManager.
26
- * @param opts.debug {boolean} - Whether debugging is enabled.
24
+ * @param {LazyCanvas} [lazyCanvas] - The LazyCanvas instance to associate with this manager.
25
+ * @param {Object} [opts] - Optional settings for the LayersManager.
26
+ * @param {boolean} [opts.debug] - Whether debugging is enabled.
27
27
  */
28
- constructor(lazycanvas, opts) {
29
- this.lazycanvas = lazycanvas;
28
+ constructor(lazyCanvas, opts) {
29
+ this.lazyCanvas = lazyCanvas;
30
30
  this.map = new Map();
31
31
  this.debug = opts?.debug || false;
32
32
  }
33
33
  /**
34
34
  * Adds layers or groups to the map.
35
- * @param layers {Array<AnyLayer | Group>} - The layers or groups to add to the map.
35
+ * @param {Array<AnyLayer | Group>} [layers] - The layers or groups to add to the map.
36
36
  * @returns {this} The current instance for chaining.
37
37
  * @throws {LazyError} If a layer with the same ID already exists.
38
38
  */
@@ -48,8 +48,8 @@ class LayersManager {
48
48
  throw new LazyUtil_1.LazyError("Layer already exists");
49
49
  this.map.set(layer.id, layer);
50
50
  // onLayerAdded hook
51
- if (this.lazycanvas && this.lazycanvas.manager?.plugins) {
52
- this.lazycanvas.manager.plugins.executeHook('onLayerAdded', this.lazycanvas, layer);
51
+ if (this.lazyCanvas && this.lazyCanvas.manager?.plugins) {
52
+ this.lazyCanvas.manager.plugins.executeHook('onLayerAdded', this.lazyCanvas, layer);
53
53
  }
54
54
  }
55
55
  this.sort();
@@ -57,7 +57,7 @@ class LayersManager {
57
57
  }
58
58
  /**
59
59
  * Removes layers or groups from the map by their IDs.
60
- * @param ids {string[]} - The IDs of the layers or groups to remove.
60
+ * @param {string[]} [ids] - The IDs of the layers or groups to remove.
61
61
  * @returns {this} The current instance for chaining.
62
62
  */
63
63
  remove(...ids) {
@@ -65,8 +65,8 @@ class LayersManager {
65
65
  const layer = this.map.get(id);
66
66
  this.map.delete(id);
67
67
  // onLayerRemoved hook
68
- if (this.lazycanvas && this.lazycanvas.manager?.plugins) {
69
- this.lazycanvas.manager.plugins.executeHook('onLayerRemoved', this.lazycanvas, id);
68
+ if (this.lazyCanvas && this.lazyCanvas.manager?.plugins) {
69
+ this.lazyCanvas.manager.plugins.executeHook('onLayerRemoved', this.lazyCanvas, id);
70
70
  }
71
71
  }
72
72
  return this;
@@ -81,8 +81,8 @@ class LayersManager {
81
81
  }
82
82
  /**
83
83
  * Retrieves a layer or group from the map by its ID.
84
- * @param id {string} - The ID of the layer or group to retrieve.
85
- * @param cross {boolean} - Whether to search within groups for the ID.
84
+ * @param {string} [id] - The ID of the layer or group to retrieve.
85
+ * @param {boolean} [cross] - Whether to search within groups for the ID.
86
86
  * @returns {AnyLayer | Group | undefined} The retrieved layer or group, or undefined if not found.
87
87
  */
88
88
  get(id, cross = false) {
@@ -93,7 +93,7 @@ class LayersManager {
93
93
  }
94
94
  /**
95
95
  * Checks if a layer or group exists in the map by its ID.
96
- * @param id {string} - The ID of the layer or group to check.
96
+ * @param {string} [id] - The ID of the layer or group to check.
97
97
  * @returns {boolean} True if the layer or group exists, false otherwise.
98
98
  */
99
99
  has(id) {
@@ -129,7 +129,7 @@ class LayersManager {
129
129
  }
130
130
  /**
131
131
  * Executes a callback function for each layer or group in the map.
132
- * @param callbackfn {Function} - The callback function to execute.
132
+ * @param {Function} [callbackfn] - The callback function to execute.
133
133
  * @returns {this} The current instance for chaining.
134
134
  */
135
135
  forEach(callbackfn) {
@@ -145,7 +145,7 @@ class LayersManager {
145
145
  }
146
146
  /**
147
147
  * Populates the map from a JSON object.
148
- * @param json {object} - The JSON object to populate the map from.
148
+ * @param {object} [json] - The JSON object to populate the map from.
149
149
  * @returns {this} The current instance for chaining.
150
150
  */
151
151
  fromJSON(json) {
@@ -161,7 +161,7 @@ class LayersManager {
161
161
  }
162
162
  /**
163
163
  * Populates the map from an array of layers and groups.
164
- * @param array {Array<AnyLayer | Group>} - The array of layers and groups to populate the map from.
164
+ * @param {Array<AnyLayer | Group>} [array] - The array of layers and groups to populate the map from.
165
165
  * @returns {this} The current instance for chaining.
166
166
  */
167
167
  fromArray(array) {
@@ -177,7 +177,7 @@ class LayersManager {
177
177
  }
178
178
  /**
179
179
  * Searches for a layer or group by its ID, including within groups.
180
- * @param id {string} - The ID of the layer or group to search for.
180
+ * @param {string} [id] - The ID of the layer or group to search for.
181
181
  * @returns {AnyLayer | Group | undefined} The found layer or group, or undefined if not found.
182
182
  */
183
183
  crossSearch(id) {
@@ -1,6 +1,7 @@
1
1
  import { LazyCanvas } from "../LazyCanvas";
2
2
  import { AnyLayer } from "../../types";
3
3
  import { Group } from "../components";
4
+ import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
4
5
  /**
5
6
  * Interface representing a LazyCanvas plugin.
6
7
  */
@@ -69,7 +70,7 @@ export interface IPluginHooks {
69
70
  /**
70
71
  * Called after export completes.
71
72
  */
72
- afterExport?(canvas: LazyCanvas, result: any): void;
73
+ afterExport?(canvas: LazyCanvas, result: string | Buffer<ArrayBufferLike> | SKRSContext2D | Canvas | SvgCanvas): void;
73
74
  /**
74
75
  * Called when canvas is resized.
75
76
  */
@@ -165,27 +166,28 @@ export declare class PluginManager implements IPluginManager {
165
166
  canvas: LazyCanvas;
166
167
  /**
167
168
  * Constructs a new PluginManager instance.
168
- * @param canvas - The LazyCanvas instance.
169
- * @param opts - Optional settings for the PluginManager.
169
+ * @param {LazyCanvas} [canvas] - The LazyCanvas instance.
170
+ * @param {Object} [opts] - Optional settings for the PluginManager.
171
+ * @param {boolean} [opts.debug] - Whether debugging is enabled.
170
172
  */
171
173
  constructor(canvas: LazyCanvas, opts?: {
172
174
  debug?: boolean;
173
175
  });
174
176
  /**
175
177
  * Registers a plugin.
176
- * @param plugin - The plugin to register.
178
+ * @param {ILazyCanvasPlugin} [plugin] - The plugin to register.
177
179
  * @throws {LazyError} If a plugin with the same name is already registered.
178
180
  */
179
181
  register(plugin: ILazyCanvasPlugin): void;
180
182
  /**
181
183
  * Unregisters a plugin by name.
182
- * @param pluginName - The name of the plugin to unregister.
184
+ * @param {string} [pluginName] - The name of the plugin to unregister.
183
185
  * @throws {LazyError} If the plugin is not found or if other plugins depend on it.
184
186
  */
185
187
  unregister(pluginName: string): void;
186
188
  /**
187
189
  * Gets a plugin by name.
188
- * @param pluginName - The name of the plugin.
190
+ * @param {string} [pluginName] - The name of the plugin.
189
191
  * @returns The plugin or undefined if not found.
190
192
  */
191
193
  get(pluginName: string): ILazyCanvasPlugin | undefined;
@@ -196,14 +198,14 @@ export declare class PluginManager implements IPluginManager {
196
198
  list(): string[];
197
199
  /**
198
200
  * Checks if a plugin is registered.
199
- * @param pluginName - The name of the plugin.
201
+ * @param {string} [pluginName] - The name of the plugin.
200
202
  * @returns True if the plugin is registered, false otherwise.
201
203
  */
202
204
  has(pluginName: string): boolean;
203
205
  /**
204
206
  * Executes a hook for all plugins that implement it.
205
- * @param hookName - The name of the hook to execute.
206
- * @param args - Arguments to pass to the hook.
207
+ * @param {keyof IPluginHooks} [hookName] - The name of the hook to execute.
208
+ * @param {any} [args] - Arguments to pass to the hook.
207
209
  */
208
210
  executeHook(hookName: keyof IPluginHooks, ...args: any[]): void;
209
211
  /**
@@ -20,8 +20,9 @@ class PluginManager {
20
20
  canvas;
21
21
  /**
22
22
  * Constructs a new PluginManager instance.
23
- * @param canvas - The LazyCanvas instance.
24
- * @param opts - Optional settings for the PluginManager.
23
+ * @param {LazyCanvas} [canvas] - The LazyCanvas instance.
24
+ * @param {Object} [opts] - Optional settings for the PluginManager.
25
+ * @param {boolean} [opts.debug] - Whether debugging is enabled.
25
26
  */
26
27
  constructor(canvas, opts) {
27
28
  this.plugins = new Map();
@@ -30,7 +31,7 @@ class PluginManager {
30
31
  }
31
32
  /**
32
33
  * Registers a plugin.
33
- * @param plugin - The plugin to register.
34
+ * @param {ILazyCanvasPlugin} [plugin] - The plugin to register.
34
35
  * @throws {LazyError} If a plugin with the same name is already registered.
35
36
  */
36
37
  register(plugin) {
@@ -58,7 +59,7 @@ class PluginManager {
58
59
  }
59
60
  /**
60
61
  * Unregisters a plugin by name.
61
- * @param pluginName - The name of the plugin to unregister.
62
+ * @param {string} [pluginName] - The name of the plugin to unregister.
62
63
  * @throws {LazyError} If the plugin is not found or if other plugins depend on it.
63
64
  */
64
65
  unregister(pluginName) {
@@ -87,7 +88,7 @@ class PluginManager {
87
88
  }
88
89
  /**
89
90
  * Gets a plugin by name.
90
- * @param pluginName - The name of the plugin.
91
+ * @param {string} [pluginName] - The name of the plugin.
91
92
  * @returns The plugin or undefined if not found.
92
93
  */
93
94
  get(pluginName) {
@@ -102,7 +103,7 @@ class PluginManager {
102
103
  }
103
104
  /**
104
105
  * Checks if a plugin is registered.
105
- * @param pluginName - The name of the plugin.
106
+ * @param {string} [pluginName] - The name of the plugin.
106
107
  * @returns True if the plugin is registered, false otherwise.
107
108
  */
108
109
  has(pluginName) {
@@ -110,8 +111,8 @@ class PluginManager {
110
111
  }
111
112
  /**
112
113
  * Executes a hook for all plugins that implement it.
113
- * @param hookName - The name of the hook to execute.
114
- * @param args - Arguments to pass to the hook.
114
+ * @param {keyof IPluginHooks} [hookName] - The name of the hook to execute.
115
+ * @param {any} [args] - Arguments to pass to the hook.
115
116
  */
116
117
  executeHook(hookName, ...args) {
117
118
  this.plugins.forEach(plugin => {
@@ -28,31 +28,31 @@ export declare class RenderManager implements IRenderManager {
28
28
  debug: boolean;
29
29
  /**
30
30
  * Constructs a new RenderManager instance.
31
- * @param lazyCanvas {LazyCanvas} - The LazyCanvas instance to use for rendering.
32
- * @param opts {Object} - Optional settings for the RenderManager.
33
- * @param opts.debug {boolean} - Whether debugging is enabled.
31
+ * @param {LazyCanvas} [lazyCanvas] - The LazyCanvas instance to use for rendering.
32
+ * @param {Object} [opts] - Optional settings for the RenderManager.
33
+ * @param {boolean} [opts.debug] - Whether debugging is enabled.
34
34
  */
35
35
  constructor(lazyCanvas: LazyCanvas, opts?: {
36
36
  debug?: boolean;
37
37
  });
38
38
  /**
39
39
  * Merges multiple ImageData objects into a single ImageData object.
40
- * @param ctx {SKRSContext2D} - The canvas rendering context.
41
- * @param imageDataList {ImageData[]} - The list of ImageData objects to merge.
42
- * @param width {number} - The width of the resulting ImageData.
43
- * @param height {number} - The height of the resulting ImageData.
40
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
41
+ * @param {ImageData[]} [imageDataList] - The list of ImageData objects to merge.
42
+ * @param {number} [width] - The width of the resulting ImageData.
43
+ * @param {number} [height] - The height of the resulting ImageData.
44
44
  * @returns {ImageData} The merged ImageData object.
45
45
  */
46
46
  private mergeImageData;
47
47
  /**
48
48
  * Renders a single layer or group of layers.
49
- * @param layer {AnyLayer | Group} - The layer or group to render.
49
+ * @param {AnyLayer | Group} [layer] - The layer or group to render.
50
50
  * @returns {Promise<SKRSContext2D>} The canvas rendering context after rendering.
51
51
  */
52
52
  private renderLayer;
53
53
  /**
54
54
  * Renders all layers statically and exports the result in the specified format.
55
- * @param exportType {AnyExport} - The export format (e.g., buffer, SVG, or context).
55
+ * @param {AnyExport} [exportType] - The export format (e.g., buffer, SVG, or context).
56
56
  * @returns {Promise<Buffer | SKRSContext2D | string>} The rendered output in the specified format.
57
57
  */
58
58
  private renderStatic;
@@ -63,7 +63,7 @@ export declare class RenderManager implements IRenderManager {
63
63
  private renderAnimation;
64
64
  /**
65
65
  * Renders all layers and exports the result in the specified format.
66
- * @param format {AnyExport} - The export format (e.g., buffer, context, SVG, or canvas).
66
+ * @param {AnyExport} [format] - The export format (e.g., buffer, context, SVG, or canvas).
67
67
  * @returns {Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>} The rendered output in the specified format.
68
68
  */
69
69
  render(format: AnyExport): Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>;
@@ -19,9 +19,9 @@ class RenderManager {
19
19
  debug;
20
20
  /**
21
21
  * Constructs a new RenderManager instance.
22
- * @param lazyCanvas {LazyCanvas} - The LazyCanvas instance to use for rendering.
23
- * @param opts {Object} - Optional settings for the RenderManager.
24
- * @param opts.debug {boolean} - Whether debugging is enabled.
22
+ * @param {LazyCanvas} [lazyCanvas] - The LazyCanvas instance to use for rendering.
23
+ * @param {Object} [opts] - Optional settings for the RenderManager.
24
+ * @param {boolean} [opts.debug] - Whether debugging is enabled.
25
25
  */
26
26
  constructor(lazyCanvas, opts) {
27
27
  this.lazyCanvas = lazyCanvas;
@@ -29,10 +29,10 @@ class RenderManager {
29
29
  }
30
30
  /**
31
31
  * Merges multiple ImageData objects into a single ImageData object.
32
- * @param ctx {SKRSContext2D} - The canvas rendering context.
33
- * @param imageDataList {ImageData[]} - The list of ImageData objects to merge.
34
- * @param width {number} - The width of the resulting ImageData.
35
- * @param height {number} - The height of the resulting ImageData.
32
+ * @param {SKRSContext2D} [ctx] - The canvas rendering context.
33
+ * @param {ImageData[]} [imageDataList] - The list of ImageData objects to merge.
34
+ * @param {number} [width] - The width of the resulting ImageData.
35
+ * @param {number} [height] - The height of the resulting ImageData.
36
36
  * @returns {ImageData} The merged ImageData object.
37
37
  */
38
38
  mergeImageData(ctx, imageDataList, width, height) {
@@ -59,7 +59,7 @@ class RenderManager {
59
59
  }
60
60
  /**
61
61
  * Renders a single layer or group of layers.
62
- * @param layer {AnyLayer | Group} - The layer or group to render.
62
+ * @param {AnyLayer | Group} [layer] - The layer or group to render.
63
63
  * @returns {Promise<SKRSContext2D>} The canvas rendering context after rendering.
64
64
  */
65
65
  async renderLayer(layer) {
@@ -74,7 +74,7 @@ class RenderManager {
74
74
  }
75
75
  /**
76
76
  * Renders all layers statically and exports the result in the specified format.
77
- * @param exportType {AnyExport} - The export format (e.g., buffer, SVG, or context).
77
+ * @param {AnyExport} [exportType] - The export format (e.g., buffer, SVG, or context).
78
78
  * @returns {Promise<Buffer | SKRSContext2D | string>} The rendered output in the specified format.
79
79
  */
80
80
  async renderStatic(exportType) {
@@ -141,7 +141,7 @@ class RenderManager {
141
141
  }
142
142
  /**
143
143
  * Renders all layers and exports the result in the specified format.
144
- * @param format {AnyExport} - The export format (e.g., buffer, context, SVG, or canvas).
144
+ * @param {AnyExport} [format] - The export format (e.g., buffer, context, SVG, or canvas).
145
145
  * @returns {Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>} The rendered output in the specified format.
146
146
  */
147
147
  async render(format) {
@@ -0,0 +1,5 @@
1
+ export * from './LayersManager';
2
+ export * from './PluginManager';
3
+ export * from './FontsManager';
4
+ export * from './RenderManager';
5
+ export * from './AnimationManager';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./LayersManager"), exports);
18
+ __exportStar(require("./PluginManager"), exports);
19
+ __exportStar(require("./FontsManager"), exports);
20
+ __exportStar(require("./RenderManager"), exports);
21
+ __exportStar(require("./AnimationManager"), exports);
@@ -1,3 +1,2 @@
1
1
  export type * from "./types";
2
2
  export * from './enum';
3
- export * from '../structures/managers/PluginManager';
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./enum"), exports);
18
- __exportStar(require("../structures/managers/PluginManager"), exports);
@@ -96,4 +96,10 @@ export interface Transform {
96
96
  matrix: DOMMatrix2DInit;
97
97
  }
98
98
 
99
- export type radiusCorner = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' | 'all';
99
+ export type RadiusCorner = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' | 'all';
100
+
101
+ export type SubStringColor = {
102
+ color: StringColorType;
103
+ start: number;
104
+ end: number;
105
+ }
@@ -1,10 +1,10 @@
1
- import type { AnyCentring, AnyLayer, AnyTextAlign, ColorType, PointNumber, ScaleType, Transform } from "../types";
1
+ import type { AnyCentring, AnyLayer, AnyTextAlign, ColorType, PointNumber, ScaleType, SubStringColor, Transform } from "../types";
2
2
  import { LayerType } from "../types";
3
3
  import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
4
- import { LayersManager } from "../structures/managers/LayersManager";
4
+ import { LayersManager } from "../structures/managers";
5
5
  import { Group } from "../structures/components";
6
6
  export declare function generateID(type: string): string;
7
- export declare function isColor(v: ColorType): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
7
+ export declare function isColor(v: ColorType | SubStringColor): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
8
8
  export declare function parseToNormal(v: ScaleType, ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, layer?: {
9
9
  width: number;
10
10
  height: number;
@@ -35,7 +35,7 @@ export declare function parser(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, m
35
35
  export declare function drawShadow(ctx: SKRSContext2D, shadow: any): void;
36
36
  export declare function opacity(ctx: SKRSContext2D, opacity?: number): void;
37
37
  export declare function filters(ctx: SKRSContext2D, filters: string | null | undefined): void;
38
- export declare function parseFillStyle(ctx: SKRSContext2D, color: ColorType, opts: {
38
+ export declare function parseFillStyle(ctx: SKRSContext2D, color: ColorType | SubStringColor, opts: {
39
39
  debug?: boolean;
40
40
  layer?: {
41
41
  width: number;
@@ -45,7 +45,7 @@ export declare function parseFillStyle(ctx: SKRSContext2D, color: ColorType, opt
45
45
  align: AnyCentring;
46
46
  };
47
47
  manager?: LayersManager;
48
- }): string | Promise<CanvasPattern> | CanvasGradient;
48
+ }): string | CanvasGradient | Promise<CanvasPattern>;
49
49
  export declare function transform(ctx: SKRSContext2D, transform: Transform, layer?: {
50
50
  width: number;
51
51
  height: number;
@@ -33,7 +33,7 @@ let rgbaReg = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(0|0?\.\d+|1(\.0)?)\)$/;
33
33
  let hslReg = /^hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)$/;
34
34
  let hslaReg = /^hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*(0|0?\.\d+|1(\.0)?)\)$/;
35
35
  function isColor(v) {
36
- return typeof (v === 'string' && (hexReg.test(v) || rgbReg.test(v) || rgbaReg.test(v) || hslReg.test(v) || hslaReg.test(v))) || v instanceof helpers_1.Gradient || v instanceof helpers_1.Pattern;
36
+ return typeof (v === 'string' && (hexReg.test(v) || rgbReg.test(v) || rgbaReg.test(v) || hslReg.test(v) || hslaReg.test(v))) || v instanceof helpers_1.Gradient || v instanceof helpers_1.Pattern || (typeof v === 'object' && (v.start && v.end && v.color));
37
37
  }
38
38
  function parseToNormal(v, ctx, canvas, layer = { width: 0, height: 0 }, options = { vertical: false, layer: false }, manager) {
39
39
  if (typeof v === 'number')
@@ -149,7 +149,13 @@ function parseFillStyle(ctx, color, opts) {
149
149
  if (color instanceof helpers_1.Gradient || color instanceof helpers_1.Pattern) {
150
150
  return color.draw(ctx, opts);
151
151
  }
152
- return color;
152
+ if (typeof color === 'object' && color.start && color.end && color.color) {
153
+ return color.color;
154
+ }
155
+ else if (typeof color === 'string') {
156
+ return color;
157
+ }
158
+ return '#000000';
153
159
  }
154
160
  function transform(ctx, transform, layer = { width: 0, height: 0, x: 0, y: 0, type: types_1.LayerType.Morph }, extra = { text: '', textAlign: types_1.TextAlign.Left, fontSize: 0, multiline: false }) {
155
161
  if (transform) {