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,44 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { quoteSExprString } from "../utils/quoteSExprString"
4
+ import { toStringValue } from "../utils/toStringValue"
5
+
6
+ export class FootprintPath extends SxClass {
7
+ static override token = "path"
8
+ static override parentToken = "footprint"
9
+ token = "path"
10
+
11
+ private _value: string
12
+
13
+ constructor(value: string) {
14
+ super()
15
+ this._value = value
16
+ }
17
+
18
+ static override fromSexprPrimitives(
19
+ primitiveSexprs: PrimitiveSExpr[],
20
+ ): FootprintPath {
21
+ const value = toStringValue(primitiveSexprs[0])
22
+ if (value === undefined) {
23
+ throw new Error("path expects a string value")
24
+ }
25
+ return new FootprintPath(value)
26
+ }
27
+
28
+ get value(): string {
29
+ return this._value
30
+ }
31
+
32
+ set value(value: string) {
33
+ this._value = value
34
+ }
35
+
36
+ override getChildren(): SxClass[] {
37
+ return []
38
+ }
39
+
40
+ override getString(): string {
41
+ return `(path ${quoteSExprString(this._value)})`
42
+ }
43
+ }
44
+ SxClass.register(FootprintPath)
@@ -0,0 +1,32 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import { SxPrimitiveBoolean } from "../base-classes/SxPrimitiveBoolean"
3
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
4
+ import { parseYesNo } from "../utils/parseYesNo"
5
+
6
+ export class FootprintPlaced extends SxPrimitiveBoolean {
7
+ static override token = "placed"
8
+ static override parentToken = "footprint"
9
+ token = "placed"
10
+
11
+ constructor(value = true) {
12
+ super(value)
13
+ }
14
+
15
+ static override fromSexprPrimitives(
16
+ primitiveSexprs: PrimitiveSExpr[],
17
+ ): FootprintPlaced {
18
+ if (primitiveSexprs.length === 0) {
19
+ return new FootprintPlaced(true)
20
+ }
21
+
22
+ const parsed = parseYesNo(primitiveSexprs[0])
23
+ if (parsed === undefined) {
24
+ throw new Error(
25
+ `placed expects yes/no, received ${JSON.stringify(primitiveSexprs[0])}`,
26
+ )
27
+ }
28
+
29
+ return new FootprintPlaced(parsed)
30
+ }
31
+ }
32
+ SxClass.register(FootprintPlaced)
@@ -0,0 +1,56 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { quoteSExprString } from "../utils/quoteSExprString"
4
+ import { toStringValue } from "../utils/toStringValue"
5
+
6
+ export class FootprintPrivateLayers extends SxClass {
7
+ static override token = "private_layers"
8
+ static override parentToken = "footprint"
9
+ token = "private_layers"
10
+
11
+ private _layers: string[] = []
12
+
13
+ constructor(layers: string[]) {
14
+ super()
15
+ this.layers = layers
16
+ }
17
+
18
+ static override fromSexprPrimitives(
19
+ primitiveSexprs: PrimitiveSExpr[],
20
+ ): FootprintPrivateLayers {
21
+ const layers = primitiveSexprs.map((primitive) => {
22
+ const value = toStringValue(primitive)
23
+ if (value === undefined) {
24
+ throw new Error(
25
+ `private_layers expects string layer names, received ${JSON.stringify(primitive)}`,
26
+ )
27
+ }
28
+ return value
29
+ })
30
+ return new FootprintPrivateLayers(layers)
31
+ }
32
+
33
+ get layers(): string[] {
34
+ return [...this._layers]
35
+ }
36
+
37
+ set layers(values: string[]) {
38
+ this._layers = values.map((value) => String(value))
39
+ }
40
+
41
+ override getChildren(): SxClass[] {
42
+ return []
43
+ }
44
+
45
+ override getString(): string {
46
+ const rendered = this._layers
47
+ .map((layer) =>
48
+ /^[^\s()"]+$/u.test(layer) && !["nil", "#t", "#f"].includes(layer)
49
+ ? layer
50
+ : quoteSExprString(layer),
51
+ )
52
+ .join(" ")
53
+ return `(private_layers ${rendered})`
54
+ }
55
+ }
56
+ SxClass.register(FootprintPrivateLayers)
@@ -0,0 +1,44 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { quoteSExprString } from "../utils/quoteSExprString"
4
+ import { toStringValue } from "../utils/toStringValue"
5
+
6
+ export class FootprintSheetfile extends SxClass {
7
+ static override token = "sheetfile"
8
+ static override parentToken = "footprint"
9
+ override token = "sheetfile"
10
+
11
+ private _value: string
12
+
13
+ constructor(value: string) {
14
+ super()
15
+ this._value = value
16
+ }
17
+
18
+ static override fromSexprPrimitives(
19
+ primitiveSexprs: PrimitiveSExpr[],
20
+ ): FootprintSheetfile {
21
+ const value = toStringValue(primitiveSexprs[0])
22
+ if (value === undefined) {
23
+ throw new Error("sheetfile expects a string value")
24
+ }
25
+ return new FootprintSheetfile(value)
26
+ }
27
+
28
+ get value(): string {
29
+ return this._value
30
+ }
31
+
32
+ set value(value: string) {
33
+ this._value = value
34
+ }
35
+
36
+ override getChildren(): SxClass[] {
37
+ return []
38
+ }
39
+
40
+ override getString(): string {
41
+ return `(sheetfile ${quoteSExprString(this._value)})`
42
+ }
43
+ }
44
+ SxClass.register(FootprintSheetfile)
@@ -0,0 +1,44 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { quoteSExprString } from "../utils/quoteSExprString"
4
+ import { toStringValue } from "../utils/toStringValue"
5
+
6
+ export class FootprintSheetname extends SxClass {
7
+ static override token = "sheetname"
8
+ static override parentToken = "footprint"
9
+ override token = "sheetname"
10
+
11
+ private _value: string
12
+
13
+ constructor(value: string) {
14
+ super()
15
+ this._value = value
16
+ }
17
+
18
+ static override fromSexprPrimitives(
19
+ primitiveSexprs: PrimitiveSExpr[],
20
+ ): FootprintSheetname {
21
+ const value = toStringValue(primitiveSexprs[0])
22
+ if (value === undefined) {
23
+ throw new Error("sheetname expects a string value")
24
+ }
25
+ return new FootprintSheetname(value)
26
+ }
27
+
28
+ get value(): string {
29
+ return this._value
30
+ }
31
+
32
+ set value(value: string) {
33
+ this._value = value
34
+ }
35
+
36
+ override getChildren(): SxClass[] {
37
+ return []
38
+ }
39
+
40
+ override getString(): string {
41
+ return `(sheetname ${quoteSExprString(this._value)})`
42
+ }
43
+ }
44
+ SxClass.register(FootprintSheetname)
@@ -0,0 +1,9 @@
1
+ import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
2
+ import { SxClass } from "../base-classes/SxClass"
3
+
4
+ export class FootprintSolderMaskMargin extends SxPrimitiveNumber {
5
+ static override token = "solder_mask_margin"
6
+ static override parentToken = "footprint"
7
+ token = "solder_mask_margin"
8
+ }
9
+ SxClass.register(FootprintSolderMaskMargin)
@@ -0,0 +1,9 @@
1
+ import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
2
+ import { SxClass } from "../base-classes/SxClass"
3
+
4
+ export class FootprintSolderPasteMargin extends SxPrimitiveNumber {
5
+ static override token = "solder_paste_margin"
6
+ static override parentToken = "footprint"
7
+ token = "solder_paste_margin"
8
+ }
9
+ SxClass.register(FootprintSolderPasteMargin)
@@ -0,0 +1,9 @@
1
+ import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
2
+ import { SxClass } from "../base-classes/SxClass"
3
+
4
+ export class FootprintSolderPasteRatio extends SxPrimitiveNumber {
5
+ static override token = "solder_paste_ratio"
6
+ static override parentToken = "footprint"
7
+ token = "solder_paste_ratio"
8
+ }
9
+ SxClass.register(FootprintSolderPasteRatio)
@@ -0,0 +1,44 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { quoteSExprString } from "../utils/quoteSExprString"
4
+ import { toStringValue } from "../utils/toStringValue"
5
+
6
+ export class FootprintTags extends SxClass {
7
+ static override token = "tags"
8
+ static override parentToken = "footprint"
9
+ token = "tags"
10
+
11
+ private _value: string
12
+
13
+ constructor(value: string) {
14
+ super()
15
+ this._value = value
16
+ }
17
+
18
+ static override fromSexprPrimitives(
19
+ primitiveSexprs: PrimitiveSExpr[],
20
+ ): FootprintTags {
21
+ const value = toStringValue(primitiveSexprs[0])
22
+ if (value === undefined) {
23
+ throw new Error("tags expects a string value")
24
+ }
25
+ return new FootprintTags(value)
26
+ }
27
+
28
+ get value(): string {
29
+ return this._value
30
+ }
31
+
32
+ set value(value: string) {
33
+ this._value = value
34
+ }
35
+
36
+ override getChildren(): SxClass[] {
37
+ return []
38
+ }
39
+
40
+ override getString(): string {
41
+ return `(tags ${quoteSExprString(this._value)})`
42
+ }
43
+ }
44
+ SxClass.register(FootprintTags)
@@ -0,0 +1,21 @@
1
+ import { SxPrimitiveString } from "../base-classes/SxPrimitiveString"
2
+ import { SxClass } from "../base-classes/SxClass"
3
+ import { toStringValue } from "../utils/toStringValue"
4
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
5
+
6
+ export class FootprintTedit extends SxPrimitiveString {
7
+ static override token = "tedit"
8
+ static override parentToken = "footprint"
9
+ token = "tedit"
10
+
11
+ static override fromSexprPrimitives(
12
+ primitiveSexprs: PrimitiveSExpr[],
13
+ ): FootprintTedit {
14
+ const value = toStringValue(primitiveSexprs[0])
15
+ if (value === undefined) {
16
+ throw new Error("tedit expects a string value")
17
+ }
18
+ return new FootprintTedit(value)
19
+ }
20
+ }
21
+ SxClass.register(FootprintTedit)
@@ -0,0 +1,9 @@
1
+ import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
2
+ import { SxClass } from "../base-classes/SxClass"
3
+
4
+ export class FootprintThermalGap extends SxPrimitiveNumber {
5
+ static override token = "thermal_gap"
6
+ static override parentToken = "footprint"
7
+ token = "thermal_gap"
8
+ }
9
+ SxClass.register(FootprintThermalGap)
@@ -0,0 +1,9 @@
1
+ import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
2
+ import { SxClass } from "../base-classes/SxClass"
3
+
4
+ export class FootprintThermalWidth extends SxPrimitiveNumber {
5
+ static override token = "thermal_width"
6
+ static override parentToken = "footprint"
7
+ token = "thermal_width"
8
+ }
9
+ SxClass.register(FootprintThermalWidth)
@@ -0,0 +1,9 @@
1
+ import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
2
+ import { SxClass } from "../base-classes/SxClass"
3
+
4
+ export class FootprintZoneConnect extends SxPrimitiveNumber {
5
+ static override token = "zone_connect"
6
+ static override parentToken = "footprint"
7
+ token = "zone_connect"
8
+ }
9
+ SxClass.register(FootprintZoneConnect)
@@ -0,0 +1,289 @@
1
+ import { SxClass } from "../base-classes/SxClass"
2
+ import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
+ import { Layer } from "./Layer"
4
+ import { Stroke } from "./Stroke"
5
+ import { Uuid } from "./Uuid"
6
+ import { Width } from "./Width"
7
+ import { toNumberValue } from "../utils/toNumberValue"
8
+
9
+ export class FpArc extends SxClass {
10
+ static override token = "fp_arc"
11
+ token = "fp_arc"
12
+
13
+ private _sxStart?: FpArcStart
14
+ private _sxMid?: FpArcMid
15
+ private _sxEnd?: FpArcEnd
16
+ private _sxLayer?: Layer
17
+ private _sxWidth?: Width
18
+ private _sxStroke?: Stroke
19
+ private _sxUuid?: Uuid
20
+ private _locked = false
21
+
22
+ static override fromSexprPrimitives(
23
+ primitiveSexprs: PrimitiveSExpr[],
24
+ ): FpArc {
25
+ const arc = new FpArc()
26
+
27
+ const { propertyMap } = SxClass.parsePrimitivesToClassProperties(
28
+ primitiveSexprs,
29
+ this.token,
30
+ )
31
+
32
+ arc._sxStart = propertyMap.start as FpArcStart | undefined
33
+ arc._sxMid = propertyMap.mid as FpArcMid | undefined
34
+ arc._sxEnd = propertyMap.end as FpArcEnd | undefined
35
+ arc._sxLayer = propertyMap.layer as Layer | undefined
36
+ arc._sxWidth = propertyMap.width as Width | undefined
37
+ arc._sxStroke = propertyMap.stroke as Stroke | undefined
38
+ arc._sxUuid = propertyMap.uuid as Uuid | undefined
39
+
40
+ for (const primitive of primitiveSexprs) {
41
+ if (primitive === "locked") {
42
+ arc._locked = true
43
+ }
44
+ }
45
+
46
+ return arc
47
+ }
48
+
49
+ get start(): FpArcStart | undefined {
50
+ return this._sxStart
51
+ }
52
+
53
+ set start(value: FpArcStart | { x: number; y: number } | undefined) {
54
+ if (value === undefined) {
55
+ this._sxStart = undefined
56
+ return
57
+ }
58
+ if (value instanceof FpArcStart) {
59
+ this._sxStart = value
60
+ return
61
+ }
62
+ this._sxStart = new FpArcStart(value.x, value.y)
63
+ }
64
+
65
+ get mid(): FpArcMid | undefined {
66
+ return this._sxMid
67
+ }
68
+
69
+ set mid(value: FpArcMid | { x: number; y: number } | undefined) {
70
+ if (value === undefined) {
71
+ this._sxMid = undefined
72
+ return
73
+ }
74
+ if (value instanceof FpArcMid) {
75
+ this._sxMid = value
76
+ return
77
+ }
78
+ this._sxMid = new FpArcMid(value.x, value.y)
79
+ }
80
+
81
+ get end(): FpArcEnd | undefined {
82
+ return this._sxEnd
83
+ }
84
+
85
+ set end(value: FpArcEnd | { x: number; y: number } | undefined) {
86
+ if (value === undefined) {
87
+ this._sxEnd = undefined
88
+ return
89
+ }
90
+ if (value instanceof FpArcEnd) {
91
+ this._sxEnd = value
92
+ return
93
+ }
94
+ this._sxEnd = new FpArcEnd(value.x, value.y)
95
+ }
96
+
97
+ get layer(): Layer | undefined {
98
+ return this._sxLayer
99
+ }
100
+
101
+ set layer(value: Layer | string | string[] | undefined) {
102
+ if (value === undefined) {
103
+ this._sxLayer = undefined
104
+ return
105
+ }
106
+ if (value instanceof Layer) {
107
+ this._sxLayer = value
108
+ return
109
+ }
110
+ const names = Array.isArray(value) ? value : [value]
111
+ this._sxLayer = new Layer(names)
112
+ }
113
+
114
+ get width(): number | undefined {
115
+ return this._sxWidth?.value
116
+ }
117
+
118
+ set width(value: number | Width | undefined) {
119
+ if (value === undefined) {
120
+ this._sxWidth = undefined
121
+ return
122
+ }
123
+ if (value instanceof Width) {
124
+ this._sxWidth = value
125
+ return
126
+ }
127
+ this._sxWidth = new Width(value)
128
+ }
129
+
130
+ get widthClass(): Width | undefined {
131
+ return this._sxWidth
132
+ }
133
+
134
+ get stroke(): Stroke | undefined {
135
+ return this._sxStroke
136
+ }
137
+
138
+ set stroke(value: Stroke | undefined) {
139
+ this._sxStroke = value
140
+ }
141
+
142
+ get uuid(): string | undefined {
143
+ return this._sxUuid?.value
144
+ }
145
+
146
+ set uuid(value: string | Uuid | undefined) {
147
+ if (value === undefined) {
148
+ this._sxUuid = undefined
149
+ return
150
+ }
151
+ if (value instanceof Uuid) {
152
+ this._sxUuid = value
153
+ return
154
+ }
155
+ this._sxUuid = new Uuid(value)
156
+ }
157
+
158
+ get uuidClass(): Uuid | undefined {
159
+ return this._sxUuid
160
+ }
161
+
162
+ get locked(): boolean {
163
+ return this._locked
164
+ }
165
+
166
+ set locked(value: boolean) {
167
+ this._locked = value
168
+ }
169
+
170
+ override getChildren(): SxClass[] {
171
+ const children: SxClass[] = []
172
+ if (this._sxStart) children.push(this._sxStart)
173
+ if (this._sxMid) children.push(this._sxMid)
174
+ if (this._sxEnd) children.push(this._sxEnd)
175
+ if (this._sxLayer) children.push(this._sxLayer)
176
+ if (this._sxWidth) children.push(this._sxWidth)
177
+ if (this._sxStroke) children.push(this._sxStroke)
178
+ if (this._sxUuid) children.push(this._sxUuid)
179
+ return children
180
+ }
181
+
182
+ override getString(): string {
183
+ const lines = ["(fp_arc"]
184
+ const push = (value?: SxClass) => {
185
+ if (!value) return
186
+ lines.push(value.getStringIndented())
187
+ }
188
+
189
+ push(this._sxStart)
190
+ push(this._sxMid)
191
+ push(this._sxEnd)
192
+ push(this._sxLayer)
193
+ push(this._sxWidth)
194
+ push(this._sxStroke)
195
+ push(this._sxUuid)
196
+
197
+ if (this._locked) {
198
+ lines.push(" locked")
199
+ }
200
+
201
+ lines.push(")")
202
+ return lines.join("\n")
203
+ }
204
+ }
205
+ SxClass.register(FpArc)
206
+
207
+ export class FpArcStart extends SxClass {
208
+ static override token = "start"
209
+ static override parentToken = "fp_arc"
210
+ token = "start"
211
+
212
+ x: number
213
+ y: number
214
+
215
+ constructor(x: number, y: number) {
216
+ super()
217
+ this.x = x
218
+ this.y = y
219
+ }
220
+
221
+ static override fromSexprPrimitives(
222
+ primitiveSexprs: PrimitiveSExpr[],
223
+ ): FpArcStart {
224
+ const x = toNumberValue(primitiveSexprs[0]) ?? 0
225
+ const y = toNumberValue(primitiveSexprs[1]) ?? 0
226
+ return new FpArcStart(x, y)
227
+ }
228
+
229
+ override getString(): string {
230
+ return `(start ${this.x} ${this.y})`
231
+ }
232
+ }
233
+ SxClass.register(FpArcStart)
234
+
235
+ export class FpArcMid extends SxClass {
236
+ static override token = "mid"
237
+ static override parentToken = "fp_arc"
238
+ token = "mid"
239
+
240
+ x: number
241
+ y: number
242
+
243
+ constructor(x: number, y: number) {
244
+ super()
245
+ this.x = x
246
+ this.y = y
247
+ }
248
+
249
+ static override fromSexprPrimitives(
250
+ primitiveSexprs: PrimitiveSExpr[],
251
+ ): FpArcMid {
252
+ const x = toNumberValue(primitiveSexprs[0]) ?? 0
253
+ const y = toNumberValue(primitiveSexprs[1]) ?? 0
254
+ return new FpArcMid(x, y)
255
+ }
256
+
257
+ override getString(): string {
258
+ return `(mid ${this.x} ${this.y})`
259
+ }
260
+ }
261
+ SxClass.register(FpArcMid)
262
+
263
+ export class FpArcEnd extends SxClass {
264
+ static override token = "end"
265
+ static override parentToken = "fp_arc"
266
+ token = "end"
267
+
268
+ x: number
269
+ y: number
270
+
271
+ constructor(x: number, y: number) {
272
+ super()
273
+ this.x = x
274
+ this.y = y
275
+ }
276
+
277
+ static override fromSexprPrimitives(
278
+ primitiveSexprs: PrimitiveSExpr[],
279
+ ): FpArcEnd {
280
+ const x = toNumberValue(primitiveSexprs[0]) ?? 0
281
+ const y = toNumberValue(primitiveSexprs[1]) ?? 0
282
+ return new FpArcEnd(x, y)
283
+ }
284
+
285
+ override getString(): string {
286
+ return `(end ${this.x} ${this.y})`
287
+ }
288
+ }
289
+ SxClass.register(FpArcEnd)