@tscircuit/core 0.0.651 → 0.0.652
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 +8 -1
- package/dist/index.js +116 -31
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -459,7 +459,7 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
459
459
|
doInitialAssignNameToUnnamedComponents(): void;
|
|
460
460
|
doInitialOptimizeSelectorCache(): void;
|
|
461
461
|
_cachedSelectAllQueries: Map<string, PrimitiveComponent[]>;
|
|
462
|
-
selectAll(selectorRaw: string):
|
|
462
|
+
selectAll<T extends PrimitiveComponent = PrimitiveComponent>(selectorRaw: string): T[];
|
|
463
463
|
_cachedSelectOneQueries: Map<string, PrimitiveComponent | null>;
|
|
464
464
|
selectOne<T = PrimitiveComponent>(selectorRaw: string, options?: {
|
|
465
465
|
type?: string;
|
|
@@ -956,11 +956,18 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
|
|
|
956
956
|
doInitialSourceParentAttachment(): void;
|
|
957
957
|
doInitialPcbPortRender(): void;
|
|
958
958
|
doInitialSchematicPortRender(): void;
|
|
959
|
+
_getSubcircuitConnectivityKey(): string | undefined;
|
|
959
960
|
_setPositionFromLayout(newCenter: {
|
|
960
961
|
x: number;
|
|
961
962
|
y: number;
|
|
962
963
|
}): void;
|
|
963
964
|
_hasMatchedPcbPrimitive(): boolean;
|
|
965
|
+
/**
|
|
966
|
+
* Return the text that should be used for the net label for this port if a
|
|
967
|
+
* trace can't be drawn. This net label text usually doesn't appear at this
|
|
968
|
+
* port, but appears at the port it connects to.
|
|
969
|
+
*/
|
|
970
|
+
_getNetLabelText(): string | undefined;
|
|
964
971
|
}
|
|
965
972
|
|
|
966
973
|
interface INormalComponent {
|
package/dist/index.js
CHANGED
|
@@ -1033,12 +1033,14 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1033
1033
|
_cachedSelectAllQueries = /* @__PURE__ */ new Map();
|
|
1034
1034
|
selectAll(selectorRaw) {
|
|
1035
1035
|
if (this._cachedSelectAllQueries.has(selectorRaw)) {
|
|
1036
|
-
return this._cachedSelectAllQueries.get(
|
|
1037
|
-
selectorRaw
|
|
1038
|
-
);
|
|
1036
|
+
return this._cachedSelectAllQueries.get(selectorRaw);
|
|
1039
1037
|
}
|
|
1040
1038
|
const selector = preprocessSelector(selectorRaw);
|
|
1041
|
-
const result = selectAll(
|
|
1039
|
+
const result = selectAll(
|
|
1040
|
+
selector,
|
|
1041
|
+
this,
|
|
1042
|
+
cssSelectOptionsInsideSubcircuit
|
|
1043
|
+
);
|
|
1042
1044
|
if (result.length > 0) {
|
|
1043
1045
|
this._cachedSelectAllQueries.set(selectorRaw, result);
|
|
1044
1046
|
return result;
|
|
@@ -3305,6 +3307,9 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
3305
3307
|
});
|
|
3306
3308
|
this.schematic_port_id = schematic_port.schematic_port_id;
|
|
3307
3309
|
}
|
|
3310
|
+
_getSubcircuitConnectivityKey() {
|
|
3311
|
+
return this.root?.db.source_port.get(this.source_port_id)?.subcircuit_connectivity_map_key;
|
|
3312
|
+
}
|
|
3308
3313
|
_setPositionFromLayout(newCenter) {
|
|
3309
3314
|
const { db } = this.root;
|
|
3310
3315
|
if (!this.pcb_port_id) return;
|
|
@@ -3316,6 +3321,14 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
3316
3321
|
_hasMatchedPcbPrimitive() {
|
|
3317
3322
|
return this.matchedComponents.some((c) => c.isPcbPrimitive);
|
|
3318
3323
|
}
|
|
3324
|
+
/**
|
|
3325
|
+
* Return the text that should be used for the net label for this port if a
|
|
3326
|
+
* trace can't be drawn. This net label text usually doesn't appear at this
|
|
3327
|
+
* port, but appears at the port it connects to.
|
|
3328
|
+
*/
|
|
3329
|
+
_getNetLabelText() {
|
|
3330
|
+
return `${this.parent?.props.name}_${this.props.name}`;
|
|
3331
|
+
}
|
|
3319
3332
|
};
|
|
3320
3333
|
|
|
3321
3334
|
// lib/utils/getPortFromHints.ts
|
|
@@ -10041,6 +10054,12 @@ var oppositeSide = (input) => {
|
|
|
10041
10054
|
}
|
|
10042
10055
|
};
|
|
10043
10056
|
|
|
10057
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getNetNameFromPorts.ts
|
|
10058
|
+
var getNetNameFromPorts = (ports) => {
|
|
10059
|
+
const netName = ports.map((p) => p._getNetLabelText()).join("/");
|
|
10060
|
+
return netName;
|
|
10061
|
+
};
|
|
10062
|
+
|
|
10044
10063
|
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyNetLabelPlacements.ts
|
|
10045
10064
|
function applyNetLabelPlacements(args) {
|
|
10046
10065
|
const {
|
|
@@ -10050,7 +10069,10 @@ function applyNetLabelPlacements(args) {
|
|
|
10050
10069
|
allScks,
|
|
10051
10070
|
allSourceAndSchematicPortIdsInScope,
|
|
10052
10071
|
schPortIdToSourcePortId,
|
|
10053
|
-
userNetIdToSck
|
|
10072
|
+
userNetIdToSck,
|
|
10073
|
+
pinIdToSchematicPortId,
|
|
10074
|
+
schematicPortIdsWithPreExistingNetLabels,
|
|
10075
|
+
schematicPortIdsWithRoutedTraces
|
|
10054
10076
|
} = args;
|
|
10055
10077
|
const { db } = group.root;
|
|
10056
10078
|
const netLabelPlacements = solver.netLabelPlacementSolver?.netLabelPlacements ?? [];
|
|
@@ -10062,18 +10084,38 @@ function applyNetLabelPlacements(args) {
|
|
|
10062
10084
|
const orientation = placement.orientation;
|
|
10063
10085
|
const anchor_side = oppositeSide(orientation);
|
|
10064
10086
|
const sourceNet = placementSck ? sckToSourceNet.get(placementSck) : void 0;
|
|
10065
|
-
|
|
10087
|
+
const schPortIds = placement.pinIds.map(
|
|
10088
|
+
(pinId) => pinIdToSchematicPortId.get(pinId)
|
|
10089
|
+
);
|
|
10090
|
+
if (schPortIds.some(
|
|
10091
|
+
(schPortId) => schematicPortIdsWithPreExistingNetLabels.has(schPortId)
|
|
10092
|
+
)) {
|
|
10066
10093
|
continue;
|
|
10067
10094
|
}
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10095
|
+
if (sourceNet) {
|
|
10096
|
+
const text2 = sourceNet.name;
|
|
10097
|
+
const center2 = computeSchematicNetLabelCenter({
|
|
10098
|
+
anchor_position,
|
|
10099
|
+
anchor_side,
|
|
10100
|
+
text: text2
|
|
10101
|
+
});
|
|
10102
|
+
db.schematic_net_label.insert({
|
|
10103
|
+
text: text2,
|
|
10104
|
+
anchor_position,
|
|
10105
|
+
center: center2,
|
|
10106
|
+
anchor_side,
|
|
10107
|
+
...sourceNet?.source_net_id ? { source_net_id: sourceNet.source_net_id } : {}
|
|
10108
|
+
});
|
|
10109
|
+
return;
|
|
10110
|
+
}
|
|
10111
|
+
if (schPortIds.some(
|
|
10112
|
+
(schPortId) => schematicPortIdsWithRoutedTraces.has(schPortId)
|
|
10113
|
+
)) {
|
|
10114
|
+
continue;
|
|
10115
|
+
}
|
|
10116
|
+
const ports = group.selectAll("port").filter((p) => p._getSubcircuitConnectivityKey() === placementSck);
|
|
10117
|
+
const text = getNetNameFromPorts(ports);
|
|
10118
|
+
const center = computeSchematicNetLabelCenter({
|
|
10077
10119
|
anchor_position,
|
|
10078
10120
|
anchor_side,
|
|
10079
10121
|
text
|
|
@@ -10082,8 +10124,7 @@ function applyNetLabelPlacements(args) {
|
|
|
10082
10124
|
text,
|
|
10083
10125
|
anchor_position,
|
|
10084
10126
|
center,
|
|
10085
|
-
anchor_side
|
|
10086
|
-
...sourceNet?.source_net_id ? { source_net_id: sourceNet.source_net_id } : {}
|
|
10127
|
+
anchor_side
|
|
10087
10128
|
});
|
|
10088
10129
|
}
|
|
10089
10130
|
}
|
|
@@ -10091,7 +10132,12 @@ function applyNetLabelPlacements(args) {
|
|
|
10091
10132
|
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/insertNetLabelsForTracesExcludedFromRouting.ts
|
|
10092
10133
|
import "@tscircuit/schematic-trace-solver";
|
|
10093
10134
|
function insertNetLabelsForTracesExcludedFromRouting(args) {
|
|
10094
|
-
const {
|
|
10135
|
+
const {
|
|
10136
|
+
group,
|
|
10137
|
+
displayLabelTraces,
|
|
10138
|
+
pinIdToSchematicPortId,
|
|
10139
|
+
schematicPortIdsWithPreExistingNetLabels
|
|
10140
|
+
} = args;
|
|
10095
10141
|
const { db } = group.root;
|
|
10096
10142
|
for (const trace of displayLabelTraces) {
|
|
10097
10143
|
const label = trace._parsedProps?.schDisplayLabel;
|
|
@@ -10126,7 +10172,9 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
10126
10172
|
allSourceAndSchematicPortIdsInScope,
|
|
10127
10173
|
group,
|
|
10128
10174
|
schPortIdToSourcePortId,
|
|
10129
|
-
sckToSourceNet: connKeyToNet
|
|
10175
|
+
sckToSourceNet: connKeyToNet,
|
|
10176
|
+
pinIdToSchematicPortId,
|
|
10177
|
+
schematicPortIdsWithPreExistingNetLabels
|
|
10130
10178
|
}) => {
|
|
10131
10179
|
const { db } = group.root;
|
|
10132
10180
|
for (const schOrSrcPortId of Array.from(
|
|
@@ -10144,13 +10192,6 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
10144
10192
|
if (!sourceNet) {
|
|
10145
10193
|
continue;
|
|
10146
10194
|
}
|
|
10147
|
-
const hasLabelForNet = db.schematic_net_label.list().some((nl) => {
|
|
10148
|
-
if (sourceNet.source_net_id && nl.source_net_id) {
|
|
10149
|
-
return nl.source_net_id === sourceNet.source_net_id;
|
|
10150
|
-
}
|
|
10151
|
-
return nl.text === (sourceNet.name || key);
|
|
10152
|
-
});
|
|
10153
|
-
if (hasLabelForNet) continue;
|
|
10154
10195
|
const existingAtPort = db.schematic_net_label.list().some((nl) => {
|
|
10155
10196
|
const samePos = Math.abs(nl.anchor_position.x - sp.center.x) < 1e-6 && Math.abs(nl.anchor_position.y - sp.center.y) < 1e-6;
|
|
10156
10197
|
if (!samePos) return false;
|
|
@@ -10177,6 +10218,38 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
10177
10218
|
}
|
|
10178
10219
|
};
|
|
10179
10220
|
|
|
10221
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicPortIdsWithAssignedNetLabels.ts
|
|
10222
|
+
var getSchematicPortIdsWithAssignedNetLabels = (group) => {
|
|
10223
|
+
const schematicPortIdsWithNetLabels = /* @__PURE__ */ new Set();
|
|
10224
|
+
const netLabels = group.selectAll("netlabel");
|
|
10225
|
+
for (const netLabel of netLabels) {
|
|
10226
|
+
const netLabelPorts = netLabel._getConnectedPorts();
|
|
10227
|
+
for (const port of netLabelPorts) {
|
|
10228
|
+
if (!port.schematic_port_id) continue;
|
|
10229
|
+
schematicPortIdsWithNetLabels.add(port.schematic_port_id);
|
|
10230
|
+
}
|
|
10231
|
+
}
|
|
10232
|
+
return schematicPortIdsWithNetLabels;
|
|
10233
|
+
};
|
|
10234
|
+
|
|
10235
|
+
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicPortIdsWithRoutedTraces.ts
|
|
10236
|
+
var getSchematicPortIdsWithRoutedTraces = ({
|
|
10237
|
+
solver,
|
|
10238
|
+
pinIdToSchematicPortId
|
|
10239
|
+
}) => {
|
|
10240
|
+
const solvedTraces = solver.schematicTraceLinesSolver.solvedTracePaths;
|
|
10241
|
+
const schematicPortIdsWithRoutedTraces = /* @__PURE__ */ new Set();
|
|
10242
|
+
for (const solvedTrace of solvedTraces) {
|
|
10243
|
+
for (const pinId of solvedTrace.pinIds) {
|
|
10244
|
+
const schPortId = pinIdToSchematicPortId.get(pinId);
|
|
10245
|
+
if (schPortId) {
|
|
10246
|
+
schematicPortIdsWithRoutedTraces.add(schPortId);
|
|
10247
|
+
}
|
|
10248
|
+
}
|
|
10249
|
+
}
|
|
10250
|
+
return schematicPortIdsWithRoutedTraces;
|
|
10251
|
+
};
|
|
10252
|
+
|
|
10180
10253
|
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts
|
|
10181
10254
|
var debug7 = Debug8("Group_doInitialSchematicTraceRender");
|
|
10182
10255
|
var Group_doInitialSchematicTraceRender = (group) => {
|
|
@@ -10194,6 +10267,7 @@ var Group_doInitialSchematicTraceRender = (group) => {
|
|
|
10194
10267
|
allScks,
|
|
10195
10268
|
userNetIdToSck
|
|
10196
10269
|
} = createSchematicTraceSolverInputProblem(group);
|
|
10270
|
+
const schematicPortIdsWithPreExistingNetLabels = getSchematicPortIdsWithAssignedNetLabels(group);
|
|
10197
10271
|
if (debug7.enabled) {
|
|
10198
10272
|
globalThis.debugOutputs?.add(
|
|
10199
10273
|
"group-trace-render-input-problem",
|
|
@@ -10202,6 +10276,10 @@ var Group_doInitialSchematicTraceRender = (group) => {
|
|
|
10202
10276
|
}
|
|
10203
10277
|
const solver = new SchematicTracePipelineSolver4(inputProblem);
|
|
10204
10278
|
solver.solve();
|
|
10279
|
+
const schematicPortIdsWithRoutedTraces = getSchematicPortIdsWithRoutedTraces({
|
|
10280
|
+
solver,
|
|
10281
|
+
pinIdToSchematicPortId
|
|
10282
|
+
});
|
|
10205
10283
|
applyTracesFromSolverOutput({
|
|
10206
10284
|
group,
|
|
10207
10285
|
solver,
|
|
@@ -10214,19 +10292,26 @@ var Group_doInitialSchematicTraceRender = (group) => {
|
|
|
10214
10292
|
sckToSourceNet,
|
|
10215
10293
|
allSourceAndSchematicPortIdsInScope,
|
|
10216
10294
|
schPortIdToSourcePortId,
|
|
10295
|
+
pinIdToSchematicPortId,
|
|
10217
10296
|
allScks,
|
|
10218
|
-
userNetIdToSck
|
|
10297
|
+
userNetIdToSck,
|
|
10298
|
+
schematicPortIdsWithPreExistingNetLabels,
|
|
10299
|
+
schematicPortIdsWithRoutedTraces
|
|
10219
10300
|
});
|
|
10220
10301
|
insertNetLabelsForPortsMissingTrace({
|
|
10221
10302
|
group,
|
|
10222
10303
|
allSourceAndSchematicPortIdsInScope,
|
|
10223
10304
|
schPortIdToSourcePortId,
|
|
10224
|
-
sckToSourceNet
|
|
10305
|
+
sckToSourceNet,
|
|
10306
|
+
pinIdToSchematicPortId,
|
|
10307
|
+
schematicPortIdsWithPreExistingNetLabels
|
|
10225
10308
|
});
|
|
10226
10309
|
insertNetLabelsForTracesExcludedFromRouting({
|
|
10227
10310
|
group,
|
|
10228
10311
|
solver,
|
|
10229
|
-
displayLabelTraces
|
|
10312
|
+
displayLabelTraces,
|
|
10313
|
+
pinIdToSchematicPortId,
|
|
10314
|
+
schematicPortIdsWithPreExistingNetLabels
|
|
10230
10315
|
});
|
|
10231
10316
|
};
|
|
10232
10317
|
|
|
@@ -13669,7 +13754,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
13669
13754
|
var package_default = {
|
|
13670
13755
|
name: "@tscircuit/core",
|
|
13671
13756
|
type: "module",
|
|
13672
|
-
version: "0.0.
|
|
13757
|
+
version: "0.0.651",
|
|
13673
13758
|
types: "dist/index.d.ts",
|
|
13674
13759
|
main: "dist/index.js",
|
|
13675
13760
|
module: "dist/index.js",
|
|
@@ -13711,7 +13796,7 @@ var package_default = {
|
|
|
13711
13796
|
"@tscircuit/props": "^0.0.287",
|
|
13712
13797
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
13713
13798
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
13714
|
-
"@tscircuit/schematic-trace-solver": "^0.0.
|
|
13799
|
+
"@tscircuit/schematic-trace-solver": "^0.0.17",
|
|
13715
13800
|
"@tscircuit/simple-3d-svg": "^0.0.38",
|
|
13716
13801
|
"@types/bun": "^1.2.16",
|
|
13717
13802
|
"@types/debug": "^4.1.12",
|
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.652",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@tscircuit/props": "^0.0.287",
|
|
44
44
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
45
45
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
46
|
-
"@tscircuit/schematic-trace-solver": "^0.0.
|
|
46
|
+
"@tscircuit/schematic-trace-solver": "^0.0.17",
|
|
47
47
|
"@tscircuit/simple-3d-svg": "^0.0.38",
|
|
48
48
|
"@types/bun": "^1.2.16",
|
|
49
49
|
"@types/debug": "^4.1.12",
|