circuitscript 0.0.37 → 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 (40) hide show
  1. package/dist/cjs/BaseVisitor.js +56 -38
  2. package/dist/cjs/SymbolValidatorVisitor.js +1 -1
  3. package/dist/cjs/antlr/CircuitScriptLexer.js +95 -90
  4. package/dist/cjs/antlr/CircuitScriptParser.js +350 -325
  5. package/dist/cjs/builtinMethods.js +5 -2
  6. package/dist/cjs/draw_symbols.js +63 -45
  7. package/dist/cjs/execute.js +29 -16
  8. package/dist/cjs/globals.js +2 -1
  9. package/dist/cjs/layout.js +14 -26
  10. package/dist/cjs/objects/Frame.js +2 -0
  11. package/dist/cjs/objects/types.js +41 -0
  12. package/dist/cjs/render.js +1 -0
  13. package/dist/cjs/utils.js +25 -1
  14. package/dist/cjs/visitor.js +73 -35
  15. package/dist/esm/BaseVisitor.mjs +56 -38
  16. package/dist/esm/SymbolValidatorVisitor.mjs +1 -1
  17. package/dist/esm/antlr/CircuitScriptLexer.mjs +95 -90
  18. package/dist/esm/antlr/CircuitScriptParser.mjs +350 -325
  19. package/dist/esm/builtinMethods.mjs +5 -2
  20. package/dist/esm/draw_symbols.mjs +67 -47
  21. package/dist/esm/execute.mjs +29 -16
  22. package/dist/esm/globals.mjs +1 -0
  23. package/dist/esm/layout.mjs +13 -26
  24. package/dist/esm/objects/Frame.mjs +2 -0
  25. package/dist/esm/objects/types.mjs +42 -0
  26. package/dist/esm/render.mjs +2 -1
  27. package/dist/esm/utils.mjs +22 -0
  28. package/dist/esm/visitor.mjs +74 -36
  29. package/dist/types/BaseVisitor.d.ts +2 -1
  30. package/dist/types/antlr/CircuitScriptParser.d.ts +3 -0
  31. package/dist/types/draw_symbols.d.ts +11 -5
  32. package/dist/types/execute.d.ts +1 -1
  33. package/dist/types/globals.d.ts +1 -0
  34. package/dist/types/layout.d.ts +1 -0
  35. package/dist/types/objects/Frame.d.ts +3 -1
  36. package/dist/types/objects/types.d.ts +7 -2
  37. package/dist/types/utils.d.ts +3 -0
  38. package/dist/types/visitor.d.ts +1 -0
  39. package/libs/lib.cst +88 -30
  40. package/package.json +1 -1
@@ -41,7 +41,7 @@ function range(...args) {
41
41
  }
42
42
  function enumerate(array) {
43
43
  if (!Array.isArray(array)) {
44
- throw "Invalid parameter for enumerate function!";
44
+ throw "Invalid parameter for enumerate function";
45
45
  }
46
46
  const output = array.map((item, index) => {
47
47
  return [index, item];
@@ -82,7 +82,10 @@ function toString(obj) {
82
82
  return "[" + inner + "]";
83
83
  }
84
84
  else {
85
- if (obj.toString) {
85
+ if (obj.toDisplayString) {
86
+ return obj.toDisplayString();
87
+ }
88
+ else if (obj.toString) {
86
89
  return obj.toString();
87
90
  }
88
91
  else {
@@ -2,7 +2,8 @@ import { milsToMM } from "./helpers.mjs";
2
2
  import { ColorScheme, CustomSymbolParamTextSize, CustomSymbolPinIdSize, CustomSymbolPinTextSize, CustomSymbolRefDesSize, PortArrowSize, PortPaddingHorizontal, PortPaddingVertical, ReferenceTypes, SymbolPinSide, defaultFont, defaultPinIdTextSize, defaultPinNameTextSize, defaultSymbolLineWidth, fontDisplayScale } from "./globals.mjs";
3
3
  import { Geometry, GeometryProp, HorizontalAlign, Textbox, VerticalAlign } from "./geometry.mjs";
4
4
  import { PinTypes } from "./objects/PinTypes.mjs";
5
- import { roundValue } from "./utils.mjs";
5
+ import { roundValue, throwWithContext } from "./utils.mjs";
6
+ import { DeclaredReference, UndeclaredReference } from "./objects/types.mjs";
6
7
  export class SymbolGraphic {
7
8
  drawPortsName = true;
8
9
  displayBounds = false;
@@ -13,6 +14,9 @@ export class SymbolGraphic {
13
14
  width;
14
15
  height;
15
16
  labelTexts = new Map();
17
+ constructor() {
18
+ this.drawing = new SymbolDrawing();
19
+ }
16
20
  get angle() {
17
21
  return (this._angle % 360);
18
22
  }
@@ -310,15 +314,6 @@ export class SymbolGraphic {
310
314
  return VerticalAlign.Middle;
311
315
  }
312
316
  }
313
- setLabelValue(labelId, labelValue) {
314
- this.labelTexts.set(labelId, labelValue);
315
- }
316
- getLabelValue(labelId) {
317
- if (this.labelTexts.has(labelId)) {
318
- return this.labelTexts.get(labelId);
319
- }
320
- return undefined;
321
- }
322
317
  }
323
318
  export function SymbolFactory(name) {
324
319
  switch (name) {
@@ -329,7 +324,8 @@ export function SymbolFactory(name) {
329
324
  }
330
325
  export class SymbolPointHidden extends SymbolGraphic {
331
326
  generateDrawing() {
332
- const drawing = new SymbolDrawing();
327
+ const drawing = this.drawing;
328
+ drawing.clear();
333
329
  drawing.addPin(1, 0, 0, 0, 0);
334
330
  this.drawing = drawing;
335
331
  }
@@ -343,7 +339,8 @@ export class SymbolText extends SymbolGraphic {
343
339
  this.text = text;
344
340
  }
345
341
  generateDrawing() {
346
- const drawing = new SymbolDrawing();
342
+ const drawing = this.drawing;
343
+ drawing.clear();
347
344
  drawing.addTextbox(0, 0, this.text, {
348
345
  fontSize: this.fontSize,
349
346
  anchor: HorizontalAlign.Middle,
@@ -370,7 +367,17 @@ export class SymbolPlaceholder extends SymbolGraphic {
370
367
  drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
371
368
  let lineColor = "#333";
372
369
  let textColor = "#333";
373
- commands.forEach(([commandName, positionParams, keywordParams]) => {
370
+ commands.forEach(([commandName, positionParams, keywordParams, ctx]) => {
371
+ positionParams = positionParams.map(param => {
372
+ return this.resolveReference(param);
373
+ });
374
+ if (keywordParams instanceof Map) {
375
+ const tmpKeywordParams = new Map(keywordParams);
376
+ tmpKeywordParams.forEach((value, key) => {
377
+ tmpKeywordParams.set(key, this.resolveReference(value));
378
+ });
379
+ keywordParams = tmpKeywordParams;
380
+ }
374
381
  switch (commandName) {
375
382
  case PlaceHolderCommands.rect:
376
383
  drawing.log('add rect', ...positionParams);
@@ -426,16 +433,17 @@ export class SymbolPlaceholder extends SymbolGraphic {
426
433
  if (style['textColor'] === undefined) {
427
434
  style['textColor'] = textColor;
428
435
  }
429
- positionParams = [...positionParams];
430
- positionParams.push(style);
431
- const labelId = positionParams[0];
432
- const tmpPositionParams = [...positionParams];
433
- const tmpLabelValue = this.getLabelValue(labelId);
434
- if (tmpLabelValue !== undefined) {
435
- tmpPositionParams[3] = tmpLabelValue;
436
- }
436
+ const tmpPositionParams = [
437
+ positionParams[1], positionParams[2],
438
+ positionParams[0], style
439
+ ];
437
440
  drawing.log('add label', JSON.stringify(tmpPositionParams));
438
- drawing.addLabelId(...tmpPositionParams);
441
+ try {
442
+ drawing.addLabelMils(...tmpPositionParams);
443
+ }
444
+ catch (err) {
445
+ throwWithContext(ctx, err);
446
+ }
439
447
  break;
440
448
  }
441
449
  case PlaceHolderCommands.text: {
@@ -459,13 +467,30 @@ export class SymbolPlaceholder extends SymbolGraphic {
459
467
  });
460
468
  drawing.log("=== end generate drawing ===");
461
469
  }
470
+ resolveReference(param) {
471
+ if (param instanceof DeclaredReference) {
472
+ return param.value;
473
+ }
474
+ else if (param instanceof UndeclaredReference) {
475
+ throw "Undefined symbol: " + param.nameString();
476
+ }
477
+ return param;
478
+ }
462
479
  parseLabelStyle(keywordParams) {
463
480
  const keywords = ['fontSize', 'anchor', 'vanchor',
464
- 'angle', 'textColor', 'portType'];
481
+ 'angle', 'textColor', 'portType', 'bold'];
465
482
  const style = {};
466
483
  keywords.forEach(item => {
467
484
  if (keywordParams.has(item)) {
468
485
  style[item] = keywordParams.get(item);
486
+ if (item === 'bold') {
487
+ if (keywordParams.get(item) === true) {
488
+ style['fontWeight'] = 'bold';
489
+ }
490
+ else {
491
+ style['fontWeight'] = 'normal';
492
+ }
493
+ }
469
494
  }
470
495
  });
471
496
  return style;
@@ -625,7 +650,8 @@ export class SymbolCustom extends SymbolGraphic {
625
650
  });
626
651
  const maxLeftPins = Math.max(...leftPins.map(item => item.position)) + 1;
627
652
  const maxRightPins = Math.max(...rightPins.map(item => item.position)) + 1;
628
- const drawing = new SymbolDrawing();
653
+ this.drawing.clear();
654
+ const drawing = this.drawing;
629
655
  drawing.angle = this._angle;
630
656
  drawing.flipX = this._flipX;
631
657
  drawing.flipY = this._flipY;
@@ -678,14 +704,14 @@ export class SymbolCustom extends SymbolGraphic {
678
704
  textColor: defaultLineColor
679
705
  });
680
706
  });
681
- const instanceName = this.getLabelValue("refdes");
707
+ const instanceName = drawing.variables.get('refdes');
682
708
  instanceName && drawing.addLabel(-bodyWidthMM / 2, -bodyHeightMM / 2 - milsToMM(20), instanceName, {
683
709
  fontSize: CustomSymbolRefDesSize,
684
710
  anchor: HorizontalAlign.Left,
685
711
  });
686
712
  const acceptedMPNKeys = ['MPN', 'mpn', 'manufacturer_pn'];
687
713
  acceptedMPNKeys.some(key => {
688
- const labelValue = this.getLabelValue(key);
714
+ const labelValue = drawing.variables.get(key);
689
715
  if (labelValue !== undefined) {
690
716
  drawing.addLabel(-bodyWidthMM / 2, bodyHeightMM / 2 + milsToMM(20), labelValue, {
691
717
  fontSize: CustomSymbolParamTextSize,
@@ -742,6 +768,7 @@ export class SymbolDrawing {
742
768
  flipY = 0;
743
769
  mainOrigin = [0, 0];
744
770
  logger = null;
771
+ variables = new Map();
745
772
  clear() {
746
773
  this.items = [];
747
774
  this.pins = [];
@@ -857,10 +884,10 @@ export class SymbolDrawing {
857
884
  this.items.push(Geometry.label(null, x, y, textValue, style));
858
885
  return this;
859
886
  }
860
- addLabelId(id, x, y, textValue, style) {
887
+ addLabelMils(x, y, textValue, style) {
861
888
  x = milsToMM(x);
862
889
  y = milsToMM(y);
863
- this.items.push(Geometry.label(id, x, y, textValue, style));
890
+ this.items.push(Geometry.label(null, x, y, textValue, style));
864
891
  return this;
865
892
  }
866
893
  addTextbox(x, y, textValue, style) {
@@ -1086,31 +1113,24 @@ export class SymbolDrawing {
1086
1113
  }
1087
1114
  export class SymbolDrawingCommands extends SymbolDrawing {
1088
1115
  id = "";
1089
- commands;
1090
- constructor(commands) {
1116
+ commands = [];
1117
+ paramIds = [];
1118
+ callback;
1119
+ constructor(callback) {
1091
1120
  super();
1092
- this.commands = commands;
1121
+ this.callback = callback;
1093
1122
  this.id = Math.random().toString().slice(2);
1094
1123
  }
1124
+ runCommands() {
1125
+ this.commands = this.callback(this.variables);
1126
+ }
1095
1127
  getCommands() {
1128
+ this.runCommands();
1096
1129
  return this.commands;
1097
1130
  }
1098
1131
  clone() {
1099
- const tmpCommands = this.commands.map(item => {
1100
- if (item[0] === PlaceHolderCommands.label) {
1101
- const commandName = item[0];
1102
- const positionParams = item[1];
1103
- const keywordParams = item[2];
1104
- const newMap = new Map();
1105
- for (const [key, value] of keywordParams) {
1106
- newMap.set(key, value);
1107
- }
1108
- return [commandName, positionParams, newMap];
1109
- }
1110
- else {
1111
- return [...item];
1112
- }
1113
- });
1114
- return new SymbolDrawingCommands(tmpCommands);
1132
+ const cloned = new SymbolDrawingCommands(this.callback);
1133
+ cloned.variables = this.variables;
1134
+ return cloned;
1115
1135
  }
1116
1136
  }
@@ -465,7 +465,7 @@ export class ExecutionContext {
465
465
  getFunction(functionName) {
466
466
  return this.scope.functions.get(functionName);
467
467
  }
468
- resolveVariable(executionStack, idName) {
468
+ resolveVariable(executionStack, idName, trailers = []) {
469
469
  const reversed = [...executionStack].reverse();
470
470
  for (let i = 0; i < reversed.length; i++) {
471
471
  const context = reversed[i];
@@ -477,21 +477,34 @@ export class ExecutionContext {
477
477
  name: idName,
478
478
  });
479
479
  }
480
- else if (context.scope.variables.has(idName)) {
481
- return new DeclaredReference({
482
- found: true,
483
- value: context.scope.variables.get(idName),
484
- type: ReferenceTypes.variable,
485
- name: idName,
486
- });
487
- }
488
- else if (context.scope.instances.has(idName)) {
489
- return new DeclaredReference({
490
- found: true,
491
- value: context.scope.instances.get(idName),
492
- type: ReferenceTypes.instance,
493
- name: idName,
494
- });
480
+ else {
481
+ const isVariable = context.scope.variables.has(idName);
482
+ const isComponentInstance = context.scope.instances.has(idName);
483
+ if (isVariable || isComponentInstance) {
484
+ const scopeList = isVariable ? context.scope.variables
485
+ : context.scope.instances;
486
+ let parentValue = undefined;
487
+ let useValue = scopeList.get(idName);
488
+ if (trailers.length > 0) {
489
+ parentValue = useValue;
490
+ const trailersPath = trailers.join(".");
491
+ if (isVariable) {
492
+ useValue = parentValue[trailersPath];
493
+ }
494
+ else if (isComponentInstance) {
495
+ useValue = parentValue.parameters.get(trailersPath);
496
+ }
497
+ }
498
+ return new DeclaredReference({
499
+ type: isVariable ? ReferenceTypes.variable
500
+ : ReferenceTypes.instance,
501
+ found: (useValue !== undefined),
502
+ parentValue,
503
+ value: useValue,
504
+ name: idName,
505
+ trailers,
506
+ });
507
+ }
495
508
  }
496
509
  }
497
510
  return new DeclaredReference({
@@ -97,6 +97,7 @@ export var FrameType;
97
97
  FrameType[FrameType["Frame"] = 1] = "Frame";
98
98
  FrameType[FrameType["Sheet"] = 2] = "Sheet";
99
99
  })(FrameType || (FrameType = {}));
100
+ export const ModuleContainsKeyword = 'contains';
100
101
  export const GlobalDocumentName = 'document';
101
102
  export const RenderFlags = {
102
103
  ShowElementFrames: false,
@@ -2,11 +2,10 @@ import { Graph, alg } from '@dagrejs/graphlib';
2
2
  import { SymbolCustom, SymbolDrawing, SymbolFactory, SymbolCustomModule, SymbolPlaceholder, SymbolText, PlaceHolderCommands } from "./draw_symbols.mjs";
3
3
  import { FrameAction, SequenceAction } from "./objects/ExecutionScope.mjs";
4
4
  import { defaultFrameTitleTextSize, defaultGridSizeUnits, FrameType, GlobalNames, ParamKeys, WireAutoDirection } from './globals.mjs';
5
- import { NumericValue } from './objects/ParamDefinition.mjs';
6
5
  import { Geometry } from './geometry.mjs';
7
6
  import { Logger } from './logger.mjs';
8
7
  import { Frame, FrameParamKeys, FramePlotDirection } from './objects/Frame.mjs';
9
- import { getBoundsSize, printBounds, resizeBounds, resizeToNearestGrid, roundValue, toNearestGrid } from './utils.mjs';
8
+ import { combineMaps, getBoundsSize, printBounds, resizeBounds, resizeToNearestGrid, roundValue, toNearestGrid } from './utils.mjs';
10
9
  import { Direction } from './objects/types.mjs';
11
10
  import { milsToMM, UnitDimension } from './helpers.mjs';
12
11
  export class LayoutEngine {
@@ -287,7 +286,9 @@ export class LayoutEngine {
287
286
  const contentsBounds = resizeBounds(getBoundsFromPoints(boundPoints), frame.padding);
288
287
  if (frame.frame.parameters.has(FrameParamKeys.SheetType)) {
289
288
  const frameComponent = frame.frame.parameters.get(FrameParamKeys.SheetType);
290
- const rects = ExtractDrawingRects(frameComponent.displayProp);
289
+ const frameDrawing = frameComponent.displayProp;
290
+ frameDrawing.variables = combineMaps(frameComponent.parameters, frame.frame.parameters);
291
+ const rects = ExtractDrawingRects(frameDrawing);
291
292
  let frameWidth = 0;
292
293
  let frameHeight = 0;
293
294
  if (rects[1]) {
@@ -373,7 +374,8 @@ export class LayoutEngine {
373
374
  }, []);
374
375
  if (frame.type === RenderFrameType.Container) {
375
376
  const frameObject = frame.frame;
376
- if (frameObject.parameters.has(FrameParamKeys.Title)) {
377
+ const isSheetFrame = frameObject.frameType === FrameType.Sheet;
378
+ if (frameObject.parameters.has(FrameParamKeys.Title) && !isSheetFrame) {
377
379
  const title = frameObject.parameters.get(FrameParamKeys.Title);
378
380
  const tmpFrame = new RenderFrame(new Frame(-2), RenderFrameType.Elements);
379
381
  tmpFrame.containsTitle = true;
@@ -448,7 +450,7 @@ export class LayoutEngine {
448
450
  tmpSymbol = new SymbolCustom(symbolPinDefinitions);
449
451
  }
450
452
  }
451
- applyComponentParamsToSymbol(typeProp, component, tmpSymbol);
453
+ applyComponentParamsToSymbol(component, tmpSymbol);
452
454
  let didSetAngle = false;
453
455
  if (component.parameters.has('angle')) {
454
456
  didSetAngle = true;
@@ -996,28 +998,12 @@ function generateLayoutPinDefinition(component) {
996
998
  }
997
999
  return symbolPinDefinitions;
998
1000
  }
999
- function applyComponentParamsToSymbol(typeProp, component, symbol) {
1000
- if (typeProp === 'net') {
1001
- symbol.setLabelValue("net_name", component.parameters.get(ParamKeys.net_name));
1002
- }
1003
- if (component.assignedRefDes !== null) {
1004
- symbol.setLabelValue("refdes", component.assignedRefDes);
1005
- }
1006
- for (const [key, value] of component.parameters) {
1007
- if (key !== 'refdes' && key !== 'net_name') {
1008
- let useValue;
1009
- if (typeof value == 'object' && (value instanceof NumericValue)) {
1010
- useValue = value.toDisplayString();
1011
- }
1012
- else if (typeof value === 'number') {
1013
- useValue = value.toString();
1014
- }
1015
- else if (typeof value === 'string') {
1016
- useValue = value;
1017
- }
1018
- symbol.setLabelValue(key, useValue);
1019
- }
1001
+ export function applyComponentParamsToSymbol(component, symbol) {
1002
+ const newMap = new Map(component.parameters);
1003
+ if (!newMap.has('refdes')) {
1004
+ newMap.set('refdes', component.assignedRefDes ?? "?");
1020
1005
  }
1006
+ symbol.drawing.variables = newMap;
1021
1007
  }
1022
1008
  function calculateSymbolAngle(symbol, pin, direction) {
1023
1009
  let directionVector = 0;
@@ -1341,6 +1327,7 @@ export function CalculatePinPositions(component) {
1341
1327
  const symbolPinDefinitions = generateLayoutPinDefinition(component);
1342
1328
  tmpSymbol = new SymbolCustom(symbolPinDefinitions);
1343
1329
  }
1330
+ applyComponentParamsToSymbol(component, tmpSymbol);
1344
1331
  tmpSymbol.refreshDrawing();
1345
1332
  const pins = component.pins;
1346
1333
  pins.forEach((value, key) => {
@@ -17,6 +17,8 @@ export var FrameParamKeys;
17
17
  FrameParamKeys["Height"] = "height";
18
18
  FrameParamKeys["PaperSize"] = "paper_size";
19
19
  FrameParamKeys["SheetType"] = "sheet_type";
20
+ FrameParamKeys["SheetNumber"] = "sheet_number";
21
+ FrameParamKeys["SheetTotal"] = "sheet_total";
20
22
  })(FrameParamKeys || (FrameParamKeys = {}));
21
23
  export var FramePlotDirection;
22
24
  (function (FramePlotDirection) {
@@ -6,6 +6,17 @@ export class UndeclaredReference {
6
6
  throwMessage() {
7
7
  return `Unknown symbol: ${this.reference.name}`;
8
8
  }
9
+ toString() {
10
+ return 'undefined';
11
+ }
12
+ nameString() {
13
+ const { name, trailers = [] } = this.reference;
14
+ let extra = '';
15
+ if (trailers.length > 0) {
16
+ extra = '.' + trailers.join('.');
17
+ }
18
+ return name + extra;
19
+ }
9
20
  }
10
21
  export class DeclaredReference {
11
22
  found;
@@ -13,16 +24,47 @@ export class DeclaredReference {
13
24
  trailers;
14
25
  type;
15
26
  value;
27
+ parentValue;
16
28
  constructor(refType) {
17
29
  this.found = refType.found;
18
30
  this.name = refType.name;
19
31
  this.trailers = refType.trailers;
20
32
  this.type = refType.type;
21
33
  this.value = refType.value;
34
+ this.parentValue = refType.parentValue;
22
35
  }
23
36
  toString() {
24
37
  return `[DeclaredReference name: ${this.name} trailers:${this.trailers} found: ${this.found}]`;
25
38
  }
39
+ toDisplayString() {
40
+ let returnValue = undefined;
41
+ if (this.parentValue) {
42
+ const trailersString = this.trailers.join(".");
43
+ if (this.type === 'instance') {
44
+ returnValue = this.parentValue.parameters.get(trailersString);
45
+ }
46
+ else if (this.type === 'variable') {
47
+ returnValue = this.parentValue[trailersString];
48
+ }
49
+ }
50
+ else {
51
+ returnValue = this.value;
52
+ }
53
+ if (returnValue !== undefined) {
54
+ if (returnValue !== null) {
55
+ if (returnValue.toDisplayString) {
56
+ return returnValue.toDisplayString();
57
+ }
58
+ else {
59
+ return returnValue.toString();
60
+ }
61
+ }
62
+ else {
63
+ return 'null';
64
+ }
65
+ }
66
+ throw 'Could not find string value: ' + this;
67
+ }
26
68
  }
27
69
  export var ParseSymbolType;
28
70
  (function (ParseSymbolType) {
@@ -3,7 +3,7 @@ import { ExtractDrawingRects, RenderFrameType, getBounds } from "./layout.mjs";
3
3
  import { applyFontsToSVG, getCreateSVGWindow } from './sizing.mjs';
4
4
  import { ColorScheme, ComponentTypes, FrameType, MMToPt, MMToPx, ParamKeys, RenderFlags, defaultFont, defaultGridSizeUnits, defaultPageSpacingMM, defaultWireLineWidth, fontDisplayScale, junctionSize } from './globals.mjs';
5
5
  import { NumericValue } from './objects/ParamDefinition.mjs';
6
- import { getBoundsSize } from './utils.mjs';
6
+ import { combineMaps, getBoundsSize } from './utils.mjs';
7
7
  import { getPaperSize, milsToMM, PaperGridReferences } from './helpers.mjs';
8
8
  import SVGtoPDF from 'svg-to-pdfkit';
9
9
  import { FrameParamKeys } from './objects/Frame.mjs';
@@ -254,6 +254,7 @@ function drawSheetFrameBorder(frameGroup, frame) {
254
254
  if (displayProp) {
255
255
  const sheetFrameGroup = frameGroup.group();
256
256
  const symbol = new SymbolPlaceholder(displayProp);
257
+ symbol.drawing.variables = combineMaps(frameComponent.parameters, frameParams);
257
258
  symbol.refreshDrawing();
258
259
  symbol.draw(sheetFrameGroup);
259
260
  const offsetX = milsToMM(frameComponent.getParam('offset_x'));
@@ -66,3 +66,25 @@ export function getPortType(component) {
66
66
  export function roundValue(value) {
67
67
  return +value.toFixed(7);
68
68
  }
69
+ export function throwWithContext(context, message) {
70
+ const startLine = context.start?.line;
71
+ const startColumn = context.start?.column;
72
+ const startString = startLine + ":" + startColumn;
73
+ const stopLine = context.stop?.line;
74
+ const stopColumn = context.stop?.column;
75
+ let stopString = "";
76
+ if (startLine === stopLine) {
77
+ stopString = stopColumn?.toString();
78
+ }
79
+ else {
80
+ stopString = stopLine + ":" + stopString;
81
+ }
82
+ throw `Parse exception at [${startString} - ${stopString}] : ${message}`;
83
+ }
84
+ export function combineMaps(map1, map2) {
85
+ const newMap = new Map(map1);
86
+ map2.forEach((value, key) => {
87
+ newMap.set(key, value);
88
+ });
89
+ return newMap;
90
+ }