@tscircuit/core 0.0.806 → 0.0.807

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 +1344 -373
  2. package/dist/index.js +58 -5
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ __export(components_exports, {
37
37
  Net: () => Net,
38
38
  NetLabel: () => NetLabel,
39
39
  NormalComponent: () => NormalComponent3,
40
+ Panel: () => Panel,
40
41
  PcbNoteDimension: () => PcbNoteDimension,
41
42
  PcbNoteLine: () => PcbNoteLine,
42
43
  PcbNotePath: () => PcbNotePath,
@@ -1028,6 +1029,9 @@ var PrimitiveComponent2 = class extends Renderable {
1028
1029
  if (this.lowercaseComponentName === "board" && component.lowercaseComponentName === "board") {
1029
1030
  throw new Error("Nested boards are not supported");
1030
1031
  }
1032
+ if (component.lowercaseComponentName === "panel") {
1033
+ throw new Error("<panel> must be a root-level element");
1034
+ }
1031
1035
  if (!component.onAddToParent) {
1032
1036
  throw new Error(
1033
1037
  `Invalid JSX Element: Expected a React component but received "${JSON.stringify(
@@ -6710,7 +6714,14 @@ var Trace3 = class extends PrimitiveComponent2 {
6710
6714
  const match = selector.match(/^net\.(.+)$/);
6711
6715
  const netName = match ? match[1] : null;
6712
6716
  if (!netName) return null;
6713
- const allDescendants = this.root._getBoard().getDescendants();
6717
+ const board = this.root?._getBoard();
6718
+ if (!board) {
6719
+ this.renderError(
6720
+ `Could not find a <board> ancestor for ${this}, so net "${selector}" cannot be resolved`
6721
+ );
6722
+ return null;
6723
+ }
6724
+ const allDescendants = board.getDescendants();
6714
6725
  return allDescendants.find(
6715
6726
  (d) => d.componentName === "Net" && d._parsedProps.name === netName
6716
6727
  ) || null;
@@ -13753,6 +13764,32 @@ var Board = class extends Group6 {
13753
13764
  }
13754
13765
  };
13755
13766
 
13767
+ // lib/components/normal-components/Panel.ts
13768
+ import { panelProps } from "@tscircuit/props";
13769
+ var Panel = class extends Group6 {
13770
+ get config() {
13771
+ return {
13772
+ componentName: "Panel",
13773
+ zodProps: panelProps
13774
+ };
13775
+ }
13776
+ get isGroup() {
13777
+ return true;
13778
+ }
13779
+ add(component) {
13780
+ if (component.lowercaseComponentName !== "board") {
13781
+ throw new Error("<panel> can only contain <board> elements");
13782
+ }
13783
+ super.add(component);
13784
+ }
13785
+ runRenderCycle() {
13786
+ if (!this.children.some((child) => child.componentName === "Board")) {
13787
+ throw new Error("<panel> must contain at least one <board>");
13788
+ }
13789
+ super.runRenderCycle();
13790
+ }
13791
+ };
13792
+
13756
13793
  // lib/components/normal-components/Capacitor.ts
13757
13794
  import { capacitorProps } from "@tscircuit/props";
13758
13795
 
@@ -17161,7 +17198,7 @@ import { identity as identity6 } from "transformation-matrix";
17161
17198
  var package_default = {
17162
17199
  name: "@tscircuit/core",
17163
17200
  type: "module",
17164
- version: "0.0.805",
17201
+ version: "0.0.806",
17165
17202
  types: "dist/index.d.ts",
17166
17203
  main: "dist/index.js",
17167
17204
  module: "dist/index.js",
@@ -17321,9 +17358,11 @@ var RootCircuit = class {
17321
17358
  * Get the main board for this Circuit.
17322
17359
  */
17323
17360
  _getBoard() {
17324
- return this.children.find(
17325
- (c) => c.componentName === "Board"
17326
- );
17361
+ const directBoard = this.children.find((c) => c.componentName === "Board");
17362
+ if (directBoard) {
17363
+ return directBoard;
17364
+ }
17365
+ return void 0;
17327
17366
  }
17328
17367
  _guessRootComponent() {
17329
17368
  if (this.firstChild) return;
@@ -17332,6 +17371,19 @@ var RootCircuit = class {
17332
17371
  "Not able to guess root component: RootCircuit has no children (use circuit.add(...))"
17333
17372
  );
17334
17373
  }
17374
+ const panels = this.children.filter(
17375
+ (child) => child.lowercaseComponentName === "panel"
17376
+ );
17377
+ if (panels.length > 1) {
17378
+ throw new Error("Only one <panel> is allowed per circuit");
17379
+ }
17380
+ if (panels.length === 1) {
17381
+ if (this.children.length !== 1) {
17382
+ throw new Error("<panel> must be the root element of the circuit");
17383
+ }
17384
+ this.firstChild = panels[0];
17385
+ return;
17386
+ }
17335
17387
  if (this.children.length === 1 && this.children[0].isGroup) {
17336
17388
  this.firstChild = this.children[0];
17337
17389
  return;
@@ -17699,6 +17751,7 @@ export {
17699
17751
  Net,
17700
17752
  NetLabel,
17701
17753
  NormalComponent3 as NormalComponent,
17754
+ Panel,
17702
17755
  PcbNoteDimension,
17703
17756
  PcbNoteLine,
17704
17757
  PcbNotePath,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.806",
4
+ "version": "0.0.807",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",