circuitscript 0.5.4 → 0.5.5

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 (58) hide show
  1. package/dist/cjs/BaseVisitor.js +11 -10
  2. package/dist/cjs/builtinMethods.js +6 -5
  3. package/dist/cjs/environment/environment.js +2 -2
  4. package/dist/cjs/errors.js +140 -0
  5. package/dist/cjs/execute.js +12 -5
  6. package/dist/cjs/main.js +3 -2
  7. package/dist/cjs/objects/ClassComponent.js +4 -4
  8. package/dist/cjs/objects/ExecutionScope.js +2 -2
  9. package/dist/cjs/objects/NumericValue.js +15 -0
  10. package/dist/cjs/objects/PinDefinition.js +2 -2
  11. package/dist/cjs/objects/types.js +2 -2
  12. package/dist/cjs/parser.js +3 -2
  13. package/dist/cjs/pipeline.js +21 -14
  14. package/dist/cjs/regenerate-tests.js +6 -6
  15. package/dist/cjs/render/draw_symbols.js +17 -17
  16. package/dist/cjs/render/geometry.js +6 -6
  17. package/dist/cjs/render/layout.js +325 -253
  18. package/dist/cjs/render/render.js +21 -18
  19. package/dist/cjs/semantic-tokens/getSemanticTokens.js +2 -2
  20. package/dist/cjs/sizing.js +2 -2
  21. package/dist/cjs/utils.js +13 -110
  22. package/dist/cjs/validate/validateScript.js +2 -2
  23. package/dist/cjs/visitor.js +14 -12
  24. package/dist/esm/BaseVisitor.js +2 -1
  25. package/dist/esm/builtinMethods.js +6 -5
  26. package/dist/esm/environment/environment.js +1 -1
  27. package/dist/esm/errors.js +119 -0
  28. package/dist/esm/execute.js +10 -3
  29. package/dist/esm/main.js +3 -2
  30. package/dist/esm/objects/ClassComponent.js +1 -1
  31. package/dist/esm/objects/ExecutionScope.js +1 -1
  32. package/dist/esm/objects/NumericValue.js +15 -0
  33. package/dist/esm/objects/PinDefinition.js +1 -1
  34. package/dist/esm/objects/types.js +1 -1
  35. package/dist/esm/parser.js +2 -1
  36. package/dist/esm/pipeline.js +10 -3
  37. package/dist/esm/regenerate-tests.js +6 -6
  38. package/dist/esm/render/draw_symbols.js +15 -15
  39. package/dist/esm/render/geometry.js +6 -6
  40. package/dist/esm/render/layout.js +325 -253
  41. package/dist/esm/render/render.js +22 -19
  42. package/dist/esm/semantic-tokens/getSemanticTokens.js +1 -1
  43. package/dist/esm/sizing.js +2 -2
  44. package/dist/esm/utils.js +10 -95
  45. package/dist/esm/validate/validateScript.js +1 -1
  46. package/dist/esm/visitor.js +4 -2
  47. package/dist/libs/std.cst +31 -31
  48. package/dist/types/BaseVisitor.d.ts +3 -1
  49. package/dist/types/errors.d.ts +37 -0
  50. package/dist/types/execute.d.ts +1 -1
  51. package/dist/types/helpers.d.ts +1 -1
  52. package/dist/types/objects/NumericValue.d.ts +5 -1
  53. package/dist/types/render/geometry.d.ts +4 -4
  54. package/dist/types/render/layout.d.ts +7 -1
  55. package/dist/types/utils.d.ts +2 -27
  56. package/dist/types/visitor.d.ts +1 -1
  57. package/libs/std.cst +31 -31
  58. package/package.json +1 -1
@@ -5,7 +5,7 @@ const helpers_js_1 = require("../helpers.js");
5
5
  const globals_js_1 = require("../globals.js");
6
6
  const geometry_js_1 = require("./geometry.js");
7
7
  const PinTypes_js_1 = require("../objects/PinTypes.js");
8
- const utils_js_1 = require("../utils.js");
8
+ const errors_js_1 = require("../errors.js");
9
9
  const types_js_1 = require("../objects/types.js");
10
10
  const NumericValue_js_1 = require("../objects/NumericValue.js");
11
11
  const PinDefinition_js_1 = require("../objects/PinDefinition.js");
@@ -88,7 +88,7 @@ class SymbolGraphic {
88
88
  pinPosition(id) {
89
89
  const pin = this.drawing.getPinPosition(id);
90
90
  if (pin === null) {
91
- throw new utils_js_1.RuntimeExecutionError(`Could not determine pin ${id} position`);
91
+ throw new errors_js_1.RuntimeExecutionError(`Could not determine pin ${id} position`);
92
92
  }
93
93
  const [x, y] = pin.start;
94
94
  const useX = (0, NumericValue_js_1.roundValue)(x);
@@ -154,7 +154,7 @@ class SymbolGraphic {
154
154
  }
155
155
  const isHorizontalLabel = finalLabelAngle === 0 || finalLabelAngle === 180;
156
156
  const isVerticalLabel = finalLabelAngle === 90 || finalLabelAngle === -90;
157
- if (useAnchor === geometry_js_1.HorizontalAlign.Middle) {
157
+ if (useAnchor === geometry_js_1.HorizontalAlign.Center) {
158
158
  anchorStyle = geometry_js_1.HorizontalAlignProp.Middle;
159
159
  }
160
160
  else if (useAnchor === geometry_js_1.HorizontalAlign.Left) {
@@ -163,7 +163,7 @@ class SymbolGraphic {
163
163
  else if (useAnchor === geometry_js_1.HorizontalAlign.Right) {
164
164
  anchorStyle = geometry_js_1.HorizontalAlignProp.End;
165
165
  }
166
- if (useDominantBaseline === geometry_js_1.VerticalAlign.Middle) {
166
+ if (useDominantBaseline === geometry_js_1.VerticalAlign.Center) {
167
167
  dominantBaseline = geometry_js_1.VerticalAlignProp.Central;
168
168
  }
169
169
  else if (useDominantBaseline === geometry_js_1.VerticalAlign.Top) {
@@ -331,7 +331,7 @@ class SymbolGraphic {
331
331
  return geometry_js_1.HorizontalAlign.Left;
332
332
  }
333
333
  else {
334
- return geometry_js_1.HorizontalAlign.Middle;
334
+ return geometry_js_1.HorizontalAlign.Center;
335
335
  }
336
336
  }
337
337
  flipDominantBaseline(value) {
@@ -342,7 +342,7 @@ class SymbolGraphic {
342
342
  return geometry_js_1.VerticalAlign.Top;
343
343
  }
344
344
  else {
345
- return geometry_js_1.VerticalAlign.Middle;
345
+ return geometry_js_1.VerticalAlign.Center;
346
346
  }
347
347
  }
348
348
  }
@@ -359,7 +359,7 @@ class SymbolText extends SymbolGraphic {
359
359
  drawing.clear();
360
360
  drawing.addTextbox((0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(0), this.text, {
361
361
  fontSize: this.fontSize,
362
- anchor: geometry_js_1.HorizontalAlign.Middle,
362
+ anchor: geometry_js_1.HorizontalAlign.Center,
363
363
  fontWeight: this.fontWeight,
364
364
  });
365
365
  this.drawing = drawing;
@@ -469,7 +469,7 @@ class SymbolPlaceholder extends SymbolGraphic {
469
469
  drawing.addLabelMils(...tmpPositionParams);
470
470
  }
471
471
  catch (err) {
472
- (0, utils_js_1.throwWithContext)(ctx, err);
472
+ (0, errors_js_1.throwWithContext)(ctx, err);
473
473
  }
474
474
  break;
475
475
  }
@@ -647,7 +647,7 @@ class SymbolPlaceholder extends SymbolGraphic {
647
647
  displayPinName && usePinName !== "" && drawing.addLabel(endX.add(pinNameOffsetX), endY.add(pinNameOffsetY), usePinName, {
648
648
  fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.defaultPinNameTextSize),
649
649
  anchor: pinNameAlignment,
650
- vanchor: geometry_js_1.VerticalAlign.Middle,
650
+ vanchor: geometry_js_1.VerticalAlign.Center,
651
651
  textColor: pinNameColor,
652
652
  angle: (0, NumericValue_js_1.numeric)(usePinIdAngle)
653
653
  });
@@ -760,7 +760,7 @@ class SymbolCustom extends SymbolGraphic {
760
760
  drawing.addLabel(leftPinStart.add((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
761
761
  fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
762
762
  anchor: geometry_js_1.HorizontalAlign.Left,
763
- vanchor: geometry_js_1.VerticalAlign.Middle,
763
+ vanchor: geometry_js_1.VerticalAlign.Center,
764
764
  textColor: globals_js_1.ColorScheme.PinNameColor,
765
765
  });
766
766
  drawing.addLabel(leftPinStart.sub((0, helpers_js_1.milsToMM)(10)), pinY.sub((0, helpers_js_1.milsToMM)(10)), pin.pinId.toString(), {
@@ -777,7 +777,7 @@ class SymbolCustom extends SymbolGraphic {
777
777
  drawing.addLabel(rightPinStart.sub((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
778
778
  fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
779
779
  anchor: geometry_js_1.HorizontalAlign.Right,
780
- vanchor: geometry_js_1.VerticalAlign.Middle,
780
+ vanchor: geometry_js_1.VerticalAlign.Center,
781
781
  textColor: globals_js_1.ColorScheme.PinNameColor,
782
782
  });
783
783
  drawing.addLabel(rightPinStart.add((0, helpers_js_1.milsToMM)(10)), pinY.sub((0, helpers_js_1.milsToMM)(10)), pin.pinId.toString(), {
@@ -794,7 +794,7 @@ class SymbolCustom extends SymbolGraphic {
794
794
  drawing.addLabel(pinX, topPinStart.add((0, helpers_js_1.milsToMM)(20)), pin.text, {
795
795
  fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
796
796
  anchor: geometry_js_1.HorizontalAlign.Right,
797
- vanchor: geometry_js_1.VerticalAlign.Middle,
797
+ vanchor: geometry_js_1.VerticalAlign.Center,
798
798
  textColor: globals_js_1.ColorScheme.PinNameColor,
799
799
  angle: (0, NumericValue_js_1.numeric)(-90),
800
800
  });
@@ -813,7 +813,7 @@ class SymbolCustom extends SymbolGraphic {
813
813
  drawing.addLabel(pinX, bottomPinStart.sub((0, helpers_js_1.milsToMM)(20)), pin.text, {
814
814
  fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
815
815
  anchor: geometry_js_1.HorizontalAlign.Left,
816
- vanchor: geometry_js_1.VerticalAlign.Middle,
816
+ vanchor: geometry_js_1.VerticalAlign.Center,
817
817
  textColor: globals_js_1.ColorScheme.PinNameColor,
818
818
  angle: (0, NumericValue_js_1.numeric)(-90),
819
819
  });
@@ -900,7 +900,7 @@ class SymbolCustomModule extends SymbolCustom {
900
900
  drawing.addLabel(leftPinStart.add(this.portWidth).add((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
901
901
  fontSize: (0, NumericValue_js_1.numeric)(40),
902
902
  anchor: geometry_js_1.HorizontalAlign.Left,
903
- vanchor: geometry_js_1.VerticalAlign.Middle,
903
+ vanchor: geometry_js_1.VerticalAlign.Center,
904
904
  textColor: globals_js_1.ColorScheme.PinNameColor,
905
905
  });
906
906
  });
@@ -912,7 +912,7 @@ class SymbolCustomModule extends SymbolCustom {
912
912
  drawing.addLabel(rightPinStart.sub(this.portWidth).sub((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
913
913
  fontSize: (0, NumericValue_js_1.numeric)(40),
914
914
  anchor: geometry_js_1.HorizontalAlign.Right,
915
- vanchor: geometry_js_1.VerticalAlign.Middle,
915
+ vanchor: geometry_js_1.VerticalAlign.Center,
916
916
  textColor: globals_js_1.ColorScheme.PinNameColor,
917
917
  });
918
918
  });
@@ -924,7 +924,7 @@ class SymbolCustomModule extends SymbolCustom {
924
924
  drawing.addLabel(pinX, topPinStart.add(this.portWidth).add((0, helpers_js_1.milsToMM)(20)), pin.text, {
925
925
  fontSize: (0, NumericValue_js_1.numeric)(40),
926
926
  anchor: geometry_js_1.HorizontalAlign.Right,
927
- vanchor: geometry_js_1.VerticalAlign.Middle,
927
+ vanchor: geometry_js_1.VerticalAlign.Center,
928
928
  textColor: globals_js_1.ColorScheme.PinNameColor,
929
929
  angle: (0, NumericValue_js_1.numeric)(-90),
930
930
  });
@@ -937,7 +937,7 @@ class SymbolCustomModule extends SymbolCustom {
937
937
  drawing.addLabel(pinX, bottomPinStart.sub(this.portWidth).sub((0, helpers_js_1.milsToMM)(20)), pin.text, {
938
938
  fontSize: (0, NumericValue_js_1.numeric)(40),
939
939
  anchor: geometry_js_1.HorizontalAlign.Left,
940
- vanchor: geometry_js_1.VerticalAlign.Middle,
940
+ vanchor: geometry_js_1.VerticalAlign.Center,
941
941
  textColor: globals_js_1.ColorScheme.PinNameColor,
942
942
  angle: (0, NumericValue_js_1.numeric)(-90),
943
943
  });
@@ -465,7 +465,7 @@ function labelPolygonForAnchors(x, y, width, height, hAnchor, vAnchor) {
465
465
  [1, 1],
466
466
  ];
467
467
  }
468
- else if (vAnchor === VerticalAlign.Middle) {
468
+ else if (vAnchor === VerticalAlign.Center) {
469
469
  coordVectors = [
470
470
  [0, -0.5],
471
471
  [0, 0.5],
@@ -491,7 +491,7 @@ function labelPolygonForAnchors(x, y, width, height, hAnchor, vAnchor) {
491
491
  [0, -1],
492
492
  ];
493
493
  }
494
- else if (vAnchor === VerticalAlign.Middle) {
494
+ else if (vAnchor === VerticalAlign.Center) {
495
495
  coordVectors = [
496
496
  [0, -0.5],
497
497
  [0, 0.5],
@@ -508,7 +508,7 @@ function labelPolygonForAnchors(x, y, width, height, hAnchor, vAnchor) {
508
508
  ];
509
509
  }
510
510
  }
511
- else if (hAnchor === HorizontalAlign.Middle) {
511
+ else if (hAnchor === HorizontalAlign.Center) {
512
512
  if (vAnchor === VerticalAlign.Bottom) {
513
513
  coordVectors = [
514
514
  [-0.5, 0],
@@ -517,7 +517,7 @@ function labelPolygonForAnchors(x, y, width, height, hAnchor, vAnchor) {
517
517
  [0.5, 0]
518
518
  ];
519
519
  }
520
- else if (vAnchor === VerticalAlign.Middle) {
520
+ else if (vAnchor === VerticalAlign.Center) {
521
521
  coordVectors = [
522
522
  [-0.5, 0.5],
523
523
  [-0.5, -0.5],
@@ -544,13 +544,13 @@ function labelPolygonForAnchors(x, y, width, height, hAnchor, vAnchor) {
544
544
  var HorizontalAlign;
545
545
  (function (HorizontalAlign) {
546
546
  HorizontalAlign["Left"] = "left";
547
- HorizontalAlign["Middle"] = "middle";
547
+ HorizontalAlign["Center"] = "center";
548
548
  HorizontalAlign["Right"] = "right";
549
549
  })(HorizontalAlign || (exports.HorizontalAlign = HorizontalAlign = {}));
550
550
  var VerticalAlign;
551
551
  (function (VerticalAlign) {
552
552
  VerticalAlign["Top"] = "top";
553
- VerticalAlign["Middle"] = "middle";
553
+ VerticalAlign["Center"] = "center";
554
554
  VerticalAlign["Bottom"] = "bottom";
555
555
  })(VerticalAlign || (exports.VerticalAlign = VerticalAlign = {}));
556
556
  var HorizontalAlignProp;