jscad-electronics 0.0.161 → 0.0.162
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 +14 -1
- package/dist/index.js +1104 -1047
- package/dist/index.js.map +1 -1
- package/dist/vanilla.js +72 -19
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.js
CHANGED
|
@@ -193,8 +193,50 @@ var ExtrudedPads = ({
|
|
|
193
193
|
] });
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
// lib/
|
|
196
|
+
// lib/TwoPadCrystal.tsx
|
|
197
197
|
import { fp as fp2 } from "@tscircuit/footprinter";
|
|
198
|
+
var twoPadCrystalPackages = {
|
|
199
|
+
FC135: [3.2, 1.5, 0.9, 0.7],
|
|
200
|
+
FC12M: [2.05, 1.2, 0.6, 0.5],
|
|
201
|
+
FC1610AN: [1.65, 1.05, 0.5, 0.4],
|
|
202
|
+
NX3225GD: [3.2, 2.5, 0.8, 1.2]
|
|
203
|
+
};
|
|
204
|
+
var TwoPadCrystal = ({
|
|
205
|
+
packageName = "FC135",
|
|
206
|
+
footprint = "smdpads2_p2.5mm_pw1mm_ph1.8mm"
|
|
207
|
+
}) => {
|
|
208
|
+
const dims = twoPadCrystalPackages[packageName];
|
|
209
|
+
if (!dims) throw new Error("Unsupported two-pad crystal package");
|
|
210
|
+
const [length, width10, height10, terminalLength] = dims;
|
|
211
|
+
const pads = fp2.string(footprint).circuitJson().filter(
|
|
212
|
+
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
213
|
+
);
|
|
214
|
+
if (pads.length !== 2) throw new Error("TwoPadCrystal requires two pads");
|
|
215
|
+
const [a, b] = pads;
|
|
216
|
+
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
217
|
+
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: [
|
|
218
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#e0dcca", children: /* @__PURE__ */ jsx(Cuboid, { size: [length, width10, 0.2], center: [0, 0, 0.13] }) }),
|
|
219
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#acb1b8", children: /* @__PURE__ */ jsx(
|
|
220
|
+
RoundedCuboid,
|
|
221
|
+
{
|
|
222
|
+
size: [length - 0.04, width10 - 0.04, height10 - 0.18],
|
|
223
|
+
roundRadius: 0.035,
|
|
224
|
+
center: [0, 0, (height10 + 0.18) / 2]
|
|
225
|
+
}
|
|
226
|
+
) }),
|
|
227
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#c6af65", children: [-1, 1].map((side) => /* @__PURE__ */ jsx(
|
|
228
|
+
Cuboid,
|
|
229
|
+
{
|
|
230
|
+
size: [terminalLength, width10 - 0.12, 0.06],
|
|
231
|
+
center: [side * (length - terminalLength) / 2, 0, 0.03]
|
|
232
|
+
},
|
|
233
|
+
side
|
|
234
|
+
)) })
|
|
235
|
+
] }) });
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// lib/TantalumCapacitor.tsx
|
|
239
|
+
import { fp as fp3 } from "@tscircuit/footprinter";
|
|
198
240
|
var tantalumCases = {
|
|
199
241
|
A: [3.2, 1.6, 1.6, 1.2, 0.8],
|
|
200
242
|
B: [3.5, 2.8, 1.9, 2.2, 0.8],
|
|
@@ -208,7 +250,7 @@ var TantalumCapacitor = ({
|
|
|
208
250
|
const dims = tantalumCases[caseSize];
|
|
209
251
|
if (!dims) throw new Error("Unsupported tantalum case");
|
|
210
252
|
const [length, width10, height10, leadWidth, leadLength] = dims;
|
|
211
|
-
const pads =
|
|
253
|
+
const pads = fp3.string(footprint).circuitJson().filter(
|
|
212
254
|
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
213
255
|
);
|
|
214
256
|
if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
|
|
@@ -253,7 +295,7 @@ var TantalumCapacitor = ({
|
|
|
253
295
|
};
|
|
254
296
|
|
|
255
297
|
// lib/Footprinter3d.tsx
|
|
256
|
-
import { fp as
|
|
298
|
+
import { fp as fp10 } from "@tscircuit/footprinter";
|
|
257
299
|
import { mp } from "@tscircuit/modelprinter";
|
|
258
300
|
|
|
259
301
|
// lib/ChipBody.tsx
|
|
@@ -5239,7 +5281,7 @@ var JSTPH2_0mm = ({
|
|
|
5239
5281
|
};
|
|
5240
5282
|
|
|
5241
5283
|
// lib/JSTXH2_5mm.tsx
|
|
5242
|
-
import { fp as
|
|
5284
|
+
import { fp as fp4 } from "@tscircuit/footprinter";
|
|
5243
5285
|
var JSTXH2_5mm = ({
|
|
5244
5286
|
numPins = 4,
|
|
5245
5287
|
showPins = true,
|
|
@@ -5348,7 +5390,7 @@ var JSTXH2_5mm = ({
|
|
|
5348
5390
|
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
5391
|
showFootprint && (() => {
|
|
5350
5392
|
try {
|
|
5351
|
-
const circuitJson =
|
|
5393
|
+
const circuitJson = fp4.string(`jst${numPins}_xh`).circuitJson();
|
|
5352
5394
|
const platedHoles = circuitJson.filter(
|
|
5353
5395
|
(e) => e.type === "pcb_plated_hole"
|
|
5354
5396
|
);
|
|
@@ -5844,9 +5886,9 @@ var SmdPinHeader = ({
|
|
|
5844
5886
|
import { mm } from "@tscircuit/mm";
|
|
5845
5887
|
|
|
5846
5888
|
// lib/utils/getPlatedHoleCenters.ts
|
|
5847
|
-
import { fp as
|
|
5889
|
+
import { fp as fp5 } from "@tscircuit/footprinter";
|
|
5848
5890
|
var getPlatedHoleCenters = (footprint) => {
|
|
5849
|
-
const elements =
|
|
5891
|
+
const elements = fp5.string(footprint).circuitJson();
|
|
5850
5892
|
return elements.filter(
|
|
5851
5893
|
(element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5852
5894
|
).map((element) => ({
|
|
@@ -5857,9 +5899,9 @@ var getPlatedHoleCenters = (footprint) => {
|
|
|
5857
5899
|
};
|
|
5858
5900
|
|
|
5859
5901
|
// lib/utils/getSmtPadRects.ts
|
|
5860
|
-
import { fp as
|
|
5902
|
+
import { fp as fp6 } from "@tscircuit/footprinter";
|
|
5861
5903
|
var getSmtPadRects = (footprint) => {
|
|
5862
|
-
const elements =
|
|
5904
|
+
const elements = fp6.string(footprint).circuitJson();
|
|
5863
5905
|
return elements.filter(
|
|
5864
5906
|
(element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5865
5907
|
).map((element) => ({
|
|
@@ -6615,7 +6657,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
|
|
|
6615
6657
|
};
|
|
6616
6658
|
|
|
6617
6659
|
// lib/BGA.tsx
|
|
6618
|
-
import { fp as
|
|
6660
|
+
import { fp as fp7 } from "@tscircuit/footprinter";
|
|
6619
6661
|
var BGA = ({
|
|
6620
6662
|
packageWidth = 10,
|
|
6621
6663
|
packageLength = 10,
|
|
@@ -6631,7 +6673,7 @@ var BGA = ({
|
|
|
6631
6673
|
const bodyHeight = packageHeight - standoffHeight;
|
|
6632
6674
|
const bodyOffset = standoffHeight + bodyHeight / 2;
|
|
6633
6675
|
const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
|
|
6634
|
-
const ballsSoup = footprintString ?
|
|
6676
|
+
const ballsSoup = footprintString ? fp7.string(footprintString).circuitJson() : null;
|
|
6635
6677
|
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
6636
6678
|
/* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
|
|
6637
6679
|
!footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
|
|
@@ -6661,7 +6703,7 @@ var BGA = ({
|
|
|
6661
6703
|
};
|
|
6662
6704
|
|
|
6663
6705
|
// lib/UsbCMidmount.tsx
|
|
6664
|
-
import { fp as
|
|
6706
|
+
import { fp as fp8 } from "@tscircuit/footprinter";
|
|
6665
6707
|
var Capsule = ({
|
|
6666
6708
|
width: width10,
|
|
6667
6709
|
height: height10,
|
|
@@ -6671,14 +6713,14 @@ var UsbCMidmount = ({
|
|
|
6671
6713
|
footprint = "usbcmidmount16"
|
|
6672
6714
|
}) => {
|
|
6673
6715
|
const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
|
|
6674
|
-
const params =
|
|
6675
|
-
const elements =
|
|
6716
|
+
const params = fp8.string(canonical).json();
|
|
6717
|
+
const elements = fp8.string(canonical).circuitJson();
|
|
6676
6718
|
const pads = elements.filter(
|
|
6677
6719
|
(e) => e.type === "pcb_smtpad" && e.shape === "rect"
|
|
6678
6720
|
);
|
|
6679
6721
|
const slots = elements.filter((e) => e.type === "pcb_plated_hole");
|
|
6680
6722
|
const holes = elements.filter((e) => e.type === "pcb_hole");
|
|
6681
|
-
const target =
|
|
6723
|
+
const target = fp8.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
|
|
6682
6724
|
const first = slots[0];
|
|
6683
6725
|
const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
|
|
6684
6726
|
const width10 = 8.94, height10 = 3.2, wall = 0.22;
|
|
@@ -6762,15 +6804,15 @@ var UsbCMidmount = ({
|
|
|
6762
6804
|
};
|
|
6763
6805
|
|
|
6764
6806
|
// lib/SOT143.tsx
|
|
6765
|
-
import { fp as
|
|
6766
|
-
var getPads = (footprint) =>
|
|
6807
|
+
import { fp as fp9 } from "@tscircuit/footprinter";
|
|
6808
|
+
var getPads = (footprint) => fp9.string(footprint).circuitJson().filter(
|
|
6767
6809
|
(element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
|
|
6768
6810
|
).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
|
|
6769
6811
|
var SOT143 = ({ footprint = "sot143" }) => {
|
|
6770
6812
|
const pads = getPads(footprint);
|
|
6771
6813
|
if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
|
|
6772
6814
|
const canonical = getPads("sot143");
|
|
6773
|
-
const options =
|
|
6815
|
+
const options = fp9.string(footprint).json();
|
|
6774
6816
|
const origin = canonical[1];
|
|
6775
6817
|
const target = pads.find((pad) => pad.pin === "2");
|
|
6776
6818
|
const angle = options.pin1location ? Math.round(
|
|
@@ -7366,6 +7408,17 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7366
7408
|
caseSize: tantalum[1]
|
|
7367
7409
|
}
|
|
7368
7410
|
);
|
|
7411
|
+
const crystal2 = footprint.match(
|
|
7412
|
+
/(?:^|_)crystal2(FC135|FC12M|FC1610AN|NX3225GD)(?:_|$)/
|
|
7413
|
+
);
|
|
7414
|
+
if (crystal2)
|
|
7415
|
+
return /* @__PURE__ */ jsx(
|
|
7416
|
+
TwoPadCrystal,
|
|
7417
|
+
{
|
|
7418
|
+
footprint,
|
|
7419
|
+
packageName: crystal2[1]
|
|
7420
|
+
}
|
|
7421
|
+
);
|
|
7369
7422
|
const modelFn = mp.string(footprint.split("_", 1)[0]).params().fn;
|
|
7370
7423
|
if (mp.getModelNames().includes(modelFn)) {
|
|
7371
7424
|
const model = mp.string(footprint).json();
|
|
@@ -7390,7 +7443,7 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7390
7443
|
const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
|
|
7391
7444
|
normalizedFootprint = `jst${numPins}_xh`;
|
|
7392
7445
|
}
|
|
7393
|
-
const fpJson =
|
|
7446
|
+
const fpJson = fp10.string(normalizedFootprint).json();
|
|
7394
7447
|
const colorMatch = footprint.match(/_color\(([^)]+)\)/);
|
|
7395
7448
|
const color = colorMatch ? colorMatch[1] : void 0;
|
|
7396
7449
|
const dim = (value, fallback) => {
|