@grame/faustwasm 0.13.0 → 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.
@@ -10980,6 +10980,7 @@ var FaustPolyScriptProcessorNode = class extends FaustScriptProcessorNode {
10980
10980
  };
10981
10981
 
10982
10982
  // src/FaustDspGenerator.ts
10983
+ var import_meta = {};
10983
10984
  var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
10984
10985
  constructor() {
10985
10986
  this.factory = null;
@@ -11628,20 +11629,38 @@ var _FaustDspGenerator = class _FaustDspGenerator {
11628
11629
  async createFaustNode(context, name, code, sp, bufferSize) {
11629
11630
  const getCompiler = async () => {
11630
11631
  if (!_FaustDspGenerator.compilerPromise) {
11631
- const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
11632
- if (!baseURL)
11633
- throw new Error("Cannot resolve libfaust-wasm location.");
11634
- const jsURL = new URL(
11635
- "../libfaust-wasm/libfaust-wasm.js",
11636
- baseURL
11637
- ).href;
11638
- const dataURL = jsURL.replace(/c?js$/, "data");
11639
- const wasmURL = jsURL.replace(/c?js$/, "wasm");
11640
- _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
11641
- jsURL,
11642
- dataURL,
11643
- wasmURL
11644
- ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
11632
+ const isNode = typeof document === "undefined" && typeof window === "undefined";
11633
+ if (isNode) {
11634
+ const baseURL = (typeof __dirname !== "undefined" ? `file://${__dirname}/` : void 0) || (typeof import_meta !== "undefined" && typeof import_meta.url === "string" ? import_meta.url : void 0);
11635
+ if (!baseURL)
11636
+ throw new Error("Cannot resolve libfaust-wasm location.");
11637
+ const jsURL = new URL(
11638
+ "../libfaust-wasm/libfaust-wasm.js",
11639
+ baseURL
11640
+ ).href;
11641
+ const dataURL = jsURL.replace(/c?js$/, "data");
11642
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
11643
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
11644
+ jsURL,
11645
+ dataURL,
11646
+ wasmURL
11647
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
11648
+ } else {
11649
+ const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
11650
+ if (!baseURL)
11651
+ throw new Error("Cannot resolve libfaust-wasm location.");
11652
+ const jsURL = new URL(
11653
+ "../libfaust-wasm/libfaust-wasm.js",
11654
+ baseURL
11655
+ ).href;
11656
+ const dataURL = jsURL.replace(/c?js$/, "data");
11657
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
11658
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
11659
+ jsURL,
11660
+ dataURL,
11661
+ wasmURL
11662
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
11663
+ }
11645
11664
  }
11646
11665
  return _FaustDspGenerator.compilerPromise;
11647
11666
  };