@tscircuit/core 0.0.17 → 0.0.19
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 +83 -2
- package/dist/index.js +91 -8
- package/lib/components/base-components/NormalComponent.ts +1 -1
- package/lib/components/base-components/PrimitiveComponent.ts +9 -2
- package/lib/components/index.ts +1 -0
- package/lib/components/primitive-components/PlatedHole.ts +60 -0
- package/lib/components/primitive-components/SilkscreenPath.ts +14 -1
- package/lib/components/primitive-components/SmtPad.ts +7 -3
- package/lib/utils/createComponentsFromSoup.ts +14 -0
- package/package.json +2 -2
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,
|
|
@@ -122,6 +123,7 @@ import {
|
|
|
122
123
|
applyToPoint,
|
|
123
124
|
compose,
|
|
124
125
|
identity,
|
|
126
|
+
rotate,
|
|
125
127
|
translate
|
|
126
128
|
} from "transformation-matrix";
|
|
127
129
|
|
|
@@ -215,7 +217,12 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
215
217
|
* components
|
|
216
218
|
*/
|
|
217
219
|
computePcbPropsTransform() {
|
|
218
|
-
|
|
220
|
+
const { _parsedProps: props } = this;
|
|
221
|
+
const matrix = compose(
|
|
222
|
+
translate(props.pcbX ?? 0, props.pcbY ?? 0),
|
|
223
|
+
rotate((props.pcbRotation ?? 0) * Math.PI / 180)
|
|
224
|
+
);
|
|
225
|
+
return matrix;
|
|
219
226
|
}
|
|
220
227
|
/**
|
|
221
228
|
* Compute a transformation matrix combining all parent transforms for PCB
|
|
@@ -739,6 +746,7 @@ function getPortFromHints(hints) {
|
|
|
739
746
|
|
|
740
747
|
// lib/components/primitive-components/SmtPad.ts
|
|
741
748
|
import { smtPadProps } from "@tscircuit/props";
|
|
749
|
+
import { decomposeTSR } from "transformation-matrix";
|
|
742
750
|
var SmtPad = class extends PrimitiveComponent {
|
|
743
751
|
pcb_smtpad_id = null;
|
|
744
752
|
matchedPort = null;
|
|
@@ -768,6 +776,8 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
768
776
|
const { _parsedProps: props } = this;
|
|
769
777
|
if (!props.portHints) return;
|
|
770
778
|
const position = this.getGlobalPcbPosition();
|
|
779
|
+
const decomposedMat = decomposeTSR(this.computePcbGlobalTransform());
|
|
780
|
+
const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01;
|
|
771
781
|
let pcb_smtpad = null;
|
|
772
782
|
if (props.shape === "circle") {
|
|
773
783
|
pcb_smtpad = db.pcb_smtpad.insert({
|
|
@@ -787,9 +797,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
787
797
|
pcb_port_id: this.matchedPort?.pcb_port_id,
|
|
788
798
|
layer: props.layer ?? "top",
|
|
789
799
|
shape: "rect",
|
|
790
|
-
|
|
791
|
-
width: props.width,
|
|
792
|
-
height: props.height,
|
|
800
|
+
...isRotated90 ? { width: props.height, height: props.width } : { width: props.width, height: props.height },
|
|
793
801
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
794
802
|
x: position.x,
|
|
795
803
|
y: position.y
|
|
@@ -803,6 +811,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
803
811
|
|
|
804
812
|
// lib/components/primitive-components/SilkscreenPath.ts
|
|
805
813
|
import { silkscreenPathProps } from "@tscircuit/props";
|
|
814
|
+
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
806
815
|
var SilkscreenPath = class extends PrimitiveComponent {
|
|
807
816
|
pcb_silkscreen_path_id = null;
|
|
808
817
|
get config() {
|
|
@@ -819,16 +828,76 @@ var SilkscreenPath = class extends PrimitiveComponent {
|
|
|
819
828
|
`Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`
|
|
820
829
|
);
|
|
821
830
|
}
|
|
831
|
+
const transform = this.computePcbGlobalTransform();
|
|
822
832
|
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({
|
|
823
833
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
824
834
|
layer,
|
|
825
|
-
route: props.route
|
|
835
|
+
route: props.route.map((p) => {
|
|
836
|
+
const transformedPosition = applyToPoint3(transform, {
|
|
837
|
+
x: p.x,
|
|
838
|
+
y: p.y
|
|
839
|
+
});
|
|
840
|
+
return {
|
|
841
|
+
...p,
|
|
842
|
+
x: transformedPosition.x,
|
|
843
|
+
y: transformedPosition.y
|
|
844
|
+
};
|
|
845
|
+
}),
|
|
826
846
|
stroke_width: props.strokeWidth ?? 0.1
|
|
827
847
|
});
|
|
828
848
|
this.pcb_silkscreen_path_id = pcb_silkscreen_path.pcb_silkscreen_path_id;
|
|
829
849
|
}
|
|
830
850
|
};
|
|
831
851
|
|
|
852
|
+
// lib/components/primitive-components/PlatedHole.ts
|
|
853
|
+
import { platedHoleProps } from "@tscircuit/props";
|
|
854
|
+
var PlatedHole = class extends PrimitiveComponent {
|
|
855
|
+
pcb_plated_hole_id = null;
|
|
856
|
+
matchedPort = null;
|
|
857
|
+
isPcbPrimitive = true;
|
|
858
|
+
get config() {
|
|
859
|
+
return {
|
|
860
|
+
zodProps: platedHoleProps
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
doInitialPortMatching() {
|
|
864
|
+
const parentPorts = (this.parent?.children ?? []).filter(
|
|
865
|
+
(c) => c.componentName === "Port"
|
|
866
|
+
);
|
|
867
|
+
if (!this.props.portHints) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
for (const port of parentPorts) {
|
|
871
|
+
if (port.isMatchingAnyOf(this.props.portHints)) {
|
|
872
|
+
this.matchedPort = port;
|
|
873
|
+
port.registerMatch(this);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
doInitialPcbPrimitiveRender() {
|
|
879
|
+
const { db } = this.project;
|
|
880
|
+
const { _parsedProps: props } = this;
|
|
881
|
+
if (!props.portHints) return;
|
|
882
|
+
const position = this.getGlobalPcbPosition();
|
|
883
|
+
if (props.shape === "circle") {
|
|
884
|
+
const plated_hole_input = {
|
|
885
|
+
pcb_component_id: this.parent?.pcb_component_id,
|
|
886
|
+
pcb_port_id: this.matchedPort?.pcb_port_id,
|
|
887
|
+
layers: ["top", "bottom"],
|
|
888
|
+
outer_diameter: props.outerDiameter,
|
|
889
|
+
hole_diameter: props.holeDiameter,
|
|
890
|
+
shape: "circle",
|
|
891
|
+
port_hints: this.getNameAndAliases(),
|
|
892
|
+
x: position.x,
|
|
893
|
+
y: position.y,
|
|
894
|
+
type: "pcb_plated_hole"
|
|
895
|
+
};
|
|
896
|
+
const pcb_plated_hole = db.pcb_plated_hole.insert(plated_hole_input);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
|
|
832
901
|
// lib/utils/createComponentsFromSoup.ts
|
|
833
902
|
var createComponentsFromSoup = (soup) => {
|
|
834
903
|
const components = [];
|
|
@@ -864,6 +933,19 @@ var createComponentsFromSoup = (soup) => {
|
|
|
864
933
|
strokeWidth: elm.stroke_width
|
|
865
934
|
})
|
|
866
935
|
);
|
|
936
|
+
} else if (elm.type === "pcb_plated_hole" && elm.shape === "circle") {
|
|
937
|
+
if (elm.shape === "circle") {
|
|
938
|
+
components.push(
|
|
939
|
+
new PlatedHole({
|
|
940
|
+
pcbX: elm.x,
|
|
941
|
+
pcbY: elm.y,
|
|
942
|
+
shape: "circle",
|
|
943
|
+
holeDiameter: elm.hole_diameter,
|
|
944
|
+
outerDiameter: elm.outer_diameter,
|
|
945
|
+
portHints: elm.port_hints
|
|
946
|
+
})
|
|
947
|
+
);
|
|
948
|
+
}
|
|
867
949
|
}
|
|
868
950
|
}
|
|
869
951
|
return components;
|
|
@@ -1002,7 +1084,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
1002
1084
|
width: 0,
|
|
1003
1085
|
height: 0,
|
|
1004
1086
|
layer: props.layer ?? "top",
|
|
1005
|
-
rotation: props.
|
|
1087
|
+
rotation: props.pcbRotation ?? 0,
|
|
1006
1088
|
source_component_id: this.source_component_id
|
|
1007
1089
|
});
|
|
1008
1090
|
this.pcb_component_id = pcb_component.pcb_component_id;
|
|
@@ -1612,7 +1694,7 @@ searched component ${targetComponent.getString()}, which has ports:${targetCompo
|
|
|
1612
1694
|
|
|
1613
1695
|
// lib/components/primitive-components/TraceHint.ts
|
|
1614
1696
|
import "@tscircuit/props";
|
|
1615
|
-
import { applyToPoint as
|
|
1697
|
+
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
1616
1698
|
var TraceHint = class extends PrimitiveComponent {
|
|
1617
1699
|
matchedPort = null;
|
|
1618
1700
|
doInitialPortMatching() {
|
|
@@ -1646,7 +1728,7 @@ var TraceHint = class extends PrimitiveComponent {
|
|
|
1646
1728
|
const globalTransform = this.computePcbGlobalTransform();
|
|
1647
1729
|
return offsets.map(
|
|
1648
1730
|
(offset) => ({
|
|
1649
|
-
...
|
|
1731
|
+
...applyToPoint4(globalTransform, offset),
|
|
1650
1732
|
via: offset.via,
|
|
1651
1733
|
to_layer: offset.to_layer,
|
|
1652
1734
|
trace_width: offset.trace_width
|
|
@@ -2194,6 +2276,7 @@ export {
|
|
|
2194
2276
|
Led,
|
|
2195
2277
|
Net,
|
|
2196
2278
|
NormalComponent,
|
|
2279
|
+
PlatedHole,
|
|
2197
2280
|
Port,
|
|
2198
2281
|
PrimitiveComponent,
|
|
2199
2282
|
Project,
|
|
@@ -197,7 +197,7 @@ export class NormalComponent<
|
|
|
197
197
|
width: 0,
|
|
198
198
|
height: 0,
|
|
199
199
|
layer: props.layer ?? "top",
|
|
200
|
-
rotation: props.
|
|
200
|
+
rotation: props.pcbRotation ?? 0,
|
|
201
201
|
source_component_id: this.source_component_id!,
|
|
202
202
|
})
|
|
203
203
|
this.pcb_component_id = pcb_component.pcb_component_id
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
applyToPoint,
|
|
11
11
|
compose,
|
|
12
12
|
identity,
|
|
13
|
+
rotate,
|
|
13
14
|
translate,
|
|
14
15
|
type Matrix,
|
|
15
16
|
} from "transformation-matrix"
|
|
@@ -97,8 +98,14 @@ export abstract class PrimitiveComponent<
|
|
|
97
98
|
* components
|
|
98
99
|
*/
|
|
99
100
|
computePcbPropsTransform(): Matrix {
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
const { _parsedProps: props } = this
|
|
102
|
+
|
|
103
|
+
const matrix = compose(
|
|
104
|
+
translate(props.pcbX ?? 0, props.pcbY ?? 0),
|
|
105
|
+
rotate(((props.pcbRotation ?? 0) * Math.PI) / 180),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
return matrix
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
/**
|
package/lib/components/index.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { silkscreenPathProps } from "@tscircuit/props"
|
|
2
2
|
import { PrimitiveComponent } from "../base-components/PrimitiveComponent"
|
|
3
|
+
import { applyToPoint } from "transformation-matrix"
|
|
3
4
|
|
|
4
5
|
export class SilkscreenPath extends PrimitiveComponent<
|
|
5
6
|
typeof silkscreenPathProps
|
|
@@ -23,10 +24,22 @@ export class SilkscreenPath extends PrimitiveComponent<
|
|
|
23
24
|
)
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
const transform = this.computePcbGlobalTransform()
|
|
28
|
+
|
|
26
29
|
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({
|
|
27
30
|
pcb_component_id: this.parent?.pcb_component_id!,
|
|
28
31
|
layer,
|
|
29
|
-
route: props.route
|
|
32
|
+
route: props.route.map((p) => {
|
|
33
|
+
const transformedPosition = applyToPoint(transform, {
|
|
34
|
+
x: p.x,
|
|
35
|
+
y: p.y,
|
|
36
|
+
})
|
|
37
|
+
return {
|
|
38
|
+
...p,
|
|
39
|
+
x: transformedPosition.x,
|
|
40
|
+
y: transformedPosition.y,
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
30
43
|
stroke_width: props.strokeWidth ?? 0.1,
|
|
31
44
|
})
|
|
32
45
|
|
|
@@ -3,6 +3,7 @@ import { smtPadProps } from "@tscircuit/props"
|
|
|
3
3
|
import type { Port } from "./Port"
|
|
4
4
|
import type { RenderPhaseFn } from "../base-components/Renderable"
|
|
5
5
|
import type { PCBSMTPad } from "@tscircuit/soup"
|
|
6
|
+
import { decomposeTSR } from "transformation-matrix"
|
|
6
7
|
|
|
7
8
|
export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
|
|
8
9
|
pcb_smtpad_id: string | null = null
|
|
@@ -40,6 +41,9 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
|
|
|
40
41
|
const { _parsedProps: props } = this
|
|
41
42
|
if (!props.portHints) return
|
|
42
43
|
const position = this.getGlobalPcbPosition()
|
|
44
|
+
const decomposedMat = decomposeTSR(this.computePcbGlobalTransform())
|
|
45
|
+
const isRotated90 =
|
|
46
|
+
Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01
|
|
43
47
|
let pcb_smtpad: PCBSMTPad | null = null
|
|
44
48
|
if (props.shape === "circle") {
|
|
45
49
|
pcb_smtpad = db.pcb_smtpad.insert({
|
|
@@ -63,9 +67,9 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
|
|
|
63
67
|
layer: props.layer ?? "top",
|
|
64
68
|
shape: "rect",
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
...(isRotated90
|
|
71
|
+
? { width: props.height, height: props.width }
|
|
72
|
+
: { width: props.width, height: props.height }),
|
|
69
73
|
|
|
70
74
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
71
75
|
|
|
@@ -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.
|
|
5
|
+
"version": "0.0.19",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "^5.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tscircuit/infgrid-ijump-astar": "0.0.
|
|
34
|
+
"@tscircuit/infgrid-ijump-astar": "^0.0.6",
|
|
35
35
|
"@tscircuit/props": "^0.0.49",
|
|
36
36
|
"@tscircuit/soup": "^0.0.58",
|
|
37
37
|
"@tscircuit/soup-util": "0.0.18",
|