@tscircuit/props 0.0.436 → 0.0.438
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 +92 -7
- package/dist/index.d.ts +1179 -7
- package/dist/index.js +207 -172
- package/dist/index.js.map +1 -1
- package/lib/components/currentsource.ts +58 -0
- package/lib/components/group.ts +8 -0
- package/lib/index.ts +1 -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"),
|
|
@@ -395,6 +399,8 @@ export const autorouterProp: z.ZodType<AutorouterProp> = z.union([
|
|
|
395
399
|
autorouterString,
|
|
396
400
|
])
|
|
397
401
|
|
|
402
|
+
export const autorouterEffortLevel = z.enum(["1x", "2x", "5x", "10x", "100x"])
|
|
403
|
+
|
|
398
404
|
export interface SubcircuitGroupProps extends BaseGroupProps {
|
|
399
405
|
manualEdits?: ManualEditsFileInput
|
|
400
406
|
routingDisabled?: boolean
|
|
@@ -404,6 +410,7 @@ export interface SubcircuitGroupProps extends BaseGroupProps {
|
|
|
404
410
|
pcbRouteCache?: PcbRouteCache
|
|
405
411
|
|
|
406
412
|
autorouter?: AutorouterProp
|
|
413
|
+
autorouterEffortLevel?: "1x" | "2x" | "5x" | "10x" | "100x"
|
|
407
414
|
|
|
408
415
|
/**
|
|
409
416
|
* Serialized circuit JSON describing a precompiled subcircuit
|
|
@@ -561,6 +568,7 @@ export const subcircuitGroupProps = baseGroupProps.extend({
|
|
|
561
568
|
partsEngine: partsEngine.optional(),
|
|
562
569
|
pcbRouteCache: z.custom<PcbRouteCache>((v) => true).optional(),
|
|
563
570
|
autorouter: autorouterProp.optional(),
|
|
571
|
+
autorouterEffortLevel: autorouterEffortLevel.optional(),
|
|
564
572
|
square: z.boolean().optional(),
|
|
565
573
|
emptyArea: z.string().optional(),
|
|
566
574
|
filledArea: z.string().optional(),
|
package/lib/index.ts
CHANGED
|
@@ -78,6 +78,7 @@ export * from "./components/cadassembly"
|
|
|
78
78
|
export * from "./components/cadmodel"
|
|
79
79
|
export * from "./components/power-source"
|
|
80
80
|
export * from "./components/voltagesource"
|
|
81
|
+
export * from "./components/currentsource"
|
|
81
82
|
export * from "./components/voltageprobe"
|
|
82
83
|
export * from "./components/schematic-arc"
|
|
83
84
|
export * from "./components/toolingrail"
|