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.
Files changed (163) hide show
  1. package/dist/cjs/antlr/CircuitScriptLexer.js +288 -0
  2. package/dist/cjs/antlr/CircuitScriptParser.js +4905 -0
  3. package/dist/cjs/antlr/CircuitScriptVisitor.js +6 -0
  4. package/{src/draw_symbols.ts → dist/cjs/draw_symbols.js} +303 -614
  5. package/dist/cjs/execute.js +780 -0
  6. package/{src/export.ts → dist/cjs/export.js} +34 -56
  7. package/dist/cjs/fonts.js +4 -0
  8. package/dist/cjs/geometry.js +430 -0
  9. package/dist/cjs/globals.js +60 -0
  10. package/dist/cjs/helpers.js +99 -0
  11. package/dist/cjs/index.js +29 -0
  12. package/{src/layout.ts → dist/cjs/layout.js} +413 -1002
  13. package/dist/cjs/lexer.js +114 -0
  14. package/dist/cjs/logger.js +17 -0
  15. package/dist/cjs/main.js +87 -0
  16. package/dist/cjs/objects/ClassComponent.js +142 -0
  17. package/dist/cjs/objects/ExecutionScope.js +134 -0
  18. package/dist/cjs/objects/Frame.js +22 -0
  19. package/{src/objects/Net.ts → dist/cjs/objects/Net.js} +9 -24
  20. package/dist/cjs/objects/ParamDefinition.js +42 -0
  21. package/dist/cjs/objects/PinDefinition.js +31 -0
  22. package/dist/cjs/objects/PinTypes.js +11 -0
  23. package/dist/cjs/objects/Wire.js +9 -0
  24. package/dist/cjs/objects/types.js +9 -0
  25. package/dist/cjs/parser.js +299 -0
  26. package/dist/cjs/regenerate-tests.js +23 -0
  27. package/dist/cjs/render.js +155 -0
  28. package/{src/server.ts → dist/cjs/server.js} +15 -21
  29. package/dist/cjs/sizing.js +105 -0
  30. package/{src/utils.ts → dist/cjs/utils.js} +25 -35
  31. package/{src/visitor.ts → dist/cjs/visitor.js} +392 -948
  32. package/{build/src/antlr/CircuitScriptLexer.js → dist/esm/antlr/CircuitScriptLexer.mjs} +90 -91
  33. package/{build/src/antlr/CircuitScriptParser.js → dist/esm/antlr/CircuitScriptParser.mjs} +138 -136
  34. package/{build/src/draw_symbols.js → dist/esm/draw_symbols.mjs} +11 -11
  35. package/{build/src/execute.js → dist/esm/execute.mjs} +9 -8
  36. package/{build/src/export.js → dist/esm/export.mjs} +2 -2
  37. package/{build/src/geometry.js → dist/esm/geometry.mjs} +3 -7
  38. package/{build/src/helpers.js → dist/esm/helpers.mjs} +27 -7
  39. package/dist/esm/index.mjs +13 -0
  40. package/{build/src/layout.js → dist/esm/layout.mjs} +11 -11
  41. package/{build/src/lexer.js → dist/esm/lexer.mjs} +2 -2
  42. package/{build/src/main.js → dist/esm/main.mjs} +5 -5
  43. package/{build/src/objects/ClassComponent.js → dist/esm/objects/ClassComponent.mjs} +3 -3
  44. package/{build/src/objects/PinDefinition.js → dist/esm/objects/PinDefinition.mjs} +1 -1
  45. package/dist/esm/parser.mjs +269 -0
  46. package/{build/src/regenerate-tests.js → dist/esm/regenerate-tests.mjs} +1 -1
  47. package/{build/src/render.js → dist/esm/render.mjs} +7 -24
  48. package/{build/src/sizing.js → dist/esm/sizing.mjs} +22 -8
  49. package/{build/src/visitor.js → dist/esm/visitor.mjs} +10 -29
  50. package/dist/types/antlr/CircuitScriptLexer.d.ts +71 -0
  51. package/dist/types/antlr/CircuitScriptParser.d.ts +675 -0
  52. package/dist/types/antlr/CircuitScriptVisitor.d.ts +115 -0
  53. package/dist/types/draw_symbols.d.ts +162 -0
  54. package/dist/types/execute.d.ts +85 -0
  55. package/dist/types/export.d.ts +2 -0
  56. package/dist/types/fonts.d.ts +1 -0
  57. package/dist/types/geometry.d.ts +84 -0
  58. package/dist/types/globals.d.ts +50 -0
  59. package/dist/types/helpers.d.ts +9 -0
  60. package/dist/types/index.d.ts +13 -0
  61. package/dist/types/layout.d.ts +147 -0
  62. package/dist/types/lexer.d.ts +19 -0
  63. package/dist/types/logger.d.ts +6 -0
  64. package/dist/types/main.d.ts +2 -0
  65. package/dist/types/objects/ClassComponent.d.ts +40 -0
  66. package/dist/types/objects/ExecutionScope.d.ts +64 -0
  67. package/dist/types/objects/Frame.d.ts +15 -0
  68. package/dist/types/objects/Net.d.ts +10 -0
  69. package/dist/types/objects/ParamDefinition.d.ts +20 -0
  70. package/dist/types/objects/PinDefinition.d.ts +24 -0
  71. package/dist/types/objects/PinTypes.d.ts +7 -0
  72. package/dist/types/objects/Wire.d.ts +11 -0
  73. package/dist/types/objects/types.d.ts +49 -0
  74. package/dist/types/parser.d.ts +38 -0
  75. package/dist/types/regenerate-tests.d.ts +1 -0
  76. package/dist/types/render.d.ts +10 -0
  77. package/dist/types/server.d.ts +1 -0
  78. package/dist/types/sizing.d.ts +15 -0
  79. package/dist/types/utils.d.ts +19 -0
  80. package/dist/types/visitor.d.ts +135 -0
  81. package/package.json +30 -12
  82. package/.editorconfig +0 -15
  83. package/.eslintignore +0 -1
  84. package/.eslintrc.json +0 -27
  85. package/.gitlab-ci.yml +0 -81
  86. package/.prettierignore +0 -8
  87. package/.prettierrc +0 -16
  88. package/__tests__/expectedResults.ts +0 -657
  89. package/__tests__/helpers.ts +0 -82
  90. package/__tests__/parseScripts.ts +0 -593
  91. package/__tests__/renderData/script1.cst +0 -58
  92. package/__tests__/renderData/script1.cst.svg +0 -1
  93. package/__tests__/renderData/script2.cst +0 -16
  94. package/__tests__/renderData/script2.cst.svg +0 -1
  95. package/__tests__/renderData/script3.cst +0 -30
  96. package/__tests__/renderData/script3.cst.svg +0 -1
  97. package/__tests__/renderData/script4.cst +0 -54
  98. package/__tests__/renderData/script4.cst.svg +0 -1
  99. package/__tests__/renderData/script5.cst +0 -23
  100. package/__tests__/renderData/script5.cst.svg +0 -1
  101. package/__tests__/renderData/script6.cst +0 -28
  102. package/__tests__/renderData/script6.cst.svg +0 -1
  103. package/__tests__/renderData/script7.cst +0 -26
  104. package/__tests__/renderData/script7.cst.svg +0 -1
  105. package/__tests__/renderData/script8.cst +0 -37
  106. package/__tests__/renderData/script8.cst.svg +0 -1
  107. package/__tests__/testCLI.ts +0 -68
  108. package/__tests__/testMathOps.ts +0 -36
  109. package/__tests__/testMergeWires.ts +0 -141
  110. package/__tests__/testParse.ts +0 -263
  111. package/__tests__/testRender.ts +0 -38
  112. package/build/src/parser.js +0 -69
  113. package/documentation.md +0 -238
  114. package/examples/example_arduino_uno.cst +0 -1146
  115. package/examples/example_garden_pump.cst +0 -567
  116. package/examples/lib.cst +0 -185
  117. package/fonts/Inter-Bold.ttf +0 -0
  118. package/fonts/Inter-Regular.ttf +0 -0
  119. package/fonts/OpenSans-Regular.ttf +0 -0
  120. package/fonts/Roboto-Regular.ttf +0 -0
  121. package/jest.config.js +0 -23
  122. package/libs/lib.cst +0 -185
  123. package/refresh.html +0 -42
  124. package/server.cjs +0 -50
  125. package/src/antlr/CircuitScript.g4 +0 -209
  126. package/src/antlr/CircuitScriptLexer.ts +0 -317
  127. package/src/antlr/CircuitScriptParser.ts +0 -4979
  128. package/src/antlr/CircuitScriptVisitor.ts +0 -420
  129. package/src/execute.ts +0 -1227
  130. package/src/fonts.ts +0 -1
  131. package/src/geometry.ts +0 -638
  132. package/src/globals.ts +0 -67
  133. package/src/helpers.ts +0 -114
  134. package/src/lexer.ts +0 -151
  135. package/src/logger.ts +0 -17
  136. package/src/main.ts +0 -105
  137. package/src/objects/ClassComponent.ts +0 -223
  138. package/src/objects/ExecutionScope.ts +0 -201
  139. package/src/objects/Frame.ts +0 -20
  140. package/src/objects/ParamDefinition.ts +0 -49
  141. package/src/objects/PinDefinition.ts +0 -49
  142. package/src/objects/PinTypes.ts +0 -7
  143. package/src/objects/Wire.ts +0 -19
  144. package/src/objects/types.ts +0 -66
  145. package/src/parser.ts +0 -106
  146. package/src/regenerate-tests.ts +0 -25
  147. package/src/render.ts +0 -260
  148. package/src/sizing.ts +0 -96
  149. package/tsconfig.json +0 -26
  150. package/tsconfig.release.json +0 -8
  151. /package/{build/src/antlr/CircuitScriptVisitor.js → dist/esm/antlr/CircuitScriptVisitor.mjs} +0 -0
  152. /package/{build/src/fonts.js → dist/esm/fonts.mjs} +0 -0
  153. /package/{build/src/globals.js → dist/esm/globals.mjs} +0 -0
  154. /package/{build/src/logger.js → dist/esm/logger.mjs} +0 -0
  155. /package/{build/src/objects/ExecutionScope.js → dist/esm/objects/ExecutionScope.mjs} +0 -0
  156. /package/{build/src/objects/Frame.js → dist/esm/objects/Frame.mjs} +0 -0
  157. /package/{build/src/objects/Net.js → dist/esm/objects/Net.mjs} +0 -0
  158. /package/{build/src/objects/ParamDefinition.js → dist/esm/objects/ParamDefinition.mjs} +0 -0
  159. /package/{build/src/objects/PinTypes.js → dist/esm/objects/PinTypes.mjs} +0 -0
  160. /package/{build/src/objects/Wire.js → dist/esm/objects/Wire.mjs} +0 -0
  161. /package/{build/src/objects/types.js → dist/esm/objects/types.mjs} +0 -0
  162. /package/{build/src/server.js → dist/esm/server.mjs} +0 -0
  163. /package/{build/src/utils.js → dist/esm/utils.mjs} +0 -0
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MainLexer = void 0;
7
+ const antlr4_1 = require("antlr4");
8
+ const CircuitScriptParser_js_1 = __importDefault(require("./antlr/CircuitScriptParser.js"));
9
+ const CircuitScriptLexer_js_1 = __importDefault(require("./antlr/CircuitScriptLexer.js"));
10
+ class MainLexer extends CircuitScriptLexer_js_1.default {
11
+ constructor(input) {
12
+ super(input);
13
+ this.tokens = [];
14
+ this.indents = [];
15
+ this.opened = 0;
16
+ }
17
+ reset() {
18
+ this.tokens = [];
19
+ this.indents = [];
20
+ this.opened = 0;
21
+ super.reset();
22
+ }
23
+ emitToken(token) {
24
+ super.emitToken(token);
25
+ this.tokens.push(token);
26
+ }
27
+ nextToken() {
28
+ if (this._input.LA(1) === CircuitScriptParser_js_1.default.EOF && this.indents.length) {
29
+ this.tokens = this.tokens.filter(function (val) {
30
+ return val.type !== CircuitScriptParser_js_1.default.EOF;
31
+ });
32
+ this.emitToken(this.commonToken(CircuitScriptParser_js_1.default.NEWLINE, "\n"));
33
+ while (this.indents.length) {
34
+ this.emitToken(this.createDedent());
35
+ this.indents.pop();
36
+ }
37
+ this.emitToken(this.commonToken(CircuitScriptParser_js_1.default.EOF, "<EOF>"));
38
+ }
39
+ const next = super.nextToken();
40
+ return this.tokens.length ? this.tokens.shift() : next;
41
+ }
42
+ createDedent() {
43
+ return this.commonToken(CircuitScriptParser_js_1.default.DEDENT, "");
44
+ }
45
+ getCharIndex() {
46
+ return this._input.index;
47
+ }
48
+ commonToken(type, text) {
49
+ const stop = this.getCharIndex() - 1;
50
+ const start = text.length ? stop - text.length + 1 : stop;
51
+ const token = new antlr4_1.CommonToken([this, this._input], type, 0, start, stop);
52
+ let tokenTypeString;
53
+ if (type === CircuitScriptParser_js_1.default.INDENT) {
54
+ tokenTypeString = "indent";
55
+ }
56
+ else if (type === CircuitScriptParser_js_1.default.DEDENT) {
57
+ tokenTypeString = "dedent";
58
+ }
59
+ if (tokenTypeString) {
60
+ token.text = tokenTypeString;
61
+ }
62
+ return token;
63
+ }
64
+ getIndentationCount(whitespace) {
65
+ let count = 0;
66
+ for (let i = 0; i < whitespace.length; i++) {
67
+ if (whitespace[i] === '\t') {
68
+ count += 8 - count % 8;
69
+ }
70
+ else {
71
+ count++;
72
+ }
73
+ }
74
+ return count;
75
+ }
76
+ atStartOfInput() {
77
+ return this.getCharIndex() === 0;
78
+ }
79
+ openBrace() {
80
+ this.opened++;
81
+ }
82
+ closeBrace() {
83
+ this.opened--;
84
+ }
85
+ onNewLine() {
86
+ const newLine = this.text.replace(/[^\r\n]+/g, '');
87
+ const spaces = this.text.replace(/[\r\n]+/g, '');
88
+ const next = this._input.LA(1);
89
+ const nextnext = this._input.LA(2);
90
+ if (this.opened > 0 || (nextnext != -1 &&
91
+ (next === 13 || next === 10 || next === 35))) {
92
+ this.skip();
93
+ }
94
+ else {
95
+ this.emitToken(this.commonToken(CircuitScriptParser_js_1.default.NEWLINE, newLine));
96
+ const indent = this.getIndentationCount(spaces);
97
+ const previous = this.indents.length ? this.indents[this.indents.length - 1] : 0;
98
+ if (indent === previous) {
99
+ this.skip();
100
+ }
101
+ else if (indent > previous) {
102
+ this.indents.push(indent);
103
+ this.emitToken(this.commonToken(CircuitScriptParser_js_1.default.INDENT, spaces));
104
+ }
105
+ else {
106
+ while (this.indents.length && this.indents[this.indents.length - 1] > indent) {
107
+ this.emitToken(this.createDedent());
108
+ this.indents.pop();
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ exports.MainLexer = MainLexer;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ class Logger {
5
+ constructor() {
6
+ this.logs = [];
7
+ this.add((new Date()).toISOString());
8
+ this.add('starting logger...');
9
+ }
10
+ add(message) {
11
+ this.logs.push((new Date()).toISOString() + " | " + message);
12
+ }
13
+ dump() {
14
+ return this.logs.join('\n');
15
+ }
16
+ }
17
+ exports.Logger = Logger;
@@ -0,0 +1,87 @@
1
+ #! /usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = require("commander");
8
+ const figlet_1 = __importDefault(require("figlet"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const fs_1 = require("fs");
11
+ const sizing_js_1 = require("./sizing.js");
12
+ const helpers_js_1 = require("./helpers.js");
13
+ async function main() {
14
+ const { filePath } = (0, helpers_js_1.getCurrentPath)();
15
+ const toolSrcPath = filePath;
16
+ const toolDirectory = path_1.default.dirname(toolSrcPath) + '/../../';
17
+ const fontsPath = toolDirectory + '/fonts';
18
+ const defaultLibsPath = toolDirectory + '/libs';
19
+ const packageJson = JSON.parse((0, fs_1.readFileSync)(toolDirectory + 'package.json').toString());
20
+ ;
21
+ const { version } = packageJson;
22
+ commander_1.program
23
+ .description('generate graphical output from circuitscript files')
24
+ .version(version)
25
+ .option('-i, --input text <input text>', 'Input text directly')
26
+ .option('-f, --input-file <path>', 'Input file')
27
+ .option('-o, --output <path>', 'Output path')
28
+ .option('-c, --current-directory <path>', 'Set current directory')
29
+ .option('-k, --kicad-netlist <filename>', 'Create KiCad netlist')
30
+ .option('-w, --watch', 'Watch for file changes')
31
+ .option('-n, --dump-nets', 'Dump out net information')
32
+ .option('-d, --dump-data', 'Dump data during parsing')
33
+ .option('-s, --stats', 'Show stats during generation');
34
+ commander_1.program.addHelpText('before', figlet_1.default.textSync('circuitscript', {
35
+ font: 'Small Slant'
36
+ }));
37
+ if (process.argv.length < 3) {
38
+ commander_1.program.help();
39
+ }
40
+ commander_1.program.parse();
41
+ const options = commander_1.program.opts();
42
+ const watchFileChanges = options.watch;
43
+ const outputPath = options.output ?? null;
44
+ const dumpNets = options.dumpNets;
45
+ const dumpData = options.dumpData;
46
+ const kicadNetlist = options.kicadNetlist;
47
+ let currentDirectory = options.currentDirectory ?? null;
48
+ if (watchFileChanges) {
49
+ console.log('watching for file changes...');
50
+ }
51
+ await (0, sizing_js_1.prepareSVGEnvironment)(fontsPath);
52
+ let inputFilePath = null;
53
+ let scriptData;
54
+ if (options.input) {
55
+ scriptData = options.input;
56
+ }
57
+ else {
58
+ inputFilePath = options.inputFile;
59
+ scriptData = (0, fs_1.readFileSync)(inputFilePath, { encoding: 'utf-8' });
60
+ if (currentDirectory === null) {
61
+ currentDirectory = path_1.default.dirname(inputFilePath);
62
+ }
63
+ }
64
+ const renderOptions = {
65
+ currentDirectory,
66
+ defaultLibsPath,
67
+ dumpNets,
68
+ dumpData,
69
+ kicadNetlistPath: kicadNetlist,
70
+ showStats: options.stats,
71
+ };
72
+ const output = (0, helpers_js_1.renderScript)(scriptData, outputPath, renderOptions);
73
+ if (outputPath === null && output) {
74
+ console.log(output);
75
+ }
76
+ if (watchFileChanges) {
77
+ (0, fs_1.watch)(inputFilePath, event => {
78
+ if (event === 'change') {
79
+ const scriptData = (0, fs_1.readFileSync)(inputFilePath, { encoding: 'utf-8' });
80
+ (0, helpers_js_1.renderScript)(scriptData, outputPath, renderOptions);
81
+ console.log('done');
82
+ }
83
+ });
84
+ }
85
+ }
86
+ exports.default = main;
87
+ main();
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassComponent = void 0;
4
+ const draw_symbols_js_1 = require("../draw_symbols.js");
5
+ const PinDefinition_js_1 = require("./PinDefinition.js");
6
+ const PinTypes_js_1 = require("./PinTypes.js");
7
+ class ClassComponent {
8
+ constructor(instanceName, numPins, className) {
9
+ this.parameters = new Map();
10
+ this.pins = new Map();
11
+ this.pinNets = new Map();
12
+ this.pinWires = new Map();
13
+ this._copyID = null;
14
+ this._copyFrom = null;
15
+ this.arrangeProps = null;
16
+ this.displayProp = null;
17
+ this.widthProp = null;
18
+ this.typeProp = null;
19
+ this.styles = {};
20
+ this.assignedRefDes = null;
21
+ this.instanceName = instanceName;
22
+ this.numPins = numPins;
23
+ this.className = className;
24
+ }
25
+ setupPins() {
26
+ for (let i = 1; i < this.numPins + 1; i++) {
27
+ const pinIndex = i;
28
+ this.pins.set(pinIndex, new PinDefinition_js_1.PinDefinition(pinIndex, PinDefinition_js_1.PinIdType.Int, pinIndex.toString(), PinTypes_js_1.PinTypes.Any));
29
+ }
30
+ this.refreshPinsCache();
31
+ }
32
+ getDefaultPin() {
33
+ return 1;
34
+ }
35
+ hasPin(pinId) {
36
+ if (typeof pinId === 'number') {
37
+ return this.pins.has(pinId);
38
+ }
39
+ else {
40
+ for (const [, pinDef] of this.pins) {
41
+ if (pinDef.name === pinId ||
42
+ pinDef.altNames.indexOf(pinId) !== -1) {
43
+ return true;
44
+ }
45
+ }
46
+ }
47
+ return false;
48
+ }
49
+ getPin(pinId) {
50
+ if (typeof pinId === 'number') {
51
+ return pinId;
52
+ }
53
+ else {
54
+ for (const [pin, pinDef] of this.pins) {
55
+ if (pinDef.name === pinId ||
56
+ pinDef.altNames.indexOf(pinId) !== -1) {
57
+ return pin;
58
+ }
59
+ }
60
+ return -1;
61
+ }
62
+ }
63
+ getNextPinAfter(pinIndex) {
64
+ if (pinIndex + 1 <= this.numPins) {
65
+ return pinIndex + 1;
66
+ }
67
+ else {
68
+ return 1;
69
+ }
70
+ }
71
+ setParam(key, value) {
72
+ this.parameters.set(key, value);
73
+ this.refreshParamCache();
74
+ }
75
+ refreshParamCache() {
76
+ this._cachedParams =
77
+ JSON.stringify(Object.fromEntries(this.parameters));
78
+ }
79
+ refreshPinsCache() {
80
+ this._cachedPins = JSON.stringify(Object.fromEntries(this.pins));
81
+ }
82
+ refreshCache() {
83
+ this.refreshParamCache();
84
+ this.refreshPinsCache();
85
+ }
86
+ getParam(key) {
87
+ if (this.parameters.has(key)) {
88
+ return this.parameters.get(key);
89
+ }
90
+ else {
91
+ throw 'Invalid parameter key';
92
+ }
93
+ }
94
+ toString() {
95
+ return this.instanceName;
96
+ }
97
+ static simple(instanceName, numPins, className) {
98
+ const component = new ClassComponent(instanceName, numPins, className);
99
+ component.setupPins();
100
+ return component;
101
+ }
102
+ isEqual(other) {
103
+ return this.instanceName === other.instanceName
104
+ && this.numPins === other.numPins
105
+ && this.className === other.className
106
+ && this._copyID === other._copyID
107
+ && this.arrangeProps === other.arrangeProps
108
+ && this.displayProp === other.displayProp
109
+ && this.widthProp === other.widthProp
110
+ && this.typeProp === other.typeProp
111
+ && this._cachedPins === other._cachedPins
112
+ && this._cachedParams === other._cachedParams;
113
+ }
114
+ clone() {
115
+ const component = new ClassComponent(this.instanceName, this.numPins, this.className);
116
+ component._copyID = this._copyID;
117
+ component.arrangeProps = this.arrangeProps;
118
+ component.widthProp = this.widthProp;
119
+ component.typeProp = this.typeProp;
120
+ if (this.displayProp) {
121
+ if (typeof this.displayProp === "string") {
122
+ component.displayProp = this.displayProp;
123
+ }
124
+ else if (this.displayProp instanceof draw_symbols_js_1.SymbolDrawingCommands) {
125
+ component.displayProp =
126
+ this.displayProp.clone();
127
+ }
128
+ }
129
+ for (const [key, value] of this.parameters) {
130
+ component.parameters.set(key, value);
131
+ }
132
+ for (const [key, value] of this.pins) {
133
+ component.pins.set(key, value);
134
+ }
135
+ for (const key in this.styles) {
136
+ component.styles[key] = this.styles[key];
137
+ }
138
+ component.refreshCache();
139
+ return component;
140
+ }
141
+ }
142
+ exports.ClassComponent = ClassComponent;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActiveObject = exports.FrameAction = exports.SequenceAction = exports.ExecutionScope = void 0;
4
+ class ExecutionScope {
5
+ constructor(scopeId) {
6
+ this.nets = [];
7
+ this.instances = new Map();
8
+ this.functions = new Map();
9
+ this.variables = new Map();
10
+ this.blockStack = new Map();
11
+ this.wires = [];
12
+ this.frames = [];
13
+ this.indentLevel = 0;
14
+ this.netCounter = 1;
15
+ this.unnamedCounter = 1;
16
+ this.currentComponent = null;
17
+ this.currentPin = null;
18
+ this.currentWireId = -1;
19
+ this.currentFrameId = -1;
20
+ this.netGnd = null;
21
+ this.componentGnd = null;
22
+ this.componentRoot = null;
23
+ this.copyIDs = new Map();
24
+ this.sequence = [];
25
+ this.scopeId = scopeId;
26
+ }
27
+ static create() {
28
+ const scope = new ExecutionScope(ExecutionScope.scopeId);
29
+ ExecutionScope.scopeId += 1;
30
+ return scope;
31
+ }
32
+ findNet(component, pin) {
33
+ return this.nets.find(([tmpComponent, tmpPin]) => {
34
+ return tmpComponent.isEqual(component) && tmpPin === pin;
35
+ });
36
+ }
37
+ getNetWithName(name) {
38
+ const found = this.nets.find(([, , net]) => {
39
+ return net.name === name;
40
+ });
41
+ return found ? found[2] : null;
42
+ }
43
+ hasNet(component, pin) {
44
+ return this.findNet(component, pin) !== undefined;
45
+ }
46
+ getNet(component, pin) {
47
+ const result = this.findNet(component, pin);
48
+ if (result) {
49
+ return result[2];
50
+ }
51
+ return null;
52
+ }
53
+ setNet(component, pin, net) {
54
+ const pair = this.findNet(component, pin);
55
+ const result = this.nets.indexOf(pair);
56
+ if (result === -1) {
57
+ this.nets.push([component, pin, net]);
58
+ }
59
+ else {
60
+ this.nets[result][2] = net;
61
+ }
62
+ component.pinNets.set(pin, net);
63
+ }
64
+ removeNet(component, pin) {
65
+ const pair = this.findNet(component, pin);
66
+ const result = this.nets.indexOf(pair);
67
+ if (result !== -1) {
68
+ this.nets.splice(result, 1);
69
+ }
70
+ component.pinNets.delete(pin);
71
+ }
72
+ getNets() {
73
+ return this.nets;
74
+ }
75
+ dumpNets() {
76
+ const sortedNet = [...this.nets].sort((a, b) => {
77
+ const netA = a[2];
78
+ const netB = b[2];
79
+ const netAId = netA.namespace + netA.name;
80
+ const netBId = netB.namespace + b[2].name;
81
+ if (netAId > netBId) {
82
+ return 1;
83
+ }
84
+ else if (netAId < netBId) {
85
+ return -1;
86
+ }
87
+ else {
88
+ return 0;
89
+ }
90
+ });
91
+ return sortedNet.map(([component, pin, net]) => {
92
+ return [net.namespace + net.name, component.instanceName, pin];
93
+ });
94
+ }
95
+ printNets() {
96
+ this.dumpNets().forEach(item => {
97
+ const [netName, instanceName, pin] = item;
98
+ console.log(netName.padEnd(10), '=>', instanceName, pin);
99
+ });
100
+ }
101
+ setActive(type, item) {
102
+ this.clearActive();
103
+ if (type === ActiveObject.Wire) {
104
+ this.currentWireId = item;
105
+ }
106
+ else if (type === ActiveObject.Frame) {
107
+ this.currentFrameId = item;
108
+ }
109
+ }
110
+ clearActive() {
111
+ this.currentWireId = -1;
112
+ this.currentFrameId = -1;
113
+ }
114
+ }
115
+ exports.ExecutionScope = ExecutionScope;
116
+ ExecutionScope.scopeId = 0;
117
+ var SequenceAction;
118
+ (function (SequenceAction) {
119
+ SequenceAction["To"] = "to";
120
+ SequenceAction["At"] = "at";
121
+ SequenceAction["Wire"] = "wire";
122
+ SequenceAction["WireJump"] = "wire-jump";
123
+ SequenceAction["Frame"] = "frame";
124
+ })(SequenceAction || (exports.SequenceAction = SequenceAction = {}));
125
+ var FrameAction;
126
+ (function (FrameAction) {
127
+ FrameAction["Enter"] = "enter";
128
+ FrameAction["Exit"] = "exit";
129
+ })(FrameAction || (exports.FrameAction = FrameAction = {}));
130
+ var ActiveObject;
131
+ (function (ActiveObject) {
132
+ ActiveObject["Frame"] = "frame";
133
+ ActiveObject["Wire"] = "wire";
134
+ })(ActiveObject || (exports.ActiveObject = ActiveObject = {}));
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FramePlotDirection = exports.FrameParamKeys = exports.Frame = void 0;
4
+ class Frame {
5
+ constructor(frameId) {
6
+ this.parameters = new Map();
7
+ this.frameId = frameId;
8
+ }
9
+ }
10
+ exports.Frame = Frame;
11
+ var FrameParamKeys;
12
+ (function (FrameParamKeys) {
13
+ FrameParamKeys["Title"] = "title";
14
+ FrameParamKeys["Direction"] = "direction";
15
+ FrameParamKeys["Padding"] = "padding";
16
+ FrameParamKeys["Border"] = "border";
17
+ })(FrameParamKeys || (exports.FrameParamKeys = FrameParamKeys = {}));
18
+ var FramePlotDirection;
19
+ (function (FramePlotDirection) {
20
+ FramePlotDirection["Row"] = "row";
21
+ FramePlotDirection["Column"] = "column";
22
+ })(FramePlotDirection || (exports.FramePlotDirection = FramePlotDirection = {}));
@@ -1,43 +1,28 @@
1
- export class Net {
2
-
3
- name: string;
4
-
5
- // Name that is specified when the net was defined.
6
- baseName: string;
7
-
8
- // Defines where the net was created. This is important for determining
9
- // the 'location' of global nets.
10
- namespace: string;
11
-
12
- priority: number;
13
- type: any;
14
-
15
- constructor(namespace: string, name: string, priority = 0, type: any = null) {
16
- if (namespace.indexOf(' ') !== -1){
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Net = void 0;
4
+ class Net {
5
+ constructor(namespace, name, priority = 0, type = null) {
6
+ if (namespace.indexOf(' ') !== -1) {
17
7
  throw "Invalid net namespace provided";
18
8
  }
19
-
20
9
  if (name.indexOf(' ') !== -1) {
21
10
  throw "Invalid net name provided!";
22
11
  }
23
-
24
12
  this.namespace = namespace;
25
13
  this.name = name;
26
-
27
14
  this.priority = priority;
28
15
  this.type = type;
29
-
30
16
  this.baseName = name;
31
17
  }
32
-
33
- toString(): string {
18
+ toString() {
34
19
  return this.name;
35
20
  }
36
-
37
- static isSame(netA: Net, netB: Net): boolean {
21
+ static isSame(netA, netB) {
38
22
  return netA.name === netB.name &&
39
23
  netA.baseName === netB.baseName &&
40
24
  netA.priority === netB.priority &&
41
25
  netA.type === netB.type;
42
26
  }
43
27
  }
28
+ exports.Net = Net;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PinBlankValue = exports.PercentageValue = exports.NumericValue = exports.ParamDefinition = void 0;
4
+ class ParamDefinition {
5
+ constructor(paramName, paramValue) {
6
+ this.paramName = paramName;
7
+ this.paramValue = paramValue;
8
+ }
9
+ }
10
+ exports.ParamDefinition = ParamDefinition;
11
+ class NumericValue {
12
+ constructor(value) {
13
+ this.value = value;
14
+ }
15
+ toString() {
16
+ return 'numeric:' + this.value;
17
+ }
18
+ toDisplayString() {
19
+ if (typeof this.value === 'number') {
20
+ return this.value.toString();
21
+ }
22
+ else if (typeof this.value === 'string') {
23
+ return this.value;
24
+ }
25
+ }
26
+ }
27
+ exports.NumericValue = NumericValue;
28
+ class PercentageValue {
29
+ constructor(value) {
30
+ this.value = value;
31
+ }
32
+ toString() {
33
+ return this.value.toString();
34
+ }
35
+ }
36
+ exports.PercentageValue = PercentageValue;
37
+ class PinBlankValue {
38
+ constructor(value) {
39
+ this.blank = value;
40
+ }
41
+ }
42
+ exports.PinBlankValue = PinBlankValue;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PinReference = exports.PortSide = exports.PinIdType = exports.PinDefinition = void 0;
4
+ const PinTypes_js_1 = require("./PinTypes.js");
5
+ class PinDefinition {
6
+ constructor(id, idType, name, pinType = PinTypes_js_1.PinTypes.Any, altNames = []) {
7
+ this.side = PortSide.EAST;
8
+ this.position = -1;
9
+ this.id = id;
10
+ this.idType = idType;
11
+ this.pinType = pinType;
12
+ this.name = name;
13
+ this.altNames = altNames;
14
+ }
15
+ }
16
+ exports.PinDefinition = PinDefinition;
17
+ var PinIdType;
18
+ (function (PinIdType) {
19
+ PinIdType["Int"] = "int";
20
+ PinIdType["Str"] = "str";
21
+ })(PinIdType || (exports.PinIdType = PinIdType = {}));
22
+ var PortSide;
23
+ (function (PortSide) {
24
+ PortSide["WEST"] = "WEST";
25
+ PortSide["EAST"] = "EAST";
26
+ PortSide["SOUTH"] = "SOUTH";
27
+ PortSide["NORTH"] = "NORTH";
28
+ })(PortSide || (exports.PortSide = PortSide = {}));
29
+ class PinReference {
30
+ }
31
+ exports.PinReference = PinReference;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PinTypes = void 0;
4
+ var PinTypes;
5
+ (function (PinTypes) {
6
+ PinTypes["Any"] = "any";
7
+ PinTypes["Input"] = "input";
8
+ PinTypes["Output"] = "output";
9
+ PinTypes["IO"] = "io";
10
+ PinTypes["Power"] = "power";
11
+ })(PinTypes || (exports.PinTypes = PinTypes = {}));
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Wire = void 0;
4
+ class Wire {
5
+ constructor(path) {
6
+ this.path = path;
7
+ }
8
+ }
9
+ exports.Wire = Wire;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UndeclaredReference = void 0;
4
+ class UndeclaredReference {
5
+ constructor(reference) {
6
+ this.reference = reference;
7
+ }
8
+ }
9
+ exports.UndeclaredReference = UndeclaredReference;