@grame/faustwasm 0.13.1 → 0.13.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -1126,28 +1126,21 @@ export class FaustDspGenerator implements IFaustDspGenerator {
1126
1126
  const isNode =
1127
1127
  typeof document === 'undefined' && typeof window === 'undefined';
1128
1128
  if (isNode) {
1129
- // Resolve assets relative to this file when running in Node.
1130
- const baseURL =
1131
- (typeof __dirname !== 'undefined'
1132
- ? `file://${__dirname}/`
1133
- : undefined) ||
1134
- (typeof import.meta !== 'undefined' &&
1135
- typeof import.meta.url === 'string'
1136
- ? import.meta.url
1137
- : undefined);
1138
- if (!baseURL)
1139
- throw new Error('Cannot resolve libfaust-wasm location.');
1140
- const jsURL = new URL(
1141
- '../libfaust-wasm/libfaust-wasm.js',
1142
- baseURL
1143
- ).href;
1144
- const dataURL = jsURL.replace(/c?js$/, 'data');
1145
- const wasmURL = jsURL.replace(/c?js$/, 'wasm');
1129
+ // Resolve assets as filesystem paths in Node (no file:// prefix for fs.readFile)
1130
+ const { fileURLToPath } = await import('url');
1131
+ const jsPath = fileURLToPath(
1132
+ new URL(
1133
+ '../../libfaust-wasm/libfaust-wasm.js',
1134
+ import.meta.url
1135
+ )
1136
+ );
1137
+ const dataPath = jsPath.replace(/c?js$/, 'data');
1138
+ const wasmPath = jsPath.replace(/c?js$/, 'wasm');
1146
1139
  FaustDspGenerator.compilerPromise =
1147
1140
  instantiateFaustModuleFromFile(
1148
- jsURL,
1149
- dataURL,
1150
- wasmURL
1141
+ jsPath,
1142
+ dataPath,
1143
+ wasmPath
1151
1144
  ).then((module) => new FaustCompiler(new LibFaust(module)));
1152
1145
  } else {
1153
1146
  // Resolve libfaust-wasm assets relative to current script/page location (works in browser and bundlers).