@tscircuit/core 0.0.2147 → 0.0.2148

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.
Files changed (2) hide show
  1. package/dist/index.js +38 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -118369,14 +118369,42 @@ function getConnectionSelectorsFromAutoroutingPhaseProps(phaseProps) {
118369
118369
  ...phaseProps.connections ?? []
118370
118370
  ];
118371
118371
  }
118372
- function traceHasEndpointMatchingConnectionSelector(trace, connectionSelectorEndpointKey) {
118372
+ function traceHasEndpointMatchingConnectionSelector(trace, connectionSelector) {
118373
+ const connectionSelectorEndpointKey = convertPortSelectorToEndpointKey(connectionSelector);
118373
118374
  if (trace.getTracePortPathSelectors().some(
118374
118375
  (selector) => convertPortSelectorToEndpointKey(selector) === connectionSelectorEndpointKey
118375
118376
  ))
118376
118377
  return true;
118377
- const port = trace.getSubcircuit().selectOne(connectionSelectorEndpointKey, { type: "port" });
118378
+ const port = trace.getSubcircuit().selectOne(connectionSelector, { type: "port" });
118378
118379
  return port !== null && (trace._findConnectedPorts().ports?.includes(port) ?? false);
118379
118380
  }
118381
+ function resolvePhaseConnectionTraces(group, traces, phaseProps) {
118382
+ const resolvedTraces = /* @__PURE__ */ new Set();
118383
+ const phaseName = phaseProps.name ?? "unnamed phase";
118384
+ for (const rawSelector of getConnectionSelectorsFromAutoroutingPhaseProps(
118385
+ phaseProps
118386
+ )) {
118387
+ const selector = rawSelector.trim();
118388
+ const explicitlySelectsTrace = selector.startsWith("trace.");
118389
+ const namedTraces = explicitlySelectsTrace ? group.selectAll(selector).filter((trace) => traces.includes(trace)) : traces.filter((trace) => trace.name === selector);
118390
+ const endpointTraces = explicitlySelectsTrace ? [] : traces.filter(
118391
+ (trace) => traceHasEndpointMatchingConnectionSelector(trace, selector)
118392
+ );
118393
+ if (namedTraces.length > 1 || namedTraces.length > 0 && endpointTraces.length > 0) {
118394
+ throw new Error(
118395
+ `Autorouting phase "${phaseName}": connection "${rawSelector}" is ambiguous. Use a unique trace name qualified as "trace.DDR_D0" or a port such as ".U1 > .A1".`
118396
+ );
118397
+ }
118398
+ const matches = namedTraces.length > 0 ? namedTraces : endpointTraces;
118399
+ if (matches.length === 0) {
118400
+ throw new Error(
118401
+ `Autorouting phase "${phaseName}": connection "${rawSelector}" matched no trace or endpoint. Use a trace name such as "DDR_D0" or a port such as ".U1 > .A1".`
118402
+ );
118403
+ }
118404
+ for (const trace of matches) resolvedTraces.add(trace);
118405
+ }
118406
+ return resolvedTraces;
118407
+ }
118380
118408
  function getAutoroutersByPhaseIndex(group) {
118381
118409
  const autoroutingPhases = group.selectAll(
118382
118410
  "autoroutingphase"
@@ -118468,6 +118496,12 @@ function Group_getRoutingPhasePlans(group) {
118468
118496
  const plansByPhaseIndex = /* @__PURE__ */ new Map();
118469
118497
  const autoroutersByPhaseIndex = getAutoroutersByPhaseIndex(group);
118470
118498
  const phasePropsByPhaseIndex = getAutoroutingPhasePropsByPhaseIndex(group);
118499
+ const selectedTracesByPhaseIndex = new Map(
118500
+ Array.from(phasePropsByPhaseIndex, ([phaseIndex, phaseProps]) => [
118501
+ phaseIndex,
118502
+ resolvePhaseConnectionTraces(group, traces, phaseProps)
118503
+ ])
118504
+ );
118471
118505
  const groupFanoutProps = group._parsedProps;
118472
118506
  const routeRemaining = group.getInheritedProperty("routeRemaining") !== false;
118473
118507
  const defaultPhaseProps = phasePropsByPhaseIndex.get(null);
@@ -118504,15 +118538,10 @@ function Group_getRoutingPhasePlans(group) {
118504
118538
  const connectionSelectors = getConnectionSelectorsFromAutoroutingPhaseProps(phaseProps);
118505
118539
  if (connectionSelectors.length > 0) {
118506
118540
  const plan = getOrCreateRoutingPhasePlan(plansByPhaseIndex, phaseIndex);
118507
- const connectionSelectorEndpointKeys = connectionSelectors.map(
118508
- convertPortSelectorToEndpointKey
118509
- );
118510
118541
  plan.connectionSelectors = connectionSelectors;
118511
118542
  for (const trace of traces) {
118512
118543
  if (breakoutByTrace.has(trace)) continue;
118513
- if (connectionSelectorEndpointKeys.some(
118514
- (endpointKey) => traceHasEndpointMatchingConnectionSelector(trace, endpointKey)
118515
- )) {
118544
+ if (selectedTracesByPhaseIndex.get(phaseIndex).has(trace)) {
118516
118545
  if (!phaseProps.reroute) {
118517
118546
  for (const existingPlan of plansByPhaseIndex.values()) {
118518
118547
  if (existingPlan === plan) continue;
@@ -118692,7 +118721,7 @@ var RoutingPhasePreparationError = class extends Error {
118692
118721
  var package_default = {
118693
118722
  name: "@tscircuit/core",
118694
118723
  type: "module",
118695
- version: "0.0.2146",
118724
+ version: "0.0.2147",
118696
118725
  types: "dist/index.d.ts",
118697
118726
  main: "dist/index.js",
118698
118727
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.2147",
4
+ "version": "0.0.2148",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",