@tscircuit/props 0.0.667 → 0.0.669
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 +2 -0
- package/dist/index.d.ts +74 -3
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/lib/common/fanoutTracePath.ts +24 -1
- package/lib/common/schematicSize.ts +3 -2
- package/lib/components/diode.ts +8 -0
- package/lib/components/led.ts +4 -0
- package/lib/components/trace.ts +9 -0
- package/package.json +1 -1
|
@@ -13,6 +13,10 @@ const routePoint = z.discriminatedUnion("route_type", [
|
|
|
13
13
|
x: coordinate,
|
|
14
14
|
y: coordinate,
|
|
15
15
|
width: positiveDistance,
|
|
16
|
+
width_interpolation_mode: z
|
|
17
|
+
.enum(["linear", "quadratic"])
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Interpolate width from this point to the next wire point."),
|
|
16
20
|
layer: layer_ref,
|
|
17
21
|
}),
|
|
18
22
|
z.object({
|
|
@@ -31,6 +35,10 @@ const routePoint = z.discriminatedUnion("route_type", [
|
|
|
31
35
|
* fanout's local PCB frame, in mm: +X right, +Y up, right-handed with +Z
|
|
32
36
|
* above the board. They are points (placement adds translation), not
|
|
33
37
|
* directions. Numeric distances are mm; unit strings are parsed to mm.
|
|
38
|
+
* A wire point's optional width_interpolation_mode interpolates its width to
|
|
39
|
+
* the next wire point's width. Omitted means the existing constant-width
|
|
40
|
+
* behavior; there are no aliases or migration requirements. Interpolation
|
|
41
|
+
* cannot terminate at a via directly: put a wire point at the via position.
|
|
34
42
|
* Layers are physical board layers, independent of placement. Either endpoint
|
|
35
43
|
* may be a via: the initial layer is its from_layer and the final layer is its
|
|
36
44
|
* to_layer. Placement legality (including allowViaInPad) is checked by core,
|
|
@@ -44,7 +52,22 @@ export const fanoutTracePath = z.object({
|
|
|
44
52
|
.superRefine((route, ctx) => {
|
|
45
53
|
const first = route[0]
|
|
46
54
|
let layer = first?.route_type === "via" ? first.from_layer : first?.layer
|
|
47
|
-
for (const point of route) {
|
|
55
|
+
for (const [index, point] of route.entries()) {
|
|
56
|
+
if (point.route_type === "wire" && point.width_interpolation_mode) {
|
|
57
|
+
const next = route[index + 1]
|
|
58
|
+
if (
|
|
59
|
+
next?.route_type !== "wire" ||
|
|
60
|
+
next.layer !== point.layer ||
|
|
61
|
+
(next.x === point.x && next.y === point.y)
|
|
62
|
+
) {
|
|
63
|
+
ctx.addIssue({
|
|
64
|
+
code: "custom",
|
|
65
|
+
path: [index, "width_interpolation_mode"],
|
|
66
|
+
message:
|
|
67
|
+
"Width interpolation requires a distinct next wire point on the same layer",
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
48
71
|
if (
|
|
49
72
|
(point.route_type === "wire" ? point.layer : point.from_layer) !==
|
|
50
73
|
layer
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { distance } from "circuit-json"
|
|
2
2
|
import { z } from "zod"
|
|
3
3
|
|
|
4
|
-
export const schematicSymbolSize =
|
|
5
|
-
.
|
|
4
|
+
export const schematicSymbolSize = z
|
|
5
|
+
.enum(["xs", "sm", "default", "md"])
|
|
6
|
+
.or(distance.pipe(z.number().finite()))
|
|
6
7
|
.describe("distance between pin1 and pin2 of the schematic symbol")
|
|
7
8
|
|
|
8
9
|
export type SchematicSymbolSize = z.input<typeof schematicSymbolSize>
|
package/lib/components/diode.ts
CHANGED
|
@@ -11,6 +11,11 @@ import {
|
|
|
11
11
|
} from "lib/common/schematicOrientation"
|
|
12
12
|
import { schematicPinLabel } from "lib/common/schematicPinLabel"
|
|
13
13
|
|
|
14
|
+
import {
|
|
15
|
+
schematicSymbolSize,
|
|
16
|
+
type SchematicSymbolSize,
|
|
17
|
+
} from "lib/common/schematicSize"
|
|
18
|
+
|
|
14
19
|
export const diodePins = lrPolarPins
|
|
15
20
|
export type DiodePinLabels = (typeof diodePins)[number]
|
|
16
21
|
export type DiodePinLabelsProp<PinLabel extends string = string> = Partial<
|
|
@@ -60,6 +65,7 @@ export const diodeProps = commonComponentProps
|
|
|
60
65
|
photo: z.boolean().optional(),
|
|
61
66
|
tvs: z.boolean().optional(),
|
|
62
67
|
schOrientation: schematicOrientation.optional(),
|
|
68
|
+
schSize: schematicSymbolSize.optional(),
|
|
63
69
|
pinLabels: diodePinLabelsProp.optional(),
|
|
64
70
|
})
|
|
65
71
|
.superRefine((data, ctx) => {
|
|
@@ -146,6 +152,8 @@ export interface DiodeProps<PinLabel extends string = string>
|
|
|
146
152
|
photo?: boolean
|
|
147
153
|
tvs?: boolean
|
|
148
154
|
schOrientation?: SchematicOrientation
|
|
155
|
+
/** Select a compact schematic symbol; omitted, default, and md retain the standard symbol. */
|
|
156
|
+
schSize?: SchematicSymbolSize
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
export type InferredDiodeProps = z.input<typeof diodeProps>
|
package/lib/components/led.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { createConnectionsProp } from "lib/common/connectionsProp"
|
|
|
5
5
|
import { diodePinLabelsProp } from "lib/components/diode"
|
|
6
6
|
import { schematicPinLabel } from "lib/common/schematicPinLabel"
|
|
7
7
|
|
|
8
|
+
import { schematicSymbolSize } from "lib/common/schematicSize"
|
|
9
|
+
|
|
8
10
|
export type LedPinLabels = (typeof lrPolarPins)[number]
|
|
9
11
|
|
|
10
12
|
const legacyNumericLedPinLabelsProp = z
|
|
@@ -24,6 +26,8 @@ export const ledProps = commonComponentProps.extend({
|
|
|
24
26
|
wavelength: z.string().optional(),
|
|
25
27
|
schDisplayValue: z.string().optional(),
|
|
26
28
|
schOrientation: schematicOrientation.optional(),
|
|
29
|
+
/** Select a compact schematic symbol; omitted, default, and md retain the standard symbol. */
|
|
30
|
+
schSize: schematicSymbolSize.optional(),
|
|
27
31
|
// Numeric keys are accepted for compatibility with legacy generated LED
|
|
28
32
|
// wrappers, then normalized to the canonical pin1/pin2 representation.
|
|
29
33
|
pinLabels: diodePinLabelsProp.or(legacyNumericLedPinLabelsProp).optional(),
|
package/lib/components/trace.ts
CHANGED
|
@@ -22,6 +22,15 @@ const baseTraceProps = z.object({
|
|
|
22
22
|
width: distance.optional().describe("Alias for trace thickness"),
|
|
23
23
|
schematicRouteHints: z.array(point).optional(),
|
|
24
24
|
pcbRouteHints: z.array(route_hint_point).optional(),
|
|
25
|
+
pcbTeardrops: z.boolean().optional().describe("Enable PCB trace teardrops."),
|
|
26
|
+
pcbTeardropStart: z
|
|
27
|
+
.boolean()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Teardrop at the start (from) of trace"),
|
|
30
|
+
pcbTeardropEnd: z
|
|
31
|
+
.boolean()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Teardrop at the end (to) of trace"),
|
|
25
34
|
pcbPathRelativeTo: z.string().optional(),
|
|
26
35
|
pcbPath: pcbPath.optional(),
|
|
27
36
|
pcbPaths: z.array(pcbPath).optional(),
|