@tscircuit/props 0.0.437 → 0.0.439
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 +32 -0
- package/dist/index.d.ts +6110 -3826
- package/dist/index.js +319 -269
- package/dist/index.js.map +1 -1
- package/lib/components/currentsource.ts +58 -0
- package/lib/components/group.ts +4 -0
- package/lib/components/opamp.ts +42 -0
- package/lib/index.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { frequency, rotation, current } from "circuit-json"
|
|
2
|
+
import {
|
|
3
|
+
type CommonComponentProps,
|
|
4
|
+
commonComponentProps,
|
|
5
|
+
lrPolarPins,
|
|
6
|
+
} from "lib/common/layout"
|
|
7
|
+
import { createConnectionsProp } from "lib/common/connectionsProp"
|
|
8
|
+
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
9
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
10
|
+
import { z } from "zod"
|
|
11
|
+
import { type WaveShape } from "./voltagesource"
|
|
12
|
+
|
|
13
|
+
export const currentSourcePinLabels = ["pin1", "pin2", "pos", "neg"] as const
|
|
14
|
+
export type CurrentSourcePinLabels = (typeof currentSourcePinLabels)[number]
|
|
15
|
+
|
|
16
|
+
export interface CurrentSourceProps<PinLabel extends string = string>
|
|
17
|
+
extends CommonComponentProps<PinLabel> {
|
|
18
|
+
current?: number | string
|
|
19
|
+
frequency?: number | string
|
|
20
|
+
peakToPeakCurrent?: number | string
|
|
21
|
+
waveShape?: WaveShape
|
|
22
|
+
phase?: number | string
|
|
23
|
+
dutyCycle?: number | string
|
|
24
|
+
connections?: Connections<CurrentSourcePinLabels>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const percentage = z
|
|
28
|
+
.union([z.string(), z.number()])
|
|
29
|
+
.transform((val) => {
|
|
30
|
+
if (typeof val === "string") {
|
|
31
|
+
if (val.endsWith("%")) {
|
|
32
|
+
return parseFloat(val.slice(0, -1)) / 100
|
|
33
|
+
}
|
|
34
|
+
return parseFloat(val)
|
|
35
|
+
}
|
|
36
|
+
return val
|
|
37
|
+
})
|
|
38
|
+
.pipe(
|
|
39
|
+
z
|
|
40
|
+
.number()
|
|
41
|
+
.min(0, "Duty cycle must be non-negative")
|
|
42
|
+
.max(1, "Duty cycle cannot be greater than 100%"),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
export const currentSourceProps = commonComponentProps.extend({
|
|
46
|
+
current: current.optional(),
|
|
47
|
+
frequency: frequency.optional(),
|
|
48
|
+
peakToPeakCurrent: current.optional(),
|
|
49
|
+
waveShape: z.enum(["sinewave", "square", "triangle", "sawtooth"]).optional(),
|
|
50
|
+
phase: rotation.optional(),
|
|
51
|
+
dutyCycle: percentage.optional(),
|
|
52
|
+
connections: createConnectionsProp(currentSourcePinLabels).optional(),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
export const currentSourcePins = lrPolarPins
|
|
56
|
+
|
|
57
|
+
type InferredCurrentSourceProps = z.input<typeof currentSourceProps>
|
|
58
|
+
expectTypesMatch<CurrentSourceProps, InferredCurrentSourceProps>(true)
|
package/lib/components/group.ts
CHANGED
|
@@ -313,6 +313,7 @@ export interface AutorouterConfig {
|
|
|
313
313
|
| "auto"
|
|
314
314
|
| "auto_local"
|
|
315
315
|
| "auto_cloud"
|
|
316
|
+
| "tscircuit_beta"
|
|
316
317
|
| "freerouting"
|
|
317
318
|
| "laser_prefab" // Prefabricated PCB with laser copper ablation
|
|
318
319
|
| /** @deprecated Use "sequential_trace" */ "sequential-trace"
|
|
@@ -326,6 +327,7 @@ export type AutorouterPreset =
|
|
|
326
327
|
| "auto"
|
|
327
328
|
| "auto_local"
|
|
328
329
|
| "auto_cloud"
|
|
330
|
+
| "tscircuit_beta"
|
|
329
331
|
| "freerouting"
|
|
330
332
|
| "laser_prefab"
|
|
331
333
|
| "sequential-trace"
|
|
@@ -362,6 +364,7 @@ export const autorouterConfig = z.object({
|
|
|
362
364
|
"auto",
|
|
363
365
|
"auto_local",
|
|
364
366
|
"auto_cloud",
|
|
367
|
+
"tscircuit_beta",
|
|
365
368
|
"freerouting",
|
|
366
369
|
"laser_prefab",
|
|
367
370
|
"sequential-trace",
|
|
@@ -378,6 +381,7 @@ export const autorouterPreset = z.union([
|
|
|
378
381
|
z.literal("auto"),
|
|
379
382
|
z.literal("auto_local"),
|
|
380
383
|
z.literal("auto_cloud"),
|
|
384
|
+
z.literal("tscircuit_beta"),
|
|
381
385
|
z.literal("freerouting"),
|
|
382
386
|
z.literal("laser_prefab"), // Prefabricated PCB with laser copper ablation
|
|
383
387
|
z.literal("sequential-trace"),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CommonComponentProps,
|
|
3
|
+
commonComponentProps,
|
|
4
|
+
} from "lib/common/layout"
|
|
5
|
+
import { createConnectionsProp } from "lib/common/connectionsProp"
|
|
6
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
7
|
+
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
8
|
+
import { z } from "zod"
|
|
9
|
+
|
|
10
|
+
export const opampPinLabels = [
|
|
11
|
+
"inverting_input",
|
|
12
|
+
"non_inverting_input",
|
|
13
|
+
"output",
|
|
14
|
+
"positive_supply",
|
|
15
|
+
"negative_supply",
|
|
16
|
+
] as const
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Pin labels for an op-amp component. This includes common aliases.
|
|
20
|
+
*/
|
|
21
|
+
export type OpAmpPinLabels = (typeof opampPinLabels)[number]
|
|
22
|
+
|
|
23
|
+
export interface OpAmpProps<PinLabel extends string = string>
|
|
24
|
+
extends CommonComponentProps<PinLabel> {
|
|
25
|
+
connections?: Connections<OpAmpPinLabels>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Zod schema for validating op-amp props.
|
|
30
|
+
*/
|
|
31
|
+
export const opampProps = commonComponentProps.extend({
|
|
32
|
+
connections: createConnectionsProp(opampPinLabels).optional(),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The standard five pins for an op-amp.
|
|
37
|
+
* Used for building schematic symbols.
|
|
38
|
+
*/
|
|
39
|
+
export const opampPins = opampPinLabels
|
|
40
|
+
|
|
41
|
+
type InferredOpAmpProps = z.input<typeof opampProps>
|
|
42
|
+
expectTypesMatch<OpAmpProps, InferredOpAmpProps>(true)
|
package/lib/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ export * from "./components/analogsimulation"
|
|
|
58
58
|
export * from "./manual-edits"
|
|
59
59
|
export * from "./components/transistor"
|
|
60
60
|
export * from "./components/mosfet"
|
|
61
|
+
export * from "./components/opamp"
|
|
61
62
|
export * from "./components/inductor"
|
|
62
63
|
export * from "./components/diode"
|
|
63
64
|
export * from "./components/led"
|
|
@@ -78,6 +79,7 @@ export * from "./components/cadassembly"
|
|
|
78
79
|
export * from "./components/cadmodel"
|
|
79
80
|
export * from "./components/power-source"
|
|
80
81
|
export * from "./components/voltagesource"
|
|
82
|
+
export * from "./components/currentsource"
|
|
81
83
|
export * from "./components/voltageprobe"
|
|
82
84
|
export * from "./components/schematic-arc"
|
|
83
85
|
export * from "./components/toolingrail"
|