@tscircuit/rectdiff 0.0.1
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/.claude/settings.local.json +9 -0
- package/.github/workflows/bun-formatcheck.yml +26 -0
- package/.github/workflows/bun-pver-release.yml +71 -0
- package/.github/workflows/bun-test.yml +31 -0
- package/.github/workflows/bun-typecheck.yml +26 -0
- package/CLAUDE.md +23 -0
- package/README.md +5 -0
- package/biome.json +93 -0
- package/bun.lock +29 -0
- package/bunfig.toml +5 -0
- package/components/SolverDebugger3d.tsx +833 -0
- package/cosmos.config.json +6 -0
- package/cosmos.decorator.tsx +21 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.js +921 -0
- package/experiments/rect-fill-2d.tsx +983 -0
- package/experiments/rect3d_visualizer.html +640 -0
- package/global.d.ts +4 -0
- package/index.html +12 -0
- package/lib/index.ts +1 -0
- package/lib/solvers/RectDiffSolver.ts +158 -0
- package/lib/solvers/rectdiff/candidates.ts +397 -0
- package/lib/solvers/rectdiff/engine.ts +355 -0
- package/lib/solvers/rectdiff/geometry.ts +284 -0
- package/lib/solvers/rectdiff/layers.ts +48 -0
- package/lib/solvers/rectdiff/rectsToMeshNodes.ts +22 -0
- package/lib/solvers/rectdiff/types.ts +63 -0
- package/lib/types/capacity-mesh-types.ts +33 -0
- package/lib/types/srj-types.ts +37 -0
- package/package.json +33 -0
- package/pages/example01.page.tsx +11 -0
- package/test-assets/example01.json +933 -0
- package/tests/__snapshots__/svg.snap.svg +3 -0
- package/tests/examples/__snapshots__/example01.snap.svg +121 -0
- package/tests/examples/example01.test.tsx +65 -0
- package/tests/fixtures/preload.ts +1 -0
- package/tests/incremental-solver.test.ts +100 -0
- package/tests/rect-diff-solver.test.ts +154 -0
- package/tests/svg.test.ts +12 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Format Check
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
format-check:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup bun
|
|
18
|
+
uses: oven-sh/setup-bun@v2
|
|
19
|
+
with:
|
|
20
|
+
bun-version: latest
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: bun install
|
|
24
|
+
|
|
25
|
+
- name: Run format check
|
|
26
|
+
run: bun run format:check
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Publish to npm
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
UPSTREAM_REPOS: "" # comma-separated list, e.g. "eval,tscircuit,docs"
|
|
11
|
+
UPSTREAM_PACKAGES_TO_UPDATE: "" # comma-separated list, e.g. "@tscircuit/core,@tscircuit/protos"
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
if: ${{ !(github.event_name == 'push' && startsWith(github.event.head_commit.message, 'v')) }}
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
with:
|
|
20
|
+
token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
21
|
+
- name: Setup bun
|
|
22
|
+
uses: oven-sh/setup-bun@v2
|
|
23
|
+
with:
|
|
24
|
+
bun-version: latest
|
|
25
|
+
- uses: actions/setup-node@v3
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20
|
|
28
|
+
registry-url: https://registry.npmjs.org/
|
|
29
|
+
- run: npm install -g pver
|
|
30
|
+
- run: bun install --frozen-lockfile
|
|
31
|
+
- run: bun run build
|
|
32
|
+
- run: pver release --no-push-main
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
+
GITHUB_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
36
|
+
|
|
37
|
+
- name: Create Pull Request
|
|
38
|
+
id: create-pr
|
|
39
|
+
uses: peter-evans/create-pull-request@v5
|
|
40
|
+
with:
|
|
41
|
+
commit-message: "chore: bump version"
|
|
42
|
+
title: "chore: bump version"
|
|
43
|
+
body: "Automated package update"
|
|
44
|
+
branch: bump-version-${{ github.run_number }}
|
|
45
|
+
base: main
|
|
46
|
+
token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
47
|
+
committer: tscircuitbot <githubbot@tscircuit.com>
|
|
48
|
+
author: tscircuitbot <githubbot@tscircuit.com>
|
|
49
|
+
|
|
50
|
+
- name: Enable auto-merge
|
|
51
|
+
if: steps.create-pr.outputs.pull-request-number != ''
|
|
52
|
+
run: |
|
|
53
|
+
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash --delete-branch
|
|
54
|
+
env:
|
|
55
|
+
GH_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
56
|
+
|
|
57
|
+
# - name: Trigger upstream repo updates
|
|
58
|
+
# if: env.UPSTREAM_REPOS && env.UPSTREAM_PACKAGES_TO_UPDATE
|
|
59
|
+
# run: |
|
|
60
|
+
# IFS=',' read -ra REPOS <<< "${{ env.UPSTREAM_REPOS }}"
|
|
61
|
+
# for repo in "${REPOS[@]}"; do
|
|
62
|
+
# if [[ -n "$repo" ]]; then
|
|
63
|
+
# echo "Triggering update for repo: $repo"
|
|
64
|
+
# curl -X POST \
|
|
65
|
+
# -H "Accept: application/vnd.github.v3+json" \
|
|
66
|
+
# -H "Authorization: token ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}" \
|
|
67
|
+
# -H "Content-Type: application/json" \
|
|
68
|
+
# "https://api.github.com/repos/tscircuit/$repo/actions/workflows/update-package.yml/dispatches" \
|
|
69
|
+
# -d "{\"ref\":\"main\",\"inputs\":{\"package_names\":\"${{ env.UPSTREAM_PACKAGES_TO_UPDATE }}\"}}"
|
|
70
|
+
# fi
|
|
71
|
+
# done
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Bun Test
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
pull_request:
|
|
6
|
+
push:
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
timeout-minutes: 5
|
|
14
|
+
|
|
15
|
+
# Skip test for PRs that not chore: bump version
|
|
16
|
+
if: "${{ github.event_name != 'pull_request' || github.event.pull_request.title != 'chore: bump version' }}"
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout code
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Setup bun
|
|
23
|
+
uses: oven-sh/setup-bun@v2
|
|
24
|
+
with:
|
|
25
|
+
bun-version: latest
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: bun install
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
run: bun test
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Type Check
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
type-check:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup bun
|
|
18
|
+
uses: oven-sh/setup-bun@v2
|
|
19
|
+
with:
|
|
20
|
+
bun-version: latest
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: bun i
|
|
24
|
+
|
|
25
|
+
- name: Run type check
|
|
26
|
+
run: bunx tsc --noEmit
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
This is an algorithm solver repo designed to be integrated into the tscircuit
|
|
2
|
+
autorouter.
|
|
3
|
+
|
|
4
|
+
It uses the SimpleRouteJson type as input (see lib/types/srj-types.ts)
|
|
5
|
+
|
|
6
|
+
We use svg snapshots to create visual snapshots as our primary method of
|
|
7
|
+
ensuring the algorithm works correctly. We use `export BUN_UPDATE_SNAPSHOTS=1`
|
|
8
|
+
and `bun test path/to/test.test.ts` to update the snapshots.
|
|
9
|
+
|
|
10
|
+
We use the `graphics-debug` package to turn `GraphicsObject` into SVGs using
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { getSvgFromGraphicsObject } from "graphics-debug"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
We use `cosmos` `*.page.tsx` files inside the `pages` directory to create
|
|
17
|
+
examples that can be debugged for a human.
|
|
18
|
+
|
|
19
|
+
We discovered the algorithm via `experiments/rect3d_visualizer.html` and we're
|
|
20
|
+
now formalizing it into a solver pattern and binding to our normal types.
|
|
21
|
+
|
|
22
|
+
The `test-assets` directory contains assets for test, typically simple route
|
|
23
|
+
json files with test cases that can be importing into pages or tests.
|
package/README.md
ADDED
package/biome.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
|
|
3
|
+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
|
4
|
+
"formatter": {
|
|
5
|
+
"enabled": true,
|
|
6
|
+
"indentStyle": "space"
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"includes": ["**", "!**/cosmos-export", "!**/dist", "!**/package.json"]
|
|
10
|
+
},
|
|
11
|
+
"javascript": {
|
|
12
|
+
"formatter": {
|
|
13
|
+
"jsxQuoteStyle": "double",
|
|
14
|
+
"quoteProperties": "asNeeded",
|
|
15
|
+
"trailingCommas": "all",
|
|
16
|
+
"semicolons": "asNeeded",
|
|
17
|
+
"arrowParentheses": "always",
|
|
18
|
+
"bracketSpacing": true,
|
|
19
|
+
"bracketSameLine": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"linter": {
|
|
23
|
+
"enabled": true,
|
|
24
|
+
"rules": {
|
|
25
|
+
"recommended": true,
|
|
26
|
+
"suspicious": {
|
|
27
|
+
"noExplicitAny": "off"
|
|
28
|
+
},
|
|
29
|
+
"complexity": {
|
|
30
|
+
"noForEach": "off",
|
|
31
|
+
"useLiteralKeys": "off"
|
|
32
|
+
},
|
|
33
|
+
"a11y": {
|
|
34
|
+
"noAccessKey": "off",
|
|
35
|
+
"noAriaHiddenOnFocusable": "off",
|
|
36
|
+
"noAriaUnsupportedElements": "off",
|
|
37
|
+
"noAutofocus": "off",
|
|
38
|
+
"noDistractingElements": "off",
|
|
39
|
+
"noHeaderScope": "off",
|
|
40
|
+
"noInteractiveElementToNoninteractiveRole": "off",
|
|
41
|
+
"noLabelWithoutControl": "off",
|
|
42
|
+
"noNoninteractiveElementToInteractiveRole": "off",
|
|
43
|
+
"noNoninteractiveTabindex": "off",
|
|
44
|
+
"noPositiveTabindex": "off",
|
|
45
|
+
"noRedundantAlt": "off",
|
|
46
|
+
"noRedundantRoles": "off",
|
|
47
|
+
"noStaticElementInteractions": "off",
|
|
48
|
+
"noSvgWithoutTitle": "off",
|
|
49
|
+
"useAltText": "off",
|
|
50
|
+
"useAnchorContent": "off",
|
|
51
|
+
"useAriaActivedescendantWithTabindex": "off",
|
|
52
|
+
"useAriaPropsForRole": "off",
|
|
53
|
+
"useAriaPropsSupportedByRole": "off",
|
|
54
|
+
"useButtonType": "off",
|
|
55
|
+
"useFocusableInteractive": "off",
|
|
56
|
+
"useHeadingContent": "off",
|
|
57
|
+
"useHtmlLang": "off",
|
|
58
|
+
"useIframeTitle": "off",
|
|
59
|
+
"useKeyWithClickEvents": "off",
|
|
60
|
+
"useKeyWithMouseEvents": "off",
|
|
61
|
+
"useMediaCaption": "off",
|
|
62
|
+
"useSemanticElements": "off",
|
|
63
|
+
"useValidAnchor": "off",
|
|
64
|
+
"useValidAriaProps": "off",
|
|
65
|
+
"useValidAriaRole": "off",
|
|
66
|
+
"useValidAriaValues": "off",
|
|
67
|
+
"useValidAutocomplete": "off",
|
|
68
|
+
"useValidLang": "off"
|
|
69
|
+
},
|
|
70
|
+
"style": {
|
|
71
|
+
"useSingleVarDeclarator": "error",
|
|
72
|
+
"noParameterAssign": "off",
|
|
73
|
+
"noUselessElse": "off",
|
|
74
|
+
"noNonNullAssertion": "off",
|
|
75
|
+
"useNumberNamespace": "off",
|
|
76
|
+
"noUnusedTemplateLiteral": "off",
|
|
77
|
+
"useFilenamingConvention": {
|
|
78
|
+
"level": "error",
|
|
79
|
+
"options": {
|
|
80
|
+
"strictCase": true,
|
|
81
|
+
"requireAscii": true,
|
|
82
|
+
"filenameCases": ["kebab-case", "export"]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"useAsConstAssertion": "error",
|
|
86
|
+
"useDefaultParameterLast": "error",
|
|
87
|
+
"useEnumInitializers": "error",
|
|
88
|
+
"useSelfClosingElements": "error",
|
|
89
|
+
"noInferrableTypes": "error"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
package/bun.lock
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|