@tscircuit/core 0.0.821 → 0.0.823

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 +22 -17
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -7204,12 +7204,12 @@ function isValidPinLabel(pin, label) {
7204
7204
  // lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
7205
7205
  import { isValidElement as isReactElement } from "react";
7206
7206
 
7207
- // lib/components/base-components/NormalComponent/utils/isFoorprintUrl.ts
7208
- var isFootprintUrl = (s) => s.startsWith("http://") || s.startsWith("https://") || s.startsWith("/");
7207
+ // lib/components/base-components/NormalComponent/utils/isHttpUrl.ts
7208
+ var isHttpUrl = (s) => s.startsWith("http://") || s.startsWith("https://");
7209
7209
 
7210
7210
  // lib/components/base-components/NormalComponent/utils/parseLibraryFootprintRef.ts
7211
7211
  var parseLibraryFootprintRef = (s) => {
7212
- if (isFootprintUrl(s)) return null;
7212
+ if (isHttpUrl(s)) return null;
7213
7213
  const idx = s.indexOf(":");
7214
7214
  if (idx <= 0) return null;
7215
7215
  const footprintLib = s.slice(0, idx);
@@ -7223,6 +7223,11 @@ import {
7223
7223
  circuit_json_footprint_load_error,
7224
7224
  external_footprint_load_error
7225
7225
  } from "circuit-json";
7226
+
7227
+ // lib/components/base-components/NormalComponent/utils/isStaticAssetPath.ts
7228
+ var isStaticAssetPath = (s) => s.startsWith("/");
7229
+
7230
+ // lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
7226
7231
  function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
7227
7232
  let { footprint } = component.props;
7228
7233
  footprint ??= component._getImpliedFootprintString?.();
@@ -7230,21 +7235,19 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7230
7235
  const { pcbRotation, pinLabels, pcbPinLabels } = component.props;
7231
7236
  const fileExtension = getFileExtension(String(footprint));
7232
7237
  const footprintParser = fileExtension ? component.root?.platform?.footprintFileParserMap?.[fileExtension] : null;
7233
- if (typeof footprint === "string" && isFootprintUrl(footprint) && footprintParser) {
7238
+ if (typeof footprint === "string" && (isHttpUrl(footprint) || isStaticAssetPath(footprint)) && footprintParser) {
7234
7239
  if (component._hasStartedFootprintUrlLoad) return;
7235
7240
  component._hasStartedFootprintUrlLoad = true;
7236
- const baseUrl = component.root?.platform?.projectBaseUrl;
7237
- const url = constructAssetUrl(footprint, baseUrl);
7241
+ const projectBaseUrl = component.root?.platform?.projectBaseUrl;
7242
+ const footprintUrl = isHttpUrl(footprint) ? footprint : constructAssetUrl(footprint, projectBaseUrl);
7238
7243
  queueAsyncEffect("load-footprint-from-platform-file-parser", async () => {
7239
7244
  try {
7240
- const result = await footprintParser.loadFromUrl(footprint).catch(() => {
7241
- return footprintParser.loadFromUrl(url);
7242
- });
7245
+ const result = await footprintParser.loadFromUrl(footprintUrl);
7243
7246
  const fpComponents = createComponentsFromCircuitJson(
7244
7247
  {
7245
7248
  componentName: component.name,
7246
7249
  componentRotation: pcbRotation,
7247
- footprint: url,
7250
+ footprint: footprintUrl,
7248
7251
  pinLabels,
7249
7252
  pcbPinLabels
7250
7253
  },
@@ -7256,7 +7259,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7256
7259
  const db = component.root?.db;
7257
7260
  if (db && component.source_component_id && component.pcb_component_id) {
7258
7261
  const subcircuit = component.getSubcircuit();
7259
- const errorMsg = `${component.getString()} failed to load footprint "${url}": ` + (err instanceof Error ? err.message : String(err));
7262
+ const errorMsg = `${component.getString()} failed to load footprint "${footprintUrl}": ` + (err instanceof Error ? err.message : String(err));
7260
7263
  const errorObj = external_footprint_load_error.parse({
7261
7264
  type: "external_footprint_load_error",
7262
7265
  message: errorMsg,
@@ -7264,7 +7267,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7264
7267
  source_component_id: component.source_component_id,
7265
7268
  subcircuit_id: subcircuit.subcircuit_id ?? void 0,
7266
7269
  pcb_group_id: component.getGroup()?.pcb_group_id ?? void 0,
7267
- footprinter_string: url
7270
+ footprinter_string: footprintUrl
7268
7271
  });
7269
7272
  db.external_footprint_load_error.insert(errorObj);
7270
7273
  }
@@ -7273,7 +7276,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7273
7276
  });
7274
7277
  return;
7275
7278
  }
7276
- if (typeof footprint === "string" && isFootprintUrl(footprint)) {
7279
+ if (typeof footprint === "string" && isHttpUrl(footprint)) {
7277
7280
  if (component._hasStartedFootprintUrlLoad) return;
7278
7281
  component._hasStartedFootprintUrlLoad = true;
7279
7282
  const url = footprint;
@@ -7770,7 +7773,8 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
7770
7773
  footprint ??= this._getImpliedFootprintString?.();
7771
7774
  if (!footprint) return;
7772
7775
  if (typeof footprint === "string") {
7773
- if (isFootprintUrl(footprint)) return;
7776
+ if (isHttpUrl(footprint)) return;
7777
+ if (isStaticAssetPath(footprint)) return;
7774
7778
  if (parseLibraryFootprintRef(footprint)) return;
7775
7779
  const fpSoup = fp.string(footprint).soup();
7776
7780
  const fpComponents = createComponentsFromCircuitJson(
@@ -8225,7 +8229,8 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8225
8229
  footprint = this.children.find((c) => c.componentName === "Footprint");
8226
8230
  }
8227
8231
  if (typeof footprint === "string") {
8228
- if (isFootprintUrl(footprint)) return [];
8232
+ if (isHttpUrl(footprint)) return [];
8233
+ if (isStaticAssetPath(footprint)) return [];
8229
8234
  if (parseLibraryFootprintRef(footprint)) return [];
8230
8235
  const fpSoup = fp.string(footprint).soup();
8231
8236
  const newPorts2 = [];
@@ -17280,7 +17285,7 @@ import { identity as identity6 } from "transformation-matrix";
17280
17285
  var package_default = {
17281
17286
  name: "@tscircuit/core",
17282
17287
  type: "module",
17283
- version: "0.0.820",
17288
+ version: "0.0.822",
17284
17289
  types: "dist/index.d.ts",
17285
17290
  main: "dist/index.js",
17286
17291
  module: "dist/index.js",
@@ -17340,7 +17345,7 @@ var package_default = {
17340
17345
  "circuit-json-to-gltf": "^0.0.31",
17341
17346
  "circuit-json-to-simple-3d": "^0.0.9",
17342
17347
  "circuit-json-to-spice": "^0.0.15",
17343
- "circuit-to-svg": "^0.0.250",
17348
+ "circuit-to-svg": "^0.0.253",
17344
17349
  concurrently: "^9.1.2",
17345
17350
  "connectivity-map": "^1.0.0",
17346
17351
  debug: "^4.3.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.821",
4
+ "version": "0.0.823",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -61,7 +61,7 @@
61
61
  "circuit-json-to-gltf": "^0.0.31",
62
62
  "circuit-json-to-simple-3d": "^0.0.9",
63
63
  "circuit-json-to-spice": "^0.0.15",
64
- "circuit-to-svg": "^0.0.250",
64
+ "circuit-to-svg": "^0.0.253",
65
65
  "concurrently": "^9.1.2",
66
66
  "connectivity-map": "^1.0.0",
67
67
  "debug": "^4.3.6",