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,719 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { quoteSExprString } from "../utils/quoteSExprString"
4
+ import { At } 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 class Footprint extends SxClass {
84
+ static override token = "footprint"
85
+ token = "footprint"
86
+
87
+ private _libraryLink?: string
88
+ private _sxLocked?: FootprintLocked
89
+ private _sxPlaced?: FootprintPlaced
90
+
91
+ private _sxLayer?: Layer
92
+ private _sxTedit?: FootprintTedit
93
+ private _sxUuid?: Uuid
94
+ private _sxAt?: At
95
+ private _sxXy?: Xy
96
+ private _sxDescr?: FootprintDescr
97
+ private _sxTags?: FootprintTags
98
+ private _sxPath?: FootprintPath
99
+ private _sxAutoplaceCost90?: FootprintAutoplaceCost90
100
+ private _sxAutoplaceCost180?: FootprintAutoplaceCost180
101
+ private _sxSolderMaskMargin?: FootprintSolderMaskMargin
102
+ private _sxSolderPasteMargin?: FootprintSolderPasteMargin
103
+ private _sxSolderPasteRatio?: FootprintSolderPasteRatio
104
+ private _sxClearance?: FootprintClearance
105
+ private _sxZoneConnect?: FootprintZoneConnect
106
+ private _sxThermalWidth?: FootprintThermalWidth
107
+ private _sxThermalGap?: FootprintThermalGap
108
+ private _sxAttr?: FootprintAttr
109
+ private _sxPrivateLayers?: FootprintPrivateLayers
110
+ private _sxNetTiePadGroups?: FootprintNetTiePadGroups
111
+ private _sxSheetname?: FootprintSheetname
112
+ private _sxSheetfile?: FootprintSheetfile
113
+ private _sxEmbeddedFonts?: EmbeddedFonts
114
+
115
+ private _properties: Property[] = []
116
+ private _fpTexts: FpText[] = []
117
+ private _fpTextBoxes: FpTextBox[] = []
118
+ private _fpLines: FpLine[] = []
119
+ private _fpRects: FpRect[] = []
120
+ private _fpCircles: FpCircle[] = []
121
+ private _fpArcs: FpArc[] = []
122
+ private _fpPolys: FpPoly[] = []
123
+ private _fpPads: FootprintPad[] = []
124
+ private _models: FootprintModel[] = []
125
+
126
+ static override fromSexprPrimitives(
127
+ primitiveSexprs: PrimitiveSExpr[],
128
+ ): Footprint {
129
+ const footprint = new Footprint()
130
+
131
+ const rawStrings: string[] = []
132
+ const rawNodes: PrimitiveSExpr[] = []
133
+
134
+ for (const primitive of primitiveSexprs) {
135
+ if (typeof primitive === "string") {
136
+ rawStrings.push(primitive)
137
+ continue
138
+ }
139
+ if (Array.isArray(primitive)) {
140
+ rawNodes.push(primitive)
141
+ continue
142
+ }
143
+ throw new Error(
144
+ `footprint encountered unsupported primitive child: ${JSON.stringify(primitive)}`,
145
+ )
146
+ }
147
+
148
+ let pendingFlags: string[] = []
149
+ if (rawStrings.length > 0) {
150
+ footprint._libraryLink = rawStrings[0]
151
+ pendingFlags = rawStrings.slice(1)
152
+ }
153
+
154
+ const { propertyMap, arrayPropertyMap } =
155
+ SxClass.parsePrimitivesToClassProperties(rawNodes, this.token)
156
+
157
+ for (const token of Object.keys(propertyMap)) {
158
+ if (!SUPPORTED_TOKENS.has(token)) {
159
+ throw new Error(`footprint encountered unsupported child token "${token}"`)
160
+ }
161
+ }
162
+
163
+ for (const [token, entries] of Object.entries(arrayPropertyMap)) {
164
+ if (!SUPPORTED_TOKENS.has(token)) {
165
+ throw new Error(`footprint encountered unsupported child token "${token}"`)
166
+ }
167
+ if (!MULTI_TOKENS.has(token) && entries.length > 1) {
168
+ throw new Error(`footprint does not support repeated child token "${token}"`)
169
+ }
170
+ }
171
+
172
+ footprint._sxLocked = propertyMap.locked as FootprintLocked | undefined
173
+ if (footprint._sxLocked && !footprint._sxLocked.value) {
174
+ footprint._sxLocked = undefined
175
+ }
176
+ footprint._sxPlaced = propertyMap.placed as FootprintPlaced | undefined
177
+ if (footprint._sxPlaced && !footprint._sxPlaced.value) {
178
+ footprint._sxPlaced = undefined
179
+ }
180
+ footprint._sxLayer = propertyMap.layer as Layer | undefined
181
+ footprint._sxTedit = propertyMap.tedit as FootprintTedit | undefined
182
+ footprint._sxUuid = propertyMap.uuid as Uuid | undefined
183
+ footprint._sxAt = propertyMap.at as At | undefined
184
+ footprint._sxXy = propertyMap.xy as Xy | undefined
185
+ if (footprint._sxAt && footprint._sxXy) {
186
+ throw new Error("footprint cannot include both at and xy children")
187
+ }
188
+ footprint._sxDescr = propertyMap.descr as FootprintDescr | undefined
189
+ footprint._sxTags = propertyMap.tags as FootprintTags | undefined
190
+ footprint._sxPath = propertyMap.path as FootprintPath | undefined
191
+ footprint._sxAutoplaceCost90 = propertyMap.autoplace_cost90 as
192
+ | FootprintAutoplaceCost90
193
+ | undefined
194
+ footprint._sxAutoplaceCost180 = propertyMap.autoplace_cost180 as
195
+ | FootprintAutoplaceCost180
196
+ | undefined
197
+ footprint._sxSolderMaskMargin = propertyMap.solder_mask_margin as
198
+ | FootprintSolderMaskMargin
199
+ | undefined
200
+ footprint._sxSolderPasteMargin = propertyMap.solder_paste_margin as
201
+ | FootprintSolderPasteMargin
202
+ | undefined
203
+ footprint._sxSolderPasteRatio = propertyMap.solder_paste_ratio as
204
+ | FootprintSolderPasteRatio
205
+ | undefined
206
+ footprint._sxClearance = propertyMap.clearance as FootprintClearance | undefined
207
+ footprint._sxZoneConnect = propertyMap.zone_connect as
208
+ | FootprintZoneConnect
209
+ | undefined
210
+ footprint._sxThermalWidth = propertyMap.thermal_width as
211
+ | FootprintThermalWidth
212
+ | undefined
213
+ footprint._sxThermalGap = propertyMap.thermal_gap as FootprintThermalGap | undefined
214
+ footprint._sxAttr = propertyMap.attr as FootprintAttr | undefined
215
+ footprint._sxPrivateLayers = propertyMap.private_layers as
216
+ | FootprintPrivateLayers
217
+ | undefined
218
+ footprint._sxNetTiePadGroups = propertyMap.net_tie_pad_groups as
219
+ | FootprintNetTiePadGroups
220
+ | undefined
221
+ footprint._sxSheetname = propertyMap.sheetname as FootprintSheetname | undefined
222
+ footprint._sxSheetfile = propertyMap.sheetfile as FootprintSheetfile | undefined
223
+ footprint._sxEmbeddedFonts = propertyMap.embedded_fonts as EmbeddedFonts | undefined
224
+
225
+ footprint._properties = (arrayPropertyMap.property as Property[]) ?? []
226
+ footprint._fpTexts = (arrayPropertyMap["fp_text"] as FpText[]) ?? []
227
+ footprint._fpTextBoxes =
228
+ (arrayPropertyMap["fp_text_box"] as FpTextBox[]) ?? []
229
+ footprint._fpLines = (arrayPropertyMap["fp_line"] as FpLine[]) ?? []
230
+ footprint._fpRects = (arrayPropertyMap["fp_rect"] as FpRect[]) ?? []
231
+ footprint._fpCircles = (arrayPropertyMap["fp_circle"] as FpCircle[]) ?? []
232
+ footprint._fpArcs = (arrayPropertyMap["fp_arc"] as FpArc[]) ?? []
233
+ footprint._fpPolys = (arrayPropertyMap["fp_poly"] as FpPoly[]) ?? []
234
+ footprint._fpPads = (arrayPropertyMap.pad as FootprintPad[]) ?? []
235
+ footprint._models = (arrayPropertyMap.model as FootprintModel[]) ?? []
236
+
237
+ for (const flag of pendingFlags) {
238
+ if (flag === "locked") {
239
+ if (footprint._sxLocked) {
240
+ throw new Error("footprint encountered duplicate locked tokens")
241
+ }
242
+ footprint._sxLocked = new FootprintLocked(true)
243
+ continue
244
+ }
245
+ if (flag === "placed") {
246
+ if (footprint._sxPlaced) {
247
+ throw new Error("footprint encountered duplicate placed tokens")
248
+ }
249
+ footprint._sxPlaced = new FootprintPlaced(true)
250
+ continue
251
+ }
252
+ throw new Error(`footprint encountered unsupported flag "${flag}"`)
253
+ }
254
+
255
+ return footprint
256
+ }
257
+
258
+ get libraryLink(): string | undefined {
259
+ return this._libraryLink
260
+ }
261
+
262
+ set libraryLink(value: string | undefined) {
263
+ this._libraryLink = value
264
+ }
265
+
266
+ get locked(): boolean {
267
+ return this._sxLocked?.value ?? false
268
+ }
269
+
270
+ set locked(value: FootprintLocked | boolean | undefined) {
271
+ if (value === undefined) {
272
+ this._sxLocked = undefined
273
+ return
274
+ }
275
+ if (value instanceof FootprintLocked) {
276
+ this._sxLocked = value.value ? value : undefined
277
+ return
278
+ }
279
+ this._sxLocked = value ? new FootprintLocked(true) : undefined
280
+ }
281
+
282
+ get placed(): boolean {
283
+ return this._sxPlaced?.value ?? false
284
+ }
285
+
286
+ set placed(value: FootprintPlaced | boolean | undefined) {
287
+ if (value === undefined) {
288
+ this._sxPlaced = undefined
289
+ return
290
+ }
291
+ if (value instanceof FootprintPlaced) {
292
+ this._sxPlaced = value.value ? value : undefined
293
+ return
294
+ }
295
+ this._sxPlaced = value ? new FootprintPlaced(true) : undefined
296
+ }
297
+
298
+ get layer(): Layer | undefined {
299
+ return this._sxLayer
300
+ }
301
+
302
+ set layer(value: Layer | string | string[] | undefined) {
303
+ if (value === undefined) {
304
+ this._sxLayer = undefined
305
+ return
306
+ }
307
+ if (value instanceof Layer) {
308
+ this._sxLayer = value
309
+ } else {
310
+ const names = Array.isArray(value) ? value : [value]
311
+ this._sxLayer = new Layer(names)
312
+ }
313
+ }
314
+
315
+ get tedit(): FootprintTedit | undefined {
316
+ return this._sxTedit
317
+ }
318
+
319
+ set tedit(value: FootprintTedit | string | undefined) {
320
+ if (value === undefined) {
321
+ this._sxTedit = undefined
322
+ return
323
+ }
324
+ this._sxTedit = value instanceof FootprintTedit ? value : new FootprintTedit(value)
325
+ }
326
+
327
+ get uuid(): Uuid | undefined {
328
+ return this._sxUuid
329
+ }
330
+
331
+ set uuid(value: Uuid | string | undefined) {
332
+ if (value === undefined) {
333
+ this._sxUuid = undefined
334
+ return
335
+ }
336
+ this._sxUuid = value instanceof Uuid ? value : new Uuid(value)
337
+ }
338
+
339
+ get position(): At | Xy | undefined {
340
+ return this._sxAt ?? this._sxXy
341
+ }
342
+
343
+ set position(value: At | Xy | undefined) {
344
+ if (value instanceof At) {
345
+ this._sxAt = value
346
+ this._sxXy = undefined
347
+ return
348
+ }
349
+ if (value instanceof Xy) {
350
+ this._sxXy = value
351
+ this._sxAt = undefined
352
+ return
353
+ }
354
+ this._sxAt = undefined
355
+ this._sxXy = undefined
356
+ }
357
+
358
+ get descr(): FootprintDescr | undefined {
359
+ return this._sxDescr
360
+ }
361
+
362
+ set descr(value: FootprintDescr | string | undefined) {
363
+ if (value === undefined) {
364
+ this._sxDescr = undefined
365
+ return
366
+ }
367
+ this._sxDescr = value instanceof FootprintDescr ? value : new FootprintDescr(value)
368
+ }
369
+
370
+ get tags(): FootprintTags | undefined {
371
+ return this._sxTags
372
+ }
373
+
374
+ set tags(value: FootprintTags | string | undefined) {
375
+ if (value === undefined) {
376
+ this._sxTags = undefined
377
+ return
378
+ }
379
+ this._sxTags = value instanceof FootprintTags ? value : new FootprintTags(value)
380
+ }
381
+
382
+ get path(): FootprintPath | undefined {
383
+ return this._sxPath
384
+ }
385
+
386
+ set path(value: FootprintPath | string | undefined) {
387
+ if (value === undefined) {
388
+ this._sxPath = undefined
389
+ return
390
+ }
391
+ this._sxPath = value instanceof FootprintPath ? value : new FootprintPath(value)
392
+ }
393
+
394
+ get autoplaceCost90(): FootprintAutoplaceCost90 | undefined {
395
+ return this._sxAutoplaceCost90
396
+ }
397
+
398
+ set autoplaceCost90(value: FootprintAutoplaceCost90 | number | undefined) {
399
+ if (value === undefined) {
400
+ this._sxAutoplaceCost90 = undefined
401
+ return
402
+ }
403
+ this._sxAutoplaceCost90 =
404
+ value instanceof FootprintAutoplaceCost90
405
+ ? value
406
+ : new FootprintAutoplaceCost90(value)
407
+ }
408
+
409
+ get autoplaceCost180(): FootprintAutoplaceCost180 | undefined {
410
+ return this._sxAutoplaceCost180
411
+ }
412
+
413
+ set autoplaceCost180(value: FootprintAutoplaceCost180 | number | undefined) {
414
+ if (value === undefined) {
415
+ this._sxAutoplaceCost180 = undefined
416
+ return
417
+ }
418
+ this._sxAutoplaceCost180 =
419
+ value instanceof FootprintAutoplaceCost180
420
+ ? value
421
+ : new FootprintAutoplaceCost180(value)
422
+ }
423
+
424
+ get solderMaskMargin(): FootprintSolderMaskMargin | undefined {
425
+ return this._sxSolderMaskMargin
426
+ }
427
+
428
+ set solderMaskMargin(value: FootprintSolderMaskMargin | number | undefined) {
429
+ if (value === undefined) {
430
+ this._sxSolderMaskMargin = undefined
431
+ return
432
+ }
433
+ this._sxSolderMaskMargin =
434
+ value instanceof FootprintSolderMaskMargin
435
+ ? value
436
+ : new FootprintSolderMaskMargin(value)
437
+ }
438
+
439
+ get solderPasteMargin(): FootprintSolderPasteMargin | undefined {
440
+ return this._sxSolderPasteMargin
441
+ }
442
+
443
+ set solderPasteMargin(value: FootprintSolderPasteMargin | number | undefined) {
444
+ if (value === undefined) {
445
+ this._sxSolderPasteMargin = undefined
446
+ return
447
+ }
448
+ this._sxSolderPasteMargin =
449
+ value instanceof FootprintSolderPasteMargin
450
+ ? value
451
+ : new FootprintSolderPasteMargin(value)
452
+ }
453
+
454
+ get solderPasteRatio(): FootprintSolderPasteRatio | undefined {
455
+ return this._sxSolderPasteRatio
456
+ }
457
+
458
+ set solderPasteRatio(value: FootprintSolderPasteRatio | number | undefined) {
459
+ if (value === undefined) {
460
+ this._sxSolderPasteRatio = undefined
461
+ return
462
+ }
463
+ this._sxSolderPasteRatio =
464
+ value instanceof FootprintSolderPasteRatio
465
+ ? value
466
+ : new FootprintSolderPasteRatio(value)
467
+ }
468
+
469
+ get clearance(): FootprintClearance | undefined {
470
+ return this._sxClearance
471
+ }
472
+
473
+ set clearance(value: FootprintClearance | number | undefined) {
474
+ if (value === undefined) {
475
+ this._sxClearance = undefined
476
+ return
477
+ }
478
+ this._sxClearance =
479
+ value instanceof FootprintClearance ? value : new FootprintClearance(value)
480
+ }
481
+
482
+ get zoneConnect(): FootprintZoneConnect | undefined {
483
+ return this._sxZoneConnect
484
+ }
485
+
486
+ set zoneConnect(value: FootprintZoneConnect | number | undefined) {
487
+ if (value === undefined) {
488
+ this._sxZoneConnect = undefined
489
+ return
490
+ }
491
+ this._sxZoneConnect =
492
+ value instanceof FootprintZoneConnect ? value : new FootprintZoneConnect(value)
493
+ }
494
+
495
+ get thermalWidth(): FootprintThermalWidth | undefined {
496
+ return this._sxThermalWidth
497
+ }
498
+
499
+ set thermalWidth(value: FootprintThermalWidth | number | undefined) {
500
+ if (value === undefined) {
501
+ this._sxThermalWidth = undefined
502
+ return
503
+ }
504
+ this._sxThermalWidth =
505
+ value instanceof FootprintThermalWidth
506
+ ? value
507
+ : new FootprintThermalWidth(value)
508
+ }
509
+
510
+ get thermalGap(): FootprintThermalGap | undefined {
511
+ return this._sxThermalGap
512
+ }
513
+
514
+ set thermalGap(value: FootprintThermalGap | number | undefined) {
515
+ if (value === undefined) {
516
+ this._sxThermalGap = undefined
517
+ return
518
+ }
519
+ this._sxThermalGap =
520
+ value instanceof FootprintThermalGap ? value : new FootprintThermalGap(value)
521
+ }
522
+
523
+ get attr(): FootprintAttr | undefined {
524
+ return this._sxAttr
525
+ }
526
+
527
+ set attr(value: FootprintAttr | undefined) {
528
+ this._sxAttr = value
529
+ }
530
+
531
+ get privateLayers(): FootprintPrivateLayers | undefined {
532
+ return this._sxPrivateLayers
533
+ }
534
+
535
+ set privateLayers(value: FootprintPrivateLayers | string[] | undefined) {
536
+ if (value === undefined) {
537
+ this._sxPrivateLayers = undefined
538
+ return
539
+ }
540
+ this._sxPrivateLayers =
541
+ value instanceof FootprintPrivateLayers
542
+ ? value
543
+ : new FootprintPrivateLayers(value)
544
+ }
545
+
546
+ get netTiePadGroups(): FootprintNetTiePadGroups | undefined {
547
+ return this._sxNetTiePadGroups
548
+ }
549
+
550
+ set netTiePadGroups(value: FootprintNetTiePadGroups | string[] | undefined) {
551
+ if (value === undefined) {
552
+ this._sxNetTiePadGroups = undefined
553
+ return
554
+ }
555
+ this._sxNetTiePadGroups =
556
+ value instanceof FootprintNetTiePadGroups
557
+ ? value
558
+ : new FootprintNetTiePadGroups(value)
559
+ }
560
+
561
+ get sheetname(): string | undefined {
562
+ return this._sxSheetname?.value
563
+ }
564
+
565
+ set sheetname(value: string | undefined) {
566
+ this._sxSheetname =
567
+ value === undefined ? undefined : new FootprintSheetname(value)
568
+ }
569
+
570
+ get sheetfile(): string | undefined {
571
+ return this._sxSheetfile?.value
572
+ }
573
+
574
+ set sheetfile(value: string | undefined) {
575
+ this._sxSheetfile =
576
+ value === undefined ? undefined : new FootprintSheetfile(value)
577
+ }
578
+
579
+ get embeddedFonts(): EmbeddedFonts | undefined {
580
+ return this._sxEmbeddedFonts
581
+ }
582
+
583
+ set embeddedFonts(value: EmbeddedFonts | undefined) {
584
+ this._sxEmbeddedFonts = value
585
+ }
586
+
587
+ get properties(): Property[] {
588
+ return [...this._properties]
589
+ }
590
+
591
+ set properties(value: Property[]) {
592
+ this._properties = [...value]
593
+ }
594
+
595
+ get fpTexts(): FpText[] {
596
+ return [...this._fpTexts]
597
+ }
598
+
599
+ set fpTexts(value: FpText[]) {
600
+ this._fpTexts = [...value]
601
+ }
602
+
603
+ get fpTextBoxes(): FpTextBox[] {
604
+ return [...this._fpTextBoxes]
605
+ }
606
+
607
+ set fpTextBoxes(value: FpTextBox[]) {
608
+ this._fpTextBoxes = [...value]
609
+ }
610
+
611
+ get fpLines(): FpLine[] {
612
+ return [...this._fpLines]
613
+ }
614
+
615
+ set fpLines(value: FpLine[]) {
616
+ this._fpLines = [...value]
617
+ }
618
+
619
+ get fpRects(): FpRect[] {
620
+ return [...this._fpRects]
621
+ }
622
+
623
+ set fpRects(value: FpRect[]) {
624
+ this._fpRects = [...value]
625
+ }
626
+
627
+ get fpCircles(): FpCircle[] {
628
+ return [...this._fpCircles]
629
+ }
630
+
631
+ set fpCircles(value: FpCircle[]) {
632
+ this._fpCircles = [...value]
633
+ }
634
+
635
+ get fpArcs(): FpArc[] {
636
+ return [...this._fpArcs]
637
+ }
638
+
639
+ set fpArcs(value: FpArc[]) {
640
+ this._fpArcs = [...value]
641
+ }
642
+
643
+ get fpPolys(): FpPoly[] {
644
+ return [...this._fpPolys]
645
+ }
646
+
647
+ set fpPolys(value: FpPoly[]) {
648
+ this._fpPolys = [...value]
649
+ }
650
+
651
+ get fpPads(): FootprintPad[] {
652
+ return [...this._fpPads]
653
+ }
654
+
655
+ set fpPads(value: FootprintPad[]) {
656
+ this._fpPads = [...value]
657
+ }
658
+
659
+ get models(): FootprintModel[] {
660
+ return [...this._models]
661
+ }
662
+
663
+ set models(value: FootprintModel[]) {
664
+ this._models = [...value]
665
+ }
666
+
667
+ override getChildren(): SxClass[] {
668
+ const children: SxClass[] = []
669
+ if (this._sxLocked) children.push(this._sxLocked)
670
+ if (this._sxPlaced) children.push(this._sxPlaced)
671
+ if (this._sxLayer) children.push(this._sxLayer)
672
+ if (this._sxTedit) children.push(this._sxTedit)
673
+ if (this._sxUuid) children.push(this._sxUuid)
674
+ if (this._sxAt) children.push(this._sxAt)
675
+ if (this._sxXy) children.push(this._sxXy)
676
+ if (this._sxDescr) children.push(this._sxDescr)
677
+ if (this._sxTags) children.push(this._sxTags)
678
+ if (this._sxPath) children.push(this._sxPath)
679
+ if (this._sxAutoplaceCost90) children.push(this._sxAutoplaceCost90)
680
+ if (this._sxAutoplaceCost180) children.push(this._sxAutoplaceCost180)
681
+ if (this._sxSolderMaskMargin) children.push(this._sxSolderMaskMargin)
682
+ if (this._sxSolderPasteMargin) children.push(this._sxSolderPasteMargin)
683
+ if (this._sxSolderPasteRatio) children.push(this._sxSolderPasteRatio)
684
+ if (this._sxClearance) children.push(this._sxClearance)
685
+ if (this._sxZoneConnect) children.push(this._sxZoneConnect)
686
+ if (this._sxThermalWidth) children.push(this._sxThermalWidth)
687
+ if (this._sxThermalGap) children.push(this._sxThermalGap)
688
+ if (this._sxAttr) children.push(this._sxAttr)
689
+ if (this._sxPrivateLayers) children.push(this._sxPrivateLayers)
690
+ if (this._sxNetTiePadGroups) children.push(this._sxNetTiePadGroups)
691
+ if (this._sxSheetname) children.push(this._sxSheetname)
692
+ if (this._sxSheetfile) children.push(this._sxSheetfile)
693
+ if (this._sxEmbeddedFonts) children.push(this._sxEmbeddedFonts)
694
+ children.push(...this._properties)
695
+ children.push(...this._fpTexts)
696
+ children.push(...this._fpTextBoxes)
697
+ children.push(...this._fpLines)
698
+ children.push(...this._fpRects)
699
+ children.push(...this._fpCircles)
700
+ children.push(...this._fpArcs)
701
+ children.push(...this._fpPolys)
702
+ children.push(...this._fpPads)
703
+ children.push(...this._models)
704
+ return children
705
+ }
706
+
707
+ override getString(): string {
708
+ const lines = ["(footprint"]
709
+ if (this._libraryLink !== undefined) {
710
+ lines.push(` ${quoteSExprString(this._libraryLink)}`)
711
+ }
712
+ for (const child of this.getChildren()) {
713
+ lines.push(child.getStringIndented())
714
+ }
715
+ lines.push(")")
716
+ return lines.join("\n")
717
+ }
718
+ }
719
+ SxClass.register(Footprint)