kicadts 0.0.1

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.
Files changed (188) hide show
  1. package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +111 -0
  2. package/.vscode/settings.json +16 -0
  3. package/AGENTS.md +30 -0
  4. package/README.md +206 -0
  5. package/biome.json +93 -0
  6. package/bun.lock +48 -0
  7. package/bunfig.toml +5 -0
  8. package/lib/index.ts +1 -0
  9. package/lib/sexpr/base-classes/SxClass.ts +164 -0
  10. package/lib/sexpr/base-classes/SxPrimitiveBoolean.ts +35 -0
  11. package/lib/sexpr/base-classes/SxPrimitiveNumber.ts +26 -0
  12. package/lib/sexpr/base-classes/SxPrimitiveString.ts +26 -0
  13. package/lib/sexpr/classes/At.ts +38 -0
  14. package/lib/sexpr/classes/Bus.ts +83 -0
  15. package/lib/sexpr/classes/BusEntry.ts +142 -0
  16. package/lib/sexpr/classes/Color.ts +29 -0
  17. package/lib/sexpr/classes/Dnp.ts +8 -0
  18. package/lib/sexpr/classes/EmbeddedFonts.ts +70 -0
  19. package/lib/sexpr/classes/ExcludeFromSim.ts +8 -0
  20. package/lib/sexpr/classes/FieldsAutoplaced.ts +8 -0
  21. package/lib/sexpr/classes/Footprint.ts +719 -0
  22. package/lib/sexpr/classes/FootprintAttr.ts +102 -0
  23. package/lib/sexpr/classes/FootprintAutoplaceCost180.ts +9 -0
  24. package/lib/sexpr/classes/FootprintAutoplaceCost90.ts +9 -0
  25. package/lib/sexpr/classes/FootprintClearance.ts +9 -0
  26. package/lib/sexpr/classes/FootprintDescr.ts +44 -0
  27. package/lib/sexpr/classes/FootprintLocked.ts +32 -0
  28. package/lib/sexpr/classes/FootprintModel.ts +145 -0
  29. package/lib/sexpr/classes/FootprintNetTiePadGroups.ts +50 -0
  30. package/lib/sexpr/classes/FootprintPad.ts +705 -0
  31. package/lib/sexpr/classes/FootprintPath.ts +44 -0
  32. package/lib/sexpr/classes/FootprintPlaced.ts +32 -0
  33. package/lib/sexpr/classes/FootprintPrivateLayers.ts +56 -0
  34. package/lib/sexpr/classes/FootprintSheetfile.ts +44 -0
  35. package/lib/sexpr/classes/FootprintSheetname.ts +44 -0
  36. package/lib/sexpr/classes/FootprintSolderMaskMargin.ts +9 -0
  37. package/lib/sexpr/classes/FootprintSolderPasteMargin.ts +9 -0
  38. package/lib/sexpr/classes/FootprintSolderPasteRatio.ts +9 -0
  39. package/lib/sexpr/classes/FootprintTags.ts +44 -0
  40. package/lib/sexpr/classes/FootprintTedit.ts +21 -0
  41. package/lib/sexpr/classes/FootprintThermalGap.ts +9 -0
  42. package/lib/sexpr/classes/FootprintThermalWidth.ts +9 -0
  43. package/lib/sexpr/classes/FootprintZoneConnect.ts +9 -0
  44. package/lib/sexpr/classes/FpArc.ts +289 -0
  45. package/lib/sexpr/classes/FpCircle.ts +293 -0
  46. package/lib/sexpr/classes/FpLine.ts +288 -0
  47. package/lib/sexpr/classes/FpPoly.ts +266 -0
  48. package/lib/sexpr/classes/FpPolyFill.ts +48 -0
  49. package/lib/sexpr/classes/FpPolyLocked.ts +40 -0
  50. package/lib/sexpr/classes/FpRect.ts +293 -0
  51. package/lib/sexpr/classes/FpText.ts +341 -0
  52. package/lib/sexpr/classes/FpTextBox.ts +412 -0
  53. package/lib/sexpr/classes/GrLine.ts +245 -0
  54. package/lib/sexpr/classes/GrLineAngle.ts +32 -0
  55. package/lib/sexpr/classes/GrLineEnd.ts +61 -0
  56. package/lib/sexpr/classes/GrLineLocked.ts +40 -0
  57. package/lib/sexpr/classes/GrLineStart.ts +61 -0
  58. package/lib/sexpr/classes/GrText.ts +202 -0
  59. package/lib/sexpr/classes/Image.ts +256 -0
  60. package/lib/sexpr/classes/InBom.ts +8 -0
  61. package/lib/sexpr/classes/Junction.ts +134 -0
  62. package/lib/sexpr/classes/KicadPcb.ts +313 -0
  63. package/lib/sexpr/classes/KicadSch.ts +303 -0
  64. package/lib/sexpr/classes/KicadSchGenerator.ts +32 -0
  65. package/lib/sexpr/classes/KicadSchGeneratorVersion.ts +30 -0
  66. package/lib/sexpr/classes/KicadSchVersion.ts +22 -0
  67. package/lib/sexpr/classes/Label.ts +136 -0
  68. package/lib/sexpr/classes/Layer.ts +51 -0
  69. package/lib/sexpr/classes/Layers.ts +47 -0
  70. package/lib/sexpr/classes/LibSymbols.ts +61 -0
  71. package/lib/sexpr/classes/NoConnect.ts +73 -0
  72. package/lib/sexpr/classes/OnBoard.ts +8 -0
  73. package/lib/sexpr/classes/PadChamfer.ts +50 -0
  74. package/lib/sexpr/classes/PadChamferRatio.ts +9 -0
  75. package/lib/sexpr/classes/PadClearance.ts +9 -0
  76. package/lib/sexpr/classes/PadDieLength.ts +9 -0
  77. package/lib/sexpr/classes/PadDrill.ts +145 -0
  78. package/lib/sexpr/classes/PadDrillOffset.ts +54 -0
  79. package/lib/sexpr/classes/PadLayers.ts +59 -0
  80. package/lib/sexpr/classes/PadNet.ts +56 -0
  81. package/lib/sexpr/classes/PadOptions.ts +182 -0
  82. package/lib/sexpr/classes/PadPinFunction.ts +9 -0
  83. package/lib/sexpr/classes/PadPinType.ts +9 -0
  84. package/lib/sexpr/classes/PadPrimitiveGrArc.ts +254 -0
  85. package/lib/sexpr/classes/PadPrimitiveGrCircle.ts +279 -0
  86. package/lib/sexpr/classes/PadPrimitiveGrLine.ts +126 -0
  87. package/lib/sexpr/classes/PadPrimitives.ts +289 -0
  88. package/lib/sexpr/classes/PadRectDelta.ts +57 -0
  89. package/lib/sexpr/classes/PadRoundrectRratio.ts +9 -0
  90. package/lib/sexpr/classes/PadSize.ts +54 -0
  91. package/lib/sexpr/classes/PadSolderMaskMargin.ts +9 -0
  92. package/lib/sexpr/classes/PadSolderPasteMargin.ts +9 -0
  93. package/lib/sexpr/classes/PadSolderPasteMarginRatio.ts +9 -0
  94. package/lib/sexpr/classes/PadTeardrops.ts +208 -0
  95. package/lib/sexpr/classes/PadThermalBridgeAngle.ts +9 -0
  96. package/lib/sexpr/classes/PadThermalGap.ts +9 -0
  97. package/lib/sexpr/classes/PadThermalWidth.ts +9 -0
  98. package/lib/sexpr/classes/PadZoneConnect.ts +9 -0
  99. package/lib/sexpr/classes/Paper.ts +119 -0
  100. package/lib/sexpr/classes/PcbGeneral.ts +75 -0
  101. package/lib/sexpr/classes/PcbGeneralLegacyTeardrops.ts +44 -0
  102. package/lib/sexpr/classes/PcbGeneralThickness.ts +9 -0
  103. package/lib/sexpr/classes/PcbGenerator.ts +16 -0
  104. package/lib/sexpr/classes/PcbGeneratorVersion.ts +16 -0
  105. package/lib/sexpr/classes/PcbLayerDefinition.ts +102 -0
  106. package/lib/sexpr/classes/PcbLayers.ts +34 -0
  107. package/lib/sexpr/classes/PcbNet.ts +56 -0
  108. package/lib/sexpr/classes/PcbVersion.ts +9 -0
  109. package/lib/sexpr/classes/Property.ts +246 -0
  110. package/lib/sexpr/classes/PropertyHide.ts +9 -0
  111. package/lib/sexpr/classes/PropertyUnlocked.ts +9 -0
  112. package/lib/sexpr/classes/Pts.ts +65 -0
  113. package/lib/sexpr/classes/RenderCache.ts +221 -0
  114. package/lib/sexpr/classes/SchematicText.ts +141 -0
  115. package/lib/sexpr/classes/Segment.ts +222 -0
  116. package/lib/sexpr/classes/SegmentEnd.ts +59 -0
  117. package/lib/sexpr/classes/SegmentLocked.ts +33 -0
  118. package/lib/sexpr/classes/SegmentNet.ts +62 -0
  119. package/lib/sexpr/classes/SegmentStart.ts +59 -0
  120. package/lib/sexpr/classes/Setup/PcbPlotParams.ts +729 -0
  121. package/lib/sexpr/classes/Setup/PcbPlotParamsBase.ts +9 -0
  122. package/lib/sexpr/classes/Setup/PcbPlotParamsNumericProperties.ts +105 -0
  123. package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesA.ts +104 -0
  124. package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesB.ts +105 -0
  125. package/lib/sexpr/classes/Setup/Setup.ts +573 -0
  126. package/lib/sexpr/classes/Setup/SetupPropertyTypes.ts +119 -0
  127. package/lib/sexpr/classes/Setup/Stackup.ts +140 -0
  128. package/lib/sexpr/classes/Setup/StackupLayer.ts +233 -0
  129. package/lib/sexpr/classes/Setup/StackupLayerProperties.ts +78 -0
  130. package/lib/sexpr/classes/Setup/StackupProperties.ts +41 -0
  131. package/lib/sexpr/classes/Setup/base.ts +167 -0
  132. package/lib/sexpr/classes/Setup/index.ts +14 -0
  133. package/lib/sexpr/classes/Setup/setupMultiValueProperties.ts +54 -0
  134. package/lib/sexpr/classes/Setup/setupNumericProperties.ts +151 -0
  135. package/lib/sexpr/classes/Setup/setupPropertyHandlers.ts +90 -0
  136. package/lib/sexpr/classes/Setup/setupStringProperties.ts +75 -0
  137. package/lib/sexpr/classes/Sheet.ts +205 -0
  138. package/lib/sexpr/classes/SheetFill.ts +44 -0
  139. package/lib/sexpr/classes/SheetInstances.ts +168 -0
  140. package/lib/sexpr/classes/SheetInstancesRoot.ts +165 -0
  141. package/lib/sexpr/classes/SheetPin.ts +122 -0
  142. package/lib/sexpr/classes/SheetProperty.ts +115 -0
  143. package/lib/sexpr/classes/SheetSize.ts +44 -0
  144. package/lib/sexpr/classes/Stroke.ts +58 -0
  145. package/lib/sexpr/classes/StrokeType.ts +34 -0
  146. package/lib/sexpr/classes/Symbol.ts +1541 -0
  147. package/lib/sexpr/classes/TextEffects.ts +444 -0
  148. package/lib/sexpr/classes/TitleBlock.ts +352 -0
  149. package/lib/sexpr/classes/Unit.ts +28 -0
  150. package/lib/sexpr/classes/Uuid.ts +8 -0
  151. package/lib/sexpr/classes/Via.ts +328 -0
  152. package/lib/sexpr/classes/ViaNet.ts +59 -0
  153. package/lib/sexpr/classes/Width.ts +8 -0
  154. package/lib/sexpr/classes/Wire.ts +91 -0
  155. package/lib/sexpr/classes/Xy.ts +35 -0
  156. package/lib/sexpr/classes/Zone.ts +41 -0
  157. package/lib/sexpr/index.ts +130 -0
  158. package/lib/sexpr/parseKicadSexpr.ts +5 -0
  159. package/lib/sexpr/parseToPrimitiveSExpr.ts +240 -0
  160. package/lib/sexpr/utils/indentLines.ts +3 -0
  161. package/lib/sexpr/utils/parseYesNo.ts +12 -0
  162. package/lib/sexpr/utils/quoteSExprString.ts +8 -0
  163. package/lib/sexpr/utils/strokeFromArgs.ts +19 -0
  164. package/lib/sexpr/utils/toNumberValue.ts +13 -0
  165. package/lib/sexpr/utils/toStringValue.ts +10 -0
  166. package/package.json +26 -0
  167. package/scripts/download-references.ts +66 -0
  168. package/tests/fixtures/expectEqualPrimitiveSExpr.ts +200 -0
  169. package/tests/sexpr/KicadPcbDemos.test.ts +48 -0
  170. package/tests/sexpr/KicadSchDemos.test.ts +49 -0
  171. package/tests/sexpr/classes/Footprint.test.ts +277 -0
  172. package/tests/sexpr/classes/FootprintPad.test.ts +71 -0
  173. package/tests/sexpr/classes/FpArc.test.ts +45 -0
  174. package/tests/sexpr/classes/FpCircle.test.ts +39 -0
  175. package/tests/sexpr/classes/FpPoly.test.ts +43 -0
  176. package/tests/sexpr/classes/FpRect.test.ts +40 -0
  177. package/tests/sexpr/classes/FpTextBox.test.ts +84 -0
  178. package/tests/sexpr/classes/Image.test.ts +50 -0
  179. package/tests/sexpr/classes/KicadSch.test.ts +97 -0
  180. package/tests/sexpr/classes/Paper.test.ts +30 -0
  181. package/tests/sexpr/classes/Property.test.ts +48 -0
  182. package/tests/sexpr/classes/Setup.test.ts +189 -0
  183. package/tests/sexpr/classes/Sheet.test.ts +107 -0
  184. package/tests/sexpr/classes/Stroke.test.ts +15 -0
  185. package/tests/sexpr/classes/Symbol.test.ts +96 -0
  186. package/tests/sexpr/classes/TextEffects.test.ts +56 -0
  187. package/tests/sexpr/classes/TitleBlock.test.ts +40 -0
  188. package/tsconfig.json +35 -0
@@ -0,0 +1,54 @@
1
+ import { SxClass } from "../../base-classes/SxClass"
2
+
3
+ import { CoordinateProperty, NumericListProperty } from "./base"
4
+
5
+ abstract class SetupNumericListProperty extends NumericListProperty {
6
+ static override parentToken = "setup"
7
+ }
8
+
9
+ abstract class SetupCoordinateProperty extends CoordinateProperty {
10
+ static override parentToken = "setup"
11
+ }
12
+
13
+ export class SetupPcbTextSize extends SetupNumericListProperty {
14
+ static override token = "pcb_text_size"
15
+ token = "pcb_text_size"
16
+ }
17
+ SxClass.register(SetupPcbTextSize)
18
+
19
+ export class SetupModTextSize extends SetupNumericListProperty {
20
+ static override token = "mod_text_size"
21
+ token = "mod_text_size"
22
+ }
23
+ SxClass.register(SetupModTextSize)
24
+
25
+ export class SetupPadSize extends SetupNumericListProperty {
26
+ static override token = "pad_size"
27
+ token = "pad_size"
28
+ }
29
+ SxClass.register(SetupPadSize)
30
+
31
+ export class SetupPadToPasteClearanceValues extends SetupNumericListProperty {
32
+ static override token = "pad_to_paste_clearance_values"
33
+ token = "pad_to_paste_clearance_values"
34
+ }
35
+ SxClass.register(SetupPadToPasteClearanceValues)
36
+
37
+ export class SetupTraceWidth extends SetupNumericListProperty {
38
+ static override token = "trace_width"
39
+ token = "trace_width"
40
+ }
41
+ SxClass.register(SetupTraceWidth)
42
+
43
+ export class SetupAuxAxisOrigin extends SetupCoordinateProperty {
44
+ static override token = "aux_axis_origin"
45
+ token = "aux_axis_origin"
46
+ }
47
+ SxClass.register(SetupAuxAxisOrigin)
48
+
49
+ export class SetupGridOrigin extends SetupCoordinateProperty {
50
+ static override token = "grid_origin"
51
+ token = "grid_origin"
52
+ }
53
+ SxClass.register(SetupGridOrigin)
54
+
@@ -0,0 +1,151 @@
1
+ import { SxClass } from "../../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../../parseToPrimitiveSExpr"
3
+ import { toNumberValue } from "../../utils/toNumberValue"
4
+
5
+ import { SingleValueProperty } from "./base"
6
+
7
+ abstract class SetupNumberProperty extends SingleValueProperty<number> {
8
+ static override parentToken = "setup"
9
+
10
+ protected static override parsePrimitiveValue(
11
+ value: PrimitiveSExpr | undefined,
12
+ ): number {
13
+ const parsed = toNumberValue(value)
14
+ if (parsed === undefined) {
15
+ throw new Error(`${this.name} expects a numeric value`)
16
+ }
17
+ return parsed
18
+ }
19
+ }
20
+
21
+ export class SetupPadToMaskClearance extends SetupNumberProperty {
22
+ static override token = "pad_to_mask_clearance"
23
+ token = "pad_to_mask_clearance"
24
+ }
25
+ SxClass.register(SetupPadToMaskClearance)
26
+
27
+ export class SetupSolderMaskMinWidth extends SetupNumberProperty {
28
+ static override token = "solder_mask_min_width"
29
+ token = "solder_mask_min_width"
30
+ }
31
+ SxClass.register(SetupSolderMaskMinWidth)
32
+
33
+ export class SetupPadToPasteClearance extends SetupNumberProperty {
34
+ static override token = "pad_to_paste_clearance"
35
+ token = "pad_to_paste_clearance"
36
+ }
37
+ SxClass.register(SetupPadToPasteClearance)
38
+
39
+ export class SetupPadToPasteClearanceRatio extends SetupNumberProperty {
40
+ static override token = "pad_to_paste_clearance_ratio"
41
+ token = "pad_to_paste_clearance_ratio"
42
+ }
43
+ SxClass.register(SetupPadToPasteClearanceRatio)
44
+
45
+ export class SetupLastTraceWidth extends SetupNumberProperty {
46
+ static override token = "last_trace_width"
47
+ token = "last_trace_width"
48
+ }
49
+ SxClass.register(SetupLastTraceWidth)
50
+
51
+ export class SetupTraceClearance extends SetupNumberProperty {
52
+ static override token = "trace_clearance"
53
+ token = "trace_clearance"
54
+ }
55
+ SxClass.register(SetupTraceClearance)
56
+
57
+ export class SetupZoneClearance extends SetupNumberProperty {
58
+ static override token = "zone_clearance"
59
+ token = "zone_clearance"
60
+ }
61
+ SxClass.register(SetupZoneClearance)
62
+
63
+ export class SetupTraceMin extends SetupNumberProperty {
64
+ static override token = "trace_min"
65
+ token = "trace_min"
66
+ }
67
+ SxClass.register(SetupTraceMin)
68
+
69
+ export class SetupSegmentWidth extends SetupNumberProperty {
70
+ static override token = "segment_width"
71
+ token = "segment_width"
72
+ }
73
+ SxClass.register(SetupSegmentWidth)
74
+
75
+ export class SetupEdgeWidth extends SetupNumberProperty {
76
+ static override token = "edge_width"
77
+ token = "edge_width"
78
+ }
79
+ SxClass.register(SetupEdgeWidth)
80
+
81
+ export class SetupViaSize extends SetupNumberProperty {
82
+ static override token = "via_size"
83
+ token = "via_size"
84
+ }
85
+ SxClass.register(SetupViaSize)
86
+
87
+ export class SetupViaDrill extends SetupNumberProperty {
88
+ static override token = "via_drill"
89
+ token = "via_drill"
90
+ }
91
+ SxClass.register(SetupViaDrill)
92
+
93
+ export class SetupViaMinSize extends SetupNumberProperty {
94
+ static override token = "via_min_size"
95
+ token = "via_min_size"
96
+ }
97
+ SxClass.register(SetupViaMinSize)
98
+
99
+ export class SetupViaMinDrill extends SetupNumberProperty {
100
+ static override token = "via_min_drill"
101
+ token = "via_min_drill"
102
+ }
103
+ SxClass.register(SetupViaMinDrill)
104
+
105
+ export class SetupUviaSize extends SetupNumberProperty {
106
+ static override token = "uvia_size"
107
+ token = "uvia_size"
108
+ }
109
+ SxClass.register(SetupUviaSize)
110
+
111
+ export class SetupUviaDrill extends SetupNumberProperty {
112
+ static override token = "uvia_drill"
113
+ token = "uvia_drill"
114
+ }
115
+ SxClass.register(SetupUviaDrill)
116
+
117
+ export class SetupUviaMinSize extends SetupNumberProperty {
118
+ static override token = "uvia_min_size"
119
+ token = "uvia_min_size"
120
+ }
121
+ SxClass.register(SetupUviaMinSize)
122
+
123
+ export class SetupUviaMinDrill extends SetupNumberProperty {
124
+ static override token = "uvia_min_drill"
125
+ token = "uvia_min_drill"
126
+ }
127
+ SxClass.register(SetupUviaMinDrill)
128
+
129
+ export class SetupPcbTextWidth extends SetupNumberProperty {
130
+ static override token = "pcb_text_width"
131
+ token = "pcb_text_width"
132
+ }
133
+ SxClass.register(SetupPcbTextWidth)
134
+
135
+ export class SetupModEdgeWidth extends SetupNumberProperty {
136
+ static override token = "mod_edge_width"
137
+ token = "mod_edge_width"
138
+ }
139
+ SxClass.register(SetupModEdgeWidth)
140
+
141
+ export class SetupModTextWidth extends SetupNumberProperty {
142
+ static override token = "mod_text_width"
143
+ token = "mod_text_width"
144
+ }
145
+ SxClass.register(SetupModTextWidth)
146
+
147
+ export class SetupPadDrill extends SetupNumberProperty {
148
+ static override token = "pad_drill"
149
+ token = "pad_drill"
150
+ }
151
+ SxClass.register(SetupPadDrill)
@@ -0,0 +1,90 @@
1
+ import type { SetupPropertyValues } from "./SetupPropertyTypes"
2
+ import { PcbPlotParams } from "./PcbPlotParams"
3
+ import { Stackup } from "./Stackup"
4
+ import {
5
+ SetupAuxAxisOrigin,
6
+ SetupGridOrigin,
7
+ SetupModTextSize,
8
+ SetupPadSize,
9
+ SetupPadToPasteClearanceValues,
10
+ SetupPcbTextSize,
11
+ SetupTraceWidth,
12
+ } from "./setupMultiValueProperties"
13
+ import {
14
+ SetupAllowSoldermaskBridgesInFootprints,
15
+ SetupTenting,
16
+ SetupUviasAllowed,
17
+ SetupVisibleElements,
18
+ SetupZone45Only,
19
+ } from "./setupStringProperties"
20
+ import {
21
+ SetupEdgeWidth,
22
+ SetupLastTraceWidth,
23
+ SetupModEdgeWidth,
24
+ SetupModTextWidth,
25
+ SetupPadDrill,
26
+ SetupPadToMaskClearance,
27
+ SetupPadToPasteClearance,
28
+ SetupPadToPasteClearanceRatio,
29
+ SetupPcbTextWidth,
30
+ SetupSegmentWidth,
31
+ SetupSolderMaskMinWidth,
32
+ SetupTraceClearance,
33
+ SetupTraceMin,
34
+ SetupUviaDrill,
35
+ SetupUviaMinDrill,
36
+ SetupUviaMinSize,
37
+ SetupUviaSize,
38
+ SetupViaDrill,
39
+ SetupViaMinDrill,
40
+ SetupViaMinSize,
41
+ SetupViaSize,
42
+ SetupZoneClearance,
43
+ } from "./setupNumericProperties"
44
+
45
+ type Constructor<T> = new (...args: any[]) => T
46
+
47
+ export const setupPropertyDescriptors = [
48
+ { Class: Stackup, key: "stackup" },
49
+ { Class: PcbPlotParams, key: "pcbPlotParams" },
50
+ { Class: SetupPadToMaskClearance, key: "padToMaskClearance" },
51
+ { Class: SetupSolderMaskMinWidth, key: "solderMaskMinWidth" },
52
+ { Class: SetupPadToPasteClearance, key: "padToPasteClearance" },
53
+ { Class: SetupPadToPasteClearanceRatio, key: "padToPasteClearanceRatio" },
54
+ { Class: SetupLastTraceWidth, key: "lastTraceWidth" },
55
+ { Class: SetupTraceClearance, key: "traceClearance" },
56
+ { Class: SetupZoneClearance, key: "zoneClearance" },
57
+ { Class: SetupZone45Only, key: "zone45Only" },
58
+ { Class: SetupTraceMin, key: "traceMin" },
59
+ { Class: SetupSegmentWidth, key: "segmentWidth" },
60
+ { Class: SetupEdgeWidth, key: "edgeWidth" },
61
+ { Class: SetupViaSize, key: "viaSize" },
62
+ { Class: SetupViaDrill, key: "viaDrill" },
63
+ { Class: SetupViaMinSize, key: "viaMinSize" },
64
+ { Class: SetupViaMinDrill, key: "viaMinDrill" },
65
+ { Class: SetupUviasAllowed, key: "uviasAllowed" },
66
+ { Class: SetupUviaSize, key: "uviaSize" },
67
+ { Class: SetupUviaDrill, key: "uviaDrill" },
68
+ { Class: SetupUviaMinSize, key: "uviaMinSize" },
69
+ { Class: SetupUviaMinDrill, key: "uviaMinDrill" },
70
+ { Class: SetupPcbTextWidth, key: "pcbTextWidth" },
71
+ { Class: SetupPcbTextSize, key: "pcbTextSize" },
72
+ { Class: SetupModEdgeWidth, key: "modEdgeWidth" },
73
+ { Class: SetupModTextSize, key: "modTextSize" },
74
+ { Class: SetupModTextWidth, key: "modTextWidth" },
75
+ { Class: SetupPadSize, key: "padSize" },
76
+ { Class: SetupPadDrill, key: "padDrill" },
77
+ {
78
+ Class: SetupAllowSoldermaskBridgesInFootprints,
79
+ key: "allowSoldermaskBridgesInFootprints",
80
+ },
81
+ { Class: SetupTenting, key: "tenting" },
82
+ { Class: SetupAuxAxisOrigin, key: "auxAxisOrigin" },
83
+ { Class: SetupGridOrigin, key: "gridOrigin" },
84
+ { Class: SetupVisibleElements, key: "visibleElements" },
85
+ { Class: SetupPadToPasteClearanceValues, key: "padToPasteClearanceValues" },
86
+ { Class: SetupTraceWidth, key: "traceWidth" },
87
+ ] as const satisfies ReadonlyArray<{
88
+ Class: Constructor<SetupPropertyValues[keyof SetupPropertyValues]>
89
+ key: keyof SetupPropertyValues
90
+ }>
@@ -0,0 +1,75 @@
1
+ import { SxClass } from "../../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../../parseToPrimitiveSExpr"
3
+ import { toStringValue } from "../../utils/toStringValue"
4
+
5
+ import { SingleValueProperty } from "./base"
6
+
7
+ abstract class SetupStringProperty extends SingleValueProperty<string> {
8
+ static override parentToken = "setup"
9
+ }
10
+
11
+ export class SetupZone45Only extends SetupStringProperty {
12
+ static override token = "zone_45_only"
13
+ token = "zone_45_only"
14
+ }
15
+ SxClass.register(SetupZone45Only)
16
+
17
+ export class SetupAllowSoldermaskBridgesInFootprints extends SetupStringProperty {
18
+ static override token = "allow_soldermask_bridges_in_footprints"
19
+ token = "allow_soldermask_bridges_in_footprints"
20
+ }
21
+ SxClass.register(SetupAllowSoldermaskBridgesInFootprints)
22
+
23
+ export class SetupVisibleElements extends SetupStringProperty {
24
+ static override token = "visible_elements"
25
+ token = "visible_elements"
26
+ }
27
+ SxClass.register(SetupVisibleElements)
28
+
29
+ export class SetupUviasAllowed extends SetupStringProperty {
30
+ static override token = "uvias_allowed"
31
+ token = "uvias_allowed"
32
+ }
33
+ SxClass.register(SetupUviasAllowed)
34
+
35
+ export class SetupTenting extends SxClass {
36
+ static override token = "tenting"
37
+ static override parentToken = "setup"
38
+ token = "tenting"
39
+
40
+ private _sides: string[] = []
41
+
42
+ constructor(sides: string[] = []) {
43
+ super()
44
+ this.sides = sides
45
+ }
46
+
47
+ static override fromSexprPrimitives(
48
+ primitiveSexprs: PrimitiveSExpr[],
49
+ ): SetupTenting {
50
+ const sides = primitiveSexprs
51
+ .map((primitive) => toStringValue(primitive))
52
+ .filter((value): value is string => value !== undefined)
53
+ return new SetupTenting(sides)
54
+ }
55
+
56
+ get sides(): string[] {
57
+ return [...this._sides]
58
+ }
59
+
60
+ set sides(sides: string[]) {
61
+ this._sides = sides.map((side) => String(side))
62
+ }
63
+
64
+ override getChildren(): SxClass[] {
65
+ return []
66
+ }
67
+
68
+ override getString(): string {
69
+ if (this._sides.length === 0) {
70
+ return "(tenting)"
71
+ }
72
+ return `(tenting ${this._sides.join(" ")})`
73
+ }
74
+ }
75
+ SxClass.register(SetupTenting)
@@ -0,0 +1,205 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { indentLines } from "../utils/indentLines"
4
+ import { quoteSExprString } from "../utils/quoteSExprString"
5
+ import { toNumberValue } from "../utils/toNumberValue"
6
+ import { toStringValue } from "../utils/toStringValue"
7
+ import { At } from "./At"
8
+ import { Color } from "./Color"
9
+ import { Dnp } from "./Dnp"
10
+ import { ExcludeFromSim } from "./ExcludeFromSim"
11
+ import { FieldsAutoplaced } from "./FieldsAutoplaced"
12
+ import { InBom } from "./InBom"
13
+ import { OnBoard } from "./OnBoard"
14
+ import { SheetInstances } from "./SheetInstances"
15
+ import { SheetPin } from "./SheetPin"
16
+ import { Stroke } from "./Stroke"
17
+ import { TextEffects } from "./TextEffects"
18
+ import { Uuid } from "./Uuid"
19
+ import { SymbolPropertyId as PropertyId } from "./Symbol"
20
+ import { SheetFill } from "./SheetFill"
21
+ import { SheetSize } from "./SheetSize"
22
+ import { SheetProperty } from "./SheetProperty"
23
+
24
+ export class Sheet extends SxClass {
25
+ static override token = "sheet"
26
+ token = "sheet"
27
+
28
+ private _sxAt?: At
29
+ private _sxSize?: SheetSize
30
+ private _sxExcludeFromSim?: ExcludeFromSim
31
+ private _sxInBom?: InBom
32
+ private _sxOnBoard?: OnBoard
33
+ private _sxDnp?: Dnp
34
+ private _sxFieldsAutoplaced?: FieldsAutoplaced
35
+ private _sxStroke?: Stroke
36
+ private _sxFill?: SheetFill
37
+ private _sxUuid?: Uuid
38
+ private _properties: SheetProperty[] = []
39
+ private _pins: SheetPin[] = []
40
+ private _sxInstances?: SheetInstances
41
+
42
+ static override fromSexprPrimitives(
43
+ primitiveSexprs: PrimitiveSExpr[],
44
+ ): Sheet {
45
+ const sheet = new Sheet()
46
+
47
+ const { propertyMap, arrayPropertyMap } =
48
+ SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token)
49
+
50
+ sheet._sxAt = propertyMap.at as At | undefined
51
+ sheet._sxSize = propertyMap.size as SheetSize | undefined
52
+ sheet._sxExcludeFromSim = propertyMap.exclude_from_sim as
53
+ | ExcludeFromSim
54
+ | undefined
55
+ sheet._sxInBom = propertyMap.in_bom as InBom | undefined
56
+ sheet._sxOnBoard = propertyMap.on_board as OnBoard | undefined
57
+ sheet._sxDnp = propertyMap.dnp as Dnp | undefined
58
+ sheet._sxFieldsAutoplaced = propertyMap.fields_autoplaced as
59
+ | FieldsAutoplaced
60
+ | undefined
61
+ sheet._sxStroke = propertyMap.stroke as Stroke | undefined
62
+ sheet._sxFill = propertyMap.fill as SheetFill | undefined
63
+ sheet._sxUuid = propertyMap.uuid as Uuid | undefined
64
+ sheet._properties = (arrayPropertyMap.property as SheetProperty[]) ?? []
65
+ sheet._pins = (arrayPropertyMap.pin as SheetPin[]) ?? []
66
+ sheet._sxInstances = propertyMap.instances as SheetInstances | undefined
67
+
68
+ return sheet
69
+ }
70
+
71
+ get position(): At | undefined {
72
+ return this._sxAt
73
+ }
74
+
75
+ set position(value: At | undefined) {
76
+ this._sxAt = value
77
+ }
78
+
79
+ get size(): { width: number; height: number } | undefined {
80
+ return this._sxSize?.toObject()
81
+ }
82
+
83
+ set size(value: SheetSize | { width: number; height: number } | undefined) {
84
+ if (value === undefined) {
85
+ this._sxSize = undefined
86
+ return
87
+ }
88
+ if (value instanceof SheetSize) {
89
+ this._sxSize = value
90
+ return
91
+ }
92
+ this._sxSize = new SheetSize(value.width, value.height)
93
+ }
94
+
95
+ get excludeFromSim(): boolean {
96
+ return this._sxExcludeFromSim?.value ?? false
97
+ }
98
+
99
+ set excludeFromSim(value: boolean) {
100
+ this._sxExcludeFromSim = new ExcludeFromSim(value)
101
+ }
102
+
103
+ get inBom(): boolean {
104
+ return this._sxInBom?.value ?? false
105
+ }
106
+
107
+ set inBom(value: boolean) {
108
+ this._sxInBom = new InBom(value)
109
+ }
110
+
111
+ get onBoard(): boolean {
112
+ return this._sxOnBoard?.value ?? false
113
+ }
114
+
115
+ set onBoard(value: boolean) {
116
+ this._sxOnBoard = new OnBoard(value)
117
+ }
118
+
119
+ get dnp(): boolean {
120
+ return this._sxDnp?.value ?? false
121
+ }
122
+
123
+ set dnp(value: boolean) {
124
+ this._sxDnp = new Dnp(value)
125
+ }
126
+
127
+ get fieldsAutoplaced(): boolean {
128
+ return this._sxFieldsAutoplaced?.value ?? false
129
+ }
130
+
131
+ set fieldsAutoplaced(value: boolean) {
132
+ this._sxFieldsAutoplaced = new FieldsAutoplaced(value)
133
+ }
134
+
135
+ get stroke(): Stroke | undefined {
136
+ return this._sxStroke
137
+ }
138
+
139
+ set stroke(value: Stroke | undefined) {
140
+ this._sxStroke = value
141
+ }
142
+
143
+ get fill(): SheetFill | undefined {
144
+ return this._sxFill
145
+ }
146
+
147
+ set fill(value: SheetFill | undefined) {
148
+ this._sxFill = value
149
+ }
150
+
151
+ get uuid(): Uuid | undefined {
152
+ return this._sxUuid
153
+ }
154
+
155
+ set uuid(value: Uuid | string | undefined) {
156
+ if (value === undefined) {
157
+ this._sxUuid = undefined
158
+ return
159
+ }
160
+ this._sxUuid = value instanceof Uuid ? value : new Uuid(value)
161
+ }
162
+
163
+ get properties(): SheetProperty[] {
164
+ return this._properties
165
+ }
166
+
167
+ set properties(value: SheetProperty[]) {
168
+ this._properties = value
169
+ }
170
+
171
+ get pins(): SheetPin[] {
172
+ return this._pins
173
+ }
174
+
175
+ set pins(value: SheetPin[]) {
176
+ this._pins = value
177
+ }
178
+
179
+ get instances(): SheetInstances | undefined {
180
+ return this._sxInstances
181
+ }
182
+
183
+ set instances(value: SheetInstances | undefined) {
184
+ this._sxInstances = value
185
+ }
186
+
187
+ override getChildren(): SxClass[] {
188
+ const children: SxClass[] = []
189
+ if (this._sxAt) children.push(this._sxAt)
190
+ if (this._sxSize) children.push(this._sxSize)
191
+ if (this._sxExcludeFromSim) children.push(this._sxExcludeFromSim)
192
+ if (this._sxInBom) children.push(this._sxInBom)
193
+ if (this._sxOnBoard) children.push(this._sxOnBoard)
194
+ if (this._sxDnp) children.push(this._sxDnp)
195
+ if (this._sxFieldsAutoplaced) children.push(this._sxFieldsAutoplaced)
196
+ if (this._sxStroke) children.push(this._sxStroke)
197
+ if (this._sxFill) children.push(this._sxFill)
198
+ if (this._sxUuid) children.push(this._sxUuid)
199
+ children.push(...this._properties)
200
+ children.push(...this._pins)
201
+ if (this._sxInstances) children.push(this._sxInstances)
202
+ return children
203
+ }
204
+ }
205
+ SxClass.register(Sheet)
@@ -0,0 +1,44 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { indentLines } from "../utils/indentLines"
4
+ import { quoteSExprString } from "../utils/quoteSExprString"
5
+ import { toStringValue } from "../utils/toStringValue"
6
+ import { At } from "./At"
7
+ import { TextEffects } from "./TextEffects"
8
+ import { SymbolPropertyId as PropertyId } from "./Symbol"
9
+ import type { Color } from "./Color"
10
+
11
+ export class SheetFill extends SxClass {
12
+ static override token = "fill"
13
+ static override parentToken = "sheet"
14
+ token = "fill"
15
+
16
+ private _sxColor?: Color
17
+
18
+ static override fromSexprPrimitives(
19
+ primitiveSexprs: PrimitiveSExpr[],
20
+ ): SheetFill {
21
+ const fill = new SheetFill()
22
+ const { propertyMap } = SxClass.parsePrimitivesToClassProperties(
23
+ primitiveSexprs,
24
+ this.token,
25
+ )
26
+
27
+ fill._sxColor = propertyMap.color as Color | undefined
28
+
29
+ return fill
30
+ }
31
+
32
+ get color(): Color | undefined {
33
+ return this._sxColor
34
+ }
35
+
36
+ set color(value: Color | undefined) {
37
+ this._sxColor = value
38
+ }
39
+
40
+ override getChildren(): SxClass[] {
41
+ return this._sxColor ? [this._sxColor] : []
42
+ }
43
+ }
44
+ SxClass.register(SheetFill)