circuit-json-to-gerber 0.0.3 → 0.0.5
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/dist/index.d.ts +187 -7
- package/dist/index.js +517 -209
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,186 @@
|
|
|
1
1
|
import { AnyZodObject, z } from 'zod';
|
|
2
2
|
import { AnySoupElement } from '@tscircuit/soup';
|
|
3
3
|
|
|
4
|
+
interface ExcellonDrillCommandDef<K extends string, T extends AnyZodObject | z.ZodIntersection<any, any>> {
|
|
5
|
+
command_code: K;
|
|
6
|
+
schema: T;
|
|
7
|
+
stringify: (c: z.infer<T>) => string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const excellon_drill_command_map: {
|
|
11
|
+
M48: ExcellonDrillCommandDef<"M48", z.ZodObject<{
|
|
12
|
+
command_code: z.ZodDefault<z.ZodLiteral<"M48">>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
command_code: "M48";
|
|
15
|
+
}, {
|
|
16
|
+
command_code?: "M48" | undefined;
|
|
17
|
+
}>>;
|
|
18
|
+
M95: ExcellonDrillCommandDef<"M95", z.ZodObject<{
|
|
19
|
+
command_code: z.ZodDefault<z.ZodLiteral<"M95">>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
command_code: "M95";
|
|
22
|
+
}, {
|
|
23
|
+
command_code?: "M95" | undefined;
|
|
24
|
+
}>>;
|
|
25
|
+
FMAT: ExcellonDrillCommandDef<"FMAT", z.ZodObject<{
|
|
26
|
+
command_code: z.ZodDefault<z.ZodLiteral<"FMAT">>;
|
|
27
|
+
format: z.ZodNumber;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
command_code: "FMAT";
|
|
30
|
+
format: number;
|
|
31
|
+
}, {
|
|
32
|
+
format: number;
|
|
33
|
+
command_code?: "FMAT" | undefined;
|
|
34
|
+
}>>;
|
|
35
|
+
unit_format: ExcellonDrillCommandDef<"unit_format", z.ZodObject<{
|
|
36
|
+
command_code: z.ZodDefault<z.ZodLiteral<"unit_format">>;
|
|
37
|
+
unit: z.ZodUnion<[z.ZodLiteral<"INCH">, z.ZodLiteral<"METRIC">]>;
|
|
38
|
+
lz: z.ZodDefault<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"LZ">, z.ZodLiteral<"TZ">]>>>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
command_code: "unit_format";
|
|
41
|
+
unit: "INCH" | "METRIC";
|
|
42
|
+
lz: "LZ" | "TZ" | null;
|
|
43
|
+
}, {
|
|
44
|
+
unit: "INCH" | "METRIC";
|
|
45
|
+
command_code?: "unit_format" | undefined;
|
|
46
|
+
lz?: "LZ" | "TZ" | null | undefined;
|
|
47
|
+
}>>;
|
|
48
|
+
aper_function_header: ExcellonDrillCommandDef<"aper_function_header", z.ZodObject<{
|
|
49
|
+
command_code: z.ZodDefault<z.ZodLiteral<"aper_function_header">>;
|
|
50
|
+
is_plated: z.ZodBoolean;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
command_code: "aper_function_header";
|
|
53
|
+
is_plated: boolean;
|
|
54
|
+
}, {
|
|
55
|
+
is_plated: boolean;
|
|
56
|
+
command_code?: "aper_function_header" | undefined;
|
|
57
|
+
}>>;
|
|
58
|
+
percent_sign: ExcellonDrillCommandDef<"percent_sign", z.ZodObject<{
|
|
59
|
+
command_code: z.ZodDefault<z.ZodLiteral<"percent_sign">>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
command_code: "percent_sign";
|
|
62
|
+
}, {
|
|
63
|
+
command_code?: "percent_sign" | undefined;
|
|
64
|
+
}>>;
|
|
65
|
+
T: ExcellonDrillCommandDef<"define_tool", z.ZodObject<{
|
|
66
|
+
command_code: z.ZodDefault<z.ZodLiteral<"define_tool">>;
|
|
67
|
+
tool_number: z.ZodNumber;
|
|
68
|
+
diameter: z.ZodNumber;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
command_code: "define_tool";
|
|
71
|
+
tool_number: number;
|
|
72
|
+
diameter: number;
|
|
73
|
+
}, {
|
|
74
|
+
tool_number: number;
|
|
75
|
+
diameter: number;
|
|
76
|
+
command_code?: "define_tool" | undefined;
|
|
77
|
+
}>>;
|
|
78
|
+
define_tool: ExcellonDrillCommandDef<"define_tool", z.ZodObject<{
|
|
79
|
+
command_code: z.ZodDefault<z.ZodLiteral<"define_tool">>;
|
|
80
|
+
tool_number: z.ZodNumber;
|
|
81
|
+
diameter: z.ZodNumber;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
command_code: "define_tool";
|
|
84
|
+
tool_number: number;
|
|
85
|
+
diameter: number;
|
|
86
|
+
}, {
|
|
87
|
+
tool_number: number;
|
|
88
|
+
diameter: number;
|
|
89
|
+
command_code?: "define_tool" | undefined;
|
|
90
|
+
}>>;
|
|
91
|
+
use_tool: ExcellonDrillCommandDef<"use_tool", z.ZodObject<{
|
|
92
|
+
command_code: z.ZodDefault<z.ZodLiteral<"use_tool">>;
|
|
93
|
+
tool_number: z.ZodNumber;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
command_code: "use_tool";
|
|
96
|
+
tool_number: number;
|
|
97
|
+
}, {
|
|
98
|
+
tool_number: number;
|
|
99
|
+
command_code?: "use_tool" | undefined;
|
|
100
|
+
}>>;
|
|
101
|
+
G90: ExcellonDrillCommandDef<"G90", z.ZodObject<{
|
|
102
|
+
command_code: z.ZodDefault<z.ZodLiteral<"G90">>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
command_code: "G90";
|
|
105
|
+
}, {
|
|
106
|
+
command_code?: "G90" | undefined;
|
|
107
|
+
}>>;
|
|
108
|
+
G05: ExcellonDrillCommandDef<"G05", z.ZodObject<{
|
|
109
|
+
command_code: z.ZodDefault<z.ZodLiteral<"G05">>;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
command_code: "G05";
|
|
112
|
+
}, {
|
|
113
|
+
command_code?: "G05" | undefined;
|
|
114
|
+
}>>;
|
|
115
|
+
M30: ExcellonDrillCommandDef<"M30", z.ZodObject<{
|
|
116
|
+
command_code: z.ZodDefault<z.ZodLiteral<"M30">>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
command_code: "M30";
|
|
119
|
+
}, {
|
|
120
|
+
command_code?: "M30" | undefined;
|
|
121
|
+
}>>;
|
|
122
|
+
drill_at: ExcellonDrillCommandDef<"drill_at", z.ZodObject<{
|
|
123
|
+
command_code: z.ZodDefault<z.ZodLiteral<"drill_at">>;
|
|
124
|
+
x: z.ZodNumber;
|
|
125
|
+
y: z.ZodNumber;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
command_code: "drill_at";
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
}, {
|
|
131
|
+
x: number;
|
|
132
|
+
y: number;
|
|
133
|
+
command_code?: "drill_at" | undefined;
|
|
134
|
+
}>>;
|
|
135
|
+
header_comment: ExcellonDrillCommandDef<"header_comment", z.ZodObject<{
|
|
136
|
+
command_code: z.ZodDefault<z.ZodLiteral<"header_comment">>;
|
|
137
|
+
text: z.ZodString;
|
|
138
|
+
}, "strip", z.ZodTypeAny, {
|
|
139
|
+
command_code: "header_comment";
|
|
140
|
+
text: string;
|
|
141
|
+
}, {
|
|
142
|
+
text: string;
|
|
143
|
+
command_code?: "header_comment" | undefined;
|
|
144
|
+
}>>;
|
|
145
|
+
header_attribute: ExcellonDrillCommandDef<"header_attribute", z.ZodObject<{
|
|
146
|
+
command_code: z.ZodDefault<z.ZodLiteral<"header_attribute">>;
|
|
147
|
+
attribute_name: z.ZodString;
|
|
148
|
+
attribute_value: z.ZodString;
|
|
149
|
+
}, "strip", z.ZodTypeAny, {
|
|
150
|
+
command_code: "header_attribute";
|
|
151
|
+
attribute_name: string;
|
|
152
|
+
attribute_value: string;
|
|
153
|
+
}, {
|
|
154
|
+
attribute_name: string;
|
|
155
|
+
attribute_value: string;
|
|
156
|
+
command_code?: "header_attribute" | undefined;
|
|
157
|
+
}>>;
|
|
158
|
+
rewind: ExcellonDrillCommandDef<"rewind", z.ZodObject<{
|
|
159
|
+
command_code: z.ZodDefault<z.ZodLiteral<"rewind">>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
command_code: "rewind";
|
|
162
|
+
}, {
|
|
163
|
+
command_code?: "rewind" | undefined;
|
|
164
|
+
}>>;
|
|
165
|
+
};
|
|
166
|
+
type AnyExcellonDrillCommand = z.infer<(typeof excellon_drill_command_map)[keyof typeof excellon_drill_command_map]["schema"]>;
|
|
167
|
+
|
|
168
|
+
declare const stringifyExcellonDrill: (commands: Array<AnyExcellonDrillCommand>) => string;
|
|
169
|
+
|
|
170
|
+
declare const convertSoupToExcellonDrillCommands: ({ soup, is_plated, flip_y_axis, }: {
|
|
171
|
+
soup: Array<AnySoupElement>;
|
|
172
|
+
is_plated: boolean;
|
|
173
|
+
flip_y_axis?: boolean;
|
|
174
|
+
}) => Array<AnyExcellonDrillCommand>;
|
|
175
|
+
|
|
176
|
+
declare class ExcellonDrillBuilder {
|
|
177
|
+
commands: Array<AnyExcellonDrillCommand>;
|
|
178
|
+
constructor();
|
|
179
|
+
add<T extends keyof typeof excellon_drill_command_map>(cmd: T, props: z.input<(typeof excellon_drill_command_map)[T]["schema"]>): ExcellonDrillBuilder;
|
|
180
|
+
build(): Array<AnyExcellonDrillCommand>;
|
|
181
|
+
}
|
|
182
|
+
declare const excellonDrill: () => ExcellonDrillBuilder;
|
|
183
|
+
|
|
4
184
|
interface GerberCommandDef<K extends string, T extends AnyZodObject | z.ZodIntersection<any, any>> {
|
|
5
185
|
command_code: K;
|
|
6
186
|
schema: T;
|
|
@@ -153,7 +333,7 @@ declare const gerber_command_map: {
|
|
|
153
333
|
y_decimal_digits: z.ZodDefault<z.ZodNumber>;
|
|
154
334
|
}, "strip", z.ZodTypeAny, {
|
|
155
335
|
command_code: "FS";
|
|
156
|
-
zero_omission_mode: "
|
|
336
|
+
zero_omission_mode: "T" | "L" | null;
|
|
157
337
|
coordinate_notation: "A" | "I";
|
|
158
338
|
x_integer_digits: number;
|
|
159
339
|
x_decimal_digits: number;
|
|
@@ -161,7 +341,7 @@ declare const gerber_command_map: {
|
|
|
161
341
|
y_decimal_digits: number;
|
|
162
342
|
}, {
|
|
163
343
|
command_code?: "FS" | undefined;
|
|
164
|
-
zero_omission_mode?: "
|
|
344
|
+
zero_omission_mode?: "T" | "L" | null | undefined;
|
|
165
345
|
coordinate_notation?: "A" | "I" | undefined;
|
|
166
346
|
x_integer_digits?: number | undefined;
|
|
167
347
|
x_decimal_digits?: number | undefined;
|
|
@@ -186,12 +366,12 @@ declare const gerber_command_map: {
|
|
|
186
366
|
diameter: z.ZodNumber;
|
|
187
367
|
hole_diameter: z.ZodOptional<z.ZodNumber>;
|
|
188
368
|
}, "strip", z.ZodTypeAny, {
|
|
189
|
-
standard_template_code: "C";
|
|
190
369
|
diameter: number;
|
|
370
|
+
standard_template_code: "C";
|
|
191
371
|
hole_diameter?: number | undefined;
|
|
192
372
|
}, {
|
|
193
|
-
standard_template_code: "C";
|
|
194
373
|
diameter: number;
|
|
374
|
+
standard_template_code: "C";
|
|
195
375
|
hole_diameter?: number | undefined;
|
|
196
376
|
}>, z.ZodObject<{
|
|
197
377
|
standard_template_code: z.ZodLiteral<"R">;
|
|
@@ -233,14 +413,14 @@ declare const gerber_command_map: {
|
|
|
233
413
|
standard_template_code: "P";
|
|
234
414
|
outer_diameter: number;
|
|
235
415
|
number_of_vertices: number;
|
|
236
|
-
rotation?: number | undefined;
|
|
237
416
|
hole_diameter?: number | undefined;
|
|
417
|
+
rotation?: number | undefined;
|
|
238
418
|
}, {
|
|
239
419
|
standard_template_code: "P";
|
|
240
420
|
outer_diameter: number;
|
|
241
421
|
number_of_vertices: number;
|
|
242
|
-
rotation?: number | undefined;
|
|
243
422
|
hole_diameter?: number | undefined;
|
|
423
|
+
rotation?: number | undefined;
|
|
244
424
|
}>]>, z.ZodObject<{
|
|
245
425
|
command_code: z.ZodDefault<z.ZodLiteral<"ADD">>;
|
|
246
426
|
aperture_number: z.ZodNumber;
|
|
@@ -340,4 +520,4 @@ declare const convertSoupToGerberCommands: (soup: AnySoupElement[], opts?: {
|
|
|
340
520
|
flip_y_axis?: boolean;
|
|
341
521
|
}) => LayerToGerberCommandsMap;
|
|
342
522
|
|
|
343
|
-
export { convertSoupToGerberCommands, gerberBuilder, stringifyGerberCommand, stringifyGerberCommandLayers, stringifyGerberCommands };
|
|
523
|
+
export { convertSoupToExcellonDrillCommands, convertSoupToGerberCommands, excellonDrill, gerberBuilder, stringifyExcellonDrill, stringifyGerberCommand, stringifyGerberCommandLayers, stringifyGerberCommands };
|