@tscircuit/core 0.0.1293 → 0.0.1295
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 +3 -0
- package/dist/index.js +130 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -230,6 +230,7 @@ interface DebugLogOutputEvent {
|
|
|
230
230
|
interface IIsolatedCircuit {
|
|
231
231
|
emit(event: RootCircuitEventName, ...args: any[]): void;
|
|
232
232
|
on(event: RootCircuitEventName, listener: (...args: any[]) => void): void;
|
|
233
|
+
isDoneRendering(): boolean;
|
|
233
234
|
_hasIncompleteAsyncEffectsForPhase(phase: RenderPhase): boolean;
|
|
234
235
|
}
|
|
235
236
|
|
|
@@ -387,6 +388,7 @@ declare class IsolatedCircuit {
|
|
|
387
388
|
_hasRenderedAtleastOnce: boolean;
|
|
388
389
|
private _asyncEffectIdsByPhase;
|
|
389
390
|
private _asyncEffectPhaseById;
|
|
391
|
+
private _hasUnrenderedUpdatesFromAsyncEffects;
|
|
390
392
|
private _runningAsyncEffectsById;
|
|
391
393
|
constructor({ platform, projectUrl, cachedSubcircuits, pendingSubcircuitRenders, }?: {
|
|
392
394
|
platform?: PlatformConfig;
|
|
@@ -403,6 +405,7 @@ declare class IsolatedCircuit {
|
|
|
403
405
|
_guessRootComponent(): void;
|
|
404
406
|
render(): void;
|
|
405
407
|
renderUntilSettled(): Promise<void>;
|
|
408
|
+
isDoneRendering(): boolean;
|
|
406
409
|
_hasIncompleteAsyncEffects(): boolean;
|
|
407
410
|
_hasIncompleteAsyncEffectsForPhase(phase: RenderPhase): boolean;
|
|
408
411
|
getRunningAsyncEffects(): Array<{
|
package/dist/index.js
CHANGED
|
@@ -18444,15 +18444,40 @@ function applyNetLabelPlacements(args) {
|
|
|
18444
18444
|
} = args;
|
|
18445
18445
|
const { db } = group.root;
|
|
18446
18446
|
const netLabelPlacements = solver.netLabelTraceCollisionSolver?.getOutput().netLabelPlacements ?? solver.netLabelPlacementSolver?.netLabelPlacements ?? solver.traceLabelOverlapAvoidanceSolver?.getOutput().netLabelPlacements ?? [];
|
|
18447
|
-
const
|
|
18447
|
+
const dedupedNetLabelPlacements = [];
|
|
18448
|
+
const netLabelPlacementKeys = /* @__PURE__ */ new Set();
|
|
18448
18449
|
for (const placement of netLabelPlacements) {
|
|
18450
|
+
const pinIds = [...placement.pinIds ?? []].sort();
|
|
18451
|
+
const key = `${placement.globalConnNetId}|${pinIds.join("::")}|${placement.netId ?? ""}`;
|
|
18452
|
+
if (netLabelPlacementKeys.has(key)) {
|
|
18453
|
+
debug9(
|
|
18454
|
+
`skipping duplicate placement for "${placement.netId}" REASON:identical net label placement`
|
|
18455
|
+
);
|
|
18456
|
+
continue;
|
|
18457
|
+
}
|
|
18458
|
+
netLabelPlacementKeys.add(key);
|
|
18459
|
+
dedupedNetLabelPlacements.push(placement);
|
|
18460
|
+
}
|
|
18461
|
+
const netLabelPlacementCountByGlobalNetId = /* @__PURE__ */ new Map();
|
|
18462
|
+
const routedPairKeysByGlobalNetId = /* @__PURE__ */ new Map();
|
|
18463
|
+
const globalNetIdsWithPortOnlyPlacements = /* @__PURE__ */ new Set();
|
|
18464
|
+
for (const placement of dedupedNetLabelPlacements) {
|
|
18449
18465
|
netLabelPlacementCountByGlobalNetId.set(
|
|
18450
18466
|
placement.globalConnNetId,
|
|
18451
18467
|
(netLabelPlacementCountByGlobalNetId.get(placement.globalConnNetId) ?? 0) + 1
|
|
18452
18468
|
);
|
|
18469
|
+
if ((placement.pinIds?.length ?? 0) > 1) {
|
|
18470
|
+
if (!routedPairKeysByGlobalNetId.has(placement.globalConnNetId)) {
|
|
18471
|
+
routedPairKeysByGlobalNetId.set(placement.globalConnNetId, /* @__PURE__ */ new Set());
|
|
18472
|
+
}
|
|
18473
|
+
routedPairKeysByGlobalNetId.get(placement.globalConnNetId).add(placement.pinIds.slice().sort().join("::"));
|
|
18474
|
+
}
|
|
18475
|
+
if ((placement.pinIds?.length ?? 0) <= 1) {
|
|
18476
|
+
globalNetIdsWithPortOnlyPlacements.add(placement.globalConnNetId);
|
|
18477
|
+
}
|
|
18453
18478
|
}
|
|
18454
18479
|
const globalConnMap = solver.mspConnectionPairSolver.globalConnMap;
|
|
18455
|
-
for (const placement of
|
|
18480
|
+
for (const placement of dedupedNetLabelPlacements) {
|
|
18456
18481
|
debug9(`processing placement: ${placement.netId}`);
|
|
18457
18482
|
const placementUserNetId = globalConnMap.getIdsConnectedToNet(placement.globalConnNetId).find((id) => userNetIdToConnKey.get(id));
|
|
18458
18483
|
const placementConnKey = userNetIdToConnKey.get(placementUserNetId);
|
|
@@ -18508,7 +18533,9 @@ function applyNetLabelPlacements(args) {
|
|
|
18508
18533
|
}
|
|
18509
18534
|
const ports = group.selectAll("port").filter((p) => p._getSubcircuitConnectivityKey() === placementConnKey);
|
|
18510
18535
|
const { name: text, wasAssignedDisplayLabel } = getNetNameFromPorts(ports);
|
|
18511
|
-
|
|
18536
|
+
const isRoutedPairPlacement = (placement.pinIds?.length ?? 0) > 1;
|
|
18537
|
+
const shouldKeepRoutedPairLabel = isRoutedPairPlacement && (globalNetIdsWithPortOnlyPlacements.has(placement.globalConnNetId) || (routedPairKeysByGlobalNetId.get(placement.globalConnNetId)?.size ?? 0) > 1);
|
|
18538
|
+
if (!wasAssignedDisplayLabel && !shouldKeepRoutedPairLabel && schPortIds.some(
|
|
18512
18539
|
(schPortId) => schematicPortIdsWithRoutedTraces.has(schPortId)
|
|
18513
18540
|
)) {
|
|
18514
18541
|
debug9(
|
|
@@ -18535,6 +18562,26 @@ function applyNetLabelPlacements(args) {
|
|
|
18535
18562
|
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/insertNetLabelsForPortsMissingTrace.ts
|
|
18536
18563
|
var NEAR_EXISTING_NET_LABEL_DISTANCE = 0.5;
|
|
18537
18564
|
var SAME_ANCHOR_POSITION_DISTANCE = 0.1;
|
|
18565
|
+
var doesSchematicNetLabelRepresentCurrentSourceConnection = (args) => {
|
|
18566
|
+
const { nl, connKey, sourceNet, text } = args;
|
|
18567
|
+
if (sourceNet?.source_net_id && nl.source_net_id) {
|
|
18568
|
+
return nl.source_net_id === sourceNet.source_net_id;
|
|
18569
|
+
}
|
|
18570
|
+
if (nl.source_net_id) {
|
|
18571
|
+
return nl.source_net_id === connKey;
|
|
18572
|
+
}
|
|
18573
|
+
return nl.text === text;
|
|
18574
|
+
};
|
|
18575
|
+
var getSourcePortNetLabelText = (db, sourcePortId) => {
|
|
18576
|
+
const sourcePort = db.source_port.get(sourcePortId);
|
|
18577
|
+
if (!sourcePort) return void 0;
|
|
18578
|
+
let sourceComponent;
|
|
18579
|
+
if (sourcePort.source_component_id) {
|
|
18580
|
+
sourceComponent = db.source_component.get(sourcePort.source_component_id);
|
|
18581
|
+
}
|
|
18582
|
+
if (!sourceComponent?.name || !sourcePort.name) return void 0;
|
|
18583
|
+
return `${sourceComponent.name}_${sourcePort.name}`;
|
|
18584
|
+
};
|
|
18538
18585
|
var insertNetLabelsForPortsMissingTrace = ({
|
|
18539
18586
|
allSourceAndSchematicPortIdsInScope,
|
|
18540
18587
|
group,
|
|
@@ -18554,10 +18601,14 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
18554
18601
|
const connKey = sourcePort?.subcircuit_connectivity_map_key;
|
|
18555
18602
|
if (!connKey) continue;
|
|
18556
18603
|
const sourceNet = connKeyToSourceNet.get(connKey);
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
|
|
18560
|
-
|
|
18604
|
+
const connectedSourcePortIdsForKey = Array.from(
|
|
18605
|
+
allSourceAndSchematicPortIdsInScope
|
|
18606
|
+
).map((portId) => schPortIdToSourcePortId.get(portId)).filter((sourcePortId) => {
|
|
18607
|
+
if (!sourcePortId) return false;
|
|
18608
|
+
return db.source_port.get(sourcePortId)?.subcircuit_connectivity_map_key === connKey;
|
|
18609
|
+
});
|
|
18610
|
+
const implicitPortLabelText = connectedSourcePortIdsForKey.map((sourcePortId) => getSourcePortNetLabelText(db, sourcePortId)).filter((label) => Boolean(label)).join("/");
|
|
18611
|
+
const text = sourceNet?.name || sourceNet?.source_net_id || implicitPortLabelText || connKey;
|
|
18561
18612
|
const connectedPortCountForKey = Array.from(
|
|
18562
18613
|
allSourceAndSchematicPortIdsInScope
|
|
18563
18614
|
).filter((portId) => {
|
|
@@ -18565,13 +18616,12 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
18565
18616
|
if (!sourcePortId) return false;
|
|
18566
18617
|
return db.source_port.get(sourcePortId)?.subcircuit_connectivity_map_key === connKey;
|
|
18567
18618
|
}).length;
|
|
18568
|
-
const isGndNet = sourceNet
|
|
18569
|
-
const isPowerNet = !isGndNet && sourceNet
|
|
18570
|
-
const usePowerSymbolSide = connectedPortCountForKey > 1;
|
|
18619
|
+
const isGndNet = sourceNet?.is_ground ?? false;
|
|
18620
|
+
const isPowerNet = !isGndNet && (sourceNet?.is_power ?? false);
|
|
18571
18621
|
let side;
|
|
18572
|
-
if (
|
|
18622
|
+
if (isGndNet) {
|
|
18573
18623
|
side = "top";
|
|
18574
|
-
} else if (
|
|
18624
|
+
} else if (isPowerNet) {
|
|
18575
18625
|
side = "bottom";
|
|
18576
18626
|
} else {
|
|
18577
18627
|
side = getEnteringEdgeFromDirection(
|
|
@@ -18583,32 +18633,40 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
18583
18633
|
anchor_side: side,
|
|
18584
18634
|
text
|
|
18585
18635
|
});
|
|
18586
|
-
const
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
if (sameNetLabel && connectedPortCountForKey <= 1) {
|
|
18593
|
-
db.schematic_net_label.update(sameNetLabel.schematic_net_label_id, {
|
|
18594
|
-
text,
|
|
18595
|
-
anchor_position: schPort.center,
|
|
18596
|
-
center,
|
|
18597
|
-
anchor_side: side
|
|
18636
|
+
const existingNetLabelForCurrentSourceConnection = db.schematic_net_label.list().find((nl) => {
|
|
18637
|
+
return doesSchematicNetLabelRepresentCurrentSourceConnection({
|
|
18638
|
+
nl,
|
|
18639
|
+
connKey,
|
|
18640
|
+
sourceNet,
|
|
18641
|
+
text
|
|
18598
18642
|
});
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
const labelIsNearPort = dx * dx + dy * dy < NEAR_EXISTING_NET_LABEL_DISTANCE * NEAR_EXISTING_NET_LABEL_DISTANCE;
|
|
18605
|
-
if (labelIsNearPort && sourceNet.is_ground) {
|
|
18606
|
-
db.schematic_net_label.update(sameNetLabel.schematic_net_label_id, {
|
|
18643
|
+
});
|
|
18644
|
+
if (existingNetLabelForCurrentSourceConnection && connectedPortCountForKey <= 1) {
|
|
18645
|
+
db.schematic_net_label.update(
|
|
18646
|
+
existingNetLabelForCurrentSourceConnection.schematic_net_label_id,
|
|
18647
|
+
{
|
|
18607
18648
|
text,
|
|
18608
18649
|
anchor_position: schPort.center,
|
|
18609
18650
|
center,
|
|
18610
18651
|
anchor_side: side
|
|
18611
|
-
}
|
|
18652
|
+
}
|
|
18653
|
+
);
|
|
18654
|
+
continue;
|
|
18655
|
+
}
|
|
18656
|
+
if (existingNetLabelForCurrentSourceConnection) {
|
|
18657
|
+
const dx = existingNetLabelForCurrentSourceConnection.anchor_position.x - schPort.center.x;
|
|
18658
|
+
const dy = existingNetLabelForCurrentSourceConnection.anchor_position.y - schPort.center.y;
|
|
18659
|
+
const labelIsNearPort = dx * dx + dy * dy < NEAR_EXISTING_NET_LABEL_DISTANCE * NEAR_EXISTING_NET_LABEL_DISTANCE;
|
|
18660
|
+
if (labelIsNearPort && isGndNet) {
|
|
18661
|
+
db.schematic_net_label.update(
|
|
18662
|
+
existingNetLabelForCurrentSourceConnection.schematic_net_label_id,
|
|
18663
|
+
{
|
|
18664
|
+
text,
|
|
18665
|
+
anchor_position: schPort.center,
|
|
18666
|
+
center,
|
|
18667
|
+
anchor_side: side
|
|
18668
|
+
}
|
|
18669
|
+
);
|
|
18612
18670
|
continue;
|
|
18613
18671
|
}
|
|
18614
18672
|
const existingAtPort = db.schematic_net_label.list().some((nl) => {
|
|
@@ -18617,16 +18675,41 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
18617
18675
|
if (dx2 * dx2 + dy2 * dy2 >= SAME_ANCHOR_POSITION_DISTANCE * SAME_ANCHOR_POSITION_DISTANCE) {
|
|
18618
18676
|
return false;
|
|
18619
18677
|
}
|
|
18620
|
-
|
|
18621
|
-
|
|
18622
|
-
|
|
18623
|
-
|
|
18678
|
+
return doesSchematicNetLabelRepresentCurrentSourceConnection({
|
|
18679
|
+
nl,
|
|
18680
|
+
connKey,
|
|
18681
|
+
sourceNet,
|
|
18682
|
+
text
|
|
18683
|
+
});
|
|
18624
18684
|
});
|
|
18625
18685
|
if (existingAtPort) continue;
|
|
18626
18686
|
}
|
|
18687
|
+
if (!sourceNet) {
|
|
18688
|
+
for (const nl of db.schematic_net_label.list()) {
|
|
18689
|
+
if (nl.source_net_id !== connKey) continue;
|
|
18690
|
+
const isAttachedToConnectedPort = connectedSourcePortIdsForKey.some(
|
|
18691
|
+
(sourcePortId) => {
|
|
18692
|
+
const schPortId = Array.from(
|
|
18693
|
+
schPortIdToSourcePortId.entries()
|
|
18694
|
+
).find(([, id]) => id === sourcePortId)?.[0];
|
|
18695
|
+
let connectedSchPort;
|
|
18696
|
+
if (schPortId) {
|
|
18697
|
+
connectedSchPort = db.schematic_port.get(schPortId);
|
|
18698
|
+
}
|
|
18699
|
+
if (!connectedSchPort?.center || !nl.anchor_position) return false;
|
|
18700
|
+
const dx = nl.anchor_position.x - connectedSchPort.center.x;
|
|
18701
|
+
const dy = nl.anchor_position.y - connectedSchPort.center.y;
|
|
18702
|
+
return dx * dx + dy * dy < SAME_ANCHOR_POSITION_DISTANCE * SAME_ANCHOR_POSITION_DISTANCE;
|
|
18703
|
+
}
|
|
18704
|
+
);
|
|
18705
|
+
if (!isAttachedToConnectedPort) {
|
|
18706
|
+
db.schematic_net_label.delete(nl.schematic_net_label_id);
|
|
18707
|
+
}
|
|
18708
|
+
}
|
|
18709
|
+
}
|
|
18627
18710
|
const netLabel = {
|
|
18628
18711
|
text,
|
|
18629
|
-
source_net_id: sourceNet
|
|
18712
|
+
source_net_id: sourceNet?.source_net_id ?? connKey,
|
|
18630
18713
|
anchor_position: schPort.center,
|
|
18631
18714
|
center,
|
|
18632
18715
|
anchor_side: side
|
|
@@ -22265,7 +22348,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
22265
22348
|
var package_default = {
|
|
22266
22349
|
name: "@tscircuit/core",
|
|
22267
22350
|
type: "module",
|
|
22268
|
-
version: "0.0.
|
|
22351
|
+
version: "0.0.1294",
|
|
22269
22352
|
types: "dist/index.d.ts",
|
|
22270
22353
|
main: "dist/index.js",
|
|
22271
22354
|
module: "dist/index.js",
|
|
@@ -22441,6 +22524,7 @@ var IsolatedCircuit = class {
|
|
|
22441
22524
|
_hasRenderedAtleastOnce = false;
|
|
22442
22525
|
_asyncEffectIdsByPhase = /* @__PURE__ */ new Map();
|
|
22443
22526
|
_asyncEffectPhaseById = /* @__PURE__ */ new Map();
|
|
22527
|
+
_hasUnrenderedUpdatesFromAsyncEffects = false;
|
|
22444
22528
|
_runningAsyncEffectsById = /* @__PURE__ */ new Map();
|
|
22445
22529
|
constructor({
|
|
22446
22530
|
platform,
|
|
@@ -22527,6 +22611,7 @@ var IsolatedCircuit = class {
|
|
|
22527
22611
|
if (!firstChild) throw new Error("IsolatedCircuit has no root component");
|
|
22528
22612
|
firstChild.parent = this;
|
|
22529
22613
|
firstChild.runRenderCycle();
|
|
22614
|
+
this._hasUnrenderedUpdatesFromAsyncEffects = false;
|
|
22530
22615
|
this._hasRenderedAtleastOnce = true;
|
|
22531
22616
|
}
|
|
22532
22617
|
async renderUntilSettled() {
|
|
@@ -22538,14 +22623,18 @@ var IsolatedCircuit = class {
|
|
|
22538
22623
|
});
|
|
22539
22624
|
}
|
|
22540
22625
|
this.render();
|
|
22541
|
-
while (this.
|
|
22626
|
+
while (!this.isDoneRendering()) {
|
|
22542
22627
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
22543
22628
|
this.render();
|
|
22544
22629
|
}
|
|
22545
22630
|
this.emit("renderComplete");
|
|
22546
22631
|
}
|
|
22632
|
+
isDoneRendering() {
|
|
22633
|
+
return this._hasRenderedAtleastOnce && !this._hasIncompleteAsyncEffects();
|
|
22634
|
+
}
|
|
22547
22635
|
_hasIncompleteAsyncEffects() {
|
|
22548
22636
|
if (this._asyncEffectPhaseById.size > 0) return true;
|
|
22637
|
+
if (this._hasUnrenderedUpdatesFromAsyncEffects) return true;
|
|
22549
22638
|
return this.children.some((child) => child._hasIncompleteAsyncEffects());
|
|
22550
22639
|
}
|
|
22551
22640
|
_hasIncompleteAsyncEffectsForPhase(phase) {
|
|
@@ -22674,6 +22763,7 @@ var IsolatedCircuit = class {
|
|
|
22674
22763
|
}
|
|
22675
22764
|
this._asyncEffectPhaseById.delete(asyncEffectId);
|
|
22676
22765
|
this._runningAsyncEffectsById.delete(asyncEffectId);
|
|
22766
|
+
this._hasUnrenderedUpdatesFromAsyncEffects = true;
|
|
22677
22767
|
}
|
|
22678
22768
|
};
|
|
22679
22769
|
|