@tscircuit/schematic-trace-solver 0.0.51 → 0.0.53

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 (30) hide show
  1. package/dist/index.d.ts +65 -6
  2. package/dist/index.js +835 -80
  3. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +3 -39
  4. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +16 -0
  5. package/lib/solvers/SchematicTracePipelineSolver/colorAvailableNetOrientationLabels.ts +54 -0
  6. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/TraceAnchoredNetLabelOverlapSolver.ts +331 -0
  7. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/candidates.ts +387 -0
  8. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/geometry.ts +254 -0
  9. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/types.ts +47 -0
  10. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/visualize.ts +159 -0
  11. package/package.json +1 -1
  12. package/tests/assets/example30.json +4 -1
  13. package/tests/examples/__snapshots__/example01.snap.svg +6 -3
  14. package/tests/examples/__snapshots__/example02.snap.svg +8 -4
  15. package/tests/examples/__snapshots__/example04.snap.svg +4 -2
  16. package/tests/examples/__snapshots__/example07.snap.svg +10 -5
  17. package/tests/examples/__snapshots__/example12.snap.svg +8 -4
  18. package/tests/examples/__snapshots__/example13.snap.svg +16 -8
  19. package/tests/examples/__snapshots__/example14.snap.svg +16 -8
  20. package/tests/examples/__snapshots__/example15.snap.svg +18 -9
  21. package/tests/examples/__snapshots__/example16.snap.svg +8 -4
  22. package/tests/examples/__snapshots__/example17.snap.svg +9 -5
  23. package/tests/examples/__snapshots__/example18.snap.svg +10 -5
  24. package/tests/examples/__snapshots__/example20.snap.svg +6 -3
  25. package/tests/examples/__snapshots__/example21.snap.svg +17 -12
  26. package/tests/examples/__snapshots__/example22.snap.svg +8 -4
  27. package/tests/examples/__snapshots__/example25.snap.svg +18 -9
  28. package/tests/examples/__snapshots__/example30.snap.svg +74 -62
  29. package/tests/examples/__snapshots__/example31.snap.svg +2 -1
  30. package/tests/fixtures/matcher.ts +21 -0
@@ -1,6 +1,8 @@
1
1
  import { getSvgFromGraphicsObject, type GraphicsObject } from "graphics-debug"
2
2
  import { expect, type MatcherResult } from "bun:test"
3
3
  import type { BaseSolver } from "lib/solvers/BaseSolver/BaseSolver"
4
+ import { colorAvailableNetOrientationLabels } from "lib/solvers/SchematicTracePipelineSolver/colorAvailableNetOrientationLabels"
5
+ import type { InputProblem } from "lib/types/InputProblem"
4
6
 
5
7
  const getAllElms = (graphicsObject: GraphicsObject) => {
6
8
  return [
@@ -43,6 +45,11 @@ async function toMatchSolverSnapshot(
43
45
  )
44
46
  }
45
47
 
48
+ const inputProblem = getInputProblem(received)
49
+ if (received.solved && inputProblem) {
50
+ colorAvailableNetOrientationLabels(graphicsObject, inputProblem)
51
+ }
52
+
46
53
  const svg = getSvgFromGraphicsObject(graphicsObject, {
47
54
  backgroundColor: "white",
48
55
  })
@@ -50,6 +57,20 @@ async function toMatchSolverSnapshot(
50
57
  return expect(svg).toMatchSvgSnapshot(testPathOriginal, svgName)
51
58
  }
52
59
 
60
+ const getInputProblem = (solver: BaseSolver): InputProblem | undefined => {
61
+ const maybeSolver = solver as BaseSolver & {
62
+ inputProblem?: InputProblem
63
+ input?: { inputProblem?: InputProblem }
64
+ params?: { inputProblem?: InputProblem }
65
+ }
66
+
67
+ return (
68
+ maybeSolver.inputProblem ??
69
+ maybeSolver.input?.inputProblem ??
70
+ maybeSolver.params?.inputProblem
71
+ )
72
+ }
73
+
53
74
  expect.extend({
54
75
  toMatchSolverSnapshot: toMatchSolverSnapshot as any,
55
76
  })