jscad-electronics 0.0.162 → 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/vanilla.js CHANGED
@@ -193,8 +193,48 @@ var ExtrudedPads = ({
193
193
  ] });
194
194
  };
195
195
 
196
- // lib/TwoPadCrystal.tsx
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";
198
238
  var twoPadCrystalPackages = {
199
239
  FC135: [3.2, 1.5, 0.9, 0.7],
200
240
  FC12M: [2.05, 1.2, 0.6, 0.5],
@@ -208,7 +248,7 @@ var TwoPadCrystal = ({
208
248
  const dims = twoPadCrystalPackages[packageName];
209
249
  if (!dims) throw new Error("Unsupported two-pad crystal package");
210
250
  const [length, width10, height10, terminalLength] = dims;
211
- const pads = fp2.string(footprint).circuitJson().filter(
251
+ const pads = fp3.string(footprint).circuitJson().filter(
212
252
  (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
213
253
  );
214
254
  if (pads.length !== 2) throw new Error("TwoPadCrystal requires two pads");
@@ -236,7 +276,7 @@ var TwoPadCrystal = ({
236
276
  };
237
277
 
238
278
  // lib/TantalumCapacitor.tsx
239
- import { fp as fp3 } from "@tscircuit/footprinter";
279
+ import { fp as fp4 } from "@tscircuit/footprinter";
240
280
  var tantalumCases = {
241
281
  A: [3.2, 1.6, 1.6, 1.2, 0.8],
242
282
  B: [3.5, 2.8, 1.9, 2.2, 0.8],
@@ -250,7 +290,7 @@ var TantalumCapacitor = ({
250
290
  const dims = tantalumCases[caseSize];
251
291
  if (!dims) throw new Error("Unsupported tantalum case");
252
292
  const [length, width10, height10, leadWidth, leadLength] = dims;
253
- const pads = fp3.string(footprint).circuitJson().filter(
293
+ const pads = fp4.string(footprint).circuitJson().filter(
254
294
  (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
255
295
  );
256
296
  if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
@@ -295,7 +335,7 @@ var TantalumCapacitor = ({
295
335
  };
296
336
 
297
337
  // lib/Footprinter3d.tsx
298
- import { fp as fp10 } from "@tscircuit/footprinter";
338
+ import { fp as fp11 } from "@tscircuit/footprinter";
299
339
  import { mp } from "@tscircuit/modelprinter";
300
340
 
301
341
  // lib/ChipBody.tsx
@@ -5281,7 +5321,7 @@ var JSTPH2_0mm = ({
5281
5321
  };
5282
5322
 
5283
5323
  // lib/JSTXH2_5mm.tsx
5284
- import { fp as fp4 } from "@tscircuit/footprinter";
5324
+ import { fp as fp5 } from "@tscircuit/footprinter";
5285
5325
  var JSTXH2_5mm = ({
5286
5326
  numPins = 4,
5287
5327
  showPins = true,
@@ -5390,7 +5430,7 @@ var JSTXH2_5mm = ({
5390
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)),
5391
5431
  showFootprint && (() => {
5392
5432
  try {
5393
- const circuitJson = fp4.string(`jst${numPins}_xh`).circuitJson();
5433
+ const circuitJson = fp5.string(`jst${numPins}_xh`).circuitJson();
5394
5434
  const platedHoles = circuitJson.filter(
5395
5435
  (e) => e.type === "pcb_plated_hole"
5396
5436
  );
@@ -5886,9 +5926,9 @@ var SmdPinHeader = ({
5886
5926
  import { mm } from "@tscircuit/mm";
5887
5927
 
5888
5928
  // lib/utils/getPlatedHoleCenters.ts
5889
- import { fp as fp5 } from "@tscircuit/footprinter";
5929
+ import { fp as fp6 } from "@tscircuit/footprinter";
5890
5930
  var getPlatedHoleCenters = (footprint) => {
5891
- const elements = fp5.string(footprint).circuitJson();
5931
+ const elements = fp6.string(footprint).circuitJson();
5892
5932
  return elements.filter(
5893
5933
  (element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
5894
5934
  ).map((element) => ({
@@ -5899,9 +5939,9 @@ var getPlatedHoleCenters = (footprint) => {
5899
5939
  };
5900
5940
 
5901
5941
  // lib/utils/getSmtPadRects.ts
5902
- import { fp as fp6 } from "@tscircuit/footprinter";
5942
+ import { fp as fp7 } from "@tscircuit/footprinter";
5903
5943
  var getSmtPadRects = (footprint) => {
5904
- const elements = fp6.string(footprint).circuitJson();
5944
+ const elements = fp7.string(footprint).circuitJson();
5905
5945
  return elements.filter(
5906
5946
  (element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
5907
5947
  ).map((element) => ({
@@ -6657,7 +6697,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
6657
6697
  };
6658
6698
 
6659
6699
  // lib/BGA.tsx
6660
- import { fp as fp7 } from "@tscircuit/footprinter";
6700
+ import { fp as fp8 } from "@tscircuit/footprinter";
6661
6701
  var BGA = ({
6662
6702
  packageWidth = 10,
6663
6703
  packageLength = 10,
@@ -6673,7 +6713,7 @@ var BGA = ({
6673
6713
  const bodyHeight = packageHeight - standoffHeight;
6674
6714
  const bodyOffset = standoffHeight + bodyHeight / 2;
6675
6715
  const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
6676
- const ballsSoup = footprintString ? fp7.string(footprintString).circuitJson() : null;
6716
+ const ballsSoup = footprintString ? fp8.string(footprintString).circuitJson() : null;
6677
6717
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
6678
6718
  /* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
6679
6719
  !footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
@@ -6703,7 +6743,7 @@ var BGA = ({
6703
6743
  };
6704
6744
 
6705
6745
  // lib/UsbCMidmount.tsx
6706
- import { fp as fp8 } from "@tscircuit/footprinter";
6746
+ import { fp as fp9 } from "@tscircuit/footprinter";
6707
6747
  var Capsule = ({
6708
6748
  width: width10,
6709
6749
  height: height10,
@@ -6713,14 +6753,14 @@ var UsbCMidmount = ({
6713
6753
  footprint = "usbcmidmount16"
6714
6754
  }) => {
6715
6755
  const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
6716
- const params = fp8.string(canonical).json();
6717
- const elements = fp8.string(canonical).circuitJson();
6756
+ const params = fp9.string(canonical).json();
6757
+ const elements = fp9.string(canonical).circuitJson();
6718
6758
  const pads = elements.filter(
6719
6759
  (e) => e.type === "pcb_smtpad" && e.shape === "rect"
6720
6760
  );
6721
6761
  const slots = elements.filter((e) => e.type === "pcb_plated_hole");
6722
6762
  const holes = elements.filter((e) => e.type === "pcb_hole");
6723
- const target = fp8.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6763
+ const target = fp9.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6724
6764
  const first = slots[0];
6725
6765
  const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
6726
6766
  const width10 = 8.94, height10 = 3.2, wall = 0.22;
@@ -6804,15 +6844,15 @@ var UsbCMidmount = ({
6804
6844
  };
6805
6845
 
6806
6846
  // lib/SOT143.tsx
6807
- import { fp as fp9 } from "@tscircuit/footprinter";
6808
- var getPads = (footprint) => fp9.string(footprint).circuitJson().filter(
6847
+ import { fp as fp10 } from "@tscircuit/footprinter";
6848
+ var getPads = (footprint) => fp10.string(footprint).circuitJson().filter(
6809
6849
  (element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
6810
6850
  ).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
6811
6851
  var SOT143 = ({ footprint = "sot143" }) => {
6812
6852
  const pads = getPads(footprint);
6813
6853
  if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
6814
6854
  const canonical = getPads("sot143");
6815
- const options = fp9.string(footprint).json();
6855
+ const options = fp10.string(footprint).json();
6816
6856
  const origin = canonical[1];
6817
6857
  const target = pads.find((pad) => pad.pin === "2");
6818
6858
  const angle = options.pin1location ? Math.round(
@@ -7399,6 +7439,17 @@ var FlexScreen = (props) => {
7399
7439
 
7400
7440
  // lib/Footprinter3d.tsx
7401
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
+ );
7402
7453
  const tantalum = footprint.match(/(?:^|_)tantalum([ABCD])(?:_|$)/);
7403
7454
  if (tantalum)
7404
7455
  return /* @__PURE__ */ jsx(
@@ -7443,7 +7494,7 @@ var Footprinter3d = ({ footprint }) => {
7443
7494
  const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
7444
7495
  normalizedFootprint = `jst${numPins}_xh`;
7445
7496
  }
7446
- const fpJson = fp10.string(normalizedFootprint).json();
7497
+ const fpJson = fp11.string(normalizedFootprint).json();
7447
7498
  const colorMatch = footprint.match(/_color\(([^)]+)\)/);
7448
7499
  const color = colorMatch ? colorMatch[1] : void 0;
7449
7500
  const dim = (value, fallback) => {