easyeda 0.0.358 → 0.0.360

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.
@@ -758,7 +758,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
758
758
  c_spiceCmd?: any;
759
759
  };
760
760
  canvas: string;
761
- colors: Record<string, string> | string[];
761
+ colors: string[] | Record<string, string>;
762
762
  BBox?: {
763
763
  x: number;
764
764
  y: number;
@@ -787,7 +787,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
787
787
  width: number;
788
788
  height: number;
789
789
  } | undefined;
790
- colors?: Record<string, string> | string[] | undefined;
790
+ colors?: string[] | Record<string, string> | undefined;
791
791
  }>, {
792
792
  BBox: {
793
793
  x: number;
@@ -908,7 +908,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
908
908
  c_spiceCmd?: any;
909
909
  };
910
910
  canvas: string;
911
- colors: Record<string, string> | string[];
911
+ colors: string[] | Record<string, string>;
912
912
  }, {
913
913
  shape: string[];
914
914
  head: {
@@ -931,7 +931,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
931
931
  width: number;
932
932
  height: number;
933
933
  } | undefined;
934
- colors?: Record<string, string> | string[] | undefined;
934
+ colors?: string[] | Record<string, string> | undefined;
935
935
  }>;
936
936
  declare const PackageDetailDataStrSchema: z.ZodObject<{
937
937
  head: z.ZodObject<{
@@ -3477,7 +3477,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3477
3477
  c_spiceCmd?: any;
3478
3478
  };
3479
3479
  canvas: string;
3480
- colors: Record<string, string> | string[];
3480
+ colors: string[] | Record<string, string>;
3481
3481
  BBox?: {
3482
3482
  x: number;
3483
3483
  y: number;
@@ -3506,7 +3506,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3506
3506
  width: number;
3507
3507
  height: number;
3508
3508
  } | undefined;
3509
- colors?: Record<string, string> | string[] | undefined;
3509
+ colors?: string[] | Record<string, string> | undefined;
3510
3510
  }>, {
3511
3511
  BBox: {
3512
3512
  x: number;
@@ -3627,7 +3627,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3627
3627
  c_spiceCmd?: any;
3628
3628
  };
3629
3629
  canvas: string;
3630
- colors: Record<string, string> | string[];
3630
+ colors: string[] | Record<string, string>;
3631
3631
  }, {
3632
3632
  shape: string[];
3633
3633
  head: {
@@ -3650,7 +3650,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3650
3650
  width: number;
3651
3651
  height: number;
3652
3652
  } | undefined;
3653
- colors?: Record<string, string> | string[] | undefined;
3653
+ colors?: string[] | Record<string, string> | undefined;
3654
3654
  }>;
3655
3655
  verify: z.ZodBoolean;
3656
3656
  SMT: z.ZodOptional<z.ZodBoolean>;
@@ -4895,7 +4895,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
4895
4895
  c_spiceCmd?: any;
4896
4896
  };
4897
4897
  canvas: string;
4898
- colors: Record<string, string> | string[];
4898
+ colors: string[] | Record<string, string>;
4899
4899
  };
4900
4900
  description: string;
4901
4901
  szlcsc: {
@@ -5146,7 +5146,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
5146
5146
  width: number;
5147
5147
  height: number;
5148
5148
  } | undefined;
5149
- colors?: Record<string, string> | string[] | undefined;
5149
+ colors?: string[] | Record<string, string> | undefined;
5150
5150
  };
5151
5151
  description: string;
5152
5152
  szlcsc: {
@@ -10282,6 +10282,112 @@ var PIN1_LOCATION_PARTS = {
10282
10282
  };
10283
10283
  var PIN1_LOCATIONS = Object.keys(PIN1_LOCATION_PARTS);
10284
10284
 
10285
+ // lib/utils/normalize-pin-labels.ts
10286
+ var normalizeActiveLowPinLabel = (label) => {
10287
+ const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
10288
+ if (!hasActiveLowMarker) return label;
10289
+ const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
10290
+ if (activeLowLabel.length === 0) return label;
10291
+ if (activeLowLabel.startsWith("N_")) return activeLowLabel;
10292
+ return `N_${activeLowLabel}`;
10293
+ };
10294
+ var normalizePinLabels = (inputPinLabels) => {
10295
+ const normalizedInputPinLabels = inputPinLabels.map(
10296
+ (labels) => labels.map(normalizeActiveLowPinLabel)
10297
+ );
10298
+ const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
10299
+ ...new Set(labels)
10300
+ ]);
10301
+ const result = uniqueInputPinLabels.map(() => []);
10302
+ const desiredNumbers = uniqueInputPinLabels.map(() => null);
10303
+ for (let i = 0; i < uniqueInputPinLabels.length; i++) {
10304
+ for (const label of uniqueInputPinLabels[i]) {
10305
+ if (/^\d+$/.test(label)) {
10306
+ desiredNumbers[i] = Number.parseInt(label);
10307
+ break;
10308
+ }
10309
+ }
10310
+ }
10311
+ let highestPinNumber = 0;
10312
+ const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
10313
+ for (let i = 0; i < desiredNumbers.length; i++) {
10314
+ const desiredNumber = desiredNumbers[i];
10315
+ if (desiredNumber === null || desiredNumber < 1) continue;
10316
+ if (!acceptedDesiredNumbers.has(desiredNumber)) {
10317
+ acceptedDesiredNumbers.add(desiredNumber);
10318
+ result[i].push(`pin${desiredNumber}`);
10319
+ highestPinNumber = Math.max(highestPinNumber, desiredNumber);
10320
+ continue;
10321
+ }
10322
+ let existingAltCount = 0;
10323
+ for (const label of result[i]) {
10324
+ if (label.startsWith(`pin${desiredNumber}_alt`)) {
10325
+ existingAltCount += 1;
10326
+ }
10327
+ }
10328
+ result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
10329
+ }
10330
+ for (let i = 0; i < result.length; i++) {
10331
+ const firstLabel = result[i][0];
10332
+ if (firstLabel?.includes("_alt")) {
10333
+ highestPinNumber += 1;
10334
+ result[i].unshift(`pin${highestPinNumber}`);
10335
+ }
10336
+ }
10337
+ for (let i = 0; i < result.length; i++) {
10338
+ if (result[i].length === 0) {
10339
+ highestPinNumber += 1;
10340
+ result[i].push(`pin${highestPinNumber}`);
10341
+ }
10342
+ }
10343
+ const totalLabelCounts = {};
10344
+ for (const inputLabels of uniqueInputPinLabels) {
10345
+ for (const label of inputLabels) {
10346
+ if (/^\d+$/.test(label)) continue;
10347
+ totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
10348
+ }
10349
+ }
10350
+ const incrementalLabelCounts = {};
10351
+ for (let i = 0; i < uniqueInputPinLabels.length; i++) {
10352
+ for (const label of uniqueInputPinLabels[i]) {
10353
+ if (/^\d+$/.test(label)) continue;
10354
+ if (totalLabelCounts[label] === 1) {
10355
+ result[i].push(label);
10356
+ } else {
10357
+ incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
10358
+ result[i].push(`${label}${incrementalLabelCounts[label]}`);
10359
+ }
10360
+ }
10361
+ }
10362
+ return result;
10363
+ };
10364
+
10365
+ // lib/utils/normalize-easyeda-pin-label.ts
10366
+ var normalizeEasyEdaPinLabel = (label) => {
10367
+ if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
10368
+ if (/[-–−]$/.test(label)) label = `${label.slice(0, -1)}_NEG`;
10369
+ label = normalizeActiveLowPinLabel(label);
10370
+ if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
10371
+ if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
10372
+ if (/^[-–−]/.test(label)) label = `${label.slice(1)}_NEG`;
10373
+ return label;
10374
+ };
10375
+
10376
+ // lib/utils/get-easyeda-pin-aliases.ts
10377
+ var getEasyEdaPinAliases = (label) => {
10378
+ label = label.replace(/&#(x[0-9a-f]+|[0-9]+);/gi, (entity, code) => {
10379
+ let codePoint = Number(code);
10380
+ if (/^x/i.test(code)) codePoint = Number.parseInt(code.slice(1), 16);
10381
+ const maximumUnicodeCodePoint = 1114111;
10382
+ if (codePoint > maximumUnicodeCodePoint) return entity;
10383
+ return String.fromCodePoint(codePoint);
10384
+ });
10385
+ if (label.includes("/") && !/[a-zA-Z0-9]/.test(label)) return [];
10386
+ return label.split("/").map(
10387
+ (alias) => normalizeEasyEdaPinLabel(alias.trim()).replace(/[`′]/g, "_PRIME").replace(/^[()]+|[()]+$/g, "").replace(/[^a-zA-Z0-9_]/g, "_")
10388
+ ).filter((alias) => /[a-zA-Z0-9]/.test(alias));
10389
+ };
10390
+
10285
10391
  // node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
10286
10392
  function orientation(p, q, r) {
10287
10393
  const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
@@ -10587,94 +10693,6 @@ var getPolarizedPinMetadata = (pinLabels) => {
10587
10693
  };
10588
10694
  };
10589
10695
 
10590
- // lib/utils/normalize-pin-labels.ts
10591
- var normalizeActiveLowPinLabel = (label) => {
10592
- const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
10593
- if (!hasActiveLowMarker) return label;
10594
- const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
10595
- if (activeLowLabel.length === 0) return label;
10596
- if (activeLowLabel.startsWith("N_")) return activeLowLabel;
10597
- return `N_${activeLowLabel}`;
10598
- };
10599
- var normalizePinLabels = (inputPinLabels) => {
10600
- const normalizedInputPinLabels = inputPinLabels.map(
10601
- (labels) => labels.map(normalizeActiveLowPinLabel)
10602
- );
10603
- const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
10604
- ...new Set(labels)
10605
- ]);
10606
- const result = uniqueInputPinLabels.map(() => []);
10607
- const desiredNumbers = uniqueInputPinLabels.map(() => null);
10608
- for (let i = 0; i < uniqueInputPinLabels.length; i++) {
10609
- for (const label of uniqueInputPinLabels[i]) {
10610
- if (/^\d+$/.test(label)) {
10611
- desiredNumbers[i] = Number.parseInt(label);
10612
- break;
10613
- }
10614
- }
10615
- }
10616
- let highestPinNumber = 0;
10617
- const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
10618
- for (let i = 0; i < desiredNumbers.length; i++) {
10619
- const desiredNumber = desiredNumbers[i];
10620
- if (desiredNumber === null || desiredNumber < 1) continue;
10621
- if (!acceptedDesiredNumbers.has(desiredNumber)) {
10622
- acceptedDesiredNumbers.add(desiredNumber);
10623
- result[i].push(`pin${desiredNumber}`);
10624
- highestPinNumber = Math.max(highestPinNumber, desiredNumber);
10625
- continue;
10626
- }
10627
- let existingAltCount = 0;
10628
- for (const label of result[i]) {
10629
- if (label.startsWith(`pin${desiredNumber}_alt`)) {
10630
- existingAltCount += 1;
10631
- }
10632
- }
10633
- result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
10634
- }
10635
- for (let i = 0; i < result.length; i++) {
10636
- const firstLabel = result[i][0];
10637
- if (firstLabel?.includes("_alt")) {
10638
- highestPinNumber += 1;
10639
- result[i].unshift(`pin${highestPinNumber}`);
10640
- }
10641
- }
10642
- for (let i = 0; i < result.length; i++) {
10643
- if (result[i].length === 0) {
10644
- highestPinNumber += 1;
10645
- result[i].push(`pin${highestPinNumber}`);
10646
- }
10647
- }
10648
- const totalLabelCounts = {};
10649
- for (const inputLabels of uniqueInputPinLabels) {
10650
- for (const label of inputLabels) {
10651
- if (/^\d+$/.test(label)) continue;
10652
- totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
10653
- }
10654
- }
10655
- const incrementalLabelCounts = {};
10656
- for (let i = 0; i < uniqueInputPinLabels.length; i++) {
10657
- for (const label of uniqueInputPinLabels[i]) {
10658
- if (/^\d+$/.test(label)) continue;
10659
- if (totalLabelCounts[label] === 1) {
10660
- result[i].push(label);
10661
- } else {
10662
- incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
10663
- result[i].push(`${label}${incrementalLabelCounts[label]}`);
10664
- }
10665
- }
10666
- }
10667
- return result;
10668
- };
10669
-
10670
- // lib/utils/normalize-symbol-name.ts
10671
- var normalizeSymbolName = (name) => {
10672
- const trimmedName = name.trim();
10673
- if (trimmedName === "+") return "_POS";
10674
- if (trimmedName === "-") return "_NEG";
10675
- return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
10676
- };
10677
-
10678
10696
  // lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
10679
10697
  var categoryValueContainsDiode = (value) => {
10680
10698
  if (typeof value === "string") {
@@ -11157,11 +11175,13 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
11157
11175
  );
11158
11176
  const pins = easyEdaJson.dataStr.shape.filter((shape) => shape.type === "PIN");
11159
11177
  const pinLabelSets = pads.map((pad) => {
11160
- const labels = [];
11161
- if (pad.number) labels.push(pad.number.toString());
11178
+ const padAliases = pad.number ? getEasyEdaPinAliases(pad.number.toString()) : [];
11162
11179
  const pin = pins.find((p) => p.pinNumber === pad.number);
11163
- if (pin) labels.push(normalizeSymbolName(pin.label));
11164
- return labels;
11180
+ const schematicAliases = pin ? getEasyEdaPinAliases(pin.label) : [];
11181
+ const hasNamedSchematicAlias = schematicAliases.some(
11182
+ (alias) => !/^\d+$/.test(alias)
11183
+ );
11184
+ return hasNamedSchematicAlias ? [...schematicAliases, ...padAliases] : [...padAliases, ...schematicAliases];
11165
11185
  });
11166
11186
  const padNumberKeys = pads.map((pad, index) => {
11167
11187
  const padNumber = String(pad.number ?? "").trim();
@@ -12075,14 +12095,9 @@ var PinShapeOutputSchema = external_exports.object({
12075
12095
  var parsePin = (pinString) => {
12076
12096
  const parts = pinString.split("~");
12077
12097
  const [, visibility, , pinNumber, x, y, rotation2, id] = parts;
12078
- const nameMatch = pinString.match(/~([\w+#-]+)~(start|end)~/);
12079
- let label = nameMatch ? nameMatch[1] : "";
12080
- if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
12081
- if (label.endsWith("-")) label = `${label.slice(0, -1)}_NEG`;
12082
- label = normalizeActiveLowPinLabel(label);
12083
- if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
12084
- if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
12085
- if (label.startsWith("-")) label = `${label.slice(1)}_NEG`;
12098
+ const pinNameSection = pinString.split("^^")[3];
12099
+ let label = pinNameSection?.split("~")[4] ?? "";
12100
+ if (!label.includes("/")) label = normalizeEasyEdaPinLabel(label);
12086
12101
  const colorMatch = pinString.match(/#[0-9A-F]{6}/);
12087
12102
  const labelColor = colorMatch ? colorMatch[0] : "";
12088
12103
  const path = pinString.split("^^")[2]?.split("~")[0] ?? "";
@@ -12576,6 +12591,14 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
12576
12591
  return placementPromise;
12577
12592
  };
12578
12593
 
12594
+ // lib/utils/normalize-symbol-name.ts
12595
+ var normalizeSymbolName = (name) => {
12596
+ const trimmedName = name.trim();
12597
+ if (trimmedName === "+") return "_POS";
12598
+ if (trimmedName === "-") return "_NEG";
12599
+ return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
12600
+ };
12601
+
12579
12602
  // lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
12580
12603
  var round = (value) => Number(value.toFixed(6));
12581
12604
  var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
@@ -12802,14 +12825,15 @@ var getPortMetadataByShapeId = (easyEdaJson, circuitJson) => {
12802
12825
  portName ??= `pin${pinIndex + 1}`;
12803
12826
  usedPortNames.add(portName);
12804
12827
  const sourcePort = sourcePorts.find((port) => port.name === portName);
12828
+ let aliases = getEasyEdaPinAliases(pin.label);
12829
+ if (sourcePort?.port_hints?.length) {
12830
+ aliases = sourcePort.port_hints;
12831
+ }
12805
12832
  metadataByShapeId.set(pin.id, {
12806
12833
  name: portName,
12807
12834
  pinNumber: sourcePort?.pin_number,
12808
- aliases: [
12809
- ...sourcePort?.port_hints ?? [],
12810
- ...pin.label ? [normalizeSymbolName(pin.label)] : []
12811
- ].filter(
12812
- (alias, index, aliases) => alias !== portName && aliases.indexOf(alias) === index
12835
+ aliases: aliases.filter(
12836
+ (alias, index, aliases2) => alias !== portName && aliases2.indexOf(alias) === index
12813
12837
  )
12814
12838
  });
12815
12839
  });