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.
package/dist/index.d.ts CHANGED
@@ -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: {
package/dist/index.js CHANGED
@@ -4,6 +4,112 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
+ // lib/utils/normalize-pin-labels.ts
8
+ var normalizeActiveLowPinLabel = (label) => {
9
+ const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
10
+ if (!hasActiveLowMarker) return label;
11
+ const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
12
+ if (activeLowLabel.length === 0) return label;
13
+ if (activeLowLabel.startsWith("N_")) return activeLowLabel;
14
+ return `N_${activeLowLabel}`;
15
+ };
16
+ var normalizePinLabels = (inputPinLabels) => {
17
+ const normalizedInputPinLabels = inputPinLabels.map(
18
+ (labels) => labels.map(normalizeActiveLowPinLabel)
19
+ );
20
+ const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
21
+ ...new Set(labels)
22
+ ]);
23
+ const result = uniqueInputPinLabels.map(() => []);
24
+ const desiredNumbers = uniqueInputPinLabels.map(() => null);
25
+ for (let i = 0; i < uniqueInputPinLabels.length; i++) {
26
+ for (const label of uniqueInputPinLabels[i]) {
27
+ if (/^\d+$/.test(label)) {
28
+ desiredNumbers[i] = Number.parseInt(label);
29
+ break;
30
+ }
31
+ }
32
+ }
33
+ let highestPinNumber = 0;
34
+ const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
35
+ for (let i = 0; i < desiredNumbers.length; i++) {
36
+ const desiredNumber = desiredNumbers[i];
37
+ if (desiredNumber === null || desiredNumber < 1) continue;
38
+ if (!acceptedDesiredNumbers.has(desiredNumber)) {
39
+ acceptedDesiredNumbers.add(desiredNumber);
40
+ result[i].push(`pin${desiredNumber}`);
41
+ highestPinNumber = Math.max(highestPinNumber, desiredNumber);
42
+ continue;
43
+ }
44
+ let existingAltCount = 0;
45
+ for (const label of result[i]) {
46
+ if (label.startsWith(`pin${desiredNumber}_alt`)) {
47
+ existingAltCount += 1;
48
+ }
49
+ }
50
+ result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
51
+ }
52
+ for (let i = 0; i < result.length; i++) {
53
+ const firstLabel = result[i][0];
54
+ if (firstLabel?.includes("_alt")) {
55
+ highestPinNumber += 1;
56
+ result[i].unshift(`pin${highestPinNumber}`);
57
+ }
58
+ }
59
+ for (let i = 0; i < result.length; i++) {
60
+ if (result[i].length === 0) {
61
+ highestPinNumber += 1;
62
+ result[i].push(`pin${highestPinNumber}`);
63
+ }
64
+ }
65
+ const totalLabelCounts = {};
66
+ for (const inputLabels of uniqueInputPinLabels) {
67
+ for (const label of inputLabels) {
68
+ if (/^\d+$/.test(label)) continue;
69
+ totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
70
+ }
71
+ }
72
+ const incrementalLabelCounts = {};
73
+ for (let i = 0; i < uniqueInputPinLabels.length; i++) {
74
+ for (const label of uniqueInputPinLabels[i]) {
75
+ if (/^\d+$/.test(label)) continue;
76
+ if (totalLabelCounts[label] === 1) {
77
+ result[i].push(label);
78
+ } else {
79
+ incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
80
+ result[i].push(`${label}${incrementalLabelCounts[label]}`);
81
+ }
82
+ }
83
+ }
84
+ return result;
85
+ };
86
+
87
+ // lib/utils/normalize-easyeda-pin-label.ts
88
+ var normalizeEasyEdaPinLabel = (label) => {
89
+ if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
90
+ if (/[-–−]$/.test(label)) label = `${label.slice(0, -1)}_NEG`;
91
+ label = normalizeActiveLowPinLabel(label);
92
+ if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
93
+ if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
94
+ if (/^[-–−]/.test(label)) label = `${label.slice(1)}_NEG`;
95
+ return label;
96
+ };
97
+
98
+ // lib/utils/get-easyeda-pin-aliases.ts
99
+ var getEasyEdaPinAliases = (label) => {
100
+ label = label.replace(/&#(x[0-9a-f]+|[0-9]+);/gi, (entity, code) => {
101
+ let codePoint = Number(code);
102
+ if (/^x/i.test(code)) codePoint = Number.parseInt(code.slice(1), 16);
103
+ const maximumUnicodeCodePoint = 1114111;
104
+ if (codePoint > maximumUnicodeCodePoint) return entity;
105
+ return String.fromCodePoint(codePoint);
106
+ });
107
+ if (label.includes("/") && !/[a-zA-Z0-9]/.test(label)) return [];
108
+ return label.split("/").map(
109
+ (alias) => normalizeEasyEdaPinLabel(alias.trim()).replace(/[`′]/g, "_PRIME").replace(/^[()]+|[()]+$/g, "").replace(/[^a-zA-Z0-9_]/g, "_")
110
+ ).filter((alias) => /[a-zA-Z0-9]/.test(alias));
111
+ };
112
+
7
113
  // node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
8
114
  function orientation(p, q, r) {
9
115
  const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
@@ -6744,94 +6850,6 @@ var getPolarizedPinMetadata = (pinLabels) => {
6744
6850
  };
6745
6851
  };
6746
6852
 
6747
- // lib/utils/normalize-pin-labels.ts
6748
- var normalizeActiveLowPinLabel = (label) => {
6749
- const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
6750
- if (!hasActiveLowMarker) return label;
6751
- const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
6752
- if (activeLowLabel.length === 0) return label;
6753
- if (activeLowLabel.startsWith("N_")) return activeLowLabel;
6754
- return `N_${activeLowLabel}`;
6755
- };
6756
- var normalizePinLabels = (inputPinLabels) => {
6757
- const normalizedInputPinLabels = inputPinLabels.map(
6758
- (labels) => labels.map(normalizeActiveLowPinLabel)
6759
- );
6760
- const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
6761
- ...new Set(labels)
6762
- ]);
6763
- const result = uniqueInputPinLabels.map(() => []);
6764
- const desiredNumbers = uniqueInputPinLabels.map(() => null);
6765
- for (let i = 0; i < uniqueInputPinLabels.length; i++) {
6766
- for (const label of uniqueInputPinLabels[i]) {
6767
- if (/^\d+$/.test(label)) {
6768
- desiredNumbers[i] = Number.parseInt(label);
6769
- break;
6770
- }
6771
- }
6772
- }
6773
- let highestPinNumber = 0;
6774
- const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
6775
- for (let i = 0; i < desiredNumbers.length; i++) {
6776
- const desiredNumber = desiredNumbers[i];
6777
- if (desiredNumber === null || desiredNumber < 1) continue;
6778
- if (!acceptedDesiredNumbers.has(desiredNumber)) {
6779
- acceptedDesiredNumbers.add(desiredNumber);
6780
- result[i].push(`pin${desiredNumber}`);
6781
- highestPinNumber = Math.max(highestPinNumber, desiredNumber);
6782
- continue;
6783
- }
6784
- let existingAltCount = 0;
6785
- for (const label of result[i]) {
6786
- if (label.startsWith(`pin${desiredNumber}_alt`)) {
6787
- existingAltCount += 1;
6788
- }
6789
- }
6790
- result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
6791
- }
6792
- for (let i = 0; i < result.length; i++) {
6793
- const firstLabel = result[i][0];
6794
- if (firstLabel?.includes("_alt")) {
6795
- highestPinNumber += 1;
6796
- result[i].unshift(`pin${highestPinNumber}`);
6797
- }
6798
- }
6799
- for (let i = 0; i < result.length; i++) {
6800
- if (result[i].length === 0) {
6801
- highestPinNumber += 1;
6802
- result[i].push(`pin${highestPinNumber}`);
6803
- }
6804
- }
6805
- const totalLabelCounts = {};
6806
- for (const inputLabels of uniqueInputPinLabels) {
6807
- for (const label of inputLabels) {
6808
- if (/^\d+$/.test(label)) continue;
6809
- totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
6810
- }
6811
- }
6812
- const incrementalLabelCounts = {};
6813
- for (let i = 0; i < uniqueInputPinLabels.length; i++) {
6814
- for (const label of uniqueInputPinLabels[i]) {
6815
- if (/^\d+$/.test(label)) continue;
6816
- if (totalLabelCounts[label] === 1) {
6817
- result[i].push(label);
6818
- } else {
6819
- incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
6820
- result[i].push(`${label}${incrementalLabelCounts[label]}`);
6821
- }
6822
- }
6823
- }
6824
- return result;
6825
- };
6826
-
6827
- // lib/utils/normalize-symbol-name.ts
6828
- var normalizeSymbolName = (name) => {
6829
- const trimmedName = name.trim();
6830
- if (trimmedName === "+") return "_POS";
6831
- if (trimmedName === "-") return "_NEG";
6832
- return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
6833
- };
6834
-
6835
6853
  // lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
6836
6854
  var categoryValueContainsDiode = (value) => {
6837
6855
  if (typeof value === "string") {
@@ -7314,11 +7332,13 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
7314
7332
  );
7315
7333
  const pins = easyEdaJson.dataStr.shape.filter((shape) => shape.type === "PIN");
7316
7334
  const pinLabelSets = pads.map((pad) => {
7317
- const labels = [];
7318
- if (pad.number) labels.push(pad.number.toString());
7335
+ const padAliases = pad.number ? getEasyEdaPinAliases(pad.number.toString()) : [];
7319
7336
  const pin = pins.find((p) => p.pinNumber === pad.number);
7320
- if (pin) labels.push(normalizeSymbolName(pin.label));
7321
- return labels;
7337
+ const schematicAliases = pin ? getEasyEdaPinAliases(pin.label) : [];
7338
+ const hasNamedSchematicAlias = schematicAliases.some(
7339
+ (alias) => !/^\d+$/.test(alias)
7340
+ );
7341
+ return hasNamedSchematicAlias ? [...schematicAliases, ...padAliases] : [...padAliases, ...schematicAliases];
7322
7342
  });
7323
7343
  const padNumberKeys = pads.map((pad, index) => {
7324
7344
  const padNumber = String(pad.number ?? "").trim();
@@ -8463,14 +8483,9 @@ var PinShapeOutputSchema = z201.object({
8463
8483
  var parsePin = (pinString) => {
8464
8484
  const parts = pinString.split("~");
8465
8485
  const [, visibility, , pinNumber, x, y, rotation2, id] = parts;
8466
- const nameMatch = pinString.match(/~([\w+#-]+)~(start|end)~/);
8467
- let label = nameMatch ? nameMatch[1] : "";
8468
- if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
8469
- if (label.endsWith("-")) label = `${label.slice(0, -1)}_NEG`;
8470
- label = normalizeActiveLowPinLabel(label);
8471
- if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
8472
- if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
8473
- if (label.startsWith("-")) label = `${label.slice(1)}_NEG`;
8486
+ const pinNameSection = pinString.split("^^")[3];
8487
+ let label = pinNameSection?.split("~")[4] ?? "";
8488
+ if (!label.includes("/")) label = normalizeEasyEdaPinLabel(label);
8474
8489
  const colorMatch = pinString.match(/#[0-9A-F]{6}/);
8475
8490
  const labelColor = colorMatch ? colorMatch[0] : "";
8476
8491
  const path = pinString.split("^^")[2]?.split("~")[0] ?? "";
@@ -8949,6 +8964,14 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
8949
8964
  return placementPromise;
8950
8965
  };
8951
8966
 
8967
+ // lib/utils/normalize-symbol-name.ts
8968
+ var normalizeSymbolName = (name) => {
8969
+ const trimmedName = name.trim();
8970
+ if (trimmedName === "+") return "_POS";
8971
+ if (trimmedName === "-") return "_NEG";
8972
+ return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
8973
+ };
8974
+
8952
8975
  // lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
8953
8976
  var round = (value) => Number(value.toFixed(6));
8954
8977
  var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
@@ -9175,14 +9198,15 @@ var getPortMetadataByShapeId = (easyEdaJson, circuitJson) => {
9175
9198
  portName ??= `pin${pinIndex + 1}`;
9176
9199
  usedPortNames.add(portName);
9177
9200
  const sourcePort = sourcePorts.find((port) => port.name === portName);
9201
+ let aliases = getEasyEdaPinAliases(pin.label);
9202
+ if (sourcePort?.port_hints?.length) {
9203
+ aliases = sourcePort.port_hints;
9204
+ }
9178
9205
  metadataByShapeId.set(pin.id, {
9179
9206
  name: portName,
9180
9207
  pinNumber: sourcePort?.pin_number,
9181
- aliases: [
9182
- ...sourcePort?.port_hints ?? [],
9183
- ...pin.label ? [normalizeSymbolName(pin.label)] : []
9184
- ].filter(
9185
- (alias, index, aliases) => alias !== portName && aliases.indexOf(alias) === index
9208
+ aliases: aliases.filter(
9209
+ (alias, index, aliases2) => alias !== portName && aliases2.indexOf(alias) === index
9186
9210
  )
9187
9211
  });
9188
9212
  });