easyeda 0.0.193 → 0.0.195

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.
@@ -2132,21 +2132,6 @@ import { compose, scale, translate, applyToPoint as applyToPoint2 } from "transf
2132
2132
 
2133
2133
  // lib/compute-center-offset.ts
2134
2134
  import { mm } from "@tscircuit/mm";
2135
- var computeCenterOffset = (easyeda) => {
2136
- const pads = easyeda.packageDetail.dataStr.shape.filter(
2137
- (shape) => shape.type === "PAD"
2138
- );
2139
- const minX = Math.min(...pads.map((pad) => mm(pad.center.x)));
2140
- const maxX = Math.max(...pads.map((pad) => mm(pad.center.x)));
2141
- const minY = Math.min(...pads.map((pad) => mm(pad.center.y)));
2142
- const maxY = Math.max(...pads.map((pad) => mm(pad.center.y)));
2143
- const centerX = (minX + maxX) / 2;
2144
- const centerY = (minY + maxY) / 2;
2145
- return {
2146
- x: centerX,
2147
- y: centerY
2148
- };
2149
- };
2150
2135
 
2151
2136
  // lib/convert-easyeda-json-to-tscircuit-soup-json.ts
2152
2137
  import { mm as mm2 } from "@tscircuit/mm";
@@ -2245,8 +2230,7 @@ var handleCutout = (solidRegion, index) => {
2245
2230
  });
2246
2231
  };
2247
2232
  var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecenter = true } = {}) => {
2248
- const soupElements = [];
2249
- const centerOffset = computeCenterOffset(easyEdaJson);
2233
+ const circuitElements = [];
2250
2234
  const source_component = any_source_component.parse({
2251
2235
  type: "source_component",
2252
2236
  source_component_id: "source_component_1",
@@ -2267,7 +2251,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
2267
2251
  center: { x: 0, y: 0 },
2268
2252
  layer: "top"
2269
2253
  });
2270
- soupElements.push(source_component, pcb_component2);
2254
+ circuitElements.push(source_component, pcb_component2);
2271
2255
  const pads = easyEdaJson.packageDetail.dataStr.shape.filter(
2272
2256
  (shape) => shape.type === "PAD"
2273
2257
  );
@@ -2285,7 +2269,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
2285
2269
  const pinNumber = Number.parseInt(
2286
2270
  portHints.find((hint) => hint.match(/pin\d+/)).replace("pin", "")
2287
2271
  );
2288
- soupElements.push({
2272
+ circuitElements.push({
2289
2273
  type: "source_port",
2290
2274
  source_port_id: `source_port_${index + 1}`,
2291
2275
  source_component_id: "source_component_1",
@@ -2335,7 +2319,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
2335
2319
  radius: mil2mm(pad.holeRadius)
2336
2320
  };
2337
2321
  }
2338
- soupElements.push(
2322
+ circuitElements.push(
2339
2323
  pcb_plated_hole.parse({
2340
2324
  ...commonPlatedHoleProps,
2341
2325
  ...additionalPlatedHoleProps
@@ -2370,30 +2354,30 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
2370
2354
  pcb_component_id: "pcb_component_1",
2371
2355
  pcb_port_id: `pcb_port_${index + 1}`
2372
2356
  });
2373
- soupElements.push(parsedPcbSmtpad);
2357
+ circuitElements.push(parsedPcbSmtpad);
2374
2358
  }
2375
2359
  });
2376
2360
  easyEdaJson.packageDetail.dataStr.shape.filter(
2377
2361
  (shape) => shape.type === "HOLE"
2378
2362
  ).forEach((h, index) => {
2379
- soupElements.push(handleHole(h, index));
2380
- soupElements.push(handleHoleCutout(h, index));
2363
+ circuitElements.push(handleHole(h, index));
2364
+ circuitElements.push(handleHoleCutout(h, index));
2381
2365
  });
2382
2366
  easyEdaJson.packageDetail.dataStr.shape.filter((shape) => shape.type === "VIA").forEach((v, index) => {
2383
- soupElements.push(handleVia(v, index));
2367
+ circuitElements.push(handleVia(v, index));
2384
2368
  });
2385
2369
  easyEdaJson.packageDetail.dataStr.shape.filter(
2386
2370
  (shape) => shape.type === "SOLIDREGION" && shape.fillStyle === "cutout"
2387
2371
  ).forEach((sr, index) => {
2388
- soupElements.push(handleCutout(sr, index));
2372
+ circuitElements.push(handleCutout(sr, index));
2389
2373
  });
2390
2374
  easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {
2391
2375
  if (shape.type === "TRACK") {
2392
- soupElements.push(handleSilkscreenPath(shape, index));
2376
+ circuitElements.push(handleSilkscreenPath(shape, index));
2393
2377
  } else if (shape.type === "ARC") {
2394
- soupElements.push(handleSilkscreenArc(shape, index));
2378
+ circuitElements.push(handleSilkscreenArc(shape, index));
2395
2379
  } else if (shape.type === "TEXT") {
2396
- soupElements.push(
2380
+ circuitElements.push(
2397
2381
  pcb_silkscreen_text.parse({
2398
2382
  type: "pcb_silkscreen_text",
2399
2383
  pcb_silkscreen_text_id: `pcb_silkscreen_text_${index + 1}`,
@@ -2421,7 +2405,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
2421
2405
  const objFileUrl = objFileUuid ? useModelCdn ? `https://modelcdn.tscircuit.com/easyeda_models/download?uuid=${objFileUuid}&pn=${easyEdaJson.lcsc.number}` : `https://modules.easyeda.com/3dmodel/${objFileUuid}` : void 0;
2422
2406
  if (objFileUrl !== void 0) {
2423
2407
  const [rx, ry, rz] = (svgNode?.svgData.attrs?.c_rotation ?? "0,0,0").split(",").map(Number);
2424
- soupElements.push(
2408
+ circuitElements.push(
2425
2409
  cad_component.parse({
2426
2410
  type: "cad_component",
2427
2411
  cad_component_id: "cad_component_1",
@@ -2437,14 +2421,14 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
2437
2421
  const bounds = findBoundsAndCenter(
2438
2422
  // exclude the pcb_component because it's center is currently incorrect,
2439
2423
  // we set it to (0,0)
2440
- soupElements.filter((e) => e.type !== "pcb_component")
2424
+ circuitElements.filter((e) => e.type !== "pcb_component")
2441
2425
  );
2442
2426
  const matrix = compose(
2443
2427
  translate(-bounds.center.x, bounds.center.y),
2444
2428
  scale(1, -1)
2445
2429
  );
2446
- transformPCBElements(soupElements, matrix);
2447
- soupElements.forEach((e) => {
2430
+ transformPCBElements(circuitElements, matrix);
2431
+ for (const e of circuitElements) {
2448
2432
  if (e.type === "pcb_cutout") {
2449
2433
  if (e.shape === "polygon") {
2450
2434
  e.points = e.points.map((p) => applyToPoint2(matrix, p));
@@ -2452,10 +2436,10 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
2452
2436
  e.center = applyToPoint2(matrix, e.center);
2453
2437
  }
2454
2438
  }
2455
- });
2439
+ }
2456
2440
  pcb_component2.center = { x: 0, y: 0 };
2457
2441
  }
2458
- return soupElements;
2442
+ return circuitElements;
2459
2443
  };
2460
2444
  var convertEasyEdaJsonToTscircuitSoupJson = convertEasyEdaJsonToCircuitJson;
2461
2445
 
@@ -2522,7 +2506,8 @@ var PointSchema = z84.any().transform((p) => {
2522
2506
  if (Array.isArray(p)) {
2523
2507
  const [x, y] = p;
2524
2508
  return { x, y };
2525
- } else if (typeof p === "object") {
2509
+ }
2510
+ if (typeof p === "object") {
2526
2511
  return p;
2527
2512
  }
2528
2513
  throw new Error(`Invalid point: ${p}`);
@@ -2650,8 +2635,6 @@ var ShapeItemSchema = z84.object({
2650
2635
  type: z84.string(),
2651
2636
  data: z84.string()
2652
2637
  }).transform((shape) => {
2653
- const [firstParam, ...restParams] = shape.data.split("~");
2654
- const lastParam = restParams.pop();
2655
2638
  switch (shape.type) {
2656
2639
  case "TRACK": {
2657
2640
  const [width, layer, _, pointsStr, id, _n] = shape.data.split("~");
@@ -2670,14 +2653,14 @@ var ShapeItemSchema = z84.object({
2670
2653
  number,
2671
2654
  holeRadius,
2672
2655
  ...rest
2673
- ] = params.map((p) => isNaN(Number(p)) ? p : Number(p));
2656
+ ] = params.map((p) => Number.isNaN(Number(p)) ? p : Number(p));
2674
2657
  const center = { x: centerX, y: centerY };
2675
- let points, rotation2;
2658
+ let points;
2676
2659
  if (padShape === "RECT") {
2677
2660
  points = parsePoints(rest[0]);
2678
- const r = Number(rest[1]);
2679
- rotation2 = Number.isNaN(r) ? void 0 : r;
2680
2661
  }
2662
+ const r = Number(rest[1]);
2663
+ const rotation2 = Number.isNaN(r) ? void 0 : r;
2681
2664
  const padInputParams = {
2682
2665
  type: "PAD",
2683
2666
  shape: padShape,
@@ -2816,7 +2799,6 @@ var ShapeItemSchema = z84.object({
2816
2799
  }
2817
2800
  default:
2818
2801
  throw new Error(`Unknown shape type: ${shape.type}`);
2819
- return BaseShapeSchema.parse({ type: shape.type });
2820
2802
  }
2821
2803
  }).pipe(PackageDetailShapeSchema);
2822
2804
  var ShapesArraySchema = z84.array(ShapeItemSchema);
@@ -3372,8 +3354,8 @@ var convertBetterEasyToTsx = async ({
3372
3354
  const sourcePorts = su_default(circuitJson).source_port.list();
3373
3355
  const pinLabels = {};
3374
3356
  const sortedPorts = sourcePorts.sort((a, b) => {
3375
- const aNum = parseInt(a.name.replace("pin", ""));
3376
- const bNum = parseInt(b.name.replace("pin", ""));
3357
+ const aNum = Number.parseInt(a.name.replace("pin", ""));
3358
+ const bNum = Number.parseInt(b.name.replace("pin", ""));
3377
3359
  return aNum - bNum;
3378
3360
  });
3379
3361
  for (const sourcePort of sortedPorts) {
@@ -3505,4 +3487,4 @@ export {
3505
3487
  convertRawEasyToTsx,
3506
3488
  convertEasyEdaJsonToVariousFormats
3507
3489
  };
3508
- //# sourceMappingURL=chunk-IHHD3QWA.js.map
3490
+ //# sourceMappingURL=chunk-UZMC3PUZ.js.map