@tscircuit/props 0.0.41 → 0.0.43
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 +1593 -1845
- package/dist/index.js +290 -233
- package/dist/index.js.map +1 -1
- package/lib/common/cadModel.ts +27 -0
- package/lib/common/direction.ts +20 -0
- package/lib/common/footprintProp.ts +23 -0
- package/lib/common/layout.ts +58 -0
- package/lib/common/point.ts +9 -0
- package/lib/common/point3.ts +8 -0
- package/lib/common/portHints.ts +7 -0
- package/lib/common/schematicPinDefinitions.ts +38 -0
- package/lib/components/board.ts +28 -0
- package/lib/components/chip.ts +29 -0
- package/lib/index.ts +334 -0
- package/lib/typecheck.ts +3 -0
- package/package.json +7 -2
package/lib/index.ts
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import type { LayoutBuilder } from "@tscircuit/layout"
|
|
2
|
+
import {
|
|
3
|
+
type AnySoupElementInput,
|
|
4
|
+
capacitance,
|
|
5
|
+
distance,
|
|
6
|
+
inductance,
|
|
7
|
+
layer_ref,
|
|
8
|
+
length,
|
|
9
|
+
type PCBPlatedHoleInput,
|
|
10
|
+
type PCBSMTPadInput,
|
|
11
|
+
point,
|
|
12
|
+
resistance,
|
|
13
|
+
rotation,
|
|
14
|
+
route_hint_point,
|
|
15
|
+
supplier_name,
|
|
16
|
+
voltage,
|
|
17
|
+
} from "@tscircuit/soup"
|
|
18
|
+
import type { ReactElement } from "react"
|
|
19
|
+
import { z } from "zod"
|
|
20
|
+
import { direction } from "./common/direction"
|
|
21
|
+
import { portHints } from "./common/portHints"
|
|
22
|
+
import {
|
|
23
|
+
commonComponentProps,
|
|
24
|
+
commonLayoutProps,
|
|
25
|
+
lrPins,
|
|
26
|
+
lrPolarPins,
|
|
27
|
+
pcbLayoutProps,
|
|
28
|
+
} from "./common/layout"
|
|
29
|
+
import { explicitPinSideDefinition } from "./common/schematicPinDefinitions"
|
|
30
|
+
|
|
31
|
+
export * from "./common/direction"
|
|
32
|
+
export * from "./common/portHints"
|
|
33
|
+
export * from "./common/layout"
|
|
34
|
+
export * from "./common/point3"
|
|
35
|
+
export * from "./common/portHints"
|
|
36
|
+
export * from "./common/footprintProp"
|
|
37
|
+
export * from "./common/schematicPinDefinitions"
|
|
38
|
+
|
|
39
|
+
export * from "./components/board"
|
|
40
|
+
export * from "./components/chip"
|
|
41
|
+
|
|
42
|
+
export const supplierProps = z.object({
|
|
43
|
+
supplierPartNumbers: z.record(supplier_name, z.array(z.string())).optional(),
|
|
44
|
+
})
|
|
45
|
+
export type SupplierProps = z.input<typeof supplierProps>
|
|
46
|
+
|
|
47
|
+
export const resistorProps = commonComponentProps.extend({
|
|
48
|
+
resistance,
|
|
49
|
+
})
|
|
50
|
+
export const resistorPins = lrPins
|
|
51
|
+
export type ResistorProps = z.input<typeof resistorProps>
|
|
52
|
+
|
|
53
|
+
export const capacitorProps = commonComponentProps.extend({
|
|
54
|
+
capacitance,
|
|
55
|
+
})
|
|
56
|
+
export const capacitorPins = lrPolarPins
|
|
57
|
+
export type CapacitorProps = z.input<typeof capacitorProps>
|
|
58
|
+
|
|
59
|
+
export const inductorProps = commonComponentProps.extend({
|
|
60
|
+
inductance,
|
|
61
|
+
})
|
|
62
|
+
export const inductorPins = lrPins
|
|
63
|
+
export type InductorProps = z.input<typeof inductorProps>
|
|
64
|
+
|
|
65
|
+
export const diodeProps = commonComponentProps.extend({})
|
|
66
|
+
export const diodePins = lrPolarPins
|
|
67
|
+
export type DiodeProps = z.input<typeof diodeProps>
|
|
68
|
+
|
|
69
|
+
export const ledProps = commonComponentProps.extend({
|
|
70
|
+
color: z.string().optional(),
|
|
71
|
+
})
|
|
72
|
+
export const ledPins = lrPolarPins
|
|
73
|
+
export type LedProps = z.input<typeof ledProps>
|
|
74
|
+
|
|
75
|
+
export const switchProps = commonComponentProps.extend({
|
|
76
|
+
ftype: z.literal("switch"),
|
|
77
|
+
switchType: z.enum(["spst"]).default("spst"),
|
|
78
|
+
isNormallyClosed: z.boolean().default(false),
|
|
79
|
+
})
|
|
80
|
+
export type SwitchProps = z.input<typeof switchProps>
|
|
81
|
+
|
|
82
|
+
export const distanceOrMultiplier = distance.or(z.enum(["2x", "3x", "4x"]))
|
|
83
|
+
|
|
84
|
+
export const viaProps = commonLayoutProps.extend({
|
|
85
|
+
fromLayer: layer_ref,
|
|
86
|
+
toLayer: layer_ref,
|
|
87
|
+
holeDiameter: distance,
|
|
88
|
+
outerDiameter: distance,
|
|
89
|
+
})
|
|
90
|
+
export type ViaProps = z.input<typeof viaProps>
|
|
91
|
+
|
|
92
|
+
export const netAliasProps = commonLayoutProps.extend({
|
|
93
|
+
net: z.string().optional(),
|
|
94
|
+
})
|
|
95
|
+
export type NetAliasProps = z.input<typeof netAliasProps>
|
|
96
|
+
|
|
97
|
+
export const portRef = z.union([
|
|
98
|
+
z.string(),
|
|
99
|
+
z.custom<{ getPortSelector: () => string }>((v) =>
|
|
100
|
+
Boolean(v.getPortSelector),
|
|
101
|
+
),
|
|
102
|
+
])
|
|
103
|
+
|
|
104
|
+
export const traceProps = z
|
|
105
|
+
.object({
|
|
106
|
+
path: z.array(portRef),
|
|
107
|
+
thickness: distance.optional(),
|
|
108
|
+
schematicRouteHints: z.array(point).optional(),
|
|
109
|
+
pcbRouteHints: z.array(route_hint_point).optional(),
|
|
110
|
+
})
|
|
111
|
+
.or(
|
|
112
|
+
z.object({
|
|
113
|
+
from: portRef,
|
|
114
|
+
to: portRef,
|
|
115
|
+
thickness: distance.optional(),
|
|
116
|
+
schematicRouteHints: z.array(point).optional(),
|
|
117
|
+
pcbRouteHints: z.array(route_hint_point).optional(),
|
|
118
|
+
}),
|
|
119
|
+
)
|
|
120
|
+
export type TraceProps = z.input<typeof traceProps>
|
|
121
|
+
|
|
122
|
+
export const smtPadProps = z.union([
|
|
123
|
+
pcbLayoutProps.omit({ pcbRotation: true }).extend({
|
|
124
|
+
shape: z.literal("circle"),
|
|
125
|
+
radius: distance.optional(),
|
|
126
|
+
portHints: portHints.optional(),
|
|
127
|
+
}),
|
|
128
|
+
pcbLayoutProps.omit({ pcbRotation: true }).extend({
|
|
129
|
+
shape: z.literal("rect"),
|
|
130
|
+
width: distance.optional(),
|
|
131
|
+
height: distance.optional(),
|
|
132
|
+
portHints: portHints.optional(),
|
|
133
|
+
}),
|
|
134
|
+
])
|
|
135
|
+
export type SmtPadProps = z.input<typeof smtPadProps>
|
|
136
|
+
|
|
137
|
+
export const platedHoleProps = z.union([
|
|
138
|
+
pcbLayoutProps.omit({ pcbRotation: true, layer: true }).extend({
|
|
139
|
+
shape: z.literal("circle"),
|
|
140
|
+
holeDiameter: distance,
|
|
141
|
+
outerDiameter: distance,
|
|
142
|
+
portHints: portHints.optional(),
|
|
143
|
+
}),
|
|
144
|
+
pcbLayoutProps.omit({ pcbRotation: true, layer: true }).extend({
|
|
145
|
+
shape: z.literal("oval"),
|
|
146
|
+
outerWidth: distance,
|
|
147
|
+
outerHeight: distance,
|
|
148
|
+
innerWidth: distance,
|
|
149
|
+
innerHeight: distance,
|
|
150
|
+
portHints: portHints.optional(),
|
|
151
|
+
}),
|
|
152
|
+
])
|
|
153
|
+
export type PlatedHoleProps = z.input<typeof platedHoleProps>
|
|
154
|
+
|
|
155
|
+
export const holeProps = pcbLayoutProps.omit({ pcbRotation: true }).extend({
|
|
156
|
+
holeDiameter: distance,
|
|
157
|
+
})
|
|
158
|
+
export type HoleProps = z.input<typeof holeProps>
|
|
159
|
+
|
|
160
|
+
export const schematicBoxProps = z.object({
|
|
161
|
+
schX: distance,
|
|
162
|
+
schY: distance,
|
|
163
|
+
width: distance,
|
|
164
|
+
height: distance,
|
|
165
|
+
})
|
|
166
|
+
export type SchematicBoxProps = z.input<typeof schematicBoxProps>
|
|
167
|
+
|
|
168
|
+
export const schematicTextProps = z.object({
|
|
169
|
+
schX: distance,
|
|
170
|
+
schY: distance,
|
|
171
|
+
text: z.string(),
|
|
172
|
+
})
|
|
173
|
+
export type SchematicTextProps = z.input<typeof schematicTextProps>
|
|
174
|
+
|
|
175
|
+
export const schematicLineProps = z.object({
|
|
176
|
+
x1: distance,
|
|
177
|
+
y1: distance,
|
|
178
|
+
x2: distance,
|
|
179
|
+
y2: distance,
|
|
180
|
+
})
|
|
181
|
+
export type SchematicLineProps = z.input<typeof schematicLineProps>
|
|
182
|
+
|
|
183
|
+
export const schematicPathProps = z.object({
|
|
184
|
+
points: z.array(point),
|
|
185
|
+
isFilled: z.boolean().optional().default(false),
|
|
186
|
+
fillColor: z.enum(["red", "blue"]).optional(),
|
|
187
|
+
})
|
|
188
|
+
export type SchematicPathProps = z.input<typeof schematicPathProps>
|
|
189
|
+
|
|
190
|
+
export const constraintProps = z.union([
|
|
191
|
+
z.object({
|
|
192
|
+
type: z.literal("xdist"),
|
|
193
|
+
dist: distance,
|
|
194
|
+
left: z.string(),
|
|
195
|
+
right: z.string(),
|
|
196
|
+
}),
|
|
197
|
+
z.object({
|
|
198
|
+
type: z.literal("ydist"),
|
|
199
|
+
dist: distance,
|
|
200
|
+
top: z.string(),
|
|
201
|
+
bottom: z.string(),
|
|
202
|
+
}),
|
|
203
|
+
])
|
|
204
|
+
export type ConstraintProps = z.input<typeof constraintProps>
|
|
205
|
+
|
|
206
|
+
export const constrainedLayoutProps = z.object({})
|
|
207
|
+
export type ConstrainedLayoutProps = z.input<typeof constrainedLayoutProps>
|
|
208
|
+
|
|
209
|
+
export const footprintProps = z.object({})
|
|
210
|
+
export type FootprintProps = z.input<typeof footprintProps>
|
|
211
|
+
|
|
212
|
+
export const componentProps = commonComponentProps
|
|
213
|
+
export type ComponentProps = z.input<typeof componentProps>
|
|
214
|
+
|
|
215
|
+
export const groupProps = commonLayoutProps.extend({
|
|
216
|
+
name: z.string().optional(),
|
|
217
|
+
layout: z.custom<LayoutBuilder>((v) => true).optional(),
|
|
218
|
+
children: z.any().optional(),
|
|
219
|
+
routingDisabled: z.boolean().optional(),
|
|
220
|
+
})
|
|
221
|
+
export type GroupProps = z.input<typeof groupProps>
|
|
222
|
+
|
|
223
|
+
export const powerSourceProps = commonComponentProps.extend({
|
|
224
|
+
voltage,
|
|
225
|
+
})
|
|
226
|
+
export type PowerSourceProps = z.input<typeof powerSourceProps>
|
|
227
|
+
|
|
228
|
+
export const portProps = commonLayoutProps.extend({
|
|
229
|
+
name: z.string(),
|
|
230
|
+
pinNumber: z.number().optional(),
|
|
231
|
+
aliases: z.array(z.string()).optional(),
|
|
232
|
+
direction: direction,
|
|
233
|
+
})
|
|
234
|
+
export type PortProps = z.input<typeof portProps>
|
|
235
|
+
|
|
236
|
+
export const silkscreenTextProps = pcbLayoutProps.extend({
|
|
237
|
+
text: z.string(),
|
|
238
|
+
anchorAlignment: z
|
|
239
|
+
.enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"])
|
|
240
|
+
.default("center"),
|
|
241
|
+
font: z.enum(["tscircuit2024"]).optional(),
|
|
242
|
+
fontSize: length.optional(),
|
|
243
|
+
})
|
|
244
|
+
export type SilkscreenTextProps = z.input<typeof silkscreenTextProps>
|
|
245
|
+
|
|
246
|
+
export const silkscreenPathProps = pcbLayoutProps
|
|
247
|
+
.omit({ pcbX: true, pcbY: true, pcbRotation: true })
|
|
248
|
+
.extend({
|
|
249
|
+
route: z.array(route_hint_point),
|
|
250
|
+
strokeWidth: length.optional(),
|
|
251
|
+
})
|
|
252
|
+
export type SilkscreenPathProps = z.input<typeof silkscreenPathProps>
|
|
253
|
+
|
|
254
|
+
export const silkscreenLineProps = pcbLayoutProps
|
|
255
|
+
.omit({ pcbX: true, pcbY: true, pcbRotation: true })
|
|
256
|
+
.extend({
|
|
257
|
+
strokeWidth: distance,
|
|
258
|
+
x1: distance,
|
|
259
|
+
y1: distance,
|
|
260
|
+
x2: distance,
|
|
261
|
+
y2: distance,
|
|
262
|
+
})
|
|
263
|
+
export type SilkscreenLineProps = z.input<typeof silkscreenLineProps>
|
|
264
|
+
|
|
265
|
+
export const silkscreenRectProps = pcbLayoutProps
|
|
266
|
+
.omit({ pcbRotation: true })
|
|
267
|
+
.extend({
|
|
268
|
+
isFilled: z.boolean().optional(),
|
|
269
|
+
isOutline: z.boolean().optional(),
|
|
270
|
+
strokeWidth: distance.optional(),
|
|
271
|
+
width: distance,
|
|
272
|
+
height: distance,
|
|
273
|
+
})
|
|
274
|
+
export type SilkscreenRectProps = z.input<typeof silkscreenRectProps>
|
|
275
|
+
|
|
276
|
+
export const silkscreenCircleProps = pcbLayoutProps
|
|
277
|
+
.omit({ pcbRotation: true })
|
|
278
|
+
.extend({
|
|
279
|
+
isFilled: z.boolean().optional(),
|
|
280
|
+
isOutline: z.boolean().optional(),
|
|
281
|
+
strokeWidth: distance.optional(),
|
|
282
|
+
radius: distance,
|
|
283
|
+
})
|
|
284
|
+
export type SilkscreenCircleProps = z.input<typeof silkscreenCircleProps>
|
|
285
|
+
|
|
286
|
+
export const routeHintPointProps = z.object({
|
|
287
|
+
x: distance,
|
|
288
|
+
y: distance,
|
|
289
|
+
via: z.boolean().optional(),
|
|
290
|
+
toLayer: layer_ref.optional(),
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
export const traceHintProps = z.object({
|
|
294
|
+
for: z
|
|
295
|
+
.string()
|
|
296
|
+
.optional()
|
|
297
|
+
.describe(
|
|
298
|
+
"Selector for the port you're targeting, not required if you're inside a trace",
|
|
299
|
+
),
|
|
300
|
+
order: z.number().optional(),
|
|
301
|
+
offset: route_hint_point.or(routeHintPointProps).optional(),
|
|
302
|
+
offsets: z
|
|
303
|
+
.array(route_hint_point)
|
|
304
|
+
.or(z.array(routeHintPointProps))
|
|
305
|
+
.optional(),
|
|
306
|
+
traceWidth: z.number().optional(),
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
export type TraceHintProps = z.input<typeof traceHintProps>
|
|
310
|
+
|
|
311
|
+
export const pcbTraceProps = z.object({
|
|
312
|
+
layer: z.string().optional(),
|
|
313
|
+
thickness: distance.optional(),
|
|
314
|
+
route: z.array(route_hint_point),
|
|
315
|
+
})
|
|
316
|
+
export type PcbTraceProps = z.input<typeof pcbTraceProps>
|
|
317
|
+
|
|
318
|
+
export const fabricationNoteTextProps = pcbLayoutProps.extend({
|
|
319
|
+
text: z.string(),
|
|
320
|
+
anchorAlignment: z
|
|
321
|
+
.enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"])
|
|
322
|
+
.default("center"),
|
|
323
|
+
font: z.enum(["tscircuit2024"]).optional(),
|
|
324
|
+
fontSize: length.optional(),
|
|
325
|
+
})
|
|
326
|
+
export type FabricationNoteTextProps = z.input<typeof fabricationNoteTextProps>
|
|
327
|
+
|
|
328
|
+
export const fabricationNotePathProps = pcbLayoutProps
|
|
329
|
+
.omit({ pcbX: true, pcbY: true, pcbRotation: true })
|
|
330
|
+
.extend({
|
|
331
|
+
route: z.array(route_hint_point),
|
|
332
|
+
strokeWidth: length.optional(),
|
|
333
|
+
})
|
|
334
|
+
export type FabricationNotePathProps = z.input<typeof fabricationNotePathProps>
|
package/lib/typecheck.ts
ADDED
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/props",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.43",
|
|
4
4
|
"description": "Props for tscircuit builtin component types",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsup lib/index.ts --dts --sourcemap",
|
|
8
|
+
"check-circular-deps": "madge --circular --extensions ts ./lib",
|
|
8
9
|
"format": "biome format . --write",
|
|
9
10
|
"format:check": "biome format ."
|
|
10
11
|
},
|
|
11
12
|
"keywords": [],
|
|
12
13
|
"files": [
|
|
13
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"lib"
|
|
14
16
|
],
|
|
15
17
|
"author": "",
|
|
16
18
|
"license": "ISC",
|
|
@@ -18,9 +20,12 @@
|
|
|
18
20
|
"@biomejs/biome": "^1.8.3",
|
|
19
21
|
"@tscircuit/layout": "^0.0.11",
|
|
20
22
|
"@tscircuit/soup": "^0.0.50",
|
|
23
|
+
"@types/bun": "^1.1.8",
|
|
21
24
|
"@types/node": "^20.12.11",
|
|
22
25
|
"@types/react": "^18.3.2",
|
|
23
26
|
"ava": "^6.1.3",
|
|
27
|
+
"expect-type": "^0.20.0",
|
|
28
|
+
"madge": "^8.0.0",
|
|
24
29
|
"react": "^18.3.1",
|
|
25
30
|
"tsup": "^8.0.2",
|
|
26
31
|
"tsx": "^4.10.2",
|