@grame/faustwasm 0.16.3 → 0.16.5

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.
@@ -40,19 +40,26 @@ const FAUST_DSP_VOICES = 0;
40
40
  // Create PWA and UI
41
41
  await pwa.create();
42
42
 
43
- // Event listener to handle user interaction
43
+ // Event listener to handle user interaction. The whole start sequence is
44
+ // launched from the event handler rather than split across delayed tasks so
45
+ // iOS keeps it associated with the user activation.
44
46
  function handleUserInteraction() {
45
-
47
+
46
48
  // Resume AudioContext synchronously
47
49
  pwa.resumeAudioContext();
48
50
 
49
51
  // Activate MIDI and Sensors
50
- pwa.activateMIDISensors()
51
- }
52
+ pwa.activateMIDISensors();
53
+ }
52
54
 
53
- // Activate AudioContext, MIDI and Sensors on user interaction
55
+ // Register several activation events because iOS standalone PWAs do not
56
+ // behave identically across versions: some fire pointer events reliably,
57
+ // others are more consistent with touchend or click.
58
+ window.addEventListener('pointerdown', handleUserInteraction, { passive: true });
59
+ window.addEventListener('touchend', handleUserInteraction, { passive: true });
54
60
  window.addEventListener('click', handleUserInteraction);
55
61
  window.addEventListener('touchstart', handleUserInteraction);
62
+ window.addEventListener('keydown', handleUserInteraction);
56
63
 
57
64
  // Deactivate AudioContext, MIDI and Sensors on user interaction
58
65
  window.addEventListener('visibilitychange', function () {
package/dist/cjs/index.js CHANGED
@@ -41,7 +41,7 @@
41
41
  let FaustModule;
42
42
  let dataBinary;
43
43
  let wasmBinary;
44
- const jsCodeHead = /var (.+) = \(/;
44
+ const jsCodeHead = /var (\w+)\s*=\s*\(/;
45
45
  if (typeof window === "object") {
46
46
  let jsCode = await (await fetch(jsFile)).text();
47
47
  jsCode = `${jsCode}