@arkadiuminc/sdk 2.58.1 → 2.60.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/dist/pkg/api/core/rpc.d.ts +1 -0
- package/dist/pkg/api/features/ads/index.d.ts +18 -13
- package/dist/pkg/api/features/game-lifecycle/game-lifecycle.api.d.ts +12 -2
- package/dist/pkg/api/features/host/index.d.ts +14 -0
- package/dist/pkg/api/utils/validate-input.d.ts +42 -0
- package/package.json +1 -1
|
@@ -3,9 +3,17 @@ import { ApiEnv } from '../backend/backend.api';
|
|
|
3
3
|
import { Auth } from '../auth/';
|
|
4
4
|
import { VideoAdOptions } from './video-ad';
|
|
5
5
|
import { BannerAdOptions, AdTypes } from './display-ad';
|
|
6
|
-
import { GameLifecycleArena } from '../game-lifecycle/game-lifecycle.api';
|
|
6
|
+
import { GameLifecycleArena, GameLifecycleGame } from '../game-lifecycle/game-lifecycle.api';
|
|
7
7
|
import { IHost } from '../host';
|
|
8
8
|
|
|
9
|
+
export declare type ShowInterstitialAdOptions = {
|
|
10
|
+
duration?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare type ShowRewardAdOptions = {
|
|
13
|
+
duration?: number;
|
|
14
|
+
context?: 'core' | 'default';
|
|
15
|
+
data?: any;
|
|
16
|
+
};
|
|
9
17
|
/** @hidden */
|
|
10
18
|
export interface AdsArena extends Ads, AdsArenaBanner {
|
|
11
19
|
}
|
|
@@ -46,19 +54,16 @@ export declare class AdsArenaProvider implements AdsArena {
|
|
|
46
54
|
showBannerAd(options: BannerAdOptions): any;
|
|
47
55
|
}
|
|
48
56
|
export declare class AdsGameProvider implements AdsGame {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
private
|
|
52
|
-
private
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}): Promise<
|
|
57
|
-
showRewardAd({ duration }?: {
|
|
58
|
-
duration?: number | undefined;
|
|
59
|
-
}): Promise<{
|
|
57
|
+
private readonly lifecycle;
|
|
58
|
+
readonly bannerSizes: typeof AdTypes;
|
|
59
|
+
private readonly interstitial;
|
|
60
|
+
private readonly rewarded;
|
|
61
|
+
private readonly banner;
|
|
62
|
+
constructor(rpcProvider: RpcProvider, env: ApiEnv, auth: Auth, lifecycle: GameLifecycleGame);
|
|
63
|
+
showInterstitialAd({ duration }?: ShowInterstitialAdOptions): Promise<void>;
|
|
64
|
+
showRewardAd({ duration, context, data }?: ShowRewardAdOptions): Promise<{
|
|
60
65
|
value: number;
|
|
61
66
|
}>;
|
|
62
|
-
showBannerAd(adId: string, dimensions: AdTypes[]):
|
|
67
|
+
showBannerAd(adId: string, dimensions: AdTypes[]): Promise<void>;
|
|
63
68
|
}
|
|
64
69
|
export {};
|
|
@@ -17,7 +17,10 @@ export declare enum LifecycleEvent {
|
|
|
17
17
|
AD_REWARDED_REQUESTED = 12,
|
|
18
18
|
AD_REWARDED_SHOWN = 13,
|
|
19
19
|
LEVEL_START = 14,
|
|
20
|
-
LEVEL_END = 15
|
|
20
|
+
LEVEL_END = 15,
|
|
21
|
+
REDEEM_POWERUP = 16,
|
|
22
|
+
OPT_LOG_IN = 17,
|
|
23
|
+
REWARD_START = 18
|
|
21
24
|
}
|
|
22
25
|
declare type LifecycleFn = (event: LifecycleEvent, payload?: any) => void;
|
|
23
26
|
declare global {
|
|
@@ -34,7 +37,7 @@ export declare class GameLifecycleArena {
|
|
|
34
37
|
LifecycleEvent: typeof LifecycleEvent;
|
|
35
38
|
constructor(rpcProvider: RpcProvider, host: IHost);
|
|
36
39
|
setVirtualItemsApiProvider(provider: VirtualItemsApiProvider): void;
|
|
37
|
-
onEvent(event: LifecycleEvent, payload?: any): Promise<
|
|
40
|
+
onEvent(event: LifecycleEvent, payload?: any): Promise<any>;
|
|
38
41
|
dispatchEvent(event: LifecycleEvent): Promise<void>;
|
|
39
42
|
subscribe(cb: LifecycleFn, override?: boolean): void;
|
|
40
43
|
onFtueEvent(eventId: string): Promise<boolean>;
|
|
@@ -54,6 +57,7 @@ export declare class GameLifecycleGame {
|
|
|
54
57
|
LifecycleEvent: typeof LifecycleEvent;
|
|
55
58
|
constructor(rpcProvider: RpcProvider);
|
|
56
59
|
private onEvent;
|
|
60
|
+
private getExecutionTimeLimitMs;
|
|
57
61
|
dispatchEvent(event: LifecycleEvent, payload?: any): Promise<any>;
|
|
58
62
|
onTestReady(): Promise<void>;
|
|
59
63
|
onGameStart(): Promise<void>;
|
|
@@ -75,5 +79,11 @@ export declare class GameLifecycleGame {
|
|
|
75
79
|
onLevelEnd(level: number): Promise<void>;
|
|
76
80
|
registerEventCallback(event: LifecycleEvent, callback: () => void): void;
|
|
77
81
|
onFtueEvent(eventId: string): Promise<boolean>;
|
|
82
|
+
onRedeemPowerup(data: any): Promise<any>;
|
|
83
|
+
onOptLogin(data: any): Promise<any>;
|
|
84
|
+
onRewardStart(data: any): Promise<any>;
|
|
85
|
+
private getPromiseForEvent;
|
|
86
|
+
private getCallbackType;
|
|
87
|
+
private setupPostMessageHandler;
|
|
78
88
|
}
|
|
79
89
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DebugProvider } from '../../core/debug-provider';
|
|
2
2
|
import { RpcProvider } from '../../core/rpc';
|
|
3
|
+
import { ObserverFn } from '../../utils/observable';
|
|
3
4
|
|
|
4
5
|
export declare enum ArenaType {
|
|
5
6
|
ARKCOM = "ARKCOM",
|
|
@@ -34,6 +35,11 @@ declare class WebEnvironmentDetails {
|
|
|
34
35
|
constructor(siteName?: string, siteDomain?: string, referrer?: string, activeLocale?: string, devEnvironment?: string, darkMode?: boolean);
|
|
35
36
|
clone(p: Partial<WebEnvironmentDetails>): WebEnvironmentDetails;
|
|
36
37
|
}
|
|
38
|
+
export declare type UrlState = {
|
|
39
|
+
url: 'string';
|
|
40
|
+
params?: URLSearchParams;
|
|
41
|
+
};
|
|
42
|
+
export declare type UrlStateUnsubscribeFn = () => void;
|
|
37
43
|
/** @hidden */
|
|
38
44
|
export declare class HostArena implements IHost {
|
|
39
45
|
private rpcProvider;
|
|
@@ -41,6 +47,7 @@ export declare class HostArena implements IHost {
|
|
|
41
47
|
private gameIdOverride;
|
|
42
48
|
private data;
|
|
43
49
|
private openRequest;
|
|
50
|
+
private readonly urlState;
|
|
44
51
|
/**
|
|
45
52
|
* @internal
|
|
46
53
|
*/
|
|
@@ -63,10 +70,14 @@ export declare class HostArena implements IHost {
|
|
|
63
70
|
width: number;
|
|
64
71
|
height: number;
|
|
65
72
|
}>;
|
|
73
|
+
sendUrlState(urlState: UrlState): Promise<void>;
|
|
74
|
+
private updateUrlState;
|
|
75
|
+
subscribeToUrlStateChange(observer: ObserverFn<UrlState | undefined>): UrlStateUnsubscribeFn;
|
|
66
76
|
}
|
|
67
77
|
export declare class HostGame implements IHost {
|
|
68
78
|
private rpcProvider;
|
|
69
79
|
private purchaseFormState;
|
|
80
|
+
private readonly urlState;
|
|
70
81
|
/**
|
|
71
82
|
* @internal
|
|
72
83
|
*/
|
|
@@ -90,5 +101,8 @@ export declare class HostGame implements IHost {
|
|
|
90
101
|
height: number;
|
|
91
102
|
}>;
|
|
92
103
|
getGameAssetsUrl(): string;
|
|
104
|
+
sendUrlState(urlState: UrlState): Promise<void>;
|
|
105
|
+
private updateUrlState;
|
|
106
|
+
subscribeToUrlStateChange(observer: ObserverFn<UrlState | undefined>): UrlStateUnsubscribeFn;
|
|
93
107
|
}
|
|
94
108
|
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare type ValidationResult = {
|
|
2
|
+
valid: true;
|
|
3
|
+
} | {
|
|
4
|
+
valid: false;
|
|
5
|
+
expected: string;
|
|
6
|
+
received: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type ArgumentValidator = (value: unknown) => ValidationResult;
|
|
9
|
+
/**
|
|
10
|
+
* Schema primitives for defining object shapes. Use these as the single source of truth:
|
|
11
|
+
* define the schema once, derive the type with InferSchema, and pass to schema() for validation.
|
|
12
|
+
*/
|
|
13
|
+
export declare type SchemaPrimitive = 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
14
|
+
/**
|
|
15
|
+
* Infers a TypeScript type from a schema object. Use with: type T = InferSchema<typeof mySchema>
|
|
16
|
+
*/
|
|
17
|
+
export declare type InferSchema<T> = T extends Record<string, SchemaPrimitive> ? {
|
|
18
|
+
[K in keyof T]: SchemaPrimitiveToType<T[K]>;
|
|
19
|
+
} : never;
|
|
20
|
+
declare type SchemaPrimitiveToType<P> = P extends 'string' ? string : P extends 'number' ? number : P extends 'boolean' ? boolean : P extends 'object' ? Record<string, unknown> : P extends 'array' ? unknown[] : never;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a validator from a schema object. The schema is the single source of truth:
|
|
23
|
+
* use InferSchema<typeof schema> for the type and schema(schema) for the decorator.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const UrlStateSchema = { url: 'string' } as const;
|
|
27
|
+
* type UrlState = InferSchema<typeof UrlStateSchema>;
|
|
28
|
+
* @ValidateInput(schema(UrlStateSchema))
|
|
29
|
+
* private updateUrlState(urlState: UrlState): void { ... }
|
|
30
|
+
*/
|
|
31
|
+
export declare function schema<T extends Record<string, SchemaPrimitive>>(shape: T): ArgumentValidator;
|
|
32
|
+
/**
|
|
33
|
+
* Decorator that validates method arguments before invocation.
|
|
34
|
+
* Pass one validator per argument in order.
|
|
35
|
+
* Throws an Error with details about which argument(s) failed validation.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* @ValidateInput(schema(UrlStateSchema))
|
|
39
|
+
* private updateUrlState(urlState: UrlState): void { ... }
|
|
40
|
+
*/
|
|
41
|
+
export declare function ValidateInput(...validators: ArgumentValidator[]): (_target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
42
|
+
export {};
|