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.
- package/dist/index.d.ts +4466 -0
- package/dist/index.js +14253 -0
- package/package.json +5 -2
- 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
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { At, type AtInput } from "./At"
|
|
4
|
-
import { Color } from "./Color"
|
|
5
|
-
import { Uuid } from "./Uuid"
|
|
6
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
7
|
-
|
|
8
|
-
const SUPPORTED_TOKENS = new Set(["at", "diameter", "color", "uuid"])
|
|
9
|
-
|
|
10
|
-
export interface JunctionConstructorParams {
|
|
11
|
-
at?: AtInput
|
|
12
|
-
diameter?: number | JunctionDiameter
|
|
13
|
-
color?: Color
|
|
14
|
-
uuid?: string | Uuid
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Junction extends SxClass {
|
|
18
|
-
static override token = "junction"
|
|
19
|
-
static override parentToken = "kicad_sch"
|
|
20
|
-
override token = "junction"
|
|
21
|
-
|
|
22
|
-
private _sxAt?: At
|
|
23
|
-
private _sxDiameter?: JunctionDiameter
|
|
24
|
-
private _sxColor?: Color
|
|
25
|
-
private _sxUuid?: Uuid
|
|
26
|
-
|
|
27
|
-
constructor(params: JunctionConstructorParams = {}) {
|
|
28
|
-
super()
|
|
29
|
-
|
|
30
|
-
if (params.at !== undefined) {
|
|
31
|
-
this.at = params.at
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (params.diameter !== undefined) {
|
|
35
|
-
if (params.diameter instanceof JunctionDiameter) {
|
|
36
|
-
this._sxDiameter = params.diameter
|
|
37
|
-
} else {
|
|
38
|
-
this.diameter = params.diameter
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (params.color !== undefined) {
|
|
43
|
-
this.color = params.color
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (params.uuid !== undefined) {
|
|
47
|
-
this.uuid = params.uuid
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static override fromSexprPrimitives(
|
|
52
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
53
|
-
): Junction {
|
|
54
|
-
const junction = new Junction()
|
|
55
|
-
|
|
56
|
-
for (const primitive of primitiveSexprs) {
|
|
57
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`junction encountered invalid child expression: ${JSON.stringify(primitive)}`,
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const parsed = SxClass.parsePrimitiveSexpr(primitive, {
|
|
64
|
-
parentToken: this.token,
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
if (!(parsed instanceof SxClass)) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`junction child did not resolve to an SxClass: ${JSON.stringify(primitive)}`,
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (parsed instanceof At) {
|
|
74
|
-
if (junction._sxAt) {
|
|
75
|
-
throw new Error("junction encountered duplicate at tokens")
|
|
76
|
-
}
|
|
77
|
-
junction._sxAt = parsed
|
|
78
|
-
continue
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (parsed instanceof JunctionDiameter) {
|
|
82
|
-
if (junction._sxDiameter) {
|
|
83
|
-
throw new Error("junction encountered duplicate diameter tokens")
|
|
84
|
-
}
|
|
85
|
-
junction._sxDiameter = parsed
|
|
86
|
-
continue
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (parsed instanceof Color) {
|
|
90
|
-
if (junction._sxColor) {
|
|
91
|
-
throw new Error("junction encountered duplicate color tokens")
|
|
92
|
-
}
|
|
93
|
-
junction._sxColor = parsed
|
|
94
|
-
continue
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (parsed instanceof Uuid) {
|
|
98
|
-
if (junction._sxUuid) {
|
|
99
|
-
throw new Error("junction encountered duplicate uuid tokens")
|
|
100
|
-
}
|
|
101
|
-
junction._sxUuid = parsed
|
|
102
|
-
continue
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
throw new Error(
|
|
106
|
-
`Unsupported child tokens inside junction expression: ${parsed.token}`,
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return junction
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
get at(): At | undefined {
|
|
114
|
-
return this._sxAt
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
set at(value: AtInput | undefined) {
|
|
118
|
-
this._sxAt = value !== undefined ? At.from(value) : undefined
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
get diameter(): number | undefined {
|
|
122
|
-
return this._sxDiameter?.value
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
set diameter(value: number | undefined) {
|
|
126
|
-
this._sxDiameter =
|
|
127
|
-
value === undefined ? undefined : new JunctionDiameter(value)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
get color(): Color | undefined {
|
|
131
|
-
return this._sxColor
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
set color(value: Color | undefined) {
|
|
135
|
-
this._sxColor = value
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
get uuid(): Uuid | undefined {
|
|
139
|
-
return this._sxUuid
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
set uuid(value: Uuid | string | undefined) {
|
|
143
|
-
if (value === undefined) {
|
|
144
|
-
this._sxUuid = undefined
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
this._sxUuid = value instanceof Uuid ? value : new Uuid(value)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
override getChildren(): SxClass[] {
|
|
151
|
-
const children: SxClass[] = []
|
|
152
|
-
if (this._sxAt) children.push(this._sxAt)
|
|
153
|
-
if (this._sxDiameter) children.push(this._sxDiameter)
|
|
154
|
-
if (this._sxColor) children.push(this._sxColor)
|
|
155
|
-
if (this._sxUuid) children.push(this._sxUuid)
|
|
156
|
-
return children
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
SxClass.register(Junction)
|
|
160
|
-
|
|
161
|
-
export class JunctionDiameter extends SxPrimitiveNumber {
|
|
162
|
-
static override token = "diameter"
|
|
163
|
-
static override parentToken = "junction"
|
|
164
|
-
override token = "diameter"
|
|
165
|
-
}
|
|
166
|
-
SxClass.register(JunctionDiameter)
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { Footprint } from "./Footprint"
|
|
4
|
-
import { Image } from "./Image"
|
|
5
|
-
import { PcbGeneral } from "./PcbGeneral"
|
|
6
|
-
import { PcbGenerator } from "./PcbGenerator"
|
|
7
|
-
import { PcbGeneratorVersion } from "./PcbGeneratorVersion"
|
|
8
|
-
import { PcbLayers } from "./PcbLayers"
|
|
9
|
-
import { PcbNet } from "./PcbNet"
|
|
10
|
-
import { PcbVersion } from "./PcbVersion"
|
|
11
|
-
import { Paper } from "./Paper"
|
|
12
|
-
import { Property } from "./Property"
|
|
13
|
-
import { Segment } from "./Segment"
|
|
14
|
-
import { GrLine } from "./GrLine"
|
|
15
|
-
import { GrText } from "./GrText"
|
|
16
|
-
import { Setup } from "./Setup/Setup"
|
|
17
|
-
import { TitleBlock } from "./TitleBlock"
|
|
18
|
-
import { Via } from "./Via"
|
|
19
|
-
import { Zone } from "./Zone"
|
|
20
|
-
|
|
21
|
-
export interface KicadPcbConstructorParams {
|
|
22
|
-
version?: number
|
|
23
|
-
generator?: string
|
|
24
|
-
generatorVersion?: string
|
|
25
|
-
general?: PcbGeneral
|
|
26
|
-
paper?: Paper
|
|
27
|
-
titleBlock?: TitleBlock
|
|
28
|
-
layers?: PcbLayers
|
|
29
|
-
setup?: Setup
|
|
30
|
-
properties?: Property[]
|
|
31
|
-
nets?: PcbNet[]
|
|
32
|
-
footprints?: Footprint[]
|
|
33
|
-
images?: Image[]
|
|
34
|
-
segments?: Segment[]
|
|
35
|
-
graphicLines?: GrLine[]
|
|
36
|
-
graphicTexts?: GrText[]
|
|
37
|
-
vias?: Via[]
|
|
38
|
-
zones?: Zone[]
|
|
39
|
-
otherChildren?: SxClass[]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class KicadPcb extends SxClass {
|
|
43
|
-
static override token = "kicad_pcb"
|
|
44
|
-
token = "kicad_pcb"
|
|
45
|
-
|
|
46
|
-
private _sxVersion?: PcbVersion
|
|
47
|
-
private _sxGenerator?: PcbGenerator
|
|
48
|
-
private _sxGeneratorVersion?: PcbGeneratorVersion
|
|
49
|
-
private _sxGeneral?: PcbGeneral
|
|
50
|
-
private _sxPaper?: Paper
|
|
51
|
-
private _sxTitleBlock?: TitleBlock
|
|
52
|
-
private _sxLayers?: PcbLayers
|
|
53
|
-
private _sxSetup?: Setup
|
|
54
|
-
private _properties: Property[] = []
|
|
55
|
-
private _nets: PcbNet[] = []
|
|
56
|
-
private _footprints: Footprint[] = []
|
|
57
|
-
private _images: Image[] = []
|
|
58
|
-
private _segments: Segment[] = []
|
|
59
|
-
private _grLines: GrLine[] = []
|
|
60
|
-
private _grTexts: GrText[] = []
|
|
61
|
-
private _vias: Via[] = []
|
|
62
|
-
private _zones: Zone[] = []
|
|
63
|
-
private _otherChildren: SxClass[] = []
|
|
64
|
-
|
|
65
|
-
constructor(params: KicadPcbConstructorParams = {}) {
|
|
66
|
-
super()
|
|
67
|
-
if (params.version !== undefined) this.version = params.version
|
|
68
|
-
if (params.generator !== undefined) this.generator = params.generator
|
|
69
|
-
if (params.generatorVersion !== undefined)
|
|
70
|
-
this.generatorVersion = params.generatorVersion
|
|
71
|
-
if (params.general !== undefined) this.general = params.general
|
|
72
|
-
if (params.paper !== undefined) this.paper = params.paper
|
|
73
|
-
if (params.titleBlock !== undefined) this.titleBlock = params.titleBlock
|
|
74
|
-
if (params.layers !== undefined) this.layers = params.layers
|
|
75
|
-
if (params.setup !== undefined) this.setup = params.setup
|
|
76
|
-
if (params.properties !== undefined) this.properties = params.properties
|
|
77
|
-
if (params.nets !== undefined) this.nets = params.nets
|
|
78
|
-
if (params.footprints !== undefined) this.footprints = params.footprints
|
|
79
|
-
if (params.images !== undefined) this.images = params.images
|
|
80
|
-
if (params.segments !== undefined) this.segments = params.segments
|
|
81
|
-
if (params.graphicLines !== undefined)
|
|
82
|
-
this.graphicLines = params.graphicLines
|
|
83
|
-
if (params.graphicTexts !== undefined)
|
|
84
|
-
this.graphicTexts = params.graphicTexts
|
|
85
|
-
if (params.vias !== undefined) this.vias = params.vias
|
|
86
|
-
if (params.zones !== undefined) this.zones = params.zones
|
|
87
|
-
if (params.otherChildren !== undefined)
|
|
88
|
-
this.otherChildren = params.otherChildren
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static override fromSexprPrimitives(
|
|
92
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
93
|
-
): KicadPcb {
|
|
94
|
-
const pcb = new KicadPcb()
|
|
95
|
-
|
|
96
|
-
for (const primitive of primitiveSexprs) {
|
|
97
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
`kicad_pcb encountered unsupported primitive child: ${JSON.stringify(primitive)}`,
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const parsed = SxClass.parsePrimitiveSexpr(primitive, {
|
|
104
|
-
parentToken: this.token,
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
if (!(parsed instanceof SxClass)) {
|
|
108
|
-
throw new Error(
|
|
109
|
-
`kicad_pcb expected SxClass child, received ${JSON.stringify(primitive)}`,
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
pcb.consumeChild(parsed)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return pcb
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private consumeChild(child: SxClass) {
|
|
120
|
-
if (child instanceof PcbVersion) {
|
|
121
|
-
this._sxVersion = child
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
if (child instanceof PcbGenerator) {
|
|
125
|
-
this._sxGenerator = child
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
if (child instanceof PcbGeneratorVersion) {
|
|
129
|
-
this._sxGeneratorVersion = child
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
if (child instanceof PcbGeneral) {
|
|
133
|
-
this._sxGeneral = child
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
if (child instanceof Paper) {
|
|
137
|
-
this._sxPaper = child
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
if (child instanceof TitleBlock) {
|
|
141
|
-
this._sxTitleBlock = child
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
if (child instanceof PcbLayers) {
|
|
145
|
-
this._sxLayers = child
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
if (child instanceof Setup) {
|
|
149
|
-
this._sxSetup = child
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
if (child instanceof Property) {
|
|
153
|
-
this._properties.push(child)
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
if (child instanceof PcbNet) {
|
|
157
|
-
this._nets.push(child)
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
if (child instanceof Footprint) {
|
|
161
|
-
this._footprints.push(child)
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
if (child instanceof Image) {
|
|
165
|
-
this._images.push(child)
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
if (child instanceof Segment) {
|
|
169
|
-
this._segments.push(child)
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
if (child instanceof GrLine) {
|
|
173
|
-
this._grLines.push(child)
|
|
174
|
-
return
|
|
175
|
-
}
|
|
176
|
-
if (child instanceof GrText) {
|
|
177
|
-
this._grTexts.push(child)
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
if (child instanceof Via) {
|
|
181
|
-
this._vias.push(child)
|
|
182
|
-
return
|
|
183
|
-
}
|
|
184
|
-
if (child instanceof Zone) {
|
|
185
|
-
this._zones.push(child)
|
|
186
|
-
return
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
this._otherChildren.push(child)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
get version(): number | undefined {
|
|
193
|
-
return this._sxVersion?.value
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
set version(value: number | undefined) {
|
|
197
|
-
this._sxVersion = value === undefined ? undefined : new PcbVersion(value)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
get generator(): string | undefined {
|
|
201
|
-
return this._sxGenerator?.value
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
set generator(value: string | undefined) {
|
|
205
|
-
this._sxGenerator =
|
|
206
|
-
value === undefined ? undefined : new PcbGenerator(value)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
get generatorVersion(): string | undefined {
|
|
210
|
-
return this._sxGeneratorVersion?.value
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
set generatorVersion(value: string | undefined) {
|
|
214
|
-
this._sxGeneratorVersion =
|
|
215
|
-
value === undefined ? undefined : new PcbGeneratorVersion(value)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
get general(): PcbGeneral | undefined {
|
|
219
|
-
return this._sxGeneral
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
set general(value: PcbGeneral | undefined) {
|
|
223
|
-
this._sxGeneral = value
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
get paper(): Paper | undefined {
|
|
227
|
-
return this._sxPaper
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
set paper(value: Paper | undefined) {
|
|
231
|
-
this._sxPaper = value
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
get titleBlock(): TitleBlock | undefined {
|
|
235
|
-
return this._sxTitleBlock
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
set titleBlock(value: TitleBlock | undefined) {
|
|
239
|
-
this._sxTitleBlock = value
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
get layers(): PcbLayers | undefined {
|
|
243
|
-
return this._sxLayers
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
set layers(value: PcbLayers | undefined) {
|
|
247
|
-
this._sxLayers = value
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
get setup(): Setup | undefined {
|
|
251
|
-
return this._sxSetup
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
set setup(value: Setup | undefined) {
|
|
255
|
-
this._sxSetup = value
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
get properties(): Property[] {
|
|
259
|
-
return [...this._properties]
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
set properties(value: Property[]) {
|
|
263
|
-
this._properties = [...value]
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
get nets(): PcbNet[] {
|
|
267
|
-
return [...this._nets]
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
set nets(value: PcbNet[]) {
|
|
271
|
-
this._nets = [...value]
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
get footprints(): Footprint[] {
|
|
275
|
-
return [...this._footprints]
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
set footprints(value: Footprint[]) {
|
|
279
|
-
this._footprints = [...value]
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
get images(): Image[] {
|
|
283
|
-
return [...this._images]
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
set images(value: Image[]) {
|
|
287
|
-
this._images = [...value]
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
get segments(): Segment[] {
|
|
291
|
-
return [...this._segments]
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
set segments(value: Segment[]) {
|
|
295
|
-
this._segments = [...value]
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
get graphicLines(): GrLine[] {
|
|
299
|
-
return [...this._grLines]
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
set graphicLines(value: GrLine[]) {
|
|
303
|
-
this._grLines = [...value]
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
get graphicTexts(): GrText[] {
|
|
307
|
-
return [...this._grTexts]
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
set graphicTexts(value: GrText[]) {
|
|
311
|
-
this._grTexts = [...value]
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
get vias(): Via[] {
|
|
315
|
-
return [...this._vias]
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
set vias(value: Via[]) {
|
|
319
|
-
this._vias = [...value]
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
get zones(): Zone[] {
|
|
323
|
-
return [...this._zones]
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
set zones(value: Zone[]) {
|
|
327
|
-
this._zones = [...value]
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
get otherChildren(): SxClass[] {
|
|
331
|
-
return [...this._otherChildren]
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
set otherChildren(value: SxClass[]) {
|
|
335
|
-
this._otherChildren = [...value]
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
override getChildren(): SxClass[] {
|
|
339
|
-
const children: SxClass[] = []
|
|
340
|
-
if (this._sxVersion) children.push(this._sxVersion)
|
|
341
|
-
if (this._sxGenerator) children.push(this._sxGenerator)
|
|
342
|
-
if (this._sxGeneratorVersion) children.push(this._sxGeneratorVersion)
|
|
343
|
-
if (this._sxGeneral) children.push(this._sxGeneral)
|
|
344
|
-
if (this._sxPaper) children.push(this._sxPaper)
|
|
345
|
-
if (this._sxTitleBlock) children.push(this._sxTitleBlock)
|
|
346
|
-
if (this._sxLayers) children.push(this._sxLayers)
|
|
347
|
-
if (this._sxSetup) children.push(this._sxSetup)
|
|
348
|
-
children.push(...this._properties)
|
|
349
|
-
children.push(...this._nets)
|
|
350
|
-
children.push(...this._footprints)
|
|
351
|
-
children.push(...this._images)
|
|
352
|
-
children.push(...this._segments)
|
|
353
|
-
children.push(...this._grLines)
|
|
354
|
-
children.push(...this._grTexts)
|
|
355
|
-
children.push(...this._vias)
|
|
356
|
-
children.push(...this._zones)
|
|
357
|
-
children.push(...this._otherChildren)
|
|
358
|
-
return children
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
SxClass.register(KicadPcb)
|