circuitscript 0.0.21 → 0.0.24
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/antlr/CircuitScriptLexer.js +288 -0
- package/dist/cjs/antlr/CircuitScriptParser.js +4905 -0
- package/dist/cjs/antlr/CircuitScriptVisitor.js +6 -0
- package/{src/draw_symbols.ts → dist/cjs/draw_symbols.js} +303 -614
- package/dist/cjs/execute.js +780 -0
- package/{src/export.ts → dist/cjs/export.js} +34 -56
- package/dist/cjs/fonts.js +4 -0
- package/dist/cjs/geometry.js +430 -0
- package/dist/cjs/globals.js +60 -0
- package/dist/cjs/helpers.js +99 -0
- package/dist/cjs/index.js +29 -0
- package/{src/layout.ts → dist/cjs/layout.js} +413 -1002
- package/dist/cjs/lexer.js +114 -0
- package/dist/cjs/logger.js +17 -0
- package/dist/cjs/main.js +87 -0
- package/dist/cjs/objects/ClassComponent.js +142 -0
- package/dist/cjs/objects/ExecutionScope.js +134 -0
- package/dist/cjs/objects/Frame.js +22 -0
- package/{src/objects/Net.ts → dist/cjs/objects/Net.js} +9 -24
- package/dist/cjs/objects/ParamDefinition.js +42 -0
- package/dist/cjs/objects/PinDefinition.js +31 -0
- package/dist/cjs/objects/PinTypes.js +11 -0
- package/dist/cjs/objects/Wire.js +9 -0
- package/dist/cjs/objects/types.js +9 -0
- package/dist/cjs/parser.js +299 -0
- package/dist/cjs/regenerate-tests.js +23 -0
- package/dist/cjs/render.js +155 -0
- package/{src/server.ts → dist/cjs/server.js} +15 -21
- package/dist/cjs/sizing.js +105 -0
- package/{src/utils.ts → dist/cjs/utils.js} +25 -35
- package/{src/visitor.ts → dist/cjs/visitor.js} +392 -948
- package/{build/src/antlr/CircuitScriptLexer.js → dist/esm/antlr/CircuitScriptLexer.mjs} +90 -91
- package/{build/src/antlr/CircuitScriptParser.js → dist/esm/antlr/CircuitScriptParser.mjs} +138 -136
- package/{build/src/draw_symbols.js → dist/esm/draw_symbols.mjs} +11 -11
- package/{build/src/execute.js → dist/esm/execute.mjs} +9 -8
- package/{build/src/export.js → dist/esm/export.mjs} +2 -2
- package/{build/src/geometry.js → dist/esm/geometry.mjs} +3 -7
- package/{build/src/helpers.js → dist/esm/helpers.mjs} +27 -7
- package/dist/esm/index.mjs +13 -0
- package/{build/src/layout.js → dist/esm/layout.mjs} +11 -11
- package/{build/src/lexer.js → dist/esm/lexer.mjs} +2 -2
- package/{build/src/main.js → dist/esm/main.mjs} +5 -5
- package/{build/src/objects/ClassComponent.js → dist/esm/objects/ClassComponent.mjs} +3 -3
- package/{build/src/objects/PinDefinition.js → dist/esm/objects/PinDefinition.mjs} +1 -1
- package/dist/esm/parser.mjs +269 -0
- package/{build/src/regenerate-tests.js → dist/esm/regenerate-tests.mjs} +1 -1
- package/{build/src/render.js → dist/esm/render.mjs} +7 -24
- package/{build/src/sizing.js → dist/esm/sizing.mjs} +22 -8
- package/{build/src/visitor.js → dist/esm/visitor.mjs} +10 -29
- package/dist/types/antlr/CircuitScriptLexer.d.ts +71 -0
- package/dist/types/antlr/CircuitScriptParser.d.ts +675 -0
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +115 -0
- package/dist/types/draw_symbols.d.ts +162 -0
- package/dist/types/execute.d.ts +85 -0
- package/dist/types/export.d.ts +2 -0
- package/dist/types/fonts.d.ts +1 -0
- package/dist/types/geometry.d.ts +84 -0
- package/dist/types/globals.d.ts +50 -0
- package/dist/types/helpers.d.ts +9 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/layout.d.ts +147 -0
- package/dist/types/lexer.d.ts +19 -0
- package/dist/types/logger.d.ts +6 -0
- package/dist/types/main.d.ts +2 -0
- package/dist/types/objects/ClassComponent.d.ts +40 -0
- package/dist/types/objects/ExecutionScope.d.ts +64 -0
- package/dist/types/objects/Frame.d.ts +15 -0
- package/dist/types/objects/Net.d.ts +10 -0
- package/dist/types/objects/ParamDefinition.d.ts +20 -0
- package/dist/types/objects/PinDefinition.d.ts +24 -0
- package/dist/types/objects/PinTypes.d.ts +7 -0
- package/dist/types/objects/Wire.d.ts +11 -0
- package/dist/types/objects/types.d.ts +49 -0
- package/dist/types/parser.d.ts +38 -0
- package/dist/types/regenerate-tests.d.ts +1 -0
- package/dist/types/render.d.ts +10 -0
- package/dist/types/server.d.ts +1 -0
- package/dist/types/sizing.d.ts +15 -0
- package/dist/types/utils.d.ts +19 -0
- package/dist/types/visitor.d.ts +135 -0
- package/package.json +30 -12
- package/.editorconfig +0 -15
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -27
- package/.gitlab-ci.yml +0 -81
- package/.prettierignore +0 -8
- package/.prettierrc +0 -16
- package/__tests__/expectedResults.ts +0 -657
- package/__tests__/helpers.ts +0 -82
- package/__tests__/parseScripts.ts +0 -593
- package/__tests__/renderData/script1.cst +0 -58
- package/__tests__/renderData/script1.cst.svg +0 -1
- package/__tests__/renderData/script2.cst +0 -16
- package/__tests__/renderData/script2.cst.svg +0 -1
- package/__tests__/renderData/script3.cst +0 -30
- package/__tests__/renderData/script3.cst.svg +0 -1
- package/__tests__/renderData/script4.cst +0 -54
- package/__tests__/renderData/script4.cst.svg +0 -1
- package/__tests__/renderData/script5.cst +0 -23
- package/__tests__/renderData/script5.cst.svg +0 -1
- package/__tests__/renderData/script6.cst +0 -28
- package/__tests__/renderData/script6.cst.svg +0 -1
- package/__tests__/renderData/script7.cst +0 -26
- package/__tests__/renderData/script7.cst.svg +0 -1
- package/__tests__/renderData/script8.cst +0 -37
- package/__tests__/renderData/script8.cst.svg +0 -1
- package/__tests__/testCLI.ts +0 -68
- package/__tests__/testMathOps.ts +0 -36
- package/__tests__/testMergeWires.ts +0 -141
- package/__tests__/testParse.ts +0 -263
- package/__tests__/testRender.ts +0 -38
- package/build/src/parser.js +0 -69
- package/documentation.md +0 -238
- package/examples/example_arduino_uno.cst +0 -1146
- package/examples/example_garden_pump.cst +0 -567
- package/examples/lib.cst +0 -185
- package/fonts/Inter-Bold.ttf +0 -0
- package/fonts/Inter-Regular.ttf +0 -0
- package/fonts/OpenSans-Regular.ttf +0 -0
- package/fonts/Roboto-Regular.ttf +0 -0
- package/jest.config.js +0 -23
- package/libs/lib.cst +0 -185
- package/refresh.html +0 -42
- package/server.cjs +0 -50
- package/src/antlr/CircuitScript.g4 +0 -209
- package/src/antlr/CircuitScriptLexer.ts +0 -317
- package/src/antlr/CircuitScriptParser.ts +0 -4979
- package/src/antlr/CircuitScriptVisitor.ts +0 -420
- package/src/execute.ts +0 -1227
- package/src/fonts.ts +0 -1
- package/src/geometry.ts +0 -638
- package/src/globals.ts +0 -67
- package/src/helpers.ts +0 -114
- package/src/lexer.ts +0 -151
- package/src/logger.ts +0 -17
- package/src/main.ts +0 -105
- package/src/objects/ClassComponent.ts +0 -223
- package/src/objects/ExecutionScope.ts +0 -201
- package/src/objects/Frame.ts +0 -20
- package/src/objects/ParamDefinition.ts +0 -49
- package/src/objects/PinDefinition.ts +0 -49
- package/src/objects/PinTypes.ts +0 -7
- package/src/objects/Wire.ts +0 -19
- package/src/objects/types.ts +0 -66
- package/src/parser.ts +0 -106
- package/src/regenerate-tests.ts +0 -25
- package/src/render.ts +0 -260
- package/src/sizing.ts +0 -96
- package/tsconfig.json +0 -26
- package/tsconfig.release.json +0 -8
- /package/{build/src/antlr/CircuitScriptVisitor.js → dist/esm/antlr/CircuitScriptVisitor.mjs} +0 -0
- /package/{build/src/fonts.js → dist/esm/fonts.mjs} +0 -0
- /package/{build/src/globals.js → dist/esm/globals.mjs} +0 -0
- /package/{build/src/logger.js → dist/esm/logger.mjs} +0 -0
- /package/{build/src/objects/ExecutionScope.js → dist/esm/objects/ExecutionScope.mjs} +0 -0
- /package/{build/src/objects/Frame.js → dist/esm/objects/Frame.mjs} +0 -0
- /package/{build/src/objects/Net.js → dist/esm/objects/Net.mjs} +0 -0
- /package/{build/src/objects/ParamDefinition.js → dist/esm/objects/ParamDefinition.mjs} +0 -0
- /package/{build/src/objects/PinTypes.js → dist/esm/objects/PinTypes.mjs} +0 -0
- /package/{build/src/objects/Wire.js → dist/esm/objects/Wire.mjs} +0 -0
- /package/{build/src/objects/types.js → dist/esm/objects/types.mjs} +0 -0
- /package/{build/src/server.js → dist/esm/server.mjs} +0 -0
- /package/{build/src/utils.js → dist/esm/utils.mjs} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import Flatten from '@flatten-js/core';
|
|
2
|
+
import { Box } from '@svgdotjs/svg.js';
|
|
3
|
+
export type Segment = Flatten.Segment;
|
|
4
|
+
export type Polygon = Flatten.Polygon;
|
|
5
|
+
export type Multiline = Flatten.Multiline;
|
|
6
|
+
export type Line = Flatten.Line;
|
|
7
|
+
export type Arc = Flatten.Arc;
|
|
8
|
+
export type Feature = Segment | Polygon | Label | Arc | Multiline;
|
|
9
|
+
export type LabelStyle = {
|
|
10
|
+
font?: string;
|
|
11
|
+
fontSize?: number;
|
|
12
|
+
fontWeight?: string;
|
|
13
|
+
angle?: number;
|
|
14
|
+
anchor?: HorizontalAlign.Left | HorizontalAlign.Middle | HorizontalAlign.Right;
|
|
15
|
+
vanchor?: VerticalAlign.Top | VerticalAlign.Middle | VerticalAlign.Bottom;
|
|
16
|
+
};
|
|
17
|
+
export declare class Label extends Flatten.Polygon {
|
|
18
|
+
id: string;
|
|
19
|
+
text: string;
|
|
20
|
+
anchorPoint: [number, number];
|
|
21
|
+
boundingBox: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
polygon: Polygon;
|
|
26
|
+
font: string;
|
|
27
|
+
style: LabelStyle;
|
|
28
|
+
textMeasurementBounds: Box;
|
|
29
|
+
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
|
+
getLabelPosition(): [number, number];
|
|
34
|
+
}
|
|
35
|
+
export declare class GeometryProp {
|
|
36
|
+
name: string;
|
|
37
|
+
value: string | number;
|
|
38
|
+
constructor(name: any, value: any);
|
|
39
|
+
}
|
|
40
|
+
export declare class Geometry {
|
|
41
|
+
static point(x: number, y: number): Flatten.Point;
|
|
42
|
+
static line(x1: number, y1: number, x2: number, y2: number): Flatten.Line;
|
|
43
|
+
static label(id: string, x: number, y: number, text: string, style: LabelStyle): Label;
|
|
44
|
+
static segment(start: [number, number], end: [number, number]): Segment;
|
|
45
|
+
static polygon(coords: [number, number][]): Polygon;
|
|
46
|
+
static multiline(coords: [number, number][]): Multiline;
|
|
47
|
+
static arc(center: [x: number, y: number], radius: number, startAngle: number, endAngle: number, sweepDirection: boolean): Arc;
|
|
48
|
+
static getCoords(item: Feature): [number, number][];
|
|
49
|
+
static rotateDegs(feature: Feature, angleDegrees: number, center: [number, number]): Feature;
|
|
50
|
+
static groupRotate(features: Feature[], angle: number, center: [number, number]): Feature[];
|
|
51
|
+
static groupBounds(features: Feature[]): {
|
|
52
|
+
start: [number, number];
|
|
53
|
+
end: [number, number];
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
};
|
|
57
|
+
static getType(feature: Feature): string;
|
|
58
|
+
static FullCircleRadians: number;
|
|
59
|
+
static featuresToPath(items: Feature[]): {
|
|
60
|
+
path: string;
|
|
61
|
+
isClosedPolygon: boolean;
|
|
62
|
+
};
|
|
63
|
+
static angle(dx: number, dy: number): number;
|
|
64
|
+
static getQuadrant(dx: number, dy: number): number;
|
|
65
|
+
static mergeWires(wirePoints: {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
}[][]): {
|
|
69
|
+
intersectPoints: WirePointCount[];
|
|
70
|
+
segments: [x: number, y: number][][];
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
type WirePointCount = [x: number, y: number, count: number];
|
|
74
|
+
export declare enum HorizontalAlign {
|
|
75
|
+
Left = "left",
|
|
76
|
+
Middle = "middle",
|
|
77
|
+
Right = "right"
|
|
78
|
+
}
|
|
79
|
+
export declare enum VerticalAlign {
|
|
80
|
+
Top = "top",
|
|
81
|
+
Middle = "middle",
|
|
82
|
+
Bottom = "bottom"
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare enum GlobalNames {
|
|
2
|
+
__root = "__root",
|
|
3
|
+
gnd = "gnd",
|
|
4
|
+
DefaultResistor = "res",
|
|
5
|
+
DefaultCapacitor = "cap",
|
|
6
|
+
DefaultInductor = "ind",
|
|
7
|
+
symbol = "symbol"
|
|
8
|
+
}
|
|
9
|
+
export declare const NoNetText = "NO_NET";
|
|
10
|
+
export declare enum ParamKeys {
|
|
11
|
+
__is_net = "__is_net",
|
|
12
|
+
__is_label = "__is_label",
|
|
13
|
+
priority = "priority",
|
|
14
|
+
net_name = "net_name"
|
|
15
|
+
}
|
|
16
|
+
export declare enum LayoutDirection {
|
|
17
|
+
RIGHT = "RIGHT",
|
|
18
|
+
LEFT = "LEFT"
|
|
19
|
+
}
|
|
20
|
+
export declare enum SymbolPinSide {
|
|
21
|
+
Left = "left",
|
|
22
|
+
Right = "right"
|
|
23
|
+
}
|
|
24
|
+
export declare const portWidth = 20;
|
|
25
|
+
export declare const portHeight = 2;
|
|
26
|
+
export declare const defaultFont = "Open Sans-Regular, Arial";
|
|
27
|
+
export declare const defaultFontBold = "Open Sans-Bold, Arial-Bold, Arial";
|
|
28
|
+
export declare const defaultFontSize = 10;
|
|
29
|
+
export declare const bodyColor = "#FFFEAF";
|
|
30
|
+
export declare const junctionSize = 5;
|
|
31
|
+
export declare const junctionColor = "rgb(0, 132, 0)";
|
|
32
|
+
export declare const wireColor = "rgb(0, 132, 0)";
|
|
33
|
+
export declare enum ComponentTypes {
|
|
34
|
+
gnd = "gnd",
|
|
35
|
+
net = "net",
|
|
36
|
+
label = "label",
|
|
37
|
+
point = "point"
|
|
38
|
+
}
|
|
39
|
+
export declare enum ReferenceTypes {
|
|
40
|
+
function = "function",
|
|
41
|
+
value = "value",
|
|
42
|
+
variable = "variable",
|
|
43
|
+
instance = "instance"
|
|
44
|
+
}
|
|
45
|
+
export declare enum BlockTypes {
|
|
46
|
+
Branch = 1,
|
|
47
|
+
Join = 2,
|
|
48
|
+
Parallel = 3,
|
|
49
|
+
Point = 4
|
|
50
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare enum JSModuleType {
|
|
2
|
+
CommonJs = "cjs",
|
|
3
|
+
ESM = "mjs"
|
|
4
|
+
}
|
|
5
|
+
export declare function renderScript(scriptData: string, outputPath: string, options: any): string;
|
|
6
|
+
export declare function detectJSModuleType(): JSModuleType;
|
|
7
|
+
export declare function getCurrentPath(): {
|
|
8
|
+
filePath: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './draw_symbols.js';
|
|
2
|
+
export * from './execute.js';
|
|
3
|
+
export * from './export.js';
|
|
4
|
+
export * from './geometry.js';
|
|
5
|
+
export * from './globals.js';
|
|
6
|
+
export * from './helpers.js';
|
|
7
|
+
export * from './layout.js';
|
|
8
|
+
export * from './lexer.js';
|
|
9
|
+
export * from './logger.js';
|
|
10
|
+
export * from './parser.js';
|
|
11
|
+
export * from './render.js';
|
|
12
|
+
export * from './utils.js';
|
|
13
|
+
export * from './visitor.js';
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Graph, Edge } from '@dagrejs/graphlib';
|
|
2
|
+
import { SymbolGraphic, SymbolText } from "./draw_symbols.js";
|
|
3
|
+
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
4
|
+
import { SequenceItem } from "./objects/ExecutionScope.js";
|
|
5
|
+
import { WireSegment } from './objects/Wire.js';
|
|
6
|
+
import { Net } from './objects/Net.js';
|
|
7
|
+
import { Logger } from './logger.js';
|
|
8
|
+
import { Frame, FramePlotDirection } from './objects/Frame.js';
|
|
9
|
+
import { BoundBox } from './utils.js';
|
|
10
|
+
export declare class LayoutEngine {
|
|
11
|
+
logger: Logger;
|
|
12
|
+
placeSubgraphVersion: number;
|
|
13
|
+
layoutWarnings: string[];
|
|
14
|
+
constructor();
|
|
15
|
+
protected print(...params: any[]): void;
|
|
16
|
+
protected printLevel(level: number, ...params: any[]): void;
|
|
17
|
+
protected padLevel(value: number): string;
|
|
18
|
+
runLayout(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]): {
|
|
19
|
+
components: RenderComponent[];
|
|
20
|
+
wires: RenderWire[];
|
|
21
|
+
junctions: RenderJunction[];
|
|
22
|
+
mergedWires: MergedWire[];
|
|
23
|
+
frameObjects: RenderFrame[];
|
|
24
|
+
textObjects: RenderText[];
|
|
25
|
+
};
|
|
26
|
+
findJunctions(wireGroups: Map<string, RenderWire[]>): {
|
|
27
|
+
junctions: RenderJunction[];
|
|
28
|
+
mergedWires: MergedWire[];
|
|
29
|
+
};
|
|
30
|
+
placeFrames(graph: Graph, subgraphInfo: SubGraphInfo[], frameObjects: RenderFrame[]): {
|
|
31
|
+
elementFrames: RenderFrame[];
|
|
32
|
+
textObjects: RenderText[];
|
|
33
|
+
};
|
|
34
|
+
collectElementFrames(frame: RenderFrame, level?: number): RenderFrame[];
|
|
35
|
+
applyFrameOffset(frame: RenderFrame, level?: number): void;
|
|
36
|
+
placeAndSizeFrame(frame: RenderFrame, level?: number): void;
|
|
37
|
+
dumpFrame(frame: RenderFrame, level?: number): void;
|
|
38
|
+
prepareFrames(graph: Graph, subgraphInfo: SubGraphInfo[], frame: RenderFrame, level?: number): {
|
|
39
|
+
elementFrames: RenderFrame[];
|
|
40
|
+
textObjects: RenderText[];
|
|
41
|
+
};
|
|
42
|
+
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]): {
|
|
43
|
+
graph: Graph;
|
|
44
|
+
containerFrames: RenderFrame[];
|
|
45
|
+
};
|
|
46
|
+
setGraphEdge(graph: Graph, node1: string, node2: string, edgeValue: EdgeValue): void;
|
|
47
|
+
sizeSubGraphs(graph: Graph): SubGraphInfo[];
|
|
48
|
+
walkAndPlaceGraph(graph: Graph, firstNodeId: string, subgraphNodes: string[]): void;
|
|
49
|
+
placeSubgraphV2(graph: Graph, firstNodeId: string, subgraphEdges: Edge[]): void;
|
|
50
|
+
mergeOriginNodes(node1: RenderItem, pin1: number, node2: RenderItem, pin2: number, originNode1: string, originNode2: string, originNodes: RenderItem[], originNodeGroups: Map<string, RenderItem[]>): void;
|
|
51
|
+
placeSubgraph(graph: Graph, firstNodeId: string, subgraphEdges: Edge[]): void;
|
|
52
|
+
translateNodeBy(offsetX: number, offsetY: number, item: RenderItem): void;
|
|
53
|
+
placeNodeAtPosition(fromX: number, fromY: number, item: RenderItem, pin: number, depth?: number): void;
|
|
54
|
+
placeFloatingItems(graph: Graph, item: RenderItem, depth?: number): void;
|
|
55
|
+
printWarnings(): void;
|
|
56
|
+
}
|
|
57
|
+
type EdgeValue = [
|
|
58
|
+
instance1: string,
|
|
59
|
+
instancePin1: number,
|
|
60
|
+
instance2: string,
|
|
61
|
+
instancePin2: number,
|
|
62
|
+
priority: number
|
|
63
|
+
];
|
|
64
|
+
type RenderItem = RenderComponent | RenderWire | RenderText;
|
|
65
|
+
export declare function getBounds(components: (RenderComponent | RenderText)[], wires: RenderWire[], junctions: RenderJunction[], frames: RenderFrame[]): BoundBox;
|
|
66
|
+
export declare class RenderObject {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
isFloating: boolean;
|
|
70
|
+
floatingRelativeTo: [selfPin: number, nodeId: string, pin: number][];
|
|
71
|
+
}
|
|
72
|
+
export declare class RenderWire extends RenderObject {
|
|
73
|
+
id: number;
|
|
74
|
+
segments: WireSegment[];
|
|
75
|
+
points: {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
}[];
|
|
79
|
+
netName: string;
|
|
80
|
+
constructor(x: number, y: number, segments: WireSegment[]);
|
|
81
|
+
refreshPoints(): void;
|
|
82
|
+
getAutoPoints(value: [x: number, y: number], direction: 'auto' | 'auto_'): [dx: number, dy: number][];
|
|
83
|
+
getWireEnd(): {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
};
|
|
87
|
+
isEndAutoLength(): boolean;
|
|
88
|
+
getEndAuto(): [instance: ClassComponent, pin: number];
|
|
89
|
+
setEndAuto(untilX: number, untilY: number): void;
|
|
90
|
+
toString(): string;
|
|
91
|
+
}
|
|
92
|
+
export type MergedWire = {
|
|
93
|
+
netName: string;
|
|
94
|
+
segments: [x: number, y: number][][];
|
|
95
|
+
intersectPoints: [x: number, y: number, count: number][];
|
|
96
|
+
};
|
|
97
|
+
export declare class RenderComponent extends RenderObject {
|
|
98
|
+
component: ClassComponent;
|
|
99
|
+
symbol: SymbolGraphic;
|
|
100
|
+
width: number;
|
|
101
|
+
height: number;
|
|
102
|
+
displaySymbol: string | null;
|
|
103
|
+
constructor(component: ClassComponent, width: number, height: number);
|
|
104
|
+
doesOverlap(other: RenderComponent): boolean;
|
|
105
|
+
toString(): string;
|
|
106
|
+
}
|
|
107
|
+
export declare class RenderText extends RenderObject {
|
|
108
|
+
symbol: SymbolText;
|
|
109
|
+
_fontSize: number;
|
|
110
|
+
_fontWeight: string;
|
|
111
|
+
get fontSize(): number;
|
|
112
|
+
set fontSize(value: number);
|
|
113
|
+
get fontWeight(): string;
|
|
114
|
+
set fontWeight(value: string);
|
|
115
|
+
constructor(text: string);
|
|
116
|
+
}
|
|
117
|
+
export declare class RenderFrame extends RenderObject {
|
|
118
|
+
bounds: BoundBox | null;
|
|
119
|
+
frame: Frame;
|
|
120
|
+
innerItems: (RenderComponent | RenderFrame | RenderText)[];
|
|
121
|
+
translateX: number;
|
|
122
|
+
translateY: number;
|
|
123
|
+
padding: number;
|
|
124
|
+
gap: number;
|
|
125
|
+
direction: FramePlotDirection;
|
|
126
|
+
borderWidth: number;
|
|
127
|
+
subgraphId: string;
|
|
128
|
+
type: RenderFrameType;
|
|
129
|
+
containsTitle: boolean;
|
|
130
|
+
constructor(frame: Frame, type?: RenderFrameType);
|
|
131
|
+
toString(): string;
|
|
132
|
+
}
|
|
133
|
+
export declare enum RenderFrameType {
|
|
134
|
+
Container = 1,
|
|
135
|
+
Elements = 2
|
|
136
|
+
}
|
|
137
|
+
export declare class RenderJunction {
|
|
138
|
+
x: number;
|
|
139
|
+
y: number;
|
|
140
|
+
constructor(x: number, y: number);
|
|
141
|
+
}
|
|
142
|
+
type SubGraphInfo = {
|
|
143
|
+
firstNodeId: string;
|
|
144
|
+
components: string[];
|
|
145
|
+
bounds: BoundBox;
|
|
146
|
+
};
|
|
147
|
+
export { BoundBox };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CharStream, Token } from "antlr4";
|
|
2
|
+
import CircuitScriptLexer from "./antlr/CircuitScriptLexer.js";
|
|
3
|
+
export declare class MainLexer extends CircuitScriptLexer {
|
|
4
|
+
tokens: any[];
|
|
5
|
+
indents: any[];
|
|
6
|
+
opened: number;
|
|
7
|
+
constructor(input: CharStream);
|
|
8
|
+
reset(): void;
|
|
9
|
+
emitToken(token: Token): void;
|
|
10
|
+
nextToken(): Token;
|
|
11
|
+
createDedent(): Token;
|
|
12
|
+
getCharIndex(): number;
|
|
13
|
+
commonToken(type: number, text: string): Token;
|
|
14
|
+
getIndentationCount(whitespace: string): number;
|
|
15
|
+
atStartOfInput(): boolean;
|
|
16
|
+
openBrace(): void;
|
|
17
|
+
closeBrace(): void;
|
|
18
|
+
onNewLine(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SymbolDrawingCommands } from '../draw_symbols.js';
|
|
2
|
+
import { Net } from './Net.js';
|
|
3
|
+
import { PinDefinition, PinId } from './PinDefinition.js';
|
|
4
|
+
import { WireSegment } from './Wire.js';
|
|
5
|
+
export declare class ClassComponent {
|
|
6
|
+
instanceName: string;
|
|
7
|
+
numPins: number;
|
|
8
|
+
parameters: Map<string, number | string>;
|
|
9
|
+
pins: Map<number, PinDefinition>;
|
|
10
|
+
pinNets: Map<number, Net>;
|
|
11
|
+
pinWires: Map<number, WireSegment[]>;
|
|
12
|
+
_cachedPins: string;
|
|
13
|
+
_cachedParams: string;
|
|
14
|
+
className: string;
|
|
15
|
+
_copyID?: number;
|
|
16
|
+
_copyFrom?: ClassComponent;
|
|
17
|
+
arrangeProps: Map<string, number[]> | null;
|
|
18
|
+
displayProp: string | SymbolDrawingCommands | null;
|
|
19
|
+
widthProp: number | null;
|
|
20
|
+
typeProp: string | null;
|
|
21
|
+
styles: {
|
|
22
|
+
[key: string]: number | string;
|
|
23
|
+
};
|
|
24
|
+
assignedRefDes: string | null;
|
|
25
|
+
constructor(instanceName: string, numPins: number, className: string);
|
|
26
|
+
setupPins(): void;
|
|
27
|
+
getDefaultPin(): number;
|
|
28
|
+
hasPin(pinId: number | string): boolean;
|
|
29
|
+
getPin(pinId: number | string): PinId;
|
|
30
|
+
getNextPinAfter(pinIndex: number): number;
|
|
31
|
+
setParam(key: string, value: number | string): void;
|
|
32
|
+
private refreshParamCache;
|
|
33
|
+
private refreshPinsCache;
|
|
34
|
+
refreshCache(): void;
|
|
35
|
+
getParam(key: string): number | string;
|
|
36
|
+
toString(): string;
|
|
37
|
+
static simple(instanceName: string, numPins: number, className: string): ClassComponent;
|
|
38
|
+
isEqual(other: ClassComponent): boolean;
|
|
39
|
+
clone(): ClassComponent;
|
|
40
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ClassComponent } from './ClassComponent.js';
|
|
2
|
+
import { Net } from './Net.js';
|
|
3
|
+
import { CFunction, ComponentPinNet, ComponentPinNetPair, ValueType } from './types.js';
|
|
4
|
+
import { LayoutDirection } from '../globals.js';
|
|
5
|
+
import { Wire, WireSegment } from './Wire.js';
|
|
6
|
+
import { Frame } from './Frame.js';
|
|
7
|
+
export declare class ExecutionScope {
|
|
8
|
+
scopeId: number;
|
|
9
|
+
private nets;
|
|
10
|
+
instances: Map<string, ClassComponent>;
|
|
11
|
+
functions: Map<string, CFunction>;
|
|
12
|
+
variables: Map<string, ValueType | ClassComponent>;
|
|
13
|
+
blockStack: Map<number, any>;
|
|
14
|
+
wires: Wire[];
|
|
15
|
+
frames: Frame[];
|
|
16
|
+
indentLevel: number;
|
|
17
|
+
netCounter: number;
|
|
18
|
+
unnamedCounter: number;
|
|
19
|
+
currentComponent: ClassComponent | null;
|
|
20
|
+
currentPin: number | null;
|
|
21
|
+
currentWireId: number;
|
|
22
|
+
currentFrameId: number;
|
|
23
|
+
netGnd: Net | null;
|
|
24
|
+
componentGnd: ClassComponent | null;
|
|
25
|
+
componentRoot: ClassComponent | null;
|
|
26
|
+
copyIDs: Map<string, number>;
|
|
27
|
+
sequence: any[];
|
|
28
|
+
constructor(scopeId: number);
|
|
29
|
+
static scopeId: number;
|
|
30
|
+
static create(): ExecutionScope;
|
|
31
|
+
private findNet;
|
|
32
|
+
getNetWithName(name: string): Net;
|
|
33
|
+
hasNet(component: ClassComponent, pin: number): boolean;
|
|
34
|
+
getNet(component: ClassComponent, pin: number): Net;
|
|
35
|
+
setNet(component: ClassComponent, pin: number, net: Net): void;
|
|
36
|
+
removeNet(component: ClassComponent, pin: number): void;
|
|
37
|
+
getNets(): ComponentPinNetPair[];
|
|
38
|
+
dumpNets(): ComponentPinNet[];
|
|
39
|
+
printNets(): void;
|
|
40
|
+
setActive(type: ActiveObject, item: any): void;
|
|
41
|
+
clearActive(): void;
|
|
42
|
+
}
|
|
43
|
+
export declare enum SequenceAction {
|
|
44
|
+
To = "to",
|
|
45
|
+
At = "at",
|
|
46
|
+
Wire = "wire",
|
|
47
|
+
WireJump = "wire-jump",
|
|
48
|
+
Frame = "frame"
|
|
49
|
+
}
|
|
50
|
+
export declare enum FrameAction {
|
|
51
|
+
Enter = "enter",
|
|
52
|
+
Exit = "exit"
|
|
53
|
+
}
|
|
54
|
+
export declare enum ActiveObject {
|
|
55
|
+
Frame = "frame",
|
|
56
|
+
Wire = "wire"
|
|
57
|
+
}
|
|
58
|
+
export type SequenceItem = [
|
|
59
|
+
SequenceAction.To | SequenceAction.At,
|
|
60
|
+
ClassComponent,
|
|
61
|
+
number,
|
|
62
|
+
LayoutDirection?,
|
|
63
|
+
string?
|
|
64
|
+
] | [SequenceAction.Wire, wireId: number, WireSegment[]] | [SequenceAction.WireJump, wireId: number, pinId: number] | [SequenceAction.Frame, Frame, "enter" | "exit"];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Frame {
|
|
2
|
+
parameters: Map<string, any>;
|
|
3
|
+
frameId: number;
|
|
4
|
+
constructor(frameId: number);
|
|
5
|
+
}
|
|
6
|
+
export declare enum FrameParamKeys {
|
|
7
|
+
Title = "title",
|
|
8
|
+
Direction = "direction",
|
|
9
|
+
Padding = "padding",
|
|
10
|
+
Border = "border"
|
|
11
|
+
}
|
|
12
|
+
export declare enum FramePlotDirection {
|
|
13
|
+
Row = "row",
|
|
14
|
+
Column = "column"
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Net {
|
|
2
|
+
name: string;
|
|
3
|
+
baseName: string;
|
|
4
|
+
namespace: string;
|
|
5
|
+
priority: number;
|
|
6
|
+
type: any;
|
|
7
|
+
constructor(namespace: string, name: string, priority?: number, type?: any);
|
|
8
|
+
toString(): string;
|
|
9
|
+
static isSame(netA: Net, netB: Net): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class ParamDefinition {
|
|
2
|
+
paramName: string;
|
|
3
|
+
paramValue: string | number | any;
|
|
4
|
+
constructor(paramName: string, paramValue: any);
|
|
5
|
+
}
|
|
6
|
+
export declare class NumericValue {
|
|
7
|
+
value: string | number;
|
|
8
|
+
constructor(value: string | number);
|
|
9
|
+
toString(): string;
|
|
10
|
+
toDisplayString(): string;
|
|
11
|
+
}
|
|
12
|
+
export declare class PercentageValue {
|
|
13
|
+
value: string | number;
|
|
14
|
+
constructor(value: string | number);
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|
|
17
|
+
export declare class PinBlankValue {
|
|
18
|
+
blank: number;
|
|
19
|
+
constructor(value: number);
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PinTypes } from './PinTypes.js';
|
|
2
|
+
export type PinId = number | string;
|
|
3
|
+
export declare class PinDefinition {
|
|
4
|
+
id: PinId;
|
|
5
|
+
idType: PinIdType;
|
|
6
|
+
pinType: PinTypes;
|
|
7
|
+
name: string;
|
|
8
|
+
altNames: string[];
|
|
9
|
+
side: string;
|
|
10
|
+
position: number;
|
|
11
|
+
constructor(id: PinId, idType: PinIdType, name: string, pinType?: PinTypes, altNames?: never[]);
|
|
12
|
+
}
|
|
13
|
+
export declare enum PinIdType {
|
|
14
|
+
Int = "int",
|
|
15
|
+
Str = "str"
|
|
16
|
+
}
|
|
17
|
+
export declare enum PortSide {
|
|
18
|
+
WEST = "WEST",
|
|
19
|
+
EAST = "EAST",
|
|
20
|
+
SOUTH = "SOUTH",
|
|
21
|
+
NORTH = "NORTH"
|
|
22
|
+
}
|
|
23
|
+
export declare class PinReference {
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClassComponent } from "./ClassComponent.js";
|
|
2
|
+
export declare class Wire {
|
|
3
|
+
path: WireSegment[];
|
|
4
|
+
constructor(path: WireSegment[]);
|
|
5
|
+
}
|
|
6
|
+
export type WireSegment = {
|
|
7
|
+
direction: 'up' | 'down' | 'left' | 'right' | 'auto' | 'auto_';
|
|
8
|
+
value: number;
|
|
9
|
+
valueXY?: [x: number, y: number];
|
|
10
|
+
until?: [instance: ClassComponent, pin: number];
|
|
11
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ExecutionContext } from '../execute.js';
|
|
2
|
+
import { ClassComponent } from './ClassComponent.js';
|
|
3
|
+
import { Net } from './Net.js';
|
|
4
|
+
import { NumericValue, PercentageValue, PinBlankValue } from './ParamDefinition.js';
|
|
5
|
+
export type CFunction = (args: CallableParameter[], options?: CFunctionOptions) => CFunctionResult;
|
|
6
|
+
export type CFunctionOptions = {
|
|
7
|
+
netNamespace?: string;
|
|
8
|
+
};
|
|
9
|
+
export type CFunctionResult = [
|
|
10
|
+
executionContext: ExecutionContext,
|
|
11
|
+
result: ValueType | ClassComponent | null
|
|
12
|
+
];
|
|
13
|
+
export type ComponentPinNet = [
|
|
14
|
+
netName: string,
|
|
15
|
+
instanceName: string,
|
|
16
|
+
pin: number
|
|
17
|
+
];
|
|
18
|
+
export type ComponentPinNetPair = [
|
|
19
|
+
component: ClassComponent,
|
|
20
|
+
pin: number,
|
|
21
|
+
net: Net
|
|
22
|
+
];
|
|
23
|
+
export type ComponentPin = [
|
|
24
|
+
component: ClassComponent,
|
|
25
|
+
pinId: number | string
|
|
26
|
+
];
|
|
27
|
+
export type ComplexType = ValueType | ClassComponent | UndeclaredReference | null;
|
|
28
|
+
export type ValueType = boolean | number | string | NumericValue | PercentageValue | PinBlankValue;
|
|
29
|
+
export type CallableParameter = [
|
|
30
|
+
'keyword',
|
|
31
|
+
key: string,
|
|
32
|
+
value: ValueType
|
|
33
|
+
] | [
|
|
34
|
+
'position',
|
|
35
|
+
key: number,
|
|
36
|
+
value: ValueType
|
|
37
|
+
];
|
|
38
|
+
export type FunctionDefinedParameter = [name: string, defaultValue: ValueType] | [name: string];
|
|
39
|
+
export declare class UndeclaredReference {
|
|
40
|
+
reference: ReferenceType;
|
|
41
|
+
constructor(reference: ReferenceType);
|
|
42
|
+
}
|
|
43
|
+
export type ReferenceType = {
|
|
44
|
+
found: boolean;
|
|
45
|
+
name?: string;
|
|
46
|
+
trailers?: string[];
|
|
47
|
+
type?: string;
|
|
48
|
+
value?: any;
|
|
49
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ErrorListener, ParseTreeVisitor, ParserRuleContext, TerminalNode } from 'antlr4';
|
|
2
|
+
import CircuitScriptLexer from './antlr/CircuitScriptLexer.js';
|
|
3
|
+
import CircuitScriptParser, { ScriptContext } from './antlr/CircuitScriptParser.js';
|
|
4
|
+
import { MainVisitor } from './visitor.js';
|
|
5
|
+
export declare function parseFileWithVisitor(visitor: MainVisitor, data: string): {
|
|
6
|
+
tree: ScriptContext;
|
|
7
|
+
parser: CircuitScriptParser;
|
|
8
|
+
hasError: boolean;
|
|
9
|
+
hasParseError: boolean;
|
|
10
|
+
parserTimeTaken: number;
|
|
11
|
+
lexerTimeTaken: number;
|
|
12
|
+
tokens: IParsedToken[];
|
|
13
|
+
};
|
|
14
|
+
export declare class SemanticTokensVisitor extends ParseTreeVisitor<any> {
|
|
15
|
+
parsedTokens: IParsedToken[];
|
|
16
|
+
lexer: CircuitScriptLexer;
|
|
17
|
+
script: string;
|
|
18
|
+
semanticTokens: Map<string, IParsedToken>;
|
|
19
|
+
constructor(lexer: CircuitScriptLexer, script: string);
|
|
20
|
+
visit(ctx: ParserRuleContext): any;
|
|
21
|
+
handleError(ctx: ParserRuleContext, err: Error): void;
|
|
22
|
+
checkContext(ctx: ParserRuleContext): void;
|
|
23
|
+
addSemanticToken(parsedToken: IParsedToken): void;
|
|
24
|
+
parseToken(node: TerminalNode, modifiers: string[], tokenType?: string | null): IParsedToken;
|
|
25
|
+
}
|
|
26
|
+
export interface IParsedToken {
|
|
27
|
+
line: number;
|
|
28
|
+
column: number;
|
|
29
|
+
length: number;
|
|
30
|
+
tokenType: string;
|
|
31
|
+
tokenModifiers: string[];
|
|
32
|
+
textValue: string;
|
|
33
|
+
}
|
|
34
|
+
export declare class CircuitscriptParserErrorListener extends ErrorListener {
|
|
35
|
+
syntaxErrorCounter: number;
|
|
36
|
+
syntaxError(recognizer: any, offendingSymbol: any, line: number, column: number, msg: string, e: any | undefined): void;
|
|
37
|
+
hasParseErrors(): boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BoundBox, MergedWire, RenderComponent, RenderFrame, RenderJunction, RenderText, RenderWire } from "./layout.js";
|
|
2
|
+
export declare function generateSVG2(graph: {
|
|
3
|
+
components: RenderComponent[];
|
|
4
|
+
wires: RenderWire[];
|
|
5
|
+
junctions: RenderJunction[];
|
|
6
|
+
mergedWires: MergedWire[];
|
|
7
|
+
debugRects?: BoundBox[];
|
|
8
|
+
frameObjects: RenderFrame[];
|
|
9
|
+
textObjects: RenderText[];
|
|
10
|
+
}): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Box, SVGTypeMapping } from '@svgdotjs/svg.js';
|
|
2
|
+
import { HorizontalAlign, VerticalAlign } from './geometry.js';
|
|
3
|
+
import { SVGWindow } from 'svgdom';
|
|
4
|
+
export declare function prepareSVGEnvironment(fontsPath: string | null): Promise<void>;
|
|
5
|
+
export declare function getCreateSVGWindow(): () => SVGWindow;
|
|
6
|
+
export declare function applyFontsToSVG(canvas: SVGTypeMapping): void;
|
|
7
|
+
export declare function measureTextSize(text: string, fontFamily: string, fontSize: number): Promise<{
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function measureTextSize2(text: string, fontFamily: string, fontSize: number, fontWeight?: string, anchor?: HorizontalAlign, vanchor?: VerticalAlign): {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
box: Box;
|
|
15
|
+
};
|