kicadts 0.0.2 → 0.0.4

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 (195) hide show
  1. package/dist/index.d.ts +4466 -0
  2. package/dist/index.js +14253 -0
  3. package/package.json +5 -2
  4. package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +0 -111
  5. package/.github/workflows/bun-formatcheck.yml +0 -26
  6. package/.github/workflows/bun-pver-release.yml +0 -70
  7. package/.github/workflows/bun-test.yml +0 -32
  8. package/.github/workflows/bun-typecheck.yml +0 -26
  9. package/.vscode/settings.json +0 -16
  10. package/AGENTS.md +0 -31
  11. package/TODO.md +0 -46
  12. package/biome.json +0 -93
  13. package/bunfig.toml +0 -5
  14. package/lib/index.ts +0 -1
  15. package/lib/sexpr/base-classes/SxClass.ts +0 -164
  16. package/lib/sexpr/base-classes/SxPrimitiveBoolean.ts +0 -35
  17. package/lib/sexpr/base-classes/SxPrimitiveNumber.ts +0 -26
  18. package/lib/sexpr/base-classes/SxPrimitiveString.ts +0 -26
  19. package/lib/sexpr/classes/At.ts +0 -53
  20. package/lib/sexpr/classes/Bus.ts +0 -103
  21. package/lib/sexpr/classes/BusEntry.ts +0 -169
  22. package/lib/sexpr/classes/Color.ts +0 -29
  23. package/lib/sexpr/classes/Dnp.ts +0 -8
  24. package/lib/sexpr/classes/EmbeddedFonts.ts +0 -68
  25. package/lib/sexpr/classes/ExcludeFromSim.ts +0 -8
  26. package/lib/sexpr/classes/FieldsAutoplaced.ts +0 -8
  27. package/lib/sexpr/classes/Footprint.ts +0 -849
  28. package/lib/sexpr/classes/FootprintAttr.ts +0 -104
  29. package/lib/sexpr/classes/FootprintAutoplaceCost180.ts +0 -9
  30. package/lib/sexpr/classes/FootprintAutoplaceCost90.ts +0 -9
  31. package/lib/sexpr/classes/FootprintClearance.ts +0 -9
  32. package/lib/sexpr/classes/FootprintDescr.ts +0 -44
  33. package/lib/sexpr/classes/FootprintLocked.ts +0 -32
  34. package/lib/sexpr/classes/FootprintModel.ts +0 -142
  35. package/lib/sexpr/classes/FootprintNetTiePadGroups.ts +0 -52
  36. package/lib/sexpr/classes/FootprintPad.ts +0 -857
  37. package/lib/sexpr/classes/FootprintPath.ts +0 -44
  38. package/lib/sexpr/classes/FootprintPlaced.ts +0 -32
  39. package/lib/sexpr/classes/FootprintPrivateLayers.ts +0 -56
  40. package/lib/sexpr/classes/FootprintSheetfile.ts +0 -44
  41. package/lib/sexpr/classes/FootprintSheetname.ts +0 -44
  42. package/lib/sexpr/classes/FootprintSolderMaskMargin.ts +0 -9
  43. package/lib/sexpr/classes/FootprintSolderPasteMargin.ts +0 -9
  44. package/lib/sexpr/classes/FootprintSolderPasteRatio.ts +0 -9
  45. package/lib/sexpr/classes/FootprintTags.ts +0 -44
  46. package/lib/sexpr/classes/FootprintTedit.ts +0 -21
  47. package/lib/sexpr/classes/FootprintThermalGap.ts +0 -9
  48. package/lib/sexpr/classes/FootprintThermalWidth.ts +0 -9
  49. package/lib/sexpr/classes/FootprintZoneConnect.ts +0 -9
  50. package/lib/sexpr/classes/FpArc.ts +0 -312
  51. package/lib/sexpr/classes/FpCircle.ts +0 -314
  52. package/lib/sexpr/classes/FpLine.ts +0 -316
  53. package/lib/sexpr/classes/FpPoly.ts +0 -286
  54. package/lib/sexpr/classes/FpPolyFill.ts +0 -48
  55. package/lib/sexpr/classes/FpPolyLocked.ts +0 -40
  56. package/lib/sexpr/classes/FpRect.ts +0 -314
  57. package/lib/sexpr/classes/FpText.ts +0 -375
  58. package/lib/sexpr/classes/FpTextBox.ts +0 -450
  59. package/lib/sexpr/classes/GrLine.ts +0 -264
  60. package/lib/sexpr/classes/GrLineAngle.ts +0 -32
  61. package/lib/sexpr/classes/GrLineEnd.ts +0 -61
  62. package/lib/sexpr/classes/GrLineLocked.ts +0 -40
  63. package/lib/sexpr/classes/GrLineStart.ts +0 -61
  64. package/lib/sexpr/classes/GrText.ts +0 -228
  65. package/lib/sexpr/classes/Image.ts +0 -283
  66. package/lib/sexpr/classes/InBom.ts +0 -8
  67. package/lib/sexpr/classes/Junction.ts +0 -166
  68. package/lib/sexpr/classes/KicadPcb.ts +0 -361
  69. package/lib/sexpr/classes/KicadSch.ts +0 -397
  70. package/lib/sexpr/classes/KicadSchGenerator.ts +0 -32
  71. package/lib/sexpr/classes/KicadSchGeneratorVersion.ts +0 -30
  72. package/lib/sexpr/classes/KicadSchVersion.ts +0 -22
  73. package/lib/sexpr/classes/Label.ts +0 -176
  74. package/lib/sexpr/classes/Layer.ts +0 -51
  75. package/lib/sexpr/classes/Layers.ts +0 -47
  76. package/lib/sexpr/classes/LibSymbols.ts +0 -61
  77. package/lib/sexpr/classes/NoConnect.ts +0 -90
  78. package/lib/sexpr/classes/OnBoard.ts +0 -8
  79. package/lib/sexpr/classes/PadChamfer.ts +0 -50
  80. package/lib/sexpr/classes/PadChamferRatio.ts +0 -9
  81. package/lib/sexpr/classes/PadClearance.ts +0 -9
  82. package/lib/sexpr/classes/PadDieLength.ts +0 -9
  83. package/lib/sexpr/classes/PadDrill.ts +0 -145
  84. package/lib/sexpr/classes/PadDrillOffset.ts +0 -54
  85. package/lib/sexpr/classes/PadLayers.ts +0 -71
  86. package/lib/sexpr/classes/PadNet.ts +0 -56
  87. package/lib/sexpr/classes/PadOptions.ts +0 -181
  88. package/lib/sexpr/classes/PadPinFunction.ts +0 -9
  89. package/lib/sexpr/classes/PadPinType.ts +0 -9
  90. package/lib/sexpr/classes/PadPrimitiveGrArc.ts +0 -272
  91. package/lib/sexpr/classes/PadPrimitiveGrCircle.ts +0 -298
  92. package/lib/sexpr/classes/PadPrimitiveGrLine.ts +0 -126
  93. package/lib/sexpr/classes/PadPrimitives.ts +0 -291
  94. package/lib/sexpr/classes/PadRectDelta.ts +0 -57
  95. package/lib/sexpr/classes/PadRoundrectRratio.ts +0 -9
  96. package/lib/sexpr/classes/PadSize.ts +0 -69
  97. package/lib/sexpr/classes/PadSolderMaskMargin.ts +0 -9
  98. package/lib/sexpr/classes/PadSolderPasteMargin.ts +0 -9
  99. package/lib/sexpr/classes/PadSolderPasteMarginRatio.ts +0 -9
  100. package/lib/sexpr/classes/PadTeardrops.ts +0 -210
  101. package/lib/sexpr/classes/PadThermalBridgeAngle.ts +0 -9
  102. package/lib/sexpr/classes/PadThermalGap.ts +0 -9
  103. package/lib/sexpr/classes/PadThermalWidth.ts +0 -9
  104. package/lib/sexpr/classes/PadZoneConnect.ts +0 -9
  105. package/lib/sexpr/classes/Paper.ts +0 -119
  106. package/lib/sexpr/classes/PcbGeneral.ts +0 -82
  107. package/lib/sexpr/classes/PcbGeneralLegacyTeardrops.ts +0 -44
  108. package/lib/sexpr/classes/PcbGeneralThickness.ts +0 -9
  109. package/lib/sexpr/classes/PcbGenerator.ts +0 -16
  110. package/lib/sexpr/classes/PcbGeneratorVersion.ts +0 -16
  111. package/lib/sexpr/classes/PcbLayerDefinition.ts +0 -106
  112. package/lib/sexpr/classes/PcbLayers.ts +0 -34
  113. package/lib/sexpr/classes/PcbNet.ts +0 -56
  114. package/lib/sexpr/classes/PcbVersion.ts +0 -9
  115. package/lib/sexpr/classes/Property.ts +0 -301
  116. package/lib/sexpr/classes/PropertyHide.ts +0 -9
  117. package/lib/sexpr/classes/PropertyUnlocked.ts +0 -9
  118. package/lib/sexpr/classes/Pts.ts +0 -67
  119. package/lib/sexpr/classes/RenderCache.ts +0 -221
  120. package/lib/sexpr/classes/SchematicText.ts +0 -171
  121. package/lib/sexpr/classes/Segment.ts +0 -243
  122. package/lib/sexpr/classes/SegmentEnd.ts +0 -59
  123. package/lib/sexpr/classes/SegmentLocked.ts +0 -33
  124. package/lib/sexpr/classes/SegmentNet.ts +0 -64
  125. package/lib/sexpr/classes/SegmentStart.ts +0 -59
  126. package/lib/sexpr/classes/Setup/PcbPlotParams.ts +0 -689
  127. package/lib/sexpr/classes/Setup/PcbPlotParamsBase.ts +0 -9
  128. package/lib/sexpr/classes/Setup/PcbPlotParamsNumericProperties.ts +0 -105
  129. package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesA.ts +0 -104
  130. package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesB.ts +0 -105
  131. package/lib/sexpr/classes/Setup/Setup.ts +0 -574
  132. package/lib/sexpr/classes/Setup/SetupPropertyTypes.ts +0 -119
  133. package/lib/sexpr/classes/Setup/Stackup.ts +0 -135
  134. package/lib/sexpr/classes/Setup/StackupLayer.ts +0 -233
  135. package/lib/sexpr/classes/Setup/StackupLayerProperties.ts +0 -80
  136. package/lib/sexpr/classes/Setup/StackupProperties.ts +0 -40
  137. package/lib/sexpr/classes/Setup/base.ts +0 -165
  138. package/lib/sexpr/classes/Setup/index.ts +0 -14
  139. package/lib/sexpr/classes/Setup/setupMultiValueProperties.ts +0 -53
  140. package/lib/sexpr/classes/Setup/setupNumericProperties.ts +0 -151
  141. package/lib/sexpr/classes/Setup/setupPropertyHandlers.ts +0 -90
  142. package/lib/sexpr/classes/Setup/setupStringProperties.ts +0 -75
  143. package/lib/sexpr/classes/Sheet.ts +0 -287
  144. package/lib/sexpr/classes/SheetFill.ts +0 -44
  145. package/lib/sexpr/classes/SheetInstances.ts +0 -168
  146. package/lib/sexpr/classes/SheetInstancesRoot.ts +0 -165
  147. package/lib/sexpr/classes/SheetPin.ts +0 -125
  148. package/lib/sexpr/classes/SheetProperty.ts +0 -115
  149. package/lib/sexpr/classes/SheetSize.ts +0 -44
  150. package/lib/sexpr/classes/Stroke.ts +0 -58
  151. package/lib/sexpr/classes/StrokeType.ts +0 -34
  152. package/lib/sexpr/classes/Symbol.ts +0 -1666
  153. package/lib/sexpr/classes/TextEffects.ts +0 -461
  154. package/lib/sexpr/classes/TitleBlock.ts +0 -369
  155. package/lib/sexpr/classes/Unit.ts +0 -28
  156. package/lib/sexpr/classes/Uuid.ts +0 -8
  157. package/lib/sexpr/classes/Via.ts +0 -363
  158. package/lib/sexpr/classes/ViaNet.ts +0 -60
  159. package/lib/sexpr/classes/Width.ts +0 -8
  160. package/lib/sexpr/classes/Wire.ts +0 -111
  161. package/lib/sexpr/classes/Xy.ts +0 -33
  162. package/lib/sexpr/classes/Zone.ts +0 -39
  163. package/lib/sexpr/index.ts +0 -130
  164. package/lib/sexpr/parseKicadSexpr.ts +0 -5
  165. package/lib/sexpr/parseToPrimitiveSExpr.ts +0 -245
  166. package/lib/sexpr/utils/indentLines.ts +0 -3
  167. package/lib/sexpr/utils/parseYesNo.ts +0 -12
  168. package/lib/sexpr/utils/quoteSExprString.ts +0 -8
  169. package/lib/sexpr/utils/strokeFromArgs.ts +0 -18
  170. package/lib/sexpr/utils/toNumberValue.ts +0 -13
  171. package/lib/sexpr/utils/toStringValue.ts +0 -11
  172. package/scripts/download-references.ts +0 -68
  173. package/tests/fixtures/expectEqualPrimitiveSExpr.ts +0 -199
  174. package/tests/fixtures/png-matcher.ts +0 -109
  175. package/tests/fixtures/preload.ts +0 -1
  176. package/tests/sexpr/KicadPcbDemos.test.ts +0 -48
  177. package/tests/sexpr/KicadSchDemos.test.ts +0 -49
  178. package/tests/sexpr/classes/Footprint.test.ts +0 -277
  179. package/tests/sexpr/classes/FootprintPad.test.ts +0 -78
  180. package/tests/sexpr/classes/FpArc.test.ts +0 -45
  181. package/tests/sexpr/classes/FpCircle.test.ts +0 -39
  182. package/tests/sexpr/classes/FpPoly.test.ts +0 -43
  183. package/tests/sexpr/classes/FpRect.test.ts +0 -40
  184. package/tests/sexpr/classes/FpTextBox.test.ts +0 -84
  185. package/tests/sexpr/classes/Image.test.ts +0 -58
  186. package/tests/sexpr/classes/KicadSch.test.ts +0 -95
  187. package/tests/sexpr/classes/Paper.test.ts +0 -30
  188. package/tests/sexpr/classes/Property.test.ts +0 -48
  189. package/tests/sexpr/classes/Setup.test.ts +0 -188
  190. package/tests/sexpr/classes/Sheet.test.ts +0 -107
  191. package/tests/sexpr/classes/Stroke.test.ts +0 -15
  192. package/tests/sexpr/classes/Symbol.test.ts +0 -96
  193. package/tests/sexpr/classes/TextEffects.test.ts +0 -56
  194. package/tests/sexpr/classes/TitleBlock.test.ts +0 -40
  195. package/tsconfig.json +0 -35
@@ -1,849 +0,0 @@
1
- import { SxClass } from "../base-classes/SxClass"
2
- import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
- import { quoteSExprString } from "../utils/quoteSExprString"
4
- import { At, type AtInput } from "./At"
5
- import { FootprintAttr } from "./FootprintAttr"
6
- import { FootprintAutoplaceCost180 } from "./FootprintAutoplaceCost180"
7
- import { FootprintAutoplaceCost90 } from "./FootprintAutoplaceCost90"
8
- import { FootprintClearance } from "./FootprintClearance"
9
- import { FootprintDescr } from "./FootprintDescr"
10
- import { FootprintNetTiePadGroups } from "./FootprintNetTiePadGroups"
11
- import { FootprintPath } from "./FootprintPath"
12
- import { FootprintPrivateLayers } from "./FootprintPrivateLayers"
13
- import { FootprintSolderMaskMargin } from "./FootprintSolderMaskMargin"
14
- import { FootprintSolderPasteMargin } from "./FootprintSolderPasteMargin"
15
- import { FootprintSolderPasteRatio } from "./FootprintSolderPasteRatio"
16
- import { FootprintTags } from "./FootprintTags"
17
- import { FootprintTedit } from "./FootprintTedit"
18
- import { FootprintThermalGap } from "./FootprintThermalGap"
19
- import { FootprintThermalWidth } from "./FootprintThermalWidth"
20
- import { FootprintZoneConnect } from "./FootprintZoneConnect"
21
- import { FootprintPad } from "./FootprintPad"
22
- import { Property } from "./Property"
23
- import { Layer } from "./Layer"
24
- import { FpText } from "./FpText"
25
- import { FpTextBox } from "./FpTextBox"
26
- import { FpRect } from "./FpRect"
27
- import { FpCircle } from "./FpCircle"
28
- import { FpArc } from "./FpArc"
29
- import { FpPoly } from "./FpPoly"
30
- import { Uuid } from "./Uuid"
31
- import { Xy } from "./Xy"
32
- import { FootprintSheetname } from "./FootprintSheetname"
33
- import { FootprintSheetfile } from "./FootprintSheetfile"
34
- import { FpLine } from "./FpLine"
35
- import { FootprintModel } from "./FootprintModel"
36
- import { EmbeddedFonts } from "./EmbeddedFonts"
37
- import { FootprintLocked } from "./FootprintLocked"
38
- import { FootprintPlaced } from "./FootprintPlaced"
39
-
40
- const SINGLE_TOKENS = new Set([
41
- "layer",
42
- "locked",
43
- "placed",
44
- "tedit",
45
- "uuid",
46
- "at",
47
- "xy",
48
- "descr",
49
- "tags",
50
- "path",
51
- "autoplace_cost90",
52
- "autoplace_cost180",
53
- "solder_mask_margin",
54
- "solder_paste_margin",
55
- "solder_paste_ratio",
56
- "clearance",
57
- "zone_connect",
58
- "thermal_width",
59
- "thermal_gap",
60
- "attr",
61
- "private_layers",
62
- "net_tie_pad_groups",
63
- "sheetname",
64
- "sheetfile",
65
- "embedded_fonts",
66
- ])
67
-
68
- const MULTI_TOKENS = new Set([
69
- "property",
70
- "fp_text",
71
- "fp_text_box",
72
- "fp_line",
73
- "fp_rect",
74
- "fp_circle",
75
- "fp_arc",
76
- "fp_poly",
77
- "pad",
78
- "model",
79
- ])
80
-
81
- const SUPPORTED_TOKENS = new Set([...SINGLE_TOKENS, ...MULTI_TOKENS])
82
-
83
- export interface FootprintConstructorParams {
84
- libraryLink?: string
85
- locked?: boolean
86
- placed?: boolean
87
- layer?: Layer | string | string[]
88
- uuid?: Uuid | string
89
- at?: AtInput | Xy
90
- descr?: string | FootprintDescr
91
- tags?: string | string[] | FootprintTags
92
- path?: string | FootprintPath
93
- autoplaceCost90?: number | FootprintAutoplaceCost90
94
- autoplaceCost180?: number | FootprintAutoplaceCost180
95
- solderMaskMargin?: number | FootprintSolderMaskMargin
96
- solderPasteMargin?: number | FootprintSolderPasteMargin
97
- solderPasteRatio?: number | FootprintSolderPasteRatio
98
- clearance?: number | FootprintClearance
99
- zoneConnect?: number | FootprintZoneConnect
100
- thermalWidth?: number | FootprintThermalWidth
101
- thermalGap?: number | FootprintThermalGap
102
- attr?: FootprintAttr
103
- privateLayers?: FootprintPrivateLayers
104
- netTiePadGroups?: FootprintNetTiePadGroups
105
- sheetname?: string | FootprintSheetname
106
- sheetfile?: string | FootprintSheetfile
107
- embeddedFonts?: EmbeddedFonts
108
- properties?: Property[]
109
- fpTexts?: FpText[]
110
- fpTextBoxes?: FpTextBox[]
111
- fpLines?: FpLine[]
112
- fpRects?: FpRect[]
113
- fpCircles?: FpCircle[]
114
- fpArcs?: FpArc[]
115
- fpPolys?: FpPoly[]
116
- pads?: FootprintPad[]
117
- models?: FootprintModel[]
118
- }
119
-
120
- export class Footprint extends SxClass {
121
- static override token = "footprint"
122
- token = "footprint"
123
-
124
- private _libraryLink?: string
125
- private _sxLocked?: FootprintLocked
126
- private _sxPlaced?: FootprintPlaced
127
-
128
- private _sxLayer?: Layer
129
- private _sxTedit?: FootprintTedit
130
- private _sxUuid?: Uuid
131
- private _sxAt?: At
132
- private _sxXy?: Xy
133
- private _sxDescr?: FootprintDescr
134
- private _sxTags?: FootprintTags
135
- private _sxPath?: FootprintPath
136
- private _sxAutoplaceCost90?: FootprintAutoplaceCost90
137
- private _sxAutoplaceCost180?: FootprintAutoplaceCost180
138
- private _sxSolderMaskMargin?: FootprintSolderMaskMargin
139
- private _sxSolderPasteMargin?: FootprintSolderPasteMargin
140
- private _sxSolderPasteRatio?: FootprintSolderPasteRatio
141
- private _sxClearance?: FootprintClearance
142
- private _sxZoneConnect?: FootprintZoneConnect
143
- private _sxThermalWidth?: FootprintThermalWidth
144
- private _sxThermalGap?: FootprintThermalGap
145
- private _sxAttr?: FootprintAttr
146
- private _sxPrivateLayers?: FootprintPrivateLayers
147
- private _sxNetTiePadGroups?: FootprintNetTiePadGroups
148
- private _sxSheetname?: FootprintSheetname
149
- private _sxSheetfile?: FootprintSheetfile
150
- private _sxEmbeddedFonts?: EmbeddedFonts
151
-
152
- private _properties: Property[] = []
153
- private _fpTexts: FpText[] = []
154
- private _fpTextBoxes: FpTextBox[] = []
155
- private _fpLines: FpLine[] = []
156
- private _fpRects: FpRect[] = []
157
- private _fpCircles: FpCircle[] = []
158
- private _fpArcs: FpArc[] = []
159
- private _fpPolys: FpPoly[] = []
160
- private _fpPads: FootprintPad[] = []
161
- private _models: FootprintModel[] = []
162
-
163
- constructor(params: FootprintConstructorParams = {}) {
164
- super()
165
- if (params.libraryLink !== undefined) this.libraryLink = params.libraryLink
166
- if (params.locked !== undefined) this.locked = params.locked
167
- if (params.placed !== undefined) this.placed = params.placed
168
- if (params.layer !== undefined) this.layer = params.layer
169
- if (params.uuid !== undefined) this.uuid = params.uuid
170
- if (params.at !== undefined) this.position = params.at
171
- if (params.descr !== undefined) this.descr = params.descr
172
- if (params.tags !== undefined) this.tags = params.tags
173
- if (params.path !== undefined) this.path = params.path
174
- if (params.autoplaceCost90 !== undefined)
175
- this.autoplaceCost90 = params.autoplaceCost90
176
- if (params.autoplaceCost180 !== undefined)
177
- this.autoplaceCost180 = params.autoplaceCost180
178
- if (params.solderMaskMargin !== undefined)
179
- this.solderMaskMargin = params.solderMaskMargin
180
- if (params.solderPasteMargin !== undefined)
181
- this.solderPasteMargin = params.solderPasteMargin
182
- if (params.solderPasteRatio !== undefined)
183
- this.solderPasteRatio = params.solderPasteRatio
184
- if (params.clearance !== undefined) this.clearance = params.clearance
185
- if (params.zoneConnect !== undefined) this.zoneConnect = params.zoneConnect
186
- if (params.thermalWidth !== undefined)
187
- this.thermalWidth = params.thermalWidth
188
- if (params.thermalGap !== undefined) this.thermalGap = params.thermalGap
189
- if (params.attr !== undefined) this.attr = params.attr
190
- if (params.privateLayers !== undefined)
191
- this.privateLayers = params.privateLayers
192
- if (params.netTiePadGroups !== undefined)
193
- this.netTiePadGroups = params.netTiePadGroups
194
- if (params.sheetname !== undefined) this.sheetname = params.sheetname
195
- if (params.sheetfile !== undefined) this.sheetfile = params.sheetfile
196
- if (params.embeddedFonts !== undefined)
197
- this.embeddedFonts = params.embeddedFonts
198
- if (params.properties !== undefined) this.properties = params.properties
199
- if (params.fpTexts !== undefined) this.fpTexts = params.fpTexts
200
- if (params.fpTextBoxes !== undefined) this.fpTextBoxes = params.fpTextBoxes
201
- if (params.fpLines !== undefined) this.fpLines = params.fpLines
202
- if (params.fpRects !== undefined) this.fpRects = params.fpRects
203
- if (params.fpCircles !== undefined) this.fpCircles = params.fpCircles
204
- if (params.fpArcs !== undefined) this.fpArcs = params.fpArcs
205
- if (params.fpPolys !== undefined) this.fpPolys = params.fpPolys
206
- if (params.pads !== undefined) this.fpPads = params.pads
207
- if (params.models !== undefined) this.models = params.models
208
- }
209
-
210
- static override fromSexprPrimitives(
211
- primitiveSexprs: PrimitiveSExpr[],
212
- ): Footprint {
213
- const footprint = new Footprint()
214
-
215
- const rawStrings: string[] = []
216
- const rawNodes: PrimitiveSExpr[] = []
217
-
218
- for (const primitive of primitiveSexprs) {
219
- if (typeof primitive === "string") {
220
- rawStrings.push(primitive)
221
- continue
222
- }
223
- if (Array.isArray(primitive)) {
224
- rawNodes.push(primitive)
225
- continue
226
- }
227
- throw new Error(
228
- `footprint encountered unsupported primitive child: ${JSON.stringify(primitive)}`,
229
- )
230
- }
231
-
232
- let pendingFlags: string[] = []
233
- if (rawStrings.length > 0) {
234
- footprint._libraryLink = rawStrings[0]
235
- pendingFlags = rawStrings.slice(1)
236
- }
237
-
238
- const { propertyMap, arrayPropertyMap } =
239
- SxClass.parsePrimitivesToClassProperties(rawNodes, this.token)
240
-
241
- for (const token of Object.keys(propertyMap)) {
242
- if (!SUPPORTED_TOKENS.has(token)) {
243
- throw new Error(
244
- `footprint encountered unsupported child token "${token}"`,
245
- )
246
- }
247
- }
248
-
249
- for (const [token, entries] of Object.entries(arrayPropertyMap)) {
250
- if (!SUPPORTED_TOKENS.has(token)) {
251
- throw new Error(
252
- `footprint encountered unsupported child token "${token}"`,
253
- )
254
- }
255
- if (!MULTI_TOKENS.has(token) && entries.length > 1) {
256
- throw new Error(
257
- `footprint does not support repeated child token "${token}"`,
258
- )
259
- }
260
- }
261
-
262
- footprint._sxLocked = propertyMap.locked as FootprintLocked | undefined
263
- if (footprint._sxLocked && !footprint._sxLocked.value) {
264
- footprint._sxLocked = undefined
265
- }
266
- footprint._sxPlaced = propertyMap.placed as FootprintPlaced | undefined
267
- if (footprint._sxPlaced && !footprint._sxPlaced.value) {
268
- footprint._sxPlaced = undefined
269
- }
270
- footprint._sxLayer = propertyMap.layer as Layer | undefined
271
- footprint._sxTedit = propertyMap.tedit as FootprintTedit | undefined
272
- footprint._sxUuid = propertyMap.uuid as Uuid | undefined
273
- footprint._sxAt = propertyMap.at as At | undefined
274
- footprint._sxXy = propertyMap.xy as Xy | undefined
275
- if (footprint._sxAt && footprint._sxXy) {
276
- throw new Error("footprint cannot include both at and xy children")
277
- }
278
- footprint._sxDescr = propertyMap.descr as FootprintDescr | undefined
279
- footprint._sxTags = propertyMap.tags as FootprintTags | undefined
280
- footprint._sxPath = propertyMap.path as FootprintPath | undefined
281
- footprint._sxAutoplaceCost90 = propertyMap.autoplace_cost90 as
282
- | FootprintAutoplaceCost90
283
- | undefined
284
- footprint._sxAutoplaceCost180 = propertyMap.autoplace_cost180 as
285
- | FootprintAutoplaceCost180
286
- | undefined
287
- footprint._sxSolderMaskMargin = propertyMap.solder_mask_margin as
288
- | FootprintSolderMaskMargin
289
- | undefined
290
- footprint._sxSolderPasteMargin = propertyMap.solder_paste_margin as
291
- | FootprintSolderPasteMargin
292
- | undefined
293
- footprint._sxSolderPasteRatio = propertyMap.solder_paste_ratio as
294
- | FootprintSolderPasteRatio
295
- | undefined
296
- footprint._sxClearance = propertyMap.clearance as
297
- | FootprintClearance
298
- | undefined
299
- footprint._sxZoneConnect = propertyMap.zone_connect as
300
- | FootprintZoneConnect
301
- | undefined
302
- footprint._sxThermalWidth = propertyMap.thermal_width as
303
- | FootprintThermalWidth
304
- | undefined
305
- footprint._sxThermalGap = propertyMap.thermal_gap as
306
- | FootprintThermalGap
307
- | undefined
308
- footprint._sxAttr = propertyMap.attr as FootprintAttr | undefined
309
- footprint._sxPrivateLayers = propertyMap.private_layers as
310
- | FootprintPrivateLayers
311
- | undefined
312
- footprint._sxNetTiePadGroups = propertyMap.net_tie_pad_groups as
313
- | FootprintNetTiePadGroups
314
- | undefined
315
- footprint._sxSheetname = propertyMap.sheetname as
316
- | FootprintSheetname
317
- | undefined
318
- footprint._sxSheetfile = propertyMap.sheetfile as
319
- | FootprintSheetfile
320
- | undefined
321
- footprint._sxEmbeddedFonts = propertyMap.embedded_fonts as
322
- | EmbeddedFonts
323
- | undefined
324
-
325
- footprint._properties = (arrayPropertyMap.property as Property[]) ?? []
326
- footprint._fpTexts = (arrayPropertyMap["fp_text"] as FpText[]) ?? []
327
- footprint._fpTextBoxes =
328
- (arrayPropertyMap["fp_text_box"] as FpTextBox[]) ?? []
329
- footprint._fpLines = (arrayPropertyMap["fp_line"] as FpLine[]) ?? []
330
- footprint._fpRects = (arrayPropertyMap["fp_rect"] as FpRect[]) ?? []
331
- footprint._fpCircles = (arrayPropertyMap["fp_circle"] as FpCircle[]) ?? []
332
- footprint._fpArcs = (arrayPropertyMap["fp_arc"] as FpArc[]) ?? []
333
- footprint._fpPolys = (arrayPropertyMap["fp_poly"] as FpPoly[]) ?? []
334
- footprint._fpPads = (arrayPropertyMap.pad as FootprintPad[]) ?? []
335
- footprint._models = (arrayPropertyMap.model as FootprintModel[]) ?? []
336
-
337
- for (const flag of pendingFlags) {
338
- if (flag === "locked") {
339
- if (footprint._sxLocked) {
340
- throw new Error("footprint encountered duplicate locked tokens")
341
- }
342
- footprint._sxLocked = new FootprintLocked(true)
343
- continue
344
- }
345
- if (flag === "placed") {
346
- if (footprint._sxPlaced) {
347
- throw new Error("footprint encountered duplicate placed tokens")
348
- }
349
- footprint._sxPlaced = new FootprintPlaced(true)
350
- continue
351
- }
352
- throw new Error(`footprint encountered unsupported flag "${flag}"`)
353
- }
354
-
355
- return footprint
356
- }
357
-
358
- get libraryLink(): string | undefined {
359
- return this._libraryLink
360
- }
361
-
362
- set libraryLink(value: string | undefined) {
363
- this._libraryLink = value
364
- }
365
-
366
- get locked(): boolean {
367
- return this._sxLocked?.value ?? false
368
- }
369
-
370
- set locked(value: FootprintLocked | boolean | undefined) {
371
- if (value === undefined) {
372
- this._sxLocked = undefined
373
- return
374
- }
375
- if (value instanceof FootprintLocked) {
376
- this._sxLocked = value.value ? value : undefined
377
- return
378
- }
379
- this._sxLocked = value ? new FootprintLocked(true) : undefined
380
- }
381
-
382
- get placed(): boolean {
383
- return this._sxPlaced?.value ?? false
384
- }
385
-
386
- set placed(value: FootprintPlaced | boolean | undefined) {
387
- if (value === undefined) {
388
- this._sxPlaced = undefined
389
- return
390
- }
391
- if (value instanceof FootprintPlaced) {
392
- this._sxPlaced = value.value ? value : undefined
393
- return
394
- }
395
- this._sxPlaced = value ? new FootprintPlaced(true) : undefined
396
- }
397
-
398
- get layer(): Layer | undefined {
399
- return this._sxLayer
400
- }
401
-
402
- set layer(value: Layer | string | string[] | undefined) {
403
- if (value === undefined) {
404
- this._sxLayer = undefined
405
- return
406
- }
407
- if (value instanceof Layer) {
408
- this._sxLayer = value
409
- } else {
410
- const names = Array.isArray(value) ? value : [value]
411
- this._sxLayer = new Layer(names)
412
- }
413
- }
414
-
415
- get tedit(): FootprintTedit | undefined {
416
- return this._sxTedit
417
- }
418
-
419
- set tedit(value: FootprintTedit | string | undefined) {
420
- if (value === undefined) {
421
- this._sxTedit = undefined
422
- return
423
- }
424
- this._sxTedit =
425
- value instanceof FootprintTedit ? value : new FootprintTedit(value)
426
- }
427
-
428
- get uuid(): Uuid | undefined {
429
- return this._sxUuid
430
- }
431
-
432
- set uuid(value: Uuid | string | undefined) {
433
- if (value === undefined) {
434
- this._sxUuid = undefined
435
- return
436
- }
437
- this._sxUuid = value instanceof Uuid ? value : new Uuid(value)
438
- }
439
-
440
- get position(): At | Xy | undefined {
441
- return this._sxAt ?? this._sxXy
442
- }
443
-
444
- set position(value: AtInput | Xy | undefined) {
445
- if (value === undefined) {
446
- this._sxAt = undefined
447
- this._sxXy = undefined
448
- return
449
- }
450
- if (value instanceof Xy) {
451
- this._sxXy = value
452
- this._sxAt = undefined
453
- return
454
- }
455
- // Handle AtInput (At, array, or object)
456
- this._sxAt = At.from(value as AtInput)
457
- this._sxXy = undefined
458
- }
459
-
460
- get descr(): FootprintDescr | undefined {
461
- return this._sxDescr
462
- }
463
-
464
- set descr(value: FootprintDescr | string | undefined) {
465
- if (value === undefined) {
466
- this._sxDescr = undefined
467
- return
468
- }
469
- this._sxDescr =
470
- value instanceof FootprintDescr ? value : new FootprintDescr(value)
471
- }
472
-
473
- get tags(): FootprintTags | undefined {
474
- return this._sxTags
475
- }
476
-
477
- set tags(value: string | string[] | FootprintTags | undefined) {
478
- if (value === undefined) {
479
- this._sxTags = undefined
480
- return
481
- }
482
- if (value instanceof FootprintTags) {
483
- this._sxTags = value
484
- return
485
- }
486
- const tagString = Array.isArray(value) ? value.join(" ") : value
487
- this._sxTags = new FootprintTags(tagString)
488
- }
489
-
490
- get path(): FootprintPath | undefined {
491
- return this._sxPath
492
- }
493
-
494
- set path(value: FootprintPath | string | undefined) {
495
- if (value === undefined) {
496
- this._sxPath = undefined
497
- return
498
- }
499
- this._sxPath =
500
- value instanceof FootprintPath ? value : new FootprintPath(value)
501
- }
502
-
503
- get autoplaceCost90(): FootprintAutoplaceCost90 | undefined {
504
- return this._sxAutoplaceCost90
505
- }
506
-
507
- set autoplaceCost90(value: FootprintAutoplaceCost90 | number | undefined) {
508
- if (value === undefined) {
509
- this._sxAutoplaceCost90 = undefined
510
- return
511
- }
512
- this._sxAutoplaceCost90 =
513
- value instanceof FootprintAutoplaceCost90
514
- ? value
515
- : new FootprintAutoplaceCost90(value)
516
- }
517
-
518
- get autoplaceCost180(): FootprintAutoplaceCost180 | undefined {
519
- return this._sxAutoplaceCost180
520
- }
521
-
522
- set autoplaceCost180(value: FootprintAutoplaceCost180 | number | undefined) {
523
- if (value === undefined) {
524
- this._sxAutoplaceCost180 = undefined
525
- return
526
- }
527
- this._sxAutoplaceCost180 =
528
- value instanceof FootprintAutoplaceCost180
529
- ? value
530
- : new FootprintAutoplaceCost180(value)
531
- }
532
-
533
- get solderMaskMargin(): FootprintSolderMaskMargin | undefined {
534
- return this._sxSolderMaskMargin
535
- }
536
-
537
- set solderMaskMargin(value: FootprintSolderMaskMargin | number | undefined) {
538
- if (value === undefined) {
539
- this._sxSolderMaskMargin = undefined
540
- return
541
- }
542
- this._sxSolderMaskMargin =
543
- value instanceof FootprintSolderMaskMargin
544
- ? value
545
- : new FootprintSolderMaskMargin(value)
546
- }
547
-
548
- get solderPasteMargin(): FootprintSolderPasteMargin | undefined {
549
- return this._sxSolderPasteMargin
550
- }
551
-
552
- set solderPasteMargin(value:
553
- | FootprintSolderPasteMargin
554
- | number
555
- | undefined) {
556
- if (value === undefined) {
557
- this._sxSolderPasteMargin = undefined
558
- return
559
- }
560
- this._sxSolderPasteMargin =
561
- value instanceof FootprintSolderPasteMargin
562
- ? value
563
- : new FootprintSolderPasteMargin(value)
564
- }
565
-
566
- get solderPasteRatio(): FootprintSolderPasteRatio | undefined {
567
- return this._sxSolderPasteRatio
568
- }
569
-
570
- set solderPasteRatio(value: FootprintSolderPasteRatio | number | undefined) {
571
- if (value === undefined) {
572
- this._sxSolderPasteRatio = undefined
573
- return
574
- }
575
- this._sxSolderPasteRatio =
576
- value instanceof FootprintSolderPasteRatio
577
- ? value
578
- : new FootprintSolderPasteRatio(value)
579
- }
580
-
581
- get clearance(): FootprintClearance | undefined {
582
- return this._sxClearance
583
- }
584
-
585
- set clearance(value: FootprintClearance | number | undefined) {
586
- if (value === undefined) {
587
- this._sxClearance = undefined
588
- return
589
- }
590
- this._sxClearance =
591
- value instanceof FootprintClearance
592
- ? value
593
- : new FootprintClearance(value)
594
- }
595
-
596
- get zoneConnect(): FootprintZoneConnect | undefined {
597
- return this._sxZoneConnect
598
- }
599
-
600
- set zoneConnect(value: FootprintZoneConnect | number | undefined) {
601
- if (value === undefined) {
602
- this._sxZoneConnect = undefined
603
- return
604
- }
605
- this._sxZoneConnect =
606
- value instanceof FootprintZoneConnect
607
- ? value
608
- : new FootprintZoneConnect(value)
609
- }
610
-
611
- get thermalWidth(): FootprintThermalWidth | undefined {
612
- return this._sxThermalWidth
613
- }
614
-
615
- set thermalWidth(value: FootprintThermalWidth | number | undefined) {
616
- if (value === undefined) {
617
- this._sxThermalWidth = undefined
618
- return
619
- }
620
- this._sxThermalWidth =
621
- value instanceof FootprintThermalWidth
622
- ? value
623
- : new FootprintThermalWidth(value)
624
- }
625
-
626
- get thermalGap(): FootprintThermalGap | undefined {
627
- return this._sxThermalGap
628
- }
629
-
630
- set thermalGap(value: FootprintThermalGap | number | undefined) {
631
- if (value === undefined) {
632
- this._sxThermalGap = undefined
633
- return
634
- }
635
- this._sxThermalGap =
636
- value instanceof FootprintThermalGap
637
- ? value
638
- : new FootprintThermalGap(value)
639
- }
640
-
641
- get attr(): FootprintAttr | undefined {
642
- return this._sxAttr
643
- }
644
-
645
- set attr(value: FootprintAttr | undefined) {
646
- this._sxAttr = value
647
- }
648
-
649
- get privateLayers(): FootprintPrivateLayers | undefined {
650
- return this._sxPrivateLayers
651
- }
652
-
653
- set privateLayers(value: FootprintPrivateLayers | string[] | undefined) {
654
- if (value === undefined) {
655
- this._sxPrivateLayers = undefined
656
- return
657
- }
658
- this._sxPrivateLayers =
659
- value instanceof FootprintPrivateLayers
660
- ? value
661
- : new FootprintPrivateLayers(value)
662
- }
663
-
664
- get netTiePadGroups(): FootprintNetTiePadGroups | undefined {
665
- return this._sxNetTiePadGroups
666
- }
667
-
668
- set netTiePadGroups(value: FootprintNetTiePadGroups | string[] | undefined) {
669
- if (value === undefined) {
670
- this._sxNetTiePadGroups = undefined
671
- return
672
- }
673
- this._sxNetTiePadGroups =
674
- value instanceof FootprintNetTiePadGroups
675
- ? value
676
- : new FootprintNetTiePadGroups(value)
677
- }
678
-
679
- get sheetname(): string | undefined {
680
- return this._sxSheetname?.value
681
- }
682
-
683
- set sheetname(value: string | FootprintSheetname | undefined) {
684
- if (value === undefined) {
685
- this._sxSheetname = undefined
686
- return
687
- }
688
- this._sxSheetname =
689
- value instanceof FootprintSheetname
690
- ? value
691
- : new FootprintSheetname(value)
692
- }
693
-
694
- get sheetfile(): string | undefined {
695
- return this._sxSheetfile?.value
696
- }
697
-
698
- set sheetfile(value: string | FootprintSheetfile | undefined) {
699
- if (value === undefined) {
700
- this._sxSheetfile = undefined
701
- return
702
- }
703
- this._sxSheetfile =
704
- value instanceof FootprintSheetfile
705
- ? value
706
- : new FootprintSheetfile(value)
707
- }
708
-
709
- get embeddedFonts(): EmbeddedFonts | undefined {
710
- return this._sxEmbeddedFonts
711
- }
712
-
713
- set embeddedFonts(value: EmbeddedFonts | undefined) {
714
- this._sxEmbeddedFonts = value
715
- }
716
-
717
- get properties(): Property[] {
718
- return [...this._properties]
719
- }
720
-
721
- set properties(value: Property[]) {
722
- this._properties = [...value]
723
- }
724
-
725
- get fpTexts(): FpText[] {
726
- return [...this._fpTexts]
727
- }
728
-
729
- set fpTexts(value: FpText[]) {
730
- this._fpTexts = [...value]
731
- }
732
-
733
- get fpTextBoxes(): FpTextBox[] {
734
- return [...this._fpTextBoxes]
735
- }
736
-
737
- set fpTextBoxes(value: FpTextBox[]) {
738
- this._fpTextBoxes = [...value]
739
- }
740
-
741
- get fpLines(): FpLine[] {
742
- return [...this._fpLines]
743
- }
744
-
745
- set fpLines(value: FpLine[]) {
746
- this._fpLines = [...value]
747
- }
748
-
749
- get fpRects(): FpRect[] {
750
- return [...this._fpRects]
751
- }
752
-
753
- set fpRects(value: FpRect[]) {
754
- this._fpRects = [...value]
755
- }
756
-
757
- get fpCircles(): FpCircle[] {
758
- return [...this._fpCircles]
759
- }
760
-
761
- set fpCircles(value: FpCircle[]) {
762
- this._fpCircles = [...value]
763
- }
764
-
765
- get fpArcs(): FpArc[] {
766
- return [...this._fpArcs]
767
- }
768
-
769
- set fpArcs(value: FpArc[]) {
770
- this._fpArcs = [...value]
771
- }
772
-
773
- get fpPolys(): FpPoly[] {
774
- return [...this._fpPolys]
775
- }
776
-
777
- set fpPolys(value: FpPoly[]) {
778
- this._fpPolys = [...value]
779
- }
780
-
781
- get fpPads(): FootprintPad[] {
782
- return [...this._fpPads]
783
- }
784
-
785
- set fpPads(value: FootprintPad[]) {
786
- this._fpPads = [...value]
787
- }
788
-
789
- get models(): FootprintModel[] {
790
- return [...this._models]
791
- }
792
-
793
- set models(value: FootprintModel[]) {
794
- this._models = [...value]
795
- }
796
-
797
- override getChildren(): SxClass[] {
798
- const children: SxClass[] = []
799
- if (this._sxLocked) children.push(this._sxLocked)
800
- if (this._sxPlaced) children.push(this._sxPlaced)
801
- if (this._sxLayer) children.push(this._sxLayer)
802
- if (this._sxTedit) children.push(this._sxTedit)
803
- if (this._sxUuid) children.push(this._sxUuid)
804
- if (this._sxAt) children.push(this._sxAt)
805
- if (this._sxXy) children.push(this._sxXy)
806
- if (this._sxDescr) children.push(this._sxDescr)
807
- if (this._sxTags) children.push(this._sxTags)
808
- if (this._sxPath) children.push(this._sxPath)
809
- if (this._sxAutoplaceCost90) children.push(this._sxAutoplaceCost90)
810
- if (this._sxAutoplaceCost180) children.push(this._sxAutoplaceCost180)
811
- if (this._sxSolderMaskMargin) children.push(this._sxSolderMaskMargin)
812
- if (this._sxSolderPasteMargin) children.push(this._sxSolderPasteMargin)
813
- if (this._sxSolderPasteRatio) children.push(this._sxSolderPasteRatio)
814
- if (this._sxClearance) children.push(this._sxClearance)
815
- if (this._sxZoneConnect) children.push(this._sxZoneConnect)
816
- if (this._sxThermalWidth) children.push(this._sxThermalWidth)
817
- if (this._sxThermalGap) children.push(this._sxThermalGap)
818
- if (this._sxAttr) children.push(this._sxAttr)
819
- if (this._sxPrivateLayers) children.push(this._sxPrivateLayers)
820
- if (this._sxNetTiePadGroups) children.push(this._sxNetTiePadGroups)
821
- if (this._sxSheetname) children.push(this._sxSheetname)
822
- if (this._sxSheetfile) children.push(this._sxSheetfile)
823
- if (this._sxEmbeddedFonts) children.push(this._sxEmbeddedFonts)
824
- children.push(...this._properties)
825
- children.push(...this._fpTexts)
826
- children.push(...this._fpTextBoxes)
827
- children.push(...this._fpLines)
828
- children.push(...this._fpRects)
829
- children.push(...this._fpCircles)
830
- children.push(...this._fpArcs)
831
- children.push(...this._fpPolys)
832
- children.push(...this._fpPads)
833
- children.push(...this._models)
834
- return children
835
- }
836
-
837
- override getString(): string {
838
- const lines = ["(footprint"]
839
- if (this._libraryLink !== undefined) {
840
- lines.push(` ${quoteSExprString(this._libraryLink)}`)
841
- }
842
- for (const child of this.getChildren()) {
843
- lines.push(child.getStringIndented())
844
- }
845
- lines.push(")")
846
- return lines.join("\n")
847
- }
848
- }
849
- SxClass.register(Footprint)