yach.open.jssdk 4.3.0-beta2 → 4.3.1-beta
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.1.32-bata.1.js +1 -0
- package/es/api/app/custom/talYoungFilesUpload.js +2 -0
- package/es/api/biz/chat/chooseConversationByCorpId.js +2 -0
- package/es/api/biz/chat/openSingleChat.js +2 -0
- package/es/api/biz/chat/openSquad.js +2 -0
- package/es/api/biz/chat/openTeamChat.js +2 -0
- package/es/api/biz/chat/pickConversation.js +2 -0
- package/es/api/biz/chat/sendP2PMsg.js +2 -0
- package/es/api/biz/contact/complexPicker.js +2 -0
- package/es/api/biz/contact/departmentsPicker.js +2 -0
- package/es/api/biz/group/groupComplexPicker.js +2 -0
- package/es/api/biz/map/multipointView.js +2 -0
- package/es/api/biz/map/view.js +2 -0
- package/es/api/biz/navigation/close.js +2 -0
- package/es/api/biz/navigation/goBack.js +2 -0
- package/es/api/biz/navigation/quit.js +2 -0
- package/es/api/biz/navigation/replace.js +2 -0
- package/es/api/biz/navigation/setIcon.js +2 -0
- package/es/api/biz/navigation/setLeft.js +2 -0
- package/es/api/biz/navigation/setMenu.js +2 -0
- package/es/api/biz/navigation/setRight.js +2 -0
- package/es/api/biz/navigation/setTitle.js +2 -0
- package/es/api/biz/navigation/setTitleExpandIcon.js +2 -0
- package/es/api/biz/navigation/setWindowBig.js +2 -0
- package/es/api/biz/navigation/tencentMeeting.js +2 -0
- package/es/api/biz/navigation/tencentMeetingBegin.js +2 -0
- package/es/api/biz/navigation/updateExpandTitle.js +2 -0
- package/es/api/biz/telephone/call.js +2 -0
- package/es/api/biz/telephone/showCallMenu.js +2 -0
- package/es/api/biz/util/authFinish.js +2 -0
- package/es/api/biz/util/authStart.js +2 -0
- package/es/api/biz/util/chosen.js +2 -0
- package/es/api/biz/util/clipboardFileUpload.js +2 -0
- package/es/api/biz/util/closeWindow.js +2 -0
- package/es/api/biz/util/complain.js +2 -0
- package/es/api/biz/util/createModifySchedule.js +2 -0
- package/es/api/biz/util/datepicker.js +2 -0
- package/es/api/biz/util/datetimepicker.js +2 -0
- package/es/api/biz/util/downloadFile.js +2 -0
- package/es/api/biz/util/entergroupCheck.js +3 -1
- package/es/api/biz/util/externalLinkPreviewFile.js +2 -0
- package/es/api/biz/util/feedback.js +2 -0
- package/es/api/biz/util/getSingleWebviewData.js +2 -0
- package/es/api/biz/util/getTogetherConfig.js +2 -0
- package/es/api/biz/util/getToken.js +2 -0
- package/es/api/biz/util/injectScript.js +2 -0
- package/es/api/biz/util/invoice.js +2 -0
- package/es/api/biz/util/mediaFileUpload.js +2 -0
- package/es/api/biz/util/onlineDocmentOpenTeamChat.js +2 -0
- package/es/api/biz/util/open.js +2 -0
- package/es/api/biz/util/openLink.js +2 -0
- package/es/api/biz/util/openMediaFileDialog.js +2 -0
- package/es/api/biz/util/openSingleWebview.js +2 -0
- package/es/api/biz/util/openSlidePanel.js +2 -0
- package/es/api/biz/util/openTalYoungToTopic.js +2 -0
- package/es/api/biz/util/openTogetherEyeWebview.js +2 -0
- package/es/api/biz/util/openUserSchedule.js +2 -0
- package/es/api/biz/util/openVideoPlayer.js +2 -0
- package/es/api/biz/util/previewFile.js +2 -0
- package/es/api/biz/util/previewImage.js +2 -0
- package/es/api/biz/util/proxy.js +2 -0
- package/es/api/biz/util/pushWorkMsg.js +2 -0
- package/es/api/biz/util/remind.js +2 -0
- package/es/api/biz/util/rouseApp.js +2 -0
- package/es/api/biz/util/savePic.js +2 -0
- package/es/api/biz/util/scan.js +2 -0
- package/es/api/biz/util/selectDepartment.js +2 -0
- package/es/api/biz/util/share.js +2 -0
- package/es/api/biz/util/takePicture.js +2 -0
- package/es/api/biz/util/uploadAttachment.js +2 -0
- package/es/api/biz/util/zfbAuth.js +2 -0
- package/es/api/biz/webViewMessage/send.js +2 -0
- package/es/api/device/audio/download.js +2 -0
- package/es/api/device/audio/onPlayEnd.js +2 -0
- package/es/api/device/audio/onRecordEnd.js +2 -0
- package/es/api/device/audio/onRecordEnd_v2.js +2 -0
- package/es/api/device/audio/pause.js +2 -0
- package/es/api/device/audio/play.js +2 -0
- package/es/api/device/audio/resume.js +2 -0
- package/es/api/device/audio/startRecord.js +2 -0
- package/es/api/device/audio/startRecord_v2.js +2 -0
- package/es/api/device/audio/stop.js +2 -0
- package/es/api/device/audio/stopRecord.js +2 -0
- package/es/api/device/audio/stopRecord_v2.js +2 -0
- package/es/api/device/base/checkStepPermission.js +2 -0
- package/es/api/device/base/getPhoneInfo.js +2 -0
- package/es/api/device/base/getUUID.js +3 -5
- package/es/api/device/connection/getNetworkType.js +2 -0
- package/es/api/device/connection/isAtTal.js +4 -2
- package/es/api/device/geolocation/get.js +2 -0
- package/es/api/device/geolocation/getSwitch.js +2 -0
- package/es/api/device/notification/actionSheet.js +2 -0
- package/es/api/device/notification/alert.js +2 -0
- package/es/api/device/notification/confirm.js +2 -0
- package/es/api/device/notification/hidePreloader.js +2 -0
- package/es/api/device/notification/showPreloader.js +2 -0
- package/es/api/device/notification/toast.js +2 -0
- package/es/api/device/notification/vibrate.js +2 -0
- package/es/api/device/system/getLang.js +2 -0
- package/es/api/device/system/setLight.js +2 -0
- package/es/api/initAPI.js +5 -3
- package/es/api/primary/createTab.js +2 -0
- package/es/api/primary/exitFullScreen.js +2 -0
- package/es/api/primary/fullScreen.js +2 -0
- package/es/api/primary/weeklyShare.js +2 -0
- package/es/api/runtime/permission/requestAuthCode.js +2 -0
- package/es/api/ui/pullToRefresh/disable.js +2 -0
- package/es/api/ui/pullToRefresh/enable.js +2 -0
- package/es/api/ui/pullToRefresh/stop.js +2 -0
- package/es/api/ui/webViewBounce/disable.js +2 -0
- package/es/api/util/domainStorage/getItem.js +2 -0
- package/es/api/util/domainStorage/removeItem.js +2 -0
- package/es/api/util/domainStorage/setItem.js +2 -0
- package/es/api/util/tool/flushLog.js +2 -0
- package/es/api/util/tool/log.js +2 -0
- package/es/index.d.ts +1 -7
- package/es/index.js +27 -22
- package/es/lib/bridge/mobile.js +19 -4
- package/es/lib/bridge/pc.js +11 -2
- package/es/lib/helper/apiHelper.js +2 -0
- package/es/lib/helper/codeMap.js +2 -0
- package/es/lib/helper/event.js +13 -0
- package/es/lib/helper/pcIframe.js +43 -12
- package/es/lib/index.js +21 -7
- package/es/lib/sdk/index.js +37 -18
- package/es/lib/sdk/sdk.typings.js +1 -0
- package/es/utils/bpitLog.js +13 -4
- package/es/utils/compareVersions.js +50 -23
- package/es/utils/console.js +15 -0
- package/es/utils/env.js +18 -11
- package/es/utils/index.js +5 -0
- package/libs/api/app/custom/talYoungFilesUpload.js +6 -1
- package/libs/api/biz/chat/chooseConversationByCorpId.js +6 -0
- package/libs/api/biz/chat/openSingleChat.js +6 -0
- package/libs/api/biz/chat/openSquad.js +6 -0
- package/libs/api/biz/chat/openTeamChat.js +6 -0
- package/libs/api/biz/chat/pickConversation.js +6 -0
- package/libs/api/biz/chat/sendP2PMsg.js +6 -0
- package/libs/api/biz/contact/complexPicker.js +6 -0
- package/libs/api/biz/contact/departmentsPicker.js +6 -0
- package/libs/api/biz/group/groupComplexPicker.js +6 -0
- package/libs/api/biz/map/multipointView.js +6 -0
- package/libs/api/biz/map/view.js +6 -0
- package/libs/api/biz/navigation/close.js +6 -0
- package/libs/api/biz/navigation/goBack.js +6 -0
- package/libs/api/biz/navigation/quit.js +6 -0
- package/libs/api/biz/navigation/replace.js +6 -0
- package/libs/api/biz/navigation/setIcon.js +7 -0
- package/libs/api/biz/navigation/setLeft.js +7 -0
- package/libs/api/biz/navigation/setMenu.js +7 -0
- package/libs/api/biz/navigation/setRight.js +7 -0
- package/libs/api/biz/navigation/setTitle.js +6 -0
- package/libs/api/biz/navigation/setTitleExpandIcon.js +7 -0
- package/libs/api/biz/navigation/setWindowBig.js +6 -1
- package/libs/api/biz/navigation/tencentMeeting.js +6 -0
- package/libs/api/biz/navigation/tencentMeetingBegin.js +6 -0
- package/libs/api/biz/navigation/updateExpandTitle.js +6 -0
- package/libs/api/biz/telephone/call.js +6 -0
- package/libs/api/biz/telephone/showCallMenu.js +6 -0
- package/libs/api/biz/util/authFinish.js +6 -0
- package/libs/api/biz/util/authStart.js +6 -0
- package/libs/api/biz/util/chosen.js +6 -0
- package/libs/api/biz/util/clipboardFileUpload.js +6 -0
- package/libs/api/biz/util/closeWindow.js +6 -0
- package/libs/api/biz/util/complain.js +6 -0
- package/libs/api/biz/util/createModifySchedule.js +6 -0
- package/libs/api/biz/util/datepicker.js +6 -0
- package/libs/api/biz/util/datetimepicker.js +6 -0
- package/libs/api/biz/util/downloadFile.js +6 -0
- package/libs/api/biz/util/entergroupCheck.js +7 -1
- package/libs/api/biz/util/externalLinkPreviewFile.js +6 -0
- package/libs/api/biz/util/feedback.js +6 -0
- package/libs/api/biz/util/getSingleWebviewData.js +6 -0
- package/libs/api/biz/util/getTogetherConfig.js +6 -0
- package/libs/api/biz/util/getToken.js +6 -0
- package/libs/api/biz/util/injectScript.js +6 -0
- package/libs/api/biz/util/invoice.js +6 -1
- package/libs/api/biz/util/mediaFileUpload.js +6 -1
- package/libs/api/biz/util/onlineDocmentOpenTeamChat.js +6 -0
- package/libs/api/biz/util/open.js +6 -0
- package/libs/api/biz/util/openLink.js +6 -0
- package/libs/api/biz/util/openMediaFileDialog.js +6 -1
- package/libs/api/biz/util/openSingleWebview.js +6 -0
- package/libs/api/biz/util/openSlidePanel.js +6 -0
- package/libs/api/biz/util/openTalYoungToTopic.js +6 -1
- package/libs/api/biz/util/openTogetherEyeWebview.js +6 -0
- package/libs/api/biz/util/openUserSchedule.js +6 -0
- package/libs/api/biz/util/openVideoPlayer.js +6 -0
- package/libs/api/biz/util/previewFile.js +6 -0
- package/libs/api/biz/util/previewImage.js +6 -0
- package/libs/api/biz/util/proxy.js +6 -0
- package/libs/api/biz/util/pushWorkMsg.js +6 -1
- package/libs/api/biz/util/remind.js +6 -0
- package/libs/api/biz/util/rouseApp.js +6 -1
- package/libs/api/biz/util/savePic.js +6 -0
- package/libs/api/biz/util/scan.js +6 -0
- package/libs/api/biz/util/selectDepartment.js +6 -0
- package/libs/api/biz/util/share.js +6 -0
- package/libs/api/biz/util/takePicture.js +6 -0
- package/libs/api/biz/util/uploadAttachment.js +6 -0
- package/libs/api/biz/util/zfbAuth.js +6 -0
- package/libs/api/biz/webViewMessage/send.js +6 -0
- package/libs/api/device/audio/download.js +6 -0
- package/libs/api/device/audio/onPlayEnd.js +6 -0
- package/libs/api/device/audio/onRecordEnd.js +6 -0
- package/libs/api/device/audio/onRecordEnd_v2.js +6 -0
- package/libs/api/device/audio/pause.js +6 -0
- package/libs/api/device/audio/play.js +6 -0
- package/libs/api/device/audio/resume.js +6 -0
- package/libs/api/device/audio/startRecord.js +6 -0
- package/libs/api/device/audio/startRecord_v2.js +6 -0
- package/libs/api/device/audio/stop.js +6 -0
- package/libs/api/device/audio/stopRecord.js +6 -0
- package/libs/api/device/audio/stopRecord_v2.js +6 -0
- package/libs/api/device/base/checkStepPermission.js +6 -0
- package/libs/api/device/base/getPhoneInfo.js +6 -0
- package/libs/api/device/base/getUUID.js +7 -5
- package/libs/api/device/connection/getNetworkType.js +6 -0
- package/libs/api/device/connection/isAtTal.js +8 -2
- package/libs/api/device/geolocation/get.js +6 -0
- package/libs/api/device/geolocation/getSwitch.js +6 -0
- package/libs/api/device/notification/actionSheet.js +6 -0
- package/libs/api/device/notification/alert.js +6 -0
- package/libs/api/device/notification/confirm.js +6 -0
- package/libs/api/device/notification/hidePreloader.js +6 -0
- package/libs/api/device/notification/showPreloader.js +6 -0
- package/libs/api/device/notification/toast.js +6 -0
- package/libs/api/device/notification/vibrate.js +6 -0
- package/libs/api/device/system/getLang.js +6 -0
- package/libs/api/device/system/setLight.js +6 -0
- package/libs/api/initAPI.js +13 -4
- package/libs/api/primary/createTab.js +6 -0
- package/libs/api/primary/exitFullScreen.js +6 -0
- package/libs/api/primary/fullScreen.js +6 -0
- package/libs/api/primary/weeklyShare.js +6 -0
- package/libs/api/runtime/permission/requestAuthCode.js +6 -0
- package/libs/api/ui/pullToRefresh/disable.js +6 -0
- package/libs/api/ui/pullToRefresh/enable.js +6 -0
- package/libs/api/ui/pullToRefresh/stop.js +6 -0
- package/libs/api/ui/webViewBounce/disable.js +6 -0
- package/libs/api/util/domainStorage/getItem.js +6 -0
- package/libs/api/util/domainStorage/removeItem.js +6 -0
- package/libs/api/util/domainStorage/setItem.js +6 -0
- package/libs/api/util/tool/flushLog.js +6 -0
- package/libs/api/util/tool/log.js +6 -0
- package/libs/index.d.ts +1 -7
- package/libs/index.js +271 -37
- package/libs/lib/bridge/index.js +7 -0
- package/libs/lib/bridge/mobile.js +39 -7
- package/libs/lib/bridge/pc.js +25 -5
- package/libs/lib/helper/apiHelper.js +6 -0
- package/libs/lib/helper/codeMap.js +6 -0
- package/libs/lib/helper/event.js +22 -1
- package/libs/lib/helper/pcIframe.js +49 -11
- package/libs/lib/index.js +32 -8
- package/libs/lib/sdk/index.js +47 -19
- package/libs/lib/sdk/sdk.typings.js +4 -0
- package/libs/utils/bpitLog.js +16 -4
- package/libs/utils/compareVersions.js +72 -27
- package/libs/utils/console.js +16 -0
- package/libs/utils/env.js +20 -11
- package/libs/utils/index.js +13 -0
- package/package.json +1 -1
- package/dist/yach_jssdk_4.3.0-beta2.js +0 -1
- package/es/api/biz/util/assistantCreate.d.ts +0 -11
- package/es/api/biz/util/assistantCreate.js +0 -23
- package/es/api/biz/util/disableScreenCapture.d.ts +0 -8
- package/es/api/biz/util/disableScreenCapture.js +0 -19
- package/es/api/biz/util/yachEvent.d.ts +0 -12
- package/es/api/biz/util/yachEvent.js +0 -27
- package/libs/api/biz/util/assistantCreate.d.ts +0 -11
- package/libs/api/biz/util/assistantCreate.js +0 -30
- package/libs/api/biz/util/disableScreenCapture.d.ts +0 -8
- package/libs/api/biz/util/disableScreenCapture.js +0 -26
- package/libs/api/biz/util/yachEvent.d.ts +0 -12
- package/libs/api/biz/util/yachEvent.js +0 -34
package/es/lib/helper/codeMap.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _Map from "@babel/runtime-corejs3/core-js/map";
|
|
2
2
|
var resCodeMap = new _Map([[0, 'onSuccess'], [-1, 'onCancel'], [-2, 'onFail'], [-3, 'onProgress'], [-4, 'onSubmit']]);
|
|
3
|
+
|
|
3
4
|
function electronResCodeMap(code) {
|
|
4
5
|
return resCodeMap.get(code) || 'onFail';
|
|
5
6
|
}
|
|
7
|
+
|
|
6
8
|
export { electronResCodeMap };
|
package/es/lib/helper/event.js
CHANGED
|
@@ -4,28 +4,39 @@ import _Array$isArray from "@babel/runtime-corejs3/core-js/array/is-array";
|
|
|
4
4
|
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js/instance/index-of";
|
|
5
5
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
6
6
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
|
|
7
|
+
|
|
7
8
|
var Event = /*#__PURE__*/_createClass(function Event() {
|
|
8
9
|
var _this = this;
|
|
10
|
+
|
|
9
11
|
_classCallCheck(this, Event);
|
|
12
|
+
|
|
10
13
|
this.on = function (event, fn) {
|
|
11
14
|
if (!event || 'function' !== typeof fn) throw 'eventName is null or handle is not a function, on fail';
|
|
12
15
|
if (!_Array$isArray(_this.eventsHandle[event])) _this.eventsHandle[event] = [];
|
|
16
|
+
|
|
13
17
|
_this.eventsHandle[event].push(fn);
|
|
14
18
|
};
|
|
19
|
+
|
|
15
20
|
this.off = function (event, fn) {
|
|
16
21
|
if (!event) throw 'eventName is null, invoke off fail';
|
|
22
|
+
|
|
17
23
|
if (!fn) {
|
|
18
24
|
_this.eventsHandle[event] = [];
|
|
19
25
|
return;
|
|
20
26
|
}
|
|
27
|
+
|
|
21
28
|
if (_Array$isArray(_this.eventsHandle[event])) {
|
|
22
29
|
var _context, _context2;
|
|
30
|
+
|
|
23
31
|
var n = _indexOfInstanceProperty(_context = _this.eventsHandle[event]).call(_context, fn);
|
|
32
|
+
|
|
24
33
|
-1 !== n && _spliceInstanceProperty(_context2 = _this.eventsHandle[event]).call(_context2, n, 1);
|
|
25
34
|
}
|
|
26
35
|
};
|
|
36
|
+
|
|
27
37
|
this.execEvent = function (event, data) {
|
|
28
38
|
var _context3;
|
|
39
|
+
|
|
29
40
|
_Array$isArray(this.eventsHandle[event]) && _forEachInstanceProperty(_context3 = this.eventsHandle[event]).call(_context3, function (fn) {
|
|
30
41
|
try {
|
|
31
42
|
fn(data);
|
|
@@ -34,7 +45,9 @@ var Event = /*#__PURE__*/_createClass(function Event() {
|
|
|
34
45
|
}
|
|
35
46
|
});
|
|
36
47
|
};
|
|
48
|
+
|
|
37
49
|
this.eventsHandle = {};
|
|
38
50
|
});
|
|
51
|
+
|
|
39
52
|
var event = new Event();
|
|
40
53
|
export default event;
|
|
@@ -3,20 +3,25 @@ import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
|
3
3
|
import _Date$now from "@babel/runtime-corejs3/core-js/date/now";
|
|
4
4
|
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
5
5
|
import { log } from '../../utils';
|
|
6
|
-
import Event from './event';
|
|
7
|
-
|
|
6
|
+
import Event from './event'; // 处理posmessage参数
|
|
7
|
+
|
|
8
8
|
var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, callback) {
|
|
9
9
|
var _this = this;
|
|
10
|
+
|
|
10
11
|
_classCallCheck(this, GenPostMsg);
|
|
12
|
+
|
|
11
13
|
this.genid = function () {
|
|
12
14
|
var idStr = _Date$now().toString(36);
|
|
15
|
+
|
|
13
16
|
idStr += Math.random().toString(36).substr(3);
|
|
14
17
|
return idStr;
|
|
15
18
|
};
|
|
19
|
+
|
|
16
20
|
this.receiveResponse = function (data) {
|
|
17
21
|
//this.PromiseObj.resolve(data);
|
|
18
22
|
_this.callback(data);
|
|
19
23
|
};
|
|
24
|
+
|
|
20
25
|
this.getPayload = function () {
|
|
21
26
|
return {
|
|
22
27
|
msgId: _this.id,
|
|
@@ -26,6 +31,7 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
|
|
|
26
31
|
invokeType: _this.invokeType
|
|
27
32
|
};
|
|
28
33
|
};
|
|
34
|
+
|
|
29
35
|
this.id = this.genid();
|
|
30
36
|
this.PromiseObj = {
|
|
31
37
|
resolve: null,
|
|
@@ -34,8 +40,7 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
|
|
|
34
40
|
this.methodName = method;
|
|
35
41
|
this.plainMsg = param;
|
|
36
42
|
this.invokeType = param === null || param === void 0 ? void 0 : param.invokeType;
|
|
37
|
-
this.callback = callback;
|
|
38
|
-
// this.result = new Promise(
|
|
43
|
+
this.callback = callback; // this.result = new Promise(
|
|
39
44
|
// function (resolve, reject) {
|
|
40
45
|
// this.PromiseObj = {
|
|
41
46
|
// resolve,
|
|
@@ -44,59 +49,78 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
|
|
|
44
49
|
// }.bind(this)
|
|
45
50
|
// );
|
|
46
51
|
});
|
|
52
|
+
|
|
47
53
|
var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
48
54
|
var _this2 = this;
|
|
55
|
+
|
|
49
56
|
_classCallCheck(this, Frame);
|
|
57
|
+
|
|
50
58
|
this.addPending = function (e) {
|
|
51
59
|
_this2.pendingMsgs[e.id] = e;
|
|
52
60
|
};
|
|
61
|
+
|
|
53
62
|
this.deletePending = function (e) {
|
|
54
63
|
delete _this2.pendingMsgs[e.id];
|
|
55
64
|
};
|
|
65
|
+
|
|
56
66
|
this.getPending = function (t) {
|
|
57
67
|
return this.pendingMsgs[t];
|
|
58
68
|
};
|
|
69
|
+
|
|
59
70
|
this.invokeAPIInBrowserView = function (payload) {
|
|
60
71
|
window.sendTo(payload);
|
|
61
72
|
};
|
|
73
|
+
|
|
62
74
|
this.invokeAPIInWebview = function (payload) {
|
|
63
75
|
window.sendToHost(payload);
|
|
64
76
|
};
|
|
77
|
+
|
|
65
78
|
this.invokeAPI = function (method, param, callback) {
|
|
66
79
|
var genPostMsg = new GenPostMsg(method, param, callback);
|
|
80
|
+
|
|
67
81
|
var payload = _JSON$stringify(genPostMsg.getPayload());
|
|
82
|
+
|
|
68
83
|
var _param$invokeType = param.invokeType,
|
|
69
|
-
|
|
84
|
+
invokeType = _param$invokeType === void 0 ? '' : _param$invokeType;
|
|
70
85
|
invokeType === 'browserView' ? _this2.invokeAPIInBrowserView(payload) : _this2.invokeAPIInWebview(payload);
|
|
86
|
+
|
|
71
87
|
_this2.addPending(genPostMsg);
|
|
88
|
+
|
|
72
89
|
return genPostMsg;
|
|
73
90
|
};
|
|
91
|
+
|
|
74
92
|
this.handleCallback = function (datas, invokeType) {
|
|
75
93
|
var type = datas.type,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
94
|
+
methodName = datas.methodName,
|
|
95
|
+
eventName = datas.eventName,
|
|
96
|
+
msgId = datas.msgId,
|
|
97
|
+
data = datas.data,
|
|
98
|
+
code = datas.code,
|
|
99
|
+
message = datas.message;
|
|
100
|
+
|
|
82
101
|
if (type === 'request') {
|
|
83
102
|
// 壳子的调用
|
|
84
103
|
switch (methodName) {
|
|
85
104
|
case 'refresh':
|
|
86
105
|
window.location.reload();
|
|
87
106
|
break;
|
|
107
|
+
|
|
88
108
|
case 'back':
|
|
89
109
|
window.history.back();
|
|
90
110
|
break;
|
|
111
|
+
|
|
91
112
|
case 'forward':
|
|
92
113
|
window.history.forward();
|
|
93
114
|
break;
|
|
115
|
+
|
|
94
116
|
case 'event':
|
|
95
117
|
Event.execEvent(eventName, data);
|
|
96
118
|
break;
|
|
119
|
+
|
|
97
120
|
case 'zoomInClick':
|
|
98
121
|
var scrollTopVal = document.documentElement.scrollTop || document.body.scrollTop,
|
|
99
|
-
|
|
122
|
+
url = window.location.href;
|
|
123
|
+
|
|
100
124
|
if (invokeType === 'browserView') {
|
|
101
125
|
window.sendTo(_JSON$stringify({
|
|
102
126
|
type: type,
|
|
@@ -118,13 +142,16 @@ var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
|
118
142
|
}
|
|
119
143
|
}));
|
|
120
144
|
}
|
|
145
|
+
|
|
121
146
|
break;
|
|
147
|
+
|
|
122
148
|
default:
|
|
123
149
|
break;
|
|
124
150
|
}
|
|
125
151
|
} else if (type === 'response') {
|
|
126
152
|
// 响应壳子的回调
|
|
127
153
|
var pending = _this2.getPending(msgId);
|
|
154
|
+
|
|
128
155
|
pending && pending.receiveResponse({
|
|
129
156
|
data: data,
|
|
130
157
|
code: code,
|
|
@@ -133,16 +160,20 @@ var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
|
133
160
|
code != -3 && _this2.deletePending(msgId);
|
|
134
161
|
}
|
|
135
162
|
};
|
|
163
|
+
|
|
136
164
|
this.init = function () {
|
|
137
165
|
window.addEventListener('message', function (msg) {
|
|
138
166
|
log('electron res: ', msg);
|
|
167
|
+
|
|
139
168
|
_this2.handleCallback(msg.data || {});
|
|
140
169
|
});
|
|
141
170
|
window.receiveBrowserViewData && window.receiveBrowserViewData(function (e, response) {
|
|
142
171
|
return _this2.handleCallback(response);
|
|
143
172
|
});
|
|
144
173
|
};
|
|
174
|
+
|
|
145
175
|
this.pendingMsgs = {};
|
|
146
176
|
});
|
|
177
|
+
|
|
147
178
|
var frame = new Frame();
|
|
148
179
|
export default frame;
|
package/es/lib/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
2
2
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
3
|
+
|
|
3
4
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
5
|
function adopt(value) {
|
|
5
6
|
return value instanceof P ? value : new P(function (resolve) {
|
|
6
7
|
resolve(value);
|
|
7
8
|
});
|
|
8
9
|
}
|
|
10
|
+
|
|
9
11
|
return new (P || (P = _Promise))(function (resolve, reject) {
|
|
10
12
|
function fulfilled(value) {
|
|
11
13
|
try {
|
|
@@ -14,6 +16,7 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
14
16
|
reject(e);
|
|
15
17
|
}
|
|
16
18
|
}
|
|
19
|
+
|
|
17
20
|
function rejected(value) {
|
|
18
21
|
try {
|
|
19
22
|
step(generator["throw"](value));
|
|
@@ -21,12 +24,15 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
21
24
|
reject(e);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
27
|
+
|
|
24
28
|
function step(result) {
|
|
25
29
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
30
|
}
|
|
31
|
+
|
|
27
32
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
33
|
});
|
|
29
34
|
};
|
|
35
|
+
|
|
30
36
|
import { getENV } from '../utils';
|
|
31
37
|
import Sdk from './sdk';
|
|
32
38
|
import { mobileBridge, mobileBridgeInit, PcBridgeInit, pcBridge } from './bridge';
|
|
@@ -34,20 +40,26 @@ import Event from './helper/event';
|
|
|
34
40
|
var env = getENV();
|
|
35
41
|
var platform = env.platform;
|
|
36
42
|
var yachSdk = new Sdk(env);
|
|
43
|
+
|
|
37
44
|
function initSdk() {
|
|
38
45
|
var _this = this;
|
|
46
|
+
|
|
39
47
|
var bridgeInit;
|
|
48
|
+
|
|
40
49
|
if (platform === 'pc') {
|
|
41
50
|
bridgeInit = function bridgeInit() {
|
|
42
51
|
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
43
52
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
44
|
-
while (1)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
while (1) {
|
|
54
|
+
switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
PcBridgeInit();
|
|
57
|
+
return _context.abrupt("return", pcBridge);
|
|
58
|
+
|
|
59
|
+
case 2:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
51
63
|
}
|
|
52
64
|
}, _callee);
|
|
53
65
|
}));
|
|
@@ -59,6 +71,7 @@ function initSdk() {
|
|
|
59
71
|
});
|
|
60
72
|
};
|
|
61
73
|
}
|
|
74
|
+
|
|
62
75
|
var config = {
|
|
63
76
|
platform: platform,
|
|
64
77
|
authMethod: 'config',
|
|
@@ -74,5 +87,6 @@ function initSdk() {
|
|
|
74
87
|
};
|
|
75
88
|
yachSdk.setPlatform(config);
|
|
76
89
|
}
|
|
90
|
+
|
|
77
91
|
initSdk();
|
|
78
92
|
export { yachSdk, initSdk };
|
package/es/lib/sdk/index.js
CHANGED
|
@@ -5,10 +5,13 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
|
|
|
5
5
|
import { bpitLog } from '../../utils';
|
|
6
6
|
import { compareVersions } from '../../utils/compareVersions';
|
|
7
7
|
import packageInfo from '../../../package.json';
|
|
8
|
+
|
|
8
9
|
var Sdk = /*#__PURE__*/function () {
|
|
9
10
|
function Sdk(env) {
|
|
10
11
|
var _this = this;
|
|
12
|
+
|
|
11
13
|
_classCallCheck(this, Sdk);
|
|
14
|
+
|
|
12
15
|
this.invokeAPIConfigMapByMethod = {};
|
|
13
16
|
this.configJsApiList = [];
|
|
14
17
|
this.platformConfigMap = {};
|
|
@@ -29,9 +32,11 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
29
32
|
platformV2: env.platformV2,
|
|
30
33
|
config: function config() {
|
|
31
34
|
var _config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
35
|
+
|
|
32
36
|
// 鉴权
|
|
33
37
|
var _config$jsApiList = _config.jsApiList,
|
|
34
|
-
|
|
38
|
+
jsApiList = _config$jsApiList === void 0 ? [] : _config$jsApiList;
|
|
39
|
+
|
|
35
40
|
if (_this.hadConfig) {
|
|
36
41
|
console.log('Config has been executed');
|
|
37
42
|
} else {
|
|
@@ -39,6 +44,7 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
39
44
|
fn('config', _config).then(function (value) {
|
|
40
45
|
// 鉴权成功
|
|
41
46
|
_this.cacheP.resolve(value);
|
|
47
|
+
|
|
42
48
|
_this.hadConfig = true;
|
|
43
49
|
_this.configJsApiList = jsApiList;
|
|
44
50
|
})["catch"](function (error) {
|
|
@@ -70,19 +76,19 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
70
76
|
}
|
|
71
77
|
};
|
|
72
78
|
}
|
|
79
|
+
|
|
73
80
|
_createClass(Sdk, [{
|
|
74
81
|
key: "setAPI",
|
|
75
82
|
value: function setAPI(method, config) {
|
|
76
83
|
this.invokeAPIConfigMapByMethod[method] = config;
|
|
77
|
-
}
|
|
78
|
-
|
|
84
|
+
} // 确定端的同事初始化bridge
|
|
85
|
+
|
|
79
86
|
}, {
|
|
80
87
|
key: "setPlatform",
|
|
81
88
|
value: function setPlatform(value) {
|
|
82
89
|
var platform = value.platform,
|
|
83
|
-
|
|
84
|
-
this.platformConfigMap[platform] = value;
|
|
85
|
-
// if (this.env.platform === platform) bridgeInit();
|
|
90
|
+
bridgeInit = value.bridgeInit;
|
|
91
|
+
this.platformConfigMap[platform] = value; // if (this.env.platform === platform) bridgeInit();
|
|
86
92
|
}
|
|
87
93
|
}, {
|
|
88
94
|
key: "bridgeInitFn",
|
|
@@ -91,13 +97,16 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
91
97
|
if (this.bridgeInitFnPromise) {
|
|
92
98
|
return this.bridgeInitFnPromise;
|
|
93
99
|
}
|
|
100
|
+
|
|
94
101
|
var o = this.platformConfigMap[this.env.platform];
|
|
102
|
+
|
|
95
103
|
if (o) {
|
|
96
104
|
this.bridgeInitFnPromise = o.bridgeInit();
|
|
97
105
|
} else {
|
|
98
106
|
var n = 'Do not support the current environment�' + this.env.platform;
|
|
99
107
|
this.bridgeInitFnPromise = _Promise.reject(new Error(n));
|
|
100
108
|
}
|
|
109
|
+
|
|
101
110
|
return this.bridgeInitFnPromise;
|
|
102
111
|
}
|
|
103
112
|
}, {
|
|
@@ -117,44 +126,54 @@ var Sdk = /*#__PURE__*/function () {
|
|
|
117
126
|
key: "invokeAPI",
|
|
118
127
|
value: function invokeAPI(method, params) {
|
|
119
128
|
var _context2;
|
|
129
|
+
|
|
120
130
|
if (!params) params = {};
|
|
121
|
-
if (!method) return;
|
|
122
|
-
|
|
131
|
+
if (!method) return; // 验证方法是否可用
|
|
132
|
+
|
|
123
133
|
var apiConfigs = this.invokeAPIConfigMapByMethod[method];
|
|
134
|
+
|
|
124
135
|
if (!apiConfigs) {
|
|
125
136
|
return this._onFail(method, '-1', "[".concat(method, "] method is not exist"), params.onFail);
|
|
126
137
|
}
|
|
138
|
+
|
|
127
139
|
var apiConfig = apiConfigs[this.env.platform];
|
|
140
|
+
|
|
128
141
|
if (apiConfig) {
|
|
129
142
|
var supportVersion = apiConfig.vs || '0.0.0';
|
|
143
|
+
|
|
130
144
|
if (compareVersions(this.env.version, supportVersion) < 0) {
|
|
131
145
|
var _context;
|
|
146
|
+
|
|
132
147
|
return this._onFail(method, '-1', _concatInstanceProperty(_context = "The current application version is ".concat(this.env.version, ". This method does not support versions less than ")).call(_context, supportVersion), params.onFail);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// 确定回调
|
|
148
|
+
} // 确定参数
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
var p = apiConfig.paramsDeal ? apiConfig.paramsDeal(params) : params; // 确定回调
|
|
152
|
+
|
|
137
153
|
if ('function' == typeof p.onSuccess) {
|
|
138
154
|
var v = p.onSuccess;
|
|
155
|
+
|
|
139
156
|
p.onSuccess = function (e) {
|
|
140
157
|
v(e);
|
|
141
158
|
};
|
|
142
|
-
}
|
|
143
|
-
|
|
159
|
+
} // 主方法
|
|
160
|
+
|
|
161
|
+
|
|
144
162
|
this.bridgeInitFn().then(function (fn) {
|
|
145
|
-
fn(method, p).then(function () {
|
|
146
|
-
|
|
147
|
-
})["catch"](function (error) {
|
|
148
|
-
// 调用失败
|
|
163
|
+
fn(method, p).then(function () {// 调用成功
|
|
164
|
+
})["catch"](function (error) {// 调用失败
|
|
149
165
|
});
|
|
150
166
|
})["catch"](function (err) {
|
|
151
167
|
console.log('wenai err', err);
|
|
152
168
|
});
|
|
153
169
|
return;
|
|
154
170
|
}
|
|
171
|
+
|
|
155
172
|
this._onFail(method, '-1', _concatInstanceProperty(_context2 = "[".concat(method, "] method do not support the current platform (")).call(_context2, this.env.platform, ")"), params.onFail);
|
|
156
173
|
}
|
|
157
174
|
}]);
|
|
175
|
+
|
|
158
176
|
return Sdk;
|
|
159
177
|
}();
|
|
178
|
+
|
|
160
179
|
export default Sdk;
|
package/es/utils/bpitLog.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function loadScript(url) {
|
|
2
2
|
var script = document.createElement('script');
|
|
3
3
|
script.type = 'text/javascript';
|
|
4
|
+
|
|
4
5
|
if (script.readyState) {
|
|
5
6
|
// ie 浏览器
|
|
6
7
|
script.onreadystatechange = function () {
|
|
@@ -15,31 +16,38 @@ function loadScript(url) {
|
|
|
15
16
|
document.getElementsByTagName('head')[0].removeChild(script);
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
|
|
18
20
|
script.src = url;
|
|
19
21
|
document.getElementsByTagName('head')[0].appendChild(script);
|
|
20
22
|
}
|
|
23
|
+
|
|
21
24
|
export default function bpitLog(options) {
|
|
22
25
|
if (!options) {
|
|
23
26
|
console.log('bpit error: need options');
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
29
|
+
|
|
26
30
|
if (!options.group) {
|
|
27
31
|
console.log('bpit error: need options.group');
|
|
28
32
|
return;
|
|
29
33
|
}
|
|
34
|
+
|
|
30
35
|
if (!options.project) {
|
|
31
36
|
console.log('bpit error: need options.project');
|
|
32
37
|
return;
|
|
33
38
|
}
|
|
39
|
+
|
|
34
40
|
if (!options.hasOwnProperty('env')) {
|
|
35
41
|
console.log('bpit error: need options.env');
|
|
36
42
|
return;
|
|
37
43
|
}
|
|
44
|
+
|
|
38
45
|
if (!options.hasOwnProperty('version')) {
|
|
39
46
|
console.log('bpit error: need options.version');
|
|
40
47
|
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
48
|
+
} // upload data
|
|
49
|
+
|
|
50
|
+
|
|
43
51
|
var uploadData = ['https://es.zhiyinlou.com/log.js?'];
|
|
44
52
|
uploadData.push('group=' + options.group);
|
|
45
53
|
uploadData.push('&project=' + options.project);
|
|
@@ -50,12 +58,13 @@ export default function bpitLog(options) {
|
|
|
50
58
|
if (options.workcode) uploadData.push('&workcode=' + options.workcode);
|
|
51
59
|
if (options.timestamp) uploadData.push('×tamp=' + options.timestamp);
|
|
52
60
|
if (options.errorcode) uploadData.push('&errorcode=' + options.errorcode);
|
|
53
|
-
if (options.message) uploadData.push('&message=' + options.message);
|
|
54
|
-
|
|
61
|
+
if (options.message) uploadData.push('&message=' + options.message); // api load time
|
|
62
|
+
|
|
55
63
|
if (options.api && options.time) {
|
|
56
64
|
uploadData.push('&api=' + options.api);
|
|
57
65
|
uploadData.push('&load_time=' + options.time);
|
|
58
66
|
}
|
|
67
|
+
|
|
59
68
|
var uploadDataUrl = uploadData.join('');
|
|
60
69
|
loadScript(uploadDataUrl);
|
|
61
70
|
if (options.env != 'online') console.log(uploadDataUrl);
|