@wvdsh/sdk-js 1.3.17 → 1.3.18
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 +10 -3
- package/dist/index.js +21 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare abstract class WavedashManager {
|
|
|
24
24
|
* AudioManager
|
|
25
25
|
*
|
|
26
26
|
* Mutes & unmutes the game in response to MUTE_CHANGED iframe messages, without
|
|
27
|
-
* the game needing to
|
|
27
|
+
* the game needing to handle it itself.
|
|
28
28
|
*
|
|
29
29
|
* Web Audio: subclass `AudioContext` so `ctx.destination` resolves to a master
|
|
30
30
|
* GainNode that we control. The master gain wires to the real native destination,
|
|
@@ -32,11 +32,17 @@ declare abstract class WavedashManager {
|
|
|
32
32
|
*
|
|
33
33
|
* HTML Media (`<audio>`/`<video>`): override `HTMLMediaElement.prototype.muted`
|
|
34
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
|
|
35
|
+
* whenever the SDK is muted. Tracked elements come from four sources:
|
|
36
36
|
* 1. Pre-existing DOM media (`querySelectorAll`)
|
|
37
37
|
* 2. `new Audio()` constructor shim (covers detached SFX)
|
|
38
38
|
* 3. MutationObserver for any media added to the DOM later (covers innerHTML,
|
|
39
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.
|
|
40
46
|
*/
|
|
41
47
|
declare class AudioManager extends WavedashManager {
|
|
42
48
|
private _isMuted;
|
|
@@ -47,6 +53,7 @@ declare class AudioManager extends WavedashManager {
|
|
|
47
53
|
private originalWebKitAudioContext;
|
|
48
54
|
private originalAudio;
|
|
49
55
|
private originalMutedDescriptor;
|
|
56
|
+
private originalPlay;
|
|
50
57
|
private mutationObserver;
|
|
51
58
|
constructor(sdk: WavedashSDK);
|
|
52
59
|
isMuted(): boolean;
|
|
@@ -1332,7 +1339,7 @@ declare class WavedashSDK extends EventTarget {
|
|
|
1332
1339
|
private destroy;
|
|
1333
1340
|
private setupSessionEndListeners;
|
|
1334
1341
|
/**
|
|
1335
|
-
* Respond to the service worker's
|
|
1342
|
+
* Respond to the service worker's creds request with the SDK's
|
|
1336
1343
|
* current gameplay JWT. The SW asks when it wakes from termination with no
|
|
1337
1344
|
* in-memory or IDB credentials (e.g. Safari ITP storage decay) — we're the
|
|
1338
1345
|
* fastest live source. JWT only; sessionToken is owned by the SW + cookies.
|
package/dist/index.js
CHANGED
|
@@ -129,6 +129,7 @@ var AudioManager = class extends WavedashManager {
|
|
|
129
129
|
this.originalWebKitAudioContext = null;
|
|
130
130
|
this.originalAudio = null;
|
|
131
131
|
this.originalMutedDescriptor = null;
|
|
132
|
+
this.originalPlay = null;
|
|
132
133
|
this.mutationObserver = null;
|
|
133
134
|
this.handleMute = (data) => {
|
|
134
135
|
if (this._isMuted === data.isMuted) return;
|
|
@@ -266,6 +267,14 @@ var AudioManager = class extends WavedashManager {
|
|
|
266
267
|
});
|
|
267
268
|
})(this);
|
|
268
269
|
}
|
|
270
|
+
const originalPlay = HTMLMediaElement.prototype.play;
|
|
271
|
+
this.originalPlay = originalPlay;
|
|
272
|
+
((manager) => {
|
|
273
|
+
HTMLMediaElement.prototype.play = function() {
|
|
274
|
+
manager.trackElement(this);
|
|
275
|
+
return originalPlay.call(this);
|
|
276
|
+
};
|
|
277
|
+
})(this);
|
|
269
278
|
}
|
|
270
279
|
shimAudioContextClass(Original) {
|
|
271
280
|
return /* @__PURE__ */ ((manager) => class extends Original {
|
|
@@ -312,6 +321,9 @@ var AudioManager = class extends WavedashManager {
|
|
|
312
321
|
window.Audio = this.originalAudio;
|
|
313
322
|
}
|
|
314
323
|
}
|
|
324
|
+
if (this.originalPlay) {
|
|
325
|
+
HTMLMediaElement.prototype.play = this.originalPlay;
|
|
326
|
+
}
|
|
315
327
|
if (this.originalMutedDescriptor) {
|
|
316
328
|
Object.defineProperty(
|
|
317
329
|
HTMLMediaElement.prototype,
|
|
@@ -3588,9 +3600,7 @@ var IFrameMessenger = class {
|
|
|
3588
3600
|
const timeout = setTimeout(() => {
|
|
3589
3601
|
this.pendingRequests.delete(requestId);
|
|
3590
3602
|
reject(
|
|
3591
|
-
new Error(
|
|
3592
|
-
`${requestType} request timed out after ${timeoutMs}ms`
|
|
3593
|
-
)
|
|
3603
|
+
new Error(`${requestType} request timed out after ${timeoutMs}ms`)
|
|
3594
3604
|
);
|
|
3595
3605
|
}, timeoutMs);
|
|
3596
3606
|
this.pendingRequests.set(requestId, {
|
|
@@ -3670,7 +3680,11 @@ var SwMessenger = class {
|
|
|
3670
3680
|
};
|
|
3671
3681
|
|
|
3672
3682
|
// src/index.ts
|
|
3673
|
-
import {
|
|
3683
|
+
import {
|
|
3684
|
+
IFRAME_MESSAGE_TYPE as IFRAME_MESSAGE_TYPE7,
|
|
3685
|
+
UrlParams,
|
|
3686
|
+
SERVICE_WORKER_MESSAGE_TYPE
|
|
3687
|
+
} from "@wvdsh/api";
|
|
3674
3688
|
|
|
3675
3689
|
// src/utils/validation.ts
|
|
3676
3690
|
var CONVEX_ID_REGEX = /^[0-9a-z]{31,37}$/;
|
|
@@ -4997,14 +5011,14 @@ var WavedashSDK = class extends EventTarget {
|
|
|
4997
5011
|
);
|
|
4998
5012
|
}
|
|
4999
5013
|
/**
|
|
5000
|
-
* Respond to the service worker's
|
|
5014
|
+
* Respond to the service worker's creds request with the SDK's
|
|
5001
5015
|
* current gameplay JWT. The SW asks when it wakes from termination with no
|
|
5002
5016
|
* in-memory or IDB credentials (e.g. Safari ITP storage decay) — we're the
|
|
5003
5017
|
* fastest live source. JWT only; sessionToken is owned by the SW + cookies.
|
|
5004
5018
|
*/
|
|
5005
5019
|
setupSwCredsListener() {
|
|
5006
5020
|
this.swMessenger.addEventListener(
|
|
5007
|
-
|
|
5021
|
+
SERVICE_WORKER_MESSAGE_TYPE.EMBED_CREDS_REQUEST,
|
|
5008
5022
|
async (_payload, reply) => {
|
|
5009
5023
|
let jwt;
|
|
5010
5024
|
try {
|
|
@@ -5014,7 +5028,7 @@ var WavedashSDK = class extends EventTarget {
|
|
|
5014
5028
|
return;
|
|
5015
5029
|
}
|
|
5016
5030
|
reply({
|
|
5017
|
-
type:
|
|
5031
|
+
type: SERVICE_WORKER_MESSAGE_TYPE.EMBED_CREDS_RESPONSE,
|
|
5018
5032
|
payload: { gameplayJwt: jwt }
|
|
5019
5033
|
});
|
|
5020
5034
|
}
|