@jolibox/sdk 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.
- package/.rush/temp/package-deps_build.json +3 -3
- package/dist/api/get-system-info.d.ts +2 -2
- package/dist/api/login.d.ts +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +207 -166
- package/dist/sdks/storage.d.ts +3 -3
- package/dist/sdks/task.d.ts +44 -20
- package/package.json +3 -3
- package/sdk.build.log +4 -4
- package/src/api/can-i-use.ts +2 -9
- package/src/sdks/task.ts +73 -47
package/dist/sdks/storage.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
2
|
import { StandardResponse, Storage } from '@jolibox/types';
|
|
3
3
|
export declare class StorageSDK extends BaseSDK implements Storage {
|
|
4
|
-
getItem(key: string): Promise<StandardResponse<string | null>>;
|
|
4
|
+
getItem(key: string): Promise<StandardResponse<string | null, unknown>>;
|
|
5
5
|
setItem(key: string, value: number | string | boolean): Promise<StandardResponse<void>>;
|
|
6
|
-
removeItem(key: string): Promise<StandardResponse<void>>;
|
|
7
|
-
clear(): Promise<StandardResponse<void>>;
|
|
6
|
+
removeItem(key: string): Promise<StandardResponse<void, unknown>>;
|
|
7
|
+
clear(): Promise<StandardResponse<void, unknown>>;
|
|
8
8
|
}
|
package/dist/sdks/task.d.ts
CHANGED
|
@@ -1,25 +1,49 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
2
|
import { TaskTracker, TaskResponse } from '@jolibox/types';
|
|
3
3
|
export declare class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Handles completion of a game level by sending analytics data to the backend
|
|
6
|
+
*
|
|
7
|
+
* @param params - Object containing level completion details:
|
|
8
|
+
* @param params.levelId - Unique identifier for the completed level (string or number)
|
|
9
|
+
* @param params.duration - Optional time spent in the level (milliseconds)
|
|
10
|
+
* @param params.rating - Optional user rating for the level
|
|
11
|
+
* @param params.score - Optional final score achieved in the level
|
|
12
|
+
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
13
|
+
* @throws {Promise} Rejects with error if params is not an object
|
|
14
|
+
*/
|
|
15
|
+
onLevelFinished(params: {
|
|
16
|
+
levelId: string | number;
|
|
17
|
+
duration?: number;
|
|
18
|
+
rating?: number;
|
|
19
|
+
score?: number;
|
|
20
|
+
}): Promise<TaskResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Records completion of a gameplay session with final metrics
|
|
23
|
+
*
|
|
24
|
+
* @param params - Object containing gameplay session details:
|
|
25
|
+
* @param params.duration - Optional total time spent in gameplay (milliseconds)
|
|
26
|
+
* @param params.rating - Optional user rating for the gameplay session
|
|
27
|
+
* @param params.score - Mandatory final score achieved during gameplay
|
|
28
|
+
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
29
|
+
* @throws {Promise} Rejects with error if params is not an object
|
|
30
|
+
*/
|
|
31
|
+
onGamePlayEnded(params: {
|
|
32
|
+
duration?: number;
|
|
33
|
+
rating?: number;
|
|
34
|
+
score: number;
|
|
35
|
+
}): Promise<TaskResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Tracks player progression when they upgrade to a new level
|
|
38
|
+
*
|
|
39
|
+
* @param params - Object containing level upgrade details:
|
|
40
|
+
* @param params.levelId - Unique identifier for the new level (string or number)
|
|
41
|
+
* @param params.name - Optional display name for the upgraded level
|
|
42
|
+
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
43
|
+
* @throws {Promise} Rejects with error if params is not an object
|
|
44
|
+
*/
|
|
45
|
+
onLevelUpgrade(params: {
|
|
46
|
+
levelId: string | number;
|
|
47
|
+
name?: string;
|
|
21
48
|
}): Promise<TaskResponse>;
|
|
22
|
-
onLevelUpgrade(levelId: string | number, name: string): Promise<TaskResponse>;
|
|
23
|
-
onHistoryUserLevel(level: number): Promise<TaskResponse>;
|
|
24
|
-
onHistoryUserScore(score: number): Promise<TaskResponse>;
|
|
25
49
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/sdk",
|
|
3
3
|
"description": "This project is common Jolibox JS-SDk interfere",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.27",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"typings": "dist/index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@jolibox/common": "1.1.
|
|
11
|
-
"@jolibox/types": "1.1.
|
|
10
|
+
"@jolibox/common": "1.1.27",
|
|
11
|
+
"@jolibox/types": "1.1.27"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"typescript": "5.7.3",
|
package/sdk.build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/sdk@1.1.
|
|
3
|
+
> @jolibox/sdk@1.1.27 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.1.
|
|
7
|
+
> @jolibox/sdk@1.1.27 build:cjs
|
|
8
8
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
> @jolibox/sdk@1.1.
|
|
11
|
+
> @jolibox/sdk@1.1.27 build:esm
|
|
12
12
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
> @jolibox/sdk@1.1.
|
|
15
|
+
> @jolibox/sdk@1.1.27 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|
package/src/api/can-i-use.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isObject, isString, compareVersion } from '@jolibox/common';
|
|
1
|
+
import { isObject, isString, compareVersion, isNative } from '@jolibox/common';
|
|
3
2
|
import { getCanIUseConfig, get } from '../utils/can-i-use';
|
|
4
3
|
|
|
5
4
|
const __VERSION__ = '__JOLIBOX_LOCAL_SDK_VERSION__'; // mock
|
|
6
5
|
|
|
7
6
|
export function canIUse(schema: string): boolean {
|
|
8
|
-
const env = getEnv();
|
|
9
|
-
const platform = env.data?.deviceInfo?.platform;
|
|
10
|
-
if (!platform) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
7
|
const [name, ...rest] = schema.split(':');
|
|
15
8
|
|
|
16
|
-
const api = getCanIUseConfig(
|
|
9
|
+
const api = getCanIUseConfig(isNative() ? 'native' : 'h5', name);
|
|
17
10
|
|
|
18
11
|
if (!api) return false;
|
|
19
12
|
|
package/src/sdks/task.ts
CHANGED
|
@@ -1,65 +1,91 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
|
-
import { TaskTracker, TaskResponse } from '@jolibox/types';
|
|
2
|
+
import { TaskTracker, TaskResponse, type ResponseType } from '@jolibox/types';
|
|
3
3
|
|
|
4
4
|
export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Handles completion of a game level by sending analytics data to the backend
|
|
7
|
+
*
|
|
8
|
+
* @param params - Object containing level completion details:
|
|
9
|
+
* @param params.levelId - Unique identifier for the completed level (string or number)
|
|
10
|
+
* @param params.duration - Optional time spent in the level (milliseconds)
|
|
11
|
+
* @param params.rating - Optional user rating for the level
|
|
12
|
+
* @param params.score - Optional final score achieved in the level
|
|
13
|
+
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
14
|
+
* @throws {Promise} Rejects with error if params is not an object
|
|
15
|
+
*/
|
|
16
|
+
async onLevelFinished(params: {
|
|
17
|
+
levelId: string | number;
|
|
18
|
+
duration?: number;
|
|
19
|
+
rating?: number;
|
|
20
|
+
score?: number;
|
|
21
|
+
}): Promise<TaskResponse> {
|
|
22
|
+
if (typeof params !== 'object') {
|
|
23
|
+
return Promise.reject({ code: 'FAILURE' as ResponseType, message: 'params must be an object' });
|
|
24
|
+
}
|
|
25
|
+
const { levelId, duration, rating, score } = params;
|
|
6
26
|
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onLevelFinished');
|
|
7
27
|
if (errMsg) {
|
|
8
28
|
return Promise.resolve(errMsg);
|
|
9
29
|
}
|
|
10
|
-
return await this.commands.executeCommand('TaskTrackerSDK.levelFinished',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return await this.commands.executeCommand('TaskTrackerSDK.taskFinished', taskId, { duration });
|
|
30
|
+
return await this.commands.executeCommand('TaskTrackerSDK.levelFinished', {
|
|
31
|
+
levelId,
|
|
32
|
+
duration,
|
|
33
|
+
rating,
|
|
34
|
+
score
|
|
35
|
+
});
|
|
18
36
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
): Promise<TaskResponse> {
|
|
38
|
-
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onTaskEvent');
|
|
39
|
-
if (errMsg) {
|
|
40
|
-
return errMsg;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Records completion of a gameplay session with final metrics
|
|
40
|
+
*
|
|
41
|
+
* @param params - Object containing gameplay session details:
|
|
42
|
+
* @param params.duration - Optional total time spent in gameplay (milliseconds)
|
|
43
|
+
* @param params.rating - Optional user rating for the gameplay session
|
|
44
|
+
* @param params.score - Mandatory final score achieved during gameplay
|
|
45
|
+
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
46
|
+
* @throws {Promise} Rejects with error if params is not an object
|
|
47
|
+
*/
|
|
48
|
+
async onGamePlayEnded(params: {
|
|
49
|
+
duration?: number;
|
|
50
|
+
rating?: number;
|
|
51
|
+
score: number;
|
|
52
|
+
}): Promise<TaskResponse> {
|
|
53
|
+
if (typeof params !== 'object') {
|
|
54
|
+
return Promise.reject({ code: 'FAILURE' as ResponseType, message: 'params must be an object' });
|
|
41
55
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
async onLevelUpgrade(levelId: string | number, name: string): Promise<TaskResponse> {
|
|
45
|
-
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onLevelUpgrade');
|
|
56
|
+
const { duration, rating, score } = params;
|
|
57
|
+
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onGamePlayEnded');
|
|
46
58
|
if (errMsg) {
|
|
47
|
-
return errMsg;
|
|
59
|
+
return Promise.resolve(errMsg);
|
|
48
60
|
}
|
|
49
|
-
return await this.commands.executeCommand('TaskTrackerSDK.
|
|
61
|
+
return await this.commands.executeCommand('TaskTrackerSDK.gamePlayEnded', {
|
|
62
|
+
duration,
|
|
63
|
+
rating,
|
|
64
|
+
score
|
|
65
|
+
});
|
|
50
66
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Tracks player progression when they upgrade to a new level
|
|
70
|
+
*
|
|
71
|
+
* @param params - Object containing level upgrade details:
|
|
72
|
+
* @param params.levelId - Unique identifier for the new level (string or number)
|
|
73
|
+
* @param params.name - Optional display name for the upgraded level
|
|
74
|
+
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
75
|
+
* @throws {Promise} Rejects with error if params is not an object
|
|
76
|
+
*/
|
|
77
|
+
async onLevelUpgrade(params: { levelId: string | number; name?: string }): Promise<TaskResponse> {
|
|
78
|
+
if (typeof params !== 'object') {
|
|
79
|
+
return Promise.reject({ code: 'FAILURE' as ResponseType, message: 'params must be an object' });
|
|
55
80
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
async onHistoryUserScore(score: number): Promise<TaskResponse> {
|
|
59
|
-
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onHistoryUserScore');
|
|
81
|
+
const { levelId, name } = params;
|
|
82
|
+
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onLevelUpgrade');
|
|
60
83
|
if (errMsg) {
|
|
61
84
|
return errMsg;
|
|
62
85
|
}
|
|
63
|
-
return await this.commands.executeCommand('TaskTrackerSDK.
|
|
86
|
+
return await this.commands.executeCommand('TaskTrackerSDK.levelUpgrade', {
|
|
87
|
+
levelId,
|
|
88
|
+
name
|
|
89
|
+
});
|
|
64
90
|
}
|
|
65
91
|
}
|