@tscircuit/props 0.0.536 → 0.0.538
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 +12 -0
- package/dist/index.d.ts +58 -3
- package/dist/index.js +773 -757
- package/dist/index.js.map +1 -1
- package/lib/components/drc-check.ts +16 -0
- package/lib/customDrc.ts +78 -0
- package/lib/generated/jlcpcb-autocomplete.ts +2 -3
- package/lib/index.ts +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { customDrcCheckFn, type CustomDrcCheckFn } from "lib/customDrc"
|
|
2
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
export interface DrcCheckProps {
|
|
6
|
+
name?: string
|
|
7
|
+
checkFn: CustomDrcCheckFn
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const drcCheckProps = z.object({
|
|
11
|
+
name: z.string().optional(),
|
|
12
|
+
checkFn: customDrcCheckFn,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
type InferredDrcCheckProps = z.input<typeof drcCheckProps>
|
|
16
|
+
expectTypesMatch<DrcCheckProps, InferredDrcCheckProps>(true)
|
package/lib/customDrc.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnyCircuitElement,
|
|
3
|
+
CircuitJsonError,
|
|
4
|
+
PcbComponent,
|
|
5
|
+
PcbPort,
|
|
6
|
+
SourceComponentBase,
|
|
7
|
+
SourceNet,
|
|
8
|
+
SourcePort,
|
|
9
|
+
} from "circuit-json"
|
|
10
|
+
import { z } from "zod"
|
|
11
|
+
|
|
12
|
+
type MaybePromise<T> = T | Promise<T>
|
|
13
|
+
type CircuitJsonWarning = Extract<AnyCircuitElement, { warning_type: string }>
|
|
14
|
+
|
|
15
|
+
export type CustomDrcCheckInput =
|
|
16
|
+
| Partial<CircuitJsonError>
|
|
17
|
+
| Partial<CircuitJsonWarning>
|
|
18
|
+
|
|
19
|
+
export interface SelectionResultComponent {
|
|
20
|
+
getPort: (name: string) => SelectionResultPort | null
|
|
21
|
+
getPorts: () => SelectionResultPort[]
|
|
22
|
+
getPcbComponent: () => PcbComponent | null
|
|
23
|
+
getSourceComponent: () => SourceComponentBase | null
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SelectionResultPort {
|
|
27
|
+
getPcbPort: () => PcbPort | null
|
|
28
|
+
getSourcePort: () => SourcePort | null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SelectionResultNet {
|
|
32
|
+
getSourceNet: () => SourceNet | null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type SelectionResult =
|
|
36
|
+
| SelectionResultComponent
|
|
37
|
+
| SelectionResultPort
|
|
38
|
+
| SelectionResultNet
|
|
39
|
+
|
|
40
|
+
export type CustomDrcConnectable =
|
|
41
|
+
| string
|
|
42
|
+
| AnyCircuitElement
|
|
43
|
+
| SelectionResult
|
|
44
|
+
| null
|
|
45
|
+
| undefined
|
|
46
|
+
|
|
47
|
+
export interface CustomDrcSelect {
|
|
48
|
+
(selector: `net.${string}`): SelectionResultNet | null
|
|
49
|
+
(selector: `${string}.${string}`): SelectionResultPort | null
|
|
50
|
+
(selector: string): SelectionResult | null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface CustomDrcSelectAll {
|
|
54
|
+
(selector: `chip${string}`): SelectionResultComponent[]
|
|
55
|
+
(selector: string): SelectionResult[]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface CustomDrcCheckContext {
|
|
59
|
+
select: CustomDrcSelect
|
|
60
|
+
selectAll: CustomDrcSelectAll
|
|
61
|
+
isConnected: (a: CustomDrcConnectable, b: CustomDrcConnectable) => boolean
|
|
62
|
+
isPulledUp: (a: CustomDrcConnectable) => boolean
|
|
63
|
+
isPulledDown: (a: CustomDrcConnectable) => boolean
|
|
64
|
+
getResistanceBetween: (
|
|
65
|
+
a: CustomDrcConnectable,
|
|
66
|
+
b: CustomDrcConnectable,
|
|
67
|
+
) => number | null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type CustomDrcCheckFn = (
|
|
71
|
+
ctx: CustomDrcCheckContext,
|
|
72
|
+
) => MaybePromise<
|
|
73
|
+
CustomDrcCheckInput | CustomDrcCheckInput[] | null | undefined | void
|
|
74
|
+
>
|
|
75
|
+
|
|
76
|
+
export const customDrcCheckFn = z.custom<CustomDrcCheckFn>(
|
|
77
|
+
(value) => typeof value === "function",
|
|
78
|
+
)
|
|
@@ -2488,6 +2488,5 @@ export type JlcpcbKnownPartNumber =
|
|
|
2488
2488
|
| "C783588"
|
|
2489
2489
|
| "C3265019"
|
|
2490
2490
|
|
|
2491
|
-
export type JlcpcbAutocompleteStringPath =
|
|
2492
|
-
|
|
2493
|
-
>
|
|
2491
|
+
export type JlcpcbAutocompleteStringPath =
|
|
2492
|
+
AutocompleteString<`jlcpcb:${JlcpcbKnownPartNumber}`>
|
package/lib/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./common/schematicSize"
|
|
|
20
20
|
export * from "./common/kicadFootprintMetadata"
|
|
21
21
|
export * from "./common/kicadSymbolMetadata"
|
|
22
22
|
export * from "./common/kicadPinMetadata"
|
|
23
|
+
export * from "./customDrc"
|
|
23
24
|
|
|
24
25
|
export * from "./components/board"
|
|
25
26
|
export * from "./components/panel"
|
|
@@ -49,6 +50,7 @@ export * from "./components/fiducial"
|
|
|
49
50
|
export * from "./components/constrainedlayout"
|
|
50
51
|
export * from "./components/constraint"
|
|
51
52
|
export * from "./components/cutout"
|
|
53
|
+
export * from "./components/drc-check"
|
|
52
54
|
export * from "./components/smtpad"
|
|
53
55
|
export * from "./components/solderpaste"
|
|
54
56
|
export * from "./components/hole"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/props",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.538",
|
|
4
4
|
"description": "Props for tscircuit builtin component types",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@types/node": "^20.12.11",
|
|
33
33
|
"@types/react": "^18.3.2",
|
|
34
34
|
"ava": "^6.1.3",
|
|
35
|
-
"circuit-json": "^0.0.
|
|
35
|
+
"circuit-json": "^0.0.428",
|
|
36
36
|
"expect-type": "^1.3.0",
|
|
37
37
|
"glob": "^11.0.0",
|
|
38
38
|
"madge": "^8.0.0",
|