yach.open.jssdk 4.3.8 → 4.3.9

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