@tscircuit/core 0.0.239 → 0.0.240
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 +229 -7
- package/dist/index.js +21 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _tscircuit_props from '@tscircuit/props';
|
|
2
|
-
import { subcircuitGroupProps, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, CapacitorProps, ChipProps, ResistorProps, ManualEditEvent,
|
|
2
|
+
import { subcircuitGroupProps, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, CapacitorProps, ChipProps, ResistorProps, ManualEditEvent, manual_edits_file } from '@tscircuit/props';
|
|
3
3
|
import React, { ReactElement } from 'react';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { z, ZodType } from 'zod';
|
|
@@ -255,10 +255,11 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
255
255
|
* Subcircuit groups have a prop called "layout" that can include manual
|
|
256
256
|
* placements for pcb components. These are typically added from an IDE
|
|
257
257
|
*/
|
|
258
|
-
|
|
258
|
+
_getPcbManualPlacementForComponent(component: PrimitiveComponent): {
|
|
259
259
|
x: number;
|
|
260
260
|
y: number;
|
|
261
261
|
} | null;
|
|
262
|
+
_getSchematicGlobalManualPlacementTransform(component: PrimitiveComponent): Matrix | null;
|
|
262
263
|
_getGlobalPcbPositionBeforeLayout(): {
|
|
263
264
|
x: number;
|
|
264
265
|
y: number;
|
|
@@ -930,7 +931,172 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
930
931
|
children: z.ZodOptional<z.ZodAny>;
|
|
931
932
|
}>, {
|
|
932
933
|
layout: z.ZodOptional<z.ZodType<_tscircuit_layout.LayoutBuilder, z.ZodTypeDef, _tscircuit_layout.LayoutBuilder>>;
|
|
933
|
-
manualEdits: z.ZodOptional<z.
|
|
934
|
+
manualEdits: z.ZodOptional<z.ZodObject<{
|
|
935
|
+
pcb_placements: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
936
|
+
selector: z.ZodString;
|
|
937
|
+
relative_to: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
938
|
+
center: z.ZodObject<{
|
|
939
|
+
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
940
|
+
y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
941
|
+
}, "strip", z.ZodTypeAny, {
|
|
942
|
+
x: number;
|
|
943
|
+
y: number;
|
|
944
|
+
}, {
|
|
945
|
+
x: string | number;
|
|
946
|
+
y: string | number;
|
|
947
|
+
}>;
|
|
948
|
+
}, "strip", z.ZodTypeAny, {
|
|
949
|
+
center: {
|
|
950
|
+
x: number;
|
|
951
|
+
y: number;
|
|
952
|
+
};
|
|
953
|
+
selector: string;
|
|
954
|
+
relative_to: string;
|
|
955
|
+
}, {
|
|
956
|
+
center: {
|
|
957
|
+
x: string | number;
|
|
958
|
+
y: string | number;
|
|
959
|
+
};
|
|
960
|
+
selector: string;
|
|
961
|
+
relative_to?: string | undefined;
|
|
962
|
+
}>, "many">>;
|
|
963
|
+
manual_trace_hints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
964
|
+
pcb_port_selector: z.ZodString;
|
|
965
|
+
offsets: z.ZodArray<z.ZodObject<{
|
|
966
|
+
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
967
|
+
y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
968
|
+
via: z.ZodOptional<z.ZodBoolean>;
|
|
969
|
+
to_layer: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>, z.ZodObject<{
|
|
970
|
+
name: z.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>;
|
|
971
|
+
}, "strip", z.ZodTypeAny, {
|
|
972
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
973
|
+
}, {
|
|
974
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
975
|
+
}>]>, "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6", "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
976
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
977
|
+
}>>;
|
|
978
|
+
trace_width: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
979
|
+
}, "strip", z.ZodTypeAny, {
|
|
980
|
+
x: number;
|
|
981
|
+
y: number;
|
|
982
|
+
trace_width?: number | undefined;
|
|
983
|
+
via?: boolean | undefined;
|
|
984
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
985
|
+
}, {
|
|
986
|
+
x: string | number;
|
|
987
|
+
y: string | number;
|
|
988
|
+
trace_width?: string | number | undefined;
|
|
989
|
+
via?: boolean | undefined;
|
|
990
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
991
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
992
|
+
} | undefined;
|
|
993
|
+
}>, "many">;
|
|
994
|
+
}, "strip", z.ZodTypeAny, {
|
|
995
|
+
offsets: {
|
|
996
|
+
x: number;
|
|
997
|
+
y: number;
|
|
998
|
+
trace_width?: number | undefined;
|
|
999
|
+
via?: boolean | undefined;
|
|
1000
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
1001
|
+
}[];
|
|
1002
|
+
pcb_port_selector: string;
|
|
1003
|
+
}, {
|
|
1004
|
+
offsets: {
|
|
1005
|
+
x: string | number;
|
|
1006
|
+
y: string | number;
|
|
1007
|
+
trace_width?: string | number | undefined;
|
|
1008
|
+
via?: boolean | undefined;
|
|
1009
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
1010
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
1011
|
+
} | undefined;
|
|
1012
|
+
}[];
|
|
1013
|
+
pcb_port_selector: string;
|
|
1014
|
+
}>, "many">>;
|
|
1015
|
+
schematic_placements: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1016
|
+
selector: z.ZodString;
|
|
1017
|
+
relative_to: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1018
|
+
center: z.ZodObject<{
|
|
1019
|
+
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
1020
|
+
y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
1021
|
+
}, "strip", z.ZodTypeAny, {
|
|
1022
|
+
x: number;
|
|
1023
|
+
y: number;
|
|
1024
|
+
}, {
|
|
1025
|
+
x: string | number;
|
|
1026
|
+
y: string | number;
|
|
1027
|
+
}>;
|
|
1028
|
+
}, "strip", z.ZodTypeAny, {
|
|
1029
|
+
center: {
|
|
1030
|
+
x: number;
|
|
1031
|
+
y: number;
|
|
1032
|
+
};
|
|
1033
|
+
selector: string;
|
|
1034
|
+
relative_to: string;
|
|
1035
|
+
}, {
|
|
1036
|
+
center: {
|
|
1037
|
+
x: string | number;
|
|
1038
|
+
y: string | number;
|
|
1039
|
+
};
|
|
1040
|
+
selector: string;
|
|
1041
|
+
relative_to?: string | undefined;
|
|
1042
|
+
}>, "many">>;
|
|
1043
|
+
}, "strip", z.ZodTypeAny, {
|
|
1044
|
+
pcb_placements?: {
|
|
1045
|
+
center: {
|
|
1046
|
+
x: number;
|
|
1047
|
+
y: number;
|
|
1048
|
+
};
|
|
1049
|
+
selector: string;
|
|
1050
|
+
relative_to: string;
|
|
1051
|
+
}[] | undefined;
|
|
1052
|
+
manual_trace_hints?: {
|
|
1053
|
+
offsets: {
|
|
1054
|
+
x: number;
|
|
1055
|
+
y: number;
|
|
1056
|
+
trace_width?: number | undefined;
|
|
1057
|
+
via?: boolean | undefined;
|
|
1058
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
1059
|
+
}[];
|
|
1060
|
+
pcb_port_selector: string;
|
|
1061
|
+
}[] | undefined;
|
|
1062
|
+
schematic_placements?: {
|
|
1063
|
+
center: {
|
|
1064
|
+
x: number;
|
|
1065
|
+
y: number;
|
|
1066
|
+
};
|
|
1067
|
+
selector: string;
|
|
1068
|
+
relative_to: string;
|
|
1069
|
+
}[] | undefined;
|
|
1070
|
+
}, {
|
|
1071
|
+
pcb_placements?: {
|
|
1072
|
+
center: {
|
|
1073
|
+
x: string | number;
|
|
1074
|
+
y: string | number;
|
|
1075
|
+
};
|
|
1076
|
+
selector: string;
|
|
1077
|
+
relative_to?: string | undefined;
|
|
1078
|
+
}[] | undefined;
|
|
1079
|
+
manual_trace_hints?: {
|
|
1080
|
+
offsets: {
|
|
1081
|
+
x: string | number;
|
|
1082
|
+
y: string | number;
|
|
1083
|
+
trace_width?: string | number | undefined;
|
|
1084
|
+
via?: boolean | undefined;
|
|
1085
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
1086
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
1087
|
+
} | undefined;
|
|
1088
|
+
}[];
|
|
1089
|
+
pcb_port_selector: string;
|
|
1090
|
+
}[] | undefined;
|
|
1091
|
+
schematic_placements?: {
|
|
1092
|
+
center: {
|
|
1093
|
+
x: string | number;
|
|
1094
|
+
y: string | number;
|
|
1095
|
+
};
|
|
1096
|
+
selector: string;
|
|
1097
|
+
relative_to?: string | undefined;
|
|
1098
|
+
}[] | undefined;
|
|
1099
|
+
}>>;
|
|
934
1100
|
schAutoLayoutEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
935
1101
|
routingDisabled: z.ZodOptional<z.ZodBoolean>;
|
|
936
1102
|
defaultTraceWidth: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
@@ -980,7 +1146,34 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
980
1146
|
width?: number | undefined;
|
|
981
1147
|
height?: number | undefined;
|
|
982
1148
|
layout?: _tscircuit_layout.LayoutBuilder | undefined;
|
|
983
|
-
manualEdits?:
|
|
1149
|
+
manualEdits?: {
|
|
1150
|
+
pcb_placements?: {
|
|
1151
|
+
center: {
|
|
1152
|
+
x: number;
|
|
1153
|
+
y: number;
|
|
1154
|
+
};
|
|
1155
|
+
selector: string;
|
|
1156
|
+
relative_to: string;
|
|
1157
|
+
}[] | undefined;
|
|
1158
|
+
manual_trace_hints?: {
|
|
1159
|
+
offsets: {
|
|
1160
|
+
x: number;
|
|
1161
|
+
y: number;
|
|
1162
|
+
trace_width?: number | undefined;
|
|
1163
|
+
via?: boolean | undefined;
|
|
1164
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
1165
|
+
}[];
|
|
1166
|
+
pcb_port_selector: string;
|
|
1167
|
+
}[] | undefined;
|
|
1168
|
+
schematic_placements?: {
|
|
1169
|
+
center: {
|
|
1170
|
+
x: number;
|
|
1171
|
+
y: number;
|
|
1172
|
+
};
|
|
1173
|
+
selector: string;
|
|
1174
|
+
relative_to: string;
|
|
1175
|
+
}[] | undefined;
|
|
1176
|
+
} | undefined;
|
|
984
1177
|
routingDisabled?: boolean | undefined;
|
|
985
1178
|
defaultTraceWidth?: number | undefined;
|
|
986
1179
|
minTraceWidth?: number | undefined;
|
|
@@ -1013,7 +1206,36 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
1013
1206
|
width?: string | number | undefined;
|
|
1014
1207
|
height?: string | number | undefined;
|
|
1015
1208
|
layout?: _tscircuit_layout.LayoutBuilder | undefined;
|
|
1016
|
-
manualEdits?:
|
|
1209
|
+
manualEdits?: {
|
|
1210
|
+
pcb_placements?: {
|
|
1211
|
+
center: {
|
|
1212
|
+
x: string | number;
|
|
1213
|
+
y: string | number;
|
|
1214
|
+
};
|
|
1215
|
+
selector: string;
|
|
1216
|
+
relative_to?: string | undefined;
|
|
1217
|
+
}[] | undefined;
|
|
1218
|
+
manual_trace_hints?: {
|
|
1219
|
+
offsets: {
|
|
1220
|
+
x: string | number;
|
|
1221
|
+
y: string | number;
|
|
1222
|
+
trace_width?: string | number | undefined;
|
|
1223
|
+
via?: boolean | undefined;
|
|
1224
|
+
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
1225
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
1226
|
+
} | undefined;
|
|
1227
|
+
}[];
|
|
1228
|
+
pcb_port_selector: string;
|
|
1229
|
+
}[] | undefined;
|
|
1230
|
+
schematic_placements?: {
|
|
1231
|
+
center: {
|
|
1232
|
+
x: string | number;
|
|
1233
|
+
y: string | number;
|
|
1234
|
+
};
|
|
1235
|
+
selector: string;
|
|
1236
|
+
relative_to?: string | undefined;
|
|
1237
|
+
}[] | undefined;
|
|
1238
|
+
} | undefined;
|
|
1017
1239
|
routingDisabled?: boolean | undefined;
|
|
1018
1240
|
defaultTraceWidth?: string | number | undefined;
|
|
1019
1241
|
minTraceWidth?: string | number | undefined;
|
|
@@ -8380,8 +8602,8 @@ declare const useResistor: <PropsFromHook extends Omit<ResistorProps, "name"> |
|
|
|
8380
8602
|
declare const applyEditEventsToManualEditsFile: ({ circuitJson, editEvents, manualEditsFile, }: {
|
|
8381
8603
|
circuitJson: CircuitJson;
|
|
8382
8604
|
editEvents: ManualEditEvent[];
|
|
8383
|
-
manualEditsFile: z.infer<typeof
|
|
8384
|
-
}) => z.infer<typeof
|
|
8605
|
+
manualEditsFile: z.infer<typeof manual_edits_file>;
|
|
8606
|
+
}) => z.infer<typeof manual_edits_file>;
|
|
8385
8607
|
|
|
8386
8608
|
interface TscircuitElements {
|
|
8387
8609
|
resistor: _tscircuit_props.ResistorProps;
|
package/dist/index.js
CHANGED
|
@@ -632,7 +632,7 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
632
632
|
*/
|
|
633
633
|
_computePcbGlobalTransformBeforeLayout() {
|
|
634
634
|
const { _parsedProps: props } = this;
|
|
635
|
-
const manualPlacement = this.getSubcircuit().
|
|
635
|
+
const manualPlacement = this.getSubcircuit()._getPcbManualPlacementForComponent(this);
|
|
636
636
|
if (manualPlacement && this.props.pcbX === void 0 && this.props.pcbY === void 0) {
|
|
637
637
|
return compose(
|
|
638
638
|
this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity2(),
|
|
@@ -723,6 +723,8 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
723
723
|
* component
|
|
724
724
|
*/
|
|
725
725
|
computeSchematicGlobalTransform() {
|
|
726
|
+
const manualPlacementTransform = this._getSchematicGlobalManualPlacementTransform(this);
|
|
727
|
+
if (manualPlacementTransform) return manualPlacementTransform;
|
|
726
728
|
return compose(
|
|
727
729
|
this.parent?.computeSchematicGlobalTransform?.() ?? identity2(),
|
|
728
730
|
this.computeSchematicPropsTransform()
|
|
@@ -779,7 +781,7 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
779
781
|
* Subcircuit groups have a prop called "layout" that can include manual
|
|
780
782
|
* placements for pcb components. These are typically added from an IDE
|
|
781
783
|
*/
|
|
782
|
-
|
|
784
|
+
_getPcbManualPlacementForComponent(component) {
|
|
783
785
|
if (!this.isSubcircuit) return null;
|
|
784
786
|
const layout = this.props.layout;
|
|
785
787
|
const manualEdits = this.props.manualEdits;
|
|
@@ -792,7 +794,22 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
792
794
|
this._computePcbGlobalTransformBeforeLayout(),
|
|
793
795
|
position.center
|
|
794
796
|
);
|
|
795
|
-
return
|
|
797
|
+
return center;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
_getSchematicGlobalManualPlacementTransform(component) {
|
|
803
|
+
const manualEdits = this.getSubcircuit()?._parsedProps.manualEdits;
|
|
804
|
+
if (!manualEdits) return null;
|
|
805
|
+
for (const position of manualEdits.schematic_placements ?? []) {
|
|
806
|
+
if (isMatchingSelector(component, position.selector) || component.props.name === position.selector) {
|
|
807
|
+
if (position.relative_to === "group_center") {
|
|
808
|
+
return compose(
|
|
809
|
+
this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity2(),
|
|
810
|
+
translate(position.center.x, position.center.y)
|
|
811
|
+
);
|
|
812
|
+
}
|
|
796
813
|
}
|
|
797
814
|
}
|
|
798
815
|
return null;
|
|
@@ -2959,7 +2976,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2959
2976
|
this.pcb_missing_footprint_error_id = footprint_error.pcb_missing_footprint_error_id;
|
|
2960
2977
|
}
|
|
2961
2978
|
this.pcb_component_id = pcb_component.pcb_component_id;
|
|
2962
|
-
const manualPlacement = this.getSubcircuit().
|
|
2979
|
+
const manualPlacement = this.getSubcircuit()._getPcbManualPlacementForComponent(this);
|
|
2963
2980
|
if (this.props.pcbX !== void 0 && this.props.pcbY !== void 0 && manualPlacement) {
|
|
2964
2981
|
this.renderError({
|
|
2965
2982
|
type: "pcb_manual_edit_conflict_error",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.240",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@tscircuit/footprinter": "^0.0.95",
|
|
44
44
|
"@tscircuit/infgrid-ijump-astar": "^0.0.26",
|
|
45
45
|
"@tscircuit/math-utils": "^0.0.5",
|
|
46
|
-
"@tscircuit/props": "^0.0.
|
|
46
|
+
"@tscircuit/props": "^0.0.119",
|
|
47
47
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
48
48
|
"@tscircuit/soup-util": "^0.0.41",
|
|
49
49
|
"circuit-json": "^0.0.119",
|