@tscircuit/core 0.0.657 → 0.0.658
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 +33 -1
- package/dist/index.js +99 -66
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as circuit_json from 'circuit-json';
|
|
2
|
+
import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, LayerRef, AnyCircuitElement, Size, AnySourceComponent, PcbTraceRoutePoint, PcbTrace as PcbTrace$1, PcbVia, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
|
|
1
3
|
import * as _tscircuit_props from '@tscircuit/props';
|
|
2
4
|
import { PlatformConfig, subcircuitGroupProps, AutorouterConfig, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, diodeProps, fuseProps, jumperProps, solderjumperProps, ledProps, powerSourceProps, CommonComponentProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, switchProps, testpointProps, schematicTextProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
|
|
3
5
|
import React, { ReactElement, DetailedHTMLProps, SVGProps } from 'react';
|
|
@@ -5,7 +7,6 @@ export { createElement } from 'react';
|
|
|
5
7
|
import * as zod from 'zod';
|
|
6
8
|
import { z, ZodType } from 'zod';
|
|
7
9
|
import { symbols, SchSymbol, BaseSymbolName } from 'schematic-symbols';
|
|
8
|
-
import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, LayerRef, AnyCircuitElement, AnySourceComponent, PcbTraceRoutePoint, PcbTrace as PcbTrace$1, PcbVia, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
|
|
9
10
|
import { Matrix } from 'transformation-matrix';
|
|
10
11
|
import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
|
|
11
12
|
import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
|
|
@@ -281,6 +282,15 @@ interface IGroup extends PrimitiveComponent {
|
|
|
281
282
|
source_group_id: string | null;
|
|
282
283
|
pcb_group_id: string | null;
|
|
283
284
|
_getSchematicLayoutMode(): "match-adapt" | "flex" | "grid" | "relative";
|
|
285
|
+
_getMinimumFlexContainerSize(): Size | null;
|
|
286
|
+
_repositionOnPcb(position: {
|
|
287
|
+
x: number;
|
|
288
|
+
y: number;
|
|
289
|
+
}): void;
|
|
290
|
+
_repositionOnSchematic(position: {
|
|
291
|
+
x: number;
|
|
292
|
+
y: number;
|
|
293
|
+
}): void;
|
|
284
294
|
}
|
|
285
295
|
|
|
286
296
|
type Ftype = Extract<AnySourceComponent, {
|
|
@@ -1094,6 +1104,17 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
1094
1104
|
doInitialAssignFallbackProps(): void;
|
|
1095
1105
|
doInitialCreateTracesFromProps(): void;
|
|
1096
1106
|
_createTracesFromConnectionsProp(): void;
|
|
1107
|
+
/**
|
|
1108
|
+
* Get the minimum flex container size for this component on PCB
|
|
1109
|
+
*/
|
|
1110
|
+
_getMinimumFlexContainerSize(): circuit_json.Size | null;
|
|
1111
|
+
/**
|
|
1112
|
+
* Reposition this component on the PCB to the specified coordinates
|
|
1113
|
+
*/
|
|
1114
|
+
_repositionOnPcb(position: {
|
|
1115
|
+
x: number;
|
|
1116
|
+
y: number;
|
|
1117
|
+
}): void;
|
|
1097
1118
|
}
|
|
1098
1119
|
|
|
1099
1120
|
declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps> extends NormalComponent<Props> implements ISubcircuit {
|
|
@@ -1174,6 +1195,17 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
|
|
|
1174
1195
|
_shouldUseTraceByTraceRouting(): boolean;
|
|
1175
1196
|
doInitialPcbDesignRuleChecks(): void;
|
|
1176
1197
|
doInitialSchematicReplaceNetLabelsWithSymbols(): void;
|
|
1198
|
+
/**
|
|
1199
|
+
* Get the minimum flex container size for this group on PCB
|
|
1200
|
+
*/
|
|
1201
|
+
_getMinimumFlexContainerSize(): circuit_json.Size | null;
|
|
1202
|
+
/**
|
|
1203
|
+
* Reposition this group on the PCB to the specified coordinates
|
|
1204
|
+
*/
|
|
1205
|
+
_repositionOnPcb(position: {
|
|
1206
|
+
x: number;
|
|
1207
|
+
y: number;
|
|
1208
|
+
}): void;
|
|
1177
1209
|
}
|
|
1178
1210
|
|
|
1179
1211
|
declare class Board extends Group<typeof boardProps> {
|
package/dist/index.js
CHANGED
|
@@ -6178,6 +6178,59 @@ var Trace3 = class extends PrimitiveComponent2 {
|
|
|
6178
6178
|
}
|
|
6179
6179
|
};
|
|
6180
6180
|
|
|
6181
|
+
// lib/components/base-components/NormalComponent/NormalComponent__getMinimumFlexContainerSize.ts
|
|
6182
|
+
var NormalComponent__getMinimumFlexContainerSize = (component) => {
|
|
6183
|
+
const { db } = component.root;
|
|
6184
|
+
if (component.pcb_component_id) {
|
|
6185
|
+
const pcbComponent = db.pcb_component.get(component.pcb_component_id);
|
|
6186
|
+
if (!pcbComponent) return null;
|
|
6187
|
+
return {
|
|
6188
|
+
width: pcbComponent.width,
|
|
6189
|
+
height: pcbComponent.height
|
|
6190
|
+
};
|
|
6191
|
+
}
|
|
6192
|
+
if (component.pcb_group_id) {
|
|
6193
|
+
const pcbGroup = db.pcb_group.get(
|
|
6194
|
+
component.pcb_group_id
|
|
6195
|
+
);
|
|
6196
|
+
if (!pcbGroup) return null;
|
|
6197
|
+
return {
|
|
6198
|
+
width: pcbGroup.width,
|
|
6199
|
+
height: pcbGroup.height
|
|
6200
|
+
};
|
|
6201
|
+
}
|
|
6202
|
+
return null;
|
|
6203
|
+
};
|
|
6204
|
+
|
|
6205
|
+
// lib/components/base-components/NormalComponent/NormalComponent__repositionOnPcb.ts
|
|
6206
|
+
import {
|
|
6207
|
+
repositionPcbComponentTo,
|
|
6208
|
+
repositionPcbGroupTo
|
|
6209
|
+
} from "@tscircuit/circuit-json-util";
|
|
6210
|
+
var NormalComponent__repositionOnPcb = (component, position) => {
|
|
6211
|
+
const { db } = component.root;
|
|
6212
|
+
const allCircuitJson = db.toArray();
|
|
6213
|
+
if (component.pcb_component_id) {
|
|
6214
|
+
repositionPcbComponentTo(
|
|
6215
|
+
allCircuitJson,
|
|
6216
|
+
component.pcb_component_id,
|
|
6217
|
+
position
|
|
6218
|
+
);
|
|
6219
|
+
return;
|
|
6220
|
+
}
|
|
6221
|
+
if (component.source_group_id) {
|
|
6222
|
+
repositionPcbGroupTo(
|
|
6223
|
+
allCircuitJson,
|
|
6224
|
+
component.source_group_id,
|
|
6225
|
+
position
|
|
6226
|
+
);
|
|
6227
|
+
return;
|
|
6228
|
+
}
|
|
6229
|
+
throw new Error(
|
|
6230
|
+
`Cannot reposition component ${component.getString()}: no pcb_component_id or source_group_id`
|
|
6231
|
+
);
|
|
6232
|
+
};
|
|
6233
|
+
|
|
6181
6234
|
// lib/components/base-components/NormalComponent/NormalComponent.ts
|
|
6182
6235
|
var debug3 = Debug4("tscircuit:core");
|
|
6183
6236
|
var rotation3 = z8.object({
|
|
@@ -7050,6 +7103,18 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
7050
7103
|
}
|
|
7051
7104
|
}
|
|
7052
7105
|
}
|
|
7106
|
+
/**
|
|
7107
|
+
* Get the minimum flex container size for this component on PCB
|
|
7108
|
+
*/
|
|
7109
|
+
_getMinimumFlexContainerSize() {
|
|
7110
|
+
return NormalComponent__getMinimumFlexContainerSize(this);
|
|
7111
|
+
}
|
|
7112
|
+
/**
|
|
7113
|
+
* Reposition this component on the PCB to the specified coordinates
|
|
7114
|
+
*/
|
|
7115
|
+
_repositionOnPcb(position) {
|
|
7116
|
+
return NormalComponent__repositionOnPcb(this, position);
|
|
7117
|
+
}
|
|
7053
7118
|
};
|
|
7054
7119
|
|
|
7055
7120
|
// lib/components/normal-components/Board.ts
|
|
@@ -8918,8 +8983,8 @@ var Group_doInitialSchematicLayoutFlex = (group) => {
|
|
|
8918
8983
|
|
|
8919
8984
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutGrid.ts
|
|
8920
8985
|
import {
|
|
8921
|
-
repositionPcbComponentTo,
|
|
8922
|
-
repositionPcbGroupTo
|
|
8986
|
+
repositionPcbComponentTo as repositionPcbComponentTo2,
|
|
8987
|
+
repositionPcbGroupTo as repositionPcbGroupTo2
|
|
8923
8988
|
} from "@tscircuit/circuit-json-util";
|
|
8924
8989
|
import { length as length3 } from "circuit-json";
|
|
8925
8990
|
import { CssGrid } from "minicssgrid";
|
|
@@ -9100,14 +9165,14 @@ function positionChildren(params) {
|
|
|
9100
9165
|
const targetX = groupCenter.x - gridLayout.containerWidth / 2 + coordinates.x + coordinates.width / 2;
|
|
9101
9166
|
const targetY = groupCenter.y + gridLayout.containerHeight / 2 - coordinates.y - coordinates.height / 2;
|
|
9102
9167
|
if (child.pcb_component_id) {
|
|
9103
|
-
|
|
9168
|
+
repositionPcbComponentTo2(allCircuitJson, child.pcb_component_id, {
|
|
9104
9169
|
x: targetX,
|
|
9105
9170
|
y: targetY
|
|
9106
9171
|
});
|
|
9107
9172
|
} else {
|
|
9108
9173
|
const groupChild = child;
|
|
9109
9174
|
if (groupChild.pcb_group_id && groupChild.source_group_id) {
|
|
9110
|
-
|
|
9175
|
+
repositionPcbGroupTo2(allCircuitJson, groupChild.source_group_id, {
|
|
9111
9176
|
x: targetX,
|
|
9112
9177
|
y: targetY
|
|
9113
9178
|
});
|
|
@@ -9317,44 +9382,15 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
9317
9382
|
};
|
|
9318
9383
|
|
|
9319
9384
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutFlex.ts
|
|
9320
|
-
import {
|
|
9321
|
-
getCircuitJsonTree as getCircuitJsonTree3,
|
|
9322
|
-
repositionPcbComponentTo as repositionPcbComponentTo2,
|
|
9323
|
-
repositionPcbGroupTo as repositionPcbGroupTo2,
|
|
9324
|
-
getMinimumFlexContainer as getMinimumFlexContainer2
|
|
9325
|
-
} from "@tscircuit/circuit-json-util";
|
|
9385
|
+
import { getMinimumFlexContainer as getMinimumFlexContainer2 } from "@tscircuit/circuit-json-util";
|
|
9326
9386
|
import { RootFlexBox as RootFlexBox2 } from "@tscircuit/miniflex";
|
|
9327
9387
|
import { length as length5 } from "circuit-json";
|
|
9328
|
-
var getSizeOfTreeNodeChild2 = (db, child) => {
|
|
9329
|
-
const { sourceComponent, sourceGroup } = child;
|
|
9330
|
-
if (child.nodeType === "component") {
|
|
9331
|
-
const pcbComponent = db.pcb_component.getWhere({
|
|
9332
|
-
source_component_id: sourceComponent?.source_component_id
|
|
9333
|
-
});
|
|
9334
|
-
if (!pcbComponent) return null;
|
|
9335
|
-
return {
|
|
9336
|
-
width: pcbComponent.width,
|
|
9337
|
-
height: pcbComponent.height
|
|
9338
|
-
};
|
|
9339
|
-
}
|
|
9340
|
-
if (child.nodeType === "group") {
|
|
9341
|
-
const pcbGroup = db.pcb_group.getWhere({
|
|
9342
|
-
source_group_id: sourceGroup?.source_group_id
|
|
9343
|
-
});
|
|
9344
|
-
if (!pcbGroup) return null;
|
|
9345
|
-
return {
|
|
9346
|
-
width: pcbGroup.width,
|
|
9347
|
-
height: pcbGroup.height
|
|
9348
|
-
};
|
|
9349
|
-
}
|
|
9350
|
-
return null;
|
|
9351
|
-
};
|
|
9352
9388
|
var Group_doInitialPcbLayoutFlex = (group) => {
|
|
9353
9389
|
const { db } = group.root;
|
|
9354
9390
|
const { _parsedProps: props } = group;
|
|
9355
|
-
const
|
|
9356
|
-
|
|
9357
|
-
|
|
9391
|
+
const pcbChildren = group.children.filter(
|
|
9392
|
+
(c) => c.pcb_component_id || c.pcb_group_id
|
|
9393
|
+
);
|
|
9358
9394
|
const rawJustify = props.pcbJustifyContent ?? props.justifyContent;
|
|
9359
9395
|
const rawAlign = props.pcbAlignItems ?? props.alignItems;
|
|
9360
9396
|
const rawGap = props.pcbFlexGap ?? props.pcbGap ?? props.gap;
|
|
@@ -9402,7 +9438,7 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9402
9438
|
const isInline = Boolean(width === void 0 || height === void 0);
|
|
9403
9439
|
if (isInline) {
|
|
9404
9440
|
minFlexContainer = getMinimumFlexContainer2(
|
|
9405
|
-
|
|
9441
|
+
pcbChildren.map((child) => child._getMinimumFlexContainerSize()).filter((size) => size !== null),
|
|
9406
9442
|
{
|
|
9407
9443
|
alignItems,
|
|
9408
9444
|
justifyContent,
|
|
@@ -9421,8 +9457,8 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9421
9457
|
rowGap,
|
|
9422
9458
|
columnGap
|
|
9423
9459
|
});
|
|
9424
|
-
for (const child of
|
|
9425
|
-
const size =
|
|
9460
|
+
for (const child of pcbChildren) {
|
|
9461
|
+
const size = child._getMinimumFlexContainerSize();
|
|
9426
9462
|
flexBox.addChild({
|
|
9427
9463
|
metadata: child,
|
|
9428
9464
|
// TODO these should be minWidth/minHeight
|
|
@@ -9434,7 +9470,6 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9434
9470
|
});
|
|
9435
9471
|
}
|
|
9436
9472
|
flexBox.build();
|
|
9437
|
-
const allCircuitJson = db.toArray();
|
|
9438
9473
|
const bounds = {
|
|
9439
9474
|
minX: Infinity,
|
|
9440
9475
|
minY: Infinity,
|
|
@@ -9451,36 +9486,22 @@ var Group_doInitialPcbLayoutFlex = (group) => {
|
|
|
9451
9486
|
}
|
|
9452
9487
|
bounds.width = bounds.maxX - bounds.minX;
|
|
9453
9488
|
bounds.height = bounds.maxY - bounds.minY;
|
|
9489
|
+
const groupCenter = group._getGlobalPcbPositionBeforeLayout();
|
|
9454
9490
|
const offset = {
|
|
9455
|
-
x: -(bounds.maxX + bounds.minX) / 2,
|
|
9456
|
-
y: -(bounds.maxY + bounds.minY) / 2
|
|
9491
|
+
x: groupCenter.x - (bounds.maxX + bounds.minX) / 2,
|
|
9492
|
+
y: groupCenter.y - (bounds.maxY + bounds.minY) / 2
|
|
9457
9493
|
};
|
|
9458
9494
|
for (const child of flexBox.children) {
|
|
9459
|
-
const
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
if (!pcbComponent) continue;
|
|
9465
|
-
repositionPcbComponentTo2(allCircuitJson, pcbComponent.pcb_component_id, {
|
|
9466
|
-
x: child.position.x + child.size.width / 2 + offset.x,
|
|
9467
|
-
y: child.position.y + child.size.height / 2 + offset.y
|
|
9468
|
-
});
|
|
9469
|
-
}
|
|
9470
|
-
if (sourceGroup) {
|
|
9471
|
-
const pcbGroup = db.pcb_group.getWhere({
|
|
9472
|
-
source_group_id: sourceGroup.source_group_id
|
|
9473
|
-
});
|
|
9474
|
-
if (!pcbGroup) continue;
|
|
9475
|
-
repositionPcbGroupTo2(allCircuitJson, sourceGroup.source_group_id, {
|
|
9476
|
-
x: child.position.x + child.size.width / 2 + offset.x,
|
|
9477
|
-
y: child.position.y + child.size.height / 2 + offset.y
|
|
9478
|
-
});
|
|
9479
|
-
}
|
|
9495
|
+
const childMetadata = child.metadata;
|
|
9496
|
+
childMetadata._repositionOnPcb({
|
|
9497
|
+
x: child.position.x + child.size.width / 2 + offset.x,
|
|
9498
|
+
y: child.position.y + child.size.height / 2 + offset.y
|
|
9499
|
+
});
|
|
9480
9500
|
}
|
|
9481
9501
|
db.pcb_group.update(group.pcb_group_id, {
|
|
9482
9502
|
width: bounds.width,
|
|
9483
|
-
height: bounds.height
|
|
9503
|
+
height: bounds.height,
|
|
9504
|
+
center: groupCenter
|
|
9484
9505
|
});
|
|
9485
9506
|
};
|
|
9486
9507
|
|
|
@@ -11019,6 +11040,18 @@ var Group6 = class extends NormalComponent {
|
|
|
11019
11040
|
}
|
|
11020
11041
|
}
|
|
11021
11042
|
}
|
|
11043
|
+
/**
|
|
11044
|
+
* Get the minimum flex container size for this group on PCB
|
|
11045
|
+
*/
|
|
11046
|
+
_getMinimumFlexContainerSize() {
|
|
11047
|
+
return super._getMinimumFlexContainerSize();
|
|
11048
|
+
}
|
|
11049
|
+
/**
|
|
11050
|
+
* Reposition this group on the PCB to the specified coordinates
|
|
11051
|
+
*/
|
|
11052
|
+
_repositionOnPcb(position) {
|
|
11053
|
+
return super._repositionOnPcb(position);
|
|
11054
|
+
}
|
|
11022
11055
|
};
|
|
11023
11056
|
|
|
11024
11057
|
// lib/components/normal-components/Board.ts
|
|
@@ -13729,7 +13762,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
13729
13762
|
var package_default = {
|
|
13730
13763
|
name: "@tscircuit/core",
|
|
13731
13764
|
type: "module",
|
|
13732
|
-
version: "0.0.
|
|
13765
|
+
version: "0.0.657",
|
|
13733
13766
|
types: "dist/index.d.ts",
|
|
13734
13767
|
main: "dist/index.js",
|
|
13735
13768
|
module: "dist/index.js",
|