easyeda 0.0.355 → 0.0.357
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 +156 -50
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +310 -204
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +311 -205
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -10063,6 +10063,121 @@ var PIN1_LOCATION_PARTS = {
|
|
|
10063
10063
|
};
|
|
10064
10064
|
var PIN1_LOCATIONS = Object.keys(PIN1_LOCATION_PARTS);
|
|
10065
10065
|
|
|
10066
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
10067
|
+
function orientation(p, q, r) {
|
|
10068
|
+
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
10069
|
+
if (val === 0) return 0;
|
|
10070
|
+
return val > 0 ? 1 : 2;
|
|
10071
|
+
}
|
|
10072
|
+
function distance2(p1, p2) {
|
|
10073
|
+
const dx = p1.x - p2.x;
|
|
10074
|
+
const dy = p1.y - p2.y;
|
|
10075
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
10076
|
+
}
|
|
10077
|
+
|
|
10078
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
10079
|
+
var getUnitVectorFromDirection = (direction) => {
|
|
10080
|
+
switch (direction) {
|
|
10081
|
+
case "up":
|
|
10082
|
+
return { x: 0, y: 1 };
|
|
10083
|
+
case "down":
|
|
10084
|
+
return { x: 0, y: -1 };
|
|
10085
|
+
case "left":
|
|
10086
|
+
return { x: -1, y: 0 };
|
|
10087
|
+
case "right":
|
|
10088
|
+
return { x: 1, y: 0 };
|
|
10089
|
+
}
|
|
10090
|
+
};
|
|
10091
|
+
|
|
10092
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
10093
|
+
var getBoundsCenter = (bounds) => ({
|
|
10094
|
+
x: (bounds.minX + bounds.maxX) / 2,
|
|
10095
|
+
y: (bounds.minY + bounds.maxY) / 2
|
|
10096
|
+
});
|
|
10097
|
+
|
|
10098
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
10099
|
+
var getBoundsFromPoints = (points) => {
|
|
10100
|
+
if (points.length === 0) {
|
|
10101
|
+
return null;
|
|
10102
|
+
}
|
|
10103
|
+
let minX = points[0].x;
|
|
10104
|
+
let minY = points[0].y;
|
|
10105
|
+
let maxX = points[0].x;
|
|
10106
|
+
let maxY = points[0].y;
|
|
10107
|
+
for (let i = 1; i < points.length; i++) {
|
|
10108
|
+
const point2 = points[i];
|
|
10109
|
+
if (point2.x < minX) minX = point2.x;
|
|
10110
|
+
if (point2.y < minY) minY = point2.y;
|
|
10111
|
+
if (point2.x > maxX) maxX = point2.x;
|
|
10112
|
+
if (point2.y > maxY) maxY = point2.y;
|
|
10113
|
+
}
|
|
10114
|
+
return { minX, minY, maxX, maxY };
|
|
10115
|
+
};
|
|
10116
|
+
|
|
10117
|
+
// lib/utils/get-board-outline-polygons.ts
|
|
10118
|
+
var same = (a, b) => distance2(a, b) < 1e-4;
|
|
10119
|
+
var getBoardOutlinePolygons = (tracks) => {
|
|
10120
|
+
const remainingEdges = tracks.flatMap(
|
|
10121
|
+
(track) => track.points.slice(1).map((point2, i) => [track.points[i], point2])
|
|
10122
|
+
).filter(([a, b]) => !same(a, b));
|
|
10123
|
+
const polygons = [];
|
|
10124
|
+
while (remainingEdges.length) {
|
|
10125
|
+
const edges = [remainingEdges.shift()];
|
|
10126
|
+
while (true) {
|
|
10127
|
+
const index = remainingEdges.findIndex(
|
|
10128
|
+
(edge) => edge.some((p) => edges.flat().some((q) => same(p, q)))
|
|
10129
|
+
);
|
|
10130
|
+
if (index === -1) break;
|
|
10131
|
+
edges.push(remainingEdges.splice(index, 1)[0]);
|
|
10132
|
+
}
|
|
10133
|
+
const endpoints = edges.flat();
|
|
10134
|
+
if (endpoints.some((p) => endpoints.filter((q) => same(p, q)).length > 2))
|
|
10135
|
+
continue;
|
|
10136
|
+
const route = edges.shift();
|
|
10137
|
+
let changed = true;
|
|
10138
|
+
while (changed) {
|
|
10139
|
+
changed = false;
|
|
10140
|
+
for (let i = 0; i < edges.length; i++) {
|
|
10141
|
+
const [a, b] = edges[i];
|
|
10142
|
+
if (same(route.at(-1), a)) route.push(b);
|
|
10143
|
+
else if (same(route.at(-1), b)) route.push(a);
|
|
10144
|
+
else if (same(route[0], b)) route.unshift(a);
|
|
10145
|
+
else if (same(route[0], a)) route.unshift(b);
|
|
10146
|
+
else continue;
|
|
10147
|
+
edges.splice(i, 1);
|
|
10148
|
+
changed = true;
|
|
10149
|
+
break;
|
|
10150
|
+
}
|
|
10151
|
+
}
|
|
10152
|
+
if (same(route[0], route.at(-1))) route.pop();
|
|
10153
|
+
else {
|
|
10154
|
+
const first = route[0];
|
|
10155
|
+
const last = route.at(-1);
|
|
10156
|
+
if (Math.abs(first.x - last.x) > 1e-4 && Math.abs(first.y - last.y) > 1e-4)
|
|
10157
|
+
continue;
|
|
10158
|
+
}
|
|
10159
|
+
if (route.some((p, i) => route.slice(i + 1).some((q) => same(p, q))))
|
|
10160
|
+
continue;
|
|
10161
|
+
while (route.length > 2) {
|
|
10162
|
+
const index = route.findIndex(
|
|
10163
|
+
(p, i) => orientation(
|
|
10164
|
+
route[(i + route.length - 1) % route.length],
|
|
10165
|
+
p,
|
|
10166
|
+
route[(i + 1) % route.length]
|
|
10167
|
+
) === 0
|
|
10168
|
+
);
|
|
10169
|
+
if (index === -1) break;
|
|
10170
|
+
route.splice(index, 1);
|
|
10171
|
+
}
|
|
10172
|
+
const area = route.reduce((sum, p, i) => {
|
|
10173
|
+
const q = route[(i + 1) % route.length];
|
|
10174
|
+
return sum + p.x * q.y - q.x * p.y;
|
|
10175
|
+
}, 0);
|
|
10176
|
+
if (route.length >= 3 && Math.abs(area) > 1e-8) polygons.push(route);
|
|
10177
|
+
}
|
|
10178
|
+
return polygons;
|
|
10179
|
+
};
|
|
10180
|
+
|
|
10066
10181
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
10067
10182
|
var unitToMm = {
|
|
10068
10183
|
in: 25.4,
|
|
@@ -10396,52 +10511,6 @@ var isLedCategoryComponent = (betterEasy) => {
|
|
|
10396
10511
|
].some(categoryValueContainsLed);
|
|
10397
10512
|
};
|
|
10398
10513
|
|
|
10399
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
10400
|
-
function distance2(p1, p2) {
|
|
10401
|
-
const dx = p1.x - p2.x;
|
|
10402
|
-
const dy = p1.y - p2.y;
|
|
10403
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
10404
|
-
}
|
|
10405
|
-
|
|
10406
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
10407
|
-
var getUnitVectorFromDirection = (direction) => {
|
|
10408
|
-
switch (direction) {
|
|
10409
|
-
case "up":
|
|
10410
|
-
return { x: 0, y: 1 };
|
|
10411
|
-
case "down":
|
|
10412
|
-
return { x: 0, y: -1 };
|
|
10413
|
-
case "left":
|
|
10414
|
-
return { x: -1, y: 0 };
|
|
10415
|
-
case "right":
|
|
10416
|
-
return { x: 1, y: 0 };
|
|
10417
|
-
}
|
|
10418
|
-
};
|
|
10419
|
-
|
|
10420
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
10421
|
-
var getBoundsCenter = (bounds) => ({
|
|
10422
|
-
x: (bounds.minX + bounds.maxX) / 2,
|
|
10423
|
-
y: (bounds.minY + bounds.maxY) / 2
|
|
10424
|
-
});
|
|
10425
|
-
|
|
10426
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
10427
|
-
var getBoundsFromPoints = (points) => {
|
|
10428
|
-
if (points.length === 0) {
|
|
10429
|
-
return null;
|
|
10430
|
-
}
|
|
10431
|
-
let minX = points[0].x;
|
|
10432
|
-
let minY = points[0].y;
|
|
10433
|
-
let maxX = points[0].x;
|
|
10434
|
-
let maxY = points[0].y;
|
|
10435
|
-
for (let i = 1; i < points.length; i++) {
|
|
10436
|
-
const point2 = points[i];
|
|
10437
|
-
if (point2.x < minX) minX = point2.x;
|
|
10438
|
-
if (point2.y < minY) minY = point2.y;
|
|
10439
|
-
if (point2.x > maxX) maxX = point2.x;
|
|
10440
|
-
if (point2.y > maxY) maxY = point2.y;
|
|
10441
|
-
}
|
|
10442
|
-
return { minX, minY, maxX, maxY };
|
|
10443
|
-
};
|
|
10444
|
-
|
|
10445
10514
|
// lib/websafe/get-easyeda-cad-placement-helpers.ts
|
|
10446
10515
|
var getCadSvgNode = (easyEdaJson) => {
|
|
10447
10516
|
const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(
|
|
@@ -11034,6 +11103,19 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
11034
11103
|
).forEach((sr, index) => {
|
|
11035
11104
|
circuitElements.push(handleCutout(sr, index));
|
|
11036
11105
|
});
|
|
11106
|
+
const boardOutlineTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
11107
|
+
(shape) => shape.type === "TRACK" && shape.layer === 10
|
|
11108
|
+
);
|
|
11109
|
+
getBoardOutlinePolygons(boardOutlineTracks).forEach((points, index) => {
|
|
11110
|
+
circuitElements.push(
|
|
11111
|
+
pcb_cutout.parse({
|
|
11112
|
+
type: "pcb_cutout",
|
|
11113
|
+
pcb_cutout_id: `pcb_cutout_outline_${index + 1}`,
|
|
11114
|
+
shape: "polygon",
|
|
11115
|
+
points: points.map((p) => ({ x: milx10(p.x), y: milx10(p.y) }))
|
|
11116
|
+
})
|
|
11117
|
+
);
|
|
11118
|
+
});
|
|
11037
11119
|
let hasFoundDesignator = false;
|
|
11038
11120
|
const silkscreenTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
11039
11121
|
(shape) => shape.type === "TRACK" && isSilkscreenLayer(shape.layer)
|
|
@@ -12614,6 +12696,13 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
12614
12696
|
const pcbNoteDimensions = su(circuitJson).pcb_note_dimension.list();
|
|
12615
12697
|
const courtyardOutlines = su(circuitJson).pcb_courtyard_outline.list();
|
|
12616
12698
|
const elementStrings = [];
|
|
12699
|
+
for (const cutout of su(circuitJson).pcb_cutout.list()) {
|
|
12700
|
+
if (cutout.shape === "polygon") {
|
|
12701
|
+
elementStrings.push(
|
|
12702
|
+
`<cutout shape="polygon" points={${JSON.stringify(cutout.points)}} />`
|
|
12703
|
+
);
|
|
12704
|
+
}
|
|
12705
|
+
}
|
|
12617
12706
|
for (const hole of holes) {
|
|
12618
12707
|
if (hole.hole_shape === "circle") {
|
|
12619
12708
|
elementStrings.push(
|
|
@@ -12802,6 +12891,7 @@ var generateTypescriptComponent = ({
|
|
|
12802
12891
|
supplierPartNumbers,
|
|
12803
12892
|
manufacturerPartNumber,
|
|
12804
12893
|
componentType = "chip",
|
|
12894
|
+
isPolarizedCapacitor = false,
|
|
12805
12895
|
capacitance: capacitance2,
|
|
12806
12896
|
resistance: resistance2,
|
|
12807
12897
|
inductance: inductance2,
|
|
@@ -12851,10 +12941,10 @@ ${polarizedPinLabelsString}
|
|
|
12851
12941
|
` : "";
|
|
12852
12942
|
const polarizedPinLabelsProp = polarizedPinLabels ? ` pinLabels={pinLabels}
|
|
12853
12943
|
` : "";
|
|
12854
|
-
const
|
|
12855
|
-
const capacitorPolarizedPinLabelsBlock =
|
|
12856
|
-
const capacitorPolarizedPinLabelsProp =
|
|
12857
|
-
const polarizedProp =
|
|
12944
|
+
const shouldGeneratePolarizedCapacitor = componentType === "capacitor" && circuitJson.filter((item) => item.type === "source_port").length === 2 && (isPolarizedCapacitor || polarizedPinMetadata !== void 0);
|
|
12945
|
+
const capacitorPolarizedPinLabelsBlock = shouldGeneratePolarizedCapacitor ? polarizedPinLabelsBlock : "";
|
|
12946
|
+
const capacitorPolarizedPinLabelsProp = shouldGeneratePolarizedCapacitor ? polarizedPinLabelsProp : "";
|
|
12947
|
+
const polarizedProp = shouldGeneratePolarizedCapacitor ? ` polarized
|
|
12858
12948
|
` : "";
|
|
12859
12949
|
const symbolProp = symbolTsx ? ` symbol={
|
|
12860
12950
|
${symbolTsx.split("\n").map((line) => ` ${line}`).join("\n")}
|
|
@@ -13131,6 +13221,21 @@ var isCapacitorComponent = (betterEasy) => {
|
|
|
13131
13221
|
const value = componentParameters.Value;
|
|
13132
13222
|
return prefix?.toUpperCase() === "C?" && normalizeCapacitanceValue(value) !== void 0;
|
|
13133
13223
|
};
|
|
13224
|
+
var polarizedCapacitorMetadataPattern = /(?:aluminum|aluminium|tantalum|electrolytic|supercapacitor|polarized)/i;
|
|
13225
|
+
var isPolarizedCapacitorComponent = (betterEasy) => {
|
|
13226
|
+
if (!isCapacitorComponent(betterEasy)) return false;
|
|
13227
|
+
const pins = betterEasy.dataStr.shape.filter((shape) => shape.type === "PIN");
|
|
13228
|
+
if (pins.length !== 2) return false;
|
|
13229
|
+
const metadata = [
|
|
13230
|
+
betterEasy.title,
|
|
13231
|
+
betterEasy.description,
|
|
13232
|
+
...betterEasy.tags ?? [],
|
|
13233
|
+
betterEasy.category,
|
|
13234
|
+
betterEasy.dataStr.head.c_para.name,
|
|
13235
|
+
betterEasy.dataStr.head.c_para.package
|
|
13236
|
+
].filter((value) => typeof value === "string").join(" ");
|
|
13237
|
+
return polarizedCapacitorMetadataPattern.test(metadata) || betterEasy.dataStr.shape.some((shape) => shape.type === "ARC");
|
|
13238
|
+
};
|
|
13134
13239
|
|
|
13135
13240
|
// lib/websafe/convert-to-typescript-component/is-crystal-component.ts
|
|
13136
13241
|
var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
|
|
@@ -13408,6 +13513,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
13408
13513
|
circuitJson,
|
|
13409
13514
|
supplierPartNumbers,
|
|
13410
13515
|
componentType,
|
|
13516
|
+
isPolarizedCapacitor: isPolarizedCapacitorComponent(betterEasy),
|
|
13411
13517
|
capacitance: capacitance2,
|
|
13412
13518
|
resistance: resistance2,
|
|
13413
13519
|
inductance: inductance2,
|