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,44 +0,0 @@
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)
@@ -1,32 +0,0 @@
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)
@@ -1,56 +0,0 @@
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)
@@ -1,44 +0,0 @@
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)
@@ -1,44 +0,0 @@
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)
@@ -1,9 +0,0 @@
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)
@@ -1,9 +0,0 @@
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)
@@ -1,9 +0,0 @@
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)
@@ -1,44 +0,0 @@
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)
@@ -1,21 +0,0 @@
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)
@@ -1,9 +0,0 @@
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)
@@ -1,9 +0,0 @@
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)
@@ -1,9 +0,0 @@
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)
@@ -1,312 +0,0 @@
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 interface FpArcConstructorParams {
10
- start?: FpArcStart | { x: number; y: number }
11
- mid?: FpArcMid | { x: number; y: number }
12
- end?: FpArcEnd | { x: number; y: number }
13
- layer?: Layer | string | string[]
14
- width?: number | Width
15
- stroke?: Stroke
16
- uuid?: string | Uuid
17
- locked?: boolean
18
- }
19
-
20
- export class FpArc extends SxClass {
21
- static override token = "fp_arc"
22
- token = "fp_arc"
23
-
24
- private _sxStart?: FpArcStart
25
- private _sxMid?: FpArcMid
26
- private _sxEnd?: FpArcEnd
27
- private _sxLayer?: Layer
28
- private _sxWidth?: Width
29
- private _sxStroke?: Stroke
30
- private _sxUuid?: Uuid
31
- private _locked = false
32
-
33
- constructor(params: FpArcConstructorParams = {}) {
34
- super()
35
- if (params.start !== undefined) this.start = params.start
36
- if (params.mid !== undefined) this.mid = params.mid
37
- if (params.end !== undefined) this.end = params.end
38
- if (params.layer !== undefined) this.layer = params.layer
39
- if (params.width !== undefined) this.width = params.width
40
- if (params.stroke !== undefined) this.stroke = params.stroke
41
- if (params.uuid !== undefined) this.uuid = params.uuid
42
- if (params.locked !== undefined) this.locked = params.locked
43
- }
44
-
45
- static override fromSexprPrimitives(
46
- primitiveSexprs: PrimitiveSExpr[],
47
- ): FpArc {
48
- const arc = new FpArc()
49
-
50
- const { propertyMap } = SxClass.parsePrimitivesToClassProperties(
51
- primitiveSexprs,
52
- this.token,
53
- )
54
-
55
- arc._sxStart = propertyMap.start as FpArcStart | undefined
56
- arc._sxMid = propertyMap.mid as FpArcMid | undefined
57
- arc._sxEnd = propertyMap.end as FpArcEnd | undefined
58
- arc._sxLayer = propertyMap.layer as Layer | undefined
59
- arc._sxWidth = propertyMap.width as Width | undefined
60
- arc._sxStroke = propertyMap.stroke as Stroke | undefined
61
- arc._sxUuid = propertyMap.uuid as Uuid | undefined
62
-
63
- for (const primitive of primitiveSexprs) {
64
- if (primitive === "locked") {
65
- arc._locked = true
66
- }
67
- }
68
-
69
- return arc
70
- }
71
-
72
- get start(): FpArcStart | undefined {
73
- return this._sxStart
74
- }
75
-
76
- set start(value: FpArcStart | { x: number; y: number } | undefined) {
77
- if (value === undefined) {
78
- this._sxStart = undefined
79
- return
80
- }
81
- if (value instanceof FpArcStart) {
82
- this._sxStart = value
83
- return
84
- }
85
- this._sxStart = new FpArcStart(value.x, value.y)
86
- }
87
-
88
- get mid(): FpArcMid | undefined {
89
- return this._sxMid
90
- }
91
-
92
- set mid(value: FpArcMid | { x: number; y: number } | undefined) {
93
- if (value === undefined) {
94
- this._sxMid = undefined
95
- return
96
- }
97
- if (value instanceof FpArcMid) {
98
- this._sxMid = value
99
- return
100
- }
101
- this._sxMid = new FpArcMid(value.x, value.y)
102
- }
103
-
104
- get end(): FpArcEnd | undefined {
105
- return this._sxEnd
106
- }
107
-
108
- set end(value: FpArcEnd | { x: number; y: number } | undefined) {
109
- if (value === undefined) {
110
- this._sxEnd = undefined
111
- return
112
- }
113
- if (value instanceof FpArcEnd) {
114
- this._sxEnd = value
115
- return
116
- }
117
- this._sxEnd = new FpArcEnd(value.x, value.y)
118
- }
119
-
120
- get layer(): Layer | undefined {
121
- return this._sxLayer
122
- }
123
-
124
- set layer(value: Layer | string | string[] | undefined) {
125
- if (value === undefined) {
126
- this._sxLayer = undefined
127
- return
128
- }
129
- if (value instanceof Layer) {
130
- this._sxLayer = value
131
- return
132
- }
133
- const names = Array.isArray(value) ? value : [value]
134
- this._sxLayer = new Layer(names)
135
- }
136
-
137
- get width(): number | undefined {
138
- return this._sxWidth?.value
139
- }
140
-
141
- set width(value: number | Width | undefined) {
142
- if (value === undefined) {
143
- this._sxWidth = undefined
144
- return
145
- }
146
- if (value instanceof Width) {
147
- this._sxWidth = value
148
- return
149
- }
150
- this._sxWidth = new Width(value)
151
- }
152
-
153
- get widthClass(): Width | undefined {
154
- return this._sxWidth
155
- }
156
-
157
- get stroke(): Stroke | undefined {
158
- return this._sxStroke
159
- }
160
-
161
- set stroke(value: Stroke | undefined) {
162
- this._sxStroke = value
163
- }
164
-
165
- get uuid(): string | undefined {
166
- return this._sxUuid?.value
167
- }
168
-
169
- set uuid(value: string | Uuid | undefined) {
170
- if (value === undefined) {
171
- this._sxUuid = undefined
172
- return
173
- }
174
- if (value instanceof Uuid) {
175
- this._sxUuid = value
176
- return
177
- }
178
- this._sxUuid = new Uuid(value)
179
- }
180
-
181
- get uuidClass(): Uuid | undefined {
182
- return this._sxUuid
183
- }
184
-
185
- get locked(): boolean {
186
- return this._locked
187
- }
188
-
189
- set locked(value: boolean) {
190
- this._locked = value
191
- }
192
-
193
- override getChildren(): SxClass[] {
194
- const children: SxClass[] = []
195
- if (this._sxStart) children.push(this._sxStart)
196
- if (this._sxMid) children.push(this._sxMid)
197
- if (this._sxEnd) children.push(this._sxEnd)
198
- if (this._sxLayer) children.push(this._sxLayer)
199
- if (this._sxWidth) children.push(this._sxWidth)
200
- if (this._sxStroke) children.push(this._sxStroke)
201
- if (this._sxUuid) children.push(this._sxUuid)
202
- return children
203
- }
204
-
205
- override getString(): string {
206
- const lines = ["(fp_arc"]
207
- const push = (value?: SxClass) => {
208
- if (!value) return
209
- lines.push(value.getStringIndented())
210
- }
211
-
212
- push(this._sxStart)
213
- push(this._sxMid)
214
- push(this._sxEnd)
215
- push(this._sxLayer)
216
- push(this._sxWidth)
217
- push(this._sxStroke)
218
- push(this._sxUuid)
219
-
220
- if (this._locked) {
221
- lines.push(" locked")
222
- }
223
-
224
- lines.push(")")
225
- return lines.join("\n")
226
- }
227
- }
228
- SxClass.register(FpArc)
229
-
230
- export class FpArcStart extends SxClass {
231
- static override token = "start"
232
- static override parentToken = "fp_arc"
233
- token = "start"
234
-
235
- x: number
236
- y: number
237
-
238
- constructor(x: number, y: number) {
239
- super()
240
- this.x = x
241
- this.y = y
242
- }
243
-
244
- static override fromSexprPrimitives(
245
- primitiveSexprs: PrimitiveSExpr[],
246
- ): FpArcStart {
247
- const x = toNumberValue(primitiveSexprs[0]) ?? 0
248
- const y = toNumberValue(primitiveSexprs[1]) ?? 0
249
- return new FpArcStart(x, y)
250
- }
251
-
252
- override getString(): string {
253
- return `(start ${this.x} ${this.y})`
254
- }
255
- }
256
- SxClass.register(FpArcStart)
257
-
258
- export class FpArcMid extends SxClass {
259
- static override token = "mid"
260
- static override parentToken = "fp_arc"
261
- token = "mid"
262
-
263
- x: number
264
- y: number
265
-
266
- constructor(x: number, y: number) {
267
- super()
268
- this.x = x
269
- this.y = y
270
- }
271
-
272
- static override fromSexprPrimitives(
273
- primitiveSexprs: PrimitiveSExpr[],
274
- ): FpArcMid {
275
- const x = toNumberValue(primitiveSexprs[0]) ?? 0
276
- const y = toNumberValue(primitiveSexprs[1]) ?? 0
277
- return new FpArcMid(x, y)
278
- }
279
-
280
- override getString(): string {
281
- return `(mid ${this.x} ${this.y})`
282
- }
283
- }
284
- SxClass.register(FpArcMid)
285
-
286
- export class FpArcEnd extends SxClass {
287
- static override token = "end"
288
- static override parentToken = "fp_arc"
289
- token = "end"
290
-
291
- x: number
292
- y: number
293
-
294
- constructor(x: number, y: number) {
295
- super()
296
- this.x = x
297
- this.y = y
298
- }
299
-
300
- static override fromSexprPrimitives(
301
- primitiveSexprs: PrimitiveSExpr[],
302
- ): FpArcEnd {
303
- const x = toNumberValue(primitiveSexprs[0]) ?? 0
304
- const y = toNumberValue(primitiveSexprs[1]) ?? 0
305
- return new FpArcEnd(x, y)
306
- }
307
-
308
- override getString(): string {
309
- return `(end ${this.x} ${this.y})`
310
- }
311
- }
312
- SxClass.register(FpArcEnd)