@jolibox/implement 1.1.25 → 1.1.27

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.
Files changed (40) hide show
  1. package/.rush/temp/package-deps_build.json +21 -16
  2. package/dist/common/context/index.d.ts +1 -0
  3. package/dist/common/context/url-parse.d.ts +1 -0
  4. package/dist/common/report/task-track/index.d.ts +1 -1
  5. package/dist/h5/api/base.d.ts +1 -1
  6. package/dist/h5/api/storage.d.ts +1 -1
  7. package/dist/index.js +41 -22
  8. package/dist/index.native.js +115 -99
  9. package/dist/native/api/base.d.ts +1 -1
  10. package/dist/native/api/keyboard.d.ts +3 -3
  11. package/dist/native/api/login.d.ts +1 -1
  12. package/dist/native/api/storage.d.ts +5 -5
  13. package/dist/native/payment/index.d.ts +4 -0
  14. package/dist/native/payment/payment-helper.d.ts +13 -0
  15. package/dist/native/payment/registers/base.d.ts +21 -0
  16. package/dist/native/payment/registers/joli-coin.d.ts +17 -0
  17. package/dist/native/payment/registers/type.d.ts +14 -0
  18. package/dist/native/report/task-tracker.d.ts +1 -1
  19. package/implement.build.log +2 -2
  20. package/package.json +5 -5
  21. package/src/common/context/index.ts +3 -0
  22. package/src/common/context/url-parse.ts +1 -0
  23. package/src/common/report/task-track/index.ts +3 -2
  24. package/src/common/rewards/registers/use-jolicoin-only.ts +4 -4
  25. package/src/common/rewards/registers/use-jolicoin.ts +4 -4
  26. package/src/h5/api/ads.ts +10 -1
  27. package/src/h5/api/task.ts +43 -131
  28. package/src/h5/http/index.ts +4 -1
  29. package/src/native/api/ads.ts +15 -2
  30. package/src/native/api/storage.ts +9 -7
  31. package/src/native/api/task.ts +41 -159
  32. package/src/native/bootstrap/index.ts +2 -0
  33. package/src/native/payment/index.ts +5 -0
  34. package/src/native/payment/payment-helper.ts +44 -0
  35. package/src/native/payment/registers/base.ts +97 -0
  36. package/src/native/payment/registers/joli-coin.ts +83 -0
  37. package/src/native/payment/registers/type.ts +15 -0
  38. package/src/native/report/task-tracker.ts +1 -1
  39. package/src/native/rewards/check-frequency.ts +28 -15
  40. 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>;
@@ -1,4 +1,4 @@
1
1
  export declare const login: (...inputs: unknown[]) => Promise<import("@jolibox/types").StandardResponse<{
2
2
  isLogin: boolean;
3
3
  token?: string;
4
- }>>;
4
+ }, 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' | 'TaskEvent';
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>;
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.25 clean
3
+ > @jolibox/implement@1.1.27 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.25 build:esm
7
+ > @jolibox/implement@1.1.27 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.25",
4
+ "version": "1.1.27",
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.25",
10
- "@jolibox/types": "1.1.25",
11
- "@jolibox/native-bridge": "1.1.25",
12
- "@jolibox/ads": "1.1.25",
9
+ "@jolibox/common": "1.1.27",
10
+ "@jolibox/types": "1.1.27",
11
+ "@jolibox/native-bridge": "1.1.27",
12
+ "@jolibox/ads": "1.1.27",
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
  },
@@ -22,6 +22,7 @@ interface PayloadJson {
22
22
  __from?: number; // 从哪个小程序打开的
23
23
  __testAdsMode?: boolean;
24
24
  __joliboxEnv?: 'staging' | 'production';
25
+ [property: string]: any;
25
26
  }
26
27
 
27
28
  interface Signature {
@@ -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>;
@@ -34,13 +34,13 @@ export const createJolicoinOnlyRewardHandler = (
34
34
  })();
35
35
 
36
36
  const showUnlockWithJolicoinModal = createShowUnlockWithJolicoinModal('JOLI_COIN', {
37
- confirmButtonText: 'Use Jolicoin',
38
- cancelButtonText: 'No thanks'
37
+ confirmButtonText: 'jolicoin.useJolicoin',
38
+ cancelButtonText: 'jolicoin.noThanks'
39
39
  });
40
40
 
41
41
  const initiateAndAwaitPayment = createInitiateAndAwaitPayment('JOLI_COIN', {
42
- confirmButtonText: 'Pay and unlock',
43
- cancelButtonText: 'No thanks'
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: 'Use Jolicoin',
30
- cancelButtonText: 'No watch ads'
29
+ confirmButtonText: 'jolicoin.useJolicoin',
30
+ cancelButtonText: 'jolicoin.noWatchAds'
31
31
  });
32
32
 
33
33
  const initiateAndAwaitPayment = createInitiateAndAwaitPayment('ADS-JOLI_COIN', {
34
- confirmButtonText: 'Pay and unlock',
35
- cancelButtonText: 'No watch ads'
34
+ confirmButtonText: 'jolicoin.payAndUnlock',
35
+ cancelButtonText: 'jolicoin.noWatchAds'
36
36
  });
37
37
 
38
38
  const jolicoinOnlyRewardHandler = createCommonJolicoinRewardHandler(httpClient, {
package/src/h5/api/ads.ts CHANGED
@@ -25,6 +25,14 @@ const adsContext: IAdsContext<'GAME'> = {
25
25
  checkNetwork: () => httpClientManager.getNetworkStatus(),
26
26
  track,
27
27
  eventEmitter: adEventEmitter,
28
+ getWindowInfo: () => ({
29
+ width: window.innerWidth * window.devicePixelRatio,
30
+ height: window.innerHeight * window.devicePixelRatio,
31
+ statusBarHeight: 0
32
+ }),
33
+ handleLinkClicked: (link) => {
34
+ window.open(link, '_blank');
35
+ },
28
36
  getContextInfo: () => {
29
37
  return {
30
38
  hostAppId: context.hostInfo?.aid ?? '1',
@@ -40,7 +48,8 @@ const adsContext: IAdsContext<'GAME'> = {
40
48
  deviceModel: context.deviceInfo.model,
41
49
  osType: platform.isAndroid ? 'ANDROID' : platform.isiOS ? 'IOS' : 'PC',
42
50
  runtimeType: 'WEB',
43
- platform: 1000 // WebSDK
51
+ platform: 1000, // WebSDK
52
+ joliSource: context.joliSource ?? ''
44
53
  };
45
54
  }
46
55
  };
@@ -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
- result: t.boolean(),
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 (levelId, parmas) => {
17
- const { result, duration } = parmas;
18
- logger.info(`onLevelFinished`, result, duration);
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
- result,
26
- duration
25
+ duration,
26
+ rating,
27
+ score
27
28
  })
28
29
  ]);
29
30
  }
30
31
  });
31
32
 
32
- const onTaskFinished = createAPI('taskFinished', {
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 (taskId, params) => {
40
- const { duration } = params;
41
- await taskTracker.tracker('TaskFinished', {
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
- taskId
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 onTaskEvent = createAPI('taskEvent', {
52
+ const onLevelUpgrade = createAPI('levelUpgrade', {
77
53
  paramsSchema: t.tuple(
78
- t.string(),
79
54
  t.object({
80
- tools: t
81
- .array(
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 (taskId, params) => {
107
- if (params.tools?.length) {
108
- await Promise.all([
109
- taskTracker.reporter({
110
- event: 'USE_GAME_ITEM'
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.taskFinished', onTaskFinished);
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.0.0',
72
+ version: '1.1.25',
130
73
  properties: {
131
- levelId: '1.0.0',
132
74
  params: {
133
- result: '1.0.0',
134
- duration: '1.0.0'
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.onTaskFinished', {
140
- version: '1.0.0',
83
+ registerCanIUse('TaskTrackerSDK.onGamePlayEnded', {
84
+ version: '1.1.25',
141
85
  properties: {
142
- taskId: '1.0.0',
143
- duration: '1.0.0'
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.0.0',
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
- tools: {
175
- id: '1.0.0',
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
  });
@@ -1,6 +1,7 @@
1
1
  import { IHttpClient } from '@/common/http';
2
2
  import { xUserAgent } from '../../common/http/xua';
3
3
  import { context } from '@/common/context';
4
+ import { platform } from '@jolibox/common';
4
5
 
5
6
  declare global {
6
7
  interface Window {
@@ -131,7 +132,9 @@ class JoliboxHttpClient implements IHttpClient {
131
132
  headers ?? {},
132
133
  { 'Content-Type': 'application/json' },
133
134
  xua ? { 'x-user-agent': xua } : {},
134
- joliSource ? { 'x-joli-source': joliSource } : {}
135
+ joliSource ? { 'x-joli-source': joliSource } : {},
136
+ { 'x-os-type': platform.isAndroid ? 'ANDROID' : platform.isiOS ? 'IOS' : 'PC' },
137
+ { 'x-runtime-type': 'WEB' }
135
138
  );
136
139
  const response = await fetch(url, {
137
140
  method: 'POST',
@@ -54,6 +54,15 @@ const adsContext: IAdsContext<'GAME'> = {
54
54
  checkNetwork: checkNetworkStatus,
55
55
  track,
56
56
  eventEmitter: adEventEmitter,
57
+ // TODO: @Deng Xue
58
+ getWindowInfo: () => ({
59
+ width: window.innerWidth * window.devicePixelRatio,
60
+ height: window.innerHeight * window.devicePixelRatio,
61
+ statusBarHeight: 30
62
+ }),
63
+ handleLinkClicked: (link) => {
64
+ window.open(link, '_blank');
65
+ },
57
66
  getContextInfo: () => {
58
67
  return {
59
68
  hostAppId: context.hostInfo?.aid ?? '1',
@@ -69,7 +78,8 @@ const adsContext: IAdsContext<'GAME'> = {
69
78
  deviceModel: context.deviceInfo.model,
70
79
  osType: context.platform === 'android' ? 'ANDROID' : context.platform === 'ios' ? 'IOS' : 'PC',
71
80
  runtimeType: 'APP',
72
- platform: 1000 // WebSDK
81
+ platform: 1000, // WebSDK
82
+ joliSource: context.joliSource ?? ''
73
83
  };
74
84
  }
75
85
  };
@@ -107,12 +117,15 @@ rewardsHelper.registerRewardHandler(
107
117
 
108
118
  const showUnlockSuccessToast = (params: { quantity: number; balance: number }) => {
109
119
  const { quantity } = params;
110
- const toastTemplate = `{slot-coin} ${quantity} JoliCoins used`;
120
+ const toastTemplate = `{slot-coin} ${quantity} {slot-i18n-jolicoin.coinUsed}`;
111
121
  createToast(toastTemplate, {
112
122
  customStyle: {
113
123
  mark: {
114
124
  marginRight: '8px'
115
125
  }
126
+ },
127
+ i18nParams: {
128
+ text: 'Jolicoin Used'
116
129
  }
117
130
  });
118
131
  };
@@ -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
- const type = Object.prototype.toString
236
- .call(data)
237
- .split(' ')[1]
238
- .split(']')[0]
239
- .toLocaleLowerCase() as DataType;
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 { data, dataType } = await applyNative('getGlobalStorageAsync', { key });
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);