kicadts 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/index.d.ts +4466 -0
  2. package/dist/index.js +14253 -0
  3. package/package.json +5 -2
  4. package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +0 -111
  5. package/.github/workflows/bun-formatcheck.yml +0 -26
  6. package/.github/workflows/bun-pver-release.yml +0 -70
  7. package/.github/workflows/bun-test.yml +0 -32
  8. package/.github/workflows/bun-typecheck.yml +0 -26
  9. package/.vscode/settings.json +0 -16
  10. package/AGENTS.md +0 -31
  11. package/TODO.md +0 -46
  12. package/biome.json +0 -93
  13. package/bunfig.toml +0 -5
  14. package/lib/index.ts +0 -1
  15. package/lib/sexpr/base-classes/SxClass.ts +0 -164
  16. package/lib/sexpr/base-classes/SxPrimitiveBoolean.ts +0 -35
  17. package/lib/sexpr/base-classes/SxPrimitiveNumber.ts +0 -26
  18. package/lib/sexpr/base-classes/SxPrimitiveString.ts +0 -26
  19. package/lib/sexpr/classes/At.ts +0 -53
  20. package/lib/sexpr/classes/Bus.ts +0 -103
  21. package/lib/sexpr/classes/BusEntry.ts +0 -169
  22. package/lib/sexpr/classes/Color.ts +0 -29
  23. package/lib/sexpr/classes/Dnp.ts +0 -8
  24. package/lib/sexpr/classes/EmbeddedFonts.ts +0 -68
  25. package/lib/sexpr/classes/ExcludeFromSim.ts +0 -8
  26. package/lib/sexpr/classes/FieldsAutoplaced.ts +0 -8
  27. package/lib/sexpr/classes/Footprint.ts +0 -849
  28. package/lib/sexpr/classes/FootprintAttr.ts +0 -104
  29. package/lib/sexpr/classes/FootprintAutoplaceCost180.ts +0 -9
  30. package/lib/sexpr/classes/FootprintAutoplaceCost90.ts +0 -9
  31. package/lib/sexpr/classes/FootprintClearance.ts +0 -9
  32. package/lib/sexpr/classes/FootprintDescr.ts +0 -44
  33. package/lib/sexpr/classes/FootprintLocked.ts +0 -32
  34. package/lib/sexpr/classes/FootprintModel.ts +0 -142
  35. package/lib/sexpr/classes/FootprintNetTiePadGroups.ts +0 -52
  36. package/lib/sexpr/classes/FootprintPad.ts +0 -857
  37. package/lib/sexpr/classes/FootprintPath.ts +0 -44
  38. package/lib/sexpr/classes/FootprintPlaced.ts +0 -32
  39. package/lib/sexpr/classes/FootprintPrivateLayers.ts +0 -56
  40. package/lib/sexpr/classes/FootprintSheetfile.ts +0 -44
  41. package/lib/sexpr/classes/FootprintSheetname.ts +0 -44
  42. package/lib/sexpr/classes/FootprintSolderMaskMargin.ts +0 -9
  43. package/lib/sexpr/classes/FootprintSolderPasteMargin.ts +0 -9
  44. package/lib/sexpr/classes/FootprintSolderPasteRatio.ts +0 -9
  45. package/lib/sexpr/classes/FootprintTags.ts +0 -44
  46. package/lib/sexpr/classes/FootprintTedit.ts +0 -21
  47. package/lib/sexpr/classes/FootprintThermalGap.ts +0 -9
  48. package/lib/sexpr/classes/FootprintThermalWidth.ts +0 -9
  49. package/lib/sexpr/classes/FootprintZoneConnect.ts +0 -9
  50. package/lib/sexpr/classes/FpArc.ts +0 -312
  51. package/lib/sexpr/classes/FpCircle.ts +0 -314
  52. package/lib/sexpr/classes/FpLine.ts +0 -316
  53. package/lib/sexpr/classes/FpPoly.ts +0 -286
  54. package/lib/sexpr/classes/FpPolyFill.ts +0 -48
  55. package/lib/sexpr/classes/FpPolyLocked.ts +0 -40
  56. package/lib/sexpr/classes/FpRect.ts +0 -314
  57. package/lib/sexpr/classes/FpText.ts +0 -375
  58. package/lib/sexpr/classes/FpTextBox.ts +0 -450
  59. package/lib/sexpr/classes/GrLine.ts +0 -264
  60. package/lib/sexpr/classes/GrLineAngle.ts +0 -32
  61. package/lib/sexpr/classes/GrLineEnd.ts +0 -61
  62. package/lib/sexpr/classes/GrLineLocked.ts +0 -40
  63. package/lib/sexpr/classes/GrLineStart.ts +0 -61
  64. package/lib/sexpr/classes/GrText.ts +0 -228
  65. package/lib/sexpr/classes/Image.ts +0 -283
  66. package/lib/sexpr/classes/InBom.ts +0 -8
  67. package/lib/sexpr/classes/Junction.ts +0 -166
  68. package/lib/sexpr/classes/KicadPcb.ts +0 -361
  69. package/lib/sexpr/classes/KicadSch.ts +0 -397
  70. package/lib/sexpr/classes/KicadSchGenerator.ts +0 -32
  71. package/lib/sexpr/classes/KicadSchGeneratorVersion.ts +0 -30
  72. package/lib/sexpr/classes/KicadSchVersion.ts +0 -22
  73. package/lib/sexpr/classes/Label.ts +0 -176
  74. package/lib/sexpr/classes/Layer.ts +0 -51
  75. package/lib/sexpr/classes/Layers.ts +0 -47
  76. package/lib/sexpr/classes/LibSymbols.ts +0 -61
  77. package/lib/sexpr/classes/NoConnect.ts +0 -90
  78. package/lib/sexpr/classes/OnBoard.ts +0 -8
  79. package/lib/sexpr/classes/PadChamfer.ts +0 -50
  80. package/lib/sexpr/classes/PadChamferRatio.ts +0 -9
  81. package/lib/sexpr/classes/PadClearance.ts +0 -9
  82. package/lib/sexpr/classes/PadDieLength.ts +0 -9
  83. package/lib/sexpr/classes/PadDrill.ts +0 -145
  84. package/lib/sexpr/classes/PadDrillOffset.ts +0 -54
  85. package/lib/sexpr/classes/PadLayers.ts +0 -71
  86. package/lib/sexpr/classes/PadNet.ts +0 -56
  87. package/lib/sexpr/classes/PadOptions.ts +0 -181
  88. package/lib/sexpr/classes/PadPinFunction.ts +0 -9
  89. package/lib/sexpr/classes/PadPinType.ts +0 -9
  90. package/lib/sexpr/classes/PadPrimitiveGrArc.ts +0 -272
  91. package/lib/sexpr/classes/PadPrimitiveGrCircle.ts +0 -298
  92. package/lib/sexpr/classes/PadPrimitiveGrLine.ts +0 -126
  93. package/lib/sexpr/classes/PadPrimitives.ts +0 -291
  94. package/lib/sexpr/classes/PadRectDelta.ts +0 -57
  95. package/lib/sexpr/classes/PadRoundrectRratio.ts +0 -9
  96. package/lib/sexpr/classes/PadSize.ts +0 -69
  97. package/lib/sexpr/classes/PadSolderMaskMargin.ts +0 -9
  98. package/lib/sexpr/classes/PadSolderPasteMargin.ts +0 -9
  99. package/lib/sexpr/classes/PadSolderPasteMarginRatio.ts +0 -9
  100. package/lib/sexpr/classes/PadTeardrops.ts +0 -210
  101. package/lib/sexpr/classes/PadThermalBridgeAngle.ts +0 -9
  102. package/lib/sexpr/classes/PadThermalGap.ts +0 -9
  103. package/lib/sexpr/classes/PadThermalWidth.ts +0 -9
  104. package/lib/sexpr/classes/PadZoneConnect.ts +0 -9
  105. package/lib/sexpr/classes/Paper.ts +0 -119
  106. package/lib/sexpr/classes/PcbGeneral.ts +0 -82
  107. package/lib/sexpr/classes/PcbGeneralLegacyTeardrops.ts +0 -44
  108. package/lib/sexpr/classes/PcbGeneralThickness.ts +0 -9
  109. package/lib/sexpr/classes/PcbGenerator.ts +0 -16
  110. package/lib/sexpr/classes/PcbGeneratorVersion.ts +0 -16
  111. package/lib/sexpr/classes/PcbLayerDefinition.ts +0 -106
  112. package/lib/sexpr/classes/PcbLayers.ts +0 -34
  113. package/lib/sexpr/classes/PcbNet.ts +0 -56
  114. package/lib/sexpr/classes/PcbVersion.ts +0 -9
  115. package/lib/sexpr/classes/Property.ts +0 -301
  116. package/lib/sexpr/classes/PropertyHide.ts +0 -9
  117. package/lib/sexpr/classes/PropertyUnlocked.ts +0 -9
  118. package/lib/sexpr/classes/Pts.ts +0 -67
  119. package/lib/sexpr/classes/RenderCache.ts +0 -221
  120. package/lib/sexpr/classes/SchematicText.ts +0 -171
  121. package/lib/sexpr/classes/Segment.ts +0 -243
  122. package/lib/sexpr/classes/SegmentEnd.ts +0 -59
  123. package/lib/sexpr/classes/SegmentLocked.ts +0 -33
  124. package/lib/sexpr/classes/SegmentNet.ts +0 -64
  125. package/lib/sexpr/classes/SegmentStart.ts +0 -59
  126. package/lib/sexpr/classes/Setup/PcbPlotParams.ts +0 -689
  127. package/lib/sexpr/classes/Setup/PcbPlotParamsBase.ts +0 -9
  128. package/lib/sexpr/classes/Setup/PcbPlotParamsNumericProperties.ts +0 -105
  129. package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesA.ts +0 -104
  130. package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesB.ts +0 -105
  131. package/lib/sexpr/classes/Setup/Setup.ts +0 -574
  132. package/lib/sexpr/classes/Setup/SetupPropertyTypes.ts +0 -119
  133. package/lib/sexpr/classes/Setup/Stackup.ts +0 -135
  134. package/lib/sexpr/classes/Setup/StackupLayer.ts +0 -233
  135. package/lib/sexpr/classes/Setup/StackupLayerProperties.ts +0 -80
  136. package/lib/sexpr/classes/Setup/StackupProperties.ts +0 -40
  137. package/lib/sexpr/classes/Setup/base.ts +0 -165
  138. package/lib/sexpr/classes/Setup/index.ts +0 -14
  139. package/lib/sexpr/classes/Setup/setupMultiValueProperties.ts +0 -53
  140. package/lib/sexpr/classes/Setup/setupNumericProperties.ts +0 -151
  141. package/lib/sexpr/classes/Setup/setupPropertyHandlers.ts +0 -90
  142. package/lib/sexpr/classes/Setup/setupStringProperties.ts +0 -75
  143. package/lib/sexpr/classes/Sheet.ts +0 -287
  144. package/lib/sexpr/classes/SheetFill.ts +0 -44
  145. package/lib/sexpr/classes/SheetInstances.ts +0 -168
  146. package/lib/sexpr/classes/SheetInstancesRoot.ts +0 -165
  147. package/lib/sexpr/classes/SheetPin.ts +0 -125
  148. package/lib/sexpr/classes/SheetProperty.ts +0 -115
  149. package/lib/sexpr/classes/SheetSize.ts +0 -44
  150. package/lib/sexpr/classes/Stroke.ts +0 -58
  151. package/lib/sexpr/classes/StrokeType.ts +0 -34
  152. package/lib/sexpr/classes/Symbol.ts +0 -1666
  153. package/lib/sexpr/classes/TextEffects.ts +0 -461
  154. package/lib/sexpr/classes/TitleBlock.ts +0 -369
  155. package/lib/sexpr/classes/Unit.ts +0 -28
  156. package/lib/sexpr/classes/Uuid.ts +0 -8
  157. package/lib/sexpr/classes/Via.ts +0 -363
  158. package/lib/sexpr/classes/ViaNet.ts +0 -60
  159. package/lib/sexpr/classes/Width.ts +0 -8
  160. package/lib/sexpr/classes/Wire.ts +0 -111
  161. package/lib/sexpr/classes/Xy.ts +0 -33
  162. package/lib/sexpr/classes/Zone.ts +0 -39
  163. package/lib/sexpr/index.ts +0 -130
  164. package/lib/sexpr/parseKicadSexpr.ts +0 -5
  165. package/lib/sexpr/parseToPrimitiveSExpr.ts +0 -245
  166. package/lib/sexpr/utils/indentLines.ts +0 -3
  167. package/lib/sexpr/utils/parseYesNo.ts +0 -12
  168. package/lib/sexpr/utils/quoteSExprString.ts +0 -8
  169. package/lib/sexpr/utils/strokeFromArgs.ts +0 -18
  170. package/lib/sexpr/utils/toNumberValue.ts +0 -13
  171. package/lib/sexpr/utils/toStringValue.ts +0 -11
  172. package/scripts/download-references.ts +0 -68
  173. package/tests/fixtures/expectEqualPrimitiveSExpr.ts +0 -199
  174. package/tests/fixtures/png-matcher.ts +0 -109
  175. package/tests/fixtures/preload.ts +0 -1
  176. package/tests/sexpr/KicadPcbDemos.test.ts +0 -48
  177. package/tests/sexpr/KicadSchDemos.test.ts +0 -49
  178. package/tests/sexpr/classes/Footprint.test.ts +0 -277
  179. package/tests/sexpr/classes/FootprintPad.test.ts +0 -78
  180. package/tests/sexpr/classes/FpArc.test.ts +0 -45
  181. package/tests/sexpr/classes/FpCircle.test.ts +0 -39
  182. package/tests/sexpr/classes/FpPoly.test.ts +0 -43
  183. package/tests/sexpr/classes/FpRect.test.ts +0 -40
  184. package/tests/sexpr/classes/FpTextBox.test.ts +0 -84
  185. package/tests/sexpr/classes/Image.test.ts +0 -58
  186. package/tests/sexpr/classes/KicadSch.test.ts +0 -95
  187. package/tests/sexpr/classes/Paper.test.ts +0 -30
  188. package/tests/sexpr/classes/Property.test.ts +0 -48
  189. package/tests/sexpr/classes/Setup.test.ts +0 -188
  190. package/tests/sexpr/classes/Sheet.test.ts +0 -107
  191. package/tests/sexpr/classes/Stroke.test.ts +0 -15
  192. package/tests/sexpr/classes/Symbol.test.ts +0 -96
  193. package/tests/sexpr/classes/TextEffects.test.ts +0 -56
  194. package/tests/sexpr/classes/TitleBlock.test.ts +0 -40
  195. package/tsconfig.json +0 -35
@@ -1,375 +0,0 @@
1
- import { SxClass } from "../base-classes/SxClass"
2
- import { printSExpr, type PrimitiveSExpr } from "../parseToPrimitiveSExpr"
3
- import { quoteSExprString } from "../utils/quoteSExprString"
4
- import { toStringValue } from "../utils/toStringValue"
5
- import { At, type AtInput } from "./At"
6
- import { Layer } from "./Layer"
7
- import { TextEffects } from "./TextEffects"
8
- import { Uuid } from "./Uuid"
9
- import { Xy } from "./Xy"
10
-
11
- export type FpTextType = "reference" | "value" | "user" | string
12
-
13
- const SUPPORTED_SINGLE_TOKENS = new Set([
14
- "at",
15
- "xy",
16
- "layer",
17
- "effects",
18
- "uuid",
19
- "unlocked",
20
- "hide",
21
- ])
22
-
23
- const SUPPORTED_MULTI_TOKENS = new Set<string>()
24
-
25
- export interface FpTextConstructorParams {
26
- type?: FpTextType
27
- text?: string
28
- position?: AtInput | Xy
29
- unlocked?: boolean
30
- hidden?: boolean
31
- layer?: Layer | string | string[]
32
- effects?: TextEffects
33
- uuid?: Uuid | string
34
- }
35
-
36
- export class FpText extends SxClass {
37
- static override token = "fp_text"
38
- token = "fp_text"
39
-
40
- private _type?: FpTextType
41
- private _text = ""
42
- private _sxPosition?: At | Xy
43
- private _sxUnlocked?: FpTextUnlocked
44
- private _sxHide?: FpTextHide
45
- private _sxLayer?: Layer
46
- private _sxEffects?: TextEffects
47
- private _sxUuid?: Uuid
48
-
49
- constructor(params: FpTextConstructorParams = {}) {
50
- super()
51
- if (params.type !== undefined) this.type = params.type
52
- if (params.text !== undefined) this.text = params.text
53
- if (params.position !== undefined) this.position = params.position
54
- if (params.unlocked !== undefined) this.unlocked = params.unlocked
55
- if (params.hidden !== undefined) this.hidden = params.hidden
56
- if (params.layer !== undefined) this.layer = params.layer
57
- if (params.effects !== undefined) this.effects = params.effects
58
- if (params.uuid !== undefined) this.uuid = params.uuid
59
- }
60
-
61
- static override fromSexprPrimitives(
62
- primitiveSexprs: PrimitiveSExpr[],
63
- ): FpText {
64
- if (primitiveSexprs.length < 2) {
65
- throw new Error("fp_text requires a type and text value")
66
- }
67
-
68
- const [rawType, rawText, ...rest] = primitiveSexprs
69
- const fpText = new FpText()
70
-
71
- if (typeof rawType !== "string") {
72
- throw new Error(
73
- `fp_text type must be a string token, received ${JSON.stringify(rawType)}`,
74
- )
75
- }
76
- fpText._type = rawType
77
-
78
- fpText._text = primitiveToString(rawText)
79
-
80
- const structuredPrimitives: PrimitiveSExpr[] = []
81
- let sawBareUnlocked = false
82
- let sawBareHide = false
83
-
84
- for (const primitive of rest) {
85
- if (typeof primitive === "string") {
86
- if (primitive === "unlocked") {
87
- if (sawBareUnlocked) {
88
- throw new Error(
89
- "fp_text encountered duplicate bare unlocked tokens",
90
- )
91
- }
92
- sawBareUnlocked = true
93
- continue
94
- }
95
- if (primitive === "hide") {
96
- if (sawBareHide) {
97
- throw new Error("fp_text encountered duplicate bare hide tokens")
98
- }
99
- sawBareHide = true
100
- continue
101
- }
102
- throw new Error(`fp_text encountered unsupported flag "${primitive}"`)
103
- }
104
-
105
- if (!Array.isArray(primitive) || primitive.length === 0) {
106
- throw new Error(
107
- `fp_text encountered invalid child expression: ${JSON.stringify(primitive)}`,
108
- )
109
- }
110
-
111
- structuredPrimitives.push(primitive)
112
- }
113
-
114
- const { propertyMap, arrayPropertyMap } =
115
- SxClass.parsePrimitivesToClassProperties(structuredPrimitives, this.token)
116
-
117
- for (const token of Object.keys(propertyMap)) {
118
- if (!SUPPORTED_SINGLE_TOKENS.has(token)) {
119
- throw new Error(
120
- `fp_text encountered unsupported child token "${token}"`,
121
- )
122
- }
123
- }
124
-
125
- for (const [token, entries] of Object.entries(arrayPropertyMap)) {
126
- if (!SUPPORTED_SINGLE_TOKENS.has(token)) {
127
- throw new Error(
128
- `fp_text encountered unsupported child token "${token}"`,
129
- )
130
- }
131
- if (!SUPPORTED_MULTI_TOKENS.has(token) && entries.length > 1) {
132
- throw new Error(
133
- `fp_text does not support repeated child token "${token}"`,
134
- )
135
- }
136
- }
137
-
138
- const atInstance = propertyMap.at as At | undefined
139
- const xyInstance = propertyMap.xy as Xy | undefined
140
- if (atInstance && xyInstance) {
141
- throw new Error("fp_text cannot include both at and xy child tokens")
142
- }
143
-
144
- fpText._sxPosition = atInstance ?? xyInstance
145
- fpText._sxLayer = propertyMap.layer as Layer | undefined
146
- fpText._sxEffects = propertyMap.effects as TextEffects | undefined
147
- fpText._sxUuid = propertyMap.uuid as Uuid | undefined
148
-
149
- const unlockedEntry = propertyMap.unlocked as FpTextUnlocked | undefined
150
- const hideEntry = propertyMap.hide as FpTextHide | undefined
151
-
152
- if (unlockedEntry && sawBareUnlocked) {
153
- throw new Error(
154
- "fp_text encountered both bare and structured unlocked tokens",
155
- )
156
- }
157
- if (hideEntry && sawBareHide) {
158
- throw new Error(
159
- "fp_text encountered both bare and structured hide tokens",
160
- )
161
- }
162
-
163
- fpText._sxUnlocked = unlockedEntry
164
- fpText._sxHide = hideEntry
165
-
166
- if (sawBareUnlocked) {
167
- fpText._sxUnlocked = new FpTextUnlocked({ value: true, bare: true })
168
- }
169
- if (sawBareHide) {
170
- fpText._sxHide = new FpTextHide({ value: true, bare: true })
171
- }
172
-
173
- return fpText
174
- }
175
-
176
- get type(): FpTextType | undefined {
177
- return this._type
178
- }
179
-
180
- set type(value: FpTextType | undefined) {
181
- this._type = value
182
- }
183
-
184
- get text(): string {
185
- return this._text
186
- }
187
-
188
- set text(value: string) {
189
- this._text = value
190
- }
191
-
192
- get position(): At | Xy | undefined {
193
- return this._sxPosition
194
- }
195
-
196
- set position(value: AtInput | Xy | undefined) {
197
- if (value === undefined) {
198
- this._sxPosition = undefined
199
- return
200
- }
201
- if (value instanceof Xy) {
202
- this._sxPosition = value
203
- return
204
- }
205
- // Handle AtInput (At, array, or object)
206
- this._sxPosition = At.from(value as AtInput)
207
- }
208
-
209
- get unlocked(): boolean {
210
- return this._sxUnlocked?.value ?? false
211
- }
212
-
213
- set unlocked(value: boolean) {
214
- this._sxUnlocked = value
215
- ? new FpTextUnlocked({ value: true, bare: true })
216
- : undefined
217
- }
218
-
219
- get hidden(): boolean {
220
- return this._sxHide?.value ?? false
221
- }
222
-
223
- set hidden(value: boolean) {
224
- this._sxHide = value
225
- ? new FpTextHide({ value: true, bare: true })
226
- : undefined
227
- }
228
-
229
- get layer(): Layer | undefined {
230
- return this._sxLayer
231
- }
232
-
233
- set layer(value: Layer | string | string[] | undefined) {
234
- if (value === undefined) {
235
- this._sxLayer = undefined
236
- return
237
- }
238
- if (value instanceof Layer) {
239
- this._sxLayer = value
240
- } else {
241
- const names = Array.isArray(value) ? value : [value]
242
- this._sxLayer = new Layer(names)
243
- }
244
- }
245
-
246
- get effects(): TextEffects | undefined {
247
- return this._sxEffects
248
- }
249
-
250
- set effects(value: TextEffects | undefined) {
251
- this._sxEffects = value
252
- }
253
-
254
- get uuid(): Uuid | undefined {
255
- return this._sxUuid
256
- }
257
-
258
- set uuid(value: Uuid | string | undefined) {
259
- if (value === undefined) {
260
- this._sxUuid = undefined
261
- return
262
- }
263
- this._sxUuid = value instanceof Uuid ? value : new Uuid(value)
264
- }
265
-
266
- override getChildren(): SxClass[] {
267
- const children: SxClass[] = []
268
- if (this._sxPosition) children.push(this._sxPosition)
269
- if (this._sxUnlocked) children.push(this._sxUnlocked)
270
- if (this._sxLayer) children.push(this._sxLayer)
271
- if (this._sxHide) children.push(this._sxHide)
272
- if (this._sxEffects) children.push(this._sxEffects)
273
- if (this._sxUuid) children.push(this._sxUuid)
274
- return children
275
- }
276
-
277
- override getString(): string {
278
- const lines = ["(fp_text"]
279
-
280
- if (this._type !== undefined) {
281
- lines.push(` ${this._type}`)
282
- }
283
-
284
- lines.push(` ${quoteSExprString(this._text)}`)
285
-
286
- for (const child of this.getChildren()) {
287
- lines.push(child.getStringIndented())
288
- }
289
-
290
- lines.push(")")
291
- return lines.join("\n")
292
- }
293
- }
294
- SxClass.register(FpText)
295
-
296
- function primitiveToString(value: PrimitiveSExpr | undefined): string {
297
- if (value === undefined) return ""
298
- const str = toStringValue(value)
299
- if (str !== undefined) return str
300
- return printSExpr(value)
301
- }
302
-
303
- class FpTextUnlocked extends SxClass {
304
- static override token = "unlocked"
305
- static override parentToken = "fp_text"
306
- token = "unlocked"
307
-
308
- value: boolean
309
- private readonly renderBare: boolean
310
-
311
- constructor(options: { value?: boolean; bare?: boolean } = {}) {
312
- super()
313
- this.value = options.value ?? true
314
- this.renderBare = options.bare ?? false
315
- }
316
-
317
- static override fromSexprPrimitives(
318
- primitiveSexprs: PrimitiveSExpr[],
319
- ): FpTextUnlocked {
320
- const [raw] = primitiveSexprs
321
- const rawString = toStringValue(raw)
322
- const value =
323
- rawString === undefined ? true : !/^(no|false)$/iu.test(rawString)
324
- return new FpTextUnlocked({ value, bare: false })
325
- }
326
-
327
- override getChildren(): SxClass[] {
328
- return []
329
- }
330
-
331
- override getString(): string {
332
- if (this.renderBare) {
333
- return "unlocked"
334
- }
335
- return `(unlocked ${this.value ? "yes" : "no"})`
336
- }
337
- }
338
- SxClass.register(FpTextUnlocked)
339
-
340
- class FpTextHide extends SxClass {
341
- static override token = "hide"
342
- static override parentToken = "fp_text"
343
- token = "hide"
344
-
345
- value: boolean
346
- private readonly renderBare: boolean
347
-
348
- constructor(options: { value?: boolean; bare?: boolean } = {}) {
349
- super()
350
- this.value = options.value ?? true
351
- this.renderBare = options.bare ?? false
352
- }
353
-
354
- static override fromSexprPrimitives(
355
- primitiveSexprs: PrimitiveSExpr[],
356
- ): FpTextHide {
357
- const [raw] = primitiveSexprs
358
- const rawString = toStringValue(raw)
359
- const value =
360
- rawString === undefined ? true : !/^(no|false)$/iu.test(rawString)
361
- return new FpTextHide({ value, bare: false })
362
- }
363
-
364
- override getChildren(): SxClass[] {
365
- return []
366
- }
367
-
368
- override getString(): string {
369
- if (this.renderBare) {
370
- return "hide"
371
- }
372
- return `(hide ${this.value ? "yes" : "no"})`
373
- }
374
- }
375
- SxClass.register(FpTextHide)