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,369 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import { printSExpr, type PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { quoteSExprString } from "../utils/quoteSExprString"
|
|
4
|
-
import { toNumberValue } from "../utils/toNumberValue"
|
|
5
|
-
import { toStringValue } from "../utils/toStringValue"
|
|
6
|
-
import { At } from "./At"
|
|
7
|
-
import { TextEffects } from "./TextEffects"
|
|
8
|
-
import { Uuid } from "./Uuid"
|
|
9
|
-
|
|
10
|
-
function primitiveToString(value: PrimitiveSExpr | undefined): string {
|
|
11
|
-
if (value === undefined) return ""
|
|
12
|
-
const str = toStringValue(value)
|
|
13
|
-
if (str !== undefined) return str
|
|
14
|
-
return printSExpr(value)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface TitleBlockConstructorParams {
|
|
18
|
-
title?: string
|
|
19
|
-
date?: string
|
|
20
|
-
rev?: string
|
|
21
|
-
company?: string
|
|
22
|
-
comments?: TitleBlockComment[]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class TitleBlock extends SxClass {
|
|
26
|
-
static override token = "title_block"
|
|
27
|
-
token = "title_block"
|
|
28
|
-
|
|
29
|
-
private _sxTitle?: TitleBlockTitle
|
|
30
|
-
private _sxDate?: TitleBlockDate
|
|
31
|
-
private _sxRev?: TitleBlockRevision
|
|
32
|
-
private _sxCompany?: TitleBlockCompany
|
|
33
|
-
comments: TitleBlockComment[] = []
|
|
34
|
-
|
|
35
|
-
constructor(params: TitleBlockConstructorParams = {}) {
|
|
36
|
-
super()
|
|
37
|
-
|
|
38
|
-
if (params.title !== undefined) this.title = params.title
|
|
39
|
-
if (params.date !== undefined) this.date = params.date
|
|
40
|
-
if (params.rev !== undefined) this.rev = params.rev
|
|
41
|
-
if (params.company !== undefined) this.company = params.company
|
|
42
|
-
if (params.comments !== undefined) this.comments = params.comments
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static override fromSexprPrimitives(
|
|
46
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
47
|
-
): TitleBlock {
|
|
48
|
-
const titleBlock = new TitleBlock()
|
|
49
|
-
|
|
50
|
-
for (const primitive of primitiveSexprs) {
|
|
51
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`Unexpected primitive inside title_block: ${printSExpr(primitive)}`,
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const parsed = SxClass.parsePrimitiveSexpr(primitive, {
|
|
58
|
-
parentToken: this.token,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
if (!(parsed instanceof SxClass)) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Unable to parse child node inside title_block: ${printSExpr(primitive)}`,
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (parsed instanceof TitleBlockTitle) {
|
|
68
|
-
titleBlock._sxTitle = parsed
|
|
69
|
-
continue
|
|
70
|
-
}
|
|
71
|
-
if (parsed instanceof TitleBlockDate) {
|
|
72
|
-
titleBlock._sxDate = parsed
|
|
73
|
-
continue
|
|
74
|
-
}
|
|
75
|
-
if (parsed instanceof TitleBlockRevision) {
|
|
76
|
-
titleBlock._sxRev = parsed
|
|
77
|
-
continue
|
|
78
|
-
}
|
|
79
|
-
if (parsed instanceof TitleBlockCompany) {
|
|
80
|
-
titleBlock._sxCompany = parsed
|
|
81
|
-
continue
|
|
82
|
-
}
|
|
83
|
-
if (parsed instanceof TitleBlockComment) {
|
|
84
|
-
titleBlock.comments.push(parsed)
|
|
85
|
-
continue
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
throw new Error(
|
|
89
|
-
`Unsupported child "${parsed.token}" inside title_block expression`,
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return titleBlock
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
get title(): string | undefined {
|
|
97
|
-
return this._sxTitle?.value
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
set title(value: string | undefined) {
|
|
101
|
-
this._sxTitle = value === undefined ? undefined : new TitleBlockTitle(value)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
get date(): string | undefined {
|
|
105
|
-
return this._sxDate?.value
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
set date(value: string | undefined) {
|
|
109
|
-
this._sxDate = value === undefined ? undefined : new TitleBlockDate(value)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
get rev(): string | undefined {
|
|
113
|
-
return this._sxRev?.value
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
set rev(value: string | undefined) {
|
|
117
|
-
this._sxRev =
|
|
118
|
-
value === undefined ? undefined : new TitleBlockRevision(value)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
get company(): string | undefined {
|
|
122
|
-
return this._sxCompany?.value
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
set company(value: string | undefined) {
|
|
126
|
-
this._sxCompany =
|
|
127
|
-
value === undefined ? undefined : new TitleBlockCompany(value)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
getComment(index: number): string | undefined {
|
|
131
|
-
return this.comments.find((comment) => comment.index === index)?.value
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
setComment(index: number, value: string) {
|
|
135
|
-
const existing = this.comments.find((comment) => comment.index === index)
|
|
136
|
-
if (existing) {
|
|
137
|
-
existing.value = value
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
this.comments.push(new TitleBlockComment(index, value))
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
removeComment(index: number) {
|
|
144
|
-
this.comments = this.comments.filter((comment) => comment.index !== index)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
override getChildren(): SxClass[] {
|
|
148
|
-
const children: SxClass[] = []
|
|
149
|
-
if (this._sxTitle) children.push(this._sxTitle)
|
|
150
|
-
if (this._sxDate) children.push(this._sxDate)
|
|
151
|
-
if (this._sxRev) children.push(this._sxRev)
|
|
152
|
-
if (this._sxCompany) children.push(this._sxCompany)
|
|
153
|
-
|
|
154
|
-
const sortedComments = [...this.comments].sort((a, b) => a.index - b.index)
|
|
155
|
-
children.push(...sortedComments)
|
|
156
|
-
return children
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
override getString(): string {
|
|
160
|
-
const lines: string[] = ["(title_block"]
|
|
161
|
-
|
|
162
|
-
for (const child of this.getChildren()) {
|
|
163
|
-
lines.push(child.getStringIndented())
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
lines.push(")")
|
|
167
|
-
return lines.join("\n")
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
SxClass.register(TitleBlock)
|
|
171
|
-
|
|
172
|
-
abstract class TitleBlockStringValue extends SxClass {
|
|
173
|
-
value: string
|
|
174
|
-
|
|
175
|
-
constructor(value: string) {
|
|
176
|
-
super()
|
|
177
|
-
this.value = value
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
override getChildren(): SxClass[] {
|
|
181
|
-
return []
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export class TitleBlockTitle extends TitleBlockStringValue {
|
|
186
|
-
static override token = "title"
|
|
187
|
-
static override parentToken = "title_block"
|
|
188
|
-
token = "title"
|
|
189
|
-
|
|
190
|
-
static override fromSexprPrimitives(
|
|
191
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
192
|
-
): TitleBlockTitle {
|
|
193
|
-
const [rawValue] = primitiveSexprs
|
|
194
|
-
return new TitleBlockTitle(primitiveToString(rawValue))
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
override getString(): string {
|
|
198
|
-
return `(title ${quoteSExprString(this.value)})`
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
SxClass.register(TitleBlockTitle)
|
|
202
|
-
|
|
203
|
-
export class TitleBlockDate extends TitleBlockStringValue {
|
|
204
|
-
static override token = "date"
|
|
205
|
-
static override parentToken = "title_block"
|
|
206
|
-
token = "date"
|
|
207
|
-
|
|
208
|
-
static override fromSexprPrimitives(
|
|
209
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
210
|
-
): TitleBlockDate {
|
|
211
|
-
const [rawValue] = primitiveSexprs
|
|
212
|
-
return new TitleBlockDate(primitiveToString(rawValue))
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
override getString(): string {
|
|
216
|
-
return `(date ${quoteSExprString(this.value)})`
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
SxClass.register(TitleBlockDate)
|
|
220
|
-
|
|
221
|
-
export class TitleBlockRevision extends TitleBlockStringValue {
|
|
222
|
-
static override token = "rev"
|
|
223
|
-
static override parentToken = "title_block"
|
|
224
|
-
token = "rev"
|
|
225
|
-
|
|
226
|
-
static override fromSexprPrimitives(
|
|
227
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
228
|
-
): TitleBlockRevision {
|
|
229
|
-
const [rawValue] = primitiveSexprs
|
|
230
|
-
return new TitleBlockRevision(primitiveToString(rawValue))
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
override getString(): string {
|
|
234
|
-
return `(rev ${quoteSExprString(this.value)})`
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
SxClass.register(TitleBlockRevision)
|
|
238
|
-
|
|
239
|
-
export class TitleBlockCompany extends TitleBlockStringValue {
|
|
240
|
-
static override token = "company"
|
|
241
|
-
static override parentToken = "title_block"
|
|
242
|
-
token = "company"
|
|
243
|
-
|
|
244
|
-
static override fromSexprPrimitives(
|
|
245
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
246
|
-
): TitleBlockCompany {
|
|
247
|
-
const [rawValue] = primitiveSexprs
|
|
248
|
-
return new TitleBlockCompany(primitiveToString(rawValue))
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
override getString(): string {
|
|
252
|
-
return `(company ${quoteSExprString(this.value)})`
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
SxClass.register(TitleBlockCompany)
|
|
256
|
-
|
|
257
|
-
export class TitleBlockComment extends SxClass {
|
|
258
|
-
static override token = "comment"
|
|
259
|
-
static override parentToken = "title_block"
|
|
260
|
-
token = "comment"
|
|
261
|
-
|
|
262
|
-
index: number
|
|
263
|
-
value: string
|
|
264
|
-
private _sxAt?: At
|
|
265
|
-
private _sxEffects?: TextEffects
|
|
266
|
-
private _sxUuid?: Uuid
|
|
267
|
-
|
|
268
|
-
constructor(index: number, value: string) {
|
|
269
|
-
super()
|
|
270
|
-
this.index = index
|
|
271
|
-
this.value = value
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
static override fromSexprPrimitives(
|
|
275
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
276
|
-
): TitleBlockComment {
|
|
277
|
-
const [rawIndex, rawValue, ...rest] = primitiveSexprs
|
|
278
|
-
const index = toNumberValue(rawIndex)
|
|
279
|
-
if (index === undefined) {
|
|
280
|
-
throw new Error("title_block comment requires a numeric index")
|
|
281
|
-
}
|
|
282
|
-
const value = primitiveToString(rawValue)
|
|
283
|
-
const comment = new TitleBlockComment(index, value)
|
|
284
|
-
|
|
285
|
-
for (const primitive of rest) {
|
|
286
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
287
|
-
throw new Error(
|
|
288
|
-
`Unexpected primitive inside title_block comment: ${printSExpr(primitive)}`,
|
|
289
|
-
)
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const parsed = SxClass.parsePrimitiveSexpr(primitive, {
|
|
293
|
-
parentToken: this.token,
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
if (!(parsed instanceof SxClass)) {
|
|
297
|
-
throw new Error(
|
|
298
|
-
`Unable to parse child node inside title_block comment: ${printSExpr(primitive)}`,
|
|
299
|
-
)
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (parsed instanceof At) {
|
|
303
|
-
comment._sxAt = parsed
|
|
304
|
-
continue
|
|
305
|
-
}
|
|
306
|
-
if (parsed instanceof TextEffects) {
|
|
307
|
-
comment._sxEffects = parsed
|
|
308
|
-
continue
|
|
309
|
-
}
|
|
310
|
-
if (parsed instanceof Uuid) {
|
|
311
|
-
comment._sxUuid = parsed
|
|
312
|
-
continue
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
throw new Error(
|
|
316
|
-
`Unsupported child "${parsed.token}" inside title_block comment`,
|
|
317
|
-
)
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return comment
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
get at(): At | undefined {
|
|
324
|
-
return this._sxAt
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
set at(value: At | undefined) {
|
|
328
|
-
this._sxAt = value
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
get effects(): TextEffects | undefined {
|
|
332
|
-
return this._sxEffects
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
set effects(value: TextEffects | undefined) {
|
|
336
|
-
this._sxEffects = value
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
get uuid(): Uuid | undefined {
|
|
340
|
-
return this._sxUuid
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
set uuid(value: Uuid | undefined) {
|
|
344
|
-
this._sxUuid = value
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
override getChildren(): SxClass[] {
|
|
348
|
-
const children: SxClass[] = []
|
|
349
|
-
if (this._sxAt) children.push(this._sxAt)
|
|
350
|
-
if (this._sxEffects) children.push(this._sxEffects)
|
|
351
|
-
if (this._sxUuid) children.push(this._sxUuid)
|
|
352
|
-
return children
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
override getString(): string {
|
|
356
|
-
const children = this.getChildren()
|
|
357
|
-
if (children.length === 0) {
|
|
358
|
-
return `(comment ${this.index} ${quoteSExprString(this.value)})`
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const lines = [`(comment ${this.index} ${quoteSExprString(this.value)}`]
|
|
362
|
-
for (const child of children) {
|
|
363
|
-
lines.push(child.getStringIndented())
|
|
364
|
-
}
|
|
365
|
-
lines.push(")")
|
|
366
|
-
return lines.join("\n")
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
SxClass.register(TitleBlockComment)
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
|
|
4
|
-
export type UnitString = "inches" | "mils" | "millimeters" | "automatic"
|
|
5
|
-
|
|
6
|
-
const unitValues = ["inches", "mils", "millimeters", "automatic"] as const
|
|
7
|
-
|
|
8
|
-
export class Unit extends SxClass {
|
|
9
|
-
static override token = "unit"
|
|
10
|
-
token = "unit"
|
|
11
|
-
|
|
12
|
-
value: UnitString
|
|
13
|
-
|
|
14
|
-
constructor(value: UnitString | number) {
|
|
15
|
-
super()
|
|
16
|
-
if (typeof value === "number") {
|
|
17
|
-
this.value = unitValues[value]!
|
|
18
|
-
} else {
|
|
19
|
-
this.value = value
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static override fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): Unit {
|
|
24
|
-
const [numericValue] = primitiveSexprs
|
|
25
|
-
return new Unit(numericValue as number)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
SxClass.register(Unit)
|