@linkiez/dxf-renew 5.3.1 → 7.1.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/{docs/CODE_PATTERNS.md → .github/instructions/code-patterns.instructions.md} +4 -1
- package/.github/instructions/exdxf.instruction.md +161 -0
- package/.github/instructions/tdd.instructions.md +271 -0
- package/.github/workflows/release.yml +4 -5
- package/.releaserc.json +1 -1
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +59 -0
- package/CONTRIBUTING.md +16 -14
- package/PLAN.md +34 -84
- package/README.md +43 -8
- package/dist/dxf.js +1388 -376
- package/docs/DIMENSION_SUMMARY.md +11 -5
- package/docs/DXF_VERSION_SUPPORT.md +45 -0
- package/docs/ENTITY_SVG_ROADMAP.md +96 -0
- package/docs/EZDXF_REFERENCE_SITEMAP.md +55 -0
- package/docs/FIXTURE_VALIDATION_EZDXF.md +62 -0
- package/docs/README.md +22 -0
- package/docs/SVG_RENDERING_INTEGRATION_TESTS.md +119 -0
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +1 -1
- package/lib/Helper.cjs +2 -2
- package/lib/Helper.cjs.map +2 -2
- package/lib/Helper.js +2 -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/handlers/entities.cjs +90 -26
- package/lib/handlers/entities.cjs.map +3 -3
- package/lib/handlers/entities.js +90 -26
- 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/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/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/objects.cjs +257 -136
- package/lib/handlers/objects.cjs.map +2 -2
- package/lib/handlers/objects.js +257 -136
- package/lib/handlers/objects.js.map +2 -2
- package/lib/toSVG.cjs +71 -8
- package/lib/toSVG.cjs.map +3 -3
- package/lib/toSVG.js +72 -9
- 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/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 +8 -0
- package/lib/types/index.cjs.map +2 -2
- package/lib/types/index.js +4 -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/options.cjs.map +1 -1
- 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/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/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 +13 -4
- package/playwright.config.cjs +20 -0
- package/src/Helper.ts +3 -3
- package/src/denormalise.ts +182 -116
- package/src/dimensionToSVG.ts +466 -54
- package/src/handlers/entities.ts +109 -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/pdfUnderlay.ts +94 -0
- package/src/handlers/entity/tolerance.ts +75 -0
- package/src/handlers/objects.ts +323 -139
- package/src/toSVG.ts +98 -7
- package/src/types/dimension-entity.ts +11 -0
- package/src/types/entity.ts +10 -0
- package/src/types/image-entity.ts +35 -0
- package/src/types/index.ts +4 -0
- package/src/types/leader-entity.ts +40 -0
- package/src/types/options.ts +41 -0
- package/src/types/tables.ts +84 -0
- package/src/types/tolerance-entity.ts +20 -0
- package/src/types/underlay-entity.ts +35 -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.pt-BR.md +0 -248
- package/docs/IMPLEMENTED-2D-ENTITIES.pt-BR.md +0 -54
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.pt-BR.md +0 -169
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
1
4
|
# Code Patterns & Best Practices
|
|
2
5
|
|
|
3
6
|
This document codifies the current implementation patterns used in DXF-Renewed, plus recommended best practices for new contributions.
|
|
@@ -19,7 +22,7 @@ This document codifies the current implementation patterns used in DXF-Renewed,
|
|
|
19
22
|
Best practices:
|
|
20
23
|
|
|
21
24
|
- Prefer `import type { ... }` for type-only imports.
|
|
22
|
-
- Avoid `any` in new code. If runtime constraints require it, keep it local and document why.
|
|
25
|
+
- Avoid `any` or `unknown` in new code. If runtime constraints require it, keep it local and document why.
|
|
23
26
|
- Keep names and comments in **English (en_US)**.
|
|
24
27
|
|
|
25
28
|
## Project Architecture (High-Level)
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**/*'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Development Instructions (DXF-Renewed) — using ezdxf
|
|
6
|
+
|
|
7
|
+
This repository is a TypeScript DXF parser. For DXF fixtures, debugging, and cross-checking group codes, we use the Python library **ezdxf**.
|
|
8
|
+
|
|
9
|
+
Official docs:
|
|
10
|
+
|
|
11
|
+
- Setup (extras): <https://ezdxf.readthedocs.io/en/stable/setup.html#installation-with-extras>
|
|
12
|
+
- Reference index: <https://ezdxf.readthedocs.io/en/stable/reference.html>
|
|
13
|
+
|
|
14
|
+
## 1) Install ezdxf (recommended: local venv)
|
|
15
|
+
|
|
16
|
+
Many Linux distributions use an externally-managed Python environment (PEP 668), which blocks `pip install --user`.
|
|
17
|
+
Use a local virtualenv inside this repo:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cd <path-to>/DXF-Renewed
|
|
21
|
+
python3 -m venv .venv-ezdxf
|
|
22
|
+
. .venv-ezdxf/bin/activate
|
|
23
|
+
python -m pip install -U pip
|
|
24
|
+
|
|
25
|
+
# Core library
|
|
26
|
+
python -m pip install -U ezdxf
|
|
27
|
+
|
|
28
|
+
# Optional drawing add-on dependencies (recommended by ezdxf docs)
|
|
29
|
+
python -m pip install -U 'ezdxf[draw]'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Extras from the ezdxf docs:
|
|
33
|
+
|
|
34
|
+
- `ezdxf[draw]`: Matplotlib, PySide6, PyMuPDF, Pillow
|
|
35
|
+
- `ezdxf[dev]`: `draw` + setuptools, wheel, Cython, pytest
|
|
36
|
+
- If PySide6 is not available, use `ezdxf[draw5]` / `ezdxf[dev5]` (PyQt5-based)
|
|
37
|
+
|
|
38
|
+
Verify:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
. .venv-ezdxf/bin/activate
|
|
42
|
+
python -m ezdxf -V
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 2) How ezdxf helps this repo
|
|
46
|
+
|
|
47
|
+
Use ezdxf for:
|
|
48
|
+
|
|
49
|
+
- generating **minimal DXF fixtures** for TDD (`test/resources/*.dxf`)
|
|
50
|
+
- dumping **raw group-code tags** for an entity/object/table
|
|
51
|
+
- checking real-world DXF parsing expectations without guessing group codes
|
|
52
|
+
|
|
53
|
+
This repo’s workflow is TDD-first:
|
|
54
|
+
|
|
55
|
+
- add a minimal fixture + failing unit test
|
|
56
|
+
- implement parser support
|
|
57
|
+
- keep `yarn test` + `yarn lint` green
|
|
58
|
+
|
|
59
|
+
## 3) Inspect an existing DXF fixture
|
|
60
|
+
|
|
61
|
+
Print entity types, handles, and layers:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
. .venv-ezdxf/bin/activate
|
|
65
|
+
python - <<'PY'
|
|
66
|
+
import ezdxf
|
|
67
|
+
|
|
68
|
+
doc = ezdxf.readfile('test/resources/entities.dxf')
|
|
69
|
+
msp = doc.modelspace()
|
|
70
|
+
|
|
71
|
+
for e in msp:
|
|
72
|
+
handle = getattr(e.dxf, 'handle', None)
|
|
73
|
+
layer = getattr(e.dxf, 'layer', None)
|
|
74
|
+
print(e.dxftype(), handle, layer)
|
|
75
|
+
PY
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 4) Dump raw group codes (tags) for a single entity
|
|
79
|
+
|
|
80
|
+
This is the most useful thing for implementing a new handler in `src/handlers/entity/*`.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
. .venv-ezdxf/bin/activate
|
|
84
|
+
python - <<'PY'
|
|
85
|
+
import ezdxf
|
|
86
|
+
from ezdxf.lldxf.tagwriter import TagCollector
|
|
87
|
+
|
|
88
|
+
doc = ezdxf.readfile('test/resources/leader-basic.dxf')
|
|
89
|
+
entity = next(iter(doc.modelspace()))
|
|
90
|
+
|
|
91
|
+
collector = TagCollector()
|
|
92
|
+
entity.export_dxf(collector)
|
|
93
|
+
|
|
94
|
+
for tag in collector.tags:
|
|
95
|
+
print(tag.code, tag.value)
|
|
96
|
+
PY
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Tip: If you want to dump all entities:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
. .venv-ezdxf/bin/activate
|
|
103
|
+
python - <<'PY'
|
|
104
|
+
import ezdxf
|
|
105
|
+
from ezdxf.lldxf.tagwriter import TagCollector
|
|
106
|
+
|
|
107
|
+
doc = ezdxf.readfile('test/resources/entities.dxf')
|
|
108
|
+
for i, entity in enumerate(doc.modelspace()):
|
|
109
|
+
print('---', i, entity.dxftype(), '---')
|
|
110
|
+
collector = TagCollector()
|
|
111
|
+
entity.export_dxf(collector)
|
|
112
|
+
for tag in collector.tags:
|
|
113
|
+
print(tag.code, tag.value)
|
|
114
|
+
PY
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 5) Generate a new minimal fixture (recommended pattern)
|
|
118
|
+
|
|
119
|
+
If ezdxf supports the entity via `layout.new_entity()`, you can create it directly.
|
|
120
|
+
|
|
121
|
+
Example: create a minimal `TOLERANCE` entity and export:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
. .venv-ezdxf/bin/activate
|
|
125
|
+
python - <<'PY'
|
|
126
|
+
import ezdxf
|
|
127
|
+
|
|
128
|
+
doc = ezdxf.new('R2010')
|
|
129
|
+
msp = doc.modelspace()
|
|
130
|
+
|
|
131
|
+
# Create entity by DXF type name. dxfattribs depends on entity.
|
|
132
|
+
# "insert" maps to group codes 10/20/30 for many entities.
|
|
133
|
+
fcf = msp.new_entity('TOLERANCE', dxfattribs={
|
|
134
|
+
'layer': '0',
|
|
135
|
+
'insert': (10, 20, 0),
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
# You can set additional attributes if supported:
|
|
139
|
+
# fcf.dxf.text = '%%v%%v'
|
|
140
|
+
|
|
141
|
+
out = 'test/resources/tolerance-basic.dxf'
|
|
142
|
+
doc.saveas(out)
|
|
143
|
+
print('wrote', out)
|
|
144
|
+
PY
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
If the high-level attribute you need is unclear, use the **tag dump** technique above to learn what ezdxf writes.
|
|
148
|
+
|
|
149
|
+
## 6) Run DXF-Renewed checks
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
cd <path-to>/DXF-Renewed
|
|
153
|
+
yarn test
|
|
154
|
+
yarn lint
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 7) Reference sitemap
|
|
158
|
+
|
|
159
|
+
Curated ezdxf reference links live here:
|
|
160
|
+
|
|
161
|
+
- docs/EZDXF_REFERENCE_SITEMAP.md
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**/*'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Test-Driven Development (TDD) Principles - AI Instructions
|
|
6
|
+
|
|
7
|
+
## Core TDD Workflow
|
|
8
|
+
|
|
9
|
+
1. **RED**: Write failing test first
|
|
10
|
+
2. **GREEN**: Write minimal code to pass test
|
|
11
|
+
3. **REFACTOR**: Improve code while maintaining test pass
|
|
12
|
+
|
|
13
|
+
## Mandatory Rules
|
|
14
|
+
|
|
15
|
+
### Test-First Discipline
|
|
16
|
+
|
|
17
|
+
- NEVER write production code without failing test
|
|
18
|
+
- Test describes expected behavior before implementation
|
|
19
|
+
- Watch test fail before writing implementation
|
|
20
|
+
- Verify test passes after implementation
|
|
21
|
+
|
|
22
|
+
### Minimal Implementation
|
|
23
|
+
|
|
24
|
+
- Write ONLY code needed to pass current test
|
|
25
|
+
- Avoid premature optimization
|
|
26
|
+
- Resist implementing features without tests
|
|
27
|
+
- Each test drives one specific behavior
|
|
28
|
+
|
|
29
|
+
### Test Quality Standards
|
|
30
|
+
|
|
31
|
+
- Tests must be deterministic (same input = same output)
|
|
32
|
+
- Tests should be independent (no execution order dependency)
|
|
33
|
+
- Use descriptive test names explaining expected behavior
|
|
34
|
+
- One assertion concept per test (arrange, act, assert)
|
|
35
|
+
|
|
36
|
+
## Test Structure Pattern
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
describe('UnitUnderTest', () => {
|
|
40
|
+
// Arrange: Setup test data and mocks
|
|
41
|
+
const input = validInput();
|
|
42
|
+
const expected = expectedOutput();
|
|
43
|
+
|
|
44
|
+
// Act: Execute function/method
|
|
45
|
+
const result = functionUnderTest(input);
|
|
46
|
+
|
|
47
|
+
// Assert: Verify result matches expectation
|
|
48
|
+
expect(result).toEqual(expected);
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Code Coverage Requirements
|
|
53
|
+
|
|
54
|
+
- Aim for 100% line coverage
|
|
55
|
+
- 100% branch coverage (all if/else paths)
|
|
56
|
+
- 100% function coverage
|
|
57
|
+
- Use Istanbul/c8 for coverage reporting
|
|
58
|
+
- Uncovered code indicates missing tests
|
|
59
|
+
|
|
60
|
+
## Anti-Patterns to Avoid
|
|
61
|
+
|
|
62
|
+
### Do NOT
|
|
63
|
+
|
|
64
|
+
- Write implementation before test
|
|
65
|
+
- Write multiple tests before implementation
|
|
66
|
+
- Skip watching test fail
|
|
67
|
+
- Test implementation details instead of behavior
|
|
68
|
+
- Couple tests to internal structure
|
|
69
|
+
- Use random/non-deterministic test data
|
|
70
|
+
- Share state between tests
|
|
71
|
+
|
|
72
|
+
### Do NOT Cheat
|
|
73
|
+
|
|
74
|
+
- Hard-coding expected results to pass tests
|
|
75
|
+
- Writing `if` statements matching test inputs
|
|
76
|
+
- Returning specific values for test cases
|
|
77
|
+
- Example of cheating:
|
|
78
|
+
```typescript
|
|
79
|
+
// BAD: Hard-coded for specific test
|
|
80
|
+
function calculate(a: number, b: number): number {
|
|
81
|
+
if (a === 215 && b === 300) return 85;
|
|
82
|
+
if (a === 486 && b === 600) return 114;
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Mocking Strategy
|
|
88
|
+
|
|
89
|
+
### When to Mock
|
|
90
|
+
|
|
91
|
+
- External dependencies (APIs, databases, file system)
|
|
92
|
+
- Time-dependent operations (Date.now(), timers)
|
|
93
|
+
- Random operations (Math.random())
|
|
94
|
+
- Complex dependencies not under test
|
|
95
|
+
- Async operations (Promises, Observables)
|
|
96
|
+
|
|
97
|
+
### Mock Requirements
|
|
98
|
+
|
|
99
|
+
- Mock external service calls
|
|
100
|
+
- Mock database queries
|
|
101
|
+
- Mock file I/O operations
|
|
102
|
+
- Use spy functions to verify interactions
|
|
103
|
+
- Return predictable, synchronous data when possible
|
|
104
|
+
|
|
105
|
+
### Mock Example
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// Mock Observable service method
|
|
109
|
+
jest.spyOn(service, 'get').mockReturnValue(
|
|
110
|
+
of({
|
|
111
|
+
id: 1,
|
|
112
|
+
data: 'test',
|
|
113
|
+
toJson: () => ({ id: 1, data: 'test' }),
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Handling Async Operations
|
|
119
|
+
|
|
120
|
+
### Observable/Promise Patterns
|
|
121
|
+
|
|
122
|
+
- Use `firstValueFrom()` in implementation
|
|
123
|
+
- Mock Observables with `of()` or `throwError()`
|
|
124
|
+
- Properly handle async/await in tests
|
|
125
|
+
- Ensure all Observables complete in tests
|
|
126
|
+
|
|
127
|
+
### Timeout Prevention
|
|
128
|
+
|
|
129
|
+
- Mock all external async operations
|
|
130
|
+
- Avoid real HTTP calls in unit tests
|
|
131
|
+
- Mock timers with `jest.useFakeTimers()`
|
|
132
|
+
- Set reasonable test timeouts
|
|
133
|
+
|
|
134
|
+
## Test Organization
|
|
135
|
+
|
|
136
|
+
### File Structure
|
|
137
|
+
|
|
138
|
+
- `*.spec.ts` for unit tests (same directory as source)
|
|
139
|
+
- `*.test.ts` for integration tests
|
|
140
|
+
- `*.e2e.ts` for end-to-end tests
|
|
141
|
+
- One test file per source file
|
|
142
|
+
|
|
143
|
+
### Test Grouping
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
describe('ServiceName', () => {
|
|
147
|
+
describe('methodName', () => {
|
|
148
|
+
it('should handle valid input', () => {});
|
|
149
|
+
it('should throw on invalid input', () => {});
|
|
150
|
+
it('should return empty for edge case', () => {});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Regression Prevention
|
|
156
|
+
|
|
157
|
+
- All tests must pass before commit
|
|
158
|
+
- New features require new tests
|
|
159
|
+
- Bug fixes require reproduction test
|
|
160
|
+
- Refactoring must not break existing tests
|
|
161
|
+
- Use CI to enforce test pass
|
|
162
|
+
|
|
163
|
+
## Documentation Through Tests
|
|
164
|
+
|
|
165
|
+
- Tests serve as executable documentation
|
|
166
|
+
- Test names explain functionality
|
|
167
|
+
- Use JSDoc comments for complex logic
|
|
168
|
+
- Include usage examples in test descriptions
|
|
169
|
+
|
|
170
|
+
## Performance Considerations
|
|
171
|
+
|
|
172
|
+
- Unit tests should run fast (< 1s per test)
|
|
173
|
+
- Mock slow operations
|
|
174
|
+
- Use test parallelization
|
|
175
|
+
- Avoid real database/network in unit tests
|
|
176
|
+
- Integration tests can be slower
|
|
177
|
+
|
|
178
|
+
## Implementation Workflow
|
|
179
|
+
|
|
180
|
+
1. Write test describing one behavior
|
|
181
|
+
2. Run test → verify it fails
|
|
182
|
+
3. Write minimum code to pass test
|
|
183
|
+
4. Run test → verify it passes
|
|
184
|
+
5. Refactor if needed
|
|
185
|
+
6. Run all tests → verify no regression
|
|
186
|
+
7. Repeat for next behavior
|
|
187
|
+
|
|
188
|
+
## Red-Green-Refactor Cycle
|
|
189
|
+
|
|
190
|
+
**RED Phase:**
|
|
191
|
+
|
|
192
|
+
- Write test for non-existent functionality
|
|
193
|
+
- Test must fail with meaningful error
|
|
194
|
+
- Verify test failure reason is correct
|
|
195
|
+
|
|
196
|
+
**GREEN Phase:**
|
|
197
|
+
|
|
198
|
+
- Write simplest code to make test pass
|
|
199
|
+
- Don't worry about code quality yet
|
|
200
|
+
- Focus only on making test green
|
|
201
|
+
|
|
202
|
+
**REFACTOR Phase:**
|
|
203
|
+
|
|
204
|
+
- Improve code structure
|
|
205
|
+
- Remove duplication
|
|
206
|
+
- Optimize performance if needed
|
|
207
|
+
- All tests must remain green
|
|
208
|
+
|
|
209
|
+
## Practical Example: Vending Machine Change
|
|
210
|
+
|
|
211
|
+
**Requirement:** Calculate coin change for vending machine
|
|
212
|
+
|
|
213
|
+
**Test 1 - Empty Case:**
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
test('getChange(1,1) returns empty array', () => {
|
|
217
|
+
expect(getChange(1, 1)).toEqual([]);
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Implementation 1:**
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
function getChange(payable: number, paid: number): number[] {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Test 2 - Basic Change:**
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
test('getChange(215, 300) returns [50,20,10,5]', () => {
|
|
233
|
+
expect(getChange(215, 300)).toEqual([50, 20, 10, 5]);
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Implementation 2:**
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
function getChange(payable: number, paid: number): number[] {
|
|
241
|
+
const coins = [200, 100, 50, 20, 10, 5, 2, 1];
|
|
242
|
+
const change: number[] = [];
|
|
243
|
+
let remaining = paid - payable;
|
|
244
|
+
|
|
245
|
+
for (const coin of coins) {
|
|
246
|
+
while (remaining >= coin) {
|
|
247
|
+
change.push(coin);
|
|
248
|
+
remaining -= coin;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return change;
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Summary Checklist
|
|
257
|
+
|
|
258
|
+
Before writing any production code:
|
|
259
|
+
|
|
260
|
+
- [ ] Write failing test
|
|
261
|
+
- [ ] Verify test fails with expected reason
|
|
262
|
+
- [ ] Write minimal implementation
|
|
263
|
+
- [ ] Verify test passes
|
|
264
|
+
- [ ] Verify no test regressions
|
|
265
|
+
- [ ] Refactor if needed
|
|
266
|
+
- [ ] All tests still pass
|
|
267
|
+
|
|
268
|
+
## Reference Sources
|
|
269
|
+
|
|
270
|
+
Based on: https://github.com/dwyl/learn-tdd
|
|
271
|
+
Key principles: Red-Green-Refactor, Test-First, Minimal Implementation
|
|
@@ -73,6 +73,10 @@ jobs:
|
|
|
73
73
|
uses: actions/setup-node@v4
|
|
74
74
|
with:
|
|
75
75
|
node-version: 22.x
|
|
76
|
+
registry-url: https://registry.npmjs.org
|
|
77
|
+
|
|
78
|
+
- name: Upgrade npm (Trusted Publishers)
|
|
79
|
+
run: npm i -g npm@^11.5.1
|
|
76
80
|
|
|
77
81
|
- name: Enable Corepack
|
|
78
82
|
run: corepack enable
|
|
@@ -95,11 +99,6 @@ jobs:
|
|
|
95
99
|
- name: Build
|
|
96
100
|
run: yarn build
|
|
97
101
|
|
|
98
|
-
- name: Create tarball for GitHub release
|
|
99
|
-
run: |
|
|
100
|
-
mkdir -p dist
|
|
101
|
-
yarn pack --out dist/%s-%v.tgz
|
|
102
|
-
|
|
103
102
|
- name: Release
|
|
104
103
|
env:
|
|
105
104
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/.releaserc.json
CHANGED
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
## 7.1.0 (2026-01-01)
|
|
9
|
+
|
|
10
|
+
* 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)
|
|
11
|
+
* docs: add ezdxf reference sitemap and dev instructions ([859da63](https://github.com/linkiez/DXF-Renewed/commit/859da63))
|
|
12
|
+
* docs: add SVG rendering integration testing docs ([5bb0dbb](https://github.com/linkiez/DXF-Renewed/commit/5bb0dbb))
|
|
13
|
+
* docs: clarify type safety guidance ([dc01286](https://github.com/linkiez/DXF-Renewed/commit/dc01286))
|
|
14
|
+
* docs: consolidate documentation and plan ([2f4f01e](https://github.com/linkiez/DXF-Renewed/commit/2f4f01e))
|
|
15
|
+
* docs: switch to main-only workflow ([6098ad6](https://github.com/linkiez/DXF-Renewed/commit/6098ad6))
|
|
16
|
+
* docs: update dimension docs and test guidance ([c171703](https://github.com/linkiez/DXF-Renewed/commit/c171703))
|
|
17
|
+
* chore: ignore local ezdxf venv ([053e4c4](https://github.com/linkiez/DXF-Renewed/commit/053e4c4))
|
|
18
|
+
* chore(fixtures): add ezdxf validation tooling ([c81c871](https://github.com/linkiez/DXF-Renewed/commit/c81c871))
|
|
19
|
+
* chore(fixtures): regenerate DXF fixtures via ezdxf ([7c6876d](https://github.com/linkiez/DXF-Renewed/commit/7c6876d))
|
|
20
|
+
* chore(tests): track rendered screenshots ([ebcd1f1](https://github.com/linkiez/DXF-Renewed/commit/ebcd1f1))
|
|
21
|
+
* test(dimension): add fixtures for all dimension types ([6b5f9cf](https://github.com/linkiez/DXF-Renewed/commit/6b5f9cf))
|
|
22
|
+
* test(integration): add node DIMENSION SVG rendering test ([820efc6](https://github.com/linkiez/DXF-Renewed/commit/820efc6))
|
|
23
|
+
* test(integration): run SVG rendering tests in browser ([b0abe31](https://github.com/linkiez/DXF-Renewed/commit/b0abe31))
|
|
24
|
+
* feat(dimension): add angular 3-point rendering ([a9ee537](https://github.com/linkiez/DXF-Renewed/commit/a9ee537))
|
|
25
|
+
* feat(entities): add image, underlay, leader, and tolerance support ([7f17e47](https://github.com/linkiez/DXF-Renewed/commit/7f17e47))
|
|
26
|
+
* feat(objects): add handle maps for common DXF objects ([7672211](https://github.com/linkiez/DXF-Renewed/commit/7672211))
|
|
27
|
+
* style: normalize import ordering ([55d54c1](https://github.com/linkiez/DXF-Renewed/commit/55d54c1))
|
|
28
|
+
* fix(denormalise): apply block basepoint to TEXT/MTEXT/DIMENSION ([1ee560e](https://github.com/linkiez/DXF-Renewed/commit/1ee560e))
|
|
29
|
+
* fix(parser): harden POLYLINE sequencing ([7eb1fb7](https://github.com/linkiez/DXF-Renewed/commit/7eb1fb7))
|
|
30
|
+
|
|
31
|
+
## 7.0.0 (2025-12-31)
|
|
32
|
+
|
|
33
|
+
* fix: consolidar tipos ParsedDXF e corrigir incompatibilidades ([804c485](https://github.com/linkiez/DXF-Renewed/commit/804c485))
|
|
34
|
+
* fix: tipar handlers e entidades no parseEntities ([a364044](https://github.com/linkiez/DXF-Renewed/commit/a364044))
|
|
35
|
+
* fix(ci): enable corepack for yarn 4 support in github actions ([59048b9](https://github.com/linkiez/DXF-Renewed/commit/59048b9))
|
|
36
|
+
* fix(ci): remove yarn cache from setup-node to enable corepack first ([ba3186c](https://github.com/linkiez/DXF-Renewed/commit/ba3186c))
|
|
37
|
+
* fix(ci): skip eslint temporarily - babel parser incompatible with ts+esm ([37276c4](https://github.com/linkiez/DXF-Renewed/commit/37276c4))
|
|
38
|
+
* fix(ci): use node 22.x for semantic-release v25 compatibility ([c20e69b](https://github.com/linkiez/DXF-Renewed/commit/c20e69b))
|
|
39
|
+
* fix(release): simplify to use only main branch for releases ([705b77d](https://github.com/linkiez/DXF-Renewed/commit/705b77d))
|
|
40
|
+
* fix(release): use https repository URL ([77e9a17](https://github.com/linkiez/DXF-Renewed/commit/77e9a17))
|
|
41
|
+
* chore: sync package and release configuration ([e391038](https://github.com/linkiez/DXF-Renewed/commit/e391038))
|
|
42
|
+
* chore: update yarn.lock ([6a7fb91](https://github.com/linkiez/DXF-Renewed/commit/6a7fb91))
|
|
43
|
+
* docs: add warning about development status to README ([def8658](https://github.com/linkiez/DXF-Renewed/commit/def8658))
|
|
44
|
+
* feat: adicionar tipos para entidades hatch, viewport e ole2frame ([e1c7b8f](https://github.com/linkiez/DXF-Renewed/commit/e1c7b8f))
|
|
45
|
+
* feat: implement DIMENSION rendering with DIMSTYLE support (Phases 1 and 2) ([37b7e62](https://github.com/linkiez/DXF-Renewed/commit/37b7e62))
|
|
46
|
+
* feat: implement Phase 3 - advanced DIMENSION rendering with arrows and extension lines ([02ff584](https://github.com/linkiez/DXF-Renewed/commit/02ff584))
|
|
47
|
+
* feat: implement semantic-release and translate project to en_US ([e5b880d](https://github.com/linkiez/DXF-Renewed/commit/e5b880d))
|
|
48
|
+
* feat(lint): add typescript eslint support and fix lint errors ([df13e74](https://github.com/linkiez/DXF-Renewed/commit/df13e74))
|
|
49
|
+
* refactor: consolidar ColorRGB type em types/common ([4a0bd43](https://github.com/linkiez/DXF-Renewed/commit/4a0bd43))
|
|
50
|
+
* refactor: consolidar types e interfaces em src/types/ ([604aa5c](https://github.com/linkiez/DXF-Renewed/commit/604aa5c))
|
|
51
|
+
* refactor: eliminar interfaces duplicadas de arquivos principais ([3429635](https://github.com/linkiez/DXF-Renewed/commit/3429635))
|
|
52
|
+
* refactor: remover extrusionZ duplicado de InsertEntity ([3a1fcfd](https://github.com/linkiez/DXF-Renewed/commit/3a1fcfd))
|
|
53
|
+
* refactor: simplificar types com extends pattern ([ea08247](https://github.com/linkiez/DXF-Renewed/commit/ea08247))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### BREAKING CHANGE
|
|
57
|
+
|
|
58
|
+
* All commits must now follow Conventional Commits format in English
|
|
59
|
+
|
|
60
|
+
# Changelog
|
|
61
|
+
|
|
3
62
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
63
|
|
|
5
64
|
### [5.3.1](https://github.com/skymakerolof/dxf/compare/v5.3.0...v5.3.1) (2025-09-01)
|
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
|
|