playsout-web-sdk 1.0.62 → 1.0.63
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 +206 -366
- package/dist/arrow-DVB3ZH4I.png +0 -0
- package/dist/bofang-7CYHXAOR.png +0 -0
- package/dist/chunk-DXJDUM6W.js +2 -0
- package/dist/chunk-FQSZP2MS.cjs +2 -0
- package/dist/chunk-GZLJ3BX5.js +1929 -0
- package/dist/chunk-RBKA52ZP.cjs +1929 -0
- package/dist/chunk-VZ5ZVHY4.js +2 -0
- package/dist/chunk-ZWHQXIXN.cjs +2 -0
- package/dist/clock-UCOJBATJ.png +0 -0
- package/dist/comment-CYSCAN7M.png +0 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -0
- package/{core → dist/core}/api.d.ts +1 -5
- package/dist/core/api.d.ts.map +1 -0
- package/{core → dist/core}/errors.d.ts +1 -4
- package/dist/core/errors.d.ts.map +1 -0
- package/{core → dist/core}/events.d.ts +1 -9
- package/{core → dist/core}/events.d.ts.map +1 -1
- package/{core → dist/core}/index.d.ts.map +1 -1
- package/{core → dist/core}/storage.d.ts +0 -1
- package/{core → dist/core}/storage.d.ts.map +1 -1
- package/{core → dist/core}/types.d.ts +2 -37
- package/dist/core/types.d.ts.map +1 -0
- package/dist/data/games.d.ts +3 -0
- package/dist/data/games.d.ts.map +1 -0
- package/dist/fenxiang-SHOVHZII.png +0 -0
- package/dist/index.cjs +1 -0
- package/{index.d.ts → dist/index.d.ts} +1 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +1929 -0
- package/dist/index.iife.js +1929 -0
- package/{index.js → dist/index.js} +1 -1
- package/dist/like-UTHO5POC.png +0 -0
- package/dist/live-like-4WE6H52V.png +0 -0
- package/dist/next-T6TSGXOI.png +0 -0
- package/dist/react/PlaysoutVideoWidget.d.ts +16 -0
- package/dist/react/PlaysoutVideoWidget.d.ts.map +1 -0
- package/dist/react/index.cjs +1 -0
- package/{react → dist/react}/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +1 -0
- package/dist/share-2WNZMMZ6.png +0 -0
- package/dist/shoucang-CSI3UBYK.png +0 -0
- package/dist/shuqian-KOBOMTMJ.png +0 -0
- package/dist/shuqian1-VMWYGXP3.png +0 -0
- package/dist/vue/PlaysoutVideoWidget.d.ts +31 -0
- package/dist/vue/PlaysoutVideoWidget.d.ts.map +1 -0
- package/{vue → dist/vue}/composable.d.ts +4 -2
- package/{vue → dist/vue}/composable.d.ts.map +1 -1
- package/dist/vue/index.cjs +1 -0
- package/{vue → dist/vue}/index.d.ts +1 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +1 -0
- package/dist/web-components/PlaysoutVideoWidget.d.ts +59 -0
- package/dist/web-components/PlaysoutVideoWidget.d.ts.map +1 -0
- package/{web-components → dist/web-components}/PlaysoutWidget.d.ts +6 -3
- package/dist/web-components/PlaysoutWidget.d.ts.map +1 -0
- package/dist/web-components/index.cjs +1 -0
- package/dist/web-components/index.d.ts +5 -0
- package/dist/web-components/index.d.ts.map +1 -0
- package/dist/web-components/index.js +1 -0
- package/package.json +77 -63
- package/chunk-EZLO3WY6.js +0 -2
- package/chunk-MDSUYVLI.cjs +0 -2
- package/chunk-Z2CIDSTP.cjs +0 -2
- package/chunk-Z5PDR5PA.js +0 -2
- package/core/api.d.ts.map +0 -1
- package/core/errors.d.ts.map +0 -1
- package/core/types.d.ts.map +0 -1
- package/data/games.d.ts +0 -30
- package/data/games.d.ts.map +0 -1
- package/index.cjs +0 -1
- package/index.d.ts.map +0 -1
- package/index.global.js +0 -1546
- package/index.iife.js +0 -1546
- package/react/index.cjs +0 -1
- package/react/index.d.ts.map +0 -1
- package/react/index.js +0 -1
- package/vue/index.cjs +0 -1
- package/vue/index.d.ts.map +0 -1
- package/vue/index.js +0 -1
- package/web-components/PlaysoutWidget.d.ts.map +0 -1
- package/web-components/imageCache.d.ts +0 -13
- package/web-components/imageCache.d.ts.map +0 -1
- package/web-components/index.cjs +0 -1546
- package/web-components/index.d.ts +0 -3
- package/web-components/index.d.ts.map +0 -1
- package/web-components/index.js +0 -1546
- /package/{core → dist/core}/index.d.ts +0 -0
- /package/{iife-entry.d.ts → dist/iife-entry.d.ts} +0 -0
- /package/{iife-entry.d.ts.map → dist/iife-entry.d.ts.map} +0 -0
- /package/{public-api.d.ts → dist/public-api.d.ts} +0 -0
- /package/{public-api.d.ts.map → dist/public-api.d.ts.map} +0 -0
- /package/{react → dist/react}/context.d.ts +0 -0
- /package/{react → dist/react}/context.d.ts.map +0 -0
- /package/{vue → dist/vue}/plugin.d.ts +0 -0
- /package/{vue → dist/vue}/plugin.d.ts.map +0 -0
- /package/{web-components → dist/web-components}/PrivyBridge.d.ts +0 -0
- /package/{web-components → dist/web-components}/PrivyBridge.d.ts.map +0 -0
- /package/{web-components → dist/web-components}/assetUrl.d.ts +0 -0
- /package/{web-components → dist/web-components}/assetUrl.d.ts.map +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {c as c$1,b as b$1}from'./chunk-DXJDUM6W.js';var b=(d=>(d.NOT_INITIALIZED="NOT_INITIALIZED",d.ALREADY_INITIALIZED="ALREADY_INITIALIZED",d.NOT_LOGGED_IN="NOT_LOGGED_IN",d.TOKEN_EXPIRED="TOKEN_EXPIRED",d.NETWORK_ERROR="NETWORK_ERROR",d.TIMEOUT="TIMEOUT",d.SERVER_ERROR="SERVER_ERROR",d.API_ERROR="API_ERROR",d.INVALID_PARAMS="INVALID_PARAMS",d.MISSING_PARAMS="MISSING_PARAMS",d.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",d.UNKNOWN="UNKNOWN",d))(b||{}),y=class extends Error{constructor(t,o,i){super(o);this.code=t;this.details=i;this.name="SDKError";}toJSON(){return {name:this.name,code:this.code,message:this.message,details:this.details}}},q={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.",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."};function n(r,e){return new y(r,q[r],e)}var w="playsout_",R=class{constructor(e){this.storage=e;}get(e){try{return this.storage.getItem(w+e)}catch{return null}}set(e,t){try{this.storage.setItem(w+e,t);}catch(o){console.warn("[PlaysoutSDK] Storage set failed:",o);}}remove(e){try{this.storage.removeItem(w+e);}catch{}}clear(){try{let e=[];for(let t=0;t<this.storage.length;t++){let o=this.storage.key(t);o&&o.startsWith(w)&&e.push(o);}e.forEach(t=>this.storage.removeItem(t));}catch{}}},N=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(r="localStorage"){return typeof window>"u"||r==="memory"?new N:r==="sessionStorage"?new R(sessionStorage):new R(localStorage)}var E=x(),l={get:r=>E.get(r),set:(r,e)=>{E.set(r,e);},remove:r=>{E.remove(r);},clear:()=>{E.clear();},getJSON:r=>{let e=E.get(r);if(!e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(r,e)=>{E.set(r,JSON.stringify(e));},configure(r){E=x(r);}},c={TOKEN_DATA:"token_data",USER:"user",LOGIN_PARAMS:"login_params",LOCALE:"locale"};var W=r=>{if(!r)return r;try{let e=new URL(r);if(e.hostname==="games.playsout.com"){let t=e.pathname,o=t.endsWith("/"),i=/\.[a-z0-9]+$/i.test(t);!o&&!i&&(e.pathname=`${t}/`);}return e.toString()}catch{return r}},Z=r=>r.map(e=>{if(!e.externalUrl)return e;let t=W(e.externalUrl);return t===e.externalUrl?e:{...e,externalUrl:t}}),J=[{id:"BlockCrushFun",title:"Block Crush Fun",category:"Puzzle",image:c$1("./games/BlockCrushFun.png"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/BlockCrushFun/"},{id:"KittyEscape",title:"Kitty Escape",category:"Puzzle",image:c$1("./games/KittyEscape.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/KittyEscape/"},{id:"ProjectGarden",title:"Project: Garden",category:"Adventure",image:c$1("./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$1("./games/ProjectIDLE.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/idle/"},{id:"SoccerDASH",title:"Soccer Dash",category:"Arcade",image:c$1("./games/Soccer Dash.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/SoccerDASH/"},{id:"SoccerSurvivor",title:"Soccer Survivor",category:"Arcade",image:c$1("./games/SoccerSurvivor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/SoccerSurvivors/"},{id:"CulinaryStarWeb",title:"Culinary Star",category:"Casual",image:c$1("./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$1("./games/PickaxeQuest.jpg"),description:"Mining and adventure game",isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/PickaxeQuest/",apiGameId:73},{id:"MonsterSurvivors",title:"Monster Survivors",category:"Adventure",image:c$1("./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$1("./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$1("./games/MushroomWarriors.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/MushroomWarriors/"},{id:"FollowThePath",title:"Follow The Path",category:"Arcade",image:c$1("./games/FollowThePath.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/FollowThePath/"},{id:"SoccerCascade",title:"Soccer Cascade",category:"Arcade",image:c$1("./games/Soccer Cascade.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/SoccerCascade/"},{id:"CatDelta",title:"Cat Delta",category:"Adventure",image:c$1("./games/CatDelta.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/CatDelta/"},{id:"ColorRun",title:"Color Run",category:"Arcade",image:c$1("./games/ColorRun.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/ColorRun/"},{id:"SoccerZombies",title:"Soccer vs. Zombies",category:"Tower Defense",image:c$1("./games/Soccer vs. Zombies.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/SoccerZombies/"},{id:"MiniSoccer",title:"Mini Soccer",category:"Arcade",image:c$1("./games/minisoccer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/minisoccer/"},{id:"SoccerMaze",title:"Soccer Maze",category:"Arcade",image:c$1("./games/Soccer Maze.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/SoccerMaze/"},{id:"StupidArrow",title:"Stupid Arrow",category:"Arcade",image:c$1("./games/StupidArrow.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/StupidArrow/"},{id:"ZigZag",title:"Zig Zag",category:"Arcade",image:c$1("./games/ZigZag.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/ZigZag/"},{id:"SpikesEverywhere",title:"Spikes Everywhere",category:"Arcade",image:c$1("./games/SpikesEverywhere.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/SpikesEverywhere/"},{id:"ArrowRacer",title:"Arrow Racer",category:"Arcade",image:c$1("./games/ArrowRacer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/ArrowRacer/"},{id:"CircleLeap",title:"Circle Leap",category:"Arcade",image:c$1("./games/CircleLeap.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/CircleLeap/"},{id:"ColorMatcher",title:"Color Matcher",category:"Arcade",image:c$1("./games/ColorMatcher.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/ColorMatcher/"},{id:"EndlessMaze",title:"Endless Maze",category:"Arcade",image:c$1("./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$1("./games/SpinningAround.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/SpinningAround/"},{id:"BoomBallz",title:"Boom Ballz",category:"Arcade",image:c$1("./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$1("./games/CubeHead.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/CubeHead/"},{id:"CapybaraLink",title:"Capybara Link",category:"Puzzle",image:c$1("./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$1("./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$1("./games/FishTankFury.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/FishTankFury/"},{id:"ConnectBalls",title:"Connect Balls",category:"Arcade",image:c$1("./games/ConnectBalls.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/ConnectBalls/"},{id:"CircularBreaker",title:"Circular Breaker",category:"Arcade",image:c$1("./games/CircularBreaker.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/CircularBreaker/"},{id:"OneDoor",title:"One Door",category:"Arcade",image:c$1("./games/OneDoor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/OneDoor/"},{id:"CatchtheFruits",title:"Catch the Fruits",category:"Casual",image:c$1("./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$1("./games/Falling2048.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/grab/Falling2048/"}],$=Z(J),V=r=>r.enable!==false&&r.isEnabled!==false,P=()=>$.filter(V);var O="https://api.playsout.com",C=3e4;function X(r){let e=String(r?.platform||"").toLowerCase();if(e==="tiktok"){let t=r.authorizationCode;if(typeof t!="string"||!t.trim())throw n("MISSING_PARAMS","authorizationCode is required for TikTok login");return {platform:e,authorizationCode:t}}if(e==="grab"||e==="eros"){let t=r;if(typeof t.platformUserId!="string"||!t.platformUserId.trim())throw n("MISSING_PARAMS","platformUserId is required for Grab/Eros login");if(typeof t.platformToken!="string"||!t.platformToken.trim())throw n("MISSING_PARAMS","platformToken is required for Grab/Eros login");if(typeof t.username!="string"||!t.username.trim())throw n("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 n("INVALID_PARAMS","Unsupported platform. Expected grab, eros, or tiktok")}var A=null,D=null,v=null,U=null;function G(r){D=r;}function H(r){v=r;}function j(r){U=r;}function K(){if(U)try{U();}catch{}}async function Y(r){if(!v)throw K(),r instanceof y?r:n("TOKEN_EXPIRED",r);try{return await v()}catch(e){throw K(),e instanceof y?e:n("TOKEN_EXPIRED",e)}}async function M(r,e={},t,o=false,i=o){let m=t?.apiBaseUrl||O,p=r.startsWith("http")?r:`${m}${r}`,u=new AbortController,f=setTimeout(()=>u.abort(),C);try{let g=l.getJSON(c.TOKEN_DATA),S={"Content-Type":"application/json",...e.headers};o&&g?.accessToken&&!S.token&&(S.token=g.accessToken);let T=await fetch(p,{...e,signal:u.signal,headers:S});if(clearTimeout(f),!T.ok){if(T.status===401&&o&&i)return await z(r,e,t);throw n(T.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${T.status}: ${T.statusText}`)}let d=await T.json();if(d.code!==1e4){if(o&&i)return await z(r,e,t);throw n("API_ERROR",d.msg||"API request failed")}return d.data}catch(g){throw clearTimeout(f),g instanceof y?g:g instanceof Error?g.name==="AbortError"?n("TIMEOUT"):n("NETWORK_ERROR",g.message):n("UNKNOWN")}}async function z(r,e,t){await F(t);let o=t?.apiBaseUrl||O,i=r.startsWith("http")?r:`${o}${r}`,m=new AbortController,p=setTimeout(()=>m.abort(),C);try{let u=l.getJSON(c.TOKEN_DATA),f={"Content-Type":"application/json",...e.headers};u?.accessToken&&(f.token=u.accessToken);let g=await fetch(i,{...e,signal:m.signal,headers:f});if(clearTimeout(p),!g.ok)throw n(g.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${g.status}: ${g.statusText}`);let S=await g.json();if(S.code!==1e4)throw n("API_ERROR",S.msg||"API request failed");return S.data}catch(u){throw clearTimeout(p),u instanceof y?u:u instanceof Error&&u.name==="AbortError"?n("TIMEOUT"):n("NETWORK_ERROR",u?.message||"Request failed")}}async function F(r){if(A)return A;let e=(async()=>{try{let t=l.getJSON(c.TOKEN_DATA),o=Math.floor(Date.now()/1e3);if(!t?.refreshToken||t.refreshExpiresAt<=o)throw n("TOKEN_EXPIRED","Refresh token has expired");let i=r?.apiBaseUrl||O,m=new AbortController,p=setTimeout(()=>m.abort(),C);try{let u=await fetch(`${i}/platform/refreshToken`,{method:"POST",signal:m.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t.refreshToken})});if(clearTimeout(p),!u.ok)throw u.status>=500?n("SERVER_ERROR",`HTTP ${u.status}: ${u.statusText}`):n("TOKEN_EXPIRED",`HTTP ${u.status}: ${u.statusText}`);let f=await u.json();if(f.code!==1e4||!f.data)throw n("TOKEN_EXPIRED",f.msg||"Failed to refresh token");let g=f.data;if(l.setJSON(c.TOKEN_DATA,g),D)try{D(g);}catch{}return g}catch(u){throw clearTimeout(p),u instanceof y?u:u instanceof Error&&u.name==="AbortError"?n("TIMEOUT"):n("NETWORK_ERROR",u?.message||"Refresh token failed")}}catch(t){return await Y(t)}})();A=e;try{return await e}finally{A===e&&(A=null);}}var L=class{constructor(){this.config=null;}configure(e){this.config=e;}async refreshToken(){return await F(this.config||void 0)}async loginOnly(e){let t=X(e);return await M("/platform/login",{method:"POST",body:JSON.stringify(t)},this.config??void 0)}async Login(e){let t=await this.loginOnly(e);l.setJSON(c.TOKEN_DATA,t);try{let o=await this.getUserInfo(!1);return {tokenData:t,user:o}}catch(o){throw l.remove(c.TOKEN_DATA),l.remove(c.USER),o}}async getUserInfo(e=true){return await M("/platform/user",{method:"GET"},this.config??void 0,true,e)}async getUser(){return l.getJSON(c.USER)}async validateToken(e){return !!e}},_=null;function k(){return _||(_=new L),_}var Q="https://api.playsout.com",B="zh",I=class r{constructor(){this.config=null;this._isInitialized=false;this._user=null;this._token=null;this._locale=B;this._widget=null;}clearAuthState(){let e=!!(this._token||l.get(c.TOKEN_DATA)||l.get(c.USER));return this._user=null,this._token=null,l.remove(c.TOKEN_DATA),l.remove(c.USER),l.remove(c.LOGIN_PARAMS),e}updateUser(e){this._user={userId:String(e.id),username:e.username},l.setJSON(c.USER,this._user);}saveLoginParams(e){if(e.platform==="grab"||e.platform==="eros"){l.setJSON(c.LOGIN_PARAMS,{...e});return}l.remove(c.LOGIN_PARAMS);}async performLogin(e,t){let o=k();o.configure(this.config);let i=await o.loginOnly(e);l.setJSON(c.TOKEN_DATA,i);let m=await o.getUserInfo(false);return this._token=i.accessToken,this.updateUser(m),t&&this.saveLoginParams(e),b$1.emit("login",{user:this._user,token:this._token}),{tokenData:i,user:m}}async recoverAuthentication(){let e=l.getJSON(c.LOGIN_PARAMS);if(!e||e.platform!=="grab"&&e.platform!=="eros")throw n("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 r.instance||(r.instance=new r),r.instance}async init(e={}){if(this._isInitialized)throw n("ALREADY_INITIALIZED");this.config={apiBaseUrl:e.apiBaseUrl||Q,debug:e.debug||false,storage:e.storage||"localStorage",locale:e.locale||B},l.configure(this.config.storage),G(i=>{this._token=i.accessToken;}),H(()=>this.recoverAuthentication()),j(()=>{this.handleAuthExpired();});let t=l.getJSON(c.TOKEN_DATA);this._user=l.getJSON(c.USER),this._locale=l.get(c.LOCALE)||this.config.locale;let o=Math.floor(Date.now()/1e3);if(t){let i=k();if(i.configure(this.config),t.accessToken&&t.expiresAt>o?this._token=t.accessToken:await i.refreshToken(),this._token&&!this._user){let m=await i.getUserInfo();this.updateUser(m);}}else this._user&&(this._user=null,l.remove(c.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 n("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 n("INVALID_PARAMS",`Unsupported locale: ${e}`);this._locale=e,l.set(c.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=P();if(e?.category&&(t=t.filter(o=>o.category===e.category)),e?.search){let o=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(o)||i.category.toLowerCase().includes(o)||i.description&&i.description.toLowerCase().includes(o));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(o=>o.isNew).concat(t.filter(o=>!o.isNew));break;case "rating":t=t.filter(o=>o.isHot).concat(t.filter(o=>!o.isHot));break}if(e?.page&&e?.pageSize){let o=(e.page-1)*e.pageSize;t=t.slice(o,o+e.pageSize);}return t}async getCategories(){this.ensureInitialized();let e=P(),t=new Map;return e.forEach(o=>{if(!o.category)return;let i=t.get(o.category)||0;t.set(o.category,i+1);}),Array.from(t.entries()).map(([o,i])=>({id:o,name:o,count:i}))}async getGameById(e){return this.ensureInitialized(),P().find(t=>t.id===e)}mount(e,t){if(this.ensureInitialized(),typeof document>"u")throw n("FEATURE_NOT_SUPPORTED","mount requires DOM environment");let o=document.querySelector(e);if(!o)throw n("INVALID_PARAMS",`Container not found: ${e}`);let i=document.createElement("playsout-widget");i.setAttribute("locale",t?.locale||this._locale),t?.detailMode&&i.setAttribute("detail-mode",t.detailMode),this._widget=i,t?.onGameClick&&i.addEventListener("game-click",m=>{let p=m;t.onGameClick(p.detail);}),t?.onLoginRequired&&i.addEventListener("login-required",t.onLoginRequired),t?.onLocaleChange&&i.addEventListener("locale-change",m=>{let p=m;t.onLocaleChange(p.detail);}),o.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 n("NOT_INITIALIZED")}},s=I.getInstance(),pe=s;typeof window<"u"&&(window.__playsout_sdk_instance=s);var ye=Object.freeze({init:s.init.bind(s),mount:s.mount.bind(s),unmount:s.unmount.bind(s),destroy:s.destroy.bind(s),Login:s.Login.bind(s),logout:s.logout.bind(s),getToken:s.getToken.bind(s),getUserInfo:s.getUserInfo.bind(s),getUser:s.getUser.bind(s),setLocale:s.setLocale.bind(s),getLocale:s.getLocale.bind(s),getGames:s.getGames.bind(s),getCategories:s.getCategories.bind(s),on:s.on.bind(s),off:s.off.bind(s),get isInitialized(){return s.isInitialized},get isLoggedIn(){return s.isLoggedIn},instance:s,PlaysoutSDKClass:I});
|
|
2
|
+
export{b as a,y as b,l as c,c as d,I as e,s as f,pe as g,ye as h};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var i=(s=>(s.INITIALIZED="initialized",s.LOGIN="login",s.LOGOUT="logout",s.LOCALE_CHANGE="localeChange",s.ERROR="error",s.GAME_CLICK="gameClick",s.LOGIN_REQUIRED="loginRequired",s.AUTH_EXPIRED="authExpired",s))(i||{}),a=class{constructor(){this.events=new Map;}on(e,t){return this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t),()=>{this.off(e,t);}}once(e,t){let r=o=>{t(o),this.off(e,r);};return this.on(e,r)}off(e,t){this.events.get(e)?.delete(t),this.events.get(e)?.size===0&&this.events.delete(e);}emit(e,t){this.events.get(e)?.forEach(r=>{try{r(t);}catch(o){console.error(`[PlaysoutSDK] Event handler error for "${e}":`,o);}});}clear(){this.events.clear();}},c=new a;var l="https://games.playsout.com/resources/icon/image";function d(n){if(!n||/^(data:|https?:|blob:)/i.test(n))return n;let e=n.replace(/^\.\//,"");return `${l}/${e}`}
|
|
2
|
+
exports.a=i;exports.b=c;exports.c=d;
|
|
Binary file
|
|
Binary file
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,yCAAyC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SDKConfig,
|
|
1
|
+
import type { SDKConfig, User, PlatformLoginParams, PlatformLoginResult, PlatformUserInfo, TokenData } from './types';
|
|
2
2
|
export declare function setTokenRefreshListener(listener: (tokenData: TokenData) => void): void;
|
|
3
3
|
export declare function setAuthRecoveryListener(listener: () => Promise<TokenData>): void;
|
|
4
4
|
export declare function setAuthExpiredListener(listener: () => void): void;
|
|
@@ -6,10 +6,6 @@ export declare class SDKAPI {
|
|
|
6
6
|
private config;
|
|
7
7
|
configure(config: SDKConfig): void;
|
|
8
8
|
refreshToken(): Promise<TokenData>;
|
|
9
|
-
getGames(params?: GetGamesParams): Promise<Game[]>;
|
|
10
|
-
getCategories(): Promise<Category[]>;
|
|
11
|
-
getGameById(id: string): Promise<Game | undefined>;
|
|
12
|
-
getCategoryNames(): Promise<string[]>;
|
|
13
9
|
loginOnly(params: PlatformLoginParams): Promise<TokenData>;
|
|
14
10
|
Login(params: PlatformLoginParams): Promise<PlatformLoginResult>;
|
|
15
11
|
getUserInfo(allowAuthRecovery?: boolean): Promise<PlatformUserInfo>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/core/api.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,SAAS,EAET,IAAI,EACJ,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACV,MAAM,SAAS,CAAC;AA2FjB,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;IAOlC,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"}
|
|
@@ -3,7 +3,6 @@ export declare enum ErrorCode {
|
|
|
3
3
|
ALREADY_INITIALIZED = "ALREADY_INITIALIZED",
|
|
4
4
|
NOT_LOGGED_IN = "NOT_LOGGED_IN",
|
|
5
5
|
TOKEN_EXPIRED = "TOKEN_EXPIRED",
|
|
6
|
-
INVALID_TOKEN = "INVALID_TOKEN",
|
|
7
6
|
NETWORK_ERROR = "NETWORK_ERROR",
|
|
8
7
|
TIMEOUT = "TIMEOUT",
|
|
9
8
|
SERVER_ERROR = "SERVER_ERROR",
|
|
@@ -11,9 +10,7 @@ export declare enum ErrorCode {
|
|
|
11
10
|
INVALID_PARAMS = "INVALID_PARAMS",
|
|
12
11
|
MISSING_PARAMS = "MISSING_PARAMS",
|
|
13
12
|
FEATURE_NOT_SUPPORTED = "FEATURE_NOT_SUPPORTED",
|
|
14
|
-
UNKNOWN = "UNKNOWN"
|
|
15
|
-
PAYMENT_FAILED = "PAYMENT_FAILED",
|
|
16
|
-
SHARE_FAILED = "SHARE_FAILED"
|
|
13
|
+
UNKNOWN = "UNKNOWN"
|
|
17
14
|
}
|
|
18
15
|
export declare class SDKError extends Error {
|
|
19
16
|
code: ErrorCode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAQA,oBAAY,SAAS;IAGnB,eAAe,oBAAoB;IAEnC,mBAAmB,wBAAwB;IAI3C,aAAa,kBAAkB;IAE/B,aAAa,kBAAkB;IAG/B,aAAa,kBAAkB;IAE/B,OAAO,YAAY;IAEnB,YAAY,iBAAiB;IAE7B,SAAS,cAAc;IAIvB,cAAc,mBAAmB;IAEjC,cAAc,mBAAmB;IAIjC,qBAAqB,0BAA0B;IAE/C,OAAO,YAAY;CAEpB;AAKD,qBAAa,QAAS,SAAQ,KAAK;IAExB,IAAI,EAAE,SAAS;IAEf,OAAO,CAAC,EAAE,OAAO;gBAFjB,IAAI,EAAE,SAAS,EACtB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,OAAO,YAAA;IAM1B,MAAM;;;;;;CAQP;AAOD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAanD,CAAC;AAKF,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAE3E"}
|
|
@@ -15,16 +15,8 @@ declare class EventEmitter {
|
|
|
15
15
|
once<T = unknown>(event: string, callback: EventCallback<T>): () => void;
|
|
16
16
|
off(event: string, callback: EventCallback): void;
|
|
17
17
|
emit<T = unknown>(event: string, data?: T): void;
|
|
18
|
-
listenerCount(event: string): number;
|
|
19
18
|
clear(): void;
|
|
20
19
|
}
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const eventEmitter: {
|
|
23
|
-
on: <T = unknown>(event: string, callback: EventCallback<T>) => (() => void);
|
|
24
|
-
once: <T = unknown>(event: string, callback: EventCallback<T>) => (() => void);
|
|
25
|
-
off: (event: string, callback: EventCallback) => void;
|
|
26
|
-
clear: () => void;
|
|
27
|
-
emit: <T = unknown>(event: string, data?: T) => void;
|
|
28
|
-
};
|
|
20
|
+
export declare const eventEmitter: EventEmitter;
|
|
29
21
|
export {};
|
|
30
22
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;AAK3D,o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KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAWxE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAUjD,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI;IAahD,KAAK,IAAI,IAAI;CAGd;AAKD,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -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,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;
|
|
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,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OL,CAAC,OAAO,MAAM,KAAG,CAAC,GAAG,IAAI;cAazB,CAAC,OAAO,MAAM,SAAS,CAAC,KAAG,IAAI;oBAOzB,WAAW,GAAG,IAAI;CAGnC,CAAC;AAKF,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/core/storage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf;AAkFD,wBAAgB,aAAa,CAAC,IAAI,GAAE,WAA4B,GAAG,cAAc,CAYhF;AASD,eAAO,MAAM,OAAO;eAIP,MAAM,KAAG,MAAM,GAAG,IAAI;eAOtB,MAAM,SAAS,MAAM,KAAG,IAAI;kBAOzB,MAAM,KAAG,IAAI;iBAOhB,IAAI;cAOL,CAAC,OAAO,MAAM,KAAG,CAAC,GAAG,IAAI;cAazB,CAAC,OAAO,MAAM,SAAS,CAAC,KAAG,IAAI;oBAOzB,WAAW,GAAG,IAAI;CAGnC,CAAC;AAKF,eAAO,MAAM,YAAY;;;;;CAKf,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export declare const SDK_PACKAGE_NAME = "playsout";
|
|
2
1
|
export type SupportedLocale = 'zh' | 'en' | 'ja' | 'ko' | 'vi' | 'th' | 'id' | 'ms';
|
|
3
2
|
export interface SDKConfig {
|
|
4
|
-
appId?: string;
|
|
5
3
|
apiBaseUrl?: string;
|
|
6
4
|
debug?: boolean;
|
|
7
5
|
storage?: StorageType;
|
|
@@ -50,7 +48,8 @@ export interface Game {
|
|
|
50
48
|
isNew?: boolean;
|
|
51
49
|
isHot?: boolean;
|
|
52
50
|
isBanner?: boolean;
|
|
53
|
-
enable
|
|
51
|
+
enable?: boolean;
|
|
52
|
+
isEnabled?: boolean;
|
|
54
53
|
externalUrl?: string;
|
|
55
54
|
orientation?: 'portrait' | 'landscape';
|
|
56
55
|
apiGameId?: number;
|
|
@@ -68,27 +67,6 @@ export interface GetGamesParams {
|
|
|
68
67
|
pageSize?: number;
|
|
69
68
|
sortBy?: 'rating' | 'players' | 'newest';
|
|
70
69
|
}
|
|
71
|
-
export interface ShareParams {
|
|
72
|
-
title: string;
|
|
73
|
-
text: string;
|
|
74
|
-
url: string;
|
|
75
|
-
image?: string;
|
|
76
|
-
}
|
|
77
|
-
export interface ShareResult {
|
|
78
|
-
success: boolean;
|
|
79
|
-
platform?: string;
|
|
80
|
-
}
|
|
81
|
-
export interface PaymentParams {
|
|
82
|
-
gameId: string;
|
|
83
|
-
itemId: string;
|
|
84
|
-
amount: number;
|
|
85
|
-
currency?: string;
|
|
86
|
-
}
|
|
87
|
-
export interface PaymentResult {
|
|
88
|
-
orderId: string;
|
|
89
|
-
status: 'pending' | 'success' | 'failed';
|
|
90
|
-
transactionId?: string;
|
|
91
|
-
}
|
|
92
70
|
export interface APIResponse<T> {
|
|
93
71
|
code: number;
|
|
94
72
|
msg: string;
|
|
@@ -102,11 +80,6 @@ export interface MountOptions {
|
|
|
102
80
|
onLoginRequired?: () => void;
|
|
103
81
|
onLocaleChange?: (locale: SupportedLocale) => void;
|
|
104
82
|
}
|
|
105
|
-
export interface RefreshTokenResult {
|
|
106
|
-
accessToken: string;
|
|
107
|
-
refreshToken?: string;
|
|
108
|
-
expiresIn?: number;
|
|
109
|
-
}
|
|
110
83
|
export interface TokenData {
|
|
111
84
|
accessToken: string;
|
|
112
85
|
expiresIn: number;
|
|
@@ -115,12 +88,4 @@ export interface TokenData {
|
|
|
115
88
|
refreshExpiresIn: number;
|
|
116
89
|
refreshExpiresAt: number;
|
|
117
90
|
}
|
|
118
|
-
export interface SDKState {
|
|
119
|
-
isInitialized: boolean;
|
|
120
|
-
isLoggedIn: boolean;
|
|
121
|
-
user: User | null;
|
|
122
|
-
token: string | null;
|
|
123
|
-
locale: SupportedLocale;
|
|
124
|
-
config: SDKConfig | null;
|
|
125
|
-
}
|
|
126
91
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAMA,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,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,cAAc,EAAE,MAAM,CAAC;IAEvB,aAAa,EAAE,MAAM,CAAC;IAEtB,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,QAAQ,CAAC;IACnB,iBAAiB,EAAE,M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B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;CAC1C;AAGD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,YAAY;IAE3B,MAAM,CAAC,EAAE,eAAe,CAAC;IAEzB,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE/B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEnC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAE7B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CACpD;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"games.d.ts","sourceRoot":"","sources":["../../src/data/games.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAsb1C,eAAO,MAAM,eAAe,QAAO,IAAI,EAEtC,CAAC"}
|
|
Binary file
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkFQSZP2MS_cjs=require('./chunk-FQSZP2MS.cjs'),chunkZWHQXIXN_cjs=require('./chunk-ZWHQXIXN.cjs');Object.defineProperty(exports,"ErrorCode",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.a}});Object.defineProperty(exports,"Playsout",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.h}});Object.defineProperty(exports,"PlaysoutSDK",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.e}});Object.defineProperty(exports,"SDKError",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.b}});Object.defineProperty(exports,"STORAGE_KEYS",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.d}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.g}});Object.defineProperty(exports,"sdk",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.f}});Object.defineProperty(exports,"storage",{enumerable:true,get:function(){return chunkFQSZP2MS_cjs.c}});Object.defineProperty(exports,"SDKEvent",{enumerable:true,get:function(){return chunkZWHQXIXN_cjs.a}});Object.defineProperty(exports,"eventEmitter",{enumerable:true,get:function(){return chunkZWHQXIXN_cjs.b}});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { PlaysoutSDK, sdk, default } from './core';
|
|
2
2
|
export { Playsout } from './public-api';
|
|
3
3
|
export type { PlaysoutPublicAPI } from './public-api';
|
|
4
|
-
export type { SDKConfig, SupportedLocale, StorageType, User, PlatformType, GrabErosLoginParams, TikTokLoginParams, PlatformLoginParams, PlatformLoginResult, PlatformUserInfo,
|
|
4
|
+
export type { SDKConfig, SupportedLocale, StorageType, User, PlatformType, GrabErosLoginParams, TikTokLoginParams, PlatformLoginParams, PlatformLoginResult, PlatformUserInfo, Game, Category, GetGamesParams, APIResponse, MountOptions, } from './core/types';
|
|
5
5
|
export { SDKError, ErrorCode } from './core/errors';
|
|
6
6
|
export type { StorageAdapter } from './core/storage';
|
|
7
7
|
export { storage, STORAGE_KEYS } from './core/storage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,YAAY,EACV,SAAS,EACT,eAAe,EACf,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|