easyeda 0.0.278 → 0.0.280
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.js +187 -176
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +187 -176
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +188 -177
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -3513,7 +3513,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
3513
3513
|
var package_default = {
|
|
3514
3514
|
name: "easyeda",
|
|
3515
3515
|
type: "module",
|
|
3516
|
-
version: "0.0.
|
|
3516
|
+
version: "0.0.279",
|
|
3517
3517
|
files: [
|
|
3518
3518
|
"dist"
|
|
3519
3519
|
],
|
|
@@ -9200,6 +9200,9 @@ var mil2mm = (mil) => {
|
|
|
9200
9200
|
return mm(mil);
|
|
9201
9201
|
};
|
|
9202
9202
|
|
|
9203
|
+
// lib/constants.ts
|
|
9204
|
+
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
9205
|
+
|
|
9203
9206
|
// lib/math/arc-utils.ts
|
|
9204
9207
|
function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag, sweepFlag) {
|
|
9205
9208
|
const start = { x: startX, y: startY };
|
|
@@ -9248,6 +9251,173 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
9248
9251
|
// lib/utils/easyeda-unit-to-mm.ts
|
|
9249
9252
|
var mil10ToMm = (value) => value * 10 * 0.0254;
|
|
9250
9253
|
|
|
9254
|
+
// lib/utils/get-polarized-pin-metadata.ts
|
|
9255
|
+
var getPinLabelValues = (labels) => {
|
|
9256
|
+
if (typeof labels === "string") return [labels];
|
|
9257
|
+
return [...labels];
|
|
9258
|
+
};
|
|
9259
|
+
var stripEasyEdaPolarityHintDecoration = (label) => label.toLowerCase().replace(/[^a-z0-9+-]/g, "");
|
|
9260
|
+
var getPinKeySortValue = (pinKey) => {
|
|
9261
|
+
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
9262
|
+
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
9263
|
+
};
|
|
9264
|
+
var getPolarizedPinMetadata = (pinLabels) => {
|
|
9265
|
+
const labelsByPin = Object.entries(pinLabels).map(([pin, labels]) => ({
|
|
9266
|
+
pin,
|
|
9267
|
+
labels: getPinLabelValues(labels).map(stripEasyEdaPolarityHintDecoration)
|
|
9268
|
+
}));
|
|
9269
|
+
const anodePin = labelsByPin.find(
|
|
9270
|
+
({ labels }) => labels.some((label) => ["a", "anode", "pos", "+"].includes(label))
|
|
9271
|
+
)?.pin;
|
|
9272
|
+
const cathodePin = labelsByPin.find(
|
|
9273
|
+
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
9274
|
+
)?.pin;
|
|
9275
|
+
if (!anodePin || !cathodePin || anodePin === cathodePin) return void 0;
|
|
9276
|
+
const polarizedPinEntries = [
|
|
9277
|
+
[anodePin, ["anode", "pos"]],
|
|
9278
|
+
[cathodePin, ["cathode", "neg"]]
|
|
9279
|
+
].sort(
|
|
9280
|
+
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
9281
|
+
);
|
|
9282
|
+
return {
|
|
9283
|
+
portHintsMap: Object.fromEntries(
|
|
9284
|
+
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
9285
|
+
),
|
|
9286
|
+
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
9287
|
+
};
|
|
9288
|
+
};
|
|
9289
|
+
|
|
9290
|
+
// lib/utils/normalize-pin-labels.ts
|
|
9291
|
+
var normalizePinLabels = (inputPinLabels) => {
|
|
9292
|
+
const uniqueInputPinLabels = inputPinLabels.map((labels) => [
|
|
9293
|
+
...new Set(labels)
|
|
9294
|
+
]);
|
|
9295
|
+
const result = uniqueInputPinLabels.map(() => []);
|
|
9296
|
+
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
9297
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9298
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
9299
|
+
if (/^\d+$/.test(label)) {
|
|
9300
|
+
desiredNumbers[i] = Number.parseInt(label);
|
|
9301
|
+
break;
|
|
9302
|
+
}
|
|
9303
|
+
}
|
|
9304
|
+
}
|
|
9305
|
+
let highestPinNumber = 0;
|
|
9306
|
+
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
9307
|
+
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
9308
|
+
const desiredNumber = desiredNumbers[i];
|
|
9309
|
+
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
9310
|
+
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
9311
|
+
acceptedDesiredNumbers.add(desiredNumber);
|
|
9312
|
+
result[i].push(`pin${desiredNumber}`);
|
|
9313
|
+
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
9314
|
+
continue;
|
|
9315
|
+
}
|
|
9316
|
+
let existingAltCount = 0;
|
|
9317
|
+
for (const label of result[i]) {
|
|
9318
|
+
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
9319
|
+
existingAltCount += 1;
|
|
9320
|
+
}
|
|
9321
|
+
}
|
|
9322
|
+
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
9323
|
+
}
|
|
9324
|
+
for (let i = 0; i < result.length; i++) {
|
|
9325
|
+
const firstLabel = result[i][0];
|
|
9326
|
+
if (firstLabel?.includes("_alt")) {
|
|
9327
|
+
highestPinNumber += 1;
|
|
9328
|
+
result[i].unshift(`pin${highestPinNumber}`);
|
|
9329
|
+
}
|
|
9330
|
+
}
|
|
9331
|
+
for (let i = 0; i < result.length; i++) {
|
|
9332
|
+
if (result[i].length === 0) {
|
|
9333
|
+
highestPinNumber += 1;
|
|
9334
|
+
result[i].push(`pin${highestPinNumber}`);
|
|
9335
|
+
}
|
|
9336
|
+
}
|
|
9337
|
+
const totalLabelCounts = {};
|
|
9338
|
+
for (const inputLabels of uniqueInputPinLabels) {
|
|
9339
|
+
for (const label of inputLabels) {
|
|
9340
|
+
if (/^\d+$/.test(label)) continue;
|
|
9341
|
+
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
9342
|
+
}
|
|
9343
|
+
}
|
|
9344
|
+
const incrementalLabelCounts = {};
|
|
9345
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9346
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
9347
|
+
if (/^\d+$/.test(label)) continue;
|
|
9348
|
+
if (totalLabelCounts[label] === 1) {
|
|
9349
|
+
result[i].push(label);
|
|
9350
|
+
} else {
|
|
9351
|
+
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
9352
|
+
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
9353
|
+
}
|
|
9354
|
+
}
|
|
9355
|
+
}
|
|
9356
|
+
return result;
|
|
9357
|
+
};
|
|
9358
|
+
|
|
9359
|
+
// lib/utils/normalize-symbol-name.ts
|
|
9360
|
+
var normalizeSymbolName = (name) => {
|
|
9361
|
+
const trimmedName = name.trim();
|
|
9362
|
+
if (trimmedName === "+") return "_POS";
|
|
9363
|
+
if (trimmedName === "-") return "_NEG";
|
|
9364
|
+
return trimmedName;
|
|
9365
|
+
};
|
|
9366
|
+
|
|
9367
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
9368
|
+
var categoryValueContainsDiode = (value) => {
|
|
9369
|
+
if (typeof value === "string") {
|
|
9370
|
+
return /(^|[^a-z])diodes?([^a-z]|$)/i.test(value);
|
|
9371
|
+
}
|
|
9372
|
+
if (Array.isArray(value)) {
|
|
9373
|
+
return value.some(categoryValueContainsDiode);
|
|
9374
|
+
}
|
|
9375
|
+
if (value && typeof value === "object") {
|
|
9376
|
+
return Object.values(value).some(categoryValueContainsDiode);
|
|
9377
|
+
}
|
|
9378
|
+
return false;
|
|
9379
|
+
};
|
|
9380
|
+
|
|
9381
|
+
// lib/websafe/convert-to-typescript-component/is-diode-category-component.ts
|
|
9382
|
+
var isDiodeCategoryComponent = (betterEasy) => {
|
|
9383
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
9384
|
+
return [
|
|
9385
|
+
betterEasy.tags,
|
|
9386
|
+
cPara.category,
|
|
9387
|
+
cPara.Category,
|
|
9388
|
+
cPara["LCSC Category"],
|
|
9389
|
+
cPara["JLCPCB Category"],
|
|
9390
|
+
betterEasy.category
|
|
9391
|
+
].some(categoryValueContainsDiode);
|
|
9392
|
+
};
|
|
9393
|
+
|
|
9394
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
9395
|
+
var categoryValueContainsLed = (value) => {
|
|
9396
|
+
if (typeof value === "string") {
|
|
9397
|
+
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
9398
|
+
}
|
|
9399
|
+
if (Array.isArray(value)) {
|
|
9400
|
+
return value.some(categoryValueContainsLed);
|
|
9401
|
+
}
|
|
9402
|
+
if (value && typeof value === "object") {
|
|
9403
|
+
return Object.values(value).some(categoryValueContainsLed);
|
|
9404
|
+
}
|
|
9405
|
+
return false;
|
|
9406
|
+
};
|
|
9407
|
+
|
|
9408
|
+
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
9409
|
+
var isLedCategoryComponent = (betterEasy) => {
|
|
9410
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
9411
|
+
return [
|
|
9412
|
+
betterEasy.tags,
|
|
9413
|
+
cPara.category,
|
|
9414
|
+
cPara.Category,
|
|
9415
|
+
cPara["LCSC Category"],
|
|
9416
|
+
cPara["JLCPCB Category"],
|
|
9417
|
+
betterEasy.category
|
|
9418
|
+
].some(categoryValueContainsLed);
|
|
9419
|
+
};
|
|
9420
|
+
|
|
9251
9421
|
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
9252
9422
|
var getBoundsCenter = (bounds) => ({
|
|
9253
9423
|
x: (bounds.minX + bounds.maxX) / 2,
|
|
@@ -9384,86 +9554,6 @@ var getCadSvgNodeZOffsetMm = (easyEdaJson) => {
|
|
|
9384
9554
|
};
|
|
9385
9555
|
var getCadSvgNodeModelUuid = (easyEdaJson) => getCadSvgNode(easyEdaJson)?.svgData.attrs?.uuid ?? null;
|
|
9386
9556
|
|
|
9387
|
-
// lib/utils/normalize-pin-labels.ts
|
|
9388
|
-
var normalizePinLabels = (inputPinLabels) => {
|
|
9389
|
-
const uniqueInputPinLabels = inputPinLabels.map((labels) => [
|
|
9390
|
-
...new Set(labels)
|
|
9391
|
-
]);
|
|
9392
|
-
const result = uniqueInputPinLabels.map(() => []);
|
|
9393
|
-
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
9394
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9395
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
9396
|
-
if (/^\d+$/.test(label)) {
|
|
9397
|
-
desiredNumbers[i] = Number.parseInt(label);
|
|
9398
|
-
break;
|
|
9399
|
-
}
|
|
9400
|
-
}
|
|
9401
|
-
}
|
|
9402
|
-
let highestPinNumber = 0;
|
|
9403
|
-
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
9404
|
-
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
9405
|
-
const desiredNumber = desiredNumbers[i];
|
|
9406
|
-
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
9407
|
-
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
9408
|
-
acceptedDesiredNumbers.add(desiredNumber);
|
|
9409
|
-
result[i].push(`pin${desiredNumber}`);
|
|
9410
|
-
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
9411
|
-
continue;
|
|
9412
|
-
}
|
|
9413
|
-
let existingAltCount = 0;
|
|
9414
|
-
for (const label of result[i]) {
|
|
9415
|
-
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
9416
|
-
existingAltCount += 1;
|
|
9417
|
-
}
|
|
9418
|
-
}
|
|
9419
|
-
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
9420
|
-
}
|
|
9421
|
-
for (let i = 0; i < result.length; i++) {
|
|
9422
|
-
const firstLabel = result[i][0];
|
|
9423
|
-
if (firstLabel?.includes("_alt")) {
|
|
9424
|
-
highestPinNumber += 1;
|
|
9425
|
-
result[i].unshift(`pin${highestPinNumber}`);
|
|
9426
|
-
}
|
|
9427
|
-
}
|
|
9428
|
-
for (let i = 0; i < result.length; i++) {
|
|
9429
|
-
if (result[i].length === 0) {
|
|
9430
|
-
highestPinNumber += 1;
|
|
9431
|
-
result[i].push(`pin${highestPinNumber}`);
|
|
9432
|
-
}
|
|
9433
|
-
}
|
|
9434
|
-
const totalLabelCounts = {};
|
|
9435
|
-
for (const inputLabels of uniqueInputPinLabels) {
|
|
9436
|
-
for (const label of inputLabels) {
|
|
9437
|
-
if (/^\d+$/.test(label)) continue;
|
|
9438
|
-
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
9439
|
-
}
|
|
9440
|
-
}
|
|
9441
|
-
const incrementalLabelCounts = {};
|
|
9442
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
9443
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
9444
|
-
if (/^\d+$/.test(label)) continue;
|
|
9445
|
-
if (totalLabelCounts[label] === 1) {
|
|
9446
|
-
result[i].push(label);
|
|
9447
|
-
} else {
|
|
9448
|
-
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
9449
|
-
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
9450
|
-
}
|
|
9451
|
-
}
|
|
9452
|
-
}
|
|
9453
|
-
return result;
|
|
9454
|
-
};
|
|
9455
|
-
|
|
9456
|
-
// lib/utils/normalize-symbol-name.ts
|
|
9457
|
-
var normalizeSymbolName = (name) => {
|
|
9458
|
-
const trimmedName = name.trim();
|
|
9459
|
-
if (trimmedName === "+") return "_POS";
|
|
9460
|
-
if (trimmedName === "-") return "_NEG";
|
|
9461
|
-
return trimmedName;
|
|
9462
|
-
};
|
|
9463
|
-
|
|
9464
|
-
// lib/constants.ts
|
|
9465
|
-
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
9466
|
-
|
|
9467
9557
|
// lib/convert-easyeda-json-to-tscircuit-soup-json.ts
|
|
9468
9558
|
var EASYEDA_STEP_MODEL_URL = "https://modules.easyeda.com/qAxj6KHrDKw4blvCG8QJPs7Y";
|
|
9469
9559
|
var EASYEDA_OBJ_MODEL_URL = "https://modules.easyeda.com/3dmodel";
|
|
@@ -9669,11 +9759,20 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9669
9759
|
return labels;
|
|
9670
9760
|
});
|
|
9671
9761
|
const normalizedPinLabels = normalizePinLabels(pinLabelSets);
|
|
9762
|
+
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
9763
|
+
normalizedPinLabels.map((labels) => {
|
|
9764
|
+
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
9765
|
+
return [pin, labels.filter((label) => label !== pin)];
|
|
9766
|
+
})
|
|
9767
|
+
);
|
|
9768
|
+
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
9672
9769
|
pads.forEach((pad, index) => {
|
|
9673
9770
|
const portHints = normalizedPinLabels[index];
|
|
9674
9771
|
const pinNumber = Number.parseInt(
|
|
9675
9772
|
portHints.find((hint) => hint.match(/pin\d+/)).replace("pin", "")
|
|
9676
9773
|
);
|
|
9774
|
+
const canonicalPinName = `pin${pinNumber}`;
|
|
9775
|
+
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
9677
9776
|
circuitElements.push({
|
|
9678
9777
|
type: "source_port",
|
|
9679
9778
|
source_port_id: `source_port_${index + 1}`,
|
|
@@ -9690,7 +9789,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9690
9789
|
x: mil2mm(pad.center.x),
|
|
9691
9790
|
y: mil2mm(pad.center.y),
|
|
9692
9791
|
layers: ["top"],
|
|
9693
|
-
port_hints:
|
|
9792
|
+
port_hints: pcbPortHints,
|
|
9694
9793
|
pcb_component_id: "pcb_component_1",
|
|
9695
9794
|
pcb_port_id: `pcb_port_${index + 1}`
|
|
9696
9795
|
};
|
|
@@ -9802,7 +9901,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9802
9901
|
radius: Math.min(mil2mm(pad.width), mil2mm(pad.height)) / 2
|
|
9803
9902
|
},
|
|
9804
9903
|
layer: "top",
|
|
9805
|
-
port_hints:
|
|
9904
|
+
port_hints: pcbPortHints,
|
|
9806
9905
|
pcb_component_id: "pcb_component_1",
|
|
9807
9906
|
pcb_port_id: `pcb_port_${index + 1}`
|
|
9808
9907
|
});
|
|
@@ -10940,7 +11039,7 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
|
|
|
10940
11039
|
// lib/websafe/generate-footprint-tsx.ts
|
|
10941
11040
|
var mapPortHints = (portHints, portHintsMap) => {
|
|
10942
11041
|
if (!portHintsMap || !portHints) return portHints;
|
|
10943
|
-
return portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]);
|
|
11042
|
+
return [...new Set(portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]))];
|
|
10944
11043
|
};
|
|
10945
11044
|
var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
10946
11045
|
const holes = su(circuitJson).pcb_hole.list();
|
|
@@ -11034,40 +11133,6 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
11034
11133
|
};
|
|
11035
11134
|
|
|
11036
11135
|
// lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
|
|
11037
|
-
var getPinLabelValues = (labels) => {
|
|
11038
|
-
if (typeof labels === "string") return [labels];
|
|
11039
|
-
return [...labels];
|
|
11040
|
-
};
|
|
11041
|
-
var stripEasyEdaPolarityHintDecoration = (label) => label.toLowerCase().replace(/[^a-z0-9+-]/g, "");
|
|
11042
|
-
var getPinKeySortValue = (pinKey) => {
|
|
11043
|
-
const match = /^pin(\d+)$/i.exec(pinKey);
|
|
11044
|
-
return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
|
|
11045
|
-
};
|
|
11046
|
-
var getPolarizedPinMetadata = (pinLabels) => {
|
|
11047
|
-
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
11048
|
-
pin,
|
|
11049
|
-
labels: getPinLabelValues(labels).map(stripEasyEdaPolarityHintDecoration)
|
|
11050
|
-
}));
|
|
11051
|
-
const anodePin = labelsByPin.find(
|
|
11052
|
-
({ labels }) => labels.some((label) => ["a", "anode", "pos", "+"].includes(label))
|
|
11053
|
-
)?.pin;
|
|
11054
|
-
const cathodePin = labelsByPin.find(
|
|
11055
|
-
({ labels }) => labels.some((label) => ["c", "k", "cathode", "neg", "-"].includes(label))
|
|
11056
|
-
)?.pin;
|
|
11057
|
-
if (!anodePin || !cathodePin) return void 0;
|
|
11058
|
-
const polarizedPinEntries = [
|
|
11059
|
-
[anodePin, ["anode", "pos"]],
|
|
11060
|
-
[cathodePin, ["cathode", "neg"]]
|
|
11061
|
-
].sort(
|
|
11062
|
-
([pinA], [pinB]) => getPinKeySortValue(pinA) - getPinKeySortValue(pinB)
|
|
11063
|
-
);
|
|
11064
|
-
return {
|
|
11065
|
-
portHintsMap: Object.fromEntries(
|
|
11066
|
-
polarizedPinEntries.map(([pin, labels]) => [pin, [pin, ...labels]])
|
|
11067
|
-
),
|
|
11068
|
-
pinLabels: Object.fromEntries(polarizedPinEntries)
|
|
11069
|
-
};
|
|
11070
|
-
};
|
|
11071
11136
|
var generateTypescriptComponent = ({
|
|
11072
11137
|
pinLabels,
|
|
11073
11138
|
componentName,
|
|
@@ -11237,60 +11302,6 @@ ${cadModelLines}
|
|
|
11237
11302
|
`.trim();
|
|
11238
11303
|
};
|
|
11239
11304
|
|
|
11240
|
-
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
11241
|
-
var categoryValueContainsDiode = (value) => {
|
|
11242
|
-
if (typeof value === "string") {
|
|
11243
|
-
return /(^|[^a-z])diodes?([^a-z]|$)/i.test(value);
|
|
11244
|
-
}
|
|
11245
|
-
if (Array.isArray(value)) {
|
|
11246
|
-
return value.some(categoryValueContainsDiode);
|
|
11247
|
-
}
|
|
11248
|
-
if (value && typeof value === "object") {
|
|
11249
|
-
return Object.values(value).some(categoryValueContainsDiode);
|
|
11250
|
-
}
|
|
11251
|
-
return false;
|
|
11252
|
-
};
|
|
11253
|
-
|
|
11254
|
-
// lib/websafe/convert-to-typescript-component/is-diode-category-component.ts
|
|
11255
|
-
var isDiodeCategoryComponent = (betterEasy) => {
|
|
11256
|
-
const cPara = betterEasy.dataStr.head.c_para;
|
|
11257
|
-
return [
|
|
11258
|
-
betterEasy.tags,
|
|
11259
|
-
cPara.category,
|
|
11260
|
-
cPara.Category,
|
|
11261
|
-
cPara["LCSC Category"],
|
|
11262
|
-
cPara["JLCPCB Category"],
|
|
11263
|
-
betterEasy.category
|
|
11264
|
-
].some(categoryValueContainsDiode);
|
|
11265
|
-
};
|
|
11266
|
-
|
|
11267
|
-
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
11268
|
-
var categoryValueContainsLed = (value) => {
|
|
11269
|
-
if (typeof value === "string") {
|
|
11270
|
-
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
11271
|
-
}
|
|
11272
|
-
if (Array.isArray(value)) {
|
|
11273
|
-
return value.some(categoryValueContainsLed);
|
|
11274
|
-
}
|
|
11275
|
-
if (value && typeof value === "object") {
|
|
11276
|
-
return Object.values(value).some(categoryValueContainsLed);
|
|
11277
|
-
}
|
|
11278
|
-
return false;
|
|
11279
|
-
};
|
|
11280
|
-
|
|
11281
|
-
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
11282
|
-
var isLedCategoryComponent = (betterEasy) => {
|
|
11283
|
-
const cPara = betterEasy.dataStr.head.c_para;
|
|
11284
|
-
return [
|
|
11285
|
-
betterEasy.tags,
|
|
11286
|
-
cPara.category,
|
|
11287
|
-
cPara.Category,
|
|
11288
|
-
cPara["LCSC Category"],
|
|
11289
|
-
cPara["JLCPCB Category"],
|
|
11290
|
-
betterEasy.category
|
|
11291
|
-
].some(categoryValueContainsLed);
|
|
11292
|
-
};
|
|
11293
|
-
|
|
11294
11305
|
// lib/websafe/convert-to-typescript-component/category-value-contains-pushbutton.ts
|
|
11295
11306
|
var categoryValueContainsPushbutton = (value) => {
|
|
11296
11307
|
if (typeof value === "string") {
|
|
@@ -11574,27 +11585,27 @@ var generateShapeTsx = ({
|
|
|
11574
11585
|
x: shape.position.x + shape.width / 2,
|
|
11575
11586
|
y: shape.position.y + shape.height / 2
|
|
11576
11587
|
});
|
|
11577
|
-
return `<schematicrect schX={${center.x}} schY={${center.y}} width={${toMillimeters(shape.width)}} height={${toMillimeters(shape.height)}}
|
|
11588
|
+
return `<schematicrect schX={${center.x}} schY={${center.y}} width={${toMillimeters(shape.width)}} height={${toMillimeters(shape.height)}} color=${JSON.stringify(shape.color)}${shape.fillColor && shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
11578
11589
|
}
|
|
11579
11590
|
if (shape.type === "ELLIPSE") {
|
|
11580
11591
|
const center = transformPoint(shape.center);
|
|
11581
|
-
return `<schematiccircle center={{ x: ${center.x}, y: ${center.y} }} radius={${toMillimeters(Math.max(shape.radiusX, shape.radiusY))}}
|
|
11592
|
+
return `<schematiccircle center={{ x: ${center.x}, y: ${center.y} }} radius={${toMillimeters(Math.max(shape.radiusX, shape.radiusY))}} color=${JSON.stringify(shape.color)}${shape.fillColor && shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
11582
11593
|
}
|
|
11583
11594
|
if (shape.type === "POLYLINE" || shape.type === "POLYGON") {
|
|
11584
11595
|
const isPolygon = shape.type === "POLYGON";
|
|
11585
11596
|
const points = shape.points.map(transformPoint);
|
|
11586
11597
|
if (isPolygon && points.length > 0) points.push(points[0]);
|
|
11587
|
-
return `<schematicpath points={${JSON.stringify(points)}}
|
|
11598
|
+
return `<schematicpath points={${JSON.stringify(points)}} strokeColor=${JSON.stringify(isPolygon ? shape.lineColor : shape.color)}${isPolygon && shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
11588
11599
|
}
|
|
11589
11600
|
if (shape.type === "PATH") {
|
|
11590
11601
|
const transformedPath = transformSvgPath(shape.pathData, origin);
|
|
11591
11602
|
if (!transformedPath) return void 0;
|
|
11592
|
-
return `<schematicpath svgPath=${JSON.stringify(transformedPath)}
|
|
11603
|
+
return `<schematicpath svgPath=${JSON.stringify(transformedPath)} strokeColor=${JSON.stringify(shape.strokeColor)}${shape.fillColor !== "none" ? ` isFilled fillColor=${JSON.stringify(shape.fillColor)}` : ""} />`;
|
|
11593
11604
|
}
|
|
11594
11605
|
if (shape.type === "ARC") {
|
|
11595
11606
|
const transformedPath = transformSvgPath(shape.pathData, origin);
|
|
11596
11607
|
if (!transformedPath) return void 0;
|
|
11597
|
-
return `<schematicpath svgPath=${JSON.stringify(transformedPath)}
|
|
11608
|
+
return `<schematicpath svgPath=${JSON.stringify(transformedPath)} strokeColor=${JSON.stringify(shape.color)} />`;
|
|
11598
11609
|
}
|
|
11599
11610
|
if (shape.type === "TEXT") {
|
|
11600
11611
|
if (shape.visibility !== "1") return void 0;
|