@wvdsh/sdk-js 1.3.26 → 1.3.29
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/index.d.ts +25 -52
- package/dist/index.js +505 -223
- package/dist/inject.global.js +2 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -21,47 +21,21 @@ declare abstract class WavedashManager {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Mutes & unmutes the game in response to MUTE_CHANGED iframe messages, with no
|
|
25
|
+
* game-side code required.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
* the game
|
|
27
|
+
* Globals like `AudioContext` are per-frame, so we shim the SDK's own window
|
|
28
|
+
* (where the game usually runs) plus any same-origin iframes the game adds.
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* so `node.connect(ctx.destination)` and any other game code is unaffected.
|
|
32
|
-
*
|
|
33
|
-
* HTML Media (`<audio>`/`<video>`): override `HTMLMediaElement.prototype.muted`
|
|
34
|
-
* to record the game's intended state, but write `true` to the underlying element
|
|
35
|
-
* whenever the SDK is muted. Tracked elements come from four sources:
|
|
36
|
-
* 1. Pre-existing DOM media (`querySelectorAll`)
|
|
37
|
-
* 2. `new Audio()` constructor shim (covers detached SFX)
|
|
38
|
-
* 3. MutationObserver for any media added to the DOM later (covers innerHTML,
|
|
39
|
-
* framework rendering, createElement + append, etc.)
|
|
40
|
-
* 4. `HTMLMediaElement.prototype.play()` shim — the universal point where an
|
|
41
|
-
* element starts producing audio. Catches anything driven purely via
|
|
42
|
-
* `.play()`/`.volume` (never assigning `.muted`, never entering the DOM,
|
|
43
|
-
* e.g. a PIXI/GDevelop intro video), force-muting it before playback begins
|
|
44
|
-
* regardless of how it was created — the one path the DOM-based sources and
|
|
45
|
-
* the `muted` setter all miss.
|
|
46
|
-
*
|
|
47
|
-
* Speech synthesis (`window.speechSynthesis`): bypasses both Web Audio and HTML
|
|
48
|
-
* media entirely, so it gets its own shim — `speak()` forces the utterance's
|
|
49
|
-
* native volume to 0 while muted.
|
|
30
|
+
* Each frame's shimming lives in {@link AudioFrameShim}; this class owns the
|
|
31
|
+
* mute state and fans it out to every attached frame.
|
|
50
32
|
*/
|
|
51
33
|
declare class AudioManager extends WavedashManager {
|
|
52
34
|
private _isMuted;
|
|
53
|
-
private
|
|
54
|
-
private
|
|
55
|
-
private
|
|
56
|
-
private
|
|
57
|
-
private originalAudioContext;
|
|
58
|
-
private originalWebKitAudioContext;
|
|
59
|
-
private originalAudio;
|
|
60
|
-
private originalMutedDescriptor;
|
|
61
|
-
private originalPlay;
|
|
62
|
-
private originalSpeak;
|
|
63
|
-
private originalUtteranceVolumeDescriptor;
|
|
64
|
-
private mutationObserver;
|
|
35
|
+
private frames;
|
|
36
|
+
private iframeBindings;
|
|
37
|
+
private iframeLoadHandlers;
|
|
38
|
+
private boundIframes;
|
|
65
39
|
constructor(sdk: WavedashSDK);
|
|
66
40
|
isMuted(): boolean;
|
|
67
41
|
/**
|
|
@@ -79,25 +53,24 @@ declare class AudioManager extends WavedashManager {
|
|
|
79
53
|
*/
|
|
80
54
|
toggleMute(): Promise<boolean>;
|
|
81
55
|
private handleMute;
|
|
56
|
+
/** Shim a window we can reach. Same-origin only (cross-origin access throws). */
|
|
57
|
+
private attachWindow;
|
|
82
58
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
59
|
+
* Start tracking an iframe: attach now (already-loaded frames) and on every
|
|
60
|
+
* `load` (about:blank → game, and later src swaps). Idempotent.
|
|
85
61
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
62
|
+
bindIframe(iframe: HTMLIFrameElement): void;
|
|
63
|
+
/** Stop tracking an iframe and tear down its frame (iframe removed from DOM). */
|
|
64
|
+
unbindIframe(iframe: HTMLIFrameElement): void;
|
|
88
65
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
* cancel() would discard the pending queue).
|
|
98
|
-
*/
|
|
99
|
-
private shimSpeechSynthesis;
|
|
100
|
-
private shimAudioContextClass;
|
|
66
|
+
* Install (or re-install) a shim for an iframe's current document. No-ops
|
|
67
|
+
* while not yet navigated or already shimmed; replaces the previous shim when
|
|
68
|
+
* the iframe navigates to a fresh document, and drops it when it goes
|
|
69
|
+
* cross-origin (we can no longer reach it).
|
|
70
|
+
*/
|
|
71
|
+
private attachIframe;
|
|
72
|
+
/** Remove and uninstall the shim bound to an iframe's (previous) document. */
|
|
73
|
+
private teardownFrame;
|
|
101
74
|
destroy(): void;
|
|
102
75
|
}
|
|
103
76
|
|