jscad-electronics 0.0.161 → 0.0.163
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 +26 -1
- package/dist/index.js +1202 -1090
- package/dist/index.js.map +1 -1
- package/dist/vanilla.js +123 -19
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.js
CHANGED
|
@@ -193,8 +193,90 @@ var ExtrudedPads = ({
|
|
|
193
193
|
] });
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
// lib/
|
|
196
|
+
// lib/MelfResistor.tsx
|
|
197
197
|
import { fp as fp2 } from "@tscircuit/footprinter";
|
|
198
|
+
var melfResistorSizes = {
|
|
199
|
+
"0102": [2.2, 1.1, 0.4],
|
|
200
|
+
"0204": [3.6, 1.4, 0.75],
|
|
201
|
+
"0207": [5.8, 2.2, 1.15]
|
|
202
|
+
};
|
|
203
|
+
var MelfResistor = ({
|
|
204
|
+
size = "0204",
|
|
205
|
+
footprint = "smdpads2_p2.8mm_pw1.2mm_ph1.6mm"
|
|
206
|
+
}) => {
|
|
207
|
+
const dims = melfResistorSizes[size];
|
|
208
|
+
if (!dims) throw new Error("Unsupported MELF resistor size");
|
|
209
|
+
const [length, diameter, capLength] = dims;
|
|
210
|
+
const pads = fp2.string(footprint).circuitJson().filter(
|
|
211
|
+
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
212
|
+
);
|
|
213
|
+
if (pads.length !== 2) throw new Error("MelfResistor requires two pads");
|
|
214
|
+
const [a, b] = pads;
|
|
215
|
+
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
216
|
+
return /* @__PURE__ */ jsx(Translate, { offset: [(a.x + b.x) / 2, (a.y + b.y) / 2, diameter / 2], children: /* @__PURE__ */ jsx(Rotate, { rotation: [0, 0, angle], children: /* @__PURE__ */ jsxs(Rotate, { rotation: [0, Math.PI / 2, 0], children: [
|
|
217
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#426d63", children: /* @__PURE__ */ jsx(
|
|
218
|
+
Cylinder,
|
|
219
|
+
{
|
|
220
|
+
radius: (diameter - 0.08) / 2,
|
|
221
|
+
height: length - 2 * capLength + 0.04
|
|
222
|
+
}
|
|
223
|
+
) }),
|
|
224
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#c6c8cb", children: [-1, 1].map((side) => /* @__PURE__ */ jsx(
|
|
225
|
+
Cylinder,
|
|
226
|
+
{
|
|
227
|
+
radius: diameter / 2,
|
|
228
|
+
height: capLength,
|
|
229
|
+
center: [0, 0, side * (length - capLength) / 2]
|
|
230
|
+
},
|
|
231
|
+
side
|
|
232
|
+
)) })
|
|
233
|
+
] }) }) });
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// lib/TwoPadCrystal.tsx
|
|
237
|
+
import { fp as fp3 } from "@tscircuit/footprinter";
|
|
238
|
+
var twoPadCrystalPackages = {
|
|
239
|
+
FC135: [3.2, 1.5, 0.9, 0.7],
|
|
240
|
+
FC12M: [2.05, 1.2, 0.6, 0.5],
|
|
241
|
+
FC1610AN: [1.65, 1.05, 0.5, 0.4],
|
|
242
|
+
NX3225GD: [3.2, 2.5, 0.8, 1.2]
|
|
243
|
+
};
|
|
244
|
+
var TwoPadCrystal = ({
|
|
245
|
+
packageName = "FC135",
|
|
246
|
+
footprint = "smdpads2_p2.5mm_pw1mm_ph1.8mm"
|
|
247
|
+
}) => {
|
|
248
|
+
const dims = twoPadCrystalPackages[packageName];
|
|
249
|
+
if (!dims) throw new Error("Unsupported two-pad crystal package");
|
|
250
|
+
const [length, width10, height10, terminalLength] = dims;
|
|
251
|
+
const pads = fp3.string(footprint).circuitJson().filter(
|
|
252
|
+
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
253
|
+
);
|
|
254
|
+
if (pads.length !== 2) throw new Error("TwoPadCrystal requires two pads");
|
|
255
|
+
const [a, b] = pads;
|
|
256
|
+
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
257
|
+
return /* @__PURE__ */ jsx(Translate, { offset: [(a.x + b.x) / 2, (a.y + b.y) / 2, 0], children: /* @__PURE__ */ jsxs(Rotate, { rotation: [0, 0, angle], children: [
|
|
258
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#e0dcca", children: /* @__PURE__ */ jsx(Cuboid, { size: [length, width10, 0.2], center: [0, 0, 0.13] }) }),
|
|
259
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#acb1b8", children: /* @__PURE__ */ jsx(
|
|
260
|
+
RoundedCuboid,
|
|
261
|
+
{
|
|
262
|
+
size: [length - 0.04, width10 - 0.04, height10 - 0.18],
|
|
263
|
+
roundRadius: 0.035,
|
|
264
|
+
center: [0, 0, (height10 + 0.18) / 2]
|
|
265
|
+
}
|
|
266
|
+
) }),
|
|
267
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#c6af65", children: [-1, 1].map((side) => /* @__PURE__ */ jsx(
|
|
268
|
+
Cuboid,
|
|
269
|
+
{
|
|
270
|
+
size: [terminalLength, width10 - 0.12, 0.06],
|
|
271
|
+
center: [side * (length - terminalLength) / 2, 0, 0.03]
|
|
272
|
+
},
|
|
273
|
+
side
|
|
274
|
+
)) })
|
|
275
|
+
] }) });
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// lib/TantalumCapacitor.tsx
|
|
279
|
+
import { fp as fp4 } from "@tscircuit/footprinter";
|
|
198
280
|
var tantalumCases = {
|
|
199
281
|
A: [3.2, 1.6, 1.6, 1.2, 0.8],
|
|
200
282
|
B: [3.5, 2.8, 1.9, 2.2, 0.8],
|
|
@@ -208,7 +290,7 @@ var TantalumCapacitor = ({
|
|
|
208
290
|
const dims = tantalumCases[caseSize];
|
|
209
291
|
if (!dims) throw new Error("Unsupported tantalum case");
|
|
210
292
|
const [length, width10, height10, leadWidth, leadLength] = dims;
|
|
211
|
-
const pads =
|
|
293
|
+
const pads = fp4.string(footprint).circuitJson().filter(
|
|
212
294
|
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
213
295
|
);
|
|
214
296
|
if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
|
|
@@ -253,7 +335,7 @@ var TantalumCapacitor = ({
|
|
|
253
335
|
};
|
|
254
336
|
|
|
255
337
|
// lib/Footprinter3d.tsx
|
|
256
|
-
import { fp as
|
|
338
|
+
import { fp as fp11 } from "@tscircuit/footprinter";
|
|
257
339
|
import { mp } from "@tscircuit/modelprinter";
|
|
258
340
|
|
|
259
341
|
// lib/ChipBody.tsx
|
|
@@ -5239,7 +5321,7 @@ var JSTPH2_0mm = ({
|
|
|
5239
5321
|
};
|
|
5240
5322
|
|
|
5241
5323
|
// lib/JSTXH2_5mm.tsx
|
|
5242
|
-
import { fp as
|
|
5324
|
+
import { fp as fp5 } from "@tscircuit/footprinter";
|
|
5243
5325
|
var JSTXH2_5mm = ({
|
|
5244
5326
|
numPins = 4,
|
|
5245
5327
|
showPins = true,
|
|
@@ -5348,7 +5430,7 @@ var JSTXH2_5mm = ({
|
|
|
5348
5430
|
showPins && Array.from({ length: numPins }).map((_, i) => /* @__PURE__ */ jsx(Colorize, { color: pinColor, children: /* @__PURE__ */ jsx(Translate, { offset: [startX + i * pitch, 0, pinLength / 2 - 3.4], children: /* @__PURE__ */ jsx(Cuboid, { size: [0.64, 0.64, pinLength] }) }) }, i)),
|
|
5349
5431
|
showFootprint && (() => {
|
|
5350
5432
|
try {
|
|
5351
|
-
const circuitJson =
|
|
5433
|
+
const circuitJson = fp5.string(`jst${numPins}_xh`).circuitJson();
|
|
5352
5434
|
const platedHoles = circuitJson.filter(
|
|
5353
5435
|
(e) => e.type === "pcb_plated_hole"
|
|
5354
5436
|
);
|
|
@@ -5844,9 +5926,9 @@ var SmdPinHeader = ({
|
|
|
5844
5926
|
import { mm } from "@tscircuit/mm";
|
|
5845
5927
|
|
|
5846
5928
|
// lib/utils/getPlatedHoleCenters.ts
|
|
5847
|
-
import { fp as
|
|
5929
|
+
import { fp as fp6 } from "@tscircuit/footprinter";
|
|
5848
5930
|
var getPlatedHoleCenters = (footprint) => {
|
|
5849
|
-
const elements =
|
|
5931
|
+
const elements = fp6.string(footprint).circuitJson();
|
|
5850
5932
|
return elements.filter(
|
|
5851
5933
|
(element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5852
5934
|
).map((element) => ({
|
|
@@ -5857,9 +5939,9 @@ var getPlatedHoleCenters = (footprint) => {
|
|
|
5857
5939
|
};
|
|
5858
5940
|
|
|
5859
5941
|
// lib/utils/getSmtPadRects.ts
|
|
5860
|
-
import { fp as
|
|
5942
|
+
import { fp as fp7 } from "@tscircuit/footprinter";
|
|
5861
5943
|
var getSmtPadRects = (footprint) => {
|
|
5862
|
-
const elements =
|
|
5944
|
+
const elements = fp7.string(footprint).circuitJson();
|
|
5863
5945
|
return elements.filter(
|
|
5864
5946
|
(element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5865
5947
|
).map((element) => ({
|
|
@@ -6615,7 +6697,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
|
|
|
6615
6697
|
};
|
|
6616
6698
|
|
|
6617
6699
|
// lib/BGA.tsx
|
|
6618
|
-
import { fp as
|
|
6700
|
+
import { fp as fp8 } from "@tscircuit/footprinter";
|
|
6619
6701
|
var BGA = ({
|
|
6620
6702
|
packageWidth = 10,
|
|
6621
6703
|
packageLength = 10,
|
|
@@ -6631,7 +6713,7 @@ var BGA = ({
|
|
|
6631
6713
|
const bodyHeight = packageHeight - standoffHeight;
|
|
6632
6714
|
const bodyOffset = standoffHeight + bodyHeight / 2;
|
|
6633
6715
|
const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
|
|
6634
|
-
const ballsSoup = footprintString ?
|
|
6716
|
+
const ballsSoup = footprintString ? fp8.string(footprintString).circuitJson() : null;
|
|
6635
6717
|
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
6636
6718
|
/* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
|
|
6637
6719
|
!footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
|
|
@@ -6661,7 +6743,7 @@ var BGA = ({
|
|
|
6661
6743
|
};
|
|
6662
6744
|
|
|
6663
6745
|
// lib/UsbCMidmount.tsx
|
|
6664
|
-
import { fp as
|
|
6746
|
+
import { fp as fp9 } from "@tscircuit/footprinter";
|
|
6665
6747
|
var Capsule = ({
|
|
6666
6748
|
width: width10,
|
|
6667
6749
|
height: height10,
|
|
@@ -6671,14 +6753,14 @@ var UsbCMidmount = ({
|
|
|
6671
6753
|
footprint = "usbcmidmount16"
|
|
6672
6754
|
}) => {
|
|
6673
6755
|
const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
|
|
6674
|
-
const params =
|
|
6675
|
-
const elements =
|
|
6756
|
+
const params = fp9.string(canonical).json();
|
|
6757
|
+
const elements = fp9.string(canonical).circuitJson();
|
|
6676
6758
|
const pads = elements.filter(
|
|
6677
6759
|
(e) => e.type === "pcb_smtpad" && e.shape === "rect"
|
|
6678
6760
|
);
|
|
6679
6761
|
const slots = elements.filter((e) => e.type === "pcb_plated_hole");
|
|
6680
6762
|
const holes = elements.filter((e) => e.type === "pcb_hole");
|
|
6681
|
-
const target =
|
|
6763
|
+
const target = fp9.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
|
|
6682
6764
|
const first = slots[0];
|
|
6683
6765
|
const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
|
|
6684
6766
|
const width10 = 8.94, height10 = 3.2, wall = 0.22;
|
|
@@ -6762,15 +6844,15 @@ var UsbCMidmount = ({
|
|
|
6762
6844
|
};
|
|
6763
6845
|
|
|
6764
6846
|
// lib/SOT143.tsx
|
|
6765
|
-
import { fp as
|
|
6766
|
-
var getPads = (footprint) =>
|
|
6847
|
+
import { fp as fp10 } from "@tscircuit/footprinter";
|
|
6848
|
+
var getPads = (footprint) => fp10.string(footprint).circuitJson().filter(
|
|
6767
6849
|
(element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
|
|
6768
6850
|
).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
|
|
6769
6851
|
var SOT143 = ({ footprint = "sot143" }) => {
|
|
6770
6852
|
const pads = getPads(footprint);
|
|
6771
6853
|
if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
|
|
6772
6854
|
const canonical = getPads("sot143");
|
|
6773
|
-
const options =
|
|
6855
|
+
const options = fp10.string(footprint).json();
|
|
6774
6856
|
const origin = canonical[1];
|
|
6775
6857
|
const target = pads.find((pad) => pad.pin === "2");
|
|
6776
6858
|
const angle = options.pin1location ? Math.round(
|
|
@@ -7357,6 +7439,17 @@ var FlexScreen = (props) => {
|
|
|
7357
7439
|
|
|
7358
7440
|
// lib/Footprinter3d.tsx
|
|
7359
7441
|
var Footprinter3d = ({ footprint }) => {
|
|
7442
|
+
const melfResistor = footprint.match(
|
|
7443
|
+
/(?:^|_)melfresistor(0102|0204|0207)(?:_|$)/
|
|
7444
|
+
);
|
|
7445
|
+
if (melfResistor)
|
|
7446
|
+
return /* @__PURE__ */ jsx(
|
|
7447
|
+
MelfResistor,
|
|
7448
|
+
{
|
|
7449
|
+
footprint,
|
|
7450
|
+
size: melfResistor[1]
|
|
7451
|
+
}
|
|
7452
|
+
);
|
|
7360
7453
|
const tantalum = footprint.match(/(?:^|_)tantalum([ABCD])(?:_|$)/);
|
|
7361
7454
|
if (tantalum)
|
|
7362
7455
|
return /* @__PURE__ */ jsx(
|
|
@@ -7366,6 +7459,17 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7366
7459
|
caseSize: tantalum[1]
|
|
7367
7460
|
}
|
|
7368
7461
|
);
|
|
7462
|
+
const crystal2 = footprint.match(
|
|
7463
|
+
/(?:^|_)crystal2(FC135|FC12M|FC1610AN|NX3225GD)(?:_|$)/
|
|
7464
|
+
);
|
|
7465
|
+
if (crystal2)
|
|
7466
|
+
return /* @__PURE__ */ jsx(
|
|
7467
|
+
TwoPadCrystal,
|
|
7468
|
+
{
|
|
7469
|
+
footprint,
|
|
7470
|
+
packageName: crystal2[1]
|
|
7471
|
+
}
|
|
7472
|
+
);
|
|
7369
7473
|
const modelFn = mp.string(footprint.split("_", 1)[0]).params().fn;
|
|
7370
7474
|
if (mp.getModelNames().includes(modelFn)) {
|
|
7371
7475
|
const model = mp.string(footprint).json();
|
|
@@ -7390,7 +7494,7 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7390
7494
|
const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
|
|
7391
7495
|
normalizedFootprint = `jst${numPins}_xh`;
|
|
7392
7496
|
}
|
|
7393
|
-
const fpJson =
|
|
7497
|
+
const fpJson = fp11.string(normalizedFootprint).json();
|
|
7394
7498
|
const colorMatch = footprint.match(/_color\(([^)]+)\)/);
|
|
7395
7499
|
const color = colorMatch ? colorMatch[1] : void 0;
|
|
7396
7500
|
const dim = (value, fallback) => {
|