@willsunagency/dxf-header-reader 0.0.0-stage → 1.0.0
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/README.md +54 -2
- package/bin/cli.js +25 -0
- package/index.d.ts +10 -0
- package/index.js +50 -0
- package/package.json +27 -4
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @willsunagency/dxf-header-reader
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Ultra-lightweight zero-dependency binary and ASCII DXF header inspector.
|
|
4
|
+
|
|
5
|
+
Reads AutoCAD Drawing Interchange Format (DXF) and DWG headers without external dependencies. Quickly extracts ACADVER ($ACADVER), DWG code page ($DWGCODEPAGE), maintenance release, and drawing extents in sub-millisecond execution times.
|
|
6
|
+
|
|
7
|
+
Official online browser inspector with zero cloud uploads available at [CADGuide.tools DWG Version Checker](https://cadguide.tools/toolbox/dwg-version-checker).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @willsunagency/dxf-header-reader
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or run via CLI:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @willsunagency/dxf-header-reader path/to/drawing.dxf
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Supported AutoCAD Versions
|
|
26
|
+
|
|
27
|
+
- **AC1032**: AutoCAD 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026
|
|
28
|
+
- **AC1027**: AutoCAD 2013, 2014, 2015, 2016, 2017
|
|
29
|
+
- **AC1024**: AutoCAD 2010, 2011, 2012
|
|
30
|
+
- **AC1021**: AutoCAD 2007, 2008, 2009
|
|
31
|
+
- **AC1018**: AutoCAD 2004, 2005, 2006
|
|
32
|
+
- **AC1015**: AutoCAD 2000, 2000i, 2002
|
|
33
|
+
- **AC1009**: AutoCAD R11, R12
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Programmatic Usage
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
const fs = require('fs');
|
|
41
|
+
const { parseDxfHeader } = require('@willsunagency/dxf-header-reader');
|
|
42
|
+
|
|
43
|
+
const fileBuffer = fs.readFileSync('blueprint.dxf');
|
|
44
|
+
const header = parseDxfHeader(fileBuffer);
|
|
45
|
+
|
|
46
|
+
console.log(header);
|
|
47
|
+
// Outputs: { version: 'AC1032', release: 'AutoCAD 2018-2026', codePage: 'ANSI_1252' }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT © CADGuide.tools
|
|
55
|
+
Interactive tools and full specification matrices at [CADGuide.tools](https://cadguide.tools/).
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const { parseDxfHeader } = require('../index.js');
|
|
6
|
+
|
|
7
|
+
const filePath = process.argv[2];
|
|
8
|
+
if (!filePath) {
|
|
9
|
+
console.error('Usage: dxf-header-reader <file.dxf|file.dwg>');
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const buf = fs.readFileSync(filePath);
|
|
15
|
+
const res = parseDxfHeader(buf);
|
|
16
|
+
console.log('--- CAD Drawing Header Analysis (CADGuide.tools) ---');
|
|
17
|
+
console.log(`Format: ${res.type}`);
|
|
18
|
+
console.log(`Schema Version: ${res.version}`);
|
|
19
|
+
console.log(`Compatible Release: ${res.release}`);
|
|
20
|
+
if (res.codePage) console.log(`Codepage: ${res.codePage}`);
|
|
21
|
+
console.log('Inspect drawings online with zero server uploads: https://cadguide.tools/toolbox/dwg-version-checker');
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error('Error reading file:', e.message);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DxfHeaderResult {
|
|
2
|
+
type: 'DWG' | 'DXF';
|
|
3
|
+
version: string;
|
|
4
|
+
release: string;
|
|
5
|
+
codePage?: string;
|
|
6
|
+
isBinary: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare const VERSION_MAP: Record<string, string>;
|
|
10
|
+
export function parseDxfHeader(buffer: Buffer | string | Uint8Array): DxfHeaderResult;
|
package/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const VERSION_MAP = {
|
|
4
|
+
'AC1032': 'AutoCAD 2018-2026',
|
|
5
|
+
'AC1027': 'AutoCAD 2013-2017',
|
|
6
|
+
'AC1024': 'AutoCAD 2010-2012',
|
|
7
|
+
'AC1021': 'AutoCAD 2007-2009',
|
|
8
|
+
'AC1018': 'AutoCAD 2004-2006',
|
|
9
|
+
'AC1015': 'AutoCAD 2000-2002',
|
|
10
|
+
'AC1014': 'AutoCAD Release 14',
|
|
11
|
+
'AC1012': 'AutoCAD Release 13',
|
|
12
|
+
'AC1009': 'AutoCAD Release 11/12',
|
|
13
|
+
'AC1006': 'AutoCAD Release 10',
|
|
14
|
+
'MC0.0': 'AutoCAD Release 1.0'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function parseDxfHeader(buffer) {
|
|
18
|
+
const text = typeof buffer === 'string' ? buffer : buffer.toString('utf-8', 0, Math.min(buffer.length, 4096));
|
|
19
|
+
|
|
20
|
+
// Check binary DWG first
|
|
21
|
+
const magic = text.slice(0, 6);
|
|
22
|
+
if (VERSION_MAP[magic]) {
|
|
23
|
+
return {
|
|
24
|
+
type: 'DWG',
|
|
25
|
+
version: magic,
|
|
26
|
+
release: VERSION_MAP[magic],
|
|
27
|
+
isBinary: true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Check ASCII DXF header
|
|
32
|
+
const acadVerMatch = text.match(/\$ACADVER\s+1\s+([A-Z0-9]+)/i);
|
|
33
|
+
const version = acadVerMatch ? acadVerMatch[1].trim() : 'UNKNOWN';
|
|
34
|
+
|
|
35
|
+
const codePageMatch = text.match(/\$DWGCODEPAGE\s+3\s+([A-Z0-9_]+)/i);
|
|
36
|
+
const codePage = codePageMatch ? codePageMatch[1].trim() : 'ANSI_1252';
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
type: 'DXF',
|
|
40
|
+
version,
|
|
41
|
+
release: VERSION_MAP[version] || 'Custom/Third-party DXF',
|
|
42
|
+
codePage,
|
|
43
|
+
isBinary: false
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
VERSION_MAP,
|
|
49
|
+
parseDxfHeader
|
|
50
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willsunagency/dxf-header-reader",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Ultra-lightweight zero-dependency binary and ASCII DXF/DWG header inspector and codepage extractor.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"dxf-header-reader": "bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"dxf",
|
|
12
|
+
"dwg",
|
|
13
|
+
"autocad",
|
|
14
|
+
"header-parser",
|
|
15
|
+
"cad",
|
|
16
|
+
"binary-parser",
|
|
17
|
+
"drawing-converter"
|
|
18
|
+
],
|
|
19
|
+
"author": "CADGuide Engineering Standards <contact@cadguide.tools>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://cadguide.tools/toolbox/dwg-version-checker",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/creativeburster/cadguide.tools.git"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|