@tscircuit/props 0.0.46 → 0.0.48
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/dist/index.d.ts +693 -123
- package/dist/index.js +200 -150
- package/dist/index.js.map +1 -1
- package/lib/common/cadModel.ts +38 -1
- package/lib/common/layout.ts +55 -6
- package/lib/common/schematicPinStyle.ts +24 -0
- package/lib/components/capacitor.ts +32 -0
- package/lib/components/chip.ts +2 -10
- package/lib/components/jumper.ts +32 -0
- package/lib/components/resistor.ts +30 -0
- package/lib/index.ts +3 -16
- package/lib/typecheck.ts +4 -2
- package/package.json +2 -1
package/lib/common/cadModel.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod"
|
|
2
2
|
import { point3 } from "./point3"
|
|
3
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
3
4
|
|
|
4
5
|
export const rotationPoint3 = z.object({
|
|
5
6
|
x: z.union([z.number(), z.string()]),
|
|
@@ -7,21 +8,57 @@ export const rotationPoint3 = z.object({
|
|
|
7
8
|
z: z.union([z.number(), z.string()]),
|
|
8
9
|
})
|
|
9
10
|
|
|
11
|
+
export interface CadModelBase {
|
|
12
|
+
rotationOffset?:
|
|
13
|
+
| number
|
|
14
|
+
| { x: number | string; y: number | string; z: number | string }
|
|
15
|
+
positionOffset?: {
|
|
16
|
+
x: number | string
|
|
17
|
+
y: number | string
|
|
18
|
+
z: number | string
|
|
19
|
+
}
|
|
20
|
+
size?: { x: number | string; y: number | string; z: number | string }
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
export const cadModelBase = z.object({
|
|
11
24
|
rotationOffset: z.number().or(rotationPoint3).optional(),
|
|
12
25
|
positionOffset: point3.optional(),
|
|
13
26
|
size: point3.optional(),
|
|
14
27
|
})
|
|
15
28
|
|
|
29
|
+
expectTypesMatch<CadModelBase, z.input<typeof cadModelBase>>(true)
|
|
30
|
+
|
|
31
|
+
export interface CadModelStl extends CadModelBase {
|
|
32
|
+
stlUrl: string
|
|
33
|
+
}
|
|
16
34
|
export const cadModelStl = cadModelBase.extend({
|
|
17
35
|
stlUrl: z.string(),
|
|
18
36
|
})
|
|
19
37
|
|
|
38
|
+
export interface CadModelObj extends CadModelBase {
|
|
39
|
+
objUrl: string
|
|
40
|
+
mtlUrl?: string
|
|
41
|
+
}
|
|
20
42
|
export const cadModelObj = cadModelBase.extend({
|
|
21
43
|
objUrl: z.string(),
|
|
22
44
|
mtlUrl: z.string().optional(),
|
|
23
45
|
})
|
|
24
46
|
|
|
47
|
+
export interface CadModelJscad extends CadModelBase {
|
|
48
|
+
jscad: Record<string, any>
|
|
49
|
+
}
|
|
25
50
|
export const cadModelJscad = cadModelBase.extend({
|
|
26
|
-
jscad: z.any(),
|
|
51
|
+
jscad: z.record(z.any()),
|
|
27
52
|
})
|
|
53
|
+
|
|
54
|
+
export type CadModelProp = string | CadModelStl | CadModelObj | CadModelJscad
|
|
55
|
+
|
|
56
|
+
export const cadModelProp = z.union([
|
|
57
|
+
z.string(),
|
|
58
|
+
cadModelStl,
|
|
59
|
+
cadModelObj,
|
|
60
|
+
cadModelJscad,
|
|
61
|
+
])
|
|
62
|
+
|
|
63
|
+
type InferredCadModelProp = z.input<typeof cadModelProp>
|
|
64
|
+
expectTypesMatch<CadModelProp, InferredCadModelProp>(true)
|
package/lib/common/layout.ts
CHANGED
|
@@ -3,12 +3,24 @@ import {
|
|
|
3
3
|
type AnySoupElementInput,
|
|
4
4
|
distance,
|
|
5
5
|
layer_ref,
|
|
6
|
+
type LayerRef,
|
|
7
|
+
type LayerRefInput,
|
|
6
8
|
rotation,
|
|
7
9
|
supplier_name,
|
|
8
10
|
} from "@tscircuit/soup"
|
|
9
11
|
import { point3 } from "./point3"
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
+
import {
|
|
13
|
+
cadModelJscad,
|
|
14
|
+
cadModelObj,
|
|
15
|
+
cadModelProp,
|
|
16
|
+
cadModelStl,
|
|
17
|
+
type CadModelJscad,
|
|
18
|
+
type CadModelObj,
|
|
19
|
+
type CadModelProp,
|
|
20
|
+
type CadModelStl,
|
|
21
|
+
} from "./cadModel"
|
|
22
|
+
import { footprintProp, type Footprint } from "./footprintProp"
|
|
23
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
12
24
|
|
|
13
25
|
export const pcbLayoutProps = z.object({
|
|
14
26
|
pcbX: distance,
|
|
@@ -17,6 +29,19 @@ export const pcbLayoutProps = z.object({
|
|
|
17
29
|
layer: layer_ref.optional(),
|
|
18
30
|
})
|
|
19
31
|
|
|
32
|
+
export interface CommonLayoutProps {
|
|
33
|
+
pcbX?: string | number
|
|
34
|
+
pcbY?: string | number
|
|
35
|
+
pcbRotation?: string | number
|
|
36
|
+
|
|
37
|
+
schX?: string | number
|
|
38
|
+
schY?: string | number
|
|
39
|
+
schRotation?: string | number
|
|
40
|
+
|
|
41
|
+
layer?: LayerRefInput
|
|
42
|
+
footprint?: Footprint
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
export const commonLayoutProps = z.object({
|
|
21
46
|
pcbX: distance.optional(),
|
|
22
47
|
pcbY: distance.optional(),
|
|
@@ -27,21 +52,45 @@ export const commonLayoutProps = z.object({
|
|
|
27
52
|
layer: layer_ref.optional(),
|
|
28
53
|
footprint: footprintProp.optional(),
|
|
29
54
|
})
|
|
30
|
-
export type CommonLayoutProps = z.input<typeof commonLayoutProps>
|
|
31
55
|
|
|
56
|
+
type InferredCommonLayoutProps = z.input<typeof commonLayoutProps>
|
|
57
|
+
expectTypesMatch<CommonLayoutProps, InferredCommonLayoutProps>(true)
|
|
58
|
+
|
|
59
|
+
export type SupplierName =
|
|
60
|
+
| "jlcpcb"
|
|
61
|
+
| "macrofab"
|
|
62
|
+
| "pcbway"
|
|
63
|
+
| "digikey"
|
|
64
|
+
| "mouser"
|
|
65
|
+
| "lcsc"
|
|
66
|
+
export interface SupplierProps {
|
|
67
|
+
supplierPartNumbers?: { [k in SupplierName]?: string[] }
|
|
68
|
+
}
|
|
32
69
|
export const supplierProps = z.object({
|
|
33
70
|
supplierPartNumbers: z.record(supplier_name, z.array(z.string())).optional(),
|
|
34
71
|
})
|
|
35
|
-
|
|
72
|
+
|
|
73
|
+
expectTypesMatch<SupplierProps, z.input<typeof supplierProps>>(true)
|
|
74
|
+
|
|
75
|
+
export interface CommonComponentProps extends CommonLayoutProps {
|
|
76
|
+
name: string
|
|
77
|
+
supplierPartNumbers?: SupplierProps["supplierPartNumbers"]
|
|
78
|
+
cadModel?: CadModelProp
|
|
79
|
+
children?: any
|
|
80
|
+
symbolName?: string
|
|
81
|
+
}
|
|
36
82
|
|
|
37
83
|
export const commonComponentProps = commonLayoutProps
|
|
38
84
|
.merge(supplierProps)
|
|
39
85
|
.extend({
|
|
40
86
|
name: z.string(),
|
|
41
|
-
cadModel:
|
|
87
|
+
cadModel: cadModelProp.optional(),
|
|
42
88
|
children: z.any().optional(),
|
|
89
|
+
symbolName: z.string().optional(),
|
|
43
90
|
})
|
|
44
|
-
|
|
91
|
+
|
|
92
|
+
type InferredCommonComponentProps = z.input<typeof commonComponentProps>
|
|
93
|
+
expectTypesMatch<CommonComponentProps, InferredCommonComponentProps>(true)
|
|
45
94
|
|
|
46
95
|
export const lrPins = ["pin1", "left", "pin2", "right"] as const
|
|
47
96
|
export const lrPolarPins = [
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
import { distance } from "@tscircuit/soup"
|
|
3
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
4
|
+
|
|
5
|
+
export type SchematicPinStyle = Record<
|
|
6
|
+
string,
|
|
7
|
+
{
|
|
8
|
+
leftMargin?: number | string
|
|
9
|
+
rightMargin?: number | string
|
|
10
|
+
topMargin?: number | string
|
|
11
|
+
bottomMargin?: number | string
|
|
12
|
+
}
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
export const schematicPinStyle = z.record(
|
|
16
|
+
z.object({
|
|
17
|
+
leftMargin: distance.optional(),
|
|
18
|
+
rightMargin: distance.optional(),
|
|
19
|
+
topMargin: distance.optional(),
|
|
20
|
+
bottomMargin: distance.optional(),
|
|
21
|
+
}),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
expectTypesMatch<SchematicPinStyle, z.input<typeof schematicPinStyle>>(true)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
import { capacitance } from "@tscircuit/soup"
|
|
3
|
+
import {
|
|
4
|
+
commonComponentProps,
|
|
5
|
+
lrPins,
|
|
6
|
+
lrPolarPins,
|
|
7
|
+
type CommonComponentProps,
|
|
8
|
+
} from "lib/common/layout"
|
|
9
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
10
|
+
|
|
11
|
+
export interface CapacitorProps extends CommonComponentProps {
|
|
12
|
+
capacitance: number | string
|
|
13
|
+
|
|
14
|
+
decouplingFor?: string
|
|
15
|
+
decouplingTo?: string
|
|
16
|
+
|
|
17
|
+
bypassFor?: string
|
|
18
|
+
bypassTo?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const capacitorProps = commonComponentProps.extend({
|
|
22
|
+
capacitance,
|
|
23
|
+
|
|
24
|
+
decouplingFor: z.string().optional(),
|
|
25
|
+
decouplingTo: z.string().optional(),
|
|
26
|
+
|
|
27
|
+
bypassFor: z.string().optional(),
|
|
28
|
+
bypassTo: z.string().optional(),
|
|
29
|
+
})
|
|
30
|
+
export const capacitorPins = lrPolarPins
|
|
31
|
+
|
|
32
|
+
expectTypesMatch<CapacitorProps, z.input<typeof capacitorProps>>(true)
|
package/lib/components/chip.ts
CHANGED
|
@@ -2,22 +2,14 @@ import { z } from "zod"
|
|
|
2
2
|
import { distance } from "@tscircuit/soup"
|
|
3
3
|
import { commonComponentProps } from "lib/common/layout"
|
|
4
4
|
import { schematicPortArrangement } from "lib/common/schematicPinDefinitions"
|
|
5
|
+
import { schematicPinStyle } from "lib/common/schematicPinStyle"
|
|
5
6
|
|
|
6
7
|
export const chipProps = commonComponentProps.extend({
|
|
7
8
|
manufacturerPartNumber: z.string().optional(),
|
|
8
9
|
pinLabels: z.record(z.number().or(z.string()), z.string()).optional(),
|
|
9
10
|
|
|
10
11
|
schPortArrangement: schematicPortArrangement.optional(),
|
|
11
|
-
schPinStyle:
|
|
12
|
-
.record(
|
|
13
|
-
z.object({
|
|
14
|
-
leftMargin: distance.optional(),
|
|
15
|
-
rightMargin: distance.optional(),
|
|
16
|
-
topMargin: distance.optional(),
|
|
17
|
-
bottomMargin: distance.optional(),
|
|
18
|
-
}),
|
|
19
|
-
)
|
|
20
|
-
.optional(),
|
|
12
|
+
schPinStyle: schematicPinStyle.optional(),
|
|
21
13
|
schPinSpacing: distance.optional(),
|
|
22
14
|
schWidth: distance.optional(),
|
|
23
15
|
schHeight: distance.optional(),
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
import {
|
|
3
|
+
commonComponentProps,
|
|
4
|
+
type CommonComponentProps,
|
|
5
|
+
} from "lib/common/layout"
|
|
6
|
+
import {
|
|
7
|
+
schematicPinStyle,
|
|
8
|
+
type SchematicPinStyle,
|
|
9
|
+
} from "lib/common/schematicPinStyle"
|
|
10
|
+
import { distance } from "@tscircuit/soup"
|
|
11
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
12
|
+
|
|
13
|
+
export interface JumperProps extends CommonComponentProps {
|
|
14
|
+
manufacturerPartNumber?: string
|
|
15
|
+
pinLabels?: Record<number | string, string>
|
|
16
|
+
schPinStyle?: SchematicPinStyle
|
|
17
|
+
schPinSpacing?: number | string
|
|
18
|
+
schWidth?: number | string
|
|
19
|
+
schHeight?: number | string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const jumperProps = commonComponentProps.extend({
|
|
23
|
+
manufacturerPartNumber: z.string().optional(),
|
|
24
|
+
pinLabels: z.record(z.number().or(z.string()), z.string()).optional(),
|
|
25
|
+
schPinStyle: schematicPinStyle.optional(),
|
|
26
|
+
schPinSpacing: distance.optional(),
|
|
27
|
+
schWidth: distance.optional(),
|
|
28
|
+
schHeight: distance.optional(),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
type InferredJumperProps = z.input<typeof jumperProps>
|
|
32
|
+
expectTypesMatch<JumperProps, InferredJumperProps>(true)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
import { resistance } from "@tscircuit/soup"
|
|
3
|
+
import {
|
|
4
|
+
commonComponentProps,
|
|
5
|
+
lrPins,
|
|
6
|
+
type CommonComponentProps,
|
|
7
|
+
} from "lib/common/layout"
|
|
8
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
9
|
+
|
|
10
|
+
export interface ResistorProps extends CommonComponentProps {
|
|
11
|
+
resistance: number | string
|
|
12
|
+
pullupFor?: string
|
|
13
|
+
pullupTo?: string
|
|
14
|
+
pulldownFor?: string
|
|
15
|
+
pulldownTo?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const resistorProps = commonComponentProps.extend({
|
|
19
|
+
resistance,
|
|
20
|
+
|
|
21
|
+
pullupFor: z.string().optional(),
|
|
22
|
+
pullupTo: z.string().optional(),
|
|
23
|
+
|
|
24
|
+
pulldownFor: z.string().optional(),
|
|
25
|
+
pulldownTo: z.string().optional(),
|
|
26
|
+
})
|
|
27
|
+
export const resistorPins = lrPins
|
|
28
|
+
|
|
29
|
+
type InferredResistorProps = z.input<typeof resistorProps>
|
|
30
|
+
expectTypesMatch<ResistorProps, InferredResistorProps>(true)
|
package/lib/index.ts
CHANGED
|
@@ -46,23 +46,10 @@ export * from "./common/schematicPinDefinitions"
|
|
|
46
46
|
|
|
47
47
|
export * from "./components/board"
|
|
48
48
|
export * from "./components/chip"
|
|
49
|
+
export * from "./components/jumper"
|
|
49
50
|
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
export type SupplierProps = z.input<typeof supplierProps>
|
|
54
|
-
|
|
55
|
-
export const resistorProps = commonComponentProps.extend({
|
|
56
|
-
resistance,
|
|
57
|
-
})
|
|
58
|
-
export const resistorPins = lrPins
|
|
59
|
-
export type ResistorProps = z.input<typeof resistorProps>
|
|
60
|
-
|
|
61
|
-
export const capacitorProps = commonComponentProps.extend({
|
|
62
|
-
capacitance,
|
|
63
|
-
})
|
|
64
|
-
export const capacitorPins = lrPolarPins
|
|
65
|
-
export type CapacitorProps = z.input<typeof capacitorProps>
|
|
51
|
+
export * from "./components/resistor"
|
|
52
|
+
export * from "./components/capacitor"
|
|
66
53
|
|
|
67
54
|
export const inductorProps = commonComponentProps.extend({
|
|
68
55
|
inductance,
|
package/lib/typecheck.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/props",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Props for tscircuit builtin component types",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"expect-type": "^0.20.0",
|
|
28
28
|
"madge": "^8.0.0",
|
|
29
29
|
"react": "^18.3.1",
|
|
30
|
+
"ts-expect": "^1.3.0",
|
|
30
31
|
"tsup": "^8.0.2",
|
|
31
32
|
"tsx": "^4.10.2",
|
|
32
33
|
"typescript": "^5.4.5",
|