circuitscript 0.0.38 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseVisitor.js +69 -46
- package/dist/cjs/SymbolValidatorVisitor.js +1 -1
- package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
- package/dist/cjs/antlr/CircuitScriptParser.js +580 -613
- package/dist/cjs/builtinMethods.js +32 -10
- package/dist/cjs/draw_symbols.js +375 -233
- package/dist/cjs/execute.js +142 -131
- package/dist/cjs/export.js +2 -4
- package/dist/cjs/geometry.js +52 -19
- package/dist/cjs/globals.js +14 -9
- package/dist/cjs/helpers.js +16 -3
- package/dist/cjs/layout.js +143 -151
- package/dist/cjs/logger.js +8 -1
- package/dist/cjs/objects/ClassComponent.js +22 -22
- package/dist/cjs/objects/ExecutionScope.js +10 -4
- package/dist/cjs/objects/Frame.js +4 -1
- package/dist/cjs/objects/ParamDefinition.js +120 -4
- package/dist/cjs/objects/PinDefinition.js +1 -4
- package/dist/cjs/objects/types.js +41 -0
- package/dist/cjs/render.js +41 -110
- package/dist/cjs/sizing.js +33 -7
- package/dist/cjs/utils.js +92 -2
- package/dist/cjs/visitor.js +279 -284
- package/dist/esm/BaseVisitor.mjs +70 -47
- package/dist/esm/SymbolValidatorVisitor.mjs +1 -1
- package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
- package/dist/esm/antlr/CircuitScriptParser.mjs +580 -613
- package/dist/esm/builtinMethods.mjs +29 -10
- package/dist/esm/draw_symbols.mjs +381 -238
- package/dist/esm/execute.mjs +144 -133
- package/dist/esm/export.mjs +2 -4
- package/dist/esm/geometry.mjs +52 -19
- package/dist/esm/globals.mjs +13 -8
- package/dist/esm/helpers.mjs +17 -4
- package/dist/esm/layout.mjs +144 -153
- package/dist/esm/logger.mjs +8 -1
- package/dist/esm/objects/ClassComponent.mjs +21 -26
- package/dist/esm/objects/ExecutionScope.mjs +10 -4
- package/dist/esm/objects/Frame.mjs +4 -1
- package/dist/esm/objects/ParamDefinition.mjs +119 -3
- package/dist/esm/objects/PinDefinition.mjs +0 -2
- package/dist/esm/objects/types.mjs +42 -0
- package/dist/esm/render.mjs +44 -113
- package/dist/esm/sizing.mjs +34 -8
- package/dist/esm/utils.mjs +86 -1
- package/dist/esm/visitor.mjs +281 -286
- package/dist/types/BaseVisitor.d.ts +3 -2
- package/dist/types/antlr/CircuitScriptParser.d.ts +5 -3
- package/dist/types/draw_symbols.d.ts +81 -49
- package/dist/types/execute.d.ts +16 -11
- package/dist/types/geometry.d.ts +31 -19
- package/dist/types/globals.d.ts +15 -10
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/layout.d.ts +22 -21
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +19 -16
- package/dist/types/objects/ExecutionScope.d.ts +2 -1
- package/dist/types/objects/Frame.d.ts +5 -3
- package/dist/types/objects/ParamDefinition.d.ts +31 -2
- package/dist/types/objects/PinDefinition.d.ts +0 -2
- package/dist/types/objects/types.d.ts +7 -2
- package/dist/types/render.d.ts +2 -1
- package/dist/types/utils.d.ts +9 -1
- package/dist/types/visitor.d.ts +5 -5
- package/libs/lib.cst +102 -32
- package/package.json +7 -3
|
@@ -17,7 +17,6 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
17
17
|
printStream: string[];
|
|
18
18
|
printToConsole: boolean;
|
|
19
19
|
acceptedDirections: Direction[];
|
|
20
|
-
acceptedFlip: string[];
|
|
21
20
|
protected resultData: Map<ParserRuleContext, any>;
|
|
22
21
|
protected paramData: Map<ParserRuleContext, any>;
|
|
23
22
|
pinTypesList: string[];
|
|
@@ -54,7 +53,8 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
54
53
|
visitArrayExpr: (ctx: ArrayExprContext) => void;
|
|
55
54
|
protected setResult(ctx: ParserRuleContext, value: any): void;
|
|
56
55
|
protected getResult(ctx: ParserRuleContext): any;
|
|
57
|
-
protected
|
|
56
|
+
protected visitResult(ctx: ParserRuleContext): any;
|
|
57
|
+
protected handleImportFile(name: string, throwErrors?: boolean, ctx?: ParserRuleContext | null): {
|
|
58
58
|
hasError: boolean;
|
|
59
59
|
hasParseError: boolean;
|
|
60
60
|
pathExists: boolean;
|
|
@@ -67,5 +67,6 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
67
67
|
protected getInstanceParam<T>(object: ClassComponent, trailers: string[]): T;
|
|
68
68
|
protected enterNewChildContext(executionStack: ExecutionContext[], parentContext: ExecutionContext, executionContextName: string, options: CFunctionOptions, funcDefinedParameters: FunctionDefinedParameter[], passedInParameters: CallableParameter[]): ExecutionContext;
|
|
69
69
|
protected prepareStringValue(value: string): string;
|
|
70
|
+
protected throwWithContext(context: ParserRuleContext, message: string): void;
|
|
70
71
|
}
|
|
71
72
|
export type OnErrorCallback = (line: number, column: number, message: string, e: any | undefined) => void;
|
|
@@ -339,6 +339,7 @@ export declare class Component_select_exprContext extends antlr.ParserRuleContex
|
|
|
339
339
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
340
340
|
data_expr_with_assignment(): Data_expr_with_assignmentContext | null;
|
|
341
341
|
pin_select_expr(): Pin_select_exprContext | null;
|
|
342
|
+
Point(): antlr.TerminalNode | null;
|
|
342
343
|
get ruleIndex(): number;
|
|
343
344
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
344
345
|
}
|
|
@@ -352,15 +353,13 @@ export declare class Pin_select_expr2Context extends antlr.ParserRuleContext {
|
|
|
352
353
|
export declare class At_component_exprContext extends antlr.ParserRuleContext {
|
|
353
354
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
354
355
|
At(): antlr.TerminalNode;
|
|
355
|
-
component_select_expr(): Component_select_exprContext
|
|
356
|
-
Point(): antlr.TerminalNode | null;
|
|
356
|
+
component_select_expr(): Component_select_exprContext;
|
|
357
357
|
get ruleIndex(): number;
|
|
358
358
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
359
359
|
}
|
|
360
360
|
export declare class To_component_exprContext extends antlr.ParserRuleContext {
|
|
361
361
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
362
362
|
To(): antlr.TerminalNode;
|
|
363
|
-
Point(): antlr.TerminalNode | null;
|
|
364
363
|
component_select_expr(): Component_select_exprContext[];
|
|
365
364
|
component_select_expr(i: number): Component_select_exprContext | null;
|
|
366
365
|
get ruleIndex(): number;
|
|
@@ -708,6 +707,9 @@ export declare class Create_graphic_exprContext extends antlr.ParserRuleContext
|
|
|
708
707
|
Create(): antlr.TerminalNode;
|
|
709
708
|
Graphic(): antlr.TerminalNode;
|
|
710
709
|
graphic_expressions_block(): Graphic_expressions_blockContext;
|
|
710
|
+
OPEN_PAREN(): antlr.TerminalNode | null;
|
|
711
|
+
ID(): antlr.TerminalNode | null;
|
|
712
|
+
CLOSE_PAREN(): antlr.TerminalNode | null;
|
|
711
713
|
get ruleIndex(): number;
|
|
712
714
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
713
715
|
}
|
|
@@ -2,6 +2,8 @@ import { G } from "@svgdotjs/svg.js";
|
|
|
2
2
|
import { Feature, GeometryProp, HorizontalAlign, LabelStyle, Textbox, VerticalAlign } from "./geometry.js";
|
|
3
3
|
import { Logger } from "./logger.js";
|
|
4
4
|
import { PinTypes } from "./objects/PinTypes.js";
|
|
5
|
+
import { ParserRuleContext } from "antlr4ng";
|
|
6
|
+
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
5
7
|
export declare abstract class SymbolGraphic {
|
|
6
8
|
drawPortsName: boolean;
|
|
7
9
|
displayBounds: boolean;
|
|
@@ -9,9 +11,10 @@ export declare abstract class SymbolGraphic {
|
|
|
9
11
|
_angle: number;
|
|
10
12
|
_flipX: number;
|
|
11
13
|
_flipY: number;
|
|
12
|
-
width:
|
|
13
|
-
height:
|
|
14
|
+
width: NumericValue;
|
|
15
|
+
height: NumericValue;
|
|
14
16
|
labelTexts: Map<string, string>;
|
|
17
|
+
constructor();
|
|
15
18
|
get angle(): number;
|
|
16
19
|
set angle(value: number);
|
|
17
20
|
get flipX(): number;
|
|
@@ -19,7 +22,12 @@ export declare abstract class SymbolGraphic {
|
|
|
19
22
|
get flipY(): number;
|
|
20
23
|
set flipY(value: number);
|
|
21
24
|
refreshDrawing(calculateSize?: boolean): void;
|
|
22
|
-
calculateSize():
|
|
25
|
+
calculateSize(): {
|
|
26
|
+
bodyWidth: NumericValue;
|
|
27
|
+
bodyHeight: NumericValue;
|
|
28
|
+
width: NumericValue;
|
|
29
|
+
height: NumericValue;
|
|
30
|
+
};
|
|
23
31
|
abstract generateDrawing(): void;
|
|
24
32
|
size(): {
|
|
25
33
|
width: number;
|
|
@@ -30,9 +38,9 @@ export declare abstract class SymbolGraphic {
|
|
|
30
38
|
place?: boolean;
|
|
31
39
|
}): void;
|
|
32
40
|
pinPosition(id: number): {
|
|
33
|
-
x:
|
|
34
|
-
y:
|
|
35
|
-
angle:
|
|
41
|
+
x: NumericValue;
|
|
42
|
+
y: NumericValue;
|
|
43
|
+
angle: NumericValue;
|
|
36
44
|
};
|
|
37
45
|
protected drawBounds(group: G): void;
|
|
38
46
|
protected drawBody(group: G): void;
|
|
@@ -40,22 +48,17 @@ export declare abstract class SymbolGraphic {
|
|
|
40
48
|
protected drawLabels(group: G): void;
|
|
41
49
|
flipTextAnchor(value: HorizontalAlign): HorizontalAlign;
|
|
42
50
|
flipDominantBaseline(value: VerticalAlign): VerticalAlign;
|
|
43
|
-
setLabelValue(labelId: string, labelValue: string): void;
|
|
44
|
-
getLabelValue(labelId: string): string;
|
|
45
|
-
}
|
|
46
|
-
export declare function SymbolFactory(name: string): SymbolGraphic;
|
|
47
|
-
export declare class SymbolPointHidden extends SymbolGraphic {
|
|
48
|
-
generateDrawing(): void;
|
|
49
51
|
}
|
|
50
52
|
export declare class SymbolText extends SymbolGraphic {
|
|
51
53
|
text: string;
|
|
52
|
-
fontSize:
|
|
54
|
+
fontSize: NumericValue;
|
|
53
55
|
fontWeight: string;
|
|
54
56
|
constructor(text: string);
|
|
55
57
|
generateDrawing(): void;
|
|
56
58
|
}
|
|
57
59
|
export declare class SymbolPlaceholder extends SymbolGraphic {
|
|
58
60
|
generateDrawing(): void;
|
|
61
|
+
private resolveReference;
|
|
59
62
|
parseLabelStyle(keywordParams: Map<string, any>): {
|
|
60
63
|
[key: string]: any;
|
|
61
64
|
};
|
|
@@ -85,61 +88,85 @@ export declare enum PlaceHolderCommands {
|
|
|
85
88
|
}
|
|
86
89
|
export declare class SymbolCustom extends SymbolGraphic {
|
|
87
90
|
pinDefinition: SymbolPinDefintion[];
|
|
88
|
-
bodyWidth:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
bodyWidth: NumericValue;
|
|
92
|
+
bodyHeight: NumericValue;
|
|
93
|
+
pinLength: NumericValue;
|
|
94
|
+
width: NumericValue;
|
|
95
|
+
height: NumericValue;
|
|
96
|
+
pinSpacing: NumericValue;
|
|
97
|
+
pinTextPadding: NumericValue;
|
|
94
98
|
pins: SymbolPinLayout[];
|
|
95
99
|
_cacheLeftPins: SymbolPinDefintion[];
|
|
96
100
|
_cacheRightPins: SymbolPinDefintion[];
|
|
97
|
-
|
|
101
|
+
_cacheTopPins: SymbolPinDefintion[];
|
|
102
|
+
_cacheBottomPins: SymbolPinDefintion[];
|
|
103
|
+
pinMaxPositions: {
|
|
104
|
+
[key: string]: number;
|
|
105
|
+
};
|
|
106
|
+
constructor(pinDefinition: SymbolPinDefintion[], pinMaxPositions: {
|
|
107
|
+
[key: string]: number;
|
|
108
|
+
});
|
|
98
109
|
generateDrawing(): void;
|
|
99
|
-
|
|
100
|
-
|
|
110
|
+
private getPins;
|
|
111
|
+
generateDrawingPins(drawing: SymbolDrawing, bodyWidthMM: NumericValue, bodyHeightMM: NumericValue, pins: {
|
|
112
|
+
left: SymbolPinDefintion[];
|
|
113
|
+
right: SymbolPinDefintion[];
|
|
114
|
+
top: SymbolPinDefintion[];
|
|
115
|
+
bottom: SymbolPinDefintion[];
|
|
116
|
+
}, defaultLineColor: string): void;
|
|
117
|
+
calculateSize(): {
|
|
118
|
+
bodyWidth: NumericValue;
|
|
119
|
+
bodyHeight: NumericValue;
|
|
120
|
+
width: NumericValue;
|
|
121
|
+
height: NumericValue;
|
|
122
|
+
};
|
|
101
123
|
}
|
|
102
124
|
export declare class SymbolCustomModule extends SymbolCustom {
|
|
103
|
-
pinLength:
|
|
104
|
-
portWidth:
|
|
105
|
-
portHeight:
|
|
106
|
-
generateDrawingPins(drawing: SymbolDrawing, bodyWidthMM:
|
|
125
|
+
pinLength: NumericValue;
|
|
126
|
+
portWidth: NumericValue;
|
|
127
|
+
portHeight: NumericValue;
|
|
128
|
+
generateDrawingPins(drawing: SymbolDrawing, bodyWidthMM: NumericValue, bodyHeightMM: NumericValue, pins: {
|
|
129
|
+
left: SymbolPinDefintion[];
|
|
130
|
+
right: SymbolPinDefintion[];
|
|
131
|
+
top: SymbolPinDefintion[];
|
|
132
|
+
bottom: SymbolPinDefintion[];
|
|
133
|
+
}, defaultLineColor: string): void;
|
|
107
134
|
}
|
|
108
135
|
export declare class SymbolDrawing {
|
|
109
136
|
items: (Feature | GeometryProp)[];
|
|
110
|
-
pins: [
|
|
137
|
+
pins: [NumericValue, Feature, angle: NumericValue, lineColor: string][];
|
|
111
138
|
angle: number;
|
|
112
139
|
flipX: number;
|
|
113
140
|
flipY: number;
|
|
114
|
-
mainOrigin: [
|
|
141
|
+
mainOrigin: [x: NumericValue, y: NumericValue];
|
|
115
142
|
logger: Logger;
|
|
143
|
+
variables: Map<string, any>;
|
|
116
144
|
clear(): void;
|
|
117
145
|
log(...params: any[]): void;
|
|
118
|
-
addLine(startX:
|
|
119
|
-
addPin(pinId:
|
|
120
|
-
addPinMM(pinId:
|
|
121
|
-
addVLine(startX:
|
|
122
|
-
addHLine(startX:
|
|
123
|
-
addRect(centerX:
|
|
124
|
-
addRectMM(centerX:
|
|
125
|
-
addTriangle(startX:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
addModulePort(x: number, y: number, width: number, height: number, portType?: PinTypes, scaleX?: number): SymbolDrawing;
|
|
146
|
+
addLine(startX: NumericValue, startY: NumericValue, endX: NumericValue, endY: NumericValue): SymbolDrawing;
|
|
147
|
+
addPin(pinId: NumericValue, startX: NumericValue, startY: NumericValue, endX: NumericValue, endY: NumericValue, lineColor: string): SymbolDrawing;
|
|
148
|
+
addPinMM(pinId: NumericValue, startXMM: NumericValue, startYMM: NumericValue, endXMM: NumericValue, endYMM: NumericValue, lineColor: string): SymbolDrawing;
|
|
149
|
+
addVLine(startX: NumericValue, startY: NumericValue, value: NumericValue): SymbolDrawing;
|
|
150
|
+
addHLine(startX: NumericValue, startY: NumericValue, value: NumericValue): SymbolDrawing;
|
|
151
|
+
addRect(centerX: NumericValue, centerY: NumericValue, width: NumericValue, height: NumericValue): SymbolDrawing;
|
|
152
|
+
addRectMM(centerX: NumericValue, centerY: NumericValue, width: NumericValue, height: NumericValue): SymbolDrawing;
|
|
153
|
+
addTriangle(startX: NumericValue, startY: NumericValue, endX: NumericValue, endY: NumericValue, width: NumericValue): SymbolDrawing;
|
|
154
|
+
addLabel(x: NumericValue, y: NumericValue, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
155
|
+
addLabelMils(x: NumericValue, y: NumericValue, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
156
|
+
addTextbox(x: NumericValue, y: NumericValue, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
157
|
+
addModulePort(x: NumericValue, y: NumericValue, width: NumericValue, height: NumericValue, portType?: PinTypes, scaleX?: number, angle?: number): SymbolDrawing;
|
|
131
158
|
addPath(...pathParts: any): SymbolDrawing;
|
|
132
|
-
addSetLineWidth(value:
|
|
159
|
+
addSetLineWidth(value: NumericValue): SymbolDrawing;
|
|
133
160
|
addSetLineColor(value: string): SymbolDrawing;
|
|
134
161
|
addSetTextColor(value: string): SymbolDrawing;
|
|
135
162
|
addSetFillColor(value: string): SymbolDrawing;
|
|
136
|
-
addArc(x:
|
|
163
|
+
addArc(x: NumericValue, y: NumericValue, radius: NumericValue, startAngle: NumericValue, endAngle: NumericValue): SymbolDrawing;
|
|
137
164
|
addSetUnits(value: string): SymbolDrawing;
|
|
138
165
|
getPaths(): {
|
|
139
166
|
path: string;
|
|
140
167
|
fillColor: string;
|
|
141
168
|
lineColor: string;
|
|
142
|
-
lineWidth:
|
|
169
|
+
lineWidth: NumericValue;
|
|
143
170
|
}[];
|
|
144
171
|
getPinsPath(): {
|
|
145
172
|
path: string;
|
|
@@ -154,22 +181,27 @@ export declare class SymbolDrawing {
|
|
|
154
181
|
end: SimplePoint;
|
|
155
182
|
};
|
|
156
183
|
getPinPosition(pinId: number): {
|
|
157
|
-
start: [
|
|
158
|
-
end: [
|
|
159
|
-
angle:
|
|
184
|
+
start: [x: NumericValue, y: NumericValue];
|
|
185
|
+
end: [x: NumericValue, y: NumericValue];
|
|
186
|
+
angle: NumericValue;
|
|
160
187
|
};
|
|
161
188
|
}
|
|
162
189
|
export type GraphicExprCommand = [
|
|
163
190
|
commandName: string,
|
|
164
191
|
positionParams: any[],
|
|
165
|
-
keywordParams: Map<string, any
|
|
192
|
+
keywordParams: Map<string, any>,
|
|
193
|
+
ctx: ParserRuleContext
|
|
166
194
|
];
|
|
167
195
|
export declare class SymbolDrawingCommands extends SymbolDrawing {
|
|
168
196
|
id: string;
|
|
169
197
|
private commands;
|
|
170
|
-
|
|
198
|
+
paramIds: string[];
|
|
199
|
+
callback: (variables: Map<string, any>) => GraphicExprCommand[];
|
|
200
|
+
constructor(callback: (variables: Map<string, any>) => GraphicExprCommand[]);
|
|
201
|
+
runCommands(): void;
|
|
171
202
|
getCommands(): GraphicExprCommand[];
|
|
172
203
|
clone(): SymbolDrawingCommands;
|
|
204
|
+
eq(other: SymbolDrawingCommands): boolean;
|
|
173
205
|
}
|
|
174
206
|
type SimplePoint = [x: number, y: number];
|
|
175
207
|
type SymbolPinLayout = {
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { BlockTypes, FrameType } from './globals.js';
|
|
|
2
2
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
3
3
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
4
4
|
import { Net } from './objects/Net.js';
|
|
5
|
-
import { ParamDefinition } from './objects/ParamDefinition.js';
|
|
5
|
+
import { NumericValue, ParamDefinition } from './objects/ParamDefinition.js';
|
|
6
6
|
import { PinDefinition } from './objects/PinDefinition.js';
|
|
7
7
|
import { CFunction, CFunctionResult, CallableParameter, ComponentPin, DeclaredReference } from './objects/types.js';
|
|
8
8
|
import { Logger } from './logger.js';
|
|
9
9
|
import { UnitDimension } from './helpers.js';
|
|
10
10
|
import { ParserRuleContext } from 'antlr4ng';
|
|
11
|
+
import { SymbolDrawingCommands } from './draw_symbols.js';
|
|
11
12
|
export declare class ExecutionContext {
|
|
12
13
|
name: string;
|
|
13
14
|
namespace: string;
|
|
@@ -29,20 +30,21 @@ export declare class ExecutionContext {
|
|
|
29
30
|
constructor(name: string, namespace: string, netNamespace: string, executionLevel: number | undefined, indentLevel: number | undefined, silent: boolean | undefined, logger: Logger, parent: ExecutionContext);
|
|
30
31
|
log(...params: any[]): void;
|
|
31
32
|
private setupRoot;
|
|
32
|
-
getUniqueInstanceName(
|
|
33
|
-
getUniqueNetName
|
|
33
|
+
getUniqueInstanceName(): string;
|
|
34
|
+
private getUniqueNetName;
|
|
34
35
|
getCurrentPoint(): ComponentPin;
|
|
35
36
|
private linkComponentPinNet;
|
|
36
37
|
private mergeNets;
|
|
37
38
|
createComponent(instanceName: string, pins: PinDefinition[], params: ParamDefinition[], props: {
|
|
38
39
|
arrange?: Map<string, number[]>;
|
|
39
|
-
display?:
|
|
40
|
+
display?: SymbolDrawingCommands;
|
|
40
41
|
type?: string;
|
|
41
42
|
width?: number;
|
|
43
|
+
height?: number;
|
|
42
44
|
copy: boolean;
|
|
43
|
-
angle?:
|
|
45
|
+
angle?: NumericValue;
|
|
44
46
|
followWireOrientation: boolean;
|
|
45
|
-
}): ClassComponent;
|
|
47
|
+
}, isModule?: boolean): ClassComponent;
|
|
46
48
|
printPoint(extra?: string): void;
|
|
47
49
|
addComponentExisting(component: ClassComponent, pin: number): ComponentPin;
|
|
48
50
|
toComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
@@ -65,20 +67,23 @@ export declare class ExecutionContext {
|
|
|
65
67
|
createFunction(functionName: string, __runFunc: CFunction): void;
|
|
66
68
|
hasFunction(functionName: string): boolean;
|
|
67
69
|
getFunction(functionName: string): CFunction;
|
|
68
|
-
resolveVariable(executionStack: ExecutionContext[], idName: string): DeclaredReference;
|
|
70
|
+
resolveVariable(executionStack: ExecutionContext[], idName: string, trailers?: string[]): DeclaredReference;
|
|
69
71
|
callFunction(functionName: string, functionParams: CallableParameter[], executionStack: ExecutionContext[], netNamespace: string): CFunctionResult;
|
|
70
72
|
mergeScope(childScope: ExecutionScope, namespace: string): void;
|
|
71
73
|
addWire(segments: [string, (number | UnitDimension)?][]): void;
|
|
72
74
|
addPoint(pointId: string, userDefined?: boolean): ComponentPin;
|
|
75
|
+
private getPointSymbol;
|
|
73
76
|
setProperty(nameWithProp: string, value: any): void;
|
|
74
|
-
setCurrentComponentStyle(styles: {
|
|
75
|
-
[key: string]: number | string;
|
|
76
|
-
}): void;
|
|
77
77
|
applyComponentAngleFromWire(component: ClassComponent, pin: number, opposite?: boolean): void;
|
|
78
78
|
enterFrame(frameType: FrameType): number;
|
|
79
79
|
exitFrame(frameId: number): void;
|
|
80
80
|
}
|
|
81
|
-
export declare function getPortSide(pins: Map<number, PinDefinition>, arrangeProps: null | Map<string, number[]>):
|
|
81
|
+
export declare function getPortSide(pins: Map<number, PinDefinition>, arrangeProps: null | Map<string, number[]>): {
|
|
82
|
+
pins: PortSideItem[];
|
|
83
|
+
maxPositions: {
|
|
84
|
+
[key: string]: number;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
82
87
|
type PortSideItem = {
|
|
83
88
|
pinId: number;
|
|
84
89
|
side: string;
|
package/dist/types/geometry.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Flatten from '@flatten-js/core';
|
|
2
2
|
import { Box } from '@svgdotjs/svg.js';
|
|
3
|
+
import { NumericValue } from './objects/ParamDefinition.js';
|
|
3
4
|
import { PinTypes } from './objects/PinTypes.js';
|
|
4
5
|
export type Segment = Flatten.Segment;
|
|
5
6
|
export type Polygon = Flatten.Polygon;
|
|
@@ -9,9 +10,9 @@ export type Arc = Flatten.Arc;
|
|
|
9
10
|
export type Feature = Segment | Polygon | Textbox | Arc | Multiline;
|
|
10
11
|
export type LabelStyle = {
|
|
11
12
|
font?: string;
|
|
12
|
-
fontSize?:
|
|
13
|
+
fontSize?: NumericValue;
|
|
13
14
|
fontWeight?: string;
|
|
14
|
-
angle?:
|
|
15
|
+
angle?: NumericValue;
|
|
15
16
|
anchor?: HorizontalAlign.Left | HorizontalAlign.Middle | HorizontalAlign.Right;
|
|
16
17
|
vanchor?: VerticalAlign.Top | VerticalAlign.Middle | VerticalAlign.Bottom;
|
|
17
18
|
textColor?: string;
|
|
@@ -20,7 +21,7 @@ export type LabelStyle = {
|
|
|
20
21
|
export declare class Textbox extends Flatten.Polygon {
|
|
21
22
|
id: string;
|
|
22
23
|
text: string;
|
|
23
|
-
anchorPoint: [
|
|
24
|
+
anchorPoint: [NumericValue, NumericValue];
|
|
24
25
|
boundingBox: {
|
|
25
26
|
width: number;
|
|
26
27
|
height: number;
|
|
@@ -31,12 +32,12 @@ export declare class Textbox extends Flatten.Polygon {
|
|
|
31
32
|
textMeasurementBounds: Box;
|
|
32
33
|
label: boolean;
|
|
33
34
|
get box(): Flatten.Box;
|
|
34
|
-
constructor(id: string, text: string, anchorPoint: [
|
|
35
|
-
static fromPoint(id: string, x:
|
|
35
|
+
constructor(id: string, text: string, anchorPoint: [NumericValue, NumericValue], polygon: Flatten.Polygon, style: LabelStyle, bounds: Box, label: boolean);
|
|
36
|
+
static fromPoint(id: string, x: NumericValue, y: NumericValue, text: string, style: LabelStyle, label: boolean): Textbox;
|
|
36
37
|
rotate(angle: number, origin: Flatten.Point): Textbox;
|
|
37
38
|
transform(matrix: Flatten.Matrix): Textbox;
|
|
38
39
|
private transformAnchorPoint;
|
|
39
|
-
getLabelPosition(): [
|
|
40
|
+
getLabelPosition(): [x: NumericValue, y: NumericValue];
|
|
40
41
|
}
|
|
41
42
|
export declare class GeometryProp {
|
|
42
43
|
name: string;
|
|
@@ -44,18 +45,18 @@ export declare class GeometryProp {
|
|
|
44
45
|
constructor(name: any, value: any);
|
|
45
46
|
}
|
|
46
47
|
export declare class Geometry {
|
|
47
|
-
static point(x:
|
|
48
|
-
static line(x1:
|
|
49
|
-
static label(id: string, x:
|
|
50
|
-
static textbox(id: string | null, x:
|
|
51
|
-
static segment(start: [
|
|
52
|
-
static polygon(coords: [
|
|
53
|
-
static multiline(coords: [
|
|
54
|
-
static arc(center: [x:
|
|
55
|
-
static getCoords(item: Feature): [
|
|
56
|
-
static rotateDegs(feature: Feature, angleDegrees: number, center: [
|
|
48
|
+
static point(x: NumericValue, y: NumericValue): Flatten.Point;
|
|
49
|
+
static line(x1: NumericValue, y1: NumericValue, x2: NumericValue, y2: NumericValue): Flatten.Line;
|
|
50
|
+
static label(id: string, x: NumericValue, y: NumericValue, text: string, style: LabelStyle): Textbox;
|
|
51
|
+
static textbox(id: string | null, x: NumericValue, y: NumericValue, text: string, style: LabelStyle): Textbox;
|
|
52
|
+
static segment(start: [NumericValue, NumericValue], end: [NumericValue, NumericValue]): Segment;
|
|
53
|
+
static polygon(coords: [NumericValue, NumericValue][]): Polygon;
|
|
54
|
+
static multiline(coords: [NumericValue, NumericValue][]): Multiline;
|
|
55
|
+
static arc(center: [x: NumericValue, y: NumericValue], radius: NumericValue, startAngle: NumericValue, endAngle: NumericValue, sweepDirection: boolean): Arc;
|
|
56
|
+
static getCoords(item: Feature): [x: NumericValue, y: NumericValue][];
|
|
57
|
+
static rotateDegs(feature: Feature, angleDegrees: number, center: [x: NumericValue, y: NumericValue]): Feature;
|
|
57
58
|
static flip(feature: Feature, flipX: number, flipY: number): Feature;
|
|
58
|
-
static groupRotate(features: Feature[], angle: number, center: [
|
|
59
|
+
static groupRotate(features: Feature[], angle: number, center: [x: NumericValue, y: NumericValue]): Feature[];
|
|
59
60
|
static groupFlip(features: Feature[], flipX: number, flipY: number): Feature[];
|
|
60
61
|
static groupBounds(features: Feature[]): {
|
|
61
62
|
start: [number, number];
|
|
@@ -72,8 +73,8 @@ export declare class Geometry {
|
|
|
72
73
|
static angle(dx: number, dy: number): number;
|
|
73
74
|
static getQuadrant(dx: number, dy: number): number;
|
|
74
75
|
static mergeWires(wirePoints: {
|
|
75
|
-
x:
|
|
76
|
-
y:
|
|
76
|
+
x: NumericValue;
|
|
77
|
+
y: NumericValue;
|
|
77
78
|
}[][]): {
|
|
78
79
|
intersectPoints: WirePointCount[];
|
|
79
80
|
segments: [x: number, y: number][][];
|
|
@@ -90,4 +91,15 @@ export declare enum VerticalAlign {
|
|
|
90
91
|
Middle = "middle",
|
|
91
92
|
Bottom = "bottom"
|
|
92
93
|
}
|
|
94
|
+
export declare enum HorizontalAlignProp {
|
|
95
|
+
Start = "start",
|
|
96
|
+
Middle = "middle",
|
|
97
|
+
End = "end"
|
|
98
|
+
}
|
|
99
|
+
export declare enum VerticalAlignProp {
|
|
100
|
+
Hanging = "hanging",
|
|
101
|
+
Middle = "middle",
|
|
102
|
+
Central = "central",
|
|
103
|
+
TextTop = "text-top"
|
|
104
|
+
}
|
|
93
105
|
export {};
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export declare enum GlobalNames {
|
|
2
2
|
__root = "__root",
|
|
3
|
-
gnd = "gnd",
|
|
4
|
-
DefaultResistor = "res",
|
|
5
|
-
DefaultCapacitor = "cap",
|
|
6
|
-
DefaultInductor = "ind",
|
|
7
3
|
symbol = "symbol"
|
|
8
4
|
}
|
|
9
5
|
export declare const NoNetText = "NO_NET";
|
|
10
6
|
export declare enum ParamKeys {
|
|
11
7
|
priority = "priority",
|
|
12
|
-
net_name = "net_name"
|
|
8
|
+
net_name = "net_name",
|
|
9
|
+
flip = "flip",
|
|
10
|
+
flipX = "flipX",
|
|
11
|
+
flipY = "flipY",
|
|
12
|
+
angle = "angle"
|
|
13
13
|
}
|
|
14
14
|
export declare enum LayoutDirection {
|
|
15
15
|
RIGHT = "RIGHT",
|
|
@@ -17,7 +17,9 @@ export declare enum LayoutDirection {
|
|
|
17
17
|
}
|
|
18
18
|
export declare enum SymbolPinSide {
|
|
19
19
|
Left = "left",
|
|
20
|
-
Right = "right"
|
|
20
|
+
Right = "right",
|
|
21
|
+
Top = "top",
|
|
22
|
+
Bottom = "bottom"
|
|
21
23
|
}
|
|
22
24
|
export declare enum LengthUnit {
|
|
23
25
|
mm = "mm",
|
|
@@ -64,11 +66,10 @@ export declare const ColorScheme: {
|
|
|
64
66
|
PinNameColor: string;
|
|
65
67
|
};
|
|
66
68
|
export declare enum ComponentTypes {
|
|
67
|
-
gnd = "gnd",
|
|
68
69
|
net = "net",
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
graphic = "graphic",
|
|
71
|
+
port = "port",
|
|
72
|
+
module = "module"
|
|
72
73
|
}
|
|
73
74
|
export declare enum ReferenceTypes {
|
|
74
75
|
function = "function",
|
|
@@ -87,8 +88,12 @@ export declare enum FrameType {
|
|
|
87
88
|
Frame = 1,
|
|
88
89
|
Sheet = 2
|
|
89
90
|
}
|
|
91
|
+
export declare const ModuleContainsKeyword = "contains";
|
|
90
92
|
export declare const GlobalDocumentName = "document";
|
|
91
93
|
export declare const RenderFlags: {
|
|
92
94
|
ShowElementFrames: boolean;
|
|
93
95
|
ShowOrigin: boolean;
|
|
96
|
+
ShowGridOrigin: boolean;
|
|
97
|
+
ShowLabelBoxBounds: boolean;
|
|
98
|
+
ShowLabelOrigin: boolean;
|
|
94
99
|
};
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { CircuitScriptParser } from "./antlr/CircuitScriptParser.js";
|
|
|
4
4
|
import { CircuitScriptLexer } from "./antlr/CircuitScriptLexer.js";
|
|
5
5
|
import { IParsedToken, SemanticTokensVisitor } from "./SemanticTokenVisitor.js";
|
|
6
6
|
import { LengthUnit } from "./globals.js";
|
|
7
|
+
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
7
8
|
export declare enum JSModuleType {
|
|
8
9
|
CommonJs = "cjs",
|
|
9
10
|
ESM = "mjs"
|
|
@@ -47,7 +48,7 @@ export declare class UnitDimension {
|
|
|
47
48
|
static mils(value: number): UnitDimension;
|
|
48
49
|
static px(value: number): UnitDimension;
|
|
49
50
|
}
|
|
50
|
-
export declare function milsToMM(value: number):
|
|
51
|
+
export declare function milsToMM(value: NumericValue | number): NumericValue;
|
|
51
52
|
export declare function pxToMM(value: number): number;
|
|
52
53
|
export declare const PaperGridReferences: {
|
|
53
54
|
[key: string]: [rows: number, columns: number];
|
package/dist/types/layout.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Net } from './objects/Net.js';
|
|
|
8
8
|
import { Logger } from './logger.js';
|
|
9
9
|
import { Frame, FramePlotDirection } from './objects/Frame.js';
|
|
10
10
|
import { BoundBox } from './utils.js';
|
|
11
|
+
import { NumericValue } from './objects/ParamDefinition.js';
|
|
11
12
|
export declare class LayoutEngine {
|
|
12
13
|
logger: Logger;
|
|
13
14
|
placeSubgraphVersion: number;
|
|
@@ -48,7 +49,7 @@ export declare class LayoutEngine {
|
|
|
48
49
|
mergeOriginNodes(node1: RenderItem, pin1: number, node2: RenderItem, pin2: number, originNode1: string, originNode2: string, originNodes: RenderItem[], originNodeGroups: Map<string, RenderItem[]>): void;
|
|
49
50
|
placeSubgraph(graph: Graph, firstNodeId: string, subgraphEdges: Edge[]): void;
|
|
50
51
|
translateNodeBy(offsetX: number, offsetY: number, item: RenderItem): void;
|
|
51
|
-
placeNodeAtPosition(fromX:
|
|
52
|
+
placeNodeAtPosition(fromX: NumericValue, fromY: NumericValue, item: RenderItem, pin: number, depth?: number): void;
|
|
52
53
|
placeFloatingItems(graph: Graph, item: RenderItem, depth?: number): void;
|
|
53
54
|
printWarnings(): void;
|
|
54
55
|
}
|
|
@@ -60,10 +61,11 @@ type EdgeValue = [
|
|
|
60
61
|
priority: number
|
|
61
62
|
];
|
|
62
63
|
type RenderItem = RenderComponent | RenderWire | RenderText;
|
|
64
|
+
export declare function applyComponentParamsToSymbol(component: ClassComponent, symbol: SymbolGraphic): void;
|
|
63
65
|
export declare function getBounds(components: (RenderComponent | RenderText)[], wires: RenderWire[], junctions: RenderJunction[], frames: RenderFrame[]): BoundBox;
|
|
64
66
|
export declare class RenderObject {
|
|
65
|
-
x:
|
|
66
|
-
y:
|
|
67
|
+
x: NumericValue;
|
|
68
|
+
y: NumericValue;
|
|
67
69
|
isFloating: boolean;
|
|
68
70
|
floatingRelativeTo: [selfPin: number, nodeId: string, pin: number][];
|
|
69
71
|
}
|
|
@@ -75,16 +77,16 @@ export declare class RenderWire extends RenderObject {
|
|
|
75
77
|
y: number;
|
|
76
78
|
}[];
|
|
77
79
|
netName: string;
|
|
78
|
-
constructor(x:
|
|
80
|
+
constructor(x: NumericValue, y: NumericValue, segments: WireSegment[]);
|
|
79
81
|
refreshPoints(): void;
|
|
80
|
-
getAutoPoints(value: [x:
|
|
82
|
+
getAutoPoints(value: [x: NumericValue, y: NumericValue], direction: WireAutoDirection): [dx: number, dy: number][];
|
|
81
83
|
getWireEnd(): {
|
|
82
84
|
x: number;
|
|
83
85
|
y: number;
|
|
84
86
|
};
|
|
85
87
|
isEndAutoLength(): boolean;
|
|
86
88
|
getEndAuto(): [instance: ClassComponent, pin: number];
|
|
87
|
-
setEndAuto(untilX:
|
|
89
|
+
setEndAuto(untilX: NumericValue, untilY: NumericValue): void;
|
|
88
90
|
toString(): string;
|
|
89
91
|
}
|
|
90
92
|
export type MergedWire = {
|
|
@@ -104,10 +106,10 @@ export declare class RenderComponent extends RenderObject {
|
|
|
104
106
|
}
|
|
105
107
|
export declare class RenderText extends RenderObject {
|
|
106
108
|
symbol: SymbolText;
|
|
107
|
-
_fontSize:
|
|
109
|
+
_fontSize: NumericValue;
|
|
108
110
|
_fontWeight: string;
|
|
109
|
-
get fontSize():
|
|
110
|
-
set fontSize(value:
|
|
111
|
+
get fontSize(): NumericValue;
|
|
112
|
+
set fontSize(value: NumericValue);
|
|
111
113
|
get fontWeight(): string;
|
|
112
114
|
set fontWeight(value: string);
|
|
113
115
|
constructor(text: string);
|
|
@@ -118,13 +120,12 @@ export declare class RenderFrame extends RenderObject {
|
|
|
118
120
|
innerItems: (RenderComponent | RenderFrame | RenderText)[];
|
|
119
121
|
translateX: number;
|
|
120
122
|
translateY: number;
|
|
121
|
-
padding:
|
|
122
|
-
gap:
|
|
123
|
+
padding: NumericValue;
|
|
124
|
+
gap: NumericValue;
|
|
125
|
+
borderWidth: NumericValue;
|
|
123
126
|
direction: FramePlotDirection;
|
|
124
|
-
borderWidth: number;
|
|
125
127
|
width: number | null;
|
|
126
128
|
height: number | null;
|
|
127
|
-
size: string | null;
|
|
128
129
|
subgraphId: string;
|
|
129
130
|
type: RenderFrameType;
|
|
130
131
|
containsTitle: boolean;
|
|
@@ -136,9 +137,9 @@ export declare enum RenderFrameType {
|
|
|
136
137
|
Elements = 2
|
|
137
138
|
}
|
|
138
139
|
export declare class RenderJunction {
|
|
139
|
-
x:
|
|
140
|
-
y:
|
|
141
|
-
constructor(x:
|
|
140
|
+
x: NumericValue;
|
|
141
|
+
y: NumericValue;
|
|
142
|
+
constructor(x: NumericValue, y: NumericValue);
|
|
142
143
|
}
|
|
143
144
|
export type SheetFrame = {
|
|
144
145
|
frame: RenderFrame;
|
|
@@ -150,13 +151,13 @@ export type SheetFrame = {
|
|
|
150
151
|
mergedWires: MergedWire[];
|
|
151
152
|
};
|
|
152
153
|
export declare function CalculatePinPositions(component: ClassComponent): Map<number, {
|
|
153
|
-
x:
|
|
154
|
-
y:
|
|
155
|
-
angle:
|
|
154
|
+
x: NumericValue;
|
|
155
|
+
y: NumericValue;
|
|
156
|
+
angle: NumericValue;
|
|
156
157
|
}>;
|
|
157
158
|
export declare function ExtractDrawingRects(drawing: SymbolDrawingCommands): {
|
|
158
|
-
width:
|
|
159
|
-
height:
|
|
159
|
+
width: NumericValue;
|
|
160
|
+
height: NumericValue;
|
|
160
161
|
}[];
|
|
161
162
|
type SubGraphInfo = {
|
|
162
163
|
firstNodeId: string;
|