@wvdsh/sdk-js 1.3.17 → 1.3.19
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 +27 -8
- 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,12 @@ 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
|
+
PlayRouteCaller,
|
|
3687
|
+
SERVICE_WORKER_MESSAGE_TYPE
|
|
3688
|
+
} from "@wvdsh/api";
|
|
3674
3689
|
|
|
3675
3690
|
// src/utils/validation.ts
|
|
3676
3691
|
var CONVEX_ID_REGEX = /^[0-9a-z]{31,37}$/;
|
|
@@ -4947,7 +4962,11 @@ var WavedashSDK = class extends EventTarget {
|
|
|
4947
4962
|
await previous.catch(() => {
|
|
4948
4963
|
});
|
|
4949
4964
|
}
|
|
4950
|
-
const
|
|
4965
|
+
const refreshQuery = new URLSearchParams({
|
|
4966
|
+
[UrlParams.Caller]: PlayRouteCaller.Wavedash
|
|
4967
|
+
});
|
|
4968
|
+
const refreshPath = `/auth/refresh?${refreshQuery.toString()}`;
|
|
4969
|
+
const response = await fetch(refreshPath, {
|
|
4951
4970
|
method: "POST",
|
|
4952
4971
|
credentials: "same-origin"
|
|
4953
4972
|
});
|
|
@@ -4997,14 +5016,14 @@ var WavedashSDK = class extends EventTarget {
|
|
|
4997
5016
|
);
|
|
4998
5017
|
}
|
|
4999
5018
|
/**
|
|
5000
|
-
* Respond to the service worker's
|
|
5019
|
+
* Respond to the service worker's creds request with the SDK's
|
|
5001
5020
|
* current gameplay JWT. The SW asks when it wakes from termination with no
|
|
5002
5021
|
* in-memory or IDB credentials (e.g. Safari ITP storage decay) — we're the
|
|
5003
5022
|
* fastest live source. JWT only; sessionToken is owned by the SW + cookies.
|
|
5004
5023
|
*/
|
|
5005
5024
|
setupSwCredsListener() {
|
|
5006
5025
|
this.swMessenger.addEventListener(
|
|
5007
|
-
|
|
5026
|
+
SERVICE_WORKER_MESSAGE_TYPE.EMBED_CREDS_REQUEST,
|
|
5008
5027
|
async (_payload, reply) => {
|
|
5009
5028
|
let jwt;
|
|
5010
5029
|
try {
|
|
@@ -5014,7 +5033,7 @@ var WavedashSDK = class extends EventTarget {
|
|
|
5014
5033
|
return;
|
|
5015
5034
|
}
|
|
5016
5035
|
reply({
|
|
5017
|
-
type:
|
|
5036
|
+
type: SERVICE_WORKER_MESSAGE_TYPE.EMBED_CREDS_RESPONSE,
|
|
5018
5037
|
payload: { gameplayJwt: jwt }
|
|
5019
5038
|
});
|
|
5020
5039
|
}
|