circuit-json-to-gerber 0.0.4 → 0.0.6

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 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: "L" | "T" | null;
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?: "L" | "T" | null | undefined;
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;
@@ -284,12 +464,12 @@ declare const gerber_command_map: {
284
464
  }>>;
285
465
  readonly set_unit: GerberCommandDef<"MO", z.ZodObject<{
286
466
  command_code: z.ZodDefault<z.ZodLiteral<"MO">>;
287
- unit: z.ZodEnum<["mm", "in"]>;
467
+ unit: z.ZodEnum<["MM", "in"]>;
288
468
  }, "strip", z.ZodTypeAny, {
289
469
  command_code: "MO";
290
- unit: "mm" | "in";
470
+ unit: "MM" | "in";
291
471
  }, {
292
- unit: "mm" | "in";
472
+ unit: "MM" | "in";
293
473
  command_code?: "MO" | undefined;
294
474
  }>>;
295
475
  readonly set_layer_polarity: GerberCommandDef<"LP", z.ZodObject<{
@@ -340,176 +520,4 @@ declare const convertSoupToGerberCommands: (soup: AnySoupElement[], opts?: {
340
520
  flip_y_axis?: boolean;
341
521
  }) => LayerToGerberCommandsMap;
342
522
 
343
- interface ExcellonDrillCommandDef<K extends string, T extends AnyZodObject | z.ZodIntersection<any, any>> {
344
- command_code: K;
345
- schema: T;
346
- stringify: (c: z.infer<T>) => string;
347
- }
348
-
349
- declare const excellon_drill_command_map: {
350
- M48: ExcellonDrillCommandDef<"M48", z.ZodObject<{
351
- command_code: z.ZodDefault<z.ZodLiteral<"M48">>;
352
- }, "strip", z.ZodTypeAny, {
353
- command_code: "M48";
354
- }, {
355
- command_code?: "M48" | undefined;
356
- }>>;
357
- M95: ExcellonDrillCommandDef<"M95", z.ZodObject<{
358
- command_code: z.ZodDefault<z.ZodLiteral<"M95">>;
359
- }, "strip", z.ZodTypeAny, {
360
- command_code: "M95";
361
- }, {
362
- command_code?: "M95" | undefined;
363
- }>>;
364
- FMAT: ExcellonDrillCommandDef<"FMAT", z.ZodObject<{
365
- command_code: z.ZodDefault<z.ZodLiteral<"FMAT">>;
366
- format: z.ZodNumber;
367
- }, "strip", z.ZodTypeAny, {
368
- command_code: "FMAT";
369
- format: number;
370
- }, {
371
- format: number;
372
- command_code?: "FMAT" | undefined;
373
- }>>;
374
- unit_format: ExcellonDrillCommandDef<"unit_format", z.ZodObject<{
375
- command_code: z.ZodDefault<z.ZodLiteral<"unit_format">>;
376
- unit: z.ZodUnion<[z.ZodLiteral<"INCH">, z.ZodLiteral<"METRIC">]>;
377
- lz: z.ZodDefault<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"LZ">, z.ZodLiteral<"TZ">]>>>;
378
- }, "strip", z.ZodTypeAny, {
379
- command_code: "unit_format";
380
- unit: "INCH" | "METRIC";
381
- lz: "LZ" | "TZ" | null;
382
- }, {
383
- unit: "INCH" | "METRIC";
384
- command_code?: "unit_format" | undefined;
385
- lz?: "LZ" | "TZ" | null | undefined;
386
- }>>;
387
- aper_function_header: ExcellonDrillCommandDef<"aper_function_header", z.ZodObject<{
388
- command_code: z.ZodDefault<z.ZodLiteral<"aper_function_header">>;
389
- is_plated: z.ZodBoolean;
390
- }, "strip", z.ZodTypeAny, {
391
- command_code: "aper_function_header";
392
- is_plated: boolean;
393
- }, {
394
- is_plated: boolean;
395
- command_code?: "aper_function_header" | undefined;
396
- }>>;
397
- percent_sign: ExcellonDrillCommandDef<"percent_sign", z.ZodObject<{
398
- command_code: z.ZodDefault<z.ZodLiteral<"percent_sign">>;
399
- }, "strip", z.ZodTypeAny, {
400
- command_code: "percent_sign";
401
- }, {
402
- command_code?: "percent_sign" | undefined;
403
- }>>;
404
- T: ExcellonDrillCommandDef<"define_tool", z.ZodObject<{
405
- command_code: z.ZodDefault<z.ZodLiteral<"define_tool">>;
406
- tool_number: z.ZodNumber;
407
- diameter: z.ZodNumber;
408
- }, "strip", z.ZodTypeAny, {
409
- command_code: "define_tool";
410
- diameter: number;
411
- tool_number: number;
412
- }, {
413
- diameter: number;
414
- tool_number: number;
415
- command_code?: "define_tool" | undefined;
416
- }>>;
417
- define_tool: ExcellonDrillCommandDef<"define_tool", z.ZodObject<{
418
- command_code: z.ZodDefault<z.ZodLiteral<"define_tool">>;
419
- tool_number: z.ZodNumber;
420
- diameter: z.ZodNumber;
421
- }, "strip", z.ZodTypeAny, {
422
- command_code: "define_tool";
423
- diameter: number;
424
- tool_number: number;
425
- }, {
426
- diameter: number;
427
- tool_number: number;
428
- command_code?: "define_tool" | undefined;
429
- }>>;
430
- use_tool: ExcellonDrillCommandDef<"use_tool", z.ZodObject<{
431
- command_code: z.ZodDefault<z.ZodLiteral<"use_tool">>;
432
- tool_number: z.ZodNumber;
433
- }, "strip", z.ZodTypeAny, {
434
- command_code: "use_tool";
435
- tool_number: number;
436
- }, {
437
- tool_number: number;
438
- command_code?: "use_tool" | undefined;
439
- }>>;
440
- G90: ExcellonDrillCommandDef<"G90", z.ZodObject<{
441
- command_code: z.ZodDefault<z.ZodLiteral<"G90">>;
442
- }, "strip", z.ZodTypeAny, {
443
- command_code: "G90";
444
- }, {
445
- command_code?: "G90" | undefined;
446
- }>>;
447
- G05: ExcellonDrillCommandDef<"G05", z.ZodObject<{
448
- command_code: z.ZodDefault<z.ZodLiteral<"G05">>;
449
- }, "strip", z.ZodTypeAny, {
450
- command_code: "G05";
451
- }, {
452
- command_code?: "G05" | undefined;
453
- }>>;
454
- M30: ExcellonDrillCommandDef<"M30", z.ZodObject<{
455
- command_code: z.ZodDefault<z.ZodLiteral<"M30">>;
456
- }, "strip", z.ZodTypeAny, {
457
- command_code: "M30";
458
- }, {
459
- command_code?: "M30" | undefined;
460
- }>>;
461
- drill_at: ExcellonDrillCommandDef<"drill_at", z.ZodObject<{
462
- command_code: z.ZodDefault<z.ZodLiteral<"drill_at">>;
463
- x: z.ZodNumber;
464
- y: z.ZodNumber;
465
- }, "strip", z.ZodTypeAny, {
466
- command_code: "drill_at";
467
- x: number;
468
- y: number;
469
- }, {
470
- x: number;
471
- y: number;
472
- command_code?: "drill_at" | undefined;
473
- }>>;
474
- header_comment: ExcellonDrillCommandDef<"header_comment", z.ZodObject<{
475
- command_code: z.ZodDefault<z.ZodLiteral<"header_comment">>;
476
- text: z.ZodString;
477
- }, "strip", z.ZodTypeAny, {
478
- command_code: "header_comment";
479
- text: string;
480
- }, {
481
- text: string;
482
- command_code?: "header_comment" | undefined;
483
- }>>;
484
- header_attribute: ExcellonDrillCommandDef<"header_attribute", z.ZodObject<{
485
- command_code: z.ZodDefault<z.ZodLiteral<"header_attribute">>;
486
- attribute_name: z.ZodString;
487
- attribute_value: z.ZodString;
488
- }, "strip", z.ZodTypeAny, {
489
- command_code: "header_attribute";
490
- attribute_name: string;
491
- attribute_value: string;
492
- }, {
493
- attribute_name: string;
494
- attribute_value: string;
495
- command_code?: "header_attribute" | undefined;
496
- }>>;
497
- rewind: ExcellonDrillCommandDef<"rewind", z.ZodObject<{
498
- command_code: z.ZodDefault<z.ZodLiteral<"rewind">>;
499
- }, "strip", z.ZodTypeAny, {
500
- command_code: "rewind";
501
- }, {
502
- command_code?: "rewind" | undefined;
503
- }>>;
504
- };
505
- type AnyExcellonDrillCommand = z.infer<(typeof excellon_drill_command_map)[keyof typeof excellon_drill_command_map]["schema"]>;
506
-
507
- declare const stringifyExcellonDrill: (commands: Array<AnyExcellonDrillCommand>) => string;
508
-
509
- declare const convertSoupToExcellonDrillCommands: ({ soup, is_plated, flip_y_axis, }: {
510
- soup: Array<AnySoupElement>;
511
- is_plated: boolean;
512
- flip_y_axis?: boolean;
513
- }) => Array<AnyExcellonDrillCommand>;
514
-
515
- export { convertSoupToExcellonDrillCommands, convertSoupToGerberCommands, gerberBuilder, stringifyExcellonDrill, stringifyGerberCommand, stringifyGerberCommandLayers, stringifyGerberCommands };
523
+ export { convertSoupToExcellonDrillCommands, convertSoupToGerberCommands, excellonDrill, gerberBuilder, stringifyExcellonDrill, stringifyGerberCommand, stringifyGerberCommandLayers, stringifyGerberCommands };