schematic-symbols 0.0.142 → 0.0.143

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.
package/dist/index.js CHANGED
@@ -913,21 +913,30 @@ var SymbolModifier = class {
913
913
  }
914
914
  };
915
915
  var modifySymbol = (symbol5) => {
916
+ const primitives = symbol5.primitives ?? [
917
+ ...Object.values(symbol5.paths ?? {}),
918
+ ...Object.values(symbol5.texts ?? {}),
919
+ ...Object.values(symbol5.circles ?? {}),
920
+ ...Object.values(symbol5.rects ?? {})
921
+ ];
922
+ const ports = symbol5.ports ?? Object.entries(symbol5.refblocks).flatMap(([key, refblock]) => {
923
+ return [{ ...refblock, labels: [key] }];
924
+ });
925
+ let center = symbol5.center ?? {
926
+ x: symbol5.bounds.centerX,
927
+ y: symbol5.bounds.centerY
928
+ };
929
+ if (ports.length === 2) {
930
+ center = {
931
+ x: (ports[0].x + ports[1].x) / 2,
932
+ y: (ports[0].y + ports[1].y) / 2
933
+ };
934
+ }
916
935
  return new SymbolModifier({
917
936
  ...symbol5,
918
- primitives: symbol5.primitives ?? [
919
- ...Object.values(symbol5.paths ?? {}),
920
- ...Object.values(symbol5.texts ?? {}),
921
- ...Object.values(symbol5.circles ?? {}),
922
- ...Object.values(symbol5.rects ?? {})
923
- ],
924
- ports: symbol5.ports ?? Object.entries(symbol5.refblocks).flatMap(([key, refblock]) => {
925
- return [{ ...refblock, labels: [key] }];
926
- }),
927
- center: symbol5.center ?? {
928
- x: symbol5.bounds.centerX,
929
- y: symbol5.bounds.centerY
930
- }
937
+ primitives,
938
+ ports,
939
+ center
931
940
  });
932
941
  };
933
942