circuitscript 0.1.0 → 0.1.2

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 (61) hide show
  1. package/dist/cjs/BaseVisitor.js +13 -8
  2. package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
  3. package/dist/cjs/antlr/CircuitScriptParser.js +599 -657
  4. package/dist/cjs/builtinMethods.js +27 -8
  5. package/dist/cjs/draw_symbols.js +314 -190
  6. package/dist/cjs/execute.js +113 -115
  7. package/dist/cjs/export.js +2 -4
  8. package/dist/cjs/geometry.js +52 -19
  9. package/dist/cjs/globals.js +12 -8
  10. package/dist/cjs/helpers.js +16 -3
  11. package/dist/cjs/layout.js +129 -125
  12. package/dist/cjs/logger.js +8 -1
  13. package/dist/cjs/objects/ClassComponent.js +22 -22
  14. package/dist/cjs/objects/ExecutionScope.js +10 -4
  15. package/dist/cjs/objects/Frame.js +2 -1
  16. package/dist/cjs/objects/ParamDefinition.js +120 -4
  17. package/dist/cjs/objects/PinDefinition.js +1 -4
  18. package/dist/cjs/render.js +40 -110
  19. package/dist/cjs/sizing.js +33 -7
  20. package/dist/cjs/utils.js +68 -2
  21. package/dist/cjs/visitor.js +214 -254
  22. package/dist/esm/BaseVisitor.mjs +15 -10
  23. package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
  24. package/dist/esm/antlr/CircuitScriptParser.mjs +599 -657
  25. package/dist/esm/builtinMethods.mjs +24 -8
  26. package/dist/esm/draw_symbols.mjs +316 -193
  27. package/dist/esm/execute.mjs +115 -117
  28. package/dist/esm/export.mjs +2 -4
  29. package/dist/esm/geometry.mjs +52 -19
  30. package/dist/esm/globals.mjs +12 -8
  31. package/dist/esm/helpers.mjs +17 -4
  32. package/dist/esm/layout.mjs +131 -127
  33. package/dist/esm/logger.mjs +8 -1
  34. package/dist/esm/objects/ClassComponent.mjs +21 -26
  35. package/dist/esm/objects/ExecutionScope.mjs +10 -4
  36. package/dist/esm/objects/Frame.mjs +2 -1
  37. package/dist/esm/objects/ParamDefinition.mjs +119 -3
  38. package/dist/esm/objects/PinDefinition.mjs +0 -2
  39. package/dist/esm/render.mjs +42 -112
  40. package/dist/esm/sizing.mjs +34 -8
  41. package/dist/esm/utils.mjs +64 -1
  42. package/dist/esm/visitor.mjs +216 -256
  43. package/dist/types/BaseVisitor.d.ts +1 -1
  44. package/dist/types/antlr/CircuitScriptParser.d.ts +2 -3
  45. package/dist/types/draw_symbols.d.ts +71 -45
  46. package/dist/types/execute.d.ts +15 -10
  47. package/dist/types/geometry.d.ts +31 -19
  48. package/dist/types/globals.d.ts +14 -10
  49. package/dist/types/helpers.d.ts +2 -1
  50. package/dist/types/layout.d.ts +21 -21
  51. package/dist/types/logger.d.ts +1 -1
  52. package/dist/types/objects/ClassComponent.d.ts +19 -16
  53. package/dist/types/objects/ExecutionScope.d.ts +2 -1
  54. package/dist/types/objects/Frame.d.ts +2 -2
  55. package/dist/types/objects/ParamDefinition.d.ts +31 -2
  56. package/dist/types/objects/PinDefinition.d.ts +0 -2
  57. package/dist/types/render.d.ts +2 -1
  58. package/dist/types/utils.d.ts +6 -1
  59. package/dist/types/visitor.d.ts +4 -5
  60. package/libs/lib.cst +15 -3
  61. package/package.json +7 -3
@@ -4,10 +4,6 @@ exports.RenderFlags = exports.GlobalDocumentName = exports.ModuleContainsKeyword
4
4
  var GlobalNames;
5
5
  (function (GlobalNames) {
6
6
  GlobalNames["__root"] = "__root";
7
- GlobalNames["gnd"] = "gnd";
8
- GlobalNames["DefaultResistor"] = "res";
9
- GlobalNames["DefaultCapacitor"] = "cap";
10
- GlobalNames["DefaultInductor"] = "ind";
11
7
  GlobalNames["symbol"] = "symbol";
12
8
  })(GlobalNames || (exports.GlobalNames = GlobalNames = {}));
13
9
  exports.NoNetText = 'NO_NET';
@@ -15,6 +11,10 @@ var ParamKeys;
15
11
  (function (ParamKeys) {
16
12
  ParamKeys["priority"] = "priority";
17
13
  ParamKeys["net_name"] = "net_name";
14
+ ParamKeys["flip"] = "flip";
15
+ ParamKeys["flipX"] = "flipX";
16
+ ParamKeys["flipY"] = "flipY";
17
+ ParamKeys["angle"] = "angle";
18
18
  })(ParamKeys || (exports.ParamKeys = ParamKeys = {}));
19
19
  var LayoutDirection;
20
20
  (function (LayoutDirection) {
@@ -25,6 +25,8 @@ var SymbolPinSide;
25
25
  (function (SymbolPinSide) {
26
26
  SymbolPinSide["Left"] = "left";
27
27
  SymbolPinSide["Right"] = "right";
28
+ SymbolPinSide["Top"] = "top";
29
+ SymbolPinSide["Bottom"] = "bottom";
28
30
  })(SymbolPinSide || (exports.SymbolPinSide = SymbolPinSide = {}));
29
31
  var LengthUnit;
30
32
  (function (LengthUnit) {
@@ -74,11 +76,10 @@ exports.ColorScheme = {
74
76
  };
75
77
  var ComponentTypes;
76
78
  (function (ComponentTypes) {
77
- ComponentTypes["gnd"] = "gnd";
78
79
  ComponentTypes["net"] = "net";
79
- ComponentTypes["label"] = "label";
80
- ComponentTypes["point"] = "point";
81
- ComponentTypes["frame"] = "frame";
80
+ ComponentTypes["graphic"] = "graphic";
81
+ ComponentTypes["port"] = "port";
82
+ ComponentTypes["module"] = "module";
82
83
  })(ComponentTypes || (exports.ComponentTypes = ComponentTypes = {}));
83
84
  var ReferenceTypes;
84
85
  (function (ReferenceTypes) {
@@ -105,4 +106,7 @@ exports.GlobalDocumentName = 'document';
105
106
  exports.RenderFlags = {
106
107
  ShowElementFrames: false,
107
108
  ShowOrigin: false,
109
+ ShowGridOrigin: false,
110
+ ShowLabelBoxBounds: false,
111
+ ShowLabelOrigin: false,
108
112
  };
@@ -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
- return [item2.direction, item2.value].join(",");
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 svgCanvas = (0, render_js_1.renderSheetsToSVG)(sheetFrames);
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
- return value * globals_js_1.MilsToMM;
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)));
340
353
  }
341
354
  exports.milsToMM = milsToMM;
342
355
  function pxToMM(value) {