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,57 +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 PadRectDelta extends SxClass {
|
|
6
|
-
static override token = "rect_delta"
|
|
7
|
-
static override parentToken = "pad"
|
|
8
|
-
override token = "rect_delta"
|
|
9
|
-
|
|
10
|
-
private _x: number
|
|
11
|
-
private _y: number
|
|
12
|
-
|
|
13
|
-
constructor(x = 0, y = 0) {
|
|
14
|
-
super()
|
|
15
|
-
this._x = x
|
|
16
|
-
this._y = y
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static override fromSexprPrimitives(
|
|
20
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
21
|
-
): PadRectDelta {
|
|
22
|
-
const [rawX, rawY] = primitiveSexprs
|
|
23
|
-
const x = toNumberValue(rawX)
|
|
24
|
-
const y = toNumberValue(rawY)
|
|
25
|
-
|
|
26
|
-
if (x === undefined || y === undefined) {
|
|
27
|
-
throw new Error("pad rect_delta expects two numeric arguments")
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return new PadRectDelta(x, y)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get x(): number {
|
|
34
|
-
return this._x
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
set x(value: number) {
|
|
38
|
-
this._x = value
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get y(): number {
|
|
42
|
-
return this._y
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
set y(value: number) {
|
|
46
|
-
this._y = value
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
override getChildren(): SxClass[] {
|
|
50
|
-
return []
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
override getString(): string {
|
|
54
|
-
return `(rect_delta ${this._x} ${this._y})`
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
SxClass.register(PadRectDelta)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PadRoundrectRratio extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "roundrect_rratio"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
token = "roundrect_rratio"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadRoundrectRratio)
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { toNumberValue } from "../utils/toNumberValue"
|
|
4
|
-
|
|
5
|
-
export type PadSizeInput =
|
|
6
|
-
| PadSize
|
|
7
|
-
| [width: number, height: number]
|
|
8
|
-
| { width: number; height: number }
|
|
9
|
-
|
|
10
|
-
export class PadSize extends SxClass {
|
|
11
|
-
static override token = "size"
|
|
12
|
-
static override parentToken = "pad"
|
|
13
|
-
token = "size"
|
|
14
|
-
|
|
15
|
-
private _width: number
|
|
16
|
-
private _height: number
|
|
17
|
-
|
|
18
|
-
constructor(width: number, height: number) {
|
|
19
|
-
super()
|
|
20
|
-
this._width = width
|
|
21
|
-
this._height = height
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static from(input: PadSizeInput): PadSize {
|
|
25
|
-
if (input instanceof PadSize) {
|
|
26
|
-
return input
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(input)) {
|
|
29
|
-
return new PadSize(input[0], input[1])
|
|
30
|
-
}
|
|
31
|
-
return new PadSize(input.width, input.height)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static override fromSexprPrimitives(
|
|
35
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
36
|
-
): PadSize {
|
|
37
|
-
const width = toNumberValue(primitiveSexprs[0])
|
|
38
|
-
const height = toNumberValue(primitiveSexprs[1])
|
|
39
|
-
if (width === undefined || height === undefined) {
|
|
40
|
-
throw new Error("size requires width and height numeric values")
|
|
41
|
-
}
|
|
42
|
-
return new PadSize(width, height)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get width(): number {
|
|
46
|
-
return this._width
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
set width(value: number) {
|
|
50
|
-
this._width = value
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
get height(): number {
|
|
54
|
-
return this._height
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
set height(value: number) {
|
|
58
|
-
this._height = value
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
override getChildren(): SxClass[] {
|
|
62
|
-
return []
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
override getString(): string {
|
|
66
|
-
return `(size ${this._width} ${this._height})`
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
SxClass.register(PadSize)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PadSolderMaskMargin extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "solder_mask_margin"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
token = "solder_mask_margin"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadSolderMaskMargin)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PadSolderPasteMargin extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "solder_paste_margin"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
token = "solder_paste_margin"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadSolderPasteMargin)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PadSolderPasteMarginRatio extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "solder_paste_margin_ratio"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
token = "solder_paste_margin_ratio"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadSolderPasteMarginRatio)
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { toNumberValue } from "../utils/toNumberValue"
|
|
4
|
-
import { parseYesNo } from "../utils/parseYesNo"
|
|
5
|
-
|
|
6
|
-
type NumericTeardropProperty =
|
|
7
|
-
| "bestLengthRatio"
|
|
8
|
-
| "maxLength"
|
|
9
|
-
| "bestWidthRatio"
|
|
10
|
-
| "maxWidth"
|
|
11
|
-
| "filterRatio"
|
|
12
|
-
|
|
13
|
-
type BooleanTeardropProperty =
|
|
14
|
-
| "curvedEdges"
|
|
15
|
-
| "enabled"
|
|
16
|
-
| "allowTwoSegments"
|
|
17
|
-
| "preferZoneConnections"
|
|
18
|
-
|
|
19
|
-
const NUMERIC_TOKENS = new Map<string, NumericTeardropProperty>([
|
|
20
|
-
["best_length_ratio", "bestLengthRatio"],
|
|
21
|
-
["max_length", "maxLength"],
|
|
22
|
-
["best_width_ratio", "bestWidthRatio"],
|
|
23
|
-
["max_width", "maxWidth"],
|
|
24
|
-
["filter_ratio", "filterRatio"],
|
|
25
|
-
])
|
|
26
|
-
|
|
27
|
-
const BOOLEAN_TOKENS = new Map<string, BooleanTeardropProperty>([
|
|
28
|
-
["curved_edges", "curvedEdges"],
|
|
29
|
-
["enabled", "enabled"],
|
|
30
|
-
["allow_two_segments", "allowTwoSegments"],
|
|
31
|
-
["prefer_zone_connections", "preferZoneConnections"],
|
|
32
|
-
])
|
|
33
|
-
|
|
34
|
-
export class PadTeardrops extends SxClass {
|
|
35
|
-
static override token = "teardrops"
|
|
36
|
-
static override parentToken = "pad"
|
|
37
|
-
override token = "teardrops"
|
|
38
|
-
|
|
39
|
-
private _bestLengthRatio?: number
|
|
40
|
-
private _maxLength?: number
|
|
41
|
-
private _bestWidthRatio?: number
|
|
42
|
-
private _maxWidth?: number
|
|
43
|
-
private _filterRatio?: number
|
|
44
|
-
private _curvedEdges?: boolean
|
|
45
|
-
private _enabled?: boolean
|
|
46
|
-
private _allowTwoSegments?: boolean
|
|
47
|
-
private _preferZoneConnections?: boolean
|
|
48
|
-
|
|
49
|
-
static override fromSexprPrimitives(
|
|
50
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
51
|
-
): PadTeardrops {
|
|
52
|
-
const teardrops = new PadTeardrops()
|
|
53
|
-
|
|
54
|
-
for (const primitive of primitiveSexprs) {
|
|
55
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
56
|
-
throw new Error(
|
|
57
|
-
`teardrops encountered invalid child expression: ${JSON.stringify(primitive)}`,
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
const [rawToken, rawValue] = primitive
|
|
61
|
-
if (typeof rawToken !== "string") {
|
|
62
|
-
throw new Error(
|
|
63
|
-
`teardrops encountered non-string token: ${JSON.stringify(rawToken)}`,
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (NUMERIC_TOKENS.has(rawToken)) {
|
|
68
|
-
const property = NUMERIC_TOKENS.get(rawToken)!
|
|
69
|
-
const numeric = toNumberValue(rawValue)
|
|
70
|
-
if (numeric === undefined) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
`teardrops ${rawToken} expects a numeric value, received ${JSON.stringify(rawValue)}`,
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
teardrops[property] = numeric
|
|
76
|
-
continue
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (BOOLEAN_TOKENS.has(rawToken)) {
|
|
80
|
-
const property = BOOLEAN_TOKENS.get(rawToken)!
|
|
81
|
-
const booleanValue = parseYesNo(rawValue)
|
|
82
|
-
if (booleanValue === undefined) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
`teardrops ${rawToken} expects yes/no, received ${JSON.stringify(rawValue)}`,
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
teardrops[property] = booleanValue
|
|
88
|
-
continue
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
throw new Error(`teardrops encountered unsupported token "${rawToken}"`)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return teardrops
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
get bestLengthRatio(): number | undefined {
|
|
98
|
-
return this._bestLengthRatio
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
set bestLengthRatio(value: number | undefined) {
|
|
102
|
-
this._bestLengthRatio = value
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
get maxLength(): number | undefined {
|
|
106
|
-
return this._maxLength
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
set maxLength(value: number | undefined) {
|
|
110
|
-
this._maxLength = value
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
get bestWidthRatio(): number | undefined {
|
|
114
|
-
return this._bestWidthRatio
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
set bestWidthRatio(value: number | undefined) {
|
|
118
|
-
this._bestWidthRatio = value
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
get maxWidth(): number | undefined {
|
|
122
|
-
return this._maxWidth
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
set maxWidth(value: number | undefined) {
|
|
126
|
-
this._maxWidth = value
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
get filterRatio(): number | undefined {
|
|
130
|
-
return this._filterRatio
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
set filterRatio(value: number | undefined) {
|
|
134
|
-
this._filterRatio = value
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
get curvedEdges(): boolean | undefined {
|
|
138
|
-
return this._curvedEdges
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
set curvedEdges(value: boolean | undefined) {
|
|
142
|
-
this._curvedEdges = value
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
get enabled(): boolean | undefined {
|
|
146
|
-
return this._enabled
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
set enabled(value: boolean | undefined) {
|
|
150
|
-
this._enabled = value
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
get allowTwoSegments(): boolean | undefined {
|
|
154
|
-
return this._allowTwoSegments
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
set allowTwoSegments(value: boolean | undefined) {
|
|
158
|
-
this._allowTwoSegments = value
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
get preferZoneConnections(): boolean | undefined {
|
|
162
|
-
return this._preferZoneConnections
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
set preferZoneConnections(value: boolean | undefined) {
|
|
166
|
-
this._preferZoneConnections = value
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
override getChildren(): SxClass[] {
|
|
170
|
-
return []
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
override getString(): string {
|
|
174
|
-
const lines = ["(teardrops"]
|
|
175
|
-
if (this._bestLengthRatio !== undefined) {
|
|
176
|
-
lines.push(` (best_length_ratio ${this._bestLengthRatio})`)
|
|
177
|
-
}
|
|
178
|
-
if (this._maxLength !== undefined) {
|
|
179
|
-
lines.push(` (max_length ${this._maxLength})`)
|
|
180
|
-
}
|
|
181
|
-
if (this._bestWidthRatio !== undefined) {
|
|
182
|
-
lines.push(` (best_width_ratio ${this._bestWidthRatio})`)
|
|
183
|
-
}
|
|
184
|
-
if (this._maxWidth !== undefined) {
|
|
185
|
-
lines.push(` (max_width ${this._maxWidth})`)
|
|
186
|
-
}
|
|
187
|
-
if (this._curvedEdges !== undefined) {
|
|
188
|
-
lines.push(` (curved_edges ${this._curvedEdges ? "yes" : "no"})`)
|
|
189
|
-
}
|
|
190
|
-
if (this._filterRatio !== undefined) {
|
|
191
|
-
lines.push(` (filter_ratio ${this._filterRatio})`)
|
|
192
|
-
}
|
|
193
|
-
if (this._enabled !== undefined) {
|
|
194
|
-
lines.push(` (enabled ${this._enabled ? "yes" : "no"})`)
|
|
195
|
-
}
|
|
196
|
-
if (this._allowTwoSegments !== undefined) {
|
|
197
|
-
lines.push(
|
|
198
|
-
` (allow_two_segments ${this._allowTwoSegments ? "yes" : "no"})`,
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
if (this._preferZoneConnections !== undefined) {
|
|
202
|
-
lines.push(
|
|
203
|
-
` (prefer_zone_connections ${this._preferZoneConnections ? "yes" : "no"})`,
|
|
204
|
-
)
|
|
205
|
-
}
|
|
206
|
-
lines.push(")")
|
|
207
|
-
return lines.join("\n")
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
SxClass.register(PadTeardrops)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
3
|
-
|
|
4
|
-
export class PadThermalBridgeAngle extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "thermal_bridge_angle"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
override token = "thermal_bridge_angle"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadThermalBridgeAngle)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PadThermalGap extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "thermal_gap"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
token = "thermal_gap"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadThermalGap)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PadThermalWidth extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "thermal_width"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
token = "thermal_width"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadThermalWidth)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PadZoneConnect extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "zone_connect"
|
|
6
|
-
static override parentToken = "pad"
|
|
7
|
-
token = "zone_connect"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PadZoneConnect)
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
|
|
4
|
-
export type StandardPaperSize =
|
|
5
|
-
| "A0"
|
|
6
|
-
| "A1"
|
|
7
|
-
| "A2"
|
|
8
|
-
| "A3"
|
|
9
|
-
| "A4"
|
|
10
|
-
| "A5"
|
|
11
|
-
| "A"
|
|
12
|
-
| "B"
|
|
13
|
-
| "C"
|
|
14
|
-
| "D"
|
|
15
|
-
| "E"
|
|
16
|
-
|
|
17
|
-
export class Paper extends SxClass {
|
|
18
|
-
static override token = "paper"
|
|
19
|
-
token = "paper"
|
|
20
|
-
|
|
21
|
-
private _size?: StandardPaperSize | string
|
|
22
|
-
private _width?: number
|
|
23
|
-
private _height?: number
|
|
24
|
-
private _portrait = false
|
|
25
|
-
|
|
26
|
-
static override fromSexprPrimitives(
|
|
27
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
28
|
-
): Paper {
|
|
29
|
-
const paper = new Paper()
|
|
30
|
-
|
|
31
|
-
const numericArgs: number[] = []
|
|
32
|
-
|
|
33
|
-
for (const primitive of primitiveSexprs) {
|
|
34
|
-
if (typeof primitive === "number") {
|
|
35
|
-
numericArgs.push(primitive)
|
|
36
|
-
continue
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (typeof primitive === "string") {
|
|
40
|
-
if (primitive === "portrait") {
|
|
41
|
-
paper._portrait = true
|
|
42
|
-
continue
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (paper._size === undefined && numericArgs.length === 0) {
|
|
46
|
-
paper._size = primitive as StandardPaperSize | string
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (numericArgs.length >= 2) {
|
|
52
|
-
paper._width = numericArgs[0]
|
|
53
|
-
paper._height = numericArgs[1]
|
|
54
|
-
} else if (numericArgs.length === 1) {
|
|
55
|
-
paper._width = numericArgs[0]
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return paper
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get size(): string | undefined {
|
|
62
|
-
return this._size
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
set size(value: string | undefined) {
|
|
66
|
-
this._size = value
|
|
67
|
-
if (value !== undefined) {
|
|
68
|
-
this._width = undefined
|
|
69
|
-
this._height = undefined
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get customSize(): { width: number; height: number } | undefined {
|
|
74
|
-
if (typeof this._width === "number" && typeof this._height === "number") {
|
|
75
|
-
return { width: this._width, height: this._height }
|
|
76
|
-
}
|
|
77
|
-
return undefined
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
set customSize(size: { width: number; height: number } | undefined) {
|
|
81
|
-
if (!size) {
|
|
82
|
-
this._width = undefined
|
|
83
|
-
this._height = undefined
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
this._width = size.width
|
|
87
|
-
this._height = size.height
|
|
88
|
-
this._size = undefined
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get isPortrait(): boolean {
|
|
92
|
-
return this._portrait
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
set isPortrait(value: boolean) {
|
|
96
|
-
this._portrait = value
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
override getString(): string {
|
|
100
|
-
const lines = ["(paper"]
|
|
101
|
-
|
|
102
|
-
if (this._size) {
|
|
103
|
-
lines.push(` ${this._size}`)
|
|
104
|
-
} else if (
|
|
105
|
-
typeof this._width === "number" &&
|
|
106
|
-
typeof this._height === "number"
|
|
107
|
-
) {
|
|
108
|
-
lines.push(` ${this._width} ${this._height}`)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (this._portrait) {
|
|
112
|
-
lines.push(" portrait")
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
lines.push(")")
|
|
116
|
-
return lines.join("\n")
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
SxClass.register(Paper)
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { PcbGeneralThickness } from "./PcbGeneralThickness"
|
|
4
|
-
import { PcbGeneralLegacyTeardrops } from "./PcbGeneralLegacyTeardrops"
|
|
5
|
-
|
|
6
|
-
const SINGLE_TOKENS = new Set(["thickness", "legacy_teardrops"])
|
|
7
|
-
|
|
8
|
-
export class PcbGeneral extends SxClass {
|
|
9
|
-
static override token = "general"
|
|
10
|
-
static override parentToken = "kicad_pcb"
|
|
11
|
-
token = "general"
|
|
12
|
-
|
|
13
|
-
private _sxThickness?: PcbGeneralThickness
|
|
14
|
-
private _sxLegacyTeardrops?: PcbGeneralLegacyTeardrops
|
|
15
|
-
|
|
16
|
-
static override fromSexprPrimitives(
|
|
17
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
18
|
-
): PcbGeneral {
|
|
19
|
-
const general = new PcbGeneral()
|
|
20
|
-
const { propertyMap, arrayPropertyMap } =
|
|
21
|
-
SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token)
|
|
22
|
-
|
|
23
|
-
for (const token of Object.keys(propertyMap)) {
|
|
24
|
-
if (!SINGLE_TOKENS.has(token)) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
`general encountered unsupported child token "${token}"`,
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
for (const [token, entries] of Object.entries(arrayPropertyMap)) {
|
|
32
|
-
if (!SINGLE_TOKENS.has(token)) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
`general encountered unsupported child token "${token}"`,
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
if (entries.length > 1) {
|
|
38
|
-
throw new Error(`general encountered repeated child token "${token}"`)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
general._sxThickness =
|
|
43
|
-
(arrayPropertyMap.thickness?.[0] as PcbGeneralThickness | undefined) ??
|
|
44
|
-
(propertyMap.thickness as PcbGeneralThickness | undefined)
|
|
45
|
-
general._sxLegacyTeardrops =
|
|
46
|
-
(arrayPropertyMap.legacy_teardrops?.[0] as
|
|
47
|
-
| PcbGeneralLegacyTeardrops
|
|
48
|
-
| undefined) ??
|
|
49
|
-
(propertyMap.legacy_teardrops as PcbGeneralLegacyTeardrops | undefined)
|
|
50
|
-
|
|
51
|
-
return general
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get thickness(): number | undefined {
|
|
55
|
-
return this._sxThickness?.value
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
set thickness(value: number | undefined) {
|
|
59
|
-
this._sxThickness =
|
|
60
|
-
value === undefined ? undefined : new PcbGeneralThickness(value)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get legacyTeardrops(): boolean | undefined {
|
|
64
|
-
return this._sxLegacyTeardrops?.enabled
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
set legacyTeardrops(value: boolean | undefined) {
|
|
68
|
-
if (value === undefined) {
|
|
69
|
-
this._sxLegacyTeardrops = undefined
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
this._sxLegacyTeardrops = new PcbGeneralLegacyTeardrops(value)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
override getChildren(): SxClass[] {
|
|
76
|
-
const children: SxClass[] = []
|
|
77
|
-
if (this._sxThickness) children.push(this._sxThickness)
|
|
78
|
-
if (this._sxLegacyTeardrops) children.push(this._sxLegacyTeardrops)
|
|
79
|
-
return children
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
SxClass.register(PcbGeneral)
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { toStringValue } from "../utils/toStringValue"
|
|
4
|
-
|
|
5
|
-
export class PcbGeneralLegacyTeardrops extends SxClass {
|
|
6
|
-
static override token = "legacy_teardrops"
|
|
7
|
-
static override parentToken = "general"
|
|
8
|
-
token = "legacy_teardrops"
|
|
9
|
-
|
|
10
|
-
private _enabled: boolean
|
|
11
|
-
|
|
12
|
-
constructor(enabled: boolean) {
|
|
13
|
-
super()
|
|
14
|
-
this._enabled = enabled
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static override fromSexprPrimitives(
|
|
18
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
19
|
-
): PcbGeneralLegacyTeardrops {
|
|
20
|
-
const value = toStringValue(primitiveSexprs[0])
|
|
21
|
-
if (value === undefined) {
|
|
22
|
-
throw new Error("legacy_teardrops expects a string value")
|
|
23
|
-
}
|
|
24
|
-
const enabled = /^(yes|true)$/iu.test(value)
|
|
25
|
-
return new PcbGeneralLegacyTeardrops(enabled)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get enabled(): boolean {
|
|
29
|
-
return this._enabled
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
set enabled(value: boolean) {
|
|
33
|
-
this._enabled = value
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
override getChildren(): SxClass[] {
|
|
37
|
-
return []
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
override getString(): string {
|
|
41
|
-
return `(legacy_teardrops ${this._enabled ? "yes" : "no"})`
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
SxClass.register(PcbGeneralLegacyTeardrops)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveNumber } from "../base-classes/SxPrimitiveNumber"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
|
|
4
|
-
export class PcbGeneralThickness extends SxPrimitiveNumber {
|
|
5
|
-
static override token = "thickness"
|
|
6
|
-
static override parentToken = "general"
|
|
7
|
-
token = "thickness"
|
|
8
|
-
}
|
|
9
|
-
SxClass.register(PcbGeneralThickness)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SxPrimitiveString } from "../base-classes/SxPrimitiveString"
|
|
2
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
3
|
-
import { quoteSExprString } from "../utils/quoteSExprString"
|
|
4
|
-
|
|
5
|
-
const isSymbol = (value: string) => /^[A-Za-z0-9._-]+$/.test(value)
|
|
6
|
-
|
|
7
|
-
export class PcbGenerator extends SxPrimitiveString {
|
|
8
|
-
static override token = "generator"
|
|
9
|
-
static override parentToken = "kicad_pcb"
|
|
10
|
-
token = "generator"
|
|
11
|
-
|
|
12
|
-
override getString(): string {
|
|
13
|
-
return `(generator ${isSymbol(this.value) ? this.value : quoteSExprString(this.value)})`
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
SxClass.register(PcbGenerator)
|