@linkiez/dxf-renew 7.1.0 → 7.2.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/.eslintrc.json +1 -16
- package/.yarn/install-state.gz +0 -0
- package/ARCHITECTURE.md +163 -0
- package/CHANGELOG.md +16 -0
- package/README.md +72 -10
- package/{PLAN.md → ROADMAP.md} +227 -35
- package/dist/dxf.js +1090 -344
- package/docs/FIXTURE_VALIDATION_EZDXF.md +1 -1
- package/lib/Helper.cjs +4 -0
- package/lib/Helper.cjs.map +3 -3
- package/lib/Helper.js +4 -0
- package/lib/Helper.js.map +2 -2
- package/lib/entityToPolyline.cjs +95 -0
- package/lib/entityToPolyline.cjs.map +3 -3
- package/lib/entityToPolyline.js +95 -0
- package/lib/entityToPolyline.js.map +2 -2
- package/lib/handlers/entities.cjs +22 -2
- package/lib/handlers/entities.cjs.map +3 -3
- package/lib/handlers/entities.js +22 -2
- package/lib/handlers/entities.js.map +2 -2
- package/lib/handlers/entity/mleader.cjs +69 -0
- package/lib/handlers/entity/mleader.cjs.map +7 -0
- package/lib/handlers/entity/mleader.js +34 -0
- package/lib/handlers/entity/mleader.js.map +7 -0
- package/lib/handlers/entity/mline.cjs +91 -0
- package/lib/handlers/entity/mline.cjs.map +7 -0
- package/lib/handlers/entity/mline.js +56 -0
- package/lib/handlers/entity/mline.js.map +7 -0
- package/lib/handlers/entity/oleframe.cjs +98 -0
- package/lib/handlers/entity/oleframe.cjs.map +7 -0
- package/lib/handlers/entity/oleframe.js +63 -0
- package/lib/handlers/entity/oleframe.js.map +7 -0
- package/lib/handlers/entity/ray.cjs +81 -0
- package/lib/handlers/entity/ray.cjs.map +7 -0
- package/lib/handlers/entity/ray.js +46 -0
- package/lib/handlers/entity/ray.js.map +7 -0
- package/lib/handlers/entity/region.cjs +67 -0
- package/lib/handlers/entity/region.cjs.map +7 -0
- package/lib/handlers/entity/region.js +32 -0
- package/lib/handlers/entity/region.js.map +7 -0
- package/lib/handlers/entity/shape.cjs +95 -0
- package/lib/handlers/entity/shape.cjs.map +7 -0
- package/lib/handlers/entity/shape.js +60 -0
- package/lib/handlers/entity/shape.js.map +7 -0
- package/lib/handlers/entity/table.cjs +71 -0
- package/lib/handlers/entity/table.cjs.map +7 -0
- package/lib/handlers/entity/table.js +36 -0
- package/lib/handlers/entity/table.js.map +7 -0
- package/lib/handlers/entity/trace.cjs +101 -0
- package/lib/handlers/entity/trace.cjs.map +7 -0
- package/lib/handlers/entity/trace.js +66 -0
- package/lib/handlers/entity/trace.js.map +7 -0
- package/lib/handlers/entity/wipeout.cjs +122 -0
- package/lib/handlers/entity/wipeout.cjs.map +7 -0
- package/lib/handlers/entity/wipeout.js +87 -0
- package/lib/handlers/entity/wipeout.js.map +7 -0
- package/lib/handlers/entity/xline.cjs +81 -0
- package/lib/handlers/entity/xline.cjs.map +7 -0
- package/lib/handlers/entity/xline.js +46 -0
- package/lib/handlers/entity/xline.js.map +7 -0
- package/lib/handlers/objects.cjs +43 -1
- package/lib/handlers/objects.cjs.map +2 -2
- package/lib/handlers/objects.js +43 -1
- package/lib/handlers/objects.js.map +2 -2
- package/lib/handlers/tables.cjs +96 -17
- package/lib/handlers/tables.cjs.map +2 -2
- package/lib/handlers/tables.js +96 -17
- package/lib/handlers/tables.js.map +2 -2
- package/lib/index.cjs +5 -2
- package/lib/index.cjs.map +3 -3
- package/lib/index.js +18 -16
- package/lib/index.js.map +3 -3
- package/lib/toJson.cjs +29 -0
- package/lib/toJson.cjs.map +7 -0
- package/lib/toJson.js +9 -0
- package/lib/toJson.js.map +7 -0
- package/lib/toSVG.cjs +34 -3
- package/lib/toSVG.cjs.map +2 -2
- package/lib/toSVG.js +34 -3
- package/lib/toSVG.js.map +2 -2
- package/lib/types/entity.cjs.map +1 -1
- package/lib/types/helper.cjs.map +1 -1
- package/lib/types/index.cjs +20 -0
- package/lib/types/index.cjs.map +2 -2
- package/lib/types/index.js +10 -0
- package/lib/types/index.js.map +2 -2
- package/lib/types/mleader-entity.cjs +17 -0
- package/lib/types/mleader-entity.cjs.map +7 -0
- package/lib/types/mleader-entity.js +1 -0
- package/lib/types/mleader-entity.js.map +7 -0
- package/lib/types/mline-entity.cjs +17 -0
- package/lib/types/mline-entity.cjs.map +7 -0
- package/lib/types/mline-entity.js +1 -0
- package/lib/types/mline-entity.js.map +7 -0
- package/lib/types/oleframe-entity.cjs +17 -0
- package/lib/types/oleframe-entity.cjs.map +7 -0
- package/lib/types/oleframe-entity.js +1 -0
- package/lib/types/oleframe-entity.js.map +7 -0
- package/lib/types/options.cjs.map +1 -1
- package/lib/types/ray-entity.cjs +17 -0
- package/lib/types/ray-entity.cjs.map +7 -0
- package/lib/types/ray-entity.js +1 -0
- package/lib/types/ray-entity.js.map +7 -0
- package/lib/types/region-entity.cjs +17 -0
- package/lib/types/region-entity.cjs.map +7 -0
- package/lib/types/region-entity.js +1 -0
- package/lib/types/region-entity.js.map +7 -0
- package/lib/types/shape-entity.cjs +17 -0
- package/lib/types/shape-entity.cjs.map +7 -0
- package/lib/types/shape-entity.js +1 -0
- package/lib/types/shape-entity.js.map +7 -0
- package/lib/types/table-entity.cjs +17 -0
- package/lib/types/table-entity.cjs.map +7 -0
- package/lib/types/table-entity.js +1 -0
- package/lib/types/table-entity.js.map +7 -0
- package/lib/types/tables.cjs.map +1 -1
- package/lib/types/trace-entity.cjs +17 -0
- package/lib/types/trace-entity.cjs.map +7 -0
- package/lib/types/trace-entity.js +1 -0
- package/lib/types/trace-entity.js.map +7 -0
- package/lib/types/wipeout-entity.cjs +17 -0
- package/lib/types/wipeout-entity.cjs.map +7 -0
- package/lib/types/wipeout-entity.js +1 -0
- package/lib/types/wipeout-entity.js.map +7 -0
- package/lib/types/xline-entity.cjs +17 -0
- package/lib/types/xline-entity.cjs.map +7 -0
- package/lib/types/xline-entity.js +1 -0
- package/lib/types/xline-entity.js.map +7 -0
- package/package.json +5 -19
- package/src/Helper.ts +6 -1
- package/src/entityToPolyline.ts +124 -2
- package/src/handlers/entities.ts +21 -1
- package/src/handlers/entity/mleader.ts +46 -0
- package/src/handlers/entity/mline.ts +74 -0
- package/src/handlers/entity/oleframe.ts +62 -0
- package/src/handlers/entity/ray.ts +52 -0
- package/src/handlers/entity/region.ts +42 -0
- package/src/handlers/entity/shape.ts +73 -0
- package/src/handlers/entity/table.ts +49 -0
- package/src/handlers/entity/trace.ts +72 -0
- package/src/handlers/entity/wipeout.ts +114 -0
- package/src/handlers/entity/xline.ts +52 -0
- package/src/handlers/objects.ts +64 -8
- package/src/handlers/tables.ts +134 -21
- package/src/index.ts +9 -18
- package/src/toJson.ts +8 -0
- package/src/toSVG.ts +45 -3
- package/src/types/entity.ts +20 -0
- package/src/types/helper.ts +2 -1
- package/src/types/index.ts +10 -0
- package/src/types/mleader-entity.ts +8 -0
- package/src/types/mline-entity.ts +12 -0
- package/src/types/oleframe-entity.ts +40 -0
- package/src/types/options.ts +7 -0
- package/src/types/ray-entity.ts +12 -0
- package/src/types/region-entity.ts +11 -0
- package/src/types/shape-entity.ts +19 -0
- package/src/types/table-entity.ts +14 -0
- package/src/types/tables.ts +76 -0
- package/src/types/trace-entity.ts +14 -0
- package/src/types/wipeout-entity.ts +20 -0
- package/src/types/xline-entity.ts +12 -0
- package/docs/DIMENSION_SUMMARY.md +0 -254
- package/docs/DXF_VERSION_SUPPORT.md +0 -45
- package/docs/ENTITY_SVG_ROADMAP.md +0 -96
- package/docs/IMPLEMENTED-2D-ENTITIES.md +0 -54
- package/docs/README.md +0 -22
- package/docs/SVG_RENDERING_INTEGRATION_TESTS.md +0 -119
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +0 -241
package/.eslintrc.json
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
"node": true
|
|
6
6
|
},
|
|
7
7
|
"extends": [
|
|
8
|
-
"plugin:react/recommended",
|
|
9
8
|
"standard",
|
|
10
|
-
"standard-react",
|
|
11
9
|
"prettier"
|
|
12
10
|
],
|
|
13
11
|
"globals": {
|
|
@@ -21,25 +19,12 @@
|
|
|
21
19
|
"afterEach": "readonly"
|
|
22
20
|
},
|
|
23
21
|
"parserOptions": {
|
|
24
|
-
"
|
|
25
|
-
"presets": ["@babel/preset-react"]
|
|
26
|
-
},
|
|
27
|
-
"ecmaFeatures": {
|
|
28
|
-
"jsx": true
|
|
29
|
-
},
|
|
30
|
-
"ecmaVersion": 2018,
|
|
22
|
+
"ecmaVersion": 2020,
|
|
31
23
|
"sourceType": "module"
|
|
32
24
|
},
|
|
33
|
-
"plugins": ["react"],
|
|
34
|
-
"parser": "@babel/eslint-parser",
|
|
35
25
|
"rules": {
|
|
36
26
|
"no-lone-blocks": "off"
|
|
37
27
|
},
|
|
38
|
-
"settings": {
|
|
39
|
-
"react": {
|
|
40
|
-
"version": "detect"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
28
|
"overrides": [
|
|
44
29
|
{
|
|
45
30
|
"files": ["*.ts", "*.tsx"],
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
This document describes the high-level architecture of DXF-Renewed, including the parsing pipeline, denormalisation (INSERT expansion), and rendering outputs.
|
|
4
|
+
|
|
5
|
+
## Goals
|
|
6
|
+
|
|
7
|
+
- Parse DXF text into a typed model deterministically.
|
|
8
|
+
- Expand INSERT/BLOCK references into a flattened entity list with transforms.
|
|
9
|
+
- Provide multiple output formats:
|
|
10
|
+
- SVG string (`toSVG`)
|
|
11
|
+
- numeric polylines (`toPolylines`)
|
|
12
|
+
- JSON string (`toJson`)
|
|
13
|
+
- Prefer "parse what we can, warn for what we can’t" over throwing, when feasible.
|
|
14
|
+
|
|
15
|
+
## Project Layout
|
|
16
|
+
|
|
17
|
+
- `src/` — TypeScript source
|
|
18
|
+
- `src/index.ts` — public API exports
|
|
19
|
+
- `src/Helper.ts` — convenience wrapper around parsing + denormalisation + outputs
|
|
20
|
+
- `src/parseString.ts` — main DXF text parser (routes sections)
|
|
21
|
+
- `src/handlers/` — section handlers and entity handlers
|
|
22
|
+
- `src/types/` — public type definitions
|
|
23
|
+
- `src/denormalise.ts` — INSERT expansion + transform stacking
|
|
24
|
+
- `src/toSVG.ts` — SVG renderer
|
|
25
|
+
- `src/toPolylines.ts` + `src/entityToPolyline.ts` — polyline renderer
|
|
26
|
+
- `src/toJson.ts` — JSON serializer for the parsed model
|
|
27
|
+
- `src/util/` — shared helpers (logger, XML escaping, etc.)
|
|
28
|
+
- `test/` — tests and fixtures
|
|
29
|
+
- `test/unit/` — unit tests (Mocha + TSX)
|
|
30
|
+
- `test/integration-browser/` — Playwright browser rendering tests
|
|
31
|
+
- `test/resources/` — DXF fixtures
|
|
32
|
+
- `docs/` — documentation and references
|
|
33
|
+
- `lib/` and `dist/` — build outputs
|
|
34
|
+
|
|
35
|
+
## Data Flow (End-to-End)
|
|
36
|
+
|
|
37
|
+
Typical usage:
|
|
38
|
+
|
|
39
|
+
1. `parseString(dxfText)` produces a `ParsedDXF` object.
|
|
40
|
+
2. `denormalise(parsed)` expands block inserts and returns a flattened `Entity[]`.
|
|
41
|
+
3. Render or export:
|
|
42
|
+
- `toSVG(parsed)` renders the denormalised entities into an SVG string.
|
|
43
|
+
- `toPolylines(parsed)` converts supported entities into numeric polyline arrays.
|
|
44
|
+
- `toJson(parsed)` serializes the `ParsedDXF` model into a JSON string.
|
|
45
|
+
|
|
46
|
+
The `Helper` class wraps this pipeline:
|
|
47
|
+
|
|
48
|
+
- Constructs from DXF text
|
|
49
|
+
- Exposes `parsed` and `denormalised`
|
|
50
|
+
- Exposes `toSVG()`, `toPolylines()`, and `toJson()`
|
|
51
|
+
|
|
52
|
+
### Pipeline Diagram
|
|
53
|
+
|
|
54
|
+
```mermaid
|
|
55
|
+
flowchart LR
|
|
56
|
+
A[DXF text] --> B[parseString]
|
|
57
|
+
B --> C[ParsedDXF]
|
|
58
|
+
|
|
59
|
+
subgraph SectionHandlers[Section handlers]
|
|
60
|
+
H[HEADER]
|
|
61
|
+
T[TABLES]
|
|
62
|
+
BL[BLOCKS]
|
|
63
|
+
E[ENTITIES]
|
|
64
|
+
O[OBJECTS]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
B -. routes sections .-> SectionHandlers
|
|
68
|
+
SectionHandlers -. populate .-> C
|
|
69
|
+
|
|
70
|
+
C --> D[denormalise]
|
|
71
|
+
D --> E2["Entity[] (flattened + transforms)"]
|
|
72
|
+
|
|
73
|
+
E2 --> S[toSVG]
|
|
74
|
+
E2 --> P[toPolylines]
|
|
75
|
+
C --> J[toJson]
|
|
76
|
+
|
|
77
|
+
S --> S2[SVG string]
|
|
78
|
+
P --> P2[Polyline arrays]
|
|
79
|
+
J --> J2[JSON string]
|
|
80
|
+
|
|
81
|
+
A --> HLP[Helper]
|
|
82
|
+
HLP --> C
|
|
83
|
+
HLP --> E2
|
|
84
|
+
HLP --> S2
|
|
85
|
+
HLP --> P2
|
|
86
|
+
HLP --> J2
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Parsing
|
|
90
|
+
|
|
91
|
+
### Tuple Stream
|
|
92
|
+
|
|
93
|
+
The parser converts the DXF text into a tuple stream of `[groupCode, value]` and routes it by section.
|
|
94
|
+
|
|
95
|
+
### Section Routing
|
|
96
|
+
|
|
97
|
+
`src/parseString.ts` is responsible for splitting tuples into sections and delegating to section handlers:
|
|
98
|
+
|
|
99
|
+
- `src/handlers/header.ts`
|
|
100
|
+
- `src/handlers/tables.ts`
|
|
101
|
+
- `src/handlers/blocks.ts`
|
|
102
|
+
- `src/handlers/entities.ts`
|
|
103
|
+
- `src/handlers/objects.ts`
|
|
104
|
+
|
|
105
|
+
### Entity Handlers
|
|
106
|
+
|
|
107
|
+
Entity handlers live in `src/handlers/entity/*.ts` and follow a consistent pattern:
|
|
108
|
+
|
|
109
|
+
- Export `TYPE` (DXF entity type string).
|
|
110
|
+
- Export a `process(tuples)` function that reduces group codes into a typed entity.
|
|
111
|
+
- Delegate common fields (layer, color, handle, etc.) to shared parsing helpers.
|
|
112
|
+
|
|
113
|
+
Multi-entity sequences (e.g. `POLYLINE` → `VERTEX`… → `SEQEND`) are handled by sequencing logic in `src/handlers/entities.ts`.
|
|
114
|
+
|
|
115
|
+
## Denormalisation (INSERT Expansion)
|
|
116
|
+
|
|
117
|
+
`src/denormalise.ts` expands `INSERT` entities into the referenced BLOCK contents.
|
|
118
|
+
|
|
119
|
+
Responsibilities:
|
|
120
|
+
|
|
121
|
+
- Resolve INSERT → BLOCK.
|
|
122
|
+
- Apply transform stacks to expanded entities.
|
|
123
|
+
- Expand rectangular arrays when present.
|
|
124
|
+
|
|
125
|
+
The output is a flat list of entities with an optional `transforms` stack used by renderers.
|
|
126
|
+
|
|
127
|
+
## Rendering
|
|
128
|
+
|
|
129
|
+
### SVG (`toSVG`)
|
|
130
|
+
|
|
131
|
+
`src/toSVG.ts` renders the denormalised entities.
|
|
132
|
+
|
|
133
|
+
- Uses native SVG primitives when feasible (`<circle>`, `<ellipse>`, path arcs).
|
|
134
|
+
- Uses polyline approximations for entities that do not have a native SVG primitive or where approximation is acceptable.
|
|
135
|
+
- Unsupported entity types are skipped with a warning.
|
|
136
|
+
|
|
137
|
+
### Polylines (`toPolylines`)
|
|
138
|
+
|
|
139
|
+
`src/entityToPolyline.ts` is the main conversion point for entities → polylines.
|
|
140
|
+
|
|
141
|
+
- Designed to be pure: same input entity should result in the same polyline output.
|
|
142
|
+
- Options (e.g., interpolation density) should be expressed via `ToPolylinesOptions`.
|
|
143
|
+
|
|
144
|
+
### JSON (`toJson`)
|
|
145
|
+
|
|
146
|
+
`src/toJson.ts` provides a stable way to serialize the parsed model.
|
|
147
|
+
|
|
148
|
+
- Intended to represent the parsed model 1-to-1.
|
|
149
|
+
- Supports pretty-printing via options.
|
|
150
|
+
|
|
151
|
+
## Logging & Error Handling
|
|
152
|
+
|
|
153
|
+
- Logging goes through `src/util/logger.ts`.
|
|
154
|
+
- Prefer warnings over exceptions for unsupported features.
|
|
155
|
+
- Parsing should remain resilient: bad/unknown codes should not crash the entire parse when possible.
|
|
156
|
+
|
|
157
|
+
## Build & Test
|
|
158
|
+
|
|
159
|
+
- Build: TypeScript + esbuild bundling.
|
|
160
|
+
- Unit tests: Mocha executed with `tsx`.
|
|
161
|
+
- Browser integration tests: Playwright (renders fixtures and captures screenshots under `test/rendered/`).
|
|
162
|
+
- Functional manual viewer: Vite dev server under `test/functional/`.
|
|
163
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## 7.2.0 (2026-01-01)
|
|
9
|
+
|
|
10
|
+
* Merge pull request #2 from linkiez/feature/2026.01.01 ([c01512f](https://github.com/linkiez/DXF-Renewed/commit/c01512f)), closes [#2](https://github.com/linkiez/DXF-Renewed/issues/2)
|
|
11
|
+
* docs: add architecture diagram ([7f61ef2](https://github.com/linkiez/DXF-Renewed/commit/7f61ef2))
|
|
12
|
+
* docs: clarify supported entities ([8cd47dc](https://github.com/linkiez/DXF-Renewed/commit/8cd47dc))
|
|
13
|
+
* docs: consolidate documentation into PLAN.md ([204abf9](https://github.com/linkiez/DXF-Renewed/commit/204abf9))
|
|
14
|
+
* docs: fix mermaid diagram parsing ([0cedf8d](https://github.com/linkiez/DXF-Renewed/commit/0cedf8d))
|
|
15
|
+
* docs: improve README structure ([3c6659d](https://github.com/linkiez/DXF-Renewed/commit/3c6659d))
|
|
16
|
+
* docs: rename plan to roadmap ([23b060e](https://github.com/linkiez/DXF-Renewed/commit/23b060e))
|
|
17
|
+
* docs: update README progress ([64566b7](https://github.com/linkiez/DXF-Renewed/commit/64566b7))
|
|
18
|
+
* feat: add toJson processor ([94e112c](https://github.com/linkiez/DXF-Renewed/commit/94e112c))
|
|
19
|
+
* feat(entities): add handlers for additional 2D entities ([221ef8b](https://github.com/linkiez/DXF-Renewed/commit/221ef8b))
|
|
20
|
+
* feat(parser): add FIELD/DIMASSOC objects and extra table types ([ef89ed7](https://github.com/linkiez/DXF-Renewed/commit/ef89ed7))
|
|
21
|
+
* feat(render): support LEADER/RAY/XLINE/TRACE/SHAPE/WIPEOUT ([05a7c82](https://github.com/linkiez/DXF-Renewed/commit/05a7c82))
|
|
22
|
+
* chore(tooling): remove babel/react/webpack and migrate functional tests to vite ([dd92031](https://github.com/linkiez/DXF-Renewed/commit/dd92031))
|
|
23
|
+
|
|
8
24
|
## 7.1.0 (2026-01-01)
|
|
9
25
|
|
|
10
26
|
* Merge pull request #1 from linkiez/feat/seqend-sequencing ([068c6e1](https://github.com/linkiez/DXF-Renewed/commit/068c6e1)), closes [#1](https://github.com/linkiez/DXF-Renewed/issues/1)
|
package/README.md
CHANGED
|
@@ -11,6 +11,39 @@ Written in **TypeScript** with full type definitions included. Uses modern ES201
|
|
|
11
11
|
|
|
12
12
|
> **Note:** This is a renewed and modernized fork of the original [dxf](https://github.com/skymakerolof/dxf) library, with complete TypeScript migration, enhanced performance, and additional features.
|
|
13
13
|
|
|
14
|
+
## TL;DR
|
|
15
|
+
|
|
16
|
+
- Parse: `parseString(dxfText)` → typed `ParsedDXF`
|
|
17
|
+
- Expand blocks: `denormalise(parsed)` → flat `Entity[]` with transforms
|
|
18
|
+
- Render/export:
|
|
19
|
+
- `toSVG(parsed)` → SVG string
|
|
20
|
+
- `toPolylines(parsed)` → numeric polyline arrays
|
|
21
|
+
- `toJson(parsed)` → JSON string
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- TypeScript-first public API (strict typing)
|
|
26
|
+
- Deterministic parsing + regression coverage via real DXF fixtures
|
|
27
|
+
- INSERT/BLOCK expansion (denormalisation) with transform stacking
|
|
28
|
+
- SVG rendering for common 2D geometry + annotation entities
|
|
29
|
+
- Polyline output for custom renderers (Canvas/WebGL/etc.)
|
|
30
|
+
- Framework-agnostic (no React/Webpack required)
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
- Project roadmap and progress: [ROADMAP.md](./ROADMAP.md)
|
|
35
|
+
- Architecture overview: [ARCHITECTURE.md](./ARCHITECTURE.md)
|
|
36
|
+
|
|
37
|
+
## Table of Contents
|
|
38
|
+
|
|
39
|
+
- [Version History](#version-history)
|
|
40
|
+
- [Supported Entities](#supported-entities)
|
|
41
|
+
- [Getting started](#getting-started)
|
|
42
|
+
- [API](#api)
|
|
43
|
+
- [Running the Examples](#running-the-examples)
|
|
44
|
+
- [Tests](#tests)
|
|
45
|
+
- [Build System](#build-system)
|
|
46
|
+
|
|
14
47
|
## Version History
|
|
15
48
|
|
|
16
49
|
**Version 2.0** - Complete rewrite from SAX-style parsing to handle nested references properly (inserts, blocks, etc.)
|
|
@@ -30,9 +63,9 @@ Written in **TypeScript** with full type definitions included. Uses modern ES201
|
|
|
30
63
|
|
|
31
64
|
## Supported Entities
|
|
32
65
|
|
|
33
|
-
|
|
66
|
+
Many common DXF entities are **parsed and rendered to SVG**. Some entities are parsed but currently skipped during SVG rendering.
|
|
34
67
|
|
|
35
|
-
###
|
|
68
|
+
### Rendered to SVG
|
|
36
69
|
|
|
37
70
|
- ✅ **LINE** - Straight line segments
|
|
38
71
|
- ✅ **CIRCLE** - Native SVG `<circle />` element
|
|
@@ -44,16 +77,23 @@ All major geometric entities are **parsed and rendered to SVG**:
|
|
|
44
77
|
- ✅ **TEXT** - Single-line text with rotation
|
|
45
78
|
- ✅ **MTEXT** - Multi-line text with formatting
|
|
46
79
|
- ✅ **DIMENSION** - Linear, aligned, radial, diameter, and ordinate dimensions
|
|
47
|
-
- ✅ **INSERT** - Block references with transformations
|
|
48
|
-
- ✅ **POINT** - Point entities
|
|
49
80
|
- ✅ **SOLID** - Solid-filled triangles and quadrilaterals
|
|
50
|
-
- ✅ **
|
|
81
|
+
- ✅ **TRACE** - Rendered as a filled path outline
|
|
82
|
+
- ✅ **RAY/XLINE** - Rendered as polylines
|
|
83
|
+
- ✅ **WIPEOUT** - Rendered as outline fallback
|
|
84
|
+
- ✅ **LEADER** - Rendered as an SVG path (basic)
|
|
85
|
+
- ✅ **TOLERANCE** - Rendered with SVG text fallback
|
|
86
|
+
- ✅ **SHAPE** - Rendered with SVG text fallback
|
|
87
|
+
|
|
88
|
+
> **INSERT note:** INSERT is supported via denormalisation. The library expands INSERT entities into their referenced BLOCK contents and then renders the resulting entities with transforms applied.
|
|
51
89
|
|
|
52
90
|
### Parsed (Not Rendered)
|
|
53
91
|
|
|
54
|
-
- ⚠️ **
|
|
55
|
-
- ⚠️ **
|
|
92
|
+
- ⚠️ **POINT** - Parsed but currently not rendered to SVG
|
|
93
|
+
- ⚠️ **3DFACE** - Parsed but currently not rendered to SVG
|
|
94
|
+
- ⚠️ **HATCH** - Parsed but currently not rendered to SVG
|
|
56
95
|
- ⚠️ **ATTDEF/ATTRIB** - Block attributes parsed
|
|
96
|
+
- ⚠️ **Text styles (STYLE table)** - Parsed (colors supported; fonts are not applied to SVG)
|
|
57
97
|
|
|
58
98
|
## Getting started
|
|
59
99
|
|
|
@@ -75,6 +115,9 @@ console.log('svg:', helper.toSVG())
|
|
|
75
115
|
|
|
76
116
|
// Create polylines (e.g. to render in WebGL)
|
|
77
117
|
console.log('polylines:', helper.toPolylines())
|
|
118
|
+
|
|
119
|
+
// Create a JSON representation (1-to-1 with the parsed model)
|
|
120
|
+
console.log('json:', helper.toJson({ pretty: true }))
|
|
78
121
|
```
|
|
79
122
|
|
|
80
123
|
JavaScript example:
|
|
@@ -95,8 +138,28 @@ console.log('svg:', helper.toSVG())
|
|
|
95
138
|
|
|
96
139
|
// Create polylines (e.g. to render in WebGL)
|
|
97
140
|
console.log('polylines:', helper.toPolylines())
|
|
141
|
+
|
|
142
|
+
// Create a JSON representation (1-to-1 with the parsed model)
|
|
143
|
+
console.log('json:', helper.toJson({ pretty: true }))
|
|
98
144
|
```
|
|
99
145
|
|
|
146
|
+
## API
|
|
147
|
+
|
|
148
|
+
The public API is exported from `src/index.ts`.
|
|
149
|
+
|
|
150
|
+
- `parseString(dxfText: string): ParsedDXF`
|
|
151
|
+
- Parse DXF text into a typed model.
|
|
152
|
+
- `denormalise(parsed: ParsedDXF): Entity[]`
|
|
153
|
+
- Expand `INSERT` entities into their referenced `BLOCK` contents.
|
|
154
|
+
- `toSVG(parsed: ParsedDXF, options?): string`
|
|
155
|
+
- Render the drawing to an SVG string.
|
|
156
|
+
- `toPolylines(parsed: ParsedDXF, options?): any[]`
|
|
157
|
+
- Convert supported entities to polyline arrays.
|
|
158
|
+
- `toJson(parsed: ParsedDXF, options?): string`
|
|
159
|
+
- Serialize the parsed model as JSON.
|
|
160
|
+
- `Helper`
|
|
161
|
+
- Convenience wrapper that exposes `parsed`, `denormalised`, plus `toSVG()`, `toPolylines()`, and `toJson()`.
|
|
162
|
+
|
|
100
163
|
## Running the Examples
|
|
101
164
|
|
|
102
165
|
There are examples in the `examples/` directory.
|
|
@@ -231,11 +294,11 @@ Running the functional tests in a browser:
|
|
|
231
294
|
yarn test:functional
|
|
232
295
|
```
|
|
233
296
|
|
|
234
|
-
|
|
297
|
+
This starts a Vite dev server and opens `http://localhost:8030/toSVG.html`.
|
|
235
298
|
|
|
236
299
|
## Development Guidelines
|
|
237
300
|
|
|
238
|
-
Project documentation index: `
|
|
301
|
+
Project documentation index: `ROADMAP.md` (see “Documentation (Consolidated)”).
|
|
239
302
|
|
|
240
303
|
## TypeScript Support
|
|
241
304
|
|
|
@@ -288,7 +351,6 @@ This project uses [semantic-release](https://semantic-release.gitbook.io/) for a
|
|
|
288
351
|
|
|
289
352
|
- `main` - Stable production releases (`1.0.0`, `1.1.0`, `2.0.0`)
|
|
290
353
|
|
|
291
|
-
|
|
292
354
|
### Commit Format
|
|
293
355
|
|
|
294
356
|
```bash
|