@tscircuit/core 0.0.929 → 0.0.930
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 +12 -6
- package/dist/index.js +42 -5
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1416,6 +1416,7 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
|
|
|
1416
1416
|
pcbOffsetX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
1417
1417
|
pcbOffsetY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
1418
1418
|
pcbRotation: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
1419
|
+
pcbPositionAnchor: zod.ZodOptional<zod.ZodString>;
|
|
1419
1420
|
pcbPositionMode: zod.ZodOptional<zod.ZodEnum<["relative_to_group_anchor", "auto", "relative_to_board_anchor", "relative_to_component_anchor"]>>;
|
|
1420
1421
|
pcbMarginTop: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
1421
1422
|
pcbMarginRight: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
@@ -1770,7 +1771,7 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
|
|
|
1770
1771
|
pcbPaddingRight: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
1771
1772
|
pcbPaddingTop: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
1772
1773
|
pcbPaddingBottom: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
1773
|
-
|
|
1774
|
+
pcbAnchorAlignment: zod.ZodOptional<zod.ZodType<_tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right">, zod.ZodTypeDef, _tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right">>>;
|
|
1774
1775
|
layoutMode: zod.ZodOptional<zod.ZodEnum<["grid", "flex", "match-adapt", "relative", "none"]>>;
|
|
1775
1776
|
position: zod.ZodOptional<zod.ZodEnum<["absolute", "relative"]>>;
|
|
1776
1777
|
gridCols: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
|
|
@@ -2169,7 +2170,7 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
|
|
|
2169
2170
|
pcbOffsetX?: number | undefined;
|
|
2170
2171
|
pcbOffsetY?: number | undefined;
|
|
2171
2172
|
pcbRotation?: number | undefined;
|
|
2172
|
-
pcbPositionAnchor?:
|
|
2173
|
+
pcbPositionAnchor?: string | undefined;
|
|
2173
2174
|
pcbPositionMode?: "relative_to_group_anchor" | "auto" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
|
|
2174
2175
|
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
2175
2176
|
pcbMarginTop?: number | undefined;
|
|
@@ -2371,6 +2372,7 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
|
|
|
2371
2372
|
pcbPaddingRight?: number | undefined;
|
|
2372
2373
|
pcbPaddingTop?: number | undefined;
|
|
2373
2374
|
pcbPaddingBottom?: number | undefined;
|
|
2375
|
+
pcbAnchorAlignment?: _tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right"> | undefined;
|
|
2374
2376
|
manualEdits?: {
|
|
2375
2377
|
pcb_placements?: {
|
|
2376
2378
|
center: {
|
|
@@ -2483,7 +2485,7 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
|
|
|
2483
2485
|
pcbOffsetX?: string | number | undefined;
|
|
2484
2486
|
pcbOffsetY?: string | number | undefined;
|
|
2485
2487
|
pcbRotation?: string | number | undefined;
|
|
2486
|
-
pcbPositionAnchor?:
|
|
2488
|
+
pcbPositionAnchor?: string | undefined;
|
|
2487
2489
|
pcbPositionMode?: "relative_to_group_anchor" | "auto" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
|
|
2488
2490
|
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
2489
2491
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
@@ -2687,6 +2689,7 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
|
|
|
2687
2689
|
pcbPaddingRight?: string | number | undefined;
|
|
2688
2690
|
pcbPaddingTop?: string | number | undefined;
|
|
2689
2691
|
pcbPaddingBottom?: string | number | undefined;
|
|
2692
|
+
pcbAnchorAlignment?: _tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right"> | undefined;
|
|
2690
2693
|
manualEdits?: {
|
|
2691
2694
|
pcb_placements?: {
|
|
2692
2695
|
center: {
|
|
@@ -2836,6 +2839,7 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
2836
2839
|
pcbOffsetX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
2837
2840
|
pcbOffsetY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
2838
2841
|
pcbRotation: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
2842
|
+
pcbPositionAnchor: zod.ZodOptional<zod.ZodString>;
|
|
2839
2843
|
pcbPositionMode: zod.ZodOptional<zod.ZodEnum<["relative_to_group_anchor", "auto", "relative_to_board_anchor", "relative_to_component_anchor"]>>;
|
|
2840
2844
|
pcbMarginTop: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
2841
2845
|
pcbMarginRight: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
@@ -3192,7 +3196,7 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3192
3196
|
pcbPaddingRight: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
3193
3197
|
pcbPaddingTop: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
3194
3198
|
pcbPaddingBottom: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
3195
|
-
|
|
3199
|
+
pcbAnchorAlignment: zod.ZodOptional<zod.ZodType<_tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right">, zod.ZodTypeDef, _tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right">>>;
|
|
3196
3200
|
layoutMode: zod.ZodOptional<zod.ZodEnum<["grid", "flex", "match-adapt", "relative", "none"]>>;
|
|
3197
3201
|
position: zod.ZodOptional<zod.ZodEnum<["absolute", "relative"]>>;
|
|
3198
3202
|
gridCols: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
|
|
@@ -3391,7 +3395,7 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3391
3395
|
pcbOffsetX?: number | undefined;
|
|
3392
3396
|
pcbOffsetY?: number | undefined;
|
|
3393
3397
|
pcbRotation?: number | undefined;
|
|
3394
|
-
pcbPositionAnchor?:
|
|
3398
|
+
pcbPositionAnchor?: string | undefined;
|
|
3395
3399
|
pcbPositionMode?: "relative_to_group_anchor" | "auto" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
|
|
3396
3400
|
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
3397
3401
|
pcbMarginTop?: number | undefined;
|
|
@@ -3595,6 +3599,7 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3595
3599
|
pcbPaddingRight?: number | undefined;
|
|
3596
3600
|
pcbPaddingTop?: number | undefined;
|
|
3597
3601
|
pcbPaddingBottom?: number | undefined;
|
|
3602
|
+
pcbAnchorAlignment?: _tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right"> | undefined;
|
|
3598
3603
|
pcbGrid?: boolean | undefined;
|
|
3599
3604
|
pcbGridCols?: string | number | undefined;
|
|
3600
3605
|
pcbGridRows?: string | number | undefined;
|
|
@@ -3660,7 +3665,7 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3660
3665
|
pcbOffsetX?: string | number | undefined;
|
|
3661
3666
|
pcbOffsetY?: string | number | undefined;
|
|
3662
3667
|
pcbRotation?: string | number | undefined;
|
|
3663
|
-
pcbPositionAnchor?:
|
|
3668
|
+
pcbPositionAnchor?: string | undefined;
|
|
3664
3669
|
pcbPositionMode?: "relative_to_group_anchor" | "auto" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
|
|
3665
3670
|
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
3666
3671
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
@@ -3866,6 +3871,7 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3866
3871
|
pcbPaddingRight?: string | number | undefined;
|
|
3867
3872
|
pcbPaddingTop?: string | number | undefined;
|
|
3868
3873
|
pcbPaddingBottom?: string | number | undefined;
|
|
3874
|
+
pcbAnchorAlignment?: _tscircuit_props.AutocompleteString<"top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right"> | undefined;
|
|
3869
3875
|
pcbGrid?: boolean | undefined;
|
|
3870
3876
|
pcbGridCols?: string | number | undefined;
|
|
3871
3877
|
pcbGridRows?: string | number | undefined;
|
package/dist/index.js
CHANGED
|
@@ -13681,6 +13681,39 @@ function Group_doInitialPcbComponentAnchorAlignment(group) {
|
|
|
13681
13681
|
});
|
|
13682
13682
|
}
|
|
13683
13683
|
|
|
13684
|
+
// lib/components/primitive-components/Group/utils/computeCenterFromAnchorPosition.ts
|
|
13685
|
+
function computeCenterFromAnchorPosition(anchorPosition, ctx) {
|
|
13686
|
+
const { width, height, pcbAnchorAlignment } = ctx;
|
|
13687
|
+
if (!pcbAnchorAlignment) return anchorPosition;
|
|
13688
|
+
const alignment = pcbAnchorAlignment;
|
|
13689
|
+
if (typeof width !== "number" || typeof height !== "number") {
|
|
13690
|
+
console.log("width or height is not a number");
|
|
13691
|
+
return anchorPosition;
|
|
13692
|
+
}
|
|
13693
|
+
const ax = anchorPosition.x;
|
|
13694
|
+
const ay = anchorPosition.y;
|
|
13695
|
+
switch (alignment) {
|
|
13696
|
+
case "top_left":
|
|
13697
|
+
return { x: ax + width / 2, y: ay - height / 2 };
|
|
13698
|
+
case "top_center":
|
|
13699
|
+
return { x: ax, y: ay - height / 2 };
|
|
13700
|
+
case "top_right":
|
|
13701
|
+
return { x: ax - width / 2, y: ay - height / 2 };
|
|
13702
|
+
case "center_left":
|
|
13703
|
+
return { x: ax + width / 2, y: ay };
|
|
13704
|
+
case "center_right":
|
|
13705
|
+
return { x: ax - width / 2, y: ay };
|
|
13706
|
+
case "bottom_left":
|
|
13707
|
+
return { x: ax + width / 2, y: ay + height / 2 };
|
|
13708
|
+
case "bottom_center":
|
|
13709
|
+
return { x: ax, y: ay + height / 2 };
|
|
13710
|
+
case "bottom_right":
|
|
13711
|
+
return { x: ax - width / 2, y: ay + height / 2 };
|
|
13712
|
+
default:
|
|
13713
|
+
return anchorPosition;
|
|
13714
|
+
}
|
|
13715
|
+
}
|
|
13716
|
+
|
|
13684
13717
|
// lib/components/primitive-components/Group/Group.ts
|
|
13685
13718
|
var Group6 = class extends NormalComponent3 {
|
|
13686
13719
|
pcb_group_id = null;
|
|
@@ -13743,18 +13776,22 @@ var Group6 = class extends NormalComponent3 {
|
|
|
13743
13776
|
x: distance8.parse(point2.x),
|
|
13744
13777
|
y: distance8.parse(point2.y)
|
|
13745
13778
|
})) : void 0;
|
|
13779
|
+
const ctx = this.props;
|
|
13780
|
+
const anchorPosition = this._getGlobalPcbPositionBeforeLayout();
|
|
13781
|
+
const center = computeCenterFromAnchorPosition(anchorPosition, ctx);
|
|
13746
13782
|
const pcb_group = db.pcb_group.insert({
|
|
13747
13783
|
is_subcircuit: this.isSubcircuit,
|
|
13748
13784
|
subcircuit_id: this.subcircuit_id ?? this.getSubcircuit()?.subcircuit_id,
|
|
13749
13785
|
name: this.name,
|
|
13750
|
-
|
|
13751
|
-
|
|
13786
|
+
anchor_position: anchorPosition,
|
|
13787
|
+
center,
|
|
13752
13788
|
...hasOutline ? { outline: numericOutline } : { width: 0, height: 0 },
|
|
13753
13789
|
pcb_component_ids: [],
|
|
13754
13790
|
source_group_id: this.source_group_id,
|
|
13755
13791
|
autorouter_configuration: props.autorouter ? {
|
|
13756
13792
|
trace_clearance: props.autorouter.traceClearance
|
|
13757
|
-
} : void 0
|
|
13793
|
+
} : void 0,
|
|
13794
|
+
anchor_alignment: props.pcbAnchorAlignment ?? null
|
|
13758
13795
|
});
|
|
13759
13796
|
this.pcb_group_id = pcb_group.pcb_group_id;
|
|
13760
13797
|
for (const child of this.children) {
|
|
@@ -19595,7 +19632,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
19595
19632
|
var package_default = {
|
|
19596
19633
|
name: "@tscircuit/core",
|
|
19597
19634
|
type: "module",
|
|
19598
|
-
version: "0.0.
|
|
19635
|
+
version: "0.0.929",
|
|
19599
19636
|
types: "dist/index.d.ts",
|
|
19600
19637
|
main: "dist/index.js",
|
|
19601
19638
|
module: "dist/index.js",
|
|
@@ -19639,7 +19676,7 @@ var package_default = {
|
|
|
19639
19676
|
"@tscircuit/math-utils": "^0.0.29",
|
|
19640
19677
|
"@tscircuit/miniflex": "^0.0.4",
|
|
19641
19678
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
19642
|
-
"@tscircuit/props": "^0.0.
|
|
19679
|
+
"@tscircuit/props": "^0.0.429",
|
|
19643
19680
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
19644
19681
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
19645
19682
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|
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.930",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@tscircuit/math-utils": "^0.0.29",
|
|
46
46
|
"@tscircuit/miniflex": "^0.0.4",
|
|
47
47
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
48
|
-
"@tscircuit/props": "^0.0.
|
|
48
|
+
"@tscircuit/props": "^0.0.429",
|
|
49
49
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
50
50
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
51
51
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|