playkit-sdk 1.2.8-beta.4 → 1.2.8-beta.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.
- package/dist/playkit-sdk.cjs.js +10 -17
- package/dist/playkit-sdk.cjs.js.map +1 -1
- package/dist/playkit-sdk.d.ts +6 -1
- package/dist/playkit-sdk.esm.js +10 -17
- package/dist/playkit-sdk.esm.js.map +1 -1
- package/dist/playkit-sdk.umd.js +10 -17
- package/dist/playkit-sdk.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/playkit-sdk.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* playkit-sdk v1.2.8-beta.
|
|
2
|
+
* playkit-sdk v1.2.8-beta.5
|
|
3
3
|
* PlayKit SDK for JavaScript
|
|
4
4
|
* @license SEE LICENSE IN LICENSE
|
|
5
5
|
*/
|
|
@@ -3447,19 +3447,11 @@ class PlayerClient extends EventEmitter {
|
|
|
3447
3447
|
* Get player information
|
|
3448
3448
|
*/
|
|
3449
3449
|
async getPlayerInfo() {
|
|
3450
|
-
var _a, _b;
|
|
3450
|
+
var _a, _b, _c;
|
|
3451
3451
|
const token = this.authManager.getToken();
|
|
3452
3452
|
if (!token) {
|
|
3453
3453
|
throw new PlayKitError('Not authenticated', 'NOT_AUTHENTICATED');
|
|
3454
3454
|
}
|
|
3455
|
-
// If using developer token, return mock player info
|
|
3456
|
-
const authState = this.authManager.getAuthState();
|
|
3457
|
-
if (authState.tokenType === 'developer') {
|
|
3458
|
-
return {
|
|
3459
|
-
userId: 'developer',
|
|
3460
|
-
credits: 999999,
|
|
3461
|
-
};
|
|
3462
|
-
}
|
|
3463
3455
|
try {
|
|
3464
3456
|
// Build headers with X-Game-Id to support Global Developer Token
|
|
3465
3457
|
const headers = {
|
|
@@ -3489,13 +3481,14 @@ class PlayerClient extends EventEmitter {
|
|
|
3489
3481
|
const data = await response.json();
|
|
3490
3482
|
this.playerInfo = {
|
|
3491
3483
|
userId: data.userId,
|
|
3484
|
+
balance: (_a = data.balance) !== null && _a !== void 0 ? _a : 0,
|
|
3492
3485
|
credits: data.credits,
|
|
3493
|
-
nickname: (
|
|
3486
|
+
nickname: (_b = data.nickname) !== null && _b !== void 0 ? _b : null,
|
|
3494
3487
|
dailyRefresh: data.dailyRefresh,
|
|
3495
3488
|
};
|
|
3496
3489
|
this.emit('player_info_updated', this.playerInfo);
|
|
3497
3490
|
// Emit daily refresh event if credits were refreshed
|
|
3498
|
-
if ((
|
|
3491
|
+
if ((_c = data.dailyRefresh) === null || _c === void 0 ? void 0 : _c.refreshed) {
|
|
3499
3492
|
this.emit('daily_credits_refreshed', data.dailyRefresh);
|
|
3500
3493
|
// Show toast notification if enabled
|
|
3501
3494
|
if (this.rechargeConfig.showDailyRefreshToast !== false) {
|
|
@@ -3611,7 +3604,7 @@ class PlayerClient extends EventEmitter {
|
|
|
3611
3604
|
this.logger.warn('RechargeManager not initialized. Cannot show modal.');
|
|
3612
3605
|
return;
|
|
3613
3606
|
}
|
|
3614
|
-
const balance = (_a = this.playerInfo) === null || _a === void 0 ? void 0 : _a.
|
|
3607
|
+
const balance = (_a = this.playerInfo) === null || _a === void 0 ? void 0 : _a.balance;
|
|
3615
3608
|
await this.rechargeManager.showInsufficientBalanceModal({
|
|
3616
3609
|
currentBalance: balance,
|
|
3617
3610
|
message: customMessage,
|
|
@@ -3644,9 +3637,9 @@ class PlayerClient extends EventEmitter {
|
|
|
3644
3637
|
this.balanceCheckInterval = setInterval(async () => {
|
|
3645
3638
|
var _a, _b;
|
|
3646
3639
|
try {
|
|
3647
|
-
const oldBalance = (_a = this.playerInfo) === null || _a === void 0 ? void 0 : _a.
|
|
3640
|
+
const oldBalance = (_a = this.playerInfo) === null || _a === void 0 ? void 0 : _a.balance;
|
|
3648
3641
|
await this.refreshPlayerInfo();
|
|
3649
|
-
const newBalance = (_b = this.playerInfo) === null || _b === void 0 ? void 0 : _b.
|
|
3642
|
+
const newBalance = (_b = this.playerInfo) === null || _b === void 0 ? void 0 : _b.balance;
|
|
3650
3643
|
// Emit balance_updated event
|
|
3651
3644
|
if (newBalance !== undefined) {
|
|
3652
3645
|
this.emit('balance_updated', newBalance);
|
|
@@ -6434,14 +6427,14 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6434
6427
|
getCachedBalance() {
|
|
6435
6428
|
var _a;
|
|
6436
6429
|
const playerInfo = this.playerClient.getCachedPlayerInfo();
|
|
6437
|
-
return (_a = playerInfo === null || playerInfo === void 0 ? void 0 : playerInfo.
|
|
6430
|
+
return (_a = playerInfo === null || playerInfo === void 0 ? void 0 : playerInfo.balance) !== null && _a !== void 0 ? _a : null;
|
|
6438
6431
|
}
|
|
6439
6432
|
/**
|
|
6440
6433
|
* Refresh and get player's current balance
|
|
6441
6434
|
*/
|
|
6442
6435
|
async refreshBalance() {
|
|
6443
6436
|
const playerInfo = await this.playerClient.refreshPlayerInfo();
|
|
6444
|
-
return playerInfo.
|
|
6437
|
+
return playerInfo.balance;
|
|
6445
6438
|
}
|
|
6446
6439
|
// ============================================================
|
|
6447
6440
|
// Player Profile Methods
|