@tscircuit/core 0.0.747 → 0.0.748

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 +52 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6933,11 +6933,62 @@ import {
6933
6933
  circuit_json_footprint_load_error,
6934
6934
  external_footprint_load_error
6935
6935
  } from "circuit-json";
6936
+
6937
+ // lib/components/base-components/NormalComponent/utils/getFileExtension.ts
6938
+ var getFileExtension = (filename) => {
6939
+ if (!filename) return null;
6940
+ const cleanFilename = filename.split("?")[0];
6941
+ return cleanFilename.split(".").pop();
6942
+ };
6943
+
6944
+ // lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
6936
6945
  function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
6937
6946
  let { footprint } = component.props;
6938
6947
  footprint ??= component._getImpliedFootprintString?.();
6939
6948
  if (!footprint) return;
6940
6949
  const { pcbRotation, pinLabels, pcbPinLabels } = component.props;
6950
+ const fileExtension = getFileExtension(String(footprint));
6951
+ const footprintParser = fileExtension ? component.root?.platform?.footprintFileParserMap?.[fileExtension] : null;
6952
+ if (typeof footprint === "string" && isFootprintUrl(footprint) && footprintParser) {
6953
+ if (component._hasStartedFootprintUrlLoad) return;
6954
+ component._hasStartedFootprintUrlLoad = true;
6955
+ const url = footprint;
6956
+ queueAsyncEffect("load-footprint-from-platform-file-parser", async () => {
6957
+ try {
6958
+ const result = await footprintParser.loadFromUrl(url);
6959
+ const fpComponents = createComponentsFromCircuitJson(
6960
+ {
6961
+ componentName: component.name,
6962
+ componentRotation: pcbRotation,
6963
+ footprint: url,
6964
+ pinLabels,
6965
+ pcbPinLabels
6966
+ },
6967
+ result.footprintCircuitJson
6968
+ );
6969
+ component.addAll(fpComponents);
6970
+ component._markDirty("InitializePortsFromChildren");
6971
+ } catch (err) {
6972
+ const db = component.root?.db;
6973
+ if (db && component.source_component_id && component.pcb_component_id) {
6974
+ const subcircuit = component.getSubcircuit();
6975
+ const errorMsg = `${component.getString()} failed to load footprint "${url}": ` + (err instanceof Error ? err.message : String(err));
6976
+ const errorObj = external_footprint_load_error.parse({
6977
+ type: "external_footprint_load_error",
6978
+ message: errorMsg,
6979
+ pcb_component_id: component.pcb_component_id,
6980
+ source_component_id: component.source_component_id,
6981
+ subcircuit_id: subcircuit.subcircuit_id ?? void 0,
6982
+ pcb_group_id: component.getGroup()?.pcb_group_id ?? void 0,
6983
+ footprinter_string: url
6984
+ });
6985
+ db.external_footprint_load_error.insert(errorObj);
6986
+ }
6987
+ throw err;
6988
+ }
6989
+ });
6990
+ return;
6991
+ }
6941
6992
  if (typeof footprint === "string" && isFootprintUrl(footprint)) {
6942
6993
  if (component._hasStartedFootprintUrlLoad) return;
6943
6994
  component._hasStartedFootprintUrlLoad = true;
@@ -15724,7 +15775,7 @@ import { identity as identity6 } from "transformation-matrix";
15724
15775
  var package_default = {
15725
15776
  name: "@tscircuit/core",
15726
15777
  type: "module",
15727
- version: "0.0.746",
15778
+ version: "0.0.747",
15728
15779
  types: "dist/index.d.ts",
15729
15780
  main: "dist/index.js",
15730
15781
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.747",
4
+ "version": "0.0.748",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",