@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 +1 -1
- package/src/FaustDspGenerator.ts +13 -20
package/package.json
CHANGED
package/src/FaustDspGenerator.ts
CHANGED
|
@@ -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
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
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
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
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).
|