altium-to-circuit-json 0.0.64 → 0.0.65

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
@@ -2841,6 +2841,45 @@ function convertComponentPin({
2841
2841
  };
2842
2842
  }
2843
2843
 
2844
+ // lib/schematic/components/createAlphanumericPinDesignatorText.ts
2845
+ var EDGE_VECTOR_BY_SIDE = {
2846
+ bottom: { x: 0, y: 1 },
2847
+ left: { x: 1, y: 0 },
2848
+ right: { x: -1, y: 0 },
2849
+ top: { x: 0, y: -1 }
2850
+ };
2851
+ function createAlphanumericPinDesignatorText({
2852
+ pin,
2853
+ recordIndex,
2854
+ scale: scale5,
2855
+ schematicPort
2856
+ }) {
2857
+ const designator = pin.designator;
2858
+ if (!designator || parsePinNumber(designator) !== void 0) return void 0;
2859
+ const pinConglomerate = pin.pinConglomerate;
2860
+ const isDesignatorVisible = pinConglomerate === void 0 || (pinConglomerate & 16) !== 0;
2861
+ const side = schematicPort.side_of_component;
2862
+ if (!isDesignatorVisible || !side) return void 0;
2863
+ const edgeVector = EDGE_VECTOR_BY_SIDE[side];
2864
+ const halfPinLength = (schematicPort.distance_from_component_edge ?? 0.4) / 2;
2865
+ const position = {
2866
+ x: schematicPort.center.x + edgeVector.x * halfPinLength,
2867
+ y: schematicPort.center.y + edgeVector.y * halfPinLength
2868
+ };
2869
+ return {
2870
+ type: "schematic_text",
2871
+ anchor: "bottom_center",
2872
+ color: "#a90000",
2873
+ font_size: Math.max(scaleLength(1.5, scale5), 0.15),
2874
+ position,
2875
+ rotation: side === "top" || side === "bottom" ? -90 : 0,
2876
+ schematic_component_id: schematicPort.schematic_component_id,
2877
+ schematic_sheet_id: schematicPort.schematic_sheet_id,
2878
+ schematic_text_id: `schematic_pin_designator_altium_${recordIndex}`,
2879
+ text: designator
2880
+ };
2881
+ }
2882
+
2844
2883
  // lib/schematic/components/createSourceComponent.ts
2845
2884
  import {
2846
2885
  source_simple_capacitor,
@@ -3149,6 +3188,20 @@ function convertComponent({
3149
3188
  if (symbolSelection) {
3150
3189
  applyNativeSymbolPortGeometry({ center, selection: symbolSelection });
3151
3190
  }
3191
+ const pinDesignatorTexts = componentPorts.flatMap(
3192
+ ({ isSchematicVisible, schematicPort }, pinIndex) => {
3193
+ if (!isSchematicVisible) return [];
3194
+ const pin = pins[pinIndex];
3195
+ if (!pin) return [];
3196
+ const pinDesignatorText = createAlphanumericPinDesignatorText({
3197
+ pin,
3198
+ recordIndex: document.records.indexOf(pin),
3199
+ scale: options.scale,
3200
+ schematicPort
3201
+ });
3202
+ return pinDesignatorText ? [pinDesignatorText] : [];
3203
+ }
3204
+ );
3152
3205
  convertedPorts.push(...componentPorts);
3153
3206
  elements.push(
3154
3207
  ...componentPorts.flatMap(
@@ -3156,7 +3209,8 @@ function convertComponent({
3156
3209
  sourcePort,
3157
3210
  ...isSchematicVisible ? [schematicPort] : []
3158
3211
  ]
3159
- )
3212
+ ),
3213
+ ...pinDesignatorTexts
3160
3214
  );
3161
3215
  const schematicComponent = {
3162
3216
  type: "schematic_component",