@grame/faustwasm 0.15.6 → 0.15.7

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.
@@ -1378,13 +1378,6 @@ export declare class SoundfileReader {
1378
1378
  * @returns : the URLs
1379
1379
  */
1380
1380
  static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"];
1381
- /**
1382
- * Check if the file exists.
1383
- *
1384
- * @param url : the url of the file to check
1385
- * @returns : true if the file exists, otherwise false
1386
- */
1387
- private static checkFileExists;
1388
1381
  /**
1389
1382
  * Fetch the soundfile.
1390
1383
  *
package/dist/cjs/index.js CHANGED
@@ -2741,7 +2741,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2741
2741
  const trimmed = input.replace(/^\{|\}$/g, "");
2742
2742
  return trimmed.split(";").map(
2743
2743
  (str) => str.length <= 2 ? "" : str.substring(1, str.length - 1)
2744
- );
2744
+ ).map((str) => str.trim()).filter((str) => str.length > 0);
2745
2745
  }
2746
2746
  get hasAccInput() {
2747
2747
  return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0;
@@ -4002,7 +4002,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4002
4002
  outputs[i].set(output, l);
4003
4003
  }
4004
4004
  }
4005
- l += this.fBufferSize;
4005
+ l += sliceLength;
4006
4006
  onUpdate == null ? void 0 : onUpdate(l);
4007
4007
  }
4008
4008
  this.fDSPCode.stop();
@@ -4551,29 +4551,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4551
4551
  const callback = (item) => {
4552
4552
  if (item.type === "soundfile") {
4553
4553
  const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);
4554
- urls.forEach((url) => soundfiles[url] = null);
4554
+ urls.filter((url) => url.trim().length > 0).forEach((url) => soundfiles[url] = null);
4555
4555
  }
4556
4556
  };
4557
4557
  FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);
4558
4558
  return soundfiles;
4559
4559
  }
4560
- /**
4561
- * Check if the file exists.
4562
- *
4563
- * @param url : the url of the file to check
4564
- * @returns : true if the file exists, otherwise false
4565
- */
4566
- static async checkFileExists(url) {
4567
- try {
4568
- console.log(`"checkFileExists" url: ${url}`);
4569
- const response = await fetch(url);
4570
- console.log(`"checkFileExists" response.ok: ${response.ok}`);
4571
- return response.ok;
4572
- } catch (error) {
4573
- console.error("Fetch error:", error);
4574
- return false;
4575
- }
4576
- }
4577
4560
  /**
4578
4561
  * Fetch the soundfile.
4579
4562
  *
@@ -4608,17 +4591,20 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4608
4591
  (path) => new URL(filename, path.endsWith("/") ? path : `${path}/`).href
4609
4592
  )
4610
4593
  ];
4611
- const checkResults = await Promise.all(
4612
- urlsToCheck.map((url) => this.checkFileExists(url))
4613
- );
4614
- const successIndex = checkResults.findIndex((r) => !!r);
4615
- if (successIndex === -1)
4616
- throw new Error(
4617
- `Failed to load sound file ${filename}, all check failed.`
4618
- );
4619
- soundfiles[filename] = await this.fetchSoundfile(
4620
- urlsToCheck[successIndex],
4621
- audioCtx
4594
+ let lastError = null;
4595
+ for (const url of urlsToCheck) {
4596
+ try {
4597
+ soundfiles[filename] = await this.fetchSoundfile(
4598
+ url,
4599
+ audioCtx
4600
+ );
4601
+ return;
4602
+ } catch (error) {
4603
+ lastError = error;
4604
+ }
4605
+ }
4606
+ throw new Error(
4607
+ `Failed to load sound file ${filename}, all check failed. Last error: ${String(lastError)}`
4622
4608
  );
4623
4609
  }
4624
4610
  /**