@tscircuit/pcb-viewer 1.11.342 → 1.11.344

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.js CHANGED
@@ -5433,9 +5433,53 @@ function connect(map, a, b) {
5433
5433
  }
5434
5434
  function buildSubtree(soup, opts) {
5435
5435
  if (!opts.subcircuit_id && !opts.source_group_id) return [...soup];
5436
+ let effectiveOpts = opts;
5437
+ if (opts.subcircuit_id) {
5438
+ const subcircuitIds = /* @__PURE__ */ new Set([opts.subcircuit_id]);
5439
+ const groupChildren = /* @__PURE__ */ new Map();
5440
+ const groupSubcircuit = /* @__PURE__ */ new Map();
5441
+ for (const elm of soup) {
5442
+ if (elm.type === "source_group") {
5443
+ const groupId = elm.source_group_id;
5444
+ const subcircuitId = elm.subcircuit_id;
5445
+ if (subcircuitId) {
5446
+ groupSubcircuit.set(groupId, subcircuitId);
5447
+ }
5448
+ const parentId = elm.parent_source_group_id;
5449
+ if (parentId) {
5450
+ if (!groupChildren.has(parentId)) {
5451
+ groupChildren.set(parentId, []);
5452
+ }
5453
+ groupChildren.get(parentId).push(groupId);
5454
+ }
5455
+ }
5456
+ }
5457
+ let rootGroupId;
5458
+ for (const [groupId, subcircuitId] of groupSubcircuit) {
5459
+ if (subcircuitId === opts.subcircuit_id) {
5460
+ rootGroupId = groupId;
5461
+ break;
5462
+ }
5463
+ }
5464
+ if (rootGroupId) {
5465
+ const collectChildSubcircuits = (groupId) => {
5466
+ const children = groupChildren.get(groupId) || [];
5467
+ for (const childId of children) {
5468
+ const childSubcircuit = groupSubcircuit.get(childId);
5469
+ if (childSubcircuit) {
5470
+ subcircuitIds.add(childSubcircuit);
5471
+ }
5472
+ collectChildSubcircuits(childId);
5473
+ }
5474
+ };
5475
+ collectChildSubcircuits(rootGroupId);
5476
+ effectiveOpts = { ...opts, subcircuit_ids: Array.from(subcircuitIds) };
5477
+ }
5478
+ }
5436
5479
  const idMap = /* @__PURE__ */ new Map();
5437
5480
  for (const elm of soup) {
5438
- const idVal = elm[`${elm.type}_id`];
5481
+ const idKey = `${elm.type}_id`;
5482
+ const idVal = elm[idKey];
5439
5483
  if (typeof idVal === "string") {
5440
5484
  idMap.set(idVal, elm);
5441
5485
  }
@@ -5461,9 +5505,17 @@ function buildSubtree(soup, opts) {
5461
5505
  const queue = [];
5462
5506
  const included = /* @__PURE__ */ new Set();
5463
5507
  for (const elm of soup) {
5464
- if (opts.subcircuit_id && elm.subcircuit_id === opts.subcircuit_id || opts.source_group_id && (elm.source_group_id === opts.source_group_id || Array.isArray(elm.member_source_group_ids) && elm.member_source_group_ids.includes(
5465
- opts.source_group_id
5466
- ))) {
5508
+ let shouldInclude = false;
5509
+ if (effectiveOpts.subcircuit_id && "subcircuit_id" in elm && elm.subcircuit_id === effectiveOpts.subcircuit_id) {
5510
+ shouldInclude = true;
5511
+ } else if (effectiveOpts.subcircuit_ids && "subcircuit_id" in elm && elm.subcircuit_id && effectiveOpts.subcircuit_ids.includes(elm.subcircuit_id)) {
5512
+ shouldInclude = true;
5513
+ } else if (effectiveOpts.source_group_id && "source_group_id" in elm && elm.source_group_id === effectiveOpts.source_group_id) {
5514
+ shouldInclude = true;
5515
+ } else if (effectiveOpts.source_group_id && "member_source_group_ids" in elm && Array.isArray(elm.member_source_group_ids) && elm.member_source_group_ids.includes(effectiveOpts.source_group_id)) {
5516
+ shouldInclude = true;
5517
+ }
5518
+ if (shouldInclude) {
5467
5519
  queue.push(elm);
5468
5520
  included.add(elm);
5469
5521
  }
@@ -14139,7 +14191,7 @@ import { css as css3 } from "@emotion/css";
14139
14191
  // package.json
14140
14192
  var package_default = {
14141
14193
  name: "@tscircuit/pcb-viewer",
14142
- version: "1.11.341",
14194
+ version: "1.11.343",
14143
14195
  main: "dist/index.js",
14144
14196
  type: "module",
14145
14197
  repository: "tscircuit/pcb-viewer",
@@ -14163,7 +14215,7 @@ var package_default = {
14163
14215
  "@semantic-release/npm": "^9.0.1",
14164
14216
  "@semantic-release/release-notes-generator": "^10.0.3",
14165
14217
  "@swc/core": "^1.4.12",
14166
- "@tscircuit/circuit-json-util": "^0.0.75",
14218
+ "@tscircuit/circuit-json-util": "^0.0.78",
14167
14219
  "@tscircuit/eagle-xml-converter": "^1.0.0",
14168
14220
  "@types/bun": "latest",
14169
14221
  "@types/color": "^3.0.6",
@@ -14189,11 +14241,11 @@ var package_default = {
14189
14241
  },
14190
14242
  dependencies: {
14191
14243
  "@emotion/css": "^11.11.2",
14192
- "@tscircuit/alphabet": "^0.0.20",
14244
+ "@tscircuit/alphabet": "^0.0.22",
14193
14245
  "@tscircuit/math-utils": "^0.0.29",
14194
14246
  "@vitejs/plugin-react": "^5.0.2",
14195
- "circuit-json": "^0.0.374",
14196
- "circuit-to-canvas": "^0.0.79",
14247
+ "circuit-json": "^0.0.387",
14248
+ "circuit-to-canvas": "^0.0.81",
14197
14249
  "circuit-to-svg": "^0.0.323",
14198
14250
  color: "^4.2.3",
14199
14251
  "react-supergrid": "^1.0.10",