@tscircuit/schematic-trace-solver 0.0.26 → 0.0.27

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 (28) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +8 -0
  3. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver.ts +11 -0
  4. package/package.json +1 -1
  5. package/site/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver01.page.tsx +574 -0
  6. package/site/examples/example11.page.tsx +1 -1
  7. package/site/examples/example12.page.tsx +1 -1
  8. package/site/examples/example13.page.tsx +219 -0
  9. package/site/examples/example14.page.tsx +210 -0
  10. package/tests/examples/__snapshots__/example01.snap.svg +4 -4
  11. package/tests/examples/__snapshots__/example02.snap.svg +4 -4
  12. package/tests/examples/__snapshots__/example03.snap.svg +68 -68
  13. package/tests/examples/__snapshots__/example04.snap.svg +12 -12
  14. package/tests/examples/__snapshots__/example05.snap.svg +1 -1
  15. package/tests/examples/__snapshots__/example06.snap.svg +11 -11
  16. package/tests/examples/__snapshots__/example07.snap.svg +48 -48
  17. package/tests/examples/__snapshots__/example08.snap.svg +25 -25
  18. package/tests/examples/__snapshots__/example09.snap.svg +131 -131
  19. package/tests/examples/__snapshots__/example10.snap.svg +26 -26
  20. package/tests/examples/__snapshots__/example11.snap.svg +162 -0
  21. package/tests/examples/__snapshots__/example12.snap.svg +145 -0
  22. package/tests/examples/__snapshots__/example13.snap.svg +316 -0
  23. package/tests/examples/__snapshots__/example14.snap.svg +213 -0
  24. package/tests/examples/example11.test.tsx +12 -0
  25. package/tests/examples/example12.test.tsx +12 -0
  26. package/tests/examples/example13.test.tsx +12 -0
  27. package/tests/examples/example14.test.tsx +12 -0
  28. package/tests/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver01.test.ts +13 -0
package/dist/index.d.ts CHANGED
@@ -331,6 +331,7 @@ declare class SingleNetLabelPlacementSolver extends BaseSolver {
331
331
  overlappingSameNetTraceGroup: OverlappingSameNetTraceGroup;
332
332
  availableOrientations: FacingDirection[];
333
333
  });
334
+ getConstructorParams(): ConstructorParameters<typeof SingleNetLabelPlacementSolver>[0];
334
335
  _step(): void;
335
336
  visualize(): GraphicsObject;
336
337
  }
package/dist/index.js CHANGED
@@ -1579,6 +1579,14 @@ var SingleNetLabelPlacementSolver = class extends BaseSolver {
1579
1579
  this.availableOrientations = params.availableOrientations;
1580
1580
  this.chipObstacleSpatialIndex = params.inputProblem._chipObstacleSpatialIndex ?? new ChipObstacleSpatialIndex(params.inputProblem.chips);
1581
1581
  }
1582
+ getConstructorParams() {
1583
+ return {
1584
+ inputProblem: this.inputProblem,
1585
+ inputTraceMap: this.inputTraceMap,
1586
+ overlappingSameNetTraceGroup: this.overlappingSameNetTraceGroup,
1587
+ availableOrientations: this.availableOrientations
1588
+ };
1589
+ }
1582
1590
  _step() {
1583
1591
  if (this.netLabelPlacement) {
1584
1592
  this.solved = true;
@@ -87,6 +87,17 @@ export class SingleNetLabelPlacementSolver extends BaseSolver {
87
87
  new ChipObstacleSpatialIndex(params.inputProblem.chips)
88
88
  }
89
89
 
90
+ override getConstructorParams(): ConstructorParameters<
91
+ typeof SingleNetLabelPlacementSolver
92
+ >[0] {
93
+ return {
94
+ inputProblem: this.inputProblem,
95
+ inputTraceMap: this.inputTraceMap,
96
+ overlappingSameNetTraceGroup: this.overlappingSameNetTraceGroup,
97
+ availableOrientations: this.availableOrientations,
98
+ }
99
+ }
100
+
90
101
  override _step() {
91
102
  if (this.netLabelPlacement) {
92
103
  this.solved = true
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/schematic-trace-solver",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.26",
4
+ "version": "0.0.27",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "cosmos",
@@ -0,0 +1,574 @@
1
+ import { useMemo } from "react"
2
+ import { GenericSolverDebugger } from "../components/GenericSolverDebugger"
3
+ import { SingleNetLabelPlacementSolver } from "lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver"
4
+
5
+ export const input = {
6
+ inputProblem: {
7
+ chips: [
8
+ {
9
+ chipId: "schematic_component_0",
10
+ center: {
11
+ x: 0,
12
+ y: 0,
13
+ },
14
+ width: 2.4000000000000004,
15
+ height: 1,
16
+ pins: [
17
+ {
18
+ pinId: "U1.1",
19
+ x: 1.2000000000000002,
20
+ y: -0.30000000000000004,
21
+ },
22
+ {
23
+ pinId: "U1.2",
24
+ x: -1.2000000000000002,
25
+ y: -0.30000000000000004,
26
+ },
27
+ {
28
+ pinId: "U1.3",
29
+ x: 1.2000000000000002,
30
+ y: 0.09999999999999998,
31
+ },
32
+ {
33
+ pinId: "U1.4",
34
+ x: -1.2000000000000002,
35
+ y: 0.30000000000000004,
36
+ },
37
+ {
38
+ pinId: "U1.5",
39
+ x: -1.2000000000000002,
40
+ y: 0.10000000000000003,
41
+ },
42
+ {
43
+ pinId: "U1.6",
44
+ x: -1.2000000000000002,
45
+ y: -0.09999999999999998,
46
+ },
47
+ {
48
+ pinId: "U1.7",
49
+ x: 1.2000000000000002,
50
+ y: -0.10000000000000003,
51
+ },
52
+ {
53
+ pinId: "U1.8",
54
+ x: 1.2000000000000002,
55
+ y: 0.30000000000000004,
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ chipId: "schematic_component_1",
61
+ center: {
62
+ x: 2.45,
63
+ y: -0.10000000000000009,
64
+ },
65
+ width: 1.0999999999999996,
66
+ height: 0.388910699999999,
67
+ pins: [
68
+ {
69
+ pinId: "R1.1",
70
+ x: 3,
71
+ y: -0.10000000000000016,
72
+ },
73
+ {
74
+ pinId: "R1.2",
75
+ x: 1.9000000000000004,
76
+ y: -0.10000000000000002,
77
+ },
78
+ ],
79
+ },
80
+ {
81
+ chipId: "schematic_component_2",
82
+ center: {
83
+ x: 0.6500000000000001,
84
+ y: -1.2944553500000002,
85
+ },
86
+ width: 1.1,
87
+ height: 0.388910699999999,
88
+ pins: [
89
+ {
90
+ pinId: "R2.1",
91
+ x: 1.2000000000000002,
92
+ y: -1.2944553500000002,
93
+ },
94
+ {
95
+ pinId: "R2.2",
96
+ x: 0.10000000000000009,
97
+ y: -1.2944553500000002,
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ chipId: "schematic_component_3",
103
+ center: {
104
+ x: -1.2000000000000002,
105
+ y: -1.7000000000000002,
106
+ },
107
+ width: 1.06,
108
+ height: 1.1,
109
+ pins: [
110
+ {
111
+ pinId: "C1.1",
112
+ x: -1.2000000000000002,
113
+ y: -1.1500000000000001,
114
+ },
115
+ {
116
+ pinId: "C1.2",
117
+ x: -1.2000000000000002,
118
+ y: -2.25,
119
+ },
120
+ ],
121
+ },
122
+ {
123
+ chipId: "schematic_component_4",
124
+ center: {
125
+ x: -2.45,
126
+ y: 0.10000000000000009,
127
+ },
128
+ width: 1.0999999999999996,
129
+ height: 0.84,
130
+ pins: [
131
+ {
132
+ pinId: "C2.1",
133
+ x: -1.9000000000000004,
134
+ y: 0.10000000000000002,
135
+ },
136
+ {
137
+ pinId: "C2.2",
138
+ x: -3,
139
+ y: 0.10000000000000016,
140
+ },
141
+ ],
142
+ },
143
+ {
144
+ chipId: "schematic_component_5",
145
+ center: {
146
+ x: 1.2000000000000002,
147
+ y: 1.7000000000000002,
148
+ },
149
+ width: 1.06,
150
+ height: 1.1,
151
+ pins: [
152
+ {
153
+ pinId: "R3.1",
154
+ x: 1.2000000000000002,
155
+ y: 1.1500000000000001,
156
+ },
157
+ {
158
+ pinId: "R3.2",
159
+ x: 1.2000000000000002,
160
+ y: 2.25,
161
+ },
162
+ ],
163
+ },
164
+ ],
165
+ directConnections: [
166
+ {
167
+ pinIds: ["U1.5", "C2.1"],
168
+ netId: "U1.CTRL to C2.pin1",
169
+ },
170
+ {
171
+ pinIds: ["U1.6", "U1.2"],
172
+ netId: "U1.THRES to U1.TRIG",
173
+ },
174
+ {
175
+ pinIds: ["R1.2", "U1.7"],
176
+ netId: "R1.pin2 to U1.DISCH",
177
+ },
178
+ {
179
+ pinIds: ["U1.7", "R2.1"],
180
+ netId: "U1.DISCH to R2.pin1",
181
+ },
182
+ {
183
+ pinIds: ["R2.2", "U1.6"],
184
+ netId: "R2.pin2 to U1.THRES",
185
+ },
186
+ {
187
+ pinIds: ["U1.6", "C1.1"],
188
+ netId: "U1.THRES to C1.pin1",
189
+ },
190
+ {
191
+ pinIds: ["U1.3", "R3.1"],
192
+ netId: "U1.OUT to R3.pin1",
193
+ },
194
+ ],
195
+ netConnections: [
196
+ {
197
+ netId: "GND",
198
+ pinIds: ["U1.1", "C1.2", "C2.2"],
199
+ },
200
+ {
201
+ netId: "VCC",
202
+ pinIds: ["U1.4", "U1.8", "R1.1"],
203
+ },
204
+ ],
205
+ availableNetLabelOrientations: {
206
+ VCC: ["y+"],
207
+ GND: ["y-"],
208
+ },
209
+ maxMspPairDistance: 2.4,
210
+ },
211
+ inputTraceMap: {
212
+ "U1.5-C2.1": {
213
+ mspPairId: "U1.5-C2.1",
214
+ dcConnNetId: "connectivity_net0",
215
+ globalConnNetId: "connectivity_net0",
216
+ userNetId: "U1.CTRL to C2.pin1",
217
+ pins: [
218
+ {
219
+ pinId: "U1.5",
220
+ x: -1.2000000000000002,
221
+ y: 0.10000000000000003,
222
+ chipId: "schematic_component_0",
223
+ },
224
+ {
225
+ pinId: "C2.1",
226
+ x: -1.9000000000000004,
227
+ y: 0.10000000000000002,
228
+ chipId: "schematic_component_4",
229
+ },
230
+ ],
231
+ tracePath: [
232
+ {
233
+ x: -1.2000000000000002,
234
+ y: 0.10000000000000003,
235
+ },
236
+ {
237
+ x: -1.4000000000000001,
238
+ y: 0.10000000000000003,
239
+ },
240
+ {
241
+ x: -1.5500000000000003,
242
+ y: 0.10000000000000003,
243
+ },
244
+ {
245
+ x: -1.5500000000000003,
246
+ y: 0.10000000000000002,
247
+ },
248
+ {
249
+ x: -1.7000000000000004,
250
+ y: 0.10000000000000002,
251
+ },
252
+ {
253
+ x: -1.9000000000000004,
254
+ y: 0.10000000000000002,
255
+ },
256
+ ],
257
+ mspConnectionPairIds: ["U1.5-C2.1"],
258
+ pinIds: ["U1.5", "C2.1"],
259
+ },
260
+ "U1.2-C1.1": {
261
+ mspPairId: "U1.2-C1.1",
262
+ dcConnNetId: "connectivity_net1",
263
+ globalConnNetId: "connectivity_net1",
264
+ userNetId: "U1.THRES to U1.TRIG",
265
+ pins: [
266
+ {
267
+ pinId: "U1.2",
268
+ x: -1.2000000000000002,
269
+ y: -0.30000000000000004,
270
+ chipId: "schematic_component_0",
271
+ },
272
+ {
273
+ pinId: "C1.1",
274
+ x: -1.2000000000000002,
275
+ y: -1.1500000000000001,
276
+ chipId: "schematic_component_3",
277
+ },
278
+ ],
279
+ tracePath: [
280
+ {
281
+ x: -1.2000000000000002,
282
+ y: -0.30000000000000004,
283
+ },
284
+ {
285
+ x: -1.4000000000000001,
286
+ y: -0.30000000000000004,
287
+ },
288
+ {
289
+ x: -1.4000000000000001,
290
+ y: -0.7250000000000001,
291
+ },
292
+ {
293
+ x: -1.2000000000000002,
294
+ y: -0.7250000000000001,
295
+ },
296
+ {
297
+ x: -1.2000000000000002,
298
+ y: -1.1500000000000001,
299
+ },
300
+ ],
301
+ mspConnectionPairIds: ["U1.2-C1.1"],
302
+ pinIds: ["U1.2", "C1.1"],
303
+ },
304
+ "U1.6-U1.2": {
305
+ mspPairId: "U1.6-U1.2",
306
+ dcConnNetId: "connectivity_net1",
307
+ globalConnNetId: "connectivity_net1",
308
+ userNetId: "U1.THRES to C1.pin1",
309
+ pins: [
310
+ {
311
+ pinId: "U1.6",
312
+ x: -1.2000000000000002,
313
+ y: -0.09999999999999998,
314
+ chipId: "schematic_component_0",
315
+ },
316
+ {
317
+ pinId: "U1.2",
318
+ x: -1.2000000000000002,
319
+ y: -0.30000000000000004,
320
+ chipId: "schematic_component_0",
321
+ },
322
+ ],
323
+ tracePath: [
324
+ {
325
+ x: -1.2000000000000002,
326
+ y: -0.09999999999999998,
327
+ },
328
+ {
329
+ x: -1.4000000000000001,
330
+ y: -0.09999999999999998,
331
+ },
332
+ {
333
+ x: -1.4000000000000001,
334
+ y: -0.30000000000000004,
335
+ },
336
+ {
337
+ x: -1.2000000000000002,
338
+ y: -0.30000000000000004,
339
+ },
340
+ ],
341
+ mspConnectionPairIds: ["U1.6-U1.2"],
342
+ pinIds: ["U1.6", "U1.2"],
343
+ },
344
+ "R2.2-C1.1": {
345
+ mspPairId: "R2.2-C1.1",
346
+ dcConnNetId: "connectivity_net1",
347
+ globalConnNetId: "connectivity_net1",
348
+ userNetId: "R2.pin2 to U1.THRES",
349
+ pins: [
350
+ {
351
+ pinId: "R2.2",
352
+ x: 0.10000000000000009,
353
+ y: -1.2944553500000002,
354
+ chipId: "schematic_component_2",
355
+ },
356
+ {
357
+ pinId: "C1.1",
358
+ x: -1.2000000000000002,
359
+ y: -1.1500000000000001,
360
+ chipId: "schematic_component_3",
361
+ },
362
+ ],
363
+ tracePath: [
364
+ {
365
+ x: 0.09999999999999987,
366
+ y: -1.2944553500000002,
367
+ },
368
+ {
369
+ x: -0.55,
370
+ y: -1.2944553500000002,
371
+ },
372
+ {
373
+ x: -0.55,
374
+ y: -0.9500000000000002,
375
+ },
376
+ {
377
+ x: -1.2000000000000002,
378
+ y: -0.9500000000000002,
379
+ },
380
+ {
381
+ x: -1.2000000000000002,
382
+ y: -1.1500000000000001,
383
+ },
384
+ ],
385
+ mspConnectionPairIds: ["R2.2-C1.1"],
386
+ pinIds: ["R2.2", "C1.1"],
387
+ },
388
+ "U1.7-R1.2": {
389
+ mspPairId: "U1.7-R1.2",
390
+ dcConnNetId: "connectivity_net2",
391
+ globalConnNetId: "connectivity_net2",
392
+ userNetId: "U1.DISCH to R2.pin1",
393
+ pins: [
394
+ {
395
+ pinId: "U1.7",
396
+ x: 1.2000000000000002,
397
+ y: -0.10000000000000003,
398
+ chipId: "schematic_component_0",
399
+ },
400
+ {
401
+ pinId: "R1.2",
402
+ x: 1.9000000000000004,
403
+ y: -0.10000000000000002,
404
+ chipId: "schematic_component_1",
405
+ },
406
+ ],
407
+ tracePath: [
408
+ {
409
+ x: 1.2000000000000002,
410
+ y: -0.10000000000000003,
411
+ },
412
+ {
413
+ x: 1.4000000000000001,
414
+ y: -0.10000000000000003,
415
+ },
416
+ {
417
+ x: 1.5500000000000003,
418
+ y: -0.10000000000000003,
419
+ },
420
+ {
421
+ x: 1.5500000000000003,
422
+ y: -0.10000000000000002,
423
+ },
424
+ {
425
+ x: 1.7000000000000004,
426
+ y: -0.10000000000000002,
427
+ },
428
+ {
429
+ x: 1.9000000000000004,
430
+ y: -0.10000000000000002,
431
+ },
432
+ ],
433
+ mspConnectionPairIds: ["U1.7-R1.2"],
434
+ pinIds: ["U1.7", "R1.2"],
435
+ },
436
+ "R2.1-U1.7": {
437
+ mspPairId: "R2.1-U1.7",
438
+ dcConnNetId: "connectivity_net2",
439
+ globalConnNetId: "connectivity_net2",
440
+ userNetId: "U1.DISCH to R2.pin1",
441
+ pins: [
442
+ {
443
+ pinId: "R2.1",
444
+ x: 1.2000000000000002,
445
+ y: -1.2944553500000002,
446
+ chipId: "schematic_component_2",
447
+ },
448
+ {
449
+ pinId: "U1.7",
450
+ x: 1.2000000000000002,
451
+ y: -0.10000000000000003,
452
+ chipId: "schematic_component_0",
453
+ },
454
+ ],
455
+ tracePath: [
456
+ {
457
+ x: 1.2000000000000002,
458
+ y: -1.2944553500000002,
459
+ },
460
+ {
461
+ x: 1.4000000000000001,
462
+ y: -1.2944553500000002,
463
+ },
464
+ {
465
+ x: 1.4000000000000001,
466
+ y: -0.10000000000000003,
467
+ },
468
+ {
469
+ x: 1.2000000000000002,
470
+ y: -0.10000000000000003,
471
+ },
472
+ ],
473
+ mspConnectionPairIds: ["R2.1-U1.7"],
474
+ pinIds: ["R2.1", "U1.7"],
475
+ },
476
+ "U1.3-R3.1": {
477
+ mspPairId: "U1.3-R3.1",
478
+ dcConnNetId: "connectivity_net3",
479
+ globalConnNetId: "connectivity_net3",
480
+ userNetId: "U1.OUT to R3.pin1",
481
+ pins: [
482
+ {
483
+ pinId: "U1.3",
484
+ x: 1.2000000000000002,
485
+ y: 0.09999999999999998,
486
+ chipId: "schematic_component_0",
487
+ },
488
+ {
489
+ pinId: "R3.1",
490
+ x: 1.2000000000000002,
491
+ y: 1.1500000000000001,
492
+ chipId: "schematic_component_5",
493
+ },
494
+ ],
495
+ tracePath: [
496
+ {
497
+ x: 1.2000000000000002,
498
+ y: 0.09999999999999998,
499
+ },
500
+ {
501
+ x: 1.4000000000000001,
502
+ y: 0.09999999999999998,
503
+ },
504
+ {
505
+ x: 1.4000000000000001,
506
+ y: 0.625,
507
+ },
508
+ {
509
+ x: 1.2000000000000002,
510
+ y: 0.625,
511
+ },
512
+ {
513
+ x: 1.2000000000000002,
514
+ y: 1.1500000000000001,
515
+ },
516
+ ],
517
+ mspConnectionPairIds: ["U1.3-R3.1"],
518
+ pinIds: ["U1.3", "R3.1"],
519
+ },
520
+ "U1.8-R1.1": {
521
+ mspPairId: "U1.8-R1.1",
522
+ dcConnNetId: "connectivity_net5",
523
+ globalConnNetId: "connectivity_net5",
524
+ userNetId: "VCC",
525
+ pins: [
526
+ {
527
+ pinId: "U1.8",
528
+ x: 1.2000000000000002,
529
+ y: 0.30000000000000004,
530
+ chipId: "schematic_component_0",
531
+ },
532
+ {
533
+ pinId: "R1.1",
534
+ x: 3,
535
+ y: -0.10000000000000016,
536
+ chipId: "schematic_component_1",
537
+ },
538
+ ],
539
+ tracePath: [
540
+ {
541
+ x: 1.2000000000000002,
542
+ y: 0.30000000000000004,
543
+ },
544
+ {
545
+ x: 3.2,
546
+ y: 0.30000000000000004,
547
+ },
548
+ {
549
+ x: 3.2,
550
+ y: -0.10000000000000016,
551
+ },
552
+ {
553
+ x: 3,
554
+ y: -0.10000000000000016,
555
+ },
556
+ ],
557
+ mspConnectionPairIds: ["U1.8-R1.1"],
558
+ pinIds: ["U1.8", "R1.1"],
559
+ },
560
+ },
561
+ overlappingSameNetTraceGroup: {
562
+ globalConnNetId: "connectivity_net4",
563
+ netId: "GND",
564
+ portOnlyPinId: "U1.1",
565
+ },
566
+ availableOrientations: ["x+", "x-", "y+", "y-"],
567
+ }
568
+
569
+ export default () => {
570
+ const solver = useMemo(() => {
571
+ return new SingleNetLabelPlacementSolver(input as any)
572
+ }, [])
573
+ return <GenericSolverDebugger solver={solver} />
574
+ }
@@ -1,7 +1,7 @@
1
1
  import { PipelineDebugger } from "site/components/PipelineDebugger"
2
2
  import type { InputProblem } from "lib/types/InputProblem"
3
3
 
4
- const inputProblem: InputProblem = {
4
+ export const inputProblem: InputProblem = {
5
5
  chips: [
6
6
  {
7
7
  chipId: "schematic_component_0",
@@ -1,7 +1,7 @@
1
1
  import { PipelineDebugger } from "site/components/PipelineDebugger"
2
2
  import type { InputProblem } from "lib/types/InputProblem"
3
3
 
4
- const inputProblem: InputProblem = {
4
+ export const inputProblem: InputProblem = {
5
5
  chips: [
6
6
  {
7
7
  chipId: "schematic_component_0",