@jolibox/implement 1.1.43 → 1.1.45

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.43 clean
3
+ > @jolibox/implement@1.1.45 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.43 build:esm
7
+ > @jolibox/implement@1.1.45 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.43",
4
+ "version": "1.1.45",
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.43",
10
- "@jolibox/types": "1.1.43",
11
- "@jolibox/native-bridge": "1.1.43",
12
- "@jolibox/ads": "1.1.43",
9
+ "@jolibox/common": "1.1.45",
10
+ "@jolibox/types": "1.1.45",
11
+ "@jolibox/native-bridge": "1.1.45",
12
+ "@jolibox/ads": "1.1.45",
13
13
  "localforage": "1.10.0",
14
14
  "@jolibox/ui": "1.0.0",
15
15
  "web-vitals": "4.2.4"
@@ -148,6 +148,9 @@ const wrapContext = () => {
148
148
  if (hasMetaTag('gamedistribution', 'jolibox')) {
149
149
  return SDKEnvironment.gamedistribution;
150
150
  }
151
+ if (hasMetaTag('funmax', 'jolibox')) {
152
+ return SDKEnvironment.funmax;
153
+ }
151
154
  return SDKEnvironment.jolibox;
152
155
  },
153
156
  get viewport(): Viewport {
package/src/h5/api/ads.ts CHANGED
@@ -21,6 +21,8 @@ import '../rewards';
21
21
  import DlightekAdsHandler from './platformAdsHandle/DlightekAdsHandler';
22
22
  import HuaweiQuickAdsHandler from './platformAdsHandle/HuaweiQuickAdsHandler';
23
23
  import GamedistributionAdsHandler from './platformAdsHandle/GamedistributionAdsHandler';
24
+ import FunmaxAdsHandler from './platformAdsHandle/FunmaxAdsHandler';
25
+ import JoliboxAdsHandler from './platformAdsHandle/JoliboxAdsHandler';
24
26
 
25
27
  declare global {
26
28
  interface Window {
@@ -39,44 +41,6 @@ export interface IAdsHandler {
39
41
  adUnit(params: IAdUnitParams): void;
40
42
  getAdsInstance(): JoliboxAdsForGame;
41
43
  }
42
- class JoliboxAdsHandler implements IAdsHandler {
43
- constructor(private ads: JoliboxAdsForGame) {}
44
-
45
- getAdsInstance(): JoliboxAdsForGame {
46
- return this.ads;
47
- }
48
-
49
- init(config?: IAdsInitParams): void {
50
- this.ads.init(config);
51
- }
52
-
53
- adConfig(params: IAdConfigParams): void {
54
- this.ads.adConfig(params);
55
- }
56
-
57
- async adBreak(params: IAdBreakParams): Promise<void> {
58
- if (params.type === 'reward') {
59
- try {
60
- const rewardsTypes = await rewardsHelper.getRewardsTypes(httpClient);
61
- await rewardsHelper.handleReward(rewardsTypes, params);
62
- } catch (e) {
63
- console.info('handleReward failed', e);
64
- params.adBreakDone?.({
65
- breakType: params.type,
66
- breakFormat: params.type === 'reward' ? 'reward' : 'interstitial',
67
- breakStatus: 'noAdPreloaded'
68
- });
69
- }
70
- } else {
71
- this.ads.adBreak(params);
72
- }
73
- }
74
-
75
- adUnit(params: IAdUnitParams): void {
76
- this.ads.adUnit(params);
77
- }
78
- }
79
-
80
44
  class H5AdsManager {
81
45
  private context: IAdsContext<'GAME'>;
82
46
  private cacheHandler: IAdsHandler | null = null;
@@ -103,9 +67,14 @@ class H5AdsManager {
103
67
  this.cacheHandler = GamedistributionAdsHandler.getInstance();
104
68
  break;
105
69
  }
70
+ case SDKEnvironment.funmax: {
71
+ const joliboxAds = new JoliboxAdsForGame(this.context);
72
+ this.cacheHandler = new FunmaxAdsHandler(joliboxAds, httpClient);
73
+ break;
74
+ }
106
75
  default: {
107
76
  const joliboxAds = new JoliboxAdsForGame(this.context);
108
- this.cacheHandler = new JoliboxAdsHandler(joliboxAds);
77
+ this.cacheHandler = new JoliboxAdsHandler(joliboxAds, httpClient);
109
78
  break;
110
79
  }
111
80
  }
@@ -0,0 +1,40 @@
1
+ import { IAdBreakParams, JoliboxAdsForGame } from '@jolibox/ads';
2
+ import JoliboxAdsHandler from './JoliboxAdsHandler';
3
+ import { JoliboxHttpClient } from '@/h5/http';
4
+
5
+ export default class FunmaxAdsHandler extends JoliboxAdsHandler {
6
+ private startTimes: number;
7
+
8
+ constructor(ads: JoliboxAdsForGame, httpClient: JoliboxHttpClient) {
9
+ super(ads, httpClient);
10
+ this.startTimes = Date.now();
11
+ }
12
+
13
+ async adBreak(params: IAdBreakParams): Promise<void> {
14
+ if (params.type !== 'reward') {
15
+ if (params.type === 'preroll') {
16
+ params.adBreakDone?.({
17
+ breakType: params.type,
18
+ breakFormat: 'interstitial',
19
+ breakStatus: 'noAdPreloaded'
20
+ });
21
+ return;
22
+ }
23
+
24
+ const now = Date.now();
25
+
26
+ console.log('FunmaxAdsHandler time => ', now - this.startTimes);
27
+
28
+ if (now - this.startTimes < 40000) {
29
+ params.adBreakDone?.({
30
+ breakType: params.type,
31
+ breakFormat: 'interstitial',
32
+ breakStatus: 'noAdPreloaded'
33
+ });
34
+ return;
35
+ }
36
+ }
37
+
38
+ super.adBreak(params);
39
+ }
40
+ }
@@ -0,0 +1,48 @@
1
+ import { rewardsHelper } from '@/common/rewards';
2
+ import {
3
+ JoliboxAdsForGame,
4
+ IAdsInitParams,
5
+ IAdConfigParams,
6
+ IAdBreakParams,
7
+ IAdUnitParams
8
+ } from '@jolibox/ads';
9
+ import { IAdsHandler } from '../ads';
10
+ import { JoliboxHttpClient } from '@/h5/http';
11
+
12
+ export default class JoliboxAdsHandler implements IAdsHandler {
13
+ constructor(private ads: JoliboxAdsForGame, private httpClient: JoliboxHttpClient) {}
14
+
15
+ getAdsInstance(): JoliboxAdsForGame {
16
+ return this.ads;
17
+ }
18
+
19
+ init(config?: IAdsInitParams): void {
20
+ this.ads.init(config);
21
+ }
22
+
23
+ adConfig(params: IAdConfigParams): void {
24
+ this.ads.adConfig(params);
25
+ }
26
+
27
+ async adBreak(params: IAdBreakParams): Promise<void> {
28
+ if (params.type === 'reward') {
29
+ try {
30
+ const rewardsTypes = await rewardsHelper.getRewardsTypes(this.httpClient);
31
+ await rewardsHelper.handleReward(rewardsTypes, params);
32
+ } catch (e) {
33
+ console.info('handleReward failed', e);
34
+ params.adBreakDone?.({
35
+ breakType: params.type,
36
+ breakFormat: params.type === 'reward' ? 'reward' : 'interstitial',
37
+ breakStatus: 'noAdPreloaded'
38
+ });
39
+ }
40
+ } else {
41
+ this.ads.adBreak(params);
42
+ }
43
+ }
44
+
45
+ adUnit(params: IAdUnitParams): void {
46
+ this.ads.adUnit(params);
47
+ }
48
+ }
@@ -59,7 +59,7 @@ export class HttpClientManager {
59
59
  };
60
60
  }
61
61
 
62
- class JoliboxHttpClient implements IHttpClient {
62
+ export class JoliboxHttpClient implements IHttpClient {
63
63
  private baseUrl: string;
64
64
  protected xua = xUserAgent();
65
65
 
@@ -56,7 +56,7 @@ const interceptSystemExitSync = createSyncAPI('interceptSystemExitSync', {
56
56
 
57
57
  const navigateToNativePage = createSyncAPI('navigateToNativePage', {
58
58
  paramsSchema: t.tuple(
59
- t.enum('openHistory', 'openDiscover', 'openDiscover', 'openGame', 'openDrama', 'openTopup'),
59
+ t.enum('openHistory', 'openDiscover', 'openDiscover', 'openGame', 'openDrama', 'openTopup', 'openFeed'),
60
60
  t.object()
61
61
  ),
62
62
  implement: (path, params) => {
@@ -54,6 +54,17 @@ let isInterceptSystemExit = false;
54
54
  */
55
55
  let isInterceptBackPress = false;
56
56
 
57
+ /**
58
+ * 是否使用退出挽留
59
+ */
60
+ let disableExitRecommendDialog = false;
61
+
62
+ const updateDisableExitRecommendDialog = (disable?: boolean) => {
63
+ if (isBoolean(disable)) {
64
+ disableExitRecommendDialog = disable;
65
+ }
66
+ };
67
+
57
68
  RuntimeLoader.onReady(() => {
58
69
  // TODO: merge some env config
59
70
  });
@@ -90,7 +101,8 @@ function addBackPressListener() {
90
101
  isInterceptBackPress = intercept;
91
102
  });
92
103
 
93
- onNative('onBeforeBackPress', ({ uuid }) => {
104
+ onNative('onBeforeBackPress', ({ uuid, disableExitRecommendDialog }) => {
105
+ updateDisableExitRecommendDialog(disableExitRecommendDialog);
94
106
  hostEmitter.emit('onBackPress', {});
95
107
  globalThis.joliboxJSCore?.doBackPress?.(uuid);
96
108
  });
@@ -139,7 +151,8 @@ function addGameServiceReadyListener() {
139
151
  registerLanguageHandler(() => context.language);
140
152
  });
141
153
 
142
- onNative('onBeforeExit', ({ uuid }) => {
154
+ onNative('onBeforeExit', ({ uuid, disableExitRecommendDialog }) => {
155
+ updateDisableExitRecommendDialog(disableExitRecommendDialog);
143
156
  globalThis.joliboxJSCore?.doExit(uuid);
144
157
  });
145
158
  }
@@ -148,6 +161,7 @@ function addDoExitLoader() {
148
161
  /**
149
162
  * 退出逻辑
150
163
  * 1. 如果正在展示广告,则禁止退出
164
+ * 2. 如果
151
165
  * 2. 如果指定退出挽留逻辑,则按照指定逻辑运行
152
166
  * 3. 如果退出挽留逻辑返回 true,则按照指定逻辑运行
153
167
  * 4. 否则,按照默认逻辑运行
@@ -181,7 +195,7 @@ function addDoExitLoader() {
181
195
  return context.shouldInterupt;
182
196
  }
183
197
 
184
- if (baskcMeta?.canShowRecommended) {
198
+ if (baskcMeta?.canShowRecommended && !disableExitRecommendDialog) {
185
199
  const stay = await openRetentionSchema();
186
200
  if (stay) {
187
201
  // 挽留成功,打断退出
@@ -1,6 +1,4 @@
1
1
  import { isString, logger, Deferred, isObject, hostEmitter, isUndefined, uuidv4 } from '@jolibox/common';
2
- import { reportNetworkAPI } from './report';
3
- import { RequestFrom } from './types';
4
2
  import { FetchResponse, FetchOptions } from './types';
5
3
  import { invokeNative, onNative } from '@jolibox/native-bridge';
6
4
  import { AnyFunction } from '@jolibox/types';
@@ -98,6 +96,9 @@ export function createFetch(
98
96
  });
99
97
 
100
98
  hostEmitter.on('onLoginComplete', ({ isLogin, token }) => {
99
+ if (type === 'public') {
100
+ return;
101
+ }
101
102
  if (isLogin && token) {
102
103
  defaultHeaders['X-JOLI-TOKEN'] = token;
103
104
  }