kicadts 0.0.7 → 0.0.8

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 +48 -37
  2. package/dist/index.js +206 -144
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -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
@@ -4133,34 +4133,215 @@ var Property = class _Property extends SxClass {
4133
4133
  };
4134
4134
  SxClass.register(Property);
4135
4135
 
4136
+ // lib/sexpr/classes/SheetInstancesRoot.ts
4137
+ var SUPPORTED_ARRAY_TOKENS2 = /* @__PURE__ */ new Set(["page"]);
4138
+ var SheetInstancesRoot = class _SheetInstancesRoot extends SxClass {
4139
+ static token = "sheet_instances";
4140
+ token = "sheet_instances";
4141
+ _paths = [];
4142
+ static fromSexprPrimitives(primitiveSexprs) {
4143
+ const sheetInstances = new _SheetInstancesRoot();
4144
+ const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token);
4145
+ const unsupportedSingularTokens = Object.keys(propertyMap).filter(
4146
+ (token) => token !== "path"
4147
+ );
4148
+ if (unsupportedSingularTokens.length > 0) {
4149
+ throw new Error(
4150
+ `Unsupported singular child tokens inside sheet_instances expression: ${unsupportedSingularTokens.join(", ")}`
4151
+ );
4152
+ }
4153
+ const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
4154
+ (token) => token !== "path"
4155
+ );
4156
+ if (unsupportedArrayTokens.length > 0) {
4157
+ throw new Error(
4158
+ `Unsupported repeated child tokens inside sheet_instances expression: ${unsupportedArrayTokens.join(", ")}`
4159
+ );
4160
+ }
4161
+ const paths = arrayPropertyMap.path ?? [];
4162
+ if (!paths.length && propertyMap.path) {
4163
+ paths.push(propertyMap.path);
4164
+ }
4165
+ sheetInstances._paths = paths;
4166
+ return sheetInstances;
4167
+ }
4168
+ get paths() {
4169
+ return [...this._paths];
4170
+ }
4171
+ set paths(value) {
4172
+ this._paths = [...value];
4173
+ }
4174
+ getChildren() {
4175
+ return [...this._paths];
4176
+ }
4177
+ };
4178
+ SxClass.register(SheetInstancesRoot);
4179
+ var SheetInstancesRootPath = class _SheetInstancesRootPath extends SxClass {
4180
+ static token = "path";
4181
+ static parentToken = "sheet_instances";
4182
+ token = "path";
4183
+ _value = "";
4184
+ _pages = [];
4185
+ static fromSexprPrimitives(primitiveSexprs) {
4186
+ const [valuePrimitive, ...rest] = primitiveSexprs;
4187
+ const value = toStringValue(valuePrimitive);
4188
+ if (value === void 0) {
4189
+ throw new Error("sheet_instances path requires a string identifier");
4190
+ }
4191
+ const path = new _SheetInstancesRootPath();
4192
+ path._value = value;
4193
+ const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(rest, "sheet_instances_path");
4194
+ const unsupportedSingularTokens = Object.keys(propertyMap).filter(
4195
+ (token) => !SUPPORTED_ARRAY_TOKENS2.has(token)
4196
+ );
4197
+ if (unsupportedSingularTokens.length > 0) {
4198
+ throw new Error(
4199
+ `Unsupported singular child tokens inside sheet_instances path expression: ${unsupportedSingularTokens.join(", ")}`
4200
+ );
4201
+ }
4202
+ const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
4203
+ (token) => !SUPPORTED_ARRAY_TOKENS2.has(token)
4204
+ );
4205
+ if (unsupportedArrayTokens.length > 0) {
4206
+ throw new Error(
4207
+ `Unsupported repeated child tokens inside sheet_instances path expression: ${unsupportedArrayTokens.join(", ")}`
4208
+ );
4209
+ }
4210
+ const pages = arrayPropertyMap.page ?? [];
4211
+ if (!pages.length && propertyMap.page) {
4212
+ pages.push(propertyMap.page);
4213
+ }
4214
+ path._pages = pages;
4215
+ return path;
4216
+ }
4217
+ get value() {
4218
+ return this._value;
4219
+ }
4220
+ set value(newValue) {
4221
+ this._value = newValue;
4222
+ }
4223
+ get pages() {
4224
+ return [...this._pages];
4225
+ }
4226
+ set pages(value) {
4227
+ this._pages = [...value];
4228
+ }
4229
+ getChildren() {
4230
+ return [...this._pages];
4231
+ }
4232
+ getString() {
4233
+ const lines = [`(path ${quoteSExprString(this._value)}`];
4234
+ for (const page of this._pages) {
4235
+ lines.push(page.getStringIndented());
4236
+ }
4237
+ lines.push(")");
4238
+ return lines.join("\n");
4239
+ }
4240
+ };
4241
+ SxClass.register(SheetInstancesRootPath);
4242
+ var SheetInstancesRootPage = class _SheetInstancesRootPage extends SxPrimitiveString {
4243
+ static token = "page";
4244
+ static parentToken = "sheet_instances_path";
4245
+ token = "page";
4246
+ static fromSexprPrimitives(primitiveSexprs) {
4247
+ const [valuePrimitive] = primitiveSexprs;
4248
+ const value = toStringValue(valuePrimitive);
4249
+ if (value === void 0) {
4250
+ throw new Error("sheet_instances page expects a string value");
4251
+ }
4252
+ return new _SheetInstancesRootPage(value);
4253
+ }
4254
+ getString() {
4255
+ return `(page ${quoteSExprString(this.value)})`;
4256
+ }
4257
+ };
4258
+ SxClass.register(SheetInstancesRootPage);
4259
+
4136
4260
  // lib/sexpr/classes/SheetInstances.ts
4261
+ var SUPPORTED_CHILD_TOKENS = /* @__PURE__ */ new Set(["project", "path"]);
4262
+ var parseSheetInstancesChildren = (primitiveSexprs) => {
4263
+ const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(primitiveSexprs, "sheet_instances");
4264
+ const unsupportedSingularTokens = Object.keys(propertyMap).filter(
4265
+ (token) => !SUPPORTED_CHILD_TOKENS.has(token)
4266
+ );
4267
+ if (unsupportedSingularTokens.length > 0) {
4268
+ throw new Error(
4269
+ `sheet_instances encountered unsupported child token${unsupportedSingularTokens.length > 1 ? "s" : ""} ${unsupportedSingularTokens.map((token) => `"${token}"`).join(", ")}`
4270
+ );
4271
+ }
4272
+ const unsupportedArrayTokens = Object.keys(arrayPropertyMap).filter(
4273
+ (token) => !SUPPORTED_CHILD_TOKENS.has(token)
4274
+ );
4275
+ if (unsupportedArrayTokens.length > 0) {
4276
+ throw new Error(
4277
+ `sheet_instances encountered unsupported repeated child token${unsupportedArrayTokens.length > 1 ? "s" : ""} ${unsupportedArrayTokens.map((token) => `"${token}"`).join(", ")}`
4278
+ );
4279
+ }
4280
+ const projects = arrayPropertyMap.project ?? [];
4281
+ if (!projects.length && propertyMap.project) {
4282
+ projects.push(propertyMap.project);
4283
+ }
4284
+ const paths = arrayPropertyMap.path ?? [];
4285
+ if (!paths.length && propertyMap.path) {
4286
+ paths.push(propertyMap.path);
4287
+ }
4288
+ return { projects, paths };
4289
+ };
4137
4290
  var SheetInstances = class _SheetInstances extends SxClass {
4138
4291
  static token = "sheet_instances";
4139
4292
  static parentToken = "kicad_sch";
4140
4293
  token = "sheet_instances";
4141
- projects = [];
4294
+ _projects = [];
4295
+ _paths = [];
4142
4296
  static fromSexprPrimitives(primitiveSexprs) {
4143
4297
  const instances = new _SheetInstances();
4144
- const { arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(
4145
- primitiveSexprs,
4146
- "sheet_instances"
4147
- );
4148
- instances.projects = arrayPropertyMap.project ?? [];
4298
+ const { projects, paths } = parseSheetInstancesChildren(primitiveSexprs);
4299
+ instances.projects = projects;
4300
+ instances.paths = paths;
4149
4301
  return instances;
4150
4302
  }
4303
+ get projects() {
4304
+ return [...this._projects];
4305
+ }
4306
+ set projects(value) {
4307
+ this._projects = [...value];
4308
+ }
4309
+ get paths() {
4310
+ return [...this._paths];
4311
+ }
4312
+ set paths(value) {
4313
+ this._paths = [...value];
4314
+ }
4151
4315
  getChildren() {
4152
- return [...this.projects];
4316
+ return [...this._projects, ...this._paths];
4153
4317
  }
4154
4318
  getString() {
4155
- const lines = ["(sheet_instances"];
4156
- for (const project of this.projects) {
4157
- lines.push(project.getStringIndented());
4319
+ const children = this.getChildren();
4320
+ if (children.length === 0) {
4321
+ return `(${this.token})`;
4322
+ }
4323
+ const lines = [`(${this.token}`];
4324
+ for (const child of children) {
4325
+ lines.push(child.getStringIndented());
4158
4326
  }
4159
4327
  lines.push(")");
4160
4328
  return lines.join("\n");
4161
4329
  }
4162
4330
  };
4163
4331
  SxClass.register(SheetInstances);
4332
+ var SheetInstancesForSheet = class _SheetInstancesForSheet extends SheetInstances {
4333
+ static token = "instances";
4334
+ static parentToken = "sheet";
4335
+ token = "instances";
4336
+ static fromSexprPrimitives(primitiveSexprs) {
4337
+ const instances = new _SheetInstancesForSheet();
4338
+ const { projects, paths } = parseSheetInstancesChildren(primitiveSexprs);
4339
+ instances.projects = projects;
4340
+ instances.paths = paths;
4341
+ return instances;
4342
+ }
4343
+ };
4344
+ SxClass.register(SheetInstancesForSheet);
4164
4345
  var SheetInstancesProject = class _SheetInstancesProject extends SxClass {
4165
4346
  static token = "project";
4166
4347
  static parentToken = "sheet_instances";
@@ -4678,7 +4859,6 @@ var SINGLE_CHILD_TOKENS = /* @__PURE__ */ new Set([
4678
4859
  "paper",
4679
4860
  "title_block",
4680
4861
  "lib_symbols",
4681
- "sheet_instances",
4682
4862
  "embedded_fonts"
4683
4863
  ]);
4684
4864
  var MULTI_CHILD_TOKENS = /* @__PURE__ */ new Set([
@@ -4689,9 +4869,10 @@ var MULTI_CHILD_TOKENS = /* @__PURE__ */ new Set([
4689
4869
  "text",
4690
4870
  "label",
4691
4871
  "junction",
4692
- "wire"
4872
+ "wire",
4873
+ "sheet_instances"
4693
4874
  ]);
4694
- var SUPPORTED_CHILD_TOKENS = /* @__PURE__ */ new Set([
4875
+ var SUPPORTED_CHILD_TOKENS2 = /* @__PURE__ */ new Set([
4695
4876
  ...SINGLE_CHILD_TOKENS,
4696
4877
  ...MULTI_CHILD_TOKENS
4697
4878
  ]);
@@ -4705,7 +4886,7 @@ var KicadSch = class _KicadSch extends SxClass {
4705
4886
  _sxPaper;
4706
4887
  _sxTitleBlock;
4707
4888
  _sxLibSymbols;
4708
- _sxSheetInstances;
4889
+ _sheetInstances = [];
4709
4890
  _sxEmbeddedFonts;
4710
4891
  _properties = [];
4711
4892
  _images = [];
@@ -4790,14 +4971,14 @@ var KicadSch = class _KicadSch extends SxClass {
4790
4971
  }
4791
4972
  const { propertyMap, arrayPropertyMap } = SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token);
4792
4973
  for (const token of Object.keys(propertyMap)) {
4793
- if (!SUPPORTED_CHILD_TOKENS.has(token)) {
4974
+ if (!SUPPORTED_CHILD_TOKENS2.has(token)) {
4794
4975
  throw new Error(
4795
4976
  `kicad_sch encountered unsupported child token "${token}"`
4796
4977
  );
4797
4978
  }
4798
4979
  }
4799
4980
  for (const [token, entries] of Object.entries(arrayPropertyMap)) {
4800
- if (!SUPPORTED_CHILD_TOKENS.has(token)) {
4981
+ if (!SUPPORTED_CHILD_TOKENS2.has(token)) {
4801
4982
  throw new Error(
4802
4983
  `kicad_sch encountered unsupported child token "${token}"`
4803
4984
  );
@@ -4816,7 +4997,7 @@ var KicadSch = class _KicadSch extends SxClass {
4816
4997
  paper: propertyMap.paper,
4817
4998
  titleBlock: propertyMap.title_block,
4818
4999
  libSymbols: propertyMap.lib_symbols,
4819
- sheetInstances: propertyMap.sheet_instances,
5000
+ sheetInstances: arrayPropertyMap.sheet_instances,
4820
5001
  embeddedFonts: propertyMap.embedded_fonts,
4821
5002
  properties: arrayPropertyMap.property ?? [],
4822
5003
  images: arrayPropertyMap.image ?? [],
@@ -4875,10 +5056,14 @@ var KicadSch = class _KicadSch extends SxClass {
4875
5056
  this._sxLibSymbols = value;
4876
5057
  }
4877
5058
  get sheetInstances() {
4878
- return this._sxSheetInstances;
5059
+ return [...this._sheetInstances];
4879
5060
  }
4880
5061
  set sheetInstances(value) {
4881
- this._sxSheetInstances = value;
5062
+ if (value === void 0) {
5063
+ this._sheetInstances = [];
5064
+ return;
5065
+ }
5066
+ this._sheetInstances = Array.isArray(value) ? [...value] : [value];
4882
5067
  }
4883
5068
  get embeddedFonts() {
4884
5069
  return this._sxEmbeddedFonts;
@@ -4943,7 +5128,7 @@ var KicadSch = class _KicadSch extends SxClass {
4943
5128
  if (this._sxPaper) children.push(this._sxPaper);
4944
5129
  if (this._sxTitleBlock) children.push(this._sxTitleBlock);
4945
5130
  if (this._sxLibSymbols) children.push(this._sxLibSymbols);
4946
- if (this._sxSheetInstances) children.push(this._sxSheetInstances);
5131
+ children.push(...this._sheetInstances);
4947
5132
  if (this._sxEmbeddedFonts) children.push(this._sxEmbeddedFonts);
4948
5133
  children.push(...this._properties);
4949
5134
  children.push(...this._images);
@@ -11059,130 +11244,6 @@ var Layers = class _Layers extends SxClass {
11059
11244
  };
11060
11245
  SxClass.register(Layers);
11061
11246
 
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
11247
  // lib/sexpr/classes/Setup/base.ts
11187
11248
  var SingleValueProperty = class extends SxClass {
11188
11249
  _value;
@@ -14168,6 +14229,7 @@ export {
14168
14229
  SheetInstancePage,
14169
14230
  SheetInstancePath,
14170
14231
  SheetInstances,
14232
+ SheetInstancesForSheet,
14171
14233
  SheetInstancesProject,
14172
14234
  SheetInstancesRoot,
14173
14235
  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.8",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",