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.
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 +320 -197
  6. package/dist/cjs/execute.js +114 -116
  7. package/dist/cjs/export.js +2 -4
  8. package/dist/cjs/geometry.js +52 -19
  9. package/dist/cjs/globals.js +17 -12
  10. package/dist/cjs/helpers.js +16 -3
  11. package/dist/cjs/layout.js +473 -354
  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 +11 -2
  16. package/dist/cjs/objects/ParamDefinition.js +123 -4
  17. package/dist/cjs/objects/PinDefinition.js +1 -4
  18. package/dist/cjs/render.js +76 -138
  19. package/dist/cjs/sizing.js +33 -7
  20. package/dist/cjs/utils.js +86 -2
  21. package/dist/cjs/visitor.js +224 -255
  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 +322 -200
  27. package/dist/esm/execute.mjs +116 -118
  28. package/dist/esm/export.mjs +2 -4
  29. package/dist/esm/geometry.mjs +52 -19
  30. package/dist/esm/globals.mjs +17 -12
  31. package/dist/esm/helpers.mjs +17 -4
  32. package/dist/esm/layout.mjs +479 -360
  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 +10 -1
  37. package/dist/esm/objects/ParamDefinition.mjs +122 -3
  38. package/dist/esm/objects/PinDefinition.mjs +0 -2
  39. package/dist/esm/render.mjs +79 -141
  40. package/dist/esm/sizing.mjs +34 -8
  41. package/dist/esm/utils.mjs +80 -1
  42. package/dist/esm/visitor.mjs +226 -257
  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 +72 -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 +15 -11
  49. package/dist/types/helpers.d.ts +2 -1
  50. package/dist/types/layout.d.ts +35 -54
  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 +3 -2
  54. package/dist/types/objects/Frame.d.ts +9 -2
  55. package/dist/types/objects/ParamDefinition.d.ts +32 -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 +14 -1
  59. package/dist/types/visitor.d.ts +4 -5
  60. package/libs/lib.cst +25 -8
  61. package/package.json +7 -3
@@ -1,10 +1,7 @@
1
+ import { numeric } from "./objects/ParamDefinition";
1
2
  export var GlobalNames;
2
3
  (function (GlobalNames) {
3
4
  GlobalNames["__root"] = "__root";
4
- GlobalNames["gnd"] = "gnd";
5
- GlobalNames["DefaultResistor"] = "res";
6
- GlobalNames["DefaultCapacitor"] = "cap";
7
- GlobalNames["DefaultInductor"] = "ind";
8
5
  GlobalNames["symbol"] = "symbol";
9
6
  })(GlobalNames || (GlobalNames = {}));
10
7
  export const NoNetText = 'NO_NET';
@@ -12,6 +9,10 @@ export var ParamKeys;
12
9
  (function (ParamKeys) {
13
10
  ParamKeys["priority"] = "priority";
14
11
  ParamKeys["net_name"] = "net_name";
12
+ ParamKeys["flip"] = "flip";
13
+ ParamKeys["flipX"] = "flipX";
14
+ ParamKeys["flipY"] = "flipY";
15
+ ParamKeys["angle"] = "angle";
15
16
  })(ParamKeys || (ParamKeys = {}));
16
17
  export var LayoutDirection;
17
18
  (function (LayoutDirection) {
@@ -22,6 +23,8 @@ export var SymbolPinSide;
22
23
  (function (SymbolPinSide) {
23
24
  SymbolPinSide["Left"] = "left";
24
25
  SymbolPinSide["Right"] = "right";
26
+ SymbolPinSide["Top"] = "top";
27
+ SymbolPinSide["Bottom"] = "bottom";
25
28
  })(SymbolPinSide || (SymbolPinSide = {}));
26
29
  export var LengthUnit;
27
30
  (function (LengthUnit) {
@@ -40,11 +43,11 @@ export const MMToPt = 2.8346456693;
40
43
  export const PxToMM = 0.2645833;
41
44
  export const portWidth = 20;
42
45
  export const portHeight = 2;
43
- export const defaultGridSizeUnits = MilsToMM * 100;
46
+ export const defaultGridSizeUnits = numeric(MilsToMM).mul(100).toNumber();
44
47
  export const defaultZoomScale = 2.5;
45
48
  export const fontDisplayScale = 0.032;
46
- export const defaultSymbolLineWidth = MilsToMM * 6;
47
- export const defaultWireLineWidth = MilsToMM * 6;
49
+ export const defaultSymbolLineWidth = numeric(MilsToMM).mul(6).toNumber();
50
+ export const defaultWireLineWidth = numeric(MilsToMM).mul(6).toNumber();
48
51
  export const defaultPinNameTextSize = 40;
49
52
  export const defaultPinIdTextSize = 30;
50
53
  export const defaultPageMarginMM = 10;
@@ -58,7 +61,7 @@ export const displayUnits = LengthUnit.mils;
58
61
  export const defaultFont = 'Arial';
59
62
  export const defaultFontBold = 'Arial';
60
63
  export const defaultFontSize = 10;
61
- export const junctionSize = MilsToMM * 20;
64
+ export const junctionSize = numeric(MilsToMM).mul(20);
62
65
  export const PortArrowSize = MilsToMM * 50;
63
66
  export const PortPaddingHorizontal = MilsToMM * 10;
64
67
  export const PortPaddingVertical = MilsToMM * 10;
@@ -71,11 +74,10 @@ export const ColorScheme = {
71
74
  };
72
75
  export var ComponentTypes;
73
76
  (function (ComponentTypes) {
74
- ComponentTypes["gnd"] = "gnd";
75
77
  ComponentTypes["net"] = "net";
76
- ComponentTypes["label"] = "label";
77
- ComponentTypes["point"] = "point";
78
- ComponentTypes["frame"] = "frame";
78
+ ComponentTypes["graphic"] = "graphic";
79
+ ComponentTypes["port"] = "port";
80
+ ComponentTypes["module"] = "module";
79
81
  })(ComponentTypes || (ComponentTypes = {}));
80
82
  export var ReferenceTypes;
81
83
  (function (ReferenceTypes) {
@@ -102,4 +104,7 @@ export const GlobalDocumentName = 'document';
102
104
  export const RenderFlags = {
103
105
  ShowElementFrames: false,
104
106
  ShowOrigin: false,
107
+ ShowGridOrigin: false,
108
+ ShowLabelBoxBounds: false,
109
+ ShowLabelOrigin: false,
105
110
  };
@@ -6,7 +6,7 @@ import { LayoutEngine } from "./layout.mjs";
6
6
  import { SequenceAction } from "./objects/ExecutionScope.mjs";
7
7
  import { parseFileWithVisitor } from "./parser.mjs";
8
8
  import { generatePdfOutput, generateSvgOutput, renderSheetsToSVG } from "./render.mjs";
9
- import { SimpleStopwatch } from "./utils.mjs";
9
+ import { resolveToNumericValue, SimpleStopwatch } from "./utils.mjs";
10
10
  import { ParserVisitor, VisitorExecutionException } from "./visitor.mjs";
11
11
  import { createContext } from "this-file";
12
12
  import { SymbolValidatorResolveVisitor, SymbolValidatorVisitor } from "./SymbolValidatorVisitor.mjs";
@@ -16,6 +16,8 @@ import { CircuitScriptParser } from "./antlr/CircuitScriptParser.mjs";
16
16
  import { prepareTokens, SemanticTokensVisitor } from "./SemanticTokenVisitor.mjs";
17
17
  import { defaultPageMarginMM, defaultZoomScale, LengthUnit, MilsToMM, PxToMM } from "./globals.mjs";
18
18
  import { FrameParamKeys } from "./objects/Frame.mjs";
19
+ import Big from "big.js";
20
+ import { Logger } from "./logger.mjs";
19
21
  export var JSModuleType;
20
22
  (function (JSModuleType) {
21
23
  JSModuleType["CommonJs"] = "cjs";
@@ -189,7 +191,13 @@ export function renderScript(scriptData, outputPath, options) {
189
191
  const action = tmp[0];
190
192
  if (action === SequenceAction.Wire) {
191
193
  tmp[2] = tmp[2].map(item2 => {
192
- return [item2.direction, item2.value].join(",");
194
+ const lengthValue = item2.value;
195
+ const useValue = [item2.direction];
196
+ if (lengthValue !== null) {
197
+ useValue.push(lengthValue.value);
198
+ useValue.push(lengthValue.type);
199
+ }
200
+ return useValue.join(",");
193
201
  }).join(" ");
194
202
  }
195
203
  else if (action === SequenceAction.Frame) {
@@ -227,8 +235,10 @@ export function renderScript(scriptData, outputPath, options) {
227
235
  showStats && console.log('Layout took:', layoutTimer.lap());
228
236
  dumpData && writeFileSync('dump/raw-layout.txt', layoutEngine.logger.dump());
229
237
  const generateSvgTimer = new SimpleStopwatch();
230
- const svgCanvas = renderSheetsToSVG(sheetFrames);
238
+ const renderLogger = new Logger();
239
+ const svgCanvas = renderSheetsToSVG(sheetFrames, renderLogger);
231
240
  showStats && console.log('Render took:', generateSvgTimer.lap());
241
+ dumpData && writeFileSync('dump/raw-render.txt', renderLogger.dump());
232
242
  svgOutput = generateSvgOutput(svgCanvas, outputDefaultZoom);
233
243
  if (outputPath) {
234
244
  if (fileExtension === 'svg') {
@@ -320,7 +330,10 @@ export class UnitDimension {
320
330
  }
321
331
  }
322
332
  export function milsToMM(value) {
323
- return value * MilsToMM;
333
+ if (typeof value === 'number') {
334
+ value = resolveToNumericValue(new Big(value));
335
+ }
336
+ return resolveToNumericValue(value.toBigNumber().mul(new Big(MilsToMM)).round(6));
324
337
  }
325
338
  export function pxToMM(value) {
326
339
  return value * PxToMM;