circuitscript 0.0.38 → 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 (66) hide show
  1. package/dist/cjs/BaseVisitor.js +69 -46
  2. package/dist/cjs/SymbolValidatorVisitor.js +1 -1
  3. package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
  4. package/dist/cjs/antlr/CircuitScriptParser.js +580 -613
  5. package/dist/cjs/builtinMethods.js +32 -10
  6. package/dist/cjs/draw_symbols.js +375 -233
  7. package/dist/cjs/execute.js +142 -131
  8. package/dist/cjs/export.js +2 -4
  9. package/dist/cjs/geometry.js +52 -19
  10. package/dist/cjs/globals.js +14 -9
  11. package/dist/cjs/helpers.js +16 -3
  12. package/dist/cjs/layout.js +143 -151
  13. package/dist/cjs/logger.js +8 -1
  14. package/dist/cjs/objects/ClassComponent.js +22 -22
  15. package/dist/cjs/objects/ExecutionScope.js +10 -4
  16. package/dist/cjs/objects/Frame.js +4 -1
  17. package/dist/cjs/objects/ParamDefinition.js +120 -4
  18. package/dist/cjs/objects/PinDefinition.js +1 -4
  19. package/dist/cjs/objects/types.js +41 -0
  20. package/dist/cjs/render.js +41 -110
  21. package/dist/cjs/sizing.js +33 -7
  22. package/dist/cjs/utils.js +92 -2
  23. package/dist/cjs/visitor.js +279 -284
  24. package/dist/esm/BaseVisitor.mjs +70 -47
  25. package/dist/esm/SymbolValidatorVisitor.mjs +1 -1
  26. package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
  27. package/dist/esm/antlr/CircuitScriptParser.mjs +580 -613
  28. package/dist/esm/builtinMethods.mjs +29 -10
  29. package/dist/esm/draw_symbols.mjs +381 -238
  30. package/dist/esm/execute.mjs +144 -133
  31. package/dist/esm/export.mjs +2 -4
  32. package/dist/esm/geometry.mjs +52 -19
  33. package/dist/esm/globals.mjs +13 -8
  34. package/dist/esm/helpers.mjs +17 -4
  35. package/dist/esm/layout.mjs +144 -153
  36. package/dist/esm/logger.mjs +8 -1
  37. package/dist/esm/objects/ClassComponent.mjs +21 -26
  38. package/dist/esm/objects/ExecutionScope.mjs +10 -4
  39. package/dist/esm/objects/Frame.mjs +4 -1
  40. package/dist/esm/objects/ParamDefinition.mjs +119 -3
  41. package/dist/esm/objects/PinDefinition.mjs +0 -2
  42. package/dist/esm/objects/types.mjs +42 -0
  43. package/dist/esm/render.mjs +44 -113
  44. package/dist/esm/sizing.mjs +34 -8
  45. package/dist/esm/utils.mjs +86 -1
  46. package/dist/esm/visitor.mjs +281 -286
  47. package/dist/types/BaseVisitor.d.ts +3 -2
  48. package/dist/types/antlr/CircuitScriptParser.d.ts +5 -3
  49. package/dist/types/draw_symbols.d.ts +81 -49
  50. package/dist/types/execute.d.ts +16 -11
  51. package/dist/types/geometry.d.ts +31 -19
  52. package/dist/types/globals.d.ts +15 -10
  53. package/dist/types/helpers.d.ts +2 -1
  54. package/dist/types/layout.d.ts +22 -21
  55. package/dist/types/logger.d.ts +1 -1
  56. package/dist/types/objects/ClassComponent.d.ts +19 -16
  57. package/dist/types/objects/ExecutionScope.d.ts +2 -1
  58. package/dist/types/objects/Frame.d.ts +5 -3
  59. package/dist/types/objects/ParamDefinition.d.ts +31 -2
  60. package/dist/types/objects/PinDefinition.d.ts +0 -2
  61. package/dist/types/objects/types.d.ts +7 -2
  62. package/dist/types/render.d.ts +2 -1
  63. package/dist/types/utils.d.ts +9 -1
  64. package/dist/types/visitor.d.ts +5 -5
  65. package/libs/lib.cst +102 -32
  66. package/package.json +7 -3
@@ -5,11 +5,14 @@ const globals_js_1 = require("./globals.js");
5
5
  const ClassComponent_js_1 = require("./objects/ClassComponent.js");
6
6
  const ExecutionScope_js_1 = require("./objects/ExecutionScope.js");
7
7
  const Net_js_1 = require("./objects/Net.js");
8
+ const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
8
9
  const PinDefinition_js_1 = require("./objects/PinDefinition.js");
9
10
  const types_js_1 = require("./objects/types.js");
10
11
  const Wire_js_1 = require("./objects/Wire.js");
11
12
  const Frame_js_1 = require("./objects/Frame.js");
12
13
  const layout_js_1 = require("./layout.js");
14
+ const helpers_js_1 = require("./helpers.js");
15
+ const draw_symbols_js_1 = require("./draw_symbols.js");
13
16
  class ExecutionContext {
14
17
  constructor(name, namespace, netNamespace, executionLevel = 0, indentLevel = 0, silent = false, logger, parent) {
15
18
  this.tmpPointId = 0;
@@ -52,27 +55,14 @@ class ExecutionContext {
52
55
  }
53
56
  setupRoot() {
54
57
  const componentRoot = ClassComponent_js_1.ClassComponent.simple(globals_js_1.GlobalNames.__root, 1, '__root');
55
- componentRoot.typeProp = globals_js_1.ComponentTypes.point;
56
- componentRoot.displayProp = 'point';
58
+ componentRoot.typeProp = globals_js_1.ComponentTypes.net;
59
+ componentRoot.displayProp = this.getPointSymbol();
57
60
  this.scope.instances.set(globals_js_1.GlobalNames.__root, componentRoot);
58
- this.scope.currentComponent = componentRoot;
59
- this.scope.currentPin = componentRoot.getDefaultPin();
61
+ this.scope.setCurrent(componentRoot);
60
62
  this.scope.componentRoot = componentRoot;
61
63
  }
62
- getUniqueInstanceName(className) {
63
- let extraPrefix = '';
64
- switch (className) {
65
- case globals_js_1.GlobalNames.DefaultResistor:
66
- extraPrefix = 'R_';
67
- break;
68
- case globals_js_1.GlobalNames.DefaultCapacitor:
69
- extraPrefix = 'C_';
70
- break;
71
- case globals_js_1.GlobalNames.DefaultInductor:
72
- extraPrefix = 'L_';
73
- break;
74
- }
75
- const tmpName = extraPrefix + 'COMP_' + this.scope.unnamedCounter;
64
+ getUniqueInstanceName() {
65
+ const tmpName = 'COMP_' + this.scope.unnamedCounter;
76
66
  this.scope.unnamedCounter += 1;
77
67
  return tmpName;
78
68
  }
@@ -85,14 +75,8 @@ class ExecutionContext {
85
75
  return [this.scope.currentComponent, this.scope.currentPin];
86
76
  }
87
77
  linkComponentPinNet(component1, component1Pin, component2, component2Pin) {
88
- const net1_exists = this.scope.hasNet(component1, component1Pin);
89
- const net2_exists = this.scope.hasNet(component2, component2Pin);
90
- const net1 = net1_exists
91
- ? this.scope.getNet(component1, component1Pin)
92
- : null;
93
- const net2 = net2_exists
94
- ? this.scope.getNet(component2, component2Pin)
95
- : null;
78
+ const net1 = this.scope.getNet(component1, component1Pin);
79
+ const net2 = this.scope.getNet(component2, component2Pin);
96
80
  this.log('link nets', component1, component1Pin, net1, 'to', component2, component2Pin, net2);
97
81
  let returnNet;
98
82
  if (net1 === null && net2 === null) {
@@ -114,43 +98,43 @@ class ExecutionContext {
114
98
  returnNet = this.mergeNets(net1, net2);
115
99
  }
116
100
  else {
117
- return net1;
101
+ returnNet = net1;
118
102
  }
119
103
  }
104
+ this.log('final net after link: ', returnNet);
120
105
  return returnNet;
121
106
  }
122
107
  mergeNets(net1, net2) {
123
108
  if (net1 === net2) {
124
109
  return net1;
125
110
  }
126
- let tmpNet;
127
111
  if (net2.priority > net1.priority) {
128
- tmpNet = net1;
112
+ const tmpNet = net1;
129
113
  net1 = net2;
130
114
  net2 = tmpNet;
131
115
  }
132
- const scopeNets = this.scope.getNets();
133
- scopeNets.forEach(([component, pin, net]) => {
116
+ this.scope.getNets().forEach(([component, pin, net]) => {
134
117
  if (Net_js_1.Net.isSame(net, net2)) {
135
118
  this.scope.setNet(component, pin, net1);
136
119
  }
137
120
  });
138
121
  return net1;
139
122
  }
140
- createComponent(instanceName, pins, params, props) {
141
- const numPins = pins.length;
142
- const component = new ClassComponent_js_1.ClassComponent(instanceName, numPins, globals_js_1.GlobalNames.symbol);
123
+ createComponent(instanceName, pins, params, props, isModule = false) {
124
+ const className = isModule ? ClassComponent_js_1.ModuleComponent : ClassComponent_js_1.ClassComponent;
125
+ const component = new className(instanceName, pins.length);
143
126
  pins.forEach((pin) => {
144
127
  component.pins.set(pin.id, pin);
145
128
  });
146
129
  component.arrangeProps = props.arrange ?? null;
147
130
  component.displayProp = props.display ?? null;
148
131
  component.widthProp = props.width ?? null;
132
+ component.heightProp = props.height ?? null;
149
133
  component.typeProp = props.type ?? null;
150
134
  component.copyProp = props.copy ?? false;
151
135
  let useAngle = null;
152
136
  if (props.angle) {
153
- useAngle = props.angle % 360;
137
+ useAngle = props.angle.toNumber() % 360;
154
138
  if (useAngle < 0) {
155
139
  useAngle += 360;
156
140
  }
@@ -162,10 +146,12 @@ class ExecutionContext {
162
146
  component.parameters.set(param.paramName, param.paramValue);
163
147
  paramsMap.set(param.paramName, param.paramValue);
164
148
  });
165
- if (component.typeProp === globals_js_1.ComponentTypes.net
166
- || component.typeProp === globals_js_1.ComponentTypes.label) {
149
+ if (component.typeProp === globals_js_1.ComponentTypes.net) {
167
150
  const netName = paramsMap.get(globals_js_1.ParamKeys.net_name);
168
- const priority = paramsMap.get(globals_js_1.ParamKeys.priority);
151
+ let priority = 0;
152
+ if (paramsMap.has(globals_js_1.ParamKeys.priority)) {
153
+ priority = paramsMap.get(globals_js_1.ParamKeys.priority).toNumber();
154
+ }
169
155
  const result = this.resolveNet(netName, this.netNamespace);
170
156
  let tmpNet;
171
157
  if (result.found) {
@@ -179,8 +165,9 @@ class ExecutionContext {
179
165
  this.scope.setNet(component, 1, tmpNet);
180
166
  this.log('set net', netName, 'component', component);
181
167
  }
182
- const portSides = getPortSide(component.pins, component.arrangeProps);
183
- portSides.forEach(({ pinId, side, position }) => {
168
+ const { pins: pinSides, maxPositions } = getPortSide(component.pins, component.arrangeProps);
169
+ component.pinsMaxPositions = maxPositions;
170
+ pinSides.forEach(({ pinId, side, position }) => {
184
171
  if (component.pins.has(pinId)) {
185
172
  const tmpPin = component.pins.get(pinId);
186
173
  tmpPin.side = side;
@@ -211,10 +198,9 @@ class ExecutionContext {
211
198
  this.scope.currentPin + ' ' + netString);
212
199
  }
213
200
  addComponentExisting(component, pin) {
214
- const startPin = pin;
215
- const nextPin = component.getNextPinAfter(startPin);
201
+ const nextPin = component.getNextPinAfter(pin);
216
202
  this.applyComponentAngleFromWire(component, pin);
217
- this.toComponent(component, startPin, { addSequence: true });
203
+ this.toComponent(component, pin, { addSequence: true });
218
204
  this.log('move to next pin: ' + nextPin);
219
205
  this.atComponent(component, nextPin, {
220
206
  addSequence: true
@@ -250,13 +236,10 @@ class ExecutionContext {
250
236
  }
251
237
  const linkedNet = this.linkComponentPinNet(this.scope.currentComponent, this.scope.currentPin, component, pinId);
252
238
  this.applyComponentAngleFromWire(component, pinId);
253
- this.scope.currentComponent = component;
254
- this.scope.currentPin = pinId;
239
+ this.scope.setCurrent(component, pinId);
255
240
  this.scope.clearActive();
256
241
  if (addSequence) {
257
242
  if (this.scope.sequence.length > 0) {
258
- if (component.pinWires.has(pinId) && component.typeProp !== globals_js_1.ComponentTypes.point) {
259
- }
260
243
  const [entryType, , segments] = this.scope.sequence[this.scope.sequence.length - 1];
261
244
  if (entryType === ExecutionScope_js_1.SequenceAction.Wire && isWireSegmentsEndAuto(segments)) {
262
245
  segments[segments.length - 1].until = [
@@ -274,7 +257,6 @@ class ExecutionContext {
274
257
  atComponent(component, pinId, options) {
275
258
  this.log('at component');
276
259
  const { addSequence = false } = options ?? {};
277
- this.scope.currentComponent = component;
278
260
  let usePinId;
279
261
  if (pinId === null) {
280
262
  usePinId = component.getDefaultPin();
@@ -287,9 +269,7 @@ class ExecutionContext {
287
269
  throw 'Invalid pin number ' + pinId + ' in ' + component;
288
270
  }
289
271
  }
290
- if (usePinId) {
291
- this.scope.currentPin = usePinId;
292
- }
272
+ this.scope.setCurrent(component, usePinId);
293
273
  this.scope.clearActive();
294
274
  if (addSequence) {
295
275
  this.scope.sequence.push([ExecutionScope_js_1.SequenceAction.At,
@@ -316,12 +296,9 @@ class ExecutionContext {
316
296
  return componentCopy;
317
297
  }
318
298
  enterBlocks(blockType) {
319
- if (blockType === globals_js_1.BlockTypes.Point) {
320
- this.addPoint(`_point.${this.name}.${this.tmpPointId}`, false);
321
- this.tmpPointId += 1;
322
- }
323
- else if (blockType === globals_js_1.BlockTypes.Parallel) {
324
- this.addPoint(`_parallel.${this.name}.${this.tmpPointId}`, false);
299
+ if (blockType === globals_js_1.BlockTypes.Point || blockType === globals_js_1.BlockTypes.Parallel) {
300
+ const key = blockType === globals_js_1.BlockTypes.Point ? 'point' : 'parallel';
301
+ this.addPoint(`_${key}.${this.name}.${this.tmpPointId}`, false);
325
302
  this.tmpPointId += 1;
326
303
  }
327
304
  this.scope.blockStack.set(this.scope.indentLevel, {
@@ -342,8 +319,7 @@ class ExecutionContext {
342
319
  if (blockType === globals_js_1.BlockTypes.Join || blockType === globals_js_1.BlockTypes.Parallel) {
343
320
  const { final_point: finalPoint } = stackRef;
344
321
  const [component, pin, wireId] = finalPoint;
345
- this.scope.currentComponent = component;
346
- this.scope.currentPin = pin;
322
+ this.scope.setCurrent(component, pin);
347
323
  this.scope.currentWireId = wireId;
348
324
  if (wireId !== -1) {
349
325
  this.scope.sequence.push([
@@ -366,8 +342,7 @@ class ExecutionContext {
366
342
  ignore_last_net: false,
367
343
  });
368
344
  if (blockType === globals_js_1.BlockTypes.Join || blockType === globals_js_1.BlockTypes.Point) {
369
- this.scope.currentComponent = null;
370
- this.scope.currentPin = null;
345
+ this.scope.setCurrent(null);
371
346
  this.scope.currentWireId = -1;
372
347
  }
373
348
  else if (blockType === globals_js_1.BlockTypes.Parallel) {
@@ -461,7 +436,7 @@ class ExecutionContext {
461
436
  getFunction(functionName) {
462
437
  return this.scope.functions.get(functionName);
463
438
  }
464
- resolveVariable(executionStack, idName) {
439
+ resolveVariable(executionStack, idName, trailers = []) {
465
440
  const reversed = [...executionStack].reverse();
466
441
  for (let i = 0; i < reversed.length; i++) {
467
442
  const context = reversed[i];
@@ -473,21 +448,34 @@ class ExecutionContext {
473
448
  name: idName,
474
449
  });
475
450
  }
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
- });
451
+ else {
452
+ const isVariable = context.scope.variables.has(idName);
453
+ const isComponentInstance = context.scope.instances.has(idName);
454
+ if (isVariable || isComponentInstance) {
455
+ const scopeList = isVariable ? context.scope.variables
456
+ : context.scope.instances;
457
+ let parentValue = undefined;
458
+ let useValue = scopeList.get(idName);
459
+ if (trailers.length > 0) {
460
+ parentValue = useValue;
461
+ const trailersPath = trailers.join(".");
462
+ if (isVariable) {
463
+ useValue = parentValue[trailersPath];
464
+ }
465
+ else if (isComponentInstance) {
466
+ useValue = parentValue.parameters.get(trailersPath);
467
+ }
468
+ }
469
+ return new types_js_1.DeclaredReference({
470
+ type: isVariable ? globals_js_1.ReferenceTypes.variable
471
+ : globals_js_1.ReferenceTypes.instance,
472
+ found: (useValue !== undefined),
473
+ parentValue,
474
+ value: useValue,
475
+ name: idName,
476
+ trailers,
477
+ });
478
+ }
491
479
  }
492
480
  }
493
481
  return new types_js_1.DeclaredReference({
@@ -571,7 +559,6 @@ class ExecutionContext {
571
559
  }
572
560
  const wireIdOffset = this.scope.wires.length;
573
561
  const frameIdOffset = this.scope.frames.length;
574
- let incrementGndLinkId = 0;
575
562
  childScope.sequence.forEach(sequenceAction => {
576
563
  const [action] = sequenceAction;
577
564
  if (action === ExecutionScope_js_1.SequenceAction.Wire) {
@@ -584,20 +571,6 @@ class ExecutionContext {
584
571
  this.scope.sequence.push([ExecutionScope_js_1.SequenceAction.WireJump, jumpWireId, 1]);
585
572
  }
586
573
  else if (action === ExecutionScope_js_1.SequenceAction.At || action === ExecutionScope_js_1.SequenceAction.To) {
587
- const tmpComponent = sequenceAction[1];
588
- if (tmpComponent.typeProp === globals_js_1.ComponentTypes.net
589
- && tmpComponent.parameters.get(globals_js_1.ParamKeys.net_name) === 'gnd') {
590
- tmpComponent._copyID = gndCopyIdOffset + incrementGndLinkId;
591
- incrementGndLinkId += 1;
592
- }
593
- else if (tmpComponent === tmpRoot) {
594
- if (currentWireId !== -1) {
595
- sequenceAction = [ExecutionScope_js_1.SequenceAction.WireJump, currentWireId];
596
- }
597
- else {
598
- sequenceAction = [action, currentComponent, currentPin];
599
- }
600
- }
601
574
  this.scope.sequence.push(sequenceAction);
602
575
  }
603
576
  else if (action === ExecutionScope_js_1.SequenceAction.Frame) {
@@ -611,13 +584,11 @@ class ExecutionContext {
611
584
  }
612
585
  });
613
586
  if (childScope.currentComponent === childScope.componentRoot) {
614
- this.scope.currentComponent = currentComponent;
615
- this.scope.currentPin = currentPin;
587
+ this.scope.setCurrent(currentComponent, currentPin);
616
588
  this.scope.currentWireId = currentWireId;
617
589
  }
618
590
  else {
619
- this.scope.currentComponent = childScope.currentComponent;
620
- this.scope.currentPin = childScope.currentPin;
591
+ this.scope.setCurrent(childScope.currentComponent, childScope.currentPin);
621
592
  this.scope.currentWireId = childScope.currentWireId + wireIdOffset;
622
593
  }
623
594
  this.printPoint('resume at');
@@ -647,7 +618,15 @@ class ExecutionContext {
647
618
  this.scope.wires.push(new Wire_js_1.Wire(tmp));
648
619
  const output = [];
649
620
  segments.forEach(item => {
650
- output.push(item.join(","));
621
+ const tmpArray = item.map(item2 => {
622
+ if (item2 instanceof helpers_js_1.UnitDimension) {
623
+ return item2.value;
624
+ }
625
+ else {
626
+ return item2;
627
+ }
628
+ });
629
+ output.push(tmpArray.join(","));
651
630
  });
652
631
  this.log('add wire: ', output.join("|"));
653
632
  this.scope.setActive(ExecutionScope_js_1.ActiveObject.Wire, wireId);
@@ -664,12 +643,26 @@ class ExecutionContext {
664
643
  }
665
644
  const useName = userDefined ? 'point.' + pointId : pointId;
666
645
  const componentPoint = ClassComponent_js_1.ClassComponent.simple(useName, 1, "point");
667
- componentPoint.displayProp = "point";
668
- componentPoint.typeProp = globals_js_1.ComponentTypes.point;
646
+ componentPoint.displayProp = this.getPointSymbol();
647
+ componentPoint.typeProp = globals_js_1.ComponentTypes.net;
669
648
  this.scope.instances.set(pointId, componentPoint);
670
649
  this.toComponent(componentPoint, 1, { addSequence: true });
671
650
  return this.getCurrentPoint();
672
651
  }
652
+ getPointSymbol() {
653
+ return new draw_symbols_js_1.SymbolDrawingCommands(() => {
654
+ return [
655
+ [draw_symbols_js_1.PlaceHolderCommands.pin,
656
+ [(0, ParamDefinition_js_1.numeric)(1), (0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0),
657
+ (0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0)],
658
+ new Map([
659
+ ["display_pin_id", false]
660
+ ]),
661
+ null
662
+ ]
663
+ ];
664
+ });
665
+ }
673
666
  setProperty(nameWithProp, value) {
674
667
  this.log('set property', nameWithProp, 'value', value);
675
668
  let idName;
@@ -702,11 +695,6 @@ class ExecutionContext {
702
695
  }
703
696
  }
704
697
  }
705
- setCurrentComponentStyle(styles) {
706
- for (const key in styles) {
707
- this.scope.currentComponent.styles[key] = styles[key];
708
- }
709
- }
710
698
  applyComponentAngleFromWire(component, pin, opposite = false) {
711
699
  if (this.componentAngleFollowsWire
712
700
  && component.followWireOrientationProp
@@ -757,23 +745,23 @@ class ExecutionContext {
757
745
  return;
758
746
  }
759
747
  this.log('set component angle from wire, target angle:', targetAngle, ', component angle:', component.angleProp, 'pin angle:', connectedPinPos.angle);
760
- let useAngle = (targetAngle - connectedPinPos.angle) % 360;
748
+ let useAngle = (targetAngle - connectedPinPos.angle.toNumber()) % 360;
761
749
  if (useAngle < 0) {
762
750
  useAngle += 360;
763
751
  }
764
752
  if (useAngle === 90) {
765
- component.setParam('angle', 90);
753
+ component.setParam(globals_js_1.ParamKeys.angle, (0, ParamDefinition_js_1.numeric)(90));
766
754
  }
767
755
  else if (useAngle === 180) {
768
756
  if (component.angleProp === 0 || component.angleProp === 180) {
769
- component.setParam('flipX', 1);
757
+ component.setParam(globals_js_1.ParamKeys.flipX, 1);
770
758
  }
771
759
  else if (component.angleProp === 90 || component.angleProp === 270) {
772
- component.setParam('flipY', 1);
760
+ component.setParam(globals_js_1.ParamKeys.flipY, 1);
773
761
  }
774
762
  }
775
763
  else if (useAngle === 270) {
776
- component.setParam('angle', 270);
764
+ component.setParam(globals_js_1.ParamKeys.angle, (0, ParamDefinition_js_1.numeric)(270));
777
765
  }
778
766
  component.wireOrientationAngle = useAngle;
779
767
  component.didSetWireOrientationAngle = true;
@@ -809,6 +797,12 @@ function isWireSegmentsEndAuto(segments) {
809
797
  }
810
798
  function getPortSide(pins, arrangeProps) {
811
799
  const result = [];
800
+ const maxPositions = {
801
+ [globals_js_1.SymbolPinSide.Left]: 0,
802
+ [globals_js_1.SymbolPinSide.Right]: 0,
803
+ [globals_js_1.SymbolPinSide.Top]: 0,
804
+ [globals_js_1.SymbolPinSide.Bottom]: 0,
805
+ };
812
806
  if (arrangeProps === null) {
813
807
  let counter = 0;
814
808
  for (const [pinId] of pins) {
@@ -820,6 +814,14 @@ function getPortSide(pins, arrangeProps) {
820
814
  });
821
815
  counter++;
822
816
  }
817
+ const leftSideItems = result.filter(item => {
818
+ return item.side === PinDefinition_js_1.PortSide.WEST;
819
+ });
820
+ const rightSideItems = result.filter(item => {
821
+ return item.side === PinDefinition_js_1.PortSide.EAST;
822
+ });
823
+ maxPositions[globals_js_1.SymbolPinSide.Left] = leftSideItems.length;
824
+ maxPositions[globals_js_1.SymbolPinSide.Right] = rightSideItems.length;
823
825
  }
824
826
  else {
825
827
  let counter = pins.size;
@@ -833,36 +835,45 @@ function getPortSide(pins, arrangeProps) {
833
835
  useItems = [...items];
834
836
  }
835
837
  let useSide = PinDefinition_js_1.PortSide.WEST;
836
- if (key === 'left') {
837
- useSide = PinDefinition_js_1.PortSide.WEST;
838
- }
839
- else if (key === 'right') {
840
- useSide = PinDefinition_js_1.PortSide.EAST;
841
- }
842
- else if (key === 'top') {
843
- useSide = PinDefinition_js_1.PortSide.NORTH;
844
- }
845
- else if (key === 'bottom') {
846
- useSide = PinDefinition_js_1.PortSide.SOUTH;
838
+ switch (key) {
839
+ case globals_js_1.SymbolPinSide.Left:
840
+ useSide = PinDefinition_js_1.PortSide.WEST;
841
+ break;
842
+ case globals_js_1.SymbolPinSide.Right:
843
+ useSide = PinDefinition_js_1.PortSide.EAST;
844
+ break;
845
+ case globals_js_1.SymbolPinSide.Top:
846
+ useSide = PinDefinition_js_1.PortSide.NORTH;
847
+ break;
848
+ case globals_js_1.SymbolPinSide.Bottom:
849
+ useSide = PinDefinition_js_1.PortSide.SOUTH;
850
+ break;
847
851
  }
848
852
  let position = 0;
849
853
  useItems.forEach(item => {
850
854
  if (typeof item === 'object' && Array.isArray(item)) {
851
- position += item[0];
855
+ position += item[0].toNumber();
852
856
  }
853
- if (existingPinIds.indexOf(item) !== -1) {
854
- result.push({
855
- pinId: item,
856
- side: useSide,
857
- position,
858
- order: counter
859
- });
860
- counter--;
861
- position += 1;
857
+ else {
858
+ const itemValue = item.toNumber();
859
+ if (existingPinIds.indexOf(itemValue) !== -1) {
860
+ result.push({
861
+ pinId: itemValue,
862
+ side: useSide,
863
+ position,
864
+ order: counter
865
+ });
866
+ counter--;
867
+ position += 1;
868
+ }
862
869
  }
863
870
  });
871
+ maxPositions[key] = position;
864
872
  }
865
873
  }
866
- return result;
874
+ return {
875
+ pins: result,
876
+ maxPositions,
877
+ };
867
878
  }
868
879
  exports.getPortSide = getPortSide;
@@ -50,10 +50,8 @@ function generateKiCADNetList(netlist) {
50
50
  }
51
51
  }
52
52
  else {
53
- if (instance.typeProp !== globals_js_1.ComponentTypes.label &&
54
- instance.typeProp !== globals_js_1.ComponentTypes.net &&
55
- instance.typeProp !== globals_js_1.ComponentTypes.point &&
56
- instance.typeProp !== globals_js_1.ComponentTypes.frame &&
53
+ if (instance.typeProp !== globals_js_1.ComponentTypes.net &&
54
+ instance.typeProp !== globals_js_1.ComponentTypes.graphic &&
57
55
  instance.typeProp !== null) {
58
56
  console.log('Skipping', instance.instanceName);
59
57
  }