@tscircuit/core 0.0.821 → 0.0.822
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.
- package/dist/index.js +21 -16
- package/package.json +1 -1
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/
|
|
7208
|
-
var
|
|
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 (
|
|
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" &&
|
|
7238
|
+
if (typeof footprint === "string" && (isHttpUrl(footprint) || isStaticAssetPath(footprint)) && footprintParser) {
|
|
7234
7239
|
if (component._hasStartedFootprintUrlLoad) return;
|
|
7235
7240
|
component._hasStartedFootprintUrlLoad = true;
|
|
7236
|
-
const
|
|
7237
|
-
const
|
|
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(
|
|
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:
|
|
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 "${
|
|
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:
|
|
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" &&
|
|
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 (
|
|
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 (
|
|
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.
|
|
17288
|
+
version: "0.0.821",
|
|
17284
17289
|
types: "dist/index.d.ts",
|
|
17285
17290
|
main: "dist/index.js",
|
|
17286
17291
|
module: "dist/index.js",
|