@jolibox/implement 1.1.11-beta.1 → 1.1.11-beta.3
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/ads/anti-cheating.d.ts +11 -1
- package/dist/common/ads/index.d.ts +4 -9
- package/dist/index.js +2 -2
- package/dist/index.native.js +4 -4
- package/implement.build.log +2 -2
- package/package.json +3 -3
- package/src/common/ads/anti-cheating.ts +24 -1
- package/src/common/ads/index.ts +15 -16
- package/src/native/api/ads.ts +7 -0
- package/src/native/api/navigate.ts +42 -4
- package/src/native/bootstrap/index.ts +5 -5
- package/src/native/bootstrap/retention.ts +8 -4
- package/src/native/types/native-method-map.d.ts +17 -0
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { createCommands, UserCustomError } from '@jolibox/common';
|
|
2
2
|
import { invokeNative } from '../bootstrap/bridge';
|
|
3
3
|
import { createSyncAPI, t, registerCanIUse } from './base';
|
|
4
|
+
import { context } from '@/common/context';
|
|
4
5
|
|
|
5
6
|
const commands = createCommands();
|
|
6
7
|
|
|
7
8
|
const openSchemaSync = createSyncAPI('openSchemaSync', {
|
|
8
9
|
paramsSchema: t.tuple(t.string()),
|
|
9
10
|
implement: (schema) => {
|
|
11
|
+
// Add compatibility logic for incomplete URLs
|
|
12
|
+
let finalSchema = schema;
|
|
13
|
+
if (!schema.match(/^https?:\/\//)) {
|
|
14
|
+
finalSchema = `https://${context.mpId}.app.jolibox.com${schema.startsWith('/') ? '' : '/'}${schema}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
const res = invokeNative('openSchemaSync', {
|
|
11
|
-
schema
|
|
18
|
+
schema: finalSchema
|
|
12
19
|
});
|
|
13
20
|
if (res.errNo !== 0) {
|
|
14
21
|
throw new UserCustomError(res.errMsg, res.errNo);
|
|
@@ -16,8 +23,39 @@ const openSchemaSync = createSyncAPI('openSchemaSync', {
|
|
|
16
23
|
}
|
|
17
24
|
});
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
const openPageSync = createSyncAPI('openPageSync', {
|
|
27
|
+
paramsSchema: t.tuple(t.string()),
|
|
28
|
+
implement: (page) => {
|
|
29
|
+
const { errNo, errMsg, data } = invokeNative('openPageSync', { url: page });
|
|
30
|
+
if (errNo !== 0 || !data) {
|
|
31
|
+
throw new UserCustomError(errMsg, errNo);
|
|
32
|
+
}
|
|
33
|
+
return { webviewId: data.webviewId };
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const closePageSync = createSyncAPI('closePageSync', {
|
|
38
|
+
paramsSchema: t.tuple(t.number()),
|
|
39
|
+
implement: (webviewId) => {
|
|
40
|
+
const { errNo, errMsg } = invokeNative('closePageSync', { webviewId });
|
|
41
|
+
if (errNo !== 0) {
|
|
42
|
+
throw new UserCustomError(errMsg, errNo);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
commands.registerCommand('RouterSDK.openSchema', openSchemaSync);
|
|
48
|
+
commands.registerCommand('RouterSDK.openPage', openPageSync);
|
|
49
|
+
commands.registerCommand('RouterSDK.closePage', closePageSync);
|
|
50
|
+
|
|
51
|
+
registerCanIUse('router.openSchema', {
|
|
52
|
+
version: '1.1.10'
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
registerCanIUse('router.openPage', {
|
|
56
|
+
version: '1.1.10'
|
|
57
|
+
});
|
|
20
58
|
|
|
21
|
-
registerCanIUse('
|
|
22
|
-
version: '1.1.
|
|
59
|
+
registerCanIUse('router.closePage', {
|
|
60
|
+
version: '1.1.10'
|
|
23
61
|
});
|
|
@@ -42,11 +42,11 @@ RuntimeLoader.doExit(async () => {
|
|
|
42
42
|
return context.shouldInterupt;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const stay = await openRetentionSchema();
|
|
46
|
+
if (stay) {
|
|
47
|
+
// 挽留成功,打断退出
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
// 退出,对应上报
|
|
52
52
|
//埋点上报
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { context } from '@/common/context';
|
|
2
2
|
import { invokeNative, subscribe } from './bridge';
|
|
3
3
|
import { Deferred } from '@jolibox/common';
|
|
4
|
-
|
|
5
4
|
export async function openRetentionSchema() {
|
|
6
5
|
const { data } = invokeNative('envSync');
|
|
7
6
|
const { orientation, webviewId } = data;
|
|
@@ -11,7 +10,8 @@ export async function openRetentionSchema() {
|
|
|
11
10
|
// set entryPath
|
|
12
11
|
__orientation: orientation ?? 'VERTICAL', // 默认竖屏
|
|
13
12
|
__showStatusBar: false,
|
|
14
|
-
__shouldInterupt: false
|
|
13
|
+
__shouldInterupt: false,
|
|
14
|
+
__showCapsuleButton: false
|
|
15
15
|
};
|
|
16
16
|
if (webviewId) {
|
|
17
17
|
joliPayload = {
|
|
@@ -22,8 +22,10 @@ export async function openRetentionSchema() {
|
|
|
22
22
|
|
|
23
23
|
const joliSource = context.encodeJoliSourceQuery(joliPayload);
|
|
24
24
|
|
|
25
|
-
const host = context.testMode
|
|
26
|
-
|
|
25
|
+
const host = context.testMode
|
|
26
|
+
? `https://G32115508989327465281365749294.app.jolibox.com`
|
|
27
|
+
: `https://G32115508989327465281365749294.app.jolibox.com`;
|
|
28
|
+
const retentionSchema = `${host}/recommended-guide/${context.mpId}?appId=${context.mpId}&joliSource=${joliSource}&navigationStyle=present`;
|
|
27
29
|
|
|
28
30
|
const quitResultDeffer = new Deferred<boolean>();
|
|
29
31
|
|
|
@@ -38,3 +40,5 @@ export async function openRetentionSchema() {
|
|
|
38
40
|
}, 0);
|
|
39
41
|
return quitResultDeffer.promise;
|
|
40
42
|
}
|
|
43
|
+
|
|
44
|
+
// 添加锁变量,防止多次执行
|
|
@@ -262,6 +262,23 @@ declare global {
|
|
|
262
262
|
/** 错误码 */
|
|
263
263
|
errNo?: number;
|
|
264
264
|
};
|
|
265
|
+
|
|
266
|
+
openPageSync: (params: { url: string }) => {
|
|
267
|
+
/** 错误消息 */
|
|
268
|
+
errMsg: string;
|
|
269
|
+
/** 错误码 */
|
|
270
|
+
errNo?: number;
|
|
271
|
+
data?: {
|
|
272
|
+
webviewId: number;
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
closePageSync: (params: { webviewId: number }) => {
|
|
277
|
+
/** 错误消息 */
|
|
278
|
+
errMsg: string;
|
|
279
|
+
/** 错误码 */
|
|
280
|
+
errNo?: number;
|
|
281
|
+
};
|
|
265
282
|
}
|
|
266
283
|
|
|
267
284
|
interface NativeEventMap {
|