@grame/faustwasm 0.3.2 → 0.4.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.
Files changed (36) hide show
  1. package/README.md +10 -4
  2. package/assets/standalone/faust-ui/index.js +177 -247
  3. package/assets/standalone/faust-ui/index.js.map +1 -1
  4. package/assets/standalone/faustwasm/index.d.ts +6 -0
  5. package/assets/standalone/faustwasm/index.js +12 -4
  6. package/assets/standalone/faustwasm/index.js.map +2 -2
  7. package/assets/standalone/icon.png +0 -0
  8. package/assets/standalone/index-poly.js +11 -0
  9. package/assets/standalone/index.html +4 -2
  10. package/assets/standalone/index.js +11 -0
  11. package/assets/standalone/manifest.json +18 -0
  12. package/assets/standalone/service-worker.js +48 -0
  13. package/dist/cjs/index.d.ts +6 -0
  14. package/dist/cjs/index.js +12 -4
  15. package/dist/cjs/index.js.map +2 -2
  16. package/dist/cjs-bundle/index.d.ts +6 -0
  17. package/dist/cjs-bundle/index.js +12 -4
  18. package/dist/cjs-bundle/index.js.map +2 -2
  19. package/dist/esm/index.d.ts +6 -0
  20. package/dist/esm/index.js +12 -4
  21. package/dist/esm/index.js.map +2 -2
  22. package/dist/esm-bundle/index.d.ts +6 -0
  23. package/dist/esm-bundle/index.js +12 -4
  24. package/dist/esm-bundle/index.js.map +2 -2
  25. package/package.json +2 -2
  26. package/src/FaustAudioWorkletNode.ts +0 -3
  27. package/src/SoundfileReader.ts +16 -2
  28. package/src/copyWebStandaloneAssets.js +11 -1
  29. package/test/faustlive-wasm/faust-ui/index.js +177 -247
  30. package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
  31. package/test/faustlive-wasm/faustwasm/index.d.ts +6 -0
  32. package/test/faustlive-wasm/faustwasm/index.js +12 -4
  33. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  34. package/test/osc2.dsp +1 -1
  35. package/0001-Invert-x-y-z-accelerometer-on-Android.patch +0 -194
  36. package/build +0 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.3.2",
3
+ "version": "0.4.1",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "homepage": "https://github.com/grame-cncm/faustwasm#readme",
40
40
  "devDependencies": {
41
41
  "@aws-crypto/sha256-js": "^5.2.0",
42
- "@shren/faust-ui": "^1.1.9",
42
+ "@shren/faust-ui": "^1.1.11",
43
43
  "@types/node": "^20.12.7",
44
44
  "@types/webmidi": "^2.0.10",
45
45
  "dts-bundle-generator": "^9.5.1",
@@ -76,8 +76,6 @@ export class FaustAudioWorkletNode<Poly extends boolean = false> extends (global
76
76
  async listenSensors() {
77
77
  if (this.hasAccInput) {
78
78
  const isAndroid: boolean = /Android/i.test(navigator.userAgent);
79
- console.log(navigator.userAgent);
80
- console.log(isAndroid);
81
79
  let handleDeviceMotion = null;
82
80
  if (isAndroid) {
83
81
  handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {
@@ -242,7 +240,6 @@ export class FaustAudioWorkletNode<Poly extends boolean = false> extends (global
242
240
  this.port.postMessage({ type: "destroy" });
243
241
  this.port.close();
244
242
  }
245
-
246
243
  }
247
244
 
248
245
  /**
@@ -3,7 +3,18 @@ import type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from
3
3
 
4
4
  /** Read metadata and fetch soundfiles */
5
5
  class SoundfileReader {
6
- static get fallbackPaths() { return [location.href, location.origin]; }
6
+
7
+ // Set the fallback paths
8
+ static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }
9
+
10
+ /**
11
+ * Extract the parent URL from an URL.
12
+ * @param url : the URL
13
+ * @returns : the parent URL
14
+ */
15
+ private static getParentUrl(url: string) {
16
+ return url.substring(0, url.lastIndexOf('/') + 1);
17
+ }
7
18
 
8
19
  /**
9
20
  * Convert an audio buffer to audio data.
@@ -46,7 +57,10 @@ class SoundfileReader {
46
57
  private static async checkFileExists(url: string): Promise<boolean> {
47
58
  try {
48
59
  console.log(`"checkFileExists" url: ${url}`);
49
- const response = await fetch(url, { method: "HEAD" });
60
+ // Fetch in "HEAD" mode does not properly work with the service-worker.js cache, so use "GET" mode for now
61
+ //const response = await fetch(url, { method: "HEAD" });
62
+ const response = await fetch(url);
63
+ console.log(`"checkFileExists" response.ok: ${response.ok}`);
50
64
  return response.ok; // Will be true if the status code is 200-299
51
65
  } catch (error) {
52
66
  console.error('Fetch error:', error);
@@ -22,13 +22,23 @@ const copyWebStandaloneAssets = (outputDir, dspName, poly = false) => {
22
22
  cpSyncModify(templateJSPath, outputDir + `/${dspName}.js`, "FAUST_DSP", dspName);
23
23
 
24
24
  const templateHTMLPath = path.join(__dirname, "../assets/standalone/index.html");
25
- cpSyncModify(templateHTMLPath, outputDir + `/${dspName}.html`, "FAUST_DSP", dspName);
25
+ //cpSyncModify(templateHTMLPath, outputDir + `/${dspName}.html`, "FAUST_DSP", dspName);
26
+ cpSyncModify(templateHTMLPath, outputDir + `/index.html`, "FAUST_DSP", dspName);
27
+
28
+ const templateServerJSPath = path.join(__dirname, "../assets/standalone/service-worker.js");
29
+ cpSyncModify(templateServerJSPath, outputDir + `/service-worker.js`, "FAUST_DSP", dspName);
30
+
31
+ const templateIconPath = path.join(__dirname, "../assets/standalone/icon.png");
32
+ cpSync(templateIconPath, outputDir + `/icon.png`);
26
33
 
27
34
  const faustwasmPath = path.join(__dirname, "../assets/standalone/faustwasm");
28
35
  cpSync(faustwasmPath, outputDir + "/faustwasm");
29
36
 
30
37
  const faustuiPath = path.join(__dirname, "../assets/standalone/faust-ui");
31
38
  cpSync(faustuiPath, outputDir + "/faust-ui");
39
+
40
+ const templateManifestPath = path.join(__dirname, "../assets/standalone/manifest.json");
41
+ cpSyncModify(templateManifestPath, outputDir + `/manifest.json`, "FAUST_DSP", dspName);
32
42
  };
33
43
 
34
44
  /**