Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manually give componentName to each component #122

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/components/normal-components/Board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Group } from "../primitive-components/Group"
export class Board extends Group<typeof boardProps> {
pcb_board_id: string | null = null

componentName = "Board"

get isSubcircuit() {
return true
}
Expand Down
2 changes: 2 additions & 0 deletions lib/components/normal-components/Capacitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export class Capacitor extends NormalComponent<
}
}

componentName = "Capacitor"

pin1 = this.portMap.pin1
pin2 = this.portMap.pin2

Expand Down
2 changes: 2 additions & 0 deletions lib/components/normal-components/Chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<
}
}

componentName = "Chip"

doInitialSourceRender(): void {
const { db } = this.root!
const { _parsedProps: props } = this
Expand Down
2 changes: 2 additions & 0 deletions lib/components/normal-components/Diode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export class Diode extends NormalComponent<typeof diodeProps, TwoPinPorts> {
}
}

componentName = "Diode"

initPorts() {
this.add(new Port({ name: "pin1", aliases: ["1", "pin1"] }))
this.add(new Port({ name: "pin2", aliases: ["2", "pin2"] }))
Expand Down
2 changes: 2 additions & 0 deletions lib/components/normal-components/Jumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class Jumper<PinLabels extends string = never> extends NormalComponent<
}
}

componentName = "Jumper"

doInitialSourceRender(): void {
const { db } = this.root!
const { _parsedProps: props } = this
Expand Down
2 changes: 2 additions & 0 deletions lib/components/normal-components/Led.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class Led extends NormalComponent<
}
}

componentName = "Led"

pos = this.portMap.pin1
pin1 = this.portMap.pin1
anode = this.portMap.pin1
Expand Down
2 changes: 2 additions & 0 deletions lib/components/normal-components/Resistor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class Resistor extends NormalComponent<
typeof resistorProps,
PassivePorts
> {
componentName = "Resistor"

get config() {
return {
schematicSymbolName: "boxresistor" as BaseSymbolName,
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/FabricationNotePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { applyToPoint } from "transformation-matrix"
export class FabricationNotePath extends PrimitiveComponent<
typeof fabricationNotePathProps
> {
componentName = "FabricationNotePath"
fabrication_note_path_id: string | null = null

get config() {
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/FabricationNoteText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fabricationNoteTextProps } from "@tscircuit/props"
export class FabricationNoteText extends PrimitiveComponent<
typeof fabricationNoteTextProps
> {
componentName = "FabricationNoteText"
doInitialPcbPrimitiveRender(): void {
const { db } = this.root!
const { _parsedProps: props } = this
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/Footprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Debug from "debug"
const debug = Debug("tscircuit:core:footprint")

export class Footprint extends PrimitiveComponent<typeof footprintProps> {
componentName = "Footprint"
/**
* A footprint is a constrainedlayout, the db elements are adjusted according
* to any constraints that are defined.
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Group<
zodProps: groupProps as unknown as Props,
}
}
componentName = "Group"

doInitialCreateTraceHintsFromProps(): void {
const { _parsedProps: props } = this
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/Hole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { PCBHole } from "circuit-json"
export class Hole extends PrimitiveComponent<typeof holeProps> {
pcb_hole_id: string | null = null
isPcbPrimitive = true
componentName = "Hole"

get config() {
return {
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/Keepout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class Keepout extends PrimitiveComponent<typeof pcbKeepoutProps> {
pcb_keepout_id: string | null = null

isPcbPrimitive = true
componentName = "Keepout"

get config() {
return {
Expand Down
2 changes: 2 additions & 0 deletions lib/components/primitive-components/Net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const netProps = z.object({
export class Net extends PrimitiveComponent<typeof netProps> {
source_net_id?: string

componentName = "Net"

getPortSelector() {
return `net.${this.props.name}`
}
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/PlatedHole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
pcb_plated_hole_id: string | null = null
matchedPort: Port | null = null
isPcbPrimitive = true
componentName = "PlatedHole"

get config() {
return {
Expand Down
2 changes: 2 additions & 0 deletions lib/components/primitive-components/Port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class Port extends PrimitiveComponent<typeof portProps> {
matchedComponents: PrimitiveComponent[]
facingDirection: "up" | "down" | "left" | "right" | null = null

componentName = "Port"

constructor(props: z.input<typeof portProps>) {
if (!props.name && props.pinNumber) props.name = `pin${props.pinNumber}`
if (!props.name) {
Expand Down
2 changes: 2 additions & 0 deletions lib/components/primitive-components/SilkscreenPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export class SilkscreenPath extends PrimitiveComponent<
> {
pcb_silkscreen_path_id: string | null = null

componentName = "SilkscreenPath"

get config() {
return {
zodProps: silkscreenPathProps,
Expand Down
1 change: 1 addition & 0 deletions lib/components/primitive-components/SilkscreenText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class SilkscreenText extends PrimitiveComponent<
typeof silkscreenTextProps
> {
isPcbPrimitive = true
componentName = "SilkscreenText"
doInitialPcbPrimitiveRender(): void {
const { db } = this.root!
const { _parsedProps: props } = this
Expand Down
3 changes: 2 additions & 1 deletion lib/components/primitive-components/SmtPad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import {
translate,
} from "transformation-matrix"


export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
pcb_smtpad_id: string | null = null

matchedPort: Port | null = null

isPcbPrimitive = true

componentName = "SmtPad"

get config() {
return {
zodProps: smtPadProps,
Expand Down
2 changes: 2 additions & 0 deletions lib/components/primitive-components/Trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export class Trace extends PrimitiveComponent<typeof traceProps> {
schematic_trace_id: string | null = null
_portsRoutedOnPcb: Port[]

componentName = "Trace"

constructor(props: z.input<typeof traceProps>) {
super(props)
this._portsRoutedOnPcb = []
Expand Down
2 changes: 2 additions & 0 deletions lib/components/primitive-components/TraceHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { applyToPoint } from "transformation-matrix"
export class TraceHint extends PrimitiveComponent<typeof traceHintProps> {
matchedPort: Port | null = null

componentName = "TraceHint"

doInitialPortMatching(): void {
const { db } = this.root!
const { _parsedProps: props, parent } = this
Expand Down
Loading