@tscircuit/props 0.0.640 → 0.0.641

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,41 @@
1
+ import { layer_ref, type LayerRefInput } from "circuit-json"
2
+ import { expectTypesMatch } from "lib/typecheck"
3
+ import { z } from "zod"
4
+ import { point, type Point } from "./point"
5
+
6
+ export interface PcbPathPoint extends Point {
7
+ via?: boolean
8
+ fromLayer?: LayerRefInput
9
+ toLayer?: LayerRefInput
10
+ }
11
+
12
+ const basePcbPathPoint = point.extend({
13
+ via: z.boolean().optional(),
14
+ fromLayer: layer_ref.optional(),
15
+ toLayer: layer_ref.optional(),
16
+ })
17
+
18
+ export const pcbPathPoint = basePcbPathPoint.superRefine((value, ctx) => {
19
+ if (value.via) {
20
+ if (!value.toLayer) {
21
+ ctx.addIssue({
22
+ code: z.ZodIssueCode.custom,
23
+ message: "toLayer is required when via is true",
24
+ path: ["toLayer"],
25
+ })
26
+ }
27
+ } else if (value.fromLayer || value.toLayer) {
28
+ ctx.addIssue({
29
+ code: z.ZodIssueCode.custom,
30
+ message: "fromLayer/toLayer are only allowed when via is true",
31
+ path: ["via"],
32
+ })
33
+ }
34
+ })
35
+
36
+ export const pcbPath = z.array(z.union([pcbPathPoint, z.string()]))
37
+
38
+ export type PcbPath = Array<PcbPathPoint | string>
39
+
40
+ expectTypesMatch<PcbPathPoint, z.input<typeof pcbPathPoint>>(true)
41
+ expectTypesMatch<PcbPath, z.input<typeof pcbPath>>(true)
@@ -0,0 +1,23 @@
1
+ import {
2
+ type CommonComponentProps,
3
+ commonComponentProps,
4
+ } from "lib/common/layout"
5
+ import { type PcbPath, pcbPath } from "lib/common/pcbPath"
6
+ import { expectTypesMatch } from "lib/typecheck"
7
+ import { z } from "zod"
8
+
9
+ /** Props for an antenna component with an optional explicit PCB path. */
10
+ export interface AntennaProps extends CommonComponentProps {
11
+ /**
12
+ * Explicit antenna path. Entries use the same selector, point, and via
13
+ * syntax as trace pcbPath entries.
14
+ */
15
+ pcbPath?: PcbPath
16
+ }
17
+
18
+ export const antennaProps = commonComponentProps.extend({
19
+ pcbPath: pcbPath.optional(),
20
+ })
21
+
22
+ type InferredAntennaProps = z.input<typeof antennaProps>
23
+ expectTypesMatch<AntennaProps, InferredAntennaProps>(true)
@@ -1,6 +1,7 @@
1
- import { distance, layer_ref, route_hint_point } from "circuit-json"
1
+ import { distance, route_hint_point } from "circuit-json"
2
2
  import { z } from "zod"
3
3
  import { point } from "../common/point"
4
+ import { pcbPath } from "../common/pcbPath"
4
5
 
5
6
  export const portRef = z.union([
6
7
  z.string(),
@@ -13,32 +14,6 @@ export const portRef = z.union([
13
14
  ),
14
15
  ])
15
16
 
16
- const pcbPathPoint = point
17
- .extend({
18
- via: z.boolean().optional(),
19
- fromLayer: layer_ref.optional(),
20
- toLayer: layer_ref.optional(),
21
- })
22
- .superRefine((value, ctx) => {
23
- if (value.via) {
24
- if (!value.toLayer) {
25
- ctx.addIssue({
26
- code: z.ZodIssueCode.custom,
27
- message: "toLayer is required when via is true",
28
- path: ["toLayer"],
29
- })
30
- }
31
- } else if (value.fromLayer || value.toLayer) {
32
- ctx.addIssue({
33
- code: z.ZodIssueCode.custom,
34
- message: "fromLayer/toLayer are only allowed when via is true",
35
- path: ["via"],
36
- })
37
- }
38
- })
39
-
40
- const pcbPath = z.array(z.union([pcbPathPoint, z.string()]))
41
-
42
17
  const baseTraceProps = z.object({
43
18
  key: z.string().optional(),
44
19
  name: z.string().optional(),
package/lib/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./common/portHints"
6
6
  export * from "./common/layout"
7
7
  export * from "./common/pinAttributeMap"
8
8
  export * from "./common/point3"
9
+ export * from "./common/pcbPath"
9
10
  export * from "./common/portHints"
10
11
  export * from "./common/footprintProp"
11
12
  export * from "./common/symbolProp"
@@ -57,6 +58,7 @@ export * from "./components/drc-check"
57
58
  export * from "./components/smtpad"
58
59
  export * from "./components/solderpaste"
59
60
  export * from "./components/hole"
61
+ export * from "./components/antenna"
60
62
  export * from "./components/trace"
61
63
  export * from "./components/bus"
62
64
  export * from "./components/differentialpair"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.640",
3
+ "version": "0.0.641",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",