@jolibox/sdk 1.1.48 → 1.1.50
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 +6 -5
- package/dist/api/call-host-method.d.ts +5 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +217 -178
- package/dist/sdks/task.d.ts +4 -0
- package/package.json +3 -3
- package/sdk.build.log +4 -4
- package/src/api/call-host-method.ts +15 -0
- package/src/api/index.ts +1 -0
- package/src/index.ts +11 -1
- package/src/sdks/router.ts +5 -1
- package/src/sdks/task.ts +10 -4
package/dist/sdks/task.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
15
15
|
* @param params.duration - Optional time spent in the level (milliseconds)
|
|
16
16
|
* @param params.rating - Optional user rating for the level
|
|
17
17
|
* @param params.score - Optional final score achieved in the level
|
|
18
|
+
* @param params.variation - Optional variation
|
|
18
19
|
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
19
20
|
* @throws {Promise} Rejects with error if params is not an object
|
|
20
21
|
*/
|
|
@@ -23,6 +24,7 @@ export declare class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
23
24
|
duration?: number;
|
|
24
25
|
rating?: number;
|
|
25
26
|
score?: number;
|
|
27
|
+
variation?: string;
|
|
26
28
|
}): Promise<TaskResponse>;
|
|
27
29
|
/**
|
|
28
30
|
* Records completion of a gameplay session with final metrics
|
|
@@ -31,6 +33,7 @@ export declare class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
31
33
|
* @param params.duration - Optional total time spent in gameplay (milliseconds)
|
|
32
34
|
* @param params.rating - Optional user rating for the gameplay session
|
|
33
35
|
* @param params.score - Mandatory final score achieved during gameplay
|
|
36
|
+
* @param params.variation - Optional variation
|
|
34
37
|
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
35
38
|
* @throws {Promise} Rejects with error if params is not an object
|
|
36
39
|
*/
|
|
@@ -38,6 +41,7 @@ export declare class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
38
41
|
duration?: number;
|
|
39
42
|
rating?: number;
|
|
40
43
|
score: number;
|
|
44
|
+
variation?: string;
|
|
41
45
|
}): Promise<TaskResponse>;
|
|
42
46
|
/**
|
|
43
47
|
* Tracks player progression when they upgrade to a new level
|
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.50",
|
|
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.50",
|
|
11
|
+
"@jolibox/types": "1.1.50"
|
|
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.50 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.1.
|
|
7
|
+
> @jolibox/sdk@1.1.50 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.50 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.50 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ICallHostMethodParams } from '@jolibox/types';
|
|
2
|
+
import { canIUse } from './can-i-use';
|
|
3
|
+
import { createCommands } from '@jolibox/common';
|
|
4
|
+
|
|
5
|
+
const commands = createCommands();
|
|
6
|
+
|
|
7
|
+
export async function callHostMethod(params: ICallHostMethodParams) {
|
|
8
|
+
if (!canIUse('callHostMethod')) {
|
|
9
|
+
return {
|
|
10
|
+
code: 'FAILURE' as ResponseType,
|
|
11
|
+
message: '[Jolibox SDK] callHostMethod is not supported in this platform'
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return await commands.executeCommand('API.callHostMethod', params);
|
|
15
|
+
}
|
package/src/api/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
request,
|
|
18
18
|
onCustomEvent,
|
|
19
19
|
offCustomEvent,
|
|
20
|
-
onceCustomEvent
|
|
20
|
+
onceCustomEvent,
|
|
21
|
+
callHostMethod
|
|
21
22
|
} from './api';
|
|
22
23
|
import { RuntimeSDK } from './sdks/runtime';
|
|
23
24
|
import { LifecycleSDK } from './sdks/lifecycle';
|
|
@@ -196,6 +197,15 @@ export class JoliboxSDK {
|
|
|
196
197
|
*/
|
|
197
198
|
isNativeSupport = isNativeSupport.bind(this);
|
|
198
199
|
|
|
200
|
+
/**
|
|
201
|
+
* @private
|
|
202
|
+
* Calls a host method.
|
|
203
|
+
* @see {@link callHostMethod} for more details.
|
|
204
|
+
* @param {ICallHostMethodParams} params - Parameters for the host method.
|
|
205
|
+
* @returns {Promise<void>} A promise that resolves with the host method response.
|
|
206
|
+
*/
|
|
207
|
+
callHostMethod = callHostMethod.bind(this);
|
|
208
|
+
|
|
199
209
|
/**
|
|
200
210
|
* @public
|
|
201
211
|
* Constructs a new JoliboxSDK instance or returns the existing singleton instance.
|
package/src/sdks/router.ts
CHANGED
|
@@ -104,10 +104,14 @@ export class RouterSDK extends BaseSDK implements Router {
|
|
|
104
104
|
message: 'invalid path'
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
await this.commands.executeCommand(
|
|
108
108
|
'RouterSDK.navigateToNativePage',
|
|
109
109
|
path as NavigateToNativePageType,
|
|
110
110
|
params
|
|
111
111
|
);
|
|
112
|
+
return {
|
|
113
|
+
code: 'SUCCESS' as ResponseType,
|
|
114
|
+
message: `navigate to ${path} success`
|
|
115
|
+
};
|
|
112
116
|
}
|
|
113
117
|
}
|
package/src/sdks/task.ts
CHANGED
|
@@ -16,6 +16,7 @@ export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
16
16
|
* @param params.duration - Optional time spent in the level (milliseconds)
|
|
17
17
|
* @param params.rating - Optional user rating for the level
|
|
18
18
|
* @param params.score - Optional final score achieved in the level
|
|
19
|
+
* @param params.variation - Optional variation
|
|
19
20
|
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
20
21
|
* @throws {Promise} Rejects with error if params is not an object
|
|
21
22
|
*/
|
|
@@ -24,11 +25,12 @@ export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
24
25
|
duration?: number;
|
|
25
26
|
rating?: number;
|
|
26
27
|
score?: number;
|
|
28
|
+
variation?: string;
|
|
27
29
|
}): Promise<TaskResponse> {
|
|
28
30
|
if (typeof params !== 'object') {
|
|
29
31
|
return Promise.reject({ code: 'FAILURE' as ResponseType, message: 'params must be an object' });
|
|
30
32
|
}
|
|
31
|
-
const { levelId, duration, rating, score } = params;
|
|
33
|
+
const { levelId, duration, rating, score, variation } = params;
|
|
32
34
|
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onLevelFinished');
|
|
33
35
|
if (errMsg) {
|
|
34
36
|
return Promise.resolve(errMsg);
|
|
@@ -37,7 +39,8 @@ export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
37
39
|
levelId,
|
|
38
40
|
duration,
|
|
39
41
|
rating,
|
|
40
|
-
score
|
|
42
|
+
score,
|
|
43
|
+
variation
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
|
|
@@ -48,6 +51,7 @@ export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
48
51
|
* @param params.duration - Optional total time spent in gameplay (milliseconds)
|
|
49
52
|
* @param params.rating - Optional user rating for the gameplay session
|
|
50
53
|
* @param params.score - Mandatory final score achieved during gameplay
|
|
54
|
+
* @param params.variation - Optional variation
|
|
51
55
|
* @returns Promise resolving to TaskResponse or error message if validation fails
|
|
52
56
|
* @throws {Promise} Rejects with error if params is not an object
|
|
53
57
|
*/
|
|
@@ -55,11 +59,12 @@ export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
55
59
|
duration?: number;
|
|
56
60
|
rating?: number;
|
|
57
61
|
score: number;
|
|
62
|
+
variation?: string;
|
|
58
63
|
}): Promise<TaskResponse> {
|
|
59
64
|
if (typeof params !== 'object') {
|
|
60
65
|
return Promise.reject({ code: 'FAILURE' as ResponseType, message: 'params must be an object' });
|
|
61
66
|
}
|
|
62
|
-
const { duration, rating, score } = params;
|
|
67
|
+
const { duration, rating, score, variation } = params;
|
|
63
68
|
const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onGamePlayEnded');
|
|
64
69
|
if (errMsg) {
|
|
65
70
|
return Promise.resolve(errMsg);
|
|
@@ -67,7 +72,8 @@ export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
|
67
72
|
return await this.commands.executeCommand('TaskTrackerSDK.gamePlayEnded', {
|
|
68
73
|
duration,
|
|
69
74
|
rating,
|
|
70
|
-
score
|
|
75
|
+
score,
|
|
76
|
+
variation
|
|
71
77
|
});
|
|
72
78
|
}
|
|
73
79
|
|