circuit-json-to-step 0.0.25 → 0.0.26

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.d.ts CHANGED
@@ -1,4 +1,13 @@
1
1
  import { CircuitJson } from 'circuit-json';
2
+ import * as circuit_json_to_gltf from 'circuit-json-to-gltf';
3
+
4
+ type CircuitJsonToGltfModule = typeof circuit_json_to_gltf;
5
+ declare global {
6
+ var tscircuitDynamicModules: {
7
+ "circuit-json-to-gltf"?: CircuitJsonToGltfModule;
8
+ } | undefined;
9
+ }
10
+ declare const getCircuitJsonToGltfModule: () => Promise<CircuitJsonToGltfModule>;
2
11
 
3
12
  interface CircuitJsonToStepOptions {
4
13
  /** Board width in mm (optional if pcb_board is present) */
@@ -25,4 +34,4 @@ interface CircuitJsonToStepOptions {
25
34
  */
26
35
  declare function circuitJsonToStep(circuitJson: CircuitJson, options?: CircuitJsonToStepOptions): Promise<string>;
27
36
 
28
- export { type CircuitJsonToStepOptions, circuitJsonToStep };
37
+ export { type CircuitJsonToStepOptions, circuitJsonToStep, getCircuitJsonToGltfModule };
package/dist/index.js CHANGED
@@ -35,6 +35,20 @@ import {
35
35
  // lib/mesh-generation.ts
36
36
  import "stepts";
37
37
 
38
+ // lib/get-circuit-json-to-gltf-module.ts
39
+ var getCircuitJsonToGltfModule = async () => {
40
+ try {
41
+ return await import("circuit-json-to-gltf");
42
+ } catch (error) {
43
+ const dynamicGlobal = globalThis.tscircuitDynamicModules?.["circuit-json-to-gltf"];
44
+ if (dynamicGlobal) return dynamicGlobal;
45
+ throw new Error(
46
+ 'Unable to load "circuit-json-to-gltf" from import() or globalThis.tscircuitDynamicModules.',
47
+ { cause: error }
48
+ );
49
+ }
50
+ };
51
+
38
52
  // lib/scene-box-to-step.ts
39
53
  import { ClosedShell, ManifoldSolidBrep } from "stepts";
40
54
 
@@ -343,11 +357,7 @@ async function generateComponentMeshes(options) {
343
357
  }
344
358
  return element;
345
359
  });
346
- const gltfModule = "circuit-json-to-gltf";
347
- const { convertCircuitJsonTo3D } = await import(
348
- /* @vite-ignore */
349
- gltfModule
350
- );
360
+ const { convertCircuitJsonTo3D } = await getCircuitJsonToGltfModule();
351
361
  const scene3d = await convertCircuitJsonTo3D(filteredCircuitJson, {
352
362
  boardThickness,
353
363
  renderBoardTextures: false
@@ -1974,5 +1984,6 @@ async function circuitJsonToStep(circuitJson, options = {}) {
1974
1984
  return normalizeStepNumericExponents(stepText);
1975
1985
  }
1976
1986
  export {
1977
- circuitJsonToStep
1987
+ circuitJsonToStep,
1988
+ getCircuitJsonToGltfModule
1978
1989
  };
@@ -0,0 +1,24 @@
1
+ export type CircuitJsonToGltfModule = typeof import("circuit-json-to-gltf")
2
+
3
+ declare global {
4
+ var tscircuitDynamicModules:
5
+ | {
6
+ "circuit-json-to-gltf"?: CircuitJsonToGltfModule
7
+ }
8
+ | undefined
9
+ }
10
+
11
+ export const getCircuitJsonToGltfModule =
12
+ async (): Promise<CircuitJsonToGltfModule> => {
13
+ try {
14
+ return await import("circuit-json-to-gltf")
15
+ } catch (error) {
16
+ const dynamicGlobal =
17
+ globalThis.tscircuitDynamicModules?.["circuit-json-to-gltf"]
18
+ if (dynamicGlobal) return dynamicGlobal
19
+ throw new Error(
20
+ 'Unable to load "circuit-json-to-gltf" from import() or globalThis.tscircuitDynamicModules.',
21
+ { cause: error },
22
+ )
23
+ }
24
+ }
package/lib/index.ts CHANGED
@@ -760,3 +760,5 @@ export async function circuitJsonToStep(
760
760
  const stepText = repo.toPartFile({ name: productName })
761
761
  return normalizeStepNumericExponents(stepText)
762
762
  }
763
+
764
+ export { getCircuitJsonToGltfModule } from "./get-circuit-json-to-gltf-module"
@@ -1,6 +1,7 @@
1
1
  import type { CircuitJson } from "circuit-json"
2
2
  import type { Ref, Repository } from "stepts"
3
3
  import { ManifoldSolidBrep } from "stepts"
4
+ import { getCircuitJsonToGltfModule } from "./get-circuit-json-to-gltf-module"
4
5
  import { createSceneBoxSolid } from "./scene-box-to-step"
5
6
  import type { GeneratedSceneSolid, SceneBox } from "./scene-geometry"
6
7
 
@@ -93,10 +94,7 @@ export async function generateComponentMeshes(
93
94
  return element
94
95
  })
95
96
 
96
- const gltfModule = "circuit-json-to-gltf"
97
- const { convertCircuitJsonTo3D } = await import(
98
- /* @vite-ignore */ gltfModule
99
- )
97
+ const { convertCircuitJsonTo3D } = await getCircuitJsonToGltfModule()
100
98
 
101
99
  const scene3d = await convertCircuitJsonTo3D(filteredCircuitJson, {
102
100
  boardThickness,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-json-to-step",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.25",
4
+ "version": "0.0.26",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "pull-reference": "git clone https://github.com/tscircuit/circuit-json.git && find circuit-json/tests -name '*.test.ts' -exec bash -c 'mv \"$0\" \"${0%.test.ts}.ts\"' {} \\; && git clone https://github.com/tscircuit/stepts.git && find stepts/tests -name '*.test.ts' -exec bash -c 'mv \"$0\" \"${0%.test.ts}.ts\"' {} \\;",
@@ -0,0 +1,11 @@
1
+ import { expect, test } from "bun:test"
2
+ import { getCircuitJsonToGltfModule } from "../lib/index"
3
+
4
+ test("getCircuitJsonToGltfModule returns the circuit-json-to-gltf module", async () => {
5
+ const loaded = await getCircuitJsonToGltfModule()
6
+ const direct = await import("circuit-json-to-gltf")
7
+
8
+ expect(loaded).toBe(direct)
9
+ expect(loaded.convertCircuitJsonTo3D).toBeFunction()
10
+ expect(loaded.convertSceneToGLTF).toBeFunction()
11
+ })