tsdraft 0.2.1 → 0.2.2
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/CHANGELOG.md +24 -0
- package/README.md +42 -12
- package/dist/layers.d.ts +17 -6
- package/dist/layers.js +88 -11
- package/dist/lint.js +7 -1
- package/dist/rules.d.ts +7 -4
- package/dist/rules.js +7 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
Found by opening tsdraft's output in AutoCAD 2025.
|
|
6
|
+
|
|
7
|
+
- Fixed: AutoCAD keeps two layers such as `straße` and `STRASSE` apart, but its
|
|
8
|
+
`AUDIT` reports them as a duplicate name. `lint` now reports the second layer
|
|
9
|
+
as a duplicate, and the builder throws at the `layer()` call. It does so for
|
|
10
|
+
the kinds of pair measured in AutoCAD, in either letter case and inside longer
|
|
11
|
+
names:
|
|
12
|
+
- a letter and the letters it stands for, such as `ß` and `ss`, `æ` and `ae`,
|
|
13
|
+
`œ` and `oe`, `ij` and `ij`, `fi` and `fi`, `dž` and `dž`, and `þ` and `th`;
|
|
14
|
+
- a composed character and its decomposed form, such as `é`;
|
|
15
|
+
- a name with a soft hyphen inside it or in front of it and the same name
|
|
16
|
+
without.
|
|
17
|
+
|
|
18
|
+
This is not all that `AUDIT` reports. The README lists what is covered and
|
|
19
|
+
what is left out.
|
|
20
|
+
|
|
21
|
+
- When an entity names its layer by the other spelling of such a pair, the
|
|
22
|
+
undefined-layer error now says which declared layer AutoCAD does not take it
|
|
23
|
+
for. AutoCAD adds a layer for the entity, and `AUDIT` reports a duplicate name.
|
|
24
|
+
- `pnpm test:cad` checks each kind of pair against AutoCAD, and 600 longer names
|
|
25
|
+
beside respellings of themselves.
|
|
26
|
+
|
|
3
27
|
## 0.2.1
|
|
4
28
|
|
|
5
29
|
Every fix below was found by opening tsdraft's output in AutoCAD 2025.
|
package/README.md
CHANGED
|
@@ -162,18 +162,48 @@ entity's layer as undefined:
|
|
|
162
162
|
- Georgian, Cherokee and most other letters that gained a case after Unicode
|
|
163
163
|
5.1.
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
`
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
165
|
+
Where `AUDIT` would take the entity's spelling for the declared layer's, as it
|
|
166
|
+
does for `STRASSE` and `straße`, the message says so. AutoCAD adds a layer for
|
|
167
|
+
the entity, and `AUDIT` then reports a duplicate name.
|
|
168
|
+
|
|
169
|
+
### Layer names that AUDIT calls duplicates
|
|
170
|
+
|
|
171
|
+
AutoCAD's `AUDIT` compares layer names another way than AutoCAD looks them up.
|
|
172
|
+
It reports "Duplicate name" for some pairs of layers that AutoCAD keeps as two.
|
|
173
|
+
`lint` reports the second layer of such a pair as a duplicate, which is an
|
|
174
|
+
error, for these kinds of pair. Each kind holds in either letter case and
|
|
175
|
+
inside a longer name, so `Hauptstraße 12` and `HAUPTSTRASSE 12` are a pair.
|
|
176
|
+
|
|
177
|
+
- Single letters: `σ` and `ς`, `Ÿ` and `ÿ`, `ß` and `ẞ`, a title-case digraph
|
|
178
|
+
such as `Dž` and `dž`, and a few others.
|
|
179
|
+
- A letter and the letters it stands for: `ß` and `ss`, `æ` and `ae`, `œ` and
|
|
180
|
+
`oe`, `ij` and `ij`, `þ` and `th`, `dž` and `dž`, `lj` and `lj`, `nj` and `nj`,
|
|
181
|
+
`dz` and `dz`, the ligatures `ff`, `fi`, `fl`, `ffi`, `ffl` and `st`, and `ȸ`, `ȹ`,
|
|
182
|
+
`ʪ`, `ʫ`, `ꜳ`, `ꜵ`, `ꜷ`, `ꜹ`, `ꜽ`, `ꝏ` and `ᴂ`.
|
|
183
|
+
- A composed character and its decomposed form, such as `é` and an `e` with a
|
|
184
|
+
combining acute accent, with its marks in any order Unicode counts as the
|
|
185
|
+
same, such as a dot below before or after a circumflex. Hangul syllables are
|
|
186
|
+
an exception, and so are 40 Arabic, Indic, Myanmar, kana, Hebrew and CJK
|
|
187
|
+
compatibility characters: `AUDIT` keeps those apart from their decomposed
|
|
188
|
+
forms.
|
|
189
|
+
- A name with a soft hyphen, U+00AD, inside it or in front of it, and the same
|
|
190
|
+
name without.
|
|
191
|
+
|
|
192
|
+
This is what was measured in AutoCAD 2025. It is not AutoCAD's whole comparison,
|
|
193
|
+
so a drawing that passes `lint` can still get a "Duplicate name" from `AUDIT`.
|
|
194
|
+
The rule is kept narrow so that it does not go the other way: in over 20,000
|
|
195
|
+
pairs tried, `lint` reported none that `AUDIT` accepts. What it leaves out:
|
|
196
|
+
|
|
197
|
+
- A name that ends with a soft hyphen and the same name without it, and a soft
|
|
198
|
+
hyphen in front of a combining mark or a Hangul jamo. `AUDIT` reports some of
|
|
199
|
+
those pairs and not others. It does not report `coop` and `coop` followed by a
|
|
200
|
+
soft hyphen. Two names that both end with a soft hyphen are compared like any
|
|
201
|
+
others.
|
|
202
|
+
- Compatibility characters that `AUDIT` takes for their plain forms, such as a
|
|
203
|
+
modifier letter `ʰ` and `h`, `㎏` and `kg`, and Arabic presentation forms.
|
|
204
|
+
- Characters that `AUDIT` cannot tell from an unassigned one, such as `Ԥ`,
|
|
205
|
+
U+0524, and `Ꙡ`, U+A660. Two names that differ only in such characters are
|
|
206
|
+
duplicates to it.
|
|
177
207
|
|
|
178
208
|
### Layer name characters
|
|
179
209
|
|
package/dist/layers.d.ts
CHANGED
|
@@ -33,13 +33,24 @@ export declare function rejectedNameCharacter(name: string): string | undefined;
|
|
|
33
33
|
export declare function layerKey(name: string): string;
|
|
34
34
|
/**
|
|
35
35
|
* The form of a layer name that AutoCAD's AUDIT compares when it looks for
|
|
36
|
-
* duplicate names. AUDIT takes
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* duplicate names. AUDIT takes more names for the same than the layer table
|
|
37
|
+
* does, so two layers can have different `layerKey`s and still be an AUDIT
|
|
38
|
+
* error. Two names with the same key here are such a pair, unless they have
|
|
39
|
+
* the same `layerKey` too.
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* The key follows the kinds of pair measured in AutoCAD 2025:
|
|
42
|
+
*
|
|
43
|
+
* - A few single letters, such as σ and ς.
|
|
44
|
+
* - A letter and the letters it stands for, such as ß and `ss`.
|
|
45
|
+
* - A composed character and its decomposed form, such as é and `e` with a
|
|
46
|
+
* combining acute accent, with its marks in any order Unicode counts as the
|
|
47
|
+
* same, such as a dot below before or after a circumflex.
|
|
48
|
+
* - A name with a soft hyphen inside it or in front of it and the same name
|
|
49
|
+
* without.
|
|
50
|
+
*
|
|
51
|
+
* It is not AUDIT's whole comparison. AUDIT also takes some compatibility
|
|
52
|
+
* characters for their plain forms, and cannot tell two characters apart when
|
|
53
|
+
* it knows neither.
|
|
43
54
|
*
|
|
44
55
|
* @param name - The layer name.
|
|
45
56
|
* @returns The key to find AUDIT's duplicate names by.
|
package/dist/layers.js
CHANGED
|
@@ -118,8 +118,7 @@ const FOLDED = new Set(FOLDED_RANGES.split(" ").flatMap((range) => {
|
|
|
118
118
|
/**
|
|
119
119
|
* Pairs of letters that AutoCAD keeps as two layers but its AUDIT reports as a
|
|
120
120
|
* duplicate name, written `from>to` in hexadecimal after `layerKey` has
|
|
121
|
-
* lower-cased the name. They include
|
|
122
|
-
* ς, and ß and ẞ.
|
|
121
|
+
* lower-cased the name. They include the two lower-case sigmas σ and ς.
|
|
123
122
|
*/
|
|
124
123
|
const AUDIT_SAME_PAIRS = "178>ff 1c6>1c5 1c9>1c8 1cc>1cb 1f3>1f2 3c3>3c2 3f5>3b5 527>526 1e9e>df 1fbe>3b9 " +
|
|
125
124
|
"2c7e>23f 2c7f>240 2cec>2ceb 2cee>2ced a791>a790 a7a1>a7a0 a7a3>a7a2 a7a5>a7a4 " +
|
|
@@ -128,6 +127,60 @@ const AUDIT_SAME = new Map(AUDIT_SAME_PAIRS.split(" ").map((pair) => {
|
|
|
128
127
|
const [from = "", to = ""] = pair.split(">");
|
|
129
128
|
return [String.fromCharCode(parseInt(from, 16)), String.fromCharCode(parseInt(to, 16))];
|
|
130
129
|
}));
|
|
130
|
+
/**
|
|
131
|
+
* Letters that AUDIT takes for the two or three letters they stand for, in
|
|
132
|
+
* either letter case: it reports `straße` and `STRASSE` as a duplicate name,
|
|
133
|
+
* and `Þórr` and `Thórr`. Each is listed in lower case, as `layerKey` leaves
|
|
134
|
+
* it, with a title-case digraph beside its lower-case form.
|
|
135
|
+
*/
|
|
136
|
+
const AUDIT_SPELLED_OUT = new Map(Object.entries({
|
|
137
|
+
ß: "ss",
|
|
138
|
+
ẞ: "ss",
|
|
139
|
+
æ: "ae",
|
|
140
|
+
ᴂ: "ae",
|
|
141
|
+
œ: "oe",
|
|
142
|
+
ij: "ij",
|
|
143
|
+
þ: "th",
|
|
144
|
+
dž: "dž",
|
|
145
|
+
Dž: "dž",
|
|
146
|
+
lj: "lj",
|
|
147
|
+
Lj: "lj",
|
|
148
|
+
nj: "nj",
|
|
149
|
+
Nj: "nj",
|
|
150
|
+
dz: "dz",
|
|
151
|
+
Dz: "dz",
|
|
152
|
+
ff: "ff",
|
|
153
|
+
fi: "fi",
|
|
154
|
+
fl: "fl",
|
|
155
|
+
ffi: "ffi",
|
|
156
|
+
ffl: "ffl",
|
|
157
|
+
st: "st",
|
|
158
|
+
ȸ: "db",
|
|
159
|
+
ȹ: "qp",
|
|
160
|
+
ʪ: "ls",
|
|
161
|
+
ʫ: "lz",
|
|
162
|
+
ꜳ: "aa",
|
|
163
|
+
ꜵ: "ao",
|
|
164
|
+
ꜷ: "au",
|
|
165
|
+
ꜹ: "av",
|
|
166
|
+
ꜽ: "ay",
|
|
167
|
+
ꝏ: "oo",
|
|
168
|
+
// The key is compared in decomposed form, so `ž` is spelled as it decomposes.
|
|
169
|
+
}).map(([letter, spelling]) => [letter, spelling.normalize("NFD")]));
|
|
170
|
+
/**
|
|
171
|
+
* Composed characters that AUDIT does not take for their decomposed forms,
|
|
172
|
+
* though Unicode calls the two equivalent: Hangul syllables, and some Arabic,
|
|
173
|
+
* Indic, Myanmar, kana, Hebrew and CJK compatibility characters. AUDIT takes
|
|
174
|
+
* every other composed character below U+10000 for its decomposed form.
|
|
175
|
+
*/
|
|
176
|
+
const KEPT_COMPOSED = /([\u0622-\u0624\u0626\u06c0\u06c2\u06d3\u09cb\u09cc\u09df\u0b48\u0b4b\u0b4c\u0b94\u0bca-\u0bcc\u0c48\u0cc0\u0cc7\u0cc8\u0cca\u0ccb\u0d4a-\u0d4c\u0dda\u0ddc-\u0dde\u1026\u309e\u30fe\ufa2e\ufa2f\ufa6b\ufa6d\ufb1f\ufb2c\ufb2d\uac00-\ud7a3])/;
|
|
177
|
+
const SOFT_HYPHEN = "\u00ad";
|
|
178
|
+
/**
|
|
179
|
+
* Soft hyphens that AUDIT ignores. It does not ignore one in front of a
|
|
180
|
+
* combining mark or a Hangul jamo: `E`, a soft hyphen and a combining acute
|
|
181
|
+
* accent are not É to it.
|
|
182
|
+
*/
|
|
183
|
+
const IGNORED_SOFT_HYPHENS = /\u00ad+(?![\u00ad\p{M}\u1100-\u11ff\ua960-\ua97f\ud7b0-\ud7ff])/gu;
|
|
131
184
|
/**
|
|
132
185
|
* The form of a layer name that AutoCAD looks layers up by. Two names with the
|
|
133
186
|
* same key are one layer to AutoCAD: an entity on `wall` goes on a layer
|
|
@@ -149,22 +202,46 @@ export function layerKey(name) {
|
|
|
149
202
|
}
|
|
150
203
|
/**
|
|
151
204
|
* The form of a layer name that AutoCAD's AUDIT compares when it looks for
|
|
152
|
-
* duplicate names. AUDIT takes
|
|
153
|
-
*
|
|
154
|
-
*
|
|
205
|
+
* duplicate names. AUDIT takes more names for the same than the layer table
|
|
206
|
+
* does, so two layers can have different `layerKey`s and still be an AUDIT
|
|
207
|
+
* error. Two names with the same key here are such a pair, unless they have
|
|
208
|
+
* the same `layerKey` too.
|
|
155
209
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
210
|
+
* The key follows the kinds of pair measured in AutoCAD 2025:
|
|
211
|
+
*
|
|
212
|
+
* - A few single letters, such as σ and ς.
|
|
213
|
+
* - A letter and the letters it stands for, such as ß and `ss`.
|
|
214
|
+
* - A composed character and its decomposed form, such as é and `e` with a
|
|
215
|
+
* combining acute accent, with its marks in any order Unicode counts as the
|
|
216
|
+
* same, such as a dot below before or after a circumflex.
|
|
217
|
+
* - A name with a soft hyphen inside it or in front of it and the same name
|
|
218
|
+
* without.
|
|
219
|
+
*
|
|
220
|
+
* It is not AUDIT's whole comparison. AUDIT also takes some compatibility
|
|
221
|
+
* characters for their plain forms, and cannot tell two characters apart when
|
|
222
|
+
* it knows neither.
|
|
159
223
|
*
|
|
160
224
|
* @param name - The layer name.
|
|
161
225
|
* @returns The key to find AUDIT's duplicate names by.
|
|
162
226
|
*/
|
|
163
227
|
export function layerAuditKey(name) {
|
|
164
228
|
let key = "";
|
|
165
|
-
for (const character of layerKey(name))
|
|
166
|
-
key += AUDIT_SAME.get(character) ?? character;
|
|
167
|
-
|
|
229
|
+
for (const character of layerKey(decomposed(name.replace(IGNORED_SOFT_HYPHENS, "")))) {
|
|
230
|
+
key += AUDIT_SPELLED_OUT.get(character) ?? AUDIT_SAME.get(character) ?? character;
|
|
231
|
+
}
|
|
232
|
+
// AUDIT does not report `coop` and `coop` with a soft hyphen after it as duplicates, though it
|
|
233
|
+
// does report some other pairs that differ by a soft hyphen at the end. A mark for one at the
|
|
234
|
+
// end keeps a name that ends with a soft hyphen apart from every name that does not. Two names
|
|
235
|
+
// that both end with one are compared like any others, as the pairs in `auditPairs` in
|
|
236
|
+
// `scripts/cad-check.ts` check.
|
|
237
|
+
return name.endsWith(SOFT_HYPHEN) ? key + SOFT_HYPHEN : key;
|
|
238
|
+
}
|
|
239
|
+
/** Decomposes every composed character that AUDIT takes for its decomposed form. */
|
|
240
|
+
function decomposed(name) {
|
|
241
|
+
return name
|
|
242
|
+
.split(KEPT_COMPOSED)
|
|
243
|
+
.map((part, i) => (i % 2 === 1 ? part : part.normalize("NFD")))
|
|
244
|
+
.join("");
|
|
168
245
|
}
|
|
169
246
|
/**
|
|
170
247
|
* Orders layers for a DXF layer table. AutoCAD's AUDIT reports "Layer zero name
|
package/dist/lint.js
CHANGED
|
@@ -49,7 +49,13 @@ export function lint(drawing, options = {}) {
|
|
|
49
49
|
drawing.entities.forEach((entity, index) => {
|
|
50
50
|
const add = (rule, severity, problem) => out.push({ rule, severity, message: `${entity.kind} #${index}: ${problem}`, entity: index });
|
|
51
51
|
if (!seen.has(layerKey(entity.layer))) {
|
|
52
|
-
|
|
52
|
+
// AutoCAD adds a layer for a name it does not know. When AUDIT takes that name for a
|
|
53
|
+
// declared layer's, it then reports the new layer as a duplicate of it.
|
|
54
|
+
const twin = audited.get(layerAuditKey(entity.layer));
|
|
55
|
+
const hint = twin
|
|
56
|
+
? `. AutoCAD does not take it for layer ${JSON.stringify(twin)}: it would add a layer, and its AUDIT would report a duplicate name`
|
|
57
|
+
: "";
|
|
58
|
+
add("undefined-layer", "error", `layer ${JSON.stringify(entity.layer)} is not defined${hint}`);
|
|
53
59
|
}
|
|
54
60
|
const problems = geometryProblems(entity);
|
|
55
61
|
for (const problem of problems)
|
package/dist/rules.d.ts
CHANGED
|
@@ -47,10 +47,13 @@ export declare function layerNameProblem(name: string, version: DxfVersion): str
|
|
|
47
47
|
/**
|
|
48
48
|
* Returns what is wrong with a drawing that has both names as layers, or
|
|
49
49
|
* undefined when the two can stand together. AutoCAD looks layers up one way
|
|
50
|
-
* and its AUDIT compares their names another, so
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* and its AUDIT compares their names another, so some pairs of names are two
|
|
51
|
+
* layers to AutoCAD and one duplicate name to AUDIT: `ΟΔΟΣ` and `οδος`,
|
|
52
|
+
* `straße` and `strasse`, a composed é and a decomposed one, and a name with
|
|
53
|
+
* and without a soft hyphen. `layerAuditKey` lists the kinds this covers,
|
|
54
|
+
* which are those measured in AutoCAD and not all that AUDIT reports. Names
|
|
55
|
+
* that are one layer to AutoCAD are not this function's concern. The rule
|
|
56
|
+
* compares two names, so it has no type.
|
|
54
57
|
*
|
|
55
58
|
* @param name - The name of the layer being checked.
|
|
56
59
|
* @param other - The name of another layer in the drawing.
|
package/dist/rules.js
CHANGED
|
@@ -39,10 +39,13 @@ export function layerNameProblem(name, version) {
|
|
|
39
39
|
/**
|
|
40
40
|
* Returns what is wrong with a drawing that has both names as layers, or
|
|
41
41
|
* undefined when the two can stand together. AutoCAD looks layers up one way
|
|
42
|
-
* and its AUDIT compares their names another, so
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
42
|
+
* and its AUDIT compares their names another, so some pairs of names are two
|
|
43
|
+
* layers to AutoCAD and one duplicate name to AUDIT: `ΟΔΟΣ` and `οδος`,
|
|
44
|
+
* `straße` and `strasse`, a composed é and a decomposed one, and a name with
|
|
45
|
+
* and without a soft hyphen. `layerAuditKey` lists the kinds this covers,
|
|
46
|
+
* which are those measured in AutoCAD and not all that AUDIT reports. Names
|
|
47
|
+
* that are one layer to AutoCAD are not this function's concern. The rule
|
|
48
|
+
* compares two names, so it has no type.
|
|
46
49
|
*
|
|
47
50
|
* @param name - The name of the layer being checked.
|
|
48
51
|
* @param other - The name of another layer in the drawing.
|