@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.
@@ -11026,6 +11026,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11026
11026
  };
11027
11027
 
11028
11028
  // src/FaustDspGenerator.ts
11029
+ var import_meta = {};
11029
11030
  var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
11030
11031
  constructor() {
11031
11032
  this.factory = null;
@@ -11674,20 +11675,38 @@ const dependencies = {
11674
11675
  async createFaustNode(context, name, code, sp, bufferSize) {
11675
11676
  const getCompiler = async () => {
11676
11677
  if (!_FaustDspGenerator.compilerPromise) {
11677
- const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
11678
- if (!baseURL)
11679
- throw new Error("Cannot resolve libfaust-wasm location.");
11680
- const jsURL = new URL(
11681
- "../libfaust-wasm/libfaust-wasm.js",
11682
- baseURL
11683
- ).href;
11684
- const dataURL = jsURL.replace(/c?js$/, "data");
11685
- const wasmURL = jsURL.replace(/c?js$/, "wasm");
11686
- _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
11687
- jsURL,
11688
- dataURL,
11689
- wasmURL
11690
- ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
11678
+ const isNode = typeof document === "undefined" && typeof window === "undefined";
11679
+ if (isNode) {
11680
+ const baseURL = (typeof __dirname !== "undefined" ? `file://${__dirname}/` : void 0) || (typeof import_meta !== "undefined" && typeof import_meta.url === "string" ? import_meta.url : void 0);
11681
+ if (!baseURL)
11682
+ throw new Error("Cannot resolve libfaust-wasm location.");
11683
+ const jsURL = new URL(
11684
+ "../libfaust-wasm/libfaust-wasm.js",
11685
+ baseURL
11686
+ ).href;
11687
+ const dataURL = jsURL.replace(/c?js$/, "data");
11688
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
11689
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
11690
+ jsURL,
11691
+ dataURL,
11692
+ wasmURL
11693
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
11694
+ } else {
11695
+ const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
11696
+ if (!baseURL)
11697
+ throw new Error("Cannot resolve libfaust-wasm location.");
11698
+ const jsURL = new URL(
11699
+ "../libfaust-wasm/libfaust-wasm.js",
11700
+ baseURL
11701
+ ).href;
11702
+ const dataURL = jsURL.replace(/c?js$/, "data");
11703
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
11704
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
11705
+ jsURL,
11706
+ dataURL,
11707
+ wasmURL
11708
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
11709
+ }
11691
11710
  }
11692
11711
  return _FaustDspGenerator.compilerPromise;
11693
11712
  };