easyeda 0.0.358 → 0.0.359
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/browser/index.d.ts +10 -10
- package/dist/browser/index.js +125 -103
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +125 -103
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +126 -104
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1078,7 +1078,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
1078
1078
|
var package_default = {
|
|
1079
1079
|
name: "easyeda",
|
|
1080
1080
|
type: "module",
|
|
1081
|
-
version: "0.0.
|
|
1081
|
+
version: "0.0.358",
|
|
1082
1082
|
files: [
|
|
1083
1083
|
"dist"
|
|
1084
1084
|
],
|
|
@@ -1135,6 +1135,112 @@ var package_default = {
|
|
|
1135
1135
|
types: "./dist/index.d.ts"
|
|
1136
1136
|
};
|
|
1137
1137
|
|
|
1138
|
+
// lib/utils/normalize-pin-labels.ts
|
|
1139
|
+
var normalizeActiveLowPinLabel = (label) => {
|
|
1140
|
+
const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
|
|
1141
|
+
if (!hasActiveLowMarker) return label;
|
|
1142
|
+
const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
|
|
1143
|
+
if (activeLowLabel.length === 0) return label;
|
|
1144
|
+
if (activeLowLabel.startsWith("N_")) return activeLowLabel;
|
|
1145
|
+
return `N_${activeLowLabel}`;
|
|
1146
|
+
};
|
|
1147
|
+
var normalizePinLabels = (inputPinLabels) => {
|
|
1148
|
+
const normalizedInputPinLabels = inputPinLabels.map(
|
|
1149
|
+
(labels) => labels.map(normalizeActiveLowPinLabel)
|
|
1150
|
+
);
|
|
1151
|
+
const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
|
|
1152
|
+
...new Set(labels)
|
|
1153
|
+
]);
|
|
1154
|
+
const result = uniqueInputPinLabels.map(() => []);
|
|
1155
|
+
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
1156
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
1157
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
1158
|
+
if (/^\d+$/.test(label)) {
|
|
1159
|
+
desiredNumbers[i] = Number.parseInt(label);
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
let highestPinNumber = 0;
|
|
1165
|
+
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
1166
|
+
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
1167
|
+
const desiredNumber = desiredNumbers[i];
|
|
1168
|
+
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
1169
|
+
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
1170
|
+
acceptedDesiredNumbers.add(desiredNumber);
|
|
1171
|
+
result[i].push(`pin${desiredNumber}`);
|
|
1172
|
+
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1175
|
+
let existingAltCount = 0;
|
|
1176
|
+
for (const label of result[i]) {
|
|
1177
|
+
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
1178
|
+
existingAltCount += 1;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
1182
|
+
}
|
|
1183
|
+
for (let i = 0; i < result.length; i++) {
|
|
1184
|
+
const firstLabel = result[i][0];
|
|
1185
|
+
if (firstLabel?.includes("_alt")) {
|
|
1186
|
+
highestPinNumber += 1;
|
|
1187
|
+
result[i].unshift(`pin${highestPinNumber}`);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
for (let i = 0; i < result.length; i++) {
|
|
1191
|
+
if (result[i].length === 0) {
|
|
1192
|
+
highestPinNumber += 1;
|
|
1193
|
+
result[i].push(`pin${highestPinNumber}`);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
const totalLabelCounts = {};
|
|
1197
|
+
for (const inputLabels of uniqueInputPinLabels) {
|
|
1198
|
+
for (const label of inputLabels) {
|
|
1199
|
+
if (/^\d+$/.test(label)) continue;
|
|
1200
|
+
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
const incrementalLabelCounts = {};
|
|
1204
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
1205
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
1206
|
+
if (/^\d+$/.test(label)) continue;
|
|
1207
|
+
if (totalLabelCounts[label] === 1) {
|
|
1208
|
+
result[i].push(label);
|
|
1209
|
+
} else {
|
|
1210
|
+
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
1211
|
+
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
return result;
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
// lib/utils/normalize-easyeda-pin-label.ts
|
|
1219
|
+
var normalizeEasyEdaPinLabel = (label) => {
|
|
1220
|
+
if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
|
|
1221
|
+
if (/[-–−]$/.test(label)) label = `${label.slice(0, -1)}_NEG`;
|
|
1222
|
+
label = normalizeActiveLowPinLabel(label);
|
|
1223
|
+
if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
|
|
1224
|
+
if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
|
|
1225
|
+
if (/^[-–−]/.test(label)) label = `${label.slice(1)}_NEG`;
|
|
1226
|
+
return label;
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
// lib/utils/get-easyeda-pin-aliases.ts
|
|
1230
|
+
var getEasyEdaPinAliases = (label) => {
|
|
1231
|
+
label = label.replace(/&#(x[0-9a-f]+|[0-9]+);/gi, (entity, code) => {
|
|
1232
|
+
let codePoint = Number(code);
|
|
1233
|
+
if (/^x/i.test(code)) codePoint = Number.parseInt(code.slice(1), 16);
|
|
1234
|
+
const maximumUnicodeCodePoint = 1114111;
|
|
1235
|
+
if (codePoint > maximumUnicodeCodePoint) return entity;
|
|
1236
|
+
return String.fromCodePoint(codePoint);
|
|
1237
|
+
});
|
|
1238
|
+
if (label.includes("/") && !/[a-zA-Z0-9]/.test(label)) return [];
|
|
1239
|
+
return label.split("/").map(
|
|
1240
|
+
(alias) => normalizeEasyEdaPinLabel(alias.trim()).replace(/[`′]/g, "_PRIME").replace(/^[()]+|[()]+$/g, "").replace(/[^a-zA-Z0-9_]/g, "_")
|
|
1241
|
+
).filter((alias) => /[a-zA-Z0-9]/.test(alias));
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1138
1244
|
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
1139
1245
|
function orientation(p, q, r) {
|
|
1140
1246
|
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
@@ -7875,94 +7981,6 @@ var getPolarizedPinMetadata = (pinLabels) => {
|
|
|
7875
7981
|
};
|
|
7876
7982
|
};
|
|
7877
7983
|
|
|
7878
|
-
// lib/utils/normalize-pin-labels.ts
|
|
7879
|
-
var normalizeActiveLowPinLabel = (label) => {
|
|
7880
|
-
const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
|
|
7881
|
-
if (!hasActiveLowMarker) return label;
|
|
7882
|
-
const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
|
|
7883
|
-
if (activeLowLabel.length === 0) return label;
|
|
7884
|
-
if (activeLowLabel.startsWith("N_")) return activeLowLabel;
|
|
7885
|
-
return `N_${activeLowLabel}`;
|
|
7886
|
-
};
|
|
7887
|
-
var normalizePinLabels = (inputPinLabels) => {
|
|
7888
|
-
const normalizedInputPinLabels = inputPinLabels.map(
|
|
7889
|
-
(labels) => labels.map(normalizeActiveLowPinLabel)
|
|
7890
|
-
);
|
|
7891
|
-
const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
|
|
7892
|
-
...new Set(labels)
|
|
7893
|
-
]);
|
|
7894
|
-
const result = uniqueInputPinLabels.map(() => []);
|
|
7895
|
-
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
7896
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
7897
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
7898
|
-
if (/^\d+$/.test(label)) {
|
|
7899
|
-
desiredNumbers[i] = Number.parseInt(label);
|
|
7900
|
-
break;
|
|
7901
|
-
}
|
|
7902
|
-
}
|
|
7903
|
-
}
|
|
7904
|
-
let highestPinNumber = 0;
|
|
7905
|
-
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
7906
|
-
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
7907
|
-
const desiredNumber = desiredNumbers[i];
|
|
7908
|
-
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
7909
|
-
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
7910
|
-
acceptedDesiredNumbers.add(desiredNumber);
|
|
7911
|
-
result[i].push(`pin${desiredNumber}`);
|
|
7912
|
-
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
7913
|
-
continue;
|
|
7914
|
-
}
|
|
7915
|
-
let existingAltCount = 0;
|
|
7916
|
-
for (const label of result[i]) {
|
|
7917
|
-
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
7918
|
-
existingAltCount += 1;
|
|
7919
|
-
}
|
|
7920
|
-
}
|
|
7921
|
-
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
7922
|
-
}
|
|
7923
|
-
for (let i = 0; i < result.length; i++) {
|
|
7924
|
-
const firstLabel = result[i][0];
|
|
7925
|
-
if (firstLabel?.includes("_alt")) {
|
|
7926
|
-
highestPinNumber += 1;
|
|
7927
|
-
result[i].unshift(`pin${highestPinNumber}`);
|
|
7928
|
-
}
|
|
7929
|
-
}
|
|
7930
|
-
for (let i = 0; i < result.length; i++) {
|
|
7931
|
-
if (result[i].length === 0) {
|
|
7932
|
-
highestPinNumber += 1;
|
|
7933
|
-
result[i].push(`pin${highestPinNumber}`);
|
|
7934
|
-
}
|
|
7935
|
-
}
|
|
7936
|
-
const totalLabelCounts = {};
|
|
7937
|
-
for (const inputLabels of uniqueInputPinLabels) {
|
|
7938
|
-
for (const label of inputLabels) {
|
|
7939
|
-
if (/^\d+$/.test(label)) continue;
|
|
7940
|
-
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
7941
|
-
}
|
|
7942
|
-
}
|
|
7943
|
-
const incrementalLabelCounts = {};
|
|
7944
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
7945
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
7946
|
-
if (/^\d+$/.test(label)) continue;
|
|
7947
|
-
if (totalLabelCounts[label] === 1) {
|
|
7948
|
-
result[i].push(label);
|
|
7949
|
-
} else {
|
|
7950
|
-
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
7951
|
-
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
7952
|
-
}
|
|
7953
|
-
}
|
|
7954
|
-
}
|
|
7955
|
-
return result;
|
|
7956
|
-
};
|
|
7957
|
-
|
|
7958
|
-
// lib/utils/normalize-symbol-name.ts
|
|
7959
|
-
var normalizeSymbolName = (name) => {
|
|
7960
|
-
const trimmedName = name.trim();
|
|
7961
|
-
if (trimmedName === "+") return "_POS";
|
|
7962
|
-
if (trimmedName === "-") return "_NEG";
|
|
7963
|
-
return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
|
|
7964
|
-
};
|
|
7965
|
-
|
|
7966
7984
|
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
7967
7985
|
var categoryValueContainsDiode = (value) => {
|
|
7968
7986
|
if (typeof value === "string") {
|
|
@@ -8446,9 +8464,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
8446
8464
|
const pins = easyEdaJson.dataStr.shape.filter((shape) => shape.type === "PIN");
|
|
8447
8465
|
const pinLabelSets = pads.map((pad) => {
|
|
8448
8466
|
const labels = [];
|
|
8449
|
-
if (pad.number) labels.push(pad.number.toString());
|
|
8467
|
+
if (pad.number) labels.push(...getEasyEdaPinAliases(pad.number.toString()));
|
|
8450
8468
|
const pin = pins.find((p) => p.pinNumber === pad.number);
|
|
8451
|
-
if (pin) labels.push(
|
|
8469
|
+
if (pin) labels.push(...getEasyEdaPinAliases(pin.label));
|
|
8452
8470
|
return labels;
|
|
8453
8471
|
});
|
|
8454
8472
|
const padNumberKeys = pads.map((pad, index) => {
|
|
@@ -9368,14 +9386,9 @@ var PinShapeOutputSchema = import_zod201.z.object({
|
|
|
9368
9386
|
var parsePin = (pinString) => {
|
|
9369
9387
|
const parts = pinString.split("~");
|
|
9370
9388
|
const [, visibility, , pinNumber, x, y, rotation2, id] = parts;
|
|
9371
|
-
const
|
|
9372
|
-
let label =
|
|
9373
|
-
if (label.
|
|
9374
|
-
if (label.endsWith("-")) label = `${label.slice(0, -1)}_NEG`;
|
|
9375
|
-
label = normalizeActiveLowPinLabel(label);
|
|
9376
|
-
if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
|
|
9377
|
-
if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
|
|
9378
|
-
if (label.startsWith("-")) label = `${label.slice(1)}_NEG`;
|
|
9389
|
+
const pinNameSection = pinString.split("^^")[3];
|
|
9390
|
+
let label = pinNameSection?.split("~")[4] ?? "";
|
|
9391
|
+
if (!label.includes("/")) label = normalizeEasyEdaPinLabel(label);
|
|
9379
9392
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
9380
9393
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
9381
9394
|
const path = pinString.split("^^")[2]?.split("~")[0] ?? "";
|
|
@@ -9854,6 +9867,14 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
|
|
|
9854
9867
|
return placementPromise;
|
|
9855
9868
|
};
|
|
9856
9869
|
|
|
9870
|
+
// lib/utils/normalize-symbol-name.ts
|
|
9871
|
+
var normalizeSymbolName = (name) => {
|
|
9872
|
+
const trimmedName = name.trim();
|
|
9873
|
+
if (trimmedName === "+") return "_POS";
|
|
9874
|
+
if (trimmedName === "-") return "_NEG";
|
|
9875
|
+
return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
|
|
9876
|
+
};
|
|
9877
|
+
|
|
9857
9878
|
// lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
|
|
9858
9879
|
var round = (value) => Number(value.toFixed(6));
|
|
9859
9880
|
var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
|
|
@@ -10080,14 +10101,15 @@ var getPortMetadataByShapeId = (easyEdaJson, circuitJson) => {
|
|
|
10080
10101
|
portName ??= `pin${pinIndex + 1}`;
|
|
10081
10102
|
usedPortNames.add(portName);
|
|
10082
10103
|
const sourcePort = sourcePorts.find((port) => port.name === portName);
|
|
10104
|
+
let aliases = getEasyEdaPinAliases(pin.label);
|
|
10105
|
+
if (sourcePort?.port_hints?.length) {
|
|
10106
|
+
aliases = sourcePort.port_hints;
|
|
10107
|
+
}
|
|
10083
10108
|
metadataByShapeId.set(pin.id, {
|
|
10084
10109
|
name: portName,
|
|
10085
10110
|
pinNumber: sourcePort?.pin_number,
|
|
10086
|
-
aliases:
|
|
10087
|
-
|
|
10088
|
-
...pin.label ? [normalizeSymbolName(pin.label)] : []
|
|
10089
|
-
].filter(
|
|
10090
|
-
(alias, index, aliases) => alias !== portName && aliases.indexOf(alias) === index
|
|
10111
|
+
aliases: aliases.filter(
|
|
10112
|
+
(alias, index, aliases2) => alias !== portName && aliases2.indexOf(alias) === index
|
|
10091
10113
|
)
|
|
10092
10114
|
});
|
|
10093
10115
|
});
|