@jolibox/implement 1.1.13-beta.1 → 1.1.13-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 +16 -33
- package/.rush/temp/shrinkwrap-deps.json +1 -1
- package/dist/index.js +3 -3
- package/dist/index.native.js +6 -6
- package/dist/native/api/keyboard.d.ts +1 -1
- package/implement.build.log +2 -2
- package/package.json +4 -3
- package/src/common/ads/index.ts +51 -33
- package/src/native/api/ads.ts +1 -1
- package/src/native/api/get-system-info.ts +1 -1
- package/src/native/api/keyboard.ts +1 -1
- package/src/native/api/lifecycle.ts +1 -1
- package/src/native/api/login.ts +1 -1
- package/src/native/api/navigate.ts +1 -1
- package/src/native/api/storage.ts +1 -1
- package/src/native/bootstrap/index.ts +13 -6
- package/src/native/network/create-fetch.ts +1 -1
- package/src/native/report/errors/index.ts +1 -1
- package/src/native/report/index.ts +1 -1
- package/src/native/report/task-tracker.ts +1 -1
- package/src/native/ui/retention.ts +1 -1
- package/dist/native/bootstrap/bridge.d.ts +0 -4
- package/dist/native/js-bridge/const.d.ts +0 -6
- package/dist/native/js-bridge/index.d.ts +0 -2
- package/dist/native/js-bridge/invoke.d.ts +0 -21
- package/dist/native/js-bridge/js-bridge.d.ts +0 -6
- package/dist/native/js-bridge/publish.d.ts +0 -1
- package/dist/native/js-bridge/report.d.ts +0 -63
- package/dist/native/js-bridge/subscribe.d.ts +0 -10
- package/dist/native/js-bridge/types.d.ts +0 -18
- package/dist/native/js-bridge/utils.d.ts +0 -17
- package/dist/native/js-core/index.d.ts +0 -3
- package/dist/native/js-core/jolibox-js-core.d.ts +0 -50
- package/dist/native/js-core/message-port.d.ts +0 -12
- package/dist/native/js-core/utils.d.ts +0 -7
- package/src/native/bootstrap/bridge.ts +0 -68
- package/src/native/js-bridge/const.ts +0 -13
- package/src/native/js-bridge/index.ts +0 -2
- package/src/native/js-bridge/invoke.ts +0 -208
- package/src/native/js-bridge/js-bridge.ts +0 -28
- package/src/native/js-bridge/publish.ts +0 -44
- package/src/native/js-bridge/report.ts +0 -311
- package/src/native/js-bridge/subscribe.ts +0 -74
- package/src/native/js-bridge/types.ts +0 -36
- package/src/native/js-bridge/utils.ts +0 -116
- package/src/native/js-core/index.ts +0 -4
- package/src/native/js-core/jolibox-js-core.ts +0 -192
- package/src/native/js-core/message-port.ts +0 -52
- package/src/native/js-core/utils.ts +0 -9
- package/src/native/types/global.d.ts +0 -27
- package/src/native/types/native-method-map.d.ts +0 -329
- package/src/native/types/native-method.d.ts +0 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const showKeyboard: (params: {
|
|
2
2
|
defaultValue?: string | undefined;
|
|
3
|
-
maxLength?: unknown;
|
|
4
3
|
multiple?: boolean | undefined;
|
|
4
|
+
maxLength?: unknown;
|
|
5
5
|
}) => import("@jolibox/types").StandardResponse<void>;
|
|
6
6
|
export declare const updateKeyboard: (params: {
|
|
7
7
|
value: string;
|
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.1.13-beta.
|
|
3
|
+
> @jolibox/implement@1.1.13-beta.3 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.1.13-beta.
|
|
7
|
+
> @jolibox/implement@1.1.13-beta.3 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,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/implement",
|
|
3
3
|
"description": "This project is Jolibox JS-SDk implement for Native && H5",
|
|
4
|
-
"version": "1.1.13-beta.
|
|
4
|
+
"version": "1.1.13-beta.3",
|
|
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.13-beta.
|
|
10
|
-
"@jolibox/types": "1.1.13-beta.
|
|
9
|
+
"@jolibox/common": "1.1.13-beta.3",
|
|
10
|
+
"@jolibox/types": "1.1.13-beta.3",
|
|
11
|
+
"@jolibox/native-bridge": "1.0.0",
|
|
11
12
|
"localforage": "1.10.0",
|
|
12
13
|
"@jolibox/ui": "1.0.0",
|
|
13
14
|
"web-vitals": "4.2.4"
|
package/src/common/ads/index.ts
CHANGED
|
@@ -377,6 +377,55 @@ export class JoliboxAdsImpl {
|
|
|
377
377
|
* @returns IAdBreakParams
|
|
378
378
|
*/
|
|
379
379
|
private wrapAdBreakParams = (params: IAdBreakParams): IAdBreakParams => {
|
|
380
|
+
let googleHasResponse = false;
|
|
381
|
+
|
|
382
|
+
/* hook adBreakDone to track adBreakDone event -- start */
|
|
383
|
+
const originAdBreakDone = params.adBreakDone;
|
|
384
|
+
const adBreakDone = (placementInfo: IPlacementInfo) => {
|
|
385
|
+
googleHasResponse = true;
|
|
386
|
+
this.adsActionDetection.adBreakIsShowing = false;
|
|
387
|
+
this.track('CallAdBreakDone', {
|
|
388
|
+
breakType: placementInfo.breakType,
|
|
389
|
+
breakName: placementInfo.breakName ?? '',
|
|
390
|
+
breakFormat: placementInfo.breakFormat,
|
|
391
|
+
breakStatus: placementInfo.breakStatus
|
|
392
|
+
});
|
|
393
|
+
if (originAdBreakDone) {
|
|
394
|
+
originAdBreakDone(placementInfo);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
params.adBreakDone = adBreakDone;
|
|
398
|
+
/* hook adBreakDone to track adBreakDone event -- end */
|
|
399
|
+
|
|
400
|
+
/* hook for reward -- start */
|
|
401
|
+
if (params.type === 'reward') {
|
|
402
|
+
const originBeforeReward = params.beforeReward;
|
|
403
|
+
const wrapShowAdFn = (originShowAdFn: () => void) => () => {
|
|
404
|
+
this.track('CallShowAdFn', null);
|
|
405
|
+
originShowAdFn();
|
|
406
|
+
};
|
|
407
|
+
const beforeReward = (originShowAdFn: () => void) => {
|
|
408
|
+
googleHasResponse = true;
|
|
409
|
+
if (originBeforeReward) {
|
|
410
|
+
originBeforeReward(wrapShowAdFn(originShowAdFn));
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
params.beforeReward = beforeReward;
|
|
414
|
+
|
|
415
|
+
window.setTimeout(() => {
|
|
416
|
+
if (!googleHasResponse) {
|
|
417
|
+
this.track('CallAdBreakTimeout', { type: params.type });
|
|
418
|
+
params.adBreakDone?.({
|
|
419
|
+
breakType: params.type,
|
|
420
|
+
breakName: params.name ?? '',
|
|
421
|
+
breakFormat: 'reward',
|
|
422
|
+
breakStatus: 'timeout'
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}, 10000); // Timeout duration in milliseconds, 10 seconds
|
|
426
|
+
}
|
|
427
|
+
/* hook for reward -- end */
|
|
428
|
+
|
|
380
429
|
const isPreroll = (params: IAdBreakParams): params is IPrerollParams => {
|
|
381
430
|
return params.type === 'preroll';
|
|
382
431
|
};
|
|
@@ -396,6 +445,7 @@ export class JoliboxAdsImpl {
|
|
|
396
445
|
const originAfterAd = params.afterAd;
|
|
397
446
|
|
|
398
447
|
const beforeAd = () => {
|
|
448
|
+
googleHasResponse = true;
|
|
399
449
|
adEventEmitter.emit('isAdShowing', true);
|
|
400
450
|
this.track('CallBeforeAd', {
|
|
401
451
|
type: params.type,
|
|
@@ -407,6 +457,7 @@ export class JoliboxAdsImpl {
|
|
|
407
457
|
};
|
|
408
458
|
|
|
409
459
|
const afterAd = () => {
|
|
460
|
+
googleHasResponse = true;
|
|
410
461
|
adEventEmitter.emit('isAdShowing', false);
|
|
411
462
|
this.track('CallAfterAd', {
|
|
412
463
|
type: params.type,
|
|
@@ -529,39 +580,6 @@ export class JoliboxAdsImpl {
|
|
|
529
580
|
|
|
530
581
|
const type = params.type;
|
|
531
582
|
|
|
532
|
-
/* hook adBreakDone to track adBreakDone event -- start */
|
|
533
|
-
const originAdBreakDone = params.adBreakDone;
|
|
534
|
-
const adBreakDone = (placementInfo: IPlacementInfo) => {
|
|
535
|
-
this.adsActionDetection.adBreakIsShowing = false;
|
|
536
|
-
this.track('CallAdBreakDone', {
|
|
537
|
-
breakType: placementInfo.breakType,
|
|
538
|
-
breakName: placementInfo.breakName ?? '',
|
|
539
|
-
breakFormat: placementInfo.breakFormat,
|
|
540
|
-
breakStatus: placementInfo.breakStatus
|
|
541
|
-
});
|
|
542
|
-
if (originAdBreakDone) {
|
|
543
|
-
originAdBreakDone(placementInfo);
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
params.adBreakDone = adBreakDone;
|
|
547
|
-
/* hook adBreakDone to track adBreakDone event -- end */
|
|
548
|
-
|
|
549
|
-
/* hook beforeAd to track beforeAd event -- start */
|
|
550
|
-
if (params.type === 'reward') {
|
|
551
|
-
const originBeforeReward = params.beforeReward;
|
|
552
|
-
const wrapShowAdFn = (originShowAdFn: () => void) => () => {
|
|
553
|
-
this.track('CallShowAdFn', null);
|
|
554
|
-
originShowAdFn();
|
|
555
|
-
};
|
|
556
|
-
const beforeReward = (originShowAdFn: () => void) => {
|
|
557
|
-
if (originBeforeReward) {
|
|
558
|
-
originBeforeReward(wrapShowAdFn(originShowAdFn));
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
params.beforeReward = beforeReward;
|
|
562
|
-
}
|
|
563
|
-
/* hook beforeAd to track beforeAd event -- end */
|
|
564
|
-
|
|
565
583
|
let paramsToTrack;
|
|
566
584
|
switch (type) {
|
|
567
585
|
case 'preroll':
|
package/src/native/api/ads.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IAdsInitParams, JoliboxAdsImpl, IAdConfigParams, IAdBreakParams, IAdUni
|
|
|
7
7
|
import { track } from '../report';
|
|
8
8
|
|
|
9
9
|
import { innerFetch as fetch } from '../network';
|
|
10
|
-
import { invokeNative } from '
|
|
10
|
+
import { invokeNative } from '@jolibox/native-bridge';
|
|
11
11
|
|
|
12
12
|
const checkNetworkStatus = () => {
|
|
13
13
|
const { data } = invokeNative('getNetworkStatusSync');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createCommands } from '@jolibox/common';
|
|
2
|
-
import { invokeNative } from '
|
|
2
|
+
import { invokeNative } from '@jolibox/native-bridge';
|
|
3
3
|
import { createSyncAPI, registerCanIUse, t } from './base';
|
|
4
4
|
|
|
5
5
|
export const showKeyboard = createSyncAPI('showKeyboard', {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseError, createCommands, wrapUserFunction, hostEmitter, isBoolean } from '@jolibox/common';
|
|
2
2
|
import { createAPI, createSyncAPI, registerCanIUse, t } from './base';
|
|
3
3
|
import { reportError } from '@/common/report/errors/report';
|
|
4
|
-
import { applyNative, onNative, publish } from '
|
|
4
|
+
import { applyNative, onNative, publish } from '@jolibox/native-bridge';
|
|
5
5
|
import { nativeTaskEmitter } from '../report';
|
|
6
6
|
import { context } from '@/common/context';
|
|
7
7
|
|
package/src/native/api/login.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { context } from '@/common/context';
|
|
2
|
-
import { applyNative, invokeNative, onNative } from '
|
|
2
|
+
import { applyNative, invokeNative, onNative } from '@jolibox/native-bridge';
|
|
3
3
|
import { createAPI, t, registerCanIUse } from './base';
|
|
4
4
|
import { createCommands, Deferred, hostEmitter } from '@jolibox/common';
|
|
5
5
|
import { createAPIError } from '@/common/report/errors';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createCommands, UserCustomError } from '@jolibox/common';
|
|
2
|
-
import { invokeNative } from '
|
|
2
|
+
import { invokeNative } from '@jolibox/native-bridge';
|
|
3
3
|
import { createSyncAPI, t, registerCanIUse } from './base';
|
|
4
4
|
import { context } from '@/common/context';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAPI, createSyncAPI, registerCanIUse, t } from './base';
|
|
2
|
-
import { applyNative, invokeNative } from '
|
|
2
|
+
import { applyNative, invokeNative } from '@jolibox/native-bridge';
|
|
3
3
|
import { createCommands } from '@jolibox/common';
|
|
4
4
|
import { innerFetch as fetch } from '../network';
|
|
5
5
|
import { context } from '@/common/context';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { invokeNative, onNative, RuntimeLoader } from '
|
|
2
|
-
import { joliboxJSCore } from '../js-core';
|
|
1
|
+
import { invokeNative, onNative, RuntimeLoader } from '@jolibox/native-bridge';
|
|
3
2
|
import { context } from '@/common/context';
|
|
4
3
|
import { hostEmitter, isBoolean } from '@jolibox/common';
|
|
5
4
|
import { taskTracker, track } from '../report';
|
|
@@ -7,11 +6,19 @@ import { initializeNativeEnv } from './init-env';
|
|
|
7
6
|
import { adEventEmitter } from '@/common/ads';
|
|
8
7
|
import { openRetentionSchema } from '../ui/retention';
|
|
9
8
|
import { innerFetch } from '../network';
|
|
10
|
-
|
|
9
|
+
import { Env } from '@jolibox/types';
|
|
11
10
|
interface IBasicMetaConfig {
|
|
12
11
|
canShowRecommended: boolean;
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
declare const globalThis: {
|
|
15
|
+
joliboxJSCore: {
|
|
16
|
+
doExit: (uuid: string) => void;
|
|
17
|
+
onDocumentReady: (path: string) => void;
|
|
18
|
+
env: (params: { onError: (error: Error) => void }) => Env | undefined;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* 全局变量
|
|
17
24
|
*/
|
|
@@ -58,7 +65,7 @@ function addShowAdListener() {
|
|
|
58
65
|
*/
|
|
59
66
|
function addWebviewReadyListener() {
|
|
60
67
|
hostEmitter.on('onDocumentReady', () => {
|
|
61
|
-
joliboxJSCore?.onDocumentReady(window.location.href);
|
|
68
|
+
globalThis.joliboxJSCore?.onDocumentReady(window.location.href);
|
|
62
69
|
track('onDocumentReady', {
|
|
63
70
|
start_timestamp,
|
|
64
71
|
timestamp: Date.now()
|
|
@@ -89,7 +96,7 @@ function addGameServiceReadyListener() {
|
|
|
89
96
|
});
|
|
90
97
|
|
|
91
98
|
onNative('onBeforeExit', ({ uuid }) => {
|
|
92
|
-
joliboxJSCore?.doExit(uuid);
|
|
99
|
+
globalThis.joliboxJSCore?.doExit(uuid);
|
|
93
100
|
});
|
|
94
101
|
}
|
|
95
102
|
|
|
@@ -111,7 +118,7 @@ function addDoExitLoader() {
|
|
|
111
118
|
taskTracker.close(Date.now() - start_timestamp);
|
|
112
119
|
};
|
|
113
120
|
|
|
114
|
-
RuntimeLoader.
|
|
121
|
+
RuntimeLoader.onDoExit(async () => {
|
|
115
122
|
if (isAdShowing) {
|
|
116
123
|
return true; // Forbid exit on watching ads
|
|
117
124
|
}
|
|
@@ -2,7 +2,7 @@ import { isString, logger, Deferred, isObject, hostEmitter } from '@jolibox/comm
|
|
|
2
2
|
import { reportNetworkAPI } from './report';
|
|
3
3
|
import { RequestFrom } from './types';
|
|
4
4
|
import { FetchResponse, FetchOptions } from './types';
|
|
5
|
-
import { invokeNative, onNative } from '
|
|
5
|
+
import { invokeNative, onNative } from '@jolibox/native-bridge';
|
|
6
6
|
import { AnyFunction } from '@jolibox/types';
|
|
7
7
|
import { reportError } from '@/common/report/errors/report';
|
|
8
8
|
import { createAPIError } from '@/common/report/errors';
|
|
@@ -5,7 +5,7 @@ import '@/common/report/errors/report/listeners';
|
|
|
5
5
|
import { errorReportEmitter } from '@/common/report/errors';
|
|
6
6
|
import { ErrorData } from '@/common/report/errors/report';
|
|
7
7
|
import { logger } from '@jolibox/common';
|
|
8
|
-
import {
|
|
8
|
+
import { invokeNative } from '@jolibox/native-bridge';
|
|
9
9
|
|
|
10
10
|
errorReportEmitter.on('GLOBAL_ERROR', (error, errorData: ErrorData) => {
|
|
11
11
|
const extra = {
|
|
@@ -4,7 +4,7 @@ export * from '../../common/report/types';
|
|
|
4
4
|
import { createTracks, ReportHandler } from '@/common/report';
|
|
5
5
|
import { context } from '@/common/context';
|
|
6
6
|
import { NativeTaskTracker } from './task-tracker';
|
|
7
|
-
import { invokeNative } from '
|
|
7
|
+
import { invokeNative } from '@jolibox/native-bridge';
|
|
8
8
|
|
|
9
9
|
const reportNative: ReportHandler = (event, data, webviewId) => {
|
|
10
10
|
const _data = data as Record<string, unknown>;
|
|
@@ -6,7 +6,7 @@ import { context } from '@/common/context';
|
|
|
6
6
|
import { TaskTracker, TaskPoint } from '@/common/report/task-track';
|
|
7
7
|
import { EventEmitter } from '@jolibox/common';
|
|
8
8
|
import { innerFetch as fetch } from '../network';
|
|
9
|
-
import { applyNative } from '
|
|
9
|
+
import { applyNative } from '@jolibox/native-bridge';
|
|
10
10
|
import type { Track } from '.';
|
|
11
11
|
import type { TrackEvent } from '@jolibox/types';
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { context } from '@/common/context';
|
|
2
|
-
import { invokeNative, subscribe } from '
|
|
2
|
+
import { invokeNative, subscribe } from '@jolibox/native-bridge';
|
|
3
3
|
import { Deferred } from '@jolibox/common';
|
|
4
4
|
import { createRecommendModal, IGame, IRecommendationButton, RecommendModalOnCloseParams } from '@jolibox/ui';
|
|
5
5
|
import { innerFetch as fetch } from '../network';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { On } from '../js-bridge';
|
|
2
|
-
export declare const applyNative: jsb.service.ApplyNative, invokeNative: jsb.service.InvokeNative, onNative: jsb.service.OnNative, offNative: jsb.service.OnNative, subscribeHandler: import("../js-bridge").SubscribeHandler, publish: import("../js-bridge").Publish, subscribe: On, unsubscribe: import("../js-bridge").Off;
|
|
3
|
-
export declare const onNativeWithError: On;
|
|
4
|
-
export { RuntimeLoader } from '../js-core';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const CUSTOM_EVENT_PREFIX = "custom_event_";
|
|
2
|
-
export declare const HOST_EVENT_PREFIX = "host_event_";
|
|
3
|
-
export declare const BUFFER_METHODS: string[];
|
|
4
|
-
export declare const BACKGROUND_FORBIDDEN_METHODS: string[];
|
|
5
|
-
export declare const SYNC_METHODS: string[];
|
|
6
|
-
export declare const BATCH_EVENT = "__batch_event__";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { InvokeHandler, On } from './types';
|
|
2
|
-
interface Invokes {
|
|
3
|
-
/** 暴露给宿主, 触发调用的方法 */
|
|
4
|
-
invokeHandler: InvokeHandler;
|
|
5
|
-
/** 基础库内部, 调用宿主的方法, 返回 native 返回对象 */
|
|
6
|
-
invokeNative: (method: string, args?: Record<string, unknown>, webviewId?: number) => any;
|
|
7
|
-
/** 基础库内部, 调用宿主的方法, 会根据 errMsg throwError */
|
|
8
|
-
applyNative: (method: string, args?: Record<string, unknown>, webviewId?: number) => any;
|
|
9
|
-
}
|
|
10
|
-
export declare function createInvoke(jsCore: jsb.JSCore, onNative: On): Invokes;
|
|
11
|
-
export declare function ifThrowError(method: string, res: {
|
|
12
|
-
errMsg?: string;
|
|
13
|
-
errNo?: number;
|
|
14
|
-
errorType?: string;
|
|
15
|
-
errorCode?: number;
|
|
16
|
-
}): {} | undefined;
|
|
17
|
-
export declare class ApplyNativeError extends Error {
|
|
18
|
-
readonly errNo?: number | undefined;
|
|
19
|
-
constructor(message: string, errNo?: number | undefined);
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createPublish(jsCore: jsb.JSCore): (event: string, data: Record<string, unknown>, webviewId?: number, force?: boolean) => void;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { On } from './types';
|
|
2
|
-
type MetricReporter = (points: unknown) => unknown;
|
|
3
|
-
interface MetricCache {
|
|
4
|
-
[props: string]: MetricCache | (number | string)[];
|
|
5
|
-
}
|
|
6
|
-
interface PVMetricCache {
|
|
7
|
-
[props: string]: PVMetricCache | number;
|
|
8
|
-
}
|
|
9
|
-
type MetricCacheType = MetricCache | PVMetricCache;
|
|
10
|
-
type MetricType = 'pv' | 'default';
|
|
11
|
-
type Prettier<T> = T extends Record<string, unknown> ? {
|
|
12
|
-
[K in keyof T]: T[K];
|
|
13
|
-
} : T;
|
|
14
|
-
type MetricPoint<Tag extends string, Name extends string> = Prettier<{
|
|
15
|
-
[k in Tag]: string;
|
|
16
|
-
} & {
|
|
17
|
-
[K in Name]: number | string;
|
|
18
|
-
}>;
|
|
19
|
-
interface PVPoint {
|
|
20
|
-
[props: string]: string | JSON;
|
|
21
|
-
}
|
|
22
|
-
interface MetricConfig<Tag extends string, Name extends string, Type extends string> {
|
|
23
|
-
reporter: MetricReporter;
|
|
24
|
-
interval?: number;
|
|
25
|
-
eventName: string;
|
|
26
|
-
tagNameOrder: Tag[];
|
|
27
|
-
metricName: Name;
|
|
28
|
-
type?: Type;
|
|
29
|
-
}
|
|
30
|
-
export declare class MetricsMonitor<Tag extends string, Name extends string, Type extends string> {
|
|
31
|
-
reporter: MetricReporter;
|
|
32
|
-
interval: number;
|
|
33
|
-
lastReportTime: number;
|
|
34
|
-
cache: MetricCacheType;
|
|
35
|
-
eventName: string;
|
|
36
|
-
tagNameOrder: Tag[];
|
|
37
|
-
metricName: Name;
|
|
38
|
-
type: MetricType;
|
|
39
|
-
constructor(config: MetricConfig<Tag, Name, Type>);
|
|
40
|
-
report(point: Type extends 'pv' ? PVPoint : MetricPoint<Tag, Name>): void;
|
|
41
|
-
flush(): void;
|
|
42
|
-
private tryReport;
|
|
43
|
-
private addPoint;
|
|
44
|
-
private addPVPoint;
|
|
45
|
-
private processPoints;
|
|
46
|
-
private clearPoints;
|
|
47
|
-
}
|
|
48
|
-
interface InvokeMetrics {
|
|
49
|
-
errMsg: string;
|
|
50
|
-
errNo?: number;
|
|
51
|
-
__timing?: {
|
|
52
|
-
receiveJSInvoke: number;
|
|
53
|
-
invokeCallback: number;
|
|
54
|
-
};
|
|
55
|
-
method: string;
|
|
56
|
-
startTime: number;
|
|
57
|
-
args?: Record<string, unknown>;
|
|
58
|
-
isForeground: string;
|
|
59
|
-
[prop: string]: unknown;
|
|
60
|
-
}
|
|
61
|
-
export type reportInvokeFn = (invokeMetrics: InvokeMetrics) => void;
|
|
62
|
-
export declare function createReportInvokeMetrics(jsCore: jsb.JSCore, onNative: On): reportInvokeFn;
|
|
63
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Off, On } from './types';
|
|
2
|
-
import { AnyFunction } from '@jolibox/types';
|
|
3
|
-
export interface Subscribes {
|
|
4
|
-
onNative: On;
|
|
5
|
-
offNative: Off;
|
|
6
|
-
subscribeHandler: AnyFunction;
|
|
7
|
-
subscribe: On;
|
|
8
|
-
unsubscribe: Off;
|
|
9
|
-
}
|
|
10
|
-
export declare function createSubscribe(jsCore: jsb.JSCore): Subscribes;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type Listener = (...args: any[]) => any;
|
|
2
|
-
export type On = <T extends string>(event: T, handler: Listener) => void;
|
|
3
|
-
export type Off = <T extends string>(event: T, handler: Listener) => void;
|
|
4
|
-
export type InvokeHandler = (callbackId: string | number, data: string | Record<string, unknown>) => void;
|
|
5
|
-
export type Publish = (event: string, data: Record<string, unknown>, webviewId?: number, force?: boolean) => void;
|
|
6
|
-
export type SubscribeHandler = (event: string, data: string | Record<string, unknown>, webviewId?: number) => void;
|
|
7
|
-
export type AnyFunction = (...args: any[]) => any;
|
|
8
|
-
export interface JSBridge {
|
|
9
|
-
invokeHandler: InvokeHandler;
|
|
10
|
-
subscribeHandler: SubscribeHandler;
|
|
11
|
-
invokeNative: jsb.service.InvokeNative;
|
|
12
|
-
applyNative: jsb.service.ApplyNative;
|
|
13
|
-
onNative: jsb.service.OnNative;
|
|
14
|
-
offNative: jsb.service.OffNative;
|
|
15
|
-
publish: Publish;
|
|
16
|
-
subscribe: On;
|
|
17
|
-
unsubscribe: Off;
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface DataObj {
|
|
2
|
-
params?: Record<string, unknown>;
|
|
3
|
-
errorCode?: number;
|
|
4
|
-
__extra?: {
|
|
5
|
-
startTime: number;
|
|
6
|
-
type: string;
|
|
7
|
-
};
|
|
8
|
-
__nativeBuffers__?: NativeBufferElement[] | undefined;
|
|
9
|
-
}
|
|
10
|
-
interface NativeBufferElement {
|
|
11
|
-
key: string;
|
|
12
|
-
value?: ArrayBuffer;
|
|
13
|
-
base64?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function unpack(data: unknown): DataObj;
|
|
16
|
-
export declare function pack(_data?: {}, useArrayBuffer?: boolean): Record<string, unknown>;
|
|
17
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export declare let joliboxJSCore: jsb.JSCore | undefined;
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
JoliAndroidSDKBridge?: {
|
|
5
|
-
invoke: (invokeString: string) => void;
|
|
6
|
-
onDocumentReady: (paramsstr: string) => void;
|
|
7
|
-
doExit: (uuidString: string) => void;
|
|
8
|
-
publish: (params: {
|
|
9
|
-
event: string;
|
|
10
|
-
webviewIds: number[] | '*';
|
|
11
|
-
paramsString: string;
|
|
12
|
-
}) => void;
|
|
13
|
-
};
|
|
14
|
-
webkit?: {
|
|
15
|
-
messageHandlers: {
|
|
16
|
-
invoke: {
|
|
17
|
-
postMessage: (params: {
|
|
18
|
-
event: string;
|
|
19
|
-
callbackId: number;
|
|
20
|
-
paramsString: string;
|
|
21
|
-
}) => void;
|
|
22
|
-
};
|
|
23
|
-
publish: {
|
|
24
|
-
postMessage: (params: {
|
|
25
|
-
event: string;
|
|
26
|
-
webviewIds: number[] | '*';
|
|
27
|
-
paramsString: string;
|
|
28
|
-
}) => void;
|
|
29
|
-
};
|
|
30
|
-
onDocumentReady: {
|
|
31
|
-
postMessage: (params: {
|
|
32
|
-
path: string;
|
|
33
|
-
}) => void;
|
|
34
|
-
};
|
|
35
|
-
doExit: {
|
|
36
|
-
postMessage: (params: {
|
|
37
|
-
uuid: string;
|
|
38
|
-
shouldInterrupt: boolean;
|
|
39
|
-
}) => void;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export declare const RuntimeLoader: {
|
|
46
|
-
trigger(): void;
|
|
47
|
-
exit(): Promise<boolean>;
|
|
48
|
-
onReady(fn: () => void): void;
|
|
49
|
-
doExit(fn: () => Promise<boolean>): void;
|
|
50
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface MessageEvent {
|
|
2
|
-
data: string;
|
|
3
|
-
ports: MessagePort[];
|
|
4
|
-
}
|
|
5
|
-
interface MessagePort {
|
|
6
|
-
onmessage: (msg: MessageEvent) => void;
|
|
7
|
-
postMessage: (msg: string) => void;
|
|
8
|
-
publish: (event: string, data: Record<string, unknown>) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare let messagePort: MessagePort | undefined;
|
|
11
|
-
export declare function initMessagePort(): void;
|
|
12
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { createBridge, On } from '../js-bridge';
|
|
2
|
-
|
|
3
|
-
import { joliboxJSCore, initMessagePort } from '../js-core';
|
|
4
|
-
|
|
5
|
-
import { formatErrorCode } from '../../common/report/errors';
|
|
6
|
-
import { AnyFunction } from '@jolibox/types';
|
|
7
|
-
import { InternalJSCoreNotFoundError } from '@jolibox/common';
|
|
8
|
-
|
|
9
|
-
declare const globalThis: {
|
|
10
|
-
joliboxJSBridge?: {
|
|
11
|
-
callHandler: AnyFunction;
|
|
12
|
-
invokeHandler: AnyFunction;
|
|
13
|
-
subscribeHandler: AnyFunction;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
|
-
const jsCore = joliboxJSCore!;
|
|
19
|
-
|
|
20
|
-
if (!jsCore) {
|
|
21
|
-
throw new InternalJSCoreNotFoundError('No joliboxJScore is found, native bridge not found.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
initMessagePort();
|
|
25
|
-
|
|
26
|
-
const core: jsb.JSCore = {
|
|
27
|
-
...jsCore
|
|
28
|
-
// publish(event: string, params: Record<string, unknown>, webviewIds: number[]) {
|
|
29
|
-
// if (messagePort) {
|
|
30
|
-
// messagePort.publish(event, params);
|
|
31
|
-
// return;
|
|
32
|
-
// }
|
|
33
|
-
// jsCore.publish(event, params, webviewIds);
|
|
34
|
-
// }
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const bridge = createBridge(core);
|
|
38
|
-
|
|
39
|
-
const { invokeHandler } = bridge;
|
|
40
|
-
|
|
41
|
-
export const {
|
|
42
|
-
applyNative,
|
|
43
|
-
invokeNative,
|
|
44
|
-
onNative,
|
|
45
|
-
offNative,
|
|
46
|
-
subscribeHandler,
|
|
47
|
-
publish,
|
|
48
|
-
subscribe,
|
|
49
|
-
unsubscribe
|
|
50
|
-
} = bridge;
|
|
51
|
-
|
|
52
|
-
export const onNativeWithError: On = (event, handler) => {
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
onNative(event as keyof jsb.service.NativeEventMap, (...rest: any) => {
|
|
55
|
-
if (rest[0]?.errorCode) {
|
|
56
|
-
rest[0].errorCode = formatErrorCode(event, rest[0].errorCode);
|
|
57
|
-
}
|
|
58
|
-
handler(...rest);
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
globalThis.joliboxJSBridge = {
|
|
63
|
-
callHandler: invokeHandler,
|
|
64
|
-
invokeHandler,
|
|
65
|
-
subscribeHandler
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export { RuntimeLoader } from '../js-core';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const CUSTOM_EVENT_PREFIX = 'custom_event_';
|
|
2
|
-
|
|
3
|
-
export const HOST_EVENT_PREFIX = 'host_event_';
|
|
4
|
-
|
|
5
|
-
//TODO: add buffer supported method
|
|
6
|
-
export const BUFFER_METHODS: string[] = [];
|
|
7
|
-
|
|
8
|
-
// TODO: add method cannot invoke background
|
|
9
|
-
export const BACKGROUND_FORBIDDEN_METHODS: string[] = [];
|
|
10
|
-
|
|
11
|
-
export const SYNC_METHODS: string[] = ['env', 'createRequestTask', 'login'];
|
|
12
|
-
|
|
13
|
-
export const BATCH_EVENT = '__batch_event__';
|