@tscircuit/props 0.0.610 → 0.0.612

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.
@@ -1,4 +1,10 @@
1
1
  import { expectTypesMatch } from "lib/typecheck"
2
+ import {
3
+ distance,
4
+ layer_ref,
5
+ resistance,
6
+ type LayerRefInput,
7
+ } from "circuit-json"
2
8
  import { z } from "zod"
3
9
 
4
10
  export type BusName = string
@@ -13,12 +19,24 @@ export interface BusProps {
13
19
  connections: string[]
14
20
  /** If set, every trace in this bus is assigned to this autorouting phase. */
15
21
  routingPhaseIndex?: number | null
22
+ /** Maximum routed-length difference between bus members. Raw numbers are millimeters. */
23
+ maxLengthSkew?: number | string
24
+ /** Intended single-ended characteristic impedance. Raw numbers are ohms. */
25
+ targetImpedance?: number | string
26
+ /** Explicit PCB trace width for every bus member. Raw numbers are millimeters. */
27
+ pcbTraceWidth?: number | string
28
+ /** PCB layers on which the bus may be routed. */
29
+ pcbAllowedLayers?: LayerRefInput[]
16
30
  }
17
31
 
18
32
  export const busProps = z.object({
19
33
  name: z.string().optional(),
20
34
  connections: z.array(z.string()).min(2),
21
35
  routingPhaseIndex: z.number().nullable().optional(),
36
+ maxLengthSkew: distance.pipe(z.number().min(0).finite()).optional(),
37
+ targetImpedance: resistance.pipe(z.number().positive().finite()).optional(),
38
+ pcbTraceWidth: distance.pipe(z.number().positive().finite()).optional(),
39
+ pcbAllowedLayers: z.array(layer_ref).min(1).optional(),
22
40
  })
23
41
 
24
42
  type InferredBusProps = z.input<typeof busProps>
@@ -1,4 +1,5 @@
1
1
  import { expectTypesMatch } from "lib/typecheck"
2
+ import { distance, resistance } from "circuit-json"
2
3
  import { z } from "zod"
3
4
 
4
5
  /**
@@ -11,15 +12,26 @@ export interface DifferentialPairProps {
11
12
  positiveConnection: string
12
13
  /** Name of the trace or pin carrying the negative signal. */
13
14
  negativeConnection: string
14
- /** Maximum permitted routed-length skew in millimeters. */
15
- maxLengthSkew?: number
15
+ /** Maximum permitted routed-length skew. Raw numbers are millimeters. */
16
+ maxLengthSkew?: number | string
17
+ /** Intended differential characteristic impedance. Raw numbers are ohms. */
18
+ targetDifferentialImpedance?: number | string
19
+ /** Edge-to-edge PCB copper gap between the pair. Raw numbers are millimeters. */
20
+ pcbTraceGap?: number | string
21
+ /** Maximum length over which the pair may be routed without coupling. Raw numbers are millimeters. */
22
+ maxUncoupledLength?: number | string
16
23
  }
17
24
 
18
25
  export const differentialPairProps = z.object({
19
26
  name: z.string().optional(),
20
27
  positiveConnection: z.string(),
21
28
  negativeConnection: z.string(),
22
- maxLengthSkew: z.number().min(0).finite().optional(),
29
+ maxLengthSkew: distance.pipe(z.number().min(0).finite()).optional(),
30
+ targetDifferentialImpedance: resistance
31
+ .pipe(z.number().positive().finite())
32
+ .optional(),
33
+ pcbTraceGap: distance.pipe(z.number().positive().finite()).optional(),
34
+ maxUncoupledLength: distance.pipe(z.number().min(0).finite()).optional(),
23
35
  })
24
36
 
25
37
  type InferredDifferentialPairProps = z.input<typeof differentialPairProps>
@@ -3,15 +3,30 @@ import { schematicOrientation } from "lib/common/schematicOrientation"
3
3
  import { z } from "zod"
4
4
  import { createConnectionsProp } from "lib/common/connectionsProp"
5
5
  import { diodePinLabelsProp } from "lib/components/diode"
6
+ import { schematicPinLabel } from "lib/common/schematicPinLabel"
6
7
 
7
8
  export type LedPinLabels = (typeof lrPolarPins)[number]
8
9
 
10
+ const legacyNumericLedPinLabelsProp = z
11
+ .record(
12
+ z.enum(["1", "2"]),
13
+ schematicPinLabel
14
+ .or(z.array(schematicPinLabel).readonly())
15
+ .or(z.array(schematicPinLabel)),
16
+ )
17
+ .transform((pinLabels) => ({
18
+ ...(pinLabels["1"] === undefined ? {} : { pin1: pinLabels["1"] }),
19
+ ...(pinLabels["2"] === undefined ? {} : { pin2: pinLabels["2"] }),
20
+ }))
21
+
9
22
  export const ledProps = commonComponentProps.extend({
10
23
  color: z.string().optional(),
11
24
  wavelength: z.string().optional(),
12
25
  schDisplayValue: z.string().optional(),
13
26
  schOrientation: schematicOrientation.optional(),
14
- pinLabels: diodePinLabelsProp.optional(),
27
+ // Numeric keys are accepted for compatibility with legacy generated LED
28
+ // wrappers, then normalized to the canonical pin1/pin2 representation.
29
+ pinLabels: diodePinLabelsProp.or(legacyNumericLedPinLabelsProp).optional(),
15
30
  connections: createConnectionsProp(lrPolarPins).optional(),
16
31
  laser: z.boolean().optional(),
17
32
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.610",
3
+ "version": "0.0.612",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",