jscad-electronics 0.0.78 → 0.0.80

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
@@ -35,6 +35,7 @@ var Hull = Symbol("Hull");
35
35
  var Colorize = Symbol("Colorize");
36
36
  var Polygon = Symbol("Polygon");
37
37
  var ExtrudeLinear = Symbol("ExtrudeLinear");
38
+ var RoundedCylinder = Symbol("RoundedCylinder");
38
39
 
39
40
  // lib/vanilla/react-shim.ts
40
41
  var Fragment2 = Fragment;
@@ -2369,6 +2370,154 @@ var LQFP = ({
2369
2370
  ] });
2370
2371
  };
2371
2372
 
2373
+ // lib/dfn.tsx
2374
+ var DFN = ({
2375
+ num_pins,
2376
+ bodyWidth = 5.3,
2377
+ bodyLength: bodyLength10 = 5.3,
2378
+ bodyThickness = 1,
2379
+ thermalPadSize,
2380
+ // For a body length of 5 the typical pad width/length are 0.6 and 1.
2381
+ // Scale those values proportionally when `bodyLength` changes.
2382
+ padWidth = bodyLength10 / 5.3 * 0.6,
2383
+ padLength = bodyLength10 / 5.3 * 1,
2384
+ pitch = 0.5,
2385
+ thermalPadThickness = 0.2
2386
+ }) => {
2387
+ const pinPositions = [];
2388
+ const pinsPerSide = Math.floor(num_pins / 2);
2389
+ const pinSpan = pitch * (pinsPerSide - 1);
2390
+ for (let i = 0; i < num_pins; i++) {
2391
+ const side = i < pinsPerSide ? "left" : "right";
2392
+ const indexOnSide = i % pinsPerSide;
2393
+ const y = pinSpan / 2 - indexOnSide * pitch;
2394
+ const padSizeX = padLength;
2395
+ const padSizeY = padWidth;
2396
+ const x = side === "left" ? -bodyWidth / 2 + padSizeX / 2 : bodyWidth / 2 - padSizeX / 2;
2397
+ const pinNumber = i + 1;
2398
+ pinPositions.push({ pinNumber, x, y, padSizeX, padSizeY });
2399
+ }
2400
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
2401
+ /* @__PURE__ */ jsx(
2402
+ ChipBody,
2403
+ {
2404
+ center: { x: 0, y: 0, z: 0 },
2405
+ width: bodyWidth,
2406
+ length: bodyLength10,
2407
+ height: bodyThickness,
2408
+ heightAboveSurface: 0,
2409
+ color: "grey",
2410
+ chamferSize: 0.2,
2411
+ taperRatio: 0,
2412
+ notchPosition: {
2413
+ x: bodyWidth / 2 - padLength,
2414
+ y: bodyLength10 / 2 - padLength,
2415
+ z: bodyThickness
2416
+ }
2417
+ }
2418
+ ),
2419
+ pinPositions.map((p, i) => /* @__PURE__ */ jsx(
2420
+ Cuboid,
2421
+ {
2422
+ center: [p.x, p.y, thermalPadThickness / 2],
2423
+ size: [p.padSizeX, p.padSizeY, thermalPadThickness]
2424
+ },
2425
+ i
2426
+ )),
2427
+ thermalPadSize?.length !== void 0 && thermalPadSize?.width !== void 0 && /* @__PURE__ */ jsx(
2428
+ Cuboid,
2429
+ {
2430
+ center: [0, 0, thermalPadThickness / 2],
2431
+ size: [
2432
+ thermalPadSize.width,
2433
+ thermalPadSize.length,
2434
+ thermalPadThickness
2435
+ ]
2436
+ }
2437
+ )
2438
+ ] });
2439
+ };
2440
+
2441
+ // lib/hc49.tsx
2442
+ var HC49 = ({
2443
+ bodyLength: bodyLength10 = 10.2,
2444
+ bodyWidth = 4.65,
2445
+ bodyHeight = 13.46,
2446
+ leadSpacing = 5,
2447
+ leadDiameter = 0.8,
2448
+ leadLength = 12.7,
2449
+ color = "#ddd",
2450
+ leadColor = "#b87333"
2451
+ }) => {
2452
+ const halfLength = bodyLength10 / 2;
2453
+ const endRadius = bodyWidth / 2;
2454
+ const endCenterX = halfLength - endRadius;
2455
+ const leadCenterX = leadSpacing / 2;
2456
+ const baseHeight = 0.85;
2457
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
2458
+ /* @__PURE__ */ jsxs(Colorize, { color, children: [
2459
+ /* @__PURE__ */ jsxs(Hull, { children: [
2460
+ /* @__PURE__ */ jsx(
2461
+ RoundedCylinder,
2462
+ {
2463
+ height: bodyHeight,
2464
+ roundRadius: 0.5,
2465
+ radius: endRadius,
2466
+ center: [-endCenterX, 0, bodyHeight]
2467
+ }
2468
+ ),
2469
+ /* @__PURE__ */ jsx(
2470
+ RoundedCylinder,
2471
+ {
2472
+ height: bodyHeight,
2473
+ roundRadius: 0.5,
2474
+ radius: endRadius,
2475
+ center: [endCenterX, 0, bodyHeight]
2476
+ }
2477
+ )
2478
+ ] }),
2479
+ /* @__PURE__ */ jsxs(Hull, { children: [
2480
+ /* @__PURE__ */ jsx(
2481
+ RoundedCylinder,
2482
+ {
2483
+ height: baseHeight,
2484
+ roundRadius: 0.1,
2485
+ radius: endRadius + 0.85,
2486
+ center: [-endCenterX, 0, bodyHeight / 2 + baseHeight / 2]
2487
+ }
2488
+ ),
2489
+ /* @__PURE__ */ jsx(
2490
+ RoundedCylinder,
2491
+ {
2492
+ height: baseHeight,
2493
+ roundRadius: 0.1,
2494
+ radius: endRadius + 0.85,
2495
+ center: [endCenterX, 0, bodyHeight / 2 + baseHeight / 2]
2496
+ }
2497
+ )
2498
+ ] })
2499
+ ] }),
2500
+ /* @__PURE__ */ jsxs(Colorize, { color: leadColor, children: [
2501
+ /* @__PURE__ */ jsx(
2502
+ Cylinder,
2503
+ {
2504
+ height: leadLength + bodyHeight / 2,
2505
+ radius: leadDiameter / 2,
2506
+ center: [-leadCenterX + 0.06, 0, -(leadLength / 2) + bodyHeight / 2]
2507
+ }
2508
+ ),
2509
+ /* @__PURE__ */ jsx(
2510
+ Cylinder,
2511
+ {
2512
+ height: leadLength + bodyHeight / 2,
2513
+ radius: leadDiameter / 2,
2514
+ center: [leadCenterX - 0.06, 0, -(leadLength / 2) + bodyHeight / 2]
2515
+ }
2516
+ )
2517
+ ] })
2518
+ ] });
2519
+ };
2520
+
2372
2521
  // lib/Footprinter3d.tsx
2373
2522
  var Footprinter3d = ({ footprint }) => {
2374
2523
  const fpJson = fp.string(footprint).json();
@@ -2413,7 +2562,7 @@ var Footprinter3d = ({ footprint }) => {
2413
2562
  return /* @__PURE__ */ jsx(tqfp_default, {});
2414
2563
  case "lqfp":
2415
2564
  return /* @__PURE__ */ jsx(LQFP, { pinCount: fpJson.num_pins });
2416
- case "qfn":
2565
+ case "qfn": {
2417
2566
  const hasThermalPad = typeof fpJson.thermalpad?.x === "number" && typeof fpJson.thermalpad?.y === "number";
2418
2567
  return /* @__PURE__ */ jsx(
2419
2568
  qfn_default,
@@ -2430,6 +2579,25 @@ var Footprinter3d = ({ footprint }) => {
2430
2579
  } : void 0
2431
2580
  }
2432
2581
  );
2582
+ }
2583
+ case "dfn": {
2584
+ const hasThermalPad = typeof fpJson.thermalpad?.x === "number" && typeof fpJson.thermalpad?.y === "number";
2585
+ return /* @__PURE__ */ jsx(
2586
+ DFN,
2587
+ {
2588
+ num_pins: fpJson.num_pins,
2589
+ bodyWidth: fpJson.w,
2590
+ bodyLength: fpJson.h,
2591
+ pitch: fpJson.p,
2592
+ padLength: fpJson.pl,
2593
+ padWidth: fpJson.pw,
2594
+ thermalPadSize: hasThermalPad ? {
2595
+ width: fpJson.thermalpad.x,
2596
+ length: fpJson.thermalpad.y
2597
+ } : void 0
2598
+ }
2599
+ );
2600
+ }
2433
2601
  case "pinrow":
2434
2602
  if (fpJson.male)
2435
2603
  return /* @__PURE__ */ jsx(PinRow, { numberOfPins: fpJson.num_pins, pitch: fpJson.p });
@@ -2499,6 +2667,8 @@ var Footprinter3d = ({ footprint }) => {
2499
2667
  return /* @__PURE__ */ jsx(SOD123FL, {});
2500
2668
  case "sod923":
2501
2669
  return /* @__PURE__ */ jsx(SOD923, {});
2670
+ case "hc49":
2671
+ return /* @__PURE__ */ jsx(HC49, {});
2502
2672
  }
2503
2673
  const colorMatch = footprint.match(/_color\(([^)]+)\)/);
2504
2674
  const color = colorMatch ? colorMatch[1] : void 0;
@@ -2624,7 +2794,7 @@ function renderNode(node, colorCtx, renderCtx) {
2624
2794
  }
2625
2795
  return [{ geom: g3, color: colorCtx ?? props?.color }];
2626
2796
  }
2627
- if (type === Cuboid || type === Cube || type === Cylinder || type === Sphere || type === RoundedCuboid) {
2797
+ if (type === Cuboid || type === Cube || type === Cylinder || type === Sphere || type === RoundedCuboid || type === RoundedCylinder) {
2628
2798
  let g;
2629
2799
  if (type === Cuboid) {
2630
2800
  const size = props?.size ?? [1, 1, 1];
@@ -2645,6 +2815,12 @@ function renderNode(node, colorCtx, renderCtx) {
2645
2815
  const radius = props?.radius ?? 1;
2646
2816
  const center = props?.center ?? [0, 0, 0];
2647
2817
  g = primitives.sphere({ radius, center });
2818
+ } else if (type === RoundedCylinder) {
2819
+ const height10 = props?.height ?? 1;
2820
+ const radius = props?.radius ?? 1;
2821
+ const roundRadius = props?.roundRadius ?? 0.1;
2822
+ const center = props?.center ?? [0, 0, 0];
2823
+ g = primitives.roundedCylinder({ height: height10, radius, roundRadius, center });
2648
2824
  } else {
2649
2825
  const size = props?.size ?? [1, 1, 1];
2650
2826
  const roundRadius = props?.roundRadius ?? 0.1;