@tscircuit/props 0.0.605 → 0.0.607

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.
@@ -33,7 +33,7 @@ const connectionTarget = z
33
33
 
34
34
  const connectionsProp = z.record(diodeConnectionKeys, connectionTarget)
35
35
 
36
- const diodePinLabelsProp = z.record(
36
+ export const diodePinLabelsProp = z.record(
37
37
  z.enum(diodePins),
38
38
  schematicPinLabel
39
39
  .or(z.array(schematicPinLabel).readonly())
@@ -1,19 +1,38 @@
1
- import { type LayerRef, layer_ref } from "circuit-json"
1
+ import {
2
+ type InsertionDirectionInput,
3
+ type LayerRef,
4
+ layer_ref,
5
+ } from "circuit-json"
2
6
  import { expectTypesMatch } from "lib/typecheck"
3
7
  import { z } from "zod"
4
8
  import { type FootprintProp, footprintProp } from "../common/footprintProp"
5
9
 
6
- export type FootprintInsertionDirection =
7
- | "from_above"
8
- | "from_left"
9
- | "from_right"
10
- | "from_front"
11
- | "from_back"
10
+ /**
11
+ * Direction a cable or mating part is attached from, named for the side of the
12
+ * footprint it approaches from.
13
+ *
14
+ * Aliased to Circuit JSON's input union so the two cannot drift apart. Both the
15
+ * named spellings and their Cartesian equivalents are accepted here, as are the
16
+ * deprecated `from_front` (now `from_top`) and `from_back` (now `from_bottom`).
17
+ * Core normalizes them to the six named values before writing
18
+ * `pcb_component.insertion_direction`.
19
+ */
20
+ export type FootprintInsertionDirection = InsertionDirectionInput
12
21
 
13
22
  export const footprintInsertionDirection = z.enum([
14
- "from_above",
15
23
  "from_left",
16
24
  "from_right",
25
+ "from_top",
26
+ "from_bottom",
27
+ "from_above",
28
+ "from_below",
29
+ "from_x_neg",
30
+ "from_x_pos",
31
+ "from_y_pos",
32
+ "from_y_neg",
33
+ "from_z_pos",
34
+ "from_z_neg",
35
+ // Deprecated, accepted so existing sources keep type-checking.
17
36
  "from_front",
18
37
  "from_back",
19
38
  ])
@@ -45,8 +64,21 @@ export interface FootprintProps {
45
64
  */
46
65
  src?: FootprintProp
47
66
  /**
48
- * Direction a cable or mating part is inserted into this footprint in its
49
- * unrotated orientation.
67
+ * Direction a cable or mating part is attached from, in the footprint's own
68
+ * frame -- the same frame its pads are drawn in. Directions are named for the
69
+ * footprint as drawn in the 2D PCB view: `from_top` is +Y, `from_bottom` -Y,
70
+ * `from_left` -X, `from_right` +X, `from_above` +Z and `from_below` -Z.
71
+ * Cartesian spellings such as `from_y_pos` are also accepted.
72
+ *
73
+ * This names a side, not a motion. A receptacle on the +Y edge is `from_top`
74
+ * because that is the side the plug comes from, even though the plug itself
75
+ * moves in -Y as it seats.
76
+ *
77
+ * This is a property of the part, so it is authored without regard to where
78
+ * the part is placed. Rotating or flipping the component rotates this with it,
79
+ * and `pcb_component.insertion_direction` reports the result in board
80
+ * coordinates. The two frames coincide for an unrotated top-layer part, which
81
+ * makes the distinction easy to miss.
50
82
  */
51
83
  insertionDirection?: FootprintInsertionDirection
52
84
  }
@@ -60,7 +92,7 @@ export const footprintProps = z.object({
60
92
  insertionDirection: footprintInsertionDirection
61
93
  .optional()
62
94
  .describe(
63
- "Direction a cable or mating part is inserted into this footprint in its unrotated orientation.",
95
+ "Direction a cable or mating part is attached from, named for the side of the footprint it approaches from, in its unrotated orientation.",
64
96
  ),
65
97
  })
66
98
 
@@ -2,6 +2,7 @@ import { commonComponentProps, lrPolarPins } from "lib/common/layout"
2
2
  import { schematicOrientation } from "lib/common/schematicOrientation"
3
3
  import { z } from "zod"
4
4
  import { createConnectionsProp } from "lib/common/connectionsProp"
5
+ import { diodePinLabelsProp } from "lib/components/diode"
5
6
 
6
7
  export type LedPinLabels = (typeof lrPolarPins)[number]
7
8
 
@@ -10,6 +11,7 @@ export const ledProps = commonComponentProps.extend({
10
11
  wavelength: z.string().optional(),
11
12
  schDisplayValue: z.string().optional(),
12
13
  schOrientation: schematicOrientation.optional(),
14
+ pinLabels: diodePinLabelsProp.optional(),
13
15
  connections: createConnectionsProp(lrPolarPins).optional(),
14
16
  laser: z.boolean().optional(),
15
17
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.605",
3
+ "version": "0.0.607",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "@types/node": "^20.12.11",
33
33
  "@types/react": "^18.3.2",
34
34
  "ava": "^6.1.3",
35
- "circuit-json": "^0.0.455",
35
+ "circuit-json": "^0.0.461",
36
36
  "expect-type": "^1.3.0",
37
37
  "glob": "^11.0.0",
38
38
  "madge": "^8.0.0",