@tscircuit/core 0.0.1038 → 0.0.1040

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 (3) hide show
  1. package/dist/index.d.ts +1103 -68
  2. package/dist/index.js +719 -620
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ __export(components_exports, {
33
33
  Fiducial: () => Fiducial,
34
34
  Footprint: () => Footprint,
35
35
  Fuse: () => Fuse,
36
- Group: () => Group,
36
+ Group: () => Group6,
37
37
  Hole: () => Hole,
38
38
  Inductor: () => Inductor,
39
39
  Interconnect: () => Interconnect,
@@ -296,6 +296,7 @@ import Debug from "debug";
296
296
  var debug = Debug("tscircuit:renderable");
297
297
  var orderedRenderPhases = [
298
298
  "ReactSubtreesRender",
299
+ "RenderIsolatedSubcircuits",
299
300
  "InflateSubcircuitCircuitJson",
300
301
  "SourceNameDuplicateComponentRemoval",
301
302
  "PcbFootprintStringRender",
@@ -351,6 +352,7 @@ var renderPhaseIndexMap = new Map(
351
352
  orderedRenderPhases.map((phase, index) => [phase, index])
352
353
  );
353
354
  var asyncPhaseDependencies = {
355
+ InflateSubcircuitCircuitJson: ["RenderIsolatedSubcircuits"],
354
356
  PcbFootprintLayout: ["PcbFootprintStringRender"],
355
357
  PcbComponentSizeCalculation: ["PcbFootprintStringRender"],
356
358
  PcbLayout: ["PcbFootprintStringRender"],
@@ -8081,7 +8083,7 @@ var CadModel = class extends PrimitiveComponent2 {
8081
8083
  pcb_component_id: parent.pcb_component_id,
8082
8084
  source_component_id: parent.source_component_id,
8083
8085
  model_unit_to_mm_scale_factor: typeof props.modelUnitToMmScale === "number" ? props.modelUnitToMmScale : void 0,
8084
- show_as_translucent_model: parent._parsedProps.showAsTranslucentModel,
8086
+ show_as_translucent_model: props.showAsTranslucentModel ?? parent._parsedProps.showAsTranslucentModel,
8085
8087
  ...urlProps
8086
8088
  });
8087
8089
  this.cad_component_id = cad.cad_component_id;
@@ -10160,7 +10162,7 @@ import {
10160
10162
  import {
10161
10163
  distance as distance8
10162
10164
  } from "circuit-json";
10163
- import Debug14 from "debug";
10165
+ import Debug13 from "debug";
10164
10166
 
10165
10167
  // lib/utils/autorouting/CapacityMeshAutorouter.ts
10166
10168
  import "@tscircuit/capacity-autorouter";
@@ -12569,464 +12571,59 @@ var Group_doInitialPcbLayoutPack = (group) => {
12569
12571
  });
12570
12572
  };
12571
12573
 
12572
- // lib/IsolatedCircuit.ts
12573
- import { su as su5 } from "@tscircuit/circuit-json-util";
12574
- import Debug7 from "debug";
12575
- import { isValidElement as isValidElement2 } from "react";
12576
- import { identity as identity4 } from "transformation-matrix";
12577
-
12578
- // package.json
12579
- var package_default = {
12580
- name: "@tscircuit/core",
12581
- type: "module",
12582
- version: "0.0.1037",
12583
- types: "dist/index.d.ts",
12584
- main: "dist/index.js",
12585
- module: "dist/index.js",
12586
- exports: {
12587
- ".": {
12588
- import: "./dist/index.js",
12589
- types: "./dist/index.d.ts"
12590
- }
12591
- },
12592
- files: [
12593
- "dist"
12594
- ],
12595
- repository: {
12596
- type: "git",
12597
- url: "https://github.com/tscircuit/core"
12598
- },
12599
- scripts: {
12600
- build: "tsup-node index.ts --format esm --dts",
12601
- format: "biome format . --write",
12602
- "measure-bundle": "howfat -r table .",
12603
- "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
12604
- "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
12605
- "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
12606
- "build:benchmarking:watch": `chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,
12607
- "start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"',
12608
- "generate-test-plan": "bun run scripts/generate-test-plan.ts"
12609
- },
12610
- devDependencies: {
12611
- "@biomejs/biome": "^1.8.3",
12612
- "@resvg/resvg-js": "^2.6.2",
12613
- "@tscircuit/alphabet": "0.0.18",
12614
- "@tscircuit/capacity-autorouter": "^0.0.269",
12615
- "@tscircuit/checks": "^0.0.90",
12616
- "@tscircuit/circuit-json-util": "^0.0.77",
12617
- "@tscircuit/common": "^0.0.20",
12618
- "@tscircuit/copper-pour-solver": "^0.0.20",
12619
- "@tscircuit/footprinter": "^0.0.288",
12620
- "@tscircuit/infgrid-ijump-astar": "^0.0.35",
12621
- "@tscircuit/log-soup": "^1.0.2",
12622
- "@tscircuit/matchpack": "^0.0.16",
12623
- "@tscircuit/math-utils": "^0.0.29",
12624
- "@tscircuit/miniflex": "^0.0.4",
12625
- "@tscircuit/ngspice-spice-engine": "^0.0.8",
12626
- "@tscircuit/props": "^0.0.474",
12627
- "@tscircuit/schematic-match-adapt": "^0.0.16",
12628
- "@tscircuit/schematic-trace-solver": "^v0.0.45",
12629
- "@tscircuit/solver-utils": "^0.0.3",
12630
- "@tscircuit/soup-util": "^0.0.41",
12631
- "@types/bun": "^1.2.16",
12632
- "@types/debug": "^4.1.12",
12633
- "@types/react": "^19.1.8",
12634
- "@types/react-dom": "^19.1.6",
12635
- "@types/react-reconciler": "^0.28.9",
12636
- "bpc-graph": "^0.0.57",
12637
- "bun-match-svg": "0.0.12",
12638
- "calculate-elbow": "^0.0.12",
12639
- "chokidar-cli": "^3.0.0",
12640
- "circuit-json": "^0.0.379",
12641
- "circuit-json-to-bpc": "^0.0.13",
12642
- "circuit-json-to-connectivity-map": "^0.0.23",
12643
- "circuit-json-to-gltf": "^0.0.65",
12644
- "circuit-json-to-simple-3d": "^0.0.9",
12645
- "circuit-json-to-spice": "^0.0.34",
12646
- "circuit-to-svg": "^0.0.328",
12647
- concurrently: "^9.1.2",
12648
- "connectivity-map": "^1.0.0",
12649
- debug: "^4.3.6",
12650
- "eecircuit-engine": "^1.5.6",
12651
- flatbush: "^4.5.0",
12652
- "graphics-debug": "^0.0.60",
12653
- howfat: "^0.3.8",
12654
- "live-server": "^1.2.2",
12655
- "looks-same": "^9.0.1",
12656
- minicssgrid: "^0.0.9",
12657
- "pkg-pr-new": "^0.0.37",
12658
- poppygl: "^0.0.16",
12659
- react: "^19.1.0",
12660
- "react-dom": "^19.1.0",
12661
- "schematic-symbols": "^0.0.208",
12662
- spicey: "^0.0.14",
12663
- "ts-expect": "^1.3.0",
12664
- tsup: "^8.2.4"
12665
- },
12666
- peerDependencies: {
12667
- "@tscircuit/capacity-autorouter": "*",
12668
- "@tscircuit/checks": "*",
12669
- "@tscircuit/circuit-json-util": "*",
12670
- "@tscircuit/footprinter": "*",
12671
- "@tscircuit/infgrid-ijump-astar": "*",
12672
- "@tscircuit/math-utils": "*",
12673
- "@tscircuit/props": "*",
12674
- "@tscircuit/schematic-match-adapt": "*",
12675
- "circuit-json-to-bpc": "*",
12676
- "bpc-graph": "*",
12677
- "@tscircuit/matchpack": "*",
12678
- "circuit-json": "*",
12679
- "circuit-json-to-connectivity-map": "*",
12680
- "schematic-symbols": "*",
12681
- typescript: "^5.0.0"
12682
- },
12683
- dependencies: {
12684
- "@flatten-js/core": "^1.6.2",
12685
- "@lume/kiwi": "^0.4.3",
12686
- "calculate-packing": "0.0.68",
12687
- "css-select": "5.1.0",
12688
- "format-si-unit": "^0.0.3",
12689
- nanoid: "^5.0.7",
12690
- "performance-now": "^2.1.0",
12691
- "react-reconciler": "^0.32.0",
12692
- "svg-path-commander": "^2.1.11",
12693
- "transformation-matrix": "^2.16.1",
12694
- zod: "^3.25.67"
12574
+ // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutFlex.ts
12575
+ import {
12576
+ getCircuitJsonTree,
12577
+ getMinimumFlexContainer as getMinimumFlexContainer2,
12578
+ repositionSchematicComponentTo,
12579
+ repositionSchematicGroupTo
12580
+ } from "@tscircuit/circuit-json-util";
12581
+ import { RootFlexBox as RootFlexBox2 } from "@tscircuit/miniflex";
12582
+ import { length as length4 } from "circuit-json";
12583
+ var getSizeOfTreeNodeChild = (db, child) => {
12584
+ const { sourceComponent, sourceGroup } = child;
12585
+ if (child.nodeType === "component") {
12586
+ const schComponent = db.schematic_component.getWhere({
12587
+ source_component_id: sourceComponent?.source_component_id
12588
+ });
12589
+ if (!schComponent?.size) return null;
12590
+ return {
12591
+ width: schComponent.size.width,
12592
+ height: schComponent.size.height
12593
+ };
12695
12594
  }
12696
- };
12697
-
12698
- // lib/IsolatedCircuit.ts
12699
- var IsolatedCircuit = class {
12700
- firstChild = null;
12701
- children;
12702
- db;
12703
- root = null;
12704
- isRootCircuit = false;
12705
- _schematicDisabledOverride;
12706
- get schematicDisabled() {
12707
- if (this._schematicDisabledOverride !== void 0) {
12708
- return this._schematicDisabledOverride;
12709
- }
12710
- if (this.platform?.schematicDisabled !== void 0) {
12711
- return this.platform.schematicDisabled;
12595
+ if (child.nodeType === "group") {
12596
+ const schGroup = db.schematic_group.getWhere({
12597
+ source_group_id: sourceGroup?.source_group_id
12598
+ });
12599
+ if (schGroup?.width && schGroup?.height) {
12600
+ return {
12601
+ width: schGroup.width,
12602
+ height: schGroup.height
12603
+ };
12712
12604
  }
12713
- const board = this._getBoard();
12714
- return board?._parsedProps?.schematicDisabled ?? false;
12715
- }
12716
- set schematicDisabled(value) {
12717
- this._schematicDisabledOverride = value;
12718
- }
12719
- pcbDisabled = false;
12720
- pcbRoutingDisabled = false;
12721
- _featureMspSchematicTraceRouting = true;
12722
- /**
12723
- * The IsolatedCircuit name is usually set by the platform, it's not required but
12724
- * if supplied can identify the circuit in certain effects, e.g. it is passed
12725
- * as the display_name parameter for autorouting effects.
12726
- */
12727
- name;
12728
- platform;
12729
- /**
12730
- * Optional URL pointing to where this project is hosted or documented.
12731
- * When provided it is stored in the source_project_metadata.project_url field
12732
- * of the generated Circuit JSON.
12733
- */
12734
- projectUrl;
12735
- _hasRenderedAtleastOnce = false;
12736
- _asyncEffectIdsByPhase = /* @__PURE__ */ new Map();
12737
- _asyncEffectPhaseById = /* @__PURE__ */ new Map();
12738
- constructor({
12739
- platform,
12740
- projectUrl
12741
- } = {}) {
12742
- this.children = [];
12743
- this.db = su5([]);
12744
- this.platform = platform;
12745
- this.projectUrl = projectUrl;
12746
- this.pcbDisabled = platform?.pcbDisabled ?? false;
12747
- this.root = this;
12748
- }
12749
- add(componentOrElm) {
12750
- let component;
12751
- if (isValidElement2(componentOrElm)) {
12752
- component = createInstanceFromReactElement(componentOrElm);
12753
- } else {
12754
- component = componentOrElm;
12605
+ const groupComponents = db.schematic_component.list({
12606
+ schematic_group_id: schGroup?.schematic_group_id
12607
+ });
12608
+ let minX = Infinity;
12609
+ let maxX = -Infinity;
12610
+ let minY = Infinity;
12611
+ let maxY = -Infinity;
12612
+ for (const comp of groupComponents) {
12613
+ if (comp.center && comp.size) {
12614
+ const halfWidth = comp.size.width / 2;
12615
+ const halfHeight = comp.size.height / 2;
12616
+ minX = Math.min(minX, comp.center.x - halfWidth);
12617
+ maxX = Math.max(maxX, comp.center.x + halfWidth);
12618
+ minY = Math.min(minY, comp.center.y - halfHeight);
12619
+ maxY = Math.max(maxY, comp.center.y + halfHeight);
12620
+ }
12755
12621
  }
12756
- this.children.push(component);
12757
- }
12758
- setPlatform(platform) {
12759
- this.platform = {
12760
- ...this.platform,
12761
- ...platform
12762
- };
12763
- }
12764
- /**
12765
- * Get the main board for this Circuit.
12766
- */
12767
- _getBoard() {
12768
- const directBoard = this.children.find((c) => c.componentName === "Board");
12769
- if (directBoard) {
12770
- return directBoard;
12771
- }
12772
- return void 0;
12773
- }
12774
- _guessRootComponent() {
12775
- if (this.firstChild) return;
12776
- if (this.children.length === 0) {
12777
- throw new Error(
12778
- "Not able to guess root component: IsolatedCircuit has no children (use circuit.add(...))"
12779
- );
12780
- }
12781
- const panels = this.children.filter(
12782
- (child) => child.lowercaseComponentName === "panel"
12783
- );
12784
- if (panels.length > 1) {
12785
- throw new Error("Only one <panel> is allowed per circuit");
12786
- }
12787
- if (panels.length === 1) {
12788
- if (this.children.length !== 1) {
12789
- throw new Error("<panel> must be the root element of the circuit");
12790
- }
12791
- this.firstChild = panels[0];
12792
- return;
12793
- }
12794
- if (this.children.length === 1 && this.children[0].isGroup) {
12795
- this.firstChild = this.children[0];
12796
- return;
12797
- }
12798
- const group = new Group({ subcircuit: true });
12799
- group.parent = this;
12800
- group.addAll(this.children);
12801
- this.children = [group];
12802
- this.firstChild = group;
12803
- }
12804
- render() {
12805
- if (!this.firstChild) {
12806
- this._guessRootComponent();
12807
- }
12808
- const { firstChild, db } = this;
12809
- if (!firstChild) throw new Error("IsolatedCircuit has no root component");
12810
- firstChild.parent = this;
12811
- firstChild.runRenderCycle();
12812
- this._hasRenderedAtleastOnce = true;
12813
- }
12814
- async renderUntilSettled() {
12815
- const existing = this.db.source_project_metadata.list()?.[0];
12816
- if (!existing) {
12817
- this.db.source_project_metadata.insert({
12818
- software_used_string: `@tscircuit/core@${this.getCoreVersion()}`,
12819
- ...this.projectUrl ? { project_url: this.projectUrl } : {}
12820
- });
12821
- }
12822
- this.render();
12823
- while (this._hasIncompleteAsyncEffects()) {
12824
- await new Promise((resolve) => setTimeout(resolve, 100));
12825
- this.render();
12826
- }
12827
- this.emit("renderComplete");
12828
- }
12829
- _hasIncompleteAsyncEffects() {
12830
- if (this._asyncEffectPhaseById.size > 0) return true;
12831
- return this.children.some((child) => child._hasIncompleteAsyncEffects());
12832
- }
12833
- _hasIncompleteAsyncEffectsForPhase(phase) {
12834
- return (this._asyncEffectIdsByPhase.get(phase)?.size ?? 0) > 0;
12835
- }
12836
- getCircuitJson() {
12837
- if (!this._hasRenderedAtleastOnce) this.render();
12838
- return this.db.toArray();
12839
- }
12840
- toJson() {
12841
- return this.getCircuitJson();
12842
- }
12843
- async getSvg(options) {
12844
- const circuitToSvg = await import("circuit-to-svg").catch((e) => {
12845
- throw new Error(
12846
- `To use circuit.getSvg, you must install the "circuit-to-svg" package.
12847
-
12848
- "${e.message}"`
12849
- );
12850
- });
12851
- if (options.view === "pcb") {
12852
- return circuitToSvg.convertCircuitJsonToPcbSvg(this.getCircuitJson());
12853
- }
12854
- if (options.view === "schematic") {
12855
- return circuitToSvg.convertCircuitJsonToSchematicSvg(
12856
- this.getCircuitJson()
12857
- );
12858
- }
12859
- throw new Error(`Invalid view: ${options.view}`);
12860
- }
12861
- getCoreVersion() {
12862
- const [major, minor, patch] = package_default.version.split(".").map(Number);
12863
- return `${major}.${minor}.${patch + 1}`;
12864
- }
12865
- async preview(previewNameOrOpts) {
12866
- const previewOpts = typeof previewNameOrOpts === "object" ? previewNameOrOpts : { previewName: previewNameOrOpts };
12867
- throw new Error("project.preview is not yet implemented");
12868
- }
12869
- computeSchematicGlobalTransform() {
12870
- return identity4();
12871
- }
12872
- _computePcbGlobalTransformBeforeLayout() {
12873
- return identity4();
12874
- }
12875
- selectAll(selector) {
12876
- this._guessRootComponent();
12877
- return this.firstChild?.selectAll(selector) ?? [];
12878
- }
12879
- selectOne(selector, opts) {
12880
- this._guessRootComponent();
12881
- return this.firstChild?.selectOne(selector, opts) ?? null;
12882
- }
12883
- _eventListeners = {};
12884
- emit(event, ...args) {
12885
- if (event === "asyncEffect:start") {
12886
- this._registerAsyncEffectStart(args[0]);
12887
- } else if (event === "asyncEffect:end") {
12888
- this._registerAsyncEffectEnd(args[0]);
12889
- }
12890
- if (!this._eventListeners[event]) return;
12891
- for (const listener of this._eventListeners[event]) {
12892
- listener(...args);
12893
- }
12894
- }
12895
- on(event, listener) {
12896
- if (!this._eventListeners[event]) {
12897
- this._eventListeners[event] = [];
12898
- }
12899
- this._eventListeners[event].push(listener);
12900
- }
12901
- removeListener(event, listener) {
12902
- if (!this._eventListeners[event]) return;
12903
- this._eventListeners[event] = this._eventListeners[event].filter(
12904
- (l) => l !== listener
12905
- );
12906
- }
12907
- enableDebug(debug11) {
12908
- if (typeof debug11 === "string") {
12909
- Debug7.enable(debug11);
12910
- } else if (debug11 === null || debug11 === false) {
12911
- Debug7.disable();
12912
- }
12913
- }
12914
- getClientOrigin() {
12915
- if (typeof window !== "undefined" && window.location) {
12916
- return window.location.origin;
12917
- }
12918
- if (typeof self !== "undefined" && self.location) {
12919
- return self.location.origin;
12920
- }
12921
- return "";
12922
- }
12923
- _registerAsyncEffectStart(payload) {
12924
- if (!payload?.asyncEffectId || !payload.phase) return;
12925
- const { asyncEffectId, phase } = payload;
12926
- const existingPhase = this._asyncEffectPhaseById.get(asyncEffectId);
12927
- if (existingPhase && existingPhase !== phase) {
12928
- this._asyncEffectIdsByPhase.get(existingPhase)?.delete(asyncEffectId);
12929
- }
12930
- if (!this._asyncEffectIdsByPhase.has(phase)) {
12931
- this._asyncEffectIdsByPhase.set(phase, /* @__PURE__ */ new Set());
12932
- }
12933
- this._asyncEffectIdsByPhase.get(phase).add(asyncEffectId);
12934
- this._asyncEffectPhaseById.set(asyncEffectId, phase);
12935
- }
12936
- _registerAsyncEffectEnd(payload) {
12937
- if (!payload?.asyncEffectId) return;
12938
- const { asyncEffectId } = payload;
12939
- const phase = this._asyncEffectPhaseById.get(asyncEffectId) ?? payload.phase;
12940
- if (phase) {
12941
- const phaseSet = this._asyncEffectIdsByPhase.get(phase);
12942
- phaseSet?.delete(asyncEffectId);
12943
- if (phaseSet && phaseSet.size === 0) {
12944
- this._asyncEffectIdsByPhase.delete(phase);
12945
- }
12946
- }
12947
- this._asyncEffectPhaseById.delete(asyncEffectId);
12948
- }
12949
- };
12950
-
12951
- // lib/components/primitive-components/Group/Group_doInitialRenderIsolatedSubcircuits.ts
12952
- function Group_doInitialRenderIsolatedSubcircuits(group) {
12953
- if (!group._isolatedCircuit) {
12954
- const parentRoot = group.root;
12955
- group._isolatedCircuit = new IsolatedCircuit({
12956
- platform: {
12957
- ...parentRoot.platform,
12958
- pcbDisabled: parentRoot.pcbDisabled,
12959
- schematicDisabled: parentRoot.schematicDisabled
12960
- }
12961
- });
12962
- for (const child of group.children) {
12963
- group._isolatedCircuit.add(child);
12964
- }
12965
- }
12966
- group._isolatedCircuit.render();
12967
- if (group._isolatedCircuit._hasIncompleteAsyncEffects()) {
12968
- return false;
12969
- }
12970
- group._isolatedCircuitJson = group._isolatedCircuit.getCircuitJson();
12971
- group.children = [];
12972
- group._normalComponentNameMap = null;
12973
- group._isolatedCircuit = null;
12974
- return true;
12975
- }
12976
-
12977
- // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutFlex.ts
12978
- import {
12979
- getCircuitJsonTree,
12980
- getMinimumFlexContainer as getMinimumFlexContainer2,
12981
- repositionSchematicComponentTo,
12982
- repositionSchematicGroupTo
12983
- } from "@tscircuit/circuit-json-util";
12984
- import { RootFlexBox as RootFlexBox2 } from "@tscircuit/miniflex";
12985
- import { length as length4 } from "circuit-json";
12986
- var getSizeOfTreeNodeChild = (db, child) => {
12987
- const { sourceComponent, sourceGroup } = child;
12988
- if (child.nodeType === "component") {
12989
- const schComponent = db.schematic_component.getWhere({
12990
- source_component_id: sourceComponent?.source_component_id
12991
- });
12992
- if (!schComponent?.size) return null;
12993
- return {
12994
- width: schComponent.size.width,
12995
- height: schComponent.size.height
12996
- };
12997
- }
12998
- if (child.nodeType === "group") {
12999
- const schGroup = db.schematic_group.getWhere({
13000
- source_group_id: sourceGroup?.source_group_id
13001
- });
13002
- if (schGroup?.width && schGroup?.height) {
13003
- return {
13004
- width: schGroup.width,
13005
- height: schGroup.height
13006
- };
13007
- }
13008
- const groupComponents = db.schematic_component.list({
13009
- schematic_group_id: schGroup?.schematic_group_id
13010
- });
13011
- let minX = Infinity;
13012
- let maxX = -Infinity;
13013
- let minY = Infinity;
13014
- let maxY = -Infinity;
13015
- for (const comp of groupComponents) {
13016
- if (comp.center && comp.size) {
13017
- const halfWidth = comp.size.width / 2;
13018
- const halfHeight = comp.size.height / 2;
13019
- minX = Math.min(minX, comp.center.x - halfWidth);
13020
- maxX = Math.max(maxX, comp.center.x + halfWidth);
13021
- minY = Math.min(minY, comp.center.y - halfHeight);
13022
- maxY = Math.max(maxY, comp.center.y + halfHeight);
13023
- }
13024
- }
13025
- const groupWidth = maxX - minX;
13026
- const groupHeight = maxY - minY;
13027
- return {
13028
- width: groupWidth,
13029
- height: groupHeight
12622
+ const groupWidth = maxX - minX;
12623
+ const groupHeight = maxY - minY;
12624
+ return {
12625
+ width: groupWidth,
12626
+ height: groupHeight
13030
12627
  };
13031
12628
  }
13032
12629
  return null;
@@ -13354,9 +12951,9 @@ function Group_doInitialSchematicLayoutGrid(group) {
13354
12951
  // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
13355
12952
  import { convertCircuitJsonToBpc } from "circuit-json-to-bpc";
13356
12953
  import { getGraphicsForBpcGraph, layoutSchematicGraphVariants } from "bpc-graph";
13357
- import Debug8 from "debug";
12954
+ import Debug7 from "debug";
13358
12955
  import { buildSubtree } from "@tscircuit/circuit-json-util";
13359
- var debug5 = Debug8("Group_doInitialSchematicLayoutMatchAdapt");
12956
+ var debug5 = Debug7("Group_doInitialSchematicLayoutMatchAdapt");
13360
12957
  function Group_doInitialSchematicLayoutMatchAdapt(group) {
13361
12958
  const { db } = group.root;
13362
12959
  const subtreeCircuitJson = buildSubtree(db.toArray(), {
@@ -13482,8 +13079,8 @@ import {
13482
13079
  getCircuitJsonTree as getCircuitJsonTree2
13483
13080
  } from "@tscircuit/circuit-json-util";
13484
13081
  import { LayoutPipelineSolver } from "@tscircuit/matchpack";
13485
- import Debug9 from "debug";
13486
- var debug6 = Debug9("Group_doInitialSchematicLayoutMatchpack");
13082
+ import Debug8 from "debug";
13083
+ var debug6 = Debug8("Group_doInitialSchematicLayoutMatchpack");
13487
13084
  function facingDirectionToSide(facingDirection) {
13488
13085
  switch (facingDirection) {
13489
13086
  case "up":
@@ -14101,7 +13698,7 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
14101
13698
 
14102
13699
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts
14103
13700
  import { SchematicTracePipelineSolver as SchematicTracePipelineSolver4 } from "@tscircuit/schematic-trace-solver";
14104
- import Debug12 from "debug";
13701
+ import Debug11 from "debug";
14105
13702
 
14106
13703
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/createSchematicTraceSolverInputProblem.ts
14107
13704
  import "@tscircuit/schematic-trace-solver";
@@ -14620,8 +14217,8 @@ function computeJunctions(traces, opts = {}) {
14620
14217
  }
14621
14218
 
14622
14219
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts
14623
- import Debug10 from "debug";
14624
- var debug7 = Debug10("Group_doInitialSchematicTraceRender");
14220
+ import Debug9 from "debug";
14221
+ var debug7 = Debug9("Group_doInitialSchematicTraceRender");
14625
14222
  function applyTracesFromSolverOutput(args) {
14626
14223
  const { group, solver, pinIdToSchematicPortId, userNetIdToSck } = args;
14627
14224
  const { db } = group.root;
@@ -14733,8 +14330,8 @@ var getNetNameFromPorts = (ports) => {
14733
14330
  };
14734
14331
 
14735
14332
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyNetLabelPlacements.ts
14736
- import Debug11 from "debug";
14737
- var debug8 = Debug11("Group_doInitialSchematicTraceRender");
14333
+ import Debug10 from "debug";
14334
+ var debug8 = Debug10("Group_doInitialSchematicTraceRender");
14738
14335
  function applyNetLabelPlacements(args) {
14739
14336
  const {
14740
14337
  group,
@@ -14899,7 +14496,7 @@ var getSchematicPortIdsWithRoutedTraces = ({
14899
14496
  };
14900
14497
 
14901
14498
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts
14902
- var debug9 = Debug12("Group_doInitialSchematicTraceRender");
14499
+ var debug9 = Debug11("Group_doInitialSchematicTraceRender");
14903
14500
  var Group_doInitialSchematicTraceRender = (group) => {
14904
14501
  if (!group.root?._featureMspSchematicTraceRouting) return;
14905
14502
  if (!group.isSubcircuit) return;
@@ -14959,7 +14556,7 @@ var Group_doInitialSchematicTraceRender = (group) => {
14959
14556
 
14960
14557
  // lib/components/primitive-components/Group/Group_doInitialSimulationSpiceEngineRender.ts
14961
14558
  import { circuitJsonToSpice } from "circuit-json-to-spice";
14962
- import Debug13 from "debug";
14559
+ import Debug12 from "debug";
14963
14560
 
14964
14561
  // lib/spice/get-spicey-engine.ts
14965
14562
  import { simulate, spiceyTranToVGraphs } from "spicey";
@@ -15017,7 +14614,7 @@ function resetSimulationColorState() {
15017
14614
  }
15018
14615
 
15019
14616
  // lib/components/primitive-components/Group/Group_doInitialSimulationSpiceEngineRender.ts
15020
- var debug10 = Debug13("tscircuit:core:Group_doInitialSimulationSpiceEngineRender");
14617
+ var debug10 = Debug12("tscircuit:core:Group_doInitialSimulationSpiceEngineRender");
15021
14618
  function Group_doInitialSimulationSpiceEngineRender(group) {
15022
14619
  if (!group.isSubcircuit) return;
15023
14620
  const { root } = group;
@@ -15503,14 +15100,13 @@ function computeCenterFromAnchorPosition(anchorPosition, ctx) {
15503
15100
  }
15504
15101
 
15505
15102
  // lib/components/primitive-components/Group/Group.ts
15506
- var Group = class extends NormalComponent3 {
15103
+ var Group6 = class extends NormalComponent3 {
15507
15104
  pcb_group_id = null;
15508
15105
  schematic_group_id = null;
15509
15106
  subcircuit_id = null;
15510
15107
  _hasStartedAsyncAutorouting = false;
15511
15108
  _isInflatedFromCircuitJson = false;
15512
15109
  _isolatedCircuitJson = null;
15513
- _isolatedCircuit = null;
15514
15110
  get _isIsolatedSubcircuit() {
15515
15111
  return Boolean(this._parsedProps._subcircuitCachingEnabled);
15516
15112
  }
@@ -15550,14 +15146,6 @@ var Group = class extends NormalComponent3 {
15550
15146
  componentName: "Group"
15551
15147
  };
15552
15148
  }
15553
- runRenderCycle() {
15554
- if (!this._isIsolatedSubcircuit || !this.root) {
15555
- super.runRenderCycle();
15556
- return;
15557
- }
15558
- if (!Group_doInitialRenderIsolatedSubcircuits(this)) return;
15559
- super.runRenderCycle();
15560
- }
15561
15149
  doInitialSourceGroupRender() {
15562
15150
  const { db } = this.root;
15563
15151
  const hasExplicitName = typeof this._parsedProps.name === "string" && this._parsedProps.name.length > 0;
@@ -15746,14 +15334,14 @@ var Group = class extends NormalComponent3 {
15746
15334
  return false;
15747
15335
  }
15748
15336
  _hasTracesToRoute() {
15749
- const debug11 = Debug14("tscircuit:core:_hasTracesToRoute");
15337
+ const debug11 = Debug13("tscircuit:core:_hasTracesToRoute");
15750
15338
  const traces = this.selectAll("trace");
15751
15339
  debug11(`[${this.getString()}] has ${traces.length} traces to route`);
15752
15340
  return traces.length > 0;
15753
15341
  }
15754
15342
  async _runEffectMakeHttpAutoroutingRequest() {
15755
15343
  const { db } = this.root;
15756
- const debug11 = Debug14("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
15344
+ const debug11 = Debug13("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
15757
15345
  const props = this._parsedProps;
15758
15346
  const autorouterConfig = this._getAutorouterConfig();
15759
15347
  const serverUrl = autorouterConfig.serverUrl;
@@ -15876,7 +15464,7 @@ var Group = class extends NormalComponent3 {
15876
15464
  async _runLocalAutorouting() {
15877
15465
  const { db } = this.root;
15878
15466
  const props = this._parsedProps;
15879
- const debug11 = Debug14("tscircuit:core:_runLocalAutorouting");
15467
+ const debug11 = Debug13("tscircuit:core:_runLocalAutorouting");
15880
15468
  debug11(`[${this.getString()}] starting local autorouting`);
15881
15469
  const autorouterConfig = this._getAutorouterConfig();
15882
15470
  const isLaserPrefabPreset = this._isLaserPrefabAutorouter(autorouterConfig);
@@ -16015,7 +15603,7 @@ var Group = class extends NormalComponent3 {
16015
15603
  }
16016
15604
  }
16017
15605
  doInitialPcbTraceRender() {
16018
- const debug11 = Debug14("tscircuit:core:doInitialPcbTraceRender");
15606
+ const debug11 = Debug13("tscircuit:core:doInitialPcbTraceRender");
16019
15607
  if (!this.isSubcircuit) return;
16020
15608
  if (this.root?.pcbDisabled) return;
16021
15609
  if (this.getInheritedProperty("routingDisabled")) return;
@@ -16037,7 +15625,7 @@ var Group = class extends NormalComponent3 {
16037
15625
  Group_doInitialSchematicTraceRender(this);
16038
15626
  }
16039
15627
  updatePcbTraceRender() {
16040
- const debug11 = Debug14("tscircuit:core:updatePcbTraceRender");
15628
+ const debug11 = Debug13("tscircuit:core:updatePcbTraceRender");
16041
15629
  debug11(`[${this.getString()}] updating...`);
16042
15630
  if (!this.isSubcircuit) return;
16043
15631
  if (this._isInflatedFromCircuitJson) return;
@@ -16994,7 +16582,7 @@ function inflateSourceDiode(sourceElm, inflatorContext) {
16994
16582
  // lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceGroup.ts
16995
16583
  function inflateSourceGroup(sourceGroup, inflatorContext) {
16996
16584
  const { subcircuit, groupsMap } = inflatorContext;
16997
- const group = new Group({
16585
+ const group = new Group6({
16998
16586
  name: sourceGroup.name ?? `inflated_group_${sourceGroup.source_group_id}`
16999
16587
  });
17000
16588
  group.source_group_id = sourceGroup.source_group_id;
@@ -17235,7 +16823,13 @@ function pcbTraceRouteToPcbPath(route) {
17235
16823
  if (route.length <= 2) {
17236
16824
  return [];
17237
16825
  }
17238
- return route.slice(1, -1).map((point6) => {
16826
+ const firstPoint = route[0];
16827
+ const lastPoint = route[route.length - 1];
16828
+ return route.slice(1, -1).filter((point6) => {
16829
+ const isSameAsFirst = point6.x === firstPoint.x && point6.y === firstPoint.y;
16830
+ const isSameAsLast = point6.x === lastPoint.x && point6.y === lastPoint.y;
16831
+ return !isSameAsFirst && !isSameAsLast;
16832
+ }).map((point6) => {
17239
16833
  if (point6.route_type === "via") {
17240
16834
  return {
17241
16835
  x: point6.x,
@@ -17316,6 +16910,8 @@ function inflateSourceTrace(sourceTrace, inflatorContext) {
17316
16910
  };
17317
16911
  if (pcbPath && pcbPath.length > 0) {
17318
16912
  traceProps2.pcbPath = pcbPath;
16913
+ } else if (pcbTrace) {
16914
+ traceProps2.pcbStraightLine = true;
17319
16915
  }
17320
16916
  const trace = new Trace3(traceProps2);
17321
16917
  trace.source_trace_id = sourceTrace.source_trace_id;
@@ -17527,7 +17123,7 @@ var getRoundedRectOutline = (width, height, radius) => {
17527
17123
  }
17528
17124
  return outline;
17529
17125
  };
17530
- var Board = class extends Group {
17126
+ var Board = class extends Group6 {
17531
17127
  pcb_board_id = null;
17532
17128
  source_board_id = null;
17533
17129
  _drcChecksComplete = false;
@@ -17778,152 +17374,631 @@ var Board = class extends Group {
17778
17374
  computedWidth = maxX - minX;
17779
17375
  computedHeight = maxY - minY;
17780
17376
  }
17781
- let outline = props.outline;
17782
- if (!outline && props.borderRadius != null && computedWidth > 0 && computedHeight > 0) {
17783
- outline = getRoundedRectOutline(
17784
- computedWidth,
17785
- computedHeight,
17786
- props.borderRadius
17377
+ let outline = props.outline;
17378
+ if (!outline && props.borderRadius != null && computedWidth > 0 && computedHeight > 0) {
17379
+ outline = getRoundedRectOutline(
17380
+ computedWidth,
17381
+ computedHeight,
17382
+ props.borderRadius
17383
+ );
17384
+ }
17385
+ let outlineTranslation = { x: 0, y: 0 };
17386
+ if (outline && outline.length > 0 && (this.parent?.lowercaseComponentName === "panel" || this.parent?.lowercaseComponentName === "subpanel")) {
17387
+ const outlineBounds = getBoundsFromPoints4(outline);
17388
+ if (outlineBounds) {
17389
+ const outlineCenterX = (outlineBounds.minX + outlineBounds.maxX) / 2;
17390
+ const outlineCenterY = (outlineBounds.minY + outlineBounds.maxY) / 2;
17391
+ outlineTranslation = {
17392
+ x: center.x - outlineCenterX,
17393
+ y: center.y - outlineCenterY
17394
+ };
17395
+ }
17396
+ }
17397
+ const pcb_board = db.pcb_board.insert({
17398
+ source_board_id: this.source_board_id,
17399
+ center,
17400
+ thickness: this.boardThickness,
17401
+ num_layers: this.allLayers.length,
17402
+ width: computedWidth,
17403
+ height: computedHeight,
17404
+ outline: outline?.map((point6) => ({
17405
+ x: point6.x + (props.outlineOffsetX ?? 0) + outlineTranslation.x,
17406
+ y: point6.y + (props.outlineOffsetY ?? 0) + outlineTranslation.y
17407
+ })),
17408
+ material: props.material
17409
+ });
17410
+ this.pcb_board_id = pcb_board.pcb_board_id;
17411
+ this._addBoardInformationToSilkscreen();
17412
+ }
17413
+ removePcbComponentRender() {
17414
+ const { db } = this.root;
17415
+ if (!this.pcb_board_id) return;
17416
+ db.pcb_board.delete(this.pcb_board_id);
17417
+ this.pcb_board_id = null;
17418
+ }
17419
+ doInitialPcbDesignRuleChecks() {
17420
+ if (this.root?.pcbDisabled) return;
17421
+ if (this.getInheritedProperty("routingDisabled")) return;
17422
+ super.doInitialPcbDesignRuleChecks();
17423
+ }
17424
+ updatePcbDesignRuleChecks() {
17425
+ if (this.root?.pcbDisabled) return;
17426
+ if (this.getInheritedProperty("routingDisabled")) return;
17427
+ const { db } = this.root;
17428
+ if (!this._areChildSubcircuitsRouted()) return;
17429
+ if (this._drcChecksComplete) return;
17430
+ const runDrcChecks = (circuitJson) => {
17431
+ const pcbTraceOverlappingErrors = checkEachPcbTraceNonOverlapping(circuitJson);
17432
+ for (const error of pcbTraceOverlappingErrors) {
17433
+ db.pcb_trace_error.insert(error);
17434
+ }
17435
+ const pcbPortNotConnectedErrors = checkEachPcbPortConnectedToPcbTraces(circuitJson);
17436
+ for (const error of pcbPortNotConnectedErrors) {
17437
+ db.pcb_port_not_connected_error.insert(error);
17438
+ }
17439
+ const pcbComponentOutsideErrors = checkPcbComponentsOutOfBoard(circuitJson);
17440
+ for (const error of pcbComponentOutsideErrors) {
17441
+ db.pcb_component_outside_board_error.insert(error);
17442
+ }
17443
+ const pcbTracesOutOfBoardErrors = checkPcbTracesOutOfBoard(circuitJson);
17444
+ for (const error of pcbTracesOutOfBoardErrors) {
17445
+ db.pcb_trace_error.insert(error);
17446
+ }
17447
+ const differentNetViaErrors = checkDifferentNetViaSpacing(circuitJson);
17448
+ for (const error of differentNetViaErrors) {
17449
+ db.pcb_via_clearance_error.insert(error);
17450
+ }
17451
+ const sameNetViaErrors = checkSameNetViaSpacing(circuitJson);
17452
+ for (const error of sameNetViaErrors) {
17453
+ db.pcb_via_clearance_error.insert(error);
17454
+ }
17455
+ const pcbComponentOverlapErrors = checkPcbComponentOverlap(circuitJson);
17456
+ for (const error of pcbComponentOverlapErrors) {
17457
+ db.pcb_footprint_overlap_error.insert(error);
17458
+ }
17459
+ const sourcePinMustBeConnectedErrors = checkPinMustBeConnected(circuitJson);
17460
+ for (const error of sourcePinMustBeConnectedErrors) {
17461
+ db.source_pin_must_be_connected_error.insert(error);
17462
+ }
17463
+ };
17464
+ const subcircuit = db.subtree({ subcircuit_id: this.subcircuit_id });
17465
+ const subcircuitCircuitJson = subcircuit.toArray();
17466
+ runDrcChecks(subcircuitCircuitJson);
17467
+ this._drcChecksComplete = true;
17468
+ }
17469
+ _emitRenderLifecycleEvent(phase, startOrEnd) {
17470
+ super._emitRenderLifecycleEvent(phase, startOrEnd);
17471
+ if (startOrEnd === "start") {
17472
+ this.root?.emit("board:renderPhaseStarted", {
17473
+ renderId: this._renderId,
17474
+ phase
17475
+ });
17476
+ }
17477
+ }
17478
+ _repositionOnPcb(position) {
17479
+ const { db } = this.root;
17480
+ const pcbBoard = this.pcb_board_id ? db.pcb_board.get(this.pcb_board_id) : null;
17481
+ const oldPos = pcbBoard?.center;
17482
+ if (!oldPos) {
17483
+ if (this.pcb_board_id) {
17484
+ db.pcb_board.update(this.pcb_board_id, { center: position });
17485
+ }
17486
+ return;
17487
+ }
17488
+ const deltaX = position.x - oldPos.x;
17489
+ const deltaY = position.y - oldPos.y;
17490
+ if (Math.abs(deltaX) < 1e-6 && Math.abs(deltaY) < 1e-6) {
17491
+ return;
17492
+ }
17493
+ if (this.pcb_board_id) {
17494
+ db.pcb_board.update(this.pcb_board_id, { center: position });
17495
+ if (pcbBoard?.outline) {
17496
+ const outlineBounds = getBoundsFromPoints4(pcbBoard.outline);
17497
+ if (outlineBounds) {
17498
+ const oldOutlineCenter = {
17499
+ x: (outlineBounds.minX + outlineBounds.maxX) / 2,
17500
+ y: (outlineBounds.minY + outlineBounds.maxY) / 2
17501
+ };
17502
+ const outlineDeltaX = position.x - oldOutlineCenter.x;
17503
+ const outlineDeltaY = position.y - oldOutlineCenter.y;
17504
+ const newOutline = pcbBoard.outline.map((p) => ({
17505
+ x: p.x + outlineDeltaX,
17506
+ y: p.y + outlineDeltaY
17507
+ }));
17508
+ db.pcb_board.update(this.pcb_board_id, {
17509
+ outline: newOutline
17510
+ });
17511
+ }
17512
+ }
17513
+ }
17514
+ }
17515
+ };
17516
+
17517
+ // lib/components/normal-components/MountedBoard.ts
17518
+ import { mountedboardProps } from "@tscircuit/props";
17519
+
17520
+ // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
17521
+ import "@tscircuit/props";
17522
+
17523
+ // lib/IsolatedCircuit.ts
17524
+ import { su as su5 } from "@tscircuit/circuit-json-util";
17525
+ import Debug14 from "debug";
17526
+ import { isValidElement as isValidElement2 } from "react";
17527
+ import { identity as identity4 } from "transformation-matrix";
17528
+
17529
+ // package.json
17530
+ var package_default = {
17531
+ name: "@tscircuit/core",
17532
+ type: "module",
17533
+ version: "0.0.1039",
17534
+ types: "dist/index.d.ts",
17535
+ main: "dist/index.js",
17536
+ module: "dist/index.js",
17537
+ exports: {
17538
+ ".": {
17539
+ import: "./dist/index.js",
17540
+ types: "./dist/index.d.ts"
17541
+ }
17542
+ },
17543
+ files: [
17544
+ "dist"
17545
+ ],
17546
+ repository: {
17547
+ type: "git",
17548
+ url: "https://github.com/tscircuit/core"
17549
+ },
17550
+ scripts: {
17551
+ build: "tsup-node index.ts --format esm --dts",
17552
+ format: "biome format . --write",
17553
+ "measure-bundle": "howfat -r table .",
17554
+ "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
17555
+ "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
17556
+ "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
17557
+ "build:benchmarking:watch": `chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,
17558
+ "start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"',
17559
+ "generate-test-plan": "bun run scripts/generate-test-plan.ts"
17560
+ },
17561
+ devDependencies: {
17562
+ "@biomejs/biome": "^1.8.3",
17563
+ "@resvg/resvg-js": "^2.6.2",
17564
+ "@tscircuit/alphabet": "0.0.18",
17565
+ "@tscircuit/capacity-autorouter": "^0.0.269",
17566
+ "@tscircuit/checks": "^0.0.90",
17567
+ "@tscircuit/circuit-json-util": "^0.0.77",
17568
+ "@tscircuit/common": "^0.0.20",
17569
+ "@tscircuit/copper-pour-solver": "^0.0.20",
17570
+ "@tscircuit/footprinter": "^0.0.288",
17571
+ "@tscircuit/infgrid-ijump-astar": "^0.0.35",
17572
+ "@tscircuit/log-soup": "^1.0.2",
17573
+ "@tscircuit/matchpack": "^0.0.16",
17574
+ "@tscircuit/math-utils": "^0.0.29",
17575
+ "@tscircuit/miniflex": "^0.0.4",
17576
+ "@tscircuit/ngspice-spice-engine": "^0.0.8",
17577
+ "@tscircuit/props": "^0.0.478",
17578
+ "@tscircuit/schematic-match-adapt": "^0.0.16",
17579
+ "@tscircuit/schematic-trace-solver": "^v0.0.45",
17580
+ "@tscircuit/solver-utils": "^0.0.3",
17581
+ "@tscircuit/soup-util": "^0.0.41",
17582
+ "@types/bun": "^1.2.16",
17583
+ "@types/debug": "^4.1.12",
17584
+ "@types/react": "^19.1.8",
17585
+ "@types/react-dom": "^19.1.6",
17586
+ "@types/react-reconciler": "^0.28.9",
17587
+ "bpc-graph": "^0.0.57",
17588
+ "bun-match-svg": "0.0.12",
17589
+ "calculate-elbow": "^0.0.12",
17590
+ "chokidar-cli": "^3.0.0",
17591
+ "circuit-json": "^0.0.379",
17592
+ "circuit-json-to-bpc": "^0.0.13",
17593
+ "circuit-json-to-connectivity-map": "^0.0.23",
17594
+ "circuit-json-to-gltf": "^0.0.65",
17595
+ "circuit-json-to-simple-3d": "^0.0.9",
17596
+ "circuit-json-to-spice": "^0.0.34",
17597
+ "circuit-to-svg": "^0.0.328",
17598
+ concurrently: "^9.1.2",
17599
+ "connectivity-map": "^1.0.0",
17600
+ debug: "^4.3.6",
17601
+ "eecircuit-engine": "^1.5.6",
17602
+ flatbush: "^4.5.0",
17603
+ "graphics-debug": "^0.0.60",
17604
+ howfat: "^0.3.8",
17605
+ "live-server": "^1.2.2",
17606
+ "looks-same": "^9.0.1",
17607
+ minicssgrid: "^0.0.9",
17608
+ "pkg-pr-new": "^0.0.37",
17609
+ poppygl: "^0.0.16",
17610
+ react: "^19.1.0",
17611
+ "react-dom": "^19.1.0",
17612
+ "schematic-symbols": "^0.0.208",
17613
+ spicey: "^0.0.14",
17614
+ "ts-expect": "^1.3.0",
17615
+ tsup: "^8.2.4"
17616
+ },
17617
+ peerDependencies: {
17618
+ "@tscircuit/capacity-autorouter": "*",
17619
+ "@tscircuit/checks": "*",
17620
+ "@tscircuit/circuit-json-util": "*",
17621
+ "@tscircuit/footprinter": "*",
17622
+ "@tscircuit/infgrid-ijump-astar": "*",
17623
+ "@tscircuit/math-utils": "*",
17624
+ "@tscircuit/props": "*",
17625
+ "@tscircuit/schematic-match-adapt": "*",
17626
+ "circuit-json-to-bpc": "*",
17627
+ "bpc-graph": "*",
17628
+ "@tscircuit/matchpack": "*",
17629
+ "circuit-json": "*",
17630
+ "circuit-json-to-connectivity-map": "*",
17631
+ "schematic-symbols": "*",
17632
+ typescript: "^5.0.0"
17633
+ },
17634
+ dependencies: {
17635
+ "@flatten-js/core": "^1.6.2",
17636
+ "@lume/kiwi": "^0.4.3",
17637
+ "calculate-packing": "0.0.68",
17638
+ "css-select": "5.1.0",
17639
+ "format-si-unit": "^0.0.3",
17640
+ nanoid: "^5.0.7",
17641
+ "performance-now": "^2.1.0",
17642
+ "react-reconciler": "^0.32.0",
17643
+ "svg-path-commander": "^2.1.11",
17644
+ "transformation-matrix": "^2.16.1",
17645
+ zod: "^3.25.67"
17646
+ }
17647
+ };
17648
+
17649
+ // lib/IsolatedCircuit.ts
17650
+ var IsolatedCircuit = class {
17651
+ firstChild = null;
17652
+ children;
17653
+ db;
17654
+ root = null;
17655
+ isRootCircuit = false;
17656
+ /**
17657
+ * Optional cache for isolated subcircuit circuit JSON, keyed by prop hash.
17658
+ * This is passed down from the RootCircuit when creating isolated circuits
17659
+ * for subcircuit rendering.
17660
+ */
17661
+ cachedSubcircuits;
17662
+ _schematicDisabledOverride;
17663
+ get schematicDisabled() {
17664
+ if (this._schematicDisabledOverride !== void 0) {
17665
+ return this._schematicDisabledOverride;
17666
+ }
17667
+ if (this.platform?.schematicDisabled !== void 0) {
17668
+ return this.platform.schematicDisabled;
17669
+ }
17670
+ const board = this._getBoard();
17671
+ return board?._parsedProps?.schematicDisabled ?? false;
17672
+ }
17673
+ set schematicDisabled(value) {
17674
+ this._schematicDisabledOverride = value;
17675
+ }
17676
+ pcbDisabled = false;
17677
+ pcbRoutingDisabled = false;
17678
+ _featureMspSchematicTraceRouting = true;
17679
+ /**
17680
+ * The IsolatedCircuit name is usually set by the platform, it's not required but
17681
+ * if supplied can identify the circuit in certain effects, e.g. it is passed
17682
+ * as the display_name parameter for autorouting effects.
17683
+ */
17684
+ name;
17685
+ platform;
17686
+ /**
17687
+ * Optional URL pointing to where this project is hosted or documented.
17688
+ * When provided it is stored in the source_project_metadata.project_url field
17689
+ * of the generated Circuit JSON.
17690
+ */
17691
+ projectUrl;
17692
+ _hasRenderedAtleastOnce = false;
17693
+ _asyncEffectIdsByPhase = /* @__PURE__ */ new Map();
17694
+ _asyncEffectPhaseById = /* @__PURE__ */ new Map();
17695
+ constructor({
17696
+ platform,
17697
+ projectUrl,
17698
+ cachedSubcircuits
17699
+ } = {}) {
17700
+ this.children = [];
17701
+ this.db = su5([]);
17702
+ this.platform = platform;
17703
+ this.projectUrl = projectUrl;
17704
+ this.pcbDisabled = platform?.pcbDisabled ?? false;
17705
+ this.cachedSubcircuits = cachedSubcircuits;
17706
+ this.root = this;
17707
+ }
17708
+ add(componentOrElm) {
17709
+ let component;
17710
+ if (isValidElement2(componentOrElm)) {
17711
+ component = createInstanceFromReactElement(componentOrElm);
17712
+ } else {
17713
+ component = componentOrElm;
17714
+ }
17715
+ this.children.push(component);
17716
+ }
17717
+ setPlatform(platform) {
17718
+ this.platform = {
17719
+ ...this.platform,
17720
+ ...platform
17721
+ };
17722
+ }
17723
+ /**
17724
+ * Get the main board for this Circuit.
17725
+ */
17726
+ _getBoard() {
17727
+ const directBoard = this.children.find((c) => c.componentName === "Board");
17728
+ if (directBoard) {
17729
+ return directBoard;
17730
+ }
17731
+ return void 0;
17732
+ }
17733
+ _guessRootComponent() {
17734
+ if (this.firstChild) return;
17735
+ if (this.children.length === 0) {
17736
+ throw new Error(
17737
+ "Not able to guess root component: IsolatedCircuit has no children (use circuit.add(...))"
17738
+ );
17739
+ }
17740
+ const panels = this.children.filter(
17741
+ (child) => child.lowercaseComponentName === "panel"
17742
+ );
17743
+ if (panels.length > 1) {
17744
+ throw new Error("Only one <panel> is allowed per circuit");
17745
+ }
17746
+ if (panels.length === 1) {
17747
+ if (this.children.length !== 1) {
17748
+ throw new Error("<panel> must be the root element of the circuit");
17749
+ }
17750
+ this.firstChild = panels[0];
17751
+ return;
17752
+ }
17753
+ if (this.children.length === 1 && this.children[0].isGroup) {
17754
+ this.firstChild = this.children[0];
17755
+ return;
17756
+ }
17757
+ const group = new Group6({ subcircuit: true });
17758
+ group.parent = this;
17759
+ group.addAll(this.children);
17760
+ this.children = [group];
17761
+ this.firstChild = group;
17762
+ }
17763
+ render() {
17764
+ if (!this.firstChild) {
17765
+ this._guessRootComponent();
17766
+ }
17767
+ const { firstChild, db } = this;
17768
+ if (!firstChild) throw new Error("IsolatedCircuit has no root component");
17769
+ firstChild.parent = this;
17770
+ firstChild.runRenderCycle();
17771
+ this._hasRenderedAtleastOnce = true;
17772
+ }
17773
+ async renderUntilSettled() {
17774
+ const existing = this.db.source_project_metadata.list()?.[0];
17775
+ if (!existing) {
17776
+ this.db.source_project_metadata.insert({
17777
+ software_used_string: `@tscircuit/core@${this.getCoreVersion()}`,
17778
+ ...this.projectUrl ? { project_url: this.projectUrl } : {}
17779
+ });
17780
+ }
17781
+ this.render();
17782
+ while (this._hasIncompleteAsyncEffects()) {
17783
+ await new Promise((resolve) => setTimeout(resolve, 100));
17784
+ this.render();
17785
+ }
17786
+ this.emit("renderComplete");
17787
+ }
17788
+ _hasIncompleteAsyncEffects() {
17789
+ if (this._asyncEffectPhaseById.size > 0) return true;
17790
+ return this.children.some((child) => child._hasIncompleteAsyncEffects());
17791
+ }
17792
+ _hasIncompleteAsyncEffectsForPhase(phase) {
17793
+ return (this._asyncEffectIdsByPhase.get(phase)?.size ?? 0) > 0;
17794
+ }
17795
+ getCircuitJson() {
17796
+ if (!this._hasRenderedAtleastOnce) this.render();
17797
+ return this.db.toArray();
17798
+ }
17799
+ toJson() {
17800
+ return this.getCircuitJson();
17801
+ }
17802
+ async getSvg(options) {
17803
+ const circuitToSvg = await import("circuit-to-svg").catch((e) => {
17804
+ throw new Error(
17805
+ `To use circuit.getSvg, you must install the "circuit-to-svg" package.
17806
+
17807
+ "${e.message}"`
17808
+ );
17809
+ });
17810
+ if (options.view === "pcb") {
17811
+ return circuitToSvg.convertCircuitJsonToPcbSvg(this.getCircuitJson());
17812
+ }
17813
+ if (options.view === "schematic") {
17814
+ return circuitToSvg.convertCircuitJsonToSchematicSvg(
17815
+ this.getCircuitJson()
17787
17816
  );
17788
17817
  }
17789
- let outlineTranslation = { x: 0, y: 0 };
17790
- if (outline && outline.length > 0 && (this.parent?.lowercaseComponentName === "panel" || this.parent?.lowercaseComponentName === "subpanel")) {
17791
- const outlineBounds = getBoundsFromPoints4(outline);
17792
- if (outlineBounds) {
17793
- const outlineCenterX = (outlineBounds.minX + outlineBounds.maxX) / 2;
17794
- const outlineCenterY = (outlineBounds.minY + outlineBounds.maxY) / 2;
17795
- outlineTranslation = {
17796
- x: center.x - outlineCenterX,
17797
- y: center.y - outlineCenterY
17798
- };
17799
- }
17818
+ throw new Error(`Invalid view: ${options.view}`);
17819
+ }
17820
+ getCoreVersion() {
17821
+ const [major, minor, patch] = package_default.version.split(".").map(Number);
17822
+ return `${major}.${minor}.${patch + 1}`;
17823
+ }
17824
+ async preview(previewNameOrOpts) {
17825
+ const previewOpts = typeof previewNameOrOpts === "object" ? previewNameOrOpts : { previewName: previewNameOrOpts };
17826
+ throw new Error("project.preview is not yet implemented");
17827
+ }
17828
+ computeSchematicGlobalTransform() {
17829
+ return identity4();
17830
+ }
17831
+ _computePcbGlobalTransformBeforeLayout() {
17832
+ return identity4();
17833
+ }
17834
+ selectAll(selector) {
17835
+ this._guessRootComponent();
17836
+ return this.firstChild?.selectAll(selector) ?? [];
17837
+ }
17838
+ selectOne(selector, opts) {
17839
+ this._guessRootComponent();
17840
+ return this.firstChild?.selectOne(selector, opts) ?? null;
17841
+ }
17842
+ _eventListeners = {};
17843
+ emit(event, ...args) {
17844
+ if (event === "asyncEffect:start") {
17845
+ this._registerAsyncEffectStart(args[0]);
17846
+ } else if (event === "asyncEffect:end") {
17847
+ this._registerAsyncEffectEnd(args[0]);
17848
+ }
17849
+ if (!this._eventListeners[event]) return;
17850
+ for (const listener of this._eventListeners[event]) {
17851
+ listener(...args);
17800
17852
  }
17801
- const pcb_board = db.pcb_board.insert({
17802
- source_board_id: this.source_board_id,
17803
- center,
17804
- thickness: this.boardThickness,
17805
- num_layers: this.allLayers.length,
17806
- width: computedWidth,
17807
- height: computedHeight,
17808
- outline: outline?.map((point6) => ({
17809
- x: point6.x + (props.outlineOffsetX ?? 0) + outlineTranslation.x,
17810
- y: point6.y + (props.outlineOffsetY ?? 0) + outlineTranslation.y
17811
- })),
17812
- material: props.material
17813
- });
17814
- this.pcb_board_id = pcb_board.pcb_board_id;
17815
- this._addBoardInformationToSilkscreen();
17816
17853
  }
17817
- removePcbComponentRender() {
17818
- const { db } = this.root;
17819
- if (!this.pcb_board_id) return;
17820
- db.pcb_board.delete(this.pcb_board_id);
17821
- this.pcb_board_id = null;
17854
+ on(event, listener) {
17855
+ if (!this._eventListeners[event]) {
17856
+ this._eventListeners[event] = [];
17857
+ }
17858
+ this._eventListeners[event].push(listener);
17822
17859
  }
17823
- doInitialPcbDesignRuleChecks() {
17824
- if (this.root?.pcbDisabled) return;
17825
- if (this.getInheritedProperty("routingDisabled")) return;
17826
- super.doInitialPcbDesignRuleChecks();
17860
+ removeListener(event, listener) {
17861
+ if (!this._eventListeners[event]) return;
17862
+ this._eventListeners[event] = this._eventListeners[event].filter(
17863
+ (l) => l !== listener
17864
+ );
17827
17865
  }
17828
- updatePcbDesignRuleChecks() {
17829
- if (this.root?.pcbDisabled) return;
17830
- if (this.getInheritedProperty("routingDisabled")) return;
17831
- const { db } = this.root;
17832
- if (!this._areChildSubcircuitsRouted()) return;
17833
- if (this._drcChecksComplete) return;
17834
- const runDrcChecks = (circuitJson) => {
17835
- const pcbTraceOverlappingErrors = checkEachPcbTraceNonOverlapping(circuitJson);
17836
- for (const error of pcbTraceOverlappingErrors) {
17837
- db.pcb_trace_error.insert(error);
17838
- }
17839
- const pcbPortNotConnectedErrors = checkEachPcbPortConnectedToPcbTraces(circuitJson);
17840
- for (const error of pcbPortNotConnectedErrors) {
17841
- db.pcb_port_not_connected_error.insert(error);
17842
- }
17843
- const pcbComponentOutsideErrors = checkPcbComponentsOutOfBoard(circuitJson);
17844
- for (const error of pcbComponentOutsideErrors) {
17845
- db.pcb_component_outside_board_error.insert(error);
17846
- }
17847
- const pcbTracesOutOfBoardErrors = checkPcbTracesOutOfBoard(circuitJson);
17848
- for (const error of pcbTracesOutOfBoardErrors) {
17849
- db.pcb_trace_error.insert(error);
17850
- }
17851
- const differentNetViaErrors = checkDifferentNetViaSpacing(circuitJson);
17852
- for (const error of differentNetViaErrors) {
17853
- db.pcb_via_clearance_error.insert(error);
17854
- }
17855
- const sameNetViaErrors = checkSameNetViaSpacing(circuitJson);
17856
- for (const error of sameNetViaErrors) {
17857
- db.pcb_via_clearance_error.insert(error);
17858
- }
17859
- const pcbComponentOverlapErrors = checkPcbComponentOverlap(circuitJson);
17860
- for (const error of pcbComponentOverlapErrors) {
17861
- db.pcb_footprint_overlap_error.insert(error);
17862
- }
17863
- const sourcePinMustBeConnectedErrors = checkPinMustBeConnected(circuitJson);
17864
- for (const error of sourcePinMustBeConnectedErrors) {
17865
- db.source_pin_must_be_connected_error.insert(error);
17866
- }
17867
- };
17868
- const subcircuit = db.subtree({ subcircuit_id: this.subcircuit_id });
17869
- const subcircuitCircuitJson = subcircuit.toArray();
17870
- runDrcChecks(subcircuitCircuitJson);
17871
- this._drcChecksComplete = true;
17866
+ enableDebug(debug11) {
17867
+ if (typeof debug11 === "string") {
17868
+ Debug14.enable(debug11);
17869
+ } else if (debug11 === null || debug11 === false) {
17870
+ Debug14.disable();
17871
+ }
17872
17872
  }
17873
- _emitRenderLifecycleEvent(phase, startOrEnd) {
17874
- super._emitRenderLifecycleEvent(phase, startOrEnd);
17875
- if (startOrEnd === "start") {
17876
- this.root?.emit("board:renderPhaseStarted", {
17877
- renderId: this._renderId,
17878
- phase
17879
- });
17873
+ getClientOrigin() {
17874
+ if (typeof window !== "undefined" && window.location) {
17875
+ return window.location.origin;
17876
+ }
17877
+ if (typeof self !== "undefined" && self.location) {
17878
+ return self.location.origin;
17880
17879
  }
17880
+ return "";
17881
17881
  }
17882
- _repositionOnPcb(position) {
17883
- const { db } = this.root;
17884
- const pcbBoard = this.pcb_board_id ? db.pcb_board.get(this.pcb_board_id) : null;
17885
- const oldPos = pcbBoard?.center;
17886
- if (!oldPos) {
17887
- if (this.pcb_board_id) {
17888
- db.pcb_board.update(this.pcb_board_id, { center: position });
17889
- }
17890
- return;
17882
+ _registerAsyncEffectStart(payload) {
17883
+ if (!payload?.asyncEffectId || !payload.phase) return;
17884
+ const { asyncEffectId, phase } = payload;
17885
+ const existingPhase = this._asyncEffectPhaseById.get(asyncEffectId);
17886
+ if (existingPhase && existingPhase !== phase) {
17887
+ this._asyncEffectIdsByPhase.get(existingPhase)?.delete(asyncEffectId);
17891
17888
  }
17892
- const deltaX = position.x - oldPos.x;
17893
- const deltaY = position.y - oldPos.y;
17894
- if (Math.abs(deltaX) < 1e-6 && Math.abs(deltaY) < 1e-6) {
17895
- return;
17889
+ if (!this._asyncEffectIdsByPhase.has(phase)) {
17890
+ this._asyncEffectIdsByPhase.set(phase, /* @__PURE__ */ new Set());
17896
17891
  }
17897
- if (this.pcb_board_id) {
17898
- db.pcb_board.update(this.pcb_board_id, { center: position });
17899
- if (pcbBoard?.outline) {
17900
- const outlineBounds = getBoundsFromPoints4(pcbBoard.outline);
17901
- if (outlineBounds) {
17902
- const oldOutlineCenter = {
17903
- x: (outlineBounds.minX + outlineBounds.maxX) / 2,
17904
- y: (outlineBounds.minY + outlineBounds.maxY) / 2
17905
- };
17906
- const outlineDeltaX = position.x - oldOutlineCenter.x;
17907
- const outlineDeltaY = position.y - oldOutlineCenter.y;
17908
- const newOutline = pcbBoard.outline.map((p) => ({
17909
- x: p.x + outlineDeltaX,
17910
- y: p.y + outlineDeltaY
17911
- }));
17912
- db.pcb_board.update(this.pcb_board_id, {
17913
- outline: newOutline
17914
- });
17915
- }
17892
+ this._asyncEffectIdsByPhase.get(phase).add(asyncEffectId);
17893
+ this._asyncEffectPhaseById.set(asyncEffectId, phase);
17894
+ }
17895
+ _registerAsyncEffectEnd(payload) {
17896
+ if (!payload?.asyncEffectId) return;
17897
+ const { asyncEffectId } = payload;
17898
+ const phase = this._asyncEffectPhaseById.get(asyncEffectId) ?? payload.phase;
17899
+ if (phase) {
17900
+ const phaseSet = this._asyncEffectIdsByPhase.get(phase);
17901
+ phaseSet?.delete(asyncEffectId);
17902
+ if (phaseSet && phaseSet.size === 0) {
17903
+ this._asyncEffectIdsByPhase.delete(phase);
17916
17904
  }
17917
17905
  }
17906
+ this._asyncEffectPhaseById.delete(asyncEffectId);
17918
17907
  }
17919
17908
  };
17920
17909
 
17921
- // lib/components/normal-components/MountedBoard.ts
17922
- import { mountedboardProps } from "@tscircuit/props";
17910
+ // lib/components/primitive-components/Group/Subcircuit/Subcircuit_doInitialRenderIsolatedSubcircuits.ts
17911
+ function Subcircuit_doInitialRenderIsolatedSubcircuits(subcircuit) {
17912
+ if (!subcircuit._isIsolatedSubcircuit) return;
17913
+ if (subcircuit._isolatedCircuitJson) return;
17914
+ const propHash = subcircuit.getSubcircuitPropHash();
17915
+ const cachedSubcircuits = subcircuit.root?.cachedSubcircuits;
17916
+ const cached = cachedSubcircuits?.get(propHash);
17917
+ if (cached) {
17918
+ subcircuit._isolatedCircuitJson = cached;
17919
+ subcircuit.children = [];
17920
+ subcircuit._normalComponentNameMap = null;
17921
+ return;
17922
+ }
17923
+ const parentRoot = subcircuit.root;
17924
+ const childrenToRender = [...subcircuit.children];
17925
+ subcircuit.children = [];
17926
+ subcircuit._normalComponentNameMap = null;
17927
+ subcircuit._queueAsyncEffect("render-isolated-subcircuit", async () => {
17928
+ const isolatedCircuit = new IsolatedCircuit({
17929
+ platform: {
17930
+ ...parentRoot.platform,
17931
+ pcbDisabled: parentRoot.pcbDisabled,
17932
+ schematicDisabled: parentRoot.schematicDisabled
17933
+ },
17934
+ cachedSubcircuits
17935
+ });
17936
+ for (const child of childrenToRender) {
17937
+ isolatedCircuit.add(child);
17938
+ }
17939
+ await isolatedCircuit.renderUntilSettled();
17940
+ const circuitJson = isolatedCircuit.getCircuitJson();
17941
+ cachedSubcircuits?.set(propHash, circuitJson);
17942
+ subcircuit._isolatedCircuitJson = circuitJson;
17943
+ });
17944
+ }
17945
+
17946
+ // lib/components/primitive-components/Group/Subcircuit_getSubcircuitPropHash.ts
17947
+ var EXCLUDED_PROPS = /* @__PURE__ */ new Set([
17948
+ "name",
17949
+ "key",
17950
+ "pcbX",
17951
+ "pcbY",
17952
+ "schX",
17953
+ "schY",
17954
+ "pcbLeftEdgeX",
17955
+ "pcbRightEdgeX",
17956
+ "pcbTopEdgeY",
17957
+ "pcbBottomEdgeY",
17958
+ "pcbRotation",
17959
+ "schRotation"
17960
+ ]);
17961
+ function getHashableProps(props) {
17962
+ const result = {};
17963
+ const keys = Object.keys(props).sort();
17964
+ for (const key of keys) {
17965
+ if (!EXCLUDED_PROPS.has(key) && props[key] !== void 0) {
17966
+ result[key] = props[key];
17967
+ }
17968
+ }
17969
+ return result;
17970
+ }
17971
+ function getChildrenHashData(children) {
17972
+ return children.map((child) => ({
17973
+ componentName: child.componentName,
17974
+ props: getHashableProps(child.props ?? {}),
17975
+ children: getChildrenHashData(child.children)
17976
+ }));
17977
+ }
17978
+ function fnv1aHash(str) {
17979
+ let hash = 2166136261;
17980
+ for (let i = 0; i < str.length; i++) {
17981
+ hash ^= str.charCodeAt(i);
17982
+ hash = Math.imul(hash, 16777619);
17983
+ }
17984
+ return hash >>> 0;
17985
+ }
17986
+ function computeHash(data) {
17987
+ const jsonString = JSON.stringify(data);
17988
+ const hash1 = fnv1aHash(jsonString);
17989
+ const hash2 = fnv1aHash(jsonString + hash1.toString());
17990
+ return hash1.toString(16).padStart(8, "0") + hash2.toString(16).padStart(8, "0");
17991
+ }
17992
+ function Subcircuit_getSubcircuitPropHash(subcircuit) {
17993
+ const hashableData = {
17994
+ props: getHashableProps(subcircuit.props ?? {}),
17995
+ children: getChildrenHashData(subcircuit.children)
17996
+ };
17997
+ return computeHash(hashableData);
17998
+ }
17923
17999
 
17924
18000
  // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
17925
- import "@tscircuit/props";
17926
- var Subcircuit = class extends Group {
18001
+ var Subcircuit = class extends Group6 {
17927
18002
  constructor(props) {
17928
18003
  super({
17929
18004
  ...props,
@@ -17931,6 +18006,26 @@ var Subcircuit = class extends Group {
17931
18006
  subcircuit: true
17932
18007
  });
17933
18008
  }
18009
+ /**
18010
+ * Computes a hash of this subcircuit's props and children for caching.
18011
+ * Position/identity props are excluded so identical subcircuits at
18012
+ * different locations share the same hash.
18013
+ */
18014
+ getSubcircuitPropHash() {
18015
+ return Subcircuit_getSubcircuitPropHash(this);
18016
+ }
18017
+ /**
18018
+ * Render this subcircuit in isolation if _subcircuitCachingEnabled is set.
18019
+ * This phase runs before InflateSubcircuitCircuitJson to prepare the
18020
+ * isolated circuit JSON that will be inflated.
18021
+ *
18022
+ * The rendering is synchronous - it loops until all async effects in the
18023
+ * isolated circuit are complete, ensuring the cache is populated before
18024
+ * processing the next subcircuit with potentially the same props.
18025
+ */
18026
+ doInitialRenderIsolatedSubcircuits() {
18027
+ Subcircuit_doInitialRenderIsolatedSubcircuits(this);
18028
+ }
17934
18029
  /**
17935
18030
  * During this phase, we inflate the subcircuit circuit json into class
17936
18031
  * instances
@@ -18414,7 +18509,7 @@ var packBoardsIntoGrid = ({
18414
18509
  };
18415
18510
 
18416
18511
  // lib/components/normal-components/Subpanel.ts
18417
- var Subpanel = class _Subpanel extends Group {
18512
+ var Subpanel = class _Subpanel extends Group6 {
18418
18513
  pcb_panel_id = null;
18419
18514
  _tabsAndMouseBitesGenerated = false;
18420
18515
  get config() {
@@ -20215,7 +20310,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
20215
20310
 
20216
20311
  // lib/components/primitive-components/Breakout/Breakout.ts
20217
20312
  import "@tscircuit/props";
20218
- var Breakout = class extends Group {
20313
+ var Breakout = class extends Group6 {
20219
20314
  constructor(props) {
20220
20315
  super({
20221
20316
  ...props,
@@ -23211,7 +23306,11 @@ var RootCircuit = class extends IsolatedCircuit {
23211
23306
  platform,
23212
23307
  projectUrl
23213
23308
  } = {}) {
23214
- super({ platform, projectUrl });
23309
+ super({
23310
+ platform,
23311
+ projectUrl,
23312
+ cachedSubcircuits: /* @__PURE__ */ new Map()
23313
+ });
23215
23314
  this.root = this;
23216
23315
  }
23217
23316
  };
@@ -23452,7 +23551,7 @@ export {
23452
23551
  Fiducial,
23453
23552
  Footprint,
23454
23553
  Fuse,
23455
- Group,
23554
+ Group6 as Group,
23456
23555
  Hole,
23457
23556
  Inductor,
23458
23557
  Interconnect,