circuitscript 0.0.38 → 0.1.0

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 (38) hide show
  1. package/dist/cjs/BaseVisitor.js +56 -38
  2. package/dist/cjs/SymbolValidatorVisitor.js +1 -1
  3. package/dist/cjs/antlr/CircuitScriptParser.js +348 -323
  4. package/dist/cjs/builtinMethods.js +5 -2
  5. package/dist/cjs/draw_symbols.js +63 -45
  6. package/dist/cjs/execute.js +29 -16
  7. package/dist/cjs/globals.js +2 -1
  8. package/dist/cjs/layout.js +14 -26
  9. package/dist/cjs/objects/Frame.js +2 -0
  10. package/dist/cjs/objects/types.js +41 -0
  11. package/dist/cjs/render.js +1 -0
  12. package/dist/cjs/utils.js +25 -1
  13. package/dist/cjs/visitor.js +70 -35
  14. package/dist/esm/BaseVisitor.mjs +56 -38
  15. package/dist/esm/SymbolValidatorVisitor.mjs +1 -1
  16. package/dist/esm/antlr/CircuitScriptParser.mjs +348 -323
  17. package/dist/esm/builtinMethods.mjs +5 -2
  18. package/dist/esm/draw_symbols.mjs +67 -47
  19. package/dist/esm/execute.mjs +29 -16
  20. package/dist/esm/globals.mjs +1 -0
  21. package/dist/esm/layout.mjs +13 -26
  22. package/dist/esm/objects/Frame.mjs +2 -0
  23. package/dist/esm/objects/types.mjs +42 -0
  24. package/dist/esm/render.mjs +2 -1
  25. package/dist/esm/utils.mjs +22 -0
  26. package/dist/esm/visitor.mjs +71 -36
  27. package/dist/types/BaseVisitor.d.ts +2 -1
  28. package/dist/types/antlr/CircuitScriptParser.d.ts +3 -0
  29. package/dist/types/draw_symbols.d.ts +11 -5
  30. package/dist/types/execute.d.ts +1 -1
  31. package/dist/types/globals.d.ts +1 -0
  32. package/dist/types/layout.d.ts +1 -0
  33. package/dist/types/objects/Frame.d.ts +3 -1
  34. package/dist/types/objects/types.d.ts +7 -2
  35. package/dist/types/utils.d.ts +3 -0
  36. package/dist/types/visitor.d.ts +1 -0
  37. package/libs/lib.cst +88 -30
  38. package/package.json +1 -1
@@ -45,7 +45,7 @@ function range(...args) {
45
45
  }
46
46
  function enumerate(array) {
47
47
  if (!Array.isArray(array)) {
48
- throw "Invalid parameter for enumerate function!";
48
+ throw "Invalid parameter for enumerate function";
49
49
  }
50
50
  const output = array.map((item, index) => {
51
51
  return [index, item];
@@ -86,7 +86,10 @@ function toString(obj) {
86
86
  return "[" + inner + "]";
87
87
  }
88
88
  else {
89
- if (obj.toString) {
89
+ if (obj.toDisplayString) {
90
+ return obj.toDisplayString();
91
+ }
92
+ else if (obj.toString) {
90
93
  return obj.toString();
91
94
  }
92
95
  else {
@@ -6,6 +6,7 @@ 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
8
  const utils_js_1 = require("./utils.js");
9
+ const types_js_1 = require("./objects/types.js");
9
10
  class SymbolGraphic {
10
11
  constructor() {
11
12
  this.drawPortsName = true;
@@ -14,6 +15,7 @@ class SymbolGraphic {
14
15
  this._flipX = 0;
15
16
  this._flipY = 0;
16
17
  this.labelTexts = new Map();
18
+ this.drawing = new SymbolDrawing();
17
19
  }
18
20
  get angle() {
19
21
  return (this._angle % 360);
@@ -312,15 +314,6 @@ class SymbolGraphic {
312
314
  return geometry_js_1.VerticalAlign.Middle;
313
315
  }
314
316
  }
315
- setLabelValue(labelId, labelValue) {
316
- this.labelTexts.set(labelId, labelValue);
317
- }
318
- getLabelValue(labelId) {
319
- if (this.labelTexts.has(labelId)) {
320
- return this.labelTexts.get(labelId);
321
- }
322
- return undefined;
323
- }
324
317
  }
325
318
  exports.SymbolGraphic = SymbolGraphic;
326
319
  function SymbolFactory(name) {
@@ -333,7 +326,8 @@ function SymbolFactory(name) {
333
326
  exports.SymbolFactory = SymbolFactory;
334
327
  class SymbolPointHidden extends SymbolGraphic {
335
328
  generateDrawing() {
336
- const drawing = new SymbolDrawing();
329
+ const drawing = this.drawing;
330
+ drawing.clear();
337
331
  drawing.addPin(1, 0, 0, 0, 0);
338
332
  this.drawing = drawing;
339
333
  }
@@ -347,7 +341,8 @@ class SymbolText extends SymbolGraphic {
347
341
  this.text = text;
348
342
  }
349
343
  generateDrawing() {
350
- const drawing = new SymbolDrawing();
344
+ const drawing = this.drawing;
345
+ drawing.clear();
351
346
  drawing.addTextbox(0, 0, this.text, {
352
347
  fontSize: this.fontSize,
353
348
  anchor: geometry_js_1.HorizontalAlign.Middle,
@@ -375,7 +370,17 @@ class SymbolPlaceholder extends SymbolGraphic {
375
370
  drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
376
371
  let lineColor = "#333";
377
372
  let textColor = "#333";
378
- commands.forEach(([commandName, positionParams, keywordParams]) => {
373
+ commands.forEach(([commandName, positionParams, keywordParams, ctx]) => {
374
+ positionParams = positionParams.map(param => {
375
+ return this.resolveReference(param);
376
+ });
377
+ if (keywordParams instanceof Map) {
378
+ const tmpKeywordParams = new Map(keywordParams);
379
+ tmpKeywordParams.forEach((value, key) => {
380
+ tmpKeywordParams.set(key, this.resolveReference(value));
381
+ });
382
+ keywordParams = tmpKeywordParams;
383
+ }
379
384
  switch (commandName) {
380
385
  case PlaceHolderCommands.rect:
381
386
  drawing.log('add rect', ...positionParams);
@@ -431,16 +436,17 @@ class SymbolPlaceholder extends SymbolGraphic {
431
436
  if (style['textColor'] === undefined) {
432
437
  style['textColor'] = textColor;
433
438
  }
434
- positionParams = [...positionParams];
435
- positionParams.push(style);
436
- const labelId = positionParams[0];
437
- const tmpPositionParams = [...positionParams];
438
- const tmpLabelValue = this.getLabelValue(labelId);
439
- if (tmpLabelValue !== undefined) {
440
- tmpPositionParams[3] = tmpLabelValue;
441
- }
439
+ const tmpPositionParams = [
440
+ positionParams[1], positionParams[2],
441
+ positionParams[0], style
442
+ ];
442
443
  drawing.log('add label', JSON.stringify(tmpPositionParams));
443
- drawing.addLabelId(...tmpPositionParams);
444
+ try {
445
+ drawing.addLabelMils(...tmpPositionParams);
446
+ }
447
+ catch (err) {
448
+ (0, utils_js_1.throwWithContext)(ctx, err);
449
+ }
444
450
  break;
445
451
  }
446
452
  case PlaceHolderCommands.text: {
@@ -464,13 +470,30 @@ class SymbolPlaceholder extends SymbolGraphic {
464
470
  });
465
471
  drawing.log("=== end generate drawing ===");
466
472
  }
473
+ resolveReference(param) {
474
+ if (param instanceof types_js_1.DeclaredReference) {
475
+ return param.value;
476
+ }
477
+ else if (param instanceof types_js_1.UndeclaredReference) {
478
+ throw "Undefined symbol: " + param.nameString();
479
+ }
480
+ return param;
481
+ }
467
482
  parseLabelStyle(keywordParams) {
468
483
  const keywords = ['fontSize', 'anchor', 'vanchor',
469
- 'angle', 'textColor', 'portType'];
484
+ 'angle', 'textColor', 'portType', 'bold'];
470
485
  const style = {};
471
486
  keywords.forEach(item => {
472
487
  if (keywordParams.has(item)) {
473
488
  style[item] = keywordParams.get(item);
489
+ if (item === 'bold') {
490
+ if (keywordParams.get(item) === true) {
491
+ style['fontWeight'] = 'bold';
492
+ }
493
+ else {
494
+ style['fontWeight'] = 'normal';
495
+ }
496
+ }
474
497
  }
475
498
  });
476
499
  return style;
@@ -629,7 +652,8 @@ class SymbolCustom extends SymbolGraphic {
629
652
  });
630
653
  const maxLeftPins = Math.max(...leftPins.map(item => item.position)) + 1;
631
654
  const maxRightPins = Math.max(...rightPins.map(item => item.position)) + 1;
632
- const drawing = new SymbolDrawing();
655
+ this.drawing.clear();
656
+ const drawing = this.drawing;
633
657
  drawing.angle = this._angle;
634
658
  drawing.flipX = this._flipX;
635
659
  drawing.flipY = this._flipY;
@@ -682,14 +706,14 @@ class SymbolCustom extends SymbolGraphic {
682
706
  textColor: defaultLineColor
683
707
  });
684
708
  });
685
- const instanceName = this.getLabelValue("refdes");
709
+ const instanceName = drawing.variables.get('refdes');
686
710
  instanceName && drawing.addLabel(-bodyWidthMM / 2, -bodyHeightMM / 2 - (0, helpers_js_1.milsToMM)(20), instanceName, {
687
711
  fontSize: globals_js_1.CustomSymbolRefDesSize,
688
712
  anchor: geometry_js_1.HorizontalAlign.Left,
689
713
  });
690
714
  const acceptedMPNKeys = ['MPN', 'mpn', 'manufacturer_pn'];
691
715
  acceptedMPNKeys.some(key => {
692
- const labelValue = this.getLabelValue(key);
716
+ const labelValue = drawing.variables.get(key);
693
717
  if (labelValue !== undefined) {
694
718
  drawing.addLabel(-bodyWidthMM / 2, bodyHeightMM / 2 + (0, helpers_js_1.milsToMM)(20), labelValue, {
695
719
  fontSize: globals_js_1.CustomSymbolParamTextSize,
@@ -752,6 +776,7 @@ class SymbolDrawing {
752
776
  this.flipY = 0;
753
777
  this.mainOrigin = [0, 0];
754
778
  this.logger = null;
779
+ this.variables = new Map();
755
780
  }
756
781
  clear() {
757
782
  this.items = [];
@@ -868,10 +893,10 @@ class SymbolDrawing {
868
893
  this.items.push(geometry_js_1.Geometry.label(null, x, y, textValue, style));
869
894
  return this;
870
895
  }
871
- addLabelId(id, x, y, textValue, style) {
896
+ addLabelMils(x, y, textValue, style) {
872
897
  x = (0, helpers_js_1.milsToMM)(x);
873
898
  y = (0, helpers_js_1.milsToMM)(y);
874
- this.items.push(geometry_js_1.Geometry.label(id, x, y, textValue, style));
899
+ this.items.push(geometry_js_1.Geometry.label(null, x, y, textValue, style));
875
900
  return this;
876
901
  }
877
902
  addTextbox(x, y, textValue, style) {
@@ -1097,32 +1122,25 @@ class SymbolDrawing {
1097
1122
  }
1098
1123
  exports.SymbolDrawing = SymbolDrawing;
1099
1124
  class SymbolDrawingCommands extends SymbolDrawing {
1100
- constructor(commands) {
1125
+ constructor(callback) {
1101
1126
  super();
1102
1127
  this.id = "";
1103
- this.commands = commands;
1128
+ this.commands = [];
1129
+ this.paramIds = [];
1130
+ this.callback = callback;
1104
1131
  this.id = Math.random().toString().slice(2);
1105
1132
  }
1133
+ runCommands() {
1134
+ this.commands = this.callback(this.variables);
1135
+ }
1106
1136
  getCommands() {
1137
+ this.runCommands();
1107
1138
  return this.commands;
1108
1139
  }
1109
1140
  clone() {
1110
- const tmpCommands = this.commands.map(item => {
1111
- if (item[0] === PlaceHolderCommands.label) {
1112
- const commandName = item[0];
1113
- const positionParams = item[1];
1114
- const keywordParams = item[2];
1115
- const newMap = new Map();
1116
- for (const [key, value] of keywordParams) {
1117
- newMap.set(key, value);
1118
- }
1119
- return [commandName, positionParams, newMap];
1120
- }
1121
- else {
1122
- return [...item];
1123
- }
1124
- });
1125
- return new SymbolDrawingCommands(tmpCommands);
1141
+ const cloned = new SymbolDrawingCommands(this.callback);
1142
+ cloned.variables = this.variables;
1143
+ return cloned;
1126
1144
  }
1127
1145
  }
1128
1146
  exports.SymbolDrawingCommands = SymbolDrawingCommands;
@@ -461,7 +461,7 @@ class ExecutionContext {
461
461
  getFunction(functionName) {
462
462
  return this.scope.functions.get(functionName);
463
463
  }
464
- resolveVariable(executionStack, idName) {
464
+ resolveVariable(executionStack, idName, trailers = []) {
465
465
  const reversed = [...executionStack].reverse();
466
466
  for (let i = 0; i < reversed.length; i++) {
467
467
  const context = reversed[i];
@@ -473,21 +473,34 @@ class ExecutionContext {
473
473
  name: idName,
474
474
  });
475
475
  }
476
- else if (context.scope.variables.has(idName)) {
477
- return new types_js_1.DeclaredReference({
478
- found: true,
479
- value: context.scope.variables.get(idName),
480
- type: globals_js_1.ReferenceTypes.variable,
481
- name: idName,
482
- });
483
- }
484
- else if (context.scope.instances.has(idName)) {
485
- return new types_js_1.DeclaredReference({
486
- found: true,
487
- value: context.scope.instances.get(idName),
488
- type: globals_js_1.ReferenceTypes.instance,
489
- name: idName,
490
- });
476
+ else {
477
+ const isVariable = context.scope.variables.has(idName);
478
+ const isComponentInstance = context.scope.instances.has(idName);
479
+ if (isVariable || isComponentInstance) {
480
+ const scopeList = isVariable ? context.scope.variables
481
+ : context.scope.instances;
482
+ let parentValue = undefined;
483
+ let useValue = scopeList.get(idName);
484
+ if (trailers.length > 0) {
485
+ parentValue = useValue;
486
+ const trailersPath = trailers.join(".");
487
+ if (isVariable) {
488
+ useValue = parentValue[trailersPath];
489
+ }
490
+ else if (isComponentInstance) {
491
+ useValue = parentValue.parameters.get(trailersPath);
492
+ }
493
+ }
494
+ return new types_js_1.DeclaredReference({
495
+ type: isVariable ? globals_js_1.ReferenceTypes.variable
496
+ : globals_js_1.ReferenceTypes.instance,
497
+ found: (useValue !== undefined),
498
+ parentValue,
499
+ value: useValue,
500
+ name: idName,
501
+ trailers,
502
+ });
503
+ }
491
504
  }
492
505
  }
493
506
  return new types_js_1.DeclaredReference({
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RenderFlags = exports.GlobalDocumentName = 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;
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
4
  var GlobalNames;
5
5
  (function (GlobalNames) {
6
6
  GlobalNames["__root"] = "__root";
@@ -100,6 +100,7 @@ var FrameType;
100
100
  FrameType[FrameType["Frame"] = 1] = "Frame";
101
101
  FrameType[FrameType["Sheet"] = 2] = "Sheet";
102
102
  })(FrameType || (exports.FrameType = FrameType = {}));
103
+ exports.ModuleContainsKeyword = 'contains';
103
104
  exports.GlobalDocumentName = 'document';
104
105
  exports.RenderFlags = {
105
106
  ShowElementFrames: false,
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExtractDrawingRects = exports.CalculatePinPositions = exports.RenderJunction = exports.RenderFrameType = exports.RenderFrame = exports.RenderText = exports.RenderComponent = exports.RenderWire = exports.RenderObject = exports.getBounds = exports.LayoutEngine = void 0;
3
+ exports.ExtractDrawingRects = exports.CalculatePinPositions = exports.RenderJunction = exports.RenderFrameType = exports.RenderFrame = exports.RenderText = exports.RenderComponent = exports.RenderWire = exports.RenderObject = exports.getBounds = exports.applyComponentParamsToSymbol = exports.LayoutEngine = void 0;
4
4
  const graphlib_1 = require("@dagrejs/graphlib");
5
5
  const draw_symbols_js_1 = require("./draw_symbols.js");
6
6
  const ExecutionScope_js_1 = require("./objects/ExecutionScope.js");
7
7
  const globals_js_1 = require("./globals.js");
8
- const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
9
8
  const geometry_js_1 = require("./geometry.js");
10
9
  const logger_js_1 = require("./logger.js");
11
10
  const Frame_js_1 = require("./objects/Frame.js");
@@ -289,7 +288,9 @@ class LayoutEngine {
289
288
  const contentsBounds = (0, utils_js_1.resizeBounds)(getBoundsFromPoints(boundPoints), frame.padding);
290
289
  if (frame.frame.parameters.has(Frame_js_1.FrameParamKeys.SheetType)) {
291
290
  const frameComponent = frame.frame.parameters.get(Frame_js_1.FrameParamKeys.SheetType);
292
- const rects = ExtractDrawingRects(frameComponent.displayProp);
291
+ const frameDrawing = frameComponent.displayProp;
292
+ frameDrawing.variables = (0, utils_js_1.combineMaps)(frameComponent.parameters, frame.frame.parameters);
293
+ const rects = ExtractDrawingRects(frameDrawing);
293
294
  let frameWidth = 0;
294
295
  let frameHeight = 0;
295
296
  if (rects[1]) {
@@ -375,7 +376,8 @@ class LayoutEngine {
375
376
  }, []);
376
377
  if (frame.type === RenderFrameType.Container) {
377
378
  const frameObject = frame.frame;
378
- if (frameObject.parameters.has(Frame_js_1.FrameParamKeys.Title)) {
379
+ const isSheetFrame = frameObject.frameType === globals_js_1.FrameType.Sheet;
380
+ if (frameObject.parameters.has(Frame_js_1.FrameParamKeys.Title) && !isSheetFrame) {
379
381
  const title = frameObject.parameters.get(Frame_js_1.FrameParamKeys.Title);
380
382
  const tmpFrame = new RenderFrame(new Frame_js_1.Frame(-2), RenderFrameType.Elements);
381
383
  tmpFrame.containsTitle = true;
@@ -450,7 +452,7 @@ class LayoutEngine {
450
452
  tmpSymbol = new draw_symbols_js_1.SymbolCustom(symbolPinDefinitions);
451
453
  }
452
454
  }
453
- applyComponentParamsToSymbol(typeProp, component, tmpSymbol);
455
+ applyComponentParamsToSymbol(component, tmpSymbol);
454
456
  let didSetAngle = false;
455
457
  if (component.parameters.has('angle')) {
456
458
  didSetAngle = true;
@@ -999,29 +1001,14 @@ function generateLayoutPinDefinition(component) {
999
1001
  }
1000
1002
  return symbolPinDefinitions;
1001
1003
  }
1002
- function applyComponentParamsToSymbol(typeProp, component, symbol) {
1003
- if (typeProp === 'net') {
1004
- symbol.setLabelValue("net_name", component.parameters.get(globals_js_1.ParamKeys.net_name));
1005
- }
1006
- if (component.assignedRefDes !== null) {
1007
- symbol.setLabelValue("refdes", component.assignedRefDes);
1008
- }
1009
- for (const [key, value] of component.parameters) {
1010
- if (key !== 'refdes' && key !== 'net_name') {
1011
- let useValue;
1012
- if (typeof value == 'object' && (value instanceof ParamDefinition_js_1.NumericValue)) {
1013
- useValue = value.toDisplayString();
1014
- }
1015
- else if (typeof value === 'number') {
1016
- useValue = value.toString();
1017
- }
1018
- else if (typeof value === 'string') {
1019
- useValue = value;
1020
- }
1021
- symbol.setLabelValue(key, useValue);
1022
- }
1004
+ function applyComponentParamsToSymbol(component, symbol) {
1005
+ const newMap = new Map(component.parameters);
1006
+ if (!newMap.has('refdes')) {
1007
+ newMap.set('refdes', component.assignedRefDes ?? "?");
1023
1008
  }
1009
+ symbol.drawing.variables = newMap;
1024
1010
  }
1011
+ exports.applyComponentParamsToSymbol = applyComponentParamsToSymbol;
1025
1012
  function calculateSymbolAngle(symbol, pin, direction) {
1026
1013
  let directionVector = 0;
1027
1014
  switch (direction) {
@@ -1342,6 +1329,7 @@ function CalculatePinPositions(component) {
1342
1329
  const symbolPinDefinitions = generateLayoutPinDefinition(component);
1343
1330
  tmpSymbol = new draw_symbols_js_1.SymbolCustom(symbolPinDefinitions);
1344
1331
  }
1332
+ applyComponentParamsToSymbol(component, tmpSymbol);
1345
1333
  tmpSymbol.refreshDrawing();
1346
1334
  const pins = component.pins;
1347
1335
  pins.forEach((value, key) => {
@@ -19,6 +19,8 @@ var FrameParamKeys;
19
19
  FrameParamKeys["Height"] = "height";
20
20
  FrameParamKeys["PaperSize"] = "paper_size";
21
21
  FrameParamKeys["SheetType"] = "sheet_type";
22
+ FrameParamKeys["SheetNumber"] = "sheet_number";
23
+ FrameParamKeys["SheetTotal"] = "sheet_total";
22
24
  })(FrameParamKeys || (exports.FrameParamKeys = FrameParamKeys = {}));
23
25
  var FramePlotDirection;
24
26
  (function (FramePlotDirection) {
@@ -8,6 +8,17 @@ class UndeclaredReference {
8
8
  throwMessage() {
9
9
  return `Unknown symbol: ${this.reference.name}`;
10
10
  }
11
+ toString() {
12
+ return 'undefined';
13
+ }
14
+ nameString() {
15
+ const { name, trailers = [] } = this.reference;
16
+ let extra = '';
17
+ if (trailers.length > 0) {
18
+ extra = '.' + trailers.join('.');
19
+ }
20
+ return name + extra;
21
+ }
11
22
  }
12
23
  exports.UndeclaredReference = UndeclaredReference;
13
24
  class DeclaredReference {
@@ -17,10 +28,40 @@ class DeclaredReference {
17
28
  this.trailers = refType.trailers;
18
29
  this.type = refType.type;
19
30
  this.value = refType.value;
31
+ this.parentValue = refType.parentValue;
20
32
  }
21
33
  toString() {
22
34
  return `[DeclaredReference name: ${this.name} trailers:${this.trailers} found: ${this.found}]`;
23
35
  }
36
+ toDisplayString() {
37
+ let returnValue = undefined;
38
+ if (this.parentValue) {
39
+ const trailersString = this.trailers.join(".");
40
+ if (this.type === 'instance') {
41
+ returnValue = this.parentValue.parameters.get(trailersString);
42
+ }
43
+ else if (this.type === 'variable') {
44
+ returnValue = this.parentValue[trailersString];
45
+ }
46
+ }
47
+ else {
48
+ returnValue = this.value;
49
+ }
50
+ if (returnValue !== undefined) {
51
+ if (returnValue !== null) {
52
+ if (returnValue.toDisplayString) {
53
+ return returnValue.toDisplayString();
54
+ }
55
+ else {
56
+ return returnValue.toString();
57
+ }
58
+ }
59
+ else {
60
+ return 'null';
61
+ }
62
+ }
63
+ throw 'Could not find string value: ' + this;
64
+ }
24
65
  }
25
66
  exports.DeclaredReference = DeclaredReference;
26
67
  var ParseSymbolType;
@@ -263,6 +263,7 @@ function drawSheetFrameBorder(frameGroup, frame) {
263
263
  if (displayProp) {
264
264
  const sheetFrameGroup = frameGroup.group();
265
265
  const symbol = new draw_symbols_js_1.SymbolPlaceholder(displayProp);
266
+ symbol.drawing.variables = (0, utils_js_1.combineMaps)(frameComponent.parameters, frameParams);
266
267
  symbol.refreshDrawing();
267
268
  symbol.draw(sheetFrameGroup);
268
269
  const offsetX = (0, helpers_js_1.milsToMM)(frameComponent.getParam('offset_x'));
package/dist/cjs/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roundValue = exports.getPortType = exports.getBoundsSize = exports.toNearestGrid = exports.resizeToNearestGrid = exports.printBounds = exports.resizeBounds = exports.SimpleStopwatch = void 0;
3
+ exports.combineMaps = exports.throwWithContext = exports.roundValue = exports.getPortType = exports.getBoundsSize = exports.toNearestGrid = exports.resizeToNearestGrid = exports.printBounds = exports.resizeBounds = exports.SimpleStopwatch = void 0;
4
4
  class SimpleStopwatch {
5
5
  constructor() {
6
6
  this.startTime = new Date();
@@ -76,3 +76,27 @@ function roundValue(value) {
76
76
  return +value.toFixed(7);
77
77
  }
78
78
  exports.roundValue = roundValue;
79
+ function throwWithContext(context, message) {
80
+ const startLine = context.start?.line;
81
+ const startColumn = context.start?.column;
82
+ const startString = startLine + ":" + startColumn;
83
+ const stopLine = context.stop?.line;
84
+ const stopColumn = context.stop?.column;
85
+ let stopString = "";
86
+ if (startLine === stopLine) {
87
+ stopString = stopColumn?.toString();
88
+ }
89
+ else {
90
+ stopString = stopLine + ":" + stopString;
91
+ }
92
+ throw `Parse exception at [${startString} - ${stopString}] : ${message}`;
93
+ }
94
+ exports.throwWithContext = throwWithContext;
95
+ function combineMaps(map1, map2) {
96
+ const newMap = new Map(map1);
97
+ map2.forEach((value, key) => {
98
+ newMap.set(key, value);
99
+ });
100
+ return newMap;
101
+ }
102
+ exports.combineMaps = combineMaps;