@tscircuit/core 0.0.17 → 0.0.18

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 { boardProps, footprintProps, smtPadProps, resistorProps, ledProps, traceProps, traceHintProps, groupProps, chipProps, jumperProps, silkscreenPathProps } from '@tscircuit/props';
9
+ import { boardProps, footprintProps, smtPadProps, resistorProps, ledProps, traceProps, traceHintProps, groupProps, chipProps, jumperProps, silkscreenPathProps, platedHoleProps } from '@tscircuit/props';
10
10
  import * as _tscircuit_layout from '@tscircuit/layout';
11
11
 
12
12
  declare class Project {
@@ -3217,6 +3217,87 @@ declare class SilkscreenPath extends PrimitiveComponent<typeof silkscreenPathPro
3217
3217
  doInitialPcbPrimitiveRender(): void;
3218
3218
  }
3219
3219
 
3220
+ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
3221
+ pcb_plated_hole_id: string | null;
3222
+ matchedPort: Port | null;
3223
+ isPcbPrimitive: boolean;
3224
+ get config(): {
3225
+ zodProps: zod.ZodUnion<[zod.ZodObject<zod.objectUtil.extendShape<Omit<{
3226
+ pcbX: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3227
+ pcbY: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3228
+ pcbRotation: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3229
+ layer: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>, zod.ZodObject<{
3230
+ name: zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>;
3231
+ }, "strip", zod.ZodTypeAny, {
3232
+ name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
3233
+ }, {
3234
+ name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
3235
+ }>]>, "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6", "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
3236
+ name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
3237
+ }>>;
3238
+ }, "pcbRotation" | "layer">, {
3239
+ shape: zod.ZodLiteral<"circle">;
3240
+ holeDiameter: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3241
+ outerDiameter: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3242
+ portHints: zod.ZodOptional<zod.ZodArray<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, "many">>;
3243
+ }>, "strip", zod.ZodTypeAny, {
3244
+ pcbX: number;
3245
+ pcbY: number;
3246
+ shape: "circle";
3247
+ holeDiameter: number;
3248
+ outerDiameter: number;
3249
+ portHints?: (string | number)[] | undefined;
3250
+ }, {
3251
+ pcbX: string | number;
3252
+ pcbY: string | number;
3253
+ shape: "circle";
3254
+ holeDiameter: string | number;
3255
+ outerDiameter: string | number;
3256
+ portHints?: (string | number)[] | undefined;
3257
+ }>, zod.ZodObject<zod.objectUtil.extendShape<Omit<{
3258
+ pcbX: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3259
+ pcbY: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3260
+ pcbRotation: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3261
+ layer: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>, zod.ZodObject<{
3262
+ name: zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>;
3263
+ }, "strip", zod.ZodTypeAny, {
3264
+ name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
3265
+ }, {
3266
+ name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
3267
+ }>]>, "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6", "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
3268
+ name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
3269
+ }>>;
3270
+ }, "pcbRotation" | "layer">, {
3271
+ shape: zod.ZodLiteral<"oval">;
3272
+ outerWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3273
+ outerHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3274
+ innerWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3275
+ innerHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3276
+ portHints: zod.ZodOptional<zod.ZodArray<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, "many">>;
3277
+ }>, "strip", zod.ZodTypeAny, {
3278
+ pcbX: number;
3279
+ pcbY: number;
3280
+ shape: "oval";
3281
+ outerWidth: number;
3282
+ outerHeight: number;
3283
+ innerWidth: number;
3284
+ innerHeight: number;
3285
+ portHints?: (string | number)[] | undefined;
3286
+ }, {
3287
+ pcbX: string | number;
3288
+ pcbY: string | number;
3289
+ shape: "oval";
3290
+ outerWidth: string | number;
3291
+ outerHeight: string | number;
3292
+ innerWidth: string | number;
3293
+ innerHeight: string | number;
3294
+ portHints?: (string | number)[] | undefined;
3295
+ }>]>;
3296
+ };
3297
+ doInitialPortMatching(): void;
3298
+ doInitialPcbPrimitiveRender(): void;
3299
+ }
3300
+
3220
3301
  declare global {
3221
3302
  namespace JSX {
3222
3303
  interface IntrinsicElements {
@@ -3259,4 +3340,4 @@ declare global {
3259
3340
  }
3260
3341
  }
3261
3342
 
3262
- export { Board, Capacitor, Chip, Footprint, Group, type IRenderable, Jumper, Led, Net, NormalComponent, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SmtPad, Trace, TraceHint };
3343
+ export { Board, Capacitor, Chip, Footprint, Group, type IRenderable, Jumper, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SmtPad, Trace, TraceHint };
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ __export(components_exports, {
16
16
  Led: () => Led,
17
17
  Net: () => Net,
18
18
  NormalComponent: () => NormalComponent,
19
+ PlatedHole: () => PlatedHole,
19
20
  Port: () => Port,
20
21
  PrimitiveComponent: () => PrimitiveComponent,
21
22
  Renderable: () => Renderable,
@@ -829,6 +830,55 @@ var SilkscreenPath = class extends PrimitiveComponent {
829
830
  }
830
831
  };
831
832
 
833
+ // lib/components/primitive-components/PlatedHole.ts
834
+ import { platedHoleProps } from "@tscircuit/props";
835
+ var PlatedHole = class extends PrimitiveComponent {
836
+ pcb_plated_hole_id = null;
837
+ matchedPort = null;
838
+ isPcbPrimitive = true;
839
+ get config() {
840
+ return {
841
+ zodProps: platedHoleProps
842
+ };
843
+ }
844
+ doInitialPortMatching() {
845
+ const parentPorts = (this.parent?.children ?? []).filter(
846
+ (c) => c.componentName === "Port"
847
+ );
848
+ if (!this.props.portHints) {
849
+ return;
850
+ }
851
+ for (const port of parentPorts) {
852
+ if (port.isMatchingAnyOf(this.props.portHints)) {
853
+ this.matchedPort = port;
854
+ port.registerMatch(this);
855
+ return;
856
+ }
857
+ }
858
+ }
859
+ doInitialPcbPrimitiveRender() {
860
+ const { db } = this.project;
861
+ const { _parsedProps: props } = this;
862
+ if (!props.portHints) return;
863
+ const position = this.getGlobalPcbPosition();
864
+ if (props.shape === "circle") {
865
+ const plated_hole_input = {
866
+ pcb_component_id: this.parent?.pcb_component_id,
867
+ pcb_port_id: this.matchedPort?.pcb_port_id,
868
+ layers: ["top", "bottom"],
869
+ outer_diameter: props.outerDiameter,
870
+ hole_diameter: props.holeDiameter,
871
+ shape: "circle",
872
+ port_hints: this.getNameAndAliases(),
873
+ x: position.x,
874
+ y: position.y,
875
+ type: "pcb_plated_hole"
876
+ };
877
+ const pcb_plated_hole = db.pcb_plated_hole.insert(plated_hole_input);
878
+ }
879
+ }
880
+ };
881
+
832
882
  // lib/utils/createComponentsFromSoup.ts
833
883
  var createComponentsFromSoup = (soup) => {
834
884
  const components = [];
@@ -864,6 +914,19 @@ var createComponentsFromSoup = (soup) => {
864
914
  strokeWidth: elm.stroke_width
865
915
  })
866
916
  );
917
+ } else if (elm.type === "pcb_plated_hole" && elm.shape === "circle") {
918
+ if (elm.shape === "circle") {
919
+ components.push(
920
+ new PlatedHole({
921
+ pcbX: elm.x,
922
+ pcbY: elm.y,
923
+ shape: "circle",
924
+ holeDiameter: elm.hole_diameter,
925
+ outerDiameter: elm.outer_diameter,
926
+ portHints: elm.port_hints
927
+ })
928
+ );
929
+ }
867
930
  }
868
931
  }
869
932
  return components;
@@ -2194,6 +2257,7 @@ export {
2194
2257
  Led,
2195
2258
  Net,
2196
2259
  NormalComponent,
2260
+ PlatedHole,
2197
2261
  Port,
2198
2262
  PrimitiveComponent,
2199
2263
  Project,
@@ -15,3 +15,4 @@ export { Group } from "./primitive-components/Group"
15
15
  export { Chip } from "./normal-components/Chip"
16
16
  export { Jumper } from "./normal-components/Jumper"
17
17
  export { SilkscreenPath } from "./primitive-components/SilkscreenPath"
18
+ export { PlatedHole } from "./primitive-components/PlatedHole"
@@ -0,0 +1,60 @@
1
+ import { PrimitiveComponent } from "../base-components/PrimitiveComponent"
2
+ import { platedHoleProps } from "@tscircuit/props"
3
+ import type { Port } from "./Port"
4
+ import type { PCBPlatedHoleInput } from "@tscircuit/soup"
5
+
6
+ export class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
7
+ pcb_plated_hole_id: string | null = null
8
+ matchedPort: Port | null = null
9
+ isPcbPrimitive = true
10
+
11
+ get config() {
12
+ return {
13
+ zodProps: platedHoleProps,
14
+ }
15
+ }
16
+
17
+ doInitialPortMatching(): void {
18
+ const parentPorts = (this.parent?.children ?? []).filter(
19
+ (c) => c.componentName === "Port",
20
+ ) as Port[]
21
+
22
+ if (!this.props.portHints) {
23
+ return
24
+ }
25
+
26
+ for (const port of parentPorts) {
27
+ if (port.isMatchingAnyOf(this.props.portHints)) {
28
+ this.matchedPort = port
29
+ port.registerMatch(this)
30
+ return
31
+ }
32
+ }
33
+ }
34
+
35
+ doInitialPcbPrimitiveRender(): void {
36
+ const { db } = this.project!
37
+ const { _parsedProps: props } = this
38
+ if (!props.portHints) return
39
+ const position = this.getGlobalPcbPosition()
40
+ if (props.shape === "circle") {
41
+ const plated_hole_input: PCBPlatedHoleInput = {
42
+ pcb_component_id: this.parent?.pcb_component_id!,
43
+ pcb_port_id: this.matchedPort?.pcb_port_id!,
44
+ layers: ["top", "bottom"],
45
+ outer_diameter: props.outerDiameter,
46
+ hole_diameter: props.holeDiameter,
47
+ shape: "circle",
48
+ port_hints: this.getNameAndAliases(),
49
+ x: position.x,
50
+ y: position.y,
51
+ type: "pcb_plated_hole",
52
+ }
53
+
54
+ // @ts-ignore - some issue with soup-util types it seems
55
+ const pcb_plated_hole = db.pcb_plated_hole.insert(plated_hole_input)
56
+
57
+ // this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id
58
+ }
59
+ }
60
+ }
@@ -2,6 +2,7 @@ import type { AnySoupElement } from "@tscircuit/soup"
2
2
  import type { PrimitiveComponent } from "../components/base-components/PrimitiveComponent"
3
3
  import { SmtPad } from "lib/components/primitive-components/SmtPad"
4
4
  import { SilkscreenPath } from "lib/components/primitive-components/SilkscreenPath"
5
+ import { PlatedHole } from "lib/components/primitive-components/PlatedHole"
5
6
 
6
7
  export const createComponentsFromSoup = (
7
8
  soup: AnySoupElement[],
@@ -39,6 +40,19 @@ export const createComponentsFromSoup = (
39
40
  strokeWidth: elm.stroke_width,
40
41
  }),
41
42
  )
43
+ } else if (elm.type === "pcb_plated_hole" && elm.shape === "circle") {
44
+ if (elm.shape === "circle") {
45
+ components.push(
46
+ new PlatedHole({
47
+ pcbX: elm.x,
48
+ pcbY: elm.y,
49
+ shape: "circle",
50
+ holeDiameter: elm.hole_diameter,
51
+ outerDiameter: elm.outer_diameter,
52
+ portHints: elm.port_hints,
53
+ }),
54
+ )
55
+ }
42
56
  }
43
57
  }
44
58
  return components
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.17",
5
+ "version": "0.0.18",
6
6
  "types": "dist/index.d.ts",
7
7
  "main": "dist/index.js",
8
8
  "files": [