@tscircuit/props 0.0.643 → 0.0.645
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 +6545 -6434
- package/dist/index.js +1212 -1153
- package/dist/index.js.map +1 -1
- package/lib/assembly/index.ts +3 -0
- package/lib/assembly/screen.ts +69 -0
- package/lib/components/antenna.ts +39 -1
- package/package.json +1 -1
package/lib/assembly/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { assemblyDeviceProps } from "./device"
|
|
2
|
+
import { assemblyScreenProps } from "./screen"
|
|
2
3
|
|
|
3
4
|
export * from "./device"
|
|
5
|
+
export * from "./screen"
|
|
4
6
|
|
|
5
7
|
export const assemblyProps = {
|
|
6
8
|
device: assemblyDeviceProps,
|
|
9
|
+
screen: assemblyScreenProps,
|
|
7
10
|
} as const
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type Distance, distance } from "lib/common/distance"
|
|
2
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
export interface AssemblyScreenProps {
|
|
6
|
+
/** Stable product-level identity for the screen assembly. */
|
|
7
|
+
name: string
|
|
8
|
+
/** Selector for the connector that the screen attaches to. */
|
|
9
|
+
connectsTo: string
|
|
10
|
+
/**
|
|
11
|
+
* Outer width of the screen body, including its bezel but excluding the flex
|
|
12
|
+
* cable. When supplied, it must be provided together with `height`.
|
|
13
|
+
*/
|
|
14
|
+
width?: Distance
|
|
15
|
+
/**
|
|
16
|
+
* Outer height of the screen body, including its bezel but excluding the flex
|
|
17
|
+
* cable. When supplied, it must be provided together with `width`.
|
|
18
|
+
*/
|
|
19
|
+
height?: Distance
|
|
20
|
+
/**
|
|
21
|
+
* Advanced modelprinter string used to render the screen assembly. Required
|
|
22
|
+
* when `width` and `height` are omitted.
|
|
23
|
+
*/
|
|
24
|
+
cadModel?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const nonemptyString = (fieldName: "name" | "connectsTo" | "cadModel") =>
|
|
28
|
+
z.string().refine((value) => value.trim().length > 0, {
|
|
29
|
+
message: `${fieldName} cannot be empty`,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const positiveDistance = (fieldName: "width" | "height") =>
|
|
33
|
+
distance.refine((value) => Number.isFinite(value) && value > 0, {
|
|
34
|
+
message: `${fieldName} must be a positive finite distance`,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const assemblyScreenProps = z
|
|
38
|
+
.object({
|
|
39
|
+
name: nonemptyString("name"),
|
|
40
|
+
connectsTo: nonemptyString("connectsTo"),
|
|
41
|
+
width: positiveDistance("width").optional(),
|
|
42
|
+
height: positiveDistance("height").optional(),
|
|
43
|
+
cadModel: nonemptyString("cadModel").optional(),
|
|
44
|
+
})
|
|
45
|
+
.superRefine((screen, context) => {
|
|
46
|
+
const hasWidth = screen.width !== undefined
|
|
47
|
+
const hasHeight = screen.height !== undefined
|
|
48
|
+
|
|
49
|
+
if (hasWidth !== hasHeight) {
|
|
50
|
+
context.addIssue({
|
|
51
|
+
code: z.ZodIssueCode.custom,
|
|
52
|
+
message: "width and height must be provided together",
|
|
53
|
+
path: hasWidth ? ["height"] : ["width"],
|
|
54
|
+
})
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!hasWidth && screen.cadModel === undefined) {
|
|
59
|
+
context.addIssue({
|
|
60
|
+
code: z.ZodIssueCode.custom,
|
|
61
|
+
message: "provide either width and height or cadModel",
|
|
62
|
+
path: [],
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
export type AssemblyScreenPropsInput = z.input<typeof assemblyScreenProps>
|
|
68
|
+
|
|
69
|
+
expectTypesMatch<AssemblyScreenProps, AssemblyScreenPropsInput>(true)
|
|
@@ -6,8 +6,44 @@ import { type PcbPath, pcbPath } from "lib/common/pcbPath"
|
|
|
6
6
|
import { expectTypesMatch } from "lib/typecheck"
|
|
7
7
|
import { z } from "zod"
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/** Band-qualified PCB-trace antenna topologies. */
|
|
10
|
+
export const antennaShapes = [
|
|
11
|
+
"2.4ghz_quarter_wave_monopole",
|
|
12
|
+
"2.4ghz_meandered_monopole",
|
|
13
|
+
"2.4ghz_inverted_f",
|
|
14
|
+
"2.4ghz_meandered_inverted_f",
|
|
15
|
+
"2.4ghz_folded_dipole",
|
|
16
|
+
] as const
|
|
17
|
+
|
|
18
|
+
export type AntennaShape = (typeof antennaShapes)[number]
|
|
19
|
+
export const antennaShape = z.enum(antennaShapes)
|
|
20
|
+
|
|
21
|
+
/** Nominal Wi-Fi and Bluetooth operating-band configurations. */
|
|
22
|
+
export const antennaFrequencyBands = [
|
|
23
|
+
"2.4ghz",
|
|
24
|
+
"5ghz",
|
|
25
|
+
"6ghz",
|
|
26
|
+
"dual_band_2.4ghz_5ghz",
|
|
27
|
+
"tri_band_2.4ghz_5ghz_6ghz",
|
|
28
|
+
] as const
|
|
29
|
+
|
|
30
|
+
export type AntennaFrequencyBand = (typeof antennaFrequencyBands)[number]
|
|
31
|
+
export const antennaFrequencyBand = z.enum(antennaFrequencyBands)
|
|
32
|
+
|
|
33
|
+
/** Props for an antenna component with optional generated or explicit geometry. */
|
|
10
34
|
export interface AntennaProps extends CommonComponentProps {
|
|
35
|
+
/**
|
|
36
|
+
* Band-qualified PCB-trace topology to generate. The encoded band is enough
|
|
37
|
+
* to select the geometry without frequencyBand. No shape is assumed when
|
|
38
|
+
* omitted. An explicit pcbPath takes precedence when both are provided.
|
|
39
|
+
*/
|
|
40
|
+
antennaShape?: AntennaShape
|
|
41
|
+
/**
|
|
42
|
+
* Nominal operating band or multiband configuration. This is redundant when
|
|
43
|
+
* antennaShape is present; the band encoded in antennaShape controls generated
|
|
44
|
+
* geometry.
|
|
45
|
+
*/
|
|
46
|
+
frequencyBand?: AntennaFrequencyBand
|
|
11
47
|
/**
|
|
12
48
|
* Explicit antenna path. Entries use the same selector, point, and via
|
|
13
49
|
* syntax as trace pcbPath entries.
|
|
@@ -16,6 +52,8 @@ export interface AntennaProps extends CommonComponentProps {
|
|
|
16
52
|
}
|
|
17
53
|
|
|
18
54
|
export const antennaProps = commonComponentProps.extend({
|
|
55
|
+
antennaShape: antennaShape.optional(),
|
|
56
|
+
frequencyBand: antennaFrequencyBand.optional(),
|
|
19
57
|
pcbPath: pcbPath.optional(),
|
|
20
58
|
})
|
|
21
59
|
|