@jolibox/implement 1.1.24 → 1.1.26
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/.rush/temp/package-deps_build.json +19 -14
- package/dist/common/context/index.d.ts +1 -0
- package/dist/common/context/url-parse.d.ts +1 -0
- package/dist/common/report/task-track/index.d.ts +1 -1
- package/dist/h5/api/base.d.ts +1 -1
- package/dist/h5/api/storage.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.native.js +119 -103
- package/dist/native/api/base.d.ts +1 -1
- package/dist/native/api/keyboard.d.ts +3 -3
- package/dist/native/api/login.d.ts +1 -1
- package/dist/native/api/storage.d.ts +5 -5
- package/dist/native/payment/index.d.ts +4 -0
- package/dist/native/payment/payment-helper.d.ts +13 -0
- package/dist/native/payment/registers/base.d.ts +21 -0
- package/dist/native/payment/registers/joli-coin.d.ts +17 -0
- package/dist/native/payment/registers/type.d.ts +14 -0
- package/dist/native/report/task-tracker.d.ts +1 -1
- package/implement.build.log +2 -2
- package/package.json +5 -5
- package/src/common/context/index.ts +3 -0
- package/src/common/context/url-parse.ts +1 -0
- package/src/common/report/task-track/index.ts +5 -3
- package/src/common/rewards/registers/use-jolicoin-only.ts +4 -4
- package/src/common/rewards/registers/use-jolicoin.ts +4 -4
- package/src/h5/api/task.ts +43 -131
- package/src/native/api/ads.ts +4 -1
- package/src/native/api/storage.ts +9 -7
- package/src/native/api/task.ts +41 -159
- package/src/native/bootstrap/index.ts +2 -0
- package/src/native/payment/index.ts +5 -0
- package/src/native/payment/payment-helper.ts +44 -0
- package/src/native/payment/registers/base.ts +97 -0
- package/src/native/payment/registers/joli-coin.ts +83 -0
- package/src/native/payment/registers/type.ts +15 -0
- package/src/native/report/task-tracker.ts +1 -1
- package/src/native/rewards/check-frequency.ts +28 -15
- package/src/native/rewards/index.ts +8 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const createAPI: <ParamsSchema extends import("@/common/api-factory/validator").Validator<unknown[]>, Inputs extends import("@/common/api-factory/validator").Type<ParamsSchema> & unknown[], Return>(method: string, config: {
|
|
2
2
|
paramsSchema?: ParamsSchema;
|
|
3
|
-
implement: Inputs extends undefined ? () => Promise<Return | import("@jolibox/types").StandardResponse<Return>> : (...params: Inputs) => Promise<Return | import("@jolibox/types").StandardResponse<Return>>;
|
|
3
|
+
implement: Inputs extends undefined ? () => Promise<Return | import("@jolibox/types").StandardResponse<Return, unknown>> : (...params: Inputs) => Promise<Return | import("@jolibox/types").StandardResponse<Return, unknown>>;
|
|
4
4
|
}) => (...inputs: unknown[]) => Promise<import("@jolibox/types").StandardResponse<Return>>, createSyncAPI: <ParamsSchema extends import("@/common/api-factory/validator").Validator<unknown[]>, Inputs extends import("@/common/api-factory/validator").Type<ParamsSchema> & unknown[], Return = void>(method: string, config: {
|
|
5
5
|
paramsSchema?: ParamsSchema;
|
|
6
6
|
implement: (...inputs: Inputs) => Return | {
|
|
@@ -2,8 +2,8 @@ export declare const showKeyboard: (params: {
|
|
|
2
2
|
defaultValue?: string | undefined;
|
|
3
3
|
multiple?: boolean | undefined;
|
|
4
4
|
maxLength?: unknown;
|
|
5
|
-
}) => import("@jolibox/types").StandardResponse<void>;
|
|
5
|
+
}) => import("@jolibox/types").StandardResponse<void, unknown>;
|
|
6
6
|
export declare const updateKeyboard: (params: {
|
|
7
7
|
value: string;
|
|
8
|
-
}) => import("@jolibox/types").StandardResponse<void>;
|
|
9
|
-
export declare const hideKeyboard: () => import("@jolibox/types").StandardResponse<void>;
|
|
8
|
+
}) => import("@jolibox/types").StandardResponse<void, unknown>;
|
|
9
|
+
export declare const hideKeyboard: () => import("@jolibox/types").StandardResponse<void, unknown>;
|
|
@@ -2,7 +2,7 @@ import { StandardResponse } from '@jolibox/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 移除指定key
|
|
4
4
|
*/
|
|
5
|
-
export declare const removeStorage: (...inputs: unknown[]) => Promise<StandardResponse<void>>;
|
|
5
|
+
export declare const removeStorage: (...inputs: unknown[]) => Promise<StandardResponse<void, unknown>>;
|
|
6
6
|
/**
|
|
7
7
|
* 异步获取当前storage的相关信息
|
|
8
8
|
*/
|
|
@@ -10,7 +10,7 @@ export declare const getStorageInfo: (...inputs: unknown[]) => Promise<StandardR
|
|
|
10
10
|
currentSize: number;
|
|
11
11
|
limitSize: number;
|
|
12
12
|
keys: string[];
|
|
13
|
-
}>>;
|
|
13
|
+
}, unknown>>;
|
|
14
14
|
/**
|
|
15
15
|
* 同步获取当前storage的相关信息
|
|
16
16
|
*/
|
|
@@ -22,9 +22,9 @@ export declare const getStorageInfoSync: () => StandardResponse<{
|
|
|
22
22
|
limitSize: number;
|
|
23
23
|
keys: string[];
|
|
24
24
|
};
|
|
25
|
-
}>;
|
|
26
|
-
export declare const getGlobalStorage: (...inputs: unknown[]) => Promise<StandardResponse<any>>;
|
|
25
|
+
}, unknown>;
|
|
26
|
+
export declare const getGlobalStorage: (...inputs: unknown[]) => Promise<StandardResponse<any, unknown>>;
|
|
27
27
|
export declare const setGlobalStorage: (...inputs: unknown[]) => Promise<StandardResponse<{
|
|
28
28
|
code: string;
|
|
29
29
|
message: string;
|
|
30
|
-
}>>;
|
|
30
|
+
}, unknown>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const paymentHelper: {
|
|
2
|
+
registerPaymentHandler<T extends import("./payment-helper").PaymentType>(type: T, handler: import("./payment-helper").PaymentHandler<T>): void;
|
|
3
|
+
invokePayment<T extends import("./payment-helper").PaymentType>(type: T, ...args: Parameters<import("./payment-helper").PaymentHandler<T>>): Promise<any>;
|
|
4
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PaymentType = 'JOLI_COIN';
|
|
2
|
+
import { StandardResponse } from '@jolibox/types';
|
|
3
|
+
type PaymentResult = StandardResponse<void>;
|
|
4
|
+
export interface PaymentHandlerMap {
|
|
5
|
+
JOLI_COIN: (productId: string) => Promise<PaymentResult>;
|
|
6
|
+
}
|
|
7
|
+
export type PaymentHandler<T extends PaymentType> = PaymentHandlerMap[T];
|
|
8
|
+
export declare function createPaymentHelper(): {
|
|
9
|
+
registerPaymentHandler<T extends PaymentType>(type: T, handler: PaymentHandler<T>): void;
|
|
10
|
+
invokePayment<T extends PaymentType>(type: T, ...args: Parameters<PaymentHandler<T>>): Promise<any>;
|
|
11
|
+
};
|
|
12
|
+
export type PaymentHelper = ReturnType<typeof createPaymentHelper>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StandardResponse } from '@jolibox/types';
|
|
2
|
+
import type { IPlaceOrderJoliCoinParamas, IJoliCoinProductInfo, IJolicoinPaymentContext } from './joli-coin';
|
|
3
|
+
import type { IPlaceOrderResponse } from './type';
|
|
4
|
+
type PaymentStatus = 'INIT' | 'PENDING' | 'SUCCESS' | 'FAILED';
|
|
5
|
+
import { UserPaymentError, InternalPaymentError } from '@jolibox/common';
|
|
6
|
+
type IPlaceOrderParams = IPlaceOrderJoliCoinParamas;
|
|
7
|
+
type IOrderProductInfo = IJoliCoinProductInfo;
|
|
8
|
+
type IOrderPaymentContext = IJolicoinPaymentContext;
|
|
9
|
+
declare const createPaymentError: (errMsg: string, errNo: number, extra?: Record<string, unknown>) => UserPaymentError | InternalPaymentError, createPaymentInternalError: (errMsg: string, errNo: number, extra?: Record<string, unknown>) => UserPaymentError | InternalPaymentError;
|
|
10
|
+
export { createPaymentError, createPaymentInternalError };
|
|
11
|
+
export declare abstract class BasePaymentRegister<T extends IPlaceOrderParams, E extends IOrderProductInfo> {
|
|
12
|
+
private _orderId;
|
|
13
|
+
private _orderStatus;
|
|
14
|
+
startPayment: (params: T) => Promise<void>;
|
|
15
|
+
cancelOrder: (orderId: string) => Promise<void>;
|
|
16
|
+
private generateCallbackUrl;
|
|
17
|
+
abstract placeOrder(params: T): Promise<StandardResponse<IPlaceOrderResponse<E>>>;
|
|
18
|
+
abstract generatePaymentContext(): IOrderPaymentContext;
|
|
19
|
+
get orderId(): string | null;
|
|
20
|
+
get status(): PaymentStatus;
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ResponseType } from '@jolibox/types';
|
|
2
|
+
export interface IPlaceOrderJoliCoinParamas {
|
|
3
|
+
productId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface IJoliCoinProductInfo {
|
|
6
|
+
quantity: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IJolicoinPaymentContext {
|
|
9
|
+
type: 'JOLI_COIN_ORDER_CONTEXT';
|
|
10
|
+
state: 'TO_CHECKOUT' | 'TO_VALIDATE';
|
|
11
|
+
productId: string;
|
|
12
|
+
orderId: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const createJolicoinPaymentHandler: () => (productId: string) => Promise<{
|
|
15
|
+
code: ResponseType;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type OrderStatus = 'PENDING' | 'PAYING' | 'PAYMENT_FAILED' | 'PAYMENT_SUCCESS' | 'PAYMENT_CLOSED';
|
|
2
|
+
export interface IPlaceOrderResponse<T> {
|
|
3
|
+
orderId: string;
|
|
4
|
+
status: OrderStatus;
|
|
5
|
+
totalAmountStr: string;
|
|
6
|
+
joliBizType: 'DRAMA' | 'JOLI_COIN';
|
|
7
|
+
productInfo: T;
|
|
8
|
+
}
|
|
9
|
+
export declare enum PaymentErrorCodeMap {
|
|
10
|
+
PlaceOrderFailed = 1001,
|
|
11
|
+
JolicoinPlaceOrderRequestFailed = 1002,
|
|
12
|
+
CancelOrderFailed = 1003
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -5,7 +5,7 @@ import { TaskTracker, TaskPoint } from '@/common/report/task-track';
|
|
|
5
5
|
import { EventEmitter } from '@jolibox/common';
|
|
6
6
|
import type { Track } from '.';
|
|
7
7
|
import type { TrackEvent } from '@jolibox/types';
|
|
8
|
-
type NativeTaskPointEvent = 'OpenGame' | 'CloseGame' | 'LevelFinished' | 'TaskFinished' | 'LevelUpgrade' | 'HistoryUserLevel' | 'HistoryUserScore' | 'UseGameItem' | '
|
|
8
|
+
type NativeTaskPointEvent = 'OpenGame' | 'CloseGame' | 'LevelFinished' | 'TaskFinished' | 'LevelUpgrade' | 'HistoryUserLevel' | 'HistoryUserScore' | 'UseGameItem' | 'GameTaskEvent';
|
|
9
9
|
export type NativeTaskPoint = {
|
|
10
10
|
event: NativeTaskPointEvent;
|
|
11
11
|
params: Record<string, unknown>;
|
package/implement.build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:esm && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/implement@1.1.
|
|
3
|
+
> @jolibox/implement@1.1.26 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.1.
|
|
7
|
+
> @jolibox/implement@1.1.26 build:esm
|
|
8
8
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/implement",
|
|
3
3
|
"description": "This project is Jolibox JS-SDk implement for Native && H5",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.26",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@jolibox/common": "1.1.
|
|
10
|
-
"@jolibox/types": "1.1.
|
|
11
|
-
"@jolibox/native-bridge": "1.1.
|
|
12
|
-
"@jolibox/ads": "1.1.
|
|
9
|
+
"@jolibox/common": "1.1.26",
|
|
10
|
+
"@jolibox/types": "1.1.26",
|
|
11
|
+
"@jolibox/native-bridge": "1.1.26",
|
|
12
|
+
"@jolibox/ads": "1.1.26",
|
|
13
13
|
"localforage": "1.10.0",
|
|
14
14
|
"@jolibox/ui": "1.0.0",
|
|
15
15
|
"web-vitals": "4.2.4"
|
|
@@ -112,6 +112,9 @@ const wrapContext = () => {
|
|
|
112
112
|
get adId(): string {
|
|
113
113
|
return env.deviceInfo.adId ?? env.deviceInfo.did;
|
|
114
114
|
},
|
|
115
|
+
get language(): string {
|
|
116
|
+
return env.deviceInfo.lang;
|
|
117
|
+
},
|
|
115
118
|
onEnvConfigChanged: (newConfig: Partial<Env>) => {
|
|
116
119
|
mergeWith(env, newConfig, mergeArray);
|
|
117
120
|
},
|
|
@@ -6,9 +6,10 @@ type TaskEvent =
|
|
|
6
6
|
| 'PLAY_GAME'
|
|
7
7
|
| 'CLOSE_GAME'
|
|
8
8
|
| 'COMPLETE_GAME_LEVEL'
|
|
9
|
-
| 'USE_GAME_ITEM' //
|
|
9
|
+
| 'USE_GAME_ITEM' // TODO: deprecate
|
|
10
10
|
| 'IN_GAME_PURCHASES' // 游戏内购
|
|
11
|
-
| 'ADS_UNLOCK_GAME'
|
|
11
|
+
| 'ADS_UNLOCK_GAME' // 广告解锁
|
|
12
|
+
| 'GAME_TASK_EVENT'; // 关卡行为
|
|
12
13
|
export type TaskPoint = {
|
|
13
14
|
event: TaskEvent;
|
|
14
15
|
params?: Record<string, unknown>;
|
|
@@ -76,7 +77,8 @@ export abstract class TaskTracker {
|
|
|
76
77
|
const deltaTime = currentTime - lastTime;
|
|
77
78
|
if (deltaTime >= this.interval) {
|
|
78
79
|
if (this.visible) {
|
|
79
|
-
totalTime
|
|
80
|
+
// Flutter WebView affects the execution of setInterval timing tasks. Here we do a simple handling. Each totalTime can accumulate at most this.interval + 1s
|
|
81
|
+
totalTime += Math.min(deltaTime, this.interval + 1000);
|
|
80
82
|
callback(totalTime);
|
|
81
83
|
}
|
|
82
84
|
lastTime = currentTime;
|
|
@@ -34,13 +34,13 @@ export const createJolicoinOnlyRewardHandler = (
|
|
|
34
34
|
})();
|
|
35
35
|
|
|
36
36
|
const showUnlockWithJolicoinModal = createShowUnlockWithJolicoinModal('JOLI_COIN', {
|
|
37
|
-
confirmButtonText: '
|
|
38
|
-
cancelButtonText: '
|
|
37
|
+
confirmButtonText: 'jolicoin.useJolicoin',
|
|
38
|
+
cancelButtonText: 'jolicoin.noThanks'
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
const initiateAndAwaitPayment = createInitiateAndAwaitPayment('JOLI_COIN', {
|
|
42
|
-
confirmButtonText: '
|
|
43
|
-
cancelButtonText: '
|
|
42
|
+
confirmButtonText: 'jolicoin.payAndUnlock',
|
|
43
|
+
cancelButtonText: 'jolicoin.noThanks'
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
const jolicoinOnlyRewardHandler = createCommonJolicoinRewardHandler(httpClient, {
|
|
@@ -26,13 +26,13 @@ export const createJolicoinRewardHandler = (
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const showUnlockWithJolicoinModal = createShowUnlockWithJolicoinModal('ADS-JOLI_COIN', {
|
|
29
|
-
confirmButtonText: '
|
|
30
|
-
cancelButtonText: '
|
|
29
|
+
confirmButtonText: 'jolicoin.useJolicoin',
|
|
30
|
+
cancelButtonText: 'jolicoin.noWatchAds'
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
const initiateAndAwaitPayment = createInitiateAndAwaitPayment('ADS-JOLI_COIN', {
|
|
34
|
-
confirmButtonText: '
|
|
35
|
-
cancelButtonText: '
|
|
34
|
+
confirmButtonText: 'jolicoin.payAndUnlock',
|
|
35
|
+
cancelButtonText: 'jolicoin.noWatchAds'
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
const jolicoinOnlyRewardHandler = createCommonJolicoinRewardHandler(httpClient, {
|
package/src/h5/api/task.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createCommands, logger } from '@jolibox/common';
|
|
2
|
-
|
|
3
2
|
import { createAPI, registerCanIUse, t } from './base';
|
|
4
3
|
import { taskTracker } from '../report';
|
|
5
4
|
|
|
@@ -7,184 +6,97 @@ const commands = createCommands();
|
|
|
7
6
|
|
|
8
7
|
const onLevelFinished = createAPI('levelFinished', {
|
|
9
8
|
paramsSchema: t.tuple(
|
|
10
|
-
t.string(),
|
|
11
9
|
t.object({
|
|
12
|
-
|
|
13
|
-
duration: t.number()
|
|
10
|
+
levelId: t.or(t.string(), t.number()),
|
|
11
|
+
duration: t.number().optional(),
|
|
12
|
+
rating: t.number().optional(),
|
|
13
|
+
score: t.number().optional()
|
|
14
14
|
})
|
|
15
15
|
),
|
|
16
|
-
implement: async (
|
|
17
|
-
const {
|
|
18
|
-
logger.info(`onLevelFinished`,
|
|
16
|
+
implement: async (parmas) => {
|
|
17
|
+
const { levelId, duration, rating, score } = parmas;
|
|
18
|
+
logger.info(`onLevelFinished`, duration, rating, score);
|
|
19
19
|
await Promise.all([
|
|
20
20
|
taskTracker.reporter({
|
|
21
21
|
event: 'COMPLETE_GAME_LEVEL'
|
|
22
22
|
}),
|
|
23
23
|
taskTracker.tracker('LevelFinished', {
|
|
24
24
|
levelId,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
duration,
|
|
26
|
+
rating,
|
|
27
|
+
score
|
|
27
28
|
})
|
|
28
29
|
]);
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
32
|
|
|
32
|
-
const
|
|
33
|
+
const onGamePlayEnded = createAPI('gamePlayEnded', {
|
|
33
34
|
paramsSchema: t.tuple(
|
|
34
|
-
t.string(),
|
|
35
35
|
t.object({
|
|
36
|
-
duration: t.number()
|
|
36
|
+
duration: t.number().optional(),
|
|
37
|
+
rating: t.number().optional(),
|
|
38
|
+
score: t.number()
|
|
37
39
|
})
|
|
38
40
|
),
|
|
39
|
-
implement: async (
|
|
40
|
-
const { duration } = params;
|
|
41
|
-
|
|
41
|
+
implement: async (params) => {
|
|
42
|
+
const { duration, rating, score } = params;
|
|
43
|
+
logger.info(`onGamePlayEnded`, duration, rating, score);
|
|
44
|
+
return taskTracker.tracker('GamePlayEnded', {
|
|
42
45
|
duration,
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const onLevelUpgrade = createAPI('levelUpgrade', {
|
|
49
|
-
paramsSchema: t.tuple(t.string(), t.string()),
|
|
50
|
-
implement: async (levelId, name) => {
|
|
51
|
-
return await taskTracker.tracker('LevelUpgrade', {
|
|
52
|
-
name,
|
|
53
|
-
levelId
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const onHistoryUserLevel = createAPI('onHistoryUserLevel', {
|
|
59
|
-
paramsSchema: t.tuple(t.number()),
|
|
60
|
-
implement: async (level) => {
|
|
61
|
-
return await taskTracker.tracker('HistoryUserLevel', {
|
|
62
|
-
level
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const onHistoryUserScore = createAPI('onHistoryUserScore', {
|
|
68
|
-
paramsSchema: t.tuple(t.number()),
|
|
69
|
-
implement: async (score) => {
|
|
70
|
-
return await taskTracker.tracker('HistoryUserScore', {
|
|
46
|
+
rating,
|
|
71
47
|
score
|
|
72
48
|
});
|
|
73
49
|
}
|
|
74
50
|
});
|
|
75
51
|
|
|
76
|
-
const
|
|
52
|
+
const onLevelUpgrade = createAPI('levelUpgrade', {
|
|
77
53
|
paramsSchema: t.tuple(
|
|
78
|
-
t.string(),
|
|
79
54
|
t.object({
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
t.object({
|
|
83
|
-
id: t.string(),
|
|
84
|
-
name: t.string(),
|
|
85
|
-
count: t.number(),
|
|
86
|
-
description: t.string().optional(),
|
|
87
|
-
price: t
|
|
88
|
-
.object({
|
|
89
|
-
amount: t.number(),
|
|
90
|
-
unit: t.string()
|
|
91
|
-
})
|
|
92
|
-
.optional()
|
|
93
|
-
})
|
|
94
|
-
)
|
|
95
|
-
.optional(),
|
|
96
|
-
awards: t
|
|
97
|
-
.array(
|
|
98
|
-
t.object({
|
|
99
|
-
id: t.string(),
|
|
100
|
-
name: t.string()
|
|
101
|
-
})
|
|
102
|
-
)
|
|
103
|
-
.optional()
|
|
55
|
+
levelId: t.or(t.string(), t.number()),
|
|
56
|
+
name: t.string().optional()
|
|
104
57
|
})
|
|
105
58
|
),
|
|
106
|
-
implement: async (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}),
|
|
112
|
-
taskTracker.tracker('UseGameItem', {
|
|
113
|
-
taskId,
|
|
114
|
-
...params
|
|
115
|
-
})
|
|
116
|
-
]);
|
|
117
|
-
}
|
|
59
|
+
implement: async ({ levelId, name }) => {
|
|
60
|
+
return taskTracker.tracker('LevelUpgrade', {
|
|
61
|
+
name,
|
|
62
|
+
levelId
|
|
63
|
+
});
|
|
118
64
|
}
|
|
119
65
|
});
|
|
120
66
|
|
|
121
67
|
commands.registerCommand('TaskTrackerSDK.levelFinished', onLevelFinished);
|
|
122
|
-
commands.registerCommand('TaskTrackerSDK.
|
|
68
|
+
commands.registerCommand('TaskTrackerSDK.gamePlayEnded', onGamePlayEnded);
|
|
123
69
|
commands.registerCommand('TaskTrackerSDK.levelUpgrade', onLevelUpgrade);
|
|
124
|
-
commands.registerCommand('TaskTrackerSDK.historyUserLevel', onHistoryUserLevel);
|
|
125
|
-
commands.registerCommand('TaskTrackerSDK.historyUserScore', onHistoryUserScore);
|
|
126
|
-
commands.registerCommand('TaskTrackerSDK.taskEvent', onTaskEvent);
|
|
127
70
|
|
|
128
71
|
registerCanIUse('TaskTrackerSDK.onLevelFinished', {
|
|
129
|
-
version: '1.
|
|
72
|
+
version: '1.1.25',
|
|
130
73
|
properties: {
|
|
131
|
-
levelId: '1.0.0',
|
|
132
74
|
params: {
|
|
133
|
-
|
|
134
|
-
duration: '1.
|
|
75
|
+
levelId: '1.1.25',
|
|
76
|
+
duration: '1.1.25',
|
|
77
|
+
rating: '1.1.25',
|
|
78
|
+
score: '1.1.25'
|
|
135
79
|
}
|
|
136
80
|
}
|
|
137
81
|
});
|
|
138
82
|
|
|
139
|
-
registerCanIUse('TaskTrackerSDK.
|
|
140
|
-
version: '1.
|
|
83
|
+
registerCanIUse('TaskTrackerSDK.onGamePlayEnded', {
|
|
84
|
+
version: '1.1.25',
|
|
141
85
|
properties: {
|
|
142
|
-
|
|
143
|
-
|
|
86
|
+
params: {
|
|
87
|
+
duration: '1.1.25',
|
|
88
|
+
rating: '1.1.25',
|
|
89
|
+
score: '1.1.25'
|
|
90
|
+
}
|
|
144
91
|
}
|
|
145
92
|
});
|
|
146
93
|
|
|
147
94
|
registerCanIUse('TaskTrackerSDK.onLevelUpgrade', {
|
|
148
|
-
version: '1.
|
|
149
|
-
properties: {
|
|
150
|
-
levelId: '1.0.0',
|
|
151
|
-
name: '1.0.0'
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
registerCanIUse('TaskTrackerSDK.onHistoryUserLevel', {
|
|
156
|
-
version: '1.0.0',
|
|
157
|
-
properties: {
|
|
158
|
-
level: '1.0.0'
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
registerCanIUse('TaskTrackerSDK.onHistoryUserScore', {
|
|
163
|
-
version: '1.0.0',
|
|
164
|
-
properties: {
|
|
165
|
-
score: '1.0.0'
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
registerCanIUse('TaskTrackerSDK.onTaskEvent', {
|
|
170
|
-
version: '1.0.0',
|
|
95
|
+
version: '1.1.25',
|
|
171
96
|
properties: {
|
|
172
|
-
taskId: '1.0.0',
|
|
173
97
|
params: {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
name: '1.0.0',
|
|
177
|
-
count: '1.0.0',
|
|
178
|
-
description: '1.0.0',
|
|
179
|
-
price: {
|
|
180
|
-
amount: '1.0.0',
|
|
181
|
-
unit: '1.0.0'
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
awards: {
|
|
185
|
-
id: '1.0.0',
|
|
186
|
-
name: '1.0.0'
|
|
187
|
-
}
|
|
98
|
+
levelId: '1.1.25',
|
|
99
|
+
name: '1.1.25'
|
|
188
100
|
}
|
|
189
101
|
}
|
|
190
102
|
});
|
package/src/native/api/ads.ts
CHANGED
|
@@ -107,12 +107,15 @@ rewardsHelper.registerRewardHandler(
|
|
|
107
107
|
|
|
108
108
|
const showUnlockSuccessToast = (params: { quantity: number; balance: number }) => {
|
|
109
109
|
const { quantity } = params;
|
|
110
|
-
const toastTemplate = `{slot-coin} ${quantity}
|
|
110
|
+
const toastTemplate = `{slot-coin} ${quantity} {slot-i18n-jolicoin.coinUsed}`;
|
|
111
111
|
createToast(toastTemplate, {
|
|
112
112
|
customStyle: {
|
|
113
113
|
mark: {
|
|
114
114
|
marginRight: '8px'
|
|
115
115
|
}
|
|
116
|
+
},
|
|
117
|
+
i18nParams: {
|
|
118
|
+
text: 'Jolicoin Used'
|
|
116
119
|
}
|
|
117
120
|
});
|
|
118
121
|
};
|
|
@@ -232,11 +232,11 @@ const DATA_TYPE = [
|
|
|
232
232
|
type DataType = typeof DATA_TYPE[number];
|
|
233
233
|
|
|
234
234
|
function getType(data: unknown): DataType {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
let type = Object.prototype.toString.call(data).split(' ')[1].split(']')[0].toLocaleLowerCase() as DataType;
|
|
236
|
+
|
|
237
|
+
if ((type as string) === 'array') {
|
|
238
|
+
type = 'object' as DataType;
|
|
239
|
+
}
|
|
240
240
|
|
|
241
241
|
if (DATA_TYPE.includes(type)) {
|
|
242
242
|
return type;
|
|
@@ -290,7 +290,9 @@ export const getGlobalStorage = createAPI('getGlobalStorage', {
|
|
|
290
290
|
paramsSchema: t.tuple(t.string()),
|
|
291
291
|
async implement(key) {
|
|
292
292
|
try {
|
|
293
|
-
const {
|
|
293
|
+
const {
|
|
294
|
+
data: { data, dataType }
|
|
295
|
+
} = await applyNative('getGlobalStorageAsync', { key });
|
|
294
296
|
const parsedData = parse(data, dataType);
|
|
295
297
|
return {
|
|
296
298
|
code: 'SUCCESS',
|
|
@@ -308,7 +310,7 @@ export const getGlobalStorage = createAPI('getGlobalStorage', {
|
|
|
308
310
|
});
|
|
309
311
|
|
|
310
312
|
export const setGlobalStorage = createAPI('setGlobalStorage', {
|
|
311
|
-
paramsSchema: t.tuple(t.string(), t.or(t.string(), t.boolean(), t.number())),
|
|
313
|
+
paramsSchema: t.tuple(t.string(), t.or(t.string(), t.boolean(), t.number(), t.array())),
|
|
312
314
|
async implement(key, value) {
|
|
313
315
|
try {
|
|
314
316
|
const dataType = getType(value);
|