jscad-electronics 0.0.163 → 0.0.164
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 +9 -1
- package/dist/index.js +1075 -1030
- package/dist/index.js.map +1 -1
- package/dist/vanilla.js +65 -23
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.js
CHANGED
|
@@ -193,8 +193,48 @@ var ExtrudedPads = ({
|
|
|
193
193
|
] });
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
// lib/
|
|
196
|
+
// lib/CeramicChipAntenna.tsx
|
|
197
197
|
import { fp as fp2 } from "@tscircuit/footprinter";
|
|
198
|
+
var CeramicChipAntenna = ({
|
|
199
|
+
footprint = "smdpads2_p5.4mm_pw1mm_ph2mm"
|
|
200
|
+
}) => {
|
|
201
|
+
const pads = fp2.string(footprint).circuitJson().filter(
|
|
202
|
+
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
203
|
+
);
|
|
204
|
+
if (pads.length !== 2) throw new Error("CeramicChipAntenna requires two pads");
|
|
205
|
+
const [a, b] = pads;
|
|
206
|
+
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
207
|
+
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: [
|
|
208
|
+
/* @__PURE__ */ jsx(
|
|
209
|
+
Cuboid,
|
|
210
|
+
{
|
|
211
|
+
size: [4.44, 1.99, 1.14],
|
|
212
|
+
center: [0, 0, 0.575],
|
|
213
|
+
color: "#4053a3"
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
[-1, 1].map((side) => /* @__PURE__ */ jsx(
|
|
217
|
+
Cuboid,
|
|
218
|
+
{
|
|
219
|
+
size: [0.4, 2, 1.15],
|
|
220
|
+
center: [side * 2.4, 0, 0.575],
|
|
221
|
+
color: "#c2c4c7"
|
|
222
|
+
},
|
|
223
|
+
side
|
|
224
|
+
)),
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
226
|
+
Cuboid,
|
|
227
|
+
{
|
|
228
|
+
size: [0.9, 2, 0.01],
|
|
229
|
+
center: [-1.75, 0, 1.145],
|
|
230
|
+
color: "#b1b3b6"
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
] }) });
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// lib/MelfResistor.tsx
|
|
237
|
+
import { fp as fp3 } from "@tscircuit/footprinter";
|
|
198
238
|
var melfResistorSizes = {
|
|
199
239
|
"0102": [2.2, 1.1, 0.4],
|
|
200
240
|
"0204": [3.6, 1.4, 0.75],
|
|
@@ -207,7 +247,7 @@ var MelfResistor = ({
|
|
|
207
247
|
const dims = melfResistorSizes[size];
|
|
208
248
|
if (!dims) throw new Error("Unsupported MELF resistor size");
|
|
209
249
|
const [length, diameter, capLength] = dims;
|
|
210
|
-
const pads =
|
|
250
|
+
const pads = fp3.string(footprint).circuitJson().filter(
|
|
211
251
|
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
212
252
|
);
|
|
213
253
|
if (pads.length !== 2) throw new Error("MelfResistor requires two pads");
|
|
@@ -234,7 +274,7 @@ var MelfResistor = ({
|
|
|
234
274
|
};
|
|
235
275
|
|
|
236
276
|
// lib/TwoPadCrystal.tsx
|
|
237
|
-
import { fp as
|
|
277
|
+
import { fp as fp4 } from "@tscircuit/footprinter";
|
|
238
278
|
var twoPadCrystalPackages = {
|
|
239
279
|
FC135: [3.2, 1.5, 0.9, 0.7],
|
|
240
280
|
FC12M: [2.05, 1.2, 0.6, 0.5],
|
|
@@ -248,7 +288,7 @@ var TwoPadCrystal = ({
|
|
|
248
288
|
const dims = twoPadCrystalPackages[packageName];
|
|
249
289
|
if (!dims) throw new Error("Unsupported two-pad crystal package");
|
|
250
290
|
const [length, width10, height10, terminalLength] = dims;
|
|
251
|
-
const pads =
|
|
291
|
+
const pads = fp4.string(footprint).circuitJson().filter(
|
|
252
292
|
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
253
293
|
);
|
|
254
294
|
if (pads.length !== 2) throw new Error("TwoPadCrystal requires two pads");
|
|
@@ -276,7 +316,7 @@ var TwoPadCrystal = ({
|
|
|
276
316
|
};
|
|
277
317
|
|
|
278
318
|
// lib/TantalumCapacitor.tsx
|
|
279
|
-
import { fp as
|
|
319
|
+
import { fp as fp5 } from "@tscircuit/footprinter";
|
|
280
320
|
var tantalumCases = {
|
|
281
321
|
A: [3.2, 1.6, 1.6, 1.2, 0.8],
|
|
282
322
|
B: [3.5, 2.8, 1.9, 2.2, 0.8],
|
|
@@ -290,7 +330,7 @@ var TantalumCapacitor = ({
|
|
|
290
330
|
const dims = tantalumCases[caseSize];
|
|
291
331
|
if (!dims) throw new Error("Unsupported tantalum case");
|
|
292
332
|
const [length, width10, height10, leadWidth, leadLength] = dims;
|
|
293
|
-
const pads =
|
|
333
|
+
const pads = fp5.string(footprint).circuitJson().filter(
|
|
294
334
|
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
295
335
|
);
|
|
296
336
|
if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
|
|
@@ -335,7 +375,7 @@ var TantalumCapacitor = ({
|
|
|
335
375
|
};
|
|
336
376
|
|
|
337
377
|
// lib/Footprinter3d.tsx
|
|
338
|
-
import { fp as
|
|
378
|
+
import { fp as fp12 } from "@tscircuit/footprinter";
|
|
339
379
|
import { mp } from "@tscircuit/modelprinter";
|
|
340
380
|
|
|
341
381
|
// lib/ChipBody.tsx
|
|
@@ -5321,7 +5361,7 @@ var JSTPH2_0mm = ({
|
|
|
5321
5361
|
};
|
|
5322
5362
|
|
|
5323
5363
|
// lib/JSTXH2_5mm.tsx
|
|
5324
|
-
import { fp as
|
|
5364
|
+
import { fp as fp6 } from "@tscircuit/footprinter";
|
|
5325
5365
|
var JSTXH2_5mm = ({
|
|
5326
5366
|
numPins = 4,
|
|
5327
5367
|
showPins = true,
|
|
@@ -5430,7 +5470,7 @@ var JSTXH2_5mm = ({
|
|
|
5430
5470
|
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)),
|
|
5431
5471
|
showFootprint && (() => {
|
|
5432
5472
|
try {
|
|
5433
|
-
const circuitJson =
|
|
5473
|
+
const circuitJson = fp6.string(`jst${numPins}_xh`).circuitJson();
|
|
5434
5474
|
const platedHoles = circuitJson.filter(
|
|
5435
5475
|
(e) => e.type === "pcb_plated_hole"
|
|
5436
5476
|
);
|
|
@@ -5926,9 +5966,9 @@ var SmdPinHeader = ({
|
|
|
5926
5966
|
import { mm } from "@tscircuit/mm";
|
|
5927
5967
|
|
|
5928
5968
|
// lib/utils/getPlatedHoleCenters.ts
|
|
5929
|
-
import { fp as
|
|
5969
|
+
import { fp as fp7 } from "@tscircuit/footprinter";
|
|
5930
5970
|
var getPlatedHoleCenters = (footprint) => {
|
|
5931
|
-
const elements =
|
|
5971
|
+
const elements = fp7.string(footprint).circuitJson();
|
|
5932
5972
|
return elements.filter(
|
|
5933
5973
|
(element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5934
5974
|
).map((element) => ({
|
|
@@ -5939,9 +5979,9 @@ var getPlatedHoleCenters = (footprint) => {
|
|
|
5939
5979
|
};
|
|
5940
5980
|
|
|
5941
5981
|
// lib/utils/getSmtPadRects.ts
|
|
5942
|
-
import { fp as
|
|
5982
|
+
import { fp as fp8 } from "@tscircuit/footprinter";
|
|
5943
5983
|
var getSmtPadRects = (footprint) => {
|
|
5944
|
-
const elements =
|
|
5984
|
+
const elements = fp8.string(footprint).circuitJson();
|
|
5945
5985
|
return elements.filter(
|
|
5946
5986
|
(element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5947
5987
|
).map((element) => ({
|
|
@@ -6697,7 +6737,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
|
|
|
6697
6737
|
};
|
|
6698
6738
|
|
|
6699
6739
|
// lib/BGA.tsx
|
|
6700
|
-
import { fp as
|
|
6740
|
+
import { fp as fp9 } from "@tscircuit/footprinter";
|
|
6701
6741
|
var BGA = ({
|
|
6702
6742
|
packageWidth = 10,
|
|
6703
6743
|
packageLength = 10,
|
|
@@ -6713,7 +6753,7 @@ var BGA = ({
|
|
|
6713
6753
|
const bodyHeight = packageHeight - standoffHeight;
|
|
6714
6754
|
const bodyOffset = standoffHeight + bodyHeight / 2;
|
|
6715
6755
|
const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
|
|
6716
|
-
const ballsSoup = footprintString ?
|
|
6756
|
+
const ballsSoup = footprintString ? fp9.string(footprintString).circuitJson() : null;
|
|
6717
6757
|
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
6718
6758
|
/* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
|
|
6719
6759
|
!footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
|
|
@@ -6743,7 +6783,7 @@ var BGA = ({
|
|
|
6743
6783
|
};
|
|
6744
6784
|
|
|
6745
6785
|
// lib/UsbCMidmount.tsx
|
|
6746
|
-
import { fp as
|
|
6786
|
+
import { fp as fp10 } from "@tscircuit/footprinter";
|
|
6747
6787
|
var Capsule = ({
|
|
6748
6788
|
width: width10,
|
|
6749
6789
|
height: height10,
|
|
@@ -6753,14 +6793,14 @@ var UsbCMidmount = ({
|
|
|
6753
6793
|
footprint = "usbcmidmount16"
|
|
6754
6794
|
}) => {
|
|
6755
6795
|
const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
|
|
6756
|
-
const params =
|
|
6757
|
-
const elements =
|
|
6796
|
+
const params = fp10.string(canonical).json();
|
|
6797
|
+
const elements = fp10.string(canonical).circuitJson();
|
|
6758
6798
|
const pads = elements.filter(
|
|
6759
6799
|
(e) => e.type === "pcb_smtpad" && e.shape === "rect"
|
|
6760
6800
|
);
|
|
6761
6801
|
const slots = elements.filter((e) => e.type === "pcb_plated_hole");
|
|
6762
6802
|
const holes = elements.filter((e) => e.type === "pcb_hole");
|
|
6763
|
-
const target =
|
|
6803
|
+
const target = fp10.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
|
|
6764
6804
|
const first = slots[0];
|
|
6765
6805
|
const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
|
|
6766
6806
|
const width10 = 8.94, height10 = 3.2, wall = 0.22;
|
|
@@ -6844,15 +6884,15 @@ var UsbCMidmount = ({
|
|
|
6844
6884
|
};
|
|
6845
6885
|
|
|
6846
6886
|
// lib/SOT143.tsx
|
|
6847
|
-
import { fp as
|
|
6848
|
-
var getPads = (footprint) =>
|
|
6887
|
+
import { fp as fp11 } from "@tscircuit/footprinter";
|
|
6888
|
+
var getPads = (footprint) => fp11.string(footprint).circuitJson().filter(
|
|
6849
6889
|
(element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
|
|
6850
6890
|
).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
|
|
6851
6891
|
var SOT143 = ({ footprint = "sot143" }) => {
|
|
6852
6892
|
const pads = getPads(footprint);
|
|
6853
6893
|
if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
|
|
6854
6894
|
const canonical = getPads("sot143");
|
|
6855
|
-
const options =
|
|
6895
|
+
const options = fp11.string(footprint).json();
|
|
6856
6896
|
const origin = canonical[1];
|
|
6857
6897
|
const target = pads.find((pad) => pad.pin === "2");
|
|
6858
6898
|
const angle = options.pin1location ? Math.round(
|
|
@@ -7439,6 +7479,8 @@ var FlexScreen = (props) => {
|
|
|
7439
7479
|
|
|
7440
7480
|
// lib/Footprinter3d.tsx
|
|
7441
7481
|
var Footprinter3d = ({ footprint }) => {
|
|
7482
|
+
if (/(?:^|_)antennaRFANT5220110A0T(?:_|$)/.test(footprint))
|
|
7483
|
+
return /* @__PURE__ */ jsx(CeramicChipAntenna, { footprint });
|
|
7442
7484
|
const melfResistor = footprint.match(
|
|
7443
7485
|
/(?:^|_)melfresistor(0102|0204|0207)(?:_|$)/
|
|
7444
7486
|
);
|
|
@@ -7494,7 +7536,7 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7494
7536
|
const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
|
|
7495
7537
|
normalizedFootprint = `jst${numPins}_xh`;
|
|
7496
7538
|
}
|
|
7497
|
-
const fpJson =
|
|
7539
|
+
const fpJson = fp12.string(normalizedFootprint).json();
|
|
7498
7540
|
const colorMatch = footprint.match(/_color\(([^)]+)\)/);
|
|
7499
7541
|
const color = colorMatch ? colorMatch[1] : void 0;
|
|
7500
7542
|
const dim = (value, fallback) => {
|