@jolibox/implement 1.1.19-beta.6 → 1.1.20-beta.1

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.
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.19-beta.6 clean
3
+ > @jolibox/implement@1.1.20-beta.1 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.19-beta.6 build:esm
7
+ > @jolibox/implement@1.1.20-beta.1 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.19-beta.6",
4
+ "version": "1.1.20-beta.1",
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.19-beta.6",
10
- "@jolibox/types": "1.1.19-beta.6",
11
- "@jolibox/native-bridge": "1.1.19-beta.6",
12
- "@jolibox/ads": "1.1.19-beta.6",
9
+ "@jolibox/common": "1.1.20-beta.1",
10
+ "@jolibox/types": "1.1.20-beta.1",
11
+ "@jolibox/native-bridge": "1.1.20-beta.1",
12
+ "@jolibox/ads": "1.1.20-beta.1",
13
13
  "localforage": "1.10.0",
14
14
  "@jolibox/ui": "1.0.0",
15
15
  "web-vitals": "4.2.4"
@@ -1,4 +1,4 @@
1
- import { mergeArray, mergeWith } from '@jolibox/common';
1
+ import { getAdvertisingId, mergeArray, mergeWith } from '@jolibox/common';
2
2
  import { DeviceInfo, HostInfo, HostUserInfo, SdkInfo } from './types';
3
3
  import { Env } from '@jolibox/types';
4
4
  import { parseUrlQuery, encodeJoliSourceQuery, QueryParams } from './url-parse';
@@ -16,6 +16,7 @@ const defaultEnv: Env = {
16
16
  brand: 'UnknownBrand',
17
17
  model: 'UnknownModel',
18
18
  did: getDeviceId(),
19
+ adId: getAdvertisingId(),
19
20
  pixelRatio: window.devicePixelRatio || 1,
20
21
  platform: platform.isAndroid ? 'android' : platform.isiOS ? 'ios' : 'h5',
21
22
  system: 'UnknownSystemVersion',
@@ -108,6 +109,9 @@ const wrapContext = () => {
108
109
  get baseApiHost(): string {
109
110
  return testMode ? 'https://stg-api.jolibox.com' : 'https://api.jolibox.com';
110
111
  },
112
+ get adId(): string {
113
+ return env.deviceInfo.adId ?? env.deviceInfo.did;
114
+ },
111
115
  onEnvConfigChanged: (newConfig: Partial<Env>) => {
112
116
  mergeWith(env, newConfig, mergeArray);
113
117
  },
@@ -181,6 +181,8 @@ export const createCommonJolicoinRewardHandler = (
181
181
  }
182
182
  handleUnlockFailed?.(params);
183
183
  return false;
184
+ } finally {
185
+ unlockOptionsHandler.clearCache();
184
186
  }
185
187
  };
186
188
  };
package/src/h5/api/ads.ts CHANGED
@@ -29,7 +29,7 @@ const adsContext: IAdsContext<'GAME'> = {
29
29
  return {
30
30
  hostAppId: context.hostInfo?.aid ?? '1',
31
31
  deviceId: context.deviceInfo.did ?? '',
32
- adId: context.deviceInfo.did ?? '', //TODO: @Deng Xue
32
+ adId: context.deviceInfo.adId ?? '',
33
33
  sessionId: context.sessionId ?? '',
34
34
  userId: context.hostUserInfo?.uid ?? '',
35
35
  objectType: 'GAME',
@@ -24,7 +24,7 @@ const UseCoinEventMap: Record<string, IUseModalResultEvent['useModalResult']> =
24
24
  CANCEL: 'CANCEL'
25
25
  };
26
26
  onCustomEvent('ON_JOLIBOX_JOLI_COIN_USE_RESULT', (data) => {
27
- console.log('onCustomEvent ON_JOLIBOX_JOLI_COIN_USE_RESULT', UseCoinEventMap[data.result]);
27
+ console.log('onCustomEvent ON_JOLIBOX_JOLI_COIN_USE_RESULT', UseCoinEventMap[data.result], data.result);
28
28
 
29
29
  rewardsEmitter.emit(UseModalResultEventName, {
30
30
  useModalResult: UseCoinEventMap[data.result]
@@ -25,6 +25,7 @@ import {
25
25
  createJolicoinRewardHandler,
26
26
  createJolicoinOnlyRewardHandler
27
27
  } from '@/common/rewards';
28
+ import { adEventEmitter } from '@/common/ads';
28
29
 
29
30
  const checkNetworkStatus = () => {
30
31
  const { data } = invokeNative('getNetworkStatusSync');
@@ -52,11 +53,12 @@ const adsContext: IAdsContext<'GAME'> = {
52
53
  httpClient,
53
54
  checkNetwork: checkNetworkStatus,
54
55
  track,
56
+ eventEmitter: adEventEmitter,
55
57
  getContextInfo: () => {
56
58
  return {
57
59
  hostAppId: context.hostInfo?.aid ?? '1',
58
60
  deviceId: context.deviceInfo.did ?? '',
59
- adId: context.deviceInfo.did ?? '', //TODO: @Deng Xue
61
+ adId: context.deviceInfo.adId ?? '',
60
62
  sessionId: context.sessionId ?? '',
61
63
  userId: context.hostUserInfo?.uid ?? '',
62
64
  objectType: 'GAME',
@@ -48,6 +48,8 @@ const interceptSystemExitSync = createSyncAPI('interceptSystemExitSync', {
48
48
  paramsSchema: t.tuple(t.boolean()),
49
49
  implement: (intercept) => {
50
50
  hostEmitter.emit('onInterceptSystemExit', { intercept });
51
+ // 同步拦截物理退出
52
+ hostEmitter.emit('onInterceptBackPress', { intercept });
51
53
  }
52
54
  });
53
55
 
@@ -17,6 +17,7 @@ declare const globalThis: {
17
17
  doExit: (uuid: string) => void;
18
18
  onDocumentReady: (path: string) => void;
19
19
  env: (params: { onError: (error: Error) => void }) => Env | undefined;
20
+ doBackPress: (uuid: string) => void;
20
21
  };
21
22
  };
22
23
 
@@ -47,6 +48,11 @@ let baskcMeta: IBasicMetaConfig | null = null;
47
48
  */
48
49
  let isInterceptSystemExit = false;
49
50
 
51
+ /**
52
+ * android全局拦截物理按键
53
+ */
54
+ let isInterceptBackPress = false;
55
+
50
56
  RuntimeLoader.onReady(() => {
51
57
  // TODO: merge some env config
52
58
  });
@@ -75,6 +81,20 @@ function addInterceptSystemExitListener() {
75
81
  });
76
82
  }
77
83
 
84
+ /**
85
+ * android 全局拦截物理退出
86
+ */
87
+ function addBackPressListener() {
88
+ hostEmitter.on('onInterceptBackPress', ({ intercept }) => {
89
+ isInterceptBackPress = intercept;
90
+ });
91
+
92
+ onNative('onBeforeBackPress', ({ uuid }) => {
93
+ hostEmitter.emit('onBackPress', {});
94
+ globalThis.joliboxJSCore?.doBackPress?.(uuid);
95
+ });
96
+ }
97
+
78
98
  /**
79
99
  * The DOMContentLoaded event might be triggered very early,
80
100
  * so the global loaded listener should be executed during the bootstrap process.
@@ -172,6 +192,13 @@ function addDoExitLoader() {
172
192
  doActualExit();
173
193
  return false;
174
194
  });
195
+
196
+ RuntimeLoader.onDoBackPress(async () => {
197
+ if (shouldInterceptSystemExit()) {
198
+ return true; // Forbid exit on watching ads
199
+ }
200
+ return false;
201
+ });
175
202
  }
176
203
 
177
204
  async function fetchMetaConfig() {
@@ -190,6 +217,7 @@ export function config(): void {
190
217
  addGameServiceReadyListener();
191
218
  addShowAdListener();
192
219
  addInterceptSystemExitListener();
220
+ addBackPressListener();
193
221
  addDoExitLoader();
194
222
  addWebviewReadyListener();
195
223
  addI18nChangedListener();