yach.open.jssdk 4.4.3 → 4.4.4-beta1
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.4-beta1.js +1 -0
- package/es/api/app/custom/talYoungFilesUpload.js +0 -2
- package/es/api/biz/chat/chooseConversationByCorpId.js +0 -2
- package/es/api/biz/chat/openSingleChat.js +0 -2
- package/es/api/biz/chat/openSquad.js +0 -2
- package/es/api/biz/chat/openTeamChat.js +0 -2
- package/es/api/biz/chat/pickConversation.js +0 -2
- package/es/api/biz/chat/sendP2PMsg.js +0 -2
- package/es/api/biz/contact/complexPicker.js +0 -2
- package/es/api/biz/contact/departmentsPicker.js +0 -2
- package/es/api/biz/group/groupComplexPicker.js +0 -2
- package/es/api/biz/map/multipointView.js +0 -2
- package/es/api/biz/map/view.js +0 -2
- package/es/api/biz/navigation/close.js +0 -2
- package/es/api/biz/navigation/goBack.js +0 -2
- package/es/api/biz/navigation/quit.js +0 -2
- package/es/api/biz/navigation/replace.js +0 -2
- package/es/api/biz/navigation/setIcon.js +0 -2
- package/es/api/biz/navigation/setLeft.js +0 -2
- package/es/api/biz/navigation/setMenu.js +0 -2
- package/es/api/biz/navigation/setPanGestureEnable.js +0 -2
- package/es/api/biz/navigation/setRight.js +0 -2
- package/es/api/biz/navigation/setTitle.js +0 -2
- package/es/api/biz/navigation/setTitleExpandIcon.js +0 -2
- package/es/api/biz/navigation/setWindowBig.js +0 -2
- package/es/api/biz/navigation/tencentMeeting.js +0 -2
- package/es/api/biz/navigation/tencentMeetingBegin.js +0 -2
- package/es/api/biz/navigation/updateExpandTitle.js +0 -2
- package/es/api/biz/telephone/call.js +0 -2
- package/es/api/biz/telephone/showCallMenu.js +0 -2
- package/es/api/biz/util/addAppToNav.js +0 -2
- package/es/api/biz/util/assistantCreate.js +0 -2
- package/es/api/biz/util/authFinish.js +0 -2
- package/es/api/biz/util/authStart.js +0 -2
- package/es/api/biz/util/chosen.js +0 -2
- package/es/api/biz/util/clipboardFileUpload.js +0 -2
- package/es/api/biz/util/closeWindow.js +0 -2
- package/es/api/biz/util/complain.js +0 -2
- package/es/api/biz/util/createModifySchedule.js +0 -2
- package/es/api/biz/util/datepicker.js +0 -2
- package/es/api/biz/util/datetimepicker.js +0 -2
- package/es/api/biz/util/disableScreenCapture.js +0 -2
- package/es/api/biz/util/downloadFile.js +0 -2
- package/es/api/biz/util/entergroupCheck.js +0 -2
- package/es/api/biz/util/externalLinkPreviewFile.js +0 -2
- package/es/api/biz/util/feedback.js +0 -2
- package/es/api/biz/util/getSingleWebviewData.js +0 -2
- package/es/api/biz/util/getTogetherConfig.js +0 -2
- package/es/api/biz/util/getToken.js +0 -2
- package/es/api/biz/util/injectScript.js +0 -2
- package/es/api/biz/util/invoice.js +0 -2
- package/es/api/biz/util/knowledgeBaseSelect.js +0 -2
- package/es/api/biz/util/mediaFileUpload.js +0 -2
- package/es/api/biz/util/onlineDocmentOpenTeamChat.js +0 -2
- package/es/api/biz/util/open.js +0 -2
- package/es/api/biz/util/openFutureGroup.js +0 -2
- package/es/api/biz/util/openLink.js +0 -2
- package/es/api/biz/util/openMediaFileDialog.js +0 -2
- package/es/api/biz/util/openSingleWebview.js +0 -2
- package/es/api/biz/util/openSlidePanel.js +0 -2
- package/es/api/biz/util/openTalYoungToTopic.js +0 -2
- package/es/api/biz/util/openTogetherEyeWebview.js +0 -2
- package/es/api/biz/util/openUserSchedule.js +0 -2
- package/es/api/biz/util/openVideoPlayer.js +0 -2
- package/es/api/biz/util/previewFile.js +0 -2
- package/es/api/biz/util/previewImage.js +0 -2
- package/es/api/biz/util/proxy.js +0 -2
- package/es/api/biz/util/pushWorkMsg.js +0 -2
- package/es/api/biz/util/remind.js +0 -2
- package/es/api/biz/util/resetSessionUnread.js +0 -2
- package/es/api/biz/util/rouseApp.js +0 -2
- package/es/api/biz/util/savePic.js +0 -2
- package/es/api/biz/util/scan.js +0 -2
- package/es/api/biz/util/screen.js +0 -2
- package/es/api/biz/util/selectDepartment.js +0 -2
- package/es/api/biz/util/share.js +0 -2
- package/es/api/biz/util/takePicture.js +0 -2
- package/es/api/biz/util/topicEvent.js +0 -2
- package/es/api/biz/util/uploadAttachment.js +0 -2
- package/es/api/biz/util/weeklyRead.js +0 -2
- package/es/api/biz/util/yachEvent.js +0 -2
- package/es/api/biz/util/zfbAuth.js +0 -2
- package/es/api/biz/webViewMessage/send.js +0 -2
- package/es/api/device/audio/download.js +0 -2
- package/es/api/device/audio/onPlayEnd.js +0 -2
- package/es/api/device/audio/onRecordEnd.js +0 -2
- package/es/api/device/audio/onRecordEnd_v2.js +0 -2
- package/es/api/device/audio/pause.js +0 -2
- package/es/api/device/audio/play.js +0 -2
- package/es/api/device/audio/resume.js +0 -2
- package/es/api/device/audio/startRecord.js +0 -2
- package/es/api/device/audio/startRecord_v2.js +0 -2
- package/es/api/device/audio/stop.js +0 -2
- package/es/api/device/audio/stopRecord.js +0 -2
- package/es/api/device/audio/stopRecord_v2.js +0 -2
- package/es/api/device/base/checkStepPermission.js +0 -2
- package/es/api/device/base/getPhoneInfo.js +0 -2
- package/es/api/device/base/getUUID.js +0 -2
- package/es/api/device/connection/getNetworkType.js +0 -2
- package/es/api/device/connection/isAtTal.js +2 -4
- package/es/api/device/geolocation/get.js +0 -2
- package/es/api/device/geolocation/getSwitch.js +0 -2
- package/es/api/device/notification/actionSheet.js +0 -2
- package/es/api/device/notification/alert.js +0 -2
- package/es/api/device/notification/confirm.js +0 -2
- package/es/api/device/notification/hidePreloader.js +0 -4
- package/es/api/device/notification/showPreloader.js +0 -4
- package/es/api/device/notification/toast.js +0 -2
- package/es/api/device/notification/vibrate.js +0 -2
- package/es/api/device/system/getLang.js +0 -2
- package/es/api/device/system/setLight.js +0 -2
- package/es/api/initAPI.js +3 -5
- package/es/api/primary/createTab.js +0 -2
- package/es/api/primary/exitFullScreen.js +0 -2
- package/es/api/primary/fullScreen.js +0 -2
- package/es/api/primary/weeklyShare.js +0 -2
- package/es/api/runtime/permission/requestAuthCode.js +0 -2
- package/es/api/ui/pullToRefresh/disable.js +0 -2
- package/es/api/ui/pullToRefresh/enable.js +0 -2
- package/es/api/ui/pullToRefresh/stop.js +0 -2
- package/es/api/ui/webViewBounce/disable.js +0 -2
- package/es/api/util/domainStorage/getItem.js +0 -2
- package/es/api/util/domainStorage/removeItem.js +0 -2
- package/es/api/util/domainStorage/setItem.js +0 -2
- package/es/api/util/tool/flushLog.js +0 -2
- package/es/api/util/tool/log.js +0 -2
- package/es/index.js +16 -27
- package/es/lib/bridge/mobile.js +12 -28
- package/es/lib/bridge/pc.js +11 -19
- package/es/lib/helper/apiHelper.js +0 -2
- package/es/lib/helper/codeMap.js +0 -2
- package/es/lib/helper/event.js +7 -19
- package/es/lib/helper/pcIframe.js +21 -51
- package/es/lib/index.js +7 -21
- package/es/lib/sdk/index.js +17 -39
- package/es/lib/sdk/sdk.typings.d.ts +1 -0
- package/es/lib/sdk/sdk.typings.js +0 -1
- package/es/utils/bpitLog.js +4 -13
- package/es/utils/compareVersions.js +26 -53
- package/es/utils/console.js +1 -17
- package/es/utils/env.js +15 -20
- package/es/utils/index.js +1 -6
- package/libs/api/app/custom/talYoungFilesUpload.js +2 -7
- package/libs/api/biz/chat/chooseConversationByCorpId.js +1 -7
- package/libs/api/biz/chat/openSingleChat.js +1 -7
- package/libs/api/biz/chat/openSquad.js +1 -7
- package/libs/api/biz/chat/openTeamChat.js +1 -7
- package/libs/api/biz/chat/pickConversation.js +1 -7
- package/libs/api/biz/chat/sendP2PMsg.js +1 -7
- package/libs/api/biz/contact/complexPicker.js +1 -7
- package/libs/api/biz/contact/departmentsPicker.js +1 -7
- package/libs/api/biz/group/groupComplexPicker.js +1 -7
- package/libs/api/biz/map/multipointView.js +1 -7
- package/libs/api/biz/map/view.js +1 -7
- package/libs/api/biz/navigation/close.js +1 -7
- package/libs/api/biz/navigation/goBack.js +1 -7
- package/libs/api/biz/navigation/quit.js +1 -7
- package/libs/api/biz/navigation/replace.js +1 -7
- package/libs/api/biz/navigation/setIcon.js +1 -8
- package/libs/api/biz/navigation/setLeft.js +1 -8
- package/libs/api/biz/navigation/setMenu.js +1 -8
- package/libs/api/biz/navigation/setPanGestureEnable.js +1 -8
- package/libs/api/biz/navigation/setRight.js +1 -8
- package/libs/api/biz/navigation/setTitle.js +1 -7
- package/libs/api/biz/navigation/setTitleExpandIcon.js +1 -8
- package/libs/api/biz/navigation/setWindowBig.js +2 -7
- package/libs/api/biz/navigation/tencentMeeting.js +1 -7
- package/libs/api/biz/navigation/tencentMeetingBegin.js +1 -7
- package/libs/api/biz/navigation/updateExpandTitle.js +1 -7
- package/libs/api/biz/telephone/call.js +1 -7
- package/libs/api/biz/telephone/showCallMenu.js +1 -7
- package/libs/api/biz/util/addAppToNav.js +1 -7
- package/libs/api/biz/util/assistantCreate.js +1 -7
- package/libs/api/biz/util/authFinish.js +1 -7
- package/libs/api/biz/util/authStart.js +1 -7
- package/libs/api/biz/util/chosen.js +1 -7
- package/libs/api/biz/util/clipboardFileUpload.js +1 -7
- package/libs/api/biz/util/closeWindow.js +1 -7
- package/libs/api/biz/util/complain.js +1 -7
- package/libs/api/biz/util/createModifySchedule.js +1 -7
- package/libs/api/biz/util/datepicker.js +1 -7
- package/libs/api/biz/util/datetimepicker.js +1 -7
- package/libs/api/biz/util/disableScreenCapture.js +1 -7
- package/libs/api/biz/util/downloadFile.js +1 -7
- package/libs/api/biz/util/entergroupCheck.js +1 -7
- package/libs/api/biz/util/externalLinkPreviewFile.js +1 -7
- package/libs/api/biz/util/feedback.js +1 -7
- package/libs/api/biz/util/getSingleWebviewData.js +1 -7
- package/libs/api/biz/util/getTogetherConfig.js +1 -7
- package/libs/api/biz/util/getToken.js +1 -7
- package/libs/api/biz/util/injectScript.js +1 -7
- package/libs/api/biz/util/invoice.js +2 -7
- package/libs/api/biz/util/knowledgeBaseSelect.js +1 -7
- package/libs/api/biz/util/mediaFileUpload.js +2 -7
- package/libs/api/biz/util/onlineDocmentOpenTeamChat.js +1 -7
- package/libs/api/biz/util/open.js +1 -7
- package/libs/api/biz/util/openFutureGroup.js +1 -7
- package/libs/api/biz/util/openLink.js +1 -7
- package/libs/api/biz/util/openMediaFileDialog.js +2 -7
- package/libs/api/biz/util/openSingleWebview.js +1 -7
- package/libs/api/biz/util/openSlidePanel.js +1 -7
- package/libs/api/biz/util/openTalYoungToTopic.js +2 -7
- package/libs/api/biz/util/openTogetherEyeWebview.js +1 -7
- package/libs/api/biz/util/openUserSchedule.js +1 -7
- package/libs/api/biz/util/openVideoPlayer.js +1 -7
- package/libs/api/biz/util/previewFile.js +1 -7
- package/libs/api/biz/util/previewImage.js +1 -7
- package/libs/api/biz/util/proxy.js +1 -7
- package/libs/api/biz/util/pushWorkMsg.js +2 -7
- package/libs/api/biz/util/remind.js +1 -7
- package/libs/api/biz/util/resetSessionUnread.js +1 -7
- package/libs/api/biz/util/rouseApp.js +2 -7
- package/libs/api/biz/util/savePic.js +1 -7
- package/libs/api/biz/util/scan.js +1 -7
- package/libs/api/biz/util/screen.js +1 -7
- package/libs/api/biz/util/selectDepartment.js +1 -7
- package/libs/api/biz/util/share.js +1 -7
- package/libs/api/biz/util/takePicture.js +1 -7
- package/libs/api/biz/util/topicEvent.js +1 -7
- package/libs/api/biz/util/uploadAttachment.js +1 -7
- package/libs/api/biz/util/weeklyRead.js +1 -7
- package/libs/api/biz/util/yachEvent.js +1 -7
- package/libs/api/biz/util/zfbAuth.js +1 -7
- package/libs/api/biz/webViewMessage/send.js +1 -7
- package/libs/api/device/audio/download.js +1 -7
- package/libs/api/device/audio/onPlayEnd.js +1 -7
- package/libs/api/device/audio/onRecordEnd.js +1 -7
- package/libs/api/device/audio/onRecordEnd_v2.js +1 -7
- package/libs/api/device/audio/pause.js +1 -7
- package/libs/api/device/audio/play.js +1 -7
- package/libs/api/device/audio/resume.js +1 -7
- package/libs/api/device/audio/startRecord.js +1 -7
- package/libs/api/device/audio/startRecord_v2.js +1 -7
- package/libs/api/device/audio/stop.js +1 -7
- package/libs/api/device/audio/stopRecord.js +1 -7
- package/libs/api/device/audio/stopRecord_v2.js +1 -7
- package/libs/api/device/base/checkStepPermission.js +1 -7
- package/libs/api/device/base/getPhoneInfo.js +1 -7
- package/libs/api/device/base/getUUID.js +1 -7
- package/libs/api/device/connection/getNetworkType.js +1 -7
- package/libs/api/device/connection/isAtTal.js +3 -9
- package/libs/api/device/geolocation/get.js +1 -7
- package/libs/api/device/geolocation/getSwitch.js +1 -7
- package/libs/api/device/notification/actionSheet.js +1 -7
- package/libs/api/device/notification/alert.js +1 -7
- package/libs/api/device/notification/confirm.js +1 -7
- package/libs/api/device/notification/hidePreloader.js +2 -10
- package/libs/api/device/notification/showPreloader.js +2 -10
- package/libs/api/device/notification/toast.js +1 -7
- package/libs/api/device/notification/vibrate.js +1 -7
- package/libs/api/device/system/getLang.js +1 -7
- package/libs/api/device/system/setLight.js +1 -7
- package/libs/api/initAPI.js +4 -13
- package/libs/api/primary/createTab.js +1 -7
- package/libs/api/primary/exitFullScreen.js +1 -7
- package/libs/api/primary/fullScreen.js +1 -7
- package/libs/api/primary/weeklyShare.js +1 -7
- package/libs/api/runtime/permission/requestAuthCode.js +1 -7
- package/libs/api/ui/pullToRefresh/disable.js +1 -7
- package/libs/api/ui/pullToRefresh/enable.js +1 -7
- package/libs/api/ui/pullToRefresh/stop.js +1 -7
- package/libs/api/ui/webViewBounce/disable.js +1 -7
- package/libs/api/util/domainStorage/getItem.js +1 -7
- package/libs/api/util/domainStorage/removeItem.js +1 -7
- package/libs/api/util/domainStorage/setItem.js +1 -7
- package/libs/api/util/tool/flushLog.js +1 -7
- package/libs/api/util/tool/log.js +1 -7
- package/libs/index.js +274 -529
- package/libs/lib/bridge/index.js +6 -13
- package/libs/lib/bridge/mobile.js +16 -50
- package/libs/lib/bridge/pc.js +16 -37
- package/libs/lib/helper/apiHelper.js +1 -7
- package/libs/lib/helper/codeMap.js +1 -7
- package/libs/lib/helper/event.js +8 -28
- package/libs/lib/helper/pcIframe.js +20 -58
- package/libs/lib/index.js +9 -33
- package/libs/lib/sdk/index.js +18 -49
- package/libs/lib/sdk/sdk.typings.d.ts +1 -0
- package/libs/lib/sdk/sdk.typings.js +0 -4
- package/libs/utils/bpitLog.js +4 -16
- package/libs/utils/compareVersions.js +32 -77
- package/libs/utils/console.js +2 -18
- package/libs/utils/env.js +15 -22
- package/libs/utils/index.js +8 -21
- package/package.json +1 -1
- package/dist/yach_jssdk_4.4.3.js +0 -1
package/es/lib/bridge/mobile.js
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
|
-
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
2
|
-
import _parseInt from "@babel/runtime-corejs3/core-js/parse-int";
|
|
3
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
4
|
-
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
5
1
|
import _setTimeout from "@babel/runtime-corejs3/core-js/set-timeout";
|
|
2
|
+
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
3
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
4
|
+
import _parseInt from "@babel/runtime-corejs3/core-js/parse-int";
|
|
5
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
6
6
|
import Event from '../helper/event';
|
|
7
7
|
import { electronResCodeMap } from '../helper/codeMap';
|
|
8
8
|
import { log, bpitLog } from '../../utils';
|
|
9
|
-
|
|
10
9
|
function setupWebViewJavascriptBridge(callback) {
|
|
11
10
|
if (window.WebViewJavascriptBridge) {
|
|
12
11
|
return callback(WebViewJavascriptBridge);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
if (window.WKWebViewJavascriptBridge) {
|
|
16
14
|
return callback(WKWebViewJavascriptBridge);
|
|
17
15
|
}
|
|
18
|
-
|
|
19
16
|
if (window.WVJBCallbacks) {
|
|
20
17
|
return window.WVJBCallbacks.push(callback);
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
window.WVJBCallbacks = [callback];
|
|
24
20
|
var WVJBIframe = document.createElement('iframe');
|
|
25
21
|
WVJBIframe.style.display = 'none';
|
|
26
22
|
WVJBIframe.src = 'https://__bridge_loaded__';
|
|
27
23
|
document.documentElement.appendChild(WVJBIframe);
|
|
28
|
-
|
|
29
24
|
_setTimeout(function () {
|
|
30
25
|
document.documentElement.removeChild(WVJBIframe);
|
|
31
26
|
}, 0);
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
var mobileBridgeInit = function mobileBridgeInit() {
|
|
35
29
|
return new _Promise(function (resolve, reject) {
|
|
36
30
|
setupWebViewJavascriptBridge(function (bridge) {
|
|
@@ -77,17 +71,14 @@ var mobileBridgeInit = function mobileBridgeInit() {
|
|
|
77
71
|
});
|
|
78
72
|
});
|
|
79
73
|
};
|
|
80
|
-
|
|
81
74
|
var mobileBridge = function mobileBridge(method, param) {
|
|
82
75
|
return new _Promise(function (resolve, reject) {
|
|
83
76
|
var p = _Object$assign({}, param);
|
|
84
|
-
|
|
85
77
|
setupWebViewJavascriptBridge(function (bridge) {
|
|
86
78
|
if (param.control) {
|
|
87
79
|
bridge.registerHandler(method, function (data) {
|
|
88
80
|
var onSuccess = param.onSuccess;
|
|
89
81
|
delete p.onSuccess;
|
|
90
|
-
|
|
91
82
|
if ('function' === typeof onSuccess) {
|
|
92
83
|
onSuccess(data);
|
|
93
84
|
resolve({
|
|
@@ -97,14 +88,11 @@ var mobileBridge = function mobileBridge(method, param) {
|
|
|
97
88
|
}
|
|
98
89
|
});
|
|
99
90
|
}
|
|
100
|
-
|
|
101
91
|
bridge.callHandler(method, param, function (e) {
|
|
102
92
|
var code = e.code,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
message = e.message,
|
|
94
|
+
data = e.data;
|
|
106
95
|
var _code = _parseInt(code);
|
|
107
|
-
|
|
108
96
|
var callbackStr = electronResCodeMap(_code);
|
|
109
97
|
var callbackFun = p[callbackStr];
|
|
110
98
|
log("SDK\u6267\u884C\u540E\u56DE\u8C03\uFF0C\u76F8\u5173\u53C2\u6570 ", {
|
|
@@ -114,40 +102,37 @@ var mobileBridge = function mobileBridge(method, param) {
|
|
|
114
102
|
_code: _code,
|
|
115
103
|
message: message,
|
|
116
104
|
callbackFun: callbackFun
|
|
117
|
-
});
|
|
118
|
-
|
|
105
|
+
});
|
|
106
|
+
// 请求失败
|
|
119
107
|
if (callbackStr === 'onFail') {
|
|
120
108
|
bpitLog({
|
|
121
109
|
method: method,
|
|
122
110
|
errorcode: _code,
|
|
123
111
|
message: message || _JSON$stringify(data) || 'SDK执行失败回调,相关参数'
|
|
124
112
|
});
|
|
125
|
-
|
|
126
113
|
if ('function' === typeof callbackFun) {
|
|
127
114
|
message ? callbackFun({
|
|
128
115
|
code: code,
|
|
129
116
|
message: message
|
|
130
117
|
}) : callbackFun(data);
|
|
131
118
|
}
|
|
132
|
-
|
|
133
119
|
reject({
|
|
134
120
|
_code: _code,
|
|
135
121
|
message: message,
|
|
136
122
|
data: data
|
|
137
123
|
});
|
|
138
124
|
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
125
|
+
}
|
|
126
|
+
// 请求成功
|
|
142
127
|
if ('function' === typeof callbackFun) {
|
|
143
128
|
callbackFun(data || message);
|
|
144
129
|
}
|
|
145
|
-
|
|
146
130
|
resolve({
|
|
147
131
|
_code: _code,
|
|
148
132
|
message: message,
|
|
149
133
|
data: data
|
|
150
|
-
});
|
|
134
|
+
});
|
|
135
|
+
// if (_code === -2 || _code === 7) {
|
|
151
136
|
// bpitLog({
|
|
152
137
|
// method,
|
|
153
138
|
// errorcode: _code,
|
|
@@ -180,5 +165,4 @@ var mobileBridge = function mobileBridge(method, param) {
|
|
|
180
165
|
});
|
|
181
166
|
});
|
|
182
167
|
};
|
|
183
|
-
|
|
184
168
|
export { mobileBridge, mobileBridgeInit };
|
package/es/lib/bridge/pc.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
2
|
-
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
3
|
-
import _parseInt from "@babel/runtime-corejs3/core-js/parse-int";
|
|
4
1
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
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";
|
|
5
5
|
import PcIframe from '../helper/pcIframe';
|
|
6
6
|
import { electronResCodeMap } from '../helper/codeMap';
|
|
7
7
|
import { log, bpitLog } from '../../utils';
|
|
8
|
-
|
|
9
8
|
var PcBridgeInit = function PcBridgeInit() {
|
|
10
9
|
PcIframe.init();
|
|
11
10
|
};
|
|
12
|
-
|
|
13
11
|
var pcBridge = function pcBridge(method, param) {
|
|
14
12
|
return new _Promise(function (resolve, reject) {
|
|
15
13
|
return PcIframe.invokeAPI(method, param, function (_ref) {
|
|
16
14
|
var data = _ref.data,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
code = _ref.code,
|
|
16
|
+
message = _ref.message;
|
|
20
17
|
var _code = _parseInt(code);
|
|
21
|
-
|
|
22
18
|
var callbackStr = electronResCodeMap(_code);
|
|
23
19
|
var callbackFun = param[callbackStr];
|
|
24
20
|
log("SDK\u6267\u884C\u540E\u56DE\u8C03\uFF0C\u76F8\u5173\u53C2\u6570 ", {
|
|
@@ -28,15 +24,14 @@ var pcBridge = function pcBridge(method, param) {
|
|
|
28
24
|
_code: _code,
|
|
29
25
|
message: message,
|
|
30
26
|
callbackFun: callbackFun
|
|
31
|
-
});
|
|
32
|
-
|
|
27
|
+
});
|
|
28
|
+
// 请求失败
|
|
33
29
|
if (callbackStr === 'onFail') {
|
|
34
30
|
bpitLog({
|
|
35
31
|
method: method,
|
|
36
32
|
errorcode: _code,
|
|
37
33
|
message: message || _JSON$stringify(data) || 'SDK执行失败回调,相关参数'
|
|
38
34
|
});
|
|
39
|
-
|
|
40
35
|
if ('function' === typeof callbackFun) {
|
|
41
36
|
console.log('wenai-code', code, _code);
|
|
42
37
|
var callbackData = Object.prototype.toString.call(data) === "[object Object]" ? _Object$assign(_Object$assign({}, data), {
|
|
@@ -49,25 +44,23 @@ var pcBridge = function pcBridge(method, param) {
|
|
|
49
44
|
};
|
|
50
45
|
message ? callbackFun(callbackData) : callbackFun(data);
|
|
51
46
|
}
|
|
52
|
-
|
|
53
47
|
reject({
|
|
54
48
|
_code: _code,
|
|
55
49
|
message: message,
|
|
56
50
|
data: data
|
|
57
51
|
});
|
|
58
52
|
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
}
|
|
54
|
+
// 请求成功
|
|
62
55
|
if ('function' === typeof callbackFun) {
|
|
63
56
|
callbackFun(data || message);
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
resolve({
|
|
67
59
|
_code: _code,
|
|
68
60
|
message: message,
|
|
69
61
|
data: data
|
|
70
|
-
});
|
|
62
|
+
});
|
|
63
|
+
// if (_code === -2) {
|
|
71
64
|
// bpitLog({
|
|
72
65
|
// method,
|
|
73
66
|
// errorcode: _code,
|
|
@@ -90,5 +83,4 @@ var pcBridge = function pcBridge(method, param) {
|
|
|
90
83
|
});
|
|
91
84
|
});
|
|
92
85
|
};
|
|
93
|
-
|
|
94
86
|
export { pcBridge, PcBridgeInit };
|
package/es/lib/helper/codeMap.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
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
|
-
|
|
4
3
|
function electronResCodeMap(code) {
|
|
5
4
|
return resCodeMap.get(code) || 'onFail';
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
export { electronResCodeMap };
|
package/es/lib/helper/event.js
CHANGED
|
@@ -1,41 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
3
|
-
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js/instance/index-of";
|
|
4
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js/array/is-array";
|
|
1
|
+
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
5
2
|
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import _Array$isArray from "@babel/runtime-corejs3/core-js/array/is-array";
|
|
4
|
+
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js/instance/index-of";
|
|
5
|
+
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
6
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
|
|
7
|
+
var Event = /*#__PURE__*/_createClass(function Event() {
|
|
8
8
|
var _this = this;
|
|
9
|
-
|
|
10
9
|
_classCallCheck(this, Event);
|
|
11
|
-
|
|
12
10
|
this.on = function (event, fn) {
|
|
13
11
|
if (!event || 'function' !== typeof fn) throw 'eventName is null or handle is not a function, on fail';
|
|
14
12
|
if (!_Array$isArray(_this.eventsHandle[event])) _this.eventsHandle[event] = [];
|
|
15
|
-
|
|
16
13
|
_this.eventsHandle[event].push(fn);
|
|
17
14
|
};
|
|
18
|
-
|
|
19
15
|
this.off = function (event, fn) {
|
|
20
16
|
if (!event) throw 'eventName is null, invoke off fail';
|
|
21
|
-
|
|
22
17
|
if (!fn) {
|
|
23
18
|
_this.eventsHandle[event] = [];
|
|
24
19
|
return;
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
if (_Array$isArray(_this.eventsHandle[event])) {
|
|
28
22
|
var _context, _context2;
|
|
29
|
-
|
|
30
23
|
var n = _indexOfInstanceProperty(_context = _this.eventsHandle[event]).call(_context, fn);
|
|
31
|
-
|
|
32
24
|
-1 !== n && _spliceInstanceProperty(_context2 = _this.eventsHandle[event]).call(_context2, n, 1);
|
|
33
25
|
}
|
|
34
26
|
};
|
|
35
|
-
|
|
36
27
|
this.execEvent = function (event, data) {
|
|
37
28
|
var _context3;
|
|
38
|
-
|
|
39
29
|
_Array$isArray(this.eventsHandle[event]) && _forEachInstanceProperty(_context3 = this.eventsHandle[event]).call(_context3, function (fn) {
|
|
40
30
|
try {
|
|
41
31
|
fn(data);
|
|
@@ -44,9 +34,7 @@ var Event = function Event() {
|
|
|
44
34
|
}
|
|
45
35
|
});
|
|
46
36
|
};
|
|
47
|
-
|
|
48
37
|
this.eventsHandle = {};
|
|
49
|
-
};
|
|
50
|
-
|
|
38
|
+
});
|
|
51
39
|
var event = new Event();
|
|
52
40
|
export default event;
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _Date$now from "@babel/runtime-corejs3/core-js/date/now";
|
|
1
|
+
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
3
2
|
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
3
|
+
import _Date$now from "@babel/runtime-corejs3/core-js/date/now";
|
|
4
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
4
5
|
import { log } from '../../utils';
|
|
5
|
-
import Event from './event';
|
|
6
|
-
|
|
7
|
-
var GenPostMsg = function GenPostMsg(method, param, callback) {
|
|
6
|
+
import Event from './event';
|
|
7
|
+
// 处理posmessage参数
|
|
8
|
+
var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, callback) {
|
|
8
9
|
var _this = this;
|
|
9
|
-
|
|
10
10
|
_classCallCheck(this, GenPostMsg);
|
|
11
|
-
|
|
12
11
|
this.genid = function () {
|
|
13
12
|
var idStr = _Date$now().toString(36);
|
|
14
|
-
|
|
15
13
|
idStr += Math.random().toString(36).substr(3);
|
|
16
14
|
return idStr;
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
this.receiveResponse = function (data) {
|
|
20
17
|
//this.PromiseObj.resolve(data);
|
|
21
18
|
_this.callback(data);
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
this.getPayload = function () {
|
|
25
21
|
return {
|
|
26
22
|
msgId: _this.id,
|
|
@@ -30,7 +26,6 @@ var GenPostMsg = function GenPostMsg(method, param, callback) {
|
|
|
30
26
|
invokeType: _this.invokeType
|
|
31
27
|
};
|
|
32
28
|
};
|
|
33
|
-
|
|
34
29
|
this.id = this.genid();
|
|
35
30
|
this.PromiseObj = {
|
|
36
31
|
resolve: null,
|
|
@@ -39,7 +34,8 @@ var GenPostMsg = function GenPostMsg(method, param, callback) {
|
|
|
39
34
|
this.methodName = method;
|
|
40
35
|
this.plainMsg = param;
|
|
41
36
|
this.invokeType = param === null || param === void 0 ? void 0 : param.invokeType;
|
|
42
|
-
this.callback = callback;
|
|
37
|
+
this.callback = callback;
|
|
38
|
+
// this.result = new Promise(
|
|
43
39
|
// function (resolve, reject) {
|
|
44
40
|
// this.PromiseObj = {
|
|
45
41
|
// resolve,
|
|
@@ -47,81 +43,62 @@ var GenPostMsg = function GenPostMsg(method, param, callback) {
|
|
|
47
43
|
// };
|
|
48
44
|
// }.bind(this)
|
|
49
45
|
// );
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var Frame = function Frame() {
|
|
46
|
+
});
|
|
47
|
+
var Frame = /*#__PURE__*/_createClass(function Frame() {
|
|
53
48
|
var _this2 = this;
|
|
54
|
-
|
|
55
49
|
_classCallCheck(this, Frame);
|
|
56
|
-
|
|
57
50
|
this.addPending = function (e) {
|
|
58
51
|
_this2.pendingMsgs[e.id] = e;
|
|
59
52
|
};
|
|
60
|
-
|
|
61
53
|
this.deletePending = function (e) {
|
|
62
54
|
delete _this2.pendingMsgs[e.id];
|
|
63
55
|
};
|
|
64
|
-
|
|
65
56
|
this.getPending = function (t) {
|
|
66
57
|
return this.pendingMsgs[t];
|
|
67
58
|
};
|
|
68
|
-
|
|
69
59
|
this.invokeAPIInBrowserView = function (payload) {
|
|
70
60
|
window.sendTo(payload);
|
|
71
61
|
};
|
|
72
|
-
|
|
73
62
|
this.invokeAPIInWebview = function (payload) {
|
|
74
63
|
window.sendToHost(payload);
|
|
75
64
|
};
|
|
76
|
-
|
|
77
65
|
this.invokeAPI = function (method, param, callback) {
|
|
78
66
|
var genPostMsg = new GenPostMsg(method, param, callback);
|
|
79
|
-
|
|
80
67
|
var payload = _JSON$stringify(genPostMsg.getPayload());
|
|
81
|
-
|
|
82
68
|
var _param$invokeType = param.invokeType,
|
|
83
|
-
|
|
69
|
+
invokeType = _param$invokeType === void 0 ? '' : _param$invokeType;
|
|
84
70
|
invokeType === 'browserView' ? _this2.invokeAPIInBrowserView(payload) : _this2.invokeAPIInWebview(payload);
|
|
85
|
-
|
|
86
71
|
_this2.addPending(genPostMsg);
|
|
87
|
-
|
|
88
72
|
return genPostMsg;
|
|
89
73
|
};
|
|
90
|
-
|
|
91
74
|
this.handleCallback = function (datas, invokeType) {
|
|
92
75
|
var type = datas.type,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
76
|
+
methodName = datas.methodName,
|
|
77
|
+
eventName = datas.eventName,
|
|
78
|
+
msgId = datas.msgId,
|
|
79
|
+
_datas$data = datas.data,
|
|
80
|
+
data = _datas$data === void 0 ? {} : _datas$data,
|
|
81
|
+
code = datas.code,
|
|
82
|
+
message = datas.message,
|
|
83
|
+
msg = datas.msg;
|
|
102
84
|
if (type === 'request') {
|
|
103
85
|
// 壳子的调用
|
|
104
86
|
switch (methodName) {
|
|
105
87
|
case 'refresh':
|
|
106
88
|
window.location.reload();
|
|
107
89
|
break;
|
|
108
|
-
|
|
109
90
|
case 'back':
|
|
110
91
|
window.history.back();
|
|
111
92
|
break;
|
|
112
|
-
|
|
113
93
|
case 'forward':
|
|
114
94
|
window.history.forward();
|
|
115
95
|
break;
|
|
116
|
-
|
|
117
96
|
case 'event':
|
|
118
97
|
Event.execEvent(eventName, data);
|
|
119
98
|
break;
|
|
120
|
-
|
|
121
99
|
case 'zoomInClick':
|
|
122
100
|
var scrollTopVal = document.documentElement.scrollTop || document.body.scrollTop,
|
|
123
|
-
|
|
124
|
-
|
|
101
|
+
url = window.location.href;
|
|
125
102
|
if (invokeType === 'browserView') {
|
|
126
103
|
window.sendTo(_JSON$stringify({
|
|
127
104
|
type: type,
|
|
@@ -143,16 +120,13 @@ var Frame = function Frame() {
|
|
|
143
120
|
}
|
|
144
121
|
}));
|
|
145
122
|
}
|
|
146
|
-
|
|
147
123
|
break;
|
|
148
|
-
|
|
149
124
|
default:
|
|
150
125
|
break;
|
|
151
126
|
}
|
|
152
127
|
} else if (type === 'response') {
|
|
153
128
|
// 响应壳子的回调
|
|
154
129
|
var pending = _this2.getPending(msgId);
|
|
155
|
-
|
|
156
130
|
pending && pending.receiveResponse({
|
|
157
131
|
data: data,
|
|
158
132
|
code: code,
|
|
@@ -161,20 +135,16 @@ var Frame = function Frame() {
|
|
|
161
135
|
code != -3 && _this2.deletePending(msgId);
|
|
162
136
|
}
|
|
163
137
|
};
|
|
164
|
-
|
|
165
138
|
this.init = function () {
|
|
166
139
|
window.addEventListener('message', function (msg) {
|
|
167
140
|
log('electron res: ', msg);
|
|
168
|
-
|
|
169
141
|
_this2.handleCallback(msg.data || {});
|
|
170
142
|
});
|
|
171
143
|
window.receiveBrowserViewData && window.receiveBrowserViewData(function (e, response) {
|
|
172
144
|
return _this2.handleCallback(response);
|
|
173
145
|
});
|
|
174
146
|
};
|
|
175
|
-
|
|
176
147
|
this.pendingMsgs = {};
|
|
177
|
-
};
|
|
178
|
-
|
|
148
|
+
});
|
|
179
149
|
var frame = new Frame();
|
|
180
150
|
export default frame;
|
package/es/lib/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
2
2
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
3
|
-
|
|
4
3
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
5
4
|
function adopt(value) {
|
|
6
5
|
return value instanceof P ? value : new P(function (resolve) {
|
|
7
6
|
resolve(value);
|
|
8
7
|
});
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return new (P || (P = _Promise))(function (resolve, reject) {
|
|
12
10
|
function fulfilled(value) {
|
|
13
11
|
try {
|
|
@@ -16,7 +14,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
16
14
|
reject(e);
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
function rejected(value) {
|
|
21
18
|
try {
|
|
22
19
|
step(generator["throw"](value));
|
|
@@ -24,15 +21,12 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
24
21
|
reject(e);
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
function step(result) {
|
|
29
25
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
28
|
});
|
|
34
29
|
};
|
|
35
|
-
|
|
36
30
|
import { getENV } from '../utils';
|
|
37
31
|
import Sdk from './sdk';
|
|
38
32
|
import { mobileBridge, mobileBridgeInit, PcBridgeInit, pcBridge } from './bridge';
|
|
@@ -40,26 +34,20 @@ import Event from './helper/event';
|
|
|
40
34
|
var env = getENV();
|
|
41
35
|
var platform = env.platform;
|
|
42
36
|
var yachSdk = new Sdk(env);
|
|
43
|
-
|
|
44
37
|
function initSdk() {
|
|
45
38
|
var _this = this;
|
|
46
|
-
|
|
47
39
|
var bridgeInit;
|
|
48
|
-
|
|
49
40
|
if (platform === 'pc') {
|
|
50
41
|
bridgeInit = function bridgeInit() {
|
|
51
42
|
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
52
43
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
53
|
-
while (1) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
case "end":
|
|
61
|
-
return _context.stop();
|
|
62
|
-
}
|
|
44
|
+
while (1) switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
PcBridgeInit();
|
|
47
|
+
return _context.abrupt("return", pcBridge);
|
|
48
|
+
case 2:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
63
51
|
}
|
|
64
52
|
}, _callee);
|
|
65
53
|
}));
|
|
@@ -71,7 +59,6 @@ function initSdk() {
|
|
|
71
59
|
});
|
|
72
60
|
};
|
|
73
61
|
}
|
|
74
|
-
|
|
75
62
|
var config = {
|
|
76
63
|
platform: platform,
|
|
77
64
|
authMethod: 'config',
|
|
@@ -87,6 +74,5 @@ function initSdk() {
|
|
|
87
74
|
};
|
|
88
75
|
yachSdk.setPlatform(config);
|
|
89
76
|
}
|
|
90
|
-
|
|
91
77
|
initSdk();
|
|
92
78
|
export { yachSdk, initSdk };
|