@tscircuit/props 0.0.340 → 0.0.342
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 +15 -0
- package/dist/index.d.ts +61 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/lib/components/board.ts +36 -0
- package/lib/platformConfig.ts +29 -0
- package/package.json +1 -1
package/lib/components/board.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AutocompleteString } from "lib/common/autocomplete"
|
|
1
2
|
import { distance, type Distance } from "lib/common/distance"
|
|
2
3
|
import { ninePointAnchor } from "lib/common/ninePointAnchor"
|
|
3
4
|
import { type Point, point } from "lib/common/point"
|
|
@@ -5,6 +6,23 @@ import { expectTypesMatch } from "lib/typecheck"
|
|
|
5
6
|
import { z } from "zod"
|
|
6
7
|
import { subcircuitGroupProps, type SubcircuitGroupProps } from "./group"
|
|
7
8
|
|
|
9
|
+
const boardColorPresets = [
|
|
10
|
+
"not_specified",
|
|
11
|
+
"green",
|
|
12
|
+
"red",
|
|
13
|
+
"blue",
|
|
14
|
+
"purple",
|
|
15
|
+
"black",
|
|
16
|
+
"white",
|
|
17
|
+
"yellow",
|
|
18
|
+
] as const
|
|
19
|
+
|
|
20
|
+
export type BoardColorPreset = (typeof boardColorPresets)[number]
|
|
21
|
+
|
|
22
|
+
export type BoardColor = AutocompleteString<BoardColorPreset>
|
|
23
|
+
|
|
24
|
+
const boardColor = z.custom<BoardColor>((value) => typeof value === "string")
|
|
25
|
+
|
|
8
26
|
export interface BoardProps extends Omit<SubcircuitGroupProps, "subcircuit"> {
|
|
9
27
|
material?: "fr4" | "fr1"
|
|
10
28
|
/** Number of layers for the PCB */
|
|
@@ -12,6 +30,18 @@ export interface BoardProps extends Omit<SubcircuitGroupProps, "subcircuit"> {
|
|
|
12
30
|
borderRadius?: Distance
|
|
13
31
|
boardAnchorPosition?: Point
|
|
14
32
|
boardAnchorAlignment?: z.infer<typeof ninePointAnchor>
|
|
33
|
+
/** Color applied to both top and bottom solder masks */
|
|
34
|
+
solderMaskColor?: BoardColor
|
|
35
|
+
/** Color of the top solder mask */
|
|
36
|
+
topSolderMaskColor?: BoardColor
|
|
37
|
+
/** Color of the bottom solder mask */
|
|
38
|
+
bottomSolderMaskColor?: BoardColor
|
|
39
|
+
/** Color applied to both top and bottom silkscreens */
|
|
40
|
+
silkscreenColor?: BoardColor
|
|
41
|
+
/** Color of the top silkscreen */
|
|
42
|
+
topSilkscreenColor?: BoardColor
|
|
43
|
+
/** Color of the bottom silkscreen */
|
|
44
|
+
bottomSilkscreenColor?: BoardColor
|
|
15
45
|
}
|
|
16
46
|
|
|
17
47
|
export const boardProps = subcircuitGroupProps.extend({
|
|
@@ -20,6 +50,12 @@ export const boardProps = subcircuitGroupProps.extend({
|
|
|
20
50
|
borderRadius: distance.optional(),
|
|
21
51
|
boardAnchorPosition: point.optional(),
|
|
22
52
|
boardAnchorAlignment: ninePointAnchor.optional(),
|
|
53
|
+
solderMaskColor: boardColor.optional(),
|
|
54
|
+
topSolderMaskColor: boardColor.optional(),
|
|
55
|
+
bottomSolderMaskColor: boardColor.optional(),
|
|
56
|
+
silkscreenColor: boardColor.optional(),
|
|
57
|
+
topSilkscreenColor: boardColor.optional(),
|
|
58
|
+
bottomSilkscreenColor: boardColor.optional(),
|
|
23
59
|
})
|
|
24
60
|
|
|
25
61
|
type InferredBoardProps = z.input<typeof boardProps>
|
package/lib/platformConfig.ts
CHANGED
|
@@ -17,6 +17,17 @@ export interface FootprintFileParserEntry {
|
|
|
17
17
|
loadFromUrl: (url: string) => Promise<FootprintLibraryResult>
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export type CircuitJson = any[]
|
|
21
|
+
|
|
22
|
+
export interface SpiceEngineSimulationResult {
|
|
23
|
+
engineVersionString?: string
|
|
24
|
+
simulationResultCircuitJson: CircuitJson
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SpiceEngine {
|
|
28
|
+
simulate: (spiceString: string) => Promise<SpiceEngineSimulationResult>
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
export interface PlatformConfig {
|
|
21
32
|
partsEngine?: PartsEngine
|
|
22
33
|
|
|
@@ -39,6 +50,8 @@ export interface PlatformConfig {
|
|
|
39
50
|
schematicDisabled?: boolean
|
|
40
51
|
partsEngineDisabled?: boolean
|
|
41
52
|
|
|
53
|
+
spiceEngine?: SpiceEngine
|
|
54
|
+
|
|
42
55
|
footprintLibraryMap?: Record<
|
|
43
56
|
string,
|
|
44
57
|
| ((path: string) => Promise<FootprintLibraryResult>)
|
|
@@ -72,6 +85,21 @@ const footprintFileParserEntry = z.object({
|
|
|
72
85
|
),
|
|
73
86
|
})
|
|
74
87
|
|
|
88
|
+
const spiceEngineSimulationResult = z.object({
|
|
89
|
+
engineVersionString: z.string().optional(),
|
|
90
|
+
simulationResultCircuitJson: unvalidatedCircuitJson,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const spiceEngineZod = z.object({
|
|
94
|
+
simulate: z
|
|
95
|
+
.function()
|
|
96
|
+
.args(z.string())
|
|
97
|
+
.returns(z.promise(spiceEngineSimulationResult))
|
|
98
|
+
.describe(
|
|
99
|
+
"A function that takes a SPICE string and returns a simulation result",
|
|
100
|
+
),
|
|
101
|
+
})
|
|
102
|
+
|
|
75
103
|
export const platformConfig = z.object({
|
|
76
104
|
partsEngine: partsEngine.optional(),
|
|
77
105
|
autorouter: autorouterProp.optional(),
|
|
@@ -86,6 +114,7 @@ export const platformConfig = z.object({
|
|
|
86
114
|
pcbDisabled: z.boolean().optional(),
|
|
87
115
|
schematicDisabled: z.boolean().optional(),
|
|
88
116
|
partsEngineDisabled: z.boolean().optional(),
|
|
117
|
+
spiceEngine: spiceEngineZod.optional(),
|
|
89
118
|
footprintLibraryMap: z
|
|
90
119
|
.record(
|
|
91
120
|
z.string(),
|