@tscircuit/rectdiff 0.0.24 → 0.0.26

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.
Files changed (31) hide show
  1. package/.github/workflows/bun-pver-release.yml +45 -24
  2. package/AGENTS.md +23 -0
  3. package/dist/index.d.ts +26 -0
  4. package/dist/index.js +414 -191
  5. package/lib/RectDiffPipeline.ts +23 -0
  6. package/lib/solvers/OuterLayerContainmentMergeSolver/OuterLayerContainmentMergeSolver.ts +311 -0
  7. package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +23 -23
  8. package/lib/solvers/RectDiffSeedingSolver/computeCandidates3D.ts +9 -10
  9. package/lib/solvers/RectDiffSeedingSolver/computeEdgeCandidates3D.ts +22 -19
  10. package/lib/solvers/RectDiffSeedingSolver/longestFreeSpanAroundZ.ts +1 -1
  11. package/lib/types/srj-types.ts +1 -0
  12. package/lib/utils/expandRectFromSeed.ts +8 -10
  13. package/lib/utils/isFullyOccupiedAtPoint.ts +2 -2
  14. package/lib/utils/rectdiff-geometry.ts +13 -20
  15. package/package.json +3 -1
  16. package/pages/pour.page.tsx +18 -0
  17. package/scripts/benchmark-slow-problem.ts +94 -0
  18. package/test-assets/bugreport49-634662.json +412 -0
  19. package/test-assets/keyboard4.json +16165 -0
  20. package/tests/solver/__snapshots__/rectDiffGridSolverPipeline.snap.svg +1 -1
  21. package/tests/solver/bugreport03-fe4a17/__snapshots__/bugreport03-fe4a17.snap.svg +1 -1
  22. package/tests/solver/bugreport08-e3ec95/__snapshots__/bugreport08-e3ec95.snap.svg +1 -1
  23. package/tests/solver/bugreport09-618e09/__snapshots__/bugreport09-618e09.snap.svg +1 -1
  24. package/tests/solver/bugreport10-71239a/__snapshots__/bugreport10-71239a.snap.svg +1 -1
  25. package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c.snap.svg +1 -1
  26. package/tests/solver/bugreport22-2a75ce/__snapshots__/bugreport22-2a75ce.snap.svg +1 -1
  27. package/tests/solver/bugreport24-05597c/__snapshots__/bugreport24-05597c.snap.svg +1 -1
  28. package/tests/solver/bugreport35-191db9/__snapshots__/bugreport35-191db9.snap.svg +1 -1
  29. package/tests/solver/bugreport36-bf8303/__snapshots__/bugreport36-bf8303.snap.svg +1 -1
  30. package/tests/solver/bugreport49-634662/__snapshots__/bugreport49-634662.snap.svg +44 -0
  31. package/tests/solver/bugreport49-634662/bugreport49-634662.test.ts +134 -0
@@ -4,6 +4,7 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
+ - '!version-bumps/**'
7
8
  workflow_dispatch:
8
9
 
9
10
  env:
@@ -13,35 +14,39 @@ env:
13
14
  jobs:
14
15
  publish:
15
16
  runs-on: ubuntu-latest
16
- if: ${{ !(github.event_name == 'push' && startsWith(github.event.head_commit.message, 'v')) }}
17
17
  steps:
18
18
  - uses: actions/checkout@v4
19
- with:
20
- token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
21
19
  - name: Setup bun
22
20
  uses: oven-sh/setup-bun@v2
23
21
  with:
24
- bun-version: 1.3.1
25
- - uses: actions/setup-node@v3
22
+ bun-version: latest
23
+ - uses: actions/setup-node@v4
26
24
  with:
27
25
  node-version: 20
28
26
  registry-url: https://registry.npmjs.org/
29
27
  - run: npm install -g pver
30
- - run: bun install
28
+ - run: bun install --frozen-lockfile
31
29
  - run: bun run build
32
30
  - run: pver release --no-push-main
33
31
  env:
34
32
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35
33
  GITHUB_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
36
34
 
35
+ - name: Get package version
36
+ id: package-version
37
+ run: |
38
+ VERSION=$(node -p "require('./package.json').version")
39
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
40
+
41
+
37
42
  - name: Create Pull Request
38
43
  id: create-pr
39
- uses: peter-evans/create-pull-request@v5
44
+ uses: peter-evans/create-pull-request@v6
40
45
  with:
41
46
  commit-message: "chore: bump version"
42
- title: "chore: bump version"
47
+ title: "chore: bump version to v${{ steps.package-version.outputs.version }}"
43
48
  body: "Automated package update"
44
- branch: bump-version-${{ github.run_number }}
49
+ branch: version-bumps/v${{ steps.package-version.outputs.version }}
45
50
  base: main
46
51
  token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
47
52
  committer: tscircuitbot <githubbot@tscircuit.com>
@@ -54,18 +59,34 @@ jobs:
54
59
  env:
55
60
  GH_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
56
61
 
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
62
+ - name: Trigger upstream repo updates
63
+ if: env.UPSTREAM_REPOS && env.UPSTREAM_PACKAGES_TO_UPDATE
64
+ run: |
65
+ IFS=',' read -ra REPOS <<< "${{ env.UPSTREAM_REPOS }}"
66
+ for repo in "${REPOS[@]}"; do
67
+ if [[ -n "$repo" ]]; then
68
+ echo "Triggering update for repo: $repo"
69
+ curl -X POST \
70
+ -H "Accept: application/vnd.github.v3+json" \
71
+ -H "Authorization: token ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}" \
72
+ -H "Content-Type: application/json" \
73
+ "https://api.github.com/repos/tscircuit/$repo/actions/workflows/update-package.yml/dispatches" \
74
+ -d "{\"ref\":\"main\",\"inputs\":{\"package_names\":\"${{ env.UPSTREAM_PACKAGES_TO_UPDATE }}\"}}"
75
+ fi
76
+ done
77
+ - name: Notify release-tracker of version update
78
+ # Continue-on-error just in case the tracker is down
79
+ continue-on-error: true
80
+ run: |
81
+ VERSION=$(node -p "require('./package.json').version")
82
+ PACKAGE_JSON=$(cat package.json)
83
+ curl -X POST https://release-tracker.tscircuit.com/release_events/create \
84
+ -H "Content-Type: application/json" \
85
+ -d "{
86
+ \"event\": {
87
+ \"event_type\": \"versions_updated\",
88
+ \"repo\": \"tscircuit/circuit-json-to-kicad\",
89
+ \"version\": \"$VERSION\",
90
+ \"package_json\": $PACKAGE_JSON
91
+ }
92
+ }"
package/AGENTS.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/dist/index.d.ts CHANGED
@@ -34,6 +34,7 @@ interface Obstacle {
34
34
  height: number;
35
35
  connectedTo: TraceId[];
36
36
  netIsAssignable?: boolean;
37
+ isCopperPour?: boolean;
37
38
  offBoardConnectsTo?: TraceId[];
38
39
  }
39
40
  interface SimpleRouteConnection {
@@ -215,6 +216,29 @@ declare class GapFillSolverPipeline extends BasePipelineSolver<GapFillSolverInpu
215
216
  finalVisualize(): GraphicsObject;
216
217
  }
217
218
 
219
+ type OuterLayerContainmentMergeSolverInput = {
220
+ meshNodes: CapacityMeshNode[];
221
+ simpleRouteJson: SimpleRouteJson;
222
+ zIndexByName: Map<string, number>;
223
+ obstacleClearance?: number;
224
+ };
225
+ declare class OuterLayerContainmentMergeSolver extends BaseSolver {
226
+ private input;
227
+ private outputNodes;
228
+ private promotedNodeIds;
229
+ private residualNodeIds;
230
+ constructor(input: OuterLayerContainmentMergeSolverInput);
231
+ _setup(): void;
232
+ _step(): void;
233
+ private processOuterLayerContainmentMerges;
234
+ private buildObstaclesByLayer;
235
+ private isTransitCompatibleAcrossIntermediateLayers;
236
+ getOutput(): {
237
+ outputNodes: CapacityMeshNode[];
238
+ };
239
+ visualize(): GraphicsObject;
240
+ }
241
+
218
242
  type RectDiffSeedingSolverInput = {
219
243
  simpleRouteJson: SimpleRouteJson;
220
244
  obstacleIndexByLayer: Array<RBush<RTreeRect>>;
@@ -242,6 +266,7 @@ declare class RectDiffSeedingSolver extends BaseSolver {
242
266
  private candidates;
243
267
  private placed;
244
268
  private placedIndexByLayer;
269
+ private hardPlacedByLayer;
245
270
  private expansionIndex;
246
271
  private edgeAnalysisDone;
247
272
  private totalSeedsThisGrid;
@@ -364,6 +389,7 @@ interface RectDiffPipelineInput {
364
389
  declare class RectDiffPipeline extends BasePipelineSolver<RectDiffPipelineInput> {
365
390
  rectDiffGridSolverPipeline?: RectDiffGridSolverPipeline;
366
391
  gapFillSolver?: GapFillSolverPipeline;
392
+ outerLayerContainmentMergeSolver?: OuterLayerContainmentMergeSolver;
367
393
  boardVoidRects: XYRect[] | undefined;
368
394
  zIndexByName?: Map<string, number>;
369
395
  layerNames?: string[];