@tscircuit/props 0.0.261 → 0.0.263
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 +334 -305
- package/dist/index.d.ts +1213 -107
- package/dist/index.js +24 -12
- package/dist/index.js.map +1 -1
- package/lib/common/layout.ts +22 -4
- package/lib/components/board.ts +0 -12
- package/lib/components/group.ts +23 -1
- package/package.json +1 -1
package/lib/common/layout.ts
CHANGED
|
@@ -70,11 +70,31 @@ export const supplierProps = z.object({
|
|
|
70
70
|
|
|
71
71
|
expectTypesMatch<SupplierProps, z.input<typeof supplierProps>>(true)
|
|
72
72
|
|
|
73
|
+
export interface PinAttributeMap {
|
|
74
|
+
providesPower?: boolean
|
|
75
|
+
requiresPower?: boolean
|
|
76
|
+
providesGround?: boolean
|
|
77
|
+
requiresGround?: boolean
|
|
78
|
+
providesVoltage?: string | number
|
|
79
|
+
requiresVoltage?: string | number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const pinAttributeMap = z.object({
|
|
83
|
+
providesPower: z.boolean().optional(),
|
|
84
|
+
requiresPower: z.boolean().optional(),
|
|
85
|
+
providesGround: z.boolean().optional(),
|
|
86
|
+
requiresGround: z.boolean().optional(),
|
|
87
|
+
providesVoltage: z.union([z.string(), z.number()]).optional(),
|
|
88
|
+
requiresVoltage: z.union([z.string(), z.number()]).optional(),
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
expectTypesMatch<PinAttributeMap, z.input<typeof pinAttributeMap>>(true)
|
|
92
|
+
|
|
73
93
|
export interface CommonComponentProps<PinLabel extends string = string>
|
|
74
94
|
extends CommonLayoutProps {
|
|
75
95
|
key?: any
|
|
76
96
|
name: string
|
|
77
|
-
pinAttributes?: Record<PinLabel,
|
|
97
|
+
pinAttributes?: Record<PinLabel, PinAttributeMap>
|
|
78
98
|
supplierPartNumbers?: SupplierPartNumbers
|
|
79
99
|
cadModel?: CadModelProp
|
|
80
100
|
children?: any
|
|
@@ -91,9 +111,7 @@ export const commonComponentProps = commonLayoutProps
|
|
|
91
111
|
children: z.any().optional(),
|
|
92
112
|
symbolName: z.string().optional(),
|
|
93
113
|
doNotPlace: z.boolean().optional(),
|
|
94
|
-
pinAttributes: z
|
|
95
|
-
.record(z.string(), z.record(z.string(), z.any()))
|
|
96
|
-
.optional(),
|
|
114
|
+
pinAttributes: z.record(z.string(), pinAttributeMap).optional(),
|
|
97
115
|
})
|
|
98
116
|
|
|
99
117
|
type InferredCommonComponentProps = z.input<typeof commonComponentProps>
|
package/lib/components/board.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import { distance } from "circuit-json"
|
|
2
|
-
import { type Point, point } from "lib/common/point"
|
|
3
1
|
import { expectTypesMatch } from "lib/typecheck"
|
|
4
2
|
import { z } from "zod"
|
|
5
3
|
import { subcircuitGroupProps, type SubcircuitGroupProps } from "./group"
|
|
6
4
|
|
|
7
5
|
export interface BoardProps extends Omit<SubcircuitGroupProps, "subcircuit"> {
|
|
8
|
-
width?: number | string
|
|
9
|
-
height?: number | string
|
|
10
|
-
outline?: Point[]
|
|
11
|
-
outlineOffsetX?: number | string
|
|
12
|
-
outlineOffsetY?: number | string
|
|
13
6
|
material?: "fr4" | "fr1"
|
|
14
7
|
}
|
|
15
8
|
|
|
16
9
|
export const boardProps = subcircuitGroupProps.extend({
|
|
17
|
-
width: distance.optional(),
|
|
18
|
-
height: distance.optional(),
|
|
19
|
-
outline: z.array(point).optional(),
|
|
20
|
-
outlineOffsetX: distance.optional(),
|
|
21
|
-
outlineOffsetY: distance.optional(),
|
|
22
10
|
material: z.enum(["fr4", "fr1"]).default("fr4"),
|
|
23
11
|
})
|
|
24
12
|
|
package/lib/components/group.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { layer_ref, length } from "circuit-json"
|
|
1
|
+
import { layer_ref, length, distance } from "circuit-json"
|
|
2
2
|
import type { Distance } from "lib/common/distance"
|
|
3
3
|
import {
|
|
4
4
|
type CommonLayoutProps,
|
|
5
5
|
commonLayoutProps,
|
|
6
6
|
type SupplierPartNumbers,
|
|
7
7
|
} from "lib/common/layout"
|
|
8
|
+
import { type Point, point } from "lib/common/point"
|
|
8
9
|
import { expectTypesMatch } from "lib/typecheck"
|
|
9
10
|
import { z } from "zod"
|
|
10
11
|
import type { AnySourceComponent, PcbTrace } from "circuit-json"
|
|
@@ -218,6 +219,19 @@ export interface SubcircuitGroupProps extends BaseGroupProps {
|
|
|
218
219
|
schTraceAutoLabelEnabled?: boolean
|
|
219
220
|
|
|
220
221
|
partsEngine?: PartsEngine
|
|
222
|
+
|
|
223
|
+
/** When autosizing, the board will be made square */
|
|
224
|
+
square?: boolean
|
|
225
|
+
/** Desired empty area of the board e.g. "22mm^2" or "20%" */
|
|
226
|
+
emptyArea?: string
|
|
227
|
+
/** Desired filled area of the board e.g. "22mm^2" or "20%" */
|
|
228
|
+
filledArea?: string
|
|
229
|
+
|
|
230
|
+
width?: number | string
|
|
231
|
+
height?: number | string
|
|
232
|
+
outline?: Point[]
|
|
233
|
+
outlineOffsetX?: number | string
|
|
234
|
+
outlineOffsetY?: number | string
|
|
221
235
|
}
|
|
222
236
|
|
|
223
237
|
export interface SubcircuitGroupPropsWithBool extends SubcircuitGroupProps {
|
|
@@ -264,6 +278,14 @@ export const subcircuitGroupProps = baseGroupProps.extend({
|
|
|
264
278
|
partsEngine: partsEngine.optional(),
|
|
265
279
|
pcbRouteCache: z.custom<PcbRouteCache>((v) => true).optional(),
|
|
266
280
|
autorouter: autorouterProp.optional(),
|
|
281
|
+
square: z.boolean().optional(),
|
|
282
|
+
emptyArea: z.string().optional(),
|
|
283
|
+
filledArea: z.string().optional(),
|
|
284
|
+
width: distance.optional(),
|
|
285
|
+
height: distance.optional(),
|
|
286
|
+
outline: z.array(point).optional(),
|
|
287
|
+
outlineOffsetX: distance.optional(),
|
|
288
|
+
outlineOffsetY: distance.optional(),
|
|
267
289
|
})
|
|
268
290
|
|
|
269
291
|
export const subcircuitGroupPropsWithBool = subcircuitGroupProps.extend({
|