@mlightcad/mtext-renderer 0.11.2 → 0.11.4

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.
@@ -9,6 +9,17 @@ export declare const MIN_REASONABLE_MTEXT_WIDTH_HEIGHT_RATIO = 1.5;
9
9
  * only when estimating a replacement wrap width from explicit line content.
10
10
  */
11
11
  export declare const CJK_MTEXT_CHAR_WIDTH_HEIGHT_RATIO = 0.8;
12
+ /**
13
+ * Maximum width-to-height ratio for a declared MTEXT wrap box. Values above this
14
+ * are treated as corrupt DXF group-code 41 data (often coordinate-scale garbage)
15
+ * rather than an intentional column width.
16
+ */
17
+ export declare const MAX_REASONABLE_MTEXT_WIDTH_HEIGHT_RATIO = 1000000;
18
+ /**
19
+ * Maximum ratio between declared wrap width and the content-estimated width.
20
+ * Catches absurd widths even when text height is also very large.
21
+ */
22
+ export declare const MAX_REASONABLE_MTEXT_WIDTH_CONTENT_EXCESS = 10000;
12
23
  /**
13
24
  * Estimates a usable MTEXT wrap width from the longest explicit line in the raw
14
25
  * MTEXT string while preserving explicit line breaks such as `\P`.
@@ -23,5 +34,10 @@ export declare function estimateMTextWrapWidth(text: string, height: number): nu
23
34
  * the word-wrap width forces CJK text to wrap one character per line. When the
24
35
  * width is clearly impossible as a layout width, estimate a usable width from
25
36
  * the longest explicit MTEXT line and preserve explicit line breaks such as `\P`.
37
+ *
38
+ * Other exports carry absurdly large group-code 41 values. Using those widths for
39
+ * middle/center attachment shifts glyph geometry by tens of millions of drawing
40
+ * units and destroys float32 precision. Replace those with the same content-based
41
+ * estimate when the declared width far exceeds the rendered text.
26
42
  */
27
43
  export declare function resolveMTextWrapWidth(mtextData: Pick<MTextData, 'text' | 'height' | 'width'>): number;
@@ -12,6 +12,8 @@ export declare class UnifiedRenderer {
12
12
  private mainThreadRenderer;
13
13
  private renderer;
14
14
  private defaultMode;
15
+ private workerConfig;
16
+ private webWorkerConfigured;
15
17
  /**
16
18
  * Constructor
17
19
  *
@@ -20,6 +22,8 @@ export declare class UnifiedRenderer {
20
22
  * when render mode is 'worker'.
21
23
  */
22
24
  constructor(defaultMode?: RenderMode, workerConfig?: WebWorkerRendererConfig);
25
+ private ensureWebWorkerRenderer;
26
+ private activateWebWorkerRenderer;
23
27
  /**
24
28
  * Sets one new style manager to override the default style manager.
25
29
  *
@@ -91,6 +95,14 @@ export declare class UnifiedRenderer {
91
95
  * with the web worker renderer.
92
96
  */
93
97
  cacheFont(data: ArrayBuffer | File, fileName?: string, aliases?: string[], encoding?: string): Promise<FontLoadStatus>;
98
+ /**
99
+ * Terminate web workers and release their memory.
100
+ *
101
+ * The unified renderer keeps working on the main thread. Workers are
102
+ * recreated lazily the next time worker rendering is requested.
103
+ * Safe to call when no workers were created.
104
+ */
105
+ terminateWorkers(): void;
94
106
  /**
95
107
  * Clean up resources
96
108
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",