circuitscript 0.0.24 → 0.0.25
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 +487 -0
- package/dist/cjs/SemanticTokenVisitor.js +218 -0
- package/dist/cjs/SymbolValidatorVisitor.js +233 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +209 -195
- package/dist/cjs/antlr/CircuitScriptParser.js +2310 -2087
- package/dist/cjs/antlr/CircuitScriptVisitor.js +4 -3
- package/dist/cjs/draw_symbols.js +67 -22
- package/dist/cjs/execute.js +51 -53
- package/dist/cjs/geometry.js +28 -8
- package/dist/cjs/helpers.js +175 -5
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/layout.js +8 -0
- package/dist/cjs/lexer.js +19 -22
- package/dist/cjs/main.js +6 -11
- package/dist/cjs/objects/ClassComponent.js +3 -0
- package/dist/cjs/objects/ExecutionScope.js +1 -0
- package/dist/cjs/objects/types.js +7 -1
- package/dist/cjs/parser.js +29 -258
- package/dist/cjs/validate.js +81 -0
- package/dist/cjs/visitor.js +529 -820
- package/dist/esm/BaseVisitor.mjs +488 -0
- package/dist/esm/SemanticTokenVisitor.mjs +215 -0
- package/dist/esm/SymbolValidatorVisitor.mjs +222 -0
- package/dist/esm/antlr/CircuitScriptLexer.mjs +184 -194
- package/dist/esm/antlr/CircuitScriptParser.mjs +2279 -2084
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +8 -3
- package/dist/esm/draw_symbols.mjs +67 -22
- package/dist/esm/execute.mjs +50 -52
- package/dist/esm/geometry.mjs +28 -8
- package/dist/esm/helpers.mjs +165 -6
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/layout.mjs +8 -0
- package/dist/esm/lexer.mjs +10 -10
- package/dist/esm/main.mjs +7 -12
- package/dist/esm/objects/ClassComponent.mjs +3 -0
- package/dist/esm/objects/ExecutionScope.mjs +1 -0
- package/dist/esm/objects/types.mjs +6 -0
- package/dist/esm/parser.mjs +25 -230
- package/dist/esm/validate.mjs +74 -0
- package/dist/esm/visitor.mjs +343 -640
- package/dist/types/BaseVisitor.d.ts +69 -0
- package/dist/types/SemanticTokenVisitor.d.ts +36 -0
- package/dist/types/SymbolValidatorVisitor.d.ts +61 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +8 -7
- package/dist/types/antlr/CircuitScriptParser.d.ts +513 -469
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +69 -59
- package/dist/types/draw_symbols.d.ts +9 -0
- package/dist/types/execute.d.ts +5 -8
- package/dist/types/geometry.d.ts +4 -0
- package/dist/types/helpers.d.ts +32 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lexer.d.ts +2 -2
- package/dist/types/objects/ExecutionScope.d.ts +4 -1
- package/dist/types/objects/types.d.ts +5 -0
- package/dist/types/parser.d.ts +15 -28
- package/dist/types/validate.d.ts +2 -0
- package/dist/types/visitor.d.ts +40 -95
- 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/libs/lib.cst +183 -0
- package/package.json +11 -6
package/dist/cjs/helpers.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCurrentPath = exports.detectJSModuleType = exports.renderScript = exports.JSModuleType = void 0;
|
|
6
|
+
exports.getPackageVersion = exports.getDefaultLibsPath = exports.getFontsPath = exports.getCurrentPath = exports.detectJSModuleType = exports.renderScript = exports.validateScript = exports.ParseErrorStrategy = exports.getSemanticTokens = exports.getScriptText = exports.prepareFile = exports.JSModuleType = void 0;
|
|
4
7
|
const fs_1 = require("fs");
|
|
5
8
|
const export_js_1 = require("./export.js");
|
|
6
9
|
const layout_js_1 = require("./layout.js");
|
|
@@ -10,17 +13,164 @@ const render_js_1 = require("./render.js");
|
|
|
10
13
|
const utils_js_1 = require("./utils.js");
|
|
11
14
|
const visitor_js_1 = require("./visitor.js");
|
|
12
15
|
const this_file_1 = require("this-file");
|
|
16
|
+
const SymbolValidatorVisitor_js_1 = require("./SymbolValidatorVisitor.js");
|
|
17
|
+
const antlr4ng_1 = require("antlr4ng");
|
|
18
|
+
const lexer_js_1 = require("./lexer.js");
|
|
19
|
+
const CircuitScriptParser_js_1 = require("./antlr/CircuitScriptParser.js");
|
|
20
|
+
const SemanticTokenVisitor_js_1 = require("./SemanticTokenVisitor.js");
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
13
22
|
var JSModuleType;
|
|
14
23
|
(function (JSModuleType) {
|
|
15
24
|
JSModuleType["CommonJs"] = "cjs";
|
|
16
25
|
JSModuleType["ESM"] = "mjs";
|
|
17
26
|
})(JSModuleType || (exports.JSModuleType = JSModuleType = {}));
|
|
27
|
+
function prepareFile(textData) {
|
|
28
|
+
const chars = antlr4ng_1.CharStream.fromString(textData);
|
|
29
|
+
const lexer = new lexer_js_1.MainLexer(chars);
|
|
30
|
+
const lexerTimer = new utils_js_1.SimpleStopwatch();
|
|
31
|
+
const tokens = new antlr4ng_1.CommonTokenStream(lexer);
|
|
32
|
+
tokens.fill();
|
|
33
|
+
const lexerTimeTaken = lexerTimer.lap();
|
|
34
|
+
const parser = new CircuitScriptParser_js_1.CircuitScriptParser(tokens);
|
|
35
|
+
return {
|
|
36
|
+
parser,
|
|
37
|
+
lexer,
|
|
38
|
+
lexerTimeTaken,
|
|
39
|
+
tokens
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.prepareFile = prepareFile;
|
|
43
|
+
function getScriptText(filePath) {
|
|
44
|
+
try {
|
|
45
|
+
return (0, fs_1.readFileSync)(filePath, { encoding: 'utf-8' });
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.getScriptText = getScriptText;
|
|
52
|
+
function getSemanticTokens(scriptData, options) {
|
|
53
|
+
const { parser, lexer, tokens } = prepareFile(scriptData);
|
|
54
|
+
const tree = parser.script();
|
|
55
|
+
const { currentDirectory = null, defaultLibsPath, } = options;
|
|
56
|
+
const visitor = new SemanticTokenVisitor_js_1.SemanticTokensVisitor(true, null, currentDirectory, defaultLibsPath, lexer, scriptData);
|
|
57
|
+
parser.removeErrorListeners();
|
|
58
|
+
visitor.onImportFile = (visitor, textData) => {
|
|
59
|
+
let hasError = false;
|
|
60
|
+
let hasParseError = false;
|
|
61
|
+
if (textData !== null) {
|
|
62
|
+
const { parser } = prepareFile(textData);
|
|
63
|
+
const tree = parser.script();
|
|
64
|
+
try {
|
|
65
|
+
visitor.visit(tree);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.log('Error while parsing: ', err);
|
|
69
|
+
hasParseError = true;
|
|
70
|
+
hasError = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log('File does not exist');
|
|
75
|
+
hasError = true;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
hasError, hasParseError
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
visitor.visit(tree);
|
|
82
|
+
const semanticTokens = visitor.getTokens();
|
|
83
|
+
const parsedTokens = (0, SemanticTokenVisitor_js_1.prepareTokens)(tokens.getTokens(), lexer, scriptData);
|
|
84
|
+
const finalParsedTokens = [];
|
|
85
|
+
parsedTokens.forEach(token => {
|
|
86
|
+
const location = `${token.line}_${token.column}`;
|
|
87
|
+
if (semanticTokens.has(location)) {
|
|
88
|
+
finalParsedTokens.push(semanticTokens.get(location));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
finalParsedTokens.push(token);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
visitor,
|
|
96
|
+
parsedTokens: finalParsedTokens
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
exports.getSemanticTokens = getSemanticTokens;
|
|
100
|
+
class TokenErrorListener extends antlr4ng_1.BaseErrorListener {
|
|
101
|
+
syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
|
|
102
|
+
console.log(msg);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
class ParseErrorStrategy extends antlr4ng_1.DefaultErrorStrategy {
|
|
106
|
+
reportUnwantedToken(recognizer) {
|
|
107
|
+
if (this.inErrorRecoveryMode(recognizer)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.beginErrorCondition(recognizer);
|
|
111
|
+
const t = recognizer.getCurrentToken();
|
|
112
|
+
const tokenName = this.getTokenErrorDisplay(t);
|
|
113
|
+
const msg = "extraneous input " + tokenName;
|
|
114
|
+
recognizer.notifyErrorListeners(msg, t, null);
|
|
115
|
+
this.endErrorCondition(recognizer);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.ParseErrorStrategy = ParseErrorStrategy;
|
|
119
|
+
function validateScript(scriptData, options) {
|
|
120
|
+
const { parser } = prepareFile(scriptData);
|
|
121
|
+
parser.removeErrorListeners();
|
|
122
|
+
parser.errorHandler = new ParseErrorStrategy();
|
|
123
|
+
parser.addErrorListener(new TokenErrorListener());
|
|
124
|
+
const tree = parser.script();
|
|
125
|
+
const { currentDirectory = null, defaultLibsPath, } = options;
|
|
126
|
+
const visitor = new SymbolValidatorVisitor_js_1.SymbolValidatorVisitor(true, null, currentDirectory, defaultLibsPath);
|
|
127
|
+
visitor.onImportFile = (visitor, textData) => {
|
|
128
|
+
let hasError = false;
|
|
129
|
+
let hasParseError = false;
|
|
130
|
+
if (textData !== null) {
|
|
131
|
+
const { parser } = prepareFile(textData);
|
|
132
|
+
const tree = parser.script();
|
|
133
|
+
try {
|
|
134
|
+
visitor.visit(tree);
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
console.log('got an error while parsing tree: ', err);
|
|
138
|
+
hasParseError = true;
|
|
139
|
+
hasError = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
console.log('file does not exist!');
|
|
144
|
+
hasError = true;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
hasError, hasParseError
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
visitor.visit(tree);
|
|
151
|
+
const symbolTable = visitor.getSymbols();
|
|
152
|
+
symbolTable.clearUndefined();
|
|
153
|
+
const visitorResolver = new SymbolValidatorVisitor_js_1.SymbolValidatorResolveVisitor(true, null, currentDirectory, defaultLibsPath);
|
|
154
|
+
visitorResolver.setSymbols(visitor.getSymbols());
|
|
155
|
+
visitorResolver.onImportFile = visitor.onImportFile;
|
|
156
|
+
visitorResolver.visit(tree);
|
|
157
|
+
return visitorResolver;
|
|
158
|
+
}
|
|
159
|
+
exports.validateScript = validateScript;
|
|
18
160
|
function renderScript(scriptData, outputPath, options) {
|
|
19
161
|
const { currentDirectory = null, defaultLibsPath, dumpNets = false, dumpData = false, kicadNetlistPath = null, showStats = false } = options;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
162
|
+
const onErrorHandler = (line, column, message, error) => {
|
|
163
|
+
if (error instanceof visitor_js_1.VisitorExecutionException) {
|
|
164
|
+
console.log('Error', line, column, message, error.errorMessage);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const visitor = new visitor_js_1.ParserVisitor(true, onErrorHandler, currentDirectory, defaultLibsPath);
|
|
168
|
+
visitor.onImportFile = (visitor, fileData) => {
|
|
169
|
+
const { hasError, hasParseError } = (0, parser_js_1.parseFileWithVisitor)(visitor, fileData);
|
|
170
|
+
return { hasError, hasParseError };
|
|
171
|
+
};
|
|
172
|
+
visitor.log('reading file');
|
|
173
|
+
visitor.log('done reading file');
|
|
24
174
|
const { tree, parser, hasParseError, hasError, parserTimeTaken, lexerTimeTaken } = (0, parser_js_1.parseFileWithVisitor)(visitor, scriptData);
|
|
25
175
|
showStats && console.log('Lexing took:', lexerTimeTaken);
|
|
26
176
|
showStats && console.log('Parsing took:', parserTimeTaken);
|
|
@@ -97,3 +247,23 @@ function getCurrentPath() {
|
|
|
97
247
|
return { filePath: filename };
|
|
98
248
|
}
|
|
99
249
|
exports.getCurrentPath = getCurrentPath;
|
|
250
|
+
function getToolsPath() {
|
|
251
|
+
const { filePath } = getCurrentPath();
|
|
252
|
+
return path_1.default.normalize(path_1.default.dirname(filePath) + '/../../');
|
|
253
|
+
}
|
|
254
|
+
function getFontsPath() {
|
|
255
|
+
const toolsPath = getToolsPath();
|
|
256
|
+
return path_1.default.normalize(toolsPath + "fonts");
|
|
257
|
+
}
|
|
258
|
+
exports.getFontsPath = getFontsPath;
|
|
259
|
+
function getDefaultLibsPath() {
|
|
260
|
+
const toolsPath = getToolsPath();
|
|
261
|
+
return path_1.default.normalize(toolsPath + "libs");
|
|
262
|
+
}
|
|
263
|
+
exports.getDefaultLibsPath = getDefaultLibsPath;
|
|
264
|
+
function getPackageVersion() {
|
|
265
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(getToolsPath() + 'package.json').toString());
|
|
266
|
+
const { version } = packageJson;
|
|
267
|
+
return version;
|
|
268
|
+
}
|
|
269
|
+
exports.getPackageVersion = getPackageVersion;
|
package/dist/cjs/index.js
CHANGED
|
@@ -27,3 +27,5 @@ __exportStar(require("./parser.js"), exports);
|
|
|
27
27
|
__exportStar(require("./render.js"), exports);
|
|
28
28
|
__exportStar(require("./utils.js"), exports);
|
|
29
29
|
__exportStar(require("./visitor.js"), exports);
|
|
30
|
+
__exportStar(require("./sizing.js"), exports);
|
|
31
|
+
__exportStar(require("./objects/types.js"), exports);
|
package/dist/cjs/layout.js
CHANGED
|
@@ -395,6 +395,14 @@ class LayoutEngine {
|
|
|
395
395
|
didSetAngle = true;
|
|
396
396
|
tmpSymbol.angle = component.parameters.get('angle');
|
|
397
397
|
}
|
|
398
|
+
if (component.parameters.has('flipX')) {
|
|
399
|
+
tmpSymbol.flipX =
|
|
400
|
+
component.parameters.get('flipX');
|
|
401
|
+
}
|
|
402
|
+
if (component.parameters.has('flipY')) {
|
|
403
|
+
tmpSymbol.flipY =
|
|
404
|
+
component.parameters.get('flipY');
|
|
405
|
+
}
|
|
398
406
|
if (tmpSymbol instanceof draw_symbols_js_1.SymbolCustom && widthProp) {
|
|
399
407
|
tmpSymbol.bodyWidth = widthProp;
|
|
400
408
|
}
|
package/dist/cjs/lexer.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.MainLexer = void 0;
|
|
7
|
-
const
|
|
8
|
-
const CircuitScriptParser_js_1 =
|
|
9
|
-
const CircuitScriptLexer_js_1 =
|
|
10
|
-
class MainLexer extends CircuitScriptLexer_js_1.
|
|
4
|
+
const antlr4ng_1 = require("antlr4ng");
|
|
5
|
+
const CircuitScriptParser_js_1 = require("./antlr/CircuitScriptParser.js");
|
|
6
|
+
const CircuitScriptLexer_js_1 = require("./antlr/CircuitScriptLexer.js");
|
|
7
|
+
class MainLexer extends CircuitScriptLexer_js_1.CircuitScriptLexer {
|
|
11
8
|
constructor(input) {
|
|
12
9
|
super(input);
|
|
13
10
|
this.tokens = [];
|
|
@@ -25,38 +22,38 @@ class MainLexer extends CircuitScriptLexer_js_1.default {
|
|
|
25
22
|
this.tokens.push(token);
|
|
26
23
|
}
|
|
27
24
|
nextToken() {
|
|
28
|
-
if (this.
|
|
25
|
+
if (this.inputStream.LA(1) === CircuitScriptParser_js_1.CircuitScriptParser.EOF && this.indents.length) {
|
|
29
26
|
this.tokens = this.tokens.filter(function (val) {
|
|
30
|
-
return val.type !== CircuitScriptParser_js_1.
|
|
27
|
+
return val.type !== CircuitScriptParser_js_1.CircuitScriptParser.EOF;
|
|
31
28
|
});
|
|
32
|
-
this.emitToken(this.commonToken(CircuitScriptParser_js_1.
|
|
29
|
+
this.emitToken(this.commonToken(CircuitScriptParser_js_1.CircuitScriptParser.NEWLINE, "\n"));
|
|
33
30
|
while (this.indents.length) {
|
|
34
31
|
this.emitToken(this.createDedent());
|
|
35
32
|
this.indents.pop();
|
|
36
33
|
}
|
|
37
|
-
this.emitToken(this.commonToken(CircuitScriptParser_js_1.
|
|
34
|
+
this.emitToken(this.commonToken(CircuitScriptParser_js_1.CircuitScriptParser.EOF, "<EOF>"));
|
|
38
35
|
}
|
|
39
36
|
const next = super.nextToken();
|
|
40
37
|
return this.tokens.length ? this.tokens.shift() : next;
|
|
41
38
|
}
|
|
42
39
|
createDedent() {
|
|
43
|
-
return this.commonToken(CircuitScriptParser_js_1.
|
|
40
|
+
return this.commonToken(CircuitScriptParser_js_1.CircuitScriptParser.DEDENT, "");
|
|
44
41
|
}
|
|
45
42
|
getCharIndex() {
|
|
46
|
-
return this.
|
|
43
|
+
return this.inputStream.index;
|
|
47
44
|
}
|
|
48
45
|
commonToken(type, text) {
|
|
49
46
|
const stop = this.getCharIndex() - 1;
|
|
50
47
|
const start = text.length ? stop - text.length + 1 : stop;
|
|
51
|
-
const token =
|
|
52
|
-
let tokenTypeString;
|
|
53
|
-
if (type === CircuitScriptParser_js_1.
|
|
48
|
+
const token = antlr4ng_1.CommonToken.fromSource([this, this.inputStream], type, 0, start, stop);
|
|
49
|
+
let tokenTypeString = null;
|
|
50
|
+
if (type === CircuitScriptParser_js_1.CircuitScriptParser.INDENT) {
|
|
54
51
|
tokenTypeString = "indent";
|
|
55
52
|
}
|
|
56
|
-
else if (type === CircuitScriptParser_js_1.
|
|
53
|
+
else if (type === CircuitScriptParser_js_1.CircuitScriptParser.DEDENT) {
|
|
57
54
|
tokenTypeString = "dedent";
|
|
58
55
|
}
|
|
59
|
-
if (tokenTypeString) {
|
|
56
|
+
if (tokenTypeString !== null) {
|
|
60
57
|
token.text = tokenTypeString;
|
|
61
58
|
}
|
|
62
59
|
return token;
|
|
@@ -85,14 +82,14 @@ class MainLexer extends CircuitScriptLexer_js_1.default {
|
|
|
85
82
|
onNewLine() {
|
|
86
83
|
const newLine = this.text.replace(/[^\r\n]+/g, '');
|
|
87
84
|
const spaces = this.text.replace(/[\r\n]+/g, '');
|
|
88
|
-
const next = this.
|
|
89
|
-
const nextnext = this.
|
|
85
|
+
const next = this.inputStream.LA(1);
|
|
86
|
+
const nextnext = this.inputStream.LA(2);
|
|
90
87
|
if (this.opened > 0 || (nextnext != -1 &&
|
|
91
88
|
(next === 13 || next === 10 || next === 35))) {
|
|
92
89
|
this.skip();
|
|
93
90
|
}
|
|
94
91
|
else {
|
|
95
|
-
this.emitToken(this.commonToken(CircuitScriptParser_js_1.
|
|
92
|
+
this.emitToken(this.commonToken(CircuitScriptParser_js_1.CircuitScriptParser.NEWLINE, newLine));
|
|
96
93
|
const indent = this.getIndentationCount(spaces);
|
|
97
94
|
const previous = this.indents.length ? this.indents[this.indents.length - 1] : 0;
|
|
98
95
|
if (indent === previous) {
|
|
@@ -100,7 +97,7 @@ class MainLexer extends CircuitScriptLexer_js_1.default {
|
|
|
100
97
|
}
|
|
101
98
|
else if (indent > previous) {
|
|
102
99
|
this.indents.push(indent);
|
|
103
|
-
this.emitToken(this.commonToken(CircuitScriptParser_js_1.
|
|
100
|
+
this.emitToken(this.commonToken(CircuitScriptParser_js_1.CircuitScriptParser.INDENT, spaces));
|
|
104
101
|
}
|
|
105
102
|
else {
|
|
106
103
|
while (this.indents.length && this.indents[this.indents.length - 1] > indent) {
|
package/dist/cjs/main.js
CHANGED
|
@@ -11,14 +11,9 @@ const fs_1 = require("fs");
|
|
|
11
11
|
const sizing_js_1 = require("./sizing.js");
|
|
12
12
|
const helpers_js_1 = require("./helpers.js");
|
|
13
13
|
async function main() {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
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;
|
|
14
|
+
const fontsPath = (0, helpers_js_1.getFontsPath)();
|
|
15
|
+
const defaultLibsPath = (0, helpers_js_1.getDefaultLibsPath)();
|
|
16
|
+
const version = (0, helpers_js_1.getPackageVersion)();
|
|
22
17
|
commander_1.program
|
|
23
18
|
.description('generate graphical output from circuitscript files')
|
|
24
19
|
.version(version)
|
|
@@ -61,7 +56,7 @@ async function main() {
|
|
|
61
56
|
currentDirectory = path_1.default.dirname(inputFilePath);
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
|
-
const
|
|
59
|
+
const scriptOptions = {
|
|
65
60
|
currentDirectory,
|
|
66
61
|
defaultLibsPath,
|
|
67
62
|
dumpNets,
|
|
@@ -69,7 +64,7 @@ async function main() {
|
|
|
69
64
|
kicadNetlistPath: kicadNetlist,
|
|
70
65
|
showStats: options.stats,
|
|
71
66
|
};
|
|
72
|
-
const output = (0, helpers_js_1.renderScript)(scriptData, outputPath,
|
|
67
|
+
const output = (0, helpers_js_1.renderScript)(scriptData, outputPath, scriptOptions);
|
|
73
68
|
if (outputPath === null && output) {
|
|
74
69
|
console.log(output);
|
|
75
70
|
}
|
|
@@ -77,7 +72,7 @@ async function main() {
|
|
|
77
72
|
(0, fs_1.watch)(inputFilePath, event => {
|
|
78
73
|
if (event === 'change') {
|
|
79
74
|
const scriptData = (0, fs_1.readFileSync)(inputFilePath, { encoding: 'utf-8' });
|
|
80
|
-
(0, helpers_js_1.renderScript)(scriptData, outputPath,
|
|
75
|
+
(0, helpers_js_1.renderScript)(scriptData, outputPath, scriptOptions);
|
|
81
76
|
console.log('done');
|
|
82
77
|
}
|
|
83
78
|
});
|
|
@@ -127,6 +127,9 @@ class ClassComponent {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
for (const [key, value] of this.parameters) {
|
|
130
|
+
if (key === 'flipX' || key === 'flipY' || key === 'angle') {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
130
133
|
component.parameters.set(key, value);
|
|
131
134
|
}
|
|
132
135
|
for (const [key, value] of this.pins) {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UndeclaredReference = void 0;
|
|
3
|
+
exports.ParseSymbolType = exports.UndeclaredReference = void 0;
|
|
4
4
|
class UndeclaredReference {
|
|
5
5
|
constructor(reference) {
|
|
6
6
|
this.reference = reference;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
exports.UndeclaredReference = UndeclaredReference;
|
|
10
|
+
var ParseSymbolType;
|
|
11
|
+
(function (ParseSymbolType) {
|
|
12
|
+
ParseSymbolType["Variable"] = "variable";
|
|
13
|
+
ParseSymbolType["Function"] = "function";
|
|
14
|
+
ParseSymbolType["Undefined"] = "undefined";
|
|
15
|
+
})(ParseSymbolType || (exports.ParseSymbolType = ParseSymbolType = {}));
|