keeperboard 1.0.3 → 1.0.4
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/README.md +14 -17
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -2
- package/dist/index.mjs +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Works with Phaser.js, vanilla JavaScript, and any TypeScript/JavaScript game run
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install keeperboard
|
|
10
|
+
npm install keeperboard
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
### Alternative: Copy source directly
|
|
@@ -30,11 +30,10 @@ import { KeeperBoardClient, PlayerIdentity } from './keeperboard/index';
|
|
|
30
30
|
### 2. Initialize the client
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
|
-
import { KeeperBoardClient, PlayerIdentity } from 'keeperboard
|
|
33
|
+
import { KeeperBoardClient, PlayerIdentity } from 'keeperboard';
|
|
34
34
|
|
|
35
35
|
// Create the API client
|
|
36
36
|
const client = new KeeperBoardClient({
|
|
37
|
-
apiUrl: 'https://keeperboard.vercel.app',
|
|
38
37
|
apiKey: 'kb_prod_your_api_key_here',
|
|
39
38
|
});
|
|
40
39
|
|
|
@@ -83,8 +82,7 @@ if (player && player.rank > 10) {
|
|
|
83
82
|
|
|
84
83
|
```typescript
|
|
85
84
|
const client = new KeeperBoardClient({
|
|
86
|
-
|
|
87
|
-
apiKey: string, // API key from dashboard
|
|
85
|
+
apiKey: string, // API key from dashboard
|
|
88
86
|
});
|
|
89
87
|
```
|
|
90
88
|
|
|
@@ -116,13 +114,10 @@ await client.submitScore('player-uuid', 'PlayerName', 2500, 'Weekly Best');
|
|
|
116
114
|
Submit with optional metadata.
|
|
117
115
|
|
|
118
116
|
```typescript
|
|
119
|
-
await client.submitScore(
|
|
120
|
-
|
|
121
|
-
'
|
|
122
|
-
|
|
123
|
-
'Weekly Best',
|
|
124
|
-
{ level: 10, character: 'warrior' }
|
|
125
|
-
);
|
|
117
|
+
await client.submitScore('player-uuid', 'PlayerName', 2500, 'Weekly Best', {
|
|
118
|
+
level: 10,
|
|
119
|
+
character: 'warrior',
|
|
120
|
+
});
|
|
126
121
|
```
|
|
127
122
|
|
|
128
123
|
---
|
|
@@ -278,7 +273,7 @@ identity.clear();
|
|
|
278
273
|
All methods throw `KeeperBoardError` on failure:
|
|
279
274
|
|
|
280
275
|
```typescript
|
|
281
|
-
import { KeeperBoardError } from 'keeperboard
|
|
276
|
+
import { KeeperBoardError } from 'keeperboard';
|
|
282
277
|
|
|
283
278
|
try {
|
|
284
279
|
await client.submitScore(playerGuid, name, score);
|
|
@@ -323,10 +318,9 @@ const endless = await client.getLeaderboard('Endless Mode', 50);
|
|
|
323
318
|
## Phaser.js Integration Example
|
|
324
319
|
|
|
325
320
|
```typescript
|
|
326
|
-
import { KeeperBoardClient, PlayerIdentity } from 'keeperboard
|
|
321
|
+
import { KeeperBoardClient, PlayerIdentity } from 'keeperboard';
|
|
327
322
|
|
|
328
323
|
const client = new KeeperBoardClient({
|
|
329
|
-
apiUrl: 'https://keeperboard.vercel.app',
|
|
330
324
|
apiKey: 'kb_prod_your_api_key',
|
|
331
325
|
});
|
|
332
326
|
|
|
@@ -353,7 +347,10 @@ class GameOverScene extends Phaser.Scene {
|
|
|
353
347
|
|
|
354
348
|
if (result.is_new_high_score) {
|
|
355
349
|
this.add
|
|
356
|
-
.text(400, 250, 'NEW HIGH SCORE!', {
|
|
350
|
+
.text(400, 250, 'NEW HIGH SCORE!', {
|
|
351
|
+
fontSize: '24px',
|
|
352
|
+
color: '#ffff00',
|
|
353
|
+
})
|
|
357
354
|
.setOrigin(0.5);
|
|
358
355
|
}
|
|
359
356
|
|
|
@@ -369,7 +366,7 @@ class GameOverScene extends Phaser.Scene {
|
|
|
369
366
|
400,
|
|
370
367
|
350 + index * 30,
|
|
371
368
|
`#${entry.rank} ${entry.player_name}: ${entry.score}`,
|
|
372
|
-
{ fontSize: '18px', color }
|
|
369
|
+
{ fontSize: '18px', color },
|
|
373
370
|
)
|
|
374
371
|
.setOrigin(0.5);
|
|
375
372
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Matches the API response shapes from the KeeperBoard public API.
|
|
4
4
|
*/
|
|
5
5
|
interface KeeperBoardConfig {
|
|
6
|
-
/** Base URL of the KeeperBoard API (e.g., "https://keeperboard.vercel.app") */
|
|
7
|
-
apiUrl: string;
|
|
8
6
|
/** API key from the KeeperBoard dashboard (e.g., "kb_dev_abc123...") */
|
|
9
7
|
apiKey: string;
|
|
8
|
+
/** @internal Base URL override for testing. Do not use in production. */
|
|
9
|
+
apiUrl?: string;
|
|
10
10
|
}
|
|
11
11
|
interface ScoreSubmission {
|
|
12
12
|
/** Unique player identifier (UUID or custom string) */
|
|
@@ -100,6 +100,7 @@ declare class KeeperBoardError extends Error {
|
|
|
100
100
|
*/
|
|
101
101
|
|
|
102
102
|
declare class KeeperBoardClient {
|
|
103
|
+
private static readonly DEFAULT_API_URL;
|
|
103
104
|
private readonly apiUrl;
|
|
104
105
|
private readonly apiKey;
|
|
105
106
|
constructor(config: KeeperBoardConfig);
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Matches the API response shapes from the KeeperBoard public API.
|
|
4
4
|
*/
|
|
5
5
|
interface KeeperBoardConfig {
|
|
6
|
-
/** Base URL of the KeeperBoard API (e.g., "https://keeperboard.vercel.app") */
|
|
7
|
-
apiUrl: string;
|
|
8
6
|
/** API key from the KeeperBoard dashboard (e.g., "kb_dev_abc123...") */
|
|
9
7
|
apiKey: string;
|
|
8
|
+
/** @internal Base URL override for testing. Do not use in production. */
|
|
9
|
+
apiUrl?: string;
|
|
10
10
|
}
|
|
11
11
|
interface ScoreSubmission {
|
|
12
12
|
/** Unique player identifier (UUID or custom string) */
|
|
@@ -100,6 +100,7 @@ declare class KeeperBoardError extends Error {
|
|
|
100
100
|
*/
|
|
101
101
|
|
|
102
102
|
declare class KeeperBoardClient {
|
|
103
|
+
private static readonly DEFAULT_API_URL;
|
|
103
104
|
private readonly apiUrl;
|
|
104
105
|
private readonly apiKey;
|
|
105
106
|
constructor(config: KeeperBoardConfig);
|
package/dist/index.js
CHANGED
|
@@ -37,9 +37,10 @@ var KeeperBoardError = class extends Error {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
// src/KeeperBoardClient.ts
|
|
40
|
-
var
|
|
40
|
+
var _KeeperBoardClient = class _KeeperBoardClient {
|
|
41
41
|
constructor(config) {
|
|
42
|
-
|
|
42
|
+
const url = config.apiUrl ?? _KeeperBoardClient.DEFAULT_API_URL;
|
|
43
|
+
this.apiUrl = url.replace(/\/$/, "");
|
|
43
44
|
this.apiKey = config.apiKey;
|
|
44
45
|
}
|
|
45
46
|
async submitScore(playerGuid, playerName, score, leaderboard, metadata) {
|
|
@@ -157,6 +158,8 @@ var KeeperBoardClient = class {
|
|
|
157
158
|
return json.data;
|
|
158
159
|
}
|
|
159
160
|
};
|
|
161
|
+
_KeeperBoardClient.DEFAULT_API_URL = "https://keeperboard.vercel.app";
|
|
162
|
+
var KeeperBoardClient = _KeeperBoardClient;
|
|
160
163
|
|
|
161
164
|
// src/PlayerIdentity.ts
|
|
162
165
|
var DEFAULT_KEY_PREFIX = "keeperboard_";
|
package/dist/index.mjs
CHANGED
|
@@ -9,9 +9,10 @@ var KeeperBoardError = class extends Error {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
// src/KeeperBoardClient.ts
|
|
12
|
-
var
|
|
12
|
+
var _KeeperBoardClient = class _KeeperBoardClient {
|
|
13
13
|
constructor(config) {
|
|
14
|
-
|
|
14
|
+
const url = config.apiUrl ?? _KeeperBoardClient.DEFAULT_API_URL;
|
|
15
|
+
this.apiUrl = url.replace(/\/$/, "");
|
|
15
16
|
this.apiKey = config.apiKey;
|
|
16
17
|
}
|
|
17
18
|
async submitScore(playerGuid, playerName, score, leaderboard, metadata) {
|
|
@@ -129,6 +130,8 @@ var KeeperBoardClient = class {
|
|
|
129
130
|
return json.data;
|
|
130
131
|
}
|
|
131
132
|
};
|
|
133
|
+
_KeeperBoardClient.DEFAULT_API_URL = "https://keeperboard.vercel.app";
|
|
134
|
+
var KeeperBoardClient = _KeeperBoardClient;
|
|
132
135
|
|
|
133
136
|
// src/PlayerIdentity.ts
|
|
134
137
|
var DEFAULT_KEY_PREFIX = "keeperboard_";
|