yach.open.jssdk 4.4.3-beta5 → 4.4.4-beta.10

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