jscad-electronics 0.0.160 → 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/vanilla.js CHANGED
@@ -193,8 +193,109 @@ var ExtrudedPads = ({
193
193
  ] });
194
194
  };
195
195
 
196
+ // lib/TwoPadCrystal.tsx
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";
240
+ var tantalumCases = {
241
+ A: [3.2, 1.6, 1.6, 1.2, 0.8],
242
+ B: [3.5, 2.8, 1.9, 2.2, 0.8],
243
+ C: [6, 3.2, 2.6, 2.2, 1.3],
244
+ D: [7.3, 4.3, 2.9, 2.4, 1.3]
245
+ };
246
+ var TantalumCapacitor = ({
247
+ caseSize = "A",
248
+ footprint = "smdpads2_p3.1mm_pw1.4mm_ph1.6mm"
249
+ }) => {
250
+ const dims = tantalumCases[caseSize];
251
+ if (!dims) throw new Error("Unsupported tantalum case");
252
+ const [length, width10, height10, leadWidth, leadLength] = dims;
253
+ const pads = fp3.string(footprint).circuitJson().filter(
254
+ (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
255
+ );
256
+ if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
257
+ const [a, b] = pads;
258
+ const angle = Math.atan2(b.y - a.y, b.x - a.x);
259
+ 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: [
260
+ /* @__PURE__ */ jsx(Colorize, { color: "#d5a64e", children: /* @__PURE__ */ jsxs(Hull, { children: [
261
+ /* @__PURE__ */ jsx(Cuboid, { size: [length - 0.1, width10, 0.02], center: [0, 0, 0.21] }),
262
+ /* @__PURE__ */ jsx(
263
+ Cuboid,
264
+ {
265
+ size: [length - 0.25, width10 - 0.15, 0.02],
266
+ center: [0, 0, height10 - 0.01]
267
+ }
268
+ )
269
+ ] }) }),
270
+ /* @__PURE__ */ jsx(Colorize, { color: "#c5c8cb", children: [-1, 1].map((side) => /* @__PURE__ */ jsxs(Union, { children: [
271
+ /* @__PURE__ */ jsx(
272
+ Cuboid,
273
+ {
274
+ size: [leadLength, leadWidth, 0.25],
275
+ center: [side * (length - leadLength) / 2, 0, 0.125]
276
+ }
277
+ ),
278
+ /* @__PURE__ */ jsx(
279
+ Cuboid,
280
+ {
281
+ size: [0.15, leadWidth, height10 * 0.45],
282
+ center: [side * (length - 0.15) / 2, 0, height10 * 0.225]
283
+ }
284
+ )
285
+ ] }, side)) }),
286
+ /* @__PURE__ */ jsx(
287
+ Cuboid,
288
+ {
289
+ size: [0.25, width10 - 0.25, 0.01],
290
+ center: [-length / 2 + 0.5, 0, height10],
291
+ color: "#423426"
292
+ }
293
+ )
294
+ ] }) });
295
+ };
296
+
196
297
  // lib/Footprinter3d.tsx
197
- import { fp as fp8 } from "@tscircuit/footprinter";
298
+ import { fp as fp10 } from "@tscircuit/footprinter";
198
299
  import { mp } from "@tscircuit/modelprinter";
199
300
 
200
301
  // lib/ChipBody.tsx
@@ -5180,7 +5281,7 @@ var JSTPH2_0mm = ({
5180
5281
  };
5181
5282
 
5182
5283
  // lib/JSTXH2_5mm.tsx
5183
- import { fp as fp2 } from "@tscircuit/footprinter";
5284
+ import { fp as fp4 } from "@tscircuit/footprinter";
5184
5285
  var JSTXH2_5mm = ({
5185
5286
  numPins = 4,
5186
5287
  showPins = true,
@@ -5289,7 +5390,7 @@ var JSTXH2_5mm = ({
5289
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)),
5290
5391
  showFootprint && (() => {
5291
5392
  try {
5292
- const circuitJson = fp2.string(`jst${numPins}_xh`).circuitJson();
5393
+ const circuitJson = fp4.string(`jst${numPins}_xh`).circuitJson();
5293
5394
  const platedHoles = circuitJson.filter(
5294
5395
  (e) => e.type === "pcb_plated_hole"
5295
5396
  );
@@ -5785,9 +5886,9 @@ var SmdPinHeader = ({
5785
5886
  import { mm } from "@tscircuit/mm";
5786
5887
 
5787
5888
  // lib/utils/getPlatedHoleCenters.ts
5788
- import { fp as fp3 } from "@tscircuit/footprinter";
5889
+ import { fp as fp5 } from "@tscircuit/footprinter";
5789
5890
  var getPlatedHoleCenters = (footprint) => {
5790
- const elements = fp3.string(footprint).circuitJson();
5891
+ const elements = fp5.string(footprint).circuitJson();
5791
5892
  return elements.filter(
5792
5893
  (element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
5793
5894
  ).map((element) => ({
@@ -5798,9 +5899,9 @@ var getPlatedHoleCenters = (footprint) => {
5798
5899
  };
5799
5900
 
5800
5901
  // lib/utils/getSmtPadRects.ts
5801
- import { fp as fp4 } from "@tscircuit/footprinter";
5902
+ import { fp as fp6 } from "@tscircuit/footprinter";
5802
5903
  var getSmtPadRects = (footprint) => {
5803
- const elements = fp4.string(footprint).circuitJson();
5904
+ const elements = fp6.string(footprint).circuitJson();
5804
5905
  return elements.filter(
5805
5906
  (element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
5806
5907
  ).map((element) => ({
@@ -6556,7 +6657,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
6556
6657
  };
6557
6658
 
6558
6659
  // lib/BGA.tsx
6559
- import { fp as fp5 } from "@tscircuit/footprinter";
6660
+ import { fp as fp7 } from "@tscircuit/footprinter";
6560
6661
  var BGA = ({
6561
6662
  packageWidth = 10,
6562
6663
  packageLength = 10,
@@ -6572,7 +6673,7 @@ var BGA = ({
6572
6673
  const bodyHeight = packageHeight - standoffHeight;
6573
6674
  const bodyOffset = standoffHeight + bodyHeight / 2;
6574
6675
  const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
6575
- const ballsSoup = footprintString ? fp5.string(footprintString).circuitJson() : null;
6676
+ const ballsSoup = footprintString ? fp7.string(footprintString).circuitJson() : null;
6576
6677
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
6577
6678
  /* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
6578
6679
  !footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
@@ -6602,7 +6703,7 @@ var BGA = ({
6602
6703
  };
6603
6704
 
6604
6705
  // lib/UsbCMidmount.tsx
6605
- import { fp as fp6 } from "@tscircuit/footprinter";
6706
+ import { fp as fp8 } from "@tscircuit/footprinter";
6606
6707
  var Capsule = ({
6607
6708
  width: width10,
6608
6709
  height: height10,
@@ -6612,14 +6713,14 @@ var UsbCMidmount = ({
6612
6713
  footprint = "usbcmidmount16"
6613
6714
  }) => {
6614
6715
  const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
6615
- const params = fp6.string(canonical).json();
6616
- const elements = fp6.string(canonical).circuitJson();
6716
+ const params = fp8.string(canonical).json();
6717
+ const elements = fp8.string(canonical).circuitJson();
6617
6718
  const pads = elements.filter(
6618
6719
  (e) => e.type === "pcb_smtpad" && e.shape === "rect"
6619
6720
  );
6620
6721
  const slots = elements.filter((e) => e.type === "pcb_plated_hole");
6621
6722
  const holes = elements.filter((e) => e.type === "pcb_hole");
6622
- const target = fp6.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6723
+ const target = fp8.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6623
6724
  const first = slots[0];
6624
6725
  const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
6625
6726
  const width10 = 8.94, height10 = 3.2, wall = 0.22;
@@ -6703,15 +6804,15 @@ var UsbCMidmount = ({
6703
6804
  };
6704
6805
 
6705
6806
  // lib/SOT143.tsx
6706
- import { fp as fp7 } from "@tscircuit/footprinter";
6707
- var getPads = (footprint) => fp7.string(footprint).circuitJson().filter(
6807
+ import { fp as fp9 } from "@tscircuit/footprinter";
6808
+ var getPads = (footprint) => fp9.string(footprint).circuitJson().filter(
6708
6809
  (element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
6709
6810
  ).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
6710
6811
  var SOT143 = ({ footprint = "sot143" }) => {
6711
6812
  const pads = getPads(footprint);
6712
6813
  if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
6713
6814
  const canonical = getPads("sot143");
6714
- const options = fp7.string(footprint).json();
6815
+ const options = fp9.string(footprint).json();
6715
6816
  const origin = canonical[1];
6716
6817
  const target = pads.find((pad) => pad.pin === "2");
6717
6818
  const angle = options.pin1location ? Math.round(
@@ -7298,6 +7399,26 @@ var FlexScreen = (props) => {
7298
7399
 
7299
7400
  // lib/Footprinter3d.tsx
7300
7401
  var Footprinter3d = ({ footprint }) => {
7402
+ const tantalum = footprint.match(/(?:^|_)tantalum([ABCD])(?:_|$)/);
7403
+ if (tantalum)
7404
+ return /* @__PURE__ */ jsx(
7405
+ TantalumCapacitor,
7406
+ {
7407
+ footprint,
7408
+ caseSize: tantalum[1]
7409
+ }
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
+ );
7301
7422
  const modelFn = mp.string(footprint.split("_", 1)[0]).params().fn;
7302
7423
  if (mp.getModelNames().includes(modelFn)) {
7303
7424
  const model = mp.string(footprint).json();
@@ -7322,7 +7443,7 @@ var Footprinter3d = ({ footprint }) => {
7322
7443
  const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
7323
7444
  normalizedFootprint = `jst${numPins}_xh`;
7324
7445
  }
7325
- const fpJson = fp8.string(normalizedFootprint).json();
7446
+ const fpJson = fp10.string(normalizedFootprint).json();
7326
7447
  const colorMatch = footprint.match(/_color\(([^)]+)\)/);
7327
7448
  const color = colorMatch ? colorMatch[1] : void 0;
7328
7449
  const dim = (value, fallback) => {