@momo-cloud/gami-sdk 0.0.84 → 0.0.93
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 +38 -6
- package/dist/index.public.js +1550 -1542
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`@momo-cloud/gami-sdk` is the integration layer between your web game and MoMo host capabilities.
|
|
4
4
|
It provides:
|
|
5
5
|
|
|
6
|
-
- Game backend APIs (spin, shake, mission, leaderboard, balance, exchange)
|
|
6
|
+
- Game backend APIs (spin, shake, mission, leaderboard, submit leaderboard score, balance, exchange)
|
|
7
7
|
- Platform bridge APIs (toast, share, permission, contacts, deep-link, calendar, clipboard, and more)
|
|
8
8
|
- Runtime utilities (server-time sync, storage helpers, SSE, event bus)
|
|
9
9
|
|
|
@@ -94,6 +94,7 @@ Typical game loop calls:
|
|
|
94
94
|
- `coinExchange({ amount })`
|
|
95
95
|
- `getMission({ viewId? })`
|
|
96
96
|
- `getLeaderboard({ boardId, group?, limit?, page? })`
|
|
97
|
+
- `submitLeaderboard({ boardName, score, periodType?, delta? })`
|
|
97
98
|
- `getHistory({ page, limit })`
|
|
98
99
|
- `getEvent({ eventId })`
|
|
99
100
|
|
|
@@ -174,7 +175,38 @@ if (res?.response_info?.error_code !== 0) {
|
|
|
174
175
|
}
|
|
175
176
|
```
|
|
176
177
|
|
|
177
|
-
## 8)
|
|
178
|
+
## 8) Leaderboard APIs
|
|
179
|
+
|
|
180
|
+
### Read leaderboard
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
const lb = await GamiSDK.getLeaderboard({
|
|
184
|
+
boardId: 'win',
|
|
185
|
+
group: 'global', // 'global' | 'friend'
|
|
186
|
+
limit: 50,
|
|
187
|
+
page: 0,
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Submit a score
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
await GamiSDK.submitLeaderboard({
|
|
195
|
+
boardName: 'win',
|
|
196
|
+
score: 1,
|
|
197
|
+
periodType: 'WEEKLY', // default – omit if weekly
|
|
198
|
+
delta: 1, // optional; defaults to score value
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- `boardName` — leaderboard identifier (e.g. `'win'`).
|
|
203
|
+
- `score` — the score value to record.
|
|
204
|
+
- `periodType` — leaderboard period bucket; defaults to `'WEEKLY'`.
|
|
205
|
+
- `delta` — incremental change amount; omit to use the same value as `score`.
|
|
206
|
+
|
|
207
|
+
`gameId` and `userId` are injected automatically from the SDK session — do not pass them manually.
|
|
208
|
+
|
|
209
|
+
## 9) Browser vs Host Runtime
|
|
178
210
|
|
|
179
211
|
- In MoMo host: full platform bridge behavior is available.
|
|
180
212
|
- In browser/dev mode: host-only behavior may be mocked, no-op, or limited.
|
|
@@ -184,7 +216,7 @@ Integration recommendation:
|
|
|
184
216
|
- Keep game domain flow independent from host-only APIs.
|
|
185
217
|
- Wrap optional host actions with graceful fallback in browser.
|
|
186
218
|
|
|
187
|
-
##
|
|
219
|
+
## 10) Build and Publish Modes
|
|
188
220
|
|
|
189
221
|
This repository supports two build modes:
|
|
190
222
|
|
|
@@ -206,7 +238,7 @@ npm run publish:npm
|
|
|
206
238
|
npm run publish:all
|
|
207
239
|
```
|
|
208
240
|
|
|
209
|
-
##
|
|
241
|
+
## 11) Integration Checklist
|
|
210
242
|
|
|
211
243
|
Before releasing a game integration:
|
|
212
244
|
|
|
@@ -218,7 +250,7 @@ Before releasing a game integration:
|
|
|
218
250
|
- Local cache keys use SDK helpers to avoid collisions
|
|
219
251
|
- Permissions flow validated for calendar/contacts/image capture
|
|
220
252
|
|
|
221
|
-
##
|
|
253
|
+
## 12) Minimal End-to-End Example
|
|
222
254
|
|
|
223
255
|
```ts
|
|
224
256
|
import GamiSDK from '@momo-cloud/gami-sdk';
|
|
@@ -244,7 +276,7 @@ export async function run() {
|
|
|
244
276
|
}
|
|
245
277
|
```
|
|
246
278
|
|
|
247
|
-
##
|
|
279
|
+
## 13) Notes for Architects
|
|
248
280
|
|
|
249
281
|
- Keep `GamiSDK` behind your own `sdkService` adapter in app code.
|
|
250
282
|
- Separate domain logic from host bridge calls for easier testability.
|