altium-to-circuit-json 0.0.97 → 0.0.99

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
@@ -3391,6 +3391,17 @@ function convertComponentPin({
3391
3391
  };
3392
3392
  }
3393
3393
 
3394
+ // lib/schematic/components/convertMarkedCapacitorBody.ts
3395
+ import {
3396
+ AltiumSchArcRecord as AltiumSchArcRecord2,
3397
+ AltiumSchDesignatorRecord,
3398
+ AltiumSchEllipticalArcRecord as AltiumSchEllipticalArcRecord2,
3399
+ AltiumSchLabelRecord,
3400
+ AltiumSchLineRecord as AltiumSchLineRecord2,
3401
+ AltiumSchParameterRecord,
3402
+ AltiumSchPolylineRecord as AltiumSchPolylineRecord2
3403
+ } from "altiumts";
3404
+
3394
3405
  // lib/schematic/components/convertOwnedCustomComponentBody.ts
3395
3406
  import {
3396
3407
  AltiumSchArcRecord,
@@ -3540,6 +3551,38 @@ function convertOwnedCustomComponentBody({
3540
3551
  return prepareOwnedComponentBodyElements(ownedElements);
3541
3552
  }
3542
3553
 
3554
+ // lib/schematic/components/convertMarkedCapacitorBody.ts
3555
+ function convertMarkedCapacitorBody({
3556
+ identity,
3557
+ records,
3558
+ symbolSelection
3559
+ }, context) {
3560
+ const hasCurvedPlate = records.some(
3561
+ (record) => record instanceof AltiumSchArcRecord2 || record instanceof AltiumSchEllipticalArcRecord2
3562
+ ) && records.some(
3563
+ (record) => record instanceof AltiumSchLineRecord2 || record instanceof AltiumSchPolylineRecord2
3564
+ );
3565
+ if (!symbolSelection?.name.startsWith("capacitor_") || symbolSelection.name.startsWith("capacitor_polarized_") || !hasCurvedPlate && !records.some(
3566
+ (record) => record instanceof AltiumSchLabelRecord && !record.getBoolean("ISHIDDEN") && record.text?.trim() === "+"
3567
+ )) {
3568
+ return void 0;
3569
+ }
3570
+ const body = convertOwnedCustomComponentBody({ identity, records }, context);
3571
+ if (!body) return void 0;
3572
+ const componentLabelIds = new Set(
3573
+ records.flatMap((record) => {
3574
+ if (!(record instanceof AltiumSchDesignatorRecord) && !(record instanceof AltiumSchParameterRecord && ["comment", "value"].includes(record.name?.toLowerCase() ?? ""))) {
3575
+ return [];
3576
+ }
3577
+ const index = context.document.records.indexOf(record);
3578
+ return index >= 0 ? [`schematic_text_altium_${index}`] : [];
3579
+ })
3580
+ );
3581
+ return body.map(
3582
+ (element) => element.type === "schematic_text" && componentLabelIds.has(element.schematic_text_id) ? { ...element, color: "#0f0f0f" } : element
3583
+ );
3584
+ }
3585
+
3543
3586
  // lib/schematic/components/normalizeLogicGatePinName.ts
3544
3587
  function normalizeLogicGatePinName(name) {
3545
3588
  return name?.trim().toUpperCase().replace(/^\d+(?=[A-Z]+$)/u, "");
@@ -4100,18 +4143,18 @@ function createSourceComponent({
4100
4143
  }
4101
4144
 
4102
4145
  // lib/schematic/components/findOwnedDesignator.ts
4103
- import { AltiumSchDesignatorRecord } from "altiumts";
4146
+ import { AltiumSchDesignatorRecord as AltiumSchDesignatorRecord2 } from "altiumts";
4104
4147
  function findOwnedDesignator(records) {
4105
4148
  return records.find(
4106
- (record) => record instanceof AltiumSchDesignatorRecord && record.getDecoded("NAME")?.toLowerCase() === "designator"
4149
+ (record) => record instanceof AltiumSchDesignatorRecord2 && record.getDecoded("NAME")?.toLowerCase() === "designator"
4107
4150
  )?.text;
4108
4151
  }
4109
4152
 
4110
4153
  // lib/schematic/components/findOwnedParameterText.ts
4111
- import { AltiumSchParameterRecord } from "altiumts";
4154
+ import { AltiumSchParameterRecord as AltiumSchParameterRecord2 } from "altiumts";
4112
4155
  function findOwnedParameterText(records, name) {
4113
4156
  return records.find(
4114
- (record) => record instanceof AltiumSchParameterRecord && record.name?.toLowerCase() === name.toLowerCase()
4157
+ (record) => record instanceof AltiumSchParameterRecord2 && record.name?.toLowerCase() === name.toLowerCase()
4115
4158
  )?.text;
4116
4159
  }
4117
4160
 
@@ -4155,12 +4198,28 @@ function getComponentIdentity({
4155
4198
  };
4156
4199
  }
4157
4200
 
4201
+ // lib/schematic/components/getComponentSize.ts
4202
+ function getComponentSize({
4203
+ bodyBounds,
4204
+ scale: scale5,
4205
+ symbolSelection
4206
+ }) {
4207
+ if (symbolSelection) return { ...symbolSelection.symbol.size };
4208
+ return {
4209
+ height: Math.max(
4210
+ scaleLength(bodyBounds.maxY - bodyBounds.minY, scale5),
4211
+ 0.4
4212
+ ),
4213
+ width: Math.max(scaleLength(bodyBounds.maxX - bodyBounds.minX, scale5), 0.4)
4214
+ };
4215
+ }
4216
+
4158
4217
  // lib/schematic/components/getVisibleSymbolLabels.ts
4159
- import { AltiumSchLabelRecord } from "altiumts";
4218
+ import { AltiumSchLabelRecord as AltiumSchLabelRecord2 } from "altiumts";
4160
4219
  function getVisibleSymbolLabels(records) {
4161
4220
  return new Set(
4162
4221
  records.filter(
4163
- (record) => record instanceof AltiumSchLabelRecord
4222
+ (record) => record instanceof AltiumSchLabelRecord2
4164
4223
  ).flatMap((record) => {
4165
4224
  const text = record.text?.trim().toUpperCase();
4166
4225
  return text ? [text] : [];
@@ -4233,29 +4292,29 @@ function convertComponent({
4233
4292
  visibleOwnedRecords,
4234
4293
  componentPorts.map(({ point }) => point)
4235
4294
  );
4236
- const symbolSelection = selectCircuitJsonSymbol({
4295
+ let symbolSelection = selectCircuitJsonSymbol({
4237
4296
  ...identity,
4238
4297
  ports: componentPorts
4239
4298
  });
4299
+ const polarizedCapacitorBody = convertMarkedCapacitorBody(
4300
+ { identity, records: visibleOwnedRecords, symbolSelection },
4301
+ context
4302
+ );
4303
+ if (polarizedCapacitorBody) symbolSelection = void 0;
4240
4304
  const singleInputGateBody = symbolSelection ? void 0 : convertOwnedSingleInputGateBody(
4241
4305
  { identity, records: visibleOwnedRecords, componentPorts },
4242
4306
  context
4243
4307
  );
4244
- const ownedComponentBody = singleInputGateBody ?? (symbolSelection ? void 0 : convertOwnedComponentBody(
4308
+ const ownedComponentBody = polarizedCapacitorBody ?? singleInputGateBody ?? (symbolSelection ? void 0 : convertOwnedComponentBody(
4245
4309
  { identity, pins, records: visibleOwnedRecords, visibleSymbolLabels },
4246
4310
  context
4247
4311
  ));
4248
4312
  const center = scalePoint(getBoundsCenter(bodyBounds), options.scale);
4249
- const size = symbolSelection ? { ...symbolSelection.symbol.size } : {
4250
- height: Math.max(
4251
- scaleLength(bodyBounds.maxY - bodyBounds.minY, options.scale),
4252
- 0.4
4253
- ),
4254
- width: Math.max(
4255
- scaleLength(bodyBounds.maxX - bodyBounds.minX, options.scale),
4256
- 0.4
4257
- )
4258
- };
4313
+ const size = getComponentSize({
4314
+ bodyBounds,
4315
+ scale: options.scale,
4316
+ symbolSelection
4317
+ });
4259
4318
  if (symbolSelection) {
4260
4319
  applyNativeSymbolPortGeometry({ center, selection: symbolSelection });
4261
4320
  }