jscad-electronics 0.0.164 → 0.0.166
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 +1472 -1314
- package/dist/index.js.map +1 -1
- package/dist/vanilla.js +205 -235
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.js
CHANGED
|
@@ -193,189 +193,8 @@ var ExtrudedPads = ({
|
|
|
193
193
|
] });
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
// lib/CeramicChipAntenna.tsx
|
|
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";
|
|
278
|
-
var twoPadCrystalPackages = {
|
|
279
|
-
FC135: [3.2, 1.5, 0.9, 0.7],
|
|
280
|
-
FC12M: [2.05, 1.2, 0.6, 0.5],
|
|
281
|
-
FC1610AN: [1.65, 1.05, 0.5, 0.4],
|
|
282
|
-
NX3225GD: [3.2, 2.5, 0.8, 1.2]
|
|
283
|
-
};
|
|
284
|
-
var TwoPadCrystal = ({
|
|
285
|
-
packageName = "FC135",
|
|
286
|
-
footprint = "smdpads2_p2.5mm_pw1mm_ph1.8mm"
|
|
287
|
-
}) => {
|
|
288
|
-
const dims = twoPadCrystalPackages[packageName];
|
|
289
|
-
if (!dims) throw new Error("Unsupported two-pad crystal package");
|
|
290
|
-
const [length, width10, height10, terminalLength] = dims;
|
|
291
|
-
const pads = fp4.string(footprint).circuitJson().filter(
|
|
292
|
-
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
293
|
-
);
|
|
294
|
-
if (pads.length !== 2) throw new Error("TwoPadCrystal requires two pads");
|
|
295
|
-
const [a, b] = pads;
|
|
296
|
-
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
297
|
-
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: [
|
|
298
|
-
/* @__PURE__ */ jsx(Colorize, { color: "#e0dcca", children: /* @__PURE__ */ jsx(Cuboid, { size: [length, width10, 0.2], center: [0, 0, 0.13] }) }),
|
|
299
|
-
/* @__PURE__ */ jsx(Colorize, { color: "#acb1b8", children: /* @__PURE__ */ jsx(
|
|
300
|
-
RoundedCuboid,
|
|
301
|
-
{
|
|
302
|
-
size: [length - 0.04, width10 - 0.04, height10 - 0.18],
|
|
303
|
-
roundRadius: 0.035,
|
|
304
|
-
center: [0, 0, (height10 + 0.18) / 2]
|
|
305
|
-
}
|
|
306
|
-
) }),
|
|
307
|
-
/* @__PURE__ */ jsx(Colorize, { color: "#c6af65", children: [-1, 1].map((side) => /* @__PURE__ */ jsx(
|
|
308
|
-
Cuboid,
|
|
309
|
-
{
|
|
310
|
-
size: [terminalLength, width10 - 0.12, 0.06],
|
|
311
|
-
center: [side * (length - terminalLength) / 2, 0, 0.03]
|
|
312
|
-
},
|
|
313
|
-
side
|
|
314
|
-
)) })
|
|
315
|
-
] }) });
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
// lib/TantalumCapacitor.tsx
|
|
319
|
-
import { fp as fp5 } from "@tscircuit/footprinter";
|
|
320
|
-
var tantalumCases = {
|
|
321
|
-
A: [3.2, 1.6, 1.6, 1.2, 0.8],
|
|
322
|
-
B: [3.5, 2.8, 1.9, 2.2, 0.8],
|
|
323
|
-
C: [6, 3.2, 2.6, 2.2, 1.3],
|
|
324
|
-
D: [7.3, 4.3, 2.9, 2.4, 1.3]
|
|
325
|
-
};
|
|
326
|
-
var TantalumCapacitor = ({
|
|
327
|
-
caseSize = "A",
|
|
328
|
-
footprint = "smdpads2_p3.1mm_pw1.4mm_ph1.6mm"
|
|
329
|
-
}) => {
|
|
330
|
-
const dims = tantalumCases[caseSize];
|
|
331
|
-
if (!dims) throw new Error("Unsupported tantalum case");
|
|
332
|
-
const [length, width10, height10, leadWidth, leadLength] = dims;
|
|
333
|
-
const pads = fp5.string(footprint).circuitJson().filter(
|
|
334
|
-
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
335
|
-
);
|
|
336
|
-
if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
|
|
337
|
-
const [a, b] = pads;
|
|
338
|
-
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
339
|
-
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: [
|
|
340
|
-
/* @__PURE__ */ jsx(Colorize, { color: "#d5a64e", children: /* @__PURE__ */ jsxs(Hull, { children: [
|
|
341
|
-
/* @__PURE__ */ jsx(Cuboid, { size: [length - 0.1, width10, 0.02], center: [0, 0, 0.21] }),
|
|
342
|
-
/* @__PURE__ */ jsx(
|
|
343
|
-
Cuboid,
|
|
344
|
-
{
|
|
345
|
-
size: [length - 0.25, width10 - 0.15, 0.02],
|
|
346
|
-
center: [0, 0, height10 - 0.01]
|
|
347
|
-
}
|
|
348
|
-
)
|
|
349
|
-
] }) }),
|
|
350
|
-
/* @__PURE__ */ jsx(Colorize, { color: "#c5c8cb", children: [-1, 1].map((side) => /* @__PURE__ */ jsxs(Union, { children: [
|
|
351
|
-
/* @__PURE__ */ jsx(
|
|
352
|
-
Cuboid,
|
|
353
|
-
{
|
|
354
|
-
size: [leadLength, leadWidth, 0.25],
|
|
355
|
-
center: [side * (length - leadLength) / 2, 0, 0.125]
|
|
356
|
-
}
|
|
357
|
-
),
|
|
358
|
-
/* @__PURE__ */ jsx(
|
|
359
|
-
Cuboid,
|
|
360
|
-
{
|
|
361
|
-
size: [0.15, leadWidth, height10 * 0.45],
|
|
362
|
-
center: [side * (length - 0.15) / 2, 0, height10 * 0.225]
|
|
363
|
-
}
|
|
364
|
-
)
|
|
365
|
-
] }, side)) }),
|
|
366
|
-
/* @__PURE__ */ jsx(
|
|
367
|
-
Cuboid,
|
|
368
|
-
{
|
|
369
|
-
size: [0.25, width10 - 0.25, 0.01],
|
|
370
|
-
center: [-length / 2 + 0.5, 0, height10],
|
|
371
|
-
color: "#423426"
|
|
372
|
-
}
|
|
373
|
-
)
|
|
374
|
-
] }) });
|
|
375
|
-
};
|
|
376
|
-
|
|
377
196
|
// lib/Footprinter3d.tsx
|
|
378
|
-
import { fp as
|
|
197
|
+
import { fp as fp10 } from "@tscircuit/footprinter";
|
|
379
198
|
import { mp } from "@tscircuit/modelprinter";
|
|
380
199
|
|
|
381
200
|
// lib/ChipBody.tsx
|
|
@@ -5361,7 +5180,7 @@ var JSTPH2_0mm = ({
|
|
|
5361
5180
|
};
|
|
5362
5181
|
|
|
5363
5182
|
// lib/JSTXH2_5mm.tsx
|
|
5364
|
-
import { fp as
|
|
5183
|
+
import { fp as fp2 } from "@tscircuit/footprinter";
|
|
5365
5184
|
var JSTXH2_5mm = ({
|
|
5366
5185
|
numPins = 4,
|
|
5367
5186
|
showPins = true,
|
|
@@ -5470,7 +5289,7 @@ var JSTXH2_5mm = ({
|
|
|
5470
5289
|
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)),
|
|
5471
5290
|
showFootprint && (() => {
|
|
5472
5291
|
try {
|
|
5473
|
-
const circuitJson =
|
|
5292
|
+
const circuitJson = fp2.string(`jst${numPins}_xh`).circuitJson();
|
|
5474
5293
|
const platedHoles = circuitJson.filter(
|
|
5475
5294
|
(e) => e.type === "pcb_plated_hole"
|
|
5476
5295
|
);
|
|
@@ -5489,6 +5308,107 @@ var JSTXH2_5mm = ({
|
|
|
5489
5308
|
] });
|
|
5490
5309
|
};
|
|
5491
5310
|
|
|
5311
|
+
// lib/JstSh.tsx
|
|
5312
|
+
import { fp as fp3 } from "@tscircuit/footprinter";
|
|
5313
|
+
import { mm } from "@tscircuit/mm";
|
|
5314
|
+
function isJstShFootprint(footprint) {
|
|
5315
|
+
const p = fp3.string(footprint).json();
|
|
5316
|
+
if (p.fn !== "jst") return false;
|
|
5317
|
+
return Boolean(
|
|
5318
|
+
p.sh || p.smd && Math.abs(mm(p.p) - 1) < 0.01 && Math.abs(mm(p.mpx ?? 0) - (p.num_pins - 1 + 2.6)) < 0.15 && Math.abs(mm(p.mpy ?? 0) - 2.525) < 0.15
|
|
5319
|
+
);
|
|
5320
|
+
}
|
|
5321
|
+
var JstSh = ({ footprint = "jst6_sh" }) => {
|
|
5322
|
+
if (!isJstShFootprint(footprint))
|
|
5323
|
+
throw new Error(
|
|
5324
|
+
"JstSh requires a named SH or matching 1mm SH top-entry footprint"
|
|
5325
|
+
);
|
|
5326
|
+
const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
|
|
5327
|
+
const params = fp3.string(canonical).json();
|
|
5328
|
+
const pads = fp3.string(canonical).circuitJson().filter((e) => e.type === "pcb_smtpad" && e.shape === "rect");
|
|
5329
|
+
const target = fp3.string(footprint).circuitJson().filter(
|
|
5330
|
+
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
5331
|
+
);
|
|
5332
|
+
const n = params.num_pins;
|
|
5333
|
+
if (!Number.isInteger(n) || n < 2 || n > 20 || pads.length !== n + 2)
|
|
5334
|
+
throw new Error("JstSh requires 2\u201320 contacts and two hold-down pads");
|
|
5335
|
+
const signals = pads.slice(0, n), mounts = pads.slice(n);
|
|
5336
|
+
const angle = Math.atan2(target[1].y - target[0].y, target[1].x - target[0].x) - Math.atan2(pads[1].y - pads[0].y, pads[1].x - pads[0].x);
|
|
5337
|
+
const x = signals.reduce((sum, p) => sum + p.x, 0) / n, rowY = signals[0].y;
|
|
5338
|
+
const direction = mounts[0].y > rowY ? 1 : -1;
|
|
5339
|
+
const y = rowY + direction * 1.8, width10 = n + 2, depth = 2.9, height10 = 4.2;
|
|
5340
|
+
const pinY = y - direction * 0.25;
|
|
5341
|
+
return /* @__PURE__ */ jsxs(Rotate, { rotation: [0, 0, angle], children: [
|
|
5342
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#e4e1d6", children: /* @__PURE__ */ jsxs(Subtract, { children: [
|
|
5343
|
+
/* @__PURE__ */ jsx(
|
|
5344
|
+
Cuboid,
|
|
5345
|
+
{
|
|
5346
|
+
size: [width10, depth, height10],
|
|
5347
|
+
center: [x, y, height10 / 2 + 0.05]
|
|
5348
|
+
}
|
|
5349
|
+
),
|
|
5350
|
+
/* @__PURE__ */ jsx(
|
|
5351
|
+
Cuboid,
|
|
5352
|
+
{
|
|
5353
|
+
size: [width10 - 1.3, 1.8, height10],
|
|
5354
|
+
center: [x, y, height10 / 2 + 0.8]
|
|
5355
|
+
}
|
|
5356
|
+
),
|
|
5357
|
+
mounts.map((pad, i) => /* @__PURE__ */ jsx(
|
|
5358
|
+
Cuboid,
|
|
5359
|
+
{
|
|
5360
|
+
size: [0.7, pad.height * 0.8, 1.5],
|
|
5361
|
+
center: [pad.x, pad.y, 0.75]
|
|
5362
|
+
},
|
|
5363
|
+
`recess-${i}`
|
|
5364
|
+
)),
|
|
5365
|
+
[-1, 1].map((side) => /* @__PURE__ */ jsx(
|
|
5366
|
+
Cuboid,
|
|
5367
|
+
{
|
|
5368
|
+
size: [0.55, 0.6, 1],
|
|
5369
|
+
center: [
|
|
5370
|
+
x + side * (width10 / 2 - 0.9),
|
|
5371
|
+
y + direction * depth / 2,
|
|
5372
|
+
4
|
|
5373
|
+
]
|
|
5374
|
+
},
|
|
5375
|
+
side
|
|
5376
|
+
))
|
|
5377
|
+
] }) }),
|
|
5378
|
+
/* @__PURE__ */ jsxs(Colorize, { color: "#c6c7c9", children: [
|
|
5379
|
+
signals.map((pad, i) => {
|
|
5380
|
+
const tailY = pad.y - direction * pad.height * 0.4;
|
|
5381
|
+
return /* @__PURE__ */ jsxs(Union, { children: [
|
|
5382
|
+
/* @__PURE__ */ jsx(
|
|
5383
|
+
Cuboid,
|
|
5384
|
+
{
|
|
5385
|
+
size: [0.2, Math.abs(pinY - tailY) + 0.1, 0.2],
|
|
5386
|
+
center: [pad.x, (pinY + tailY) / 2, 0.1]
|
|
5387
|
+
}
|
|
5388
|
+
),
|
|
5389
|
+
/* @__PURE__ */ jsx(Cuboid, { size: [0.2, 0.2, 3.45], center: [pad.x, pinY, 1.725] })
|
|
5390
|
+
] }, i);
|
|
5391
|
+
}),
|
|
5392
|
+
mounts.map((pad, i) => /* @__PURE__ */ jsxs(Union, { children: [
|
|
5393
|
+
/* @__PURE__ */ jsx(
|
|
5394
|
+
Cuboid,
|
|
5395
|
+
{
|
|
5396
|
+
size: [0.7, pad.height * 0.75, 0.2],
|
|
5397
|
+
center: [pad.x, pad.y, 0.1]
|
|
5398
|
+
}
|
|
5399
|
+
),
|
|
5400
|
+
/* @__PURE__ */ jsx(
|
|
5401
|
+
Cuboid,
|
|
5402
|
+
{
|
|
5403
|
+
size: [0.2, pad.height * 0.6, 1.35],
|
|
5404
|
+
center: [pad.x, pad.y, 0.675]
|
|
5405
|
+
}
|
|
5406
|
+
)
|
|
5407
|
+
] }, `mount-${i}`))
|
|
5408
|
+
] })
|
|
5409
|
+
] });
|
|
5410
|
+
};
|
|
5411
|
+
|
|
5492
5412
|
// lib/Crystal.tsx
|
|
5493
5413
|
var getTerminalPoints = ([centerX, centerY], width10, length, chamfer, isPinOne) => {
|
|
5494
5414
|
const xDirection = Math.sign(centerX);
|
|
@@ -5963,12 +5883,12 @@ var SmdPinHeader = ({
|
|
|
5963
5883
|
};
|
|
5964
5884
|
|
|
5965
5885
|
// lib/Footprinter3d.tsx
|
|
5966
|
-
import { mm } from "@tscircuit/mm";
|
|
5886
|
+
import { mm as mm2 } from "@tscircuit/mm";
|
|
5967
5887
|
|
|
5968
5888
|
// lib/utils/getPlatedHoleCenters.ts
|
|
5969
|
-
import { fp as
|
|
5889
|
+
import { fp as fp4 } from "@tscircuit/footprinter";
|
|
5970
5890
|
var getPlatedHoleCenters = (footprint) => {
|
|
5971
|
-
const elements =
|
|
5891
|
+
const elements = fp4.string(footprint).circuitJson();
|
|
5972
5892
|
return elements.filter(
|
|
5973
5893
|
(element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5974
5894
|
).map((element) => ({
|
|
@@ -5979,9 +5899,9 @@ var getPlatedHoleCenters = (footprint) => {
|
|
|
5979
5899
|
};
|
|
5980
5900
|
|
|
5981
5901
|
// lib/utils/getSmtPadRects.ts
|
|
5982
|
-
import { fp as
|
|
5902
|
+
import { fp as fp5 } from "@tscircuit/footprinter";
|
|
5983
5903
|
var getSmtPadRects = (footprint) => {
|
|
5984
|
-
const elements =
|
|
5904
|
+
const elements = fp5.string(footprint).circuitJson();
|
|
5985
5905
|
return elements.filter(
|
|
5986
5906
|
(element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
|
|
5987
5907
|
).map((element) => ({
|
|
@@ -6697,6 +6617,84 @@ var SmdPushButton = ({
|
|
|
6697
6617
|
] });
|
|
6698
6618
|
};
|
|
6699
6619
|
|
|
6620
|
+
// lib/SmdSlideSwitch.tsx
|
|
6621
|
+
import { fp as fp6 } from "@tscircuit/footprinter";
|
|
6622
|
+
var SmdSlideSwitch = ({
|
|
6623
|
+
footprint = "smdslideswitch7",
|
|
6624
|
+
position = 0
|
|
6625
|
+
}) => {
|
|
6626
|
+
const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
|
|
6627
|
+
const params = fp6.string(canonical).json();
|
|
6628
|
+
const elements = fp6.string(canonical).circuitJson();
|
|
6629
|
+
const pads = elements.filter(
|
|
6630
|
+
(e) => e.type === "pcb_smtpad" && e.shape === "rect"
|
|
6631
|
+
);
|
|
6632
|
+
const target = fp6.string(footprint).circuitJson().filter(
|
|
6633
|
+
(e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
|
|
6634
|
+
);
|
|
6635
|
+
if (pads.length < 7 || !Number.isFinite(params.mpx) || params.mpx < 3)
|
|
6636
|
+
throw new Error("SmdSlideSwitch needs signal pads and four mounting pads");
|
|
6637
|
+
const angle = Math.atan2(target[1].y - target[0].y, target[1].x - target[0].x) - Math.atan2(pads[1].y - pads[0].y, pads[1].x - pads[0].x);
|
|
6638
|
+
const width10 = params.mpx - 0.5, depth = 2.7, height10 = params.mpx > 6 ? 1.5 : 1.4, y = params.mounty;
|
|
6639
|
+
return /* @__PURE__ */ jsxs(Rotate, { rotation: [0, 0, angle], children: [
|
|
6640
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#aeb4ba", children: /* @__PURE__ */ jsxs(Subtract, { children: [
|
|
6641
|
+
/* @__PURE__ */ jsx(Cuboid, { size: [width10, depth, height10], center: [0, y, height10 / 2] }),
|
|
6642
|
+
/* @__PURE__ */ jsx(
|
|
6643
|
+
Cuboid,
|
|
6644
|
+
{
|
|
6645
|
+
size: [width10 - 0.3, depth - 0.3, height10],
|
|
6646
|
+
center: [0, y, height10 / 2 - 0.15]
|
|
6647
|
+
}
|
|
6648
|
+
),
|
|
6649
|
+
/* @__PURE__ */ jsx(Cuboid, { size: [2.7, 0.5, 0.9], center: [0, y - depth / 2, 0.65] })
|
|
6650
|
+
] }) }),
|
|
6651
|
+
/* @__PURE__ */ jsxs(Colorize, { color: "#28292c", children: [
|
|
6652
|
+
/* @__PURE__ */ jsx(
|
|
6653
|
+
Cuboid,
|
|
6654
|
+
{
|
|
6655
|
+
size: [width10 - 0.32, depth - 0.32, 0.35],
|
|
6656
|
+
center: [0, y, 0.175]
|
|
6657
|
+
}
|
|
6658
|
+
),
|
|
6659
|
+
/* @__PURE__ */ jsx(
|
|
6660
|
+
Cuboid,
|
|
6661
|
+
{
|
|
6662
|
+
size: [1, 2.25, 0.65],
|
|
6663
|
+
center: [position === 0 ? -0.5 : 0.5, y - 1.5, 0.65]
|
|
6664
|
+
}
|
|
6665
|
+
),
|
|
6666
|
+
elements.filter((e) => e.type === "pcb_hole").map(
|
|
6667
|
+
(hole, i) => "hole_diameter" in hole && "x" in hole ? /* @__PURE__ */ jsx(
|
|
6668
|
+
Cylinder,
|
|
6669
|
+
{
|
|
6670
|
+
radius: hole.hole_diameter * 0.42,
|
|
6671
|
+
height: 0.6,
|
|
6672
|
+
center: [hole.x, hole.y, -0.2]
|
|
6673
|
+
},
|
|
6674
|
+
i
|
|
6675
|
+
) : null
|
|
6676
|
+
)
|
|
6677
|
+
] }),
|
|
6678
|
+
/* @__PURE__ */ jsx(Colorize, { color: "#c6c7c9", children: pads.map((pad, i) => {
|
|
6679
|
+
const signal = i < pads.length - 4;
|
|
6680
|
+
const outerY = pad.y + pad.height * 0.4;
|
|
6681
|
+
const innerY = Math.min(pad.y - pad.height * 0.4, y + depth / 2 - 0.2);
|
|
6682
|
+
return /* @__PURE__ */ jsx(
|
|
6683
|
+
Cuboid,
|
|
6684
|
+
{
|
|
6685
|
+
size: [
|
|
6686
|
+
pad.width * 0.8,
|
|
6687
|
+
signal ? outerY - innerY : pad.height * 0.8,
|
|
6688
|
+
0.18
|
|
6689
|
+
],
|
|
6690
|
+
center: [pad.x, signal ? (outerY + innerY) / 2 : pad.y, 0.09]
|
|
6691
|
+
},
|
|
6692
|
+
i
|
|
6693
|
+
);
|
|
6694
|
+
}) })
|
|
6695
|
+
] });
|
|
6696
|
+
};
|
|
6697
|
+
|
|
6700
6698
|
// lib/SOT-563.tsx
|
|
6701
6699
|
var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
|
|
6702
6700
|
const bodyWidth = 1.2;
|
|
@@ -6737,7 +6735,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
|
|
|
6737
6735
|
};
|
|
6738
6736
|
|
|
6739
6737
|
// lib/BGA.tsx
|
|
6740
|
-
import { fp as
|
|
6738
|
+
import { fp as fp7 } from "@tscircuit/footprinter";
|
|
6741
6739
|
var BGA = ({
|
|
6742
6740
|
packageWidth = 10,
|
|
6743
6741
|
packageLength = 10,
|
|
@@ -6753,7 +6751,7 @@ var BGA = ({
|
|
|
6753
6751
|
const bodyHeight = packageHeight - standoffHeight;
|
|
6754
6752
|
const bodyOffset = standoffHeight + bodyHeight / 2;
|
|
6755
6753
|
const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
|
|
6756
|
-
const ballsSoup = footprintString ?
|
|
6754
|
+
const ballsSoup = footprintString ? fp7.string(footprintString).circuitJson() : null;
|
|
6757
6755
|
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
6758
6756
|
/* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
|
|
6759
6757
|
!footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
|
|
@@ -6783,7 +6781,7 @@ var BGA = ({
|
|
|
6783
6781
|
};
|
|
6784
6782
|
|
|
6785
6783
|
// lib/UsbCMidmount.tsx
|
|
6786
|
-
import { fp as
|
|
6784
|
+
import { fp as fp8 } from "@tscircuit/footprinter";
|
|
6787
6785
|
var Capsule = ({
|
|
6788
6786
|
width: width10,
|
|
6789
6787
|
height: height10,
|
|
@@ -6793,14 +6791,14 @@ var UsbCMidmount = ({
|
|
|
6793
6791
|
footprint = "usbcmidmount16"
|
|
6794
6792
|
}) => {
|
|
6795
6793
|
const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
|
|
6796
|
-
const params =
|
|
6797
|
-
const elements =
|
|
6794
|
+
const params = fp8.string(canonical).json();
|
|
6795
|
+
const elements = fp8.string(canonical).circuitJson();
|
|
6798
6796
|
const pads = elements.filter(
|
|
6799
6797
|
(e) => e.type === "pcb_smtpad" && e.shape === "rect"
|
|
6800
6798
|
);
|
|
6801
6799
|
const slots = elements.filter((e) => e.type === "pcb_plated_hole");
|
|
6802
6800
|
const holes = elements.filter((e) => e.type === "pcb_hole");
|
|
6803
|
-
const target =
|
|
6801
|
+
const target = fp8.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
|
|
6804
6802
|
const first = slots[0];
|
|
6805
6803
|
const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
|
|
6806
6804
|
const width10 = 8.94, height10 = 3.2, wall = 0.22;
|
|
@@ -6884,15 +6882,15 @@ var UsbCMidmount = ({
|
|
|
6884
6882
|
};
|
|
6885
6883
|
|
|
6886
6884
|
// lib/SOT143.tsx
|
|
6887
|
-
import { fp as
|
|
6888
|
-
var getPads = (footprint) =>
|
|
6885
|
+
import { fp as fp9 } from "@tscircuit/footprinter";
|
|
6886
|
+
var getPads = (footprint) => fp9.string(footprint).circuitJson().filter(
|
|
6889
6887
|
(element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
|
|
6890
6888
|
).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
|
|
6891
6889
|
var SOT143 = ({ footprint = "sot143" }) => {
|
|
6892
6890
|
const pads = getPads(footprint);
|
|
6893
6891
|
if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
|
|
6894
6892
|
const canonical = getPads("sot143");
|
|
6895
|
-
const options =
|
|
6893
|
+
const options = fp9.string(footprint).json();
|
|
6896
6894
|
const origin = canonical[1];
|
|
6897
6895
|
const target = pads.find((pad) => pad.pin === "2");
|
|
6898
6896
|
const angle = options.pin1location ? Math.round(
|
|
@@ -7479,39 +7477,6 @@ var FlexScreen = (props) => {
|
|
|
7479
7477
|
|
|
7480
7478
|
// lib/Footprinter3d.tsx
|
|
7481
7479
|
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
|
-
);
|
|
7495
|
-
const tantalum = footprint.match(/(?:^|_)tantalum([ABCD])(?:_|$)/);
|
|
7496
|
-
if (tantalum)
|
|
7497
|
-
return /* @__PURE__ */ jsx(
|
|
7498
|
-
TantalumCapacitor,
|
|
7499
|
-
{
|
|
7500
|
-
footprint,
|
|
7501
|
-
caseSize: tantalum[1]
|
|
7502
|
-
}
|
|
7503
|
-
);
|
|
7504
|
-
const crystal2 = footprint.match(
|
|
7505
|
-
/(?:^|_)crystal2(FC135|FC12M|FC1610AN|NX3225GD)(?:_|$)/
|
|
7506
|
-
);
|
|
7507
|
-
if (crystal2)
|
|
7508
|
-
return /* @__PURE__ */ jsx(
|
|
7509
|
-
TwoPadCrystal,
|
|
7510
|
-
{
|
|
7511
|
-
footprint,
|
|
7512
|
-
packageName: crystal2[1]
|
|
7513
|
-
}
|
|
7514
|
-
);
|
|
7515
7480
|
const modelFn = mp.string(footprint.split("_", 1)[0]).params().fn;
|
|
7516
7481
|
if (mp.getModelNames().includes(modelFn)) {
|
|
7517
7482
|
const model = mp.string(footprint).json();
|
|
@@ -7536,12 +7501,12 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7536
7501
|
const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
|
|
7537
7502
|
normalizedFootprint = `jst${numPins}_xh`;
|
|
7538
7503
|
}
|
|
7539
|
-
const fpJson =
|
|
7504
|
+
const fpJson = fp10.string(normalizedFootprint).json();
|
|
7540
7505
|
const colorMatch = footprint.match(/_color\(([^)]+)\)/);
|
|
7541
7506
|
const color = colorMatch ? colorMatch[1] : void 0;
|
|
7542
7507
|
const dim = (value, fallback) => {
|
|
7543
7508
|
if (value === void 0 || value === null) return fallback;
|
|
7544
|
-
const parsed =
|
|
7509
|
+
const parsed = mm2(value);
|
|
7545
7510
|
return Number.isFinite(parsed) ? parsed : fallback;
|
|
7546
7511
|
};
|
|
7547
7512
|
switch (fpJson.fn) {
|
|
@@ -7746,6 +7711,8 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7746
7711
|
}
|
|
7747
7712
|
case "sot457":
|
|
7748
7713
|
return /* @__PURE__ */ jsx(SOT457, {});
|
|
7714
|
+
case "smdslideswitch":
|
|
7715
|
+
return /* @__PURE__ */ jsx(SmdSlideSwitch, { footprint: normalizedFootprint });
|
|
7749
7716
|
case "usbcmidmount":
|
|
7750
7717
|
return /* @__PURE__ */ jsx(UsbCMidmount, { footprint: normalizedFootprint });
|
|
7751
7718
|
case "sot143":
|
|
@@ -7776,6 +7743,9 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7776
7743
|
}
|
|
7777
7744
|
);
|
|
7778
7745
|
case "jst":
|
|
7746
|
+
if (isJstShFootprint(normalizedFootprint)) {
|
|
7747
|
+
return /* @__PURE__ */ jsx(JstSh, { footprint: normalizedFootprint });
|
|
7748
|
+
}
|
|
7779
7749
|
if (fpJson.zh) {
|
|
7780
7750
|
return /* @__PURE__ */ jsx(JSTZH1_5mm, { numPins: fpJson.num_pins });
|
|
7781
7751
|
}
|
|
@@ -8152,8 +8122,8 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
8152
8122
|
return /* @__PURE__ */ jsx(A2512, { color });
|
|
8153
8123
|
}
|
|
8154
8124
|
if ((fpJson.fn === "res" || fpJson.fn === "cap") && fpJson.p !== void 0 && fpJson.ph !== void 0) {
|
|
8155
|
-
const padPitch =
|
|
8156
|
-
const padHeight =
|
|
8125
|
+
const padPitch = mm2(fpJson.p);
|
|
8126
|
+
const padHeight = mm2(fpJson.ph);
|
|
8157
8127
|
if (Number.isFinite(padPitch) && Number.isFinite(padHeight)) {
|
|
8158
8128
|
return /* @__PURE__ */ jsx(
|
|
8159
8129
|
ParametricChip,
|