@tscircuit/props 0.0.537 → 0.0.539
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 +25 -0
- package/dist/index.d.ts +97 -10
- package/dist/index.js +787 -758
- package/dist/index.js.map +1 -1
- package/lib/components/chip.ts +10 -0
- package/lib/components/drc-check.ts +16 -0
- package/lib/components/spicemodel.ts +15 -0
- package/lib/customDrc.ts +78 -0
- package/lib/index.ts +3 -0
- package/package.json +2 -2
package/lib/components/chip.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { distance, supplier_name } from "circuit-json"
|
|
2
2
|
import type { Distance } from "lib/common/distance"
|
|
3
|
+
import type { SpicemodelProps } from "lib/components/spicemodel"
|
|
3
4
|
import {
|
|
4
5
|
type CommonComponentProps,
|
|
5
6
|
commonComponentProps,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
} from "lib/common/schematicPinLabel"
|
|
20
21
|
import { expectTypesMatch } from "lib/typecheck"
|
|
21
22
|
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
23
|
+
import type { ReactElement } from "react"
|
|
22
24
|
import { z } from "zod"
|
|
23
25
|
|
|
24
26
|
export type PinLabelsProp<
|
|
@@ -36,6 +38,8 @@ export interface PinCompatibleVariant {
|
|
|
36
38
|
supplierPartNumber?: SupplierPartNumbers
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
export type SpicemodelElement = ReactElement<SpicemodelProps>
|
|
42
|
+
|
|
39
43
|
export interface ChipPropsSU<
|
|
40
44
|
PinLabel extends SchematicPinLabel = SchematicPinLabel,
|
|
41
45
|
> extends CommonComponentProps<PinLabel> {
|
|
@@ -67,6 +71,7 @@ export interface ChipPropsSU<
|
|
|
67
71
|
*/
|
|
68
72
|
noConnect?: readonly PinLabel[] | PinLabel[]
|
|
69
73
|
connections?: Connections<PinLabel>
|
|
74
|
+
spiceModel?: SpicemodelElement
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
export type ChipProps<PinLabelMap extends PinLabelsProp | string = string> =
|
|
@@ -130,6 +135,10 @@ const connectionsProp = z
|
|
|
130
135
|
.custom<Connections>()
|
|
131
136
|
.pipe(z.record(z.string(), connectionTarget))
|
|
132
137
|
|
|
138
|
+
const spicemodelElement = z.custom<SpicemodelElement>(
|
|
139
|
+
(v) => !!v && typeof v === "object" && "type" in v && "props" in v,
|
|
140
|
+
)
|
|
141
|
+
|
|
133
142
|
export const pinLabelsProp = z.record(
|
|
134
143
|
schematicPinLabel,
|
|
135
144
|
schematicPinLabel
|
|
@@ -163,6 +172,7 @@ export const chipProps = commonComponentProps.extend({
|
|
|
163
172
|
noSchematicRepresentation: z.boolean().optional(),
|
|
164
173
|
noConnect: noConnectProp.optional(),
|
|
165
174
|
connections: connectionsProp.optional(),
|
|
175
|
+
spiceModel: spicemodelElement.optional(),
|
|
166
176
|
})
|
|
167
177
|
|
|
168
178
|
/**
|
|
@@ -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)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
|
|
4
|
+
export interface SpicemodelProps {
|
|
5
|
+
source: string
|
|
6
|
+
spicePinMapping?: Record<string, string>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const spicemodelProps = z.object({
|
|
10
|
+
source: z.string(),
|
|
11
|
+
spicePinMapping: z.record(z.string(), z.string()).optional(),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
type InferredSpicemodelProps = z.input<typeof spicemodelProps>
|
|
15
|
+
expectTypesMatch<SpicemodelProps, InferredSpicemodelProps>(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
|
+
)
|
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"
|
|
@@ -64,6 +66,7 @@ export * from "./components/push-button"
|
|
|
64
66
|
export * from "./components/subcircuit"
|
|
65
67
|
export * from "./components/analogsimulation"
|
|
66
68
|
export * from "./components/autoroutingphase"
|
|
69
|
+
export * from "./components/spicemodel"
|
|
67
70
|
export * from "./manual-edits"
|
|
68
71
|
export * from "./components/transistor"
|
|
69
72
|
export * from "./components/mosfet"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/props",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.539",
|
|
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",
|