yach.open.jssdk 4.3.6-beta2 → 4.3.6-beta3

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.
Files changed (282) hide show
  1. package/dist/yach_jssdk_4.3.6-beta3.js +1 -0
  2. package/es/api/app/custom/talYoungFilesUpload.js +2 -0
  3. package/es/api/biz/chat/chooseConversationByCorpId.js +2 -0
  4. package/es/api/biz/chat/openSingleChat.js +2 -0
  5. package/es/api/biz/chat/openSquad.js +2 -0
  6. package/es/api/biz/chat/openTeamChat.js +2 -0
  7. package/es/api/biz/chat/pickConversation.js +2 -0
  8. package/es/api/biz/chat/sendP2PMsg.js +2 -0
  9. package/es/api/biz/contact/complexPicker.js +2 -0
  10. package/es/api/biz/contact/departmentsPicker.js +2 -0
  11. package/es/api/biz/group/groupComplexPicker.js +2 -0
  12. package/es/api/biz/map/multipointView.js +2 -0
  13. package/es/api/biz/map/view.js +2 -0
  14. package/es/api/biz/navigation/close.js +2 -0
  15. package/es/api/biz/navigation/goBack.js +2 -0
  16. package/es/api/biz/navigation/quit.js +2 -0
  17. package/es/api/biz/navigation/replace.js +2 -0
  18. package/es/api/biz/navigation/setIcon.js +2 -0
  19. package/es/api/biz/navigation/setLeft.js +2 -0
  20. package/es/api/biz/navigation/setMenu.js +2 -0
  21. package/es/api/biz/navigation/setPanGestureEnable.js +2 -0
  22. package/es/api/biz/navigation/setRight.js +2 -0
  23. package/es/api/biz/navigation/setTitle.js +2 -0
  24. package/es/api/biz/navigation/setTitleExpandIcon.js +2 -0
  25. package/es/api/biz/navigation/setWindowBig.js +2 -0
  26. package/es/api/biz/navigation/tencentMeeting.js +2 -0
  27. package/es/api/biz/navigation/tencentMeetingBegin.js +2 -0
  28. package/es/api/biz/navigation/updateExpandTitle.js +2 -0
  29. package/es/api/biz/telephone/call.js +2 -0
  30. package/es/api/biz/telephone/showCallMenu.js +2 -0
  31. package/es/api/biz/util/addAppToNav.d.ts +8 -0
  32. package/es/api/biz/util/addAppToNav.js +25 -0
  33. package/es/api/biz/util/assistantCreate.js +2 -0
  34. package/es/api/biz/util/authFinish.js +2 -0
  35. package/es/api/biz/util/authStart.js +2 -0
  36. package/es/api/biz/util/chosen.js +2 -0
  37. package/es/api/biz/util/clipboardFileUpload.js +2 -0
  38. package/es/api/biz/util/closeWindow.js +2 -0
  39. package/es/api/biz/util/complain.js +2 -0
  40. package/es/api/biz/util/createModifySchedule.js +2 -0
  41. package/es/api/biz/util/datepicker.js +2 -0
  42. package/es/api/biz/util/datetimepicker.js +2 -0
  43. package/es/api/biz/util/disableScreenCapture.js +2 -0
  44. package/es/api/biz/util/downloadFile.js +2 -0
  45. package/es/api/biz/util/entergroupCheck.js +2 -0
  46. package/es/api/biz/util/externalLinkPreviewFile.js +2 -0
  47. package/es/api/biz/util/feedback.js +2 -0
  48. package/es/api/biz/util/getSingleWebviewData.js +2 -0
  49. package/es/api/biz/util/getTogetherConfig.js +2 -0
  50. package/es/api/biz/util/getToken.js +2 -0
  51. package/es/api/biz/util/injectScript.js +2 -0
  52. package/es/api/biz/util/invoice.js +2 -0
  53. package/es/api/biz/util/mediaFileUpload.js +2 -0
  54. package/es/api/biz/util/onlineDocmentOpenTeamChat.js +2 -0
  55. package/es/api/biz/util/open.js +2 -0
  56. package/es/api/biz/util/openFutureGroup.js +2 -0
  57. package/es/api/biz/util/openLink.js +2 -0
  58. package/es/api/biz/util/openMediaFileDialog.js +2 -0
  59. package/es/api/biz/util/openSingleWebview.js +2 -0
  60. package/es/api/biz/util/openSlidePanel.js +2 -0
  61. package/es/api/biz/util/openTalYoungToTopic.js +2 -0
  62. package/es/api/biz/util/openTogetherEyeWebview.js +2 -0
  63. package/es/api/biz/util/openUserSchedule.js +2 -0
  64. package/es/api/biz/util/openVideoPlayer.js +2 -0
  65. package/es/api/biz/util/previewFile.js +2 -0
  66. package/es/api/biz/util/previewImage.js +2 -0
  67. package/es/api/biz/util/proxy.js +2 -0
  68. package/es/api/biz/util/pushWorkMsg.js +2 -0
  69. package/es/api/biz/util/remind.js +2 -0
  70. package/es/api/biz/util/resetSessionUnread.js +2 -0
  71. package/es/api/biz/util/rouseApp.js +2 -0
  72. package/es/api/biz/util/savePic.js +2 -0
  73. package/es/api/biz/util/scan.js +2 -0
  74. package/es/api/biz/util/selectDepartment.js +2 -0
  75. package/es/api/biz/util/share.js +2 -0
  76. package/es/api/biz/util/takePicture.js +2 -0
  77. package/es/api/biz/util/uploadAttachment.js +2 -0
  78. package/es/api/biz/util/yachEvent.js +2 -0
  79. package/es/api/biz/util/zfbAuth.js +2 -0
  80. package/es/api/biz/webViewMessage/send.js +2 -0
  81. package/es/api/device/audio/download.js +2 -0
  82. package/es/api/device/audio/onPlayEnd.js +2 -0
  83. package/es/api/device/audio/onRecordEnd.js +2 -0
  84. package/es/api/device/audio/onRecordEnd_v2.js +2 -0
  85. package/es/api/device/audio/pause.js +2 -0
  86. package/es/api/device/audio/play.js +2 -0
  87. package/es/api/device/audio/resume.js +2 -0
  88. package/es/api/device/audio/startRecord.js +2 -0
  89. package/es/api/device/audio/startRecord_v2.js +2 -0
  90. package/es/api/device/audio/stop.js +2 -0
  91. package/es/api/device/audio/stopRecord.js +2 -0
  92. package/es/api/device/audio/stopRecord_v2.js +2 -0
  93. package/es/api/device/base/checkStepPermission.js +2 -0
  94. package/es/api/device/base/getPhoneInfo.js +2 -0
  95. package/es/api/device/base/getUUID.js +2 -0
  96. package/es/api/device/connection/getNetworkType.js +2 -0
  97. package/es/api/device/connection/isAtTal.js +4 -2
  98. package/es/api/device/geolocation/get.js +2 -0
  99. package/es/api/device/geolocation/getSwitch.js +2 -0
  100. package/es/api/device/notification/actionSheet.js +2 -0
  101. package/es/api/device/notification/alert.js +2 -0
  102. package/es/api/device/notification/confirm.js +2 -0
  103. package/es/api/device/notification/hidePreloader.js +2 -0
  104. package/es/api/device/notification/showPreloader.js +2 -0
  105. package/es/api/device/notification/toast.js +2 -0
  106. package/es/api/device/notification/vibrate.js +2 -0
  107. package/es/api/device/system/getLang.js +2 -0
  108. package/es/api/device/system/setLight.js +2 -0
  109. package/es/api/initAPI.js +5 -3
  110. package/es/api/primary/createTab.js +2 -0
  111. package/es/api/primary/exitFullScreen.js +2 -0
  112. package/es/api/primary/fullScreen.js +2 -0
  113. package/es/api/primary/weeklyShare.js +2 -0
  114. package/es/api/runtime/permission/requestAuthCode.js +2 -0
  115. package/es/api/ui/pullToRefresh/disable.js +2 -0
  116. package/es/api/ui/pullToRefresh/enable.js +2 -0
  117. package/es/api/ui/pullToRefresh/stop.js +2 -0
  118. package/es/api/ui/webViewBounce/disable.js +2 -0
  119. package/es/api/util/domainStorage/getItem.js +2 -0
  120. package/es/api/util/domainStorage/removeItem.js +2 -0
  121. package/es/api/util/domainStorage/setItem.js +2 -0
  122. package/es/api/util/tool/flushLog.js +2 -0
  123. package/es/api/util/tool/log.js +2 -0
  124. package/es/index.d.ts +3 -1
  125. package/es/index.js +29 -16
  126. package/es/lib/bridge/mobile.js +74 -26
  127. package/es/lib/bridge/pc.js +57 -13
  128. package/es/lib/helper/apiHelper.js +2 -0
  129. package/es/lib/helper/codeMap.js +2 -0
  130. package/es/lib/helper/event.js +19 -7
  131. package/es/lib/helper/pcIframe.js +52 -20
  132. package/es/lib/index.js +21 -7
  133. package/es/lib/sdk/index.js +49 -18
  134. package/es/lib/sdk/sdk.typings.d.ts +1 -0
  135. package/es/lib/sdk/sdk.typings.js +1 -0
  136. package/es/utils/bpitLog.js +13 -4
  137. package/es/utils/compareVersions.js +53 -26
  138. package/es/utils/console.js +17 -1
  139. package/es/utils/env.js +21 -12
  140. package/es/utils/index.js +7 -2
  141. package/libs/api/app/custom/talYoungFilesUpload.js +7 -2
  142. package/libs/api/biz/chat/chooseConversationByCorpId.js +7 -1
  143. package/libs/api/biz/chat/openSingleChat.js +7 -1
  144. package/libs/api/biz/chat/openSquad.js +7 -1
  145. package/libs/api/biz/chat/openTeamChat.js +7 -1
  146. package/libs/api/biz/chat/pickConversation.js +7 -1
  147. package/libs/api/biz/chat/sendP2PMsg.js +7 -1
  148. package/libs/api/biz/contact/complexPicker.js +7 -1
  149. package/libs/api/biz/contact/departmentsPicker.js +7 -1
  150. package/libs/api/biz/group/groupComplexPicker.js +7 -1
  151. package/libs/api/biz/map/multipointView.js +7 -1
  152. package/libs/api/biz/map/view.js +7 -1
  153. package/libs/api/biz/navigation/close.js +7 -1
  154. package/libs/api/biz/navigation/goBack.js +7 -1
  155. package/libs/api/biz/navigation/quit.js +7 -1
  156. package/libs/api/biz/navigation/replace.js +7 -1
  157. package/libs/api/biz/navigation/setIcon.js +8 -1
  158. package/libs/api/biz/navigation/setLeft.js +8 -1
  159. package/libs/api/biz/navigation/setMenu.js +8 -1
  160. package/libs/api/biz/navigation/setPanGestureEnable.js +8 -1
  161. package/libs/api/biz/navigation/setRight.js +8 -1
  162. package/libs/api/biz/navigation/setTitle.js +7 -1
  163. package/libs/api/biz/navigation/setTitleExpandIcon.js +8 -1
  164. package/libs/api/biz/navigation/setWindowBig.js +7 -2
  165. package/libs/api/biz/navigation/tencentMeeting.js +7 -1
  166. package/libs/api/biz/navigation/tencentMeetingBegin.js +7 -1
  167. package/libs/api/biz/navigation/updateExpandTitle.js +7 -1
  168. package/libs/api/biz/telephone/call.js +7 -1
  169. package/libs/api/biz/telephone/showCallMenu.js +7 -1
  170. package/libs/api/biz/util/addAppToNav.d.ts +8 -0
  171. package/libs/api/biz/util/addAppToNav.js +36 -0
  172. package/libs/api/biz/util/assistantCreate.js +7 -1
  173. package/libs/api/biz/util/authFinish.js +7 -1
  174. package/libs/api/biz/util/authStart.js +7 -1
  175. package/libs/api/biz/util/chosen.js +7 -1
  176. package/libs/api/biz/util/clipboardFileUpload.js +7 -1
  177. package/libs/api/biz/util/closeWindow.js +7 -1
  178. package/libs/api/biz/util/complain.js +7 -1
  179. package/libs/api/biz/util/createModifySchedule.js +7 -1
  180. package/libs/api/biz/util/datepicker.js +7 -1
  181. package/libs/api/biz/util/datetimepicker.js +7 -1
  182. package/libs/api/biz/util/disableScreenCapture.js +7 -1
  183. package/libs/api/biz/util/downloadFile.js +7 -1
  184. package/libs/api/biz/util/entergroupCheck.js +7 -1
  185. package/libs/api/biz/util/externalLinkPreviewFile.js +7 -1
  186. package/libs/api/biz/util/feedback.js +7 -1
  187. package/libs/api/biz/util/getSingleWebviewData.js +7 -1
  188. package/libs/api/biz/util/getTogetherConfig.js +7 -1
  189. package/libs/api/biz/util/getToken.js +7 -1
  190. package/libs/api/biz/util/injectScript.js +7 -1
  191. package/libs/api/biz/util/invoice.js +7 -2
  192. package/libs/api/biz/util/mediaFileUpload.js +7 -2
  193. package/libs/api/biz/util/onlineDocmentOpenTeamChat.js +7 -1
  194. package/libs/api/biz/util/open.js +7 -1
  195. package/libs/api/biz/util/openFutureGroup.js +7 -1
  196. package/libs/api/biz/util/openLink.js +7 -1
  197. package/libs/api/biz/util/openMediaFileDialog.js +7 -2
  198. package/libs/api/biz/util/openSingleWebview.js +7 -1
  199. package/libs/api/biz/util/openSlidePanel.js +7 -1
  200. package/libs/api/biz/util/openTalYoungToTopic.js +7 -2
  201. package/libs/api/biz/util/openTogetherEyeWebview.js +7 -1
  202. package/libs/api/biz/util/openUserSchedule.js +7 -1
  203. package/libs/api/biz/util/openVideoPlayer.js +7 -1
  204. package/libs/api/biz/util/previewFile.js +7 -1
  205. package/libs/api/biz/util/previewImage.js +7 -1
  206. package/libs/api/biz/util/proxy.js +7 -1
  207. package/libs/api/biz/util/pushWorkMsg.js +7 -2
  208. package/libs/api/biz/util/remind.js +7 -1
  209. package/libs/api/biz/util/resetSessionUnread.js +7 -1
  210. package/libs/api/biz/util/rouseApp.js +7 -2
  211. package/libs/api/biz/util/savePic.js +7 -1
  212. package/libs/api/biz/util/scan.js +7 -1
  213. package/libs/api/biz/util/selectDepartment.js +7 -1
  214. package/libs/api/biz/util/share.js +7 -1
  215. package/libs/api/biz/util/takePicture.js +7 -1
  216. package/libs/api/biz/util/uploadAttachment.js +7 -1
  217. package/libs/api/biz/util/yachEvent.js +7 -1
  218. package/libs/api/biz/util/zfbAuth.js +7 -1
  219. package/libs/api/biz/webViewMessage/send.js +7 -1
  220. package/libs/api/device/audio/download.js +7 -1
  221. package/libs/api/device/audio/onPlayEnd.js +7 -1
  222. package/libs/api/device/audio/onRecordEnd.js +7 -1
  223. package/libs/api/device/audio/onRecordEnd_v2.js +7 -1
  224. package/libs/api/device/audio/pause.js +7 -1
  225. package/libs/api/device/audio/play.js +7 -1
  226. package/libs/api/device/audio/resume.js +7 -1
  227. package/libs/api/device/audio/startRecord.js +7 -1
  228. package/libs/api/device/audio/startRecord_v2.js +7 -1
  229. package/libs/api/device/audio/stop.js +7 -1
  230. package/libs/api/device/audio/stopRecord.js +7 -1
  231. package/libs/api/device/audio/stopRecord_v2.js +7 -1
  232. package/libs/api/device/base/checkStepPermission.js +7 -1
  233. package/libs/api/device/base/getPhoneInfo.js +7 -1
  234. package/libs/api/device/base/getUUID.js +7 -1
  235. package/libs/api/device/connection/getNetworkType.js +7 -1
  236. package/libs/api/device/connection/isAtTal.js +9 -3
  237. package/libs/api/device/geolocation/get.js +7 -1
  238. package/libs/api/device/geolocation/getSwitch.js +7 -1
  239. package/libs/api/device/notification/actionSheet.js +7 -1
  240. package/libs/api/device/notification/alert.js +7 -1
  241. package/libs/api/device/notification/confirm.js +7 -1
  242. package/libs/api/device/notification/hidePreloader.js +7 -1
  243. package/libs/api/device/notification/showPreloader.js +7 -1
  244. package/libs/api/device/notification/toast.js +7 -1
  245. package/libs/api/device/notification/vibrate.js +7 -1
  246. package/libs/api/device/system/getLang.js +7 -1
  247. package/libs/api/device/system/setLight.js +7 -1
  248. package/libs/api/initAPI.js +13 -4
  249. package/libs/api/primary/createTab.js +7 -1
  250. package/libs/api/primary/exitFullScreen.js +7 -1
  251. package/libs/api/primary/fullScreen.js +7 -1
  252. package/libs/api/primary/weeklyShare.js +7 -1
  253. package/libs/api/runtime/permission/requestAuthCode.js +7 -1
  254. package/libs/api/ui/pullToRefresh/disable.js +7 -1
  255. package/libs/api/ui/pullToRefresh/enable.js +7 -1
  256. package/libs/api/ui/pullToRefresh/stop.js +7 -1
  257. package/libs/api/ui/webViewBounce/disable.js +7 -1
  258. package/libs/api/util/domainStorage/getItem.js +7 -1
  259. package/libs/api/util/domainStorage/removeItem.js +7 -1
  260. package/libs/api/util/domainStorage/setItem.js +7 -1
  261. package/libs/api/util/tool/flushLog.js +7 -1
  262. package/libs/api/util/tool/log.js +7 -1
  263. package/libs/index.d.ts +3 -1
  264. package/libs/index.js +512 -258
  265. package/libs/lib/bridge/index.js +13 -6
  266. package/libs/lib/bridge/mobile.js +96 -30
  267. package/libs/lib/bridge/pc.js +74 -18
  268. package/libs/lib/helper/apiHelper.js +7 -1
  269. package/libs/lib/helper/codeMap.js +7 -1
  270. package/libs/lib/helper/event.js +28 -8
  271. package/libs/lib/helper/pcIframe.js +59 -19
  272. package/libs/lib/index.js +33 -9
  273. package/libs/lib/sdk/index.js +58 -18
  274. package/libs/lib/sdk/sdk.typings.d.ts +1 -0
  275. package/libs/lib/sdk/sdk.typings.js +4 -0
  276. package/libs/utils/bpitLog.js +16 -4
  277. package/libs/utils/compareVersions.js +77 -32
  278. package/libs/utils/console.js +18 -2
  279. package/libs/utils/env.js +23 -12
  280. package/libs/utils/index.js +22 -9
  281. package/package.json +1 -1
  282. package/dist/yach_jssdk_4.3.6-beta2.js +0 -1
@@ -1,29 +1,36 @@
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";
1
+ import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
4
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
+ import _setTimeout from "@babel/runtime-corejs3/core-js/set-timeout";
5
6
  import Event from '../helper/event';
6
7
  import { electronResCodeMap } from '../helper/codeMap';
7
8
  import { log, bpitLog } from '../../utils';
9
+
8
10
  function setupWebViewJavascriptBridge(callback) {
9
11
  if (window.WebViewJavascriptBridge) {
10
12
  return callback(WebViewJavascriptBridge);
11
13
  }
14
+
12
15
  if (window.WKWebViewJavascriptBridge) {
13
16
  return callback(WKWebViewJavascriptBridge);
14
17
  }
18
+
15
19
  if (window.WVJBCallbacks) {
16
20
  return window.WVJBCallbacks.push(callback);
17
21
  }
22
+
18
23
  window.WVJBCallbacks = [callback];
19
24
  var WVJBIframe = document.createElement('iframe');
20
25
  WVJBIframe.style.display = 'none';
21
26
  WVJBIframe.src = 'https://__bridge_loaded__';
22
27
  document.documentElement.appendChild(WVJBIframe);
28
+
23
29
  _setTimeout(function () {
24
30
  document.documentElement.removeChild(WVJBIframe);
25
31
  }, 0);
26
32
  }
33
+
27
34
  var mobileBridgeInit = function mobileBridgeInit() {
28
35
  return new _Promise(function (resolve, reject) {
29
36
  setupWebViewJavascriptBridge(function (bridge) {
@@ -70,14 +77,17 @@ var mobileBridgeInit = function mobileBridgeInit() {
70
77
  });
71
78
  });
72
79
  };
80
+
73
81
  var mobileBridge = function mobileBridge(method, param) {
74
82
  return new _Promise(function (resolve, reject) {
75
83
  var p = _Object$assign({}, param);
84
+
76
85
  setupWebViewJavascriptBridge(function (bridge) {
77
86
  if (param.control) {
78
87
  bridge.registerHandler(method, function (data) {
79
88
  var onSuccess = param.onSuccess;
80
89
  delete p.onSuccess;
90
+
81
91
  if ('function' === typeof onSuccess) {
82
92
  onSuccess(data);
83
93
  resolve({
@@ -87,31 +97,15 @@ var mobileBridge = function mobileBridge(method, param) {
87
97
  }
88
98
  });
89
99
  }
100
+
90
101
  bridge.callHandler(method, param, function (e) {
91
102
  var code = e.code,
92
- message = e.message,
93
- data = e.data;
103
+ message = e.message,
104
+ data = e.data;
105
+
94
106
  var _code = _parseInt(code);
107
+
95
108
  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
109
  var callbackFun = p[callbackStr];
116
110
  log("SDK\u6267\u884C\u540E\u56DE\u8C03\uFF0C\u76F8\u5173\u53C2\u6570 ", {
117
111
  method: method,
@@ -120,17 +114,71 @@ var mobileBridge = function mobileBridge(method, param) {
120
114
  _code: _code,
121
115
  message: message,
122
116
  callbackFun: callbackFun
123
- });
117
+ }); // 请求失败
118
+
119
+ if (callbackStr === 'onFail') {
120
+ bpitLog({
121
+ method: method,
122
+ errorcode: _code,
123
+ message: message || _JSON$stringify(data) || 'SDK执行失败回调,相关参数'
124
+ });
125
+
126
+ if ('function' === typeof callbackFun) {
127
+ message ? callbackFun({
128
+ code: code,
129
+ message: message
130
+ }) : callbackFun(data);
131
+ }
132
+
133
+ reject({
134
+ _code: _code,
135
+ message: message,
136
+ data: data
137
+ });
138
+ return;
139
+ } // 请求成功
140
+
141
+
124
142
  if ('function' === typeof callbackFun) {
125
143
  callbackFun(data || message);
126
144
  }
145
+
127
146
  resolve({
128
147
  _code: _code,
129
148
  message: message,
130
149
  data: data
131
- });
150
+ }); // if (_code === -2 || _code === 7) {
151
+ // bpitLog({
152
+ // method,
153
+ // errorcode: _code,
154
+ // message: message || 'SDK执行失败回调,相关参数',
155
+ // });
156
+ // log(`SDK执行后回调,相关参数 `, {
157
+ // method,
158
+ // param,
159
+ // data,
160
+ // _code,
161
+ // message,
162
+ // });
163
+ // reject({_code, message});
164
+ // // return;
165
+ // }
166
+ // const callbackFun = p[callbackStr];
167
+ // log(`SDK执行后回调,相关参数 `, {
168
+ // method,
169
+ // param,
170
+ // data,
171
+ // _code,
172
+ // message,
173
+ // callbackFun,
174
+ // });
175
+ // if ('function' === typeof callbackFun) {
176
+ // callbackFun(data || message);
177
+ // }
178
+ // resolve({_code, message, data});
132
179
  });
133
180
  });
134
181
  });
135
182
  };
183
+
136
184
  export { mobileBridge, mobileBridgeInit };
@@ -1,26 +1,24 @@
1
- import _Promise from "@babel/runtime-corejs3/core-js/promise";
1
+ import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
2
2
  import _parseInt from "@babel/runtime-corejs3/core-js/parse-int";
3
+ import _Promise from "@babel/runtime-corejs3/core-js/promise";
3
4
  import PcIframe from '../helper/pcIframe';
4
5
  import { electronResCodeMap } from '../helper/codeMap';
5
6
  import { log, bpitLog } from '../../utils';
7
+
6
8
  var PcBridgeInit = function PcBridgeInit() {
7
9
  PcIframe.init();
8
10
  };
11
+
9
12
  var pcBridge = function pcBridge(method, param) {
10
- return new _Promise(function (resolve) {
13
+ return new _Promise(function (resolve, reject) {
11
14
  return PcIframe.invokeAPI(method, param, function (_ref) {
12
15
  var data = _ref.data,
13
- code = _ref.code,
14
- message = _ref.message;
16
+ code = _ref.code,
17
+ message = _ref.message;
18
+
15
19
  var _code = _parseInt(code);
20
+
16
21
  var callbackStr = electronResCodeMap(_code);
17
- if (_code === -2) {
18
- bpitLog({
19
- method: method,
20
- errorcode: _code,
21
- message: message || 'SDK执行失败回调,相关参数'
22
- });
23
- }
24
22
  var callbackFun = param[callbackStr];
25
23
  log("SDK\u6267\u884C\u540E\u56DE\u8C03\uFF0C\u76F8\u5173\u53C2\u6570 ", {
26
24
  method: method,
@@ -29,16 +27,62 @@ var pcBridge = function pcBridge(method, param) {
29
27
  _code: _code,
30
28
  message: message,
31
29
  callbackFun: callbackFun
32
- });
30
+ }); // 请求失败
31
+
32
+ if (callbackStr === 'onFail') {
33
+ bpitLog({
34
+ method: method,
35
+ errorcode: _code,
36
+ message: message || _JSON$stringify(data) || 'SDK执行失败回调,相关参数'
37
+ });
38
+
39
+ if ('function' === typeof callbackFun) {
40
+ console.log('wenai-code', code, _code);
41
+ message ? callbackFun({
42
+ code: code,
43
+ message: message
44
+ }) : callbackFun(data);
45
+ }
46
+
47
+ reject({
48
+ _code: _code,
49
+ message: message,
50
+ data: data
51
+ });
52
+ return;
53
+ } // 请求成功
54
+
55
+
33
56
  if ('function' === typeof callbackFun) {
34
57
  callbackFun(data || message);
35
58
  }
59
+
36
60
  resolve({
37
61
  _code: _code,
38
62
  message: message,
39
63
  data: data
40
- });
64
+ }); // if (_code === -2) {
65
+ // bpitLog({
66
+ // method,
67
+ // errorcode: _code,
68
+ // message: message || 'SDK执行失败回调,相关参数',
69
+ // });
70
+ // }
71
+ // const callbackFun = param[callbackStr];
72
+ // log(`SDK执行后回调,相关参数 `, {
73
+ // method,
74
+ // param,
75
+ // data,
76
+ // _code,
77
+ // message,
78
+ // callbackFun
79
+ // });
80
+ // if ('function' === typeof callbackFun) {
81
+ // callbackFun(data || message);
82
+ // }
83
+ // resolve({ _code, message, data });
41
84
  });
42
85
  });
43
86
  };
87
+
44
88
  export { pcBridge, PcBridgeInit };
@@ -1,8 +1,10 @@
1
1
  import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
2
+
2
3
  function genDefaultParamsDealFn(p) {
3
4
  return function (r) {
4
5
  return _Object$assign(_Object$assign({}, p), r);
5
6
  };
6
7
  }
8
+
7
9
  ;
8
10
  export { genDefaultParamsDealFn };
@@ -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 };
@@ -1,31 +1,41 @@
1
- import _createClass from "@babel/runtime-corejs3/helpers/createClass";
2
- import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
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
1
  import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
7
- var Event = /*#__PURE__*/_createClass(function Event() {
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";
5
+ import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
6
+
7
+ var Event = function Event() {
8
8
  var _this = this;
9
+
9
10
  _classCallCheck(this, Event);
11
+
10
12
  this.on = function (event, fn) {
11
13
  if (!event || 'function' !== typeof fn) throw 'eventName is null or handle is not a function, on fail';
12
14
  if (!_Array$isArray(_this.eventsHandle[event])) _this.eventsHandle[event] = [];
15
+
13
16
  _this.eventsHandle[event].push(fn);
14
17
  };
18
+
15
19
  this.off = function (event, fn) {
16
20
  if (!event) throw 'eventName is null, invoke off fail';
21
+
17
22
  if (!fn) {
18
23
  _this.eventsHandle[event] = [];
19
24
  return;
20
25
  }
26
+
21
27
  if (_Array$isArray(_this.eventsHandle[event])) {
22
28
  var _context, _context2;
29
+
23
30
  var n = _indexOfInstanceProperty(_context = _this.eventsHandle[event]).call(_context, fn);
31
+
24
32
  -1 !== n && _spliceInstanceProperty(_context2 = _this.eventsHandle[event]).call(_context2, n, 1);
25
33
  }
26
34
  };
35
+
27
36
  this.execEvent = function (event, data) {
28
37
  var _context3;
38
+
29
39
  _Array$isArray(this.eventsHandle[event]) && _forEachInstanceProperty(_context3 = this.eventsHandle[event]).call(_context3, function (fn) {
30
40
  try {
31
41
  fn(data);
@@ -34,7 +44,9 @@ var Event = /*#__PURE__*/_createClass(function Event() {
34
44
  }
35
45
  });
36
46
  };
47
+
37
48
  this.eventsHandle = {};
38
- });
49
+ };
50
+
39
51
  var event = new Event();
40
52
  export default event;
@@ -1,22 +1,26 @@
1
- import _createClass from "@babel/runtime-corejs3/helpers/createClass";
2
- import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
3
- import _Date$now from "@babel/runtime-corejs3/core-js/date/now";
4
1
  import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
2
+ import _Date$now from "@babel/runtime-corejs3/core-js/date/now";
3
+ import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
5
4
  import { log } from '../../utils';
6
- import Event from './event';
7
- // 处理posmessage参数
8
- var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, callback) {
5
+ import Event from './event'; // 处理posmessage参数
6
+
7
+ var GenPostMsg = function GenPostMsg(method, param, callback) {
9
8
  var _this = this;
9
+
10
10
  _classCallCheck(this, GenPostMsg);
11
+
11
12
  this.genid = function () {
12
13
  var idStr = _Date$now().toString(36);
14
+
13
15
  idStr += Math.random().toString(36).substr(3);
14
16
  return idStr;
15
17
  };
18
+
16
19
  this.receiveResponse = function (data) {
17
20
  //this.PromiseObj.resolve(data);
18
21
  _this.callback(data);
19
22
  };
23
+
20
24
  this.getPayload = function () {
21
25
  return {
22
26
  msgId: _this.id,
@@ -26,6 +30,7 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
26
30
  invokeType: _this.invokeType
27
31
  };
28
32
  };
33
+
29
34
  this.id = this.genid();
30
35
  this.PromiseObj = {
31
36
  resolve: null,
@@ -34,8 +39,7 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
34
39
  this.methodName = method;
35
40
  this.plainMsg = param;
36
41
  this.invokeType = param === null || param === void 0 ? void 0 : param.invokeType;
37
- this.callback = callback;
38
- // this.result = new Promise(
42
+ this.callback = callback; // this.result = new Promise(
39
43
  // function (resolve, reject) {
40
44
  // this.PromiseObj = {
41
45
  // resolve,
@@ -43,60 +47,81 @@ var GenPostMsg = /*#__PURE__*/_createClass(function GenPostMsg(method, param, ca
43
47
  // };
44
48
  // }.bind(this)
45
49
  // );
46
- });
47
- var Frame = /*#__PURE__*/_createClass(function Frame() {
50
+ };
51
+
52
+ var Frame = function Frame() {
48
53
  var _this2 = this;
54
+
49
55
  _classCallCheck(this, Frame);
56
+
50
57
  this.addPending = function (e) {
51
58
  _this2.pendingMsgs[e.id] = e;
52
59
  };
60
+
53
61
  this.deletePending = function (e) {
54
62
  delete _this2.pendingMsgs[e.id];
55
63
  };
64
+
56
65
  this.getPending = function (t) {
57
66
  return this.pendingMsgs[t];
58
67
  };
68
+
59
69
  this.invokeAPIInBrowserView = function (payload) {
60
70
  window.sendTo(payload);
61
71
  };
72
+
62
73
  this.invokeAPIInWebview = function (payload) {
63
74
  window.sendToHost(payload);
64
75
  };
76
+
65
77
  this.invokeAPI = function (method, param, callback) {
66
78
  var genPostMsg = new GenPostMsg(method, param, callback);
79
+
67
80
  var payload = _JSON$stringify(genPostMsg.getPayload());
81
+
68
82
  var _param$invokeType = param.invokeType,
69
- invokeType = _param$invokeType === void 0 ? '' : _param$invokeType;
83
+ invokeType = _param$invokeType === void 0 ? '' : _param$invokeType;
70
84
  invokeType === 'browserView' ? _this2.invokeAPIInBrowserView(payload) : _this2.invokeAPIInWebview(payload);
85
+
71
86
  _this2.addPending(genPostMsg);
87
+
72
88
  return genPostMsg;
73
89
  };
90
+
74
91
  this.handleCallback = function (datas, invokeType) {
75
92
  var type = datas.type,
76
- methodName = datas.methodName,
77
- eventName = datas.eventName,
78
- msgId = datas.msgId,
79
- data = datas.data,
80
- code = datas.code,
81
- message = datas.message;
93
+ methodName = datas.methodName,
94
+ eventName = datas.eventName,
95
+ msgId = datas.msgId,
96
+ _datas$data = datas.data,
97
+ data = _datas$data === void 0 ? {} : _datas$data,
98
+ code = datas.code,
99
+ message = datas.message,
100
+ msg = datas.msg;
101
+
82
102
  if (type === 'request') {
83
103
  // 壳子的调用
84
104
  switch (methodName) {
85
105
  case 'refresh':
86
106
  window.location.reload();
87
107
  break;
108
+
88
109
  case 'back':
89
110
  window.history.back();
90
111
  break;
112
+
91
113
  case 'forward':
92
114
  window.history.forward();
93
115
  break;
116
+
94
117
  case 'event':
95
118
  Event.execEvent(eventName, data);
96
119
  break;
120
+
97
121
  case 'zoomInClick':
98
122
  var scrollTopVal = document.documentElement.scrollTop || document.body.scrollTop,
99
- url = window.location.href;
123
+ url = window.location.href;
124
+
100
125
  if (invokeType === 'browserView') {
101
126
  window.sendTo(_JSON$stringify({
102
127
  type: type,
@@ -118,31 +143,38 @@ var Frame = /*#__PURE__*/_createClass(function Frame() {
118
143
  }
119
144
  }));
120
145
  }
146
+
121
147
  break;
148
+
122
149
  default:
123
150
  break;
124
151
  }
125
152
  } else if (type === 'response') {
126
153
  // 响应壳子的回调
127
154
  var pending = _this2.getPending(msgId);
155
+
128
156
  pending && pending.receiveResponse({
129
157
  data: data,
130
158
  code: code,
131
- message: message
159
+ message: message || msg || data.msg || data.message
132
160
  });
133
161
  code != -3 && _this2.deletePending(msgId);
134
162
  }
135
163
  };
164
+
136
165
  this.init = function () {
137
166
  window.addEventListener('message', function (msg) {
138
167
  log('electron res: ', msg);
168
+
139
169
  _this2.handleCallback(msg.data || {});
140
170
  });
141
171
  window.receiveBrowserViewData && window.receiveBrowserViewData(function (e, response) {
142
172
  return _this2.handleCallback(response);
143
173
  });
144
174
  };
175
+
145
176
  this.pendingMsgs = {};
146
- });
177
+ };
178
+
147
179
  var frame = new Frame();
148
180
  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) 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();
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 };