@tscircuit/core 0.0.51 → 0.0.52
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.js
CHANGED
|
@@ -2223,6 +2223,17 @@ function getClosest(point, candidates) {
|
|
|
2223
2223
|
|
|
2224
2224
|
// lib/components/primitive-components/Trace.ts
|
|
2225
2225
|
import "zod";
|
|
2226
|
+
|
|
2227
|
+
// lib/utils/try-now.ts
|
|
2228
|
+
function tryNow(fn) {
|
|
2229
|
+
try {
|
|
2230
|
+
return [fn(), null];
|
|
2231
|
+
} catch (e) {
|
|
2232
|
+
return [null, e];
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
// lib/components/primitive-components/Trace.ts
|
|
2226
2237
|
var portToObjective = (port) => {
|
|
2227
2238
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
2228
2239
|
return {
|
|
@@ -2400,10 +2411,6 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
2400
2411
|
);
|
|
2401
2412
|
return;
|
|
2402
2413
|
}
|
|
2403
|
-
const pcbElements = db.toArray().filter(
|
|
2404
|
-
(elm) => elm.type === "pcb_smtpad" || elm.type === "pcb_trace" || elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "source_port" || elm.type === "pcb_port" || elm.type === "source_trace" || elm.type === "pcb_keepout"
|
|
2405
|
-
);
|
|
2406
|
-
const source_trace = db.source_trace.get(this.source_trace_id);
|
|
2407
2414
|
const hints = ports.flatMap(
|
|
2408
2415
|
(port) => port.matchedComponents.filter((c) => c.componentName === "TraceHint")
|
|
2409
2416
|
);
|
|
@@ -2451,7 +2458,22 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
2451
2458
|
);
|
|
2452
2459
|
return;
|
|
2453
2460
|
}
|
|
2454
|
-
const obstacles =
|
|
2461
|
+
const [obstacles, err] = tryNow(
|
|
2462
|
+
() => getObstaclesFromSoup(this.root.db.toArray())
|
|
2463
|
+
);
|
|
2464
|
+
if (err) {
|
|
2465
|
+
this.renderError({
|
|
2466
|
+
type: "pcb_error",
|
|
2467
|
+
error_type: "pcb_trace_error",
|
|
2468
|
+
message: `Error getting obstacles for autorouting: ${err.message}`,
|
|
2469
|
+
source_trace_id: this.source_trace_id,
|
|
2470
|
+
center: { x: 0, y: 0 },
|
|
2471
|
+
pcb_port_ids: ports.map((p) => p.pcb_port_id),
|
|
2472
|
+
pcb_trace_id: this.pcb_trace_id,
|
|
2473
|
+
pcb_component_ids: []
|
|
2474
|
+
});
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2455
2477
|
markObstaclesAsConnected(
|
|
2456
2478
|
obstacles,
|
|
2457
2479
|
orderedRouteObjectives,
|
|
@@ -2503,7 +2525,22 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
2503
2525
|
}
|
|
2504
2526
|
}
|
|
2505
2527
|
});
|
|
2506
|
-
|
|
2528
|
+
let traces = null;
|
|
2529
|
+
try {
|
|
2530
|
+
traces = ijump.solveAndMapToTraces();
|
|
2531
|
+
} catch (e) {
|
|
2532
|
+
this.renderError({
|
|
2533
|
+
type: "pcb_error",
|
|
2534
|
+
error_type: "pcb_trace_error",
|
|
2535
|
+
message: `error solving route: ${e.message}`,
|
|
2536
|
+
source_trace_id: this.source_trace_id,
|
|
2537
|
+
center: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 },
|
|
2538
|
+
pcb_port_ids: ports.map((p) => p.pcb_port_id),
|
|
2539
|
+
pcb_trace_id: this.pcb_trace_id,
|
|
2540
|
+
pcb_component_ids: ports.map((p) => p.pcb_component_id)
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
if (!traces) return;
|
|
2507
2544
|
if (traces.length === 0) {
|
|
2508
2545
|
this.renderError({
|
|
2509
2546
|
type: "pcb_error",
|
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
Obstacle,
|
|
20
20
|
SimpleRouteConnection,
|
|
21
21
|
SimpleRouteJson,
|
|
22
|
+
SimplifiedPcbTrace,
|
|
22
23
|
} from "lib/utils/autorouting/SimpleRouteJson"
|
|
23
24
|
import { computeObstacleBounds } from "lib/utils/autorouting/computeObstacleBounds"
|
|
24
25
|
import { projectPointInDirection } from "lib/utils/projectPointInDirection"
|
|
@@ -37,6 +38,7 @@ import {
|
|
|
37
38
|
isMatchingPathSelector,
|
|
38
39
|
isMatchingSelector,
|
|
39
40
|
} from "lib/utils/selector-matching"
|
|
41
|
+
import { tryNow } from "lib/utils/try-now"
|
|
40
42
|
|
|
41
43
|
type PcbRouteObjective =
|
|
42
44
|
| RouteHintPoint
|
|
@@ -285,22 +287,6 @@ export class Trace extends PrimitiveComponent<typeof traceProps> {
|
|
|
285
287
|
return
|
|
286
288
|
}
|
|
287
289
|
|
|
288
|
-
const pcbElements: AnySoupElement[] = db
|
|
289
|
-
.toArray()
|
|
290
|
-
.filter(
|
|
291
|
-
(elm) =>
|
|
292
|
-
elm.type === "pcb_smtpad" ||
|
|
293
|
-
elm.type === "pcb_trace" ||
|
|
294
|
-
elm.type === "pcb_plated_hole" ||
|
|
295
|
-
elm.type === "pcb_hole" ||
|
|
296
|
-
elm.type === "source_port" ||
|
|
297
|
-
elm.type === "pcb_port" ||
|
|
298
|
-
elm.type === "source_trace" ||
|
|
299
|
-
elm.type === "pcb_keepout",
|
|
300
|
-
)
|
|
301
|
-
|
|
302
|
-
const source_trace = db.source_trace.get(this.source_trace_id!)!
|
|
303
|
-
|
|
304
290
|
const hints = ports.flatMap((port) =>
|
|
305
291
|
port.matchedComponents.filter((c) => c.componentName === "TraceHint"),
|
|
306
292
|
) as TraceHint[]
|
|
@@ -372,7 +358,24 @@ export class Trace extends PrimitiveComponent<typeof traceProps> {
|
|
|
372
358
|
|
|
373
359
|
// Cache the PCB obstacles, they'll be needed for each segment between
|
|
374
360
|
// ports/hints
|
|
375
|
-
const obstacles =
|
|
361
|
+
const [obstacles, err] = tryNow(() =>
|
|
362
|
+
getObstaclesFromSoup(this.root!.db.toArray()),
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
if (err) {
|
|
366
|
+
this.renderError({
|
|
367
|
+
type: "pcb_error",
|
|
368
|
+
error_type: "pcb_trace_error",
|
|
369
|
+
message: `Error getting obstacles for autorouting: ${err.message}`,
|
|
370
|
+
source_trace_id: this.source_trace_id!,
|
|
371
|
+
center: { x: 0, y: 0 },
|
|
372
|
+
pcb_port_ids: ports.map((p) => p.pcb_port_id!),
|
|
373
|
+
pcb_trace_id: this.pcb_trace_id!,
|
|
374
|
+
pcb_component_ids: [],
|
|
375
|
+
})
|
|
376
|
+
return
|
|
377
|
+
}
|
|
378
|
+
|
|
376
379
|
markObstaclesAsConnected(
|
|
377
380
|
obstacles,
|
|
378
381
|
orderedRouteObjectives,
|
|
@@ -437,7 +440,22 @@ export class Trace extends PrimitiveComponent<typeof traceProps> {
|
|
|
437
440
|
},
|
|
438
441
|
},
|
|
439
442
|
})
|
|
440
|
-
|
|
443
|
+
let traces: SimplifiedPcbTrace[] | null = null
|
|
444
|
+
try {
|
|
445
|
+
traces = ijump.solveAndMapToTraces()
|
|
446
|
+
} catch (e: any) {
|
|
447
|
+
this.renderError({
|
|
448
|
+
type: "pcb_error",
|
|
449
|
+
error_type: "pcb_trace_error",
|
|
450
|
+
message: `error solving route: ${e.message}`,
|
|
451
|
+
source_trace_id: this.source_trace_id!,
|
|
452
|
+
center: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 },
|
|
453
|
+
pcb_port_ids: ports.map((p) => p.pcb_port_id!),
|
|
454
|
+
pcb_trace_id: this.pcb_trace_id!,
|
|
455
|
+
pcb_component_ids: ports.map((p) => p.pcb_component_id!),
|
|
456
|
+
})
|
|
457
|
+
}
|
|
458
|
+
if (!traces) return
|
|
441
459
|
if (traces.length === 0) {
|
|
442
460
|
this.renderError({
|
|
443
461
|
type: "pcb_error",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"module": "index.ts",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.52",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@lume/kiwi": "^0.4.3",
|
|
37
|
-
"@tscircuit/infgrid-ijump-astar": "^0.0.
|
|
37
|
+
"@tscircuit/infgrid-ijump-astar": "^0.0.11",
|
|
38
38
|
"@tscircuit/props": "^0.0.62",
|
|
39
39
|
"@tscircuit/soup": "^0.0.67",
|
|
40
40
|
"@tscircuit/soup-util": "^0.0.23",
|