@tscircuit/rectdiff 0.0.1 → 0.0.2
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/.github/workflows/bun-formatcheck.yml +1 -1
- package/.github/workflows/bun-pver-release.yml +2 -2
- package/.github/workflows/bun-test.yml +1 -1
- package/.github/workflows/bun-typecheck.yml +1 -1
- package/README.md +139 -0
- package/dist/index.js +195 -37
- package/global.d.ts +2 -2
- package/lib/solvers/RectDiffSolver.ts +15 -3
- package/lib/solvers/rectdiff/candidates.ts +158 -43
- package/lib/solvers/rectdiff/engine.ts +108 -29
- package/lib/solvers/rectdiff/geometry.ts +81 -28
- package/lib/solvers/rectdiff/layers.ts +11 -3
- package/lib/solvers/rectdiff/rectsToMeshNodes.ts +3 -0
- package/lib/solvers/rectdiff/types.ts +4 -1
- package/package.json +6 -2
- package/pages/bugreport11.page.tsx +16 -0
- package/pages/example01.page.tsx +1 -1
- package/test-assets/bugreport11-b2de3c.json +4315 -0
- package/tests/examples/example01.test.tsx +2 -2
- package/tests/fixtures/preload.ts +1 -1
- package/tests/rect-diff-solver.test.ts +6 -5
- package/tests/svg.test.ts +10 -11
- package/.claude/settings.local.json +0 -9
- package/bun.lock +0 -29
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { expect, test } from "bun:test"
|
|
2
|
-
import simpleRouteJson from "../../test-assets/
|
|
2
|
+
import simpleRouteJson from "../../test-assets/example01.json"
|
|
3
3
|
import { RectDiffSolver } from "../../lib/solvers/RectDiffSolver"
|
|
4
4
|
import { getSvgFromGraphicsObject } from "graphics-debug"
|
|
5
5
|
|
|
6
|
-
test("example01", () => {
|
|
6
|
+
test.skip("example01", () => {
|
|
7
7
|
const solver = new RectDiffSolver({ simpleRouteJson })
|
|
8
8
|
|
|
9
9
|
solver.solve()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "bun-match-svg"
|
|
1
|
+
import "bun-match-svg"
|
|
@@ -79,7 +79,7 @@ test("RectDiffSolver handles multi-layer spans", () => {
|
|
|
79
79
|
|
|
80
80
|
// Check if any nodes span multiple layers
|
|
81
81
|
const multiLayerNodes = output.meshNodes.filter(
|
|
82
|
-
(n) => n.availableZ && n.availableZ.length >= 2
|
|
82
|
+
(n) => n.availableZ && n.availableZ.length >= 2,
|
|
83
83
|
)
|
|
84
84
|
|
|
85
85
|
// With no obstacles and preferMultiLayer=true, we should get multi-layer nodes
|
|
@@ -145,10 +145,11 @@ test("disruptive placement resizes single-layer nodes", () => {
|
|
|
145
145
|
|
|
146
146
|
// Expect at least one node spanning multiple layers at/through the center
|
|
147
147
|
const mesh = solver.getOutput().meshNodes
|
|
148
|
-
const throughCenter = mesh.find(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
const throughCenter = mesh.find(
|
|
149
|
+
(n) =>
|
|
150
|
+
Math.abs(n.center.x - 5) < 0.6 &&
|
|
151
|
+
Math.abs(n.center.y - 5) < 0.6 &&
|
|
152
|
+
(n.availableZ?.length ?? 0) >= 2,
|
|
152
153
|
)
|
|
153
154
|
expect(throughCenter).toBeTruthy()
|
|
154
155
|
})
|
package/tests/svg.test.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
|
|
3
|
+
const testSvg = `<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
|
|
4
4
|
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
|
|
5
|
-
</svg>`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
</svg>`
|
|
6
|
+
|
|
7
|
+
test("svg snapshot example", async () => {
|
|
8
|
+
// First run will create the snapshot
|
|
9
|
+
// Subsequent runs will compare against the saved snapshot
|
|
10
|
+
await expect(testSvg).toMatchSvgSnapshot(import.meta.path)
|
|
11
|
+
})
|
package/bun.lock
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"lockfileVersion": 1,
|
|
3
|
-
"workspaces": {
|
|
4
|
-
"": {
|
|
5
|
-
"name": "rectdiff",
|
|
6
|
-
"devDependencies": {
|
|
7
|
-
"@types/bun": "latest",
|
|
8
|
-
},
|
|
9
|
-
"peerDependencies": {
|
|
10
|
-
"typescript": "^5",
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
"packages": {
|
|
15
|
-
"@types/bun": ["@types/bun@1.3.2", "", { "dependencies": { "bun-types": "1.3.2" } }, "sha512-t15P7k5UIgHKkxwnMNkJbWlh/617rkDGEdSsDbu+qNHTaz9SKf7aC8fiIlUdD5RPpH6GEkP0cK7WlvmrEBRtWg=="],
|
|
16
|
-
|
|
17
|
-
"@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
|
|
18
|
-
|
|
19
|
-
"@types/react": ["@types/react@19.2.5", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-keKxkZMqnDicuvFoJbzrhbtdLSPhj/rZThDlKWCDbgXmUg0rEUFtRssDXKYmtXluZlIqiC5VqkCgRwzuyLHKHw=="],
|
|
20
|
-
|
|
21
|
-
"bun-types": ["bun-types@1.3.2", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-i/Gln4tbzKNuxP70OWhJRZz1MRfvqExowP7U6JKoI8cntFrtxg7RJK3jvz7wQW54UuvNC8tbKHHri5fy74FVqg=="],
|
|
22
|
-
|
|
23
|
-
"csstype": ["csstype@3.2.1", "", {}, "sha512-98XGutrXoh75MlgLihlNxAGbUuFQc7l1cqcnEZlLNKc0UrVdPndgmaDmYTDDh929VS/eqTZV0rozmhu2qqT1/g=="],
|
|
24
|
-
|
|
25
|
-
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
26
|
-
|
|
27
|
-
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
|
28
|
-
}
|
|
29
|
-
}
|