@tscircuit/props 0.0.527 → 0.0.529
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 +106 -127
- package/dist/index.d.ts +1187 -3
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/lib/components/resistor.ts +55 -27
- package/lib/platformConfig.ts +20 -2
- package/package.json +1 -1
|
@@ -33,38 +33,66 @@ export interface ResistorProps<PinLabel extends string = string>
|
|
|
33
33
|
connections?: Connections<ResistorPinLabels>
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
type ResistorFootprint = CommonComponentProps["footprint"]
|
|
37
|
+
|
|
38
|
+
const resistorImperialFootprintNames = new Set([
|
|
39
|
+
"01005",
|
|
40
|
+
"0201",
|
|
41
|
+
"0402",
|
|
42
|
+
"0504",
|
|
43
|
+
"0603",
|
|
44
|
+
"0805",
|
|
45
|
+
"1206",
|
|
46
|
+
"1210",
|
|
47
|
+
"1812",
|
|
48
|
+
"2010",
|
|
49
|
+
"2512",
|
|
50
|
+
])
|
|
51
|
+
|
|
52
|
+
const mapResistorFootprint = (
|
|
53
|
+
footprint: ResistorFootprint,
|
|
54
|
+
): ResistorFootprint => {
|
|
55
|
+
if (typeof footprint !== "string") return footprint
|
|
56
|
+
if (!resistorImperialFootprintNames.has(footprint)) return footprint
|
|
57
|
+
return `res${footprint}`
|
|
58
|
+
}
|
|
59
|
+
export const resistorProps = commonComponentProps
|
|
60
|
+
.extend({
|
|
61
|
+
resistance,
|
|
62
|
+
tolerance: z
|
|
63
|
+
.union([z.string(), z.number()])
|
|
64
|
+
.transform((val) => {
|
|
65
|
+
if (typeof val === "string") {
|
|
66
|
+
if (val.endsWith("%")) {
|
|
67
|
+
return parseFloat(val.slice(0, -1)) / 100
|
|
68
|
+
}
|
|
69
|
+
return parseFloat(val)
|
|
44
70
|
}
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
.optional(),
|
|
71
|
+
return val
|
|
72
|
+
})
|
|
73
|
+
.pipe(
|
|
74
|
+
z
|
|
75
|
+
.number()
|
|
76
|
+
.min(0, "Tolerance must be non-negative")
|
|
77
|
+
.max(1, "Tolerance cannot be greater than 100%"),
|
|
78
|
+
)
|
|
79
|
+
.optional(),
|
|
56
80
|
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
pullupFor: z.string().optional(),
|
|
82
|
+
pullupTo: z.string().optional(),
|
|
59
83
|
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
pulldownFor: z.string().optional(),
|
|
85
|
+
pulldownTo: z.string().optional(),
|
|
62
86
|
|
|
63
|
-
|
|
64
|
-
|
|
87
|
+
schOrientation: schematicOrientation.optional(),
|
|
88
|
+
schSize: schematicSymbolSize.optional(),
|
|
65
89
|
|
|
66
|
-
|
|
67
|
-
})
|
|
90
|
+
connections: createConnectionsProp(resistorPinLabels).optional(),
|
|
91
|
+
})
|
|
92
|
+
.transform((props) => ({
|
|
93
|
+
...props,
|
|
94
|
+
footprint: mapResistorFootprint(props.footprint),
|
|
95
|
+
}))
|
|
68
96
|
export const resistorPins = lrPins
|
|
69
97
|
|
|
70
98
|
type InferredResistorProps = z.input<typeof resistorProps>
|
package/lib/platformConfig.ts
CHANGED
|
@@ -45,6 +45,19 @@ export interface AutorouterDefinition {
|
|
|
45
45
|
) => AutorouterInstance | Promise<AutorouterInstance>
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** e.g. "kicad", this is the prefix used to reference libraries in footprinter strings e.g. kicad:Resistor_0402 **/
|
|
49
|
+
type FootprintLibraryPrefix = string
|
|
50
|
+
|
|
51
|
+
/** e.g. "kicad_mod", used to reference file extensions for loaders **/
|
|
52
|
+
type FileExtension = string
|
|
53
|
+
|
|
54
|
+
type FileContent = string | ArrayBufferLike
|
|
55
|
+
|
|
56
|
+
type EsModuleImportResult = {
|
|
57
|
+
__esModule: true
|
|
58
|
+
default: any
|
|
59
|
+
}
|
|
60
|
+
|
|
48
61
|
export interface PlatformConfig {
|
|
49
62
|
partsEngine?: PartsEngine
|
|
50
63
|
|
|
@@ -84,7 +97,7 @@ export interface PlatformConfig {
|
|
|
84
97
|
spiceEngineMap?: Record<string, SpiceEngine>
|
|
85
98
|
|
|
86
99
|
footprintLibraryMap?: Record<
|
|
87
|
-
|
|
100
|
+
FootprintLibraryPrefix,
|
|
88
101
|
| ((
|
|
89
102
|
path: string,
|
|
90
103
|
options?: { resolvedPcbStyle?: PcbStyle },
|
|
@@ -99,7 +112,12 @@ export interface PlatformConfig {
|
|
|
99
112
|
>
|
|
100
113
|
>
|
|
101
114
|
|
|
102
|
-
footprintFileParserMap?: Record<
|
|
115
|
+
footprintFileParserMap?: Record<FileExtension, FootprintFileParserEntry>
|
|
116
|
+
|
|
117
|
+
staticFileLoaderMap?: Record<
|
|
118
|
+
FileExtension,
|
|
119
|
+
(fileContent: FileContent) => Promise<EsModuleImportResult>
|
|
120
|
+
>
|
|
103
121
|
|
|
104
122
|
resolveProjectStaticFileImportUrl?: (path: string) => Promise<string>
|
|
105
123
|
nodeModulesResolver?: (modulePath: string) => Promise<string | null>
|