@jolibox/implement 1.3.7 → 1.3.8
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 +8 -8
- package/dist/common/utils/index.d.ts +4 -0
- package/dist/index.js +20 -20
- package/dist/index.native.js +84 -84
- package/dist/native/report/task-tracker.d.ts +1 -0
- package/implement.build.log +2 -2
- package/package.json +6 -6
- package/src/common/utils/index.ts +4 -0
- package/src/h5/api/platformAdsHandle/HuaweiQuickAdsHandler.ts +11 -0
- package/src/h5/api/runtime.ts +9 -0
- package/src/native/api/ads.ts +5 -0
- package/src/native/api/runtime.ts +27 -0
- package/src/native/bootstrap/index.ts +11 -2
- package/src/native/report/task-tracker.ts +6 -0
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.3.
|
|
3
|
+
> @jolibox/implement@1.3.8 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.3.
|
|
7
|
+
> @jolibox/implement@1.3.8 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,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/implement",
|
|
3
3
|
"description": "This project is Jolibox JS-SDk implement for Native && H5",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.8",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@jolibox/common": "1.3.
|
|
10
|
-
"@jolibox/types": "1.3.
|
|
11
|
-
"@jolibox/native-bridge": "1.3.
|
|
12
|
-
"@jolibox/ads": "1.3.
|
|
9
|
+
"@jolibox/common": "1.3.8",
|
|
10
|
+
"@jolibox/types": "1.3.8",
|
|
11
|
+
"@jolibox/native-bridge": "1.3.8",
|
|
12
|
+
"@jolibox/ads": "1.3.8",
|
|
13
13
|
"localforage": "1.10.0",
|
|
14
|
-
"@jolibox/ui": "1.3.
|
|
14
|
+
"@jolibox/ui": "1.3.8",
|
|
15
15
|
"web-vitals": "4.2.4"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -15,6 +15,7 @@ const JOLIBOX_SUB_EVENT = 'JOLIBOX_SUB_EVENT';
|
|
|
15
15
|
|
|
16
16
|
const CP_LOAD_FINISH = 'CP_LOAD_FINISH';
|
|
17
17
|
const CP_LOAD_PROGRESS = 'CP_LOAD_PROGRESS';
|
|
18
|
+
const CP_GAME_TTI = 'CP_GAME_TTI';
|
|
18
19
|
|
|
19
20
|
interface JoliboxCustomEvent {
|
|
20
21
|
[JOLIBOX_CUSTOM_ADS_EVENT_TYPE]: {
|
|
@@ -61,6 +62,9 @@ interface JoliboxCustomEvent {
|
|
|
61
62
|
[CP_LOAD_PROGRESS]: {
|
|
62
63
|
progress: number;
|
|
63
64
|
};
|
|
65
|
+
[CP_GAME_TTI]: {
|
|
66
|
+
duration?: number;
|
|
67
|
+
};
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
const notifyCustomEvent = <T extends keyof JoliboxCustomEvent>(eventName: T, data: JoliboxCustomEvent[T]) => {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
IPlacementInfo
|
|
8
8
|
} from '@jolibox/ads';
|
|
9
9
|
import { IAdsHandler } from '../ads';
|
|
10
|
+
import { track } from '../../report';
|
|
10
11
|
|
|
11
12
|
enum HuaweiQuickAdsEventEnum {
|
|
12
13
|
INIT = 'huawei_quick_ads_init',
|
|
@@ -155,6 +156,11 @@ export default class HuaweiQuickAdsHandler implements IAdsHandler {
|
|
|
155
156
|
isBreakDone = false;
|
|
156
157
|
break;
|
|
157
158
|
case 'beforeAd':
|
|
159
|
+
track('HuaweiQuickAdsAdBreakBeforeAd', {
|
|
160
|
+
type: 'beforeAd',
|
|
161
|
+
format: callbacks?.breakType === 'reward' ? 'reward' : 'interstitial'
|
|
162
|
+
});
|
|
163
|
+
|
|
158
164
|
callbacks?.beforeAd?.();
|
|
159
165
|
isBreakDone = false;
|
|
160
166
|
break;
|
|
@@ -230,6 +236,11 @@ export default class HuaweiQuickAdsHandler implements IAdsHandler {
|
|
|
230
236
|
|
|
231
237
|
this.callbackMap.set(callbackId, callbacks);
|
|
232
238
|
|
|
239
|
+
track('HuaweiQuickAdsAdBreak', {
|
|
240
|
+
type: params.type,
|
|
241
|
+
format: params.type === 'reward' ? 'reward' : 'interstitial'
|
|
242
|
+
});
|
|
243
|
+
|
|
233
244
|
this.sendPostMessage(HuaweiQuickAdsEventEnum.AD_BREAK, callbackId, params);
|
|
234
245
|
} catch (e) {
|
|
235
246
|
params.adBreakDone?.({
|
package/src/h5/api/runtime.ts
CHANGED
|
@@ -17,3 +17,12 @@ commands.registerCommand('RuntimeSDK.loadProgressEvent', (progress) => {
|
|
|
17
17
|
notifyCustomEvent('CP_LOAD_PROGRESS', { progress });
|
|
18
18
|
console.log('RuntimeSDK.loadProgressEvent', progress);
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
commands.registerCommand('RuntimeSDK.gameTTIEvent', () => {
|
|
22
|
+
notifyCustomEvent('CP_GAME_TTI', {
|
|
23
|
+
duration: performance.now()
|
|
24
|
+
});
|
|
25
|
+
track('gameTTI', {
|
|
26
|
+
duration: performance.now()
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/native/api/ads.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { createCommands } from '@jolibox/common';
|
|
|
2
2
|
import { canIUseNative, createSyncAPI, registerCanIUse } from './base';
|
|
3
3
|
import { createToast } from '@jolibox/ui';
|
|
4
4
|
import '../rewards';
|
|
5
|
+
import { notifyCustomEvent } from '@/common/utils';
|
|
5
6
|
|
|
6
7
|
const commands = createCommands();
|
|
7
8
|
|
|
@@ -195,6 +196,10 @@ const showUnlockSuccessToast = (params: { quantity: number; balance: number }) =
|
|
|
195
196
|
warmupRewardCache(httpClient);
|
|
196
197
|
warmupGemBalanceCache(httpClient);
|
|
197
198
|
|
|
199
|
+
adEventEmitter.on('isAdShowing', (isAdShowing) => {
|
|
200
|
+
notifyCustomEvent('JOLIBOX_ADS_EVENT', { isAdShowing });
|
|
201
|
+
});
|
|
202
|
+
|
|
198
203
|
export const showGemSuccessToast = (params: { quantity: number; balance: number }) => {
|
|
199
204
|
const { quantity } = params;
|
|
200
205
|
const toastTemplate = `{slot-correct} ${quantity * -1} {slot-gem}`;
|
|
@@ -3,12 +3,16 @@ import { t, createSyncAPI } from './base';
|
|
|
3
3
|
import { emitNative } from '@jolibox/native-bridge';
|
|
4
4
|
import { context } from '@/common/context';
|
|
5
5
|
import { track } from '../report';
|
|
6
|
+
import { notifyCustomEvent } from '@/common/utils';
|
|
6
7
|
|
|
7
8
|
const commands = createCommands();
|
|
8
9
|
|
|
9
10
|
const onLoadFinished = createSyncAPI('onLoadFinished', {
|
|
10
11
|
implement: () => {
|
|
11
12
|
emitNative('cpLoadFinishEvent', {}, context.webviewId, true);
|
|
13
|
+
notifyCustomEvent('CP_LOAD_FINISH', {
|
|
14
|
+
duration: performance.now()
|
|
15
|
+
});
|
|
12
16
|
track('loadFinished', {
|
|
13
17
|
duration: performance.now()
|
|
14
18
|
});
|
|
@@ -22,6 +26,7 @@ const THROTTLE_INTERVAL = 200;
|
|
|
22
26
|
|
|
23
27
|
function notifyProgress(progress: number) {
|
|
24
28
|
emitNative('cpLoadProgressEvent', { progress }, context.webviewId, true);
|
|
29
|
+
notifyCustomEvent('CP_LOAD_PROGRESS', { progress });
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
const onLoadProgress = createSyncAPI('onLoadProgress', {
|
|
@@ -47,6 +52,28 @@ const onLoadProgress = createSyncAPI('onLoadProgress', {
|
|
|
47
52
|
}
|
|
48
53
|
});
|
|
49
54
|
|
|
55
|
+
const onGameTTI = createSyncAPI('onGameTTI', {
|
|
56
|
+
paramsSchema: t.tuple(t.number().optional()),
|
|
57
|
+
implement: () => {
|
|
58
|
+
emitNative(
|
|
59
|
+
'cpGameTTIEvent',
|
|
60
|
+
{
|
|
61
|
+
duration: performance.now()
|
|
62
|
+
},
|
|
63
|
+
context.webviewId,
|
|
64
|
+
true
|
|
65
|
+
);
|
|
66
|
+
notifyCustomEvent('CP_GAME_TTI', {
|
|
67
|
+
duration: performance.now()
|
|
68
|
+
});
|
|
69
|
+
track('gameTTI', {
|
|
70
|
+
duration: performance.now()
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
50
75
|
commands.registerCommand('RuntimeSDK.loadFinishedEvent', onLoadFinished);
|
|
51
76
|
|
|
52
77
|
commands.registerCommand('RuntimeSDK.loadProgressEvent', onLoadProgress);
|
|
78
|
+
|
|
79
|
+
commands.registerCommand('RuntimeSDK.gameTTIEvent', onGameTTI);
|
|
@@ -10,6 +10,8 @@ import { Env } from '@jolibox/types';
|
|
|
10
10
|
import { registerLanguageHandler } from '@jolibox/ui';
|
|
11
11
|
import { createIframeModal, registerIframeModalToGlobal } from '../ui/modal-iframe';
|
|
12
12
|
import { onFCP, onLCP, onTTFB } from 'web-vitals';
|
|
13
|
+
import { canIUseNative } from '../utils/can-iuse-native';
|
|
14
|
+
|
|
13
15
|
interface IBasicMetaConfig {
|
|
14
16
|
canShowRecommended: boolean;
|
|
15
17
|
}
|
|
@@ -147,8 +149,11 @@ function addGameServiceReadyListener() {
|
|
|
147
149
|
timestamp: Date.now()
|
|
148
150
|
});
|
|
149
151
|
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
+
// 任务上报,1.7.3 版本以下在onReady时机开始计算埋点
|
|
153
|
+
if (!canIUseNative('onJoliboxHideLoading')) {
|
|
154
|
+
handleTaskTracker(loadDuration);
|
|
155
|
+
}
|
|
156
|
+
|
|
152
157
|
registerLanguageHandler(() => context.language);
|
|
153
158
|
});
|
|
154
159
|
|
|
@@ -156,6 +161,10 @@ function addGameServiceReadyListener() {
|
|
|
156
161
|
updateDisableExitRecommendDialog(disableExitRecommendDialog);
|
|
157
162
|
globalThis.joliboxJSCore?.doExit(uuid);
|
|
158
163
|
});
|
|
164
|
+
|
|
165
|
+
onNative('onJoliboxHideLoading', ({ duration }) => {
|
|
166
|
+
handleTaskTracker(duration);
|
|
167
|
+
});
|
|
159
168
|
}
|
|
160
169
|
|
|
161
170
|
function addDoExitLoader() {
|
|
@@ -33,6 +33,7 @@ export class NativeTaskTracker extends TaskTracker {
|
|
|
33
33
|
private sessionId: string;
|
|
34
34
|
private track: Track;
|
|
35
35
|
private taskUrl: string;
|
|
36
|
+
private started = false;
|
|
36
37
|
|
|
37
38
|
constructor(track: Track, eventEmitter: EventEmitter<{ visible: [boolean] }>, interval?: number) {
|
|
38
39
|
super(eventEmitter, interval);
|
|
@@ -76,8 +77,13 @@ export class NativeTaskTracker extends TaskTracker {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
start(duration?: number) {
|
|
80
|
+
if (this.started) {
|
|
81
|
+
console.info('[JoliboxSDK] taskTrakcer has started');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
79
84
|
super.start(duration);
|
|
80
85
|
this.tryReportOpenGamePlus();
|
|
86
|
+
this.started = true;
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
private tryReportOpenGamePlus() {
|