@aippy/runtime 0.2.0-dev.4 → 0.2.0

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.
@@ -1,4 +1,4 @@
1
- import { c, a, i, b, p, u } from "../useAudioContext-DLWWSFAX.js";
1
+ import { c, a, i, b, p, u } from "../useAudioContext-D9Y4gIw9.js";
2
2
  export {
3
3
  c as createHiddenMediaElement,
4
4
  a as createHiddenVideoElement,
@@ -33,7 +33,7 @@ function mergeConfig(userConfig) {
33
33
  }
34
34
  };
35
35
  }
36
- const version = "0.2.0-dev.4";
36
+ const version = "0.2.0";
37
37
  const packageJson = {
38
38
  version
39
39
  };
@@ -3,7 +3,7 @@ import { A, E, c } from "../errors-DAz5_jDJ.js";
3
3
  import { CameraAPI, FileSystemAPI, GeolocationAPI, SensorsAPI, camera, fileSystem, geolocation, sensors, vibrate } from "../device/index.js";
4
4
  import { c as c2, a, P, b, p, d } from "../pwa-BkviTQoN.js";
5
5
  import { a as a2, b as b2 } from "../useTweaks-mK5PAWOs.js";
6
- import { c as c3, a as a3, i, b as b3, p as p2, u } from "../useAudioContext-DLWWSFAX.js";
6
+ import { c as c3, a as a3, i, b as b3, p as p2, u } from "../useAudioContext-D9Y4gIw9.js";
7
7
  export {
8
8
  A as AippyRuntimeError,
9
9
  CameraAPI,
@@ -259,6 +259,12 @@ function patchAudioContext(audioContext, options = {}) {
259
259
  console.log("[AudioContext] iOS unlock successful");
260
260
  }
261
261
  } catch (error) {
262
+ if (error instanceof DOMException && error.name === "NotAllowedError") {
263
+ if (debug) {
264
+ console.log("[AudioContext] Unlock requires user interaction");
265
+ }
266
+ throw error;
267
+ }
262
268
  console.error("[AudioContext] Unlock failed:", error);
263
269
  throw error;
264
270
  }
@@ -315,20 +321,24 @@ function useAudioContext(options = {}) {
315
321
  await audioContext.unlock();
316
322
  setIsUnlocked(true);
317
323
  } catch (error) {
324
+ if (error instanceof DOMException && error.name === "NotAllowedError") {
325
+ return;
326
+ }
318
327
  console.warn("Failed to unlock audio:", error);
319
328
  }
320
329
  };
321
330
  }, [audioContext, isUnlocked]);
322
331
  useEffect(() => {
323
332
  if (!autoUnlock || !audioContext) return;
324
- const handleInteraction = async () => {
333
+ const handleInteraction = async (event) => {
334
+ if (!event.isTrusted) return;
325
335
  await unlockFnRef.current?.();
326
336
  };
327
- document.addEventListener("click", handleInteraction, { once: true });
328
- document.addEventListener("touchstart", handleInteraction, { once: true });
337
+ document.addEventListener("click", handleInteraction, { once: true, capture: true });
338
+ document.addEventListener("touchstart", handleInteraction, { once: true, capture: true });
329
339
  return () => {
330
- document.removeEventListener("click", handleInteraction);
331
- document.removeEventListener("touchstart", handleInteraction);
340
+ document.removeEventListener("click", handleInteraction, { capture: true });
341
+ document.removeEventListener("touchstart", handleInteraction, { capture: true });
332
342
  };
333
343
  }, [autoUnlock, audioContext]);
334
344
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aippy/runtime",
3
- "version": "0.2.0-dev.4",
3
+ "version": "0.2.0",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",