playsout-web-sdk 1.0.5 → 1.0.6
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 +33 -52
- package/chunk-NHFWJCNJ.cjs +2 -0
- package/chunk-XDBADNFW.js +2 -0
- package/core/api.d.ts +2 -1
- package/core/api.d.ts.map +1 -1
- package/core/index.d.ts +4 -0
- package/core/index.d.ts.map +1 -1
- package/core/storage.d.ts +1 -0
- package/core/storage.d.ts.map +1 -1
- package/core/types.d.ts +1 -1
- package/core/types.d.ts.map +1 -1
- package/index.cjs +1 -1
- package/index.global.js +35 -35
- package/index.iife.js +35 -35
- package/index.js +1 -1
- package/package.json +1 -1
- package/react/index.cjs +1 -1
- package/react/index.js +1 -1
- package/vue/index.cjs +1 -1
- package/vue/index.js +1 -1
- package/chunk-5IONEDIP.cjs +0 -2
- package/chunk-OLKMPDGC.js +0 -2
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Use the following sequence when the application starts:
|
|
|
38
38
|
4. Render `<playsout-widget>`.
|
|
39
39
|
5. Use `locale` to control the language and `user-points` to display the gem amount.
|
|
40
40
|
|
|
41
|
-
During initialization, the SDK checks `
|
|
41
|
+
During initialization, the SDK checks the stored token and user information. `isLoggedIn` is `true` only when both are present. It uses a valid access token directly and tries the refresh endpoint when the access token has expired. If refresh is unavailable or fails, the SDK reuses the most recently saved Grab/Eros `Login()` parameters to re-login once. If that recovery also fails, it clears the local authentication state, emits `authExpired`, and rejects the operation. Do not use `getUserInfo()` as a startup gate. Call it only when a page explicitly needs fresh backend user data.
|
|
42
42
|
|
|
43
43
|
## Login Parameters
|
|
44
44
|
|
|
@@ -54,7 +54,7 @@ Required parameters:
|
|
|
54
54
|
| --- | --- |
|
|
55
55
|
| `platform` | Platform identifier. Use `'grab'` or `'eros'`. |
|
|
56
56
|
| `platformUserId` | Unique user ID from the host platform. |
|
|
57
|
-
| `platformToken` |
|
|
57
|
+
| `platformToken` | Any random non-empty string; there are no other requirements. |
|
|
58
58
|
| `username` | User display name. |
|
|
59
59
|
|
|
60
60
|
Example:
|
|
@@ -68,7 +68,7 @@ await Playsout.Login({
|
|
|
68
68
|
});
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
`platformToken` is
|
|
71
|
+
`platformToken` is required, but any random non-empty string is accepted.
|
|
72
72
|
|
|
73
73
|
## HTML Integration
|
|
74
74
|
|
|
@@ -113,13 +113,7 @@ Place the following code in `index.html`:
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
async function bootstrap() {
|
|
116
|
-
await window.Playsout.init({ locale: '
|
|
117
|
-
|
|
118
|
-
window.Playsout.on('authExpired', function () {
|
|
119
|
-
login().catch(function (error) {
|
|
120
|
-
console.error('Playsout re-login failed:', error);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
116
|
+
await window.Playsout.init({ locale: 'en' });
|
|
123
117
|
|
|
124
118
|
await ensureLogin();
|
|
125
119
|
|
|
@@ -141,7 +135,7 @@ Place the following code in `index.html`:
|
|
|
141
135
|
Common HTML / IIFE APIs:
|
|
142
136
|
|
|
143
137
|
```js
|
|
144
|
-
window.Playsout.init({ locale: '
|
|
138
|
+
window.Playsout.init({ locale: 'en' });
|
|
145
139
|
window.Playsout.isLoggedIn;
|
|
146
140
|
window.Playsout.Login(params);
|
|
147
141
|
window.Playsout.getUserInfo();
|
|
@@ -195,7 +189,7 @@ const app = createApp(App);
|
|
|
195
189
|
|
|
196
190
|
app.use(createPlaysoutPlugin({
|
|
197
191
|
config: {
|
|
198
|
-
locale: '
|
|
192
|
+
locale: 'en',
|
|
199
193
|
},
|
|
200
194
|
}));
|
|
201
195
|
|
|
@@ -220,27 +214,19 @@ const {
|
|
|
220
214
|
Login,
|
|
221
215
|
} = usePlaysout();
|
|
222
216
|
|
|
223
|
-
let
|
|
224
|
-
|
|
225
|
-
function login() {
|
|
226
|
-
if (!loginPromise) {
|
|
227
|
-
loginPromise = Login({
|
|
228
|
-
platform: 'eros',
|
|
229
|
-
platformUserId: '10',
|
|
230
|
-
platformToken: 'random-string',
|
|
231
|
-
username: 'TestUser',
|
|
232
|
-
}).finally(() => {
|
|
233
|
-
loginPromise = null;
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return loginPromise;
|
|
238
|
-
}
|
|
217
|
+
let initialLoginChecked = false;
|
|
239
218
|
|
|
240
|
-
watch(
|
|
241
|
-
if (!initialized ||
|
|
219
|
+
watch(isInitialized, (initialized) => {
|
|
220
|
+
if (!initialized || initialLoginChecked) return;
|
|
221
|
+
initialLoginChecked = true;
|
|
222
|
+
if (isLoggedIn.value) return;
|
|
242
223
|
|
|
243
|
-
|
|
224
|
+
Login({
|
|
225
|
+
platform: 'eros',
|
|
226
|
+
platformUserId: '10',
|
|
227
|
+
platformToken: 'random-string',
|
|
228
|
+
username: 'TestUser',
|
|
229
|
+
}).catch((error) => {
|
|
244
230
|
console.error('Playsout login flow failed:', error);
|
|
245
231
|
});
|
|
246
232
|
}, { immediate: true });
|
|
@@ -258,7 +244,7 @@ Vue notes:
|
|
|
258
244
|
|
|
259
245
|
- The page waits for plugin initialization, then checks the login state and runs the login flow automatically.
|
|
260
246
|
- `locale` controls the widget language.
|
|
261
|
-
- For a fixed default language, `config: { locale: '
|
|
247
|
+
- For a fixed default language, `config: { locale: 'en' }` in the entry file is sufficient. If the application later needs dynamic locale switching, call `setLocale()` and bind `locale`.
|
|
262
248
|
- `user-points="1000"` seeds the widget's frontend gem balance. Iframe game payments can deduct from this in-session balance only.
|
|
263
249
|
- If the application already has a game page, place the logic in that page component.
|
|
264
250
|
|
|
@@ -277,7 +263,7 @@ import 'playsout-web-sdk/web-components';
|
|
|
277
263
|
import App from './App.jsx';
|
|
278
264
|
|
|
279
265
|
createRoot(document.getElementById('root')).render(
|
|
280
|
-
<PlaysoutProvider config={{ locale: '
|
|
266
|
+
<PlaysoutProvider config={{ locale: 'en' }}>
|
|
281
267
|
<App />
|
|
282
268
|
</PlaysoutProvider>
|
|
283
269
|
);
|
|
@@ -294,7 +280,7 @@ import { useEffect, useRef } from 'react';
|
|
|
294
280
|
import { usePlaysout } from 'playsout-web-sdk/react';
|
|
295
281
|
|
|
296
282
|
export default function App() {
|
|
297
|
-
const
|
|
283
|
+
const initialLoginChecked = useRef(false);
|
|
298
284
|
const {
|
|
299
285
|
isInitialized,
|
|
300
286
|
isLoggedIn,
|
|
@@ -303,8 +289,9 @@ export default function App() {
|
|
|
303
289
|
} = usePlaysout();
|
|
304
290
|
|
|
305
291
|
useEffect(() => {
|
|
306
|
-
if (!isInitialized ||
|
|
307
|
-
|
|
292
|
+
if (!isInitialized || initialLoginChecked.current) return;
|
|
293
|
+
initialLoginChecked.current = true;
|
|
294
|
+
if (isLoggedIn) return;
|
|
308
295
|
|
|
309
296
|
Login({
|
|
310
297
|
platform: 'eros',
|
|
@@ -314,9 +301,6 @@ export default function App() {
|
|
|
314
301
|
})
|
|
315
302
|
.catch((error) => {
|
|
316
303
|
console.error('Playsout login flow failed:', error);
|
|
317
|
-
})
|
|
318
|
-
.finally(() => {
|
|
319
|
-
loginInFlight.current = false;
|
|
320
304
|
});
|
|
321
305
|
}, [isInitialized, isLoggedIn, Login]);
|
|
322
306
|
|
|
@@ -334,7 +318,7 @@ React notes:
|
|
|
334
318
|
- `PlaysoutProvider` initializes the SDK.
|
|
335
319
|
- After Provider initialization, the page checks the login state and runs the login flow once.
|
|
336
320
|
- `usePlaysout()` provides the login state, login method, user information method, and locale APIs.
|
|
337
|
-
- For a fixed default language, `<PlaysoutProvider config={{ locale: '
|
|
321
|
+
- For a fixed default language, `<PlaysoutProvider config={{ locale: 'en' }}>` is sufficient. If the application later needs dynamic locale switching, call `setLocale()` and bind `locale`.
|
|
338
322
|
- React does not need Vue's `isCustomElement` configuration.
|
|
339
323
|
|
|
340
324
|
## Common API Reference
|
|
@@ -378,27 +362,24 @@ When a game is opened in iframe detail mode, the widget listens for `privy-bridg
|
|
|
378
362
|
|
|
379
363
|
## Authentication Expiration
|
|
380
364
|
|
|
381
|
-
The SDK handles
|
|
382
|
-
|
|
383
|
-
1. A protected API reports that the token is invalid.
|
|
384
|
-
2. The SDK automatically calls the refresh token endpoint.
|
|
385
|
-
3. After a successful refresh, the SDK stores the new token and retries the original request.
|
|
365
|
+
The SDK handles authentication recovery internally:
|
|
386
366
|
|
|
387
|
-
|
|
367
|
+
1. When a protected API reports that the access token is invalid, the SDK calls the refresh token endpoint.
|
|
368
|
+
2. After a successful refresh, the SDK stores the new token and retries the original request.
|
|
369
|
+
3. If the refresh token is expired or the refresh request fails, the SDK automatically reuses the most recently saved Grab/Eros `Login()` parameters and re-logs in once.
|
|
370
|
+
4. After a successful re-login, the SDK stores both the new token and user information, then retries the original request.
|
|
388
371
|
|
|
389
|
-
-
|
|
390
|
-
- Changes the login state to logged out.
|
|
391
|
-
- Emits the `authExpired` event.
|
|
372
|
+
The automatic re-login is attempted at most once for an authentication recovery. If it fails, the SDK clears the stored token, user information, and reusable login parameters, changes `isLoggedIn` to `false`, emits `authExpired`, and throws the error to the calling application. TikTok login parameters are not reused automatically.
|
|
392
373
|
|
|
393
|
-
|
|
374
|
+
`authExpired` is an optional final-failure notification. Do not start another automatic login loop from this event:
|
|
394
375
|
|
|
395
376
|
```js
|
|
396
377
|
window.Playsout.on('authExpired', function () {
|
|
397
|
-
|
|
378
|
+
console.error('Playsout authentication recovery failed');
|
|
398
379
|
});
|
|
399
380
|
```
|
|
400
381
|
|
|
401
|
-
React and Vue adapters synchronize their reactive login state
|
|
382
|
+
React and Vue adapters synchronize their reactive login state after final recovery failure. The application should catch the failed SDK operation and decide how to present the error to the user.
|
|
402
383
|
|
|
403
384
|
## Image Loading
|
|
404
385
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkZ2CIDSTP_cjs=require('./chunk-Z2CIDSTP.cjs');var N=(m=>(m.NOT_INITIALIZED="NOT_INITIALIZED",m.ALREADY_INITIALIZED="ALREADY_INITIALIZED",m.NOT_LOGGED_IN="NOT_LOGGED_IN",m.TOKEN_EXPIRED="TOKEN_EXPIRED",m.INVALID_TOKEN="INVALID_TOKEN",m.NETWORK_ERROR="NETWORK_ERROR",m.TIMEOUT="TIMEOUT",m.SERVER_ERROR="SERVER_ERROR",m.API_ERROR="API_ERROR",m.INVALID_PARAMS="INVALID_PARAMS",m.MISSING_PARAMS="MISSING_PARAMS",m.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",m.UNKNOWN="UNKNOWN",m.PAYMENT_FAILED="PAYMENT_FAILED",m.SHARE_FAILED="SHARE_FAILED",m))(N||{}),E=class extends Error{constructor(t,r,i){super(r);this.code=t;this.details=i;this.name="SDKError";}toJSON(){return {name:this.name,code:this.code,message:this.message,details:this.details}}},Z={NOT_INITIALIZED:"SDK not initialized. Please call PlaysoutSDK.init() first.",ALREADY_INITIALIZED:"SDK already initialized. Please do not call init() more than once.",NOT_LOGGED_IN:"User not logged in. Please log in first.",TOKEN_EXPIRED:"Login token has expired. Please log in again.",INVALID_TOKEN:"Invalid login token. Please log in again.",NETWORK_ERROR:"Network connection failed. Please check your network.",TIMEOUT:"Request timed out. Please try again later.",SERVER_ERROR:"Server is busy. Please try again later.",API_ERROR:"API request failed.",INVALID_PARAMS:"Invalid parameter(s).",MISSING_PARAMS:"Missing required parameter(s).",FEATURE_NOT_SUPPORTED:"This feature is not supported in the current environment.",UNKNOWN:"An unknown error occurred.",PAYMENT_FAILED:"Payment failed.",SHARE_FAILED:"Share failed."};function s(o,e){return new E(o,Z[o],e)}var P="playsout_",R=class{constructor(e){this.storage=e;}get(e){try{return this.storage.getItem(P+e)}catch{return null}}set(e,t){try{this.storage.setItem(P+e,t);}catch(r){console.warn("[PlaysoutSDK] Storage set failed:",r);}}remove(e){try{this.storage.removeItem(P+e);}catch{}}clear(){try{let e=[];for(let t=0;t<this.storage.length;t++){let r=this.storage.key(t);r&&r.startsWith(P)&&e.push(r);}e.forEach(t=>this.storage.removeItem(t));}catch{}}},_=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function x(o="localStorage"){return typeof window>"u"||o==="memory"?new _:o==="sessionStorage"?new R(sessionStorage):new R(localStorage)}var T=x(),l={get:o=>T.get(o),set:(o,e)=>{T.set(o,e);},remove:o=>{T.remove(o);},clear:()=>{T.clear();},getJSON:o=>{let e=T.get(o);if(!e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(o,e)=>{T.set(o,JSON.stringify(e));},configure(o){T=x(o);}},u={TOKEN_DATA:"token_data",USER:"user",LOGIN_PARAMS:"login_params",LOCALE:"locale",CONFIG:"config"};var V=o=>{if(!o)return o;try{let e=new URL(o);if(e.hostname==="games.playsout.com"){let t=e.pathname,r=t.endsWith("/"),i=/\.[a-z0-9]+$/i.test(t);!r&&!i&&(e.pathname=`${t}/`);}return e.toString()}catch{return o}},X=o=>o.map(e=>{if(!e.externalUrl)return e;let t=V(e.externalUrl);return t===e.externalUrl?e:{...e,externalUrl:t}}),Y=[{id:"BlockCrushFun",title:"Block Crush Fun",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/BlockCrushFun.png"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BlockCrushFun"},{id:"DogeSurvivors",title:"Doge Survivors",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeSurvivors.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeSurvivors/"},{id:"DogeMaze",title:"Doge Maze",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeMaze.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMaze/"},{id:"DogeMart",title:"Doge Mart",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeMart.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMart/"},{id:"KittyEscape",title:"Kitty Escape",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/KittyEscape.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/KittyEscape/"},{id:"ProjectGarden",title:"Project: Garden",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/SimulatedAdventures.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/simulated/"},{id:"ProjectIDLE",title:"Project: IDLE",category:"Simulation",image:chunkZ2CIDSTP_cjs.c("./games/ProjectIDLE.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/idle/"},{id:"CulinaryStarWeb",title:"Culinary Star",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/CulinaryStar.webp"),description:"Cooking game",isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CulinaryStar/"},{id:"PickaxeQuest",title:"Pickaxe Quest",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/PickaxeQuest.jpg"),description:"Mining and adventure game",isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/PickaxeQuest/",apiGameId:73},{id:"MonsterSurvivors",title:"Monster Survivors",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/MonsterSurvivors.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MonsterSurvivors/"},{id:"IdleTowerDefense",title:"Idle Tower Defense",category:"RPG",image:chunkZ2CIDSTP_cjs.c("./games/IdleTowerDefense.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/IdleTowerDefense/"},{id:"MushroomWarriors",title:"Mushroom Warriors",category:"RPG",image:chunkZ2CIDSTP_cjs.c("./games/MushroomWarriors.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MushroomWarriors/"},{id:"FollowThePath",title:"Follow The Path",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/FollowThePath.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FollowThePath/"},{id:"ColorRun",title:"Color Run",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ColorRun.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorRun/"},{id:"StupidArrow",title:"Stupid Arrow",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/StupidArrow.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/StupidArrow/"},{id:"ZigZag",title:"Zig Zag",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ZigZag.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ZigZag/"},{id:"SpikesEverywhere",title:"Spikes Everywhere",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/SpikesEverywhere.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpikesEverywhere/"},{id:"ArrowRacer",title:"Arrow Racer",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ArrowRacer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ArrowRacer/"},{id:"CircleLeap",title:"Circle Leap",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CircleLeap.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircleLeap/"},{id:"ColorMatcher",title:"Color Matcher",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ColorMatcher.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorMatcher/"},{id:"EndlessMaze",title:"Endless Maze",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/EndlessMaze.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/EndlessMaze/"},{id:"SpinningAround",title:"Spinning Around",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/SpinningAround.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpinningAround/"},{id:"BoomBallz",title:"Boom Ballz",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/BoomBallz.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BoomBallz/"},{id:"CubeHead",title:"Cube Head",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CubeHead.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CubeHead/"},{id:"CapybaraLink",title:"Capybara Link",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/CapybaraLink.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CapybaraLink/"},{id:"Snake2048",title:"Snake 2048",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/Snake2048.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Snake2048/"},{id:"FishTankFury",title:"Fish Tank Fury",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/FishTankFury.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FishTankFury/"},{id:"ConnectBalls",title:"Connect Balls",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ConnectBalls.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ConnectBalls/"},{id:"CircularBreaker",title:"Circular Breaker",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CircularBreaker.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircularBreaker/"},{id:"OneDoor",title:"One Door",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/OneDoor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/OneDoor/"},{id:"CatchtheFruits",title:"Catch the Fruits",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/CatchtheFruits.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CatchtheFruits/"},{id:"Falling2048",title:"Falling 2048",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/Falling2048.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Falling2048/"}],M=X(Y),h=()=>M.filter(o=>o.enable);({Adventure:h().filter(o=>o.category==="Adventure"),Moba:h().filter(o=>o.category==="Moba")});var K=o=>M.find(e=>e.id===o);var z=()=>Array.from(new Set(h().map(o=>o.category)));var C="https://api.playsout.com",G=3e4;function Q(o){let e=String(o?.platform||"").toLowerCase();if(e==="tiktok"){let t=o.authorizationCode;if(typeof t!="string"||!t.trim())throw s("MISSING_PARAMS","authorizationCode is required for TikTok login");return {platform:e,authorizationCode:t}}if(e==="grab"||e==="eros"){let t=o;if(typeof t.platformUserId!="string"||!t.platformUserId.trim())throw s("MISSING_PARAMS","platformUserId is required for Grab/Eros login");if(typeof t.platformToken!="string"||!t.platformToken.trim())throw s("MISSING_PARAMS","platformToken is required for Grab/Eros login");if(typeof t.username!="string"||!t.username.trim())throw s("MISSING_PARAMS","username is required for Grab/Eros login");return {platform:e,platformUserId:t.platformUserId,platformToken:t.platformToken,username:t.username,inviteCode:typeof t.inviteCode=="string"?t.inviteCode:void 0}}throw s("INVALID_PARAMS","Unsupported platform. Expected grab, eros, or tiktok")}var S=null,v=null,O=null,b=null;function B(o){v=o;}function q(o){O=o;}function W(o){b=o;}function H(){if(b)try{b();}catch{}}async function ee(o){if(!O)throw H(),o instanceof E?o:s("TOKEN_EXPIRED",o);try{return await O()}catch(e){throw H(),e instanceof E?e:s("TOKEN_EXPIRED",e)}}async function j(o,e={},t,r=false,i=r){let c=t?.apiBaseUrl||C,p=o.startsWith("http")?o:`${c}${o}`,g=new AbortController,f=setTimeout(()=>g.abort(),G);try{let d=l.getJSON(u.TOKEN_DATA),A={"Content-Type":"application/json",...e.headers};r&&d?.accessToken&&!A.token&&(A.token=d.accessToken);let I=await fetch(p,{...e,signal:g.signal,headers:A});if(clearTimeout(f),!I.ok){if(I.status===401&&r&&i)return await F(o,e,t);throw s(I.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${I.status}: ${I.statusText}`)}let D=await I.json();if(D.code!==1e4){if(r&&i)return await F(o,e,t);throw s("API_ERROR",D.msg||"API request failed")}return D.data}catch(d){throw clearTimeout(f),d instanceof E?d:d instanceof Error?d.name==="AbortError"?s("TIMEOUT"):s("NETWORK_ERROR",d.message):s("UNKNOWN")}}async function F(o,e,t){await J(t);let r=t?.apiBaseUrl||C,i=o.startsWith("http")?o:`${r}${o}`,c=new AbortController,p=setTimeout(()=>c.abort(),G);try{let g=l.getJSON(u.TOKEN_DATA),f={"Content-Type":"application/json",...e.headers};g?.accessToken&&(f.token=g.accessToken);let d=await fetch(i,{...e,signal:c.signal,headers:f});if(clearTimeout(p),!d.ok)throw s(d.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${d.status}: ${d.statusText}`);let A=await d.json();if(A.code!==1e4)throw s("API_ERROR",A.msg||"API request failed");return A.data}catch(g){throw clearTimeout(p),g instanceof E?g:g instanceof Error&&g.name==="AbortError"?s("TIMEOUT"):s("NETWORK_ERROR",g?.message||"Request failed")}}async function J(o){if(S)return S;let e=(async()=>{try{let t=l.getJSON(u.TOKEN_DATA),r=Math.floor(Date.now()/1e3);if(!t?.refreshToken||t.refreshExpiresAt<=r)throw s("TOKEN_EXPIRED","Refresh token has expired");let i=o?.apiBaseUrl||C,c=new AbortController,p=setTimeout(()=>c.abort(),G);try{let g=await fetch(`${i}/platform/refreshToken`,{method:"POST",signal:c.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t.refreshToken})});if(clearTimeout(p),!g.ok)throw g.status>=500?s("SERVER_ERROR",`HTTP ${g.status}: ${g.statusText}`):s("TOKEN_EXPIRED",`HTTP ${g.status}: ${g.statusText}`);let f=await g.json();if(f.code!==1e4||!f.data)throw s("TOKEN_EXPIRED",f.msg||"Failed to refresh token");let d=f.data;if(l.setJSON(u.TOKEN_DATA,d),v)try{v(d);}catch{}return d}catch(g){throw clearTimeout(p),g instanceof E?g:g instanceof Error&&g.name==="AbortError"?s("TIMEOUT"):s("NETWORK_ERROR",g?.message||"Refresh token failed")}}catch(t){return await ee(t)}})();S=e;try{return await e}finally{S===e&&(S=null);}}var U=class{constructor(){this.config=null;}configure(e){this.config=e;}async refreshToken(){return await J(this.config||void 0)}async getGames(e){let t=h();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){let e=h(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],c)=>({id:`category_${c}`,name:r,count:i}))}async getGameById(e){return K(e)}async getCategoryNames(){return z()}async loginOnly(e){let t=Q(e);return await j("/platform/login",{method:"POST",body:JSON.stringify(t)},this.config??void 0)}async Login(e){let t=await this.loginOnly(e);l.setJSON(u.TOKEN_DATA,t);try{let r=await this.getUserInfo(!1);return {tokenData:t,user:r}}catch(r){throw l.remove(u.TOKEN_DATA),l.remove(u.USER),r}}async getUserInfo(e=true){return await j("/platform/user",{method:"GET"},this.config??void 0,true,e)}async getUser(){return l.getJSON(u.USER)}async validateToken(e){return !!e}},L=null;function k(){return L||(L=new U),L}var te="https://api.playsout.com",$="zh",w=class o{constructor(){this.config=null;this._isInitialized=false;this._user=null;this._token=null;this._locale=$;this._widget=null;}clearAuthState(){let e=!!(this._token||l.get(u.TOKEN_DATA)||l.get(u.USER));return this._user=null,this._token=null,l.remove(u.TOKEN_DATA),l.remove(u.USER),l.remove(u.LOGIN_PARAMS),e}updateUser(e){this._user={userId:String(e.id),username:e.username},l.setJSON(u.USER,this._user);}saveLoginParams(e){if(e.platform==="grab"||e.platform==="eros"){l.setJSON(u.LOGIN_PARAMS,{...e});return}l.remove(u.LOGIN_PARAMS);}async performLogin(e,t){let r=k();r.configure(this.config);let i=await r.loginOnly(e);l.setJSON(u.TOKEN_DATA,i);let c=await r.getUserInfo(false);return this._token=i.accessToken,this.updateUser(c),t&&this.saveLoginParams(e),chunkZ2CIDSTP_cjs.b.emit("login",{user:this._user,token:this._token}),{tokenData:i,user:c}}async recoverAuthentication(){let e=l.getJSON(u.LOGIN_PARAMS);if(!e||e.platform!=="grab"&&e.platform!=="eros")throw s("TOKEN_EXPIRED","No reusable login parameters available");return (await this.performLogin(e,false)).tokenData}handleAuthExpired(){this.clearAuthState()&&chunkZ2CIDSTP_cjs.b.emit("authExpired"),this.config?.debug&&console.warn("[PlaysoutSDK] Auth expired, logged out");}static getInstance(){return o.instance||(o.instance=new o),o.instance}async init(e={}){if(this._isInitialized)throw s("ALREADY_INITIALIZED");this.config={apiBaseUrl:e.apiBaseUrl||te,debug:e.debug||false,storage:e.storage||"localStorage",locale:e.locale||$,appId:e.appId||""},l.configure(this.config.storage),B(i=>{this._token=i.accessToken;}),q(()=>this.recoverAuthentication()),W(()=>{this.handleAuthExpired();});let t=l.getJSON(u.TOKEN_DATA);this._user=l.getJSON(u.USER),this._locale=l.get(u.LOCALE)||this.config.locale;let r=Math.floor(Date.now()/1e3);if(t){let i=k();if(i.configure(this.config),t.accessToken&&t.expiresAt>r?this._token=t.accessToken:await i.refreshToken(),this._token&&!this._user){let c=await i.getUserInfo();this.updateUser(c);}}else this._user&&(this._user=null,l.remove(u.USER));this._isInitialized=true,this.config.debug&&(console.log("[PlaysoutSDK] Initialized with config:",this.config),console.log("[PlaysoutSDK] Restored token:",this._token?this._token.substring(0,20)+"...":"(none)")),chunkZ2CIDSTP_cjs.b.emit("initialized");}destroy(){this.config=null,this._isInitialized=false,this._user=null,this._token=null,l.clear(),chunkZ2CIDSTP_cjs.b.clear();}get isInitialized(){return this._isInitialized}get isLoggedIn(){return !!(this._token&&this._user)}get user(){return this._user}get token(){return this._token}get locale(){return this._locale}get sdkConfig(){return this.config}async Login(e){this.ensureInitialized(),this.config?.debug&&console.log("[PlaysoutSDK] Login with params:",e);try{let t=await this.performLogin(e,!0);return this.config?.debug&&console.log("[PlaysoutSDK] Login success, user:",t.user),t}catch(t){throw this.clearAuthState(),t}}async getUserInfo(){if(this.ensureInitialized(),!this.isLoggedIn)throw s("NOT_LOGGED_IN","Please login first");let e=k();e.configure(this.config);let t=await e.getUserInfo();return this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo result:",t),t&&this.updateUser(t),t}logout(){this.clearAuthState(),chunkZ2CIDSTP_cjs.b.emit("logout");}getToken(){return this.ensureInitialized(),this._token}getUser(){return this.ensureInitialized(),this._user}setLocale(e){if(this.ensureInitialized(),!["zh","en","ja","ko","vi","th","id","ms"].includes(e))throw s("INVALID_PARAMS",`Unsupported locale: ${e}`);this._locale=e,l.set(u.LOCALE,e),this.config?.debug&&console.log("[PlaysoutSDK] Locale changed to:",e);let t=this._widget||document.querySelector("playsout-widget");t&&t.getAttribute("locale")!==e&&t.setAttribute("locale",e),chunkZ2CIDSTP_cjs.b.emit("localeChange",e);}getLocale(){return this.ensureInitialized(),this._locale}async getGames(e){this.ensureInitialized();let t=h();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){this.ensureInitialized();let e=h(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],c)=>({id:`category_${c}`,name:r,count:i}))}async getGameById(e){return this.ensureInitialized(),h().find(t=>t.id===e)}mount(e,t){if(this.ensureInitialized(),typeof document>"u")throw s("FEATURE_NOT_SUPPORTED","mount requires DOM environment");let r=document.querySelector(e);if(!r)throw s("INVALID_PARAMS",`Container not found: ${e}`);let i=document.createElement("playsout-widget");this.config?.appId&&i.setAttribute("app-id",this.config.appId),i.setAttribute("locale",t?.locale||this._locale),t?.detailMode&&i.setAttribute("detail-mode",t.detailMode),this._widget=i,t?.onGameClick&&i.addEventListener("game-click",c=>{let p=c;t.onGameClick(p.detail);}),t?.onLoginRequired&&i.addEventListener("login-required",t.onLoginRequired),t?.onLocaleChange&&i.addEventListener("locale-change",c=>{let p=c;t.onLocaleChange(p.detail);}),r.appendChild(i),this.config?.debug&&console.log("[PlaysoutSDK] Widget mounted to:",e);}unmount(){let e=document.querySelector("playsout-widget");e&&e.remove(),this._widget=null;}on(e,t){return this.ensureInitialized(),chunkZ2CIDSTP_cjs.b.on(e,t)}off(e,t){this.ensureInitialized(),chunkZ2CIDSTP_cjs.b.off(e,t);}ensureInitialized(){if(!this._isInitialized)throw s("NOT_INITIALIZED")}},a=w.getInstance(),Te=a;typeof window<"u"&&(window.__playsout_sdk_instance=a);var we=Object.freeze({init:a.init.bind(a),mount:a.mount.bind(a),unmount:a.unmount.bind(a),destroy:a.destroy.bind(a),Login:a.Login.bind(a),logout:a.logout.bind(a),getToken:a.getToken.bind(a),getUserInfo:a.getUserInfo.bind(a),getUser:a.getUser.bind(a),setLocale:a.setLocale.bind(a),getLocale:a.getLocale.bind(a),getGames:a.getGames.bind(a),getCategories:a.getCategories.bind(a),on:a.on.bind(a),off:a.off.bind(a),get isInitialized(){return a.isInitialized},get isLoggedIn(){return a.isLoggedIn},instance:a,PlaysoutSDKClass:w});
|
|
2
|
+
exports.a=N;exports.b=E;exports.c=l;exports.d=u;exports.e=w;exports.f=a;exports.g=Te;exports.h=we;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {c,b as b$1}from'./chunk-EZLO3WY6.js';var N=(m=>(m.NOT_INITIALIZED="NOT_INITIALIZED",m.ALREADY_INITIALIZED="ALREADY_INITIALIZED",m.NOT_LOGGED_IN="NOT_LOGGED_IN",m.TOKEN_EXPIRED="TOKEN_EXPIRED",m.INVALID_TOKEN="INVALID_TOKEN",m.NETWORK_ERROR="NETWORK_ERROR",m.TIMEOUT="TIMEOUT",m.SERVER_ERROR="SERVER_ERROR",m.API_ERROR="API_ERROR",m.INVALID_PARAMS="INVALID_PARAMS",m.MISSING_PARAMS="MISSING_PARAMS",m.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",m.UNKNOWN="UNKNOWN",m.PAYMENT_FAILED="PAYMENT_FAILED",m.SHARE_FAILED="SHARE_FAILED",m))(N||{}),E=class extends Error{constructor(t,r,i){super(r);this.code=t;this.details=i;this.name="SDKError";}toJSON(){return {name:this.name,code:this.code,message:this.message,details:this.details}}},Z={NOT_INITIALIZED:"SDK not initialized. Please call PlaysoutSDK.init() first.",ALREADY_INITIALIZED:"SDK already initialized. Please do not call init() more than once.",NOT_LOGGED_IN:"User not logged in. Please log in first.",TOKEN_EXPIRED:"Login token has expired. Please log in again.",INVALID_TOKEN:"Invalid login token. Please log in again.",NETWORK_ERROR:"Network connection failed. Please check your network.",TIMEOUT:"Request timed out. Please try again later.",SERVER_ERROR:"Server is busy. Please try again later.",API_ERROR:"API request failed.",INVALID_PARAMS:"Invalid parameter(s).",MISSING_PARAMS:"Missing required parameter(s).",FEATURE_NOT_SUPPORTED:"This feature is not supported in the current environment.",UNKNOWN:"An unknown error occurred.",PAYMENT_FAILED:"Payment failed.",SHARE_FAILED:"Share failed."};function s(o,e){return new E(o,Z[o],e)}var P="playsout_",R=class{constructor(e){this.storage=e;}get(e){try{return this.storage.getItem(P+e)}catch{return null}}set(e,t){try{this.storage.setItem(P+e,t);}catch(r){console.warn("[PlaysoutSDK] Storage set failed:",r);}}remove(e){try{this.storage.removeItem(P+e);}catch{}}clear(){try{let e=[];for(let t=0;t<this.storage.length;t++){let r=this.storage.key(t);r&&r.startsWith(P)&&e.push(r);}e.forEach(t=>this.storage.removeItem(t));}catch{}}},_=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function x(o="localStorage"){return typeof window>"u"||o==="memory"?new _:o==="sessionStorage"?new R(sessionStorage):new R(localStorage)}var T=x(),l={get:o=>T.get(o),set:(o,e)=>{T.set(o,e);},remove:o=>{T.remove(o);},clear:()=>{T.clear();},getJSON:o=>{let e=T.get(o);if(!e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(o,e)=>{T.set(o,JSON.stringify(e));},configure(o){T=x(o);}},u={TOKEN_DATA:"token_data",USER:"user",LOGIN_PARAMS:"login_params",LOCALE:"locale",CONFIG:"config"};var V=o=>{if(!o)return o;try{let e=new URL(o);if(e.hostname==="games.playsout.com"){let t=e.pathname,r=t.endsWith("/"),i=/\.[a-z0-9]+$/i.test(t);!r&&!i&&(e.pathname=`${t}/`);}return e.toString()}catch{return o}},X=o=>o.map(e=>{if(!e.externalUrl)return e;let t=V(e.externalUrl);return t===e.externalUrl?e:{...e,externalUrl:t}}),Y=[{id:"BlockCrushFun",title:"Block Crush Fun",category:"Puzzle",image:c("./games/BlockCrushFun.png"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BlockCrushFun"},{id:"DogeSurvivors",title:"Doge Survivors",category:"Doge OS",image:c("./games/DogeSurvivors.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeSurvivors/"},{id:"DogeMaze",title:"Doge Maze",category:"Doge OS",image:c("./games/DogeMaze.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMaze/"},{id:"DogeMart",title:"Doge Mart",category:"Doge OS",image:c("./games/DogeMart.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMart/"},{id:"KittyEscape",title:"Kitty Escape",category:"Puzzle",image:c("./games/KittyEscape.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/KittyEscape/"},{id:"ProjectGarden",title:"Project: Garden",category:"Adventure",image:c("./games/SimulatedAdventures.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/simulated/"},{id:"ProjectIDLE",title:"Project: IDLE",category:"Simulation",image:c("./games/ProjectIDLE.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/idle/"},{id:"CulinaryStarWeb",title:"Culinary Star",category:"Casual",image:c("./games/CulinaryStar.webp"),description:"Cooking game",isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CulinaryStar/"},{id:"PickaxeQuest",title:"Pickaxe Quest",category:"Adventure",image:c("./games/PickaxeQuest.jpg"),description:"Mining and adventure game",isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/PickaxeQuest/",apiGameId:73},{id:"MonsterSurvivors",title:"Monster Survivors",category:"Adventure",image:c("./games/MonsterSurvivors.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MonsterSurvivors/"},{id:"IdleTowerDefense",title:"Idle Tower Defense",category:"RPG",image:c("./games/IdleTowerDefense.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/IdleTowerDefense/"},{id:"MushroomWarriors",title:"Mushroom Warriors",category:"RPG",image:c("./games/MushroomWarriors.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MushroomWarriors/"},{id:"FollowThePath",title:"Follow The Path",category:"Arcade",image:c("./games/FollowThePath.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FollowThePath/"},{id:"ColorRun",title:"Color Run",category:"Arcade",image:c("./games/ColorRun.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorRun/"},{id:"StupidArrow",title:"Stupid Arrow",category:"Arcade",image:c("./games/StupidArrow.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/StupidArrow/"},{id:"ZigZag",title:"Zig Zag",category:"Arcade",image:c("./games/ZigZag.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ZigZag/"},{id:"SpikesEverywhere",title:"Spikes Everywhere",category:"Arcade",image:c("./games/SpikesEverywhere.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpikesEverywhere/"},{id:"ArrowRacer",title:"Arrow Racer",category:"Arcade",image:c("./games/ArrowRacer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ArrowRacer/"},{id:"CircleLeap",title:"Circle Leap",category:"Arcade",image:c("./games/CircleLeap.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircleLeap/"},{id:"ColorMatcher",title:"Color Matcher",category:"Arcade",image:c("./games/ColorMatcher.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorMatcher/"},{id:"EndlessMaze",title:"Endless Maze",category:"Arcade",image:c("./games/EndlessMaze.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/EndlessMaze/"},{id:"SpinningAround",title:"Spinning Around",category:"Arcade",image:c("./games/SpinningAround.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpinningAround/"},{id:"BoomBallz",title:"Boom Ballz",category:"Arcade",image:c("./games/BoomBallz.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BoomBallz/"},{id:"CubeHead",title:"Cube Head",category:"Arcade",image:c("./games/CubeHead.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CubeHead/"},{id:"CapybaraLink",title:"Capybara Link",category:"Puzzle",image:c("./games/CapybaraLink.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CapybaraLink/"},{id:"Snake2048",title:"Snake 2048",category:"Puzzle",image:c("./games/Snake2048.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Snake2048/"},{id:"FishTankFury",title:"Fish Tank Fury",category:"Puzzle",image:c("./games/FishTankFury.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FishTankFury/"},{id:"ConnectBalls",title:"Connect Balls",category:"Arcade",image:c("./games/ConnectBalls.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ConnectBalls/"},{id:"CircularBreaker",title:"Circular Breaker",category:"Arcade",image:c("./games/CircularBreaker.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircularBreaker/"},{id:"OneDoor",title:"One Door",category:"Arcade",image:c("./games/OneDoor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/OneDoor/"},{id:"CatchtheFruits",title:"Catch the Fruits",category:"Casual",image:c("./games/CatchtheFruits.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CatchtheFruits/"},{id:"Falling2048",title:"Falling 2048",category:"Casual",image:c("./games/Falling2048.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Falling2048/"}],M=X(Y),h=()=>M.filter(o=>o.enable);({Adventure:h().filter(o=>o.category==="Adventure"),Moba:h().filter(o=>o.category==="Moba")});var K=o=>M.find(e=>e.id===o);var z=()=>Array.from(new Set(h().map(o=>o.category)));var C="https://api.playsout.com",G=3e4;function Q(o){let e=String(o?.platform||"").toLowerCase();if(e==="tiktok"){let t=o.authorizationCode;if(typeof t!="string"||!t.trim())throw s("MISSING_PARAMS","authorizationCode is required for TikTok login");return {platform:e,authorizationCode:t}}if(e==="grab"||e==="eros"){let t=o;if(typeof t.platformUserId!="string"||!t.platformUserId.trim())throw s("MISSING_PARAMS","platformUserId is required for Grab/Eros login");if(typeof t.platformToken!="string"||!t.platformToken.trim())throw s("MISSING_PARAMS","platformToken is required for Grab/Eros login");if(typeof t.username!="string"||!t.username.trim())throw s("MISSING_PARAMS","username is required for Grab/Eros login");return {platform:e,platformUserId:t.platformUserId,platformToken:t.platformToken,username:t.username,inviteCode:typeof t.inviteCode=="string"?t.inviteCode:void 0}}throw s("INVALID_PARAMS","Unsupported platform. Expected grab, eros, or tiktok")}var S=null,v=null,O=null,b=null;function B(o){v=o;}function q(o){O=o;}function W(o){b=o;}function H(){if(b)try{b();}catch{}}async function ee(o){if(!O)throw H(),o instanceof E?o:s("TOKEN_EXPIRED",o);try{return await O()}catch(e){throw H(),e instanceof E?e:s("TOKEN_EXPIRED",e)}}async function j(o,e={},t,r=false,i=r){let c=t?.apiBaseUrl||C,p=o.startsWith("http")?o:`${c}${o}`,g=new AbortController,f=setTimeout(()=>g.abort(),G);try{let d=l.getJSON(u.TOKEN_DATA),A={"Content-Type":"application/json",...e.headers};r&&d?.accessToken&&!A.token&&(A.token=d.accessToken);let I=await fetch(p,{...e,signal:g.signal,headers:A});if(clearTimeout(f),!I.ok){if(I.status===401&&r&&i)return await F(o,e,t);throw s(I.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${I.status}: ${I.statusText}`)}let D=await I.json();if(D.code!==1e4){if(r&&i)return await F(o,e,t);throw s("API_ERROR",D.msg||"API request failed")}return D.data}catch(d){throw clearTimeout(f),d instanceof E?d:d instanceof Error?d.name==="AbortError"?s("TIMEOUT"):s("NETWORK_ERROR",d.message):s("UNKNOWN")}}async function F(o,e,t){await J(t);let r=t?.apiBaseUrl||C,i=o.startsWith("http")?o:`${r}${o}`,c=new AbortController,p=setTimeout(()=>c.abort(),G);try{let g=l.getJSON(u.TOKEN_DATA),f={"Content-Type":"application/json",...e.headers};g?.accessToken&&(f.token=g.accessToken);let d=await fetch(i,{...e,signal:c.signal,headers:f});if(clearTimeout(p),!d.ok)throw s(d.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${d.status}: ${d.statusText}`);let A=await d.json();if(A.code!==1e4)throw s("API_ERROR",A.msg||"API request failed");return A.data}catch(g){throw clearTimeout(p),g instanceof E?g:g instanceof Error&&g.name==="AbortError"?s("TIMEOUT"):s("NETWORK_ERROR",g?.message||"Request failed")}}async function J(o){if(S)return S;let e=(async()=>{try{let t=l.getJSON(u.TOKEN_DATA),r=Math.floor(Date.now()/1e3);if(!t?.refreshToken||t.refreshExpiresAt<=r)throw s("TOKEN_EXPIRED","Refresh token has expired");let i=o?.apiBaseUrl||C,c=new AbortController,p=setTimeout(()=>c.abort(),G);try{let g=await fetch(`${i}/platform/refreshToken`,{method:"POST",signal:c.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t.refreshToken})});if(clearTimeout(p),!g.ok)throw g.status>=500?s("SERVER_ERROR",`HTTP ${g.status}: ${g.statusText}`):s("TOKEN_EXPIRED",`HTTP ${g.status}: ${g.statusText}`);let f=await g.json();if(f.code!==1e4||!f.data)throw s("TOKEN_EXPIRED",f.msg||"Failed to refresh token");let d=f.data;if(l.setJSON(u.TOKEN_DATA,d),v)try{v(d);}catch{}return d}catch(g){throw clearTimeout(p),g instanceof E?g:g instanceof Error&&g.name==="AbortError"?s("TIMEOUT"):s("NETWORK_ERROR",g?.message||"Refresh token failed")}}catch(t){return await ee(t)}})();S=e;try{return await e}finally{S===e&&(S=null);}}var U=class{constructor(){this.config=null;}configure(e){this.config=e;}async refreshToken(){return await J(this.config||void 0)}async getGames(e){let t=h();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){let e=h(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],c)=>({id:`category_${c}`,name:r,count:i}))}async getGameById(e){return K(e)}async getCategoryNames(){return z()}async loginOnly(e){let t=Q(e);return await j("/platform/login",{method:"POST",body:JSON.stringify(t)},this.config??void 0)}async Login(e){let t=await this.loginOnly(e);l.setJSON(u.TOKEN_DATA,t);try{let r=await this.getUserInfo(!1);return {tokenData:t,user:r}}catch(r){throw l.remove(u.TOKEN_DATA),l.remove(u.USER),r}}async getUserInfo(e=true){return await j("/platform/user",{method:"GET"},this.config??void 0,true,e)}async getUser(){return l.getJSON(u.USER)}async validateToken(e){return !!e}},L=null;function k(){return L||(L=new U),L}var te="https://api.playsout.com",$="zh",w=class o{constructor(){this.config=null;this._isInitialized=false;this._user=null;this._token=null;this._locale=$;this._widget=null;}clearAuthState(){let e=!!(this._token||l.get(u.TOKEN_DATA)||l.get(u.USER));return this._user=null,this._token=null,l.remove(u.TOKEN_DATA),l.remove(u.USER),l.remove(u.LOGIN_PARAMS),e}updateUser(e){this._user={userId:String(e.id),username:e.username},l.setJSON(u.USER,this._user);}saveLoginParams(e){if(e.platform==="grab"||e.platform==="eros"){l.setJSON(u.LOGIN_PARAMS,{...e});return}l.remove(u.LOGIN_PARAMS);}async performLogin(e,t){let r=k();r.configure(this.config);let i=await r.loginOnly(e);l.setJSON(u.TOKEN_DATA,i);let c=await r.getUserInfo(false);return this._token=i.accessToken,this.updateUser(c),t&&this.saveLoginParams(e),b$1.emit("login",{user:this._user,token:this._token}),{tokenData:i,user:c}}async recoverAuthentication(){let e=l.getJSON(u.LOGIN_PARAMS);if(!e||e.platform!=="grab"&&e.platform!=="eros")throw s("TOKEN_EXPIRED","No reusable login parameters available");return (await this.performLogin(e,false)).tokenData}handleAuthExpired(){this.clearAuthState()&&b$1.emit("authExpired"),this.config?.debug&&console.warn("[PlaysoutSDK] Auth expired, logged out");}static getInstance(){return o.instance||(o.instance=new o),o.instance}async init(e={}){if(this._isInitialized)throw s("ALREADY_INITIALIZED");this.config={apiBaseUrl:e.apiBaseUrl||te,debug:e.debug||false,storage:e.storage||"localStorage",locale:e.locale||$,appId:e.appId||""},l.configure(this.config.storage),B(i=>{this._token=i.accessToken;}),q(()=>this.recoverAuthentication()),W(()=>{this.handleAuthExpired();});let t=l.getJSON(u.TOKEN_DATA);this._user=l.getJSON(u.USER),this._locale=l.get(u.LOCALE)||this.config.locale;let r=Math.floor(Date.now()/1e3);if(t){let i=k();if(i.configure(this.config),t.accessToken&&t.expiresAt>r?this._token=t.accessToken:await i.refreshToken(),this._token&&!this._user){let c=await i.getUserInfo();this.updateUser(c);}}else this._user&&(this._user=null,l.remove(u.USER));this._isInitialized=true,this.config.debug&&(console.log("[PlaysoutSDK] Initialized with config:",this.config),console.log("[PlaysoutSDK] Restored token:",this._token?this._token.substring(0,20)+"...":"(none)")),b$1.emit("initialized");}destroy(){this.config=null,this._isInitialized=false,this._user=null,this._token=null,l.clear(),b$1.clear();}get isInitialized(){return this._isInitialized}get isLoggedIn(){return !!(this._token&&this._user)}get user(){return this._user}get token(){return this._token}get locale(){return this._locale}get sdkConfig(){return this.config}async Login(e){this.ensureInitialized(),this.config?.debug&&console.log("[PlaysoutSDK] Login with params:",e);try{let t=await this.performLogin(e,!0);return this.config?.debug&&console.log("[PlaysoutSDK] Login success, user:",t.user),t}catch(t){throw this.clearAuthState(),t}}async getUserInfo(){if(this.ensureInitialized(),!this.isLoggedIn)throw s("NOT_LOGGED_IN","Please login first");let e=k();e.configure(this.config);let t=await e.getUserInfo();return this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo result:",t),t&&this.updateUser(t),t}logout(){this.clearAuthState(),b$1.emit("logout");}getToken(){return this.ensureInitialized(),this._token}getUser(){return this.ensureInitialized(),this._user}setLocale(e){if(this.ensureInitialized(),!["zh","en","ja","ko","vi","th","id","ms"].includes(e))throw s("INVALID_PARAMS",`Unsupported locale: ${e}`);this._locale=e,l.set(u.LOCALE,e),this.config?.debug&&console.log("[PlaysoutSDK] Locale changed to:",e);let t=this._widget||document.querySelector("playsout-widget");t&&t.getAttribute("locale")!==e&&t.setAttribute("locale",e),b$1.emit("localeChange",e);}getLocale(){return this.ensureInitialized(),this._locale}async getGames(e){this.ensureInitialized();let t=h();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){this.ensureInitialized();let e=h(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],c)=>({id:`category_${c}`,name:r,count:i}))}async getGameById(e){return this.ensureInitialized(),h().find(t=>t.id===e)}mount(e,t){if(this.ensureInitialized(),typeof document>"u")throw s("FEATURE_NOT_SUPPORTED","mount requires DOM environment");let r=document.querySelector(e);if(!r)throw s("INVALID_PARAMS",`Container not found: ${e}`);let i=document.createElement("playsout-widget");this.config?.appId&&i.setAttribute("app-id",this.config.appId),i.setAttribute("locale",t?.locale||this._locale),t?.detailMode&&i.setAttribute("detail-mode",t.detailMode),this._widget=i,t?.onGameClick&&i.addEventListener("game-click",c=>{let p=c;t.onGameClick(p.detail);}),t?.onLoginRequired&&i.addEventListener("login-required",t.onLoginRequired),t?.onLocaleChange&&i.addEventListener("locale-change",c=>{let p=c;t.onLocaleChange(p.detail);}),r.appendChild(i),this.config?.debug&&console.log("[PlaysoutSDK] Widget mounted to:",e);}unmount(){let e=document.querySelector("playsout-widget");e&&e.remove(),this._widget=null;}on(e,t){return this.ensureInitialized(),b$1.on(e,t)}off(e,t){this.ensureInitialized(),b$1.off(e,t);}ensureInitialized(){if(!this._isInitialized)throw s("NOT_INITIALIZED")}},a=w.getInstance(),Te=a;typeof window<"u"&&(window.__playsout_sdk_instance=a);var we=Object.freeze({init:a.init.bind(a),mount:a.mount.bind(a),unmount:a.unmount.bind(a),destroy:a.destroy.bind(a),Login:a.Login.bind(a),logout:a.logout.bind(a),getToken:a.getToken.bind(a),getUserInfo:a.getUserInfo.bind(a),getUser:a.getUser.bind(a),setLocale:a.setLocale.bind(a),getLocale:a.getLocale.bind(a),getGames:a.getGames.bind(a),getCategories:a.getCategories.bind(a),on:a.on.bind(a),off:a.off.bind(a),get isInitialized(){return a.isInitialized},get isLoggedIn(){return a.isLoggedIn},instance:a,PlaysoutSDKClass:w});
|
|
2
|
+
export{N as a,E as b,l as c,u as d,w as e,a as f,Te as g,we as h};
|
package/core/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SDKConfig, Game, Category, GetGamesParams, User, PlatformLoginParams, PlatformLoginResult, PlatformUserInfo, TokenData } from './types';
|
|
2
2
|
export declare function setTokenRefreshListener(listener: (tokenData: TokenData) => void): void;
|
|
3
|
+
export declare function setAuthRecoveryListener(listener: () => Promise<TokenData>): void;
|
|
3
4
|
export declare function setAuthExpiredListener(listener: () => void): void;
|
|
4
5
|
export declare class SDKAPI {
|
|
5
6
|
private config;
|
|
@@ -11,7 +12,7 @@ export declare class SDKAPI {
|
|
|
11
12
|
getCategoryNames(): Promise<string[]>;
|
|
12
13
|
loginOnly(params: PlatformLoginParams): Promise<TokenData>;
|
|
13
14
|
Login(params: PlatformLoginParams): Promise<PlatformLoginResult>;
|
|
14
|
-
getUserInfo(): Promise<PlatformUserInfo>;
|
|
15
|
+
getUserInfo(allowAuthRecovery?: boolean): Promise<PlatformUserInfo>;
|
|
15
16
|
getUser(): Promise<User | null>;
|
|
16
17
|
validateToken(token: string): Promise<boolean>;
|
|
17
18
|
}
|
package/core/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/core/api.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,SAAS,EAET,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACV,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/core/api.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,SAAS,EAET,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACV,MAAM,SAAS,CAAC;AA4FjB,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,IAAI,CAEtF;AAKD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAEhF;AAMD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAEjE;AAqPD,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAA0B;IAKxC,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAS5B,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;IAQlC,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAuClD,aAAa,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAmBpC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IAOlD,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAOrC,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC;IAY1D,KAAK,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmBhE,WAAW,CAAC,iBAAiB,UAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAUhE,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAO/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAIrD;AAKD,wBAAgB,SAAS,IAAI,MAAM,CAKlC"}
|
package/core/index.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export declare class PlaysoutSDK {
|
|
|
9
9
|
private _widget;
|
|
10
10
|
private constructor();
|
|
11
11
|
private clearAuthState;
|
|
12
|
+
private updateUser;
|
|
13
|
+
private saveLoginParams;
|
|
14
|
+
private performLogin;
|
|
15
|
+
private recoverAuthentication;
|
|
12
16
|
private handleAuthExpired;
|
|
13
17
|
static getInstance(): PlaysoutSDK;
|
|
14
18
|
init(config?: SDKConfig): Promise<void>;
|
package/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,mBAAmB,EAEnB,mBAAmB,EACnB,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AAoBjB,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IAErC,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,OAAO,CAAmC;IAGlD,OAAO,CAAC,OAAO,CAA4B;IAE3C,OAAO;IAEP,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,eAAe;YAUT,YAAY;YAwBZ,qBAAqB;IAUnC,OAAO,CAAC,iBAAiB;IAczB,MAAM,CAAC,WAAW,IAAI,WAAW;IAW3B,IAAI,CAAC,MAAM,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAqEjD,OAAO,IAAI,IAAI;IAYf,IAAI,aAAa,IAAI,OAAO,CAE3B;IAGD,IAAI,UAAU,IAAI,OAAO,CAExB;IAGD,IAAI,IAAI,IAAI,IAAI,GAAG,IAAI,CAEtB;IAGD,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAGD,IAAI,MAAM,IAAI,eAAe,CAE5B;IAGD,IAAI,SAAS,IAAI,SAAS,GAAG,IAAI,CAEhC;IAQK,KAAK,C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,WAAW,GAAG,IAAI;CAGnC,CAAC;AAKF,eAAO,MAAM,YAAY;;;;;;CAMf,CAAC"}
|
package/core/types.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface TikTokLoginParams {
|
|
|
29
29
|
export type PlatformLoginParams = GrabErosLoginParams | TikTokLoginParams;
|
|
30
30
|
export interface PlatformLoginResult {
|
|
31
31
|
tokenData: TokenData;
|
|
32
|
-
user
|
|
32
|
+
user: PlatformUserInfo;
|
|
33
33
|
}
|
|
34
34
|
export interface PlatformUserInfo {
|
|
35
35
|
id: number;
|
package/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAG3C,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAGpF,MAAM,WAAW,SAAS;IAExB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AAGvE,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAElC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B,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CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CACpD;AAMD,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAGD,MAAM,WAAW,QAAQ;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;CAC1B"}
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkNHFWJCNJ_cjs=require('./chunk-NHFWJCNJ.cjs'),chunkZ2CIDSTP_cjs=require('./chunk-Z2CIDSTP.cjs');Object.defineProperty(exports,"ErrorCode",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.a}});Object.defineProperty(exports,"Playsout",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.h}});Object.defineProperty(exports,"PlaysoutSDK",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.e}});Object.defineProperty(exports,"SDKError",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.b}});Object.defineProperty(exports,"STORAGE_KEYS",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.d}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.g}});Object.defineProperty(exports,"sdk",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.f}});Object.defineProperty(exports,"storage",{enumerable:true,get:function(){return chunkNHFWJCNJ_cjs.c}});Object.defineProperty(exports,"SDKEvent",{enumerable:true,get:function(){return chunkZ2CIDSTP_cjs.a}});Object.defineProperty(exports,"eventEmitter",{enumerable:true,get:function(){return chunkZ2CIDSTP_cjs.b}});
|