yach.open.jssdk 4.4.10-beta.2 → 4.4.10-beta.4
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/dist/yach_jssdk_4.4.10-beta.3.js +1 -0
- package/es/api/biz/navigation/close.d.ts +1 -0
- package/es/api/biz/navigation/tencentMeeting.d.ts +1 -0
- package/es/api/biz/util/addAppToNav.d.ts +9 -0
- package/es/api/biz/util/addAppToNav.js +23 -0
- package/es/api/biz/util/copy.d.ts +11 -0
- package/es/api/biz/util/copy.js +19 -0
- package/es/api/biz/util/focus.d.ts +7 -0
- package/es/api/biz/util/focus.js +23 -0
- package/es/api/biz/util/getConfig.d.ts +13 -0
- package/es/api/biz/util/getConfig.js +19 -0
- package/es/api/biz/util/knowledgeBaseSelect.d.ts +21 -0
- package/es/api/biz/util/knowledgeBaseSelect.js +23 -0
- package/es/api/biz/util/knowledgeSelectParams.d.ts +14 -0
- package/es/api/biz/util/knowledgeSelectParams.js +19 -0
- package/es/api/biz/util/lorebaseRefreshNodeWebview.d.ts +11 -0
- package/es/api/biz/util/lorebaseRefreshNodeWebview.js +19 -0
- package/es/api/biz/util/lorebaseShowList.d.ts +11 -0
- package/es/api/biz/util/lorebaseShowList.js +19 -0
- package/es/api/biz/util/mediaFileUploadV2.d.ts +26 -0
- package/es/api/biz/util/mediaFileUploadV2.js +15 -0
- package/es/api/biz/util/openAudioPlayer.d.ts +17 -0
- package/es/api/biz/util/openAudioPlayer.js +23 -0
- package/es/api/biz/util/openFutureGroup.d.ts +10 -0
- package/es/api/biz/util/openFutureGroup.js +23 -0
- package/es/api/biz/util/openMediaFileDialogV2.d.ts +23 -0
- package/es/api/biz/util/openMediaFileDialogV2.js +16 -0
- package/es/api/biz/util/openPublish.d.ts +22 -0
- package/es/api/biz/util/openPublish.js +15 -0
- package/es/api/biz/util/screen.d.ts +15 -0
- package/es/api/biz/util/screen.js +15 -0
- package/es/api/biz/util/topicEvent.d.ts +13 -0
- package/es/api/biz/util/topicEvent.js +27 -0
- package/es/api/biz/util/weeklyRead.d.ts +5 -0
- package/es/api/biz/util/weeklyRead.js +23 -0
- package/es/api/device/connection/startNetworkChangeWatch.d.ts +8 -0
- package/es/api/device/connection/startNetworkChangeWatch.js +23 -0
- package/es/api/device/notification/actionSheet.d.ts +6 -0
- package/es/api/device/notification/hidePreloader.d.ts +6 -1
- package/es/api/device/notification/hidePreloader.js +15 -2
- package/es/api/device/notification/showPreloader.d.ts +10 -1
- package/es/api/device/notification/showPreloader.js +15 -2
- package/es/api/primary/updateTab.d.ts +9 -0
- package/es/api/primary/updateTab.js +15 -0
- package/es/index.d.ts +41 -3
- package/es/index.js +44 -5
- package/es/lib/bridge/mobile.js +61 -20
- package/es/lib/bridge/pc.js +50 -8
- package/es/lib/helper/pcIframe.d.ts +8 -25
- package/es/lib/helper/pcIframe.js +34 -8
- package/es/lib/index.js +2 -2
- package/es/lib/sdk/index.js +13 -4
- package/es/lib/sdk/sdk.typings.d.ts +2 -0
- package/es/utils/console.d.ts +1 -1
- package/es/utils/console.js +2 -2
- package/es/utils/env.js +7 -3
- package/es/utils/index.js +1 -1
- package/libs/api/biz/navigation/close.d.ts +1 -0
- package/libs/api/biz/navigation/tencentMeeting.d.ts +1 -0
- package/libs/api/biz/util/addAppToNav.d.ts +9 -0
- package/libs/api/biz/util/addAppToNav.js +30 -0
- package/libs/api/biz/util/copy.d.ts +11 -0
- package/libs/api/biz/util/copy.js +26 -0
- package/libs/api/biz/util/focus.d.ts +7 -0
- package/libs/api/biz/util/focus.js +30 -0
- package/libs/api/biz/util/getConfig.d.ts +13 -0
- package/libs/api/biz/util/getConfig.js +26 -0
- package/libs/api/biz/util/knowledgeBaseSelect.d.ts +21 -0
- package/libs/api/biz/util/knowledgeBaseSelect.js +30 -0
- package/libs/api/biz/util/knowledgeSelectParams.d.ts +14 -0
- package/libs/api/biz/util/knowledgeSelectParams.js +26 -0
- package/libs/api/biz/util/lorebaseRefreshNodeWebview.d.ts +11 -0
- package/libs/api/biz/util/lorebaseRefreshNodeWebview.js +26 -0
- package/libs/api/biz/util/lorebaseShowList.d.ts +11 -0
- package/libs/api/biz/util/lorebaseShowList.js +26 -0
- package/libs/api/biz/util/mediaFileUploadV2.d.ts +26 -0
- package/libs/api/biz/util/mediaFileUploadV2.js +23 -0
- package/libs/api/biz/util/openAudioPlayer.d.ts +17 -0
- package/libs/api/biz/util/openAudioPlayer.js +30 -0
- package/libs/api/biz/util/openFutureGroup.d.ts +10 -0
- package/libs/api/biz/util/openFutureGroup.js +30 -0
- package/libs/api/biz/util/openMediaFileDialogV2.d.ts +23 -0
- package/libs/api/biz/util/openMediaFileDialogV2.js +24 -0
- package/libs/api/biz/util/openPublish.d.ts +22 -0
- package/libs/api/biz/util/openPublish.js +22 -0
- package/libs/api/biz/util/screen.d.ts +15 -0
- package/libs/api/biz/util/screen.js +22 -0
- package/libs/api/biz/util/topicEvent.d.ts +13 -0
- package/libs/api/biz/util/topicEvent.js +34 -0
- package/libs/api/biz/util/weeklyRead.d.ts +5 -0
- package/libs/api/biz/util/weeklyRead.js +30 -0
- package/libs/api/device/connection/startNetworkChangeWatch.d.ts +8 -0
- package/libs/api/device/connection/startNetworkChangeWatch.js +30 -0
- package/libs/api/device/notification/actionSheet.d.ts +6 -0
- package/libs/api/device/notification/hidePreloader.d.ts +6 -1
- package/libs/api/device/notification/hidePreloader.js +15 -1
- package/libs/api/device/notification/showPreloader.d.ts +10 -1
- package/libs/api/device/notification/showPreloader.js +15 -1
- package/libs/api/initAPI.js +1 -2
- package/libs/api/primary/updateTab.d.ts +9 -0
- package/libs/api/primary/updateTab.js +22 -0
- package/libs/index.d.ts +41 -3
- package/libs/index.js +186 -25
- package/libs/lib/bridge/mobile.js +64 -25
- package/libs/lib/bridge/pc.js +53 -13
- package/libs/lib/helper/event.js +1 -2
- package/libs/lib/helper/pcIframe.d.ts +8 -25
- package/libs/lib/helper/pcIframe.js +35 -10
- package/libs/lib/index.js +3 -4
- package/libs/lib/sdk/index.js +13 -5
- package/libs/lib/sdk/sdk.typings.d.ts +2 -0
- package/libs/lib/sdk/sdk.typings.js +0 -1
- package/libs/utils/compareVersions.js +4 -8
- package/libs/utils/console.d.ts +1 -1
- package/libs/utils/console.js +2 -2
- package/libs/utils/env.js +7 -3
- package/libs/utils/index.js +1 -1
- package/package.json +1 -3
- package/dist/yach_jssdk_4.3.3.js +0 -1
package/es/lib/bridge/mobile.js
CHANGED
|
@@ -2,6 +2,7 @@ import _setTimeout from "@babel/runtime-corejs3/core-js/set-timeout";
|
|
|
2
2
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
3
3
|
import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
4
4
|
import _parseInt from "@babel/runtime-corejs3/core-js/parse-int";
|
|
5
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
5
6
|
import Event from '../helper/event';
|
|
6
7
|
import { electronResCodeMap } from '../helper/codeMap';
|
|
7
8
|
import { log, bpitLog } from '../../utils';
|
|
@@ -66,6 +67,16 @@ var mobileBridgeInit = function mobileBridgeInit() {
|
|
|
66
67
|
});
|
|
67
68
|
Event.execEvent('sendMsgCommon', resData);
|
|
68
69
|
});
|
|
70
|
+
bridge.registerHandler('toolbarClickEvent', function (resData, responseCallback) {
|
|
71
|
+
log("toolbarClickEvent ", {
|
|
72
|
+
resData: resData
|
|
73
|
+
});
|
|
74
|
+
var responseData = {
|
|
75
|
+
data: resData,
|
|
76
|
+
callback: responseCallback
|
|
77
|
+
};
|
|
78
|
+
Event.execEvent('toolbarClickEvent', responseData);
|
|
79
|
+
});
|
|
69
80
|
resolve();
|
|
70
81
|
});
|
|
71
82
|
});
|
|
@@ -93,26 +104,6 @@ var mobileBridge = function mobileBridge(method, param) {
|
|
|
93
104
|
data = e.data;
|
|
94
105
|
var _code = _parseInt(code);
|
|
95
106
|
var callbackStr = electronResCodeMap(_code);
|
|
96
|
-
if (_code === -2 || _code === 7) {
|
|
97
|
-
bpitLog({
|
|
98
|
-
method: method,
|
|
99
|
-
errorcode: _code,
|
|
100
|
-
message: message || 'SDK执行失败回调,相关参数'
|
|
101
|
-
});
|
|
102
|
-
log("SDK\u6267\u884C\u540E\u56DE\u8C03\uFF0C\u76F8\u5173\u53C2\u6570 ", {
|
|
103
|
-
method: method,
|
|
104
|
-
param: param,
|
|
105
|
-
data: data,
|
|
106
|
-
_code: _code,
|
|
107
|
-
message: message
|
|
108
|
-
});
|
|
109
|
-
reject({
|
|
110
|
-
_code: _code,
|
|
111
|
-
message: message
|
|
112
|
-
});
|
|
113
|
-
// return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
107
|
var callbackFun = p[callbackStr];
|
|
117
108
|
log("SDK\u6267\u884C\u540E\u56DE\u8C03\uFF0C\u76F8\u5173\u53C2\u6570 ", {
|
|
118
109
|
method: method,
|
|
@@ -122,6 +113,27 @@ var mobileBridge = function mobileBridge(method, param) {
|
|
|
122
113
|
message: message,
|
|
123
114
|
callbackFun: callbackFun
|
|
124
115
|
});
|
|
116
|
+
// 请求失败
|
|
117
|
+
if (callbackStr === 'onFail') {
|
|
118
|
+
bpitLog({
|
|
119
|
+
method: method,
|
|
120
|
+
errorcode: _code,
|
|
121
|
+
message: message || _JSON$stringify(data) || 'SDK执行失败回调,相关参数'
|
|
122
|
+
});
|
|
123
|
+
if ('function' === typeof callbackFun) {
|
|
124
|
+
message ? callbackFun({
|
|
125
|
+
code: code,
|
|
126
|
+
message: message
|
|
127
|
+
}) : callbackFun(data);
|
|
128
|
+
}
|
|
129
|
+
reject({
|
|
130
|
+
_code: _code,
|
|
131
|
+
message: message,
|
|
132
|
+
data: data
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// 请求成功
|
|
125
137
|
if ('function' === typeof callbackFun) {
|
|
126
138
|
callbackFun(data || message);
|
|
127
139
|
}
|
|
@@ -130,6 +142,35 @@ var mobileBridge = function mobileBridge(method, param) {
|
|
|
130
142
|
message: message,
|
|
131
143
|
data: data
|
|
132
144
|
});
|
|
145
|
+
// if (_code === -2 || _code === 7) {
|
|
146
|
+
// bpitLog({
|
|
147
|
+
// method,
|
|
148
|
+
// errorcode: _code,
|
|
149
|
+
// message: message || 'SDK执行失败回调,相关参数',
|
|
150
|
+
// });
|
|
151
|
+
// log(`SDK执行后回调,相关参数 `, {
|
|
152
|
+
// method,
|
|
153
|
+
// param,
|
|
154
|
+
// data,
|
|
155
|
+
// _code,
|
|
156
|
+
// message,
|
|
157
|
+
// });
|
|
158
|
+
// reject({_code, message});
|
|
159
|
+
// // return;
|
|
160
|
+
// }
|
|
161
|
+
// const callbackFun = p[callbackStr];
|
|
162
|
+
// log(`SDK执行后回调,相关参数 `, {
|
|
163
|
+
// method,
|
|
164
|
+
// param,
|
|
165
|
+
// data,
|
|
166
|
+
// _code,
|
|
167
|
+
// message,
|
|
168
|
+
// callbackFun,
|
|
169
|
+
// });
|
|
170
|
+
// if ('function' === typeof callbackFun) {
|
|
171
|
+
// callbackFun(data || message);
|
|
172
|
+
// }
|
|
173
|
+
// resolve({_code, message, data});
|
|
133
174
|
});
|
|
134
175
|
});
|
|
135
176
|
});
|
package/es/lib/bridge/pc.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
2
2
|
import _parseInt from "@babel/runtime-corejs3/core-js/parse-int";
|
|
3
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
4
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
3
5
|
import PcIframe from '../helper/pcIframe';
|
|
4
6
|
import { electronResCodeMap } from '../helper/codeMap';
|
|
5
7
|
import { log, bpitLog } from '../../utils';
|
|
@@ -7,20 +9,13 @@ var PcBridgeInit = function PcBridgeInit() {
|
|
|
7
9
|
PcIframe.init();
|
|
8
10
|
};
|
|
9
11
|
var pcBridge = function pcBridge(method, param) {
|
|
10
|
-
return new _Promise(function (resolve) {
|
|
12
|
+
return new _Promise(function (resolve, reject) {
|
|
11
13
|
return PcIframe.invokeAPI(method, param, function (_ref) {
|
|
12
14
|
var data = _ref.data,
|
|
13
15
|
code = _ref.code,
|
|
14
16
|
message = _ref.message;
|
|
15
17
|
var _code = _parseInt(code);
|
|
16
18
|
var callbackStr = electronResCodeMap(_code);
|
|
17
|
-
if (_code === -2) {
|
|
18
|
-
bpitLog({
|
|
19
|
-
method: method,
|
|
20
|
-
errorcode: _code,
|
|
21
|
-
message: message || 'SDK执行失败回调,相关参数'
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
19
|
var callbackFun = param[callbackStr];
|
|
25
20
|
log("SDK\u6267\u884C\u540E\u56DE\u8C03\uFF0C\u76F8\u5173\u53C2\u6570 ", {
|
|
26
21
|
method: method,
|
|
@@ -30,6 +25,33 @@ var pcBridge = function pcBridge(method, param) {
|
|
|
30
25
|
message: message,
|
|
31
26
|
callbackFun: callbackFun
|
|
32
27
|
});
|
|
28
|
+
// 请求失败
|
|
29
|
+
if (callbackStr === 'onFail') {
|
|
30
|
+
bpitLog({
|
|
31
|
+
method: method,
|
|
32
|
+
errorcode: _code,
|
|
33
|
+
message: message || _JSON$stringify(data) || 'SDK执行失败回调,相关参数'
|
|
34
|
+
});
|
|
35
|
+
if ('function' === typeof callbackFun) {
|
|
36
|
+
console.log('wenai-code', code, _code);
|
|
37
|
+
var callbackData = Object.prototype.toString.call(data) === "[object Object]" ? _Object$assign(_Object$assign({}, data), {
|
|
38
|
+
code: code,
|
|
39
|
+
message: message
|
|
40
|
+
}) : {
|
|
41
|
+
data: data,
|
|
42
|
+
code: code,
|
|
43
|
+
message: message
|
|
44
|
+
};
|
|
45
|
+
message ? callbackFun(callbackData) : callbackFun(data);
|
|
46
|
+
}
|
|
47
|
+
reject({
|
|
48
|
+
_code: _code,
|
|
49
|
+
message: message,
|
|
50
|
+
data: data
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// 请求成功
|
|
33
55
|
if ('function' === typeof callbackFun) {
|
|
34
56
|
callbackFun(data || message);
|
|
35
57
|
}
|
|
@@ -38,6 +60,26 @@ var pcBridge = function pcBridge(method, param) {
|
|
|
38
60
|
message: message,
|
|
39
61
|
data: data
|
|
40
62
|
});
|
|
63
|
+
// if (_code === -2) {
|
|
64
|
+
// bpitLog({
|
|
65
|
+
// method,
|
|
66
|
+
// errorcode: _code,
|
|
67
|
+
// message: message || 'SDK执行失败回调,相关参数',
|
|
68
|
+
// });
|
|
69
|
+
// }
|
|
70
|
+
// const callbackFun = param[callbackStr];
|
|
71
|
+
// log(`SDK执行后回调,相关参数 `, {
|
|
72
|
+
// method,
|
|
73
|
+
// param,
|
|
74
|
+
// data,
|
|
75
|
+
// _code,
|
|
76
|
+
// message,
|
|
77
|
+
// callbackFun
|
|
78
|
+
// });
|
|
79
|
+
// if ('function' === typeof callbackFun) {
|
|
80
|
+
// callbackFun(data || message);
|
|
81
|
+
// }
|
|
82
|
+
// resolve({ _code, message, data });
|
|
41
83
|
});
|
|
42
84
|
});
|
|
43
85
|
};
|
|
@@ -3,41 +3,24 @@ declare global {
|
|
|
3
3
|
sendToHost: any;
|
|
4
4
|
sendTo: any;
|
|
5
5
|
receiveBrowserViewData: any;
|
|
6
|
+
remoteSendToHost?: (payload: string) => void;
|
|
7
|
+
remoteReceiveFromHost?: (callback: (result: Record<string, any>) => void, moduleId?: string) => void;
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
invokeType?: 'browserView' | '';
|
|
10
|
-
[propName: string]: any;
|
|
11
|
-
}
|
|
12
|
-
declare class GenPostMsg {
|
|
13
|
-
private id;
|
|
14
|
-
private PromiseObj;
|
|
15
|
-
private methodName;
|
|
16
|
-
private plainMsg;
|
|
17
|
-
callback: (v: any) => void;
|
|
18
|
-
result: Promise<any>;
|
|
19
|
-
invokeType: 'browserView' | '';
|
|
20
|
-
constructor(method: string, param: APIParams, callback: any);
|
|
21
|
-
genid: () => string;
|
|
22
|
-
receiveResponse: (data: any) => void;
|
|
23
|
-
getPayload: () => {
|
|
24
|
-
msgId: string;
|
|
25
|
-
methodName: string;
|
|
26
|
-
body: object;
|
|
27
|
-
type: string;
|
|
28
|
-
invokeType: "" | "browserView";
|
|
29
|
-
};
|
|
30
|
-
}
|
|
10
|
+
declare type InvokeType = 'browserView' | 'moduleFederation' | '';
|
|
31
11
|
declare class Frame {
|
|
32
12
|
pendingMsgs: {};
|
|
13
|
+
invokeType?: InvokeType;
|
|
14
|
+
moduleId?: string;
|
|
33
15
|
constructor();
|
|
34
16
|
addPending: (e: any) => void;
|
|
35
17
|
deletePending: (e: any) => void;
|
|
36
18
|
getPending: (t: any) => any;
|
|
37
19
|
invokeAPIInBrowserView: (payload: string) => void;
|
|
38
20
|
invokeAPIInWebview: (payload: string) => void;
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
invokeAPIInModuleFederation: (payload: string) => void;
|
|
22
|
+
invokeAPI: (method: string, param: any, callback: any) => any;
|
|
23
|
+
handleCallback: (datas: any, invokeType?: InvokeType) => void;
|
|
41
24
|
init: () => void;
|
|
42
25
|
}
|
|
43
26
|
declare const frame: Frame;
|
|
@@ -21,6 +21,7 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
|
|
|
21
21
|
return {
|
|
22
22
|
msgId: _this.id,
|
|
23
23
|
methodName: _this.methodName,
|
|
24
|
+
moduleId: _this.moduleId,
|
|
24
25
|
body: _this.plainMsg,
|
|
25
26
|
type: 'request',
|
|
26
27
|
invokeType: _this.invokeType
|
|
@@ -34,6 +35,7 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
|
|
|
34
35
|
this.methodName = method;
|
|
35
36
|
this.plainMsg = param;
|
|
36
37
|
this.invokeType = param === null || param === void 0 ? void 0 : param.invokeType;
|
|
38
|
+
this.moduleId = param === null || param === void 0 ? void 0 : param.moduleId;
|
|
37
39
|
this.callback = callback;
|
|
38
40
|
// this.result = new Promise(
|
|
39
41
|
// function (resolve, reject) {
|
|
@@ -62,12 +64,25 @@ var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
|
62
64
|
this.invokeAPIInWebview = function (payload) {
|
|
63
65
|
window.sendToHost(payload);
|
|
64
66
|
};
|
|
67
|
+
this.invokeAPIInModuleFederation = function (payload) {
|
|
68
|
+
window.remoteSendToHost(payload);
|
|
69
|
+
};
|
|
65
70
|
this.invokeAPI = function (method, param, callback) {
|
|
66
|
-
var genPostMsg
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
var genPostMsg;
|
|
72
|
+
if (_this2.invokeType === 'moduleFederation') {
|
|
73
|
+
param.invokeType = _this2.invokeType;
|
|
74
|
+
param.moduleId = _this2.moduleId;
|
|
75
|
+
genPostMsg = new GenPostMsg(method, param, callback);
|
|
76
|
+
var payload = _JSON$stringify(genPostMsg.getPayload());
|
|
77
|
+
_this2.invokeAPIInModuleFederation(payload);
|
|
78
|
+
} else {
|
|
79
|
+
genPostMsg = new GenPostMsg(method, param, callback);
|
|
80
|
+
var _payload = _JSON$stringify(genPostMsg.getPayload());
|
|
81
|
+
var _param$invokeType = param.invokeType,
|
|
82
|
+
invokeType = _param$invokeType === void 0 ? '' : _param$invokeType;
|
|
83
|
+
invokeType === 'browserView' ? _this2.invokeAPIInBrowserView(_payload) : _this2.invokeAPIInWebview(_payload);
|
|
84
|
+
}
|
|
85
|
+
// 调用时传入 moduleId
|
|
71
86
|
_this2.addPending(genPostMsg);
|
|
72
87
|
return genPostMsg;
|
|
73
88
|
};
|
|
@@ -76,9 +91,11 @@ var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
|
76
91
|
methodName = datas.methodName,
|
|
77
92
|
eventName = datas.eventName,
|
|
78
93
|
msgId = datas.msgId,
|
|
79
|
-
data = datas.data,
|
|
94
|
+
_datas$data = datas.data,
|
|
95
|
+
data = _datas$data === void 0 ? {} : _datas$data,
|
|
80
96
|
code = datas.code,
|
|
81
|
-
message = datas.message
|
|
97
|
+
message = datas.message,
|
|
98
|
+
msg = datas.msg;
|
|
82
99
|
if (type === 'request') {
|
|
83
100
|
// 壳子的调用
|
|
84
101
|
switch (methodName) {
|
|
@@ -128,12 +145,19 @@ var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
|
128
145
|
pending && pending.receiveResponse({
|
|
129
146
|
data: data,
|
|
130
147
|
code: code,
|
|
131
|
-
message: message
|
|
148
|
+
message: message || msg || data.msg || data.message
|
|
132
149
|
});
|
|
133
150
|
code != -3 && _this2.deletePending(msgId);
|
|
134
151
|
}
|
|
135
152
|
};
|
|
136
153
|
this.init = function () {
|
|
154
|
+
var _a;
|
|
155
|
+
if (_this2.invokeType === 'moduleFederation') {
|
|
156
|
+
(_a = window.remoteReceiveFromHost) === null || _a === void 0 ? void 0 : _a.call(window, function (response) {
|
|
157
|
+
_this2.handleCallback(response);
|
|
158
|
+
}, _this2.moduleId);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
137
161
|
window.addEventListener('message', function (msg) {
|
|
138
162
|
log('electron res: ', msg);
|
|
139
163
|
_this2.handleCallback(msg.data || {});
|
|
@@ -143,6 +167,8 @@ var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
|
143
167
|
});
|
|
144
168
|
};
|
|
145
169
|
this.pendingMsgs = {};
|
|
170
|
+
this.invokeType = window.remoteSendToHost && window.remoteReceiveFromHost && process ? 'moduleFederation' : '';
|
|
171
|
+
this.moduleId = Math.random().toString(36).substring(2, 15);
|
|
146
172
|
});
|
|
147
173
|
var frame = new Frame();
|
|
148
174
|
export default frame;
|
package/es/lib/index.js
CHANGED
|
@@ -40,12 +40,12 @@ function initSdk() {
|
|
|
40
40
|
if (platform === 'pc') {
|
|
41
41
|
bridgeInit = function bridgeInit() {
|
|
42
42
|
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
43
|
-
return _regeneratorRuntime.wrap(function
|
|
43
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
44
44
|
while (1) switch (_context.prev = _context.next) {
|
|
45
45
|
case 0:
|
|
46
46
|
PcBridgeInit();
|
|
47
47
|
return _context.abrupt("return", pcBridge);
|
|
48
|
-
case
|
|
48
|
+
case 1:
|
|
49
49
|
case "end":
|
|
50
50
|
return _context.stop();
|
|
51
51
|
}
|
package/es/lib/sdk/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
3
3
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
4
4
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
5
|
-
import { bpitLog } from '../../utils';
|
|
5
|
+
import { bpitLog, log } from '../../utils';
|
|
6
6
|
import { compareVersions } from '../../utils/compareVersions';
|
|
7
7
|
import packageInfo from '../../../package.json';
|
|
8
8
|
var Sdk = /*#__PURE__*/function () {
|
|
@@ -70,7 +70,7 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
_createClass(Sdk, [{
|
|
73
|
+
return _createClass(Sdk, [{
|
|
74
74
|
key: "setAPI",
|
|
75
75
|
value: function setAPI(method, config) {
|
|
76
76
|
this.invokeAPIConfigMapByMethod[method] = config;
|
|
@@ -142,10 +142,20 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
142
142
|
}
|
|
143
143
|
// 主方法
|
|
144
144
|
this.bridgeInitFn().then(function (fn) {
|
|
145
|
-
fn(method, p).then(function () {
|
|
145
|
+
fn(method, p).then(function (res) {
|
|
146
146
|
// 调用成功
|
|
147
|
+
log("SDK \u8FD4\u56DE\u7ED3\u679C\u6210\u529F ", {
|
|
148
|
+
method: method,
|
|
149
|
+
params: p,
|
|
150
|
+
result: res
|
|
151
|
+
});
|
|
147
152
|
})["catch"](function (error) {
|
|
148
153
|
// 调用失败
|
|
154
|
+
log("SDK \u8FD4\u56DE\u7ED3\u679C\u5931\u8D25", {
|
|
155
|
+
method: method,
|
|
156
|
+
params: p,
|
|
157
|
+
error: error
|
|
158
|
+
});
|
|
149
159
|
});
|
|
150
160
|
})["catch"](function (err) {
|
|
151
161
|
console.log('wenai err', err);
|
|
@@ -155,6 +165,5 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
155
165
|
this._onFail(method, '-1', _concatInstanceProperty(_context2 = "[".concat(method, "] method do not support the current platform (")).call(_context2, this.env.platform, ")"), params.onFail);
|
|
156
166
|
}
|
|
157
167
|
}]);
|
|
158
|
-
return Sdk;
|
|
159
168
|
}();
|
|
160
169
|
export default Sdk;
|
|
@@ -17,6 +17,7 @@ export interface PlatformV2Props {
|
|
|
17
17
|
inPC: boolean;
|
|
18
18
|
inIpad: boolean;
|
|
19
19
|
inIPhone: boolean;
|
|
20
|
+
inHarmonyNext: boolean;
|
|
20
21
|
}
|
|
21
22
|
export interface IENV {
|
|
22
23
|
/** current platform (ios or android or pc or notInYach) */
|
|
@@ -26,6 +27,7 @@ export interface IENV {
|
|
|
26
27
|
/** @deprecated recommend use navigator.language to get current language */
|
|
27
28
|
language?: string;
|
|
28
29
|
platformV2: PlatformV2Props;
|
|
30
|
+
env: 'test' | 'online';
|
|
29
31
|
}
|
|
30
32
|
export interface IInvokeAPIConfigMap {
|
|
31
33
|
[platform: string]: IAPIConfig | undefined;
|
package/es/utils/console.d.ts
CHANGED
package/es/utils/console.js
CHANGED
|
@@ -6,10 +6,10 @@ var myconsole = {
|
|
|
6
6
|
warn: function warn() {},
|
|
7
7
|
error: function error() {}
|
|
8
8
|
};
|
|
9
|
-
if (window && window.console) {
|
|
9
|
+
if (typeof window !== 'undefined' && window.console) {
|
|
10
10
|
myconsole = window.console;
|
|
11
11
|
}
|
|
12
|
-
if (document && document.body) {
|
|
12
|
+
if (typeof document !== 'undefined' && document.body) {
|
|
13
13
|
var iframe = document.createElement('iframe');
|
|
14
14
|
if (iframe && iframe.contentWindow && iframe.contentWindow.console) {
|
|
15
15
|
iframe.style.display = 'none';
|
package/es/utils/env.js
CHANGED
|
@@ -9,7 +9,9 @@ function getENV() {
|
|
|
9
9
|
inAndroid = /Android/i.test(ua) && inYach,
|
|
10
10
|
inPC = /YachPc/i.test(ua),
|
|
11
11
|
inIpad = /iPad/i.test(ua) && inYach,
|
|
12
|
-
inIPhone = /iPhone/i.test(ua) && inYach
|
|
12
|
+
inIPhone = /iPhone/i.test(ua) && inYach,
|
|
13
|
+
isTest = /Yachtest/.test(ua) && inYach,
|
|
14
|
+
inHarmonyNext = /HarmonyOSNext/i.test(ua) && inYach;
|
|
13
15
|
// platform
|
|
14
16
|
var platform = ENV_ENUM.notInYach;
|
|
15
17
|
if (inIOS) {
|
|
@@ -34,10 +36,12 @@ function getENV() {
|
|
|
34
36
|
inAndroid: inAndroid,
|
|
35
37
|
inPC: inPC,
|
|
36
38
|
inIpad: inIpad,
|
|
37
|
-
inIPhone: inIPhone
|
|
39
|
+
inIPhone: inIPhone,
|
|
40
|
+
inHarmonyNext: inHarmonyNext
|
|
38
41
|
},
|
|
39
42
|
version: version,
|
|
40
|
-
language: language
|
|
43
|
+
language: language,
|
|
44
|
+
env: isTest ? 'test' : 'online'
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
export { getENV };
|
package/es/utils/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getENV } from './env';
|
|
|
4
4
|
import bpitLog from './bpitLog';
|
|
5
5
|
import { log, error, warn } from './console';
|
|
6
6
|
function staticsLog(config) {
|
|
7
|
-
var env =
|
|
7
|
+
var env = getENV().env;
|
|
8
8
|
var version = getENV().version;
|
|
9
9
|
var timestamp = _Date$now();
|
|
10
10
|
var params = _Object$assign({
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IError } from '../../common.typings';
|
|
2
|
+
export interface IAddAppToNavParams {
|
|
3
|
+
appId: string;
|
|
4
|
+
platfrorm?: string;
|
|
5
|
+
onSuccess?: (res: any) => void;
|
|
6
|
+
onFail?: (err: IError) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function addAppToNav(params: IAddAppToNavParams): void;
|
|
9
|
+
export { addAppToNav };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.addAppToNav = addAppToNav;
|
|
9
|
+
var _initAPI = _interopRequireDefault(require("../../initAPI"));
|
|
10
|
+
var ios = {
|
|
11
|
+
vs: '1.8.8'
|
|
12
|
+
};
|
|
13
|
+
var android = {
|
|
14
|
+
vs: '1.8.8'
|
|
15
|
+
};
|
|
16
|
+
var pc = {
|
|
17
|
+
vs: '1.8.8'
|
|
18
|
+
};
|
|
19
|
+
var platform = {
|
|
20
|
+
ios: ios,
|
|
21
|
+
android: android,
|
|
22
|
+
pc: pc
|
|
23
|
+
};
|
|
24
|
+
var apiName = 'biz.util.addAppToNav';
|
|
25
|
+
function addAppToNav(params) {
|
|
26
|
+
(0, _initAPI["default"])(apiName, {
|
|
27
|
+
params: params,
|
|
28
|
+
platform: platform
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IError } from '../../common.typings';
|
|
2
|
+
export interface IBizUtilCopyResult {
|
|
3
|
+
data?: Object;
|
|
4
|
+
}
|
|
5
|
+
export interface IBizUtilCopyParams {
|
|
6
|
+
text: string;
|
|
7
|
+
onSuccess?: (data: IBizUtilCopyResult) => void;
|
|
8
|
+
onFail?: (err: IError) => void;
|
|
9
|
+
}
|
|
10
|
+
declare function copy(params: IBizUtilCopyParams): void;
|
|
11
|
+
export { copy };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.copy = copy;
|
|
9
|
+
var _initAPI = _interopRequireDefault(require("../../initAPI"));
|
|
10
|
+
var ios = {
|
|
11
|
+
vs: '0.0.0'
|
|
12
|
+
};
|
|
13
|
+
var android = {
|
|
14
|
+
vs: '0.0.0'
|
|
15
|
+
};
|
|
16
|
+
var platform = {
|
|
17
|
+
ios: ios,
|
|
18
|
+
android: android
|
|
19
|
+
};
|
|
20
|
+
var apiName = 'biz.util.copy';
|
|
21
|
+
function copy(params) {
|
|
22
|
+
(0, _initAPI["default"])(apiName, {
|
|
23
|
+
params: params,
|
|
24
|
+
platform: platform
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.focus = focus;
|
|
9
|
+
var _initAPI = _interopRequireDefault(require("../../initAPI"));
|
|
10
|
+
var pc = {
|
|
11
|
+
vs: '1.9.13'
|
|
12
|
+
};
|
|
13
|
+
var ios = {
|
|
14
|
+
vs: '1.9.13'
|
|
15
|
+
};
|
|
16
|
+
var android = {
|
|
17
|
+
vs: '1.9.13'
|
|
18
|
+
};
|
|
19
|
+
var platform = {
|
|
20
|
+
pc: pc,
|
|
21
|
+
ios: ios,
|
|
22
|
+
android: android
|
|
23
|
+
};
|
|
24
|
+
var apiName = 'biz.util.focus';
|
|
25
|
+
function focus(params) {
|
|
26
|
+
(0, _initAPI["default"])(apiName, {
|
|
27
|
+
params: params,
|
|
28
|
+
platform: platform
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IError } from '../../common.typings';
|
|
2
|
+
export interface GetConfigResult {
|
|
3
|
+
code: number;
|
|
4
|
+
message: string;
|
|
5
|
+
data: any;
|
|
6
|
+
}
|
|
7
|
+
export interface GetConfigParams {
|
|
8
|
+
configNode: String;
|
|
9
|
+
onSuccess?: (res: GetConfigResult) => void;
|
|
10
|
+
onFail?: (err: IError) => void;
|
|
11
|
+
}
|
|
12
|
+
declare function getConfig(params: GetConfigParams): void;
|
|
13
|
+
export { getConfig };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getConfig = getConfig;
|
|
9
|
+
var _initAPI = _interopRequireDefault(require("../../initAPI"));
|
|
10
|
+
var ios = {
|
|
11
|
+
vs: '1.9.12'
|
|
12
|
+
};
|
|
13
|
+
var android = {
|
|
14
|
+
vs: '1.9.12'
|
|
15
|
+
};
|
|
16
|
+
var platform = {
|
|
17
|
+
ios: ios,
|
|
18
|
+
android: android
|
|
19
|
+
};
|
|
20
|
+
var apiName = 'biz.util.getConfig';
|
|
21
|
+
function getConfig(params) {
|
|
22
|
+
(0, _initAPI["default"])(apiName, {
|
|
23
|
+
params: params,
|
|
24
|
+
platform: platform
|
|
25
|
+
});
|
|
26
|
+
}
|