@codedir/mimir-code 0.1.2 → 0.1.3

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/cli.mjs CHANGED
@@ -3906,6 +3906,19 @@ import { fileURLToPath } from "url";
3906
3906
  import { readFileSync, existsSync } from "fs";
3907
3907
  function locateWasmFile() {
3908
3908
  const wasmFileName = "sql-wasm.wasm";
3909
+ const currentDir = dirname(fileURLToPath(import.meta.url));
3910
+ const nodeModulesPaths = [
3911
+ // Relative to the built module (dist/storage/Database.js)
3912
+ join(currentDir, "..", "..", "node_modules", "sql.js", "dist", wasmFileName),
3913
+ // Relative to current working directory (for local development)
3914
+ join(process.cwd(), "node_modules", "sql.js", "dist", wasmFileName)
3915
+ ];
3916
+ for (const modulePath of nodeModulesPaths) {
3917
+ if (existsSync(modulePath)) {
3918
+ const buffer = readFileSync(modulePath);
3919
+ return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
3920
+ }
3921
+ }
3909
3922
  const executablePath = process.argv[0] || process.execPath;
3910
3923
  const binaryDir = dirname(executablePath);
3911
3924
  const resourcesPaths = [
@@ -3922,23 +3935,13 @@ function locateWasmFile() {
3922
3935
  return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
3923
3936
  }
3924
3937
  }
3925
- const currentDir = dirname(fileURLToPath(import.meta.url));
3926
- const nodeModulesPaths = [
3927
- join(currentDir, "..", "..", "node_modules", "sql.js", "dist", wasmFileName),
3928
- join(process.cwd(), "node_modules", "sql.js", "dist", wasmFileName)
3929
- ];
3930
- for (const modulePath of nodeModulesPaths) {
3931
- if (existsSync(modulePath)) {
3932
- const buffer = readFileSync(modulePath);
3933
- return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
3934
- }
3935
- }
3936
3938
  const diagnostics = [
3939
+ `import.meta.url: ${import.meta.url}`,
3940
+ `currentDir: ${currentDir}`,
3937
3941
  `process.argv[0]: ${process.argv[0]}`,
3938
3942
  `process.execPath: ${process.execPath}`,
3939
3943
  `executablePath: ${executablePath}`,
3940
3944
  `binaryDir: ${binaryDir}`,
3941
- `currentDir: ${currentDir}`,
3942
3945
  `process.cwd(): ${process.cwd()}`
3943
3946
  ];
3944
3947
  throw new Error(
@@ -3948,7 +3951,7 @@ Diagnostics:
3948
3951
  ${diagnostics.join("\n")}
3949
3952
 
3950
3953
  Tried:
3951
- ` + [...resourcesPaths, ...nodeModulesPaths].map((p) => ` - ${p}`).join("\n")
3954
+ ` + [...nodeModulesPaths, ...resourcesPaths].map((p) => ` - ${p}`).join("\n")
3952
3955
  );
3953
3956
  }
3954
3957
  var DatabaseManager = class _DatabaseManager {