circuitscript 0.1.0 → 0.1.3
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 +13 -8
- package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
- package/dist/cjs/antlr/CircuitScriptParser.js +599 -657
- package/dist/cjs/builtinMethods.js +27 -8
- package/dist/cjs/draw_symbols.js +320 -197
- package/dist/cjs/execute.js +114 -116
- package/dist/cjs/export.js +2 -4
- package/dist/cjs/geometry.js +52 -19
- package/dist/cjs/globals.js +17 -12
- package/dist/cjs/helpers.js +16 -3
- package/dist/cjs/layout.js +473 -354
- 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 +11 -2
- package/dist/cjs/objects/ParamDefinition.js +123 -4
- package/dist/cjs/objects/PinDefinition.js +1 -4
- package/dist/cjs/render.js +76 -138
- package/dist/cjs/sizing.js +33 -7
- package/dist/cjs/utils.js +86 -2
- package/dist/cjs/visitor.js +224 -255
- package/dist/esm/BaseVisitor.mjs +15 -10
- package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
- package/dist/esm/antlr/CircuitScriptParser.mjs +599 -657
- package/dist/esm/builtinMethods.mjs +24 -8
- package/dist/esm/draw_symbols.mjs +322 -200
- package/dist/esm/execute.mjs +116 -118
- package/dist/esm/export.mjs +2 -4
- package/dist/esm/geometry.mjs +52 -19
- package/dist/esm/globals.mjs +17 -12
- package/dist/esm/helpers.mjs +17 -4
- package/dist/esm/layout.mjs +479 -360
- 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 +10 -1
- package/dist/esm/objects/ParamDefinition.mjs +122 -3
- package/dist/esm/objects/PinDefinition.mjs +0 -2
- package/dist/esm/render.mjs +79 -141
- package/dist/esm/sizing.mjs +34 -8
- package/dist/esm/utils.mjs +80 -1
- package/dist/esm/visitor.mjs +226 -257
- package/dist/types/BaseVisitor.d.ts +1 -1
- package/dist/types/antlr/CircuitScriptParser.d.ts +2 -3
- package/dist/types/draw_symbols.d.ts +72 -45
- package/dist/types/execute.d.ts +15 -10
- package/dist/types/geometry.d.ts +31 -19
- package/dist/types/globals.d.ts +15 -11
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/layout.d.ts +35 -54
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +19 -16
- package/dist/types/objects/ExecutionScope.d.ts +3 -2
- package/dist/types/objects/Frame.d.ts +9 -2
- package/dist/types/objects/ParamDefinition.d.ts +32 -2
- package/dist/types/objects/PinDefinition.d.ts +0 -2
- package/dist/types/render.d.ts +2 -1
- package/dist/types/utils.d.ts +14 -1
- package/dist/types/visitor.d.ts +4 -5
- package/libs/lib.cst +25 -8
- 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,6 +53,7 @@ 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;
|
|
56
|
+
protected visitResult(ctx: ParserRuleContext): any;
|
|
57
57
|
protected handleImportFile(name: string, throwErrors?: boolean, ctx?: ParserRuleContext | null): {
|
|
58
58
|
hasError: boolean;
|
|
59
59
|
hasParseError: boolean;
|
|
@@ -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;
|
|
@@ -3,6 +3,7 @@ import { Feature, GeometryProp, HorizontalAlign, LabelStyle, Textbox, VerticalAl
|
|
|
3
3
|
import { Logger } from "./logger.js";
|
|
4
4
|
import { PinTypes } from "./objects/PinTypes.js";
|
|
5
5
|
import { ParserRuleContext } from "antlr4ng";
|
|
6
|
+
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
6
7
|
export declare abstract class SymbolGraphic {
|
|
7
8
|
drawPortsName: boolean;
|
|
8
9
|
displayBounds: boolean;
|
|
@@ -10,8 +11,8 @@ export declare abstract class SymbolGraphic {
|
|
|
10
11
|
_angle: number;
|
|
11
12
|
_flipX: number;
|
|
12
13
|
_flipY: number;
|
|
13
|
-
width:
|
|
14
|
-
height:
|
|
14
|
+
width: NumericValue;
|
|
15
|
+
height: NumericValue;
|
|
15
16
|
labelTexts: Map<string, string>;
|
|
16
17
|
constructor();
|
|
17
18
|
get angle(): number;
|
|
@@ -21,7 +22,12 @@ export declare abstract class SymbolGraphic {
|
|
|
21
22
|
get flipY(): number;
|
|
22
23
|
set flipY(value: number);
|
|
23
24
|
refreshDrawing(calculateSize?: boolean): void;
|
|
24
|
-
calculateSize():
|
|
25
|
+
calculateSize(): {
|
|
26
|
+
bodyWidth: NumericValue;
|
|
27
|
+
bodyHeight: NumericValue;
|
|
28
|
+
width: NumericValue;
|
|
29
|
+
height: NumericValue;
|
|
30
|
+
};
|
|
25
31
|
abstract generateDrawing(): void;
|
|
26
32
|
size(): {
|
|
27
33
|
width: number;
|
|
@@ -32,9 +38,9 @@ export declare abstract class SymbolGraphic {
|
|
|
32
38
|
place?: boolean;
|
|
33
39
|
}): void;
|
|
34
40
|
pinPosition(id: number): {
|
|
35
|
-
x:
|
|
36
|
-
y:
|
|
37
|
-
angle:
|
|
41
|
+
x: NumericValue;
|
|
42
|
+
y: NumericValue;
|
|
43
|
+
angle: NumericValue;
|
|
38
44
|
};
|
|
39
45
|
protected drawBounds(group: G): void;
|
|
40
46
|
protected drawBody(group: G): void;
|
|
@@ -43,13 +49,9 @@ export declare abstract class SymbolGraphic {
|
|
|
43
49
|
flipTextAnchor(value: HorizontalAlign): HorizontalAlign;
|
|
44
50
|
flipDominantBaseline(value: VerticalAlign): VerticalAlign;
|
|
45
51
|
}
|
|
46
|
-
export declare function SymbolFactory(name: string): SymbolGraphic;
|
|
47
|
-
export declare class SymbolPointHidden extends SymbolGraphic {
|
|
48
|
-
generateDrawing(): void;
|
|
49
|
-
}
|
|
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;
|
|
@@ -67,6 +69,7 @@ export declare enum PlaceHolderCommands {
|
|
|
67
69
|
arc = "arc",
|
|
68
70
|
circle = "circle",
|
|
69
71
|
rect = "rect",
|
|
72
|
+
crect = "crect",
|
|
70
73
|
triangle = "triangle",
|
|
71
74
|
pin = "pin",
|
|
72
75
|
hpin = "hpin",
|
|
@@ -86,62 +89,85 @@ export declare enum PlaceHolderCommands {
|
|
|
86
89
|
}
|
|
87
90
|
export declare class SymbolCustom extends SymbolGraphic {
|
|
88
91
|
pinDefinition: SymbolPinDefintion[];
|
|
89
|
-
bodyWidth:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
bodyWidth: NumericValue;
|
|
93
|
+
bodyHeight: NumericValue;
|
|
94
|
+
pinLength: NumericValue;
|
|
95
|
+
width: NumericValue;
|
|
96
|
+
height: NumericValue;
|
|
97
|
+
pinSpacing: NumericValue;
|
|
98
|
+
pinTextPadding: NumericValue;
|
|
95
99
|
pins: SymbolPinLayout[];
|
|
96
100
|
_cacheLeftPins: SymbolPinDefintion[];
|
|
97
101
|
_cacheRightPins: SymbolPinDefintion[];
|
|
98
|
-
|
|
102
|
+
_cacheTopPins: SymbolPinDefintion[];
|
|
103
|
+
_cacheBottomPins: SymbolPinDefintion[];
|
|
104
|
+
pinMaxPositions: {
|
|
105
|
+
[key: string]: number;
|
|
106
|
+
};
|
|
107
|
+
constructor(pinDefinition: SymbolPinDefintion[], pinMaxPositions: {
|
|
108
|
+
[key: string]: number;
|
|
109
|
+
});
|
|
99
110
|
generateDrawing(): void;
|
|
100
|
-
|
|
101
|
-
|
|
111
|
+
private getPins;
|
|
112
|
+
generateDrawingPins(drawing: SymbolDrawing, bodyWidthMM: NumericValue, bodyHeightMM: NumericValue, pins: {
|
|
113
|
+
left: SymbolPinDefintion[];
|
|
114
|
+
right: SymbolPinDefintion[];
|
|
115
|
+
top: SymbolPinDefintion[];
|
|
116
|
+
bottom: SymbolPinDefintion[];
|
|
117
|
+
}, defaultLineColor: string): void;
|
|
118
|
+
calculateSize(): {
|
|
119
|
+
bodyWidth: NumericValue;
|
|
120
|
+
bodyHeight: NumericValue;
|
|
121
|
+
width: NumericValue;
|
|
122
|
+
height: NumericValue;
|
|
123
|
+
};
|
|
102
124
|
}
|
|
103
125
|
export declare class SymbolCustomModule extends SymbolCustom {
|
|
104
|
-
pinLength:
|
|
105
|
-
portWidth:
|
|
106
|
-
portHeight:
|
|
107
|
-
generateDrawingPins(drawing: SymbolDrawing, bodyWidthMM:
|
|
126
|
+
pinLength: NumericValue;
|
|
127
|
+
portWidth: NumericValue;
|
|
128
|
+
portHeight: NumericValue;
|
|
129
|
+
generateDrawingPins(drawing: SymbolDrawing, bodyWidthMM: NumericValue, bodyHeightMM: NumericValue, pins: {
|
|
130
|
+
left: SymbolPinDefintion[];
|
|
131
|
+
right: SymbolPinDefintion[];
|
|
132
|
+
top: SymbolPinDefintion[];
|
|
133
|
+
bottom: SymbolPinDefintion[];
|
|
134
|
+
}, defaultLineColor: string): void;
|
|
108
135
|
}
|
|
109
136
|
export declare class SymbolDrawing {
|
|
110
137
|
items: (Feature | GeometryProp)[];
|
|
111
|
-
pins: [
|
|
138
|
+
pins: [NumericValue, Feature, angle: NumericValue, lineColor: string][];
|
|
112
139
|
angle: number;
|
|
113
140
|
flipX: number;
|
|
114
141
|
flipY: number;
|
|
115
|
-
mainOrigin: [
|
|
142
|
+
mainOrigin: [x: NumericValue, y: NumericValue];
|
|
116
143
|
logger: Logger;
|
|
117
144
|
variables: Map<string, any>;
|
|
118
145
|
clear(): void;
|
|
119
146
|
log(...params: any[]): void;
|
|
120
|
-
addLine(startX:
|
|
121
|
-
addPin(pinId:
|
|
122
|
-
addPinMM(pinId:
|
|
123
|
-
addVLine(startX:
|
|
124
|
-
addHLine(startX:
|
|
125
|
-
addRect(
|
|
126
|
-
addRectMM(
|
|
127
|
-
addTriangle(startX:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
addModulePort(x: number, y: number, width: number, height: number, portType?: PinTypes, scaleX?: number): SymbolDrawing;
|
|
147
|
+
addLine(startX: NumericValue, startY: NumericValue, endX: NumericValue, endY: NumericValue): SymbolDrawing;
|
|
148
|
+
addPin(pinId: NumericValue, startX: NumericValue, startY: NumericValue, endX: NumericValue, endY: NumericValue, lineColor: string): SymbolDrawing;
|
|
149
|
+
addPinMM(pinId: NumericValue, startXMM: NumericValue, startYMM: NumericValue, endXMM: NumericValue, endYMM: NumericValue, lineColor: string): SymbolDrawing;
|
|
150
|
+
addVLine(startX: NumericValue, startY: NumericValue, value: NumericValue): SymbolDrawing;
|
|
151
|
+
addHLine(startX: NumericValue, startY: NumericValue, value: NumericValue): SymbolDrawing;
|
|
152
|
+
addRect(x: NumericValue, y: NumericValue, width: NumericValue, height: NumericValue): SymbolDrawing;
|
|
153
|
+
addRectMM(x: NumericValue, y: NumericValue, width: NumericValue, height: NumericValue): SymbolDrawing;
|
|
154
|
+
addTriangle(startX: NumericValue, startY: NumericValue, endX: NumericValue, endY: NumericValue, width: NumericValue): SymbolDrawing;
|
|
155
|
+
addLabel(x: NumericValue, y: NumericValue, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
156
|
+
addLabelMils(x: NumericValue, y: NumericValue, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
157
|
+
addTextbox(x: NumericValue, y: NumericValue, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
158
|
+
addModulePort(x: NumericValue, y: NumericValue, width: NumericValue, height: NumericValue, portType?: PinTypes, scaleX?: number, angle?: number): SymbolDrawing;
|
|
133
159
|
addPath(...pathParts: any): SymbolDrawing;
|
|
134
|
-
addSetLineWidth(value:
|
|
160
|
+
addSetLineWidth(value: NumericValue): SymbolDrawing;
|
|
135
161
|
addSetLineColor(value: string): SymbolDrawing;
|
|
136
162
|
addSetTextColor(value: string): SymbolDrawing;
|
|
137
163
|
addSetFillColor(value: string): SymbolDrawing;
|
|
138
|
-
addArc(x:
|
|
164
|
+
addArc(x: NumericValue, y: NumericValue, radius: NumericValue, startAngle: NumericValue, endAngle: NumericValue): SymbolDrawing;
|
|
139
165
|
addSetUnits(value: string): SymbolDrawing;
|
|
140
166
|
getPaths(): {
|
|
141
167
|
path: string;
|
|
142
168
|
fillColor: string;
|
|
143
169
|
lineColor: string;
|
|
144
|
-
lineWidth:
|
|
170
|
+
lineWidth: NumericValue;
|
|
145
171
|
}[];
|
|
146
172
|
getPinsPath(): {
|
|
147
173
|
path: string;
|
|
@@ -156,9 +182,9 @@ export declare class SymbolDrawing {
|
|
|
156
182
|
end: SimplePoint;
|
|
157
183
|
};
|
|
158
184
|
getPinPosition(pinId: number): {
|
|
159
|
-
start: [
|
|
160
|
-
end: [
|
|
161
|
-
angle:
|
|
185
|
+
start: [x: NumericValue, y: NumericValue];
|
|
186
|
+
end: [x: NumericValue, y: NumericValue];
|
|
187
|
+
angle: NumericValue;
|
|
162
188
|
};
|
|
163
189
|
}
|
|
164
190
|
export type GraphicExprCommand = [
|
|
@@ -176,6 +202,7 @@ export declare class SymbolDrawingCommands extends SymbolDrawing {
|
|
|
176
202
|
runCommands(): void;
|
|
177
203
|
getCommands(): GraphicExprCommand[];
|
|
178
204
|
clone(): SymbolDrawingCommands;
|
|
205
|
+
eq(other: SymbolDrawingCommands): boolean;
|
|
179
206
|
}
|
|
180
207
|
type SimplePoint = [x: number, y: number];
|
|
181
208
|
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?: {
|
|
@@ -70,15 +72,18 @@ export declare class ExecutionContext {
|
|
|
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",
|
|
@@ -52,7 +54,7 @@ export declare const displayUnits = LengthUnit.mils;
|
|
|
52
54
|
export declare const defaultFont = "Arial";
|
|
53
55
|
export declare const defaultFontBold = "Arial";
|
|
54
56
|
export declare const defaultFontSize = 10;
|
|
55
|
-
export declare const junctionSize:
|
|
57
|
+
export declare const junctionSize: import("./objects/ParamDefinition").NumericValue;
|
|
56
58
|
export declare const PortArrowSize: number;
|
|
57
59
|
export declare const PortPaddingHorizontal: number;
|
|
58
60
|
export declare const PortPaddingVertical: number;
|
|
@@ -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",
|
|
@@ -92,4 +93,7 @@ export declare const GlobalDocumentName = "document";
|
|
|
92
93
|
export declare const RenderFlags: {
|
|
93
94
|
ShowElementFrames: boolean;
|
|
94
95
|
ShowOrigin: boolean;
|
|
96
|
+
ShowGridOrigin: boolean;
|
|
97
|
+
ShowLabelBoxBounds: boolean;
|
|
98
|
+
ShowLabelOrigin: boolean;
|
|
95
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,9 +8,9 @@ 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
|
-
placeSubgraphVersion: number;
|
|
14
14
|
layoutWarnings: string[];
|
|
15
15
|
showBaseFrame: boolean;
|
|
16
16
|
constructor(options?: {
|
|
@@ -21,50 +21,34 @@ export declare class LayoutEngine {
|
|
|
21
21
|
protected padLevel(value: number): string;
|
|
22
22
|
runLayout(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]): SheetFrame[];
|
|
23
23
|
private flattenFrameItems;
|
|
24
|
-
findJunctions
|
|
25
|
-
|
|
26
|
-
mergedWires: MergedWire[];
|
|
27
|
-
};
|
|
28
|
-
placeFrames(graph: Graph, subgraphInfo: SubGraphInfo[], frameObjects: RenderFrame[]): {
|
|
29
|
-
elementFrames: RenderFrame[];
|
|
30
|
-
textObjects: RenderText[];
|
|
31
|
-
};
|
|
24
|
+
private findJunctions;
|
|
25
|
+
private placeFrames;
|
|
32
26
|
collectElementFrames(frame: RenderFrame, level?: number): RenderFrame[];
|
|
33
27
|
applyFrameOffset(frame: RenderFrame, level?: number): void;
|
|
34
|
-
placeAndSizeFrame
|
|
28
|
+
private placeAndSizeFrame;
|
|
35
29
|
dumpFrame(frame: RenderFrame, level?: number): void;
|
|
36
|
-
prepareFrames
|
|
37
|
-
|
|
38
|
-
textObjects: RenderText[];
|
|
39
|
-
};
|
|
30
|
+
private prepareFrames;
|
|
31
|
+
private checkAddFrameTitle;
|
|
40
32
|
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]): {
|
|
41
33
|
graph: Graph;
|
|
42
34
|
containerFrames: RenderFrame[];
|
|
43
35
|
};
|
|
44
|
-
setGraphEdge
|
|
45
|
-
sizeSubGraphs
|
|
46
|
-
walkAndPlaceGraph
|
|
36
|
+
private setGraphEdge;
|
|
37
|
+
private sizeSubGraphs;
|
|
38
|
+
private walkAndPlaceGraph;
|
|
47
39
|
placeSubgraphV2(graph: Graph, firstNodeId: string, subgraphEdges: Edge[]): void;
|
|
48
40
|
mergeOriginNodes(node1: RenderItem, pin1: number, node2: RenderItem, pin2: number, originNode1: string, originNode2: string, originNodes: RenderItem[], originNodeGroups: Map<string, RenderItem[]>): void;
|
|
49
|
-
placeSubgraph(graph: Graph, firstNodeId: string, subgraphEdges: Edge[]): void;
|
|
50
41
|
translateNodeBy(offsetX: number, offsetY: number, item: RenderItem): void;
|
|
51
|
-
placeNodeAtPosition(fromX:
|
|
42
|
+
placeNodeAtPosition(fromX: NumericValue, fromY: NumericValue, item: RenderItem, pin: number, depth?: number): void;
|
|
52
43
|
placeFloatingItems(graph: Graph, item: RenderItem, depth?: number): void;
|
|
53
44
|
printWarnings(): void;
|
|
54
45
|
}
|
|
55
|
-
type EdgeValue = [
|
|
56
|
-
instance1: string,
|
|
57
|
-
instancePin1: number,
|
|
58
|
-
instance2: string,
|
|
59
|
-
instancePin2: number,
|
|
60
|
-
priority: number
|
|
61
|
-
];
|
|
62
46
|
type RenderItem = RenderComponent | RenderWire | RenderText;
|
|
63
47
|
export declare function applyComponentParamsToSymbol(component: ClassComponent, symbol: SymbolGraphic): void;
|
|
64
48
|
export declare function getBounds(components: (RenderComponent | RenderText)[], wires: RenderWire[], junctions: RenderJunction[], frames: RenderFrame[]): BoundBox;
|
|
65
49
|
export declare class RenderObject {
|
|
66
|
-
x:
|
|
67
|
-
y:
|
|
50
|
+
x: NumericValue;
|
|
51
|
+
y: NumericValue;
|
|
68
52
|
isFloating: boolean;
|
|
69
53
|
floatingRelativeTo: [selfPin: number, nodeId: string, pin: number][];
|
|
70
54
|
}
|
|
@@ -76,16 +60,16 @@ export declare class RenderWire extends RenderObject {
|
|
|
76
60
|
y: number;
|
|
77
61
|
}[];
|
|
78
62
|
netName: string;
|
|
79
|
-
constructor(x:
|
|
63
|
+
constructor(x: NumericValue, y: NumericValue, segments: WireSegment[]);
|
|
80
64
|
refreshPoints(): void;
|
|
81
|
-
getAutoPoints(value: [x:
|
|
65
|
+
getAutoPoints(value: [x: NumericValue, y: NumericValue], direction: WireAutoDirection): [dx: number, dy: number][];
|
|
82
66
|
getWireEnd(): {
|
|
83
67
|
x: number;
|
|
84
68
|
y: number;
|
|
85
69
|
};
|
|
86
70
|
isEndAutoLength(): boolean;
|
|
87
71
|
getEndAuto(): [instance: ClassComponent, pin: number];
|
|
88
|
-
setEndAuto(untilX:
|
|
72
|
+
setEndAuto(untilX: NumericValue, untilY: NumericValue): void;
|
|
89
73
|
toString(): string;
|
|
90
74
|
}
|
|
91
75
|
export type MergedWire = {
|
|
@@ -105,10 +89,10 @@ export declare class RenderComponent extends RenderObject {
|
|
|
105
89
|
}
|
|
106
90
|
export declare class RenderText extends RenderObject {
|
|
107
91
|
symbol: SymbolText;
|
|
108
|
-
_fontSize:
|
|
92
|
+
_fontSize: NumericValue;
|
|
109
93
|
_fontWeight: string;
|
|
110
|
-
get fontSize():
|
|
111
|
-
set fontSize(value:
|
|
94
|
+
get fontSize(): NumericValue;
|
|
95
|
+
set fontSize(value: NumericValue);
|
|
112
96
|
get fontWeight(): string;
|
|
113
97
|
set fontWeight(value: string);
|
|
114
98
|
constructor(text: string);
|
|
@@ -119,15 +103,14 @@ export declare class RenderFrame extends RenderObject {
|
|
|
119
103
|
innerItems: (RenderComponent | RenderFrame | RenderText)[];
|
|
120
104
|
translateX: number;
|
|
121
105
|
translateY: number;
|
|
122
|
-
padding:
|
|
123
|
-
gap:
|
|
106
|
+
padding: NumericValue;
|
|
107
|
+
gap: NumericValue;
|
|
108
|
+
borderWidth: NumericValue;
|
|
124
109
|
direction: FramePlotDirection;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
height: number | null;
|
|
128
|
-
size: string | null;
|
|
110
|
+
width: NumericValue | null;
|
|
111
|
+
height: NumericValue | null;
|
|
129
112
|
subgraphId: string;
|
|
130
|
-
|
|
113
|
+
renderType: RenderFrameType;
|
|
131
114
|
containsTitle: boolean;
|
|
132
115
|
constructor(frame: Frame, type?: RenderFrameType);
|
|
133
116
|
toString(): string;
|
|
@@ -137,9 +120,9 @@ export declare enum RenderFrameType {
|
|
|
137
120
|
Elements = 2
|
|
138
121
|
}
|
|
139
122
|
export declare class RenderJunction {
|
|
140
|
-
x:
|
|
141
|
-
y:
|
|
142
|
-
constructor(x:
|
|
123
|
+
x: NumericValue;
|
|
124
|
+
y: NumericValue;
|
|
125
|
+
constructor(x: NumericValue, y: NumericValue);
|
|
143
126
|
}
|
|
144
127
|
export type SheetFrame = {
|
|
145
128
|
frame: RenderFrame;
|
|
@@ -151,17 +134,15 @@ export type SheetFrame = {
|
|
|
151
134
|
mergedWires: MergedWire[];
|
|
152
135
|
};
|
|
153
136
|
export declare function CalculatePinPositions(component: ClassComponent): Map<number, {
|
|
154
|
-
x:
|
|
155
|
-
y:
|
|
156
|
-
angle:
|
|
137
|
+
x: NumericValue;
|
|
138
|
+
y: NumericValue;
|
|
139
|
+
angle: NumericValue;
|
|
157
140
|
}>;
|
|
158
141
|
export declare function ExtractDrawingRects(drawing: SymbolDrawingCommands): {
|
|
159
|
-
|
|
160
|
-
|
|
142
|
+
x: NumericValue;
|
|
143
|
+
y: NumericValue;
|
|
144
|
+
width: NumericValue;
|
|
145
|
+
height: NumericValue;
|
|
146
|
+
className: string | undefined;
|
|
161
147
|
}[];
|
|
162
|
-
type SubGraphInfo = {
|
|
163
|
-
firstNodeId: string;
|
|
164
|
-
components: string[];
|
|
165
|
-
bounds: BoundBox;
|
|
166
|
-
};
|
|
167
148
|
export { BoundBox };
|