@linkiez/dxf-renew 7.0.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/.github/instructions/code-patterns.instructions.md +1 -1
- package/.github/instructions/exdxf.instruction.md +161 -0
- package/.github/instructions/tdd.instructions.md +271 -0
- package/.yarn/install-state.gz +0 -0
- package/ARCHITECTURE.md +163 -0
- package/CHANGELOG.md +39 -0
- package/CONTRIBUTING.md +16 -14
- package/README.md +113 -16
- package/{PLAN.md → ROADMAP.md} +244 -102
- package/dist/dxf.js +2212 -454
- package/docs/EZDXF_REFERENCE_SITEMAP.md +55 -0
- package/docs/FIXTURE_VALIDATION_EZDXF.md +62 -0
- package/lib/Helper.cjs +6 -2
- package/lib/Helper.cjs.map +3 -3
- package/lib/Helper.js +6 -2
- package/lib/Helper.js.map +2 -2
- package/lib/denormalise.cjs +131 -91
- package/lib/denormalise.cjs.map +2 -2
- package/lib/denormalise.js +131 -91
- package/lib/denormalise.js.map +2 -2
- package/lib/dimensionToSVG.cjs +318 -53
- package/lib/dimensionToSVG.cjs.map +3 -3
- package/lib/dimensionToSVG.js +316 -52
- package/lib/dimensionToSVG.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 +111 -27
- package/lib/handlers/entities.cjs.map +3 -3
- package/lib/handlers/entities.js +111 -27
- package/lib/handlers/entities.js.map +3 -3
- package/lib/handlers/entity/dgnUnderlay.cjs +106 -0
- package/lib/handlers/entity/dgnUnderlay.cjs.map +7 -0
- package/lib/handlers/entity/dgnUnderlay.js +71 -0
- package/lib/handlers/entity/dgnUnderlay.js.map +7 -0
- package/lib/handlers/entity/dimension.cjs +24 -0
- package/lib/handlers/entity/dimension.cjs.map +2 -2
- package/lib/handlers/entity/dimension.js +24 -0
- package/lib/handlers/entity/dimension.js.map +2 -2
- package/lib/handlers/entity/dwfUnderlay.cjs +106 -0
- package/lib/handlers/entity/dwfUnderlay.cjs.map +7 -0
- package/lib/handlers/entity/dwfUnderlay.js +71 -0
- package/lib/handlers/entity/dwfUnderlay.js.map +7 -0
- package/lib/handlers/entity/image.cjs +123 -0
- package/lib/handlers/entity/image.cjs.map +7 -0
- package/lib/handlers/entity/image.js +88 -0
- package/lib/handlers/entity/image.js.map +7 -0
- package/lib/handlers/entity/leader.cjs +148 -0
- package/lib/handlers/entity/leader.cjs.map +7 -0
- package/lib/handlers/entity/leader.js +113 -0
- package/lib/handlers/entity/leader.js.map +7 -0
- 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/pdfUnderlay.cjs +106 -0
- package/lib/handlers/entity/pdfUnderlay.cjs.map +7 -0
- package/lib/handlers/entity/pdfUnderlay.js +71 -0
- package/lib/handlers/entity/pdfUnderlay.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/tolerance.cjs +90 -0
- package/lib/handlers/entity/tolerance.cjs.map +7 -0
- package/lib/handlers/entity/tolerance.js +55 -0
- package/lib/handlers/entity/tolerance.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 +299 -136
- package/lib/handlers/objects.cjs.map +2 -2
- package/lib/handlers/objects.js +299 -136
- 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 +105 -11
- package/lib/toSVG.cjs.map +3 -3
- package/lib/toSVG.js +106 -12
- package/lib/toSVG.js.map +2 -2
- package/lib/types/dimension-entity.cjs.map +1 -1
- package/lib/types/entity.cjs.map +1 -1
- package/lib/types/helper.cjs.map +1 -1
- package/lib/types/image-entity.cjs +17 -0
- package/lib/types/image-entity.cjs.map +7 -0
- package/lib/types/image-entity.js +1 -0
- package/lib/types/image-entity.js.map +7 -0
- package/lib/types/index.cjs +28 -0
- package/lib/types/index.cjs.map +2 -2
- package/lib/types/index.js +14 -0
- package/lib/types/index.js.map +2 -2
- package/lib/types/leader-entity.cjs +17 -0
- package/lib/types/leader-entity.cjs.map +7 -0
- package/lib/types/leader-entity.js +1 -0
- package/lib/types/leader-entity.js.map +7 -0
- 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/tolerance-entity.cjs +17 -0
- package/lib/types/tolerance-entity.cjs.map +7 -0
- package/lib/types/tolerance-entity.js +1 -0
- package/lib/types/tolerance-entity.js.map +7 -0
- 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/underlay-entity.cjs +17 -0
- package/lib/types/underlay-entity.cjs.map +7 -0
- package/lib/types/underlay-entity.js +1 -0
- package/lib/types/underlay-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/lib/util/escapeXmlText.cjs +27 -0
- package/lib/util/escapeXmlText.cjs.map +7 -0
- package/lib/util/escapeXmlText.js +7 -0
- package/lib/util/escapeXmlText.js.map +7 -0
- package/package.json +9 -18
- package/playwright.config.cjs +20 -0
- package/src/Helper.ts +8 -3
- package/src/denormalise.ts +182 -116
- package/src/dimensionToSVG.ts +466 -54
- package/src/entityToPolyline.ts +124 -2
- package/src/handlers/entities.ts +129 -34
- package/src/handlers/entity/dgnUnderlay.ts +94 -0
- package/src/handlers/entity/dimension.ts +27 -1
- package/src/handlers/entity/dwfUnderlay.ts +94 -0
- package/src/handlers/entity/image.ts +118 -0
- package/src/handlers/entity/leader.ts +153 -0
- 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/pdfUnderlay.ts +94 -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/tolerance.ts +75 -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 +379 -139
- package/src/handlers/tables.ts +134 -21
- package/src/index.ts +9 -18
- package/src/toJson.ts +8 -0
- package/src/toSVG.ts +143 -10
- package/src/types/dimension-entity.ts +11 -0
- package/src/types/entity.ts +30 -0
- package/src/types/helper.ts +2 -1
- package/src/types/image-entity.ts +35 -0
- package/src/types/index.ts +14 -0
- package/src/types/leader-entity.ts +40 -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 +48 -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 +160 -0
- package/src/types/tolerance-entity.ts +20 -0
- package/src/types/trace-entity.ts +14 -0
- package/src/types/underlay-entity.ts +35 -0
- package/src/types/wipeout-entity.ts +20 -0
- package/src/types/xline-entity.ts +12 -0
- package/src/util/escapeXmlText.ts +10 -0
- package/tools/browser_test_server.cjs +87 -0
- package/tools/ezdxf_generate_dimensions_all_types.py +246 -0
- package/tools/ezdxf_generate_dimensions_angular_3p.py +59 -0
- package/tools/ezdxf_generate_dimensions_large_scale.py +87 -0
- package/tools/ezdxf_regenerate_problem_fixtures.py +184 -0
- package/tools/ezdxf_validate_fixtures.py +165 -0
- package/docs/DIMENSION_SUMMARY.md +0 -248
- package/docs/DIMENSION_SUMMARY.pt-BR.md +0 -248
- package/docs/IMPLEMENTED-2D-ENTITIES.md +0 -54
- package/docs/IMPLEMENTED-2D-ENTITIES.pt-BR.md +0 -54
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +0 -241
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.pt-BR.md +0 -169
package/CONTRIBUTING.md
CHANGED
|
@@ -36,18 +36,20 @@ Antes de reportar um bug, verifique se já existe uma issue aberta sobre o probl
|
|
|
36
36
|
### Pull Requests
|
|
37
37
|
|
|
38
38
|
1. Fork o repositório
|
|
39
|
-
2. Crie uma branch a partir de `
|
|
39
|
+
2. Crie uma branch a partir de `main`:
|
|
40
|
+
|
|
40
41
|
```bash
|
|
41
|
-
git checkout
|
|
42
|
+
git checkout main
|
|
42
43
|
git checkout -b feature/sua-feature
|
|
43
44
|
```
|
|
45
|
+
|
|
44
46
|
3. Faça suas mudanças seguindo o [Padrão de Commits](#padrão-de-commits)
|
|
45
47
|
4. Execute os testes: `yarn test`
|
|
46
48
|
5. Execute o linter: `yarn lint`
|
|
47
49
|
6. Execute a build: `yarn build`
|
|
48
50
|
7. Commit suas mudanças (o commitlint validará automaticamente)
|
|
49
51
|
8. Push para sua branch
|
|
50
|
-
9. Abra um Pull Request para `
|
|
52
|
+
9. Abra um Pull Request para `main`
|
|
51
53
|
|
|
52
54
|
## Padrão de Commits
|
|
53
55
|
|
|
@@ -55,7 +57,7 @@ Este projeto utiliza [Conventional Commits](https://www.conventionalcommits.org/
|
|
|
55
57
|
|
|
56
58
|
### Formato
|
|
57
59
|
|
|
58
|
-
```
|
|
60
|
+
```text
|
|
59
61
|
<type>(<scope>): <subject>
|
|
60
62
|
|
|
61
63
|
[optional body]
|
|
@@ -81,7 +83,7 @@ Este projeto utiliza [Conventional Commits](https://www.conventionalcommits.org/
|
|
|
81
83
|
|
|
82
84
|
To indicate a breaking change (generates MAJOR release):
|
|
83
85
|
|
|
84
|
-
```
|
|
86
|
+
```text
|
|
85
87
|
feat: allow provided config object to extend other configs
|
|
86
88
|
|
|
87
89
|
BREAKING CHANGE: `extends` key in config file is now used
|
|
@@ -90,7 +92,7 @@ to extend other config files
|
|
|
90
92
|
|
|
91
93
|
Or use `!` after the type:
|
|
92
94
|
|
|
93
|
-
```
|
|
95
|
+
```text
|
|
94
96
|
feat!: remove support for Node 6
|
|
95
97
|
```
|
|
96
98
|
|
|
@@ -139,7 +141,7 @@ This will open an interactive prompt to create the commit in the correct format.
|
|
|
139
141
|
O projeto usa [semantic-release](https://semantic-release.gitbook.io/) para releases automáticos:
|
|
140
142
|
|
|
141
143
|
1. Faça commits seguindo o padrão Conventional Commits
|
|
142
|
-
2. Faça merge do PR para `main
|
|
144
|
+
2. Faça merge do PR para `main`
|
|
143
145
|
3. O GitHub Actions automaticamente:
|
|
144
146
|
* Analisa os commits desde o último release
|
|
145
147
|
* Determina o novo número de versão (MAJOR.MINOR.PATCH)
|
|
@@ -151,8 +153,6 @@ O projeto usa [semantic-release](https://semantic-release.gitbook.io/) para rele
|
|
|
151
153
|
### Branches
|
|
152
154
|
|
|
153
155
|
* **main**: Releases estáveis de produção
|
|
154
|
-
* **develop**: Pre-releases (versões beta)
|
|
155
|
-
* **beta**: Pre-releases específicas para testes
|
|
156
156
|
|
|
157
157
|
### Versionamento
|
|
158
158
|
|
|
@@ -220,7 +220,7 @@ yarn semantic-release # Executar semantic-release
|
|
|
220
220
|
|
|
221
221
|
### Estrutura do Projeto
|
|
222
222
|
|
|
223
|
-
```
|
|
223
|
+
```text
|
|
224
224
|
dxf/
|
|
225
225
|
├── src/ # Código-fonte TypeScript
|
|
226
226
|
│ ├── handlers/ # Parsers de entidades e tabelas
|
|
@@ -238,15 +238,17 @@ dxf/
|
|
|
238
238
|
### Workflow de Desenvolvimento
|
|
239
239
|
|
|
240
240
|
1. **Crie uma issue** descrevendo o que você vai fazer
|
|
241
|
-
2. **Crie uma branch** a partir de `
|
|
241
|
+
2. **Crie uma branch** a partir de `main`:
|
|
242
|
+
|
|
242
243
|
```bash
|
|
243
|
-
git checkout
|
|
244
|
-
git pull origin
|
|
244
|
+
git checkout main
|
|
245
|
+
git pull origin main
|
|
245
246
|
git checkout -b feat/minha-feature
|
|
246
247
|
```
|
|
248
|
+
|
|
247
249
|
3. **Faça suas mudanças** com commits seguindo o padrão
|
|
248
250
|
4. **Execute os testes** localmente
|
|
249
|
-
5. **Push e crie um PR** para `
|
|
251
|
+
5. **Push e crie um PR** para `main`
|
|
250
252
|
6. **Aguarde a revisão** e responda aos comentários
|
|
251
253
|
7. **Após merge**, o release será feito automaticamente
|
|
252
254
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
# DXF-Renewed
|
|
2
|
+
|
|
1
3
|
[](https://travis-ci.org/bjnortier/dxf)
|
|
2
4
|
[](https://github.com/semantic-release/semantic-release)
|
|
3
5
|
|
|
4
|
-
# DXF-Renewed
|
|
5
|
-
|
|
6
6
|
> **⚠️ WARNING: This repository is currently under development and has not been fully tested in production. Use at your own risk.**
|
|
7
7
|
|
|
8
8
|
DXF parser for node/browser.
|
|
@@ -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.)
|
|
@@ -24,15 +57,15 @@ Written in **TypeScript** with full type definitions included. Uses modern ES201
|
|
|
24
57
|
- 🎯 Full TypeScript codebase with strict type checking
|
|
25
58
|
- ⚡ Built with esbuild (96% faster than Babel - 18ms vs 447ms)
|
|
26
59
|
- 📦 Modular type system with 22+ separate type files
|
|
27
|
-
- ✅
|
|
60
|
+
- ✅ Extensive unit tests and browser integration tests
|
|
28
61
|
- 🎨 Enhanced SVG rendering with TEXT, MTEXT, and DIMENSION support
|
|
29
62
|
- 📚 Comprehensive type definitions for all DXF entities
|
|
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.
|
|
@@ -148,6 +211,34 @@ Here's an example you will find in the functional test output:
|
|
|
148
211
|
|
|
149
212
|

|
|
150
213
|
|
|
214
|
+
### DIMENSION auto-scaling
|
|
215
|
+
|
|
216
|
+
DIMENSION rendering supports viewport-based auto-scaling so that arrows and text remain readable across different coordinate scales.
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
import { Helper } from '@linkiez/dxf-renew'
|
|
220
|
+
|
|
221
|
+
const helper = new Helper(dxfString)
|
|
222
|
+
|
|
223
|
+
const svg = helper.toSVG({
|
|
224
|
+
dimension: {
|
|
225
|
+
autoScale: true,
|
|
226
|
+
// Reference used when percentages are not provided.
|
|
227
|
+
autoScaleViewportReference: 40,
|
|
228
|
+
// Optional per-element overrides as a percentage (0..100)
|
|
229
|
+
// of min(viewBoxWidth, viewBoxHeight).
|
|
230
|
+
autoScaleViewportPercentages: {
|
|
231
|
+
arrowSize: 1.5,
|
|
232
|
+
textHeight: 1
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
When `autoScaleViewportPercentages` is provided (and `autoScale` is enabled), the final size for each configured element is computed as:
|
|
239
|
+
|
|
240
|
+
`size = min(viewBoxWidth, viewBoxHeight) * (percent / 100)`
|
|
241
|
+
|
|
151
242
|
## Interpolation
|
|
152
243
|
|
|
153
244
|
The library supports outputting DXFs as interpolated polylines for custom rendering (e.g. WebGL) or other applications:
|
|
@@ -189,17 +280,25 @@ Running the unit tests:
|
|
|
189
280
|
yarn test
|
|
190
281
|
```
|
|
191
282
|
|
|
283
|
+
Running the browser integration tests (Playwright):
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
yarn test:integration:browser
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
These tests render fixtures in a real browser and write deterministic PNG screenshots under `test/rendered/` (overwritten on each run).
|
|
290
|
+
|
|
192
291
|
Running the functional tests in a browser:
|
|
193
292
|
|
|
194
293
|
```bash
|
|
195
294
|
yarn test:functional
|
|
196
295
|
```
|
|
197
296
|
|
|
198
|
-
|
|
297
|
+
This starts a Vite dev server and opens `http://localhost:8030/toSVG.html`.
|
|
199
298
|
|
|
200
299
|
## Development Guidelines
|
|
201
300
|
|
|
202
|
-
|
|
301
|
+
Project documentation index: `ROADMAP.md` (see “Documentation (Consolidated)”).
|
|
203
302
|
|
|
204
303
|
## TypeScript Support
|
|
205
304
|
|
|
@@ -251,8 +350,6 @@ This project uses [semantic-release](https://semantic-release.gitbook.io/) for a
|
|
|
251
350
|
**Releases are automatically created** when commits following [Conventional Commits](https://www.conventionalcommits.org/en/) are pushed to:
|
|
252
351
|
|
|
253
352
|
- `main` - Stable production releases (`1.0.0`, `1.1.0`, `2.0.0`)
|
|
254
|
-
- `develop` - Pre-releases for testing (`1.1.0-dev.1`, `1.1.0-dev.2`)
|
|
255
|
-
- `beta` - Beta pre-releases (`1.1.0-beta.1`, `1.1.0-beta.2`)
|
|
256
353
|
|
|
257
354
|
### Commit Format
|
|
258
355
|
|
|
@@ -276,9 +373,9 @@ To contribute:
|
|
|
276
373
|
1. Fork the repository
|
|
277
374
|
2. Make commits using `yarn commit` (interactive) or following Conventional Commits
|
|
278
375
|
3. Push to your fork
|
|
279
|
-
4. Open a Pull Request to `
|
|
376
|
+
4. Open a Pull Request to `main`
|
|
280
377
|
|
|
281
|
-
See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines
|
|
378
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines.
|
|
282
379
|
|
|
283
380
|
## Contributors
|
|
284
381
|
|