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,135 +0,0 @@
1
- import { SxClass } from "../../base-classes/SxClass"
2
- import type { PrimitiveSExpr } from "../../parseToPrimitiveSExpr"
3
-
4
- import {
5
- StackupCastellatedPads,
6
- StackupCopperFinish,
7
- StackupDielectricConstraints,
8
- StackupEdgeConnector,
9
- StackupEdgePlating,
10
- } from "./StackupProperties"
11
- import { StackupLayer } from "./StackupLayer"
12
-
13
- export class Stackup extends SxClass {
14
- static override token = "stackup"
15
- static override parentToken = "setup"
16
- token = "stackup"
17
-
18
- private _layers: StackupLayer[] = []
19
- private _sxCopperFinish?: StackupCopperFinish
20
- private _sxDielectricConstraints?: StackupDielectricConstraints
21
- private _sxEdgeConnector?: StackupEdgeConnector
22
- private _sxCastellatedPads?: StackupCastellatedPads
23
- private _sxEdgePlating?: StackupEdgePlating
24
-
25
- constructor(
26
- opts: {
27
- layers?: StackupLayer[]
28
- copperFinish?: StackupCopperFinish
29
- dielectricConstraints?: StackupDielectricConstraints
30
- edgeConnector?: StackupEdgeConnector
31
- castellatedPads?: StackupCastellatedPads
32
- edgePlating?: StackupEdgePlating
33
- } = {},
34
- ) {
35
- super()
36
- this.layers = opts.layers ?? []
37
- this._sxCopperFinish = opts.copperFinish
38
- this._sxDielectricConstraints = opts.dielectricConstraints
39
- this._sxEdgeConnector = opts.edgeConnector
40
- this._sxCastellatedPads = opts.castellatedPads
41
- this._sxEdgePlating = opts.edgePlating
42
- }
43
-
44
- static override fromSexprPrimitives(
45
- primitiveSexprs: PrimitiveSExpr[],
46
- ): Stackup {
47
- const { propertyMap, arrayPropertyMap } =
48
- SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token)
49
-
50
- return new Stackup({
51
- layers: (arrayPropertyMap.layer as StackupLayer[] | undefined) ?? [],
52
- copperFinish: propertyMap.copper_finish as StackupCopperFinish,
53
- dielectricConstraints:
54
- propertyMap.dielectric_constraints as StackupDielectricConstraints,
55
- edgeConnector: propertyMap.edge_connector as StackupEdgeConnector,
56
- castellatedPads: propertyMap.castellated_pads as StackupCastellatedPads,
57
- edgePlating: propertyMap.edge_plating as StackupEdgePlating,
58
- })
59
- }
60
-
61
- get layers(): StackupLayer[] {
62
- return [...this._layers]
63
- }
64
-
65
- set layers(layers: StackupLayer[]) {
66
- this._layers = layers.map((layer) => {
67
- if (!(layer instanceof StackupLayer)) {
68
- throw new Error("Stackup layers must be StackupLayer instances")
69
- }
70
- return layer
71
- })
72
- }
73
-
74
- get copperFinish(): string | undefined {
75
- return this._sxCopperFinish?.value
76
- }
77
-
78
- set copperFinish(value: string | undefined) {
79
- this._sxCopperFinish = value ? new StackupCopperFinish(value) : undefined
80
- }
81
-
82
- get dielectricConstraints(): string | undefined {
83
- return this._sxDielectricConstraints?.value
84
- }
85
-
86
- set dielectricConstraints(value: string | undefined) {
87
- this._sxDielectricConstraints = value
88
- ? new StackupDielectricConstraints(value)
89
- : undefined
90
- }
91
-
92
- get edgeConnector(): string | undefined {
93
- return this._sxEdgeConnector?.value
94
- }
95
-
96
- set edgeConnector(value: string | undefined) {
97
- this._sxEdgeConnector = value ? new StackupEdgeConnector(value) : undefined
98
- }
99
-
100
- get castellatedPads(): string | undefined {
101
- return this._sxCastellatedPads?.value
102
- }
103
-
104
- set castellatedPads(value: string | undefined) {
105
- this._sxCastellatedPads = value
106
- ? new StackupCastellatedPads(value)
107
- : undefined
108
- }
109
-
110
- get edgePlating(): string | undefined {
111
- return this._sxEdgePlating?.value
112
- }
113
-
114
- set edgePlating(value: string | undefined) {
115
- this._sxEdgePlating = value ? new StackupEdgePlating(value) : undefined
116
- }
117
-
118
- override getChildren(): SxClass[] {
119
- const children: SxClass[] = [...this._layers]
120
- const optionalChildren = [
121
- this._sxCopperFinish,
122
- this._sxDielectricConstraints,
123
- this._sxEdgeConnector,
124
- this._sxCastellatedPads,
125
- this._sxEdgePlating,
126
- ]
127
- for (const child of optionalChildren) {
128
- if (child) {
129
- children.push(child)
130
- }
131
- }
132
- return children
133
- }
134
- }
135
- SxClass.register(Stackup)
@@ -1,233 +0,0 @@
1
- import { SxClass } from "../../base-classes/SxClass"
2
- import type { PrimitiveSExpr } from "../../parseToPrimitiveSExpr"
3
- import { quoteSExprString } from "../../utils/quoteSExprString"
4
- import { toNumberValue } from "../../utils/toNumberValue"
5
- import { toStringValue } from "../../utils/toStringValue"
6
-
7
- import {
8
- StackupLayerColor,
9
- StackupLayerEpsilonR,
10
- StackupLayerLossTangent,
11
- StackupLayerMaterial,
12
- StackupLayerThickness,
13
- StackupLayerType,
14
- } from "./StackupLayerProperties"
15
-
16
- export class StackupLayer extends SxClass {
17
- static override token = "layer"
18
- static override parentToken = "stackup"
19
- token = "layer"
20
-
21
- private _name: string
22
- private _number?: number
23
-
24
- private _sxType?: StackupLayerType
25
- private _sxColor?: StackupLayerColor
26
- private _sxThickness?: StackupLayerThickness
27
- private _sxMaterial?: StackupLayerMaterial
28
- private _sxEpsilonR?: StackupLayerEpsilonR
29
- private _sxLossTangent?: StackupLayerLossTangent
30
-
31
- constructor(
32
- name: string,
33
- opts: {
34
- number?: number
35
- type?: StackupLayerType
36
- color?: StackupLayerColor
37
- thickness?: StackupLayerThickness
38
- material?: StackupLayerMaterial
39
- epsilonR?: StackupLayerEpsilonR
40
- lossTangent?: StackupLayerLossTangent
41
- } = {},
42
- ) {
43
- super()
44
- this._name = name
45
- this._number = opts.number
46
- this._sxType = opts.type
47
- this._sxColor = opts.color
48
- this._sxThickness = opts.thickness
49
- this._sxMaterial = opts.material
50
- this._sxEpsilonR = opts.epsilonR
51
- this._sxLossTangent = opts.lossTangent
52
- }
53
-
54
- static override fromSexprPrimitives(
55
- primitiveSexprs: PrimitiveSExpr[],
56
- ): StackupLayer {
57
- if (primitiveSexprs.length === 0) {
58
- throw new Error("Stackup layer requires at least a name")
59
- }
60
-
61
- const name = toStringValue(primitiveSexprs[0])
62
- if (name === undefined) {
63
- throw new Error("Stackup layer name must be a string")
64
- }
65
-
66
- let propertyIndex = 1
67
- let number: number | undefined
68
- const maybeNumber = primitiveSexprs[propertyIndex]
69
- const numericLayerNumber = toNumberValue(maybeNumber)
70
- if (numericLayerNumber !== undefined) {
71
- number = numericLayerNumber
72
- propertyIndex += 1
73
- }
74
-
75
- const propertyPrimitives = primitiveSexprs.slice(propertyIndex)
76
- const { propertyMap } = SxClass.parsePrimitivesToClassProperties(
77
- propertyPrimitives,
78
- this.token,
79
- )
80
-
81
- return new StackupLayer(name, {
82
- number,
83
- type: propertyMap.type as StackupLayerType,
84
- color: propertyMap.color as StackupLayerColor,
85
- thickness: propertyMap.thickness as StackupLayerThickness,
86
- material: propertyMap.material as StackupLayerMaterial,
87
- epsilonR: propertyMap.epsilon_r as StackupLayerEpsilonR,
88
- lossTangent: propertyMap.loss_tangent as StackupLayerLossTangent,
89
- })
90
- }
91
-
92
- get name(): string {
93
- return this._name
94
- }
95
-
96
- set name(value: string) {
97
- const parsed = toStringValue(value)
98
- if (parsed === undefined) {
99
- throw new Error("Stackup layer name must be a string")
100
- }
101
- this._name = parsed
102
- }
103
-
104
- get number(): number | undefined {
105
- return this._number
106
- }
107
-
108
- set number(value: number | undefined) {
109
- if (value === undefined) {
110
- this._number = undefined
111
- return
112
- }
113
- const parsed = toNumberValue(value)
114
- if (parsed === undefined) {
115
- throw new Error("Stackup layer number must be numeric")
116
- }
117
- this._number = parsed
118
- }
119
-
120
- get type(): string | undefined {
121
- return this._sxType?.value
122
- }
123
-
124
- set type(value: string | StackupLayerType | undefined) {
125
- if (value === undefined) {
126
- this._sxType = undefined
127
- return
128
- }
129
- this._sxType =
130
- value instanceof StackupLayerType ? value : new StackupLayerType(value)
131
- }
132
-
133
- get color(): string | undefined {
134
- return this._sxColor?.value
135
- }
136
-
137
- set color(value: string | StackupLayerColor | undefined) {
138
- if (value === undefined) {
139
- this._sxColor = undefined
140
- return
141
- }
142
- this._sxColor =
143
- value instanceof StackupLayerColor ? value : new StackupLayerColor(value)
144
- }
145
-
146
- get thickness(): number | undefined {
147
- return this._sxThickness?.value
148
- }
149
-
150
- set thickness(value: number | StackupLayerThickness | undefined) {
151
- if (value === undefined) {
152
- this._sxThickness = undefined
153
- return
154
- }
155
- this._sxThickness =
156
- value instanceof StackupLayerThickness
157
- ? value
158
- : new StackupLayerThickness(value)
159
- }
160
-
161
- get material(): string | undefined {
162
- return this._sxMaterial?.value
163
- }
164
-
165
- set material(value: string | StackupLayerMaterial | undefined) {
166
- if (value === undefined) {
167
- this._sxMaterial = undefined
168
- return
169
- }
170
- this._sxMaterial =
171
- value instanceof StackupLayerMaterial
172
- ? value
173
- : new StackupLayerMaterial(value)
174
- }
175
-
176
- get epsilonR(): number | undefined {
177
- return this._sxEpsilonR?.value
178
- }
179
-
180
- set epsilonR(value: number | StackupLayerEpsilonR | undefined) {
181
- if (value === undefined) {
182
- this._sxEpsilonR = undefined
183
- return
184
- }
185
- this._sxEpsilonR =
186
- value instanceof StackupLayerEpsilonR
187
- ? value
188
- : new StackupLayerEpsilonR(value)
189
- }
190
-
191
- get lossTangent(): number | undefined {
192
- return this._sxLossTangent?.value
193
- }
194
-
195
- set lossTangent(value: number | StackupLayerLossTangent | undefined) {
196
- if (value === undefined) {
197
- this._sxLossTangent = undefined
198
- return
199
- }
200
- this._sxLossTangent =
201
- value instanceof StackupLayerLossTangent
202
- ? value
203
- : new StackupLayerLossTangent(value)
204
- }
205
-
206
- override getChildren(): SxClass[] {
207
- const children: SxClass[] = []
208
- if (this._sxType) children.push(this._sxType)
209
- if (this._sxColor) children.push(this._sxColor)
210
- if (this._sxThickness) children.push(this._sxThickness)
211
- if (this._sxMaterial) children.push(this._sxMaterial)
212
- if (this._sxEpsilonR) children.push(this._sxEpsilonR)
213
- if (this._sxLossTangent) children.push(this._sxLossTangent)
214
- return children
215
- }
216
-
217
- override getString(): string {
218
- const header = `(layer ${quoteSExprString(this._name)}${
219
- this._number !== undefined ? ` ${this._number}` : ""
220
- }`
221
- const children = this.getChildren()
222
- if (children.length === 0) {
223
- return `${header})`
224
- }
225
- const lines: string[] = [header]
226
- for (const child of children) {
227
- lines.push(child.getStringIndented())
228
- }
229
- lines.push(")")
230
- return lines.join("\n")
231
- }
232
- }
233
- SxClass.register(StackupLayer)
@@ -1,80 +0,0 @@
1
- import { SxClass } from "../../base-classes/SxClass"
2
- import type { PrimitiveSExpr } from "../../parseToPrimitiveSExpr"
3
- import { toNumberValue } from "../../utils/toNumberValue"
4
-
5
- import { SingleValueProperty } from "./base"
6
-
7
- abstract class StackupLayerProperty<
8
- T extends string | number,
9
- > extends SingleValueProperty<T> {
10
- static override parentToken = "layer"
11
- }
12
-
13
- export class StackupLayerType extends StackupLayerProperty<string> {
14
- static override token = "type"
15
- token = "type"
16
- protected override quoteStringValue = true
17
- }
18
- SxClass.register(StackupLayerType)
19
-
20
- export class StackupLayerColor extends StackupLayerProperty<string> {
21
- static override token = "color"
22
- token = "color"
23
- protected override quoteStringValue = true
24
- }
25
- SxClass.register(StackupLayerColor)
26
-
27
- export class StackupLayerThickness extends StackupLayerProperty<number> {
28
- static override token = "thickness"
29
- token = "thickness"
30
-
31
- protected static override parsePrimitiveValue(
32
- value: PrimitiveSExpr | undefined,
33
- ): number {
34
- const parsed = toNumberValue(value)
35
- if (parsed === undefined) {
36
- throw new Error("Stackup layer thickness expects a numeric value")
37
- }
38
- return parsed
39
- }
40
- }
41
- SxClass.register(StackupLayerThickness)
42
-
43
- export class StackupLayerMaterial extends StackupLayerProperty<string> {
44
- static override token = "material"
45
- token = "material"
46
- protected override quoteStringValue = true
47
- }
48
- SxClass.register(StackupLayerMaterial)
49
-
50
- export class StackupLayerEpsilonR extends StackupLayerProperty<number> {
51
- static override token = "epsilon_r"
52
- token = "epsilon_r"
53
-
54
- protected static override parsePrimitiveValue(
55
- value: PrimitiveSExpr | undefined,
56
- ): number {
57
- const parsed = toNumberValue(value)
58
- if (parsed === undefined) {
59
- throw new Error("Stackup layer epsilon_r expects a numeric value")
60
- }
61
- return parsed
62
- }
63
- }
64
- SxClass.register(StackupLayerEpsilonR)
65
-
66
- export class StackupLayerLossTangent extends StackupLayerProperty<number> {
67
- static override token = "loss_tangent"
68
- token = "loss_tangent"
69
-
70
- protected static override parsePrimitiveValue(
71
- value: PrimitiveSExpr | undefined,
72
- ): number {
73
- const parsed = toNumberValue(value)
74
- if (parsed === undefined) {
75
- throw new Error("Stackup layer loss_tangent expects a numeric value")
76
- }
77
- return parsed
78
- }
79
- }
80
- SxClass.register(StackupLayerLossTangent)
@@ -1,40 +0,0 @@
1
- import { SxClass } from "../../base-classes/SxClass"
2
-
3
- import { SingleValueProperty } from "./base"
4
-
5
- abstract class StackupSingleValueProperty<
6
- T extends string | number,
7
- > extends SingleValueProperty<T> {
8
- static override parentToken = "stackup"
9
- }
10
-
11
- export class StackupCopperFinish extends StackupSingleValueProperty<string> {
12
- static override token = "copper_finish"
13
- token = "copper_finish"
14
- protected override quoteStringValue = true
15
- }
16
- SxClass.register(StackupCopperFinish)
17
-
18
- export class StackupDielectricConstraints extends StackupSingleValueProperty<string> {
19
- static override token = "dielectric_constraints"
20
- token = "dielectric_constraints"
21
- }
22
- SxClass.register(StackupDielectricConstraints)
23
-
24
- export class StackupEdgeConnector extends StackupSingleValueProperty<string> {
25
- static override token = "edge_connector"
26
- token = "edge_connector"
27
- }
28
- SxClass.register(StackupEdgeConnector)
29
-
30
- export class StackupCastellatedPads extends StackupSingleValueProperty<string> {
31
- static override token = "castellated_pads"
32
- token = "castellated_pads"
33
- }
34
- SxClass.register(StackupCastellatedPads)
35
-
36
- export class StackupEdgePlating extends StackupSingleValueProperty<string> {
37
- static override token = "edge_plating"
38
- token = "edge_plating"
39
- }
40
- SxClass.register(StackupEdgePlating)
@@ -1,165 +0,0 @@
1
- import { SxClass } from "../../base-classes/SxClass"
2
- import { quoteSExprString } from "../../utils/quoteSExprString"
3
- import { toNumberValue } from "../../utils/toNumberValue"
4
- import { toStringValue } from "../../utils/toStringValue"
5
- import type { PrimitiveSExpr } from "../../parseToPrimitiveSExpr"
6
-
7
- type SingleValuePropertyConstructor<T extends string | number> = new (
8
- value: T,
9
- ) => SingleValueProperty<T>
10
-
11
- export abstract class SingleValueProperty<
12
- T extends string | number,
13
- > extends SxClass {
14
- protected _value: T
15
- protected quoteStringValue = false
16
-
17
- constructor(value: T) {
18
- super()
19
- this._value = value
20
- }
21
-
22
- static override fromSexprPrimitives(
23
- primitiveSexprs: PrimitiveSExpr[],
24
- ): SingleValueProperty<string | number> {
25
- const [valuePrimitive] = primitiveSexprs
26
- const value = (this as typeof SingleValueProperty).parsePrimitiveValue(
27
- valuePrimitive,
28
- )
29
- const Constructor = this as unknown as SingleValuePropertyConstructor<
30
- string | number
31
- >
32
- return new Constructor(value)
33
- }
34
-
35
- protected static parsePrimitiveValue(
36
- value: PrimitiveSExpr | undefined,
37
- ): string | number {
38
- const stringValue = toStringValue(value)
39
- if (stringValue === undefined) {
40
- throw new Error(`${this.name} expects a primitive value`)
41
- }
42
- return stringValue
43
- }
44
-
45
- get value(): T {
46
- return this._value
47
- }
48
-
49
- set value(value: T) {
50
- this._value = value
51
- }
52
-
53
- override getChildren(): SxClass[] {
54
- return []
55
- }
56
-
57
- protected formatValue(): string {
58
- if (typeof this._value === "string") {
59
- return this.quoteStringValue ? quoteSExprString(this._value) : this._value
60
- }
61
- return `${this._value}`
62
- }
63
-
64
- override getString(): string {
65
- return `(${this.token} ${this.formatValue()})`
66
- }
67
- }
68
-
69
- type NumericListPropertyConstructor = new (
70
- values: number[],
71
- ) => NumericListProperty
72
-
73
- export abstract class NumericListProperty extends SxClass {
74
- protected _values: number[]
75
-
76
- constructor(values: number[]) {
77
- super()
78
- this._values = values
79
- }
80
-
81
- static override fromSexprPrimitives(
82
- primitiveSexprs: PrimitiveSExpr[],
83
- ): NumericListProperty {
84
- const values = primitiveSexprs.map((primitive) => {
85
- const value = toNumberValue(primitive)
86
- if (value === undefined) {
87
- throw new Error(
88
- `${this.name} expects numeric primitives but received ${primitive}`,
89
- )
90
- }
91
- return value
92
- })
93
- const Constructor = this as unknown as NumericListPropertyConstructor
94
- return new Constructor(values)
95
- }
96
-
97
- get values(): number[] {
98
- return [...this._values]
99
- }
100
-
101
- set values(values: number[]) {
102
- this._values = [...values]
103
- }
104
-
105
- override getChildren(): SxClass[] {
106
- return []
107
- }
108
-
109
- override getString(): string {
110
- return `(${this.token} ${this._values.join(" ")})`
111
- }
112
- }
113
-
114
- type CoordinatePropertyConstructor = new (
115
- x: number,
116
- y: number,
117
- ) => CoordinateProperty
118
-
119
- export abstract class CoordinateProperty extends SxClass {
120
- protected _x: number
121
- protected _y: number
122
-
123
- constructor(x: number, y: number) {
124
- super()
125
- this._x = x
126
- this._y = y
127
- }
128
-
129
- static override fromSexprPrimitives(
130
- primitiveSexprs: PrimitiveSExpr[],
131
- ): CoordinateProperty {
132
- const [xPrimitive, yPrimitive] = primitiveSexprs
133
- const x = toNumberValue(xPrimitive)
134
- const y = toNumberValue(yPrimitive)
135
- if (x === undefined || y === undefined) {
136
- throw new Error(`${this.name} expects two numeric values`)
137
- }
138
- const Constructor = this as unknown as CoordinatePropertyConstructor
139
- return new Constructor(x, y)
140
- }
141
-
142
- get x(): number {
143
- return this._x
144
- }
145
-
146
- set x(value: number) {
147
- this._x = value
148
- }
149
-
150
- get y(): number {
151
- return this._y
152
- }
153
-
154
- set y(value: number) {
155
- this._y = value
156
- }
157
-
158
- override getChildren(): SxClass[] {
159
- return []
160
- }
161
-
162
- override getString(): string {
163
- return `(${this.token} ${this._x} ${this._y})`
164
- }
165
- }
@@ -1,14 +0,0 @@
1
- export * from "./Setup"
2
- export * from "./Stackup"
3
- export * from "./StackupLayer"
4
- export * from "./StackupProperties"
5
- export * from "./StackupLayerProperties"
6
- export * from "./PcbPlotParams"
7
- export * from "./PcbPlotParamsBase"
8
- export * from "./PcbPlotParamsNumericProperties"
9
- export * from "./PcbPlotParamsStringPropertiesA"
10
- export * from "./PcbPlotParamsStringPropertiesB"
11
- export * from "./setupNumericProperties"
12
- export * from "./setupMultiValueProperties"
13
- export * from "./setupStringProperties"
14
- export * from "./SetupPropertyTypes"