{"version":3,"file":"node.cjs","names":[],"sources":["../src/wasm-path.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\n\n/**\n * Get the absolute file path to the libavoid WASM binary.\n *\n * This is useful for configuring bundlers or copying the WASM file\n * to your app's public directory during build.\n *\n * Only works in Node.js environments.\n *\n * @example\n * ```ts\n * import { getWasmPath } from \"@mr_mint/elkjs-libavoid/node\";\n * console.log(getWasmPath());\n * // \"/path/to/node_modules/libavoid-js/dist/libavoid.wasm\"\n * ```\n */\nexport function getWasmPath(): string {\n\tlet entryPath: string;\n\ttry {\n\t\tconst require = createRequire(import.meta.url);\n\t\tentryPath = require.resolve(\"libavoid-js\");\n\t} catch {\n\t\tthrow new Error(\n\t\t\t\"Could not resolve libavoid-js. Ensure it is installed as a dependency.\",\n\t\t);\n\t}\n\n\tconst wasmPath = join(dirname(entryPath), \"libavoid.wasm\");\n\tif (!existsSync(wasmPath)) {\n\t\tthrow new Error(\n\t\t\t`Could not find libavoid.wasm at ${wasmPath}. Ensure libavoid-js is properly installed.`,\n\t\t);\n\t}\n\treturn wasmPath;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,cAAsB;CACrC,IAAI;AACJ,KAAI;AAEH,eAAA,GAAA,YAAA,eAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,KAD8C,CAC1B,QAAQ,cAAc;SACnC;AACP,QAAM,IAAI,MACT,yEACA;;CAGF,MAAM,YAAA,GAAA,UAAA,OAAA,GAAA,UAAA,SAAwB,UAAU,EAAE,gBAAgB;AAC1D,KAAI,EAAA,GAAA,QAAA,YAAY,SAAS,CACxB,OAAM,IAAI,MACT,mCAAmC,SAAS,6CAC5C;AAEF,QAAO"}