circuit-json-to-gltf 0.0.155 → 0.0.157

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
@@ -366,6 +366,18 @@ declare function getBestCameraPosition(circuitJson: CircuitJson, opts?: CameraFi
366
366
  fov: number;
367
367
  };
368
368
 
369
+ type OcctImportJsFactory = (moduleArgs?: {
370
+ locateFile?: (path: string, scriptDirectory: string) => string;
371
+ }) => Promise<any>;
372
+ /**
373
+ * Provide occt-import-js for STEP loading, e.g. from your own bundle or a
374
+ * self-hosted copy. Otherwise it is imported from node_modules under Node and
375
+ * from a CDN in browsers.
376
+ */
377
+ declare function setOcctImportJs(factory: OcctImportJsFactory, options?: {
378
+ wasmUrl?: string;
379
+ }): void;
380
+
369
381
  declare function applyCoordinateTransform(point: Point3, config: CoordinateTransformConfig): Point3;
370
382
  /** Convert source-frame triangles into the configured frame, in the same mm
371
383
  * units. Reflections preserve outward faces by swapping winding and vertex UVs;
@@ -405,4 +417,4 @@ interface BRepShape {
405
417
  is_negative?: boolean;
406
418
  }
407
419
 
408
- export { type BRepShape, type BoardRenderOptions, type BoundingBox, type Box3D, CAMERA_PRESET_DIRECTIONS, COORDINATE_TRANSFORMS, type Camera3D, type CameraFitOptions, type CameraPreset, type CircuitJsonWithPcbFlex, type CircuitTo3DOptions, type Color, type ConversionOptions, type CoordinateTransformConfig, type GLTFExportOptions, type LayerRef, type Light3D, type OBJMaterial, type OBJMesh, type PcbBendRecord, type PcbStiffenerRecord, type Point, type Point3, type PoppyglErrorOverlay, type PoppyglErrorOverlayOptions, type STLMesh, type Scene3D, type Size3, type Triangle, applyCoordinateTransform, clearGLBCache, clearOBJCache, clearSTLCache, convertCircuitJsonTo3D, convertCircuitJsonToGltf, convertSceneToGLTF, getBestCameraPosition, getPoppyglErrorOverlayOptions, loadGLB, loadJscadPlan, loadOBJ, loadSTL, renderBoardLayer, renderBoardTextures, transformTriangles };
420
+ export { type BRepShape, type BoardRenderOptions, type BoundingBox, type Box3D, CAMERA_PRESET_DIRECTIONS, COORDINATE_TRANSFORMS, type Camera3D, type CameraFitOptions, type CameraPreset, type CircuitJsonWithPcbFlex, type CircuitTo3DOptions, type Color, type ConversionOptions, type CoordinateTransformConfig, type GLTFExportOptions, type LayerRef, type Light3D, type OBJMaterial, type OBJMesh, type OcctImportJsFactory, type PcbBendRecord, type PcbStiffenerRecord, type Point, type Point3, type PoppyglErrorOverlay, type PoppyglErrorOverlayOptions, type STLMesh, type Scene3D, type Size3, type Triangle, applyCoordinateTransform, clearGLBCache, clearOBJCache, clearSTLCache, convertCircuitJsonTo3D, convertCircuitJsonToGltf, convertSceneToGLTF, getBestCameraPosition, getPoppyglErrorOverlayOptions, loadGLB, loadJscadPlan, loadOBJ, loadSTL, renderBoardLayer, renderBoardTextures, setOcctImportJs, transformTriangles };
package/dist/index.js CHANGED
@@ -17745,24 +17745,42 @@ function clearOBJCache() {
17745
17745
 
17746
17746
  // lib/loaders/step.ts
17747
17747
  var stepCache = /* @__PURE__ */ new Map();
17748
+ var OCCT_IMPORT_JS_VERSION = "0.0.23";
17749
+ var OCCT_IMPORT_JS_CDN_URL = `https://cdn.jsdelivr.net/npm/occt-import-js@${OCCT_IMPORT_JS_VERSION}`;
17750
+ var occtImportJsFactory;
17751
+ var occtWasmUrl;
17748
17752
  var occtModulePromise = null;
17753
+ function setOcctImportJs(factory, options = {}) {
17754
+ occtImportJsFactory = factory;
17755
+ occtWasmUrl = options.wasmUrl;
17756
+ occtModulePromise = null;
17757
+ }
17758
+ var isNode = () => typeof process !== "undefined" && Boolean(process.versions?.node);
17759
+ var importAtRuntime = (specifier) => import(
17760
+ /* @vite-ignore */
17761
+ /* webpackIgnore: true */
17762
+ specifier
17763
+ );
17764
+ async function importOcctImportJs() {
17765
+ const occtModule = await importAtRuntime(
17766
+ isNode() ? "occt-import-js" : `${OCCT_IMPORT_JS_CDN_URL}/+esm`
17767
+ );
17768
+ return occtModule.default ?? occtModule;
17769
+ }
17749
17770
  async function getOcctModule() {
17750
17771
  if (!occtModulePromise) {
17751
- const occtimportjs = (await import("occt-import-js")).default;
17752
- const isBrowser = typeof window !== "undefined" || typeof self !== "undefined";
17753
- if (isBrowser) {
17754
- let wasmUrl;
17755
- try {
17756
- wasmUrl = (await import("occt-import-js/dist/occt-import-js.wasm?url")).default;
17757
- } catch {
17758
- wasmUrl = void 0;
17759
- }
17760
- occtModulePromise = occtimportjs({
17761
- locateFile: (path) => path.endsWith(".wasm") && wasmUrl ? wasmUrl : path
17762
- });
17763
- } else {
17764
- occtModulePromise = occtimportjs();
17765
- }
17772
+ occtModulePromise = (async () => {
17773
+ const factory = occtImportJsFactory ?? await importOcctImportJs();
17774
+ const wasmUrl = occtWasmUrl ?? (occtImportJsFactory || isNode() ? void 0 : `${OCCT_IMPORT_JS_CDN_URL}/dist/occt-import-js.wasm`);
17775
+ return factory(
17776
+ wasmUrl ? {
17777
+ locateFile: (path, scriptDirectory) => path.endsWith(".wasm") ? wasmUrl : scriptDirectory + path
17778
+ } : void 0
17779
+ );
17780
+ })();
17781
+ occtModulePromise.catch(() => {
17782
+ occtModulePromise = null;
17783
+ });
17766
17784
  }
17767
17785
  return occtModulePromise;
17768
17786
  }
@@ -18400,7 +18418,7 @@ async function convertSvgToPng(svgString, resolution, backgroundColor) {
18400
18418
  });
18401
18419
  } else {
18402
18420
  try {
18403
- const { svgToPngDataUrl } = await import("./svg-to-png-AFPNZW36.js");
18421
+ const { svgToPngDataUrl } = await import("./svg-to-png-NRFWX3UJ.js");
18404
18422
  return await svgToPngDataUrl(svgString, {
18405
18423
  width: resolution,
18406
18424
  background: backgroundColor
@@ -20567,5 +20585,6 @@ export {
20567
20585
  loadSTL,
20568
20586
  renderBoardLayer,
20569
20587
  renderBoardTextures,
20588
+ setOcctImportJs,
20570
20589
  transformTriangles
20571
20590
  };
@@ -1,7 +1,6 @@
1
1
  import "./chunk-QGM4M3NI.js";
2
2
 
3
3
  // lib/utils/svg-to-png.ts
4
- import { Resvg } from "@resvg/resvg-js";
5
4
  import tscircuitFont from "@tscircuit/alphabet/base64font";
6
5
  var isNode = typeof process !== "undefined" && process.versions && process.versions.node;
7
6
  async function svgToPng(svgString, options = {}) {
@@ -49,6 +48,7 @@ async function svgToPng(svgString, options = {}) {
49
48
  sansSerifFamily: "TscircuitAlphabet"
50
49
  }
51
50
  };
51
+ const { Resvg } = await import("@resvg/resvg-js");
52
52
  const resvg = new Resvg(svgString, opts);
53
53
  const pngData = resvg.render();
54
54
  const pngBuffer = pngData.asPng();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "circuit-json-to-gltf",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.155",
5
+ "version": "0.0.157",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/tscircuit/circuit-json-to-gltf.git"
@@ -19,6 +19,12 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
+ "browser": {
23
+ "@resvg/resvg-js": false,
24
+ "fs": false,
25
+ "os": false,
26
+ "path": false
27
+ },
22
28
  "dependencies": {
23
29
  "@jscad/modeling": "^2.12.6",
24
30
  "@tscircuit/alphabet": "^0.0.25",
@@ -40,6 +46,7 @@
40
46
  "@tscircuit/circuit-json-util": "^0.0.114",
41
47
  "@tscircuit/core": "^0.0.1955",
42
48
  "@tscircuit/flex-utils": "https://jscdn.tscircuit.com/@tscircuit/flex-utils/0.0.8.tgz",
49
+ "@tscircuit/image-utils": "^0.0.10",
43
50
  "@tscircuit/props": "^0.0.664",
44
51
  "@types/bun": "latest",
45
52
  "@types/earcut": "^3.0.0",
@@ -50,7 +57,6 @@
50
57
  "circuit-json": "https://pkg.pr.new/circuit-json@90e54bd",
51
58
  "circuit-to-svg": "^0.0.445",
52
59
  "graphics-debug": "^0.0.96",
53
- "looks-same": "^9.0.1",
54
60
  "poppygl": "0.0.32",
55
61
  "react": "^19.1.1",
56
62
  "react-cosmos": "^7.0.0",