altium-to-circuit-json 0.0.52 → 0.0.53

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
@@ -318,39 +318,22 @@ function getBoundsForPoints(points) {
318
318
  };
319
319
  }
320
320
 
321
- // lib/schematic/geometry/getCoordinate.ts
322
- function getCoordinate(record, key) {
323
- const raw = record.getCaseInsensitive(key);
324
- if (raw === void 0) return void 0;
325
- const integer = Number(raw);
326
- if (!Number.isFinite(integer)) return void 0;
327
- const fractionRaw = record.getCaseInsensitive(`${key}_FRAC`);
328
- if (fractionRaw === void 0) return integer;
329
- const fraction = Number(`0.${fractionRaw.replace(/^[+-]/u, "")}`);
330
- if (!Number.isFinite(fraction)) return integer;
331
- return integer < 0 ? integer - fraction : integer + fraction;
332
- }
333
-
334
321
  // lib/schematic/geometry/getCoordinateOrFallback.ts
322
+ import { getSchematicCoordinate } from "altiumts";
335
323
  function getCoordinateOrFallback({
336
324
  record,
337
325
  key,
338
326
  fallback
339
327
  }) {
340
- const rawInteger = record.getCaseInsensitive(key);
341
- if (rawInteger !== void 0) return getCoordinate(record, key) ?? fallback;
342
- const rawFraction = record.getCaseInsensitive(`${key}_FRAC`);
343
- if (rawFraction === void 0) return fallback;
344
- const fraction = Number(`0.${rawFraction.replace(/^[+-]/u, "")}`);
345
- if (!Number.isFinite(fraction)) return fallback;
346
- return fallback < 0 ? fallback - fraction : fallback + fraction;
328
+ return getSchematicCoordinate(record, key, fallback);
347
329
  }
348
330
 
349
331
  // lib/schematic/geometry/getCorner.ts
332
+ import {
333
+ getSchematicPoint
334
+ } from "altiumts";
350
335
  function getCorner(record) {
351
- const x = getCoordinate(record, "CORNER.X");
352
- const y = getCoordinate(record, "CORNER.Y");
353
- return x === void 0 || y === void 0 ? void 0 : { x, y };
336
+ return getSchematicPoint(record, { xKey: "CORNER.X", yKey: "CORNER.Y" });
354
337
  }
355
338
 
356
339
  // lib/schematic/geometry/getDirectionForVector.ts
@@ -362,10 +345,11 @@ function getDirectionForVector(vector) {
362
345
  }
363
346
 
364
347
  // lib/schematic/geometry/getLocation.ts
348
+ import {
349
+ getSchematicPoint as getSchematicPoint2
350
+ } from "altiumts";
365
351
  function getLocation(record) {
366
- const x = getCoordinate(record, "LOCATION.X");
367
- const y = getCoordinate(record, "LOCATION.Y");
368
- return x === void 0 || y === void 0 ? void 0 : { x, y };
352
+ return getSchematicPoint2(record, { xKey: "LOCATION.X", yKey: "LOCATION.Y" });
369
353
  }
370
354
 
371
355
  // lib/schematic/geometry/getPointDistance.ts
@@ -805,8 +789,14 @@ function renderHierarchicalPort({
805
789
  }) {
806
790
  const location = getLocation(record);
807
791
  if (!location) return [];
808
- const width = Math.max(Number(record.getCaseInsensitive("WIDTH") ?? 16), 10);
809
- const height = Math.max(Number(record.getCaseInsensitive("HEIGHT") ?? 10), 4);
792
+ const width = Math.max(
793
+ getCoordinateOrFallback({ record, key: "WIDTH", fallback: 16 }),
794
+ 10
795
+ );
796
+ const height = Math.max(
797
+ getCoordinateOrFallback({ record, key: "HEIGHT", fallback: 10 }),
798
+ 4
799
+ );
810
800
  const halfHeight = height / 2;
811
801
  const pointDepth = Math.min(width * 0.22, height);
812
802
  const ioType = Number(record.getCaseInsensitive("IOTYPE") ?? 0);
@@ -889,7 +879,7 @@ function renderPin({
889
879
  { x: 0, y: -1 }
890
880
  ][orientation] ?? { x: 1, y: 0 };
891
881
  const length = Math.max(
892
- Number(record.getCaseInsensitive("PINLENGTH") ?? 10),
882
+ getCoordinateOrFallback({ record, key: "PINLENGTH", fallback: 10 }),
893
883
  1
894
884
  );
895
885
  const end = {
@@ -1782,7 +1772,10 @@ function getPortConnectionGeometry(record, wireSegments) {
1782
1772
  if (!origin) return void 0;
1783
1773
  const originToExtremity = getRecordDirection(record);
1784
1774
  const directionVector = VECTOR_BY_DIRECTION[originToExtremity];
1785
- const width = Math.max(record.getNumber("WIDTH") ?? 16, 0);
1775
+ const width = Math.max(
1776
+ getCoordinateOrFallback({ record, key: "WIDTH", fallback: 16 }),
1777
+ 0
1778
+ );
1786
1779
  const extremity = {
1787
1780
  x: origin.x + directionVector.x * width,
1788
1781
  y: origin.y + directionVector.y * width
@@ -2895,8 +2888,16 @@ function getComponentBodyBounds(records, portPoints) {
2895
2888
  if (location && corner) points.push(location, corner);
2896
2889
  points.push(...getSchematicRecordPoints6(record));
2897
2890
  if (record instanceof AltiumSchEllipseRecord && location) {
2898
- const radiusX = Math.abs(record.getNumber("RADIUS") ?? 0);
2899
- const radiusY = Math.abs(record.getNumber("SECONDARYRADIUS") ?? radiusX);
2891
+ const radiusX = Math.abs(
2892
+ getCoordinateOrFallback({ record, key: "RADIUS", fallback: 0 })
2893
+ );
2894
+ const radiusY = Math.abs(
2895
+ getCoordinateOrFallback({
2896
+ record,
2897
+ key: "SECONDARYRADIUS",
2898
+ fallback: radiusX
2899
+ })
2900
+ );
2900
2901
  points.push(
2901
2902
  { x: location.x - radiusX, y: location.y - radiusY },
2902
2903
  { x: location.x + radiusX, y: location.y + radiusY }