* Resolve the WASM directory. Walks up from this file's location until * it finds a `public/wasm` directory. Works from both source and dist: * * - Source: components/src/pipeline/wasm.ts (2 levels up) * - Dist: components/dist/pipeline.js (1 level up) * - npm: @opentrace/components/
()
| 56 | * - npm: @opentrace/components/dist/pipeline.js (1 level up) |
| 57 | */ |
| 58 | function findWasmDir(): string { |
| 59 | let dir = __dirname; |
| 60 | for (let i = 0; i < 5; i++) { |
| 61 | const candidate = join(dir, 'public', 'wasm'); |
| 62 | if (existsSync(candidate)) return candidate; |
| 63 | dir = dirname(dir); |
| 64 | } |
| 65 | // Should not happen in a correctly installed package |
| 66 | throw new Error( |
| 67 | 'Could not find WASM directory. Ensure @opentrace/components is installed correctly.', |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | let _wasmDir: string | undefined; |
| 72 |