From 8afda134bd3d51394066fea5147d46c6c5283a76 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 19:30:32 +0000 Subject: [PATCH] Resolve relative model paths in tsci export glb and gltf The glb and gltf export formats passed model URLs straight to the GLB converter, which fetch()es them, so a relative cadModel stepUrl such as ./libraries/cap.step failed with 404. They now go through convertModelUrlsToFileUrls like `tsci build --glbs` does. Fixes #5654. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PiJ1d34GaQJAWypDADnioN --- lib/shared/export-snippet.ts | 5 +++-- tests/cli/export/export-glb-relative-step-model.test.ts | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/shared/export-snippet.ts b/lib/shared/export-snippet.ts index 878e1ef4b..8efbf7766 100644 --- a/lib/shared/export-snippet.ts +++ b/lib/shared/export-snippet.ts @@ -38,6 +38,7 @@ import { getPlatformConfigWithCliDefaults } from "lib/shared/get-platform-config import { loadLocalStepModelFsMap } from "lib/shared/load-local-step-model-fs-map" import { mergePlatformConfigs } from "lib/shared/platform-config-utils" import { convertCircuitJsonToSchematicPdf } from "./convert-circuit-json-to-schematic-pdf" +import { convertModelUrlsToFileUrls } from "../../cli/build/convert-model-urls-to-file-urls" import { convertToKicadLibrary } from "./convert-to-kicad-library" import { importFromUserLand } from "./importFromUserLand" import { isCircuitJsonFile } from "./is-circuit-json-file" @@ -348,7 +349,7 @@ export const exportSnippet = async ({ case "gltf": outputContent = JSON.stringify( await convertCircuitJsonToGltf( - circuitJson, + convertModelUrlsToFileUrls(circuitJson), getCircuitJsonToGltfOptions({ format: "gltf" }), ), null, @@ -358,7 +359,7 @@ export const exportSnippet = async ({ case "glb": outputContent = Buffer.from( (await convertCircuitJsonToGltf( - circuitJson, + convertModelUrlsToFileUrls(circuitJson), getCircuitJsonToGltfOptions({ format: "glb" }), )) as ArrayBuffer, ) diff --git a/tests/cli/export/export-glb-relative-step-model.test.ts b/tests/cli/export/export-glb-relative-step-model.test.ts index 72f063e78..56a897040 100644 --- a/tests/cli/export/export-glb-relative-step-model.test.ts +++ b/tests/cli/export/export-glb-relative-step-model.test.ts @@ -37,11 +37,7 @@ test( [...stderr.matchAll(/Failed to load STEP from [^:]+/g)].map( ([message]) => message, ), - ).toMatchInlineSnapshot(` - [ - "Failed to load STEP from ./libraries/cap.step", - ] - `) + ).toMatchInlineSnapshot(`[]`) }, { timeout: 60000 }, )