@tscircuit/core 0.0.1339 → 0.0.1341

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 CHANGED
@@ -1715,6 +1715,15 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
1715
1715
  getGroup(): IGroup | null;
1716
1716
  doInitialAssignNameToUnnamedComponents(): void;
1717
1717
  doInitialOptimizeSelectorCache(): void;
1718
+ /**
1719
+ * The selector caches memoize results assuming the component tree is stable.
1720
+ * When the tree changes after the cache is first built (e.g. a connector adds
1721
+ * its ports asynchronously once a parts-engine fetch resolves), this phase is
1722
+ * re-marked dirty via _markDirty and re-runs as an update. Drop the stale
1723
+ * memoized results so later queries see the current tree, then re-warm the
1724
+ * subcircuit cache.
1725
+ */
1726
+ updateOptimizeSelectorCache(): void;
1718
1727
  _cachedSelectAllQueries: Map<string, PrimitiveComponent[]>;
1719
1728
  selectAll<T extends PrimitiveComponent = PrimitiveComponent>(selectorRaw: string): T[];
1720
1729
  _cachedSelectOneQueries: Map<string, PrimitiveComponent | null>;
package/dist/index.js CHANGED
@@ -2039,6 +2039,19 @@ var PrimitiveComponent2 = class extends Renderable {
2039
2039
  }
2040
2040
  }
2041
2041
  }
2042
+ /**
2043
+ * The selector caches memoize results assuming the component tree is stable.
2044
+ * When the tree changes after the cache is first built (e.g. a connector adds
2045
+ * its ports asynchronously once a parts-engine fetch resolves), this phase is
2046
+ * re-marked dirty via _markDirty and re-runs as an update. Drop the stale
2047
+ * memoized results so later queries see the current tree, then re-warm the
2048
+ * subcircuit cache.
2049
+ */
2050
+ updateOptimizeSelectorCache() {
2051
+ this._cachedSelectAllQueries.clear();
2052
+ this._cachedSelectOneQueries.clear();
2053
+ this.doInitialOptimizeSelectorCache();
2054
+ }
2042
2055
  _cachedSelectAllQueries = /* @__PURE__ */ new Map();
2043
2056
  selectAll(selectorRaw) {
2044
2057
  if (this._cachedSelectAllQueries.has(selectorRaw)) {
@@ -4899,7 +4912,7 @@ function Trace_doInitialPcbManualTraceRender(trace) {
4899
4912
  const layer = anchorPort.getAvailablePcbLayers()[0] || "top";
4900
4913
  let currentLayer = layer;
4901
4914
  const anchorPos = anchorPort._getGlobalPcbPositionAfterLayout();
4902
- const otherPos = otherPort._getGlobalPcbPositionAfterLayout();
4915
+ const otherPos = otherPort?._getGlobalPcbPositionAfterLayout();
4903
4916
  const route = [];
4904
4917
  route.push({
4905
4918
  route_type: "wire",
@@ -4975,14 +4988,16 @@ function Trace_doInitialPcbManualTraceRender(trace) {
4975
4988
  });
4976
4989
  }
4977
4990
  }
4978
- route.push({
4979
- route_type: "wire",
4980
- x: otherPos.x,
4981
- y: otherPos.y,
4982
- width,
4983
- layer: currentLayer,
4984
- end_pcb_port_id: otherPort.pcb_port_id
4985
- });
4991
+ if (otherPort && otherPos) {
4992
+ route.push({
4993
+ route_type: "wire",
4994
+ x: otherPos.x,
4995
+ y: otherPos.y,
4996
+ width,
4997
+ layer: currentLayer,
4998
+ end_pcb_port_id: otherPort.pcb_port_id
4999
+ });
5000
+ }
4986
5001
  const traceLength = getTraceLength(route);
4987
5002
  const pcb_trace = db.pcb_trace.insert({
4988
5003
  route,
@@ -24032,7 +24047,7 @@ import { identity as identity5 } from "transformation-matrix";
24032
24047
  var package_default = {
24033
24048
  name: "@tscircuit/core",
24034
24049
  type: "module",
24035
- version: "0.0.1338",
24050
+ version: "0.0.1340",
24036
24051
  types: "dist/index.d.ts",
24037
24052
  main: "dist/index.js",
24038
24053
  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.1339",
4
+ "version": "0.0.1341",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",