@grame/faust-web-component 0.2.10 → 0.2.12

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@grame/faust-web-component",
3
3
  "description": "Web component embedding the Faust Compiler",
4
- "version": "0.2.10",
4
+ "version": "0.2.12",
5
5
  "module": "dist/faust-web-component.js",
6
6
  "files": [
7
7
  "src/",
@@ -449,8 +449,12 @@ export default class FaustEditor extends HTMLElement {
449
449
  if (node && node.numberOfInputs > 0) {
450
450
  if (deviceId == "Audio File") {
451
451
  try {
452
+ // Extract the base URL (excluding the script filename)
453
+ const scriptTag = document.querySelector('script[src$="faust-web-component.js"]');
454
+ const scriptSrc = scriptTag.src;
455
+ const baseUrl = scriptSrc.substring(0, scriptSrc.lastIndexOf('/') + 1);
452
456
  // Load the file
453
- let file = await fetch('02-XYLO1.mp3');
457
+ let file = await fetch(baseUrl + '02-XYLO1.mp3');
454
458
  const arrayBuffer = await file.arrayBuffer();
455
459
  let audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
456
460
  // Create a source node from the buffer
@@ -218,8 +218,12 @@ export default class FaustWidget extends HTMLElement {
218
218
  if (node && node.numberOfInputs > 0) {
219
219
  if (deviceId == "Audio File") {
220
220
  try {
221
+ // Extract the base URL (excluding the script filename)
222
+ const scriptTag = document.querySelector('script[src$="faust-web-component.js"]');
223
+ const scriptSrc = scriptTag.src;
224
+ const baseUrl = scriptSrc.substring(0, scriptSrc.lastIndexOf('/') + 1);
221
225
  // Load the file
222
- let file = await fetch('02-XYLO1.mp3');
226
+ let file = await fetch(baseUrl + '02-XYLO1.mp3');
223
227
  const arrayBuffer = await file.arrayBuffer();
224
228
  let audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
225
229
  // Create a source node from the buffer