@tscircuit/core 0.0.1488 → 0.0.1489

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 +76 -12
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -23532,7 +23532,7 @@ function Group_getRoutingPhasePlans(group) {
23532
23532
  var package_default = {
23533
23533
  name: "@tscircuit/core",
23534
23534
  type: "module",
23535
- version: "0.0.1487",
23535
+ version: "0.0.1488",
23536
23536
  types: "dist/index.d.ts",
23537
23537
  main: "dist/index.js",
23538
23538
  module: "dist/index.js",
@@ -23567,7 +23567,7 @@ var package_default = {
23567
23567
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
23568
23568
  "@tscircuit/capacity-autorouter": "^0.0.710",
23569
23569
  "@tscircuit/checks": "0.0.145",
23570
- "@tscircuit/circuit-json-util": "^0.0.97",
23570
+ "@tscircuit/circuit-json-util": "^0.0.100",
23571
23571
  "@tscircuit/common": "^0.0.20",
23572
23572
  "@tscircuit/copper-pour-solver": "0.0.39",
23573
23573
  "@tscircuit/create-fdm-enclosure": "0.0.3",
@@ -23596,7 +23596,7 @@ var package_default = {
23596
23596
  "bun-match-svg": "0.0.12",
23597
23597
  "calculate-elbow": "^0.0.12",
23598
23598
  "chokidar-cli": "^3.0.0",
23599
- "circuit-json": "^0.0.451",
23599
+ "circuit-json": "^0.0.453",
23600
23600
  "circuit-json-to-bpc": "^0.0.13",
23601
23601
  "circuit-json-to-connectivity-map": "^0.0.23",
23602
23602
  "circuit-json-to-gltf": "^0.0.107",
@@ -33770,6 +33770,62 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
33770
33770
 
33771
33771
  // lib/components/primitive-components/SchematicSheet.ts
33772
33772
  import { schematicSheetProps } from "@tscircuit/props";
33773
+
33774
+ // lib/utils/schematic/insertSchematicElementOutsideSheetWarnings.ts
33775
+ import {
33776
+ getSchematicElementBounds
33777
+ } from "@tscircuit/circuit-json-util";
33778
+ var SCHEMATIC_UNIT_TO_MM = 10.16 / 1.1;
33779
+ var DEFAULT_SCHEMATIC_SHEET_WIDTH = 297 / SCHEMATIC_UNIT_TO_MM;
33780
+ var DEFAULT_SCHEMATIC_SHEET_HEIGHT = 210 / SCHEMATIC_UNIT_TO_MM;
33781
+ var SCHEMATIC_SHEET_INNER_MARGIN = 5 / SCHEMATIC_UNIT_TO_MM;
33782
+ var BOUNDS_EPSILON = 1e-6;
33783
+ var getSchematicElementId = (schematicElement) => {
33784
+ switch (schematicElement.type) {
33785
+ case "schematic_component":
33786
+ return schematicElement.schematic_component_id;
33787
+ case "schematic_net_label":
33788
+ return schematicElement.schematic_net_label_id;
33789
+ case "schematic_trace":
33790
+ return schematicElement.schematic_trace_id;
33791
+ }
33792
+ };
33793
+ var insertSchematicElementOutsideSheetWarnings = ({
33794
+ db,
33795
+ schematicSheetId,
33796
+ schematicSheetName,
33797
+ schematicSheetCenter
33798
+ }) => {
33799
+ const sheetContentBounds = {
33800
+ minX: schematicSheetCenter.x - DEFAULT_SCHEMATIC_SHEET_WIDTH / 2 + SCHEMATIC_SHEET_INNER_MARGIN,
33801
+ maxX: schematicSheetCenter.x + DEFAULT_SCHEMATIC_SHEET_WIDTH / 2 - SCHEMATIC_SHEET_INNER_MARGIN,
33802
+ minY: schematicSheetCenter.y - DEFAULT_SCHEMATIC_SHEET_HEIGHT / 2 + SCHEMATIC_SHEET_INNER_MARGIN,
33803
+ maxY: schematicSheetCenter.y + DEFAULT_SCHEMATIC_SHEET_HEIGHT / 2 - SCHEMATIC_SHEET_INNER_MARGIN
33804
+ };
33805
+ const checkedElements = [
33806
+ ...db.schematic_component.list(),
33807
+ ...db.schematic_net_label.list(),
33808
+ ...db.schematic_trace.list()
33809
+ ].filter(
33810
+ (schematicElement) => schematicElement.schematic_sheet_id === schematicSheetId
33811
+ );
33812
+ for (const schematicElement of checkedElements) {
33813
+ const elementBounds = getSchematicElementBounds(schematicElement);
33814
+ if (!elementBounds) continue;
33815
+ const isOutsideSheet = elementBounds.minX < sheetContentBounds.minX - BOUNDS_EPSILON || elementBounds.maxX > sheetContentBounds.maxX + BOUNDS_EPSILON || elementBounds.minY < sheetContentBounds.minY - BOUNDS_EPSILON || elementBounds.maxY > sheetContentBounds.maxY + BOUNDS_EPSILON;
33816
+ if (!isOutsideSheet) continue;
33817
+ const schematicElementId = getSchematicElementId(schematicElement);
33818
+ db.schematic_element_outside_sheet_warning.insert({
33819
+ warning_type: "schematic_element_outside_sheet_warning",
33820
+ message: `${schematicElement.type} ${schematicElementId} extends outside the drawing area of schematic sheet "${schematicSheetName}"`,
33821
+ schematic_sheet_id: schematicSheetId,
33822
+ schematic_element_type: schematicElement.type,
33823
+ schematic_element_id: schematicElementId
33824
+ });
33825
+ }
33826
+ };
33827
+
33828
+ // lib/components/primitive-components/SchematicSheet.ts
33773
33829
  var SchematicSheet = class extends PrimitiveComponent2 {
33774
33830
  isSchematicPrimitive = true;
33775
33831
  get config() {
@@ -33806,16 +33862,24 @@ var SchematicSheet = class extends PrimitiveComponent2 {
33806
33862
  ].filter(
33807
33863
  (element) => element.schematic_sheet_id === this.schematic_sheet_id
33808
33864
  );
33809
- if (schematicElements.length === 0) return;
33810
- const bounds = getBoundsForSchematic(schematicElements);
33811
- if (!Number.isFinite(bounds.minX) || !Number.isFinite(bounds.maxX) || !Number.isFinite(bounds.minY) || !Number.isFinite(bounds.maxY)) {
33812
- return;
33813
- }
33814
- db.schematic_sheet.update(this.schematic_sheet_id, {
33815
- center: {
33816
- x: (bounds.minX + bounds.maxX) / 2,
33817
- y: (bounds.minY + bounds.maxY) / 2
33865
+ let schematicSheetCenter = { x: 0, y: 0 };
33866
+ if (schematicElements.length > 0) {
33867
+ const bounds = getBoundsForSchematic(schematicElements);
33868
+ if (Number.isFinite(bounds.minX) && Number.isFinite(bounds.maxX) && Number.isFinite(bounds.minY) && Number.isFinite(bounds.maxY)) {
33869
+ schematicSheetCenter = {
33870
+ x: (bounds.minX + bounds.maxX) / 2,
33871
+ y: (bounds.minY + bounds.maxY) / 2
33872
+ };
33873
+ db.schematic_sheet.update(this.schematic_sheet_id, {
33874
+ center: schematicSheetCenter
33875
+ });
33818
33876
  }
33877
+ }
33878
+ insertSchematicElementOutsideSheetWarnings({
33879
+ db,
33880
+ schematicSheetId: this.schematic_sheet_id,
33881
+ schematicSheetName: this._parsedProps.displayName,
33882
+ schematicSheetCenter
33819
33883
  });
33820
33884
  }
33821
33885
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1488",
4
+ "version": "0.0.1489",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
37
37
  "@tscircuit/capacity-autorouter": "^0.0.710",
38
38
  "@tscircuit/checks": "0.0.145",
39
- "@tscircuit/circuit-json-util": "^0.0.97",
39
+ "@tscircuit/circuit-json-util": "^0.0.100",
40
40
  "@tscircuit/common": "^0.0.20",
41
41
  "@tscircuit/copper-pour-solver": "0.0.39",
42
42
  "@tscircuit/create-fdm-enclosure": "0.0.3",
@@ -65,7 +65,7 @@
65
65
  "bun-match-svg": "0.0.12",
66
66
  "calculate-elbow": "^0.0.12",
67
67
  "chokidar-cli": "^3.0.0",
68
- "circuit-json": "^0.0.451",
68
+ "circuit-json": "^0.0.453",
69
69
  "circuit-json-to-bpc": "^0.0.13",
70
70
  "circuit-json-to-connectivity-map": "^0.0.23",
71
71
  "circuit-json-to-gltf": "^0.0.107",