@grame/faustwasm 0.13.2 → 0.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -1123,53 +1123,32 @@ export class FaustDspGenerator implements IFaustDspGenerator {
1123
1123
  ): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null> {
1124
1124
  const getCompiler = async () => {
1125
1125
  if (!FaustDspGenerator.compilerPromise) {
1126
- const isNode =
1127
- typeof document === 'undefined' && typeof window === 'undefined';
1128
- if (isNode) {
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');
1139
- FaustDspGenerator.compilerPromise =
1140
- instantiateFaustModuleFromFile(
1141
- jsPath,
1142
- dataPath,
1143
- wasmPath
1144
- ).then((module) => new FaustCompiler(new LibFaust(module)));
1145
- } else {
1146
- // Resolve libfaust-wasm assets relative to current script/page location (works in browser and bundlers).
1147
- // Falling back to document/baseURI keeps things working when import.meta.url is unavailable (es2019 target).
1148
- const baseURL =
1149
- (typeof document !== 'undefined'
1150
- ? ('src' in (document.currentScript || {})
1151
- ? (document.currentScript as HTMLScriptElement)
1152
- .src
1153
- : document.baseURI)
1154
- : undefined) ||
1155
- (typeof window !== 'undefined'
1156
- ? window.location.href
1157
- : undefined);
1158
- if (!baseURL)
1159
- throw new Error('Cannot resolve libfaust-wasm location.');
1160
- const jsURL = new URL(
1161
- '../libfaust-wasm/libfaust-wasm.js',
1162
- baseURL
1163
- ).href;
1164
- const dataURL = jsURL.replace(/c?js$/, 'data');
1165
- const wasmURL = jsURL.replace(/c?js$/, 'wasm');
1166
- FaustDspGenerator.compilerPromise =
1167
- instantiateFaustModuleFromFile(
1168
- jsURL,
1169
- dataURL,
1170
- wasmURL
1171
- ).then((module) => new FaustCompiler(new LibFaust(module)));
1172
- }
1126
+ // Resolve libfaust-wasm assets relative to current script/page location (works in browser and bundlers).
1127
+ // Falling back to document/baseURI keeps things working when import.meta.url is unavailable (es2019 target).
1128
+ const baseURL =
1129
+ (typeof document !== 'undefined'
1130
+ ? ('src' in (document.currentScript || {})
1131
+ ? (document.currentScript as HTMLScriptElement)
1132
+ .src
1133
+ : document.baseURI)
1134
+ : undefined) ||
1135
+ (typeof window !== 'undefined'
1136
+ ? window.location.href
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');
1146
+ FaustDspGenerator.compilerPromise =
1147
+ instantiateFaustModuleFromFile(
1148
+ jsURL,
1149
+ dataURL,
1150
+ wasmURL
1151
+ ).then((module) => new FaustCompiler(new LibFaust(module)));
1173
1152
  }
1174
1153
  return FaustDspGenerator.compilerPromise;
1175
1154
  };
@@ -5192,7 +5192,6 @@ var FaustPolyScriptProcessorNode = class extends FaustScriptProcessorNode {
5192
5192
  };
5193
5193
 
5194
5194
  // src/FaustDspGenerator.ts
5195
- var import_meta = {};
5196
5195
  var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
5197
5196
  constructor() {
5198
5197
  this.factory = null;
@@ -5841,38 +5840,20 @@ var _FaustDspGenerator = class _FaustDspGenerator {
5841
5840
  async createFaustNode(context, name, code, sp, bufferSize) {
5842
5841
  const getCompiler = async () => {
5843
5842
  if (!_FaustDspGenerator.compilerPromise) {
5844
- const isNode = typeof document === "undefined" && typeof window === "undefined";
5845
- if (isNode) {
5846
- const baseURL = (typeof __dirname !== "undefined" ? `file://${__dirname}/` : void 0) || (typeof import_meta !== "undefined" && typeof import_meta.url === "string" ? import_meta.url : void 0);
5847
- if (!baseURL)
5848
- throw new Error("Cannot resolve libfaust-wasm location.");
5849
- const jsURL = new URL(
5850
- "../libfaust-wasm/libfaust-wasm.js",
5851
- baseURL
5852
- ).href;
5853
- const dataURL = jsURL.replace(/c?js$/, "data");
5854
- const wasmURL = jsURL.replace(/c?js$/, "wasm");
5855
- _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5856
- jsURL,
5857
- dataURL,
5858
- wasmURL
5859
- ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5860
- } else {
5861
- const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
5862
- if (!baseURL)
5863
- throw new Error("Cannot resolve libfaust-wasm location.");
5864
- const jsURL = new URL(
5865
- "../libfaust-wasm/libfaust-wasm.js",
5866
- baseURL
5867
- ).href;
5868
- const dataURL = jsURL.replace(/c?js$/, "data");
5869
- const wasmURL = jsURL.replace(/c?js$/, "wasm");
5870
- _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5871
- jsURL,
5872
- dataURL,
5873
- wasmURL
5874
- ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5875
- }
5843
+ const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
5844
+ if (!baseURL)
5845
+ throw new Error("Cannot resolve libfaust-wasm location.");
5846
+ const jsURL = new URL(
5847
+ "../libfaust-wasm/libfaust-wasm.js",
5848
+ baseURL
5849
+ ).href;
5850
+ const dataURL = jsURL.replace(/c?js$/, "data");
5851
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
5852
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5853
+ jsURL,
5854
+ dataURL,
5855
+ wasmURL
5856
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5876
5857
  }
5877
5858
  return _FaustDspGenerator.compilerPromise;
5878
5859
  };