@tscircuit/core 0.0.605 → 0.0.607
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 +4 -1
- package/dist/index.js +168 -32
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
|
|
|
11
11
|
import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
|
|
12
12
|
import { GraphicsObject } from 'graphics-debug';
|
|
13
13
|
|
|
14
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "
|
|
14
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
|
|
15
15
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
16
16
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
17
17
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
@@ -1154,6 +1154,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
1154
1154
|
pcbGridRowGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
|
|
1155
1155
|
pcbGridColumnGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
|
|
1156
1156
|
pcbFlex: zod.ZodOptional<zod.ZodUnion<[zod.ZodBoolean, zod.ZodString]>>;
|
|
1157
|
+
pcbFlexGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
|
|
1157
1158
|
pcbFlexDirection: zod.ZodOptional<zod.ZodEnum<["row", "column"]>>;
|
|
1158
1159
|
pcbAlignItems: zod.ZodOptional<zod.ZodEnum<["start", "center", "end", "stretch"]>>;
|
|
1159
1160
|
pcbJustifyContent: zod.ZodOptional<zod.ZodEnum<["start", "center", "end", "stretch", "space-between", "space-around", "space-evenly"]>>;
|
|
@@ -1803,6 +1804,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
1803
1804
|
pcbGridRowGap?: string | number | undefined;
|
|
1804
1805
|
pcbGridColumnGap?: string | number | undefined;
|
|
1805
1806
|
pcbFlex?: string | boolean | undefined;
|
|
1807
|
+
pcbFlexGap?: string | number | undefined;
|
|
1806
1808
|
pcbFlexDirection?: "row" | "column" | undefined;
|
|
1807
1809
|
pcbAlignItems?: "center" | "start" | "end" | "stretch" | undefined;
|
|
1808
1810
|
pcbJustifyContent?: "center" | "start" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
|
|
@@ -2013,6 +2015,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
2013
2015
|
pcbGridRowGap?: string | number | undefined;
|
|
2014
2016
|
pcbGridColumnGap?: string | number | undefined;
|
|
2015
2017
|
pcbFlex?: string | boolean | undefined;
|
|
2018
|
+
pcbFlexGap?: string | number | undefined;
|
|
2016
2019
|
pcbFlexDirection?: "row" | "column" | undefined;
|
|
2017
2020
|
pcbAlignItems?: "center" | "start" | "end" | "stretch" | undefined;
|
|
2018
2021
|
pcbJustifyContent?: "center" | "start" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
|
package/dist/index.js
CHANGED
|
@@ -109,8 +109,8 @@ var orderedRenderPhases = [
|
|
|
109
109
|
"PcbFootprintLayout",
|
|
110
110
|
"PcbPortRender",
|
|
111
111
|
"PcbPortAttachment",
|
|
112
|
-
"PcbLayout",
|
|
113
112
|
"PcbComponentSizeCalculation",
|
|
113
|
+
"PcbLayout",
|
|
114
114
|
"PcbBoardAutoSize",
|
|
115
115
|
"PcbTraceHintRender",
|
|
116
116
|
"PcbTraceRender",
|
|
@@ -4154,7 +4154,7 @@ var getMaxLengthFromConnectedCapacitors = (ports, { db }) => {
|
|
|
4154
4154
|
return sourceComponent.max_decoupling_trace_length;
|
|
4155
4155
|
}
|
|
4156
4156
|
return null;
|
|
4157
|
-
}).filter((
|
|
4157
|
+
}).filter((length5) => length5 !== null);
|
|
4158
4158
|
if (capacitorMaxLengths.length === 0) return void 0;
|
|
4159
4159
|
return Math.min(...capacitorMaxLengths);
|
|
4160
4160
|
};
|
|
@@ -8284,39 +8284,172 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
8284
8284
|
};
|
|
8285
8285
|
|
|
8286
8286
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutFlex.ts
|
|
8287
|
-
import
|
|
8288
|
-
import {
|
|
8287
|
+
import "@tscircuit/circuit-json-flex";
|
|
8288
|
+
import {
|
|
8289
|
+
getCircuitJsonTree,
|
|
8290
|
+
repositionPcbComponentTo,
|
|
8291
|
+
repositionPcbGroupTo
|
|
8292
|
+
} from "@tscircuit/circuit-json-util";
|
|
8293
|
+
import { RootFlexBox } from "@tscircuit/miniflex";
|
|
8294
|
+
import { getMinimumFlexContainer } from "@tscircuit/circuit-json-flex";
|
|
8295
|
+
import { length as length4 } from "circuit-json";
|
|
8296
|
+
var getSizeOfTreeNodeChild = (db, child) => {
|
|
8297
|
+
const { sourceComponent, sourceGroup } = child;
|
|
8298
|
+
if (child.nodeType === "component") {
|
|
8299
|
+
const pcbComponent = db.pcb_component.getWhere({
|
|
8300
|
+
source_component_id: sourceComponent?.source_component_id
|
|
8301
|
+
});
|
|
8302
|
+
if (!pcbComponent) return null;
|
|
8303
|
+
return {
|
|
8304
|
+
width: pcbComponent.width,
|
|
8305
|
+
height: pcbComponent.height
|
|
8306
|
+
};
|
|
8307
|
+
}
|
|
8308
|
+
if (child.nodeType === "group") {
|
|
8309
|
+
const pcbGroup = db.pcb_group.getWhere({
|
|
8310
|
+
source_group_id: sourceGroup?.source_group_id
|
|
8311
|
+
});
|
|
8312
|
+
if (!pcbGroup) return null;
|
|
8313
|
+
return {
|
|
8314
|
+
width: pcbGroup.width,
|
|
8315
|
+
height: pcbGroup.height
|
|
8316
|
+
};
|
|
8317
|
+
}
|
|
8318
|
+
return null;
|
|
8319
|
+
};
|
|
8289
8320
|
var Group_doInitialPcbLayoutFlex = (group) => {
|
|
8290
8321
|
const { db } = group.root;
|
|
8291
8322
|
const { _parsedProps: props } = group;
|
|
8292
|
-
const
|
|
8323
|
+
const tree = getCircuitJsonTree(db.toArray(), {
|
|
8293
8324
|
source_group_id: group.source_group_id
|
|
8294
8325
|
});
|
|
8295
|
-
const
|
|
8296
|
-
const
|
|
8297
|
-
const
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8326
|
+
const rawJustify = props.pcbJustifyContent ?? props.justifyContent;
|
|
8327
|
+
const rawAlign = props.pcbAlignItems ?? props.alignItems;
|
|
8328
|
+
const rawGap = props.pcbFlexGap ?? props.pcbGap ?? props.gap;
|
|
8329
|
+
const direction = props.pcbFlexDirection ?? "row";
|
|
8330
|
+
const justifyContent = {
|
|
8331
|
+
start: "flex-start",
|
|
8332
|
+
end: "flex-end",
|
|
8333
|
+
"flex-start": "flex-start",
|
|
8334
|
+
"flex-end": "flex-end",
|
|
8335
|
+
stretch: "space-between",
|
|
8336
|
+
"space-between": "space-between",
|
|
8337
|
+
"space-around": "space-around",
|
|
8338
|
+
"space-evenly": "space-evenly",
|
|
8339
|
+
center: "center"
|
|
8340
|
+
}[rawJustify ?? "space-between"];
|
|
8341
|
+
const alignItems = {
|
|
8342
|
+
start: "flex-start",
|
|
8343
|
+
end: "flex-end",
|
|
8344
|
+
"flex-start": "flex-start",
|
|
8345
|
+
"flex-end": "flex-end",
|
|
8346
|
+
stretch: "stretch",
|
|
8347
|
+
center: "center"
|
|
8348
|
+
}[rawAlign ?? "center"];
|
|
8349
|
+
if (!justifyContent) {
|
|
8350
|
+
throw new Error(`Invalid justifyContent value: "${rawJustify}"`);
|
|
8351
|
+
}
|
|
8352
|
+
if (!alignItems) {
|
|
8353
|
+
throw new Error(`Invalid alignItems value: "${rawAlign}"`);
|
|
8354
|
+
}
|
|
8355
|
+
let rowGap = 0;
|
|
8356
|
+
let columnGap = 0;
|
|
8357
|
+
if (typeof rawGap === "object") {
|
|
8358
|
+
rowGap = rawGap.y ?? 0;
|
|
8359
|
+
columnGap = rawGap.x ?? 0;
|
|
8360
|
+
} else if (typeof rawGap === "number") {
|
|
8361
|
+
rowGap = rawGap;
|
|
8362
|
+
columnGap = rawGap;
|
|
8363
|
+
} else if (typeof rawGap === "string") {
|
|
8364
|
+
rowGap = length4.parse(rawGap);
|
|
8365
|
+
columnGap = length4.parse(rawGap);
|
|
8366
|
+
}
|
|
8367
|
+
let minFlexContainer;
|
|
8368
|
+
let width = props.width ?? props.pcbWidth ?? void 0;
|
|
8369
|
+
let height = props.height ?? props.pcbHeight ?? void 0;
|
|
8370
|
+
const isInline = Boolean(width === void 0 || height === void 0);
|
|
8371
|
+
if (isInline) {
|
|
8372
|
+
minFlexContainer = getMinimumFlexContainer(
|
|
8373
|
+
tree.childNodes.map((child) => getSizeOfTreeNodeChild(db, child)).filter((size) => size !== null),
|
|
8374
|
+
{
|
|
8375
|
+
alignItems,
|
|
8376
|
+
justifyContent,
|
|
8377
|
+
direction,
|
|
8378
|
+
rowGap,
|
|
8379
|
+
columnGap
|
|
8380
|
+
}
|
|
8318
8381
|
);
|
|
8382
|
+
width = minFlexContainer.width;
|
|
8383
|
+
height = minFlexContainer.height;
|
|
8384
|
+
}
|
|
8385
|
+
const flexBox = new RootFlexBox(width, height, {
|
|
8386
|
+
alignItems,
|
|
8387
|
+
justifyContent,
|
|
8388
|
+
direction,
|
|
8389
|
+
rowGap,
|
|
8390
|
+
columnGap
|
|
8391
|
+
});
|
|
8392
|
+
for (const child of tree.childNodes) {
|
|
8393
|
+
const size = getSizeOfTreeNodeChild(db, child);
|
|
8394
|
+
flexBox.addChild({
|
|
8395
|
+
metadata: child,
|
|
8396
|
+
// TODO these should be minWidth/minHeight
|
|
8397
|
+
width: size?.width ?? 0,
|
|
8398
|
+
height: size?.height ?? 0,
|
|
8399
|
+
// TODO allow overriding flexBasis
|
|
8400
|
+
flexBasis: !size ? void 0 : direction === "row" ? size.width : size.height
|
|
8401
|
+
// TODO alignSelf, flexGrow, flexShrink etc.
|
|
8402
|
+
});
|
|
8403
|
+
}
|
|
8404
|
+
flexBox.build();
|
|
8405
|
+
const allCircuitJson = db.toArray();
|
|
8406
|
+
const bounds = {
|
|
8407
|
+
minX: Infinity,
|
|
8408
|
+
minY: Infinity,
|
|
8409
|
+
maxX: -Infinity,
|
|
8410
|
+
maxY: -Infinity,
|
|
8411
|
+
width: 0,
|
|
8412
|
+
height: 0
|
|
8413
|
+
};
|
|
8414
|
+
for (const child of flexBox.children) {
|
|
8415
|
+
bounds.minX = Math.min(bounds.minX, child.position.x);
|
|
8416
|
+
bounds.minY = Math.min(bounds.minY, child.position.y);
|
|
8417
|
+
bounds.maxX = Math.max(bounds.maxX, child.position.x + child.size.width);
|
|
8418
|
+
bounds.maxY = Math.max(bounds.maxY, child.position.y + child.size.height);
|
|
8419
|
+
}
|
|
8420
|
+
bounds.width = bounds.maxX - bounds.minX;
|
|
8421
|
+
bounds.height = bounds.maxY - bounds.minY;
|
|
8422
|
+
const offset = {
|
|
8423
|
+
x: -(bounds.maxX + bounds.minX) / 2,
|
|
8424
|
+
y: -(bounds.maxY + bounds.minY) / 2
|
|
8425
|
+
};
|
|
8426
|
+
for (const child of flexBox.children) {
|
|
8427
|
+
const { sourceComponent, sourceGroup } = child.metadata;
|
|
8428
|
+
if (sourceComponent) {
|
|
8429
|
+
const pcbComponent = db.pcb_component.getWhere({
|
|
8430
|
+
source_component_id: sourceComponent.source_component_id
|
|
8431
|
+
});
|
|
8432
|
+
if (!pcbComponent) continue;
|
|
8433
|
+
repositionPcbComponentTo(allCircuitJson, pcbComponent.pcb_component_id, {
|
|
8434
|
+
x: child.position.x + child.size.width / 2 + offset.x,
|
|
8435
|
+
y: child.position.y + child.size.height / 2 + offset.y
|
|
8436
|
+
});
|
|
8437
|
+
}
|
|
8438
|
+
if (sourceGroup) {
|
|
8439
|
+
const pcbGroup = db.pcb_group.getWhere({
|
|
8440
|
+
source_group_id: sourceGroup.source_group_id
|
|
8441
|
+
});
|
|
8442
|
+
if (!pcbGroup) continue;
|
|
8443
|
+
repositionPcbGroupTo(allCircuitJson, sourceGroup.source_group_id, {
|
|
8444
|
+
x: child.position.x + child.size.width / 2 + offset.x,
|
|
8445
|
+
y: child.position.y + child.size.height / 2 + offset.y
|
|
8446
|
+
});
|
|
8447
|
+
}
|
|
8319
8448
|
}
|
|
8449
|
+
db.pcb_group.update(group.pcb_group_id, {
|
|
8450
|
+
width: bounds.width,
|
|
8451
|
+
height: bounds.height
|
|
8452
|
+
});
|
|
8320
8453
|
};
|
|
8321
8454
|
|
|
8322
8455
|
// lib/components/primitive-components/Group/Group.ts
|
|
@@ -8376,7 +8509,7 @@ var Group = class extends NormalComponent {
|
|
|
8376
8509
|
const { _parsedProps: props } = this;
|
|
8377
8510
|
const pcb_group = db.pcb_group.insert({
|
|
8378
8511
|
is_subcircuit: this.isSubcircuit,
|
|
8379
|
-
subcircuit_id: this.subcircuit_id,
|
|
8512
|
+
subcircuit_id: this.subcircuit_id ?? this.getSubcircuit()?.subcircuit_id,
|
|
8380
8513
|
name: this.name,
|
|
8381
8514
|
center: this._getGlobalPcbPositionBeforeLayout(),
|
|
8382
8515
|
width: 0,
|
|
@@ -9084,6 +9217,7 @@ var Board = class extends Group {
|
|
|
9084
9217
|
let maxY = -Infinity;
|
|
9085
9218
|
const descendantIds = getDescendantSubcircuitIds(db, this.subcircuit_id);
|
|
9086
9219
|
const allowedSubcircuitIds = /* @__PURE__ */ new Set([this.subcircuit_id, ...descendantIds]);
|
|
9220
|
+
console.log({ allowedSubcircuitIds });
|
|
9087
9221
|
const allPcbComponents = db.pcb_component.list().filter(
|
|
9088
9222
|
(c) => c.subcircuit_id && allowedSubcircuitIds.has(c.subcircuit_id)
|
|
9089
9223
|
);
|
|
@@ -11370,7 +11504,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
11370
11504
|
var package_default = {
|
|
11371
11505
|
name: "@tscircuit/core",
|
|
11372
11506
|
type: "module",
|
|
11373
|
-
version: "0.0.
|
|
11507
|
+
version: "0.0.606",
|
|
11374
11508
|
types: "dist/index.d.ts",
|
|
11375
11509
|
main: "dist/index.js",
|
|
11376
11510
|
module: "dist/index.js",
|
|
@@ -11395,13 +11529,14 @@ var package_default = {
|
|
|
11395
11529
|
"@biomejs/biome": "^1.8.3",
|
|
11396
11530
|
"@tscircuit/capacity-autorouter": "^0.0.100",
|
|
11397
11531
|
"@tscircuit/checks": "^0.0.64",
|
|
11398
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
11532
|
+
"@tscircuit/circuit-json-util": "^0.0.62",
|
|
11399
11533
|
"@tscircuit/footprinter": "^0.0.208",
|
|
11400
11534
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
11401
11535
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
11402
11536
|
"@tscircuit/log-soup": "^1.0.2",
|
|
11403
11537
|
"@tscircuit/math-utils": "^0.0.18",
|
|
11404
|
-
"@tscircuit/
|
|
11538
|
+
"@tscircuit/miniflex": "^0.0.4",
|
|
11539
|
+
"@tscircuit/props": "^0.0.276",
|
|
11405
11540
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
11406
11541
|
"@tscircuit/schematic-corpus": "^0.0.110",
|
|
11407
11542
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
@@ -11431,6 +11566,7 @@ var package_default = {
|
|
|
11431
11566
|
"react-dom": "^19.1.0",
|
|
11432
11567
|
"schematic-symbols": "^0.0.180",
|
|
11433
11568
|
"ts-expect": "^1.3.0",
|
|
11569
|
+
"@tscircuit/circuit-json-flex": "^0.0.3",
|
|
11434
11570
|
tsup: "^8.2.4"
|
|
11435
11571
|
},
|
|
11436
11572
|
peerDependencies: {
|
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.607",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"@biomejs/biome": "^1.8.3",
|
|
27
27
|
"@tscircuit/capacity-autorouter": "^0.0.100",
|
|
28
28
|
"@tscircuit/checks": "^0.0.64",
|
|
29
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
29
|
+
"@tscircuit/circuit-json-util": "^0.0.62",
|
|
30
30
|
"@tscircuit/footprinter": "^0.0.208",
|
|
31
31
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
32
32
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
33
33
|
"@tscircuit/log-soup": "^1.0.2",
|
|
34
34
|
"@tscircuit/math-utils": "^0.0.18",
|
|
35
|
-
"@tscircuit/
|
|
35
|
+
"@tscircuit/miniflex": "^0.0.4",
|
|
36
|
+
"@tscircuit/props": "^0.0.276",
|
|
36
37
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
37
38
|
"@tscircuit/schematic-corpus": "^0.0.110",
|
|
38
39
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"react-dom": "^19.1.0",
|
|
63
64
|
"schematic-symbols": "^0.0.180",
|
|
64
65
|
"ts-expect": "^1.3.0",
|
|
66
|
+
"@tscircuit/circuit-json-flex": "^0.0.3",
|
|
65
67
|
"tsup": "^8.2.4"
|
|
66
68
|
},
|
|
67
69
|
"peerDependencies": {
|