@tscircuit/core 0.0.248 → 0.0.250
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 -0
- package/dist/index.js +51 -7
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -444,6 +444,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
444
444
|
} | undefined;
|
|
445
445
|
}>, "many">>;
|
|
446
446
|
schDisplayLabel: z.ZodOptional<z.ZodString>;
|
|
447
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
447
448
|
}, {
|
|
448
449
|
path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<{
|
|
449
450
|
getPortSelector: () => string;
|
|
@@ -468,6 +469,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
468
469
|
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
469
470
|
}[] | undefined;
|
|
470
471
|
schDisplayLabel?: string | undefined;
|
|
472
|
+
maxLength?: number | undefined;
|
|
471
473
|
}, {
|
|
472
474
|
path: (string | {
|
|
473
475
|
getPortSelector: () => string;
|
|
@@ -488,6 +490,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
488
490
|
} | undefined;
|
|
489
491
|
}[] | undefined;
|
|
490
492
|
schDisplayLabel?: string | undefined;
|
|
493
|
+
maxLength?: number | undefined;
|
|
491
494
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
492
495
|
key: z.ZodOptional<z.ZodString>;
|
|
493
496
|
thickness: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
@@ -531,6 +534,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
531
534
|
} | undefined;
|
|
532
535
|
}>, "many">>;
|
|
533
536
|
schDisplayLabel: z.ZodOptional<z.ZodString>;
|
|
537
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
534
538
|
}, {
|
|
535
539
|
from: z.ZodUnion<[z.ZodString, z.ZodType<{
|
|
536
540
|
getPortSelector: () => string;
|
|
@@ -563,6 +567,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
563
567
|
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
564
568
|
}[] | undefined;
|
|
565
569
|
schDisplayLabel?: string | undefined;
|
|
570
|
+
maxLength?: number | undefined;
|
|
566
571
|
}, {
|
|
567
572
|
from: string | {
|
|
568
573
|
getPortSelector: () => string;
|
|
@@ -586,6 +591,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
586
591
|
} | undefined;
|
|
587
592
|
}[] | undefined;
|
|
588
593
|
schDisplayLabel?: string | undefined;
|
|
594
|
+
maxLength?: number | undefined;
|
|
589
595
|
}>]>;
|
|
590
596
|
componentName: string;
|
|
591
597
|
};
|
|
@@ -1549,6 +1555,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
|
|
|
1549
1555
|
decouplingTo: zod.ZodOptional<zod.ZodString>;
|
|
1550
1556
|
bypassFor: zod.ZodOptional<zod.ZodString>;
|
|
1551
1557
|
bypassTo: zod.ZodOptional<zod.ZodString>;
|
|
1558
|
+
maxDecouplingTraceLength: zod.ZodOptional<zod.ZodNumber>;
|
|
1552
1559
|
}>, "strip", zod.ZodTypeAny, {
|
|
1553
1560
|
name: string;
|
|
1554
1561
|
capacitance: number;
|
|
@@ -1622,6 +1629,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
|
|
|
1622
1629
|
decouplingTo?: string | undefined;
|
|
1623
1630
|
bypassFor?: string | undefined;
|
|
1624
1631
|
bypassTo?: string | undefined;
|
|
1632
|
+
maxDecouplingTraceLength?: number | undefined;
|
|
1625
1633
|
}, {
|
|
1626
1634
|
name: string;
|
|
1627
1635
|
capacitance: string | number;
|
|
@@ -1697,6 +1705,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
|
|
|
1697
1705
|
decouplingTo?: string | undefined;
|
|
1698
1706
|
bypassFor?: string | undefined;
|
|
1699
1707
|
bypassTo?: string | undefined;
|
|
1708
|
+
maxDecouplingTraceLength?: number | undefined;
|
|
1700
1709
|
}>;
|
|
1701
1710
|
sourceFtype: "simple_capacitor";
|
|
1702
1711
|
};
|
package/dist/index.js
CHANGED
|
@@ -2916,8 +2916,9 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2916
2916
|
primaryPortLabels[port] = Array.isArray(label) ? label[0] : label;
|
|
2917
2917
|
}
|
|
2918
2918
|
}
|
|
2919
|
+
const center = this._getGlobalSchematicPositionBeforeLayout();
|
|
2919
2920
|
const schematic_component2 = db.schematic_component.insert({
|
|
2920
|
-
center
|
|
2921
|
+
center,
|
|
2921
2922
|
rotation: props.schRotation ?? 0,
|
|
2922
2923
|
size: dimensions.getSize(),
|
|
2923
2924
|
port_arrangement: underscorifyPortArrangement(
|
|
@@ -2938,8 +2939,8 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2938
2939
|
anchor: "left",
|
|
2939
2940
|
rotation: 0,
|
|
2940
2941
|
position: {
|
|
2941
|
-
x: hasTopOrBottomPins ?
|
|
2942
|
-
y: hasTopOrBottomPins ?
|
|
2942
|
+
x: hasTopOrBottomPins ? center.x + (schematic_box_width ?? 0) / 2 + 0.1 : center.x - (schematic_box_width ?? 0) / 2,
|
|
2943
|
+
y: hasTopOrBottomPins ? center.y + (schematic_box_height ?? 0) / 2 + 0.35 : center.y - (schematic_box_height ?? 0) / 2 - 0.13
|
|
2943
2944
|
},
|
|
2944
2945
|
color: "#006464"
|
|
2945
2946
|
});
|
|
@@ -2949,8 +2950,8 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2949
2950
|
anchor: "left",
|
|
2950
2951
|
rotation: 0,
|
|
2951
2952
|
position: {
|
|
2952
|
-
x: hasTopOrBottomPins ?
|
|
2953
|
-
y: hasTopOrBottomPins ?
|
|
2953
|
+
x: hasTopOrBottomPins ? center.x + (schematic_box_width ?? 0) / 2 + 0.1 : center.x - (schematic_box_width ?? 0) / 2,
|
|
2954
|
+
y: hasTopOrBottomPins ? center.y + (schematic_box_height ?? 0) / 2 + 0.55 : center.y + (schematic_box_height ?? 0) / 2 + 0.13
|
|
2954
2955
|
},
|
|
2955
2956
|
color: "#006464"
|
|
2956
2957
|
});
|
|
@@ -3916,6 +3917,25 @@ var mergeRoutes = (routes) => {
|
|
|
3916
3917
|
return merged;
|
|
3917
3918
|
};
|
|
3918
3919
|
|
|
3920
|
+
// lib/components/primitive-components/Trace/compute-trace-length.ts
|
|
3921
|
+
function getTraceLength(route) {
|
|
3922
|
+
let totalLength = 0;
|
|
3923
|
+
for (let i = 0; i < route.length; i++) {
|
|
3924
|
+
const point = route[i];
|
|
3925
|
+
if (point.route_type === "wire") {
|
|
3926
|
+
const nextPoint = route[i + 1];
|
|
3927
|
+
if (nextPoint) {
|
|
3928
|
+
const dx = nextPoint.x - point.x;
|
|
3929
|
+
const dy = nextPoint.y - point.y;
|
|
3930
|
+
totalLength += Math.sqrt(dx * dx + dy * dy);
|
|
3931
|
+
}
|
|
3932
|
+
} else if (point.route_type === "via") {
|
|
3933
|
+
totalLength += 1.6;
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
return totalLength;
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3919
3939
|
// lib/utils/getClosest.ts
|
|
3920
3940
|
var getDistance = (a, b) => {
|
|
3921
3941
|
const aPos = "_getGlobalPcbPositionBeforeLayout" in a ? a._getGlobalPcbPositionBeforeLayout() : a;
|
|
@@ -4326,6 +4346,23 @@ var createDownwardNetLabelGroundSymbol = ({
|
|
|
4326
4346
|
});
|
|
4327
4347
|
};
|
|
4328
4348
|
|
|
4349
|
+
// lib/components/primitive-components/Trace/get-max-length-from-conn ected-capacitors.ts
|
|
4350
|
+
var getMaxLengthFromConnectedCapacitors = (ports, { db }) => {
|
|
4351
|
+
const capacitorMaxLengths = ports.map((port) => {
|
|
4352
|
+
const sourcePort = db.source_port.get(port.source_port_id);
|
|
4353
|
+
if (!sourcePort?.source_component_id) return null;
|
|
4354
|
+
const sourceComponent = db.source_component.get(
|
|
4355
|
+
sourcePort.source_component_id
|
|
4356
|
+
);
|
|
4357
|
+
if (sourceComponent?.ftype === "simple_capacitor") {
|
|
4358
|
+
return sourceComponent.max_decoupling_trace_length;
|
|
4359
|
+
}
|
|
4360
|
+
return null;
|
|
4361
|
+
}).filter((length) => length !== null);
|
|
4362
|
+
if (capacitorMaxLengths.length === 0) return void 0;
|
|
4363
|
+
return Math.min(...capacitorMaxLengths);
|
|
4364
|
+
};
|
|
4365
|
+
|
|
4329
4366
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
4330
4367
|
var portToObjective = (port) => {
|
|
4331
4368
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
@@ -4471,7 +4508,11 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4471
4508
|
const nets = this._findConnectedNets().nets;
|
|
4472
4509
|
const trace = db.source_trace.insert({
|
|
4473
4510
|
connected_source_port_ids: ports.map((p) => p.port.source_port_id),
|
|
4474
|
-
connected_source_net_ids: nets.map((n) => n.source_net_id)
|
|
4511
|
+
connected_source_net_ids: nets.map((n) => n.source_net_id),
|
|
4512
|
+
max_length: getMaxLengthFromConnectedCapacitors(
|
|
4513
|
+
ports.map((p) => p.port),
|
|
4514
|
+
{ db }
|
|
4515
|
+
) ?? props.maxLength
|
|
4475
4516
|
});
|
|
4476
4517
|
this.source_trace_id = trace.source_trace_id;
|
|
4477
4518
|
}
|
|
@@ -4721,9 +4762,11 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4721
4762
|
routes.push(trace.route);
|
|
4722
4763
|
}
|
|
4723
4764
|
const mergedRoute = mergeRoutes(routes);
|
|
4765
|
+
const traceLength = getTraceLength(mergedRoute);
|
|
4724
4766
|
const pcb_trace = db.pcb_trace.insert({
|
|
4725
4767
|
route: mergedRoute,
|
|
4726
|
-
source_trace_id: this.source_trace_id
|
|
4768
|
+
source_trace_id: this.source_trace_id,
|
|
4769
|
+
trace_length: traceLength
|
|
4727
4770
|
});
|
|
4728
4771
|
this._portsRoutedOnPcb = ports;
|
|
4729
4772
|
this.pcb_trace_id = pcb_trace.pcb_trace_id;
|
|
@@ -5063,6 +5106,7 @@ var Capacitor = class extends NormalComponent {
|
|
|
5063
5106
|
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
5064
5107
|
supplier_part_numbers: props.supplierPartNumbers,
|
|
5065
5108
|
capacitance: props.capacitance,
|
|
5109
|
+
max_decoupling_trace_length: props.maxDecouplingTraceLength,
|
|
5066
5110
|
display_capacitance: this._getSchematicSymbolDisplayValue()
|
|
5067
5111
|
});
|
|
5068
5112
|
this.source_component_id = source_component.source_component_id;
|
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.250",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"@tscircuit/footprinter": "^0.0.95",
|
|
44
44
|
"@tscircuit/infgrid-ijump-astar": "^0.0.26",
|
|
45
45
|
"@tscircuit/math-utils": "^0.0.5",
|
|
46
|
-
"@tscircuit/props": "^0.0.
|
|
46
|
+
"@tscircuit/props": "^0.0.124",
|
|
47
47
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
48
48
|
"@tscircuit/soup-util": "^0.0.41",
|
|
49
|
-
"circuit-json": "^0.0.
|
|
49
|
+
"circuit-json": "^0.0.126",
|
|
50
50
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
51
51
|
"format-si-unit": "^0.0.2",
|
|
52
52
|
"nanoid": "^5.0.7",
|