@tscircuit/props 0.0.678 → 0.0.680
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 +8 -1
- package/dist/index.d.ts +145 -7
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/lib/common/layout.ts +5 -0
- package/lib/common/resolveManufacturerPartNumber.ts +23 -0
- package/lib/components/crystal.ts +0 -2
- package/lib/components/mountedboard.ts +4 -0
- package/lib/components/pcb-bend.ts +10 -1
- package/lib/index.ts +1 -0
- package/package.json +1 -1
package/lib/common/layout.ts
CHANGED
|
@@ -258,7 +258,11 @@ export interface CommonComponentProps<PinLabel extends string = string>
|
|
|
258
258
|
* Whether to show this component's CAD model as translucent in the 3D viewer.
|
|
259
259
|
*/
|
|
260
260
|
showAsTranslucentModel?: boolean
|
|
261
|
+
/** Alias for manufacturerPartNumber. No default; use resolveManufacturerPartNumber to resolve aliases. */
|
|
262
|
+
mpn?: string
|
|
263
|
+
/** Alias for manufacturerPartNumber. Retained for existing circuits. */
|
|
261
264
|
mfn?: string
|
|
265
|
+
/** Manufacturer's part number. Aliases must agree when specified together. */
|
|
262
266
|
manufacturerPartNumber?: string
|
|
263
267
|
/**
|
|
264
268
|
* This component will be drawn as part of this section e.g. "Power"
|
|
@@ -314,6 +318,7 @@ export const commonComponentProps = commonLayoutProps
|
|
|
314
318
|
"Whether to show this component's CAD model as translucent in the 3D viewer.",
|
|
315
319
|
),
|
|
316
320
|
pinAttributes: z.record(z.string(), pinAttributeMap).optional(),
|
|
321
|
+
mpn: z.string().describe("Manufacturer Part Number").optional(),
|
|
317
322
|
mfn: z.string().describe("Manufacturer Part Number").optional(),
|
|
318
323
|
manufacturerPartNumber: z.string().optional(),
|
|
319
324
|
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CommonComponentProps } from "./layout"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Schemas retain the author's optional aliases so their Zod objects remain
|
|
5
|
+
* composable. Consumers resolve them to a canonical manufacturer part number
|
|
6
|
+
* with this helper. There is no default: empty/whitespace-only values are absent.
|
|
7
|
+
* Equal aliases are accepted; conflicting nonempty aliases throw. Existing
|
|
8
|
+
* manufacturerPartNumber and mfn inputs remain supported without migration.
|
|
9
|
+
*/
|
|
10
|
+
export const resolveManufacturerPartNumber = (
|
|
11
|
+
props: Pick<CommonComponentProps, "manufacturerPartNumber" | "mpn" | "mfn">,
|
|
12
|
+
): string | undefined => {
|
|
13
|
+
const partNumbers = [props.manufacturerPartNumber, props.mpn, props.mfn]
|
|
14
|
+
.map((partNumber) => partNumber?.trim())
|
|
15
|
+
.filter((partNumber): partNumber is string => Boolean(partNumber))
|
|
16
|
+
|
|
17
|
+
if (new Set(partNumbers).size > 1) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
"Conflicting manufacturerPartNumber, mpn, and mfn: specify the same manufacturer part number for all aliases",
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
return partNumbers[0]
|
|
23
|
+
}
|
|
@@ -31,7 +31,6 @@ export interface CrystalProps<PinLabel extends string = string>
|
|
|
31
31
|
/** Maximum allowed PCB trace length between the crystal and its connected component */
|
|
32
32
|
maxTraceLength?: number | string
|
|
33
33
|
manufacturerPartNumber?: string
|
|
34
|
-
mpn?: string
|
|
35
34
|
pinVariant?: PinVariant
|
|
36
35
|
schOrientation?: SchematicOrientation
|
|
37
36
|
connections?: Connections<CrystalPinLabels>
|
|
@@ -42,7 +41,6 @@ export const crystalProps = commonComponentProps.extend({
|
|
|
42
41
|
loadCapacitance: capacitance,
|
|
43
42
|
maxTraceLength: distance.optional(),
|
|
44
43
|
manufacturerPartNumber: z.string().optional(),
|
|
45
|
-
mpn: z.string().optional(),
|
|
46
44
|
pinVariant: z.enum(["two_pin", "four_pin"]).optional(),
|
|
47
45
|
schOrientation: schematicOrientation.optional(),
|
|
48
46
|
connections: createConnectionsProp(crystalPins).optional(),
|
|
@@ -7,6 +7,8 @@ import { subcircuitGroupProps, type SubcircuitGroupProps } from "./group"
|
|
|
7
7
|
|
|
8
8
|
type MountedBoardChipProps = Pick<
|
|
9
9
|
ChipPropsSU,
|
|
10
|
+
| "mpn"
|
|
11
|
+
| "mfn"
|
|
10
12
|
| "manufacturerPartNumber"
|
|
11
13
|
| "pinLabels"
|
|
12
14
|
| "showPinAliases"
|
|
@@ -26,6 +28,8 @@ export interface MountedBoardProps
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export const mountedboardProps = subcircuitGroupProps.extend({
|
|
31
|
+
mpn: chipProps.shape.mpn,
|
|
32
|
+
mfn: chipProps.shape.mfn,
|
|
29
33
|
manufacturerPartNumber: chipProps.shape.manufacturerPartNumber,
|
|
30
34
|
pinLabels: chipProps.shape.pinLabels,
|
|
31
35
|
showPinAliases: chipProps.shape.showPinAliases,
|
|
@@ -3,7 +3,7 @@ import { distance, type Distance } from "lib/common/distance"
|
|
|
3
3
|
import { expectTypesMatch } from "lib/typecheck"
|
|
4
4
|
import { z } from "zod"
|
|
5
5
|
|
|
6
|
-
/** A bend on a flat flex PCB
|
|
6
|
+
/** A bend on a flat flex PCB, with optional tear-relief cutouts. */
|
|
7
7
|
export interface PcbBendProps {
|
|
8
8
|
name?: string
|
|
9
9
|
/** Start/end of the bend-zone centerline in the parent PCB coordinate system. */
|
|
@@ -15,6 +15,14 @@ export interface PcbBendProps {
|
|
|
15
15
|
bendAngle: number | string
|
|
16
16
|
/** Positive neutral-surface radius, in mm or a distance string. */
|
|
17
17
|
bendRadius: Distance
|
|
18
|
+
/**
|
|
19
|
+
* Radius of circular tear-relief cutouts centered at both bend endpoints in
|
|
20
|
+
* the flat PCB. Removes material to round the edge where each cutout meets
|
|
21
|
+
* the board outline. Finite and positive, in mm or a distance string;
|
|
22
|
+
* parsed to mm. Omit to leave the outline unchanged (no tear reliefs).
|
|
23
|
+
* Independent of bendRadius and bendSide; no aliases or conflicting props.
|
|
24
|
+
*/
|
|
25
|
+
tearReliefRadius?: Distance
|
|
18
26
|
/** Moving side, looking from (x1, y1) toward (x2, y2) in the flat layout. */
|
|
19
27
|
bendSide: "left" | "right"
|
|
20
28
|
}
|
|
@@ -30,6 +38,7 @@ export const pcbBendProps = z
|
|
|
30
38
|
y2: finiteDistance,
|
|
31
39
|
bendAngle: rotation.pipe(z.number().finite()),
|
|
32
40
|
bendRadius: distance.pipe(z.number().finite().positive()),
|
|
41
|
+
tearReliefRadius: distance.pipe(z.number().finite().positive()).optional(),
|
|
33
42
|
bendSide: z.enum(["left", "right"]),
|
|
34
43
|
})
|
|
35
44
|
.refine(({ x1, y1, x2, y2 }) => x1 !== x2 || y1 !== y2, {
|
package/lib/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./assembly"
|
|
|
4
4
|
export * from "./enclosure"
|
|
5
5
|
export * from "./common/portHints"
|
|
6
6
|
export * from "./common/layout"
|
|
7
|
+
export * from "./common/resolveManufacturerPartNumber"
|
|
7
8
|
export * from "./common/pinAttributeMap"
|
|
8
9
|
export * from "./common/point3"
|
|
9
10
|
export * from "./common/pcbPath"
|