@tscircuit/rectdiff 0.0.42 → 0.0.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/rectdiff",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "type": "module",
5
5
  "main": "lib/index.ts",
6
6
  "types": "lib/index.ts",
@@ -0,0 +1,10 @@
1
+ import simpleRouteJson from "../test-assets/simplified-out-of-bounds-example.json"
2
+ import { RectDiffPipeline } from "../lib/RectDiffPipeline"
3
+ import { useMemo } from "react"
4
+ import { SolverDebugger3d } from "../components/SolverDebugger3d"
5
+
6
+ export default () => {
7
+ const solver = useMemo(() => new RectDiffPipeline({ simpleRouteJson }), [])
8
+
9
+ return <SolverDebugger3d solver={solver} simpleRouteJson={simpleRouteJson} />
10
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "bounds": {
3
+ "minX": -5.5,
4
+ "maxX": 5.5,
5
+ "minY": -6,
6
+ "maxY": 6
7
+ },
8
+ "obstacles": [
9
+ {
10
+ "type": "rect",
11
+ "layers": ["top"],
12
+ "center": {
13
+ "x": -5.856893060790263,
14
+ "y": -8.275436101920713
15
+ },
16
+ "width": 2,
17
+ "height": 2,
18
+ "connectedTo": []
19
+ }
20
+ ],
21
+ "connections": [],
22
+ "layerCount": 2,
23
+ "minTraceWidth": 0.15
24
+ }
@@ -0,0 +1,33 @@
1
+ import { expect, test } from "bun:test"
2
+ import simpleRouteJson from "../test-assets/simplified-out-of-bounds-example.json"
3
+ import { RectDiffPipeline } from "../lib/RectDiffPipeline"
4
+
5
+ test("simplified out-of-bounds fixture currently creates a generated node outside the board bounds", () => {
6
+ const solver = new RectDiffPipeline({ simpleRouteJson })
7
+
8
+ solver.solve()
9
+
10
+ const { meshNodes } = solver.getOutput()
11
+ const outsideGeneratedNodes = meshNodes.filter((node) => {
12
+ if (!node.capacityMeshNodeId.startsWith("new-")) return false
13
+
14
+ const minX = node.center.x - node.width / 2
15
+ const maxX = node.center.x + node.width / 2
16
+ const minY = node.center.y - node.height / 2
17
+ const maxY = node.center.y + node.height / 2
18
+
19
+ return (
20
+ minX < simpleRouteJson.bounds.minX ||
21
+ maxX > simpleRouteJson.bounds.maxX ||
22
+ minY < simpleRouteJson.bounds.minY ||
23
+ maxY > simpleRouteJson.bounds.maxY
24
+ )
25
+ })
26
+
27
+ expect(solver.solved).toBe(true)
28
+ expect(meshNodes.length).toBeGreaterThan(0)
29
+ expect(outsideGeneratedNodes.length).toBeGreaterThan(0)
30
+ expect(outsideGeneratedNodes[0]!.capacityMeshNodeId.startsWith("new-")).toBe(
31
+ true,
32
+ )
33
+ })