@grame/faustwasm 0.13.7 → 0.14.1

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.
@@ -132,6 +132,7 @@ export interface FaustUIInputItem {
132
132
  type: FaustUIInputType;
133
133
  label: string;
134
134
  address: string;
135
+ shortname: string;
135
136
  url: string;
136
137
  index: number;
137
138
  init?: number;
@@ -144,6 +145,7 @@ export interface FaustUIOutputItem {
144
145
  type: FaustUIOutputType;
145
146
  label: string;
146
147
  address: string;
148
+ shortname: string;
147
149
  index: number;
148
150
  min?: number;
149
151
  max?: number;
@@ -1321,6 +1323,12 @@ export declare class WavDecoder {
1321
1323
  }
1322
1324
  /** Read metadata and fetch soundfiles */
1323
1325
  export declare class SoundfileReader {
1326
+ /**
1327
+ * Set fallback base URLs used to resolve soundfile paths.
1328
+ *
1329
+ * In Node or other non-browser runtimes, `location` may be undefined;
1330
+ * in that case this returns an empty list to avoid resolution errors.
1331
+ */
1324
1332
  static get fallbackPaths(): string[];
1325
1333
  /**
1326
1334
  * Extract the parent URL from an URL.
@@ -1394,6 +1402,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1394
1402
  protected fUICallback: UIHandler;
1395
1403
  protected fDescriptor: FaustUIInputItem[];
1396
1404
  protected fCommunicator: FaustAudioWorkletNodeCommunicator;
1405
+ protected fParamAliases: Record<string, string>;
1397
1406
  constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
1398
1407
  protected handleMessageAux: (e: MessageEvent) => void;
1399
1408
  private handleDeviceMotion;
package/dist/cjs/index.js CHANGED
@@ -2555,11 +2555,25 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2555
2555
  this.fPathTable = {};
2556
2556
  this.fUICallback = (item) => {
2557
2557
  if (item.type === "hbargraph" || item.type === "vbargraph") {
2558
+ const registerPath = (alias) => {
2559
+ if (this.fPathTable[alias] === void 0) {
2560
+ this.fPathTable[alias] = item.index;
2561
+ }
2562
+ };
2558
2563
  this.fOutputsItems.push(item.address);
2559
- this.fPathTable[item.address] = item.index;
2564
+ registerPath(item.address);
2565
+ registerPath(item.shortname);
2566
+ registerPath(item.label);
2560
2567
  } else if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
2568
+ const registerPath = (alias) => {
2569
+ if (this.fPathTable[alias] === void 0) {
2570
+ this.fPathTable[alias] = item.index;
2571
+ }
2572
+ };
2561
2573
  this.fInputsItems.push(item.address);
2562
- this.fPathTable[item.address] = item.index;
2574
+ registerPath(item.address);
2575
+ registerPath(item.shortname);
2576
+ registerPath(item.label);
2563
2577
  this.fDescriptor.push(item);
2564
2578
  if (!item.meta) return;
2565
2579
  item.meta.forEach((meta) => {
@@ -4459,13 +4473,20 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4459
4473
 
4460
4474
  // src/SoundfileReader.ts
4461
4475
  var SoundfileReader = class {
4462
- // Set the fallback paths
4476
+ /**
4477
+ * Set fallback base URLs used to resolve soundfile paths.
4478
+ *
4479
+ * In Node or other non-browser runtimes, `location` may be undefined;
4480
+ * in that case this returns an empty list to avoid resolution errors.
4481
+ */
4463
4482
  static get fallbackPaths() {
4464
- return [
4465
- location.href,
4466
- this.getParentUrl(location.href),
4467
- location.origin
4468
- ];
4483
+ const loc = typeof location !== "undefined" ? location : null;
4484
+ const href = loc == null ? void 0 : loc.href;
4485
+ const origin = loc == null ? void 0 : loc.origin;
4486
+ const parent = href ? this.getParentUrl(href) : null;
4487
+ return [href, parent, origin].filter(
4488
+ (value) => typeof value === "string" && value.length > 0
4489
+ );
4469
4490
  }
4470
4491
  /**
4471
4492
  * Extract the parent URL from an URL.
@@ -4764,11 +4785,19 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4764
4785
  this.fComputeHandler = null;
4765
4786
  this.fPlotHandler = null;
4766
4787
  this.fDescriptor = [];
4788
+ this.fParamAliases = {};
4767
4789
  this.fInputsItems = [];
4768
4790
  this.fUICallback = (item) => {
4769
4791
  if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
4770
4792
  this.fInputsItems.push(item.address);
4771
4793
  this.fDescriptor.push(item);
4794
+ const registerAlias = (alias) => {
4795
+ if (!this.fParamAliases[alias]) {
4796
+ this.fParamAliases[alias] = item.address;
4797
+ }
4798
+ };
4799
+ registerAlias(item.shortname);
4800
+ registerAlias(item.label);
4772
4801
  if (!item.meta) return;
4773
4802
  item.meta.forEach((meta) => {
4774
4803
  const { midi, acc, gyr } = meta;
@@ -4923,13 +4952,14 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4923
4952
  });
4924
4953
  }
4925
4954
  setParamValue(path, value) {
4926
- const e = { type: "param", data: { path, value } };
4927
- this.port.postMessage(e);
4928
- const param = this.parameters.get(path);
4955
+ const resolved = this.fParamAliases[path] || path;
4956
+ this.port.postMessage({ type: "param", data: { path: resolved, value } });
4957
+ const param = this.parameters.get(resolved);
4929
4958
  if (param) param.setValueAtTime(value, this.context.currentTime);
4930
4959
  }
4931
4960
  getParamValue(path) {
4932
- const param = this.parameters.get(path);
4961
+ const resolved = this.fParamAliases[path] || path;
4962
+ const param = this.parameters.get(resolved);
4933
4963
  return param ? param.value : 0;
4934
4964
  }
4935
4965
  getParams() {