circuitscript 0.1.16 → 0.1.17
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 +2 -1
- package/dist/cjs/draw_symbols.js +18 -17
- package/dist/cjs/execute.js +40 -20
- package/dist/cjs/globals.js +1 -0
- package/dist/cjs/graph.js +101 -27
- package/dist/cjs/layout.js +6 -1
- package/dist/cjs/objects/ClassComponent.js +27 -20
- package/dist/cjs/objects/ExecutionScope.js +7 -2
- package/dist/cjs/objects/Net.js +1 -1
- package/dist/cjs/objects/PinDefinition.js +55 -3
- package/dist/cjs/objects/types.js +16 -1
- package/dist/cjs/visitor.js +56 -18
- package/dist/esm/BaseVisitor.js +2 -1
- package/dist/esm/draw_symbols.js +18 -17
- package/dist/esm/execute.js +41 -21
- package/dist/esm/globals.js +1 -0
- package/dist/esm/graph.js +79 -28
- package/dist/esm/layout.js +6 -1
- package/dist/esm/objects/ClassComponent.js +28 -21
- package/dist/esm/objects/ExecutionScope.js +7 -2
- package/dist/esm/objects/Net.js +1 -1
- package/dist/esm/objects/PinDefinition.js +53 -2
- package/dist/esm/objects/types.js +15 -0
- package/dist/esm/visitor.js +58 -20
- package/dist/libs/std.cst +3 -2
- package/dist/types/BaseVisitor.d.ts +2 -1
- package/dist/types/draw_symbols.d.ts +13 -7
- package/dist/types/execute.d.ts +7 -7
- package/dist/types/globals.d.ts +1 -0
- package/dist/types/graph.d.ts +2 -1
- package/dist/types/layout.d.ts +2 -1
- package/dist/types/objects/ClassComponent.d.ts +8 -8
- package/dist/types/objects/ExecutionScope.d.ts +5 -4
- package/dist/types/objects/Net.d.ts +2 -2
- package/dist/types/objects/PinDefinition.d.ts +17 -2
- package/dist/types/objects/types.d.ts +15 -1
- package/libs/std.cst +3 -2
- package/package.json +2 -1
package/dist/types/execute.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ClassComponent } from './objects/ClassComponent.js';
|
|
|
4
4
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
5
5
|
import { Net } from './objects/Net.js';
|
|
6
6
|
import { NumericValue, ParamDefinition } from './objects/ParamDefinition.js';
|
|
7
|
-
import { PinDefinition } from './objects/PinDefinition.js';
|
|
7
|
+
import { PinDefinition, PinId } from './objects/PinDefinition.js';
|
|
8
8
|
import { AnyReference, CFunction, CFunctionEntry, CFunctionResult, CallableParameter, ComponentPin } from './objects/types.js';
|
|
9
9
|
import { Logger } from './logger.js';
|
|
10
10
|
import { UnitDimension } from './helpers.js';
|
|
@@ -21,7 +21,7 @@ export declare class ExecutionContext {
|
|
|
21
21
|
found: boolean;
|
|
22
22
|
net?: Net;
|
|
23
23
|
});
|
|
24
|
-
resolveComponentPinNet: (component: ClassComponent, pin:
|
|
24
|
+
resolveComponentPinNet: (component: ClassComponent, pin: PinId) => Net | null;
|
|
25
25
|
stopFurtherExpressions: boolean;
|
|
26
26
|
returnValue: null;
|
|
27
27
|
silent: boolean;
|
|
@@ -40,7 +40,7 @@ export declare class ExecutionContext {
|
|
|
40
40
|
private linkComponentPinNet;
|
|
41
41
|
private mergeNets;
|
|
42
42
|
createComponent(instanceName: string, pins: PinDefinition[], params: ParamDefinition[], props: {
|
|
43
|
-
arrange?: Map<string,
|
|
43
|
+
arrange?: Map<string, PinId[]>;
|
|
44
44
|
display?: SymbolDrawingCommands;
|
|
45
45
|
type?: string;
|
|
46
46
|
width?: number;
|
|
@@ -52,11 +52,11 @@ export declare class ExecutionContext {
|
|
|
52
52
|
private removeArrangePropDuplicates;
|
|
53
53
|
private getArrangePropPins;
|
|
54
54
|
printPoint(extra?: string): void;
|
|
55
|
-
addComponentExisting(component: ClassComponent, pin:
|
|
55
|
+
addComponentExisting(component: ClassComponent, pin: PinId): ComponentPin;
|
|
56
56
|
toComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
57
57
|
addSequence?: boolean;
|
|
58
58
|
}): ComponentPin;
|
|
59
|
-
atComponent(component: ClassComponent, pinId:
|
|
59
|
+
atComponent(component: ClassComponent, pinId: PinId | null, options?: {
|
|
60
60
|
addSequence?: boolean;
|
|
61
61
|
}): ComponentPin;
|
|
62
62
|
copyComponent(component: ClassComponent): ClassComponent;
|
|
@@ -86,12 +86,12 @@ export declare class ExecutionContext {
|
|
|
86
86
|
enterFrame(frameType: FrameType): number;
|
|
87
87
|
exitFrame(frameId: number): void;
|
|
88
88
|
}
|
|
89
|
-
export declare function getPortSide(pins: Map<
|
|
89
|
+
export declare function getPortSide(pins: Map<PinId, PinDefinition>, arrangeProps: null | Map<string, number[]>): {
|
|
90
90
|
pins: PortSideItem[];
|
|
91
91
|
maxPositions: Map<string, number>;
|
|
92
92
|
};
|
|
93
93
|
type PortSideItem = {
|
|
94
|
-
pinId:
|
|
94
|
+
pinId: PinId;
|
|
95
95
|
side: string;
|
|
96
96
|
order: number;
|
|
97
97
|
position: number;
|
package/dist/types/globals.d.ts
CHANGED
package/dist/types/graph.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ import { SequenceItem } from "./objects/ExecutionScope.js";
|
|
|
6
6
|
import { Net } from "./objects/Net.js";
|
|
7
7
|
import { Logger } from "./logger.js";
|
|
8
8
|
import { ComponentPinNetPair } from "./objects/types.js";
|
|
9
|
+
import { PinId } from "./objects/PinDefinition.js";
|
|
9
10
|
export declare class NetGraph {
|
|
10
11
|
logger: Logger;
|
|
11
12
|
constructor(logger: Logger);
|
|
12
|
-
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin:
|
|
13
|
+
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin: PinId, net: Net][]): {
|
|
13
14
|
graph: Graph;
|
|
14
15
|
containerFrames: RenderFrame[];
|
|
15
16
|
};
|
package/dist/types/layout.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Logger } from './logger.js';
|
|
|
8
8
|
import { Frame, FramePlotDirection } from './objects/Frame.js';
|
|
9
9
|
import { BoundBox } from './utils.js';
|
|
10
10
|
import { ComponentPinNetPair } from './objects/types.js';
|
|
11
|
+
import { PinId } from './objects/PinDefinition.js';
|
|
11
12
|
import { NumericValue } from './objects/ParamDefinition.js';
|
|
12
13
|
export declare class LayoutEngine {
|
|
13
14
|
logger: Logger;
|
|
@@ -35,7 +36,7 @@ export declare class LayoutEngine {
|
|
|
35
36
|
private placeSubgraphV2;
|
|
36
37
|
mergeOriginNodes(node1: RenderItem, pin1: number, node2: RenderItem, pin2: number, originNode1: string, originNode2: string, originNodes: RenderItem[], originNodeGroups: Map<string, RenderItem[]>): void;
|
|
37
38
|
translateNodeBy(offsetX: number, offsetY: number, item: RenderItem): void;
|
|
38
|
-
placeNodeAtPosition(fromX: NumericValue, fromY: NumericValue, item: RenderItem, pin:
|
|
39
|
+
placeNodeAtPosition(fromX: NumericValue, fromY: NumericValue, item: RenderItem, pin: PinId, depth?: number): void;
|
|
39
40
|
placeFloatingItems(graph: Graph, item: RenderItem, depth?: number): void;
|
|
40
41
|
printWarnings(): void;
|
|
41
42
|
}
|
|
@@ -9,8 +9,8 @@ export declare class ClassComponent {
|
|
|
9
9
|
instanceName: string;
|
|
10
10
|
numPins: number;
|
|
11
11
|
parameters: Map<string, number | string | NumericValue>;
|
|
12
|
-
pins: Map<
|
|
13
|
-
pinNets: Map<
|
|
12
|
+
pins: Map<PinId, PinDefinition>;
|
|
13
|
+
pinNets: Map<PinId, Net>;
|
|
14
14
|
pinWires: Map<number, WireSegment[]>;
|
|
15
15
|
pinsMaxPositions: Map<string, number>;
|
|
16
16
|
_cachedPins: string;
|
|
@@ -18,8 +18,8 @@ export declare class ClassComponent {
|
|
|
18
18
|
_copyID?: number;
|
|
19
19
|
_copyFrom?: ClassComponent;
|
|
20
20
|
_pointLinkComponent?: ClassComponent;
|
|
21
|
-
_unplacedPins:
|
|
22
|
-
arrangeProps: Map<string,
|
|
21
|
+
_unplacedPins: PinId[];
|
|
22
|
+
arrangeProps: Map<string, PinId[]> | null;
|
|
23
23
|
displayProp: SymbolDrawingCommands | null;
|
|
24
24
|
widthProp: number | null;
|
|
25
25
|
heightProp: number | null;
|
|
@@ -33,10 +33,10 @@ export declare class ClassComponent {
|
|
|
33
33
|
assignedRefDes: string | null;
|
|
34
34
|
constructor(instanceName: string, numPins: number);
|
|
35
35
|
setupPins(): void;
|
|
36
|
-
getDefaultPin():
|
|
37
|
-
hasPin(pinId:
|
|
38
|
-
getPin(pinId:
|
|
39
|
-
getNextPinAfter(pinIndex:
|
|
36
|
+
getDefaultPin(): PinId;
|
|
37
|
+
hasPin(pinId: PinId): boolean;
|
|
38
|
+
getPin(pinId: PinId): PinId;
|
|
39
|
+
getNextPinAfter(pinIndex: PinId): PinId;
|
|
40
40
|
setParam(key: string, value: number | string | NumericValue): void;
|
|
41
41
|
hasParam(key: string): boolean;
|
|
42
42
|
private refreshParamCache;
|
|
@@ -6,6 +6,7 @@ import { Wire, WireSegment } from './Wire.js';
|
|
|
6
6
|
import { Frame } from './Frame.js';
|
|
7
7
|
import { ParserRuleContext } from 'antlr4ng';
|
|
8
8
|
import { BaseVisitor } from 'src/BaseVisitor.js';
|
|
9
|
+
import { PinId } from './PinDefinition.js';
|
|
9
10
|
type OnPropertyHandler = (path: PropertyTreeKey[], value: any, valueContext: ParserRuleContext) => void;
|
|
10
11
|
export type PropertyTreeKey = [ctx: ParserRuleContext, value: any] | ['index', number];
|
|
11
12
|
export declare class ExecutionScope {
|
|
@@ -39,10 +40,10 @@ export declare class ExecutionScope {
|
|
|
39
40
|
private findNet;
|
|
40
41
|
getNetWithName(name: string): Net;
|
|
41
42
|
getNetWithNamespacePath(namespace: string, name: string): Net | null;
|
|
42
|
-
hasNet(component: ClassComponent, pin:
|
|
43
|
-
getNet(component: ClassComponent, pin:
|
|
44
|
-
setNet(component: ClassComponent, pin:
|
|
45
|
-
removeNet(component: ClassComponent, pin:
|
|
43
|
+
hasNet(component: ClassComponent, pin: PinId): boolean;
|
|
44
|
+
getNet(component: ClassComponent, pin: PinId): Net | null;
|
|
45
|
+
setNet(component: ClassComponent, pin: PinId, net: Net): void;
|
|
46
|
+
removeNet(component: ClassComponent, pin: PinId): void;
|
|
46
47
|
getNets(): ComponentPinNetPair[];
|
|
47
48
|
dumpNets(): ComponentPinNet[];
|
|
48
49
|
printNets(): void;
|
|
@@ -3,9 +3,9 @@ export declare class Net {
|
|
|
3
3
|
baseName: string;
|
|
4
4
|
namespace: string;
|
|
5
5
|
priority: number;
|
|
6
|
-
type:
|
|
6
|
+
type: string;
|
|
7
7
|
params: Map<string, any>;
|
|
8
|
-
constructor(namespace: string, name: string, priority?: number, type?:
|
|
8
|
+
constructor(namespace: string, name: string, priority?: number, type?: string);
|
|
9
9
|
toString(): string;
|
|
10
10
|
static isSame(netA: Net, netB: Net): boolean;
|
|
11
11
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import { NumericValue } from './ParamDefinition.js';
|
|
1
2
|
import { PinTypes } from './PinTypes.js';
|
|
2
|
-
export
|
|
3
|
+
export declare class PinId {
|
|
4
|
+
private value;
|
|
5
|
+
private type;
|
|
6
|
+
constructor(value: number | string);
|
|
7
|
+
getValue(): number | string;
|
|
8
|
+
getType(): PinIdType;
|
|
9
|
+
isNumeric(): boolean;
|
|
10
|
+
isString(): boolean;
|
|
11
|
+
toString(): string;
|
|
12
|
+
equals(other: PinId | number | string): boolean;
|
|
13
|
+
static from(value: number | string | NumericValue): PinId;
|
|
14
|
+
static isPinIdType(value: number | string): boolean;
|
|
15
|
+
}
|
|
3
16
|
export declare class PinDefinition {
|
|
4
17
|
id: PinId;
|
|
5
18
|
idType: PinIdType;
|
|
@@ -8,7 +21,7 @@ export declare class PinDefinition {
|
|
|
8
21
|
altNames: string[];
|
|
9
22
|
side: string;
|
|
10
23
|
position: number;
|
|
11
|
-
constructor(id: PinId, idType: PinIdType, name: string, pinType?: PinTypes, altNames?: never[]);
|
|
24
|
+
constructor(id: PinId | number | string, idType: PinIdType, name: string, pinType?: PinTypes, altNames?: never[]);
|
|
12
25
|
}
|
|
13
26
|
export declare enum PinIdType {
|
|
14
27
|
Int = "int",
|
|
@@ -20,3 +33,5 @@ export declare enum PortSide {
|
|
|
20
33
|
SOUTH = "SOUTH",
|
|
21
34
|
NORTH = "NORTH"
|
|
22
35
|
}
|
|
36
|
+
export declare function isPinId(item: any): boolean;
|
|
37
|
+
export declare function getPinDefinition(map: Map<PinId, PinDefinition>, id: PinId): PinDefinition;
|
|
@@ -4,6 +4,7 @@ import { ClassComponent } from './ClassComponent.js';
|
|
|
4
4
|
import { Net } from './Net.js';
|
|
5
5
|
import { NumericValue, PercentageValue } from './ParamDefinition.js';
|
|
6
6
|
import { ReferenceTypes } from '../globals.js';
|
|
7
|
+
import { PinId } from './PinDefinition.js';
|
|
7
8
|
export type CFunction = (args: CallableParameter[], options?: CFunctionOptions) => CFunctionResult;
|
|
8
9
|
export declare class CFunctionEntry {
|
|
9
10
|
name: string;
|
|
@@ -27,7 +28,7 @@ export type ComponentPinNet = [
|
|
|
27
28
|
];
|
|
28
29
|
export type ComponentPinNetPair = [
|
|
29
30
|
component: ClassComponent,
|
|
30
|
-
pin:
|
|
31
|
+
pin: PinId,
|
|
31
32
|
net: Net
|
|
32
33
|
];
|
|
33
34
|
export type ComponentPinWireId = [
|
|
@@ -95,3 +96,16 @@ export declare enum Direction {
|
|
|
95
96
|
Down = "down",
|
|
96
97
|
Up = "up"
|
|
97
98
|
}
|
|
99
|
+
export declare enum TypeProps {
|
|
100
|
+
Net = "net",
|
|
101
|
+
Port = "port",
|
|
102
|
+
Graphic = "graphic",
|
|
103
|
+
Resistor = "res",
|
|
104
|
+
Capacitor = "cap",
|
|
105
|
+
Inductor = "ind",
|
|
106
|
+
Diode = "diode"
|
|
107
|
+
}
|
|
108
|
+
export declare enum NetTypes {
|
|
109
|
+
Any = "any",
|
|
110
|
+
Source = "source"
|
|
111
|
+
}
|
package/libs/std.cst
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Circuitscript default lib
|
|
2
2
|
|
|
3
|
-
def net(net_name):
|
|
3
|
+
def net(net_name, net_type = "any"):
|
|
4
4
|
return create component:
|
|
5
5
|
pins: 1
|
|
6
6
|
copy: true
|
|
@@ -13,9 +13,10 @@ def net(net_name):
|
|
|
13
13
|
params:
|
|
14
14
|
net_name: net_name
|
|
15
15
|
priority: 10
|
|
16
|
+
net_type: net_type
|
|
16
17
|
|
|
17
18
|
def supply(net_name):
|
|
18
|
-
net_obj = net(net_name)
|
|
19
|
+
net_obj = net(net_name, "source")
|
|
19
20
|
return net_obj
|
|
20
21
|
|
|
21
22
|
def label(value, anchor="left"):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "circuitscript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Interpreter for the circuitscript language",
|
|
5
5
|
"homepage": "https://circuitscript.net",
|
|
6
6
|
"engines": {
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"express": "^4.18.2",
|
|
89
89
|
"figlet": "^1.7.0",
|
|
90
90
|
"lodash": "^4.17.21",
|
|
91
|
+
"ml-matrix": "^6.12.1",
|
|
91
92
|
"pdfkit": "^0.15.1",
|
|
92
93
|
"svg-to-pdfkit": "^0.1.8",
|
|
93
94
|
"svgdom": "^0.1.22",
|