@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.
package/dist/cjs/index.js CHANGED
@@ -5221,6 +5221,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
5221
5221
  };
5222
5222
 
5223
5223
  // src/FaustDspGenerator.ts
5224
+ var import_meta = {};
5224
5225
  var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
5225
5226
  constructor() {
5226
5227
  this.factory = null;
@@ -5869,20 +5870,38 @@ const dependencies = {
5869
5870
  async createFaustNode(context, name, code, sp, bufferSize) {
5870
5871
  const getCompiler = async () => {
5871
5872
  if (!_FaustDspGenerator.compilerPromise) {
5872
- const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
5873
- if (!baseURL)
5874
- throw new Error("Cannot resolve libfaust-wasm location.");
5875
- const jsURL = new URL(
5876
- "../libfaust-wasm/libfaust-wasm.js",
5877
- baseURL
5878
- ).href;
5879
- const dataURL = jsURL.replace(/c?js$/, "data");
5880
- const wasmURL = jsURL.replace(/c?js$/, "wasm");
5881
- _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5882
- jsURL,
5883
- dataURL,
5884
- wasmURL
5885
- ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5873
+ const isNode = typeof document === "undefined" && typeof window === "undefined";
5874
+ if (isNode) {
5875
+ const baseURL = (typeof __dirname !== "undefined" ? `file://${__dirname}/` : void 0) || (typeof import_meta !== "undefined" && typeof import_meta.url === "string" ? import_meta.url : void 0);
5876
+ if (!baseURL)
5877
+ throw new Error("Cannot resolve libfaust-wasm location.");
5878
+ const jsURL = new URL(
5879
+ "../libfaust-wasm/libfaust-wasm.js",
5880
+ baseURL
5881
+ ).href;
5882
+ const dataURL = jsURL.replace(/c?js$/, "data");
5883
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
5884
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5885
+ jsURL,
5886
+ dataURL,
5887
+ wasmURL
5888
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5889
+ } else {
5890
+ const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
5891
+ if (!baseURL)
5892
+ throw new Error("Cannot resolve libfaust-wasm location.");
5893
+ const jsURL = new URL(
5894
+ "../libfaust-wasm/libfaust-wasm.js",
5895
+ baseURL
5896
+ ).href;
5897
+ const dataURL = jsURL.replace(/c?js$/, "data");
5898
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
5899
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5900
+ jsURL,
5901
+ dataURL,
5902
+ wasmURL
5903
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5904
+ }
5886
5905
  }
5887
5906
  return _FaustDspGenerator.compilerPromise;
5888
5907
  };