@mlightcad/data-model 1.1.3 → 1.1.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/data-model.js +91 -62
- package/dist/data-model.umd.cjs +2 -2
- package/lib/converter/AcDbBatchProcessing.d.ts +2 -1
- package/lib/converter/AcDbBatchProcessing.d.ts.map +1 -1
- package/lib/converter/AcDbBatchProcessing.js +27 -17
- package/lib/converter/AcDbBatchProcessing.js.map +1 -1
- package/lib/database/AcDbDatabase.d.ts +10 -4
- package/lib/database/AcDbDatabase.d.ts.map +1 -1
- package/lib/database/AcDbDatabase.js +36 -29
- package/lib/database/AcDbDatabase.js.map +1 -1
- package/lib/database/AcDbDatabaseConverter.d.ts +3 -3
- package/lib/database/AcDbDatabaseConverter.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/data-model.js
CHANGED
|
@@ -1234,6 +1234,23 @@ class Hn {
|
|
|
1234
1234
|
}, this.onError = () => {
|
|
1235
1235
|
};
|
|
1236
1236
|
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Schedules a task to be executed asynchronously.
|
|
1239
|
+
*
|
|
1240
|
+
* This method uses requestAnimationFrame in browser environments or setTimeout
|
|
1241
|
+
* in Node.js environments to schedule the task.
|
|
1242
|
+
*
|
|
1243
|
+
* @param callback - The callback function to schedule
|
|
1244
|
+
* @returns Promise that resolves with the result of the callback
|
|
1245
|
+
*/
|
|
1246
|
+
scheduleTask(t) {
|
|
1247
|
+
return new Promise((e, s) => {
|
|
1248
|
+
const n = () => {
|
|
1249
|
+
Promise.resolve(t()).then(e).catch(s);
|
|
1250
|
+
};
|
|
1251
|
+
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(n) : setTimeout(n, 0);
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1237
1254
|
/**
|
|
1238
1255
|
* Adds a task to the execution queue.
|
|
1239
1256
|
*
|
|
@@ -1269,15 +1286,9 @@ class Hn {
|
|
|
1269
1286
|
for (let n = 0; n < e; n++) {
|
|
1270
1287
|
const i = this.tasks[n];
|
|
1271
1288
|
try {
|
|
1272
|
-
s = await
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
const c = await i.run(s);
|
|
1276
|
-
this.onProgress((n + 1) / e, i), a(c);
|
|
1277
|
-
} catch (c) {
|
|
1278
|
-
o(c);
|
|
1279
|
-
}
|
|
1280
|
-
}, 0);
|
|
1289
|
+
s = await this.scheduleTask(async () => {
|
|
1290
|
+
const a = await i.run(s);
|
|
1291
|
+
return this.onProgress((n + 1) / e, i), a;
|
|
1281
1292
|
});
|
|
1282
1293
|
} catch (a) {
|
|
1283
1294
|
this.onError(a, n, i);
|
|
@@ -1544,16 +1555,22 @@ class Yn {
|
|
|
1544
1555
|
* in Node.js environments to schedule the task.
|
|
1545
1556
|
*
|
|
1546
1557
|
* @param callback - The callback function to schedule
|
|
1558
|
+
* @returns Promise that resolves when the task completes
|
|
1547
1559
|
*
|
|
1548
1560
|
* @example
|
|
1549
1561
|
* ```typescript
|
|
1550
|
-
* batchProcessor.scheduleTask(() => {
|
|
1562
|
+
* await batchProcessor.scheduleTask(async () => {
|
|
1551
1563
|
* // Task to be executed asynchronously
|
|
1552
1564
|
* });
|
|
1553
1565
|
* ```
|
|
1554
1566
|
*/
|
|
1555
1567
|
scheduleTask(t) {
|
|
1556
|
-
|
|
1568
|
+
return new Promise((e, s) => {
|
|
1569
|
+
const n = () => {
|
|
1570
|
+
Promise.resolve(t()).then(e).catch(s);
|
|
1571
|
+
};
|
|
1572
|
+
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(n) : setTimeout(n, 0);
|
|
1573
|
+
});
|
|
1557
1574
|
}
|
|
1558
1575
|
/**
|
|
1559
1576
|
* Processes items in chunks using the provided callback function.
|
|
@@ -1578,7 +1595,7 @@ class Yn {
|
|
|
1578
1595
|
let e = 0;
|
|
1579
1596
|
const s = async () => {
|
|
1580
1597
|
const n = e, i = Math.min(e + this._chunkSize, this._count);
|
|
1581
|
-
await t(n, i), e = i, e < this._count && this.scheduleTask(s);
|
|
1598
|
+
await t(n, i), e = i, e < this._count && await this.scheduleTask(s);
|
|
1582
1599
|
};
|
|
1583
1600
|
await s();
|
|
1584
1601
|
}
|
|
@@ -3082,17 +3099,17 @@ class J extends Gn {
|
|
|
3082
3099
|
class _a {
|
|
3083
3100
|
/**
|
|
3084
3101
|
* Reads and converts data into an AcDbDatabase.
|
|
3085
|
-
*
|
|
3102
|
+
*
|
|
3086
3103
|
* This method orchestrates the entire conversion process, including
|
|
3087
3104
|
* parsing, processing various components (fonts, linetypes, styles, etc.),
|
|
3088
3105
|
* and building the final database.
|
|
3089
|
-
*
|
|
3106
|
+
*
|
|
3090
3107
|
* @param data - The input data to convert (string or ArrayBuffer)
|
|
3091
3108
|
* @param db - The database to populate with converted data
|
|
3092
3109
|
* @param minimumChunkSize - Minimum chunk size for batch processing
|
|
3093
3110
|
* @param progress - Optional progress callback
|
|
3094
3111
|
* @returns Promise that resolves when conversion is complete
|
|
3095
|
-
*
|
|
3112
|
+
*
|
|
3096
3113
|
* @example
|
|
3097
3114
|
* ```typescript
|
|
3098
3115
|
* const converter = new MyConverter();
|
|
@@ -17309,9 +17326,9 @@ class dh extends Wt {
|
|
|
17309
17326
|
}
|
|
17310
17327
|
/**
|
|
17311
17328
|
* Gets all tables in this drawing database.
|
|
17312
|
-
*
|
|
17329
|
+
*
|
|
17313
17330
|
* @returns Object containing all the symbol tables in the database
|
|
17314
|
-
*
|
|
17331
|
+
*
|
|
17315
17332
|
* @example
|
|
17316
17333
|
* ```typescript
|
|
17317
17334
|
* const tables = database.tables;
|
|
@@ -17324,9 +17341,9 @@ class dh extends Wt {
|
|
|
17324
17341
|
}
|
|
17325
17342
|
/**
|
|
17326
17343
|
* Gets all named object dictionaries in this drawing database.
|
|
17327
|
-
*
|
|
17344
|
+
*
|
|
17328
17345
|
* @returns Object containing all the dictionaries in the database
|
|
17329
|
-
*
|
|
17346
|
+
*
|
|
17330
17347
|
* @example
|
|
17331
17348
|
* ```typescript
|
|
17332
17349
|
* const dictionaries = database.dictionaries;
|
|
@@ -17338,11 +17355,11 @@ class dh extends Wt {
|
|
|
17338
17355
|
}
|
|
17339
17356
|
/**
|
|
17340
17357
|
* Gets the object ID of the AcDbBlockTableRecord of the current space.
|
|
17341
|
-
*
|
|
17358
|
+
*
|
|
17342
17359
|
* The current space can be either model space or paper space.
|
|
17343
|
-
*
|
|
17360
|
+
*
|
|
17344
17361
|
* @returns The object ID of the current space
|
|
17345
|
-
*
|
|
17362
|
+
*
|
|
17346
17363
|
* @example
|
|
17347
17364
|
* ```typescript
|
|
17348
17365
|
* const currentSpaceId = database.currentSpaceId;
|
|
@@ -17353,10 +17370,10 @@ class dh extends Wt {
|
|
|
17353
17370
|
}
|
|
17354
17371
|
/**
|
|
17355
17372
|
* Sets the current space by object ID.
|
|
17356
|
-
*
|
|
17373
|
+
*
|
|
17357
17374
|
* @param value - The object ID of the block table record to set as current space
|
|
17358
17375
|
* @throws {Error} When the specified block table record ID doesn't exist
|
|
17359
|
-
*
|
|
17376
|
+
*
|
|
17360
17377
|
* @example
|
|
17361
17378
|
* ```typescript
|
|
17362
17379
|
* database.currentSpaceId = 'some-block-record-id';
|
|
@@ -17372,11 +17389,11 @@ class dh extends Wt {
|
|
|
17372
17389
|
}
|
|
17373
17390
|
/**
|
|
17374
17391
|
* Gets the angle units for the database.
|
|
17375
|
-
*
|
|
17392
|
+
*
|
|
17376
17393
|
* This is the current AUNITS value for the database.
|
|
17377
|
-
*
|
|
17394
|
+
*
|
|
17378
17395
|
* @returns The angle units value
|
|
17379
|
-
*
|
|
17396
|
+
*
|
|
17380
17397
|
* @example
|
|
17381
17398
|
* ```typescript
|
|
17382
17399
|
* const angleUnits = database.aunits;
|
|
@@ -17387,9 +17404,9 @@ class dh extends Wt {
|
|
|
17387
17404
|
}
|
|
17388
17405
|
/**
|
|
17389
17406
|
* Sets the angle units for the database.
|
|
17390
|
-
*
|
|
17407
|
+
*
|
|
17391
17408
|
* @param value - The new angle units value
|
|
17392
|
-
*
|
|
17409
|
+
*
|
|
17393
17410
|
* @example
|
|
17394
17411
|
* ```typescript
|
|
17395
17412
|
* database.aunits = AcDbAngleUnits.DecimalDegrees;
|
|
@@ -17400,11 +17417,11 @@ class dh extends Wt {
|
|
|
17400
17417
|
}
|
|
17401
17418
|
/**
|
|
17402
17419
|
* Gets the drawing-units value for automatic scaling of blocks, images, or xrefs.
|
|
17403
|
-
*
|
|
17420
|
+
*
|
|
17404
17421
|
* This is the current INSUNITS value for the database.
|
|
17405
|
-
*
|
|
17422
|
+
*
|
|
17406
17423
|
* @returns The insertion units value
|
|
17407
|
-
*
|
|
17424
|
+
*
|
|
17408
17425
|
* @example
|
|
17409
17426
|
* ```typescript
|
|
17410
17427
|
* const insertionUnits = database.insunits;
|
|
@@ -17415,9 +17432,9 @@ class dh extends Wt {
|
|
|
17415
17432
|
}
|
|
17416
17433
|
/**
|
|
17417
17434
|
* Sets the drawing-units value for automatic scaling.
|
|
17418
|
-
*
|
|
17435
|
+
*
|
|
17419
17436
|
* @param value - The new insertion units value
|
|
17420
|
-
*
|
|
17437
|
+
*
|
|
17421
17438
|
* @example
|
|
17422
17439
|
* ```typescript
|
|
17423
17440
|
* database.insunits = AcDbUnitsValue.Millimeters;
|
|
@@ -17428,9 +17445,9 @@ class dh extends Wt {
|
|
|
17428
17445
|
}
|
|
17429
17446
|
/**
|
|
17430
17447
|
* Gets the line type scale factor.
|
|
17431
|
-
*
|
|
17448
|
+
*
|
|
17432
17449
|
* @returns The line type scale factor
|
|
17433
|
-
*
|
|
17450
|
+
*
|
|
17434
17451
|
* @example
|
|
17435
17452
|
* ```typescript
|
|
17436
17453
|
* const lineTypeScale = database.ltscale;
|
|
@@ -17441,9 +17458,9 @@ class dh extends Wt {
|
|
|
17441
17458
|
}
|
|
17442
17459
|
/**
|
|
17443
17460
|
* Sets the line type scale factor.
|
|
17444
|
-
*
|
|
17461
|
+
*
|
|
17445
17462
|
* @param value - The new line type scale factor
|
|
17446
|
-
*
|
|
17463
|
+
*
|
|
17447
17464
|
* @example
|
|
17448
17465
|
* ```typescript
|
|
17449
17466
|
* database.ltscale = 2.0;
|
|
@@ -17454,9 +17471,9 @@ class dh extends Wt {
|
|
|
17454
17471
|
}
|
|
17455
17472
|
/**
|
|
17456
17473
|
* Gets the color of new objects as they are created.
|
|
17457
|
-
*
|
|
17474
|
+
*
|
|
17458
17475
|
* @returns The current entity color
|
|
17459
|
-
*
|
|
17476
|
+
*
|
|
17460
17477
|
* @example
|
|
17461
17478
|
* ```typescript
|
|
17462
17479
|
* const currentColor = database.cecolor;
|
|
@@ -17467,9 +17484,9 @@ class dh extends Wt {
|
|
|
17467
17484
|
}
|
|
17468
17485
|
/**
|
|
17469
17486
|
* Sets the color of new objects as they are created.
|
|
17470
|
-
*
|
|
17487
|
+
*
|
|
17471
17488
|
* @param value - The new current entity color
|
|
17472
|
-
*
|
|
17489
|
+
*
|
|
17473
17490
|
* @example
|
|
17474
17491
|
* ```typescript
|
|
17475
17492
|
* database.cecolor = new AcCmColor(0xFF0000);
|
|
@@ -17532,23 +17549,23 @@ class dh extends Wt {
|
|
|
17532
17549
|
}
|
|
17533
17550
|
/**
|
|
17534
17551
|
* Reads drawing data from a string or ArrayBuffer.
|
|
17535
|
-
*
|
|
17552
|
+
*
|
|
17536
17553
|
* This method parses the provided data and populates the database with
|
|
17537
17554
|
* the resulting entities, tables, and objects. The method supports
|
|
17538
17555
|
* both DXF and DWG file formats.
|
|
17539
|
-
*
|
|
17556
|
+
*
|
|
17540
17557
|
* @param data - The drawing data as a string or ArrayBuffer
|
|
17541
17558
|
* - For DXF files: Pass a string containing the DXF content
|
|
17542
17559
|
* - For DWG files: Pass an ArrayBuffer instance containing the binary DWG data
|
|
17543
17560
|
* @param options - Options for reading the database
|
|
17544
17561
|
* @param fileType - The type of file being read (defaults to DXF)
|
|
17545
|
-
*
|
|
17562
|
+
*
|
|
17546
17563
|
* @example
|
|
17547
17564
|
* ```typescript
|
|
17548
17565
|
* // Reading a DXF file (string)
|
|
17549
17566
|
* const database = new AcDbDatabase();
|
|
17550
17567
|
* await database.read(dxfString, { readOnly: true }, AcDbFileType.DXF);
|
|
17551
|
-
*
|
|
17568
|
+
*
|
|
17552
17569
|
* // Reading a DWG file (ArrayBuffer)
|
|
17553
17570
|
* const database = new AcDbDatabase();
|
|
17554
17571
|
* await database.read(dwgArrayBuffer, { readOnly: true }, AcDbFileType.DWG);
|
|
@@ -17568,7 +17585,8 @@ class dh extends Wt {
|
|
|
17568
17585
|
if (this.events.openProgress.dispatch({
|
|
17569
17586
|
database: this,
|
|
17570
17587
|
percentage: i,
|
|
17571
|
-
stage:
|
|
17588
|
+
stage: "CONVERSION",
|
|
17589
|
+
subStage: a,
|
|
17572
17590
|
stageStatus: o
|
|
17573
17591
|
}), e && e.fontLoader && a == "FONT" && o == "END") {
|
|
17574
17592
|
const l = c || this.tables.textStyleTable.fonts;
|
|
@@ -17586,23 +17604,34 @@ class dh extends Wt {
|
|
|
17586
17604
|
* @param options Input options to read drawing data
|
|
17587
17605
|
*/
|
|
17588
17606
|
async openUri(t, e) {
|
|
17589
|
-
|
|
17590
|
-
|
|
17591
|
-
|
|
17592
|
-
|
|
17593
|
-
|
|
17594
|
-
}
|
|
17595
|
-
|
|
17596
|
-
|
|
17597
|
-
|
|
17598
|
-
|
|
17607
|
+
this.events.openProgress.dispatch({
|
|
17608
|
+
database: this,
|
|
17609
|
+
percentage: 0,
|
|
17610
|
+
stage: "FETCH_FILE",
|
|
17611
|
+
stageStatus: "START"
|
|
17612
|
+
});
|
|
17613
|
+
const s = await fetch(t);
|
|
17614
|
+
if (this.events.openProgress.dispatch({
|
|
17615
|
+
database: this,
|
|
17616
|
+
percentage: 100,
|
|
17617
|
+
stage: "FETCH_FILE",
|
|
17618
|
+
stageStatus: "END"
|
|
17619
|
+
}), !s.ok)
|
|
17620
|
+
throw new Error(`Failed to fetch file '${t}' with HTTP status codee '${s.status}'!`);
|
|
17621
|
+
if (t.toLowerCase().split(".").pop() === "dwg") {
|
|
17622
|
+
const i = await s.arrayBuffer();
|
|
17623
|
+
await this.read(i, e, Ze.DWG);
|
|
17624
|
+
} else {
|
|
17625
|
+
const i = await s.text();
|
|
17626
|
+
await this.read(i, e, Ze.DXF);
|
|
17627
|
+
}
|
|
17599
17628
|
}
|
|
17600
17629
|
/**
|
|
17601
17630
|
* Clears all data from the database.
|
|
17602
|
-
*
|
|
17631
|
+
*
|
|
17603
17632
|
* This method removes all entities, tables, and objects from the database,
|
|
17604
17633
|
* effectively resetting it to an empty state.
|
|
17605
|
-
*
|
|
17634
|
+
*
|
|
17606
17635
|
* @example
|
|
17607
17636
|
* ```typescript
|
|
17608
17637
|
* database.clear();
|
|
@@ -17613,12 +17642,12 @@ class dh extends Wt {
|
|
|
17613
17642
|
}
|
|
17614
17643
|
/**
|
|
17615
17644
|
* Triggers a header system variable changed event.
|
|
17616
|
-
*
|
|
17645
|
+
*
|
|
17617
17646
|
* This method is called internally when header system variables
|
|
17618
17647
|
* are modified to notify listeners of the change.
|
|
17619
|
-
*
|
|
17648
|
+
*
|
|
17620
17649
|
* @param sysVarName - The name of the system variable that changed
|
|
17621
|
-
*
|
|
17650
|
+
*
|
|
17622
17651
|
* @example
|
|
17623
17652
|
* ```typescript
|
|
17624
17653
|
* database.triggerHeaderSysVarChangedEvent('aunits');
|