@tscircuit/core 0.0.827 → 0.0.828

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 +38 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -91,7 +91,8 @@ import {
91
91
  pcb_component_invalid_layer_error,
92
92
  point3 as point32,
93
93
  rotation as rotation2,
94
- schematic_manual_edit_conflict_warning
94
+ schematic_manual_edit_conflict_warning,
95
+ unknown_error_finding_part
95
96
  } from "circuit-json";
96
97
  import { decomposeTSR as decomposeTSR5 } from "transformation-matrix";
97
98
  import Debug5 from "debug";
@@ -8518,7 +8519,26 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8518
8519
  footprinterString
8519
8520
  })
8520
8521
  );
8521
- const supplierPartNumbers = result === "Not found" ? {} : result;
8522
+ if (typeof result === "string") {
8523
+ if (result.includes("<!DOCTYPE") || result.includes("<html")) {
8524
+ throw new Error(
8525
+ `Failed to fetch supplier part numbers: Received HTML response instead of JSON. Response starts with: ${result.substring(0, 100)}`
8526
+ );
8527
+ }
8528
+ if (result === "Not found") {
8529
+ return {};
8530
+ }
8531
+ throw new Error(
8532
+ `Invalid supplier part numbers format: Expected object but got string: "${result}"`
8533
+ );
8534
+ }
8535
+ if (!result || Array.isArray(result) || typeof result !== "object") {
8536
+ const actualType = result === null ? "null" : Array.isArray(result) ? "array" : typeof result;
8537
+ throw new Error(
8538
+ `Invalid supplier part numbers format: Expected object but got ${actualType}`
8539
+ );
8540
+ }
8541
+ const supplierPartNumbers = result;
8522
8542
  if (cacheEngine) {
8523
8543
  try {
8524
8544
  await cacheEngine.setItem(cacheKey, JSON.stringify(supplierPartNumbers));
@@ -8551,8 +8571,20 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8551
8571
  return;
8552
8572
  }
8553
8573
  this._queueAsyncEffect("get-supplier-part-numbers", async () => {
8554
- this._asyncSupplierPartNumbers = await supplierPartNumbersMaybePromise;
8555
- this._markDirty("PartsEngineRender");
8574
+ await supplierPartNumbersMaybePromise.then((supplierPartNumbers) => {
8575
+ this._asyncSupplierPartNumbers = supplierPartNumbers;
8576
+ this._markDirty("PartsEngineRender");
8577
+ }).catch((error) => {
8578
+ this._asyncSupplierPartNumbers = {};
8579
+ const errorObj = unknown_error_finding_part.parse({
8580
+ type: "unknown_error_finding_part",
8581
+ message: `Failed to fetch supplier part numbers for ${this.getString()}: ${error.message}`,
8582
+ source_component_id: this.source_component_id,
8583
+ subcircuit_id: this.getSubcircuit()?.subcircuit_id
8584
+ });
8585
+ db.unknown_error_finding_part.insert(errorObj);
8586
+ this._markDirty("PartsEngineRender");
8587
+ });
8556
8588
  });
8557
8589
  }
8558
8590
  updatePartsEngineRender() {
@@ -17322,7 +17354,7 @@ import { identity as identity6 } from "transformation-matrix";
17322
17354
  var package_default = {
17323
17355
  name: "@tscircuit/core",
17324
17356
  type: "module",
17325
- version: "0.0.826",
17357
+ version: "0.0.827",
17326
17358
  types: "dist/index.d.ts",
17327
17359
  main: "dist/index.js",
17328
17360
  module: "dist/index.js",
@@ -17377,7 +17409,7 @@ var package_default = {
17377
17409
  "bun-match-svg": "0.0.12",
17378
17410
  "calculate-elbow": "^0.0.12",
17379
17411
  "chokidar-cli": "^3.0.0",
17380
- "circuit-json": "^0.0.288",
17412
+ "circuit-json": "^0.0.291",
17381
17413
  "circuit-json-to-bpc": "^0.0.13",
17382
17414
  "circuit-json-to-connectivity-map": "^0.0.22",
17383
17415
  "circuit-json-to-gltf": "^0.0.31",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.827",
4
+ "version": "0.0.828",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "bun-match-svg": "0.0.12",
57
57
  "calculate-elbow": "^0.0.12",
58
58
  "chokidar-cli": "^3.0.0",
59
- "circuit-json": "^0.0.288",
59
+ "circuit-json": "^0.0.291",
60
60
  "circuit-json-to-bpc": "^0.0.13",
61
61
  "circuit-json-to-connectivity-map": "^0.0.22",
62
62
  "circuit-json-to-gltf": "^0.0.31",