altium-to-circuit-json 0.0.49 → 0.0.51

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
@@ -1381,7 +1381,7 @@ function addComponentFallbackText({
1381
1381
 
1382
1382
  // lib/schematic/components/convertComponent.ts
1383
1383
  import {
1384
- AltiumSchLabelRecord as AltiumSchLabelRecord4,
1384
+ AltiumSchLabelRecord,
1385
1385
  AltiumSchPinRecord as AltiumSchPinRecord2
1386
1386
  } from "altiumts";
1387
1387
 
@@ -1496,12 +1496,19 @@ function uniqueStrings(strings) {
1496
1496
 
1497
1497
  // lib/schematic/connectivity/getEquivalentPortPrunedSegmentKeys.ts
1498
1498
  import {
1499
- AltiumSchLabelRecord,
1499
+ AltiumSchPortRecord as AltiumSchPortRecord2,
1500
+ getSchematicRecordPoints as getSchematicRecordPoints3
1501
+ } from "altiumts";
1502
+
1503
+ // lib/schematic/netLabels/isElectricalLabelRecord.ts
1504
+ import {
1500
1505
  AltiumSchNetLabelRecord,
1501
1506
  AltiumSchPortRecord,
1502
- AltiumSchPowerPortRecord,
1503
- getSchematicRecordPoints as getSchematicRecordPoints3
1507
+ AltiumSchPowerPortRecord
1504
1508
  } from "altiumts";
1509
+ function isElectricalLabelRecord(record) {
1510
+ return record instanceof AltiumSchNetLabelRecord || record instanceof AltiumSchPortRecord || record instanceof AltiumSchPowerPortRecord;
1511
+ }
1505
1512
 
1506
1513
  // lib/schematic/connectivity/constants.ts
1507
1514
  var DIRECTION_BY_ORIENTATION = [
@@ -1648,10 +1655,8 @@ function getEquivalentPortPrunedSegmentKeys({
1648
1655
  convertedPorts.filter((port) => port.isSchematicVisible).map((port) => pointKey(port.point))
1649
1656
  );
1650
1657
  for (const record of net.records) {
1651
- if (!(record instanceof AltiumSchLabelRecord) && !(record instanceof AltiumSchNetLabelRecord) && !(record instanceof AltiumSchPortRecord) && !(record instanceof AltiumSchPowerPortRecord)) {
1652
- continue;
1653
- }
1654
- const location = record instanceof AltiumSchPortRecord ? getPortConnectionGeometry(record, wireSegments)?.anchor : getLocation(record);
1658
+ if (!isElectricalLabelRecord(record)) continue;
1659
+ const location = record instanceof AltiumSchPortRecord2 ? getPortConnectionGeometry(record, wireSegments)?.anchor : getLocation(record);
1655
1660
  if (location) protectedPointKeys.add(pointKey(location));
1656
1661
  }
1657
1662
  const segments = /* @__PURE__ */ new Map();
@@ -1810,19 +1815,15 @@ function createConnectedWiresByRecord(groupedByRoot) {
1810
1815
  return connectedWiresByRecord;
1811
1816
  }
1812
1817
 
1818
+ // lib/schematic/netLabels/getElectricalLabelName.ts
1819
+ import { AltiumSchPortRecord as AltiumSchPortRecord3 } from "altiumts";
1820
+ function getElectricalLabelName(record) {
1821
+ return record instanceof AltiumSchPortRecord3 ? record.name : record.text;
1822
+ }
1823
+
1813
1824
  // lib/schematic/connectivity/getElectricalRecordName.ts
1814
- import {
1815
- AltiumSchLabelRecord as AltiumSchLabelRecord2,
1816
- AltiumSchNetLabelRecord as AltiumSchNetLabelRecord2,
1817
- AltiumSchPortRecord as AltiumSchPortRecord2,
1818
- AltiumSchPowerPortRecord as AltiumSchPowerPortRecord2
1819
- } from "altiumts";
1820
1825
  function getElectricalRecordName(record) {
1821
- if (record instanceof AltiumSchPortRecord2) return record.name;
1822
- if (record instanceof AltiumSchLabelRecord2) return record.text;
1823
- if (record instanceof AltiumSchNetLabelRecord2) return record.text;
1824
- if (record instanceof AltiumSchPowerPortRecord2) return record.text;
1825
- return void 0;
1826
+ return isElectricalLabelRecord(record) ? getElectricalLabelName(record) : void 0;
1826
1827
  }
1827
1828
 
1828
1829
  // lib/schematic/connectivity/getOrCreateSemanticNetGroup.ts
@@ -1847,17 +1848,14 @@ function getOrCreateSemanticNetGroup({
1847
1848
  // lib/schematic/connectivity/getPositionedElectricalRecords.ts
1848
1849
  import {
1849
1850
  AltiumSchJunctionRecord,
1850
- AltiumSchLabelRecord as AltiumSchLabelRecord3,
1851
- AltiumSchNetLabelRecord as AltiumSchNetLabelRecord3,
1852
- AltiumSchPortRecord as AltiumSchPortRecord3,
1853
- AltiumSchPowerPortRecord as AltiumSchPowerPortRecord3
1851
+ AltiumSchPortRecord as AltiumSchPortRecord4
1854
1852
  } from "altiumts";
1855
1853
  function getPositionedElectricalRecords(document, segments) {
1856
1854
  return document.records.flatMap((record) => {
1857
- if (!(record instanceof AltiumSchLabelRecord3) && !(record instanceof AltiumSchNetLabelRecord3) && !(record instanceof AltiumSchPortRecord3) && !(record instanceof AltiumSchPowerPortRecord3) && !(record instanceof AltiumSchJunctionRecord)) {
1855
+ if (!isElectricalLabelRecord(record) && !(record instanceof AltiumSchJunctionRecord)) {
1858
1856
  return [];
1859
1857
  }
1860
- const point = record instanceof AltiumSchPortRecord3 ? getPortConnectionGeometry(record, segments)?.anchor : getLocation(record);
1858
+ const point = record instanceof AltiumSchPortRecord4 ? getPortConnectionGeometry(record, segments)?.anchor : getLocation(record);
1861
1859
  return point ? [{ point, record }] : [];
1862
1860
  });
1863
1861
  }
@@ -2786,7 +2784,7 @@ function convertComponent({
2786
2784
  if (pins.length === 0) return;
2787
2785
  const visibleSymbolLabels = new Set(
2788
2786
  visibleOwnedRecords.filter(
2789
- (record) => record instanceof AltiumSchLabelRecord4
2787
+ (record) => record instanceof AltiumSchLabelRecord
2790
2788
  ).flatMap((record) => {
2791
2789
  const text = record.text?.trim().toUpperCase();
2792
2790
  return text ? [text] : [];
@@ -2911,20 +2909,19 @@ var INLINE_NET_LABEL_HORIZONTAL_PADDING = 0.12;
2911
2909
 
2912
2910
  // lib/schematic/netLabels/convertNetLabels.ts
2913
2911
  import {
2914
- AltiumSchLabelRecord as AltiumSchLabelRecord6,
2915
- AltiumSchNetLabelRecord as AltiumSchNetLabelRecord5,
2916
- AltiumSchPortRecord as AltiumSchPortRecord8,
2917
- AltiumSchPowerPortRecord as AltiumSchPowerPortRecord5
2912
+ AltiumSchNetLabelRecord as AltiumSchNetLabelRecord2,
2913
+ AltiumSchPortRecord as AltiumSchPortRecord7,
2914
+ AltiumSchPowerPortRecord as AltiumSchPowerPortRecord2
2918
2915
  } from "altiumts";
2919
2916
 
2920
2917
  // lib/schematic/netLabels/createInlineNetLabelText.ts
2921
2918
  import {
2922
- AltiumSchPortRecord as AltiumSchPortRecord5
2919
+ AltiumSchPortRecord as AltiumSchPortRecord6
2923
2920
  } from "altiumts";
2924
2921
 
2925
2922
  // lib/schematic/netLabels/getInlineNetLabelDirection.ts
2926
2923
  import {
2927
- AltiumSchPortRecord as AltiumSchPortRecord4,
2924
+ AltiumSchPortRecord as AltiumSchPortRecord5,
2928
2925
  getSchematicRecordPoints as getSchematicRecordPoints7
2929
2926
  } from "altiumts";
2930
2927
  function getInlineNetLabelDirection({
@@ -2932,7 +2929,7 @@ function getInlineNetLabelDirection({
2932
2929
  location,
2933
2930
  connectedWires
2934
2931
  }) {
2935
- if (!(record instanceof AltiumSchPortRecord4)) {
2932
+ if (!(record instanceof AltiumSchPortRecord5)) {
2936
2933
  return getRecordDirection(record);
2937
2934
  }
2938
2935
  for (const wire of connectedWires) {
@@ -3008,7 +3005,7 @@ function createInlineNetLabelText({
3008
3005
  const textWidth = (name.length * INLINE_NET_LABEL_CHARACTER_WIDTH + INLINE_NET_LABEL_HORIZONTAL_PADDING) * fontSizeRatio;
3009
3006
  const isVertical = direction === "up" || direction === "down";
3010
3007
  const directionSign = direction === "left" || direction === "down" ? -1 : 1;
3011
- const isTerminalPort = record instanceof AltiumSchPortRecord5;
3008
+ const isTerminalPort = record instanceof AltiumSchPortRecord6;
3012
3009
  const anchor = isTerminalPort ? directionSign > 0 ? "left" : "right" : "center";
3013
3010
  const position = isTerminalPort ? isVertical ? {
3014
3011
  x: scaledLocation.x - fontSize / 2,
@@ -3037,12 +3034,6 @@ function createInlineNetLabelText({
3037
3034
  };
3038
3035
  }
3039
3036
 
3040
- // lib/schematic/netLabels/getElectricalLabelName.ts
3041
- import { AltiumSchPortRecord as AltiumSchPortRecord6 } from "altiumts";
3042
- function getElectricalLabelName(record) {
3043
- return record instanceof AltiumSchPortRecord6 ? record.name : record.text;
3044
- }
3045
-
3046
3037
  // lib/schematic/netLabels/getPowerPortSymbolName.ts
3047
3038
  function getPowerPortSymbolName(record, direction) {
3048
3039
  const style = Math.round(record.getNumber("STYLE") ?? 2);
@@ -3051,17 +3042,6 @@ function getPowerPortSymbolName(record, direction) {
3051
3042
  return `vcc_${direction}`;
3052
3043
  }
3053
3044
 
3054
- // lib/schematic/netLabels/isElectricalLabelRecord.ts
3055
- import {
3056
- AltiumSchLabelRecord as AltiumSchLabelRecord5,
3057
- AltiumSchNetLabelRecord as AltiumSchNetLabelRecord4,
3058
- AltiumSchPortRecord as AltiumSchPortRecord7,
3059
- AltiumSchPowerPortRecord as AltiumSchPowerPortRecord4
3060
- } from "altiumts";
3061
- function isElectricalLabelRecord(record) {
3062
- return record instanceof AltiumSchLabelRecord5 || record instanceof AltiumSchNetLabelRecord4 || record instanceof AltiumSchPortRecord7 || record instanceof AltiumSchPowerPortRecord4;
3063
- }
3064
-
3065
3045
  // lib/schematic/netLabels/convertNetLabels.ts
3066
3046
  function convertNetLabels({
3067
3047
  connectivity,
@@ -3079,14 +3059,13 @@ function convertNetLabels({
3079
3059
  continue;
3080
3060
  }
3081
3061
  const name = getElectricalLabelName(record);
3082
- const portConnection = record instanceof AltiumSchPortRecord8 ? getPortConnectionGeometry(record, allWireSegments) : void 0;
3062
+ const portConnection = record instanceof AltiumSchPortRecord7 ? getPortConnectionGeometry(record, allWireSegments) : void 0;
3083
3063
  const location = portConnection?.anchor ?? getLocation(record);
3084
3064
  if (!name || !location) continue;
3085
3065
  const connectedWires = graph.getConnectedWiresForRecord(record);
3086
3066
  const wire = connectedWires[0];
3087
- if (record instanceof AltiumSchLabelRecord6 && !wire) continue;
3088
3067
  const sourceTraceId = connectivity.sourceTraceIdByRecord.get(record);
3089
- const shouldRenderInline = Boolean(sourceTraceId) && (record instanceof AltiumSchNetLabelRecord5 || record instanceof AltiumSchPortRecord8 && (record.getNumber("IOTYPE") ?? 0) === 0 && connectivity.sourcePortCountByRecord.get(record) === 2 && !isPowerNet(name));
3068
+ const shouldRenderInline = Boolean(sourceTraceId) && (record instanceof AltiumSchNetLabelRecord2 || record instanceof AltiumSchPortRecord7 && (record.getNumber("IOTYPE") ?? 0) === 0 && connectivity.sourcePortCountByRecord.get(record) === 2 && !isPowerNet(name));
3090
3069
  if (shouldRenderInline && sourceTraceId) {
3091
3070
  handledRecords.add(record);
3092
3071
  elements.push(
@@ -3111,7 +3090,7 @@ function convertNetLabels({
3111
3090
  });
3112
3091
  const schematicTraceId = wire ? connectivity.schematicTraceIdByRecord.get(wire) : void 0;
3113
3092
  const direction = getRecordDirection(record);
3114
- const symbolName = record instanceof AltiumSchPowerPortRecord5 ? getPowerPortSymbolName(record, direction) : void 0;
3093
+ const symbolName = record instanceof AltiumSchPowerPortRecord2 ? getPowerPortSymbolName(record, direction) : void 0;
3115
3094
  const schematicNetLabel = {
3116
3095
  type: "schematic_net_label",
3117
3096
  anchor_position: scalePoint(location, options.scale),
@@ -4878,7 +4857,7 @@ function mapTextAnchor(justification) {
4878
4857
  if (normalizedJustification?.includes("CENTER")) return "bottom_center";
4879
4858
  if (normalizedJustification?.includes("RIGHT")) return "bottom_right";
4880
4859
  if (normalizedJustification?.includes("LEFT")) return "bottom_left";
4881
- return "center";
4860
+ return "bottom_left";
4882
4861
  }
4883
4862
 
4884
4863
  // lib/pcb/text/convertPcbCopperText.ts