circuitscript 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseVisitor.js +13 -8
- package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
- package/dist/cjs/antlr/CircuitScriptParser.js +599 -657
- package/dist/cjs/builtinMethods.js +27 -8
- package/dist/cjs/draw_symbols.js +320 -197
- package/dist/cjs/execute.js +114 -116
- package/dist/cjs/export.js +2 -4
- package/dist/cjs/geometry.js +52 -19
- package/dist/cjs/globals.js +17 -12
- package/dist/cjs/helpers.js +16 -3
- package/dist/cjs/layout.js +473 -354
- package/dist/cjs/logger.js +8 -1
- package/dist/cjs/objects/ClassComponent.js +22 -22
- package/dist/cjs/objects/ExecutionScope.js +10 -4
- package/dist/cjs/objects/Frame.js +11 -2
- package/dist/cjs/objects/ParamDefinition.js +123 -4
- package/dist/cjs/objects/PinDefinition.js +1 -4
- package/dist/cjs/render.js +76 -138
- package/dist/cjs/sizing.js +33 -7
- package/dist/cjs/utils.js +86 -2
- package/dist/cjs/visitor.js +224 -255
- package/dist/esm/BaseVisitor.mjs +15 -10
- package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
- package/dist/esm/antlr/CircuitScriptParser.mjs +599 -657
- package/dist/esm/builtinMethods.mjs +24 -8
- package/dist/esm/draw_symbols.mjs +322 -200
- package/dist/esm/execute.mjs +116 -118
- package/dist/esm/export.mjs +2 -4
- package/dist/esm/geometry.mjs +52 -19
- package/dist/esm/globals.mjs +17 -12
- package/dist/esm/helpers.mjs +17 -4
- package/dist/esm/layout.mjs +479 -360
- package/dist/esm/logger.mjs +8 -1
- package/dist/esm/objects/ClassComponent.mjs +21 -26
- package/dist/esm/objects/ExecutionScope.mjs +10 -4
- package/dist/esm/objects/Frame.mjs +10 -1
- package/dist/esm/objects/ParamDefinition.mjs +122 -3
- package/dist/esm/objects/PinDefinition.mjs +0 -2
- package/dist/esm/render.mjs +79 -141
- package/dist/esm/sizing.mjs +34 -8
- package/dist/esm/utils.mjs +80 -1
- package/dist/esm/visitor.mjs +226 -257
- package/dist/types/BaseVisitor.d.ts +1 -1
- package/dist/types/antlr/CircuitScriptParser.d.ts +2 -3
- package/dist/types/draw_symbols.d.ts +72 -45
- package/dist/types/execute.d.ts +15 -10
- package/dist/types/geometry.d.ts +31 -19
- package/dist/types/globals.d.ts +15 -11
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/layout.d.ts +35 -54
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +19 -16
- package/dist/types/objects/ExecutionScope.d.ts +3 -2
- package/dist/types/objects/Frame.d.ts +9 -2
- package/dist/types/objects/ParamDefinition.d.ts +32 -2
- package/dist/types/objects/PinDefinition.d.ts +0 -2
- package/dist/types/render.d.ts +2 -1
- package/dist/types/utils.d.ts +14 -1
- package/dist/types/visitor.d.ts +4 -5
- package/libs/lib.cst +25 -8
- package/package.json +7 -3
package/dist/cjs/globals.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RenderFlags = exports.GlobalDocumentName = exports.ModuleContainsKeyword = exports.FrameType = exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.ColorScheme = exports.PortPaddingVertical = exports.PortPaddingHorizontal = exports.PortArrowSize = exports.junctionSize = exports.defaultFontSize = exports.defaultFontBold = exports.defaultFont = exports.displayUnits = exports.defaultFrameTitleTextSize = exports.CustomSymbolParamTextSize = exports.CustomSymbolRefDesSize = exports.CustomSymbolPinIdSize = exports.CustomSymbolPinTextSize = exports.defaultPageSpacingMM = exports.defaultPageMarginMM = exports.defaultPinIdTextSize = exports.defaultPinNameTextSize = exports.defaultWireLineWidth = exports.defaultSymbolLineWidth = exports.fontDisplayScale = exports.defaultZoomScale = exports.defaultGridSizeUnits = exports.portHeight = exports.portWidth = exports.PxToMM = exports.MMToPt = exports.MMToPx = exports.MilsToMM = exports.WireAutoDirection = exports.LengthUnit = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = void 0;
|
|
4
|
+
const ParamDefinition_1 = require("./objects/ParamDefinition");
|
|
4
5
|
var GlobalNames;
|
|
5
6
|
(function (GlobalNames) {
|
|
6
7
|
GlobalNames["__root"] = "__root";
|
|
7
|
-
GlobalNames["gnd"] = "gnd";
|
|
8
|
-
GlobalNames["DefaultResistor"] = "res";
|
|
9
|
-
GlobalNames["DefaultCapacitor"] = "cap";
|
|
10
|
-
GlobalNames["DefaultInductor"] = "ind";
|
|
11
8
|
GlobalNames["symbol"] = "symbol";
|
|
12
9
|
})(GlobalNames || (exports.GlobalNames = GlobalNames = {}));
|
|
13
10
|
exports.NoNetText = 'NO_NET';
|
|
@@ -15,6 +12,10 @@ var ParamKeys;
|
|
|
15
12
|
(function (ParamKeys) {
|
|
16
13
|
ParamKeys["priority"] = "priority";
|
|
17
14
|
ParamKeys["net_name"] = "net_name";
|
|
15
|
+
ParamKeys["flip"] = "flip";
|
|
16
|
+
ParamKeys["flipX"] = "flipX";
|
|
17
|
+
ParamKeys["flipY"] = "flipY";
|
|
18
|
+
ParamKeys["angle"] = "angle";
|
|
18
19
|
})(ParamKeys || (exports.ParamKeys = ParamKeys = {}));
|
|
19
20
|
var LayoutDirection;
|
|
20
21
|
(function (LayoutDirection) {
|
|
@@ -25,6 +26,8 @@ var SymbolPinSide;
|
|
|
25
26
|
(function (SymbolPinSide) {
|
|
26
27
|
SymbolPinSide["Left"] = "left";
|
|
27
28
|
SymbolPinSide["Right"] = "right";
|
|
29
|
+
SymbolPinSide["Top"] = "top";
|
|
30
|
+
SymbolPinSide["Bottom"] = "bottom";
|
|
28
31
|
})(SymbolPinSide || (exports.SymbolPinSide = SymbolPinSide = {}));
|
|
29
32
|
var LengthUnit;
|
|
30
33
|
(function (LengthUnit) {
|
|
@@ -43,11 +46,11 @@ exports.MMToPt = 2.8346456693;
|
|
|
43
46
|
exports.PxToMM = 0.2645833;
|
|
44
47
|
exports.portWidth = 20;
|
|
45
48
|
exports.portHeight = 2;
|
|
46
|
-
exports.defaultGridSizeUnits = exports.MilsToMM
|
|
49
|
+
exports.defaultGridSizeUnits = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(100).toNumber();
|
|
47
50
|
exports.defaultZoomScale = 2.5;
|
|
48
51
|
exports.fontDisplayScale = 0.032;
|
|
49
|
-
exports.defaultSymbolLineWidth = exports.MilsToMM
|
|
50
|
-
exports.defaultWireLineWidth = exports.MilsToMM
|
|
52
|
+
exports.defaultSymbolLineWidth = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
53
|
+
exports.defaultWireLineWidth = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
51
54
|
exports.defaultPinNameTextSize = 40;
|
|
52
55
|
exports.defaultPinIdTextSize = 30;
|
|
53
56
|
exports.defaultPageMarginMM = 10;
|
|
@@ -61,7 +64,7 @@ exports.displayUnits = LengthUnit.mils;
|
|
|
61
64
|
exports.defaultFont = 'Arial';
|
|
62
65
|
exports.defaultFontBold = 'Arial';
|
|
63
66
|
exports.defaultFontSize = 10;
|
|
64
|
-
exports.junctionSize = exports.MilsToMM
|
|
67
|
+
exports.junctionSize = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(20);
|
|
65
68
|
exports.PortArrowSize = exports.MilsToMM * 50;
|
|
66
69
|
exports.PortPaddingHorizontal = exports.MilsToMM * 10;
|
|
67
70
|
exports.PortPaddingVertical = exports.MilsToMM * 10;
|
|
@@ -74,11 +77,10 @@ exports.ColorScheme = {
|
|
|
74
77
|
};
|
|
75
78
|
var ComponentTypes;
|
|
76
79
|
(function (ComponentTypes) {
|
|
77
|
-
ComponentTypes["gnd"] = "gnd";
|
|
78
80
|
ComponentTypes["net"] = "net";
|
|
79
|
-
ComponentTypes["
|
|
80
|
-
ComponentTypes["
|
|
81
|
-
ComponentTypes["
|
|
81
|
+
ComponentTypes["graphic"] = "graphic";
|
|
82
|
+
ComponentTypes["port"] = "port";
|
|
83
|
+
ComponentTypes["module"] = "module";
|
|
82
84
|
})(ComponentTypes || (exports.ComponentTypes = ComponentTypes = {}));
|
|
83
85
|
var ReferenceTypes;
|
|
84
86
|
(function (ReferenceTypes) {
|
|
@@ -105,4 +107,7 @@ exports.GlobalDocumentName = 'document';
|
|
|
105
107
|
exports.RenderFlags = {
|
|
106
108
|
ShowElementFrames: false,
|
|
107
109
|
ShowOrigin: false,
|
|
110
|
+
ShowGridOrigin: false,
|
|
111
|
+
ShowLabelBoxBounds: false,
|
|
112
|
+
ShowLabelOrigin: false,
|
|
108
113
|
};
|
package/dist/cjs/helpers.js
CHANGED
|
@@ -22,6 +22,8 @@ const CircuitScriptParser_js_1 = require("./antlr/CircuitScriptParser.js");
|
|
|
22
22
|
const SemanticTokenVisitor_js_1 = require("./SemanticTokenVisitor.js");
|
|
23
23
|
const globals_js_1 = require("./globals.js");
|
|
24
24
|
const Frame_js_1 = require("./objects/Frame.js");
|
|
25
|
+
const big_js_1 = __importDefault(require("big.js"));
|
|
26
|
+
const logger_js_1 = require("./logger.js");
|
|
25
27
|
var JSModuleType;
|
|
26
28
|
(function (JSModuleType) {
|
|
27
29
|
JSModuleType["CommonJs"] = "cjs";
|
|
@@ -200,7 +202,13 @@ function renderScript(scriptData, outputPath, options) {
|
|
|
200
202
|
const action = tmp[0];
|
|
201
203
|
if (action === ExecutionScope_js_1.SequenceAction.Wire) {
|
|
202
204
|
tmp[2] = tmp[2].map(item2 => {
|
|
203
|
-
|
|
205
|
+
const lengthValue = item2.value;
|
|
206
|
+
const useValue = [item2.direction];
|
|
207
|
+
if (lengthValue !== null) {
|
|
208
|
+
useValue.push(lengthValue.value);
|
|
209
|
+
useValue.push(lengthValue.type);
|
|
210
|
+
}
|
|
211
|
+
return useValue.join(",");
|
|
204
212
|
}).join(" ");
|
|
205
213
|
}
|
|
206
214
|
else if (action === ExecutionScope_js_1.SequenceAction.Frame) {
|
|
@@ -238,8 +246,10 @@ function renderScript(scriptData, outputPath, options) {
|
|
|
238
246
|
showStats && console.log('Layout took:', layoutTimer.lap());
|
|
239
247
|
dumpData && (0, fs_1.writeFileSync)('dump/raw-layout.txt', layoutEngine.logger.dump());
|
|
240
248
|
const generateSvgTimer = new utils_js_1.SimpleStopwatch();
|
|
241
|
-
const
|
|
249
|
+
const renderLogger = new logger_js_1.Logger();
|
|
250
|
+
const svgCanvas = (0, render_js_1.renderSheetsToSVG)(sheetFrames, renderLogger);
|
|
242
251
|
showStats && console.log('Render took:', generateSvgTimer.lap());
|
|
252
|
+
dumpData && (0, fs_1.writeFileSync)('dump/raw-render.txt', renderLogger.dump());
|
|
243
253
|
svgOutput = (0, render_js_1.generateSvgOutput)(svgCanvas, outputDefaultZoom);
|
|
244
254
|
if (outputPath) {
|
|
245
255
|
if (fileExtension === 'svg') {
|
|
@@ -336,7 +346,10 @@ class UnitDimension {
|
|
|
336
346
|
}
|
|
337
347
|
exports.UnitDimension = UnitDimension;
|
|
338
348
|
function milsToMM(value) {
|
|
339
|
-
|
|
349
|
+
if (typeof value === 'number') {
|
|
350
|
+
value = (0, utils_js_1.resolveToNumericValue)(new big_js_1.default(value));
|
|
351
|
+
}
|
|
352
|
+
return (0, utils_js_1.resolveToNumericValue)(value.toBigNumber().mul(new big_js_1.default(globals_js_1.MilsToMM)).round(6));
|
|
340
353
|
}
|
|
341
354
|
exports.milsToMM = milsToMM;
|
|
342
355
|
function pxToMM(value) {
|