jscad-electronics 0.0.162 → 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/vanilla.js CHANGED
@@ -193,8 +193,88 @@ var ExtrudedPads = ({
193
193
  ] });
194
194
  };
195
195
 
196
- // lib/TwoPadCrystal.tsx
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";
238
+ var melfResistorSizes = {
239
+ "0102": [2.2, 1.1, 0.4],
240
+ "0204": [3.6, 1.4, 0.75],
241
+ "0207": [5.8, 2.2, 1.15]
242
+ };
243
+ var MelfResistor = ({
244
+ size = "0204",
245
+ footprint = "smdpads2_p2.8mm_pw1.2mm_ph1.6mm"
246
+ }) => {
247
+ const dims = melfResistorSizes[size];
248
+ if (!dims) throw new Error("Unsupported MELF resistor size");
249
+ const [length, diameter, capLength] = dims;
250
+ const pads = fp3.string(footprint).circuitJson().filter(
251
+ (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
252
+ );
253
+ if (pads.length !== 2) throw new Error("MelfResistor requires two pads");
254
+ const [a, b] = pads;
255
+ const angle = Math.atan2(b.y - a.y, b.x - a.x);
256
+ 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: [
257
+ /* @__PURE__ */ jsx(Colorize, { color: "#426d63", children: /* @__PURE__ */ jsx(
258
+ Cylinder,
259
+ {
260
+ radius: (diameter - 0.08) / 2,
261
+ height: length - 2 * capLength + 0.04
262
+ }
263
+ ) }),
264
+ /* @__PURE__ */ jsx(Colorize, { color: "#c6c8cb", children: [-1, 1].map((side) => /* @__PURE__ */ jsx(
265
+ Cylinder,
266
+ {
267
+ radius: diameter / 2,
268
+ height: capLength,
269
+ center: [0, 0, side * (length - capLength) / 2]
270
+ },
271
+ side
272
+ )) })
273
+ ] }) }) });
274
+ };
275
+
276
+ // lib/TwoPadCrystal.tsx
277
+ import { fp as fp4 } from "@tscircuit/footprinter";
198
278
  var twoPadCrystalPackages = {
199
279
  FC135: [3.2, 1.5, 0.9, 0.7],
200
280
  FC12M: [2.05, 1.2, 0.6, 0.5],
@@ -208,7 +288,7 @@ var TwoPadCrystal = ({
208
288
  const dims = twoPadCrystalPackages[packageName];
209
289
  if (!dims) throw new Error("Unsupported two-pad crystal package");
210
290
  const [length, width10, height10, terminalLength] = dims;
211
- const pads = fp2.string(footprint).circuitJson().filter(
291
+ const pads = fp4.string(footprint).circuitJson().filter(
212
292
  (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
213
293
  );
214
294
  if (pads.length !== 2) throw new Error("TwoPadCrystal requires two pads");
@@ -236,7 +316,7 @@ var TwoPadCrystal = ({
236
316
  };
237
317
 
238
318
  // lib/TantalumCapacitor.tsx
239
- import { fp as fp3 } from "@tscircuit/footprinter";
319
+ import { fp as fp5 } from "@tscircuit/footprinter";
240
320
  var tantalumCases = {
241
321
  A: [3.2, 1.6, 1.6, 1.2, 0.8],
242
322
  B: [3.5, 2.8, 1.9, 2.2, 0.8],
@@ -250,7 +330,7 @@ var TantalumCapacitor = ({
250
330
  const dims = tantalumCases[caseSize];
251
331
  if (!dims) throw new Error("Unsupported tantalum case");
252
332
  const [length, width10, height10, leadWidth, leadLength] = dims;
253
- const pads = fp3.string(footprint).circuitJson().filter(
333
+ const pads = fp5.string(footprint).circuitJson().filter(
254
334
  (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
255
335
  );
256
336
  if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
@@ -295,7 +375,7 @@ var TantalumCapacitor = ({
295
375
  };
296
376
 
297
377
  // lib/Footprinter3d.tsx
298
- import { fp as fp10 } from "@tscircuit/footprinter";
378
+ import { fp as fp12 } from "@tscircuit/footprinter";
299
379
  import { mp } from "@tscircuit/modelprinter";
300
380
 
301
381
  // lib/ChipBody.tsx
@@ -5281,7 +5361,7 @@ var JSTPH2_0mm = ({
5281
5361
  };
5282
5362
 
5283
5363
  // lib/JSTXH2_5mm.tsx
5284
- import { fp as fp4 } from "@tscircuit/footprinter";
5364
+ import { fp as fp6 } from "@tscircuit/footprinter";
5285
5365
  var JSTXH2_5mm = ({
5286
5366
  numPins = 4,
5287
5367
  showPins = true,
@@ -5390,7 +5470,7 @@ var JSTXH2_5mm = ({
5390
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)),
5391
5471
  showFootprint && (() => {
5392
5472
  try {
5393
- const circuitJson = fp4.string(`jst${numPins}_xh`).circuitJson();
5473
+ const circuitJson = fp6.string(`jst${numPins}_xh`).circuitJson();
5394
5474
  const platedHoles = circuitJson.filter(
5395
5475
  (e) => e.type === "pcb_plated_hole"
5396
5476
  );
@@ -5886,9 +5966,9 @@ var SmdPinHeader = ({
5886
5966
  import { mm } from "@tscircuit/mm";
5887
5967
 
5888
5968
  // lib/utils/getPlatedHoleCenters.ts
5889
- import { fp as fp5 } from "@tscircuit/footprinter";
5969
+ import { fp as fp7 } from "@tscircuit/footprinter";
5890
5970
  var getPlatedHoleCenters = (footprint) => {
5891
- const elements = fp5.string(footprint).circuitJson();
5971
+ const elements = fp7.string(footprint).circuitJson();
5892
5972
  return elements.filter(
5893
5973
  (element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
5894
5974
  ).map((element) => ({
@@ -5899,9 +5979,9 @@ var getPlatedHoleCenters = (footprint) => {
5899
5979
  };
5900
5980
 
5901
5981
  // lib/utils/getSmtPadRects.ts
5902
- import { fp as fp6 } from "@tscircuit/footprinter";
5982
+ import { fp as fp8 } from "@tscircuit/footprinter";
5903
5983
  var getSmtPadRects = (footprint) => {
5904
- const elements = fp6.string(footprint).circuitJson();
5984
+ const elements = fp8.string(footprint).circuitJson();
5905
5985
  return elements.filter(
5906
5986
  (element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
5907
5987
  ).map((element) => ({
@@ -6657,7 +6737,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
6657
6737
  };
6658
6738
 
6659
6739
  // lib/BGA.tsx
6660
- import { fp as fp7 } from "@tscircuit/footprinter";
6740
+ import { fp as fp9 } from "@tscircuit/footprinter";
6661
6741
  var BGA = ({
6662
6742
  packageWidth = 10,
6663
6743
  packageLength = 10,
@@ -6673,7 +6753,7 @@ var BGA = ({
6673
6753
  const bodyHeight = packageHeight - standoffHeight;
6674
6754
  const bodyOffset = standoffHeight + bodyHeight / 2;
6675
6755
  const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
6676
- const ballsSoup = footprintString ? fp7.string(footprintString).circuitJson() : null;
6756
+ const ballsSoup = footprintString ? fp9.string(footprintString).circuitJson() : null;
6677
6757
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
6678
6758
  /* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
6679
6759
  !footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
@@ -6703,7 +6783,7 @@ var BGA = ({
6703
6783
  };
6704
6784
 
6705
6785
  // lib/UsbCMidmount.tsx
6706
- import { fp as fp8 } from "@tscircuit/footprinter";
6786
+ import { fp as fp10 } from "@tscircuit/footprinter";
6707
6787
  var Capsule = ({
6708
6788
  width: width10,
6709
6789
  height: height10,
@@ -6713,14 +6793,14 @@ var UsbCMidmount = ({
6713
6793
  footprint = "usbcmidmount16"
6714
6794
  }) => {
6715
6795
  const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
6716
- const params = fp8.string(canonical).json();
6717
- const elements = fp8.string(canonical).circuitJson();
6796
+ const params = fp10.string(canonical).json();
6797
+ const elements = fp10.string(canonical).circuitJson();
6718
6798
  const pads = elements.filter(
6719
6799
  (e) => e.type === "pcb_smtpad" && e.shape === "rect"
6720
6800
  );
6721
6801
  const slots = elements.filter((e) => e.type === "pcb_plated_hole");
6722
6802
  const holes = elements.filter((e) => e.type === "pcb_hole");
6723
- const target = fp8.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6803
+ const target = fp10.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6724
6804
  const first = slots[0];
6725
6805
  const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
6726
6806
  const width10 = 8.94, height10 = 3.2, wall = 0.22;
@@ -6804,15 +6884,15 @@ var UsbCMidmount = ({
6804
6884
  };
6805
6885
 
6806
6886
  // lib/SOT143.tsx
6807
- import { fp as fp9 } from "@tscircuit/footprinter";
6808
- var getPads = (footprint) => fp9.string(footprint).circuitJson().filter(
6887
+ import { fp as fp11 } from "@tscircuit/footprinter";
6888
+ var getPads = (footprint) => fp11.string(footprint).circuitJson().filter(
6809
6889
  (element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
6810
6890
  ).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
6811
6891
  var SOT143 = ({ footprint = "sot143" }) => {
6812
6892
  const pads = getPads(footprint);
6813
6893
  if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
6814
6894
  const canonical = getPads("sot143");
6815
- const options = fp9.string(footprint).json();
6895
+ const options = fp11.string(footprint).json();
6816
6896
  const origin = canonical[1];
6817
6897
  const target = pads.find((pad) => pad.pin === "2");
6818
6898
  const angle = options.pin1location ? Math.round(
@@ -7399,6 +7479,19 @@ var FlexScreen = (props) => {
7399
7479
 
7400
7480
  // lib/Footprinter3d.tsx
7401
7481
  var Footprinter3d = ({ footprint }) => {
7482
+ if (/(?:^|_)antennaRFANT5220110A0T(?:_|$)/.test(footprint))
7483
+ return /* @__PURE__ */ jsx(CeramicChipAntenna, { footprint });
7484
+ const melfResistor = footprint.match(
7485
+ /(?:^|_)melfresistor(0102|0204|0207)(?:_|$)/
7486
+ );
7487
+ if (melfResistor)
7488
+ return /* @__PURE__ */ jsx(
7489
+ MelfResistor,
7490
+ {
7491
+ footprint,
7492
+ size: melfResistor[1]
7493
+ }
7494
+ );
7402
7495
  const tantalum = footprint.match(/(?:^|_)tantalum([ABCD])(?:_|$)/);
7403
7496
  if (tantalum)
7404
7497
  return /* @__PURE__ */ jsx(
@@ -7443,7 +7536,7 @@ var Footprinter3d = ({ footprint }) => {
7443
7536
  const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
7444
7537
  normalizedFootprint = `jst${numPins}_xh`;
7445
7538
  }
7446
- const fpJson = fp10.string(normalizedFootprint).json();
7539
+ const fpJson = fp12.string(normalizedFootprint).json();
7447
7540
  const colorMatch = footprint.match(/_color\(([^)]+)\)/);
7448
7541
  const color = colorMatch ? colorMatch[1] : void 0;
7449
7542
  const dim = (value, fallback) => {