@tscircuit/circuit-json-util 0.0.86 → 0.0.88
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/README.md +19 -0
- package/dist/index.d.ts +517 -133
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ It reduces the amount of code to retrieve or join elements from circuit json, it
|
|
|
49
49
|
| `getElementRenderLayers` | [`lib/get-element-render-layers.ts`](./lib/get-element-render-layers.ts) | Returns schematic/PCB render layers used for an element. |
|
|
50
50
|
| `computeClearanceBetweenElements` | [`lib/compute-clearance-between-elements.ts`](./lib/compute-clearance-between-elements.ts) | Computes the minimum edge-to-edge clearance between two circuit elements using geometric decomposition. |
|
|
51
51
|
| `computeGapBetweenCopper` | [`lib/compute-gap-between-copper.ts`](./lib/compute-gap-between-copper.ts) | Computes the minimum copper-to-copper gap between two circuit elements by decomposing them into primitive shapes. |
|
|
52
|
+
| `categorizeErrorOrWarning` | [`lib/categorize-error-or-warning.ts`](./lib/categorize-error-or-warning.ts) | Categorizes DRC error/warning types into `"netlist"`, `"pin_specification"`, `"placement"`, `"routing"`, or `"unknown"`. |
|
|
52
53
|
|
|
53
54
|
## Standard Usage
|
|
54
55
|
|
|
@@ -107,6 +108,24 @@ const subcircuitElements = indexedSu.source_component.list({
|
|
|
107
108
|
|
|
108
109
|
The indexed version maintains the same API as the standard version but provides significant performance improvements, especially for large circuit json arrays.
|
|
109
110
|
|
|
111
|
+
|
|
112
|
+
## Categorize DRC Errors and Warnings
|
|
113
|
+
|
|
114
|
+
Use `categorizeErrorOrWarning` to map DRC result types to high-level check categories.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { categorizeErrorOrWarning } from "@tscircuit/circuit-json-util"
|
|
118
|
+
|
|
119
|
+
categorizeErrorOrWarning("source_pin_must_be_connected_error") // "netlist"
|
|
120
|
+
categorizeErrorOrWarning("source_no_power_pin_defined_warning") // "pin_specification"
|
|
121
|
+
categorizeErrorOrWarning({ error_type: "pcb_trace_error" }) // "routing"
|
|
122
|
+
categorizeErrorOrWarning({
|
|
123
|
+
warning_type: "pcb_connector_not_in_accessible_orientation_warning",
|
|
124
|
+
}) // "placement"
|
|
125
|
+
categorizeErrorOrWarning("some_future_error_type") // "unknown"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
110
129
|
## Repositioning PCB Components
|
|
111
130
|
|
|
112
131
|
Use `repositionPcbComponentTo` to move a component and all of its related elements to a new center:
|