@idosgames/core 0.22.1 → 0.24.0
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/CHANGELOG.md +7 -0
- package/dist/{VoiceController-JKfvxpjs.d.ts → VoiceController-5wloz5B8.d.ts} +180 -79
- package/dist/{VoiceController-ClFmHUGH.d.cts → VoiceController-B6naztyl.d.cts} +180 -79
- package/dist/chunk-LWS7EEOF.js +2 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/platform/index.cjs +2 -2
- package/dist/platform/index.d.cts +22 -1
- package/dist/platform/index.d.ts +22 -1
- package/dist/platform/index.js +1 -1
- package/dist/realtime/index.d.cts +2 -2
- package/dist/realtime/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/chunk-ZR2KDXJV.js +0 -2
package/dist/platform/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
exports.BrowserPlatformAdapter=c;exports.BrowserStorage=
|
|
1
|
+
'use strict';var l=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,r){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,r);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},f=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,r){this.map.set(e,r);}remove(e){this.map.delete(e);}};function n(){return globalThis.Telegram?.WebApp??null}function E(){return crypto.randomUUID()}var O="idos_device_id",c=class{storage;constructor(e=new l){this.storage=e;}getPlatform(){return n()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=n()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=n()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(O);return e||(e=E(),this.storage.setString(O,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let r=n();if(r?.openTelegramLink){r.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let r=n();if(r?.openInvoice){r.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let r=globalThis;typeof r.showAd=="function"&&await r.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var D="idos_device_id",d=class{storage;constructor(e=new f){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(D);return e||(e="noop-device",this.storage.setString(D,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};var s=["https://idosgames.com","https://www.idosgames.com"];function M(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}function m(t){if(s.includes(t))return true;if(typeof window>"u"||!M(window.location.hostname))return false;try{return M(new URL(t).hostname)}catch{return false}}var U="IDOS_PLATFORM_WALLET_ACK",L="PLATFORM_WALLET_UNAVAILABLE",C=5e3,k=18e4;function F(){let t=[...s],e=window.location.ancestorOrigins?.[0];return e&&!t.includes(e)&&m(e)&&t.push(e),t}function N(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function i(t,e,r,v={}){let p={ok:false,error:L,data:{}};if(typeof window>"u"||window.self===window.top)return Promise.resolve(p);let _=window.parent;if(!_)return Promise.resolve(p);let A=N(),x=v.answerTimeoutMs??k;return new Promise(h=>{let R=false,g,u=a=>{R||(R=true,window.removeEventListener("message",y),clearTimeout(g),h(a));},y=a=>{if(!m(a.origin))return;let o=a.data;if(!(!o||o.requestId!==A)){if(o.type===U){clearTimeout(g),g=setTimeout(()=>u({ok:false,error:"TIMEOUT",data:{}}),x);return}o.type===e&&u({ok:o.ok===true,error:typeof o.error=="string"?o.error:void 0,data:o});}};g=setTimeout(()=>u(p),C),window.addEventListener("message",y);for(let a of F())try{_.postMessage({type:t,requestId:A,...r},a);}catch{}})}var P={request:"IDOS_PLATFORM_TOPUP_REQUEST",response:"IDOS_PLATFORM_TOPUP_RESPONSE"},b=15*6e4,W=/^[a-z0-9]{8}-preview\.idos\.games$/;function w(){if(typeof window>"u")return false;try{if(window.self===window.top||window.parent!==window.top)return !1}catch{return false}return !W.test(window.location.hostname.toLowerCase())}async function G(t){let e=await i(P.request,P.response,{titleID:t.titleID,userID:t.userID,currencyID:t.currencyID,amount:t.amount},{answerTimeoutMs:b});return e.ok?{ok:true}:{ok:false,error:e.error}}var I={request:"IDOS_PLATFORM_AUTH_REQUEST",response:"IDOS_PLATFORM_AUTH_RESPONSE"},K=30*6e4,V=/^[a-z0-9]{8}-preview\.idos\.games$/,S="idos:platformSignIn:declined:";function q(){if(typeof window>"u")return false;try{if(window.self===window.top||window.parent!==window.top)return !1}catch{return false}if(V.test(window.location.hostname.toLowerCase()))return false;let t=window.location.ancestorOrigins?.[0];if(t&&!s.includes(t))try{let e=new URL(t).hostname;if(e!=="localhost"&&e!=="127.0.0.1")return !1}catch{return false}return true}async function B(t){let e=await i(I.request,I.response,{titleID:t},{answerTimeoutMs:K}),r=e.data.code;return e.ok&&typeof r=="string"&&r.length>0?{code:r}:{error:e.error??"no_code"}}function H(t){try{window.localStorage.setItem(S+t,"1");}catch{}}function $(t){try{window.localStorage.removeItem(S+t);}catch{}}function Q(t){try{return window.localStorage.getItem(S+t)==="1"}catch{return false}}var T={request:"IDOS_PLATFORM_CREDITS_CONFIRM_REQUEST",response:"IDOS_PLATFORM_CREDITS_CONFIRM_RESPONSE"},Y=10*6e4;function z(){return w()}async function X(t){let e=await i(T.request,T.response,{titleID:t.titleID,confirmationID:t.confirmationID},{answerTimeoutMs:Y});return e.ok?{ok:true}:{ok:false,error:e.error}}
|
|
2
|
+
exports.BrowserPlatformAdapter=c;exports.BrowserStorage=l;exports.MemoryStorage=f;exports.NoopPlatformAdapter=d;exports.PLATFORM_BRIDGE_ACK=U;exports.PLATFORM_CREDITS_CONFIRM_MESSAGES=T;exports.PLATFORM_ORIGINS=s;exports.PLATFORM_PAGE_UNAVAILABLE=L;exports.PLATFORM_SIGN_IN_MESSAGES=I;exports.PLATFORM_TOPUP_MESSAGES=P;exports.askPlatformPage=i;exports.canUsePlatformCreditsConfirm=z;exports.canUsePlatformSignIn=q;exports.canUsePlatformTopUp=w;exports.clearPlatformSignInDeclined=$;exports.getTelegramWebApp=n;exports.isPlatformParentOrigin=m;exports.isPlatformSignInDeclined=Q;exports.markPlatformSignInDeclined=H;exports.requestPlatformCreditsConfirm=X;exports.requestPlatformSignIn=B;exports.requestPlatformTopUp=G;
|
|
@@ -158,4 +158,25 @@ declare function markPlatformSignInDeclined(titleID: string): void;
|
|
|
158
158
|
declare function clearPlatformSignInDeclined(titleID: string): void;
|
|
159
159
|
declare function isPlatformSignInDeclined(titleID: string): boolean;
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
/** Message names. Shared with the website's `GameCreditsConfirmBridge` — keep both in step. */
|
|
162
|
+
declare const PLATFORM_CREDITS_CONFIRM_MESSAGES: {
|
|
163
|
+
readonly request: "IDOS_PLATFORM_CREDITS_CONFIRM_REQUEST";
|
|
164
|
+
readonly response: "IDOS_PLATFORM_CREDITS_CONFIRM_RESPONSE";
|
|
165
|
+
};
|
|
166
|
+
interface PlatformCreditsConfirmResult {
|
|
167
|
+
/** The player confirmed the request in the site's window. */
|
|
168
|
+
ok: boolean;
|
|
169
|
+
error?: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Whether the page around the game can be asked at all: one frame deep (the site's `/app/{id}`; behind `/embed`
|
|
173
|
+
* the game is two frames deep and a foreign page could cover our window) and not the AI Coder preview.
|
|
174
|
+
*/
|
|
175
|
+
declare function canUsePlatformCreditsConfirm(): boolean;
|
|
176
|
+
/** Asks the idosgames.com page around the game to confirm the Credits purchase request. Never rejects. */
|
|
177
|
+
declare function requestPlatformCreditsConfirm(request: {
|
|
178
|
+
titleID: string;
|
|
179
|
+
confirmationID: string;
|
|
180
|
+
}): Promise<PlatformCreditsConfirmResult>;
|
|
181
|
+
|
|
182
|
+
export { BrowserPlatformAdapter, BrowserStorage, KeyValueStorage, MemoryStorage, NoopPlatformAdapter, PLATFORM_BRIDGE_ACK, PLATFORM_CREDITS_CONFIRM_MESSAGES, PLATFORM_ORIGINS, PLATFORM_PAGE_UNAVAILABLE, PLATFORM_SIGN_IN_MESSAGES, PLATFORM_TOPUP_MESSAGES, PlatformAdapter, type PlatformCreditsConfirmResult, type PlatformPageAnswer, type PlatformSignInAnswer, type PlatformTopUpRequest, type PlatformTopUpResult, type TelegramInitDataUnsafe, type TelegramWebApp, askPlatformPage, canUsePlatformCreditsConfirm, canUsePlatformSignIn, canUsePlatformTopUp, clearPlatformSignInDeclined, getTelegramWebApp, isPlatformParentOrigin, isPlatformSignInDeclined, markPlatformSignInDeclined, requestPlatformCreditsConfirm, requestPlatformSignIn, requestPlatformTopUp };
|
package/dist/platform/index.d.ts
CHANGED
|
@@ -158,4 +158,25 @@ declare function markPlatformSignInDeclined(titleID: string): void;
|
|
|
158
158
|
declare function clearPlatformSignInDeclined(titleID: string): void;
|
|
159
159
|
declare function isPlatformSignInDeclined(titleID: string): boolean;
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
/** Message names. Shared with the website's `GameCreditsConfirmBridge` — keep both in step. */
|
|
162
|
+
declare const PLATFORM_CREDITS_CONFIRM_MESSAGES: {
|
|
163
|
+
readonly request: "IDOS_PLATFORM_CREDITS_CONFIRM_REQUEST";
|
|
164
|
+
readonly response: "IDOS_PLATFORM_CREDITS_CONFIRM_RESPONSE";
|
|
165
|
+
};
|
|
166
|
+
interface PlatformCreditsConfirmResult {
|
|
167
|
+
/** The player confirmed the request in the site's window. */
|
|
168
|
+
ok: boolean;
|
|
169
|
+
error?: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Whether the page around the game can be asked at all: one frame deep (the site's `/app/{id}`; behind `/embed`
|
|
173
|
+
* the game is two frames deep and a foreign page could cover our window) and not the AI Coder preview.
|
|
174
|
+
*/
|
|
175
|
+
declare function canUsePlatformCreditsConfirm(): boolean;
|
|
176
|
+
/** Asks the idosgames.com page around the game to confirm the Credits purchase request. Never rejects. */
|
|
177
|
+
declare function requestPlatformCreditsConfirm(request: {
|
|
178
|
+
titleID: string;
|
|
179
|
+
confirmationID: string;
|
|
180
|
+
}): Promise<PlatformCreditsConfirmResult>;
|
|
181
|
+
|
|
182
|
+
export { BrowserPlatformAdapter, BrowserStorage, KeyValueStorage, MemoryStorage, NoopPlatformAdapter, PLATFORM_BRIDGE_ACK, PLATFORM_CREDITS_CONFIRM_MESSAGES, PLATFORM_ORIGINS, PLATFORM_PAGE_UNAVAILABLE, PLATFORM_SIGN_IN_MESSAGES, PLATFORM_TOPUP_MESSAGES, PlatformAdapter, type PlatformCreditsConfirmResult, type PlatformPageAnswer, type PlatformSignInAnswer, type PlatformTopUpRequest, type PlatformTopUpResult, type TelegramInitDataUnsafe, type TelegramWebApp, askPlatformPage, canUsePlatformCreditsConfirm, canUsePlatformSignIn, canUsePlatformTopUp, clearPlatformSignInDeclined, getTelegramWebApp, isPlatformParentOrigin, isPlatformSignInDeclined, markPlatformSignInDeclined, requestPlatformCreditsConfirm, requestPlatformSignIn, requestPlatformTopUp };
|
package/dist/platform/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{e as BrowserPlatformAdapter,a as BrowserStorage,b as MemoryStorage,
|
|
1
|
+
export{e as BrowserPlatformAdapter,a as BrowserStorage,b as MemoryStorage,q as NoopPlatformAdapter,h as PLATFORM_BRIDGE_ACK,n as PLATFORM_CREDITS_CONFIRM_MESSAGES,f as PLATFORM_ORIGINS,i as PLATFORM_PAGE_UNAVAILABLE,r as PLATFORM_SIGN_IN_MESSAGES,k as PLATFORM_TOPUP_MESSAGES,j as askPlatformPage,o as canUsePlatformCreditsConfirm,s as canUsePlatformSignIn,l as canUsePlatformTopUp,v as clearPlatformSignInDeclined,c as getTelegramWebApp,g as isPlatformParentOrigin,w as isPlatformSignInDeclined,u as markPlatformSignInDeclined,p as requestPlatformCreditsConfirm,t as requestPlatformSignIn,m as requestPlatformTopUp}from'../chunk-LWS7EEOF.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IceServer } from '../VoiceController-
|
|
2
|
-
export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-
|
|
1
|
+
import { I as IceServer } from '../VoiceController-B6naztyl.cjs';
|
|
2
|
+
export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-B6naztyl.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../PlatformAdapter-DU_8HalI.cjs';
|
|
5
5
|
import 'decimal.js';
|
package/dist/realtime/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IceServer } from '../VoiceController-
|
|
2
|
-
export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-
|
|
1
|
+
import { I as IceServer } from '../VoiceController-5wloz5B8.js';
|
|
2
|
+
export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-5wloz5B8.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../PlatformAdapter-DU_8HalI.js';
|
|
5
5
|
import 'decimal.js';
|
package/package.json
CHANGED
package/dist/chunk-ZR2KDXJV.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var s=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,r){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,r);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},l=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,r){this.map.set(e,r);}remove(e){this.map.delete(e);}};function o(){return globalThis.Telegram?.WebApp??null}function y(){return crypto.randomUUID()}var R="idos_device_id",c=class{storage;constructor(e=new s){this.storage=e;}getPlatform(){return o()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=o()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=o()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(R);return e||(e=y(),this.storage.setString(R,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let r=o();if(r?.openTelegramLink){r.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let r=o();if(r?.openInvoice){r.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let r=globalThis;typeof r.showAd=="function"&&await r.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var E="idos_device_id",d=class{storage;constructor(e=new l){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(E);return e||(e="noop-device",this.storage.setString(E,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};var i=["https://idosgames.com","https://www.idosgames.com"];function v(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}function p(t){if(i.includes(t))return true;if(typeof window>"u"||!v(window.location.hostname))return false;try{return v(new URL(t).hostname)}catch{return false}}var O="IDOS_PLATFORM_WALLET_ACK",D="PLATFORM_WALLET_UNAVAILABLE",M=5e3,x=18e4;function k(){let t=[...i],e=window.location.ancestorOrigins?.[0];return e&&!t.includes(e)&&p(e)&&t.push(e),t}function b(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function g(t,e,r,U={}){let u={ok:false,error:D,data:{}};if(typeof window>"u"||window.self===window.top)return Promise.resolve(u);let S=window.parent;if(!S)return Promise.resolve(u);let I=b(),h=U.answerTimeoutMs??x;return new Promise(L=>{let A=false,f,m=a=>{A||(A=true,window.removeEventListener("message",_),clearTimeout(f),L(a));},_=a=>{if(!p(a.origin))return;let n=a.data;if(!(!n||n.requestId!==I)){if(n.type===O){clearTimeout(f),f=setTimeout(()=>m({ok:false,error:"TIMEOUT",data:{}}),h);return}n.type===e&&m({ok:n.ok===true,error:typeof n.error=="string"?n.error:void 0,data:n});}};f=setTimeout(()=>m(u),M),window.addEventListener("message",_);for(let a of k())try{S.postMessage({type:t,requestId:I,...r},a);}catch{}})}var w={request:"IDOS_PLATFORM_TOPUP_REQUEST",response:"IDOS_PLATFORM_TOPUP_RESPONSE"},F=15*6e4,N=/^[a-z0-9]{8}-preview\.idos\.games$/;function W(){if(typeof window>"u")return false;try{if(window.self===window.top||window.parent!==window.top)return !1}catch{return false}return !N.test(window.location.hostname.toLowerCase())}async function K(t){let e=await g(w.request,w.response,{titleID:t.titleID,userID:t.userID,currencyID:t.currencyID,amount:t.amount},{answerTimeoutMs:F});return e.ok?{ok:true}:{ok:false,error:e.error}}var P={request:"IDOS_PLATFORM_AUTH_REQUEST",response:"IDOS_PLATFORM_AUTH_RESPONSE"},V=30*6e4,G=/^[a-z0-9]{8}-preview\.idos\.games$/,T="idos:platformSignIn:declined:";function q(){if(typeof window>"u")return false;try{if(window.self===window.top||window.parent!==window.top)return !1}catch{return false}if(G.test(window.location.hostname.toLowerCase()))return false;let t=window.location.ancestorOrigins?.[0];if(t&&!i.includes(t))try{let e=new URL(t).hostname;if(e!=="localhost"&&e!=="127.0.0.1")return !1}catch{return false}return true}async function C(t){let e=await g(P.request,P.response,{titleID:t},{answerTimeoutMs:V}),r=e.data.code;return e.ok&&typeof r=="string"&&r.length>0?{code:r}:{error:e.error??"no_code"}}function B(t){try{window.localStorage.setItem(T+t,"1");}catch{}}function H(t){try{window.localStorage.removeItem(T+t);}catch{}}function $(t){try{return window.localStorage.getItem(T+t)==="1"}catch{return false}}
|
|
2
|
-
export{s as a,l as b,o as c,y as d,c as e,i as f,p as g,O as h,D as i,g as j,w as k,W as l,K as m,d as n,P as o,q as p,C as q,B as r,H as s,$ as t};
|