@arkadiuminc/sdk 1.1.1 → 2.0.1
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 +18 -1
- package/dist/pkg/api/features/ads/index.d.ts +34 -22
- package/dist/pkg/api/features/analytics/analytics.api.d.ts +3 -3
- package/dist/pkg/api/features/{user-state/user-state.api.d.ts → auth/index.d.ts} +13 -7
- package/dist/pkg/api/features/backend/backend.api.d.ts +1 -3
- package/dist/pkg/api/features/game-lifecycle/game-lifecycle.api.d.ts +24 -24
- package/dist/pkg/api/features/host/index.d.ts +58 -0
- package/dist/pkg/api/features/persistence/index.d.ts +29 -0
- package/dist/pkg/arkadium-arena-sdk.d.ts +11 -13
- package/dist/pkg/arkadium-game-sdk.d.ts +11 -13
- package/dist/pkg/arkadium-sdk.mjs +1 -1
- package/dist/pkg/arkadium-sdk.umd.js +1 -1
- package/package.json +3 -4
- package/dist/pkg/api/features/environment/environment.api.d.ts +0 -60
- package/dist/pkg/api/features/game-state/game-state.api.d.ts +0 -59
- package/dist/pkg/api/features/purchases/purchases.api.d.ts +0 -25
package/README.md
CHANGED
|
@@ -22,13 +22,30 @@ const Game = {
|
|
|
22
22
|
async function main() {
|
|
23
23
|
Game.pause();
|
|
24
24
|
const { ads } = await getInstance(Env.DEV);
|
|
25
|
-
await ads.
|
|
25
|
+
await ads.showInterstitialAd();
|
|
26
26
|
Game.resume();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
main();
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## using the sandbox with a local game sdk
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
cd arkadium-sdk
|
|
36
|
+
http-server . -p 8080 -c-1 --cors
|
|
37
|
+
npm run build-fast
|
|
38
|
+
|
|
39
|
+
cd arkadium-dev-portal
|
|
40
|
+
# in the sandbox.tsx file, change SDK_PATH to 'http://localhost:8080/dist/arena/arena-sdk.umd.js'
|
|
41
|
+
npm run start
|
|
42
|
+
# visit the dev portal sandbox page: http://localhost:3511/sandbox
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
set the following fields:
|
|
46
|
+
- gameId: arkadium-sdk-test-game
|
|
47
|
+
- gameURL: http://localhost:8080/example/simple/analytics.html
|
|
48
|
+
|
|
32
49
|
|
|
33
50
|
## Reference documents
|
|
34
51
|
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { RpcProvider } from '../../core/rpc';
|
|
2
2
|
import { ApiEnv } from '../backend/backend.api';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { Auth } from '../auth/';
|
|
4
|
+
export interface GameAdsContract {
|
|
5
|
+
showInterstitialAd(options: {
|
|
6
6
|
duration?: number;
|
|
7
7
|
}): Promise<void>;
|
|
8
|
-
|
|
9
|
-
declare type RewardAdContract = {
|
|
10
|
-
show(options: {
|
|
8
|
+
showRewardAd(options: {
|
|
11
9
|
duration?: number;
|
|
12
10
|
}): Promise<{
|
|
13
11
|
value: number;
|
|
14
12
|
}>;
|
|
15
|
-
|
|
13
|
+
showBannerAd(adId: string, dimensions: AdTypes[]): any;
|
|
14
|
+
}
|
|
16
15
|
export declare enum AdTypes {
|
|
17
16
|
AD_300x250 = "AD_300x250",
|
|
18
17
|
AD_250x250 = "AD_250x250",
|
|
@@ -26,20 +25,33 @@ export declare enum AdTypes {
|
|
|
26
25
|
AD_468x60 = "AD_468x60",
|
|
27
26
|
AD_160x600 = "AD_160x600"
|
|
28
27
|
}
|
|
29
|
-
declare class
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export declare class GameAds implements GameAdsContract {
|
|
29
|
+
private interstitial;
|
|
30
|
+
private rewarded;
|
|
31
|
+
constructor(rpcProvider: RpcProvider, auth: Auth);
|
|
32
|
+
showInterstitialAd({ duration }?: {
|
|
33
|
+
duration?: number | undefined;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
showRewardAd({ duration }?: {
|
|
36
|
+
duration?: number | undefined;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
value: number;
|
|
39
|
+
}>;
|
|
40
|
+
showBannerAd(): void;
|
|
36
41
|
}
|
|
37
|
-
export declare class
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
export declare class GameAdsProxy implements GameAdsContract {
|
|
43
|
+
bannerSizes: typeof AdTypes;
|
|
44
|
+
private interstitial;
|
|
45
|
+
private rewarded;
|
|
46
|
+
private banner;
|
|
47
|
+
constructor(rpcProvider: RpcProvider, env: ApiEnv, auth: Auth);
|
|
48
|
+
showInterstitialAd({ duration }?: {
|
|
49
|
+
duration?: number | undefined;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
showRewardAd({ duration }?: {
|
|
52
|
+
duration?: number | undefined;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
value: number;
|
|
55
|
+
}>;
|
|
56
|
+
showBannerAd(adId: string, dimensions: AdTypes[]): any;
|
|
44
57
|
}
|
|
45
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RpcProvider } from '../../core/rpc';
|
|
2
|
-
import { GameIdReaderContract } from '../environment/environment.api';
|
|
3
2
|
import { AnalyticProviderEnum, IAnalyticConfig } from './defs';
|
|
4
3
|
import { DimensionsObject } from './dimensions';
|
|
4
|
+
import { IHost } from '../host';
|
|
5
5
|
interface EnvironmentVersion {
|
|
6
6
|
GameKey: string;
|
|
7
7
|
GameVersion: string;
|
|
@@ -18,12 +18,12 @@ export interface AnalyticsApiContract {
|
|
|
18
18
|
trackException(exception: Error): Promise<void>;
|
|
19
19
|
}
|
|
20
20
|
export declare class AnalyticsApi implements AnalyticsApiContract {
|
|
21
|
-
private
|
|
21
|
+
private host;
|
|
22
22
|
private rpcProvider;
|
|
23
23
|
private providers;
|
|
24
24
|
private activeProvidersTypes;
|
|
25
25
|
private info;
|
|
26
|
-
constructor(
|
|
26
|
+
constructor(host: IHost, rpcProvider: RpcProvider);
|
|
27
27
|
getEnvVersion(): Promise<EnvironmentVersion>;
|
|
28
28
|
setGameVersion(v: string): Promise<void>;
|
|
29
29
|
setNestVersion(v: string): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ApiEnv,
|
|
1
|
+
import { ApiEnv, Backend } from '../backend/backend.api';
|
|
2
2
|
import { createStore } from '../../utils/observable';
|
|
3
3
|
import { RpcProvider } from '../../core/rpc';
|
|
4
|
-
import {
|
|
4
|
+
import { IHost } from '../host';
|
|
5
5
|
interface Image {
|
|
6
6
|
png: string;
|
|
7
7
|
webp: string;
|
|
@@ -24,11 +24,17 @@ interface AuthUIManagerContract {
|
|
|
24
24
|
openAuthRequest: ReturnType<typeof createStore<boolean>>;
|
|
25
25
|
openAuthForm(): Promise<void>;
|
|
26
26
|
}
|
|
27
|
-
export declare class
|
|
28
|
-
userProfileReader
|
|
29
|
-
authUIManager
|
|
27
|
+
export declare class Auth {
|
|
28
|
+
private userProfileReader;
|
|
29
|
+
private authUIManager;
|
|
30
30
|
constructor(userProfileReader: UserProfileReaderContract, authUIManager: AuthUIManagerContract);
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
init(env: ApiEnv): Promise<void>;
|
|
32
|
+
isUserAuthorized(): Promise<boolean>;
|
|
33
|
+
getUserProfile(): Promise<UserProfile | null>;
|
|
34
|
+
onAuthStatusChange(observer: any): () => void;
|
|
35
|
+
openAuthForm(): Promise<void>;
|
|
36
|
+
onOpenAuthForm(observer: any): () => void;
|
|
37
|
+
static getArenaApi(backendApi: Backend, host: IHost, rpcProvider: RpcProvider): Auth;
|
|
38
|
+
static getGameApi(backendApi: Backend, host: IHost, rpcProvider: RpcProvider): Auth;
|
|
33
39
|
}
|
|
34
40
|
export {};
|
|
@@ -9,10 +9,8 @@ export declare enum PaymentsApiEnv {
|
|
|
9
9
|
PROD = "https://arenacloud.cdn.arkadiumhosted.com/eagle-payment-api-prod/"
|
|
10
10
|
}
|
|
11
11
|
export declare type SessionStorageType = ReturnType<typeof UserApiGateway.prototype.getSessionStorage>;
|
|
12
|
-
export declare class
|
|
12
|
+
export declare class Backend {
|
|
13
13
|
user: Awaited<ReturnType<typeof UserApiGateway.prototype.getAuthApi>> | null;
|
|
14
|
-
private paymentsApiGateway;
|
|
15
|
-
private virtualItemApiGateway;
|
|
16
14
|
private userGateway;
|
|
17
15
|
userGameData: UserGameDataApi | null;
|
|
18
16
|
uiOpenRequest: import("../../utils/observable").Observable<boolean>;
|
|
@@ -11,41 +11,41 @@ declare enum LifecycleEvent {
|
|
|
11
11
|
}
|
|
12
12
|
declare type LifecycleFn = (event: LifecycleEvent, payload?: any) => void;
|
|
13
13
|
export interface GameLifecycleContract {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
onTestReady(): Promise<void>;
|
|
15
|
+
onPauseReady(): Promise<void>;
|
|
16
|
+
onGamePause(): Promise<void>;
|
|
17
|
+
onGameResume(): Promise<void>;
|
|
18
|
+
onGameStart(): Promise<void>;
|
|
19
|
+
onInteract(): Promise<void>;
|
|
20
|
+
onChangeScore(score: number): Promise<void>;
|
|
21
|
+
onGameEnd(): Promise<void>;
|
|
22
22
|
subscribe(fn: LifecycleFn): void;
|
|
23
23
|
}
|
|
24
24
|
export declare class GameLifecycle implements GameLifecycleContract {
|
|
25
25
|
private rpcProvider;
|
|
26
26
|
private cb;
|
|
27
27
|
constructor(rpcProvider: RpcProvider);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
onTestReady(): Promise<void>;
|
|
29
|
+
onGameStart(): Promise<void>;
|
|
30
|
+
onInteract(): Promise<void>;
|
|
31
|
+
onChangeScore(score: number): Promise<void>;
|
|
32
|
+
onGameEnd(): Promise<void>;
|
|
33
33
|
subscribe(cb: LifecycleFn): void;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
onGamePause(): Promise<void>;
|
|
35
|
+
onGameResume(): Promise<void>;
|
|
36
|
+
onPauseReady(): Promise<void>;
|
|
37
37
|
}
|
|
38
38
|
export declare class GameLifecycleProxy implements GameLifecycleContract {
|
|
39
39
|
private rpcProvider;
|
|
40
40
|
constructor(rpcProvider: RpcProvider);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
onTestReady(): Promise<void>;
|
|
42
|
+
onGameStart(): Promise<void>;
|
|
43
|
+
onInteract(): Promise<void>;
|
|
44
|
+
onChangeScore(score: number): Promise<void>;
|
|
45
|
+
onGameEnd(): Promise<void>;
|
|
46
46
|
subscribe(fn: LifecycleFn): void;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
onGamePause(): Promise<void>;
|
|
48
|
+
onGameResume(): Promise<void>;
|
|
49
|
+
onPauseReady(): Promise<void>;
|
|
50
50
|
}
|
|
51
51
|
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RpcProvider } from '../../core/rpc';
|
|
2
|
+
export interface IHost {
|
|
3
|
+
getQueryParameter(key: string): Promise<string | null>;
|
|
4
|
+
getGameId(): Promise<string>;
|
|
5
|
+
setGameId(id: string): void;
|
|
6
|
+
getDetails(): Promise<WebEnvironmentDetails>;
|
|
7
|
+
setDetails?(p: Partial<WebEnvironmentDetails>): Promise<void>;
|
|
8
|
+
openPurchaseForm(r: PurchaseRequest): Promise<void>;
|
|
9
|
+
onOpenPurchaseForm?(observer: any): any;
|
|
10
|
+
}
|
|
11
|
+
export declare type PurchaseRequest = {
|
|
12
|
+
type: string;
|
|
13
|
+
currencySku: string;
|
|
14
|
+
};
|
|
15
|
+
declare class WebEnvironmentDetails {
|
|
16
|
+
siteName: string;
|
|
17
|
+
siteDomain: string;
|
|
18
|
+
referrer: string;
|
|
19
|
+
activeLocale: string;
|
|
20
|
+
devEnvironment: string;
|
|
21
|
+
darkMode: boolean;
|
|
22
|
+
constructor(siteName?: string, siteDomain?: string, referrer?: string, activeLocale?: string, devEnvironment?: string, darkMode?: boolean);
|
|
23
|
+
clone(p: Partial<WebEnvironmentDetails>): WebEnvironmentDetails;
|
|
24
|
+
}
|
|
25
|
+
export declare class HostArena implements IHost {
|
|
26
|
+
private rpcProvider;
|
|
27
|
+
private gameIdOverride;
|
|
28
|
+
private data;
|
|
29
|
+
private openRequest;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
constructor(rpcProvider: RpcProvider);
|
|
34
|
+
getQueryParameter(key: string): Promise<string | null>;
|
|
35
|
+
getGameId(): Promise<string>;
|
|
36
|
+
setGameId(id: string): Promise<void>;
|
|
37
|
+
getDetails(): Promise<WebEnvironmentDetails>;
|
|
38
|
+
setDetails(p: Partial<WebEnvironmentDetails>): Promise<void>;
|
|
39
|
+
openPurchaseForm(pr: PurchaseRequest): Promise<void>;
|
|
40
|
+
onOpenPurchaseForm(observer: any): () => void;
|
|
41
|
+
purchaseFormClosed(madePurchase: boolean): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export declare class HostGame implements IHost {
|
|
44
|
+
private rpcProvider;
|
|
45
|
+
private purchaseFormState;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
constructor(rpcProvider: RpcProvider);
|
|
50
|
+
getQueryParameter(key: string): Promise<string | null>;
|
|
51
|
+
getGameId(): Promise<string>;
|
|
52
|
+
setGameId(id: string): Promise<any>;
|
|
53
|
+
getDetails(): Promise<WebEnvironmentDetails>;
|
|
54
|
+
openPurchaseForm(r: PurchaseRequest): Promise<void>;
|
|
55
|
+
onPurchaseFormStateChange(observer: any): () => void;
|
|
56
|
+
private purchaseFormClosed;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RpcProvider } from '../../core/rpc';
|
|
2
|
+
export interface IPersistence {
|
|
3
|
+
getLocalStorageItem(key: string): Promise<string | null>;
|
|
4
|
+
setLocalStorageItem(key: string, value: string): Promise<void>;
|
|
5
|
+
removeLocalStorageItem(key: string): Promise<void>;
|
|
6
|
+
getCookie(cookieName: string): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare class PersistenceArena implements IPersistence {
|
|
9
|
+
private ls;
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
constructor(rpcProvider: RpcProvider);
|
|
14
|
+
getLocalStorageItem(key: string): Promise<string | null>;
|
|
15
|
+
setLocalStorageItem(key: string, value: string): Promise<void>;
|
|
16
|
+
removeLocalStorageItem(key: string): Promise<void>;
|
|
17
|
+
getCookie(cookieName: string): Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
export declare class PersistenceGame implements IPersistence {
|
|
20
|
+
private rpcProvider;
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
constructor(rpcProvider: RpcProvider);
|
|
25
|
+
getLocalStorageItem(key: string): Promise<string | null>;
|
|
26
|
+
setLocalStorageItem(key: string, value: string): Promise<void>;
|
|
27
|
+
removeLocalStorageItem(key: string): Promise<void>;
|
|
28
|
+
getCookie(cookieName: string): Promise<string>;
|
|
29
|
+
}
|
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import { ApiEnv,
|
|
2
|
-
import { GameStateContract } from './api/features/game-state/game-state.api';
|
|
1
|
+
import { ApiEnv, Backend, SessionStorageType } from './api/features/backend/backend.api';
|
|
3
2
|
import { GameLifecycleContract } from './api/features/game-lifecycle/game-lifecycle.api';
|
|
4
|
-
import { EnvironmentApi } from './api/features/environment/environment.api';
|
|
5
3
|
import { RpcProvider } from './api/core/rpc';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { GameAdsContract } from './api/features/ads/';
|
|
5
|
+
import { Auth } from './api/features/auth/';
|
|
8
6
|
import { AnalyticsApiContract } from './api/features/analytics/analytics.api';
|
|
9
7
|
import { Observable } from './api/utils/observable';
|
|
10
8
|
import { TimeoutTesterContract } from './api/core/timeout-tester';
|
|
11
|
-
import {
|
|
9
|
+
import { PersistenceArena } from './api/features/persistence';
|
|
10
|
+
import { HostArena } from './api/features/host';
|
|
12
11
|
export declare class ArkadiumGameSdk {
|
|
13
12
|
private rpcProvider;
|
|
14
|
-
backendApi:
|
|
15
|
-
|
|
16
|
-
gameState: GameStateContract;
|
|
13
|
+
backendApi: Backend;
|
|
14
|
+
host: HostArena;
|
|
17
15
|
lifecycle: GameLifecycleContract;
|
|
18
|
-
ads:
|
|
19
|
-
|
|
16
|
+
ads: GameAdsContract;
|
|
17
|
+
auth: Auth;
|
|
20
18
|
analytics: AnalyticsApiContract;
|
|
21
|
-
purchases: PurchasesApi<UIManagerArenaContract>;
|
|
22
19
|
private timeoutTester;
|
|
20
|
+
persistence: PersistenceArena;
|
|
23
21
|
private currentEnv;
|
|
24
22
|
private currentTarget;
|
|
25
23
|
private gamePingSender;
|
|
26
24
|
private gamePingListener;
|
|
27
25
|
$pingNotification: Observable<number>;
|
|
28
26
|
version: string;
|
|
29
|
-
constructor(rpcProvider: RpcProvider, backendApi:
|
|
27
|
+
constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostArena, lifecycle: GameLifecycleContract, ads: GameAdsContract, auth: Auth, analytics: AnalyticsApiContract, timeoutTester: TimeoutTesterContract, persistence: PersistenceArena);
|
|
30
28
|
setEnv(e: ApiEnv): void;
|
|
31
29
|
initialize(env: ApiEnv, isGameSide: boolean, sessionStorage?: SessionStorageType | null): Promise<void>;
|
|
32
30
|
private envDiscoverListener;
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { ApiEnv,
|
|
2
|
-
import { GameStateContract } from './api/features/game-state/game-state.api';
|
|
1
|
+
import { ApiEnv, Backend, SessionStorageType } from './api/features/backend/backend.api';
|
|
3
2
|
import { GameLifecycleContract } from './api/features/game-lifecycle/game-lifecycle.api';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { UserStateApi } from './api/features/user-state/user-state.api';
|
|
3
|
+
import { GameAdsContract } from './api/features/ads/';
|
|
4
|
+
import { Auth } from './api/features/auth/';
|
|
7
5
|
import { AnalyticsApiContract } from './api/features/analytics/analytics.api';
|
|
8
6
|
import { RpcProvider } from './api/core/rpc';
|
|
9
7
|
import { TimeoutTesterContract } from './api/core/timeout-tester';
|
|
10
|
-
import {
|
|
8
|
+
import { PersistenceGame } from './api/features/persistence';
|
|
9
|
+
import { HostGame } from './api/features/host';
|
|
11
10
|
export declare class ArkadiumGameSdk {
|
|
12
11
|
private rpcProvider;
|
|
13
|
-
backendApi:
|
|
14
|
-
|
|
15
|
-
gameState: GameStateContract;
|
|
12
|
+
backendApi: Backend;
|
|
13
|
+
host: HostGame;
|
|
16
14
|
lifecycle: GameLifecycleContract;
|
|
17
|
-
ads:
|
|
18
|
-
|
|
15
|
+
ads: GameAdsContract;
|
|
16
|
+
auth: Auth;
|
|
19
17
|
analytics: AnalyticsApiContract;
|
|
20
|
-
purchases: PurchasesApi<UIManagerGameContract>;
|
|
21
18
|
private timeoutTester;
|
|
19
|
+
persistence: PersistenceGame;
|
|
22
20
|
version: string;
|
|
23
21
|
private arenaPingSender;
|
|
24
22
|
private arenaPingListener;
|
|
25
|
-
constructor(rpcProvider: RpcProvider, backendApi:
|
|
23
|
+
constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostGame, lifecycle: GameLifecycleContract, ads: GameAdsContract, auth: Auth, analytics: AnalyticsApiContract, timeoutTester: TimeoutTesterContract, persistence: PersistenceGame);
|
|
26
24
|
initialize(env: ApiEnv, isGameSide: boolean, sessionStorage?: SessionStorageType | null): Promise<void>;
|
|
27
25
|
updateWinReference(target: any): void;
|
|
28
26
|
debugMode(enabled: boolean): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const d = "https://developers.arkadium.com/cdn/sdk/
|
|
1
|
+
const d = "https://developers.arkadium.com/cdn/sdk/v2/sdk.js", a = "https://developers.arkadium.com/cdn/sdk/dev/v2/sdk.js";
|
|
2
2
|
var i = /* @__PURE__ */ ((e) => (e.DEV = "DEV", e.PROD = "PROD", e))(i || {});
|
|
3
3
|
let n, t;
|
|
4
4
|
function m(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.ArkadiumSdk={}))})(this,function(e){"use strict";const n="https://developers.arkadium.com/cdn/sdk/
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.ArkadiumSdk={}))})(this,function(e){"use strict";const n="https://developers.arkadium.com/cdn/sdk/v2/sdk.js",c="https://developers.arkadium.com/cdn/sdk/dev/v2/sdk.js";var i=(t=>(t.DEV="DEV",t.PROD="PROD",t))(i||{});let d,s;function r(t){return s?Promise.resolve(s):(d||(d=new Promise(u=>{const o=document.createElement("script"),a=t==="PROD"?n:c;o.src=a,o.onload=()=>{globalThis.__GameApi__.getInstance(t).then(m=>{s=m,u(s)})},(document.head||document.body).appendChild(o)})),d)}e.Env=i,e.getInstance=r,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkadiuminc/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "dist/pkg/arkadium-sdk.umd.js",
|
|
@@ -58,8 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@arkadium/eagle-payments-api-client": "^0.0.35",
|
|
61
|
-
"@arkadium/eagle-user-client": "^0.0.
|
|
62
|
-
"@arkadium/eagle-virtual-items-api-client": "^0.0.27",
|
|
61
|
+
"@arkadium/eagle-user-client": "^0.0.90",
|
|
63
62
|
"@commitlint/cli": "^17.0.3",
|
|
64
63
|
"@commitlint/config-conventional": "^17.0.3",
|
|
65
64
|
"@types/jest": "^28.1.6",
|
|
@@ -95,4 +94,4 @@
|
|
|
95
94
|
"nanoid": "^5.0.4",
|
|
96
95
|
"vite-plugin-string-replace": "^1.1.2"
|
|
97
96
|
}
|
|
98
|
-
}
|
|
97
|
+
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { RpcProvider } from '../../core/rpc';
|
|
2
|
-
export interface LocalStorageContract {
|
|
3
|
-
getItem(key: string): Promise<string | null>;
|
|
4
|
-
setItem(key: string, value: string): Promise<void>;
|
|
5
|
-
removeItem(key: string): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare class DefaultLocalStorage implements LocalStorageContract {
|
|
8
|
-
private ls;
|
|
9
|
-
constructor(rpcProvider: RpcProvider);
|
|
10
|
-
getItem(key: string): Promise<string | null>;
|
|
11
|
-
setItem(key: string, value: string): Promise<void>;
|
|
12
|
-
removeItem(key: string): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
interface CookieStorageContract {
|
|
15
|
-
GetKey(key: string): Promise<string>;
|
|
16
|
-
}
|
|
17
|
-
interface UrlParamsReaderContract {
|
|
18
|
-
GetParam(key: string): Promise<string | null>;
|
|
19
|
-
}
|
|
20
|
-
export interface GameIdReaderContract {
|
|
21
|
-
readGameId(): Promise<string>;
|
|
22
|
-
setGameId(id: string): void;
|
|
23
|
-
}
|
|
24
|
-
export declare class GameIdReader implements GameIdReaderContract {
|
|
25
|
-
private gameIdOverride;
|
|
26
|
-
constructor(rpcProvider: RpcProvider);
|
|
27
|
-
readGameId(): Promise<string>;
|
|
28
|
-
setGameId(id: string): void;
|
|
29
|
-
}
|
|
30
|
-
export declare class GameIdReaderProxy implements GameIdReaderContract {
|
|
31
|
-
private rpcProvider;
|
|
32
|
-
constructor(rpcProvider: RpcProvider);
|
|
33
|
-
readGameId(): Promise<string>;
|
|
34
|
-
setGameId(id: string): Promise<any>;
|
|
35
|
-
}
|
|
36
|
-
declare class WebEnvironmentDetails {
|
|
37
|
-
siteName: string;
|
|
38
|
-
siteDomain: string;
|
|
39
|
-
referrer: string;
|
|
40
|
-
activeLocale: string;
|
|
41
|
-
devEnvironment: string;
|
|
42
|
-
darkMode: boolean;
|
|
43
|
-
constructor(siteName?: string, siteDomain?: string, referrer?: string, activeLocale?: string, devEnvironment?: string, darkMode?: boolean);
|
|
44
|
-
clone(p: Partial<WebEnvironmentDetails>): WebEnvironmentDetails;
|
|
45
|
-
}
|
|
46
|
-
interface WebEnvironmentDetailsProvider {
|
|
47
|
-
setParams(p: Partial<WebEnvironmentDetails>): Promise<void>;
|
|
48
|
-
getParams(): Promise<WebEnvironmentDetails>;
|
|
49
|
-
}
|
|
50
|
-
export declare class EnvironmentApi {
|
|
51
|
-
localStorage: LocalStorageContract;
|
|
52
|
-
cookieStorage: CookieStorageContract;
|
|
53
|
-
urlParamsReader: UrlParamsReaderContract;
|
|
54
|
-
gameIdReader: GameIdReaderContract;
|
|
55
|
-
webEnvironmentDetailsStorage: WebEnvironmentDetailsProvider;
|
|
56
|
-
constructor(localStorage: LocalStorageContract, cookieStorage: CookieStorageContract, urlParamsReader: UrlParamsReaderContract, gameIdReader: GameIdReaderContract, webEnvironmentDetailsStorage: WebEnvironmentDetailsProvider);
|
|
57
|
-
static getArenaApi(rpcProvider: RpcProvider): EnvironmentApi;
|
|
58
|
-
static getGameApi(rpcProvider: RpcProvider): EnvironmentApi;
|
|
59
|
-
}
|
|
60
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { RpcProvider } from '../../core/rpc';
|
|
2
|
-
import { GameIdReaderContract } from '../environment/environment.api';
|
|
3
|
-
import { BackendApi } from '../backend/backend.api';
|
|
4
|
-
declare class SaveDataContract<T> {
|
|
5
|
-
__cloudMeta__: {
|
|
6
|
-
__version: number;
|
|
7
|
-
};
|
|
8
|
-
data: T | null;
|
|
9
|
-
clone<T>(p: Partial<SaveDataContract<T>>): SaveDataContract<T>;
|
|
10
|
-
}
|
|
11
|
-
export declare const ErrSaveIsOutdated: Error;
|
|
12
|
-
export interface GameStateContract {
|
|
13
|
-
setSerializer(s: Serializer): void;
|
|
14
|
-
loadGameState(key: string): Promise<any>;
|
|
15
|
-
saveGameState(key: string, state: any): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export interface Serializer {
|
|
18
|
-
pack(data: Record<any, any>): Promise<string>;
|
|
19
|
-
unpack(data: string): Promise<Record<any, any> | null>;
|
|
20
|
-
}
|
|
21
|
-
export declare class GameStateApi {
|
|
22
|
-
private rpcProvider;
|
|
23
|
-
private ls;
|
|
24
|
-
private backendApi;
|
|
25
|
-
private gameIdReader;
|
|
26
|
-
private knownStates;
|
|
27
|
-
private serializer;
|
|
28
|
-
private useGameSerializer;
|
|
29
|
-
constructor(backendApi: BackendApi, gameIdReader: GameIdReaderContract, rpcProvider: RpcProvider);
|
|
30
|
-
private getGameId;
|
|
31
|
-
private packData;
|
|
32
|
-
private unpackData;
|
|
33
|
-
private isUserAuthorized;
|
|
34
|
-
private getStorageKey;
|
|
35
|
-
useSerializer(value: boolean): void;
|
|
36
|
-
setSerializer(s: Serializer): void;
|
|
37
|
-
loadGameState<T>(key: string): Promise<{
|
|
38
|
-
cloud: SaveDataContract<T> | null;
|
|
39
|
-
local: SaveDataContract<T> | null;
|
|
40
|
-
}>;
|
|
41
|
-
private loadData;
|
|
42
|
-
private isStateOutdated;
|
|
43
|
-
saveGameState<T>(key: string, state: SaveDataContract<T>): Promise<void>;
|
|
44
|
-
private saveDataToStorage;
|
|
45
|
-
}
|
|
46
|
-
export declare class GameStateApiProxy {
|
|
47
|
-
private rpcProvider;
|
|
48
|
-
constructor(rpcProvider: RpcProvider);
|
|
49
|
-
private serializer;
|
|
50
|
-
setSerializer(serializer: Serializer | null): void;
|
|
51
|
-
customPack(data: Record<any, any>): Promise<string | undefined>;
|
|
52
|
-
customUnpack(data: string): Promise<Record<any, any> | null | undefined>;
|
|
53
|
-
loadGameState<T>(key: string): Promise<{
|
|
54
|
-
cloud: SaveDataContract<T>;
|
|
55
|
-
local: SaveDataContract<T>;
|
|
56
|
-
}>;
|
|
57
|
-
saveGameState<T>(key: string, state: SaveDataContract<T>): Promise<void>;
|
|
58
|
-
}
|
|
59
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { RpcProvider } from '../../core/rpc';
|
|
2
|
-
import { Observable } from '../../utils/observable';
|
|
3
|
-
export declare type PurchaseRequest = {
|
|
4
|
-
type: string;
|
|
5
|
-
currencySku: string;
|
|
6
|
-
};
|
|
7
|
-
export interface UIManagerArenaContract {
|
|
8
|
-
openRequest: Observable<PurchaseRequest | undefined>;
|
|
9
|
-
shopWindowClosed(madePurchase: boolean): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export interface UIManagerGameContract {
|
|
12
|
-
purchaseRequest(r: PurchaseRequest): Promise<void>;
|
|
13
|
-
shopWindowOpened: Observable<ShopWindowNotification | undefined>;
|
|
14
|
-
}
|
|
15
|
-
declare type ShopWindowNotification = {
|
|
16
|
-
opened: boolean;
|
|
17
|
-
madePurchase: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare class PurchasesApi<T> {
|
|
20
|
-
ui: T;
|
|
21
|
-
constructor(ui: T);
|
|
22
|
-
static getArenaApi(rpcProvider: RpcProvider): PurchasesApi<UIManagerArenaContract>;
|
|
23
|
-
static getGameApi(rpcProvider: RpcProvider): PurchasesApi<UIManagerGameContract>;
|
|
24
|
-
}
|
|
25
|
-
export {};
|