@tscircuit/props 0.0.708 → 0.0.710

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.
@@ -0,0 +1,45 @@
1
+ import { z } from "zod"
2
+ import { expectTypesMatch } from "lib/typecheck"
3
+
4
+ /** Authoring intent for a dimension of model geometry or a part view's extent.
5
+ * Core resolves geometry, measurement text and paper placement in a follow-up.
6
+ */
7
+ export interface AssemblyDrawingDimensionProps {
8
+ /** Stable circuit identity; does not choose a measurement or its formatting. */
9
+ name?: string
10
+ /** Selector for one model-defined named edge or outline, e.g. .tube > .inner_top; never a preset or mesh edge index. */
11
+ edgeRef?: string
12
+ /** Request the selected geometry's width in the view. Conflicts with edgeRef and heightOfView=true. */
13
+ widthOfView?: boolean
14
+ /** Request the selected geometry's height in the view. Conflicts with edgeRef and widthOfView=true. */
15
+ heightOfView?: boolean
16
+ }
17
+
18
+ export const assemblyDrawingDimensionProps = z
19
+ .object({
20
+ name: z.string().optional(),
21
+ edgeRef: z.string().trim().min(1).optional(),
22
+ widthOfView: z.boolean().optional(),
23
+ heightOfView: z.boolean().optional(),
24
+ })
25
+ .superRefine((dimension, ctx) => {
26
+ const targets = [
27
+ dimension.edgeRef !== undefined,
28
+ dimension.widthOfView === true,
29
+ dimension.heightOfView === true,
30
+ ].filter(Boolean).length
31
+ if (targets !== 1)
32
+ ctx.addIssue({
33
+ code: "custom",
34
+ message:
35
+ "Specify exactly one of edgeRef, widthOfView=true, or heightOfView=true",
36
+ })
37
+ })
38
+
39
+ export type InferredAssemblyDrawingDimensionProps = z.input<
40
+ typeof assemblyDrawingDimensionProps
41
+ >
42
+ expectTypesMatch<
43
+ AssemblyDrawingDimensionProps,
44
+ z.input<typeof assemblyDrawingDimensionProps>
45
+ >(true)
@@ -1,15 +1,18 @@
1
1
  import { assemblyDrawingTitleBlockProps } from "./titleblock"
2
2
  import { assemblyDrawingPageProps } from "./page"
3
3
  import { assemblyDrawingPartViewProps } from "./partview"
4
+ import { assemblyDrawingDimensionProps } from "./dimension"
4
5
 
5
6
  export * from "./page"
6
7
  export * from "./page-size"
7
8
  export * from "./titleblock"
8
9
  export * from "./partview"
10
+ export * from "./dimension"
9
11
 
10
12
  /** Drawing namespace; pages contain configured part views. */
11
13
  export const assemblyDrawingProps = {
12
14
  page: assemblyDrawingPageProps,
13
15
  titleblock: assemblyDrawingTitleBlockProps,
14
16
  partview: assemblyDrawingPartViewProps,
17
+ dimension: assemblyDrawingDimensionProps,
15
18
  } as const
@@ -56,6 +56,8 @@ export interface AssemblyDrawingPartViewProps {
56
56
  showHiddenEdges?: boolean
57
57
  /** A planar cut with diagonal hatching on closed cut surfaces. */
58
58
  section?: AssemblyDrawingSectionPlane
59
+ /** Nested assembly.drawing.dimension annotations; these do not change the selected geometry. */
60
+ children?: any
59
61
  }
60
62
 
61
63
  export const assemblyDrawingPartViewProps = z
@@ -74,6 +76,7 @@ export const assemblyDrawingPartViewProps = z
74
76
  height: distance.pipe(z.number().finite().positive()),
75
77
  showHiddenEdges: z.boolean().default(false),
76
78
  section: assemblyDrawingSectionPlane.optional(),
79
+ children: z.any().optional(),
77
80
  })
78
81
  .superRefine((view, ctx) => {
79
82
  for (const [center, negative, positive] of [
@@ -1,4 +1,4 @@
1
- import { ms } from "circuit-json"
1
+ import { frequency, length, ms } from "circuit-json"
2
2
  import { expectTypesMatch } from "lib/typecheck"
3
3
  import { z } from "zod"
4
4
  import { ibisPinRunState, type IbisPinRunState } from "lib/common/ibis"
@@ -17,8 +17,119 @@ export interface AnalogTransientSimulationProps
17
17
  timePerStep?: number | string
18
18
  /** Physical pin selectors and per-experiment direction/enable states. Requires spiceEngine="pcb_spice"; rendering only declares the experiment. */
19
19
  ibisPinStates?: Record<string, IbisPinRunState>
20
+ pcbSpiceChannel?: PcbSpiceChannelProps
20
21
  }
21
22
 
23
+ export interface PcbSpiceChannelProps {
24
+ reduction: "routed-copper" | "straightened-stages"
25
+ sections: number
26
+ lanes: Array<{ name: string; from: string; to: string }>
27
+ referencePinRef: string
28
+ passiveComponentRefs?: string[]
29
+ extraction: {
30
+ minimumFrequency: number | string
31
+ maximumFrequency: number | string
32
+ modelFrequency: number | string
33
+ filaments: number
34
+ refinementFilaments: number
35
+ convergenceTolerance: number
36
+ capacitanceTolerance: number
37
+ reciprocityTolerance: number
38
+ dcResistanceTolerance: number
39
+ maxPanelLength: number | string
40
+ groundMeshSize?: number | string
41
+ }
42
+ relativePermittivity?: number
43
+ via?: {
44
+ platingThickness?: number | string
45
+ equivalentWidth?: number | string
46
+ omitThroughViaStubs?: boolean
47
+ }
48
+ straightenedStageProfiles?: Record<
49
+ string,
50
+ {
51
+ spacing: number | string
52
+ relativePermittivity: number
53
+ return: {
54
+ width: number | string
55
+ thickness: number | string
56
+ lengthFactor: number
57
+ centerY: number | string
58
+ centerZ: number | string
59
+ }
60
+ }
61
+ >
62
+ }
63
+
64
+ const positiveLength = length.pipe(z.number().finite().positive())
65
+ const signedLength = length.pipe(z.number().finite())
66
+ const positiveFrequency = frequency.pipe(z.number().finite().positive())
67
+
68
+ export const pcbSpiceChannelProps = z.object({
69
+ reduction: z.enum(["routed-copper", "straightened-stages"]),
70
+ sections: z.number().int().min(1).max(128),
71
+ lanes: z
72
+ .array(
73
+ z.object({
74
+ name: z.string().min(1),
75
+ from: z.string().min(1),
76
+ to: z.string().min(1),
77
+ }),
78
+ )
79
+ .min(1)
80
+ .max(3),
81
+ referencePinRef: z.string().min(1),
82
+ passiveComponentRefs: z.array(z.string().min(1)).optional(),
83
+ extraction: z
84
+ .object({
85
+ minimumFrequency: positiveFrequency,
86
+ maximumFrequency: positiveFrequency,
87
+ modelFrequency: positiveFrequency,
88
+ filaments: z.number().int().positive(),
89
+ refinementFilaments: z.number().int().positive(),
90
+ convergenceTolerance: z.number().finite().positive(),
91
+ capacitanceTolerance: z.number().finite().positive(),
92
+ reciprocityTolerance: z.number().finite().positive(),
93
+ dcResistanceTolerance: z.number().finite().positive(),
94
+ maxPanelLength: positiveLength,
95
+ groundMeshSize: positiveLength.optional(),
96
+ })
97
+ .refine(
98
+ (extraction) => extraction.refinementFilaments > extraction.filaments,
99
+ {
100
+ path: ["refinementFilaments"],
101
+ message: "refinementFilaments must be greater than filaments",
102
+ },
103
+ ),
104
+ relativePermittivity: z.number().finite().positive().optional(),
105
+ via: z
106
+ .object({
107
+ platingThickness: positiveLength.optional(),
108
+ equivalentWidth: positiveLength.optional(),
109
+ omitThroughViaStubs: z.boolean().optional(),
110
+ })
111
+ .optional(),
112
+ straightenedStageProfiles: z
113
+ .record(
114
+ z.object({
115
+ spacing: positiveLength,
116
+ relativePermittivity: z.number().finite().positive(),
117
+ return: z.object({
118
+ width: positiveLength,
119
+ thickness: positiveLength,
120
+ lengthFactor: z.number().finite().positive(),
121
+ centerY: signedLength,
122
+ centerZ: signedLength,
123
+ }),
124
+ }),
125
+ )
126
+ .optional(),
127
+ })
128
+
129
+ expectTypesMatch<PcbSpiceChannelProps, z.input<typeof pcbSpiceChannelProps>>(
130
+ true,
131
+ )
132
+
22
133
  const positiveMilliseconds = ms.refine(
23
134
  (milliseconds) => milliseconds > 0,
24
135
  "Time must be positive",
@@ -30,9 +141,17 @@ export const analogTransientSimulationProps = z
30
141
  duration: positiveMilliseconds.default("10ms"),
31
142
  startTime: ms.default("0ms"),
32
143
  timePerStep: positiveMilliseconds.default("0.01ms"),
144
+ pcbSpiceChannel: pcbSpiceChannelProps.optional(),
33
145
  ibisPinStates: z.record(z.string().min(1), ibisPinRunState).optional(),
34
146
  })
35
147
  .superRefine((simulation, context) => {
148
+ if (simulation.pcbSpiceChannel && simulation.spiceEngine !== "pcb_spice") {
149
+ context.addIssue({
150
+ code: z.ZodIssueCode.custom,
151
+ path: ["pcbSpiceChannel"],
152
+ message: "PCB SPICE channel settings require spiceEngine=pcb_spice",
153
+ })
154
+ }
36
155
  if (simulation.ibisPinStates && simulation.spiceEngine !== "pcb_spice") {
37
156
  context.addIssue({
38
157
  code: z.ZodIssueCode.custom,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.708",
3
+ "version": "0.0.710",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",