jww-parser 2025.12.4 → 2025.12.7

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/index.d.ts CHANGED
@@ -1,947 +1,11 @@
1
- /**
2
- * JWW (Jw_cad) file parser and DXF converter
3
- *
4
- * This module provides functionality to parse JWW binary files
5
- * and convert them to DXF format using WebAssembly.
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * Error codes for JWW parser operations
11
- */
12
- export declare enum JwwErrorCode {
13
- /** Parser has not been initialized */
14
- NOT_INITIALIZED = "NOT_INITIALIZED",
15
- /** WASM module failed to load */
16
- WASM_LOAD_FAILED = "WASM_LOAD_FAILED",
17
- /** WASM functions not available after timeout */
18
- WASM_TIMEOUT = "WASM_TIMEOUT",
19
- /** Invalid JWW file signature */
20
- INVALID_SIGNATURE = "INVALID_SIGNATURE",
21
- /** Unsupported JWW version */
22
- UNSUPPORTED_VERSION = "UNSUPPORTED_VERSION",
23
- /** General parse error */
24
- PARSE_ERROR = "PARSE_ERROR",
25
- /** DXF conversion error */
26
- CONVERSION_ERROR = "CONVERSION_ERROR",
27
- /** Validation error */
28
- VALIDATION_ERROR = "VALIDATION_ERROR",
29
- /** Memory allocation error */
30
- MEMORY_ERROR = "MEMORY_ERROR",
31
- /** Invalid argument provided */
32
- INVALID_ARGUMENT = "INVALID_ARGUMENT"
33
- }
34
- /**
35
- * Base error class for JWW parser errors
36
- */
37
- export declare class JwwParserError extends Error {
38
- /** Error code identifying the error type */
39
- readonly code: JwwErrorCode;
40
- /** Original error that caused this error, if any */
41
- readonly cause?: Error;
42
- /** Additional context about the error */
43
- readonly context?: Record<string, unknown>;
44
- /** Timestamp when the error occurred */
45
- readonly timestamp: Date;
46
- constructor(code: JwwErrorCode, message: string, options?: {
47
- cause?: Error;
48
- context?: Record<string, unknown>;
49
- });
50
- /**
51
- * Returns a detailed string representation of the error
52
- */
53
- toDetailedString(): string;
54
- /**
55
- * Converts the error to a plain object for logging/serialization
56
- */
57
- toJSON(): Record<string, unknown>;
58
- }
59
- /**
60
- * Error thrown when the parser is not initialized
61
- */
62
- export declare class NotInitializedError extends JwwParserError {
63
- constructor();
64
- }
65
- /**
66
- * Error thrown when WASM module fails to load
67
- */
68
- export declare class WasmLoadError extends JwwParserError {
69
- constructor(message: string, cause?: Error);
70
- }
71
- /**
72
- * Error thrown when file validation fails
73
- */
74
- export declare class ValidationError extends JwwParserError {
75
- /** Specific validation issues found */
76
- readonly issues: ValidationIssue[];
77
- constructor(message: string, issues: ValidationIssue[]);
78
- }
79
- /**
80
- * Error thrown during parsing
81
- */
82
- export declare class ParseError extends JwwParserError {
83
- /** Byte offset where the error occurred, if available */
84
- readonly offset?: number;
85
- /** Section being parsed when the error occurred */
86
- readonly section?: string;
87
- constructor(message: string, options?: {
88
- cause?: Error;
89
- offset?: number;
90
- section?: string;
91
- });
92
- }
93
- /**
94
- * Complete JWW document structure
95
- */
96
- export interface JwwDocument {
97
- /** JWW file version number */
98
- Version: number;
99
- /** Document memo/comments */
100
- Memo: string;
101
- /** Paper size code */
102
- PaperSize: number;
103
- /** Layer groups (16 groups) */
104
- LayerGroups: JwwLayerGroup[];
105
- /** All entities in the document */
106
- Entities: JwwEntity[];
107
- /** Block definitions */
108
- Blocks: JwwBlock[];
109
- }
110
- /**
111
- * JWW layer group containing 16 layers
112
- */
113
- export interface JwwLayerGroup {
114
- /** Layer group name */
115
- Name: string;
116
- /** Layers within this group (16 layers) */
117
- Layers: JwwLayer[];
118
- }
119
- /**
120
- * JWW layer within a layer group
121
- */
122
- export interface JwwLayer {
123
- /** Layer name */
124
- Name: string;
125
- /** Whether the layer is visible */
126
- Visible: boolean;
127
- /** Whether the layer is locked */
128
- Locked: boolean;
129
- }
130
- /**
131
- * Base interface for all JWW entities
132
- */
133
- export interface JwwEntityBase {
134
- /** Entity type discriminator */
135
- Type: string;
136
- /** Curve attribute number */
137
- Group: number;
138
- /** Line type/style */
139
- PenStyle: number;
140
- /** Color code */
141
- PenColor: number;
142
- /** Line width */
143
- PenWidth: number;
144
- /** Layer index within the group (0-15) */
145
- Layer: number;
146
- /** Layer group index (0-15) */
147
- LayerGroup: number;
148
- }
149
- /**
150
- * JWW Line entity
151
- */
152
- export interface JwwLine extends JwwEntityBase {
153
- Type: "Line";
154
- /** Start X coordinate */
155
- X1: number;
156
- /** Start Y coordinate */
157
- Y1: number;
158
- /** End X coordinate */
159
- X2: number;
160
- /** End Y coordinate */
161
- Y2: number;
162
- }
163
- /**
164
- * JWW Arc entity (includes circles and ellipses)
165
- */
166
- export interface JwwArc extends JwwEntityBase {
167
- Type: "Arc";
168
- /** Center X coordinate */
169
- CenterX: number;
170
- /** Center Y coordinate */
171
- CenterY: number;
172
- /** Arc radius */
173
- Radius: number;
174
- /** Start angle in degrees */
175
- StartAngle: number;
176
- /** End angle in degrees */
177
- EndAngle: number;
178
- /** Flatness ratio (1.0 for circles, other values for ellipses) */
179
- Flatness: number;
180
- }
181
- /**
182
- * JWW Point entity
183
- */
184
- export interface JwwPoint extends JwwEntityBase {
185
- Type: "Point";
186
- /** X coordinate */
187
- X: number;
188
- /** Y coordinate */
189
- Y: number;
190
- /** Point code/type */
191
- Code: number;
192
- }
193
- /**
194
- * JWW Text entity
195
- */
196
- export interface JwwText extends JwwEntityBase {
197
- Type: "Text";
198
- /** Text insertion X coordinate */
199
- X: number;
200
- /** Text insertion Y coordinate */
201
- Y: number;
202
- /** Text content */
203
- Text: string;
204
- /** Font name */
205
- FontName: string;
206
- /** Text height */
207
- Height: number;
208
- /** Text width (character width) */
209
- Width: number;
210
- /** Rotation angle in degrees */
211
- Angle: number;
212
- }
213
- /**
214
- * JWW Solid (filled polygon) entity
215
- */
216
- export interface JwwSolid extends JwwEntityBase {
217
- Type: "Solid";
218
- /** Array of [x, y] coordinate pairs */
219
- Points: [number, number][];
220
- }
221
- /**
222
- * JWW Block reference entity
223
- */
224
- export interface JwwBlockRef extends JwwEntityBase {
225
- Type: "Block";
226
- /** Insertion X coordinate */
227
- X: number;
228
- /** Insertion Y coordinate */
229
- Y: number;
230
- /** X scale factor */
231
- ScaleX: number;
232
- /** Y scale factor */
233
- ScaleY: number;
234
- /** Rotation angle in degrees */
235
- Angle: number;
236
- /** Referenced block definition number */
237
- BlockNumber: number;
238
- }
239
- /**
240
- * Union type of all JWW entity types
241
- */
242
- export type JwwEntity = JwwLine | JwwArc | JwwPoint | JwwText | JwwSolid | JwwBlockRef;
243
- /**
244
- * JWW block definition
245
- */
246
- export interface JwwBlock {
247
- /** Block name */
248
- Name: string;
249
- /** Entities within the block */
250
- Entities: JwwEntity[];
251
- }
252
- /**
253
- * DXF document structure
254
- */
255
- export interface DxfDocument {
256
- /** DXF layers */
257
- Layers: DxfLayer[];
258
- /** All entities in the document */
259
- Entities: DxfEntity[];
260
- /** Block definitions */
261
- Blocks: DxfBlock[];
262
- }
263
- /**
264
- * DXF layer definition
265
- */
266
- export interface DxfLayer {
267
- /** Layer name */
268
- Name: string;
269
- /** ACI color code (1-255) */
270
- Color: number;
271
- /** Whether the layer is frozen */
272
- Frozen: boolean;
273
- /** Whether the layer is locked */
274
- Locked: boolean;
275
- }
276
- /**
277
- * Base interface for all DXF entities
278
- */
279
- export interface DxfEntityBase {
280
- /** Entity type (LINE, CIRCLE, ARC, etc.) */
281
- Type: string;
282
- /** Layer name */
283
- Layer: string;
284
- /** Optional ACI color code */
285
- Color?: number;
286
- /** Optional line type name */
287
- LineType?: string;
288
- }
289
- /**
290
- * DXF LINE entity
291
- */
292
- export interface DxfLine extends DxfEntityBase {
293
- Type: "LINE";
294
- /** Start X coordinate */
295
- X1: number;
296
- /** Start Y coordinate */
297
- Y1: number;
298
- /** Start Z coordinate */
299
- Z1?: number;
300
- /** End X coordinate */
301
- X2: number;
302
- /** End Y coordinate */
303
- Y2: number;
304
- /** End Z coordinate */
305
- Z2?: number;
306
- }
307
- /**
308
- * DXF CIRCLE entity
309
- */
310
- export interface DxfCircle extends DxfEntityBase {
311
- Type: "CIRCLE";
312
- /** Center X coordinate */
313
- CenterX: number;
314
- /** Center Y coordinate */
315
- CenterY: number;
316
- /** Center Z coordinate */
317
- CenterZ?: number;
318
- /** Circle radius */
319
- Radius: number;
320
- }
321
- /**
322
- * DXF ARC entity
323
- */
324
- export interface DxfArc extends DxfEntityBase {
325
- Type: "ARC";
326
- /** Center X coordinate */
327
- CenterX: number;
328
- /** Center Y coordinate */
329
- CenterY: number;
330
- /** Center Z coordinate */
331
- CenterZ?: number;
332
- /** Arc radius */
333
- Radius: number;
334
- /** Start angle in degrees */
335
- StartAngle: number;
336
- /** End angle in degrees */
337
- EndAngle: number;
338
- }
339
- /**
340
- * DXF ELLIPSE entity
341
- */
342
- export interface DxfEllipse extends DxfEntityBase {
343
- Type: "ELLIPSE";
344
- /** Center X coordinate */
345
- CenterX: number;
346
- /** Center Y coordinate */
347
- CenterY: number;
348
- /** Center Z coordinate */
349
- CenterZ?: number;
350
- /** Major axis X component (relative to center) */
351
- MajorAxisX: number;
352
- /** Major axis Y component (relative to center) */
353
- MajorAxisY: number;
354
- /** Major axis Z component (relative to center) */
355
- MajorAxisZ?: number;
356
- /** Minor to major axis ratio (0 to 1) */
357
- MinorRatio: number;
358
- /** Start parameter (0 to 2*PI) */
359
- StartParam: number;
360
- /** End parameter (0 to 2*PI) */
361
- EndParam: number;
362
- }
363
- /**
364
- * DXF POINT entity
365
- */
366
- export interface DxfPoint extends DxfEntityBase {
367
- Type: "POINT";
368
- /** X coordinate */
369
- X: number;
370
- /** Y coordinate */
371
- Y: number;
372
- /** Z coordinate */
373
- Z?: number;
374
- }
375
- /**
376
- * DXF TEXT entity
377
- */
378
- export interface DxfText extends DxfEntityBase {
379
- Type: "TEXT";
380
- /** Insertion X coordinate */
381
- X: number;
382
- /** Insertion Y coordinate */
383
- Y: number;
384
- /** Insertion Z coordinate */
385
- Z?: number;
386
- /** Text height */
387
- Height: number;
388
- /** Text content */
389
- Content: string;
390
- /** Rotation angle in degrees */
391
- Rotation?: number;
392
- /** Text style name */
393
- Style?: string;
394
- }
395
- /**
396
- * DXF MTEXT (multiline text) entity
397
- */
398
- export interface DxfMText extends DxfEntityBase {
399
- Type: "MTEXT";
400
- /** Insertion X coordinate */
401
- X: number;
402
- /** Insertion Y coordinate */
403
- Y: number;
404
- /** Insertion Z coordinate */
405
- Z?: number;
406
- /** Text height */
407
- Height: number;
408
- /** Text content (with formatting codes) */
409
- Content: string;
410
- /** Rotation angle in degrees */
411
- Rotation?: number;
412
- /** Reference rectangle width */
413
- Width?: number;
414
- }
415
- /**
416
- * DXF SOLID entity (filled triangle or quadrilateral)
417
- */
418
- export interface DxfSolid extends DxfEntityBase {
419
- Type: "SOLID";
420
- /** First corner X */
421
- X1: number;
422
- /** First corner Y */
423
- Y1: number;
424
- /** Second corner X */
425
- X2: number;
426
- /** Second corner Y */
427
- Y2: number;
428
- /** Third corner X */
429
- X3: number;
430
- /** Third corner Y */
431
- Y3: number;
432
- /** Fourth corner X (same as third for triangles) */
433
- X4: number;
434
- /** Fourth corner Y (same as third for triangles) */
435
- Y4: number;
436
- }
437
- /**
438
- * DXF INSERT entity (block reference)
439
- */
440
- export interface DxfInsert extends DxfEntityBase {
441
- Type: "INSERT";
442
- /** Block name */
443
- BlockName: string;
444
- /** Insertion X coordinate */
445
- X: number;
446
- /** Insertion Y coordinate */
447
- Y: number;
448
- /** Insertion Z coordinate */
449
- Z?: number;
450
- /** X scale factor */
451
- ScaleX?: number;
452
- /** Y scale factor */
453
- ScaleY?: number;
454
- /** Z scale factor */
455
- ScaleZ?: number;
456
- /** Rotation angle in degrees */
457
- Rotation?: number;
458
- }
459
- /**
460
- * DXF POLYLINE vertex
461
- */
462
- export interface DxfVertex {
463
- /** X coordinate */
464
- X: number;
465
- /** Y coordinate */
466
- Y: number;
467
- /** Z coordinate */
468
- Z?: number;
469
- /** Bulge factor (for curved segments) */
470
- Bulge?: number;
471
- }
472
- /**
473
- * DXF LWPOLYLINE entity
474
- */
475
- export interface DxfLwPolyline extends DxfEntityBase {
476
- Type: "LWPOLYLINE";
477
- /** Whether the polyline is closed */
478
- Closed: boolean;
479
- /** Polyline vertices */
480
- Vertices: DxfVertex[];
481
- }
482
- /**
483
- * Union type of all DXF entity types
484
- */
485
- export type DxfEntity = DxfLine | DxfCircle | DxfArc | DxfEllipse | DxfPoint | DxfText | DxfMText | DxfSolid | DxfInsert | DxfLwPolyline | (DxfEntityBase & Record<string, unknown>);
486
- /**
487
- * DXF block definition
488
- */
489
- export interface DxfBlock {
490
- /** Block name */
491
- Name: string;
492
- /** Base point X coordinate */
493
- BaseX?: number;
494
- /** Base point Y coordinate */
495
- BaseY?: number;
496
- /** Base point Z coordinate */
497
- BaseZ?: number;
498
- /** Entities within the block */
499
- Entities: DxfEntity[];
500
- }
501
- /**
502
- * Progress stages during parsing
503
- */
504
- export type ProgressStage = "loading" | "parsing_header" | "parsing_layers" | "parsing_entities" | "parsing_blocks" | "converting" | "complete";
505
- /**
506
- * Progress information during parsing
507
- */
508
- export interface ProgressInfo {
509
- /** Current stage of parsing */
510
- stage: ProgressStage;
511
- /** Progress within the current stage (0-100) */
512
- progress: number;
513
- /** Overall progress (0-100) */
514
- overallProgress: number;
515
- /** Optional message about current operation */
516
- message?: string;
517
- /** Number of entities processed so far */
518
- entitiesProcessed?: number;
519
- /** Total number of entities (if known) */
520
- totalEntities?: number;
521
- /** Elapsed time in milliseconds */
522
- elapsedMs: number;
523
- /** Estimated remaining time in milliseconds (if available) */
524
- estimatedRemainingMs?: number;
525
- }
526
- /**
527
- * Callback function for reporting progress
528
- */
529
- export type ProgressCallback = (progress: ProgressInfo) => void;
530
- /**
531
- * Options for parsing JWW files
532
- */
533
- export interface ParseOptions {
534
- /**
535
- * Enable streaming mode for lower memory usage
536
- * When enabled, entities are processed in chunks
537
- * @default false
538
- */
539
- streamingMode?: boolean;
540
- /**
541
- * Skip parsing of specific entity types
542
- * Useful for improving performance when not all entities are needed
543
- */
544
- skipEntityTypes?: Array<JwwEntity["Type"]>;
545
- /**
546
- * Only parse entities on specific layer groups
547
- * Array of layer group indices (0-15)
548
- */
549
- layerGroupFilter?: number[];
550
- /**
551
- * Only parse entities on specific layers
552
- * Format: { layerGroup: layerIndex[] }
553
- */
554
- layerFilter?: Record<number, number[]>;
555
- /**
556
- * Limit the number of entities to parse
557
- * Useful for previewing large files
558
- */
559
- maxEntities?: number;
560
- /**
561
- * Include block definitions in the output
562
- * @default true
563
- */
564
- includeBlocks?: boolean;
565
- /**
566
- * Expand block references inline (replaces INSERT with actual entities)
567
- * Warning: May significantly increase output size
568
- * @default false
569
- */
570
- expandBlockReferences?: boolean;
571
- /**
572
- * Progress callback function
573
- * Called periodically during parsing with progress information
574
- */
575
- onProgress?: ProgressCallback;
576
- /**
577
- * Abort signal for cancelling the parse operation
578
- */
579
- signal?: AbortSignal;
580
- }
581
- /**
582
- * Options for DXF conversion
583
- */
584
- export interface ConvertOptions extends ParseOptions {
585
- /**
586
- * Convert temporary points (Code > 0)
587
- * @default false
588
- */
589
- includeTemporaryPoints?: boolean;
590
- /**
591
- * Color mapping override
592
- * Maps JWW color codes to DXF ACI colors
593
- */
594
- colorMapping?: Record<number, number>;
595
- /**
596
- * Layer naming pattern
597
- * Use {group} and {layer} placeholders
598
- * @default "{group}-{layer}"
599
- */
600
- layerNamePattern?: string;
601
- /**
602
- * Precision for coordinate values (decimal places)
603
- * @default 6
604
- */
605
- precision?: number;
606
- }
607
- /**
608
- * Severity level for validation issues
609
- */
610
- export type ValidationSeverity = "error" | "warning" | "info";
611
- /**
612
- * A single validation issue
613
- */
614
- export interface ValidationIssue {
615
- /** Severity of the issue */
616
- severity: ValidationSeverity;
617
- /** Issue code */
618
- code: string;
619
- /** Human-readable message */
620
- message: string;
621
- /** Byte offset where the issue was found, if applicable */
622
- offset?: number;
623
- /** Additional details */
624
- details?: Record<string, unknown>;
625
- }
626
- /**
627
- * Result of file validation
628
- */
629
- export interface ValidationResult {
630
- /** Whether the file is valid (no errors) */
631
- valid: boolean;
632
- /** File format version, if detected */
633
- version?: number;
634
- /** Estimated file size category */
635
- sizeCategory: "small" | "medium" | "large" | "very_large";
636
- /** Estimated entity count, if detectable */
637
- estimatedEntityCount?: number;
638
- /** List of validation issues found */
639
- issues: ValidationIssue[];
640
- /** Validation took this many milliseconds */
641
- validationTimeMs: number;
642
- }
643
- /**
644
- * Debug log levels
645
- */
646
- export type LogLevel = "debug" | "info" | "warn" | "error";
647
- /**
648
- * Debug log entry
649
- */
650
- export interface DebugLogEntry {
651
- /** Timestamp of the log entry */
652
- timestamp: Date;
653
- /** Log level */
654
- level: LogLevel;
655
- /** Log message */
656
- message: string;
657
- /** Additional data */
658
- data?: Record<string, unknown>;
659
- }
660
- /**
661
- * Debug callback function
662
- */
663
- export type DebugCallback = (entry: DebugLogEntry) => void;
664
- /**
665
- * Debug options
666
- */
667
- export interface DebugOptions {
668
- /**
669
- * Enable debug mode
670
- * @default false
671
- */
672
- enabled?: boolean;
673
- /**
674
- * Minimum log level to capture
675
- * @default "info"
676
- */
677
- logLevel?: LogLevel;
678
- /**
679
- * Debug callback function
680
- * If not provided, logs will be stored internally
681
- */
682
- onDebug?: DebugCallback;
683
- /**
684
- * Log to console
685
- * @default false
686
- */
687
- logToConsole?: boolean;
688
- /**
689
- * Maximum number of log entries to store
690
- * @default 1000
691
- */
692
- maxLogEntries?: number;
693
- /**
694
- * Include timing information
695
- * @default true
696
- */
697
- includeTiming?: boolean;
698
- /**
699
- * Include memory usage information
700
- * @default false
701
- */
702
- includeMemoryUsage?: boolean;
703
- }
704
- /**
705
- * Memory usage statistics
706
- */
707
- export interface MemoryStats {
708
- /** WASM memory buffer size in bytes */
709
- wasmMemoryBytes: number;
710
- /** Estimated JS heap usage in bytes (if available) */
711
- jsHeapBytes?: number;
712
- /** Total estimated memory usage */
713
- totalBytes: number;
714
- /** Human-readable total */
715
- totalFormatted: string;
716
- }
717
- /**
718
- * Parser statistics
719
- */
720
- export interface ParserStats {
721
- /** Number of parse operations performed */
722
- parseCount: number;
723
- /** Total bytes processed */
724
- totalBytesProcessed: number;
725
- /** Average parse time in milliseconds */
726
- averageParseTimeMs: number;
727
- /** Fastest parse time in milliseconds */
728
- fastestParseTimeMs: number;
729
- /** Slowest parse time in milliseconds */
730
- slowestParseTimeMs: number;
731
- /** Number of errors encountered */
732
- errorCount: number;
733
- /** Current memory usage */
734
- memoryStats: MemoryStats;
735
- }
736
- /**
737
- * Result type from WASM operations
738
- * @internal
739
- */
740
- interface WasmResult {
741
- ok: boolean;
742
- data?: string;
743
- error?: string;
744
- errorCode?: string;
745
- offset?: number;
746
- section?: string;
747
- }
748
- /**
749
- * Validation result from WASM
750
- * @internal
751
- */
752
- interface WasmValidationResult {
753
- ok: boolean;
754
- valid: boolean;
755
- version?: number;
756
- estimatedEntities?: number;
757
- issues?: Array<{
758
- severity: string;
759
- code: string;
760
- message: string;
761
- offset?: number;
762
- }>;
763
- error?: string;
764
- }
765
- declare global {
766
- var Go: new () => GoInstance;
767
- var jwwParse: ((data: Uint8Array) => WasmResult) | undefined;
768
- var jwwToDxf: ((data: Uint8Array) => WasmResult) | undefined;
769
- var jwwToDxfString: ((data: Uint8Array) => WasmResult) | undefined;
770
- var jwwValidate: ((data: Uint8Array) => WasmValidationResult) | undefined;
771
- var jwwGetVersion: (() => string) | undefined;
772
- var jwwSetDebug: ((enabled: boolean) => void) | undefined;
773
- }
774
- interface GoInstance {
775
- importObject: WebAssembly.Imports;
776
- run(instance: WebAssembly.Instance): Promise<void>;
777
- _inst?: WebAssembly.Instance;
778
- }
779
- /**
780
- * JWW file parser with WebAssembly backend
781
- *
782
- * @example
783
- * ```typescript
784
- * // Using the factory function (recommended)
785
- * const parser = await createParser();
786
- * const doc = parser.parse(fileData);
787
- *
788
- * // Manual initialization
789
- * const parser = new JwwParser();
790
- * await parser.init();
791
- * const doc = parser.parse(fileData);
792
- * ```
793
- */
794
- export declare class JwwParser {
795
- private initialized;
796
- private initPromise;
797
- private wasmPath;
798
- private goInstance;
799
- private wasmInstance;
800
- private debugOptions;
801
- private debugLogs;
802
- private stats;
803
- /**
804
- * Create a new JWW parser instance
805
- * @param wasmPath - Path to the jww-parser.wasm file
806
- */
807
- constructor(wasmPath?: string);
808
- private getDefaultWasmPath;
809
- /**
810
- * Enable or configure debug mode
811
- * @param options - Debug configuration options
812
- */
813
- setDebug(options: DebugOptions | boolean): void;
814
- /**
815
- * Get debug logs
816
- * @param level - Optional minimum log level to filter
817
- * @returns Array of debug log entries
818
- */
819
- getDebugLogs(level?: LogLevel): DebugLogEntry[];
820
- /**
821
- * Clear debug logs
822
- */
823
- clearDebugLogs(): void;
824
- private log;
825
- /**
826
- * Check if the parser is initialized
827
- */
828
- isInitialized(): boolean;
829
- /**
830
- * Initialize the WASM module
831
- * Must be called before using parse methods
832
- */
833
- init(): Promise<void>;
834
- private loadWasm;
835
- private loadWasmExec;
836
- private waitForWasmFunctions;
837
- private ensureInitialized;
838
- /**
839
- * Validate a JWW file without fully parsing it
840
- * Useful for checking file validity before processing
841
- *
842
- * @param data - JWW file content as Uint8Array
843
- * @returns Validation result with any issues found
844
- */
845
- validate(data: Uint8Array): ValidationResult;
846
- /**
847
- * Validate and throw if invalid
848
- * Convenience method that throws a ValidationError if the file is invalid
849
- *
850
- * @param data - JWW file content as Uint8Array
851
- * @throws {ValidationError} If the file is invalid
852
- */
853
- validateOrThrow(data: Uint8Array): void;
854
- /**
855
- * Parse a JWW file and return the document structure
856
- *
857
- * @param data - JWW file content as Uint8Array
858
- * @param options - Optional parsing options
859
- * @returns Parsed JWW document
860
- * @throws {NotInitializedError} If parser is not initialized
861
- * @throws {ParseError} If parsing fails
862
- */
863
- parse(data: Uint8Array, options?: ParseOptions): JwwDocument;
864
- private applyParseOptions;
865
- /**
866
- * Parse a JWW file and convert to DXF document structure
867
- *
868
- * @param data - JWW file content as Uint8Array
869
- * @param options - Optional conversion options
870
- * @returns DXF document object
871
- */
872
- toDxf(data: Uint8Array, options?: ConvertOptions): DxfDocument;
873
- /**
874
- * Parse a JWW file and convert to DXF file content string
875
- *
876
- * @param data - JWW file content as Uint8Array
877
- * @param options - Optional conversion options
878
- * @returns DXF file content as string (ready to save as .dxf file)
879
- */
880
- toDxfString(data: Uint8Array, options?: ConvertOptions): string;
881
- /**
882
- * Get current memory usage statistics
883
- */
884
- getMemoryStats(): MemoryStats;
885
- /**
886
- * Get parser statistics
887
- */
888
- getStats(): ParserStats;
889
- /**
890
- * Reset parser statistics
891
- */
892
- resetStats(): void;
893
- /**
894
- * Clean up resources and release memory
895
- * Call this when you're done using the parser to free WASM memory
896
- */
897
- dispose(): void;
898
- /**
899
- * Get the WASM module version
900
- */
901
- getVersion(): string;
902
- }
903
- /**
904
- * Create and initialize a JWW parser instance
905
- *
906
- * @param wasmPath - Optional path to the jww-parser.wasm file
907
- * @param options - Optional debug options
908
- * @returns Initialized JwwParser instance
909
- *
910
- * @example
911
- * ```typescript
912
- * const parser = await createParser();
913
- * const doc = parser.parse(fileData);
914
- * ```
915
- */
916
- export declare function createParser(wasmPath?: string, options?: {
917
- debug?: DebugOptions;
918
- }): Promise<JwwParser>;
919
- /**
920
- * Quick validate a JWW file without initializing a full parser
921
- * Performs basic validation only (signature, version check)
922
- *
923
- * @param data - JWW file content as Uint8Array
924
- * @returns Validation result
925
- */
926
- export declare function quickValidate(data: Uint8Array): ValidationResult;
927
- /**
928
- * Check if a Uint8Array looks like a JWW file
929
- *
930
- * @param data - File content as Uint8Array
931
- * @returns true if the file appears to be a JWW file
932
- */
933
- export declare function isJwwFile(data: Uint8Array): boolean;
934
- declare const _default: {
935
- JwwParser: typeof JwwParser;
936
- createParser: typeof createParser;
937
- quickValidate: typeof quickValidate;
938
- isJwwFile: typeof isJwwFile;
939
- JwwParserError: typeof JwwParserError;
940
- NotInitializedError: typeof NotInitializedError;
941
- WasmLoadError: typeof WasmLoadError;
942
- ValidationError: typeof ValidationError;
943
- ParseError: typeof ParseError;
944
- JwwErrorCode: typeof JwwErrorCode;
945
- };
946
- export default _default;
947
- //# sourceMappingURL=index.d.ts.map
1
+ import type * as MoonBit from "./moonbit.d.ts";
2
+
3
+ export function to_json_string(jww_doc: any): MoonBit.String;
4
+
5
+ export function jww_to_dxf(data: MoonBit.Bytes): MoonBit.String;
6
+
7
+ export function to_dxf_string(jww_doc: any): MoonBit.String;
8
+
9
+ export function to_dxf_document(jww_doc: any): any;
10
+
11
+ export function parse(data: MoonBit.Bytes): any;