@momo-cloud/gami-sdk 0.0.52 → 0.0.65
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 +16 -69
- package/dist/index.public.d.ts +47 -28
- package/dist/index.public.js +1606 -1150
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,43 +120,31 @@ await GamiSDK.endGame();
|
|
|
120
120
|
|
|
121
121
|
---
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
### Configuration & Data
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
#### `getConfig()`
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
const result = await GamiSDK.submit({
|
|
129
|
-
steps: [
|
|
130
|
-
{ action: 'start', timestamp: 1699000000000, data: {...} },
|
|
131
|
-
{ action: 'move', timestamp: 1699000001000, data: {...} },
|
|
132
|
-
{ action: 'end', timestamp: 1699000010000, data: {...} }
|
|
133
|
-
],
|
|
134
|
-
score: 1500
|
|
135
|
-
});
|
|
127
|
+
Fetch game configuration from the backend.
|
|
136
128
|
|
|
137
|
-
|
|
129
|
+
```typescript
|
|
130
|
+
const config = await GamiSDK.getConfig();
|
|
131
|
+
console.log('Game config:', config);
|
|
138
132
|
```
|
|
139
133
|
|
|
140
|
-
**
|
|
141
|
-
- `steps` (array): Array of gameplay events for validation
|
|
142
|
-
- `score` (number): Final score achieved
|
|
143
|
-
|
|
144
|
-
**Returns:** `Promise<{ gift?: any, ... }>` - Server response with rewards
|
|
134
|
+
**Returns:** `Promise<any>` - Game configuration object
|
|
145
135
|
|
|
146
136
|
---
|
|
147
137
|
|
|
148
|
-
|
|
138
|
+
#### `spin()`
|
|
149
139
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
Fetch game configuration from the backend.
|
|
140
|
+
Perform a spinner spin for the current game. Sends `POST` to the twirler service with the active `gameId` (set via `init`).
|
|
153
141
|
|
|
154
142
|
```typescript
|
|
155
|
-
const
|
|
156
|
-
console.log('
|
|
143
|
+
const result = await GamiSDK.spin();
|
|
144
|
+
console.log('Spin result:', result);
|
|
157
145
|
```
|
|
158
146
|
|
|
159
|
-
**Returns:** `Promise<any>` -
|
|
147
|
+
**Returns:** `Promise<any>` - Server response with spin outcome (e.g. prize payload); exact shape follows the backend contract
|
|
160
148
|
|
|
161
149
|
---
|
|
162
150
|
|
|
@@ -165,16 +153,15 @@ console.log('Game config:', config);
|
|
|
165
153
|
Get user's balance for specified balance IDs.
|
|
166
154
|
|
|
167
155
|
```typescript
|
|
168
|
-
const balance = await GamiSDK.getBalance({
|
|
169
|
-
|
|
156
|
+
const { result: balance } = await GamiSDK.getBalance({
|
|
157
|
+
balanceId: ['turn', 'coin', 'gem', 'ticket']
|
|
170
158
|
});
|
|
171
159
|
|
|
172
|
-
console.log('Coins:', balance.
|
|
173
|
-
console.log('Gems:', balance.gem);
|
|
160
|
+
console.log('Coins:', balance.turn);
|
|
174
161
|
```
|
|
175
162
|
|
|
176
163
|
**Parameters:**
|
|
177
|
-
- `
|
|
164
|
+
- `balanceId` (string): Balance Id
|
|
178
165
|
|
|
179
166
|
**Returns:** `Promise<TBalance>` - Balance data object
|
|
180
167
|
|
|
@@ -193,46 +180,6 @@ console.log('Available balances:', pockets);
|
|
|
193
180
|
|
|
194
181
|
---
|
|
195
182
|
|
|
196
|
-
#### `getTheme(options)`
|
|
197
|
-
|
|
198
|
-
Fetch theme assets for the game.
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
const theme = await GamiSDK.getTheme({
|
|
202
|
-
ext: 'json',
|
|
203
|
-
name: 'lunar-new-year'
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
console.log('Theme data:', theme);
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
**Parameters:**
|
|
210
|
-
- `ext` (string): extension (rule)
|
|
211
|
-
- `name` (string): Theme name/identifier
|
|
212
|
-
|
|
213
|
-
**Returns:** `Promise<any>` - Theme data
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
### Leaderboard & Rankings
|
|
218
|
-
|
|
219
|
-
#### `getLeaderboard(options)`
|
|
220
|
-
|
|
221
|
-
Fetch leaderboard data.
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
const res = await GamiSDK.getLeaderboard({
|
|
225
|
-
boardId: 'weekly',
|
|
226
|
-
limit: 50
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
console.log('Leaderboard:', res);
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
**Returns:** `Promise<TLeaderboard>` - Leaderboard data
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
183
|
#### `getHistory(options)`
|
|
237
184
|
|
|
238
185
|
Get user's game history.
|
package/dist/index.public.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { EventSource as EventSource_2 } from 'eventsource';
|
|
2
3
|
|
|
3
4
|
export declare const Calendar: CalendarAPI;
|
|
4
5
|
|
|
@@ -16,7 +17,7 @@ declare interface CalendarAPI {
|
|
|
16
17
|
}): Promise<boolean>;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export declare const GameEvent:
|
|
20
|
+
export declare const GameEvent: EventEmitter<string | symbol, any>;
|
|
20
21
|
|
|
21
22
|
declare const GamiSDK: {
|
|
22
23
|
setServerTime: (value: number) => void;
|
|
@@ -24,6 +25,7 @@ declare const GamiSDK: {
|
|
|
24
25
|
token: string;
|
|
25
26
|
gameId: string;
|
|
26
27
|
userId: string | undefined;
|
|
28
|
+
appProfile: TAppProfile;
|
|
27
29
|
userInfo: IUserInfo | null;
|
|
28
30
|
deviceInfo: TDeviceInfo;
|
|
29
31
|
isBrowser: boolean;
|
|
@@ -51,20 +53,11 @@ declare const GamiSDK: {
|
|
|
51
53
|
startGame: () => Promise<any>;
|
|
52
54
|
endGame: () => Promise<void>;
|
|
53
55
|
getBalance: (params: {
|
|
54
|
-
|
|
56
|
+
balanceId: string;
|
|
55
57
|
}) => Promise<any>;
|
|
56
58
|
getBalanceConfig: () => Promise<any>;
|
|
57
59
|
getConfig: () => Promise<any>;
|
|
58
|
-
getTheme: (params: {
|
|
59
|
-
ext: string;
|
|
60
|
-
name: string;
|
|
61
|
-
}) => Promise<any>;
|
|
62
|
-
submit: (params: {
|
|
63
|
-
steps: any[];
|
|
64
|
-
score: number;
|
|
65
|
-
}) => Promise<any>;
|
|
66
60
|
spin: () => Promise<any>;
|
|
67
|
-
getMilestone: () => Promise<any>;
|
|
68
61
|
getLeaderboard: (params: {
|
|
69
62
|
boardId: string;
|
|
70
63
|
group?: "friend" | "global";
|
|
@@ -78,15 +71,21 @@ declare const GamiSDK: {
|
|
|
78
71
|
page: number;
|
|
79
72
|
limit: number;
|
|
80
73
|
}) => Promise<any>;
|
|
74
|
+
getMission: (params: {
|
|
75
|
+
viewId?: string;
|
|
76
|
+
}) => Promise<any>;
|
|
81
77
|
showToast: (params: {
|
|
82
78
|
title?: string;
|
|
83
79
|
description: string;
|
|
84
80
|
duration: number;
|
|
85
|
-
type?: "success" | "
|
|
81
|
+
type?: "success" | "warning" | "error" | "info" | "failure";
|
|
86
82
|
}) => any;
|
|
87
83
|
showAlert: (title: string, message: string, buttons?: string[]) => any;
|
|
88
84
|
setItem: (key: string, obj: any) => void;
|
|
89
85
|
getItem: (key: string) => Promise<unknown>;
|
|
86
|
+
setProfile: (profile: {
|
|
87
|
+
avatar: string;
|
|
88
|
+
}) => void;
|
|
90
89
|
openWeb: ({ url, html, title }: {
|
|
91
90
|
url?: string;
|
|
92
91
|
html?: string;
|
|
@@ -101,15 +100,17 @@ declare const GamiSDK: {
|
|
|
101
100
|
subject?: string;
|
|
102
101
|
}) => Promise<any>;
|
|
103
102
|
copyToClipBoard: (text: string, message?: string) => Promise<any>;
|
|
104
|
-
shareFacebook: (
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
shareFacebook: (link: string) => Promise<any>;
|
|
104
|
+
shareFacebookImage: (image: string) => Promise<any>;
|
|
105
|
+
shareMessenger: (link: string) => Promise<any>;
|
|
106
|
+
requestPermission: (permission: string, showPopupPermission?: boolean) => Promise<any>;
|
|
107
107
|
checkPermission: (permission: string) => Promise<any>;
|
|
108
|
-
getContacts: ({ isMoMo }?: {
|
|
109
|
-
isMoMo?: boolean;
|
|
108
|
+
getContacts: ({ isMoMo, contactType }?: {
|
|
109
|
+
isMoMo?: boolean | undefined;
|
|
110
|
+
contactType?: "device" | string | undefined;
|
|
110
111
|
}) => Promise<any[]>;
|
|
111
112
|
formatUrl: (origin: string, args?: any[]) => string;
|
|
112
|
-
request: ({ path, method, subDomain, params, body, formData, extraHeader, useCloudMsg, mockData }: {
|
|
113
|
+
request: ({ path, method, subDomain, params, body, formData, extraHeader, useCloudMsg, useSendMessage, mockData, SignSecure }: {
|
|
113
114
|
path: string;
|
|
114
115
|
method: string;
|
|
115
116
|
subDomain?: string;
|
|
@@ -118,9 +119,11 @@ declare const GamiSDK: {
|
|
|
118
119
|
formData?: any;
|
|
119
120
|
extraHeader?: any;
|
|
120
121
|
useCloudMsg?: boolean;
|
|
122
|
+
useSendMessage?: boolean;
|
|
121
123
|
mockData?: any;
|
|
124
|
+
SignSecure?: boolean;
|
|
122
125
|
}) => Promise<any>;
|
|
123
|
-
fetch: ({ path, method, subDomain, params, body, formData, extraHeader, mockData }: {
|
|
126
|
+
fetch: ({ path, method, subDomain, params, body, formData, extraHeader, mockData, useCloudMsg, useSendMessage }: {
|
|
124
127
|
path: string;
|
|
125
128
|
method: string;
|
|
126
129
|
params?: any[];
|
|
@@ -129,7 +132,17 @@ declare const GamiSDK: {
|
|
|
129
132
|
formData?: any;
|
|
130
133
|
extraHeader?: any;
|
|
131
134
|
mockData?: any;
|
|
135
|
+
useCloudMsg?: boolean;
|
|
136
|
+
useSendMessage?: boolean;
|
|
132
137
|
}) => Promise<any>;
|
|
138
|
+
screenTracking: ({ game_id, event_name, action_name, screen_name, extra, error_code }: {
|
|
139
|
+
game_id?: string;
|
|
140
|
+
event_name: string;
|
|
141
|
+
action_name: string;
|
|
142
|
+
screen_name: string;
|
|
143
|
+
extra?: object;
|
|
144
|
+
error_code?: string | number;
|
|
145
|
+
}) => void;
|
|
133
146
|
fetchBinary: ({ url }: {
|
|
134
147
|
url: string;
|
|
135
148
|
}) => Promise<unknown>;
|
|
@@ -175,15 +188,8 @@ declare const GamiSDK: {
|
|
|
175
188
|
pinKey?: string;
|
|
176
189
|
}, callback: (data: any) => void) => void;
|
|
177
190
|
UploadImage: (base64: string) => Promise<string>;
|
|
191
|
+
getScreenShot: () => Promise<unknown>;
|
|
178
192
|
trackingEvent: (event: string, data: any) => void;
|
|
179
|
-
screenTracking: ({ game_id, event_name, action_name, screen_name, extra, error_code }: {
|
|
180
|
-
game_id?: string;
|
|
181
|
-
event_name: string;
|
|
182
|
-
action_name: string;
|
|
183
|
-
screen_name: string;
|
|
184
|
-
extra?: object;
|
|
185
|
-
error_code?: string | number;
|
|
186
|
-
}) => void;
|
|
187
193
|
startRefId: ({ refId, refExtra, useWeb }: {
|
|
188
194
|
refId: string;
|
|
189
195
|
refExtra?: string | object;
|
|
@@ -209,9 +215,22 @@ export declare interface IUserInfo {
|
|
|
209
215
|
avatar?: string;
|
|
210
216
|
}
|
|
211
217
|
|
|
218
|
+
export declare class SSE {
|
|
219
|
+
static create(url: string): EventSource_2;
|
|
220
|
+
}
|
|
221
|
+
|
|
212
222
|
declare const Storage_2: IStorageAPI;
|
|
213
223
|
export { Storage_2 as Storage }
|
|
214
224
|
|
|
225
|
+
declare type TAppProfile = {
|
|
226
|
+
id: string;
|
|
227
|
+
userId: string;
|
|
228
|
+
name: string;
|
|
229
|
+
displayName: string;
|
|
230
|
+
avatar: string;
|
|
231
|
+
userInputDateOfBirth: string;
|
|
232
|
+
};
|
|
233
|
+
|
|
215
234
|
export declare type TDeviceInfo = {
|
|
216
235
|
appVersion: string;
|
|
217
236
|
buildVersion: string;
|