tsdraft 0.2.2 → 0.4.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/CHANGELOG.md +87 -14
- package/README.md +141 -212
- package/dist/callsite.d.ts +47 -0
- package/dist/callsite.js +82 -0
- package/dist/drawing.d.ts +164 -16
- package/dist/drawing.js +339 -75
- package/dist/dxf-r2018.js +36 -15
- package/dist/dxf.d.ts +1 -1
- package/dist/format.d.ts +7 -0
- package/dist/format.js +9 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +3 -0
- package/dist/json.d.ts +21 -0
- package/dist/json.js +244 -0
- package/dist/layers.d.ts +1 -1
- package/dist/layers.js +2 -3
- package/dist/linetypes.d.ts +27 -0
- package/dist/linetypes.js +76 -0
- package/dist/lint.d.ts +19 -5
- package/dist/lint.js +132 -7
- package/dist/paper.d.ts +33 -0
- package/dist/paper.js +58 -0
- package/dist/rules.d.ts +190 -9
- package/dist/rules.js +239 -22
- package/dist/svg.d.ts +11 -2
- package/dist/svg.js +143 -10
- package/package.json +6 -4
package/dist/paper.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Units } from "./drawing.ts";
|
|
2
|
+
import { type PaperLength, type Ratio } from "./rules.ts";
|
|
3
|
+
/** A unit paper lengths are given in. */
|
|
4
|
+
export type PaperUnit = "in" | "mm";
|
|
5
|
+
/** The view a paper length is converted for. */
|
|
6
|
+
export interface PaperScale<R extends number = number> {
|
|
7
|
+
/**
|
|
8
|
+
* How many times larger the model is than its plot, as a plain number: 96
|
|
9
|
+
* for 1/8" = 1'-0", 240 for 1" = 20', 50 for 1:50.
|
|
10
|
+
*/
|
|
11
|
+
readonly ratio: Ratio<R>;
|
|
12
|
+
/** The drawing's units, as given to `createDrawing`. */
|
|
13
|
+
readonly units: Units;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Turns a length on paper into drawing units, for text, symbols and dashes
|
|
17
|
+
* that are sized by how large they plot. A 3/32 inch note on a sheet at
|
|
18
|
+
* 1/8" = 1'-0" is 9 inches in the model, which is 0.75 in a drawing in feet:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* fromPaper(3 / 32, "in", { ratio: 96, units: "ft" }); // 0.75
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* A length or a ratio of 0 or less is a compile error when it is a literal.
|
|
25
|
+
*
|
|
26
|
+
* @param length - The length as it plots, greater than 0.
|
|
27
|
+
* @param unit - The unit of `length`: `"in"` or `"mm"`.
|
|
28
|
+
* @param view - The ratio the length plots at, and the drawing's units.
|
|
29
|
+
* @returns The length in drawing units.
|
|
30
|
+
* @throws When an argument is not one of the above, or when the result would
|
|
31
|
+
* be written as 0 at the 6 decimals tsdraft writes, or is 1e100 or more.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fromPaper<L extends number, R extends number>(length: PaperLength<L>, unit: PaperUnit, view: PaperScale<R>): number;
|
package/dist/paper.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { paperLengthProblem } from "./rules.js";
|
|
2
|
+
/** Inches in one of each imperial unit, and millimetres in one of each metric unit. */
|
|
3
|
+
const SIZES = {
|
|
4
|
+
in: ["imperial", 1],
|
|
5
|
+
ft: ["imperial", 12],
|
|
6
|
+
mm: ["metric", 1],
|
|
7
|
+
cm: ["metric", 10],
|
|
8
|
+
m: ["metric", 1000],
|
|
9
|
+
};
|
|
10
|
+
const MM_PER_INCH = 25.4;
|
|
11
|
+
/**
|
|
12
|
+
* Turns a length on paper into drawing units, for text, symbols and dashes
|
|
13
|
+
* that are sized by how large they plot. A 3/32 inch note on a sheet at
|
|
14
|
+
* 1/8" = 1'-0" is 9 inches in the model, which is 0.75 in a drawing in feet:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* fromPaper(3 / 32, "in", { ratio: 96, units: "ft" }); // 0.75
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* A length or a ratio of 0 or less is a compile error when it is a literal.
|
|
21
|
+
*
|
|
22
|
+
* @param length - The length as it plots, greater than 0.
|
|
23
|
+
* @param unit - The unit of `length`: `"in"` or `"mm"`.
|
|
24
|
+
* @param view - The ratio the length plots at, and the drawing's units.
|
|
25
|
+
* @returns The length in drawing units.
|
|
26
|
+
* @throws When an argument is not one of the above, or when the result would
|
|
27
|
+
* be written as 0 at the 6 decimals tsdraft writes, or is 1e100 or more.
|
|
28
|
+
*/
|
|
29
|
+
export function fromPaper(length, unit, view) {
|
|
30
|
+
// The arguments are read as unknown, because a parameter that failed its type is a message.
|
|
31
|
+
const paper = length;
|
|
32
|
+
const { ratio, units } = view;
|
|
33
|
+
const from = unit === "in" || unit === "mm" ? SIZES[unit] : undefined;
|
|
34
|
+
const to = typeof units === "string" && Object.hasOwn(SIZES, units) ? SIZES[units] : undefined;
|
|
35
|
+
if (!from)
|
|
36
|
+
throw new Error(`The paper unit must be "in" or "mm", not ${JSON.stringify(unit)}`);
|
|
37
|
+
if (!to)
|
|
38
|
+
throw new Error(`Unknown units: ${JSON.stringify(units)}`);
|
|
39
|
+
if (typeof paper !== "number" || !Number.isFinite(paper)) {
|
|
40
|
+
throw new Error("The paper length must be a finite number");
|
|
41
|
+
}
|
|
42
|
+
if (typeof ratio !== "number" || !Number.isFinite(ratio)) {
|
|
43
|
+
throw new Error("The ratio must be a finite number");
|
|
44
|
+
}
|
|
45
|
+
// Multiplying before dividing keeps 3/32 in at 96 in feet at exactly 0.75.
|
|
46
|
+
const model = paper * ratio * from[1];
|
|
47
|
+
const sameSystem = from[0] === to[0];
|
|
48
|
+
const converted = sameSystem
|
|
49
|
+
? model
|
|
50
|
+
: from[0] === "imperial"
|
|
51
|
+
? model * MM_PER_INCH
|
|
52
|
+
: model / MM_PER_INCH;
|
|
53
|
+
const result = converted / to[1];
|
|
54
|
+
const problem = paperLengthProblem(paper, ratio, result);
|
|
55
|
+
if (problem)
|
|
56
|
+
throw new Error(problem);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
package/dist/rules.d.ts
CHANGED
|
@@ -1,27 +1,75 @@
|
|
|
1
1
|
import type { DxfVersion } from "./drawing.ts";
|
|
2
|
+
import { BUILT_IN_LINETYPES } from "./linetypes.ts";
|
|
2
3
|
import { type REJECTED_COPTIC, type REJECTED_FORMAT, type REJECTED_GEORGIAN, type REJECTED_GLAGOLITIC, type REJECTED_LETTERLIKE, type REJECTED_PRIVATE } from "./layers.ts";
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
declare const LAYER_NAMES: {
|
|
5
|
+
readonly empty: "Layer names cannot be empty";
|
|
6
|
+
readonly chars: 'Layer names cannot contain < > / \\ " : ; ? * | = ` ^ , or line breaks';
|
|
7
|
+
readonly rejected: "Layer names cannot contain a character AutoCAD rejects or replaces in names, such as a zero-width space or the ohm sign U+2126. docs/layer-names.md in the tsdraft repository lists them";
|
|
8
|
+
readonly edge: "Layer names cannot start or end with a space";
|
|
9
|
+
readonly length: "Layer names cannot be longer than 255 characters";
|
|
10
|
+
};
|
|
11
|
+
declare const LINETYPE_NAMES: {
|
|
12
|
+
readonly empty: "Linetype names cannot be empty";
|
|
13
|
+
readonly chars: 'Linetype names cannot contain < > / \\ " : ; ? * | = ` ^ , or line breaks';
|
|
14
|
+
readonly rejected: "Linetype names cannot contain a character AutoCAD rejects or replaces in names, such as a zero-width space or the ohm sign U+2126. docs/layer-names.md in the tsdraft repository lists them";
|
|
15
|
+
readonly edge: "Linetype names cannot start or end with a space";
|
|
16
|
+
readonly length: "Linetype names cannot be longer than 255 characters";
|
|
17
|
+
};
|
|
18
|
+
type NameMessages = typeof LAYER_NAMES | typeof LINETYPE_NAMES;
|
|
7
19
|
declare const NAME_R12_CHARS = "R12 layer names can only use letters, digits, $, - and _. Use DXF version \"R2018\" for other characters";
|
|
8
20
|
declare const NAME_R12_LENGTH = "R12 layer names cannot be longer than 31 characters. Use DXF version \"R2018\" for longer names";
|
|
9
21
|
declare const COLOR = "A layer color must be an AutoCAD Color Index integer from 1 to 255";
|
|
10
22
|
declare const POSITIVE = "This value must be greater than 0";
|
|
11
23
|
declare const WRITTEN_AS_ZERO = "This value is written as 0, because tsdraft writes 6 decimals. Use 0.000001 or more";
|
|
12
24
|
declare const TOO_LARGE = "This value must be under 1e100, because AutoCAD reads only two exponent digits from DXF and would take 1e+100 for 1e+10";
|
|
25
|
+
declare const PAPER_LENGTH = "The paper length must be greater than 0";
|
|
26
|
+
declare const RATIO = "The ratio must be greater than 0";
|
|
27
|
+
declare const TEXT_CONTROL = "Text must be a single line with no control characters";
|
|
28
|
+
declare const TEXT_PRIVATE_USE = "Text cannot contain the private-use characters U+E800 to U+E8FF, because AutoCAD replaces them when it reads DXF";
|
|
29
|
+
declare const R12_LINETYPES = "R12 drawings have no linetypes but Continuous, and no linetype scale. Use DXF version \"R2018\" for linetypes";
|
|
30
|
+
declare const R12_LINEWEIGHTS = "R12 drawings have no lineweights. Use DXF version \"R2018\" for lineweights";
|
|
31
|
+
declare const R12_ENTITY_STYLE = "R12 entities take no linetype or lineweight of their own. Use DXF version \"R2018\" for an entity linetype or lineweight";
|
|
32
|
+
declare const R12_LAYER_STATES = "tsdraft writes no layer states to R12 drawings. Use DXF version \"R2018\" for layers that are off, frozen, locked or not plotted";
|
|
33
|
+
declare const LINEWEIGHT = "A lineweight must be one of AutoCAD's, in millimetres: 0, 0.05, 0.09, 0.13, 0.15, 0.18, 0.2, 0.25, 0.3, 0.35, 0.4, 0.5, 0.53, 0.6, 0.7, 0.8, 0.9, 1, 1.06, 1.2, 1.4, 1.58, 2 or 2.11";
|
|
34
|
+
declare const FROZEN_CURRENT = "Layer \"0\" cannot be frozen: it is the current layer, and AutoCAD does not freeze the current layer";
|
|
35
|
+
declare const LAYER_LINETYPE = "A layer's linetype cannot be ByLayer or ByBlock. AutoCAD's AUDIT reports a layer with either";
|
|
36
|
+
declare const BUILT_IN = "Continuous, ByLayer and ByBlock are in every drawing and cannot be defined. AutoCAD keeps its own and drops the definition";
|
|
37
|
+
declare const PATTERN_COUNT = "A linetype pattern has 2 to 12 lengths, or none for a solid line. AutoCAD's AUDIT reports a pattern of one length, and AutoCAD discards a drawing with a pattern of more than 12";
|
|
38
|
+
declare const PATTERN_WRITTEN_AS_ZERO = "A dash or gap of this length is written as 0, because tsdraft writes 6 decimals, and would draw as a dot. Use 0 for a dot, or a length of 0.000001 or more";
|
|
39
|
+
declare const ID_EMPTY = "An id cannot be empty";
|
|
40
|
+
declare const ID_CHARS = "An id can only use the letters A to Z and a to z, digits, ., - and _";
|
|
41
|
+
declare const ID_LENGTH = "An id cannot be longer than 64 characters";
|
|
13
42
|
type ForbiddenChar = "<" | ">" | "/" | "\\" | '"' | ":" | ";" | "?" | "*" | "|" | "=" | "`" | "^" | "," | "\n" | "\r" | "\t";
|
|
14
43
|
type Chars<S extends string, Found = never> = S extends `${infer C}${infer Rest}` ? Chars<Rest, Found | C> : Found;
|
|
15
44
|
type R12Char = Chars<"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$_-">;
|
|
16
45
|
type RejectedChar = Chars<typeof REJECTED_FORMAT> | Chars<typeof REJECTED_LETTERLIKE> | Chars<typeof REJECTED_GLAGOLITIC> | Chars<typeof REJECTED_COPTIC> | Chars<typeof REJECTED_GEORGIAN> | Chars<typeof REJECTED_PRIVATE>;
|
|
17
46
|
/** Walks the name one character at a time, counting, so it can check both the characters and the length. */
|
|
18
47
|
type R12Name<N extends string, Rest extends string = N, Count extends 0[] = []> = Count["length"] extends 32 ? typeof NAME_R12_LENGTH : Rest extends `${infer C}${infer Tail}` ? C extends R12Char ? R12Name<N, Tail, [...Count, 0]> : typeof NAME_R12_CHARS : N;
|
|
48
|
+
/** Resolves to `Valid` when `N` passes the rules layer and linetype names share, and to the message otherwise. */
|
|
49
|
+
type NameCheck<N extends string, M extends NameMessages, Valid> = N extends "" ? M["empty"] : N extends `${string}${ForbiddenChar}${string}` ? M["chars"] : N extends `${string}${RejectedChar}${string}` ? M["rejected"] : N extends ` ${string}` | `${string} ` ? M["edge"] : Valid;
|
|
19
50
|
/**
|
|
20
51
|
* Resolves to `N` when it is a valid layer name for DXF version `V`, and to the
|
|
21
52
|
* error message otherwise, so the compiler reports the reason. Names that are
|
|
22
53
|
* not literals pass the compiler and are checked when the code runs.
|
|
23
54
|
*/
|
|
24
|
-
export type LayerName<N extends string, V extends DxfVersion> = string extends N ? N : N
|
|
55
|
+
export type LayerName<N extends string, V extends DxfVersion> = string extends N ? N : NameCheck<N, typeof LAYER_NAMES, V extends "R12" ? R12Name<N> : N>;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves to `N` when it is a valid name for a linetype to be used by, and to
|
|
58
|
+
* the error message otherwise. AutoCAD holds linetype names to the rules of
|
|
59
|
+
* layer names, apart from R12's, since R12 drawings have no linetypes.
|
|
60
|
+
*/
|
|
61
|
+
export type LinetypeName<N extends string> = string extends N ? N : NameCheck<N, typeof LINETYPE_NAMES, N>;
|
|
62
|
+
type IdChar = Exclude<R12Char, "$"> | ".";
|
|
63
|
+
/** Walks the id one character at a time, counting, as `R12Name` walks a layer name. */
|
|
64
|
+
type IdCheck<I extends string, Rest extends string = I, Count extends 0[] = []> = Count["length"] extends 65 ? typeof ID_LENGTH : Rest extends `${infer C}${infer Tail}` ? C extends IdChar ? IdCheck<I, Tail, [...Count, 0]> : typeof ID_CHARS : I;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves to `I` when it is a valid entity id, and to the error message otherwise: 1 to 64
|
|
67
|
+
* characters, each a letter A to Z or a to z, a digit, `.`, `-` or `_`. An id that is not a
|
|
68
|
+
* literal, such as `` `door-${n}` ``, passes the compiler: the first branch takes every type
|
|
69
|
+
* that is not a union of literals. It is checked when the code runs, as is whether the drawing
|
|
70
|
+
* already has the id.
|
|
71
|
+
*/
|
|
72
|
+
export type EntityId<I extends string> = {} extends Record<I, never> ? I : I extends "" ? typeof ID_EMPTY : IdCheck<I>;
|
|
25
73
|
type Enumerate<N extends number, A extends number[] = []> = A["length"] extends N ? A[number] : Enumerate<N, [...A, A["length"]]>;
|
|
26
74
|
/** AutoCAD Color Index: an integer from 1 to 255. */
|
|
27
75
|
export type Aci = Exclude<Enumerate<256>, 0>;
|
|
@@ -42,8 +90,66 @@ type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
|
42
90
|
* prints a third exponent digit as the writers do.
|
|
43
91
|
*/
|
|
44
92
|
export type Positive<N extends number> = number extends N ? N : `${N}` extends `-${string}` | "0" ? typeof POSITIVE : WrittenAsZero<`${N}`> extends true ? typeof WRITTEN_AS_ZERO : `${N}` extends `${string}e+${Digit}${Digit}${Digit}` ? typeof TOO_LARGE : N;
|
|
93
|
+
/**
|
|
94
|
+
* Resolves to `N` when it is greater than 0, and to `Message` otherwise. For a
|
|
95
|
+
* number that is worked with before anything is written, where `Positive`
|
|
96
|
+
* would refuse a small value for the 6 decimals.
|
|
97
|
+
*/
|
|
98
|
+
type AboveZero<N extends number, Message extends string> = number extends N ? N : `${N}` extends `-${string}` | "0" ? Message : N;
|
|
99
|
+
/** Resolves to `N` when it is a length on paper, and to the error message otherwise. */
|
|
100
|
+
export type PaperLength<N extends number> = AboveZero<N, typeof PAPER_LENGTH>;
|
|
101
|
+
/** Resolves to `N` when it is a scale ratio, and to the error message otherwise. */
|
|
102
|
+
export type Ratio<N extends number> = AboveZero<N, typeof RATIO>;
|
|
103
|
+
type BuiltInName = Lowercase<(typeof BUILT_IN_LINETYPES)[number]>;
|
|
104
|
+
/**
|
|
105
|
+
* Resolves to `N` when it is a valid name for a new linetype, and to the error
|
|
106
|
+
* message otherwise: a name that is valid to use, and not one of the linetypes
|
|
107
|
+
* every drawing has.
|
|
108
|
+
*/
|
|
109
|
+
export type NewLinetypeName<N extends string> = string extends N ? N : Lowercase<N> extends BuiltInName ? typeof BUILT_IN : LinetypeName<N>;
|
|
110
|
+
/** Resolves to `N` when it is a valid linetype for a layer, and to the error message otherwise. */
|
|
111
|
+
export type LayerLinetypeName<N extends string> = string extends N ? N : Lowercase<N> extends "bylayer" | "byblock" ? typeof LAYER_LINETYPE : LinetypeName<N>;
|
|
112
|
+
type Unsigned<S extends string> = S extends `-${infer A}` ? A : S;
|
|
113
|
+
/**
|
|
114
|
+
* The message for each literal pattern length the writers cannot keep: one
|
|
115
|
+
* written as 0 that is not 0, or one of 1e100 or more in size.
|
|
116
|
+
*/
|
|
117
|
+
type LengthProblem<N extends number> = N extends unknown ? number extends N ? never : Unsigned<`${N}`> extends "0" ? never : WrittenAsZero<Unsigned<`${N}`>> extends true ? typeof PATTERN_WRITTEN_AS_ZERO : Unsigned<`${N}`> extends `${string}e+${Digit}${Digit}${Digit}` ? typeof TOO_LARGE : never : never;
|
|
118
|
+
/** The message for the first length of `P` with a problem, in the order `linetypeProblem` checks them. */
|
|
119
|
+
type FirstLengthProblem<P extends readonly number[]> = P extends readonly [
|
|
120
|
+
infer N extends number,
|
|
121
|
+
...infer Rest extends readonly number[]
|
|
122
|
+
] ? [LengthProblem<N>] extends [never] ? FirstLengthProblem<Rest> : LengthProblem<N> : never;
|
|
123
|
+
/**
|
|
124
|
+
* Resolves to `P` when it is a pattern AutoCAD accepts, and to the error
|
|
125
|
+
* message otherwise. A pattern that is not a tuple, and the total of the
|
|
126
|
+
* lengths, which the compiler cannot add, are checked when the code runs.
|
|
127
|
+
*/
|
|
128
|
+
export type Pattern<P extends readonly number[]> = number extends P["length"] ? P : P["length"] extends 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 ? [FirstLengthProblem<P>] extends [never] ? P : FirstLengthProblem<P> : typeof PATTERN_COUNT;
|
|
129
|
+
type ControlChar = Chars<"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f\u007f">;
|
|
130
|
+
/**
|
|
131
|
+
* Resolves to `D` when it is a linetype description AutoCAD keeps, and to the
|
|
132
|
+
* error message otherwise. Its length, and characters above U+FFFF, are checked
|
|
133
|
+
* when the code runs.
|
|
134
|
+
*/
|
|
135
|
+
export type Description<D extends string> = string extends D ? D : D extends `${string}${ControlChar}${string}` ? typeof TEXT_CONTROL : D extends `${string}${Chars<typeof REJECTED_PRIVATE>}${string}` ? typeof TEXT_PRIVATE_USE : D;
|
|
136
|
+
/** A lineweight AutoCAD offers, in millimetres. */
|
|
137
|
+
export type LineweightMm = 0 | 0.05 | 0.09 | 0.13 | 0.15 | 0.18 | 0.2 | 0.25 | 0.3 | 0.35 | 0.4 | 0.5 | 0.53 | 0.6 | 0.7 | 0.8 | 0.9 | 1 | 1.06 | 1.2 | 1.4 | 1.58 | 2 | 2.11;
|
|
138
|
+
/** Resolves to `W` when it is one of AutoCAD's lineweights, and to the error message otherwise. */
|
|
139
|
+
export type LineweightOf<W extends number> = number extends W ? W : W extends LineweightMm ? W : typeof LINEWEIGHT;
|
|
140
|
+
/** The message for each feature an R12 drawing cannot have, as a type. */
|
|
141
|
+
export type R12Linetypes = typeof R12_LINETYPES;
|
|
142
|
+
export type R12Lineweights = typeof R12_LINEWEIGHTS;
|
|
143
|
+
export type R12EntityStyle = typeof R12_ENTITY_STYLE;
|
|
144
|
+
export type R12LayerStates = typeof R12_LAYER_STATES;
|
|
145
|
+
export type FrozenCurrent = typeof FROZEN_CURRENT;
|
|
45
146
|
/** Returns what is wrong with a layer name for a DXF version, or undefined when it is valid. */
|
|
46
147
|
export declare function layerNameProblem(name: string, version: DxfVersion): string | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Returns what is wrong with a linetype name, or undefined when it is valid.
|
|
150
|
+
* The name may be one of the linetypes every drawing has.
|
|
151
|
+
*/
|
|
152
|
+
export declare function linetypeNameProblem(name: string): string | undefined;
|
|
47
153
|
/**
|
|
48
154
|
* Returns what is wrong with a drawing that has both names as layers, or
|
|
49
155
|
* undefined when the two can stand together. AutoCAD looks layers up one way
|
|
@@ -51,15 +157,60 @@ export declare function layerNameProblem(name: string, version: DxfVersion): str
|
|
|
51
157
|
* layers to AutoCAD and one duplicate name to AUDIT: `ΟΔΟΣ` and `οδος`,
|
|
52
158
|
* `straße` and `strasse`, a composed é and a decomposed one, and a name with
|
|
53
159
|
* and without a soft hyphen. `layerAuditKey` lists the kinds this covers,
|
|
54
|
-
* which are
|
|
55
|
-
*
|
|
56
|
-
*
|
|
160
|
+
* which are not all that AUDIT reports. Names that are one layer to AutoCAD
|
|
161
|
+
* are not this function's concern. The rule compares two names, so it has no
|
|
162
|
+
* type.
|
|
57
163
|
*
|
|
58
164
|
* @param name - The name of the layer being checked.
|
|
59
165
|
* @param other - The name of another layer in the drawing.
|
|
166
|
+
* @param kind - Whether the names are of layers or of linetypes, which AutoCAD compares alike.
|
|
60
167
|
* @returns The problem, or undefined.
|
|
61
168
|
*/
|
|
62
|
-
export declare function layerTwinProblem(name: string, other: string): string | undefined;
|
|
169
|
+
export declare function layerTwinProblem(name: string, other: string, kind?: "layer" | "linetype"): string | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* Returns what is wrong with a linetype definition, or undefined when it is
|
|
172
|
+
* valid. It takes `unknown`s so that `lint` can report a drawing built by hand
|
|
173
|
+
* with a field of the wrong type.
|
|
174
|
+
*/
|
|
175
|
+
export declare function linetypeProblem(name: unknown, description: unknown, pattern: unknown): string | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* Returns what is wrong with a layer or an entity that names a linetype the
|
|
178
|
+
* drawing does not have. The rule depends on the drawing, so it has no type.
|
|
179
|
+
*/
|
|
180
|
+
export declare function undefinedLinetypeProblem(name: string): string;
|
|
181
|
+
/** Returns what is wrong with the linetype a layer names, or undefined when it can be a layer's. */
|
|
182
|
+
export declare function layerLinetypeProblem(name: string): string | undefined;
|
|
183
|
+
/**
|
|
184
|
+
* Returns what is wrong with a lineweight, or undefined when it is valid. A
|
|
185
|
+
* layer's lineweight may also be "Default", and an entity's "ByLayer",
|
|
186
|
+
* "ByBlock" or "Default". AutoCAD discards a drawing with an entity of any
|
|
187
|
+
* other lineweight, and gives a layer of another lineweight the default.
|
|
188
|
+
*
|
|
189
|
+
* @param value - The lineweight, in millimetres or by name.
|
|
190
|
+
* @param of - Whose lineweight it is.
|
|
191
|
+
* @returns The problem, or undefined.
|
|
192
|
+
*/
|
|
193
|
+
export declare function lineweightProblem(value: unknown, of: "layer" | "entity"): string | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Returns what is wrong with a layer's states, or undefined when AutoCAD takes
|
|
196
|
+
* them. tsdraft writes layer "0" as the current layer, and AutoCAD's AUDIT
|
|
197
|
+
* reports a drawing whose current layer is frozen.
|
|
198
|
+
*/
|
|
199
|
+
export declare function layerStateProblem(name: string, frozen: boolean | undefined): string | undefined;
|
|
200
|
+
/** Returns what is wrong with the value of a layer's `off`, `frozen`, `locked` or `plot`. */
|
|
201
|
+
export declare function layerFlagProblem(state: string, value: unknown): string | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Returns what is wrong with the global linetype scale, or undefined when it is
|
|
204
|
+
* valid. AutoCAD reads a scale of 0 or less, or one written as 0, as 1.
|
|
205
|
+
*/
|
|
206
|
+
export declare function linetypeScaleProblem(value: number): string | undefined;
|
|
207
|
+
/** The R12 message for a feature, for `lint` and the builder. */
|
|
208
|
+
export declare const R12_ONLY: {
|
|
209
|
+
readonly linetypes: "R12 drawings have no linetypes but Continuous, and no linetype scale. Use DXF version \"R2018\" for linetypes";
|
|
210
|
+
readonly lineweights: "R12 drawings have no lineweights. Use DXF version \"R2018\" for lineweights";
|
|
211
|
+
readonly layerStates: "tsdraft writes no layer states to R12 drawings. Use DXF version \"R2018\" for layers that are off, frozen, locked or not plotted";
|
|
212
|
+
readonly entityStyle: "R12 entities take no linetype or lineweight of their own. Use DXF version \"R2018\" for an entity linetype or lineweight";
|
|
213
|
+
};
|
|
63
214
|
/** Returns what is wrong with a layer color, or undefined when it is valid. */
|
|
64
215
|
export declare function layerColorProblem(color: number): string | undefined;
|
|
65
216
|
/**
|
|
@@ -73,6 +224,17 @@ export declare function layerColorProblem(color: number): string | undefined;
|
|
|
73
224
|
* @returns The problem, or undefined.
|
|
74
225
|
*/
|
|
75
226
|
export declare function sizeProblem(value: number): string | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* Returns what is wrong with a paper length, the ratio it plots at, or the
|
|
229
|
+
* length in drawing units they give, or undefined when the result can be
|
|
230
|
+
* written. The result is a size, so it is held to the limits of `sizeProblem`.
|
|
231
|
+
*
|
|
232
|
+
* @param length - The length on paper, which must be a finite number.
|
|
233
|
+
* @param ratio - The scale ratio, which must be a finite number.
|
|
234
|
+
* @param result - The length in drawing units.
|
|
235
|
+
* @returns The problem, or undefined.
|
|
236
|
+
*/
|
|
237
|
+
export declare function paperLengthProblem(length: number, ratio: number, result: number): string | undefined;
|
|
76
238
|
/**
|
|
77
239
|
* Returns what is wrong with the size of a number a drawing holds, or
|
|
78
240
|
* undefined when AutoCAD can read it. This goes for every number that is
|
|
@@ -106,6 +268,25 @@ export declare function arcProblem(startAngle: number, endAngle: number): string
|
|
|
106
268
|
* @returns Whether the arc is written with no length.
|
|
107
269
|
*/
|
|
108
270
|
export declare function arcIsWrittenAsPoint(startAngle: number, endAngle: number): boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Returns what is wrong with an entity id, or undefined when it is valid. It takes `unknown` so
|
|
273
|
+
* that `lint` can report a drawing built by hand with an id of the wrong type.
|
|
274
|
+
*/
|
|
275
|
+
export declare function idProblem(id: unknown): string | undefined;
|
|
276
|
+
/** The form two ids are compared in: `Door-1` and `door-1` are one id. */
|
|
277
|
+
export declare function idKey(id: string): string;
|
|
278
|
+
/**
|
|
279
|
+
* Returns what is wrong with a second entity that has an id the drawing already has. The rule
|
|
280
|
+
* depends on the drawing, so it has no type.
|
|
281
|
+
*
|
|
282
|
+
* @param id - The id of the second entity.
|
|
283
|
+
* @param first - The id as the first entity spells it.
|
|
284
|
+
*/
|
|
285
|
+
export declare function duplicateIdProblem(id: string, first: string): string;
|
|
286
|
+
/** Returns what is wrong with a drawing's format version, or undefined when tsdraft reads it. */
|
|
287
|
+
export declare function formatProblem(format: unknown): string | undefined;
|
|
288
|
+
/** A value of any type for a message: a string quoted, a number as it is, anything else by kind. */
|
|
289
|
+
export declare function shown(value: unknown): string;
|
|
109
290
|
/** Returns what is wrong with a single-line text value, or undefined when it is valid. */
|
|
110
291
|
export declare function textProblem(value: string): string | undefined;
|
|
111
292
|
/**
|