circuitscript 0.0.25 → 0.0.27

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 (51) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/BaseVisitor.js +16 -12
  3. package/dist/cjs/SemanticTokenVisitor.js +3 -3
  4. package/dist/cjs/antlr/CircuitScriptLexer.js +189 -166
  5. package/dist/cjs/antlr/CircuitScriptParser.js +1295 -719
  6. package/dist/cjs/draw_symbols.js +42 -14
  7. package/dist/cjs/execute.js +91 -30
  8. package/dist/cjs/export.js +91 -5
  9. package/dist/cjs/geometry.js +45 -26
  10. package/dist/cjs/globals.js +1 -2
  11. package/dist/cjs/helpers.js +6 -2
  12. package/dist/cjs/layout.js +37 -17
  13. package/dist/cjs/main.js +21 -9
  14. package/dist/cjs/objects/ClassComponent.js +8 -0
  15. package/dist/cjs/objects/types.js +8 -1
  16. package/dist/cjs/render.js +1 -1
  17. package/dist/cjs/visitor.js +131 -23
  18. package/dist/esm/BaseVisitor.mjs +17 -13
  19. package/dist/esm/SemanticTokenVisitor.mjs +3 -3
  20. package/dist/esm/antlr/CircuitScriptLexer.mjs +189 -166
  21. package/dist/esm/antlr/CircuitScriptParser.mjs +1287 -716
  22. package/dist/esm/antlr/CircuitScriptVisitor.mjs +6 -1
  23. package/dist/esm/draw_symbols.mjs +44 -16
  24. package/dist/esm/execute.mjs +90 -26
  25. package/dist/esm/export.mjs +89 -6
  26. package/dist/esm/geometry.mjs +44 -25
  27. package/dist/esm/globals.mjs +1 -2
  28. package/dist/esm/helpers.mjs +7 -3
  29. package/dist/esm/layout.mjs +35 -16
  30. package/dist/esm/main.mjs +21 -9
  31. package/dist/esm/objects/ClassComponent.mjs +8 -0
  32. package/dist/esm/objects/types.mjs +7 -0
  33. package/dist/esm/render.mjs +2 -2
  34. package/dist/esm/visitor.mjs +133 -25
  35. package/dist/types/BaseVisitor.d.ts +2 -5
  36. package/dist/types/SemanticTokenVisitor.d.ts +2 -2
  37. package/dist/types/antlr/CircuitScriptLexer.d.ts +29 -22
  38. package/dist/types/antlr/CircuitScriptParser.d.ts +121 -44
  39. package/dist/types/antlr/CircuitScriptVisitor.d.ts +12 -2
  40. package/dist/types/draw_symbols.d.ts +11 -6
  41. package/dist/types/execute.d.ts +6 -4
  42. package/dist/types/export.d.ts +27 -1
  43. package/dist/types/geometry.d.ts +12 -9
  44. package/dist/types/globals.d.ts +2 -3
  45. package/dist/types/layout.d.ts +5 -0
  46. package/dist/types/objects/ClassComponent.d.ts +5 -0
  47. package/dist/types/objects/Wire.d.ts +2 -1
  48. package/dist/types/objects/types.d.ts +6 -0
  49. package/dist/types/visitor.d.ts +7 -3
  50. package/libs/lib.cst +28 -10
  51. package/package.json +1 -1
@@ -26,30 +26,37 @@ export declare class CircuitScriptParser extends antlr.Parser {
26
26
  static readonly Define = 22;
27
27
  static readonly Import = 23;
28
28
  static readonly If = 24;
29
- static readonly Not = 25;
30
- static readonly Frame = 26;
31
- static readonly Equals = 27;
32
- static readonly NotEquals = 28;
33
- static readonly Addition = 29;
34
- static readonly Minus = 30;
35
- static readonly Divide = 31;
36
- static readonly Multiply = 32;
37
- static readonly OPEN_PAREN = 33;
38
- static readonly CLOSE_PAREN = 34;
39
- static readonly NOT_CONNECTED = 35;
40
- static readonly BOOLEAN_VALUE = 36;
41
- static readonly ID = 37;
42
- static readonly INTEGER_VALUE = 38;
43
- static readonly DECIMAL_VALUE = 39;
44
- static readonly NUMERIC_VALUE = 40;
45
- static readonly STRING_VALUE = 41;
46
- static readonly PERCENTAGE_VALUE = 42;
47
- static readonly ALPHA_NUMERIC = 43;
48
- static readonly WS = 44;
49
- static readonly NEWLINE = 45;
50
- static readonly COMMENT = 46;
51
- static readonly INDENT = 47;
52
- static readonly DEDENT = 48;
29
+ static readonly Else = 25;
30
+ static readonly Not = 26;
31
+ static readonly Frame = 27;
32
+ static readonly Equals = 28;
33
+ static readonly NotEquals = 29;
34
+ static readonly GreaterThan = 30;
35
+ static readonly GreatOrEqualThan = 31;
36
+ static readonly LessThan = 32;
37
+ static readonly LessOrEqualThan = 33;
38
+ static readonly LogicalAnd = 34;
39
+ static readonly LogicalOr = 35;
40
+ static readonly Addition = 36;
41
+ static readonly Minus = 37;
42
+ static readonly Divide = 38;
43
+ static readonly Multiply = 39;
44
+ static readonly OPEN_PAREN = 40;
45
+ static readonly CLOSE_PAREN = 41;
46
+ static readonly NOT_CONNECTED = 42;
47
+ static readonly BOOLEAN_VALUE = 43;
48
+ static readonly ID = 44;
49
+ static readonly INTEGER_VALUE = 45;
50
+ static readonly DECIMAL_VALUE = 46;
51
+ static readonly NUMERIC_VALUE = 47;
52
+ static readonly STRING_VALUE = 48;
53
+ static readonly PERCENTAGE_VALUE = 49;
54
+ static readonly ALPHA_NUMERIC = 50;
55
+ static readonly WS = 51;
56
+ static readonly NEWLINE = 52;
57
+ static readonly COMMENT = 53;
58
+ static readonly INDENT = 54;
59
+ static readonly DEDENT = 55;
53
60
  static readonly RULE_script = 0;
54
61
  static readonly RULE_expression = 1;
55
62
  static readonly RULE_path_blocks = 2;
@@ -92,16 +99,20 @@ export declare class CircuitScriptParser extends antlr.Parser {
92
99
  static readonly RULE_function_return_expr = 39;
93
100
  static readonly RULE_create_component_expr = 40;
94
101
  static readonly RULE_create_graphic_expr = 41;
95
- static readonly RULE_sub_expr = 42;
96
- static readonly RULE_property_expr = 43;
97
- static readonly RULE_property_key_expr = 44;
98
- static readonly RULE_property_value_expr = 45;
99
- static readonly RULE_blank_expr = 46;
100
- static readonly RULE_wire_atom_expr = 47;
101
- static readonly RULE_wire_expr = 48;
102
- static readonly RULE_point_expr = 49;
103
- static readonly RULE_import_expr = 50;
104
- static readonly RULE_frame_expr = 51;
102
+ static readonly RULE_nested_properties_inner = 42;
103
+ static readonly RULE_graphic_expr = 43;
104
+ static readonly RULE_property_expr = 44;
105
+ static readonly RULE_property_key_expr = 45;
106
+ static readonly RULE_property_value_expr = 46;
107
+ static readonly RULE_blank_expr = 47;
108
+ static readonly RULE_wire_atom_expr = 48;
109
+ static readonly RULE_wire_expr = 49;
110
+ static readonly RULE_point_expr = 50;
111
+ static readonly RULE_import_expr = 51;
112
+ static readonly RULE_frame_expr = 52;
113
+ static readonly RULE_if_expr = 53;
114
+ static readonly RULE_if_inner_expr = 54;
115
+ static readonly RULE_else_expr = 55;
105
116
  static readonly literalNames: (string | null)[];
106
117
  static readonly symbolicNames: (string | null)[];
107
118
  static readonly ruleNames: string[];
@@ -155,7 +166,8 @@ export declare class CircuitScriptParser extends antlr.Parser {
155
166
  function_return_expr(): Function_return_exprContext;
156
167
  create_component_expr(): Create_component_exprContext;
157
168
  create_graphic_expr(): Create_graphic_exprContext;
158
- sub_expr(): Sub_exprContext;
169
+ nested_properties_inner(): Nested_properties_innerContext;
170
+ graphic_expr(): Graphic_exprContext;
159
171
  property_expr(): Property_exprContext;
160
172
  property_key_expr(): Property_key_exprContext;
161
173
  property_value_expr(): Property_value_exprContext;
@@ -165,6 +177,9 @@ export declare class CircuitScriptParser extends antlr.Parser {
165
177
  point_expr(): Point_exprContext;
166
178
  import_expr(): Import_exprContext;
167
179
  frame_expr(): Frame_exprContext;
180
+ if_expr(): If_exprContext;
181
+ if_inner_expr(): If_inner_exprContext;
182
+ else_expr(): Else_exprContext;
168
183
  sempred(localContext: antlr.ParserRuleContext | null, ruleIndex: number, predIndex: number): boolean;
169
184
  private data_expr_sempred;
170
185
  static readonly _serializedATN: number[];
@@ -203,6 +218,7 @@ export declare class ExpressionContext extends antlr.ParserRuleContext {
203
218
  at_block(): At_blockContext | null;
204
219
  path_blocks(): Path_blocksContext | null;
205
220
  point_expr(): Point_exprContext | null;
221
+ if_expr(): If_exprContext | null;
206
222
  get ruleIndex(): number;
207
223
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
208
224
  }
@@ -456,6 +472,14 @@ export declare class MultiplyExprContext extends Data_exprContext {
456
472
  Divide(): antlr.TerminalNode | null;
457
473
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
458
474
  }
475
+ export declare class LogicalOperatorExprContext extends Data_exprContext {
476
+ constructor(ctx: Data_exprContext);
477
+ data_expr(): Data_exprContext[];
478
+ data_expr(i: number): Data_exprContext | null;
479
+ LogicalAnd(): antlr.TerminalNode | null;
480
+ LogicalOr(): antlr.TerminalNode | null;
481
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
482
+ }
459
483
  export declare class DataExprContext extends Data_exprContext {
460
484
  constructor(ctx: Data_exprContext);
461
485
  create_component_expr(): Create_component_exprContext | null;
@@ -492,6 +516,10 @@ export declare class Binary_operatorContext extends antlr.ParserRuleContext {
492
516
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
493
517
  Equals(): antlr.TerminalNode | null;
494
518
  NotEquals(): antlr.TerminalNode | null;
519
+ GreaterThan(): antlr.TerminalNode | null;
520
+ GreatOrEqualThan(): antlr.TerminalNode | null;
521
+ LessThan(): antlr.TerminalNode | null;
522
+ LessOrEqualThan(): antlr.TerminalNode | null;
495
523
  get ruleIndex(): number;
496
524
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
497
525
  }
@@ -608,12 +636,23 @@ export declare class Create_graphic_exprContext extends antlr.ParserRuleContext
608
636
  NEWLINE(i: number): antlr.TerminalNode | null;
609
637
  INDENT(): antlr.TerminalNode;
610
638
  DEDENT(): antlr.TerminalNode;
611
- sub_expr(): Sub_exprContext[];
612
- sub_expr(i: number): Sub_exprContext | null;
639
+ graphic_expr(): Graphic_exprContext[];
640
+ graphic_expr(i: number): Graphic_exprContext | null;
641
+ get ruleIndex(): number;
642
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
643
+ }
644
+ export declare class Nested_properties_innerContext extends antlr.ParserRuleContext {
645
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
646
+ NEWLINE(): antlr.TerminalNode[];
647
+ NEWLINE(i: number): antlr.TerminalNode | null;
648
+ INDENT(): antlr.TerminalNode | null;
649
+ DEDENT(): antlr.TerminalNode | null;
650
+ property_expr(): Property_exprContext[];
651
+ property_expr(i: number): Property_exprContext | null;
613
652
  get ruleIndex(): number;
614
653
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
615
654
  }
616
- export declare class Sub_exprContext extends antlr.ParserRuleContext {
655
+ export declare class Graphic_exprContext extends antlr.ParserRuleContext {
617
656
  _command?: Token | null;
618
657
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
619
658
  ID(): antlr.TerminalNode | null;
@@ -621,6 +660,7 @@ export declare class Sub_exprContext extends antlr.ParserRuleContext {
621
660
  parameters(): ParametersContext | null;
622
661
  OPEN_PAREN(): antlr.TerminalNode | null;
623
662
  CLOSE_PAREN(): antlr.TerminalNode | null;
663
+ nested_properties_inner(): Nested_properties_innerContext | null;
624
664
  get ruleIndex(): number;
625
665
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
626
666
  }
@@ -652,12 +692,7 @@ export declare class Single_line_propertyContext extends Property_value_exprCont
652
692
  }
653
693
  export declare class Nested_propertiesContext extends Property_value_exprContext {
654
694
  constructor(ctx: Property_value_exprContext);
655
- NEWLINE(): antlr.TerminalNode[];
656
- NEWLINE(i: number): antlr.TerminalNode | null;
657
- INDENT(): antlr.TerminalNode;
658
- DEDENT(): antlr.TerminalNode;
659
- property_expr(): Property_exprContext[];
660
- property_expr(i: number): Property_exprContext | null;
695
+ nested_properties_inner(): Nested_properties_innerContext;
661
696
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
662
697
  }
663
698
  export declare class Blank_exprContext extends antlr.ParserRuleContext {
@@ -717,3 +752,45 @@ export declare class Frame_exprContext extends antlr.ParserRuleContext {
717
752
  get ruleIndex(): number;
718
753
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
719
754
  }
755
+ export declare class If_exprContext extends antlr.ParserRuleContext {
756
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
757
+ If(): antlr.TerminalNode;
758
+ data_expr(): Data_exprContext;
759
+ NEWLINE(): antlr.TerminalNode[];
760
+ NEWLINE(i: number): antlr.TerminalNode | null;
761
+ INDENT(): antlr.TerminalNode;
762
+ DEDENT(): antlr.TerminalNode;
763
+ expression(): ExpressionContext[];
764
+ expression(i: number): ExpressionContext | null;
765
+ if_inner_expr(): If_inner_exprContext[];
766
+ if_inner_expr(i: number): If_inner_exprContext | null;
767
+ else_expr(): Else_exprContext | null;
768
+ get ruleIndex(): number;
769
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
770
+ }
771
+ export declare class If_inner_exprContext extends antlr.ParserRuleContext {
772
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
773
+ Else(): antlr.TerminalNode;
774
+ If(): antlr.TerminalNode;
775
+ data_expr(): Data_exprContext;
776
+ NEWLINE(): antlr.TerminalNode[];
777
+ NEWLINE(i: number): antlr.TerminalNode | null;
778
+ INDENT(): antlr.TerminalNode;
779
+ DEDENT(): antlr.TerminalNode;
780
+ expression(): ExpressionContext[];
781
+ expression(i: number): ExpressionContext | null;
782
+ get ruleIndex(): number;
783
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
784
+ }
785
+ export declare class Else_exprContext extends antlr.ParserRuleContext {
786
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
787
+ Else(): antlr.TerminalNode;
788
+ NEWLINE(): antlr.TerminalNode[];
789
+ NEWLINE(i: number): antlr.TerminalNode | null;
790
+ INDENT(): antlr.TerminalNode;
791
+ DEDENT(): antlr.TerminalNode;
792
+ expression(): ExpressionContext[];
793
+ expression(i: number): ExpressionContext | null;
794
+ get ruleIndex(): number;
795
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
796
+ }
@@ -30,6 +30,7 @@ import { Double_dot_property_set_exprContext } from "./CircuitScriptParser.js";
30
30
  import { FunctionCallExprContext } from "./CircuitScriptParser.js";
31
31
  import { AdditionExprContext } from "./CircuitScriptParser.js";
32
32
  import { MultiplyExprContext } from "./CircuitScriptParser.js";
33
+ import { LogicalOperatorExprContext } from "./CircuitScriptParser.js";
33
34
  import { DataExprContext } from "./CircuitScriptParser.js";
34
35
  import { UnaryOperatorExprContext } from "./CircuitScriptParser.js";
35
36
  import { ValueAtomExprContext } from "./CircuitScriptParser.js";
@@ -48,7 +49,8 @@ import { Net_namespace_exprContext } from "./CircuitScriptParser.js";
48
49
  import { Function_return_exprContext } from "./CircuitScriptParser.js";
49
50
  import { Create_component_exprContext } from "./CircuitScriptParser.js";
50
51
  import { Create_graphic_exprContext } from "./CircuitScriptParser.js";
51
- import { Sub_exprContext } from "./CircuitScriptParser.js";
52
+ import { Nested_properties_innerContext } from "./CircuitScriptParser.js";
53
+ import { Graphic_exprContext } from "./CircuitScriptParser.js";
52
54
  import { Property_exprContext } from "./CircuitScriptParser.js";
53
55
  import { Property_key_exprContext } from "./CircuitScriptParser.js";
54
56
  import { Nested_propertiesContext } from "./CircuitScriptParser.js";
@@ -60,6 +62,9 @@ import { Wire_exprContext } from "./CircuitScriptParser.js";
60
62
  import { Point_exprContext } from "./CircuitScriptParser.js";
61
63
  import { Import_exprContext } from "./CircuitScriptParser.js";
62
64
  import { Frame_exprContext } from "./CircuitScriptParser.js";
65
+ import { If_exprContext } from "./CircuitScriptParser.js";
66
+ import { If_inner_exprContext } from "./CircuitScriptParser.js";
67
+ import { Else_exprContext } from "./CircuitScriptParser.js";
63
68
  export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisitor<Result> {
64
69
  visitScript?: (ctx: ScriptContext) => Result;
65
70
  visitExpression?: (ctx: ExpressionContext) => Result;
@@ -92,6 +97,7 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
92
97
  visitFunctionCallExpr?: (ctx: FunctionCallExprContext) => Result;
93
98
  visitAdditionExpr?: (ctx: AdditionExprContext) => Result;
94
99
  visitMultiplyExpr?: (ctx: MultiplyExprContext) => Result;
100
+ visitLogicalOperatorExpr?: (ctx: LogicalOperatorExprContext) => Result;
95
101
  visitDataExpr?: (ctx: DataExprContext) => Result;
96
102
  visitUnaryOperatorExpr?: (ctx: UnaryOperatorExprContext) => Result;
97
103
  visitValueAtomExpr?: (ctx: ValueAtomExprContext) => Result;
@@ -110,7 +116,8 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
110
116
  visitFunction_return_expr?: (ctx: Function_return_exprContext) => Result;
111
117
  visitCreate_component_expr?: (ctx: Create_component_exprContext) => Result;
112
118
  visitCreate_graphic_expr?: (ctx: Create_graphic_exprContext) => Result;
113
- visitSub_expr?: (ctx: Sub_exprContext) => Result;
119
+ visitNested_properties_inner?: (ctx: Nested_properties_innerContext) => Result;
120
+ visitGraphic_expr?: (ctx: Graphic_exprContext) => Result;
114
121
  visitProperty_expr?: (ctx: Property_exprContext) => Result;
115
122
  visitProperty_key_expr?: (ctx: Property_key_exprContext) => Result;
116
123
  visitNested_properties?: (ctx: Nested_propertiesContext) => Result;
@@ -122,4 +129,7 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
122
129
  visitPoint_expr?: (ctx: Point_exprContext) => Result;
123
130
  visitImport_expr?: (ctx: Import_exprContext) => Result;
124
131
  visitFrame_expr?: (ctx: Frame_exprContext) => Result;
132
+ visitIf_expr?: (ctx: If_exprContext) => Result;
133
+ visitIf_inner_expr?: (ctx: If_inner_exprContext) => Result;
134
+ visitElse_expr?: (ctx: Else_exprContext) => Result;
125
135
  }
@@ -1,5 +1,5 @@
1
1
  import { G } from "@svgdotjs/svg.js";
2
- import { Feature, GeometryProp, HorizontalAlign, Label, LabelStyle, VerticalAlign } from "./geometry.js";
2
+ import { Feature, GeometryProp, HorizontalAlign, LabelStyle, Textbox, VerticalAlign } from "./geometry.js";
3
3
  import { Logger } from "./logger.js";
4
4
  export declare abstract class SymbolGraphic {
5
5
  drawPortsName: boolean;
@@ -56,6 +56,9 @@ export declare class SymbolText extends SymbolGraphic {
56
56
  }
57
57
  export declare class SymbolPlaceholder extends SymbolGraphic {
58
58
  generateDrawing(): void;
59
+ parseLabelStyle(keywordParams: Map<string, any>): {
60
+ [key: string]: any;
61
+ };
59
62
  drawPinParams(drawing: SymbolDrawingCommands, commandName: string, keywordParams: Map<string, any>, positionParams: any[]): void;
60
63
  constructor(drawing: SymbolDrawing);
61
64
  }
@@ -74,7 +77,8 @@ export declare enum PlaceHolderCommands {
74
77
  path = "path",
75
78
  lineWidth = "lineWidth",
76
79
  fill = "fill",
77
- lineColor = "lineColor"
80
+ lineColor = "lineColor",
81
+ text = "text"
78
82
  }
79
83
  export declare class SymbolCustom extends SymbolGraphic {
80
84
  pinDefinition: SymbolPinDefintion[];
@@ -110,6 +114,7 @@ export declare class SymbolDrawing {
110
114
  addRect2(x: number, y: number, x2: number, y2: number): SymbolDrawing;
111
115
  addLabel(x: number, y: number, textValue: string, style: LabelStyle): SymbolDrawing;
112
116
  addLabelId(id: string, x: number, y: number, textValue: string, style: LabelStyle): SymbolDrawing;
117
+ addTextbox(x: number, y: number, textValue: string, style: LabelStyle): SymbolDrawing;
113
118
  addPath(...pathParts: any): SymbolDrawing;
114
119
  addSetLineWidth(value: number): SymbolDrawing;
115
120
  addSetLineColor(value: string): SymbolDrawing;
@@ -122,7 +127,7 @@ export declare class SymbolDrawing {
122
127
  lineWidth: number;
123
128
  }[];
124
129
  getPinsPath(): string;
125
- getLabels(): Label[];
130
+ getLabels(): Textbox[];
126
131
  private featuresToPath;
127
132
  getBoundingBox(excludeLabels?: boolean): {
128
133
  width: number;
@@ -136,7 +141,7 @@ export declare class SymbolDrawing {
136
141
  angle: number;
137
142
  };
138
143
  }
139
- export type SubExpressionCommand = [
144
+ export type GraphicExprCommand = [
140
145
  commandName: string,
141
146
  positionParams: any[],
142
147
  keywordParams: Map<string, any>
@@ -144,8 +149,8 @@ export type SubExpressionCommand = [
144
149
  export declare class SymbolDrawingCommands extends SymbolDrawing {
145
150
  id: string;
146
151
  private commands;
147
- constructor(commands: SubExpressionCommand[]);
148
- getCommands(): SubExpressionCommand[];
152
+ constructor(commands: GraphicExprCommand[]);
153
+ getCommands(): GraphicExprCommand[];
149
154
  clone(): SymbolDrawingCommands;
150
155
  }
151
156
  type SimplePoint = [x: number, y: number];
@@ -23,6 +23,7 @@ export declare class ExecutionContext {
23
23
  logger: Logger;
24
24
  __functionCache: {};
25
25
  parentContext: ExecutionContext;
26
+ componentAngleFollowsWire: boolean;
26
27
  constructor(name: string, namespace: string, netNamespace: string, executionLevel: number | undefined, indentLevel: number | undefined, silent: boolean | undefined, logger: Logger, parent: ExecutionContext);
27
28
  log(...params: any[]): void;
28
29
  private setupRoot;
@@ -36,6 +37,9 @@ export declare class ExecutionContext {
36
37
  display?: string;
37
38
  type?: string;
38
39
  width?: number;
40
+ copy: boolean;
41
+ angle?: number;
42
+ followWireOrientation: boolean;
39
43
  }): ClassComponent;
40
44
  printPoint(extra?: string): void;
41
45
  addComponentExisting(component: ClassComponent, pin: number): ComponentPin;
@@ -45,7 +49,7 @@ export declare class ExecutionContext {
45
49
  atComponent(component: ClassComponent, pinId: number | null, options?: {
46
50
  addSequence?: boolean;
47
51
  }): ComponentPin;
48
- cloneComponent(component: ClassComponent): ClassComponent;
52
+ copyComponent(component: ClassComponent): ClassComponent;
49
53
  enterBlocks(blockType: BlockTypes): void;
50
54
  exitBlocks(): void;
51
55
  enterBlock(blockIndex: number): void;
@@ -66,12 +70,10 @@ export declare class ExecutionContext {
66
70
  setCurrentComponentStyle(styles: {
67
71
  [key: string]: number | string;
68
72
  }): void;
73
+ applyComponentAngleFromWire(component: ClassComponent, pin: number): void;
69
74
  enterFrame(): number;
70
75
  exitFrame(frameId: number): void;
71
76
  }
72
- export declare function isNetComponent(component: ClassComponent): boolean;
73
- export declare function isLabelComponent(component: ClassComponent): boolean;
74
- export declare function isNetOnlyComponent(component: ClassComponent): boolean;
75
77
  export declare function getPortSide(pins: Map<number, PinDefinition>, arrangeProps: null | Map<string, number[]>): PortSideItem[];
76
78
  type PortSideItem = {
77
79
  pinId: number;
@@ -1,2 +1,28 @@
1
1
  import { NetListItem } from "./visitor.js";
2
- export declare function generateKiCADNetList(netlist: NetListItem[]): string;
2
+ export declare function generateKiCADNetList(netlist: NetListItem[]): {
3
+ tree: SExp;
4
+ missingFootprints: {
5
+ refdes: string;
6
+ instanceName: string;
7
+ }[];
8
+ };
9
+ export declare function printTree(tree: (IdObject | string)[] | string, level?: number): string;
10
+ export declare class IdObject {
11
+ keyName: string;
12
+ constructor(keyName: string);
13
+ }
14
+ export declare function _id(key: string): IdObject;
15
+ export declare class SExpObject {
16
+ object: SExp;
17
+ constructor(object: SExp);
18
+ getKey(object?: SExp | null): IdObject;
19
+ getValue(object?: SExp | null): any;
20
+ getJSON(object?: SExp | null): {
21
+ [key: string]: any;
22
+ };
23
+ getWithId(id: string, object?: SExp | null): SExp | null;
24
+ print(): void;
25
+ }
26
+ export type SExpString = [id: IdObject, string];
27
+ export type SExpNested = [id: IdObject, SExp];
28
+ export type SExp = [id: IdObject, ...(SExpString | SExpNested)[]];
@@ -5,7 +5,7 @@ export type Polygon = Flatten.Polygon;
5
5
  export type Multiline = Flatten.Multiline;
6
6
  export type Line = Flatten.Line;
7
7
  export type Arc = Flatten.Arc;
8
- export type Feature = Segment | Polygon | Label | Arc | Multiline;
8
+ export type Feature = Segment | Polygon | Label | Textbox | Arc | Multiline;
9
9
  export type LabelStyle = {
10
10
  font?: string;
11
11
  fontSize?: number;
@@ -14,7 +14,7 @@ export type LabelStyle = {
14
14
  anchor?: HorizontalAlign.Left | HorizontalAlign.Middle | HorizontalAlign.Right;
15
15
  vanchor?: VerticalAlign.Top | VerticalAlign.Middle | VerticalAlign.Bottom;
16
16
  };
17
- export declare class Label extends Flatten.Polygon {
17
+ export declare class Textbox extends Flatten.Polygon {
18
18
  id: string;
19
19
  text: string;
20
20
  anchorPoint: [number, number];
@@ -26,13 +26,16 @@ export declare class Label extends Flatten.Polygon {
26
26
  font: string;
27
27
  style: LabelStyle;
28
28
  textMeasurementBounds: Box;
29
+ label: boolean;
29
30
  get box(): Flatten.Box;
30
- constructor(id: string, text: string, anchorPoint: [number, number], polygon: Flatten.Polygon, style: LabelStyle, bounds: Box);
31
- static fromPoint(id: string, x: number, y: number, text: string, style: LabelStyle): Label;
32
- rotate(angle: number, origin: Flatten.Point): Label;
33
- transform(matrix: Flatten.Matrix): Label;
31
+ constructor(id: string, text: string, anchorPoint: [number, number], polygon: Flatten.Polygon, style: LabelStyle, bounds: Box, label: boolean);
32
+ static fromPoint(id: string, x: number, y: number, text: string, style: LabelStyle, label: boolean): Textbox;
33
+ rotate(angle: number, origin: Flatten.Point): Textbox;
34
+ transform(matrix: Flatten.Matrix): Textbox;
34
35
  getLabelPosition(): [number, number];
35
36
  }
37
+ export declare class Label extends Textbox {
38
+ }
36
39
  export declare class GeometryProp {
37
40
  name: string;
38
41
  value: string | number;
@@ -41,7 +44,8 @@ export declare class GeometryProp {
41
44
  export declare class Geometry {
42
45
  static point(x: number, y: number): Flatten.Point;
43
46
  static line(x1: number, y1: number, x2: number, y2: number): Flatten.Line;
44
- static label(id: string, x: number, y: number, text: string, style: LabelStyle): Label;
47
+ static label(id: string, x: number, y: number, text: string, style: LabelStyle): Textbox;
48
+ static textbox(id: string | null, x: number, y: number, text: string, style: LabelStyle): Textbox;
45
49
  static segment(start: [number, number], end: [number, number]): Segment;
46
50
  static polygon(coords: [number, number][]): Polygon;
47
51
  static multiline(coords: [number, number][]): Multiline;
@@ -57,9 +61,8 @@ export declare class Geometry {
57
61
  width: number;
58
62
  height: number;
59
63
  };
60
- static getType(feature: Feature): string;
61
64
  static FullCircleRadians: number;
62
- static featuresToPath(items: Feature[]): {
65
+ static featuresToPath(items: Feature[], flipX: number, flipY: number): {
63
66
  path: string;
64
67
  isClosedPolygon: boolean;
65
68
  };
@@ -8,8 +8,6 @@ export declare enum GlobalNames {
8
8
  }
9
9
  export declare const NoNetText = "NO_NET";
10
10
  export declare enum ParamKeys {
11
- __is_net = "__is_net",
12
- __is_label = "__is_label",
13
11
  priority = "priority",
14
12
  net_name = "net_name"
15
13
  }
@@ -40,7 +38,8 @@ export declare enum ReferenceTypes {
40
38
  function = "function",
41
39
  value = "value",
42
40
  variable = "variable",
43
- instance = "instance"
41
+ instance = "instance",
42
+ pinType = "pinType"
44
43
  }
45
44
  export declare enum BlockTypes {
46
45
  Branch = 1,
@@ -139,6 +139,11 @@ export declare class RenderJunction {
139
139
  y: number;
140
140
  constructor(x: number, y: number);
141
141
  }
142
+ export declare function CalculatePinPositions(component: ClassComponent): Map<number, {
143
+ x: number;
144
+ y: number;
145
+ angle: number;
146
+ }>;
142
147
  type SubGraphInfo = {
143
148
  firstNodeId: string;
144
149
  components: string[];
@@ -18,6 +18,11 @@ export declare class ClassComponent {
18
18
  displayProp: string | SymbolDrawingCommands | null;
19
19
  widthProp: number | null;
20
20
  typeProp: string | null;
21
+ copyProp: boolean;
22
+ angleProp: number;
23
+ followWireOrientationProp: boolean;
24
+ wireOrientationAngle: number;
25
+ useWireOrientationAngle: boolean;
21
26
  styles: {
22
27
  [key: string]: number | string;
23
28
  };
@@ -1,10 +1,11 @@
1
1
  import { ClassComponent } from "./ClassComponent.js";
2
+ import { Direction } from "./types.js";
2
3
  export declare class Wire {
3
4
  path: WireSegment[];
4
5
  constructor(path: WireSegment[]);
5
6
  }
6
7
  export type WireSegment = {
7
- direction: 'up' | 'down' | 'left' | 'right' | 'auto' | 'auto_';
8
+ direction: Direction.Up | Direction.Down | Direction.Left | Direction.Right | 'auto' | 'auto_';
8
9
  value: number;
9
10
  valueXY?: [x: number, y: number];
10
11
  until?: [instance: ClassComponent, pin: number];
@@ -52,3 +52,9 @@ export declare enum ParseSymbolType {
52
52
  Function = "function",
53
53
  Undefined = "undefined"
54
54
  }
55
+ export declare enum Direction {
56
+ Left = "left",
57
+ Right = "right",
58
+ Down = "down",
59
+ Up = "up"
60
+ }
@@ -1,4 +1,4 @@
1
- import { Add_component_exprContext, AdditionExprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, BinaryOperatorExprContext, Path_blocksContext, Component_select_exprContext, Create_component_exprContext, Create_graphic_exprContext, DataExprContext, Data_expr_with_assignmentContext, Double_dot_property_set_exprContext, Frame_exprContext, Function_def_exprContext, Keyword_assignment_exprContext, MultiplyExprContext, Nested_propertiesContext, Net_namespace_exprContext, Pin_select_expr2Context, Pin_select_exprContext, Point_exprContext, Property_exprContext, Property_key_exprContext, Property_set_exprContext, Single_line_propertyContext, Sub_exprContext, To_component_exprContext, Wire_exprContext, UnaryOperatorExprContext, Wire_expr_direction_onlyContext, Wire_expr_direction_valueContext } from './antlr/CircuitScriptParser.js';
1
+ import { Add_component_exprContext, AdditionExprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, BinaryOperatorExprContext, Path_blocksContext, Component_select_exprContext, Create_component_exprContext, Create_graphic_exprContext, DataExprContext, Data_expr_with_assignmentContext, Double_dot_property_set_exprContext, Frame_exprContext, Function_def_exprContext, Keyword_assignment_exprContext, MultiplyExprContext, Nested_propertiesContext, Net_namespace_exprContext, Pin_select_expr2Context, Pin_select_exprContext, Point_exprContext, Property_exprContext, Property_key_exprContext, Property_set_exprContext, Single_line_propertyContext, To_component_exprContext, Wire_exprContext, UnaryOperatorExprContext, Wire_expr_direction_onlyContext, Wire_expr_direction_valueContext, Graphic_exprContext, If_exprContext, If_inner_exprContext, LogicalOperatorExprContext, Nested_properties_innerContext } from './antlr/CircuitScriptParser.js';
2
2
  import { ClassComponent } from './objects/ClassComponent.js';
3
3
  import { PinTypes } from './objects/PinTypes.js';
4
4
  import { ComponentPin, ComponentPinNet } from './objects/types.js';
@@ -8,22 +8,24 @@ import { ParserRuleContext } from 'antlr4ng';
8
8
  export declare class ParserVisitor extends BaseVisitor {
9
9
  visitKeyword_assignment_expr: (ctx: Keyword_assignment_exprContext) => void;
10
10
  visitPin_select_expr: (ctx: Pin_select_exprContext) => void;
11
- visitAdd_component_expr: (ctx: Add_component_exprContext) => ComponentPin;
11
+ visitAdd_component_expr: (ctx: Add_component_exprContext) => void;
12
12
  visitAt_component_expr: (ctx: At_component_exprContext) => ComponentPin;
13
13
  visitTo_component_expr: (ctx: To_component_exprContext) => ComponentPin;
14
14
  visitComponent_select_expr: (ctx: Component_select_exprContext) => void;
15
15
  visitPath_blocks: (ctx: Path_blocksContext) => ComponentPin;
16
16
  visitCreate_component_expr: (ctx: Create_component_exprContext) => void;
17
17
  visitCreate_graphic_expr: (ctx: Create_graphic_exprContext) => void;
18
- visitSub_expr: (ctx: Sub_exprContext) => void;
18
+ visitGraphic_expr: (ctx: Graphic_exprContext) => void;
19
19
  visitProperty_expr: (ctx: Property_exprContext) => void;
20
20
  visitSingle_line_property: (ctx: Single_line_propertyContext) => void;
21
+ visitNested_properties_inner: (ctx: Nested_properties_innerContext) => void;
21
22
  visitNested_properties: (ctx: Nested_propertiesContext) => void;
22
23
  visitProperty_key_expr: (ctx: Property_key_exprContext) => void;
23
24
  visitData_expr_with_assignment: (ctx: Data_expr_with_assignmentContext) => void;
24
25
  visitUnaryOperatorExpr: (ctx: UnaryOperatorExprContext) => void;
25
26
  visitDataExpr: (ctx: DataExprContext) => void;
26
27
  visitBinaryOperatorExpr: (ctx: BinaryOperatorExprContext) => void;
28
+ visitLogicalOperatorExpr: (ctx: LogicalOperatorExprContext) => void;
27
29
  visitMultiplyExpr: (ctx: MultiplyExprContext) => void;
28
30
  visitAdditionExpr: (ctx: AdditionExprContext) => void;
29
31
  visitFunction_def_expr: (ctx: Function_def_exprContext) => void;
@@ -40,6 +42,8 @@ export declare class ParserVisitor extends BaseVisitor {
40
42
  visitDouble_dot_property_set_expr: (ctx: Double_dot_property_set_exprContext) => void;
41
43
  visitFrame_expr: (ctx: Frame_exprContext) => void;
42
44
  visitNet_namespace_expr: (ctx: Net_namespace_exprContext) => void;
45
+ visitIf_expr: (ctx: If_exprContext) => void;
46
+ visitIf_inner_expr: (ctx: If_inner_exprContext) => void;
43
47
  pinTypes: PinTypes[];
44
48
  private parseCreateComponentPins;
45
49
  private parseCreateComponentParams;