kicadts 0.0.7 → 0.0.9

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 (3) hide show
  1. package/dist/index.d.ts +49 -38
  2. package/dist/index.js +211 -144
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -824,7 +824,7 @@ declare class SchematicSymbol extends SxClass {
824
824
  private _inlineLibId?;
825
825
  constructor(params?: SchematicSymbolConstructorParams);
826
826
  get libraryId(): string | undefined;
827
- set libraryId(value: string | undefined);
827
+ set libraryId(value: string | SymbolLibId | undefined);
828
828
  get at(): At | undefined;
829
829
  set at(value: AtInput | undefined);
830
830
  get unit(): number | undefined;
@@ -1283,15 +1283,57 @@ declare class Property extends SxClass {
1283
1283
  getString(): string;
1284
1284
  }
1285
1285
 
1286
+ declare class SheetInstancesRoot extends SxClass {
1287
+ static token: string;
1288
+ token: string;
1289
+ private _paths;
1290
+ static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstancesRoot;
1291
+ get paths(): SheetInstancesRootPath[];
1292
+ set paths(value: SheetInstancesRootPath[]);
1293
+ getChildren(): SxClass[];
1294
+ }
1295
+ declare class SheetInstancesRootPath extends SxClass {
1296
+ static token: string;
1297
+ static parentToken: string;
1298
+ token: string;
1299
+ private _value;
1300
+ private _pages;
1301
+ static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstancesRootPath;
1302
+ get value(): string;
1303
+ set value(newValue: string);
1304
+ get pages(): SheetInstancesRootPage[];
1305
+ set pages(value: SheetInstancesRootPage[]);
1306
+ getChildren(): SxClass[];
1307
+ getString(): string;
1308
+ }
1309
+ declare class SheetInstancesRootPage extends SxPrimitiveString {
1310
+ static token: string;
1311
+ static parentToken: string;
1312
+ token: string;
1313
+ static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstancesRootPage;
1314
+ getString(): string;
1315
+ }
1316
+
1286
1317
  declare class SheetInstances extends SxClass {
1287
1318
  static token: string;
1288
1319
  static parentToken: string;
1289
1320
  token: string;
1290
- projects: SheetInstancesProject[];
1321
+ private _projects;
1322
+ private _paths;
1291
1323
  static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstances;
1324
+ get projects(): SheetInstancesProject[];
1325
+ set projects(value: SheetInstancesProject[]);
1326
+ get paths(): SheetInstancesRootPath[];
1327
+ set paths(value: SheetInstancesRootPath[]);
1292
1328
  getChildren(): SxClass[];
1293
1329
  getString(): string;
1294
1330
  }
1331
+ declare class SheetInstancesForSheet extends SheetInstances {
1332
+ static token: string;
1333
+ static parentToken: string;
1334
+ token: string;
1335
+ static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstancesForSheet;
1336
+ }
1295
1337
  declare class SheetInstancesProject extends SxClass {
1296
1338
  static token: string;
1297
1339
  static parentToken: string;
@@ -1478,7 +1520,7 @@ interface KicadSchConstructorParams {
1478
1520
  paper?: Paper;
1479
1521
  titleBlock?: TitleBlock;
1480
1522
  libSymbols?: LibSymbols;
1481
- sheetInstances?: SheetInstances;
1523
+ sheetInstances?: SheetInstances | SheetInstances[];
1482
1524
  embeddedFonts?: EmbeddedFonts;
1483
1525
  properties?: Property[];
1484
1526
  images?: Image[];
@@ -1499,7 +1541,7 @@ declare class KicadSch extends SxClass {
1499
1541
  private _sxPaper?;
1500
1542
  private _sxTitleBlock?;
1501
1543
  private _sxLibSymbols?;
1502
- private _sxSheetInstances?;
1544
+ private _sheetInstances;
1503
1545
  private _sxEmbeddedFonts?;
1504
1546
  private _properties;
1505
1547
  private _images;
@@ -1525,8 +1567,8 @@ declare class KicadSch extends SxClass {
1525
1567
  set titleBlock(value: TitleBlock | undefined);
1526
1568
  get libSymbols(): LibSymbols | undefined;
1527
1569
  set libSymbols(value: LibSymbols | undefined);
1528
- get sheetInstances(): SheetInstances | undefined;
1529
- set sheetInstances(value: SheetInstances | undefined);
1570
+ get sheetInstances(): SheetInstances[];
1571
+ set sheetInstances(value: SheetInstances | SheetInstances[] | undefined);
1530
1572
  get embeddedFonts(): EmbeddedFonts | undefined;
1531
1573
  set embeddedFonts(value: EmbeddedFonts | undefined);
1532
1574
  get properties(): Property[];
@@ -3390,37 +3432,6 @@ declare class FpPolyLocked extends SxPrimitiveBoolean {
3390
3432
  getString(): string;
3391
3433
  }
3392
3434
 
3393
- declare class SheetInstancesRoot extends SxClass {
3394
- static token: string;
3395
- token: string;
3396
- private _paths;
3397
- static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstancesRoot;
3398
- get paths(): SheetInstancesRootPath[];
3399
- set paths(value: SheetInstancesRootPath[]);
3400
- getChildren(): SxClass[];
3401
- }
3402
- declare class SheetInstancesRootPath extends SxClass {
3403
- static token: string;
3404
- static parentToken: string;
3405
- token: string;
3406
- private _value;
3407
- private _pages;
3408
- static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstancesRootPath;
3409
- get value(): string;
3410
- set value(newValue: string);
3411
- get pages(): SheetInstancesRootPage[];
3412
- set pages(value: SheetInstancesRootPage[]);
3413
- getChildren(): SxClass[];
3414
- getString(): string;
3415
- }
3416
- declare class SheetInstancesRootPage extends SxPrimitiveString {
3417
- static token: string;
3418
- static parentToken: string;
3419
- token: string;
3420
- static fromSexprPrimitives(primitiveSexprs: PrimitiveSExpr[]): SheetInstancesRootPage;
3421
- getString(): string;
3422
- }
3423
-
3424
3435
  declare class PcbPlotParams extends SxClass {
3425
3436
  static token: string;
3426
3437
  static parentToken: string;
@@ -4463,4 +4474,4 @@ declare class KicadPcb extends SxClass {
4463
4474
 
4464
4475
  declare const parseKicadSexpr: (sexpr: string) => SxClass[];
4465
4476
 
4466
- export { At, type AtInput, Bus, type BusConstructorParams, BusEntry, type BusEntryConstructorParams, BusEntrySize, Color, Dnp, EmbeddedFonts, ExcludeFromSim, FieldsAutoplaced, Footprint, FootprintAttr, FootprintAutoplaceCost180, FootprintAutoplaceCost90, FootprintClearance, type FootprintConstructorParams, FootprintDescr, FootprintLocked, FootprintModel, FootprintNetTiePadGroups, FootprintPad, type FootprintPadConstructorParams, FootprintPath, FootprintPlaced, FootprintPrivateLayers, FootprintSheetfile, FootprintSheetname, FootprintSolderMaskMargin, FootprintSolderPasteMargin, FootprintSolderPasteRatio, FootprintTags, FootprintTedit, FootprintThermalGap, FootprintThermalWidth, FootprintZoneConnect, FpArc, type FpArcConstructorParams, FpArcEnd, FpArcMid, FpArcStart, FpCircle, FpCircleCenter, type FpCircleConstructorParams, FpCircleEnd, FpCircleFill, FpLine, type FpLineConstructorParams, FpLineEnd, FpLineStart, FpPoly, type FpPolyConstructorParams, FpPolyFill, FpPolyLocked, FpRect, type FpRectConstructorParams, FpRectEnd, FpRectFill, FpRectStart, FpText, FpTextBox, FpTextBoxAngle, type FpTextBoxConstructorParams, FpTextBoxEnd, FpTextBoxStart, type FpTextConstructorParams, type FpTextType, GrLine, GrLineAngle, type GrLineConstructorParams, GrLineEnd, GrLineLocked, type GrLinePoint, GrLineStart, GrText, type GrTextConstructorParams, type GrTextPosition, Image, type ImageConstructorParams, ImageData, ImageScale, InBom, Junction, type JunctionConstructorParams, JunctionDiameter, KicadPcb, type KicadPcbConstructorParams, KicadSch, type KicadSchConstructorParams, KicadSchGenerator, KicadSchGeneratorVersion, KicadSchVersion, Label, type LabelConstructorParams, Layer, Layers, LibSymbols, type ModelVector, NoConnect, type NoConnectConstructorParams, OnBoard, PadChamfer, PadChamferRatio, PadClearance, PadDieLength, PadDrill, PadDrillOffset, PadLayers, type PadLayersInput, PadNet, PadOptions, type PadOptionsAnchorShape, type PadOptionsClearanceType, PadPinFunction, PadPinType, PadPrimitiveGrArc, type PadPrimitiveGrArcConstructorParams, PadPrimitiveGrCircle, type PadPrimitiveGrCircleConstructorParams, PadPrimitiveGrLine, PadPrimitiveGrPoly, PadPrimitives, PadRectDelta, PadRoundrectRratio, PadSize, type PadSizeInput, PadSolderMaskMargin, PadSolderPasteMargin, PadSolderPasteMarginRatio, PadTeardrops, PadThermalBridgeAngle, PadThermalGap, PadThermalWidth, PadZoneConnect, Paper, PcbGeneral, PcbGeneralLegacyTeardrops, PcbGeneralThickness, PcbGenerator, PcbGeneratorVersion, PcbLayerDefinition, PcbLayers, PcbNet, PcbPlotParams, PcbVersion, PlotParamCreateGerberJobFile, PlotParamCrossoutDnpOnFab, PlotParamDashedLineDashRatio, PlotParamDashedLineGapRatio, PlotParamDisableApertMacros, PlotParamDrillShape, PlotParamDxfImperialUnits, PlotParamDxfPolygonMode, PlotParamDxfUsePcbnewFont, PlotParamExcludeEdgeLayer, PlotParamHideDnpOnFab, PlotParamHpglPenDiameter, PlotParamHpglPenNumber, PlotParamHpglPenOverlay, PlotParamHpglPenSpeed, PlotParamLayerSelection, PlotParamLineWidth, PlotParamMirror, PlotParamMode, PlotParamOutputDirectory, PlotParamOutputFormat, PlotParamPadOnSilk, PlotParamPdfBackFpPropertyPopups, PlotParamPdfFrontFpPropertyPopups, PlotParamPdfMetadata, PlotParamPdfSingleDocument, PlotParamPlotBlackAndWhite, PlotParamPlotFrameRef, PlotParamPlotInvisible, PlotParamPlotInvisibleText, PlotParamPlotOnAllLayers, PlotParamPlotOnAllLayersSelection, PlotParamPlotOtherText, PlotParamPlotPadNumbers, PlotParamPlotReference, PlotParamPlotValue, PlotParamProperty, PlotParamPsA4Output, PlotParamPsNegative, PlotParamScaleSelection, PlotParamSketchDnpOnFab, PlotParamSketchPadsOnFab, PlotParamSubtractMaskFromSilk, PlotParamSvgPrecision, PlotParamUseAuxOrigin, PlotParamUseGerberAdvancedAttributes, PlotParamUseGerberAttributes, PlotParamUseGerberExtensions, PlotParamViaOnMask, Property, type PropertyConstructorParams, PropertyHide, PropertyUnlocked, Pts, type RGBAColor, RenderCache, SchematicSymbol, type SchematicSymbolConstructorParams, SchematicText, type SchematicTextConstructorParams, Segment, type SegmentConstructorParams, SegmentEnd, SegmentLocked, SegmentNet, SegmentStart, Setup, SetupAllowSoldermaskBridgesInFootprints, SetupAuxAxisOrigin, SetupEdgeWidth, SetupGridOrigin, SetupLastTraceWidth, SetupModEdgeWidth, SetupModTextSize, SetupModTextWidth, SetupPadDrill, SetupPadSize, SetupPadToMaskClearance, SetupPadToPasteClearance, SetupPadToPasteClearanceRatio, SetupPadToPasteClearanceValues, SetupPcbTextSize, SetupPcbTextWidth, type SetupProperty, type SetupPropertyValues, SetupSegmentWidth, SetupSolderMaskMinWidth, SetupTenting, SetupTraceClearance, SetupTraceMin, SetupTraceWidth, SetupUviaDrill, SetupUviaMinDrill, SetupUviaMinSize, SetupUviaSize, SetupUviasAllowed, SetupViaDrill, SetupViaMinDrill, SetupViaMinSize, SetupViaSize, SetupVisibleElements, SetupZone45Only, SetupZoneClearance, Sheet, type SheetConstructorParams, SheetFill, SheetInstancePage, SheetInstancePath, SheetInstances, SheetInstancesProject, SheetInstancesRoot, SheetInstancesRootPage, SheetInstancesRootPath, SheetPin, type SheetPinElectricalType, SheetProperty, SheetSize, Stackup, StackupCastellatedPads, StackupCopperFinish, StackupDielectricConstraints, StackupEdgeConnector, StackupEdgePlating, StackupLayer, StackupLayerColor, StackupLayerEpsilonR, StackupLayerLossTangent, StackupLayerMaterial, StackupLayerThickness, StackupLayerType, type StandardPaperSize, Stroke, type StrokeProperty, StrokeType, type StrokeTypeString, SxClass, SymbolArc, SymbolArcEnd, SymbolArcFill, SymbolArcMid, SymbolArcStart, SymbolCircle, SymbolCircleCenter, SymbolCircleFill, SymbolCircleRadius, SymbolDuplicatePinNumbersAreJumpers, SymbolFillType, SymbolInstancePath, SymbolInstanceReference, SymbolInstanceUnit, SymbolInstances, SymbolInstancesProject, SymbolLibId, SymbolPin, SymbolPinLength, SymbolPinName, SymbolPinNames, SymbolPinNamesHide, SymbolPinNamesOffset, SymbolPinNumber, SymbolPinNumbers, SymbolPinNumbersHide, SymbolPolyline, SymbolPolylineFill, SymbolPower, SymbolProperty, SymbolPropertyId, SymbolRectangle, SymbolRectangleEnd, SymbolRectangleFill, SymbolRectangleStart, SymbolText, SymbolUnit, TextEffects, type TextEffectsConstructorParams, TextEffectsFont, TextEffectsFontFace, TextEffectsFontLineSpacing, type TextEffectsFontProperty, TextEffectsFontSize, TextEffectsFontThickness, TextEffectsJustify, type TextEffectsProperty, TitleBlock, TitleBlockComment, TitleBlockCompany, type TitleBlockConstructorParams, TitleBlockDate, TitleBlockRevision, TitleBlockTitle, Unit, type UnitString, Uuid, Via, type ViaConstructorParams, ViaNet, Width, Wire, type WireConstructorParams, Xy, Zone, parseKicadSexpr };
4477
+ export { At, type AtInput, Bus, type BusConstructorParams, BusEntry, type BusEntryConstructorParams, BusEntrySize, Color, Dnp, EmbeddedFonts, ExcludeFromSim, FieldsAutoplaced, Footprint, FootprintAttr, FootprintAutoplaceCost180, FootprintAutoplaceCost90, FootprintClearance, type FootprintConstructorParams, FootprintDescr, FootprintLocked, FootprintModel, FootprintNetTiePadGroups, FootprintPad, type FootprintPadConstructorParams, FootprintPath, FootprintPlaced, FootprintPrivateLayers, FootprintSheetfile, FootprintSheetname, FootprintSolderMaskMargin, FootprintSolderPasteMargin, FootprintSolderPasteRatio, FootprintTags, FootprintTedit, FootprintThermalGap, FootprintThermalWidth, FootprintZoneConnect, FpArc, type FpArcConstructorParams, FpArcEnd, FpArcMid, FpArcStart, FpCircle, FpCircleCenter, type FpCircleConstructorParams, FpCircleEnd, FpCircleFill, FpLine, type FpLineConstructorParams, FpLineEnd, FpLineStart, FpPoly, type FpPolyConstructorParams, FpPolyFill, FpPolyLocked, FpRect, type FpRectConstructorParams, FpRectEnd, FpRectFill, FpRectStart, FpText, FpTextBox, FpTextBoxAngle, type FpTextBoxConstructorParams, FpTextBoxEnd, FpTextBoxStart, type FpTextConstructorParams, type FpTextType, GrLine, GrLineAngle, type GrLineConstructorParams, GrLineEnd, GrLineLocked, type GrLinePoint, GrLineStart, GrText, type GrTextConstructorParams, type GrTextPosition, Image, type ImageConstructorParams, ImageData, ImageScale, InBom, Junction, type JunctionConstructorParams, JunctionDiameter, KicadPcb, type KicadPcbConstructorParams, KicadSch, type KicadSchConstructorParams, KicadSchGenerator, KicadSchGeneratorVersion, KicadSchVersion, Label, type LabelConstructorParams, Layer, Layers, LibSymbols, type ModelVector, NoConnect, type NoConnectConstructorParams, OnBoard, PadChamfer, PadChamferRatio, PadClearance, PadDieLength, PadDrill, PadDrillOffset, PadLayers, type PadLayersInput, PadNet, PadOptions, type PadOptionsAnchorShape, type PadOptionsClearanceType, PadPinFunction, PadPinType, PadPrimitiveGrArc, type PadPrimitiveGrArcConstructorParams, PadPrimitiveGrCircle, type PadPrimitiveGrCircleConstructorParams, PadPrimitiveGrLine, PadPrimitiveGrPoly, PadPrimitives, PadRectDelta, PadRoundrectRratio, PadSize, type PadSizeInput, PadSolderMaskMargin, PadSolderPasteMargin, PadSolderPasteMarginRatio, PadTeardrops, PadThermalBridgeAngle, PadThermalGap, PadThermalWidth, PadZoneConnect, Paper, PcbGeneral, PcbGeneralLegacyTeardrops, PcbGeneralThickness, PcbGenerator, PcbGeneratorVersion, PcbLayerDefinition, PcbLayers, PcbNet, PcbPlotParams, PcbVersion, PlotParamCreateGerberJobFile, PlotParamCrossoutDnpOnFab, PlotParamDashedLineDashRatio, PlotParamDashedLineGapRatio, PlotParamDisableApertMacros, PlotParamDrillShape, PlotParamDxfImperialUnits, PlotParamDxfPolygonMode, PlotParamDxfUsePcbnewFont, PlotParamExcludeEdgeLayer, PlotParamHideDnpOnFab, PlotParamHpglPenDiameter, PlotParamHpglPenNumber, PlotParamHpglPenOverlay, PlotParamHpglPenSpeed, PlotParamLayerSelection, PlotParamLineWidth, PlotParamMirror, PlotParamMode, PlotParamOutputDirectory, PlotParamOutputFormat, PlotParamPadOnSilk, PlotParamPdfBackFpPropertyPopups, PlotParamPdfFrontFpPropertyPopups, PlotParamPdfMetadata, PlotParamPdfSingleDocument, PlotParamPlotBlackAndWhite, PlotParamPlotFrameRef, PlotParamPlotInvisible, PlotParamPlotInvisibleText, PlotParamPlotOnAllLayers, PlotParamPlotOnAllLayersSelection, PlotParamPlotOtherText, PlotParamPlotPadNumbers, PlotParamPlotReference, PlotParamPlotValue, PlotParamProperty, PlotParamPsA4Output, PlotParamPsNegative, PlotParamScaleSelection, PlotParamSketchDnpOnFab, PlotParamSketchPadsOnFab, PlotParamSubtractMaskFromSilk, PlotParamSvgPrecision, PlotParamUseAuxOrigin, PlotParamUseGerberAdvancedAttributes, PlotParamUseGerberAttributes, PlotParamUseGerberExtensions, PlotParamViaOnMask, Property, type PropertyConstructorParams, PropertyHide, PropertyUnlocked, Pts, type RGBAColor, RenderCache, SchematicSymbol, type SchematicSymbolConstructorParams, SchematicText, type SchematicTextConstructorParams, Segment, type SegmentConstructorParams, SegmentEnd, SegmentLocked, SegmentNet, SegmentStart, Setup, SetupAllowSoldermaskBridgesInFootprints, SetupAuxAxisOrigin, SetupEdgeWidth, SetupGridOrigin, SetupLastTraceWidth, SetupModEdgeWidth, SetupModTextSize, SetupModTextWidth, SetupPadDrill, SetupPadSize, SetupPadToMaskClearance, SetupPadToPasteClearance, SetupPadToPasteClearanceRatio, SetupPadToPasteClearanceValues, SetupPcbTextSize, SetupPcbTextWidth, type SetupProperty, type SetupPropertyValues, SetupSegmentWidth, SetupSolderMaskMinWidth, SetupTenting, SetupTraceClearance, SetupTraceMin, SetupTraceWidth, SetupUviaDrill, SetupUviaMinDrill, SetupUviaMinSize, SetupUviaSize, SetupUviasAllowed, SetupViaDrill, SetupViaMinDrill, SetupViaMinSize, SetupViaSize, SetupVisibleElements, SetupZone45Only, SetupZoneClearance, Sheet, type SheetConstructorParams, SheetFill, SheetInstancePage, SheetInstancePath, SheetInstances, SheetInstancesForSheet, SheetInstancesProject, SheetInstancesRoot, SheetInstancesRootPage, SheetInstancesRootPath, SheetPin, type SheetPinElectricalType, SheetProperty, SheetSize, Stackup, StackupCastellatedPads, StackupCopperFinish, StackupDielectricConstraints, StackupEdgeConnector, StackupEdgePlating, StackupLayer, StackupLayerColor, StackupLayerEpsilonR, StackupLayerLossTangent, StackupLayerMaterial, StackupLayerThickness, StackupLayerType, type StandardPaperSize, Stroke, type StrokeProperty, StrokeType, type StrokeTypeString, SxClass, SymbolArc, SymbolArcEnd, SymbolArcFill, SymbolArcMid, SymbolArcStart, SymbolCircle, SymbolCircleCenter, SymbolCircleFill, SymbolCircleRadius, SymbolDuplicatePinNumbersAreJumpers, SymbolFillType, SymbolInstancePath, SymbolInstanceReference, SymbolInstanceUnit, SymbolInstances, SymbolInstancesProject, SymbolLibId, SymbolPin, SymbolPinLength, SymbolPinName, SymbolPinNames, SymbolPinNamesHide, SymbolPinNamesOffset, SymbolPinNumber, SymbolPinNumbers, SymbolPinNumbersHide, SymbolPolyline, SymbolPolylineFill, SymbolPower, SymbolProperty, SymbolPropertyId, SymbolRectangle, SymbolRectangleEnd, SymbolRectangleFill, SymbolRectangleStart, SymbolText, SymbolUnit, TextEffects, type TextEffectsConstructorParams, TextEffectsFont, TextEffectsFontFace, TextEffectsFontLineSpacing, type TextEffectsFontProperty, TextEffectsFontSize, TextEffectsFontThickness, TextEffectsJustify, type TextEffectsProperty, TitleBlock, TitleBlockComment, TitleBlockCompany, type TitleBlockConstructorParams, TitleBlockDate, TitleBlockRevision, TitleBlockTitle, Unit, type UnitString, Uuid, Via, type ViaConstructorParams, ViaNet, Width, Wire, type WireConstructorParams, Xy, Zone, parseKicadSexpr };
package/dist/index.js CHANGED
@@ -2478,6 +2478,11 @@ var SchematicSymbol = class _SchematicSymbol extends SxClass {
2478
2478
  return this._sxLibId?.value ?? this._inlineLibId;
2479
2479
  }
2480
2480
  set libraryId(value) {
2481
+ if (value && typeof value === "object") {
2482
+ this._sxLibId = value;
2483
+ this._inlineLibId = void 0;
2484
+ return;
2485
+ }
2481
2486
  if (value === void 0 || value === "") {
2482
2487
  this._inlineLibId = void 0;
2483
2488
  if (this._sxLibId) {
@@ -4133,34 +4138,215 @@ var Property = class _Property extends SxClass {
4133
4138
  };
4134
4139
  SxClass.register(Property);
4135
4140
 
4141
+ // lib/sexpr/classes/SheetInstancesRoot.ts
4142
+ var SUPPORTED_ARRAY_TOKENS2 = /* @__PURE__ */ new Set(["page"]);
4143
+ var SheetInstancesRoot = class _SheetInstancesRoot extends SxClass {
4144
+ static token = "sheet_instances";
4145
+ token = "sheet_instances";
4146
+ _paths = [];
4147
+ static fromSexprPrimitives(primitiveSexprs) {
4148
+ const sheetInstances = new _SheetInstancesRoot();
4149
+ const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token);
4150
+ const unsupportedSingularTokens = Object.keys(propertyMap).filter(
4151
+ (token) => token !== "path"
4152
+ );
4153
+ if (unsupportedSingularTokens.length > 0) {
4154
+ throw new Error(
4155
+ `Unsupported singular child tokens inside sheet_instances expression: ${unsupportedSingularTokens.join(", ")}`
4156
+ );
4157
+ }
4158
+ const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
4159
+ (token) => token !== "path"
4160
+ );
4161
+ if (unsupportedArrayTokens.length > 0) {
4162
+ throw new Error(
4163
+ `Unsupported repeated child tokens inside sheet_instances expression: ${unsupportedArrayTokens.join(", ")}`
4164
+ );
4165
+ }
4166
+ const paths = arrayPropertyMap.path ?? [];
4167
+ if (!paths.length && propertyMap.path) {
4168
+ paths.push(propertyMap.path);
4169
+ }
4170
+ sheetInstances._paths = paths;
4171
+ return sheetInstances;
4172
+ }
4173
+ get paths() {
4174
+ return [...this._paths];
4175
+ }
4176
+ set paths(value) {
4177
+ this._paths = [...value];
4178
+ }
4179
+ getChildren() {
4180
+ return [...this._paths];
4181
+ }
4182
+ };
4183
+ SxClass.register(SheetInstancesRoot);
4184
+ var SheetInstancesRootPath = class _SheetInstancesRootPath extends SxClass {
4185
+ static token = "path";
4186
+ static parentToken = "sheet_instances";
4187
+ token = "path";
4188
+ _value = "";
4189
+ _pages = [];
4190
+ static fromSexprPrimitives(primitiveSexprs) {
4191
+ const [valuePrimitive, ...rest] = primitiveSexprs;
4192
+ const value = toStringValue(valuePrimitive);
4193
+ if (value === void 0) {
4194
+ throw new Error("sheet_instances path requires a string identifier");
4195
+ }
4196
+ const path = new _SheetInstancesRootPath();
4197
+ path._value = value;
4198
+ const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(rest, "sheet_instances_path");
4199
+ const unsupportedSingularTokens = Object.keys(propertyMap).filter(
4200
+ (token) => !SUPPORTED_ARRAY_TOKENS2.has(token)
4201
+ );
4202
+ if (unsupportedSingularTokens.length > 0) {
4203
+ throw new Error(
4204
+ `Unsupported singular child tokens inside sheet_instances path expression: ${unsupportedSingularTokens.join(", ")}`
4205
+ );
4206
+ }
4207
+ const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
4208
+ (token) => !SUPPORTED_ARRAY_TOKENS2.has(token)
4209
+ );
4210
+ if (unsupportedArrayTokens.length > 0) {
4211
+ throw new Error(
4212
+ `Unsupported repeated child tokens inside sheet_instances path expression: ${unsupportedArrayTokens.join(", ")}`
4213
+ );
4214
+ }
4215
+ const pages = arrayPropertyMap.page ?? [];
4216
+ if (!pages.length && propertyMap.page) {
4217
+ pages.push(propertyMap.page);
4218
+ }
4219
+ path._pages = pages;
4220
+ return path;
4221
+ }
4222
+ get value() {
4223
+ return this._value;
4224
+ }
4225
+ set value(newValue) {
4226
+ this._value = newValue;
4227
+ }
4228
+ get pages() {
4229
+ return [...this._pages];
4230
+ }
4231
+ set pages(value) {
4232
+ this._pages = [...value];
4233
+ }
4234
+ getChildren() {
4235
+ return [...this._pages];
4236
+ }
4237
+ getString() {
4238
+ const lines = [`(path ${quoteSExprString(this._value)}`];
4239
+ for (const page of this._pages) {
4240
+ lines.push(page.getStringIndented());
4241
+ }
4242
+ lines.push(")");
4243
+ return lines.join("\n");
4244
+ }
4245
+ };
4246
+ SxClass.register(SheetInstancesRootPath);
4247
+ var SheetInstancesRootPage = class _SheetInstancesRootPage extends SxPrimitiveString {
4248
+ static token = "page";
4249
+ static parentToken = "sheet_instances_path";
4250
+ token = "page";
4251
+ static fromSexprPrimitives(primitiveSexprs) {
4252
+ const [valuePrimitive] = primitiveSexprs;
4253
+ const value = toStringValue(valuePrimitive);
4254
+ if (value === void 0) {
4255
+ throw new Error("sheet_instances page expects a string value");
4256
+ }
4257
+ return new _SheetInstancesRootPage(value);
4258
+ }
4259
+ getString() {
4260
+ return `(page ${quoteSExprString(this.value)})`;
4261
+ }
4262
+ };
4263
+ SxClass.register(SheetInstancesRootPage);
4264
+
4136
4265
  // lib/sexpr/classes/SheetInstances.ts
4266
+ var SUPPORTED_CHILD_TOKENS = /* @__PURE__ */ new Set(["project", "path"]);
4267
+ var parseSheetInstancesChildren = (primitiveSexprs) => {
4268
+ const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(primitiveSexprs, "sheet_instances");
4269
+ const unsupportedSingularTokens = Object.keys(propertyMap).filter(
4270
+ (token) => !SUPPORTED_CHILD_TOKENS.has(token)
4271
+ );
4272
+ if (unsupportedSingularTokens.length > 0) {
4273
+ throw new Error(
4274
+ `sheet_instances encountered unsupported child token${unsupportedSingularTokens.length > 1 ? "s" : ""} ${unsupportedSingularTokens.map((token) => `"${token}"`).join(", ")}`
4275
+ );
4276
+ }
4277
+ const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
4278
+ (token) => !SUPPORTED_CHILD_TOKENS.has(token)
4279
+ );
4280
+ if (unsupportedArrayTokens.length > 0) {
4281
+ throw new Error(
4282
+ `sheet_instances encountered unsupported repeated child token${unsupportedArrayTokens.length > 1 ? "s" : ""} ${unsupportedArrayTokens.map((token) => `"${token}"`).join(", ")}`
4283
+ );
4284
+ }
4285
+ const projects = arrayPropertyMap.project ?? [];
4286
+ if (!projects.length && propertyMap.project) {
4287
+ projects.push(propertyMap.project);
4288
+ }
4289
+ const paths = arrayPropertyMap.path ?? [];
4290
+ if (!paths.length && propertyMap.path) {
4291
+ paths.push(propertyMap.path);
4292
+ }
4293
+ return { projects, paths };
4294
+ };
4137
4295
  var SheetInstances = class _SheetInstances extends SxClass {
4138
4296
  static token = "sheet_instances";
4139
4297
  static parentToken = "kicad_sch";
4140
4298
  token = "sheet_instances";
4141
- projects = [];
4299
+ _projects = [];
4300
+ _paths = [];
4142
4301
  static fromSexprPrimitives(primitiveSexprs) {
4143
4302
  const instances = new _SheetInstances();
4144
- const { arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(
4145
- primitiveSexprs,
4146
- "sheet_instances"
4147
- );
4148
- instances.projects = arrayPropertyMap.project ?? [];
4303
+ const { projects, paths } = parseSheetInstancesChildren(primitiveSexprs);
4304
+ instances.projects = projects;
4305
+ instances.paths = paths;
4149
4306
  return instances;
4150
4307
  }
4308
+ get projects() {
4309
+ return [...this._projects];
4310
+ }
4311
+ set projects(value) {
4312
+ this._projects = [...value];
4313
+ }
4314
+ get paths() {
4315
+ return [...this._paths];
4316
+ }
4317
+ set paths(value) {
4318
+ this._paths = [...value];
4319
+ }
4151
4320
  getChildren() {
4152
- return [...this.projects];
4321
+ return [...this._projects, ...this._paths];
4153
4322
  }
4154
4323
  getString() {
4155
- const lines = ["(sheet_instances"];
4156
- for (const project of this.projects) {
4157
- lines.push(project.getStringIndented());
4324
+ const children = this.getChildren();
4325
+ if (children.length === 0) {
4326
+ return `(${this.token})`;
4327
+ }
4328
+ const lines = [`(${this.token}`];
4329
+ for (const child of children) {
4330
+ lines.push(child.getStringIndented());
4158
4331
  }
4159
4332
  lines.push(")");
4160
4333
  return lines.join("\n");
4161
4334
  }
4162
4335
  };
4163
4336
  SxClass.register(SheetInstances);
4337
+ var SheetInstancesForSheet = class _SheetInstancesForSheet extends SheetInstances {
4338
+ static token = "instances";
4339
+ static parentToken = "sheet";
4340
+ token = "instances";
4341
+ static fromSexprPrimitives(primitiveSexprs) {
4342
+ const instances = new _SheetInstancesForSheet();
4343
+ const { projects, paths } = parseSheetInstancesChildren(primitiveSexprs);
4344
+ instances.projects = projects;
4345
+ instances.paths = paths;
4346
+ return instances;
4347
+ }
4348
+ };
4349
+ SxClass.register(SheetInstancesForSheet);
4164
4350
  var SheetInstancesProject = class _SheetInstancesProject extends SxClass {
4165
4351
  static token = "project";
4166
4352
  static parentToken = "sheet_instances";
@@ -4678,7 +4864,6 @@ var SINGLE_CHILD_TOKENS = /* @__PURE__ */ new Set([
4678
4864
  "paper",
4679
4865
  "title_block",
4680
4866
  "lib_symbols",
4681
- "sheet_instances",
4682
4867
  "embedded_fonts"
4683
4868
  ]);
4684
4869
  var MULTI_CHILD_TOKENS = /* @__PURE__ */ new Set([
@@ -4689,9 +4874,10 @@ var MULTI_CHILD_TOKENS = /* @__PURE__ */ new Set([
4689
4874
  "text",
4690
4875
  "label",
4691
4876
  "junction",
4692
- "wire"
4877
+ "wire",
4878
+ "sheet_instances"
4693
4879
  ]);
4694
- var SUPPORTED_CHILD_TOKENS = /* @__PURE__ */ new Set([
4880
+ var SUPPORTED_CHILD_TOKENS2 = /* @__PURE__ */ new Set([
4695
4881
  ...SINGLE_CHILD_TOKENS,
4696
4882
  ...MULTI_CHILD_TOKENS
4697
4883
  ]);
@@ -4705,7 +4891,7 @@ var KicadSch = class _KicadSch extends SxClass {
4705
4891
  _sxPaper;
4706
4892
  _sxTitleBlock;
4707
4893
  _sxLibSymbols;
4708
- _sxSheetInstances;
4894
+ _sheetInstances = [];
4709
4895
  _sxEmbeddedFonts;
4710
4896
  _properties = [];
4711
4897
  _images = [];
@@ -4790,14 +4976,14 @@ var KicadSch = class _KicadSch extends SxClass {
4790
4976
  }
4791
4977
  const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token);
4792
4978
  for (const token of Object.keys(propertyMap)) {
4793
- if (!SUPPORTED_CHILD_TOKENS.has(token)) {
4979
+ if (!SUPPORTED_CHILD_TOKENS2.has(token)) {
4794
4980
  throw new Error(
4795
4981
  `kicad_sch encountered unsupported child token "${token}"`
4796
4982
  );
4797
4983
  }
4798
4984
  }
4799
4985
  for (const [token, entries] of Object.entries(arrayPropertyMap)) {
4800
- if (!SUPPORTED_CHILD_TOKENS.has(token)) {
4986
+ if (!SUPPORTED_CHILD_TOKENS2.has(token)) {
4801
4987
  throw new Error(
4802
4988
  `kicad_sch encountered unsupported child token "${token}"`
4803
4989
  );
@@ -4816,7 +5002,7 @@ var KicadSch = class _KicadSch extends SxClass {
4816
5002
  paper: propertyMap.paper,
4817
5003
  titleBlock: propertyMap.title_block,
4818
5004
  libSymbols: propertyMap.lib_symbols,
4819
- sheetInstances: propertyMap.sheet_instances,
5005
+ sheetInstances: arrayPropertyMap.sheet_instances,
4820
5006
  embeddedFonts: propertyMap.embedded_fonts,
4821
5007
  properties: arrayPropertyMap.property ?? [],
4822
5008
  images: arrayPropertyMap.image ?? [],
@@ -4875,10 +5061,14 @@ var KicadSch = class _KicadSch extends SxClass {
4875
5061
  this._sxLibSymbols = value;
4876
5062
  }
4877
5063
  get sheetInstances() {
4878
- return this._sxSheetInstances;
5064
+ return [...this._sheetInstances];
4879
5065
  }
4880
5066
  set sheetInstances(value) {
4881
- this._sxSheetInstances = value;
5067
+ if (value === void 0) {
5068
+ this._sheetInstances = [];
5069
+ return;
5070
+ }
5071
+ this._sheetInstances = Array.isArray(value) ? [...value] : [value];
4882
5072
  }
4883
5073
  get embeddedFonts() {
4884
5074
  return this._sxEmbeddedFonts;
@@ -4943,7 +5133,7 @@ var KicadSch = class _KicadSch extends SxClass {
4943
5133
  if (this._sxPaper) children.push(this._sxPaper);
4944
5134
  if (this._sxTitleBlock) children.push(this._sxTitleBlock);
4945
5135
  if (this._sxLibSymbols) children.push(this._sxLibSymbols);
4946
- if (this._sxSheetInstances) children.push(this._sxSheetInstances);
5136
+ children.push(...this._sheetInstances);
4947
5137
  if (this._sxEmbeddedFonts) children.push(this._sxEmbeddedFonts);
4948
5138
  children.push(...this._properties);
4949
5139
  children.push(...this._images);
@@ -11059,130 +11249,6 @@ var Layers = class _Layers extends SxClass {
11059
11249
  };
11060
11250
  SxClass.register(Layers);
11061
11251
 
11062
- // lib/sexpr/classes/SheetInstancesRoot.ts
11063
- var SUPPORTED_ARRAY_TOKENS2 = /* @__PURE__ */ new Set(["page"]);
11064
- var SheetInstancesRoot = class _SheetInstancesRoot extends SxClass {
11065
- static token = "sheet_instances";
11066
- token = "sheet_instances";
11067
- _paths = [];
11068
- static fromSexprPrimitives(primitiveSexprs) {
11069
- const sheetInstances = new _SheetInstancesRoot();
11070
- const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token);
11071
- const unsupportedSingularTokens = Object.keys(propertyMap).filter(
11072
- (token) => token !== "path"
11073
- );
11074
- if (unsupportedSingularTokens.length > 0) {
11075
- throw new Error(
11076
- `Unsupported singular child tokens inside sheet_instances expression: ${unsupportedSingularTokens.join(", ")}`
11077
- );
11078
- }
11079
- const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
11080
- (token) => token !== "path"
11081
- );
11082
- if (unsupportedArrayTokens.length > 0) {
11083
- throw new Error(
11084
- `Unsupported repeated child tokens inside sheet_instances expression: ${unsupportedArrayTokens.join(", ")}`
11085
- );
11086
- }
11087
- const paths = arrayPropertyMap.path ?? [];
11088
- if (!paths.length && propertyMap.path) {
11089
- paths.push(propertyMap.path);
11090
- }
11091
- sheetInstances._paths = paths;
11092
- return sheetInstances;
11093
- }
11094
- get paths() {
11095
- return [...this._paths];
11096
- }
11097
- set paths(value) {
11098
- this._paths = [...value];
11099
- }
11100
- getChildren() {
11101
- return [...this._paths];
11102
- }
11103
- };
11104
- SxClass.register(SheetInstancesRoot);
11105
- var SheetInstancesRootPath = class _SheetInstancesRootPath extends SxClass {
11106
- static token = "path";
11107
- static parentToken = "sheet_instances";
11108
- token = "path";
11109
- _value = "";
11110
- _pages = [];
11111
- static fromSexprPrimitives(primitiveSexprs) {
11112
- const [valuePrimitive, ...rest] = primitiveSexprs;
11113
- const value = toStringValue(valuePrimitive);
11114
- if (value === void 0) {
11115
- throw new Error("sheet_instances path requires a string identifier");
11116
- }
11117
- const path = new _SheetInstancesRootPath();
11118
- path._value = value;
11119
- const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(rest, "sheet_instances_path");
11120
- const unsupportedSingularTokens = Object.keys(propertyMap).filter(
11121
- (token) => !SUPPORTED_ARRAY_TOKENS2.has(token)
11122
- );
11123
- if (unsupportedSingularTokens.length > 0) {
11124
- throw new Error(
11125
- `Unsupported singular child tokens inside sheet_instances path expression: ${unsupportedSingularTokens.join(", ")}`
11126
- );
11127
- }
11128
- const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
11129
- (token) => !SUPPORTED_ARRAY_TOKENS2.has(token)
11130
- );
11131
- if (unsupportedArrayTokens.length > 0) {
11132
- throw new Error(
11133
- `Unsupported repeated child tokens inside sheet_instances path expression: ${unsupportedArrayTokens.join(", ")}`
11134
- );
11135
- }
11136
- const pages = arrayPropertyMap.page ?? [];
11137
- if (!pages.length && propertyMap.page) {
11138
- pages.push(propertyMap.page);
11139
- }
11140
- path._pages = pages;
11141
- return path;
11142
- }
11143
- get value() {
11144
- return this._value;
11145
- }
11146
- set value(newValue) {
11147
- this._value = newValue;
11148
- }
11149
- get pages() {
11150
- return [...this._pages];
11151
- }
11152
- set pages(value) {
11153
- this._pages = [...value];
11154
- }
11155
- getChildren() {
11156
- return [...this._pages];
11157
- }
11158
- getString() {
11159
- const lines = [`(path ${quoteSExprString(this._value)}`];
11160
- for (const page of this._pages) {
11161
- lines.push(page.getStringIndented());
11162
- }
11163
- lines.push(")");
11164
- return lines.join("\n");
11165
- }
11166
- };
11167
- SxClass.register(SheetInstancesRootPath);
11168
- var SheetInstancesRootPage = class _SheetInstancesRootPage extends SxPrimitiveString {
11169
- static token = "page";
11170
- static parentToken = "sheet_instances_path";
11171
- token = "page";
11172
- static fromSexprPrimitives(primitiveSexprs) {
11173
- const [valuePrimitive] = primitiveSexprs;
11174
- const value = toStringValue(valuePrimitive);
11175
- if (value === void 0) {
11176
- throw new Error("sheet_instances page expects a string value");
11177
- }
11178
- return new _SheetInstancesRootPage(value);
11179
- }
11180
- getString() {
11181
- return `(page ${quoteSExprString(this.value)})`;
11182
- }
11183
- };
11184
- SxClass.register(SheetInstancesRootPage);
11185
-
11186
11252
  // lib/sexpr/classes/Setup/base.ts
11187
11253
  var SingleValueProperty = class extends SxClass {
11188
11254
  _value;
@@ -14168,6 +14234,7 @@ export {
14168
14234
  SheetInstancePage,
14169
14235
  SheetInstancePath,
14170
14236
  SheetInstances,
14237
+ SheetInstancesForSheet,
14171
14238
  SheetInstancesProject,
14172
14239
  SheetInstancesRoot,
14173
14240
  SheetInstancesRootPage,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kicadts",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",