@tscircuit/core 0.0.122 → 0.0.123
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 -1
- package/dist/index.js +46 -5
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Matrix } from 'transformation-matrix';
|
|
|
8
8
|
import * as _tscircuit_props from '@tscircuit/props';
|
|
9
9
|
import { traceProps, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, smtPadProps, traceHintProps, viaProps, batteryProps } from '@tscircuit/props';
|
|
10
10
|
|
|
11
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortDiscovery", "PortMatching", "SourceTraceRender", "SchematicComponentRender", "
|
|
11
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortDiscovery", "PortMatching", "SourceTraceRender", "SchematicComponentRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbTraceRender", "PcbTraceHintRender", "PcbRouteNetIslands", "PcbComponentSizeCalculation", "CadModelRender"];
|
|
12
12
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
13
13
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
14
14
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
@@ -598,6 +598,10 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
|
|
|
598
598
|
x: number;
|
|
599
599
|
y: number;
|
|
600
600
|
};
|
|
601
|
+
_getGlobalSchematicPositionAfterLayout(): {
|
|
602
|
+
x: number;
|
|
603
|
+
y: number;
|
|
604
|
+
};
|
|
601
605
|
/**
|
|
602
606
|
* Smtpads and platedholes call this method to register themselves as a match
|
|
603
607
|
* for this port. All the matching is done by primitives other than the Port,
|
|
@@ -720,6 +724,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
|
|
|
720
724
|
componentName: string;
|
|
721
725
|
};
|
|
722
726
|
doInitialCreateTraceHintsFromProps(): void;
|
|
727
|
+
doInitialSchematicLayout(): void;
|
|
723
728
|
}
|
|
724
729
|
|
|
725
730
|
declare class Board extends Group<typeof boardProps> {
|
|
@@ -746,6 +751,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
746
751
|
routingDisabled: z.ZodOptional<z.ZodBoolean>;
|
|
747
752
|
children: z.ZodAny;
|
|
748
753
|
defaultTraceWidth: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
754
|
+
schAutoLayoutEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
749
755
|
}, "strip", z.ZodTypeAny, {
|
|
750
756
|
pcbX: number;
|
|
751
757
|
pcbY: number;
|
|
@@ -755,6 +761,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
755
761
|
layout?: any;
|
|
756
762
|
routingDisabled?: boolean | undefined;
|
|
757
763
|
defaultTraceWidth?: number | undefined;
|
|
764
|
+
schAutoLayoutEnabled?: boolean | undefined;
|
|
758
765
|
outline?: {
|
|
759
766
|
x: number;
|
|
760
767
|
y: number;
|
|
@@ -768,6 +775,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
768
775
|
layout?: any;
|
|
769
776
|
routingDisabled?: boolean | undefined;
|
|
770
777
|
defaultTraceWidth?: string | number | undefined;
|
|
778
|
+
schAutoLayoutEnabled?: boolean | undefined;
|
|
771
779
|
outline?: {
|
|
772
780
|
x: string | number;
|
|
773
781
|
y: string | number;
|
package/dist/index.js
CHANGED
|
@@ -60,8 +60,8 @@ var orderedRenderPhases = [
|
|
|
60
60
|
"PortMatching",
|
|
61
61
|
"SourceTraceRender",
|
|
62
62
|
"SchematicComponentRender",
|
|
63
|
-
"SchematicLayout",
|
|
64
63
|
"SchematicPortRender",
|
|
64
|
+
"SchematicLayout",
|
|
65
65
|
"SchematicTraceRender",
|
|
66
66
|
"PcbComponentRender",
|
|
67
67
|
"PcbPrimitiveRender",
|
|
@@ -1530,6 +1530,20 @@ var Port = class extends PrimitiveComponent {
|
|
|
1530
1530
|
);
|
|
1531
1531
|
return applyToPoint4(transform, this.schematicSymbolPortDef);
|
|
1532
1532
|
}
|
|
1533
|
+
_getGlobalSchematicPositionAfterLayout() {
|
|
1534
|
+
const { db } = this.root;
|
|
1535
|
+
if (!this.schematic_port_id) {
|
|
1536
|
+
throw new Error(
|
|
1537
|
+
`Can't get schematic port position after layout, no schematic_port_id`
|
|
1538
|
+
);
|
|
1539
|
+
}
|
|
1540
|
+
const schematic_port = db.schematic_port.get(this.schematic_port_id);
|
|
1541
|
+
if (!schematic_port)
|
|
1542
|
+
throw new Error(
|
|
1543
|
+
`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`
|
|
1544
|
+
);
|
|
1545
|
+
return schematic_port.center;
|
|
1546
|
+
}
|
|
1533
1547
|
/**
|
|
1534
1548
|
* Smtpads and platedholes call this method to register themselves as a match
|
|
1535
1549
|
* for this port. All the matching is done by primitives other than the Port,
|
|
@@ -2378,6 +2392,7 @@ var TraceHint = class extends PrimitiveComponent {
|
|
|
2378
2392
|
};
|
|
2379
2393
|
|
|
2380
2394
|
// lib/components/primitive-components/Group.ts
|
|
2395
|
+
import * as SAL from "@tscircuit/schematic-autolayout";
|
|
2381
2396
|
var Group = class extends NormalComponent {
|
|
2382
2397
|
get config() {
|
|
2383
2398
|
return {
|
|
@@ -2401,6 +2416,32 @@ var Group = class extends NormalComponent {
|
|
|
2401
2416
|
);
|
|
2402
2417
|
}
|
|
2403
2418
|
}
|
|
2419
|
+
doInitialSchematicLayout() {
|
|
2420
|
+
if (!this.isSubcircuit) return;
|
|
2421
|
+
const props = this._parsedProps;
|
|
2422
|
+
if (!props.schAutoLayoutEnabled) return;
|
|
2423
|
+
const { db } = this.root;
|
|
2424
|
+
const descendants = this.getDescendants();
|
|
2425
|
+
const components = [];
|
|
2426
|
+
const ports = [];
|
|
2427
|
+
for (const descendant of descendants) {
|
|
2428
|
+
if ("schematic_component_id" in descendant) {
|
|
2429
|
+
const component = db.schematic_component.get(
|
|
2430
|
+
descendant.schematic_component_id
|
|
2431
|
+
);
|
|
2432
|
+
if (component) {
|
|
2433
|
+
const schPorts = db.schematic_port.list().filter(
|
|
2434
|
+
(p) => p.schematic_component_id === component.schematic_component_id
|
|
2435
|
+
);
|
|
2436
|
+
components.push(component);
|
|
2437
|
+
ports.push(...schPorts);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
const scene = SAL.convertSoupToScene(db.toArray());
|
|
2442
|
+
const laidOutScene = SAL.ascendingCentralLrBug1(scene);
|
|
2443
|
+
SAL.mutateSoupForScene(db.toArray(), laidOutScene);
|
|
2444
|
+
}
|
|
2404
2445
|
};
|
|
2405
2446
|
|
|
2406
2447
|
// lib/components/normal-components/Board.ts
|
|
@@ -3070,7 +3111,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3070
3111
|
for (const { port } of ports) {
|
|
3071
3112
|
connection.pointsToConnect.push({
|
|
3072
3113
|
...projectPointInDirection(
|
|
3073
|
-
port.
|
|
3114
|
+
port._getGlobalSchematicPositionAfterLayout(),
|
|
3074
3115
|
port.facingDirection,
|
|
3075
3116
|
0.1501
|
|
3076
3117
|
),
|
|
@@ -3080,7 +3121,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3080
3121
|
const bounds = computeObstacleBounds(obstacles);
|
|
3081
3122
|
const simpleRouteJsonInput = {
|
|
3082
3123
|
minTraceWidth: 0.1,
|
|
3083
|
-
obstacles,
|
|
3124
|
+
obstacles: [],
|
|
3125
|
+
// leave empty to force traces to draw
|
|
3084
3126
|
connections: [connection],
|
|
3085
3127
|
bounds,
|
|
3086
3128
|
layerCount: 1
|
|
@@ -3088,10 +3130,9 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3088
3130
|
const autorouter = new IJumpAutorouter({
|
|
3089
3131
|
input: simpleRouteJsonInput
|
|
3090
3132
|
});
|
|
3091
|
-
const results = autorouter.
|
|
3133
|
+
const results = autorouter.solveAndMapToTraces();
|
|
3092
3134
|
if (results.length === 0) return;
|
|
3093
3135
|
const [result] = results;
|
|
3094
|
-
if (!result.solved) return;
|
|
3095
3136
|
const { route } = result;
|
|
3096
3137
|
const edges = [];
|
|
3097
3138
|
for (let i = 0; i < route.length - 1; i++) {
|
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.123",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -35,10 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@lume/kiwi": "^0.4.3",
|
|
38
|
-
"@tscircuit/footprinter": "^0.0.
|
|
38
|
+
"@tscircuit/footprinter": "^0.0.77",
|
|
39
39
|
"@tscircuit/infgrid-ijump-astar": "^0.0.21",
|
|
40
40
|
"@tscircuit/math-utils": "^0.0.4",
|
|
41
|
-
"@tscircuit/props": "^0.0.
|
|
41
|
+
"@tscircuit/props": "^0.0.75",
|
|
42
|
+
"@tscircuit/schematic-autolayout": "^0.0.5",
|
|
42
43
|
"@tscircuit/soup-util": "^0.0.33",
|
|
43
44
|
"circuit-json": "^0.0.86",
|
|
44
45
|
"circuit-json-to-connectivity-map": "^0.0.17",
|