@tscircuit/core 0.0.864 → 0.0.866

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 +75 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -609,16 +609,19 @@ var cssSelectPrimitiveComponentAdapterOnlySubcircuits = {
609
609
  };
610
610
 
611
611
  // lib/components/base-components/PrimitiveComponent/preprocessSelector.ts
612
- var preprocessSelector = (selector) => {
612
+ var buildPlusMinusNetErrorMessage = (selector, component) => {
613
+ const netName = selector.split("net.")[1]?.split(/[ >]/)[0] ?? selector;
614
+ const componentName = component?.componentName ?? "Unknown component";
615
+ return `Net names cannot contain "+" or "-" (component "${componentName}" received "${netName}" via "${selector}"). Try using underscores instead, e.g. VCC_P`;
616
+ };
617
+ var preprocessSelector = (selector, component) => {
613
618
  if (/net\.[^\s>]*\./.test(selector)) {
614
619
  throw new Error(
615
620
  'Net names cannot contain a period, try using "sel.net..." to autocomplete with conventional net names, e.g. V3_3'
616
621
  );
617
622
  }
618
623
  if (/net\.[^\s>]*[+-]/.test(selector)) {
619
- throw new Error(
620
- 'Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P'
621
- );
624
+ throw new Error(buildPlusMinusNetErrorMessage(selector, component));
622
625
  }
623
626
  if (/net\.[0-9]/.test(selector)) {
624
627
  const match = selector.match(/net\.([^ >]+)/);
@@ -1166,7 +1169,7 @@ var PrimitiveComponent2 = class extends Renderable {
1166
1169
  if (this._cachedSelectAllQueries.has(selectorRaw)) {
1167
1170
  return this._cachedSelectAllQueries.get(selectorRaw);
1168
1171
  }
1169
- const selector = preprocessSelector(selectorRaw);
1172
+ const selector = preprocessSelector(selectorRaw, this);
1170
1173
  const result = selectAll(
1171
1174
  selector,
1172
1175
  this,
@@ -1190,7 +1193,7 @@ var PrimitiveComponent2 = class extends Renderable {
1190
1193
  if (this._cachedSelectOneQueries.has(selectorRaw)) {
1191
1194
  return this._cachedSelectOneQueries.get(selectorRaw);
1192
1195
  }
1193
- const selector = preprocessSelector(selectorRaw);
1196
+ const selector = preprocessSelector(selectorRaw, this);
1194
1197
  if (options?.port) {
1195
1198
  options.type = "port";
1196
1199
  }
@@ -1649,7 +1652,9 @@ import { autoroute } from "@tscircuit/infgrid-ijump-astar";
1649
1652
  var netProps = z4.object({
1650
1653
  name: z4.string().refine(
1651
1654
  (val) => !/[+-]/.test(val),
1652
- 'Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P'
1655
+ (val) => ({
1656
+ message: `Net names cannot contain "+" or "-" (component "Net" received "${val}"). Try using underscores instead, e.g. VCC_P`
1657
+ })
1653
1658
  )
1654
1659
  });
1655
1660
  var Net = class extends PrimitiveComponent2 {
@@ -1840,9 +1845,9 @@ var createNetsFromProps = (component, props) => {
1840
1845
  );
1841
1846
  }
1842
1847
  if (/net\.[^\s>]*[+-]/.test(prop)) {
1843
- throw new Error(
1844
- 'Net names cannot contain "+" or "-", try using underscores instead, e.g. VCC_P'
1845
- );
1848
+ const netName = prop.split("net.")[1];
1849
+ const message = `Net names cannot contain "+" or "-" (component "${component.componentName}" received "${netName}" via "${prop}"). Try using underscores instead, e.g. VCC_P`;
1850
+ throw new Error(message);
1846
1851
  }
1847
1852
  if (/net\.[0-9]/.test(prop)) {
1848
1853
  const netName = prop.split("net.")[1];
@@ -15923,6 +15928,61 @@ function inflateSourceDiode(sourceElm, inflatorContext) {
15923
15928
  }
15924
15929
  }
15925
15930
 
15931
+ // lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceTrace.ts
15932
+ var getSelectorPath = (component, db) => {
15933
+ const path_parts = [];
15934
+ let currentGroupId = component.source_group_id;
15935
+ while (currentGroupId) {
15936
+ const group = db.source_group.get(currentGroupId);
15937
+ if (!group) break;
15938
+ path_parts.unshift(`.${group.name}`);
15939
+ currentGroupId = group.parent_source_group_id;
15940
+ }
15941
+ path_parts.push(`.${component.name}`);
15942
+ return path_parts.join(" > ");
15943
+ };
15944
+ function inflateSourceTrace(sourceTrace, inflatorContext) {
15945
+ const { injectionDb, subcircuit } = inflatorContext;
15946
+ const connectedSelectors = [];
15947
+ for (const sourcePortId of sourceTrace.connected_source_port_ids) {
15948
+ const sourcePort = injectionDb.source_port.get(sourcePortId);
15949
+ if (!sourcePort) continue;
15950
+ let selector;
15951
+ if (sourcePort.source_component_id) {
15952
+ const sourceComponent = injectionDb.source_component.get(
15953
+ sourcePort.source_component_id
15954
+ );
15955
+ if (sourceComponent) {
15956
+ const path = getSelectorPath(
15957
+ {
15958
+ name: sourceComponent.name,
15959
+ source_group_id: sourceComponent.source_group_id
15960
+ },
15961
+ injectionDb
15962
+ );
15963
+ selector = `${path} > .${sourcePort.name}`;
15964
+ }
15965
+ } else {
15966
+ selector = `.${sourcePort.name}`;
15967
+ }
15968
+ if (selector) {
15969
+ connectedSelectors.push(selector);
15970
+ }
15971
+ }
15972
+ for (const sourceNetId of sourceTrace.connected_source_net_ids) {
15973
+ const sourceNet = injectionDb.source_net.get(sourceNetId);
15974
+ if (sourceNet) {
15975
+ connectedSelectors.push(`net.${sourceNet.name}`);
15976
+ }
15977
+ }
15978
+ if (connectedSelectors.length < 2) return;
15979
+ const trace = new Trace3({
15980
+ path: connectedSelectors
15981
+ });
15982
+ trace.source_trace_id = sourceTrace.source_trace_id;
15983
+ subcircuit.add(trace);
15984
+ }
15985
+
15926
15986
  // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
15927
15987
  var Subcircuit = class extends Group6 {
15928
15988
  constructor(props) {
@@ -15990,6 +16050,10 @@ var Subcircuit = class extends Group6 {
15990
16050
  for (const sourcePort of sourcePorts) {
15991
16051
  inflateSourcePort(sourcePort, inflationCtx);
15992
16052
  }
16053
+ const sourceTraces = injectionDb.source_trace.list();
16054
+ for (const sourceTrace of sourceTraces) {
16055
+ inflateSourceTrace(sourceTrace, inflationCtx);
16056
+ }
15993
16057
  }
15994
16058
  };
15995
16059
 
@@ -17839,7 +17903,7 @@ import { identity as identity6 } from "transformation-matrix";
17839
17903
  var package_default = {
17840
17904
  name: "@tscircuit/core",
17841
17905
  type: "module",
17842
- version: "0.0.863",
17906
+ version: "0.0.865",
17843
17907
  types: "dist/index.d.ts",
17844
17908
  main: "dist/index.js",
17845
17909
  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.864",
4
+ "version": "0.0.866",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",