kicadts 0.0.3 → 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.
- package/dist/index.d.ts +4466 -0
- package/dist/index.js +14253 -0
- package/package.json +4 -1
- package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +0 -111
- package/.github/workflows/bun-formatcheck.yml +0 -26
- package/.github/workflows/bun-pver-release.yml +0 -70
- package/.github/workflows/bun-test.yml +0 -32
- package/.github/workflows/bun-typecheck.yml +0 -26
- package/.vscode/settings.json +0 -16
- package/AGENTS.md +0 -31
- package/TODO.md +0 -46
- package/biome.json +0 -93
- package/bunfig.toml +0 -5
- package/lib/index.ts +0 -1
- package/lib/sexpr/base-classes/SxClass.ts +0 -164
- package/lib/sexpr/base-classes/SxPrimitiveBoolean.ts +0 -35
- package/lib/sexpr/base-classes/SxPrimitiveNumber.ts +0 -26
- package/lib/sexpr/base-classes/SxPrimitiveString.ts +0 -26
- package/lib/sexpr/classes/At.ts +0 -53
- package/lib/sexpr/classes/Bus.ts +0 -103
- package/lib/sexpr/classes/BusEntry.ts +0 -169
- package/lib/sexpr/classes/Color.ts +0 -29
- package/lib/sexpr/classes/Dnp.ts +0 -8
- package/lib/sexpr/classes/EmbeddedFonts.ts +0 -68
- package/lib/sexpr/classes/ExcludeFromSim.ts +0 -8
- package/lib/sexpr/classes/FieldsAutoplaced.ts +0 -8
- package/lib/sexpr/classes/Footprint.ts +0 -849
- package/lib/sexpr/classes/FootprintAttr.ts +0 -104
- package/lib/sexpr/classes/FootprintAutoplaceCost180.ts +0 -9
- package/lib/sexpr/classes/FootprintAutoplaceCost90.ts +0 -9
- package/lib/sexpr/classes/FootprintClearance.ts +0 -9
- package/lib/sexpr/classes/FootprintDescr.ts +0 -44
- package/lib/sexpr/classes/FootprintLocked.ts +0 -32
- package/lib/sexpr/classes/FootprintModel.ts +0 -142
- package/lib/sexpr/classes/FootprintNetTiePadGroups.ts +0 -52
- package/lib/sexpr/classes/FootprintPad.ts +0 -857
- package/lib/sexpr/classes/FootprintPath.ts +0 -44
- package/lib/sexpr/classes/FootprintPlaced.ts +0 -32
- package/lib/sexpr/classes/FootprintPrivateLayers.ts +0 -56
- package/lib/sexpr/classes/FootprintSheetfile.ts +0 -44
- package/lib/sexpr/classes/FootprintSheetname.ts +0 -44
- package/lib/sexpr/classes/FootprintSolderMaskMargin.ts +0 -9
- package/lib/sexpr/classes/FootprintSolderPasteMargin.ts +0 -9
- package/lib/sexpr/classes/FootprintSolderPasteRatio.ts +0 -9
- package/lib/sexpr/classes/FootprintTags.ts +0 -44
- package/lib/sexpr/classes/FootprintTedit.ts +0 -21
- package/lib/sexpr/classes/FootprintThermalGap.ts +0 -9
- package/lib/sexpr/classes/FootprintThermalWidth.ts +0 -9
- package/lib/sexpr/classes/FootprintZoneConnect.ts +0 -9
- package/lib/sexpr/classes/FpArc.ts +0 -312
- package/lib/sexpr/classes/FpCircle.ts +0 -314
- package/lib/sexpr/classes/FpLine.ts +0 -316
- package/lib/sexpr/classes/FpPoly.ts +0 -286
- package/lib/sexpr/classes/FpPolyFill.ts +0 -48
- package/lib/sexpr/classes/FpPolyLocked.ts +0 -40
- package/lib/sexpr/classes/FpRect.ts +0 -314
- package/lib/sexpr/classes/FpText.ts +0 -375
- package/lib/sexpr/classes/FpTextBox.ts +0 -450
- package/lib/sexpr/classes/GrLine.ts +0 -264
- package/lib/sexpr/classes/GrLineAngle.ts +0 -32
- package/lib/sexpr/classes/GrLineEnd.ts +0 -61
- package/lib/sexpr/classes/GrLineLocked.ts +0 -40
- package/lib/sexpr/classes/GrLineStart.ts +0 -61
- package/lib/sexpr/classes/GrText.ts +0 -228
- package/lib/sexpr/classes/Image.ts +0 -283
- package/lib/sexpr/classes/InBom.ts +0 -8
- package/lib/sexpr/classes/Junction.ts +0 -166
- package/lib/sexpr/classes/KicadPcb.ts +0 -361
- package/lib/sexpr/classes/KicadSch.ts +0 -397
- package/lib/sexpr/classes/KicadSchGenerator.ts +0 -32
- package/lib/sexpr/classes/KicadSchGeneratorVersion.ts +0 -30
- package/lib/sexpr/classes/KicadSchVersion.ts +0 -22
- package/lib/sexpr/classes/Label.ts +0 -176
- package/lib/sexpr/classes/Layer.ts +0 -51
- package/lib/sexpr/classes/Layers.ts +0 -47
- package/lib/sexpr/classes/LibSymbols.ts +0 -61
- package/lib/sexpr/classes/NoConnect.ts +0 -90
- package/lib/sexpr/classes/OnBoard.ts +0 -8
- package/lib/sexpr/classes/PadChamfer.ts +0 -50
- package/lib/sexpr/classes/PadChamferRatio.ts +0 -9
- package/lib/sexpr/classes/PadClearance.ts +0 -9
- package/lib/sexpr/classes/PadDieLength.ts +0 -9
- package/lib/sexpr/classes/PadDrill.ts +0 -145
- package/lib/sexpr/classes/PadDrillOffset.ts +0 -54
- package/lib/sexpr/classes/PadLayers.ts +0 -71
- package/lib/sexpr/classes/PadNet.ts +0 -56
- package/lib/sexpr/classes/PadOptions.ts +0 -181
- package/lib/sexpr/classes/PadPinFunction.ts +0 -9
- package/lib/sexpr/classes/PadPinType.ts +0 -9
- package/lib/sexpr/classes/PadPrimitiveGrArc.ts +0 -272
- package/lib/sexpr/classes/PadPrimitiveGrCircle.ts +0 -298
- package/lib/sexpr/classes/PadPrimitiveGrLine.ts +0 -126
- package/lib/sexpr/classes/PadPrimitives.ts +0 -291
- package/lib/sexpr/classes/PadRectDelta.ts +0 -57
- package/lib/sexpr/classes/PadRoundrectRratio.ts +0 -9
- package/lib/sexpr/classes/PadSize.ts +0 -69
- package/lib/sexpr/classes/PadSolderMaskMargin.ts +0 -9
- package/lib/sexpr/classes/PadSolderPasteMargin.ts +0 -9
- package/lib/sexpr/classes/PadSolderPasteMarginRatio.ts +0 -9
- package/lib/sexpr/classes/PadTeardrops.ts +0 -210
- package/lib/sexpr/classes/PadThermalBridgeAngle.ts +0 -9
- package/lib/sexpr/classes/PadThermalGap.ts +0 -9
- package/lib/sexpr/classes/PadThermalWidth.ts +0 -9
- package/lib/sexpr/classes/PadZoneConnect.ts +0 -9
- package/lib/sexpr/classes/Paper.ts +0 -119
- package/lib/sexpr/classes/PcbGeneral.ts +0 -82
- package/lib/sexpr/classes/PcbGeneralLegacyTeardrops.ts +0 -44
- package/lib/sexpr/classes/PcbGeneralThickness.ts +0 -9
- package/lib/sexpr/classes/PcbGenerator.ts +0 -16
- package/lib/sexpr/classes/PcbGeneratorVersion.ts +0 -16
- package/lib/sexpr/classes/PcbLayerDefinition.ts +0 -106
- package/lib/sexpr/classes/PcbLayers.ts +0 -34
- package/lib/sexpr/classes/PcbNet.ts +0 -56
- package/lib/sexpr/classes/PcbVersion.ts +0 -9
- package/lib/sexpr/classes/Property.ts +0 -301
- package/lib/sexpr/classes/PropertyHide.ts +0 -9
- package/lib/sexpr/classes/PropertyUnlocked.ts +0 -9
- package/lib/sexpr/classes/Pts.ts +0 -67
- package/lib/sexpr/classes/RenderCache.ts +0 -221
- package/lib/sexpr/classes/SchematicText.ts +0 -171
- package/lib/sexpr/classes/Segment.ts +0 -243
- package/lib/sexpr/classes/SegmentEnd.ts +0 -59
- package/lib/sexpr/classes/SegmentLocked.ts +0 -33
- package/lib/sexpr/classes/SegmentNet.ts +0 -64
- package/lib/sexpr/classes/SegmentStart.ts +0 -59
- package/lib/sexpr/classes/Setup/PcbPlotParams.ts +0 -689
- package/lib/sexpr/classes/Setup/PcbPlotParamsBase.ts +0 -9
- package/lib/sexpr/classes/Setup/PcbPlotParamsNumericProperties.ts +0 -105
- package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesA.ts +0 -104
- package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesB.ts +0 -105
- package/lib/sexpr/classes/Setup/Setup.ts +0 -574
- package/lib/sexpr/classes/Setup/SetupPropertyTypes.ts +0 -119
- package/lib/sexpr/classes/Setup/Stackup.ts +0 -135
- package/lib/sexpr/classes/Setup/StackupLayer.ts +0 -233
- package/lib/sexpr/classes/Setup/StackupLayerProperties.ts +0 -80
- package/lib/sexpr/classes/Setup/StackupProperties.ts +0 -40
- package/lib/sexpr/classes/Setup/base.ts +0 -165
- package/lib/sexpr/classes/Setup/index.ts +0 -14
- package/lib/sexpr/classes/Setup/setupMultiValueProperties.ts +0 -53
- package/lib/sexpr/classes/Setup/setupNumericProperties.ts +0 -151
- package/lib/sexpr/classes/Setup/setupPropertyHandlers.ts +0 -90
- package/lib/sexpr/classes/Setup/setupStringProperties.ts +0 -75
- package/lib/sexpr/classes/Sheet.ts +0 -287
- package/lib/sexpr/classes/SheetFill.ts +0 -44
- package/lib/sexpr/classes/SheetInstances.ts +0 -168
- package/lib/sexpr/classes/SheetInstancesRoot.ts +0 -165
- package/lib/sexpr/classes/SheetPin.ts +0 -125
- package/lib/sexpr/classes/SheetProperty.ts +0 -115
- package/lib/sexpr/classes/SheetSize.ts +0 -44
- package/lib/sexpr/classes/Stroke.ts +0 -58
- package/lib/sexpr/classes/StrokeType.ts +0 -34
- package/lib/sexpr/classes/Symbol.ts +0 -1666
- package/lib/sexpr/classes/TextEffects.ts +0 -461
- package/lib/sexpr/classes/TitleBlock.ts +0 -369
- package/lib/sexpr/classes/Unit.ts +0 -28
- package/lib/sexpr/classes/Uuid.ts +0 -8
- package/lib/sexpr/classes/Via.ts +0 -363
- package/lib/sexpr/classes/ViaNet.ts +0 -60
- package/lib/sexpr/classes/Width.ts +0 -8
- package/lib/sexpr/classes/Wire.ts +0 -111
- package/lib/sexpr/classes/Xy.ts +0 -33
- package/lib/sexpr/classes/Zone.ts +0 -39
- package/lib/sexpr/index.ts +0 -130
- package/lib/sexpr/parseKicadSexpr.ts +0 -5
- package/lib/sexpr/parseToPrimitiveSExpr.ts +0 -245
- package/lib/sexpr/utils/indentLines.ts +0 -3
- package/lib/sexpr/utils/parseYesNo.ts +0 -12
- package/lib/sexpr/utils/quoteSExprString.ts +0 -8
- package/lib/sexpr/utils/strokeFromArgs.ts +0 -18
- package/lib/sexpr/utils/toNumberValue.ts +0 -13
- package/lib/sexpr/utils/toStringValue.ts +0 -11
- package/scripts/download-references.ts +0 -68
- package/tests/fixtures/expectEqualPrimitiveSExpr.ts +0 -199
- package/tests/fixtures/png-matcher.ts +0 -109
- package/tests/fixtures/preload.ts +0 -1
- package/tests/sexpr/KicadPcbDemos.test.ts +0 -48
- package/tests/sexpr/KicadSchDemos.test.ts +0 -49
- package/tests/sexpr/classes/Footprint.test.ts +0 -277
- package/tests/sexpr/classes/FootprintPad.test.ts +0 -78
- package/tests/sexpr/classes/FpArc.test.ts +0 -45
- package/tests/sexpr/classes/FpCircle.test.ts +0 -39
- package/tests/sexpr/classes/FpPoly.test.ts +0 -43
- package/tests/sexpr/classes/FpRect.test.ts +0 -40
- package/tests/sexpr/classes/FpTextBox.test.ts +0 -84
- package/tests/sexpr/classes/Image.test.ts +0 -58
- package/tests/sexpr/classes/KicadSch.test.ts +0 -95
- package/tests/sexpr/classes/Paper.test.ts +0 -30
- package/tests/sexpr/classes/Property.test.ts +0 -48
- package/tests/sexpr/classes/Setup.test.ts +0 -188
- package/tests/sexpr/classes/Sheet.test.ts +0 -107
- package/tests/sexpr/classes/Stroke.test.ts +0 -15
- package/tests/sexpr/classes/Symbol.test.ts +0 -96
- package/tests/sexpr/classes/TextEffects.test.ts +0 -56
- package/tests/sexpr/classes/TitleBlock.test.ts +0 -40
- package/tsconfig.json +0 -35
package/lib/sexpr/classes/Via.ts
DELETED
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { quoteSExprString } from "../utils/quoteSExprString"
|
|
4
|
-
import { At, type AtInput } from "./At"
|
|
5
|
-
import { Layers } from "./Layers"
|
|
6
|
-
import { Uuid } from "./Uuid"
|
|
7
|
-
import { ViaNet } from "./ViaNet"
|
|
8
|
-
import { toNumberValue } from "../utils/toNumberValue"
|
|
9
|
-
import { toStringValue } from "../utils/toStringValue"
|
|
10
|
-
import { PadTeardrops } from "./PadTeardrops"
|
|
11
|
-
|
|
12
|
-
const BARE_FLAGS = new Set([
|
|
13
|
-
"locked",
|
|
14
|
-
"free",
|
|
15
|
-
"remove_unused_layers",
|
|
16
|
-
"keep_end_layers",
|
|
17
|
-
])
|
|
18
|
-
|
|
19
|
-
export interface ViaConstructorParams {
|
|
20
|
-
type?: string
|
|
21
|
-
locked?: boolean
|
|
22
|
-
free?: boolean
|
|
23
|
-
removeUnusedLayers?: boolean
|
|
24
|
-
keepEndLayers?: boolean
|
|
25
|
-
at?: AtInput
|
|
26
|
-
size?: number
|
|
27
|
-
drill?: number
|
|
28
|
-
layers?: Layers | string[]
|
|
29
|
-
net?: ViaNet
|
|
30
|
-
uuid?: Uuid | string
|
|
31
|
-
tstamp?: string
|
|
32
|
-
teardrops?: PadTeardrops
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class Via extends SxClass {
|
|
36
|
-
static override token = "via"
|
|
37
|
-
token = "via"
|
|
38
|
-
|
|
39
|
-
private _type?: string
|
|
40
|
-
private _locked = false
|
|
41
|
-
private _free = false
|
|
42
|
-
private _removeUnusedLayers = false
|
|
43
|
-
private _keepEndLayers = false
|
|
44
|
-
private _sxAt?: At
|
|
45
|
-
private _size?: number
|
|
46
|
-
private _drill?: number
|
|
47
|
-
private _sxLayers?: Layers
|
|
48
|
-
private _sxNet?: ViaNet
|
|
49
|
-
private _sxUuid?: Uuid
|
|
50
|
-
private _tstamp?: string
|
|
51
|
-
private _sxTeardrops?: PadTeardrops
|
|
52
|
-
|
|
53
|
-
constructor(params: ViaConstructorParams = {}) {
|
|
54
|
-
super()
|
|
55
|
-
if (params.type !== undefined) this.type = params.type
|
|
56
|
-
if (params.locked !== undefined) this.locked = params.locked
|
|
57
|
-
if (params.free !== undefined) this.free = params.free
|
|
58
|
-
if (params.removeUnusedLayers !== undefined)
|
|
59
|
-
this.removeUnusedLayers = params.removeUnusedLayers
|
|
60
|
-
if (params.keepEndLayers !== undefined)
|
|
61
|
-
this.keepEndLayers = params.keepEndLayers
|
|
62
|
-
if (params.at !== undefined) this.at = params.at
|
|
63
|
-
if (params.size !== undefined) this.size = params.size
|
|
64
|
-
if (params.drill !== undefined) this.drill = params.drill
|
|
65
|
-
if (params.layers !== undefined) this.layers = params.layers
|
|
66
|
-
if (params.net !== undefined) this.net = params.net
|
|
67
|
-
if (params.uuid !== undefined) this.uuid = params.uuid
|
|
68
|
-
if (params.tstamp !== undefined) this.tstamp = params.tstamp
|
|
69
|
-
if (params.teardrops !== undefined) this.teardrops = params.teardrops
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static override fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): Via {
|
|
73
|
-
const via = new Via()
|
|
74
|
-
|
|
75
|
-
for (const primitive of primitiveSexprs) {
|
|
76
|
-
if (typeof primitive === "string") {
|
|
77
|
-
via.consumeBareToken(primitive)
|
|
78
|
-
continue
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
82
|
-
throw new Error(
|
|
83
|
-
`via encountered unsupported primitive child: ${JSON.stringify(primitive)}`,
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const [token, ...rest] = primitive
|
|
88
|
-
if (typeof token !== "string") {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`via encountered child with non-string token: ${JSON.stringify(primitive)}`,
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
via.consumeNode(token, rest as PrimitiveSExpr[])
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return via
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private consumeBareToken(token: string) {
|
|
101
|
-
if (token === "blind" || token === "micro") {
|
|
102
|
-
this._type = token
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
if (!BARE_FLAGS.has(token)) {
|
|
106
|
-
throw new Error(`via encountered unsupported flag "${token}"`)
|
|
107
|
-
}
|
|
108
|
-
switch (token) {
|
|
109
|
-
case "locked":
|
|
110
|
-
this._locked = true
|
|
111
|
-
break
|
|
112
|
-
case "free":
|
|
113
|
-
this._free = true
|
|
114
|
-
break
|
|
115
|
-
case "remove_unused_layers":
|
|
116
|
-
this._removeUnusedLayers = true
|
|
117
|
-
break
|
|
118
|
-
case "keep_end_layers":
|
|
119
|
-
this._keepEndLayers = true
|
|
120
|
-
break
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private consumeNode(token: string, args: PrimitiveSExpr[]) {
|
|
125
|
-
switch (token) {
|
|
126
|
-
case "type": {
|
|
127
|
-
const value = toStringValue(args[0])
|
|
128
|
-
if (value === undefined) {
|
|
129
|
-
throw new Error("via type expects a string value")
|
|
130
|
-
}
|
|
131
|
-
this._type = value
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
case "locked":
|
|
135
|
-
this._locked = this.parseYesNo(args)
|
|
136
|
-
return
|
|
137
|
-
case "free":
|
|
138
|
-
this._free = this.parseYesNo(args)
|
|
139
|
-
return
|
|
140
|
-
case "remove_unused_layers":
|
|
141
|
-
this._removeUnusedLayers = this.parseYesNo(args)
|
|
142
|
-
return
|
|
143
|
-
case "keep_end_layers":
|
|
144
|
-
this._keepEndLayers = this.parseYesNo(args)
|
|
145
|
-
return
|
|
146
|
-
case "at": {
|
|
147
|
-
const parsed = SxClass.parsePrimitiveSexpr(["at", ...args] as any, {
|
|
148
|
-
parentToken: this.token,
|
|
149
|
-
})
|
|
150
|
-
if (!(parsed instanceof At)) {
|
|
151
|
-
throw new Error("via failed to parse at child")
|
|
152
|
-
}
|
|
153
|
-
this._sxAt = parsed
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
case "size": {
|
|
157
|
-
const value = toNumberValue(args[0])
|
|
158
|
-
if (value === undefined) {
|
|
159
|
-
throw new Error("via size expects a numeric value")
|
|
160
|
-
}
|
|
161
|
-
this._size = value
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
case "drill": {
|
|
165
|
-
const value = toNumberValue(args[0])
|
|
166
|
-
if (value === undefined) {
|
|
167
|
-
throw new Error("via drill expects a numeric value")
|
|
168
|
-
}
|
|
169
|
-
this._drill = value
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
case "layers": {
|
|
173
|
-
this._sxLayers = Layers.fromSexprPrimitives(args)
|
|
174
|
-
return
|
|
175
|
-
}
|
|
176
|
-
case "net": {
|
|
177
|
-
this._sxNet = ViaNet.fromSexprPrimitives(args)
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
case "teardrops": {
|
|
181
|
-
this._sxTeardrops = PadTeardrops.fromSexprPrimitives(args)
|
|
182
|
-
return
|
|
183
|
-
}
|
|
184
|
-
case "uuid": {
|
|
185
|
-
const value = toStringValue(args[0])
|
|
186
|
-
if (value === undefined) {
|
|
187
|
-
throw new Error("via uuid expects a string value")
|
|
188
|
-
}
|
|
189
|
-
this._sxUuid = new Uuid(value)
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
case "tstamp": {
|
|
193
|
-
const value = toStringValue(args[0])
|
|
194
|
-
if (value === undefined) {
|
|
195
|
-
throw new Error("via tstamp expects a string value")
|
|
196
|
-
}
|
|
197
|
-
this._tstamp = value
|
|
198
|
-
return
|
|
199
|
-
}
|
|
200
|
-
default:
|
|
201
|
-
throw new Error(`via encountered unsupported child token "${token}"`)
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
private parseYesNo(args: PrimitiveSExpr[]): boolean {
|
|
206
|
-
if (args.length === 0) return true
|
|
207
|
-
const value = toStringValue(args[0])
|
|
208
|
-
if (value === undefined) {
|
|
209
|
-
throw new Error("Expected string when parsing via boolean child")
|
|
210
|
-
}
|
|
211
|
-
return /^(yes|true)$/iu.test(value)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
get type(): string | undefined {
|
|
215
|
-
return this._type
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
set type(value: string | undefined) {
|
|
219
|
-
this._type = value
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
get locked(): boolean {
|
|
223
|
-
return this._locked
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
set locked(value: boolean) {
|
|
227
|
-
this._locked = value
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
get free(): boolean {
|
|
231
|
-
return this._free
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
set free(value: boolean) {
|
|
235
|
-
this._free = value
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
get removeUnusedLayers(): boolean {
|
|
239
|
-
return this._removeUnusedLayers
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
set removeUnusedLayers(value: boolean) {
|
|
243
|
-
this._removeUnusedLayers = value
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
get keepEndLayers(): boolean {
|
|
247
|
-
return this._keepEndLayers
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
set keepEndLayers(value: boolean) {
|
|
251
|
-
this._keepEndLayers = value
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
get at(): At | undefined {
|
|
255
|
-
return this._sxAt
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
set at(value: AtInput | undefined) {
|
|
259
|
-
this._sxAt = value !== undefined ? At.from(value) : undefined
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
get size(): number | undefined {
|
|
263
|
-
return this._size
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
set size(value: number | undefined) {
|
|
267
|
-
this._size = value
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
get drill(): number | undefined {
|
|
271
|
-
return this._drill
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
set drill(value: number | undefined) {
|
|
275
|
-
this._drill = value
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
get layers(): Layers | undefined {
|
|
279
|
-
return this._sxLayers
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
set layers(value: Layers | string[] | undefined) {
|
|
283
|
-
if (value === undefined) {
|
|
284
|
-
this._sxLayers = undefined
|
|
285
|
-
return
|
|
286
|
-
}
|
|
287
|
-
this._sxLayers = value instanceof Layers ? value : new Layers(value)
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
get net(): ViaNet | undefined {
|
|
291
|
-
return this._sxNet
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
set net(value: ViaNet | undefined) {
|
|
295
|
-
this._sxNet = value
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
get uuid(): Uuid | undefined {
|
|
299
|
-
return this._sxUuid
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
set uuid(value: Uuid | string | undefined) {
|
|
303
|
-
if (value === undefined) {
|
|
304
|
-
this._sxUuid = undefined
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
this._sxUuid = value instanceof Uuid ? value : new Uuid(value)
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
get teardrops(): PadTeardrops | undefined {
|
|
311
|
-
return this._sxTeardrops
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
set teardrops(value: PadTeardrops | undefined) {
|
|
315
|
-
this._sxTeardrops = value
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
get tstamp(): string | undefined {
|
|
319
|
-
return this._tstamp
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
set tstamp(value: string | undefined) {
|
|
323
|
-
this._tstamp = value
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
override getChildren(): SxClass[] {
|
|
327
|
-
const children: SxClass[] = []
|
|
328
|
-
if (this._sxAt) children.push(this._sxAt)
|
|
329
|
-
if (this._sxLayers) children.push(this._sxLayers)
|
|
330
|
-
if (this._sxNet) children.push(this._sxNet)
|
|
331
|
-
if (this._sxUuid) children.push(this._sxUuid)
|
|
332
|
-
if (this._sxTeardrops) children.push(this._sxTeardrops)
|
|
333
|
-
return children
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
override getString(): string {
|
|
337
|
-
const lines = ["(via"]
|
|
338
|
-
|
|
339
|
-
if (this._type !== undefined) {
|
|
340
|
-
lines.push(` (type ${this._type})`)
|
|
341
|
-
}
|
|
342
|
-
if (this._locked) lines.push(" locked")
|
|
343
|
-
if (this._free) lines.push(" free")
|
|
344
|
-
if (this._removeUnusedLayers) lines.push(" remove_unused_layers")
|
|
345
|
-
if (this._keepEndLayers) lines.push(" keep_end_layers")
|
|
346
|
-
if (this._sxAt) lines.push(this._sxAt.getStringIndented())
|
|
347
|
-
if (this._size !== undefined) lines.push(` (size ${this._size})`)
|
|
348
|
-
if (this._drill !== undefined) lines.push(` (drill ${this._drill})`)
|
|
349
|
-
if (this._sxLayers) lines.push(this._sxLayers.getStringIndented())
|
|
350
|
-
if (this._sxNet) lines.push(this._sxNet.getStringIndented())
|
|
351
|
-
if (this._sxUuid) lines.push(this._sxUuid.getStringIndented())
|
|
352
|
-
if (this._tstamp !== undefined) {
|
|
353
|
-
lines.push(` (tstamp ${quoteSExprString(this._tstamp)})`)
|
|
354
|
-
}
|
|
355
|
-
if (this._sxTeardrops) {
|
|
356
|
-
lines.push(this._sxTeardrops.getStringIndented())
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
lines.push(")")
|
|
360
|
-
return lines.join("\n")
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
SxClass.register(Via)
|
|
@@ -1,60 +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
|
-
export class ViaNet extends SxClass {
|
|
8
|
-
static override token = "net"
|
|
9
|
-
static override parentToken = "via"
|
|
10
|
-
token = "net"
|
|
11
|
-
|
|
12
|
-
private _id: number
|
|
13
|
-
private _name?: string
|
|
14
|
-
|
|
15
|
-
constructor(id: number, name?: string) {
|
|
16
|
-
super()
|
|
17
|
-
this._id = id
|
|
18
|
-
this._name = name
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static override fromSexprPrimitives(
|
|
22
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
23
|
-
): ViaNet {
|
|
24
|
-
const id = toNumberValue(primitiveSexprs[0])
|
|
25
|
-
if (id === undefined) {
|
|
26
|
-
throw new Error("via net requires a numeric id")
|
|
27
|
-
}
|
|
28
|
-
const name =
|
|
29
|
-
primitiveSexprs.length > 1 ? toStringValue(primitiveSexprs[1]) : undefined
|
|
30
|
-
return new ViaNet(id, name)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get id(): number {
|
|
34
|
-
return this._id
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
set id(value: number) {
|
|
38
|
-
this._id = value
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get name(): string | undefined {
|
|
42
|
-
return this._name
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
set name(value: string | undefined) {
|
|
46
|
-
this._name = value
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
override getChildren(): SxClass[] {
|
|
50
|
-
return []
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
override getString(): string {
|
|
54
|
-
if (this._name !== undefined) {
|
|
55
|
-
return `(net ${this._id} ${quoteSExprString(this._name)})`
|
|
56
|
-
}
|
|
57
|
-
return `(net ${this._id})`
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
SxClass.register(ViaNet)
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { Pts } from "./Pts"
|
|
4
|
-
import { Stroke } from "./Stroke"
|
|
5
|
-
import { Uuid } from "./Uuid"
|
|
6
|
-
|
|
7
|
-
const SUPPORTED_TOKENS = new Set(["pts", "stroke", "uuid"])
|
|
8
|
-
|
|
9
|
-
export interface WireConstructorParams {
|
|
10
|
-
points?: Pts
|
|
11
|
-
stroke?: Stroke
|
|
12
|
-
uuid?: string | Uuid
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class Wire extends SxClass {
|
|
16
|
-
static override token = "wire"
|
|
17
|
-
static override parentToken = "kicad_sch"
|
|
18
|
-
override token = "wire"
|
|
19
|
-
|
|
20
|
-
private _sxPts?: Pts
|
|
21
|
-
private _sxStroke?: Stroke
|
|
22
|
-
private _sxUuid?: Uuid
|
|
23
|
-
|
|
24
|
-
constructor(params: WireConstructorParams = {}) {
|
|
25
|
-
super()
|
|
26
|
-
|
|
27
|
-
if (params.points !== undefined) {
|
|
28
|
-
this.points = params.points
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (params.stroke !== undefined) {
|
|
32
|
-
this.stroke = params.stroke
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (params.uuid !== undefined) {
|
|
36
|
-
this.uuid = params.uuid
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static override fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): Wire {
|
|
41
|
-
const wire = new Wire()
|
|
42
|
-
|
|
43
|
-
const { propertyMap, arrayPropertyMap } =
|
|
44
|
-
SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token)
|
|
45
|
-
|
|
46
|
-
for (const [token, entries] of Object.entries(arrayPropertyMap)) {
|
|
47
|
-
if (!SUPPORTED_TOKENS.has(token)) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Unsupported child tokens inside wire expression: ${token}`,
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
if (entries.length > 1) {
|
|
53
|
-
throw new Error(`wire does not support repeated child tokens: ${token}`)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const unsupportedTokens = Object.keys(propertyMap).filter(
|
|
58
|
-
(token) => !SUPPORTED_TOKENS.has(token),
|
|
59
|
-
)
|
|
60
|
-
if (unsupportedTokens.length > 0) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Unsupported child tokens inside wire expression: ${unsupportedTokens.join(", ")}`,
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
wire._sxPts =
|
|
67
|
-
(arrayPropertyMap.pts?.[0] as Pts | undefined) ??
|
|
68
|
-
(propertyMap.pts as Pts | undefined)
|
|
69
|
-
wire._sxStroke = propertyMap.stroke as Stroke | undefined
|
|
70
|
-
wire._sxUuid = propertyMap.uuid as Uuid | undefined
|
|
71
|
-
|
|
72
|
-
return wire
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get points(): Pts | undefined {
|
|
76
|
-
return this._sxPts
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
set points(value: Pts | undefined) {
|
|
80
|
-
this._sxPts = value
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get stroke(): Stroke | undefined {
|
|
84
|
-
return this._sxStroke
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
set stroke(value: Stroke | undefined) {
|
|
88
|
-
this._sxStroke = value
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get uuid(): Uuid | undefined {
|
|
92
|
-
return this._sxUuid
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
set uuid(value: Uuid | string | undefined) {
|
|
96
|
-
if (value === undefined) {
|
|
97
|
-
this._sxUuid = undefined
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
this._sxUuid = value instanceof Uuid ? value : new Uuid(value)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
override getChildren(): SxClass[] {
|
|
104
|
-
const children: SxClass[] = []
|
|
105
|
-
if (this._sxPts) children.push(this._sxPts)
|
|
106
|
-
if (this._sxStroke) children.push(this._sxStroke)
|
|
107
|
-
if (this._sxUuid) children.push(this._sxUuid)
|
|
108
|
-
return children
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
SxClass.register(Wire)
|
package/lib/sexpr/classes/Xy.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { toNumberValue } from "../utils/toNumberValue"
|
|
4
|
-
|
|
5
|
-
export class Xy extends SxClass {
|
|
6
|
-
static override token = "xy"
|
|
7
|
-
token = "xy"
|
|
8
|
-
|
|
9
|
-
x: number
|
|
10
|
-
y: number
|
|
11
|
-
|
|
12
|
-
constructor(x: number, y: number) {
|
|
13
|
-
super()
|
|
14
|
-
this.x = x
|
|
15
|
-
this.y = y
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static override fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): Xy {
|
|
19
|
-
const [rawX, rawY] = primitiveSexprs
|
|
20
|
-
const x = toNumberValue(rawX) ?? 0
|
|
21
|
-
const y = toNumberValue(rawY) ?? 0
|
|
22
|
-
return new Xy(x, y)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
override getChildren(): SxClass[] {
|
|
26
|
-
return []
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
override getString(): string {
|
|
30
|
-
return `(xy ${this.x} ${this.y})`
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
SxClass.register(Xy)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import { printSExpr, type PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
|
|
4
|
-
export class Zone extends SxClass {
|
|
5
|
-
static override token = "zone"
|
|
6
|
-
token = "zone"
|
|
7
|
-
|
|
8
|
-
private _rawChildren: PrimitiveSExpr[] = []
|
|
9
|
-
|
|
10
|
-
static override fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): Zone {
|
|
11
|
-
const zone = new Zone()
|
|
12
|
-
zone._rawChildren = [...primitiveSexprs]
|
|
13
|
-
return zone
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get rawChildren(): PrimitiveSExpr[] {
|
|
17
|
-
return [...this._rawChildren]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
set rawChildren(children: PrimitiveSExpr[]) {
|
|
21
|
-
this._rawChildren = [...children]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
override getChildren(): SxClass[] {
|
|
25
|
-
return []
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
override getString(): string {
|
|
29
|
-
const lines = ["(zone"]
|
|
30
|
-
|
|
31
|
-
for (const arg of this._rawChildren) {
|
|
32
|
-
lines.push(` ${printSExpr(arg)}`)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
lines.push(")")
|
|
36
|
-
return lines.join("\n")
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
SxClass.register(Zone)
|