@tscircuit/core 0.0.798 → 0.0.800
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 +9 -4
- package/dist/index.js +148 -9
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1285,6 +1285,11 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
|
|
|
1285
1285
|
doInitialPcbDesignRuleChecks(): void;
|
|
1286
1286
|
doInitialSchematicReplaceNetLabelsWithSymbols(): void;
|
|
1287
1287
|
doInitialSimulationSpiceEngineRender(): void;
|
|
1288
|
+
/**
|
|
1289
|
+
* Override anchor alignment to handle group-specific logic
|
|
1290
|
+
*/
|
|
1291
|
+
doInitialPcbComponentAnchorAlignment(): void;
|
|
1292
|
+
updatePcbComponentAnchorAlignment(): void;
|
|
1288
1293
|
/**
|
|
1289
1294
|
* Get the minimum flex container size for this group on PCB
|
|
1290
1295
|
*/
|
|
@@ -14971,10 +14976,10 @@ declare const voltageSourceProps: z.ZodObject<{
|
|
|
14971
14976
|
schX?: number | undefined;
|
|
14972
14977
|
schY?: number | undefined;
|
|
14973
14978
|
pcbX?: number | undefined;
|
|
14979
|
+
pcbY?: number | undefined;
|
|
14974
14980
|
voltage?: number | undefined;
|
|
14975
14981
|
frequency?: number | undefined;
|
|
14976
14982
|
pcbPositionAnchor?: string | undefined;
|
|
14977
|
-
pcbY?: number | undefined;
|
|
14978
14983
|
pcbMarginTop?: number | undefined;
|
|
14979
14984
|
pcbMarginRight?: number | undefined;
|
|
14980
14985
|
pcbMarginBottom?: number | undefined;
|
|
@@ -15158,10 +15163,10 @@ declare const voltageSourceProps: z.ZodObject<{
|
|
|
15158
15163
|
schX?: string | number | undefined;
|
|
15159
15164
|
schY?: string | number | undefined;
|
|
15160
15165
|
pcbX?: string | number | undefined;
|
|
15166
|
+
pcbY?: string | number | undefined;
|
|
15161
15167
|
voltage?: string | number | undefined;
|
|
15162
15168
|
frequency?: string | number | undefined;
|
|
15163
15169
|
pcbPositionAnchor?: string | undefined;
|
|
15164
|
-
pcbY?: string | number | undefined;
|
|
15165
15170
|
pcbMarginTop?: string | number | undefined;
|
|
15166
15171
|
pcbMarginRight?: string | number | undefined;
|
|
15167
15172
|
pcbMarginBottom?: string | number | undefined;
|
|
@@ -16007,10 +16012,10 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
|
|
|
16007
16012
|
schX?: number | undefined;
|
|
16008
16013
|
schY?: number | undefined;
|
|
16009
16014
|
pcbX?: number | undefined;
|
|
16015
|
+
pcbY?: number | undefined;
|
|
16010
16016
|
voltage?: number | undefined;
|
|
16011
16017
|
frequency?: number | undefined;
|
|
16012
16018
|
pcbPositionAnchor?: string | undefined;
|
|
16013
|
-
pcbY?: number | undefined;
|
|
16014
16019
|
pcbMarginTop?: number | undefined;
|
|
16015
16020
|
pcbMarginRight?: number | undefined;
|
|
16016
16021
|
pcbMarginBottom?: number | undefined;
|
|
@@ -16194,10 +16199,10 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
|
|
|
16194
16199
|
schX?: string | number | undefined;
|
|
16195
16200
|
schY?: string | number | undefined;
|
|
16196
16201
|
pcbX?: string | number | undefined;
|
|
16202
|
+
pcbY?: string | number | undefined;
|
|
16197
16203
|
voltage?: string | number | undefined;
|
|
16198
16204
|
frequency?: string | number | undefined;
|
|
16199
16205
|
pcbPositionAnchor?: string | undefined;
|
|
16200
|
-
pcbY?: string | number | undefined;
|
|
16201
16206
|
pcbMarginTop?: string | number | undefined;
|
|
16202
16207
|
pcbMarginRight?: string | number | undefined;
|
|
16203
16208
|
pcbMarginBottom?: string | number | undefined;
|
package/dist/index.js
CHANGED
|
@@ -7398,6 +7398,7 @@ function NormalComponent_doInitialPcbComponentAnchorAlignment(component) {
|
|
|
7398
7398
|
}
|
|
7399
7399
|
|
|
7400
7400
|
// lib/components/base-components/NormalComponent/NormalComponent.ts
|
|
7401
|
+
import { normalizeDegrees } from "@tscircuit/math-utils";
|
|
7401
7402
|
var debug3 = Debug4("tscircuit:core");
|
|
7402
7403
|
var rotation32 = z9.object({
|
|
7403
7404
|
x: rotation2,
|
|
@@ -8326,6 +8327,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
8326
8327
|
const globalTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
8327
8328
|
const decomposedTransform = decomposeTSR5(globalTransform);
|
|
8328
8329
|
const accumulatedRotation = decomposedTransform.rotation.angle * 180 / Math.PI;
|
|
8330
|
+
const pcbRotation = pcb_component?.rotation ?? 0;
|
|
8331
|
+
const rotationWithOffset = pcbRotation + accumulatedRotation + (rotationOffset.z ?? 0);
|
|
8332
|
+
const cadRotationZ = computedLayer === "bottom" ? normalizeDegrees(-rotationWithOffset + 180) : normalizeDegrees(rotationWithOffset);
|
|
8329
8333
|
const cad_model = db.cad_component.insert({
|
|
8330
8334
|
// TODO z maybe depends on layer
|
|
8331
8335
|
position: {
|
|
@@ -8336,7 +8340,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
8336
8340
|
rotation: {
|
|
8337
8341
|
x: rotationOffset.x,
|
|
8338
8342
|
y: (computedLayer === "top" ? 0 : 180) + rotationOffset.y,
|
|
8339
|
-
z:
|
|
8343
|
+
z: cadRotationZ
|
|
8340
8344
|
},
|
|
8341
8345
|
pcb_component_id: this.pcb_component_id,
|
|
8342
8346
|
source_component_id: this.source_component_id,
|
|
@@ -10999,7 +11003,33 @@ var applyComponentConstraintClusters = (group, packInput) => {
|
|
|
10999
11003
|
|
|
11000
11004
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/applyPackOutput.ts
|
|
11001
11005
|
import { translate as translate5, rotate as rotate2, compose as compose4 } from "transformation-matrix";
|
|
11002
|
-
import {
|
|
11006
|
+
import {
|
|
11007
|
+
transformPCBElements
|
|
11008
|
+
} from "@tscircuit/circuit-json-util";
|
|
11009
|
+
import { normalizeDegrees as normalizeDegrees2 } from "@tscircuit/math-utils";
|
|
11010
|
+
var updateCadRotation = ({
|
|
11011
|
+
db,
|
|
11012
|
+
pcbComponentId,
|
|
11013
|
+
rotationDegrees,
|
|
11014
|
+
layer
|
|
11015
|
+
}) => {
|
|
11016
|
+
if (rotationDegrees == null) return;
|
|
11017
|
+
if (!db?.cad_component?.list) return;
|
|
11018
|
+
const cadComponent = db.cad_component.getWhere({
|
|
11019
|
+
pcb_component_id: pcbComponentId
|
|
11020
|
+
});
|
|
11021
|
+
if (!cadComponent) return;
|
|
11022
|
+
const delta = layer?.toLowerCase?.() === "bottom" ? -rotationDegrees : rotationDegrees;
|
|
11023
|
+
const currentRotationZ = cadComponent.rotation?.z ?? 0;
|
|
11024
|
+
const nextRotation = {
|
|
11025
|
+
...cadComponent.rotation ?? { x: 0, y: 0, z: 0 },
|
|
11026
|
+
z: normalizeDegrees2(currentRotationZ + delta)
|
|
11027
|
+
};
|
|
11028
|
+
db.cad_component.update(cadComponent.cad_component_id, {
|
|
11029
|
+
rotation: nextRotation
|
|
11030
|
+
});
|
|
11031
|
+
cadComponent.rotation = nextRotation;
|
|
11032
|
+
};
|
|
11003
11033
|
var isDescendantGroup = (db, groupId, ancestorId) => {
|
|
11004
11034
|
if (groupId === ancestorId) return true;
|
|
11005
11035
|
const group = db.source_group.get(groupId);
|
|
@@ -11034,6 +11064,12 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
11034
11064
|
(elm) => "pcb_component_id" in elm && elm.pcb_component_id === memberId
|
|
11035
11065
|
);
|
|
11036
11066
|
transformPCBElements(related, transformMatrix2);
|
|
11067
|
+
updateCadRotation({
|
|
11068
|
+
db,
|
|
11069
|
+
pcbComponentId: memberId,
|
|
11070
|
+
rotationDegrees: rotationDegrees2,
|
|
11071
|
+
layer: member.layer
|
|
11072
|
+
});
|
|
11037
11073
|
}
|
|
11038
11074
|
continue;
|
|
11039
11075
|
}
|
|
@@ -11059,6 +11095,12 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
11059
11095
|
(elm) => "pcb_component_id" in elm && elm.pcb_component_id === componentId
|
|
11060
11096
|
);
|
|
11061
11097
|
transformPCBElements(related, transformMatrix2);
|
|
11098
|
+
updateCadRotation({
|
|
11099
|
+
db,
|
|
11100
|
+
pcbComponentId: componentId,
|
|
11101
|
+
rotationDegrees: rotationDegrees2,
|
|
11102
|
+
layer: pcbComponent.layer
|
|
11103
|
+
});
|
|
11062
11104
|
continue;
|
|
11063
11105
|
}
|
|
11064
11106
|
const pcbGroup = db.pcb_group.list().find((g) => g.source_group_id === componentId);
|
|
@@ -12411,6 +12453,86 @@ ${spiceString}`);
|
|
|
12411
12453
|
}
|
|
12412
12454
|
}
|
|
12413
12455
|
|
|
12456
|
+
// lib/components/primitive-components/Group/Group_doInitialPcbComponentAnchorAlignment.ts
|
|
12457
|
+
function Group_doInitialPcbComponentAnchorAlignment(group) {
|
|
12458
|
+
if (group.root?.pcbDisabled) return;
|
|
12459
|
+
if (!group.pcb_group_id) return;
|
|
12460
|
+
const pcbPositionAnchor = group._parsedProps?.pcbPositionAnchor;
|
|
12461
|
+
if (!pcbPositionAnchor) return;
|
|
12462
|
+
const targetPosition = group._getGlobalPcbPositionBeforeLayout();
|
|
12463
|
+
const { pcbX, pcbY } = group._parsedProps;
|
|
12464
|
+
if (pcbX === void 0 && pcbY === void 0) return;
|
|
12465
|
+
const { db } = group.root;
|
|
12466
|
+
const pcbGroup = db.pcb_group.get(group.pcb_group_id);
|
|
12467
|
+
if (!pcbGroup) return;
|
|
12468
|
+
const { width, height, center } = pcbGroup;
|
|
12469
|
+
if (width === 0 || height === 0) return;
|
|
12470
|
+
const bounds = {
|
|
12471
|
+
left: center.x - width / 2,
|
|
12472
|
+
right: center.x + width / 2,
|
|
12473
|
+
top: center.y + height / 2,
|
|
12474
|
+
// Y-up: top is at higher Y
|
|
12475
|
+
bottom: center.y - height / 2
|
|
12476
|
+
// Y-up: bottom is at lower Y
|
|
12477
|
+
};
|
|
12478
|
+
const currentCenter = { ...center };
|
|
12479
|
+
let anchorPos = null;
|
|
12480
|
+
const ninePointAnchors = /* @__PURE__ */ new Set([
|
|
12481
|
+
"center",
|
|
12482
|
+
"top_left",
|
|
12483
|
+
"top_center",
|
|
12484
|
+
"top_right",
|
|
12485
|
+
"center_left",
|
|
12486
|
+
"center_right",
|
|
12487
|
+
"bottom_left",
|
|
12488
|
+
"bottom_center",
|
|
12489
|
+
"bottom_right"
|
|
12490
|
+
]);
|
|
12491
|
+
if (ninePointAnchors.has(pcbPositionAnchor)) {
|
|
12492
|
+
switch (pcbPositionAnchor) {
|
|
12493
|
+
case "center":
|
|
12494
|
+
anchorPos = currentCenter;
|
|
12495
|
+
break;
|
|
12496
|
+
case "top_left":
|
|
12497
|
+
anchorPos = { x: bounds.left, y: bounds.top };
|
|
12498
|
+
break;
|
|
12499
|
+
case "top_center":
|
|
12500
|
+
anchorPos = { x: currentCenter.x, y: bounds.top };
|
|
12501
|
+
break;
|
|
12502
|
+
case "top_right":
|
|
12503
|
+
anchorPos = { x: bounds.right, y: bounds.top };
|
|
12504
|
+
break;
|
|
12505
|
+
case "center_left":
|
|
12506
|
+
anchorPos = { x: bounds.left, y: currentCenter.y };
|
|
12507
|
+
break;
|
|
12508
|
+
case "center_right":
|
|
12509
|
+
anchorPos = { x: bounds.right, y: currentCenter.y };
|
|
12510
|
+
break;
|
|
12511
|
+
case "bottom_left":
|
|
12512
|
+
anchorPos = { x: bounds.left, y: bounds.bottom };
|
|
12513
|
+
break;
|
|
12514
|
+
case "bottom_center":
|
|
12515
|
+
anchorPos = { x: currentCenter.x, y: bounds.bottom };
|
|
12516
|
+
break;
|
|
12517
|
+
case "bottom_right":
|
|
12518
|
+
anchorPos = { x: bounds.right, y: bounds.bottom };
|
|
12519
|
+
break;
|
|
12520
|
+
}
|
|
12521
|
+
}
|
|
12522
|
+
if (!anchorPos) return;
|
|
12523
|
+
const newCenter = { ...currentCenter };
|
|
12524
|
+
if (targetPosition.x !== void 0)
|
|
12525
|
+
newCenter.x += targetPosition.x - anchorPos.x;
|
|
12526
|
+
if (targetPosition.y !== void 0)
|
|
12527
|
+
newCenter.y += targetPosition.y - anchorPos.y;
|
|
12528
|
+
if (Math.abs(newCenter.x - currentCenter.x) > 1e-6 || Math.abs(newCenter.y - currentCenter.y) > 1e-6) {
|
|
12529
|
+
group._repositionOnPcb(newCenter);
|
|
12530
|
+
db.pcb_group.update(group.pcb_group_id, {
|
|
12531
|
+
center: newCenter
|
|
12532
|
+
});
|
|
12533
|
+
}
|
|
12534
|
+
}
|
|
12535
|
+
|
|
12414
12536
|
// lib/components/primitive-components/Group/Group.ts
|
|
12415
12537
|
var Group6 = class extends NormalComponent3 {
|
|
12416
12538
|
pcb_group_id = null;
|
|
@@ -12509,11 +12631,19 @@ var Group6 = class extends NormalComponent3 {
|
|
|
12509
12631
|
x: centerX,
|
|
12510
12632
|
y: centerY
|
|
12511
12633
|
} : { x: centerX, y: centerY };
|
|
12512
|
-
|
|
12634
|
+
const updateData = {
|
|
12513
12635
|
width: Number(props.width ?? width),
|
|
12514
12636
|
height: Number(props.height ?? height),
|
|
12515
12637
|
center
|
|
12516
|
-
}
|
|
12638
|
+
};
|
|
12639
|
+
const pcbPositionAnchor = props.pcbPositionAnchor;
|
|
12640
|
+
if (pcbPositionAnchor && hasExplicitPositioning) {
|
|
12641
|
+
const pcbX = this._parsedProps.pcbX ?? 0;
|
|
12642
|
+
const pcbY = this._parsedProps.pcbY ?? 0;
|
|
12643
|
+
updateData.anchor_position = { x: pcbX, y: pcbY };
|
|
12644
|
+
updateData.anchor_alignment = pcbPositionAnchor;
|
|
12645
|
+
}
|
|
12646
|
+
db.pcb_group.update(this.pcb_group_id, updateData);
|
|
12517
12647
|
}
|
|
12518
12648
|
}
|
|
12519
12649
|
unnamedElementCounter = {};
|
|
@@ -13168,6 +13298,15 @@ var Group6 = class extends NormalComponent3 {
|
|
|
13168
13298
|
doInitialSimulationSpiceEngineRender() {
|
|
13169
13299
|
Group_doInitialSimulationSpiceEngineRender(this);
|
|
13170
13300
|
}
|
|
13301
|
+
/**
|
|
13302
|
+
* Override anchor alignment to handle group-specific logic
|
|
13303
|
+
*/
|
|
13304
|
+
doInitialPcbComponentAnchorAlignment() {
|
|
13305
|
+
Group_doInitialPcbComponentAnchorAlignment(this);
|
|
13306
|
+
}
|
|
13307
|
+
updatePcbComponentAnchorAlignment() {
|
|
13308
|
+
this.doInitialPcbComponentAnchorAlignment();
|
|
13309
|
+
}
|
|
13171
13310
|
/**
|
|
13172
13311
|
* Get the minimum flex container size for this group on PCB
|
|
13173
13312
|
*/
|
|
@@ -16927,7 +17066,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
16927
17066
|
var package_default = {
|
|
16928
17067
|
name: "@tscircuit/core",
|
|
16929
17068
|
type: "module",
|
|
16930
|
-
version: "0.0.
|
|
17069
|
+
version: "0.0.799",
|
|
16931
17070
|
types: "dist/index.d.ts",
|
|
16932
17071
|
main: "dist/index.js",
|
|
16933
17072
|
module: "dist/index.js",
|
|
@@ -16959,13 +17098,13 @@ var package_default = {
|
|
|
16959
17098
|
"@tscircuit/capacity-autorouter": "^0.0.132",
|
|
16960
17099
|
"@tscircuit/checks": "^0.0.85",
|
|
16961
17100
|
"@tscircuit/circuit-json-util": "^0.0.72",
|
|
16962
|
-
"@tscircuit/common": "^0.0.
|
|
17101
|
+
"@tscircuit/common": "^0.0.14",
|
|
16963
17102
|
"@tscircuit/footprinter": "^0.0.236",
|
|
16964
17103
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
16965
17104
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
16966
17105
|
"@tscircuit/log-soup": "^1.0.2",
|
|
16967
17106
|
"@tscircuit/matchpack": "^0.0.16",
|
|
16968
|
-
"@tscircuit/math-utils": "^0.0.
|
|
17107
|
+
"@tscircuit/math-utils": "^0.0.28",
|
|
16969
17108
|
"@tscircuit/miniflex": "^0.0.4",
|
|
16970
17109
|
"@tscircuit/props": "0.0.369",
|
|
16971
17110
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
@@ -16983,9 +17122,9 @@ var package_default = {
|
|
|
16983
17122
|
"circuit-json": "^0.0.283",
|
|
16984
17123
|
"circuit-json-to-bpc": "^0.0.13",
|
|
16985
17124
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
16986
|
-
"circuit-json-to-gltf": "^0.0.
|
|
17125
|
+
"circuit-json-to-gltf": "^0.0.26",
|
|
16987
17126
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
16988
|
-
"circuit-to-svg": "^0.0.
|
|
17127
|
+
"circuit-to-svg": "^0.0.245",
|
|
16989
17128
|
"circuit-json-to-spice": "^0.0.14",
|
|
16990
17129
|
concurrently: "^9.1.2",
|
|
16991
17130
|
"connectivity-map": "^1.0.0",
|
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.800",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"@tscircuit/capacity-autorouter": "^0.0.132",
|
|
34
34
|
"@tscircuit/checks": "^0.0.85",
|
|
35
35
|
"@tscircuit/circuit-json-util": "^0.0.72",
|
|
36
|
-
"@tscircuit/common": "^0.0.
|
|
36
|
+
"@tscircuit/common": "^0.0.14",
|
|
37
37
|
"@tscircuit/footprinter": "^0.0.236",
|
|
38
38
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
39
39
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
40
40
|
"@tscircuit/log-soup": "^1.0.2",
|
|
41
41
|
"@tscircuit/matchpack": "^0.0.16",
|
|
42
|
-
"@tscircuit/math-utils": "^0.0.
|
|
42
|
+
"@tscircuit/math-utils": "^0.0.28",
|
|
43
43
|
"@tscircuit/miniflex": "^0.0.4",
|
|
44
44
|
"@tscircuit/props": "0.0.369",
|
|
45
45
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"circuit-json": "^0.0.283",
|
|
58
58
|
"circuit-json-to-bpc": "^0.0.13",
|
|
59
59
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
60
|
-
"circuit-json-to-gltf": "^0.0.
|
|
60
|
+
"circuit-json-to-gltf": "^0.0.26",
|
|
61
61
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
62
|
-
"circuit-to-svg": "^0.0.
|
|
62
|
+
"circuit-to-svg": "^0.0.245",
|
|
63
63
|
"circuit-json-to-spice": "^0.0.14",
|
|
64
64
|
"concurrently": "^9.1.2",
|
|
65
65
|
"connectivity-map": "^1.0.0",
|