@tscircuit/core 0.0.38 → 0.0.40

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/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import { ReactElement } from 'react';
6
6
  import { Matrix } from 'transformation-matrix';
7
7
  import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
8
8
  import * as Props from '@tscircuit/props';
9
- import { traceProps, groupProps, boardProps, footprintProps, smtPadProps, resistorProps, ledProps, diodeProps, capacitorProps, traceHintProps, chipProps, jumperProps, silkscreenPathProps, platedHoleProps, constraintProps, holeProps } from '@tscircuit/props';
9
+ import { traceProps, groupProps, boardProps, footprintProps, smtPadProps, resistorProps, ledProps, diodeProps, capacitorProps, traceHintProps, chipProps, jumperProps, silkscreenPathProps, platedHoleProps, constraintProps, holeProps, silkscreenTextProps } from '@tscircuit/props';
10
10
 
11
11
  declare class Circuit {
12
12
  firstChild: PrimitiveComponent | null;
@@ -4005,6 +4005,10 @@ declare class Hole extends PrimitiveComponent<typeof holeProps> {
4005
4005
  }): void;
4006
4006
  }
4007
4007
 
4008
+ declare class SilkscreenText extends PrimitiveComponent<typeof silkscreenTextProps> {
4009
+ doInitialPcbPrimitiveRender(): void;
4010
+ }
4011
+
4008
4012
  declare global {
4009
4013
  namespace JSX {
4010
4014
  interface IntrinsicElements {
@@ -4050,4 +4054,4 @@ declare global {
4050
4054
  }
4051
4055
  }
4052
4056
 
4053
- export { Board, Capacitor, Chip, Circuit, Constraint, Diode, Footprint, Group, Hole, type IRenderable, Jumper, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SmtPad, Trace, TraceHint };
4057
+ export { Board, Capacitor, Chip, Circuit, Constraint, Diode, Footprint, Group, Hole, type IRenderable, Jumper, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SilkscreenText, SmtPad, Trace, TraceHint };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(components_exports, {
25
25
  Renderable: () => Renderable,
26
26
  Resistor: () => Resistor,
27
27
  SilkscreenPath: () => SilkscreenPath,
28
+ SilkscreenText: () => SilkscreenText,
28
29
  SmtPad: () => SmtPad,
29
30
  Trace: () => Trace,
30
31
  TraceHint: () => TraceHint
@@ -875,8 +876,10 @@ var Port = class extends PrimitiveComponent {
875
876
  }
876
877
  _setPositionFromLayout(newCenter) {
877
878
  const { db } = this.root;
878
- db.schematic_port.update(this.schematic_port_id, {
879
- center: newCenter
879
+ if (!this.pcb_port_id) return;
880
+ db.pcb_port.update(this.pcb_port_id, {
881
+ x: newCenter.x,
882
+ y: newCenter.y
880
883
  });
881
884
  }
882
885
  };
@@ -1172,6 +1175,7 @@ var SmtPad = class extends PrimitiveComponent {
1172
1175
  x: newCenter.x,
1173
1176
  y: newCenter.y
1174
1177
  });
1178
+ this.matchedPort?._setPositionFromLayout(newCenter);
1175
1179
  }
1176
1180
  };
1177
1181
 
@@ -1260,10 +1264,11 @@ var PlatedHole = class extends PrimitiveComponent {
1260
1264
  x: newCenter.x,
1261
1265
  y: newCenter.y
1262
1266
  });
1267
+ this.matchedPort?._setPositionFromLayout(newCenter);
1263
1268
  }
1264
1269
  doInitialPortMatching() {
1265
- const parentPorts = (this.parent?.children ?? []).filter(
1266
- (c) => c.componentName === "Port"
1270
+ const parentPorts = this.getPrimitiveContainer()?.selectAll(
1271
+ "port"
1267
1272
  );
1268
1273
  if (!this.props.portHints) {
1269
1274
  return;
@@ -3033,14 +3038,17 @@ var Constraint2 = class extends PrimitiveComponent {
3033
3038
  const componentsWithSelectors = [];
3034
3039
  const container = this.getPrimitiveContainer();
3035
3040
  function addComponentFromSelector(selector) {
3036
- const component = container.selectOne(selector);
3041
+ const maybeEdge = selector.split(" ").pop();
3042
+ const edge = edgeSpecifiers.includes(maybeEdge) ? maybeEdge : void 0;
3043
+ const componentSelector = edge ? selector.replace(` ${edge}`, "") : selector;
3044
+ const component = container.selectOne(componentSelector, {
3045
+ pcbPrimitive: true
3046
+ });
3037
3047
  if (component) {
3038
- const maybeEdge = selector.split(" ").pop();
3039
- const edge = edgeSpecifiers.includes(maybeEdge) ? maybeEdge : void 0;
3040
3048
  componentsWithSelectors.push({
3041
3049
  selector,
3042
3050
  component,
3043
- componentSelector: edge ? selector.replace(` ${edge}`, "") : selector,
3051
+ componentSelector,
3044
3052
  edge
3045
3053
  });
3046
3054
  }
@@ -3111,6 +3119,28 @@ var Hole = class extends PrimitiveComponent {
3111
3119
  }
3112
3120
  };
3113
3121
 
3122
+ // lib/components/primitive-components/SilkscreenText.ts
3123
+ import "@tscircuit/props";
3124
+ var SilkscreenText = class extends PrimitiveComponent {
3125
+ doInitialPcbPrimitiveRender() {
3126
+ const { db } = this.root;
3127
+ const { _parsedProps: props } = this;
3128
+ const container = this.getPrimitiveContainer();
3129
+ db.pcb_silkscreen_text.insert({
3130
+ anchor_alignment: props.anchorAlignment,
3131
+ anchor_position: {
3132
+ x: props.pcbX ?? 0,
3133
+ y: props.pcbY ?? 0
3134
+ },
3135
+ font: props.font ?? "tscircuit2024",
3136
+ font_size: props.fontSize ?? 1,
3137
+ layer: "top",
3138
+ text: props.text ?? "",
3139
+ pcb_component_id: container.pcb_component_id
3140
+ });
3141
+ }
3142
+ };
3143
+
3114
3144
  // lib/Project.ts
3115
3145
  import { su } from "@tscircuit/soup-util";
3116
3146
  import { isValidElement as isValidElement2 } from "react";
@@ -3230,6 +3260,7 @@ export {
3230
3260
  Renderable,
3231
3261
  Resistor,
3232
3262
  SilkscreenPath,
3263
+ SilkscreenText,
3233
3264
  SmtPad,
3234
3265
  Trace,
3235
3266
  TraceHint
@@ -19,3 +19,4 @@ export { SilkscreenPath } from "./primitive-components/SilkscreenPath"
19
19
  export { PlatedHole } from "./primitive-components/PlatedHole"
20
20
  export { Constraint } from "./primitive-components/Constraint"
21
21
  export { Hole } from "./primitive-components/Hole"
22
+ export { SilkscreenText } from "./primitive-components/SilkscreenText"
@@ -56,15 +56,19 @@ export class Constraint extends PrimitiveComponent<typeof constraintProps> {
56
56
  function addComponentFromSelector(selector: string) {
57
57
  // TODO this selector has to be modified in case it contains a leftedge,
58
58
  // center/topedge/rightedge indicator
59
- const component = container.selectOne(selector)
59
+ const maybeEdge = selector.split(" ").pop() as EdgeSpecifier
60
+ const edge = edgeSpecifiers.includes(maybeEdge) ? maybeEdge : undefined
61
+ const componentSelector = edge
62
+ ? selector.replace(` ${edge}`, "")
63
+ : selector
64
+ const component = container.selectOne(componentSelector, {
65
+ pcbPrimitive: true,
66
+ })
60
67
  if (component) {
61
- const maybeEdge = selector.split(" ").pop() as EdgeSpecifier
62
- const edge = edgeSpecifiers.includes(maybeEdge) ? maybeEdge : undefined
63
-
64
68
  componentsWithSelectors.push({
65
69
  selector,
66
70
  component,
67
- componentSelector: edge ? selector.replace(` ${edge}`, "") : selector,
71
+ componentSelector,
68
72
  edge,
69
73
  })
70
74
  }
@@ -56,11 +56,12 @@ export class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
56
56
  x: newCenter.x,
57
57
  y: newCenter.y,
58
58
  })
59
+ this.matchedPort?._setPositionFromLayout(newCenter)
59
60
  }
60
61
 
61
62
  doInitialPortMatching(): void {
62
- const parentPorts = (this.parent?.children ?? []).filter(
63
- (c) => c.componentName === "Port",
63
+ const parentPorts = this.getPrimitiveContainer()?.selectAll(
64
+ "port",
64
65
  ) as Port[]
65
66
 
66
67
  if (!this.props.portHints) {
@@ -208,9 +208,11 @@ export class Port extends PrimitiveComponent<typeof portProps> {
208
208
 
209
209
  _setPositionFromLayout(newCenter: { x: number; y: number }): void {
210
210
  const { db } = this.root!
211
+ if (!this.pcb_port_id) return
211
212
 
212
- db.schematic_port.update(this.schematic_port_id!, {
213
- center: newCenter,
213
+ db.pcb_port.update(this.pcb_port_id!, {
214
+ x: newCenter.x,
215
+ y: newCenter.y,
214
216
  })
215
217
  }
216
218
  }
@@ -0,0 +1,25 @@
1
+ import { PrimitiveComponent } from "../base-components/PrimitiveComponent"
2
+ import { silkscreenTextProps } from "@tscircuit/props"
3
+
4
+ export class SilkscreenText extends PrimitiveComponent<
5
+ typeof silkscreenTextProps
6
+ > {
7
+ doInitialPcbPrimitiveRender(): void {
8
+ const { db } = this.root!
9
+ const { _parsedProps: props } = this
10
+ const container = this.getPrimitiveContainer()!
11
+
12
+ db.pcb_silkscreen_text.insert({
13
+ anchor_alignment: props.anchorAlignment,
14
+ anchor_position: {
15
+ x: props.pcbX ?? 0,
16
+ y: props.pcbY ?? 0,
17
+ },
18
+ font: props.font ?? "tscircuit2024",
19
+ font_size: props.fontSize ?? 1,
20
+ layer: "top",
21
+ text: props.text ?? "",
22
+ pcb_component_id: container.pcb_component_id!,
23
+ })
24
+ }
25
+ }
@@ -143,5 +143,6 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
143
143
  x: newCenter.x,
144
144
  y: newCenter.y,
145
145
  })
146
+ this.matchedPort?._setPositionFromLayout(newCenter)
146
147
  }
147
148
  }
@@ -6,7 +6,7 @@ import { extendCatalogue } from "./fiber/catalogue"
6
6
  // it'll automatically be registered!
7
7
  extendCatalogue(Components)
8
8
 
9
- // Aliases
9
+ // Aliases (only when class name is different than the name of the component)
10
10
  extendCatalogue({
11
11
  Bug: Components.Chip,
12
12
  })
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tscircuit/core",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "0.0.38",
5
+ "version": "0.0.40",
6
6
  "types": "dist/index.d.ts",
7
7
  "main": "dist/index.js",
8
8
  "files": [